@daily-co/daily-react-hooks
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -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 t=e(require("@daily-co/daily-js")),n=require("react"),r=e(n),i=require("recoil");function a(e,t,n,r,i,a,o){try{var u=e[a](o),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,i)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function u(e){a(o,r,i,u,c,"next",e)}function c(e){a(o,r,i,u,c,"throw",e)}u(void 0)}))}}function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var c=["children"],l=n.createContext(null),s=n.createContext({on:function(){},off:function(){}}),f=function(){return n.useContext(l)},d=0,p=function(){return d++},v=function(e,t){var r=n.useContext(s),i=r.on,a=r.off,o=n.useState(!1),u=o[0],c=o[1],l=n.useRef(0),f=n.useMemo((function(){return p()}),[]);n.useEffect((function(){if(e&&!u){if(l.current>1e3)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 i(e,t,f),function(){clearTimeout(n),a(e,f)}}}),[t,e,f,u,a,i])};function h(e,t){return e(t={exports:{}},t.exports),t.exports}var g=h((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",a=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag";function u(e,t,n,r){var i=Object.create((t&&t.prototype instanceof s?t:s).prototype),a=new x(r||[]);return i._invoke=function(e,t,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return{value:void 0,done:!0}}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var u=y(o,n);if(u){if(u===l)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=c(e,t,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===l)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}(e,n,a),i}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function s(){}function f(){}function d(){}var p={};p[i]=function(){return this};var v=Object.getPrototypeOf,h=v&&v(v(R([])));h&&h!==t&&n.call(h,i)&&(p=h);var g=d.prototype=s.prototype=Object.create(p);function k(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function m(e,t){var r;this._invoke=function(i,a){function o(){return new t((function(r,o){!function r(i,a,o,u){var l=c(e[i],e,a);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,u)}),(function(e){r("throw",e,o,u)})):t.resolve(f).then((function(e){s.value=e,o(s)}),(function(e){return r("throw",e,o,u)}))}u(l.arg)}(i,a,r,o)}))}return r=r?r.then(o,o):o()}}function y(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,y(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=c(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,l;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function R(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:C}}function C(){return{value:void 0,done:!0}}return f.prototype=g.constructor=d,d.constructor=f,d[o]=f.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,o in e||(e[o]="GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},k(m.prototype),m.prototype[a]=function(){return this},e.AsyncIterator=m,e.async=function(t,n,r,i,a){void 0===a&&(a=Promise);var o=new m(u(t,n,r,i),a);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},k(g),g[o]="Generator",g[i]=function(){return this},g.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=R,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return o.type="throw",o.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,l):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),w(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;w(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:R(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}})),k=i.atomFamily({key:"participant",default:null}),m=function(e,t){var r=void 0===t?{}:t,a=r.onParticipantLeft,c=r.onParticipantUpdated,l=f(),s=i.useRecoilValue(k(e)),d=i.useRecoilCallback((function(t){var n=t.set;return function(t){n(k(e),t)}}),[e]);return n.useEffect((function(){var t;if(l){var n=Object.values(null!=(t=l.participants())?t:{}).find((function(t){return t.session_id===e}));n&&d(n)}}),[l,d,e]),v("active-speaker-change",i.useRecoilCallback((function(t){var n=t.set,r=t.snapshot;return function(){var t=o(g.mark((function t(i){var a;return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i.activeSpeaker.peerId===e){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,r.getPromise(k(e));case 4:if(!(a=t.sent)&&l&&(a=l.participants()[e]),a){t.next=8;break}return t.abrupt("return");case 8:n(k(e),u({},a,{last_active:new Date}));case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()}),[l,e])),v("participant-updated",i.useRecoilCallback((function(t){var n=t.set;return function(t){t.participant.session_id===e&&(n(k(e),t.participant),null==c||c(t))}}),[c,e])),v("participant-left",i.useRecoilCallback((function(t){var n=t.reset;return function(t){t.participant.session_id===e&&(n(k(e)),null==a||a(t))}}),[a,e])),s},y=i.atom({key:"active-id",default:""}),b=i.atomFamily({key:"media-track",default:{state:"loading",subscribed:!1}}),w=function(e,t){void 0===t&&(t="video");var r=f(),a=n.useMemo((function(){return e+"-"+t}),[e,t]),o=i.useRecoilValue(b(a)),c=i.useRecoilCallback((function(n){var r=n.set,i=n.reset;return function(n){if(n.participant.session_id===e)switch(n.action){case"participant-joined":case"participant-updated":r(b(a),n.participant.tracks[t]);break;case"participant-left":i(b(a))}}}),[a,e,t]);v("participant-joined",c),v("participant-updated",c),v("participant-left",c),v("joined-meeting",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(b(a),e.participants.local.tracks[t])}}),[a,t]));var l=i.useRecoilCallback((function(e){var t=e.set;return function(e){e&&t(b(a),e)}}),[a]);return n.useEffect((function(){if(r){var n=null==r?void 0:r.participants();if(n){var i=Object.values(n).find((function(t){return t.session_id===e}));i&&l(i.tracks[t])}}}),[r,e,l,t]),u({},o,{isOff:"blocked"===o.state||"off"===o.state})},x=i.atom({key:"general-camera-state",default:"pending"}),R=i.atom({key:"general-microphone-state",default:"pending"}),C=i.atom({key:"camera-devices",default:[]}),S=i.atom({key:"microphone-devices",default:[]}),L=i.atom({key:"speaker-devices",default:[]}),E=i.atom({key:"input-settings",default:null}),P=i.atom({key:"input-settings-error",default:null}),_=i.atom({key:"live-streaming",default:{errorMsg:void 0,isLiveStreaming:!1,layout:void 0}}),j=i.atom({key:"local-id",default:""}),O=function(){var e=f(),t=i.useRecoilValue(j),r=i.useRecoilCallback((function(t){var n=t.set;return function(){var t,r=null==e||null==(t=e.participants())?void 0:t.local;r&&n(j,r.session_id)}}),[e]);return n.useEffect((function(){e&&r()}),[e,r]),v("loaded",n.useCallback((function(){setTimeout(r,1e3)}),[r])),m(t)},I=i.atom({key:"topology",default:"peer"}),D=i.atom({key:"networkQuality",default:100}),V=i.atom({key:"networkThreshold",default:"good"}),M=function(e,t,r){void 0===r&&(r=100);var i=n.useContext(s),a=i.on,o=i.off,u=n.useMemo((function(){return p()}),[]),c=n.useRef([]);n.useEffect((function(){if(e){var n=function(){0!==c.current.length&&(t(c.current),c.current=[])},i=setInterval(n,r);return a(e,(function(e){c.current.push(e)}),u),function(){clearInterval(i),n(),o(e,u)}}}),[t,e,u,o,a,r])},A=i.atom({key:"participants",default:[]}),T=Boolean,N=function(){return 0},F=function(e){var t=void 0===e?{filter:T,sort:N}:e,r=t.filter,a=void 0===r?T:r,u=t.onActiveSpeakerChange,c=t.onParticipantJoined,l=t.onParticipantLeft,s=t.onParticipantUpdated,d=t.sort,p=void 0===d?N:d,h=f(),k=n.useState([]),m=k[0],y=k[1],b=n.useCallback((function(e){var t,n;switch(a){case"local":t=function(e){return e.local};break;case"owner":t=function(e){return e.owner};break;case"record":t=function(e){return e.record};break;case"remote":t=function(e){return!e.local};break;default:t=a}switch(p){case"joined_at":case"session_id":case"user_id":case"user_name":n=function(e,t){return e[p]<t[p]?-1:e[p]>t[p]?1:0};break;default:n=p}var r=Object.values(e).filter(t).sort(n).map((function(e){return e.session_id})).filter(Boolean);y((function(e){return e.length===r.length&&e.every((function(e,t){return r[t]===e}))?e:r}))}),[a,p]),w=i.useRecoilCallback((function(e){var t=e.set;return function(){var e=o(g.mark((function e(n){var r;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=Object.values(null!=n?n:{}).map((function(e){return e.session_id})),t(A,(function(e){return[].concat(e,r).filter((function(e,t,n){return n.indexOf(e)==t}))})),b(null!=n?n:{});case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}),[b]);return n.useEffect((function(){h&&w(h.participants())}),[h,w]),v("joined-meeting",i.useRecoilCallback((function(e){var t=e.set;return o(g.mark((function e(){var n,r;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(h){e.next=2;break}return e.abrupt("return");case 2:n=h.participants(),r=n.local,t(A,(function(e){return[].concat(e,[r.session_id]).filter((function(e,t,n){return n.indexOf(e)==t}))})),b(n);case 6:case"end":return e.stop()}}),e)})))}),[h,b])),M("participant-joined",i.useRecoilCallback((function(e){var t=e.set;return function(){var e=o(g.mark((function e(n){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length){e.next=2;break}return e.abrupt("return");case 2:t(A,(function(e){return[].concat(e,n.map((function(e){return e.participant.session_id}))).filter((function(e,t,n){return n.indexOf(e)==t}))})),h&&b(h.participants()),n.forEach((function(e){return null==c?void 0:c(e)}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}),[h,c,b])),M("participant-updated",i.useRecoilCallback((function(){return function(e){e.length&&(h&&b(h.participants()),e.forEach((function(e){return null==s?void 0:s(e)})))}}),[h,s,b])),M("active-speaker-change",i.useRecoilCallback((function(){return function(){var e=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.length){e.next=2;break}return e.abrupt("return");case 2:h&&b(h.participants()),t.forEach((function(e){return null==u?void 0:u(e)}));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}),[h,u,b])),M("participant-left",i.useRecoilCallback((function(e){var t=e.set;return function(){var e=o(g.mark((function e(n){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length){e.next=2;break}return e.abrupt("return");case 2:t(A,(function(e){return[].concat(e).filter((function(e){return!n.some((function(t){return t.participant.session_id===e}))}))})),h&&b(h.participants()),n.forEach((function(e){return null==l?void 0:l(e)}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}),[h,l,b])),m},q=i.atomFamily({key:"participant-receive-settings",default:{}}),G=i.atom({key:"recording",default:{isLocalParticipantRecorded:!1,isRecording:!1}}),U=i.atom({key:"room",default:null}),B=i.atom({key:"waiting-participants",default:[]}),W=i.atomFamily({key:"waiting-participant",default:{awaitingAccess:{level:"full"},id:"",name:""}}),z=i.selector({key:"waitingParticipantsSelector",get:function(e){var t=e.get;return t(B).map((function(e){return t(W(e))}))}});exports.DailyProvider=function(e){var a=e.children,o=function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(i[n]=e[n]);return i}(e,c),u=n.useRef("callObject"in o?o.callObject:null),f=n.useRef({}),d=n.useCallback((function(e){var t,n,r;"action"in e&&Array.from(null!=(t=null==(n=f.current)||null==(r=n[e.action])?void 0:r.values())?t:[]).forEach((function(t){t(e)}))}),[]),p=n.useCallback((function(e){e&&Object.keys(f.current).forEach((function(t){e.off(t,d).on(t,d)}))}),[d]);n.useEffect((function(){if(!u.current){if("callObject"in o)return u.current=o.callObject,void p(o.callObject);var e=t.createCallObject(o);u.current=e,p(e)}}),[p,o]);var v=n.useCallback((function(e,t,n){var r,i,a;f.current[e]||(f.current[e]=new Map,u.current&&(null==(i=u.current)||i.on(e,d))),null!=(r=f.current[e])&&r.has(n)||null==(a=f.current[e])||a.set(n,t)}),[d]),h=n.useCallback((function(e,t){var n,r,i;null==(n=f.current[e])||n.delete(t),0===(null==(r=f.current[e])?void 0:r.size)&&(u.current&&(null==(i=u.current)||i.off(e,d)),delete f.current[e])}),[d]);return r.createElement(i.RecoilRoot,null,r.createElement(l.Provider,{value:u.current},r.createElement(s.Provider,{value:{on:v,off:h}},a)))},exports.useActiveParticipant=function(e){var t=void 0===e?{}:e,r=t.ignoreLocal,a=void 0!==r&&r,o=t.onActiveSpeakerChange,u=f(),c=i.useRecoilValue(y),l=n.useState(""),s=l[1],d=m(l[0]);return n.useEffect((function(){var e;if(u){var t=null==u||null==(e=u.participants())?void 0:e.local;a&&c===(null==t?void 0:t.session_id)||s(c)}}),[u,a,c]),v("active-speaker-change",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(y,e.activeSpeaker.peerId),null==o||o(e)}}),[o])),d},exports.useAppMessage=function(e){var t=(void 0===e?{}:e).onAppMessage,r=f(),i=n.useCallback((function(e,t){void 0===t&&(t="*"),r&&r.sendAppMessage(e,t)}),[r]),a=n.useCallback((function(e){null==t||t(e,i)}),[t,i]);return v("app-message",a),i},exports.useAudioTrack=function(e){return w(e,"audio")},exports.useDaily=f,exports.useDailyEvent=v,exports.useDevices=function(){var e=f(),t=i.useRecoilValue(x),r=i.useRecoilValue(R),a=i.useRecoilValue(C),c=i.useRecoilValue(S),l=i.useRecoilValue(L),s=i.useRecoilCallback((function(t){var n=t.set;return o(g.mark((function t(){var r,i,a,o,u,c,l,s,f,d,p,v,h,k;return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==(null==(r=navigator)||null==(i=r.mediaDevices)?void 0:i.getUserMedia)&&void 0!==(null==(a=navigator)||null==(o=a.mediaDevices)?void 0:o.enumerateDevices)){t.next=4;break}return n(x,"not-supported"),n(R,"not-supported"),t.abrupt("return");case 4:if(e){t.next=6;break}return t.abrupt("return");case 6:return t.prev=6,t.next=9,e.enumerateDevices();case 9:return c=(u=t.sent.devices).filter((function(e){return"videoinput"===e.kind&&""!==e.deviceId})),l=u.filter((function(e){return"audioinput"===e.kind&&""!==e.deviceId})),s=u.filter((function(e){return"audiooutput"===e.kind&&""!==e.deviceId})),t.next=16,e.getInputDevices();case 16:d=(f=t.sent).camera,p=f.mic,v=f.speaker,h=function(e,t,n){var r,i;return{device:t,selected:"deviceId"in e&&t.deviceId===e.deviceId,state:null!=(r=null==(i=n.find((function(e){return e.device.deviceId===t.deviceId})))?void 0:i.state)?r:"granted"}},k=function(e,t){return"default"===e.device.deviceId?-1:"default"===t.device.deviceId?1:e.device.label<t.device.label?-1:e.device.label>t.device.label?1:0},n(C,(function(e){return c.filter(Boolean).map((function(t){return h(d,t,e)})).sort(k)})),n(S,(function(e){return l.filter(Boolean).map((function(t){return h(p,t,e)})).sort(k)})),n(L,(function(e){return s.filter(Boolean).map((function(t){return h(v,t,e)})).sort(k)})),t.next=31;break;case 27:t.prev=27,t.t0=t.catch(6),n(x,"not-supported"),n(R,"not-supported");case 31:case"end":return t.stop()}}),t,null,[[6,27]])})))}),[e]),d=i.useRecoilCallback((function(t){var n=t.set,r=t.snapshot;return o(g.mark((function t(){var i,a,o,c,l,f,d,p,v,h,k,m,y,b,w,L,E;return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,r.getPromise(x);case 4:return y=t.sent,t.next=7,r.getPromise(R);case 7:b=t.sent,w=e.participants().local.tracks,L="pending"===y&&"interrupted"===w.video.state,E="pending"===b&&"interrupted"===w.audio.state,null!=(i=w.audio)&&null!=(a=i.blocked)&&a.byDeviceInUse?(n(R,"in-use"),n(S,(function(e){return e.map((function(e){return e.selected?u({},e,{state:"in-use"}):e}))}))):null!=(o=w.audio)&&null!=(c=o.blocked)&&c.byDeviceMissing?n(R,"not-found"):null!=(l=w.audio)&&null!=(f=l.blocked)&&f.byPermissions?n(R,"blocked"):E||(n(R,"granted"),n(S,(function(e){return e.map((function(e){return e.selected?u({},e,{state:"granted"}):e}))}))),null!=(d=w.video)&&null!=(p=d.blocked)&&p.byDeviceInUse?(n(x,"in-use"),n(C,(function(e){return e.map((function(e){return e.selected?u({},e,{state:"in-use"}):e}))}))):null!=(v=w.video)&&null!=(h=v.blocked)&&h.byDeviceMissing?n(x,"not-found"):null!=(k=w.video)&&null!=(m=k.blocked)&&m.byPermissions?n(x,"blocked"):L||(n(x,"granted"),n(C,(function(e){return e.map((function(e){return e.selected?u({},e,{state:"granted"}):e}))}))),s();case 14:case"end":return t.stop()}}),t)})))}),[e,s]);v("participant-updated",n.useCallback((function(e){e.participant.local&&d()}),[d])),v("camera-error",i.useRecoilCallback((function(e){var t=e.set;return function(e){var n=e.errorMsg,r=n.errorMsg,i=n.audioOk,a=n.videoOk,o=e.error;switch(null==o?void 0:o.type){case"cam-in-use":t(x,"in-use");break;case"mic-in-use":t(R,"in-use");break;case"cam-mic-in-use":t(x,"in-use"),t(R,"in-use");break;default:switch(r){case"devices error":a||t(x,"not-found"),i||t(R,"not-found");break;case"not allowed":t(x,"blocked"),t(R,"blocked"),d()}}}}),[d])),v("error",i.useRecoilCallback((function(e){var t=e.set;return function(e){switch(e.errorMsg){case"not allowed":t(x,"blocked"),t(R,"blocked"),d()}}}),[d])),v("started-camera",i.useRecoilCallback((function(e){var t=e.set;return function(){t(x,"granted"),t(R,"granted"),d()}}),[d]));var p=n.useCallback(function(){var t=o(g.mark((function t(n){return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,null==e?void 0:e.setInputDevicesAsync({videoDeviceId:n});case 2:s();case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[e,s]),h=n.useCallback(function(){var t=o(g.mark((function t(n){return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,null==e?void 0:e.setInputDevicesAsync({audioDeviceId:n});case 2:s();case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[e,s]),k=n.useCallback(function(){var t=o(g.mark((function t(n){return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null==e||e.setOutputDevice({outputDeviceId:n}),s();case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[e,s]);return{cameras:a,camState:t,hasCamError:["blocked","in-use","not-found"].includes(t),hasMicError:["blocked","in-use","not-found"].includes(r),microphones:c,micState:r,refreshDevices:s,setCamera:p,setMicrophone:h,setSpeaker:k,speakers:l}},exports.useInputSettings=function(e){var t=void 0===e?{}:e,r=t.onError,a=t.onInputSettingsUpdated,o=i.useRecoilValue(E),u=i.useRecoilValue(P),c=f(),l=i.useRecoilCallback((function(e){var t=e.set;return function(e){t(E,e)}}),[]);return n.useEffect((function(){c&&c.getInputSettings().then(l)}),[c,l]),v("input-settings-updated",n.useCallback((function(e){l(e.inputSettings),null==a||a(e)}),[a,l])),v("nonfatal-error",i.useRecoilCallback((function(e){var t=e.set;return function(e){"input-settings-error"===e.type&&(t(P,e.errorMsg),null==r||r(e))}}),[r])),{errorMsg:u,inputSettings:o,updateInputSettings:n.useCallback((function(e){null==c||c.updateInputSettings(e)}),[c])}},exports.useLiveStreaming=function(e){var t=void 0===e?{}:e,r=t.onLiveStreamingStarted,a=t.onLiveStreamingStopped,o=t.onLiveStreamingError,c=f(),l=i.useRecoilValue(_);return v("live-streaming-started",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(_,{isLiveStreaming:!0,layout:null==e?void 0:e.layout}),null==r||r(e)}}),[r])),v("live-streaming-stopped",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(_,(function(e){return u({},e,{isLiveStreaming:!1,layout:void 0})})),null==a||a(e)}}),[a])),v("live-streaming-error",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(_,(function(t){return u({},t,{errorMsg:e.errorMsg})})),null==o||o(e)}}),[o])),u({},l,{startLiveStreaming:n.useCallback((function(e){c&&c.startLiveStreaming(e)}),[c]),stopLiveStreaming:n.useCallback((function(){c&&c.stopLiveStreaming()}),[c]),updateLiveStreaming:n.useCallback((function(e){c&&c.updateLiveStreaming({layout:e.layout})}),[c])})},exports.useLocalParticipant=O,exports.useMediaTrack=w,exports.useNetwork=function(e){var t=void 0===e?{}:e,r=t.onNetworkConnection,a=t.onNetworkQualityChange,u=f(),c=i.useRecoilValue(I),l=i.useRecoilValue(D),s=i.useRecoilValue(V),d=i.useRecoilCallback((function(e){var t=e.set;return function(e){switch(e.event){case"connected":"peer-to-peer"===e.type&&t(I,"peer"),"sfu"===e.type&&t(I,"sfu")}null==r||r(e)}}),[r]),p=i.useRecoilCallback((function(e){var t=e.set;return function(e){t(D,(function(t){return t!==e.quality?e.quality:t})),t(V,(function(t){return t!==e.threshold?e.threshold:t})),null==a||a(e)}}),[a]);return v("network-connection",d),v("network-quality-change",p),{getStats:n.useCallback(o(g.mark((function e(){var t;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null==u?void 0:u.getNetworkStats();case 2:return e.abrupt("return",null==(t=e.sent)?void 0:t.stats);case 4:case"end":return e.stop()}}),e)}))),[u]),quality:l,threshold:s,topology:c}},exports.useParticipant=m,exports.useParticipantIds=F,exports.useReceiveSettings=function(e){var t=void 0===e?{}:e,r=t.id,a=void 0===r?"base":r,o=t.onReceiveSettingsUpdated,c=i.useRecoilValue(q("base")),l=i.useRecoilValue(q(a)),s=f();v("receive-settings-updated",i.useRecoilCallback((function(e){var t=e.reset,n=e.set;return function(e){for(var r=u({},e.receiveSettings),i=0,c=Object.entries(r);i<c.length;i++){var l=c[i],s=l[1];n(q(l[0]),s)}a in r||t(q(a)),null==o||o(e)}}),[a,o]));var d=n.useCallback((function(e){s&&"joined-meeting"===s.meetingState()&&(null==s||null==s.updateReceiveSettings||s.updateReceiveSettings(e))}),[s]);return{receiveSettings:"base"===a||0===Object.keys(l).length?c:l,updateReceiveSettings:d}},exports.useRecording=function(e){var t=void 0===e?{}:e,r=t.onRecordingStarted,a=t.onRecordingStopped,o=t.onRecordingError,c=t.onRecordingData,l=f(),s=i.useRecoilValue(G),d=i.useSetRecoilState(G),p=O(),h=F({filter:"record"});return n.useEffect((function(){var e,t=h.length>0,n=h.includes(null!=(e=null==p?void 0:p.session_id)?e:"local");d((function(e){return u({},e,{isLocalParticipantRecorded:"local"!==(null==e?void 0:e.type)&&null!=e&&e.type?e.isLocalParticipantRecorded:t,isRecording:"local"!==(null==e?void 0:e.type)&&null!=e&&e.type?e.isRecording:t,local:"local"!==(null==e?void 0:e.type)&&null!=e&&e.type||!t?null==e?void 0:e.local:n,type:t?"local":null==e?void 0:e.type})}))}),[null==p?void 0:p.session_id,h,d]),v("recording-started",i.useRecoilCallback((function(e){var t=e.set;return function(e){var n=!0;switch(e.type){case"cloud-beta":case"cloud":var i;p&&"single-participant"===(null==(i=e.layout)?void 0:i.preset)&&e.layout.session_id!==(null==p?void 0:p.session_id)&&(n=!1)}t(G,{error:!1,isLocalParticipantRecorded:n,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}),null==r||r(e)}}),[p,r])),v("recording-stopped",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(G,(function(e){return u({},e,{isLocalParticipantRecorded:!1,isRecording:!1})})),null==a||a(e)}}),[a])),v("recording-error",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(G,(function(e){return u({},e,{error:!0,isLocalParticipantRecorded:!1,isRecording:!1})})),null==o||o(e)}}),[o])),v("recording-data",n.useCallback((function(e){null==c||c(e)}),[c])),u({},s,{startRecording:n.useCallback((function(e){l&&l.startRecording(e)}),[l]),stopRecording:n.useCallback((function(){l&&l.stopRecording()}),[l]),updateRecording:n.useCallback((function(e){l&&l.updateRecording(e)}),[l])})},exports.useRoom=function(e){var t=i.useRecoilValue(U),r=f(),a=i.useRecoilCallback((function(t){var n=t.set;return o(g.mark((function t(){return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r){t.next=2;break}return t.abrupt("return");case 2:return t.t0=n,t.t1=U,t.next=6,r.room(e);case 6:t.t2=t.sent,(0,t.t0)(t.t1,t.t2);case 8:case"end":return t.stop()}}),t)})))}),[r,e]);return n.useEffect((function(){r&&a()}),[r,a]),v("loaded",a),v("access-state-updated",a),v("started-camera",a),v("joining-meeting",a),v("joined-meeting",a),t},exports.useScreenAudioTrack=function(e){return w(e,"screenAudio")},exports.useScreenShare=function(e){var t=void 0===e?{}:e,r=t.onLocalScreenShareStarted,i=t.onLocalScreenShareStopped,a=f(),o=n.useCallback((function(e){null==a||a.startScreenShare(e)}),[a]),u=n.useCallback((function(){null==a||a.stopScreenShare()}),[a]);v("local-screen-share-started",n.useCallback((function(){return null==r?void 0:r()}),[r])),v("local-screen-share-stopped",n.useCallback((function(){return null==i?void 0:i()}),[i]));var c=F({filter:function(e){return e.screen}}),l=n.useMemo((function(){return c.map((function(e){var t,n=Object.values(null!=(t=null==a||null==a.participants?void 0:a.participants())?t:{}).find((function(t){return t.session_id===e}));if(n)return{local:n.local,screenAudio:n.tracks.screenAudio,screenVideo:n.tracks.screenVideo,screenId:e+"-screen",session_id:e}})).filter((function(e){return!!e}))}),[a,c]);return{isSharingScreen:l.some((function(e){return e.local})),screens:l,startScreenShare:o,stopScreenShare:u}},exports.useScreenVideoTrack=function(e){return w(e,"screenVideo")},exports.useThrottledDailyEvent=M,exports.useVideoTrack=function(e){return w(e,"video")},exports.useWaitingParticipants=function(e){var t=void 0===e?{}:e,r=t.onWaitingParticipantAdded,a=t.onWaitingParticipantRemoved,o=t.onWaitingParticipantUpdated,u=f(),c=i.useRecoilValue(z),l=i.useRecoilCallback((function(e){var t=e.set;return function(e){t(B,(function(t){return t.includes(e.participant.id)?t:[].concat(t,[e.participant.id])})),t(W(e.participant.id),e.participant),null==r||r(e)}}),[r]),s=i.useRecoilCallback((function(e){var t=e.reset,n=e.set;return function(e){n(B,(function(t){return t.filter((function(t){return t!==e.participant.id}))})),t(W(e.participant.id)),null==a||a(e)}}),[a]),d=i.useRecoilCallback((function(e){var t=e.set;return function(e){t(W(e.participant.id),e.participant),null==o||o(e)}}),[o]);v("waiting-participant-added",l),v("waiting-participant-removed",s),v("waiting-participant-updated",d);var p=n.useCallback((function(e,t){"*"!==e?null==u||u.updateWaitingParticipant(e,{grantRequestedAccess:t}):null==u||u.updateWaitingParticipants({"*":{grantRequestedAccess:t}})}),[u]);return{waitingParticipants:c,grantAccess:n.useCallback((function(e){p(e,!0)}),[p]),denyAccess:n.useCallback((function(e){p(e,!1)}),[p])}}; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("@daily-co/daily-js")),n=require("react"),r=e(n),i=require("recoil");function a(e,t,n,r,i,a,o){try{var u=e[a](o),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,i)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function u(e){a(o,r,i,u,c,"next",e)}function c(e){a(o,r,i,u,c,"throw",e)}u(void 0)}))}}function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var c=["children"],l=n.createContext(null),s=n.createContext({on:function(){},off:function(){}}),f=function(){return n.useContext(l)},d=0,p=function(){return d++},v=function(e,t){var r=n.useContext(s),i=r.on,a=r.off,o=n.useState(!1),u=o[0],c=o[1],l=n.useRef(0),f=n.useMemo((function(){return p()}),[]);n.useEffect((function(){if(e&&!u){if(l.current>1e3)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 i(e,t,f),function(){clearTimeout(n),a(e,f)}}}),[t,e,f,u,a,i])};function h(e,t){return e(t={exports:{}},t.exports),t.exports}var g=h((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",a=r.asyncIterator||"@@asyncIterator",o=r.toStringTag||"@@toStringTag";function u(e,t,n,r){var i=Object.create((t&&t.prototype instanceof s?t:s).prototype),a=new x(r||[]);return i._invoke=function(e,t,n){var r="suspendedStart";return function(i,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw a;return{value:void 0,done:!0}}for(n.method=i,n.arg=a;;){var o=n.delegate;if(o){var u=y(o,n);if(u){if(u===l)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=c(e,t,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===l)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}(e,n,a),i}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function s(){}function f(){}function d(){}var p={};p[i]=function(){return this};var v=Object.getPrototypeOf,h=v&&v(v(R([])));h&&h!==t&&n.call(h,i)&&(p=h);var g=d.prototype=s.prototype=Object.create(p);function k(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function m(e,t){var r;this._invoke=function(i,a){function o(){return new t((function(r,o){!function r(i,a,o,u){var l=c(e[i],e,a);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,o,u)}),(function(e){r("throw",e,o,u)})):t.resolve(f).then((function(e){s.value=e,o(s)}),(function(e){return r("throw",e,o,u)}))}u(l.arg)}(i,a,r,o)}))}return r=r?r.then(o,o):o()}}function y(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,y(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=c(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,l;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function R(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,a=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:C}}function C(){return{value:void 0,done:!0}}return f.prototype=g.constructor=d,d.constructor=f,d[o]=f.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,o in e||(e[o]="GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},k(m.prototype),m.prototype[a]=function(){return this},e.AsyncIterator=m,e.async=function(t,n,r,i,a){void 0===a&&(a=Promise);var o=new m(u(t,n,r,i),a);return e.isGeneratorFunction(n)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},k(g),g[o]="Generator",g[i]=function(){return this},g.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=R,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return o.type="throw",o.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,l):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),w(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;w(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:R(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}})),k=i.atomFamily({key:"participant",default:null}),m=function(e,t){var r=void 0===t?{}:t,a=r.onParticipantLeft,c=r.onParticipantUpdated,l=f(),s=i.useRecoilValue(k(e)),d=i.useRecoilCallback((function(t){var n=t.set;return function(t){n(k(e),t)}}),[e]);return n.useEffect((function(){var t;if(l){var n=Object.values(null!=(t=l.participants())?t:{}).find((function(t){return t.session_id===e}));n&&d(n)}}),[l,d,e]),v("active-speaker-change",i.useRecoilCallback((function(t){var n=t.set,r=t.snapshot;return function(){var t=o(g.mark((function t(i){var a;return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(i.activeSpeaker.peerId===e){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,r.getPromise(k(e));case 4:if(!(a=t.sent)&&l&&(a=l.participants()[e]),a){t.next=8;break}return t.abrupt("return");case 8:n(k(e),u({},a,{last_active:new Date}));case 9:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()}),[l,e])),v("participant-updated",i.useRecoilCallback((function(t){var n=t.set;return function(t){t.participant.session_id===e&&(n(k(e),t.participant),null==c||c(t))}}),[c,e])),v("participant-left",i.useRecoilCallback((function(t){var n=t.reset;return function(t){t.participant.session_id===e&&(n(k(e)),null==a||a(t))}}),[a,e])),s},y=i.atom({key:"active-id",default:""}),b=i.atomFamily({key:"media-track",default:{state:"loading",subscribed:!1}}),w=function(e,t){void 0===t&&(t="video");var r=f(),a=n.useMemo((function(){return e+"-"+t}),[e,t]),o=i.useRecoilValue(b(a)),c=i.useRecoilCallback((function(n){var r=n.set,i=n.reset;return function(n){if(n.participant.session_id===e)switch(n.action){case"participant-joined":case"participant-updated":r(b(a),n.participant.tracks[t]);break;case"participant-left":i(b(a))}}}),[a,e,t]);v("participant-joined",c),v("participant-updated",c),v("participant-left",c),v("joined-meeting",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(b(a),e.participants.local.tracks[t])}}),[a,t]));var l=i.useRecoilCallback((function(e){var t=e.set;return function(e){e&&t(b(a),e)}}),[a]);return n.useEffect((function(){if(r){var n=null==r?void 0:r.participants();if(n){var i=Object.values(n).find((function(t){return t.session_id===e}));i&&l(i.tracks[t])}}}),[r,e,l,t]),u({},o,{isOff:"blocked"===o.state||"off"===o.state})},x=i.atom({key:"general-camera-state",default:"pending"}),R=i.atom({key:"general-microphone-state",default:"pending"}),C=i.atom({key:"camera-devices",default:[]}),S=i.atom({key:"microphone-devices",default:[]}),L=i.atom({key:"speaker-devices",default:[]}),E=i.atom({key:"input-settings",default:null}),P=i.atom({key:"input-settings-error",default:null}),_=i.atom({key:"live-streaming",default:{errorMsg:void 0,isLiveStreaming:!1,layout:void 0}}),j=i.atom({key:"local-id",default:""}),O=function(){var e=f(),t=i.useRecoilValue(j),r=i.useRecoilCallback((function(e){var t=e.set;return function(e){e&&t(j,e)}}),[]);return n.useEffect((function(){var n;if(e&&!t){if(null==(n=e.participants())||!n.local){var i=function(e){var t,n;null!=e&&null!=(t=e.participant)&&t.local&&r(null==e||null==(n=e.participant)?void 0:n.session_id)};return e.on("participant-updated",i),function(){e.off("participant-updated",i)}}r(e.participants().local.session_id)}}),[e,r,t]),m(t)},I=i.atom({key:"topology",default:"peer"}),D=i.atom({key:"networkQuality",default:100}),V=i.atom({key:"networkThreshold",default:"good"}),M=function(e,t,r){void 0===r&&(r=100);var i=n.useContext(s),a=i.on,o=i.off,u=n.useMemo((function(){return p()}),[]),c=n.useRef([]);n.useEffect((function(){if(e){var n=function(){0!==c.current.length&&(t(c.current),c.current=[])},i=setInterval(n,r);return a(e,(function(e){c.current.push(e)}),u),function(){clearInterval(i),n(),o(e,u)}}}),[t,e,u,o,a,r])},A=i.atom({key:"participants",default:[]}),T=Boolean,N=function(){return 0},F=function(e){var t=void 0===e?{filter:T,sort:N}:e,r=t.filter,a=void 0===r?T:r,u=t.onActiveSpeakerChange,c=t.onParticipantJoined,l=t.onParticipantLeft,s=t.onParticipantUpdated,d=t.sort,p=void 0===d?N:d,h=f(),k=n.useState([]),m=k[0],y=k[1],b=n.useCallback((function(e){var t,n;switch(a){case"local":t=function(e){return e.local};break;case"owner":t=function(e){return e.owner};break;case"record":t=function(e){return e.record};break;case"remote":t=function(e){return!e.local};break;default:t=a}switch(p){case"joined_at":case"session_id":case"user_id":case"user_name":n=function(e,t){return e[p]<t[p]?-1:e[p]>t[p]?1:0};break;default:n=p}var r=Object.values(e).filter(t).sort(n).map((function(e){return e.session_id})).filter(Boolean);y((function(e){return e.length===r.length&&e.every((function(e,t){return r[t]===e}))?e:r}))}),[a,p]),w=i.useRecoilCallback((function(e){var t=e.set;return function(){var e=o(g.mark((function e(n){var r;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=Object.values(null!=n?n:{}).map((function(e){return e.session_id})),t(A,(function(e){return[].concat(e,r).filter((function(e,t,n){return n.indexOf(e)==t}))})),b(null!=n?n:{});case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}),[b]);return n.useEffect((function(){h&&w(h.participants())}),[h,w]),v("joined-meeting",i.useRecoilCallback((function(e){var t=e.set;return o(g.mark((function e(){var n,r;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(h){e.next=2;break}return e.abrupt("return");case 2:n=h.participants(),r=n.local,t(A,(function(e){return[].concat(e,[r.session_id]).filter((function(e,t,n){return n.indexOf(e)==t}))})),b(n);case 6:case"end":return e.stop()}}),e)})))}),[h,b])),M("participant-joined",i.useRecoilCallback((function(e){var t=e.set;return function(){var e=o(g.mark((function e(n){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length){e.next=2;break}return e.abrupt("return");case 2:t(A,(function(e){return[].concat(e,n.map((function(e){return e.participant.session_id}))).filter((function(e,t,n){return n.indexOf(e)==t}))})),h&&b(h.participants()),n.forEach((function(e){return null==c?void 0:c(e)}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}),[h,c,b])),M("participant-updated",i.useRecoilCallback((function(){return function(e){e.length&&(h&&b(h.participants()),e.forEach((function(e){return null==s?void 0:s(e)})))}}),[h,s,b])),M("active-speaker-change",i.useRecoilCallback((function(){return function(){var e=o(g.mark((function e(t){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.length){e.next=2;break}return e.abrupt("return");case 2:h&&b(h.participants()),t.forEach((function(e){return null==u?void 0:u(e)}));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}),[h,u,b])),M("participant-left",i.useRecoilCallback((function(e){var t=e.set;return function(){var e=o(g.mark((function e(n){return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length){e.next=2;break}return e.abrupt("return");case 2:t(A,(function(e){return[].concat(e).filter((function(e){return!n.some((function(t){return t.participant.session_id===e}))}))})),h&&b(h.participants()),n.forEach((function(e){return null==l?void 0:l(e)}));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}),[h,l,b])),m},q=i.atomFamily({key:"participant-receive-settings",default:{}}),G=i.atom({key:"recording",default:{isLocalParticipantRecorded:!1,isRecording:!1}}),U=i.atom({key:"room",default:null}),B=i.atom({key:"waiting-participants",default:[]}),W=i.atomFamily({key:"waiting-participant",default:{awaitingAccess:{level:"full"},id:"",name:""}}),z=i.selector({key:"waitingParticipantsSelector",get:function(e){var t=e.get;return t(B).map((function(e){return t(W(e))}))}});exports.DailyProvider=function(e){var a=e.children,o=function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(i[n]=e[n]);return i}(e,c),u=n.useRef("callObject"in o?o.callObject:null),f=n.useRef({}),d=n.useCallback((function(e){var t,n,r;"action"in e&&Array.from(null!=(t=null==(n=f.current)||null==(r=n[e.action])?void 0:r.values())?t:[]).forEach((function(t){t(e)}))}),[]),p=n.useCallback((function(e){e&&Object.keys(f.current).forEach((function(t){e.off(t,d).on(t,d)}))}),[d]);n.useEffect((function(){if(!u.current){if("callObject"in o)return u.current=o.callObject,void p(o.callObject);var e=t.createCallObject(o);u.current=e,p(e)}}),[p,o]);var v=n.useCallback((function(e,t,n){var r,i,a;f.current[e]||(f.current[e]=new Map,u.current&&(null==(i=u.current)||i.on(e,d))),null!=(r=f.current[e])&&r.has(n)||null==(a=f.current[e])||a.set(n,t)}),[d]),h=n.useCallback((function(e,t){var n,r,i;null==(n=f.current[e])||n.delete(t),0===(null==(r=f.current[e])?void 0:r.size)&&(u.current&&(null==(i=u.current)||i.off(e,d)),delete f.current[e])}),[d]);return r.createElement(i.RecoilRoot,null,r.createElement(l.Provider,{value:u.current},r.createElement(s.Provider,{value:{on:v,off:h}},a)))},exports.useActiveParticipant=function(e){var t=void 0===e?{}:e,r=t.ignoreLocal,a=void 0!==r&&r,o=t.onActiveSpeakerChange,u=f(),c=i.useRecoilValue(y),l=n.useState(""),s=l[1],d=m(l[0]);return n.useEffect((function(){var e;if(u){var t=null==u||null==(e=u.participants())?void 0:e.local;a&&c===(null==t?void 0:t.session_id)||s(c)}}),[u,a,c]),v("active-speaker-change",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(y,e.activeSpeaker.peerId),null==o||o(e)}}),[o])),d},exports.useAppMessage=function(e){var t=(void 0===e?{}:e).onAppMessage,r=f(),i=n.useCallback((function(e,t){void 0===t&&(t="*"),r&&r.sendAppMessage(e,t)}),[r]),a=n.useCallback((function(e){null==t||t(e,i)}),[t,i]);return v("app-message",a),i},exports.useAudioTrack=function(e){return w(e,"audio")},exports.useDaily=f,exports.useDailyEvent=v,exports.useDevices=function(){var e=f(),t=i.useRecoilValue(x),r=i.useRecoilValue(R),a=i.useRecoilValue(C),c=i.useRecoilValue(S),l=i.useRecoilValue(L),s=i.useRecoilCallback((function(t){var n=t.set;return o(g.mark((function t(){var r,i,a,o,u,c,l,s,f,d,p,v,h,k;return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==(null==(r=navigator)||null==(i=r.mediaDevices)?void 0:i.getUserMedia)&&void 0!==(null==(a=navigator)||null==(o=a.mediaDevices)?void 0:o.enumerateDevices)){t.next=4;break}return n(x,"not-supported"),n(R,"not-supported"),t.abrupt("return");case 4:if(e){t.next=6;break}return t.abrupt("return");case 6:return t.prev=6,t.next=9,e.enumerateDevices();case 9:return c=(u=t.sent.devices).filter((function(e){return"videoinput"===e.kind&&""!==e.deviceId})),l=u.filter((function(e){return"audioinput"===e.kind&&""!==e.deviceId})),s=u.filter((function(e){return"audiooutput"===e.kind&&""!==e.deviceId})),t.next=16,e.getInputDevices();case 16:d=(f=t.sent).camera,p=f.mic,v=f.speaker,h=function(e,t,n){var r,i;return{device:t,selected:"deviceId"in e&&t.deviceId===e.deviceId,state:null!=(r=null==(i=n.find((function(e){return e.device.deviceId===t.deviceId})))?void 0:i.state)?r:"granted"}},k=function(e,t){return"default"===e.device.deviceId?-1:"default"===t.device.deviceId?1:e.device.label<t.device.label?-1:e.device.label>t.device.label?1:0},n(C,(function(e){return c.filter(Boolean).map((function(t){return h(d,t,e)})).sort(k)})),n(S,(function(e){return l.filter(Boolean).map((function(t){return h(p,t,e)})).sort(k)})),n(L,(function(e){return s.filter(Boolean).map((function(t){return h(v,t,e)})).sort(k)})),t.next=31;break;case 27:t.prev=27,t.t0=t.catch(6),n(x,"not-supported"),n(R,"not-supported");case 31:case"end":return t.stop()}}),t,null,[[6,27]])})))}),[e]),d=i.useRecoilCallback((function(t){var n=t.set,r=t.snapshot;return o(g.mark((function t(){var i,a,o,c,l,f,d,p,v,h,k,m,y,b,w,L,E;return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,r.getPromise(x);case 4:return y=t.sent,t.next=7,r.getPromise(R);case 7:b=t.sent,w=e.participants().local.tracks,L="pending"===y&&"interrupted"===w.video.state,E="pending"===b&&"interrupted"===w.audio.state,null!=(i=w.audio)&&null!=(a=i.blocked)&&a.byDeviceInUse?(n(R,"in-use"),n(S,(function(e){return e.map((function(e){return e.selected?u({},e,{state:"in-use"}):e}))}))):null!=(o=w.audio)&&null!=(c=o.blocked)&&c.byDeviceMissing?n(R,"not-found"):null!=(l=w.audio)&&null!=(f=l.blocked)&&f.byPermissions?n(R,"blocked"):E||(n(R,"granted"),n(S,(function(e){return e.map((function(e){return e.selected?u({},e,{state:"granted"}):e}))}))),null!=(d=w.video)&&null!=(p=d.blocked)&&p.byDeviceInUse?(n(x,"in-use"),n(C,(function(e){return e.map((function(e){return e.selected?u({},e,{state:"in-use"}):e}))}))):null!=(v=w.video)&&null!=(h=v.blocked)&&h.byDeviceMissing?n(x,"not-found"):null!=(k=w.video)&&null!=(m=k.blocked)&&m.byPermissions?n(x,"blocked"):L||(n(x,"granted"),n(C,(function(e){return e.map((function(e){return e.selected?u({},e,{state:"granted"}):e}))}))),s();case 14:case"end":return t.stop()}}),t)})))}),[e,s]);v("participant-updated",n.useCallback((function(e){e.participant.local&&d()}),[d])),v("camera-error",i.useRecoilCallback((function(e){var t=e.set;return function(e){var n=e.errorMsg,r=n.errorMsg,i=n.audioOk,a=n.videoOk,o=e.error;switch(null==o?void 0:o.type){case"cam-in-use":t(x,"in-use");break;case"mic-in-use":t(R,"in-use");break;case"cam-mic-in-use":t(x,"in-use"),t(R,"in-use");break;default:switch(r){case"devices error":a||t(x,"not-found"),i||t(R,"not-found");break;case"not allowed":t(x,"blocked"),t(R,"blocked"),d()}}}}),[d])),v("error",i.useRecoilCallback((function(e){var t=e.set;return function(e){switch(e.errorMsg){case"not allowed":t(x,"blocked"),t(R,"blocked"),d()}}}),[d])),v("started-camera",i.useRecoilCallback((function(e){var t=e.set;return function(){t(x,"granted"),t(R,"granted"),d()}}),[d]));var p=n.useCallback(function(){var t=o(g.mark((function t(n){return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,null==e?void 0:e.setInputDevicesAsync({videoDeviceId:n});case 2:s();case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[e,s]),h=n.useCallback(function(){var t=o(g.mark((function t(n){return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,null==e?void 0:e.setInputDevicesAsync({audioDeviceId:n});case 2:s();case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[e,s]),k=n.useCallback(function(){var t=o(g.mark((function t(n){return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:null==e||e.setOutputDevice({outputDeviceId:n}),s();case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[e,s]);return{cameras:a,camState:t,hasCamError:["blocked","in-use","not-found"].includes(t),hasMicError:["blocked","in-use","not-found"].includes(r),microphones:c,micState:r,refreshDevices:s,setCamera:p,setMicrophone:h,setSpeaker:k,speakers:l}},exports.useInputSettings=function(e){var t=void 0===e?{}:e,r=t.onError,a=t.onInputSettingsUpdated,o=i.useRecoilValue(E),u=i.useRecoilValue(P),c=f(),l=i.useRecoilCallback((function(e){var t=e.set;return function(e){t(E,e)}}),[]);return n.useEffect((function(){c&&c.getInputSettings().then(l)}),[c,l]),v("input-settings-updated",n.useCallback((function(e){l(e.inputSettings),null==a||a(e)}),[a,l])),v("nonfatal-error",i.useRecoilCallback((function(e){var t=e.set;return function(e){"input-settings-error"===e.type&&(t(P,e.errorMsg),null==r||r(e))}}),[r])),{errorMsg:u,inputSettings:o,updateInputSettings:n.useCallback((function(e){null==c||c.updateInputSettings(e)}),[c])}},exports.useLiveStreaming=function(e){var t=void 0===e?{}:e,r=t.onLiveStreamingStarted,a=t.onLiveStreamingStopped,o=t.onLiveStreamingError,c=f(),l=i.useRecoilValue(_);return v("live-streaming-started",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(_,{isLiveStreaming:!0,layout:null==e?void 0:e.layout}),null==r||r(e)}}),[r])),v("live-streaming-stopped",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(_,(function(e){return u({},e,{isLiveStreaming:!1,layout:void 0})})),null==a||a(e)}}),[a])),v("live-streaming-error",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(_,(function(t){return u({},t,{errorMsg:e.errorMsg})})),null==o||o(e)}}),[o])),u({},l,{startLiveStreaming:n.useCallback((function(e){c&&c.startLiveStreaming(e)}),[c]),stopLiveStreaming:n.useCallback((function(){c&&c.stopLiveStreaming()}),[c]),updateLiveStreaming:n.useCallback((function(e){c&&c.updateLiveStreaming({layout:e.layout})}),[c])})},exports.useLocalParticipant=O,exports.useMediaTrack=w,exports.useNetwork=function(e){var t=void 0===e?{}:e,r=t.onNetworkConnection,a=t.onNetworkQualityChange,u=f(),c=i.useRecoilValue(I),l=i.useRecoilValue(D),s=i.useRecoilValue(V),d=i.useRecoilCallback((function(e){var t=e.set;return function(e){switch(e.event){case"connected":"peer-to-peer"===e.type&&t(I,"peer"),"sfu"===e.type&&t(I,"sfu")}null==r||r(e)}}),[r]),p=i.useRecoilCallback((function(e){var t=e.set;return function(e){t(D,(function(t){return t!==e.quality?e.quality:t})),t(V,(function(t){return t!==e.threshold?e.threshold:t})),null==a||a(e)}}),[a]);return v("network-connection",d),v("network-quality-change",p),{getStats:n.useCallback(o(g.mark((function e(){var t;return g.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null==u?void 0:u.getNetworkStats();case 2:return e.abrupt("return",null==(t=e.sent)?void 0:t.stats);case 4:case"end":return e.stop()}}),e)}))),[u]),quality:l,threshold:s,topology:c}},exports.useParticipant=m,exports.useParticipantIds=F,exports.useReceiveSettings=function(e){var t=void 0===e?{}:e,r=t.id,a=void 0===r?"base":r,o=t.onReceiveSettingsUpdated,c=i.useRecoilValue(q("base")),l=i.useRecoilValue(q(a)),s=f();v("receive-settings-updated",i.useRecoilCallback((function(e){var t=e.reset,n=e.set;return function(e){for(var r=u({},e.receiveSettings),i=0,c=Object.entries(r);i<c.length;i++){var l=c[i],s=l[1];n(q(l[0]),s)}a in r||t(q(a)),null==o||o(e)}}),[a,o]));var d=n.useCallback((function(e){s&&"joined-meeting"===s.meetingState()&&(null==s||null==s.updateReceiveSettings||s.updateReceiveSettings(e))}),[s]);return{receiveSettings:"base"===a||0===Object.keys(l).length?c:l,updateReceiveSettings:d}},exports.useRecording=function(e){var t=void 0===e?{}:e,r=t.onRecordingStarted,a=t.onRecordingStopped,o=t.onRecordingError,c=t.onRecordingData,l=f(),s=i.useRecoilValue(G),d=i.useSetRecoilState(G),p=O(),h=F({filter:"record"});return n.useEffect((function(){var e,t=h.length>0,n=h.includes(null!=(e=null==p?void 0:p.session_id)?e:"local");d((function(e){return u({},e,{isLocalParticipantRecorded:"local"!==(null==e?void 0:e.type)&&null!=e&&e.type?e.isLocalParticipantRecorded:t,isRecording:"local"!==(null==e?void 0:e.type)&&null!=e&&e.type?e.isRecording:t,local:"local"!==(null==e?void 0:e.type)&&null!=e&&e.type||!t?null==e?void 0:e.local:n,type:t?"local":null==e?void 0:e.type})}))}),[null==p?void 0:p.session_id,h,d]),v("recording-started",i.useRecoilCallback((function(e){var t=e.set;return function(e){var n=!0;switch(e.type){case"cloud-beta":case"cloud":var i;p&&"single-participant"===(null==(i=e.layout)?void 0:i.preset)&&e.layout.session_id!==(null==p?void 0:p.session_id)&&(n=!1)}t(G,{error:!1,isLocalParticipantRecorded:n,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}),null==r||r(e)}}),[p,r])),v("recording-stopped",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(G,(function(e){return u({},e,{isLocalParticipantRecorded:!1,isRecording:!1})})),null==a||a(e)}}),[a])),v("recording-error",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(G,(function(e){return u({},e,{error:!0,isLocalParticipantRecorded:!1,isRecording:!1})})),null==o||o(e)}}),[o])),v("recording-data",n.useCallback((function(e){null==c||c(e)}),[c])),u({},s,{startRecording:n.useCallback((function(e){l&&l.startRecording(e)}),[l]),stopRecording:n.useCallback((function(){l&&l.stopRecording()}),[l]),updateRecording:n.useCallback((function(e){l&&l.updateRecording(e)}),[l])})},exports.useRoom=function(e){var t=i.useRecoilValue(U),r=f(),a=i.useRecoilCallback((function(t){var n=t.set;return o(g.mark((function t(){return g.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r){t.next=2;break}return t.abrupt("return");case 2:return t.t0=n,t.t1=U,t.next=6,r.room(e);case 6:t.t2=t.sent,(0,t.t0)(t.t1,t.t2);case 8:case"end":return t.stop()}}),t)})))}),[r,e]);return n.useEffect((function(){r&&a()}),[r,a]),v("loaded",a),v("access-state-updated",a),v("started-camera",a),v("joining-meeting",a),v("joined-meeting",a),t},exports.useScreenAudioTrack=function(e){return w(e,"screenAudio")},exports.useScreenShare=function(e){var t=void 0===e?{}:e,r=t.onLocalScreenShareStarted,i=t.onLocalScreenShareStopped,a=f(),o=n.useCallback((function(e){null==a||a.startScreenShare(e)}),[a]),u=n.useCallback((function(){null==a||a.stopScreenShare()}),[a]);v("local-screen-share-started",n.useCallback((function(){return null==r?void 0:r()}),[r])),v("local-screen-share-stopped",n.useCallback((function(){return null==i?void 0:i()}),[i]));var c=F({filter:function(e){return e.screen}}),l=n.useMemo((function(){return c.map((function(e){var t,n=Object.values(null!=(t=null==a||null==a.participants?void 0:a.participants())?t:{}).find((function(t){return t.session_id===e}));if(n)return{local:n.local,screenAudio:n.tracks.screenAudio,screenVideo:n.tracks.screenVideo,screenId:e+"-screen",session_id:e}})).filter((function(e){return!!e}))}),[a,c]);return{isSharingScreen:l.some((function(e){return e.local})),screens:l,startScreenShare:o,stopScreenShare:u}},exports.useScreenVideoTrack=function(e){return w(e,"screenVideo")},exports.useThrottledDailyEvent=M,exports.useVideoTrack=function(e){return w(e,"video")},exports.useWaitingParticipants=function(e){var t=void 0===e?{}:e,r=t.onWaitingParticipantAdded,a=t.onWaitingParticipantRemoved,o=t.onWaitingParticipantUpdated,u=f(),c=i.useRecoilValue(z),l=i.useRecoilCallback((function(e){var t=e.set;return function(e){t(B,(function(t){return t.includes(e.participant.id)?t:[].concat(t,[e.participant.id])})),t(W(e.participant.id),e.participant),null==r||r(e)}}),[r]),s=i.useRecoilCallback((function(e){var t=e.reset,n=e.set;return function(e){n(B,(function(t){return t.filter((function(t){return t!==e.participant.id}))})),t(W(e.participant.id)),null==a||a(e)}}),[a]),d=i.useRecoilCallback((function(e){var t=e.set;return function(e){t(W(e.participant.id),e.participant),null==o||o(e)}}),[o]);v("waiting-participant-added",l),v("waiting-participant-removed",s),v("waiting-participant-updated",d);var p=n.useCallback((function(e,t){"*"!==e?null==u||u.updateWaitingParticipant(e,{grantRequestedAccess:t}):null==u||u.updateWaitingParticipants({"*":{grantRequestedAccess:t}})}),[u]);return{waitingParticipants:c,grantAccess:n.useCallback((function(e){p(e,!0)}),[p]),denyAccess:n.useCallback((function(e){p(e,!1)}),[p])}}; | ||
//# sourceMappingURL=daily-react-hooks.cjs.production.min.js.map |
{ | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"license": "BSD-2-Clause", | ||
@@ -41,2 +41,3 @@ "main": "dist/index.js", | ||
"homepage": "https://docs.daily.co/reference/daily-react-hooks", | ||
"repository": "github:daily-co/daily-react-hooks", | ||
"contributors": [ | ||
@@ -43,0 +44,0 @@ { |
@@ -1,6 +0,6 @@ | ||
import { useCallback, useEffect } from 'react'; | ||
import { DailyEventObjectParticipant } from '@daily-co/daily-js'; | ||
import { useEffect } from 'react'; | ||
import { atom, useRecoilCallback, useRecoilValue } from 'recoil'; | ||
import { useDaily } from './useDaily'; | ||
import { useDailyEvent } from './useDailyEvent'; | ||
import { useParticipant } from './useParticipant'; | ||
@@ -22,23 +22,25 @@ | ||
({ set }) => | ||
() => { | ||
const local = daily?.participants()?.local; | ||
if (!local) return; | ||
set(localIdState, local.session_id); | ||
(session_id: string) => { | ||
if (!session_id) return; | ||
set(localIdState, session_id); | ||
}, | ||
[daily] | ||
[] | ||
); | ||
useEffect(() => { | ||
if (!daily) return; | ||
initState(); | ||
}, [daily, initState]); | ||
if (!daily || localId) return; | ||
if (daily.participants()?.local) { | ||
initState(daily.participants().local.session_id); | ||
return; | ||
} | ||
const handleParticipantUpdated = (ev?: DailyEventObjectParticipant) => { | ||
if (!ev?.participant?.local) return; | ||
initState(ev?.participant?.session_id); | ||
}; | ||
daily.on('participant-updated', handleParticipantUpdated); | ||
return () => { | ||
daily.off('participant-updated', handleParticipantUpdated); | ||
}; | ||
}, [daily, initState, localId]); | ||
useDailyEvent( | ||
'loaded', | ||
useCallback(() => { | ||
// Arbitrary timeout. See https://codepen.io/Regaddi/pen/zYdVBja | ||
setTimeout(initState, 1000); | ||
}, [initState]) | ||
); | ||
return useParticipant(localId); | ||
}; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
747109
7359