"use strict";Object.defineProperty(exports,"__esModule",{value:!0});let e=!0,t=!0;function n(e,t,n){const r=e.match(t);return r&&r.length>=n&&parseFloat(r[n],10)}function r(){if("object"==typeof window){if(e)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}}function o(e){return"[object Object]"===Object.prototype.toString.call(e)}function s(e,t,n){t&&!n.has(t.id)&&(n.set(t.id,t),Object.keys(t).forEach((r=>{r.endsWith("Id")?s(e,e.get(t[r]),n):r.endsWith("Ids")&&t[r].forEach((t=>{s(e,e.get(t),n)}))})))}exports.compactObject=function e(t){return o(t)?Object.keys(t).reduce((function(n,r){const s=o(t[r]),i=s?e(t[r]):t[r],a=s&&!Object.keys(i).length;return void 0===i||a?n:Object.assign(n,{[r]:i})}),{}):t},exports.deprecated=function(e,n){t&&console.warn(e+" is deprecated, please use "+n+" instead.")},exports.detectBrowser=function(e){const t={browser:null,version:null};if(void 0===e||!e.navigator||!e.navigator.userAgent)return t.browser="Not a browser.",t;const{navigator:r}=e;if(r.userAgentData&&r.userAgentData.brands){const e=r.userAgentData.brands.find((e=>"Chromium"===e.brand));if(e)return{browser:"chrome",version:parseInt(e.version,10)}}if(r.mozGetUserMedia)t.browser="firefox",t.version=parseInt(n(r.userAgent,/Firefox\/(\d+)\./,1));else if(r.webkitGetUserMedia||!1===e.isSecureContext&&e.webkitRTCPeerConnection)t.browser="chrome",t.version=parseInt(n(r.userAgent,/Chrom(e|ium)\/(\d+)\./,2))||null;else{if(!e.RTCPeerConnection||!r.userAgent.match(/AppleWebKit\/(\d+)\./))return t.browser="Not a supported browser.",t;t.browser="safari",t.version=parseInt(n(r.userAgent,/AppleWebKit\/(\d+)\./,1)),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&"currentDirection"in e.RTCRtpTransceiver.prototype,t._safariVersion=n(r.userAgent,/Version\/(\d+(\.?\d+))/,1)}return t},exports.disableLog=function(t){return"boolean"!=typeof t?new Error("Argument type: "+typeof t+". Please use a boolean."):(e=t,t?"adapter.js logging disabled":"adapter.js logging enabled")},exports.disableWarnings=function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(t=!e,"adapter.js deprecation warnings "+(e?"disabled":"enabled"))},exports.extractVersion=n,exports.filterStats=function(e,t,n){const r=n?"outbound-rtp":"inbound-rtp",o=new Map;if(null===t)return o;const i=[];return e.forEach((e=>{"track"===e.type&&e.trackIdentifier===t.id&&i.push(e)})),i.forEach((t=>{e.forEach((n=>{n.type===r&&n.trackId===t.id&&s(e,n,o)}))})),o},exports.log=r,exports.walkStats=s,exports.wrapPeerConnectionEvent=function(e,t,n){if(!e.RTCPeerConnection)return;if(!Object.getOwnPropertyDescriptor(EventTarget.prototype,"addEventListener").writable)return void r("Unable to polyfill events");const o=e.RTCPeerConnection.prototype,s=o.addEventListener;o.addEventListener=function(e,r){if(e!==t)return s.apply(this,arguments);const o=e=>{const t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,o),s.apply(this,[e,o])};const i=o.removeEventListener;o.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t])return i.apply(this,arguments);if(!this._eventMap[t].has(n))return i.apply(this,arguments);const r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),0===this._eventMap[t].size&&delete this._eventMap[t],0===Object.keys(this._eventMap).length&&delete this._eventMap,i.apply(this,[e,r])},Object.defineProperty(o,"on"+t,{get(){return this["_on"+t]},set(e){this["_on"+t]&&(this.removeEventListener(t,this["_on"+t]),delete this["_on"+t]),e&&this.addEventListener(t,this["_on"+t]=e)},enumerable:!0,configurable:!0})};
//# sourceMappingURL=utils.js.map
