@inlivedev/inlive-js-sdk
Version:
InLive JavaScript SDK
1 lines • 355 kB
JavaScript
const e={baseUrl:"https://api.inlive.app",version:"v1"},t={baseUrl:"https://channel.inlive.app"};Object.freeze(t);const n={iceServers:[{urls:"turn:turn.inlive.app:3478",username:"inlive",credential:"inlivesdkturn"}]};Object.freeze(n);var r=Object.freeze({__proto__:null,api:e,sse:t,webrtc:n}),i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function getAugmentedNamespace(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function a(){return this instanceof a?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var o={exports:{}};!function(e,t){var n="__lodash_hash_undefined__",r=9007199254740991,o="[object Arguments]",s="[object AsyncFunction]",c="[object Function]",d="[object GeneratorFunction]",l="[object Null]",u="[object Object]",h="[object Proxy]",m="[object Undefined]",f=/^\[object .+?Constructor\]$/,p=/^(?:0|[1-9]\d*)$/,v={};v["[object Float32Array]"]=v["[object Float64Array]"]=v["[object Int8Array]"]=v["[object Int16Array]"]=v["[object Int32Array]"]=v["[object Uint8Array]"]=v["[object Uint8ClampedArray]"]=v["[object Uint16Array]"]=v["[object Uint32Array]"]=!0,v[o]=v["[object Array]"]=v["[object ArrayBuffer]"]=v["[object Boolean]"]=v["[object DataView]"]=v["[object Date]"]=v["[object Error]"]=v[c]=v["[object Map]"]=v["[object Number]"]=v[u]=v["[object RegExp]"]=v["[object Set]"]=v["[object String]"]=v["[object WeakMap]"]=!1;var g="object"==typeof i&&i&&i.Object===Object&&i,y="object"==typeof self&&self&&self.Object===Object&&self,b=g||y||Function("return this")(),_=t&&!t.nodeType&&t,w=_&&e&&!e.nodeType&&e,S=w&&w.exports===_,C=S&&g.process,E=function(){try{var e=w&&w.require&&w.require("util").types;return e||C&&C.binding&&C.binding("util")}catch(e){}}(),k=E&&E.isTypedArray;var T,I=Array.prototype,A=Function.prototype,L=Object.prototype,x=b["__core-js_shared__"],O=A.toString,j=L.hasOwnProperty,D=(T=/[^.]+$/.exec(x&&x.keys&&x.keys.IE_PROTO||""))?"Symbol(src)_1."+T:"",M=L.toString,R=O.call(Object),F=RegExp("^"+O.call(j).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),V=S?b.Buffer:void 0,P=b.Symbol,N=b.Uint8Array,z=V?V.allocUnsafe:void 0,W=function overArg(e,t){return function(n){return e(t(n))}}(Object.getPrototypeOf,Object),U=Object.create,G=L.propertyIsEnumerable,H=I.splice,X=P?P.toStringTag:void 0,Z=function(){try{var e=getNative(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),$=V?V.isBuffer:void 0,B=Math.max,Y=Date.now,J=getNative(b,"Map"),K=getNative(Object,"create"),q=function(){function object(){}return function(e){if(!isObject(e))return{};if(U)return U(e);object.prototype=e;var t=new object;return object.prototype=void 0,t}}();function Hash(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ListCache(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function MapCache(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Stack(e){var t=this.__data__=new ListCache(e);this.size=t.size}function arrayLikeKeys(e,t){var n=ne(e),r=!n&&te(e),i=!n&&!r&&re(e),o=!n&&!r&&!i&&ie(e),s=n||r||i||o,c=s?function baseTimes(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],d=c.length;for(var l in e)!t&&!j.call(e,l)||s&&("length"==l||i&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||isIndex(l,d))||c.push(l);return c}function assignMergeValue(e,t,n){(void 0!==n&&!eq(e[t],n)||void 0===n&&!(t in e))&&baseAssignValue(e,t,n)}function assignValue(e,t,n){var r=e[t];j.call(e,t)&&eq(r,n)&&(void 0!==n||t in e)||baseAssignValue(e,t,n)}function assocIndexOf(e,t){for(var n=e.length;n--;)if(eq(e[n][0],t))return n;return-1}function baseAssignValue(e,t,n){"__proto__"==t&&Z?Z(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}Hash.prototype.clear=function hashClear(){this.__data__=K?K(null):{},this.size=0},Hash.prototype.delete=function hashDelete(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Hash.prototype.get=function hashGet(e){var t=this.__data__;if(K){var r=t[e];return r===n?void 0:r}return j.call(t,e)?t[e]:void 0},Hash.prototype.has=function hashHas(e){var t=this.__data__;return K?void 0!==t[e]:j.call(t,e)},Hash.prototype.set=function hashSet(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=K&&void 0===t?n:t,this},ListCache.prototype.clear=function listCacheClear(){this.__data__=[],this.size=0},ListCache.prototype.delete=function listCacheDelete(e){var t=this.__data__,n=assocIndexOf(t,e);return!(n<0)&&(n==t.length-1?t.pop():H.call(t,n,1),--this.size,!0)},ListCache.prototype.get=function listCacheGet(e){var t=this.__data__,n=assocIndexOf(t,e);return n<0?void 0:t[n][1]},ListCache.prototype.has=function listCacheHas(e){return assocIndexOf(this.__data__,e)>-1},ListCache.prototype.set=function listCacheSet(e,t){var n=this.__data__,r=assocIndexOf(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},MapCache.prototype.clear=function mapCacheClear(){this.size=0,this.__data__={hash:new Hash,map:new(J||ListCache),string:new Hash}},MapCache.prototype.delete=function mapCacheDelete(e){var t=getMapData(this,e).delete(e);return this.size-=t?1:0,t},MapCache.prototype.get=function mapCacheGet(e){return getMapData(this,e).get(e)},MapCache.prototype.has=function mapCacheHas(e){return getMapData(this,e).has(e)},MapCache.prototype.set=function mapCacheSet(e,t){var n=getMapData(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Stack.prototype.clear=function stackClear(){this.__data__=new ListCache,this.size=0},Stack.prototype.delete=function stackDelete(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Stack.prototype.get=function stackGet(e){return this.__data__.get(e)},Stack.prototype.has=function stackHas(e){return this.__data__.has(e)},Stack.prototype.set=function stackSet(e,t){var n=this.__data__;if(n instanceof ListCache){var r=n.__data__;if(!J||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new MapCache(r)}return n.set(e,t),this.size=n.size,this};var Q=function createBaseFor(e){return function(t,n,r){for(var i=-1,o=Object(t),s=r(t),c=s.length;c--;){var d=s[e?c:++i];if(!1===n(o[d],d,o))break}return t}}();function baseGetTag(e){return null==e?void 0===e?m:l:X&&X in Object(e)?function getRawTag(e){var t=j.call(e,X),n=e[X];try{e[X]=void 0;var r=!0}catch(e){}var i=M.call(e);r&&(t?e[X]=n:delete e[X]);return i}(e):function objectToString(e){return M.call(e)}(e)}function baseIsArguments(e){return isObjectLike(e)&&baseGetTag(e)==o}function baseIsNative(e){return!(!isObject(e)||function isMasked(e){return!!D&&D in e}(e))&&(isFunction(e)?F:f).test(function toSource(e){if(null!=e){try{return O.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function baseKeysIn(e){if(!isObject(e))return function nativeKeysIn(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=isPrototype(e),n=[];for(var r in e)("constructor"!=r||!t&&j.call(e,r))&&n.push(r);return n}function baseMerge(e,t,n,r,i){e!==t&&Q(t,(function(o,s){if(i||(i=new Stack),isObject(o))!function baseMergeDeep(e,t,n,r,i,o,s){var c=safeGet(e,n),d=safeGet(t,n),l=s.get(d);if(l)return void assignMergeValue(e,n,l);var h=o?o(c,d,n+"",e,t,s):void 0,m=void 0===h;if(m){var f=ne(d),p=!f&&re(d),v=!f&&!p&&ie(d);h=d,f||p||v?ne(c)?h=c:!function isArrayLikeObject(e){return isObjectLike(e)&&isArrayLike(e)}(c)?p?(m=!1,h=function cloneBuffer(e,t){if(t)return e.slice();var n=e.length,r=z?z(n):new e.constructor(n);return e.copy(r),r}(d,!0)):v?(m=!1,h=function cloneTypedArray(e,t){var n=t?function cloneArrayBuffer(e){var t=new e.constructor(e.byteLength);return new N(t).set(new N(e)),t}(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}(d,!0)):h=[]:h=function copyArray(e,t){var n=-1,r=e.length;t||(t=Array(r));for(;++n<r;)t[n]=e[n];return t}(c):function isPlainObject(e){if(!isObjectLike(e)||baseGetTag(e)!=u)return!1;var t=W(e);if(null===t)return!0;var n=j.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&O.call(n)==R}(d)||te(d)?(h=c,te(c)?h=function toPlainObject(e){return function copyObject(e,t,n,r){var i=!n;n||(n={});var o=-1,s=t.length;for(;++o<s;){var c=t[o],d=r?r(n[c],e[c],c,n,e):void 0;void 0===d&&(d=e[c]),i?baseAssignValue(n,c,d):assignValue(n,c,d)}return n}(e,keysIn(e))}(c):isObject(c)&&!isFunction(c)||(h=function initCloneObject(e){return"function"!=typeof e.constructor||isPrototype(e)?{}:q(W(e))}(d))):m=!1}m&&(s.set(d,h),i(h,d,r,o,s),s.delete(d));assignMergeValue(e,n,h)}(e,t,s,n,baseMerge,r,i);else{var c=r?r(safeGet(e,s),o,s+"",e,t,i):void 0;void 0===c&&(c=o),assignMergeValue(e,s,c)}}),keysIn)}function baseRest(e,t){return ee(function overRest(e,t,n){return t=B(void 0===t?e.length-1:t,0),function(){for(var r=arguments,i=-1,o=B(r.length-t,0),s=Array(o);++i<o;)s[i]=r[t+i];i=-1;for(var c=Array(t+1);++i<t;)c[i]=r[i];return c[t]=n(s),function apply(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}(e,this,c)}}(e,t,identity),e+"")}function getMapData(e,t){var n=e.__data__;return function isKeyable(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?n["string"==typeof t?"string":"hash"]:n.map}function getNative(e,t){var n=function getValue(e,t){return null==e?void 0:e[t]}(e,t);return baseIsNative(n)?n:void 0}function isIndex(e,t){var n=typeof e;return!!(t=null==t?r:t)&&("number"==n||"symbol"!=n&&p.test(e))&&e>-1&&e%1==0&&e<t}function isPrototype(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||L)}function safeGet(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var ee=function shortOut(e){var t=0,n=0;return function(){var r=Y(),i=16-(r-n);if(n=r,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(Z?function(e,t){return Z(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:identity);function eq(e,t){return e===t||e!=e&&t!=t}var te=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isObjectLike(e)&&j.call(e,"callee")&&!G.call(e,"callee")},ne=Array.isArray;function isArrayLike(e){return null!=e&&isLength(e.length)&&!isFunction(e)}var re=$||function stubFalse(){return!1};function isFunction(e){if(!isObject(e))return!1;var t=baseGetTag(e);return t==c||t==d||t==s||t==h}function isLength(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}function isObject(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function isObjectLike(e){return null!=e&&"object"==typeof e}var ie=k?function baseUnary(e){return function(t){return e(t)}}(k):function baseIsTypedArray(e){return isObjectLike(e)&&isLength(e.length)&&!!v[baseGetTag(e)]};function keysIn(e){return isArrayLike(e)?arrayLikeKeys(e,!0):baseKeysIn(e)}var ae=function createAssigner(e){return baseRest((function(t,n){var r=-1,i=n.length,o=i>1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,s&&function isIterateeCall(e,t,n){if(!isObject(n))return!1;var r=typeof t;if("number"==r?isArrayLike(n)&&isIndex(t,n.length):"string"==r&&t in n)return eq(n[t],e);return!1}(n[0],n[1],s)&&(o=i<3?void 0:o,i=1),t=Object(t);++r<i;){var c=n[r];c&&e(t,c,r,o)}return t}))}((function(e,t,n){baseMerge(e,t,n)}));function identity(e){return e}e.exports=ae}(o,o.exports);var s=getDefaultExportFromCjs(o.exports);const c={apiKey:"",api:e,webrtc:n};function InitializationInstance(e){this.config=e}var d=Object.freeze({__proto__:null,init:e=>{if(void 0!==e&&void 0!==e.apiKey){if("string"!=typeof e.apiKey)throw new TypeError("Failed to process because the API key is not in a valid string format. API key must be in a string format");if(0===e.apiKey.trim().length)throw new Error("Failed to process because the API key field is an empty string. Please provide an API key.")}return s(c,e),new InitializationInstance(c)}});const l={url:"",token:"",method:"GET",body:void 0,options:void 0},fetchHttp=async(e=l)=>{const{url:t,token:n,method:r,body:i,options:o}=e;if(0===t.trim().length)throw new Error("Please provide the url");const s={method:r||"GET",mode:"cors",referrerPolicy:"origin-when-cross-origin",headers:{Authorization:n?`Bearer ${n}`:"","Content-Type":"application/json"},body:"object"==typeof i&&"GET"!==r?JSON.stringify(i):void 0,...o};let c;c="undefined"!=typeof window&&window?(e,t)=>window.fetch(e,t):(e,t)=>import("node-fetch").then((({default:n})=>n(e,t)));const d=await c(t,s),u=d.headers.get("content-type");let h={};if(u&&u.includes("application/json"))h=await d.json();else{h=await d.text()}return d.ok&&d.status>=200&&d.status<300?Promise.resolve(h):Promise.reject(h)};var u={exports:{}};const isObject$2=e=>"object"==typeof e&&null!==e,h=Symbol("skip"),isObjectCustom=e=>isObject$2(e)&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Date),mapObject=(e,t,n,r=new WeakMap)=>{if(n={deep:!1,target:{},...n},r.has(e))return r.get(e);r.set(e,n.target);const{target:i}=n;delete n.target;const mapArray=e=>e.map((e=>isObjectCustom(e)?mapObject(e,t,n,r):e));if(Array.isArray(e))return mapArray(e);for(const[o,s]of Object.entries(e)){const c=t(o,s,e);if(c===h)continue;let[d,l,{shouldRecurse:u=!0}={}]=c;"__proto__"!==d&&(n.deep&&u&&isObjectCustom(l)&&(l=Array.isArray(l)?mapArray(l):mapObject(l,t,n,r)),i[d]=l)}return i};u.exports=(e,t,n)=>{if(!isObject$2(e))throw new TypeError(`Expected an object, got \`${e}\` (${typeof e})`);return mapObject(e,t,n)},u.exports.mapObjectSkip=h;var m=u.exports,f=getDefaultExportFromCjs(m),__assign=function(){return __assign=Object.assign||function __assign(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},__assign.apply(this,arguments)};function __awaiter(e,t,n,r){return new(n||(n=Promise))((function(i,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r.throw(e))}catch(e){o(e)}}function step(e){e.done?i(e.value):function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))}function __generator(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function verb(c){return function(d){return function step(c){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,c[0]&&(s=0)),s;)try{if(n=1,r&&(i=2&c[0]?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=0,i&&(c=[2&c[0],i.value]),c[0]){case 0:case 1:i=c;break;case 4:return s.label++,{value:c[1],done:!1};case 5:s.label++,r=c[1],c=[0];continue;case 7:c=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==c[0]&&2!==c[0])){s=0;continue}if(3===c[0]&&(!i||c[1]>i[0]&&c[1]<i[3])){s.label=c[1];break}if(6===c[0]&&s.label<i[1]){s.label=i[1],i=c;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(c);break}i[2]&&s.ops.pop(),s.trys.pop();continue}c=t.call(e,s)}catch(e){c=[6,e],r=0}finally{n=i=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,d])}}}function __spreadArray(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}function lowerCase(e){return e.toLowerCase()}"function"==typeof SuppressedError&&SuppressedError;var p=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],v=/[^A-Z0-9]+/gi;function replace(e,t,n){return t instanceof RegExp?e.replace(t,n):t.reduce((function(e,t){return e.replace(t,n)}),e)}function dotCase(e,t){return void 0===t&&(t={}),function noCase(e,t){void 0===t&&(t={});for(var n=t.splitRegexp,r=void 0===n?p:n,i=t.stripRegexp,o=void 0===i?v:i,s=t.transform,c=void 0===s?lowerCase:s,d=t.delimiter,l=void 0===d?" ":d,u=replace(replace(e,r,"$1\0$2"),o,"\0"),h=0,m=u.length;"\0"===u.charAt(h);)h++;for(;"\0"===u.charAt(m-1);)m--;return u.slice(h,m).split("\0").map(c).join(l)}(e,__assign({delimiter:"."},t))}var g=getAugmentedNamespace(Object.freeze({__proto__:null,snakeCase:function snakeCase$1(e,t){return void 0===t&&(t={}),dotCase(e,__assign({delimiter:"_"},t))}}));const y=m,{snakeCase:b}=g;var _=getDefaultExportFromCjs((function(e,t){return t=Object.assign({deep:!0,exclude:[],parsingOptions:{}},t),y(e,(function(e,n){return[(r=t.exclude,i=e,r.some((function(e){return"string"==typeof e?e===i:e.test(i)}))?e:b(e,t.parsingOptions)),n];var r,i}),t)}));const w=/[\p{Lu}]/u,S=/[\p{Ll}]/u,C=/^[\p{Lu}](?![\p{Lu}])/gu,E=/([\p{Alpha}\p{N}_]|$)/u,k=/[_.\- ]+/,T=new RegExp("^"+k.source),I=new RegExp(k.source+E.source,"gu"),A=new RegExp("\\d+"+E.source,"gu");function camelCase(e,t){if("string"!=typeof e&&!Array.isArray(e))throw new TypeError("Expected the input to be `string | string[]`");if(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},0===(e=Array.isArray(e)?e.map((e=>e.trim())).filter((e=>e.length)).join("-"):e.trim()).length)return"";const n=!1===t.locale?e=>e.toLowerCase():e=>e.toLocaleLowerCase(t.locale),r=!1===t.locale?e=>e.toUpperCase():e=>e.toLocaleUpperCase(t.locale);if(1===e.length)return k.test(e)?"":t.pascalCase?r(e):n(e);return e!==n(e)&&(e=((e,t,n)=>{let r=!1,i=!1,o=!1;for(let s=0;s<e.length;s++){const c=e[s];r&&w.test(c)?(e=e.slice(0,s)+"-"+e.slice(s),r=!1,o=i,i=!0,s++):i&&o&&S.test(c)?(e=e.slice(0,s-1)+"-"+e.slice(s-1),o=i,i=!1,r=!0):(r=t(c)===c&&n(c)!==c,o=i,i=n(c)===c&&t(c)!==c)}return e})(e,n,r)),e=e.replace(T,""),e=t.preserveConsecutiveUppercase?((e,t)=>(C.lastIndex=0,e.replace(C,(e=>t(e)))))(e,n):n(e),t.pascalCase&&(e=r(e.charAt(0))+e.slice(1)),((e,t)=>(I.lastIndex=0,A.lastIndex=0,e.replace(I,((e,n)=>t(n))).replace(A,(e=>t(e)))))(e,r)}class QuickLRU extends Map{constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if("number"==typeof e.maxAge&&0===e.maxAge)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||Number.POSITIVE_INFINITY,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if("function"==typeof this.onEviction)for(const[t,n]of e)this.onEviction(t,n.value)}_deleteIfExpired(e,t){return"number"==typeof t.expiry&&t.expiry<=Date.now()&&("function"==typeof this.onEviction&&this.onEviction(e,t.value),this.delete(e))}_getOrDeleteIfExpired(e,t){if(!1===this._deleteIfExpired(e,t))return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){const n=t.get(e);return this._getItemValue(e,n)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(const e of this.oldCache){const[t,n]=e;if(!this.cache.has(t)){!1===this._deleteIfExpired(t,n)&&(yield e)}}for(const e of this.cache){const[t,n]=e;!1===this._deleteIfExpired(t,n)&&(yield e)}}get(e){if(this.cache.has(e)){const t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){const t=this.oldCache.get(e);if(!1===this._deleteIfExpired(e,t))return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:n=this.maxAge}={}){const r="number"==typeof n&&n!==Number.POSITIVE_INFINITY?Date.now()+n:void 0;this.cache.has(e)?this.cache.set(e,{value:t,expiry:r}):this._set(e,{value:t,expiry:r})}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):!!this.oldCache.has(e)&&!this._deleteIfExpired(e,this.oldCache.get(e))}peek(e){return this.cache.has(e)?this._peek(e,this.cache):this.oldCache.has(e)?this._peek(e,this.oldCache):void 0}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");const t=[...this._entriesAscending()],n=t.length-e;n<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(n>0&&this._emitEvictions(t.slice(0,n)),this.oldCache=new Map(t.slice(n)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache){const[t,n]=e;!1===this._deleteIfExpired(t,n)&&(yield[t,n.value])}for(const e of this.oldCache){const[t,n]=e;if(!this.cache.has(t)){!1===this._deleteIfExpired(t,n)&&(yield[t,n.value])}}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){const n=e[t],[r,i]=n;!1===this._deleteIfExpired(r,i)&&(yield[r,i.value])}e=[...this.oldCache];for(let t=e.length-1;t>=0;--t){const n=e[t],[r,i]=n;if(!this.cache.has(r)){!1===this._deleteIfExpired(r,i)&&(yield[r,i.value])}}}*entriesAscending(){for(const[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}entries(){return this.entriesAscending()}forEach(e,t=this){for(const[n,r]of this.entriesAscending())e.call(t,r,n,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}}const L=new QuickLRU({maxSize:1e5}),isObject$1=e=>!("object"!=typeof e||null===e||e instanceof RegExp||e instanceof Error||e instanceof Date),camelCaseConvert=(e,t)=>{if(!isObject$1(e))return e;t={deep:!1,pascalCase:!1,...t};const{exclude:n,pascalCase:r,stopPaths:i,deep:o}=t,s=new Set(i),makeMapper=e=>(t,i)=>{if(o&&isObject$1(i)){const n=void 0===e?t:`${e}.${t}`;s.has(n)||(i=f(i,makeMapper(n)))}if(!n||!((e,t)=>e.some((e=>"string"==typeof e?e===t:(e.lastIndex=0,e.test(t)))))(n,t)){const e=r?`${t}_`:t;if(L.has(e))t=L.get(e);else{const n=camelCase(t,{pascalCase:r,locale:!1});t.length<100&&L.set(e,n),t=n}}return[t,i]};return f(e,makeMapper(void 0))};function camelcaseKeys(e,t){return Array.isArray(e)?Object.keys(e).map((n=>camelCaseConvert(e[n],t))):camelCaseConvert(e,t)}const onOpen=e=>({onOpen:t=>{e.client instanceof EventTarget&&t instanceof Function&&e.client.addEventListener("open",(e=>{t(e)}))}}),onError=e=>({onError:t=>{e.client instanceof EventTarget&&t instanceof Function&&e.client.addEventListener("error",(e=>{t(e)}))}}),onMessage=e=>({onMessage:t=>{e.client instanceof EventTarget&&t instanceof Function&&e.client.addEventListener("message",(e=>{if(e.data){let n=JSON.parse(e.data);n="object"==typeof n?n:{},t(camelcaseKeys(n,{deep:!0}))}}))}}),getEventKey=async(e,t)=>{let n=await fetchHttp({url:`${t}/auth/eventkey`,token:e,method:"POST"}).catch((e=>e));if(n)switch(n.code){case 200:e=n.data;break;case 404:throw new Error("Failed to get the event key because the stream ID is not found. Please provide a valid stream ID.");case 403:throw new Error("Failed to get event key because the authentication is failed. Check the API key")}return e},x=(()=>{const e={},isInstanceOfSet=(e,t)=>e[t]instanceof Set;return{publish:(t="",n={})=>{if(!t)throw new Error("Failed to process - event name is required");if("string"!=typeof t)throw new TypeError("Failed to process - event name must be in a string format");if(0===t.trim().length)throw new Error("Failed to process - event name must not be empty");if(isInstanceOfSet(e,t))for(const r of e[t])"function"==typeof r&&r(n);else e[t]=new Set},subscribe:(t,n)=>{if(!t)throw new Error("Failed to process - event name is required");if("string"!=typeof t)throw new TypeError("Failed to process - event name must be in a string format");if(0===t.trim().length)throw new Error("Failed to process - event name must not be empty");if("function"!=typeof n)throw new TypeError("Failed to process - please provide a callback function");isInstanceOfSet(e,t)||(e[t]=new Set),e[t].add(n);return{unsubscribe:()=>{e[t].delete(n)}}}}})();Object.freeze(x);const O=(()=>{const{iceServers:e}=n;return{closeConnection:e=>{if(!(e instanceof RTCPeerConnection))throw new TypeError("Failed to process - Peer connection object is missing");e.close(),e=null},createLocalOffer:async e=>{if(!(e instanceof RTCPeerConnection))throw new TypeError("Failed to process - Peer connection object is missing");e.addEventListener("iceconnectionstatechange",(()=>{x.publish("stream:ice-connection-state-change-event",{type:"stream:ice-connection-state-change-event",detail:{connectionState:e.connectionState,iceConnectionState:e.iceConnectionState}})}));const t=new Promise((t=>{let n,r=!1;e&&e.addEventListener("icecandidate",(e=>{null!==e.candidate||r?n=setTimeout((()=>{r||(clearTimeout(n),r=!0,t(e))}),1e3):(clearTimeout(n),r=!0,t(e))}))})),n=await e.createOffer();await e.setLocalDescription(n),await t},openConnection:()=>new RTCPeerConnection({iceServers:e}),setRemoteOffer:(e,t)=>{if(e&&t){const n=new RTCSessionDescription(t);e.setRemoteDescription(n)}}}})();Object.freeze(O);const uuidv4=()=>{let e="";return window&&"undefined"!=typeof window&&(e=crypto.randomUUID?crypto.randomUUID():([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)))),e};var j=Object.freeze({__proto__:null,config:r,fetchHttp,getEventKey,sse:()=>{let e={client:void 0};return Object.assign({},(e=>({subscribe:t=>{if("string"!=typeof t)throw new TypeError("Failed to process - URL must be a string");if(0===t.trim().length)throw new Error("Failed to process - URL cannot be empty");if(void 0!==e.client)throw new Error("Failed to process - Client was already subscribed to the specific channel. You can unsubscribe and resubscribe again to different channel");return e.client=new EventSource(t),e}}))(e),(e=>({unsubscribe:()=>{e.client instanceof EventSource&&(e.client.close(),e.client=void 0)}}))(e),onOpen(e),onError(e),onMessage(e),{publish:async(e,t)=>{if("string"!=typeof e||0===e.trim().length)throw new Error("Failed to process - Please provide the URL");if(!t)throw new Error("Failed to process - Please provide the data that wants to be published");if("object"!=typeof t)throw new TypeError("Failed to process - Data must be in an object format");return await fetchHttp({url:e,method:"POST",body:_(t)})}})},uuidv4,webrtc:O,websocket:()=>{let e={client:void 0};return Object.assign({},(e=>({subscribe:t=>{if("string"!=typeof t)throw new TypeError("Failed to process - URL must be a string");if(0===t.trim().length)throw new Error("Failed to process - URL cannot be empty");if(void 0!==e.client)throw new Error("Failed to process - Client was already subscribed to the specific channel. You can unsubscribe and resubscribe again to different channel");return e.client=new WebSocket(t),e}}))(e),(e=>({unsubscribe:()=>{e.client instanceof WebSocket&&(e.client.close(),e.client=void 0)}}))(e),onOpen(e),onError(e),onMessage(e))}});const initStream=async(e,t)=>{if(e.constructor.name!==InitializationInstance.name)throw new TypeError("Failed to process because initialization is not valid. Please provide required initialization argument which is the initialization instance returned by the init() function");if(!t||void 0===t.streamId)throw new Error("Failed to process because the stream ID is not provided. Please provide the stream ID!");if("number"!=typeof t.streamId)throw new TypeError("Failed to process because the stream ID is not in a number format. The stream ID must be in a number format");if(!t.sessionDescription||!t.sessionDescription.type||!t.sessionDescription.sdp)throw new TypeError("Failed to process because the local description has wrong format");const{streamId:n,sessionDescription:r}=t,i=`${e.config.api.baseUrl}/${e.config.api.version}`;try{const t=r.toJSON(),o=await fetchHttp({url:`${i}/streams/${n}/init`,token:e.config.apiKey,method:"POST",body:t}),{code:s,data:c}=o;return{status:{code:s||null,type:"success",message:"Successfully initialize a stream session"},data:{sdp:c&&c.sdp?c.sdp:null,type:c&&c.type?c.type:null}}}catch(e){throw console.error(e),e}},prepareStream=async(e,t)=>{if(e.constructor.name!==InitializationInstance.name)throw new TypeError("Failed to process because initialization is not valid. Please provide required initialization argument which is the initialization instance returned by the init() function");if(!t)throw new Error("Failed to process because the stream ID is not provided. Please provide the stream ID!");if("number"!=typeof t)throw new TypeError("Failed to process because the stream ID is not in a number format. The stream ID must be in a number format");const n=`${e.config.api.baseUrl}/${e.config.api.version}`;try{const r=await fetchHttp({url:`${n}/streams/${t}/prepare`,token:e.config.apiKey,method:"POST",body:{}});if(r.code>=300)throw new Error("failed to request prepare endpoint:"+r.message);return!0}catch(e){throw console.error("error sdk prepare",e),e}},startStream=async(e,t)=>{if(e.constructor.name!==InitializationInstance.name)throw new TypeError("Failed to process because initialization is not valid. Please provide required initialization argument which is the initialization instance returned by the init() function");if(!t)throw new Error("Failed to process because the stream ID is not provided. Please provide the stream ID!");if("number"!=typeof t)throw new TypeError("Failed to process because the stream ID is not in a number format. The stream ID must be in a number format");const n=`${e.config.api.baseUrl}/${e.config.api.version}`;try{const r=await fetchHttp({url:`${n}/streams/${t}/start`,token:e.config.apiKey,method:"POST",body:{}});if(r.code>=300)throw new Error("failed to request start endpoint:"+r.message);return r.data}catch(e){throw console.error(e),e}},fetchStream=async(e,t)=>{if("string"!=typeof e||0===e.trim().length)throw new Error("Error because invalid API base url");if(null==t)throw new Error("Failed to get the stream data because the stream ID is empty. Please provide a stream ID");if("number"!=typeof t)throw new TypeError("Failed to get the stream data because the stream ID is not in number format. A stream ID must be number format");{let n=await fetchHttp({url:`${e}/streams/${t}`,method:"GET"}).catch((e=>e));if(n&&404===n.code)throw new Error("Failed to get the stream data because the stream ID is not found. Please provide a valid stream ID.");const r=n.data;return{id:r.id,name:r.name,slug:r.slug,description:r.description,hlsUrl:r.hls_url,dashUrl:r.dash_url,createdAt:r.created_at,updatedAt:r.updated_at,preparedAt:r.prepared_at,startedAt:r.start_time,endedAt:r.end_time,createdBy:r.created_by,updatedBy:r.updated_by,quality:r.quality}}},endStream=async(e,t)=>{if(e.constructor.name!==InitializationInstance.name)throw new TypeError("Failed to process because initialization is not valid. Please provide required initialization argument which is the initialization instance returned by the init() function");if(!t||void 0===t)throw new Error("Failed to process because the stream ID is not provided. Please provide the stream ID!");if("number"!=typeof t)throw new TypeError("Failed to process because the stream ID is not in a number format. The stream ID must be in a number format");const n=`${e.config.api.baseUrl}/${e.config.api.version}`;try{return await fetchHttp({url:`${n}/streams/${t}/end`,token:e.config.apiKey,method:"POST",body:{}}),!0}catch(e){throw console.error(e),e}},{webrtc:D}=j;class Stream{static READY="streamReady";static STARTED="streamStarted";static ENDED="streamEnded";static ERROR="streamError";static ICECANDIDATE="iceCandidate";static STATECHANGED="stateChanged";static STATE_NEW="new";static STATE_CONNECTING="connecting";static STATE_CONNECTED="connected";static STATE_COMPLETED="completed";static STATE_DISCONNECTED="disconnected";static STATE_READY="ready";static STATE_LIVE="live";static STATE_FAILED="failed";static STATE_ENDED="ended";constructor(e,t){this.app=e,this.id=t.id,this.state=Stream.STATE_NEW,this.name=t.name,this.data=t,this.mediaStream=null,this.peerConnection=null,this.eventHandlers={streamStarted:[],streamEnded:[],streamError:[],iceCandidate:[],stateChanged:[]},this.manifests={dash:"",hls:""},""!==t.dashUrl&&""!==t.hlsUrl&&(this.manifests.dash=t.dashUrl,this.manifests.hls=t.hlsUrl),this.pandingIceCandidates=[]}getAPIUrl(){return`${this.app.config.api.baseUrl}/${this.app.config.api.version}`}async subscribe(){let e=null;const t=this.getAPIUrl();if(void 0===this.app.config.apiKey||""===this.app.config.apiKey)e=new EventSource(`${t}/streams/${this.id}/events`,{withCredentials:!0});else{const n=await getEventKey(this.app.config.apiKey,t);e=new EventSource(`${t}/streams/${this.id}/events/${n}`,{withCredentials:!0})}this.setEventHandlers(e)}async setEventHandlers(e){e.addEventListener(Stream.STARTED,(e=>{this.dispatchEvent(Stream.STARTED,e.data)})),e.addEventListener(Stream.ENDED,(e=>{this.dispatchEvent(Stream.ENDED,e.data)})),e.addEventListener(Stream.ERROR,(e=>{this.dispatchEvent(Stream.ERROR,e.data)})),e.addEventListener(Stream.ICECANDIDATE,(e=>{const t=JSON.parse(e.data);this.addIceCandidate(t)}))}addIceCandidate(e){if(null===this.peerConnection)throw new Error("the peer connection is not set");const t=new RTCIceCandidate(e);null!==this.peerConnection.remoteDescription&&null===this.peerConnection.pendingRemoteDescription?this.peerConnection.addIceCandidate(t):this.pandingIceCandidates.push(t)}dispatchEvent(e,t){if(!(e in this.eventHandlers))throw new Error("Unknown event, available events are Stream.READY|Stream.STARTED|Stream.ENDED|Stream.ERROR|Stream.STATECHANGED");for(const n of this.eventHandlers[e])n(t)}on(e,t){void 0===this.eventHandlers[e]&&(this.eventHandlers[e]=[]),this.eventHandlers[e].push(t)}changeState(e){this.state=e,this.dispatchEvent(Stream.STATECHANGED,{state:e})}listenForWebRTCEvent(){this.peerConnection.addEventListener("icecandidate",(e=>{if(e.candidate){if(""===e.candidate.candidate)return;const{candidate:t}=e;this.sendIceCandidate(t)}})),this.peerConnection.addEventListener("iceconnectionstatechange",(()=>{switch(this.peerConnection.iceConnectionState){case"new":this.changeState(Stream.STATE_CONNECTING);break;case"connected":this.changeState(Stream.STATE_CONNECTED);break;case"completed":this.changeState(Stream.STATE_COMPLETED);break;case"disconnected":this.changeState(Stream.STATE_DISCONNECTED);break;case"closed":this.changeState(Stream.STATE_ENDED);break;case"failed":this.changeState(Stream.STATE_FAILED)}}))}addPendingIceCandidates(){for(const e of this.pandingIceCandidates)this.peerConnection?.addIceCandidate(e)}async init(e){this.state===Stream.STATE_NEW&&await this.prepare(),this.mediaStream=e,this.peerConnection=D.openConnection(),this.listenForWebRTCEvent();for(const t of e.getTracks())this.peerConnection.addTrack(t,e);const t=await this.peerConnection.createOffer();await this.peerConnection.setLocalDescription(t);const n=new Promise(((e,t)=>{this.on(Stream.STATECHANGED,(n=>{n.state===Stream.STATE_CONNECTED||n.state===Stream.STATE_COMPLETED?e(!0):n.state===Stream.STATE_FAILED&&t(!1)})),this.on(Stream.ERROR,(()=>t(!1)))})),r={streamId:this.id,sessionDescription:this.peerConnection.localDescription},i=await initStream(this.app,r);return this.peerConnection.setRemoteDescription(i.data),this.addPendingIceCandidates(),n}async sendIceCandidate(e){const t=this.getAPIUrl();let n=await fetchHttp({url:`${t}/streams/${this.id}/ice`,body:e.toJSON(),token:this.app.config.apiKey,method:"POST"});if(n)switch(n.code){case 404:throw new Error("the stream ID is not found. Please provide a valid stream ID.");case 400:throw new Error("Bad request, invalid ice candidate")}}async prepare(){await this.subscribe(),await prepareStream(this.app,this.id),this.changeState(Stream.STATE_READY)}async live(){if(this.state!==Stream.STATE_CONNECTED&&this.state!==Stream.STATE_COMPLETED)throw new Error("The live function is called before the state change to connected/completed. Use stream.on(Stream.STATECHANGED,(ev) => if(ev.state ===Stream.STATE_COMPLETED || ev.state ===Stream.STATE_CONNECTED){...}) to know when the connection is ready for live.");this.manifests=await startStream(this.app,this.id),this.data=await fetchStream(this.getAPIUrl(),this.id),this.changeState(Stream.STATE_LIVE)}async end(){await endStream(this.app,this.id),this.peerConnection&&this.peerConnection.close(),this.data=await fetchStream(this.getAPIUrl(),this.id),this.changeState(Stream.STATE_ENDED)}}function eq(e,t){return e===t||e!=e&&t!=t}function assocIndexOf(e,t){for(var n=e.length;n--;)if(eq(e[n][0],t))return n;return-1}var M=Array.prototype.splice;function ListCache(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ListCache.prototype.clear=function listCacheClear(){this.__data__=[],this.size=0},ListCache.prototype.delete=function listCacheDelete(e){var t=this.__data__,n=assocIndexOf(t,e);return!(n<0)&&(n==t.length-1?t.pop():M.call(t,n,1),--this.size,!0)},ListCache.prototype.get=function listCacheGet(e){var t=this.__data__,n=assocIndexOf(t,e);return n<0?void 0:t[n][1]},ListCache.prototype.has=function listCacheHas(e){return assocIndexOf(this.__data__,e)>-1},ListCache.prototype.set=function listCacheSet(e,t){var n=this.__data__,r=assocIndexOf(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};var R="object"==typeof global&&global&&global.Object===Object&&global,F="object"==typeof self&&self&&self.Object===Object&&self,V=R||F||Function("return this")(),P=V.Symbol,N=Object.prototype,z=N.hasOwnProperty,W=N.toString,U=P?P.toStringTag:void 0;var G=Object.prototype.toString;var H="[object Null]",X="[object Undefined]",Z=P?P.toStringTag:void 0;function baseGetTag(e){return null==e?void 0===e?X:H:Z&&Z in Object(e)?function getRawTag(e){var t=z.call(e,U),n=e[U];try{e[U]=void 0;var r=!0}catch(e){}var i=W.call(e);return r&&(t?e[U]=n:delete e[U]),i}(e):function objectToString(e){return G.call(e)}(e)}function isObject(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var $="[object AsyncFunction]",B="[object Function]",Y="[object GeneratorFunction]",J="[object Proxy]";function isFunction(e){if(!isObject(e))return!1;var t=baseGetTag(e);return t==B||t==Y||t==$||t==J}var K,q=V["__core-js_shared__"],Q=(K=/[^.]+$/.exec(q&&q.keys&&q.keys.IE_PROTO||""))?"Symbol(src)_1."+K:"";var ee=Function.prototype.toString;var te=/^\[object .+?Constructor\]$/,ne=Function.prototype,re=Object.prototype,ie=ne.toString,ae=re.hasOwnProperty,oe=RegExp("^"+ie.call(ae).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative(e){return!(!isObject(e)||function isMasked(e){return!!Q&&Q in e}(e))&&(isFunction(e)?oe:te).test(function toSource(e){if(null!=e){try{return ee.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e))}function getNative(e,t){var n=function getValue(e,t){return null==e?void 0:e[t]}(e,t);return baseIsNative(n)?n:void 0}var se=getNative(V,"Map"),ce=getNative(Object,"create");var de=Object.prototype.hasOwnProperty;var le=Object.prototype.hasOwnProperty;function Hash(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function getMapData(e,t){var n=e.__data__;return function isKeyable(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?n["string"==typeof t?"string":"hash"]:n.map}function MapCache(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Hash.prototype.clear=function hashClear(){this.__data__=ce?ce(null):{},this.size=0},Hash.prototype.delete=function hashDelete(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Hash.prototype.get=function hashGet(e){var t=this.__data__;if(ce){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return de.call(t,e)?t[e]:void 0},Hash.prototype.has=function hashHas(e){var t=this.__data__;return ce?void 0!==t[e]:le.call(t,e)},Hash.prototype.set=function hashSet(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=ce&&void 0===t?"__lodash_hash_undefined__":t,this},MapCache.prototype.clear=function mapCacheClear(){this.size=0,this.__data__={hash:new Hash,map:new(se||ListCache),string:new Hash}},MapCache.prototype.delete=function mapCacheDelete(e){var t=getMapData(this,e).delete(e);return this.size-=t?1:0,t},MapCache.prototype.get=function mapCacheGet(e){return getMapData(this,e).get(e)},MapCache.prototype.has=function mapCacheHas(e){return getMapData(this,e).has(e)},MapCache.prototype.set=function mapCacheSet(e,t){var n=getMapData(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};function Stack(e){var t=this.__data__=new ListCache(e);this.size=t.size}Stack.prototype.clear=function stackClear(){this.__data__=new ListCache,this.size=0},Stack.prototype.delete=function stackDelete(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Stack.prototype.get=function stackGet(e){return this.__data__.get(e)},Stack.prototype.has=function stackHas(e){return this.__data__.has(e)},Stack.prototype.set=function stackSet(e,t){var n=this.__data__;if(n instanceof ListCache){var r=n.__data__;if(!se||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new MapCache(r)}return n.set(e,t),this.size=n.size,this};var ue=function(){try{var e=getNative(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();function baseAssignValue(e,t,n){"__proto__"==t&&ue?ue(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function assignMergeValue(e,t,n){(void 0!==n&&!eq(e[t],n)||void 0===n&&!(t in e))&&baseAssignValue(e,t,n)}var he=function createBaseFor(e){return function(t,n,r){for(var i=-1,o=Object(t),s=r(t),c=s.length;c--;){var d=s[e?c:++i];if(!1===n(o[d],d,o))break}return t}}(),me=he,fe="object"==typeof exports&&exports&&!exports.nodeType&&exports,pe=fe&&"object"==typeof module&&module&&!module.nodeType&&module,ve=pe&&pe.exports===fe?V.Buffer:void 0,ge=ve?ve.allocUnsafe:void 0;var ye=V.Uint8Array;function cloneTypedArray(e,t){var n=t?function cloneArrayBuffer(e){var t=new e.constructor(e.byteLength);return new ye(t).set(new ye(e)),t}(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var be=Object.create,_e=function(){function object(){}return function(e){if(!isObject(e))return{};if(be)return be(e);object.prototype=e;var t=new object;return object.prototype=void 0,t}}();var we=function overArg(e,t){return function(n){return e(t(n))}}(Object.getPrototypeOf,Object),Se=Object.prototype;function isPrototype(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Se)}function isObjectLike(e){return null!=e&&"object"==typeof e}function baseIsArguments(e){return isObjectLike(e)&&"[object Arguments]"==baseGetTag(e)}var Ce=Object.prototype,Ee=Ce.hasOwnProperty,ke=Ce.propertyIsEnumerable,Te=baseIsArguments(function(){return arguments}())?baseIsArguments:function(e){return isObjectLike(e)&&Ee.call(e,"callee")&&!ke.call(e,"callee")},Ie=Array.isArray,Ae=9007199254740991;function isLength(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=Ae}function isArrayLike(e){return null!=e&&isLength(e.length)&&!isFunction(e)}var Le="object"==typeof exports&&exports&&!exports.nodeType&&exports,xe=Le&&"object"==typeof module&&module&&!module.nodeType&&module,Oe=xe&&xe.exports===Le?V.Buffer:void 0,je=(Oe?Oe.isBuffer:void 0)||function stubFalse(){return!1},De="[object Object]",Me=Function.prototype,Re=Object.prototype,Fe=Me.toString,Ve=Re.hasOwnProperty,Pe=Fe.call(Object);var Ne={};Ne["[object Float32Array]"]=Ne["[object Float64Array]"]=Ne["[object Int8Array]"]=Ne["[object Int16Array]"]=Ne["[object Int32Array]"]=Ne["[object Uint8Array]"]=Ne["[object Uint8ClampedArray]"]=Ne["[object Uint16Array]"]=Ne["[object Uint32Array]"]=!0,Ne["[object Arguments]"]=Ne["[object Array]"]=Ne["[object ArrayBuffer]"]=Ne["[object Boolean]"]=Ne["[object DataView]"]=Ne["[object Date]"]=Ne["[object Error]"]=Ne["[object Function]"]=Ne["[object Map]"]=Ne["[object Number]"]=Ne["[object Object]"]=Ne["[object RegExp]"]=Ne["[object Set]"]=Ne["[object String]"]=Ne["[object WeakMap]"]=!1;var ze="object"==typeof exports&&exports&&!exports.nodeType&&exports,We=ze&&"object"==typeof module&&module&&!module.nodeType&&module,Ue=We&&We.exports===ze&&R.process,Ge=function(){try{var e=We&&We.require&&We.require("util").types;return e||Ue&&Ue.binding&&Ue.binding("util")}catch(e){}}(),He=Ge&&Ge.isTypedArray,Xe=He?function baseUnary(e){return function(t){return e(t)}}(He):function baseIsTypedArray(e){return isObjectLike(e)&&isLength(e.length)&&!!Ne[baseGetTag(e)]};function safeGet(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Ze=Object.prototype.hasOwnProperty;function assignValue(e,t,n){var r=e[t];Ze.call(e,t)&&eq(r,n)&&(void 0!==n||t in e)||baseAssignValue(e,t,n)}var $e=9007199254740991,Be=/^(?:0|[1-9]\d*)$/;function isIndex(e,t){var n=typeof e;return!!(t=null==t?$e:t)&&("number"==n||"symbol"!=n&&Be.test(e))&&e>-1&&e%1==0&&e<t}var Ye=Object.prototype.hasOwnProperty;function arrayLikeKeys(e,t){var n=Ie(e),r=!n&&Te(e),i=!n&&!r&&je(e),o=!n&&!r&&!i&&Xe(e),s=n||r||i||o,c=s?function baseTimes(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],d=c.length;for(var l in e)!t&&!Ye.call(e,l)||s&&("length"==l||i&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||isIndex(l,d))||c.push(l);return c}var Je=Object.prototype.hasOwnProperty;function baseKeysIn(e){if(!isObject(e))return function nativeKeysIn(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=isPrototype(e),n=[];for(var r in e)("constructor"!=r||!t&&Je.call(e,r))&&n.push(r);return n}function keysIn(e){return isArrayLike(e)?arrayLikeKeys(e,!0):baseKeysIn(e)}function toPlainObject(e){return function copyObject(e,t,n,r){var i=!n;n||(n={});for(var o=-1,s=t.length;++o<s;){var c=t[o],d=r?r(n[c],e[c],c,n,e):void 0;void 0===d&&(d=e[c]),i?baseAssignValue(n,c,d):assignValue(n,c,d)}return n}(e,keysIn(e))}function baseMergeDeep(e,t,n,r,i,o,s){var c=safeGet(e,n),d=safeGet(t,n),l=s.get(d);if(l)assignMergeValue(e,n,l);else{var u=o?o(c,d,n+"",e,t,s):void 0,h=void 0===u;if(h){var m=Ie(d),f=!m&&je(d),p=!m&&!f&&Xe(d);u=d,m||f||p?Ie(c)?u=c:!function isArrayLikeObject(e){return isObjectLike(e)&&isArrayLike(e)}(c)?f?(h=!1,u=function cloneBuffer(e,t){if(t)return e.slice();var n=e.length,r=ge?ge(n):new e.constructor(n);return e.copy(r),r}(d,!0)):p?(h=!1,u=cloneTypedArray(d,!0)):u=[]:u=function copyArray(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}(c):function isPlainObject(e){if(!isObjectLike(e)||baseGetTag(e)!=De)return!1;var t=we(e);if(null===t)return!0;var n=Ve.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Fe.call(n)==Pe}(d)||Te(d)?(u=c,Te(c)?u=toPlainObject(c):isObject(c)&&!isFunction(c)||(u=function initCloneObject(e){return"function"!=typeof e.constructor||isPrototype(e)?{}:_e(we(e))}(d))):h=!1}h&&(s.set(d,u),i(u,d,r,o,s),s.delete(d)),assignMergeValue(e,n,u)}}function baseMerge(e,t,n,r,i){e!==t&&me(t,(function(o,s){if(i||(i=new Stack),isObject(o))baseMergeDeep(e,t,s,n,baseMerge,r,i);else{var c=r?r(safeGet(e,s),o,s+"",e,t,i):void 0;void 0===c&&(c=o),assignMergeValue(e,s,c)}}),keysIn)}function identity(e){return e}var Ke=Math.max;var qe=ue?function(e,t){return ue(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:identity,Qe=Date.now;var et=function shortOut(e){var t=0,n=0;return function(){var r=Qe(),i=16-(r-n);if(n=r,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(qe);function baseRest(e,t){return et(function overRest(e,t,n){return t=Ke(void 0===t?e.length-1:t,0),function(){for(var r=arguments,i=-1,o=Ke(r.length-t,0),s=Array(o);++i<o;)s[i]=r[t+i];i=-1;for(var c=Array(t+1);++i<t;)c[i]=r[i];return c[t]=n(s),function apply(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}(e,this,c)}}(e,t,identity),e+"")}function createAssigner(e){return baseRest((function(t,n){var r=-1,i=n.length,o=i>1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,s&&function isIterateeCall(e,t,n){if(!isObject(n))return!1;var r=typeof t;return!!("number"==r?isArrayLike(n)&&isIndex(t,n.length):"string"==r&&t in n)&&eq(n[t],e)}(n[0],n[1],s)&&(o=i<3?void 0:o,i=1),t=Object(t);++r<i;){var c=n[r];c&&e(t,c,r,o)}return t}))}var tt=createAssigner((function(e,t,n){baseMerge(e,t,n)}));const nt={page:1,pageSize:10};class Media{constructor(e){this.stream=e}attachTo(e){if(!(e instanceof HTMLVideoElement))throw new TypeError("Failed to process - input must be a video element");e.srcObject=this.stream,e.autoplay=!0,e.muted=!0,e.playsInline=!0,e.controls=!1}}const rt=(()=>{const e={video:{frameRate:30,width:{min:640,ideal:1280,max:1280},height:{min:360,ideal:720,max:720}},audio:!0};return{getUserMedia:async(t={})=>{const n=await navigator.mediaDevices.getUserMedia({video:e.video,audio:e.audio,...t});return new Media(n)}}})();Object.freeze(rt);var it="3.4.0";function wait(e,t){return new Promise((function(n){return setTimeout(n,e,t)}))}function awaitIfAsync(e,t){try{var n=e();!function isPromise(e){return!!e&&"function"==typeof e.then}(n)?t(!0,n):n.then((function(e){return t(!0,e)}),(function(e){retur