// This is the minified and stringified code of the media-encoder-host-worker package. export const worker = `(()=>{var e={455(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),c=void 0===a?r.size:an)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(c);)c=Math.floor(Math.random()*n);return e(r,c)}},c=new WeakMap,i=r(c),d=a(i,c),l=t(d);e.addUniqueNumber=l,e.generateUniqueNumber=d}(t)}};const t={};function r(n){const o=t[n];if(void 0!==o)return o.exports;const s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";var e=r(455);const t=((e,t,r,n)=>o=>{const s=t(o);return t=>{const o=e(t);t.addEventListener("message",({data:e})=>{const{id:t}=e;if(null!==t&&o.has(t)){const{reject:r,resolve:n}=o.get(t);o.delete(t),void 0===e.error?n(e.result):r(new Error(e.error.message))}}),n(t)&&t.start();const a=(e,n=null,s=[])=>new Promise((a,c)=>{const i=r(o);o.set(i,{reject:c,resolve:a}),null===n?t.postMessage({id:i,method:e},s):t.postMessage({id:i,method:e,params:n},s)}),c=(e,r,n=[])=>{t.postMessage({id:null,method:e,params:r},n)};let i={};for(const[e,t]of Object.entries(s))i={...i,[e]:t({call:a,notify:c})};return{...i}}})((o=new WeakMap,e=>{if(o.has(e))return o.get(e);const t=new Map;return o.set(e,t),t}),(n=new WeakMap,e=>({...e,connect:({call:e})=>async()=>{const{port1:t,port2:r}=new MessageChannel,o=await e("connect",{port:t},[t]);return n.set(r,o),r},disconnect:({call:e})=>async t=>{const r=n.get(t);if(void 0===r)throw new Error("The given port is not connected.");await e("disconnect",{portId:r})},isSupported:({call:e})=>()=>e("isSupported")})),e.generateUniqueNumber,e=>"function"==typeof e.start);var n,o;const s=t({characterize:({call:e})=>()=>e("characterize"),encode:({call:e})=>(t,r)=>e("encode",{recordingId:t,timeslice:r}),record:({call:e})=>async(t,r,n)=>{await e("record",{recordingId:t,sampleRate:r,typedArrays:n},n.map(({buffer:e})=>e).filter(e=>e instanceof ArrayBuffer))}}),a=-32603,c=-32602,i=-32601,d=(e,t)=>Object.assign(new Error(e),{status:t}),l=e=>d('The handler of the method called "'.concat(e,'" returned an unexpected result.'),a),u=(e,t)=>async({data:{id:r,method:n,params:o}})=>{const s=t[n];try{if(void 0===s)throw(e=>d('The requested method called "'.concat(e,'" is not supported.'),i))(n);const t=void 0===o?s():s(o);if(void 0===t)throw(e=>d('The handler of the method called "'.concat(e,'" returned no required result.'),a))(n);const c=t instanceof Promise?await t:t;if(null===r){if(void 0!==c.result)throw l(n)}else{if(void 0===c.result)throw l(n);const{result:t,transferables:o=[]}=c;e.postMessage({id:r,result:t},o)}}catch(t){const{message:n,status:o=-32603}=t;e.postMessage({error:{code:o,message:n},id:r})}},h=new Map,f=(t,r,n)=>({...r,connect:({port:n})=>{n.start();const o=t(n,r),s=(0,e.generateUniqueNumber)(h);return h.set(s,()=>{o(),n.close(),h.delete(s)}),{result:s}},disconnect:({portId:e})=>{const t=h.get(e);if(void 0===t)throw(e=>d('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),c))(e);return t(),{result:null}},isSupported:async()=>{if(await new Promise(e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])})){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),w=(e,t,r=()=>!0)=>{const n=f(w,t,r),o=u(e,n);return e.addEventListener("message",o),()=>e.removeEventListener("message",o)},p=e=>{e.onmessage=null,e.close()},m=new Map,g=new Map,v=((e,t)=>r=>{const n=t.get(r);if(void 0===n)throw new Error("There was no encoder stored with the given id.");e.delete(n),t.delete(r)})(m,g),y=new Map,M=(e=>t=>{const r=e.get(t);if(void 0===r)throw new Error("There was no instance of an encoder stored with the given id.");return r})(y),E=((e,t)=>r=>{const n=t(r);return e.delete(r),n})(y,M),b=((e,t)=>r=>{const[n,o,s,a]=t(r);return s?new Promise(t=>{o.onmessage=({data:s})=>{0===s.length?(e(o),t(n.encode(r,null))):n.record(r,a,s)}}):n.encode(r,null)})(p,E),T=(e=>t=>{for(const[r,n]of Array.from(e.values()))if(r.test(t))return n;throw new Error("There is no encoder registered which could handle the given mimeType.")})(m),I=((e,t,r)=>(n,o,s)=>{if(t.has(n))throw new Error('There is already an encoder instance registered with an id called "'.concat(n,'".'));const a=r(o),{port1:c,port2:i}=new MessageChannel,d=[a,c,!0,s];return t.set(n,d),c.onmessage=({data:t})=>{0===t.length?(e(c),d[2]=!1):a.record(n,s,t.map(e=>"number"==typeof e?new Float32Array(e):e))},i})(p,y,T),A=((e,t,r)=>async(n,o)=>{const s=r(o),a=await s.characterize(),c=a.toString();if(e.has(c))throw new Error("There is already an encoder stored which handles exactly the same mime types.");if(t.has(n))throw new Error('There is already an encoder registered with an id called "'.concat(n,'".'));return e.set(c,[a,s]),t.set(n,c),a})(m,g,s),N=(e=>(t,r)=>{const[n]=e(t);return n.encode(t,r)})(M);w(self,{deregister:async({encoderId:e})=>(v(e),{result:null}),encode:async({encoderInstanceId:e,timeslice:t})=>{const r=null===t?await b(e):await N(e,t);return{result:r,transferables:r}},instantiate:({encoderInstanceId:e,mimeType:t,sampleRate:r})=>{const n=I(e,t,r);return{result:n,transferables:[n]}},register:async({encoderId:e,port:t})=>({result:await A(e,t)})})})()})();`; // tslint:disable-line:max-line-length