text: !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("PhaserPluginDVR",[],t):"object"==typeof exports?exports.PhaserPluginDVR=t():e.PhaserPluginDVR=t()}(window,function(){return function(e){var t={};function i(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=e,i.c=t,i.d=function(e,t,o){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(i.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(o,n,function(t){return e[t]}.bind(null,n));return o},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=1)}([function(x,y){var z;z=function(){return this}();try{z=z||Function("return this")()||eval("this")}catch(e){"object"==typeof window&&(z=window)}x.exports=z},function(e,t,i){var o=i(2),n=i(3),a=function(e){this.scene=e,this.systems=e.sys,e.sys.settings.isBooted||e.sys.events.once("boot",this.boot,this)};a.register=function(e){e.register("PhaserPluginDVR",a,"dvr")},(a.prototype={boot:function(){var e=this.systems.events;e.on("start",this.start,this),e.on("preupdate",this.preUpdate,this),e.on("update",this.update,this),e.on("postupdate",this.postUpdate,this),e.on("pause",this.pause,this),e.on("resume",this.resume,this),e.on("sleep",this.sleep,this),e.on("wake",this.wake,this),e.on("shutdown",this.shutdown,this),e.on("destroy",this.destroy,this),console.log("PhaserPluginDVR booting")},recordTestClip:function(e){console.log(this.systems);var t=this.systems.canvas;console.log(t);var i=n(t,{type:"canvas",showMousePointer:!0});i.startRecording(),setTimeout(function(){i.stopRecording(function(e){var t=i.getBlob();console.log("blob",t);var o=document.createElement("video");o.src=URL.createObjectURL(t),o.setAttribute("style","height: 50%; position: absolute; top:0; right:0; opacity:85%; border:solid 1px gray;"),document.querySelector("body").appendChild(o),o.controls=!0,o.play()})},1e3*e)},startRecording:function(){console.log("PhaserPluginDVR start recording")},pauseRecording:function(){console.log("PhaserPluginDVR pause recording")},stopRecording:function(){console.log("PhaserPluginDVR stop recording")},getVideos:function(){console.log("PhaserPluginDVR return list of video links and metadata")},test:function(e){console.log("PhaserPluginDVR testing")},start:function(){var e=this;console.log("PhaserPluginDVR starting"),console.log("MediaStreamRecorder Init",o);var t=document.createElement("div");t.innerHTML="<p>Tap anywhere to float.</p></p>Tap here to record 10 seconds of Phaser output with PhaserPluginDVR.</p>",t.id="PhaserPluginDVRTransport",t.setAttribute("style","position:absolute; height:auto; width:150px; top:0; left:0; opacity:80%; color:red; background-color:lightgray; margin:10px;"),t.onclick=function(){e.recordTestClip(10),console.log("Started recording 10 second test clip.")},document.querySelector("body").appendChild(t)},preUpdate:function(e,t){},update:function(e,t){},postUpdate:function(e,t){},pause:function(){console.log("PhaserPluginDVR paused")},resume:function(){console.log("PhaserPluginDVR resumed")},sleep:function(){console.log("PhaserPluginDVR sleeping")},wake:function(){console.log("PhaserPluginDVR woke")},shutdown:function(){console.log("PhaserPluginDVR shutting down")},destroy:function(){console.log("PhaserPluginDVR destroying"),this.shutdown(),this.scene=void 0}}).constructor=a,e.exports=a},function(e,t,i){"use strict";(function(i){var o;function n(e){if(!e)throw"MediaStream is mandatory.";var t;this.start=function(i){var o;"undefined"!=typeof MediaRecorder?o=p:(h||u||c)&&(-1!==this.mimeType.indexOf("video")?o=w:-1!==this.mimeType.indexOf("audio")&&(o=v)),"image/gif"===this.mimeType&&(o=R),"audio/wav"!==this.mimeType&&"audio/pcm"!==this.mimeType||(o=v),this.recorderType&&(o=this.recorderType),(t=new o(e)).blobs=[];var n=this;t.ondataavailable=function(e){t.blobs.push(e),n.ondataavailable(e)},t.onstop=this.onstop,t.onStartedDrawingNonBlankFrames=this.onStartedDrawingNonBlankFrames,(t=function(e,t){for(var i in t)"function"!=typeof t[i]&&(e[i]=t[i]);return e}(t,this)).start(i)},this.onStartedDrawingNonBlankFrames=function(){},this.clearOldRecordedFrames=function(){t&&t.clearOldRecordedFrames()},this.stop=function(){t&&t.stop()},this.ondataavailable=function(e){this.disableLogs||console.log("ondataavailable..",e)},this.onstop=function(e){console.warn("stopped..",e)},this.save=function(e,i){if(e)l(e,i);else{if(!t)return;ConcatenateBlobs(t.blobs,t.blobs[0].type,function(e){l(e)})}},this.pause=function(){t&&(t.pause(),this.disableLogs||console.log("Paused recording.",this.mimeType||t.mimeType))},this.resume=function(){t&&(t.resume(),this.disableLogs||console.log("Resumed recording.",this.mimeType||t.mimeType))},this.recorderType=null,this.mimeType="video/webm",this.disableLogs=!1}void 0!==n&&(n.MultiStreamRecorder=function(e,t){(e=e||[])instanceof f&&(e=[e]);var i,o,a=this;(t=t||{mimeType:"video/webm",video:{width:360,height:240}}).frameInterval||(t.frameInterval=10),t.video||(t.video={}),t.video.width||(t.video.width=360),t.video.height||(t.video.height=240),this.start=function(r){var s;for(var d in i=new function(e){var t=[],i=!1,o=document.createElement("canvas"),n=o.getContext("2d");o.style="opacity:0;position:absolute;z-index:-1;top: -100000000;left:-1000000000; margin-top:-1000000000;margin-left:-1000000000;",(document.body||document.documentElement).appendChild(o),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0;var a=this,r=window.AudioContext;void 0===r&&("undefined"!=typeof webkitAudioContext&&(r=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(r=mozAudioContext));var s=window.URL;void 0===s&&"undefined"!=typeof webkitURL&&(s=webkitURL),"undefined"!=typeof navigator&&void 0===navigator.getUserMedia&&(void 0!==navigator.webkitGetUserMedia&&(navigator.getUserMedia=navigator.webkitGetUserMedia),void 0!==navigator.mozGetUserMedia&&(navigator.getUserMedia=navigator.mozGetUserMedia));var d=window.MediaStream;void 0===d&&"undefined"!=typeof webkitMediaStream&&(d=webkitMediaStream),void 0!==d&&("getVideoTracks"in d.prototype||(d.prototype.getVideoTracks=function(){if(!this.getTracks)return[];var e=[];return this.getTracks.forEach(function(t){-1!==t.kind.toString().indexOf("video")&&e.push(t)}),e},d.prototype.getAudioTracks=function(){if(!this.getTracks)return[];var e=[];return this.getTracks.forEach(function(t){-1!==t.kind.toString().indexOf("audio")&&e.push(t)}),e}),void 0===d.prototype.stop&&(d.prototype.stop=function(){this.getTracks().forEach(function(e){e.stop()})}));var c={};function u(){if(!i){var e=t.length,n=!1,r=[];t.forEach(function(e){e.stream||(e.stream={}),e.stream.fullcanvas?n=e:r.push(e)}),n?(o.width=n.stream.width,o.height=n.stream.height):r.length?(o.width=1<e?2*r[0].width:r[0].width,o.height=2<e?2*r[0].height:r[0].height):(o.width=a.width||360,o.height=a.height||240),n&&n instanceof HTMLVideoElement&&h(n),r.forEach(function(e,t){h(e,t)}),setTimeout(u,a.frameInterval)}}function h(e,t){if(!i){var o=0,a=0,r=e.width,s=e.height;1===t&&(o=e.width),2===t&&(a=e.height),3===t&&(o=e.width,a=e.height),void 0!==e.stream.left&&(o=e.stream.left),void 0!==e.stream.top&&(a=e.stream.top),void 0!==e.stream.width&&(r=e.stream.width),void 0!==e.stream.height&&(s=e.stream.height),n.drawImage(e,o,a,r,s),"function"==typeof e.stream.onRender&&e.stream.onRender(n,o,a,r,s,t)}}function f(e){var t=document.createElement("video");return"srcObject"in t?t.srcObject=e:t.src=s.createObjectURL(e),t.muted=!0,t.volume=0,t.width=e.width||a.width||360,t.height=e.height||a.height||240,t.play(),t}function l(i){t=[],(i=i||e).forEach(function(e){if(e.getVideoTracks().length){var i=f(e);i.stream=e,t.push(i)}})}void 0!==r?c.AudioContext=r:"undefined"!=typeof webkitAudioContext&&(c.AudioContext=webkitAudioContext),this.startDrawingFrames=function(){u()},this.appendStreams=function(i){if(!i)throw"First parameter is required.";i instanceof Array||(i=[i]),e.concat(i),i.forEach(function(e){if(e.getVideoTracks().length){var i=f(e);i.stream=e,t.push(i)}if(e.getAudioTracks().length&&a.audioContext){var o=a.audioContext.createMediaStreamSource(e);o.connect(a.audioDestination),a.audioSources.push(o)}})},this.releaseStreams=function(){t=[],i=!0,a.gainNode&&(a.gainNode.disconnect(),a.gainNode=null),a.audioSources.length&&(a.audioSources.forEach(function(e){e.disconnect()}),a.audioSources=[]),a.audioDestination&&(a.audioDestination.disconnect(),a.audioDestination=null),a.audioContext=null,n.clearRect(0,0,o.width,o.height),o.stream&&(o.stream.stop(),o.stream=null)},this.resetVideoStreams=function(e){!e||e instanceof Array||(e=[e]),l(e)},this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=function(){i=!1;var t=function(){var e;l(),"captureStream"in o?e=o.captureStream():"mozCaptureStream"in o?e=o.mozCaptureStream():a.disableLogs||console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");var t=new d;return e.getVideoTracks().forEach(function(e){t.addTrack(e)}),o.stream=t}(),n=function(){c.AudioContextConstructor||(c.AudioContextConstructor=new c.AudioContext),a.audioContext=c.AudioContextConstructor,a.audioSources=[],!0===a.useGainNode&&(a.gainNode=a.audioContext.createGain(),a.gainNode.connect(a.audioContext.destination),a.gainNode.gain.value=0);var t=0;return e.forEach(function(e){if(e.getAudioTracks().length){t++;var i=a.audioContext.createMediaStreamSource(e);!0===a.useGainNode&&i.connect(a.gainNode),a.audioSources.push(i)}}),t?(a.audioDestination=a.audioContext.createMediaStreamDestination(),a.audioSources.forEach(function(e){e.connect(a.audioDestination)}),a.audioDestination.stream):void 0}();return n&&n.getAudioTracks().forEach(function(e){t.addTrack(e)}),e.forEach(function(e){e.fullcanvas}),t}}(e),(s=[],e.forEach(function(e){e.getVideoTracks().forEach(function(e){s.push(e)})}),s).length&&(i.frameInterval=t.frameInterval||10,i.width=t.video.width||360,i.height=t.video.height||240,i.startDrawingFrames()),"function"==typeof a.previewStream&&a.previewStream(i.getMixedStream()),o=new n(i.getMixedStream()),a)"function"!=typeof a[d]&&(o[d]=a[d]);o.ondataavailable=function(e){a.ondataavailable(e)},o.onstop=a.onstop,o.start(r)},this.stop=function(e){o&&o.stop(function(t){e(t)})},this.pause=function(){o&&o.pause()},this.resume=function(){o&&o.resume()},this.clearRecordedData=function(){o&&(o.clearRecordedData(),o=null),i&&(i.releaseStreams(),i=null)},this.addStreams=this.addStream=function(t){if(!t)throw"First parameter is required.";t instanceof Array||(t=[t]),e.concat(t),o&&i&&i.appendStreams(t)},this.resetVideoStreams=function(e){i&&(!e||e instanceof Array||(e=[e]),i.resetVideoStreams(e))},this.ondataavailable=function(e){a.disableLogs||console.log("ondataavailable",e)},this.onstop=function(){},this.name="MultiStreamRecorder",this.toString=function(){return this.name}});var a,r,s="Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45";a=void 0!==i?i:window,"undefined"==typeof window&&("undefined"==typeof window&&void 0!==i&&(i.navigator={userAgent:s,getUserMedia:function(){}},a.window=i),"undefined"==typeof document&&(a.document={},document.createElement=document.captureStream=document.mozCaptureStream=function(){return{}}),"undefined"==typeof location&&(a.location={protocol:"file:",href:"",hash:""}),"undefined"==typeof screen&&(a.screen={width:0,height:0})),void 0===(r=window.AudioContext)&&("undefined"!=typeof webkitAudioContext&&(r=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(r=mozAudioContext)),"undefined"==typeof window&&(window={}),void 0===(r=window.AudioContext)&&("undefined"!=typeof webkitAudioContext&&(r=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(r=mozAudioContext));var d=window.URL;void 0===d&&"undefined"!=typeof webkitURL&&(d=webkitURL),"undefined"!=typeof navigator?(void 0!==navigator.webkitGetUserMedia&&(navigator.getUserMedia=navigator.webkitGetUserMedia),void 0!==navigator.mozGetUserMedia&&(navigator.getUserMedia=navigator.mozGetUserMedia)):navigator={getUserMedia:function(){},userAgent:s};var c=!(-1===navigator.userAgent.indexOf("Edge")||!navigator.msSaveBlob&&!navigator.msSaveOrOpenBlob),u=!1;"undefined"!=typeof opera&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("OPR/")&&(u=!0);var h=!c&&!c&&!!navigator.webkitGetUserMedia,f=window.MediaStream;function l(e,t){if(!e)throw"Blob object is required.";if(!e.type)try{e.type="video/webm"}catch(e){}var i=(e.type||"video/webm").split("/")[1];if(t&&-1!==t.indexOf(".")){var o=t.split(".");t=o[0],i=o[1]}var n=(t||Math.round(9999999999*Math.random())+888888888)+"."+i;if(void 0!==navigator.msSaveOrOpenBlob)return navigator.msSaveOrOpenBlob(e,n);if(void 0!==navigator.msSaveBlob)return navigator.msSaveBlob(e,n);var a=document.createElement("a");a.href=d.createObjectURL(e),a.target="_blank",a.download=n,navigator.mozGetUserMedia&&(a.onclick=function(){(document.body||document.documentElement).removeChild(a)},(document.body||document.documentElement).appendChild(a));var r=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0});a.dispatchEvent(r),navigator.mozGetUserMedia||d.revokeObjectURL(a.href)}function g(e){if(0===e)return"0 Bytes";var t=parseInt(Math.floor(Math.log(e)/Math.log(1e3)),10);return(e/Math.pow(1e3,t)).toPrecision(3)+" "+["Bytes","KB","MB","GB","TB"][t]}void 0===f&&"undefined"!=typeof webkitMediaStream&&(f=webkitMediaStream),void 0!==f&&("getVideoTracks"in f.prototype||(f.prototype.getVideoTracks=function(){if(!this.getTracks)return[];var e=[];return this.getTracks.forEach(function(t){-1!==t.kind.toString().indexOf("video")&&e.push(t)}),e},f.prototype.getAudioTracks=function(){if(!this.getTracks)return[];var e=[];return this.getTracks.forEach(function(t){-1!==t.kind.toString().indexOf("audio")&&e.push(t)}),e}),"stop"in f.prototype||(f.prototype.stop=function(){this.getAudioTracks().forEach(function(e){e.stop&&e.stop()}),this.getVideoTracks().forEach(function(e){e.stop&&e.stop()})})),"undefined"!=typeof location&&0===location.href.indexOf("file:")&&console.error("Please load this HTML file on HTTP or HTTPS.");var m={AudioContext:r};function p(e){var t,i=this;this.start=function(o,n){var a;this.timeSlice=o||5e3,i.mimeType||(i.mimeType="video/webm"),-1!==i.mimeType.indexOf("audio")&&e.getVideoTracks().length&&e.getAudioTracks().length&&(navigator.mozGetUserMedia?(a=new f).addTrack(e.getAudioTracks()[0]):a=new f(e.getAudioTracks()),e=a),-1!==i.mimeType.indexOf("audio")&&(i.mimeType=h?"audio/webm":"audio/ogg"),i.dontFireOnDataAvailableEvent=!1;var r={mimeType:i.mimeType};i.disableLogs||n||console.log("Passing following params over MediaRecorder API.",r),t&&(t=null),h&&!function(){var e=!!window.opera||0<=navigator.userAgent.indexOf(" OPR/"),t=!!window.chrome&&!e;if(void 0!==window.InstallTrigger)return!0;if(!t)return!1;navigator.appVersion;var i,o,n=navigator.userAgent,a=""+parseFloat(navigator.appVersion),r=parseInt(navigator.appVersion,10);return t&&(i=n.indexOf("Chrome"),a=n.substring(i+7)),-1!==(o=a.indexOf(";"))&&(a=a.substring(0,o)),-1!==(o=a.indexOf(" "))&&(a=a.substring(0,o)),r=parseInt(""+a,10),isNaN(r)&&(a=""+parseFloat(navigator.appVersion),r=parseInt(navigator.appVersion,10)),49<=r}()&&(r="video/vp8");try{t=new MediaRecorder(e,r)}catch(n){t=new MediaRecorder(e)}"canRecordMimeType"in t&&!1===t.canRecordMimeType(i.mimeType)&&(i.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",i.mimeType)),!0===i.ignoreMutedMedia&&(t.ignoreMutedMedia=!0);var s=!1;t.ondataavailable=function(e){if(e.data&&e.data.size&&!(e.data.size<26800)&&!s){s=!0;var n=i.getNativeBlob?e.data:new Blob([e.data],{type:i.mimeType||"video/webm"});i.ondataavailable(n),t&&"recording"===t.state&&t.stop(),t=null,i.dontFireOnDataAvailableEvent||i.start(o,"__disableLogs")}},t.onerror=function(e){i.disableLogs||("InvalidState"===e.name?console.error("The MediaRecorder is not in a state in which the proposed operation is allowed to be executed."):"OutOfMemory"===e.name?console.error("The UA has exhaused the available memory. User agents SHOULD provide as much additional information as possible in the message attribute."):"IllegalStreamModification"===e.name?console.error("A modification to the stream has occurred that makes it impossible to continue recording. An example would be the addition of a Track while recording is occurring. User agents SHOULD provide as much additional information as possible in the message attribute."):"OtherRecordingError"===e.name?console.error("Used for an fatal error other than those listed above. User agents SHOULD provide as much additional information as possible in the message attribute."):"GenericError"===e.name?console.error("The UA cannot provide the codec or recording option that has been requested.",e):console.error("MediaRecorder Error",e)),t&&"inactive"!==t.state&&"stopped"!==t.state&&t.stop()};try{t.start(36e5)}catch(n){t=null}setTimeout(function(){t&&"recording"===t.state&&t.requestData()},o)},this.stop=function(e){t&&"recording"===t.state&&(t.requestData(),setTimeout(function(){i.dontFireOnDataAvailableEvent=!0,t&&"recording"===t.state&&t.stop(),t=null,i.onstop()},2e3))},this.pause=function(){t&&("recording"===t.state&&t.pause(),this.dontFireOnDataAvailableEvent=!0)},this.ondataavailable=function(e){console.log("recorded-blob",e)},this.resume=function(){if(this.dontFireOnDataAvailableEvent){this.dontFireOnDataAvailableEvent=!1;var e=i.disableLogs;return i.disableLogs=!0,this.start(this.timeslice||5e3),void(i.disableLogs=e)}t&&"paused"===t.state&&t.resume()},this.clearRecordedData=function(){t&&(this.pause(),this.dontFireOnDataAvailableEvent=!0,this.stop())},this.onstop=function(){},function o(){t&&(!1!==function(){if("active"in e){if(!e.active)return!1}else if("ended"in e&&e.ended)return!1;return!0}()?setTimeout(o,1e3):i.stop())}()}function v(e){var t,i;this.start=function(o){o=o||1e3,(t=new b(e,this)).record(),i=setInterval(function(){t.requestData()},o)},this.stop=function(){t&&(t.stop(),clearTimeout(i),this.onstop())},this.pause=function(){t&&t.pause()},this.resume=function(){t&&t.resume()},this.ondataavailable=function(){},this.onstop=function(){}}function b(e,t){var i;m.AudioContextConstructor||(m.AudioContextConstructor=new m.AudioContext),i=m.AudioContextConstructor.sampleRate;var o,n=[],a=[],r=!1,s=0,d=t.sampleRate||i,c=-1<(t.mimeType||"audio/wav").indexOf("audio/pcm"),u=t.audioChannels||2;function h(e,t){for(var i=new Float32Array(t),o=0,n=e.length,a=0;a<n;a++){var r=e[a];i.set(r,o),o+=r.length}return i}function f(e,t,i){for(var o=i.length,n=0;n<o;n++)e.setUint8(t+n,i.charCodeAt(n))}this.record=function(){r=!0,n.length=a.length=0,s=0},this.requestData=function(){if(!y)if(0!==s){w=!0;var e=n.slice(0),i=a.slice(0),o=s;n.length=a.length=[],s=0,w=!1;var r=h(e,o),l=r;if(2===u&&(l=function(e,t){for(var i=e.length+t.length,o=new Float32Array(i),n=0,a=0;a<i;)o[a++]=e[n],o[a++]=t[n],n++;return o}(r,h(i,o))),c){var m=new Blob([function(e){for(var t=e.length,i=new Int16Array(t);t--;)i[t]=65535*e[t];return i.buffer}(l)],{type:"audio/pcm"});return console.debug("audio recorded blob size:",g(m.size)),void t.ondataavailable(m)}var p=new ArrayBuffer(44+2*l.length),v=new DataView(p);f(v,0,"RIFF"),v.setUint32(4,44+2*l.length-8,!0),f(v,8,"WAVE"),f(v,12,"fmt "),v.setUint32(16,16,!0),v.setUint16(20,1,!0),v.setUint16(22,u,!0),v.setUint32(24,d,!0),v.setUint32(28,d*u*2,!0),v.setUint16(32,2*u,!0),v.setUint16(34,16,!0),f(v,36,"data"),v.setUint32(40,2*l.length,!0);for(var b=l.length,R=44,T=0;T<b;T++)v.setInt16(R,32767*l[T],!0),R+=2;m=new Blob([v],{type:"audio/wav"}),console.debug("audio recorded blob size:",g(m.size)),t.ondataavailable(m)}else w=!1},this.stop=function(){r=!1,this.requestData(),p.disconnect(),this.onstop()};var l=m.AudioContextConstructor;m.VolumeGainNode=l.createGain();var p,v=m.VolumeGainNode;m.AudioInput=l.createMediaStreamSource(e),(p=m.AudioInput).connect(v);var b=t.bufferSize||2048;if(0===t.bufferSize&&(b=0),l.createJavaScriptNode)o=l.createJavaScriptNode(b,u,u);else{if(!l.createScriptProcessor)throw"WebAudio API has no support on this browser.";o=l.createScriptProcessor(b,u,u)}b=o.bufferSize,console.debug("using audio buffer-size:",b);var w=!1;window.scriptprocessornode=o,1===u&&console.debug("All right-channels are skipped.");var y=!1;this.pause=function(){y=!0},this.resume=function(){y=!1},this.onstop=function(){},o.onaudioprocess=function(e){if(r&&!w&&!y){var t=e.inputBuffer.getChannelData(0);if(n.push(new Float32Array(t)),2===u){var i=e.inputBuffer.getChannelData(1);a.push(new Float32Array(i))}s+=b}},v.connect(o),o.connect(l.destination)}function w(e){var t,i;this.start=function(o){for(var n in o=o||1e3,t=new y(e,this),this)"function"!=typeof this[n]&&(t[n]=this[n]);t.record(),i=setInterval(function(){t.requestData()},o)},this.stop=function(){t&&(t.stop(),clearTimeout(i),this.onstop())},this.onstop=function(){},this.clearOldRecordedFrames=function(){t&&t.clearOldRecordedFrames()},this.pause=function(){t&&t.pause()},this.resume=function(){t&&t.resume()},this.ondataavailable=function(){}}function y(e,t){this.record=function(i){this.width||(this.width=320),this.height||(this.height=240),this.video&&this.video instanceof HTMLVideoElement&&(this.width||(this.width=r.videoWidth||r.clientWidth||320),this.height||(this.height=r.videoHeight||r.clientHeight||240)),this.video||(this.video={width:this.width,height:this.height}),this.canvas&&this.canvas.width&&this.canvas.height||(this.canvas={width:this.width,height:this.height}),u.width=this.canvas.width,u.height=this.canvas.height,this.video&&this.video instanceof HTMLVideoElement?(this.isHTMLObject=!0,r=this.video.cloneNode()):((r=document.createElement("video")).src=d.createObjectURL(e),r.width=this.video.width,r.height=this.video.height),r.muted=!0,r.play(),s=(new Date).getTime(),c=new T.Video(t.speed,t.quality),console.log("canvas resolutions",u.width,"*",u.height),console.log("video width/height",r.width||u.width,"*",r.height||u.height),n()};var i=!(this.clearOldRecordedFrames=function(){c.frames=[]}),o=!(this.requestData=function(){if(!l)if(c.frames.length){i=!0;var e=c.frames.slice(0);c.frames=function(e,t,i,o){var n=document.createElement("canvas");n.width=u.width,n.height=u.height;for(var a=n.getContext("2d"),r=[],s=e.length,d={r:0,g:0,b:0},c=Math.sqrt(Math.pow(255,2)+Math.pow(255,2)+Math.pow(255,2)),h=!1,f=0;f<s;f++){var l,g,m;if(!h){var p=new Image;p.src=e[f].image,a.drawImage(p,0,0,u.width,u.height);var v=a.getImageData(0,0,u.width,u.height);l=0,g=v.data.length,m=v.data.length/4;for(var b=0;b<g;b+=4){var w={r:v.data[b],g:v.data[b+1],b:v.data[b+2]};Math.sqrt(Math.pow(w.r-d.r,2)+Math.pow(w.g-d.g,2)+Math.pow(w.b-d.b,2))<=0*c&&l++}}!h&&m-l<=0*m||(h=!0,r.push(e[f]))}return(r=r.concat(e.slice(s))).length<=0&&r.push(e[e.length-1]),r}(e),c.compile(function(e){t.ondataavailable(e),console.debug("video recorded blob size:",g(e.size))}),c.frames=[],i=!1}else i=!1});function n(){if(l)return s=(new Date).getTime(),void setTimeout(n,500);if(!a){if(i)return setTimeout(n,100);var e=(new Date).getTime()-s;if(!e)return n();s=(new Date).getTime(),!f.isHTMLObject&&r.paused&&r.play(),h.drawImage(r,0,0,u.width,u.height),a||c.frames.push({duration:e,image:u.toDataURL("image/webp")}),o||function(e,t,i){var o=document.createElement("canvas");o.width=u.width,o.height=u.height;var n,a,r,s=o.getContext("2d"),d=0,c=0,h=0,f=Math.sqrt(Math.pow(255,2)+Math.pow(255,2)+Math.pow(255,2)),l=new Image;l.src=e.image,s.drawImage(l,0,0,u.width,u.height);var g=s.getImageData(0,0,u.width,u.height);n=0,a=g.data.length,r=g.data.length/4;for(var m=0;m<a;m+=4){var p={r:g.data[m],g:g.data[m+1],b:g.data[m+2]};Math.sqrt(Math.pow(p.r-d,2)+Math.pow(p.g-c,2)+Math.pow(p.b-h,2))<=0*f&&n++}return!(r-n<=0*r)}(c.frames[c.frames.length-1])||(o=!0,t.onStartedDrawingNonBlankFrames()),setTimeout(n,10)}}var a=!1;this.stop=function(){a=!0,this.requestData(),this.onstop()};var r,s,c,u=document.createElement("canvas"),h=u.getContext("2d"),f=this,l=!1;this.pause=function(){l=!0},this.resume=function(){l=!1},this.onstop=function(){}}function R(e){if("undefined"==typeof GIFEncoder)throw"Please link: https://cdn.webrtc-experiment.com/gif-recorder.js";function t(){Date.now();var e=new Blob([new Uint8Array(c.stream().bin)],{type:"image/gif"});o.ondataavailable(e),c.stream().bin=[]}this.start=function(e){e=e||1e3;var o=this.videoWidth||320,d=this.videoHeight||240;n.width=r.width=o,n.height=r.height=d,(c=new GIFEncoder).setRepeat(0),c.setDelay(this.frameRate||this.speed||200),c.setQuality(this.quality||1),c.start(),Date.now(),h=requestAnimationFrame(function e(t){i?setTimeout(e,500,t):(h=requestAnimationFrame(e),void 0===typeof s&&(s=t),t-s<90||(r.paused&&r.play(),a.drawImage(r,0,0,o,d),c.addFrame(a),s=t))}),u=setTimeout(t,e)},this.stop=function(){h&&(cancelAnimationFrame(h),clearTimeout(u),t(),this.onstop())};var i=!(this.onstop=function(){});this.pause=function(){i=!0},this.resume=function(){i=!1},this.ondataavailable=function(){},this.onstop=function(){};var o=this,n=document.createElement("canvas"),a=n.getContext("2d"),r=document.createElement("video");r.muted=!0,r.autoplay=!0,r.src=d.createObjectURL(e),r.play();var s,c,u,h=null}void 0!==n&&(n.MediaRecorderWrapper=p),void 0!==n&&(n.StereoAudioRecorder=v),void 0!==n&&(n.StereoAudioRecorderHelper=b),void 0!==n&&(n.WhammyRecorder=w),void 0!==n&&(n.WhammyRecorderHelper=y),void 0!==n&&(n.GifRecorder=R);var T=function(){function e(e,t){this.frames=[],e||(e=1),this.duration=1e3/e,this.quality=t||.8}function t(e){function t(e,t,i){return[{data:e,id:231}].concat(i.map(function(e){var i=function(e){var t=0;if(e.keyframe&&(t|=128),e.invisible&&(t|=8),e.lacing&&(t|=e.lacing<<1),e.discardable&&(t|=1),127<e.trackNum)throw"TrackNumber > 127 not supported";return[128|e.trackNum,e.timecode>>8,255&e.timecode,t].map(function(e){return String.fromCharCode(e)}).join("")+e.frame}({discardable:0,frame:e.data.slice(4),invisible:0,keyframe:1,lacing:0,trackNum:1,timecode:Math.round(t)});return t+=e.duration,{data:i,id:163}}))}function i(e){for(var t=[];0<e;)t.push(255&e),e>>=8;return new Uint8Array(t.reverse())}function o(e){var t=[];e=(e.length%8?new Array(9-e.length%8).join("0"):"")+e;for(var i=0;i<e.length;i+=8)t.push(parseInt(e.substr(i,8),2));return new Uint8Array(t)}var n=new function(e){var n=function(e){if(e[0]){for(var t=e[0].width,i=e[0].height,o=e[0].duration,n=1;n<e.length;n++)o+=e[n].duration;return{duration:o,width:t,height:i}}postMessage({error:"Something went wrong. Maybe WebP format is not supported in the current browser."})}(e);if(!n)return[];for(var a,r=[{id:440786851,data:[{data:1,id:17030},{data:1,id:17143},{data:4,id:17138},{data:8,id:17139},{data:"webm",id:17026},{data:2,id:17031},{data:2,id:17029}]},{id:408125543,data:[{id:357149030,data:[{data:1e6,id:2807729},{data:"whammy",id:19840},{data:"whammy",id:22337},{data:(a=n.duration,[].slice.call(new Uint8Array(new Float64Array([a]).buffer),0).map(function(e){return String.fromCharCode(e)}).reverse().join("")),id:17545}]},{id:374648427,data:[{id:174,data:[{data:1,id:215},{data:1,id:29637},{data:0,id:156},{data:"und",id:2274716},{data:"V_VP8",id:134},{data:"VP8",id:2459272},{data:1,id:131},{id:224,data:[{data:n.width,id:176},{data:n.height,id:186}]}]}]}]}],s=0,d=0;s<e.length;){for(var c=[],u=0;c.push(e[s]),u+=e[s].duration,++s<e.length&&u<3e4;);var h={id:524531317,data:t(d,0,c)};r[1].data.push(h),d+=u}return function e(t){for(var n=[],a=0;a<t.length;a++){var r=t[a].data;"object"==typeof r&&(r=e(r)),"number"==typeof r&&(r=o(r.toString(2))),"string"==typeof r&&(r=new Uint8Array(r.split("").map(function(e){return e.charCodeAt(0)})));var s=r.size||r.byteLength||r.length,d=Math.ceil(Math.ceil(Math.log(s)/Math.log(2))/8),c=s.toString(2),u=new Array(7*d+7+1-c.length).join("0")+c,h=new Array(d).join("0")+"1"+u;n.push(i(t[a].id)),n.push(o(h)),n.push(r)}return new Blob(n,{type:"video/webm"})}(r)}(e.map(function(e){var t=function(e){for(var t=e.RIFF[0].WEBP[0],i=t.indexOf("*"),o=0,n=[];o<4;o++)n[o]=t.charCodeAt(i+3+o);return{width:16383&(n[1]<<8|n[0]),height:16383&(n[3]<<8|n[2]),data:t,riff:e}}(function e(t){for(var i,o=0,n={};o<t.length;){var a=t.substr(o,4),r=(i=o,parseInt(t.substr(i+4,4).split("").map(function(e){var t=e.charCodeAt(0).toString(2);return new Array(8-t.length+1).join("0")+t}).join(""),2)),s=t.substr(o+4+4,r);o+=8+r,n[a]=n[a]||[],"RIFF"===a||"LIST"===a?n[a].push(e(s)):n[a].push(s)}return n}(atob(e.image.slice(23))));return t.duration=e.duration,t}));postMessage(n)}return e.prototype.add=function(e,t){if("canvas"in e&&(e=e.canvas),"toDataURL"in e&&(e=e.toDataURL("image/webp",this.quality)),!/^data:image\/webp;base64,/gi.test(e))throw"Input must be formatted properly as a base64 encoded DataURI of type image/webp";this.frames.push({image:e,duration:t||this.duration})},e.prototype.compile=function(e){var i,o,n,a=(i=t,o=d.createObjectURL(new Blob([i.toString(),"this.onmessage =  function (e) {"+i.name+"(e.data);}"],{type:"application/javascript"})),n=new Worker(o),d.revokeObjectURL(o),n);a.onmessage=function(t){t.data.error?console.error(t.data.error):e(t.data)},a.postMessage(this.frames)},{Video:e}}();void 0!==n&&(n.Whammy=T),window.ConcatenateBlobs=function(e,t,i){var o=[],n=0;!function a(){if(!e[n])return function(){var e=0;o.forEach(function(t){e+=t.byteLength});var n=new Uint16Array(e),a=0;o.forEach(function(e){var t=e.byteLength;t%2!=0&&(e=e.slice(0,t-1)),n.set(new Uint16Array(e),a),a+=t});var r=new Blob([n.buffer],{type:t});i(r)}();var r=new FileReader;r.onload=function(e){o.push(e.target.result),n++,a()},r.readAsArrayBuffer(e[n])}()},e.exports=n,void 0===(o=function(){return n}.apply(t,[]))||(e.exports=o),e.exports=n}).call(this,i(0))},function(e,t,i){"use strict";(function(i,o){var n,a;function r(e,t){if(!e)throw"First parameter is required.";var i=this;function o(i){i&&(t.initCallback=function(){i(),i=t.initCallback=null});var o=new d(e,t);(f=new o(e,t)).record(),h("recording"),t.disableLogs||console.log("Initialized recorderType:",f.constructor.name,"for output-type:",t.type)}function n(e){if(e=e||function(){},f){if("paused"===i.state)return i.resumeRecording(),void setTimeout(function(){n(e)},1);"recording"===i.state||t.disableLogs||console.warn('Recording state should be: "recording", however current state is: ',i.state),t.disableLogs||console.log("Stopped recording "+t.type+" stream."),"gif"!==t.type?f.stop(o):(f.stop(),o()),h("stopped")}else m();function o(o){if(f){Object.keys(f).forEach(function(e){"function"!=typeof f[e]&&(i[e]=f[e])});var n=f.blob;if(!n){if(!o)throw"Recording failed.";f.blob=n=o}if(n&&!t.disableLogs&&console.log(n.type,"->",w(n.size)),e){var a=g.createObjectURL(n);"function"==typeof e.call?e.call(i,a):e(a)}t.autoWriteToDisk&&c(function(e){var i={};i[t.type+"Blob"]=e,x.Store(i)})}else"function"==typeof e.call?e.call(i,""):e("")}}function a(e){postMessage((new FileReaderSync).readAsDataURL(e))}function c(e,i){if(!e)throw"Pass a callback function over getDataURL.";var o,n,r,s=i?i.blob:(f||{}).blob;if(!s)return t.disableLogs||console.warn("Blob encoder did not finish its job yet."),void setTimeout(function(){c(e,i)},1e3);if("undefined"==typeof Worker||navigator.mozGetUserMedia){var d=new FileReader;d.readAsDataURL(s),d.onload=function(t){e(t.target.result)}}else{var u=(o=a,n=g.createObjectURL(new Blob([o.toString(),"this.onmessage =  function (eee) {"+o.name+"(eee.data);}"],{type:"application/javascript"})),r=new Worker(n),g.revokeObjectURL(n),r);u.onmessage=function(t){e(t.data)},u.postMessage(s)}}function u(e){e=e||0,"paused"!==i.state?"stopped"!==i.state&&(e>=i.recordingDuration?n(i.onRecordingStopped):(e+=1e3,setTimeout(function(){u(e)},1e3))):setTimeout(function(){u(e)},1e3)}function h(e){i&&(i.state=e,"function"==typeof i.onStateChanged.call?i.onStateChanged.call(i,e):i.onStateChanged(e))}var f,l='It seems that recorder is destroyed or "startRecording" is not invoked for '+(t=new s(e,t=t||{type:"video"})).type+" recorder.";function m(){!0!==t.disableLogs&&console.warn(l)}var p={startRecording:function(n){return n&&(t=new s(e,n)),t.disableLogs||console.log("started recording "+t.type+" stream."),f?(f.clearRecordedData(),f.record(),h("recording"),i.recordingDuration&&u()):o(function(){i.recordingDuration&&u()}),i},stopRecording:n,pauseRecording:function(){f?"recording"===i.state?(h("paused"),f.pause(),t.disableLogs||console.log("Paused recording.")):t.disableLogs||console.warn("Unable to pause the recording. Recording state: ",i.state):m()},resumeRecording:function(){f?"paused"===i.state?(h("recording"),f.resume(),t.disableLogs||console.log("Resumed recording.")):t.disableLogs||console.warn("Unable to resume the recording. Recording state: ",i.state):m()},initRecorder:o,setRecordingDuration:function(e,t){if(void 0===e)throw"recordingDuration is required.";if("number"!=typeof e)throw"recordingDuration must be a number.";return i.recordingDuration=e,i.onRecordingStopped=t||function(){},{onRecordingStopped:function(e){i.onRecordingStopped=e}}},clearRecordedData:function(){f?(f.clearRecordedData(),t.disableLogs||console.log("Cleared old recorded data.")):m()},getBlob:function(){if(f)return f.blob;m()},getDataURL:c,toURL:function(){if(f)return g.createObjectURL(f.blob);m()},getInternalRecorder:function(){return f},save:function(e){f?function(e,t){if(!e)throw"Blob object is required.";if(!e.type)try{e.type="video/webm"}catch(e){}var i=(e.type||"video/webm").split("/")[1];if(t&&-1!==t.indexOf(".")){var o=t.split(".");t=o[0],i=o[1]}var n=(t||Math.round(9999999999*Math.random())+888888888)+"."+i;if(void 0!==navigator.msSaveOrOpenBlob)return navigator.msSaveOrOpenBlob(e,n);if(void 0!==navigator.msSaveBlob)return navigator.msSaveBlob(e,n);var a=document.createElement("a");a.href=g.createObjectURL(e),a.download=n,a.style="display:none;opacity:0;color:transparent;",(document.body||document.documentElement).appendChild(a),"function"==typeof a.click?a.click():(a.target="_blank",a.dispatchEvent(new MouseEvent("click",{view:window,bubbles:!0,cancelable:!0}))),g.revokeObjectURL(a.href)}(f.blob,e):m()},getFromDisk:function(e){f?r.getFromDisk(t.type,e):m()},setAdvertisementArray:function(e){t.advertisement=[];for(var i=e.length,o=0;o<i;o++)t.advertisement.push({duration:o,image:e[o]})},blob:null,bufferSize:0,sampleRate:0,buffer:null,reset:function(){f&&"function"==typeof f.clearRecordedData&&f.clearRecordedData(),f=null,h("inactive"),i.blob=null},onStateChanged:function(e){t.disableLogs||console.log("Recorder state changed:",e)},state:"inactive",getState:function(){return i.state},destroy:function(){var e=t.disableLogs;t={disableLogs:!0},i.reset(),h("destroyed"),p=i=null,T.AudioContextConstructor&&(T.AudioContextConstructor.close(),T.AudioContextConstructor=null),t.disableLogs=e,t.disableLogs||console.warn("RecordRTC is destroyed.")},version:"5.4.9"};if(!this)return i=p;for(var v in p)this[v]=p[v];return i=this,p}function s(e,t){return t.recorderType||t.type||(t.audio&&t.video?t.type="video":t.audio&&!t.video&&(t.type="audio")),t.recorderType&&!t.type&&(t.recorderType===M||t.recorderType===A?t.type="video":t.recorderType===U?t.type="gif":t.recorderType===C?t.type="audio":t.recorderType===k&&(e.getAudioTracks().length&&e.getVideoTracks().length?t.type="video":e.getAudioTracks().length&&!e.getVideoTracks().length?t.type="audio":!e.getAudioTracks().length&&e.getVideoTracks().length&&(t.type="audio"))),void 0!==k&&"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&(t.mimeType||(t.mimeType="video/webm"),t.type||(t.type=t.mimeType.split("/")[0]),t.bitsPerSecond),t.type||(t.mimeType&&(t.type=t.mimeType.split("/")[0]),t.type||(t.type="audio")),t}function d(e,t){var i;return(v||m||p)&&(i=C),"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&!v&&(i=k),"video"===t.type&&(v||p)&&(i=M),"gif"===t.type&&(i=U),"canvas"===t.type&&(i=A),S()&&i!==A&&i!==U&&"undefined"!=typeof MediaRecorder&&"requestData"in MediaRecorder.prototype&&(e.getVideoTracks&&e.getVideoTracks().length||e.getAudioTracks&&e.getAudioTracks().length)&&("audio"===t.type?"function"==typeof MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("audio/webm")&&(i=k):"function"==typeof MediaRecorder.isTypeSupported&&MediaRecorder.isTypeSupported("video/webm")&&(i=k)),e instanceof Array&&e.length&&(i=D),t.recorderType&&(i=t.recorderType),!t.disableLogs&&i&&i.name&&console.log("Using recorderType:",i.name||i.constructor.name),i}function c(e){this.addStream=function(t){t&&(e=t)},this.mediaType={audio:!0,video:!0},this.startRecording=function(){var t,i=this.mediaType,o=this.mimeType||{audio:null,video:null,gif:null};if("function"!=typeof i.audio&&S()&&e.getAudioTracks&&!e.getAudioTracks().length&&(i.audio=!1),"function"!=typeof i.video&&S()&&e.getVideoTracks&&!e.getVideoTracks().length&&(i.video=!1),"function"!=typeof i.gif&&S()&&e.getVideoTracks&&!e.getVideoTracks().length&&(i.gif=!1),!i.audio&&!i.video&&!i.gif)throw"MediaStream must have either audio or video tracks.";if(i.audio&&(t=null,"function"==typeof i.audio&&(t=i.audio),this.audioRecorder=new r(e,{type:"audio",bufferSize:this.bufferSize,sampleRate:this.sampleRate,numberOfAudioChannels:this.numberOfAudioChannels||2,disableLogs:this.disableLogs,recorderType:t,mimeType:o.audio,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp}),i.video||this.audioRecorder.startRecording()),i.video){t=null,"function"==typeof i.video&&(t=i.video);var n=e;if(S()&&i.audio&&"function"==typeof i.audio){var a=e.getVideoTracks()[0];navigator.mozGetUserMedia?((n=new b).addTrack(a),t&&t===M&&(t=k)):n=new b([a])}this.videoRecorder=new r(n,{type:"video",video:this.video,canvas:this.canvas,frameInterval:this.frameInterval||10,disableLogs:this.disableLogs,recorderType:t,mimeType:o.video,timeSlice:this.timeSlice,onTimeStamp:this.onTimeStamp}),i.audio||this.videoRecorder.startRecording()}if(i.audio&&i.video){var s=this;S()?(s.audioRecorder=null,s.videoRecorder.startRecording()):s.videoRecorder.initRecorder(function(){s.audioRecorder.initRecorder(function(){s.videoRecorder.startRecording(),s.audioRecorder.startRecording()})})}i.gif&&(t=null,"function"==typeof i.gif&&(t=i.gif),this.gifRecorder=new r(e,{type:"gif",frameRate:this.frameRate||200,quality:this.quality||10,disableLogs:this.disableLogs,recorderType:t,mimeType:o.gif}),this.gifRecorder.startRecording())},this.stopRecording=function(e){e=e||function(){},this.audioRecorder&&this.audioRecorder.stopRecording(function(t){e(t,"audio")}),this.videoRecorder&&this.videoRecorder.stopRecording(function(t){e(t,"video")}),this.gifRecorder&&this.gifRecorder.stopRecording(function(t){e(t,"gif")})},this.pauseRecording=function(){this.audioRecorder&&this.audioRecorder.pauseRecording(),this.videoRecorder&&this.videoRecorder.pauseRecording(),this.gifRecorder&&this.gifRecorder.pauseRecording()},this.resumeRecording=function(){this.audioRecorder&&this.audioRecorder.resumeRecording(),this.videoRecorder&&this.videoRecorder.resumeRecording(),this.gifRecorder&&this.gifRecorder.resumeRecording()},this.getBlob=function(e){var t={};return this.audioRecorder&&(t.audio=this.audioRecorder.getBlob()),this.videoRecorder&&(t.video=this.videoRecorder.getBlob()),this.gifRecorder&&(t.gif=this.gifRecorder.getBlob()),e&&e(t),t},this.destroy=function(){this.audioRecorder&&(this.audioRecorder.destroy(),this.audioRecorder=null),this.videoRecorder&&(this.videoRecorder.destroy(),this.videoRecorder=null),this.gifRecorder&&(this.gifRecorder.destroy(),this.gifRecorder=null)},this.getDataURL=function(e){function t(e,t){if("undefined"!=typeof Worker){var i=function(e){var t,i=g.createObjectURL(new Blob([e.toString(),"this.onmessage =  function (eee) {"+e.name+"(eee.data);}"],{type:"application/javascript"})),o=new Worker(i);if(void 0!==g)t=g;else{if("undefined"==typeof webkitURL)throw"Neither URL nor webkitURL detected.";t=webkitURL}return t.revokeObjectURL(i),o}(function(e){postMessage((new FileReaderSync).readAsDataURL(e))});i.onmessage=function(e){t(e.data)},i.postMessage(e)}else{var o=new FileReader;o.readAsDataURL(e),o.onload=function(e){t(e.target.result)}}}this.getBlob(function(i){i.audio&&i.video?t(i.audio,function(o){t(i.video,function(t){e({audio:o,video:t})})}):i.audio?t(i.audio,function(t){e({audio:t})}):i.video&&t(i.video,function(t){e({video:t})})})},this.writeToDisk=function(){r.writeToDisk({audio:this.audioRecorder,video:this.videoRecorder,gif:this.gifRecorder})},this.save=function(e){(e=e||{audio:!0,video:!0,gif:!0}).audio&&this.audioRecorder&&this.audioRecorder.save("string"==typeof e.audio?e.audio:""),e.video&&this.videoRecorder&&this.videoRecorder.save("string"==typeof e.video?e.video:""),e.gif&&this.gifRecorder&&this.gifRecorder.save("string"==typeof e.gif?e.gif:"")}}r.version="5.4.9",e.exports=r,void 0===(n=function(){return r}.apply(t,[]))||(e.exports=n),r.getFromDisk=function(e,t){if(!t)throw"callback is mandatory.";console.log("Getting recorded "+("all"===e?"blobs":e+" blob ")+" from disk!"),x.Fetch(function(i,o){"all"!==e&&o===e+"Blob"&&t&&t(i),"all"===e&&t&&t(i,o.replace("Blob",""))})},r.writeToDisk=function(e){console.log("Writing recorded blob(s) to disk!"),(e=e||{}).audio&&e.video&&e.gif?e.audio.getDataURL(function(t){e.video.getDataURL(function(i){e.gif.getDataURL(function(e){x.Store({audioBlob:t,videoBlob:i,gifBlob:e})})})}):e.audio&&e.video?e.audio.getDataURL(function(t){e.video.getDataURL(function(e){x.Store({audioBlob:t,videoBlob:e})})}):e.audio&&e.gif?e.audio.getDataURL(function(t){e.gif.getDataURL(function(e){x.Store({audioBlob:t,gifBlob:e})})}):e.video&&e.gif?e.video.getDataURL(function(t){e.gif.getDataURL(function(e){x.Store({videoBlob:t,gifBlob:e})})}):e.audio?e.audio.getDataURL(function(e){x.Store({audioBlob:e})}):e.video?e.video.getDataURL(function(e){x.Store({videoBlob:e})}):e.gif&&e.gif.getDataURL(function(e){x.Store({gifBlob:e})})},c.getFromDisk=r.getFromDisk,c.writeToDisk=r.writeToDisk,void 0!==r&&(r.MRecordRTC=c),(a=void 0!==i?i:null)&&"undefined"==typeof window&&void 0!==i&&(i.navigator={userAgent:"Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45",getUserMedia:function(){}},i.console||(i.console={}),void 0!==i.console.log&&void 0!==i.console.error||(i.console.error=i.console.log=i.console.log||function(){console.log(arguments)}),"undefined"==typeof document&&(a.document={},document.createElement=document.captureStream=document.mozCaptureStream=function(){var e={getContext:function(){return e},play:function(){},pause:function(){},drawImage:function(){},toDataURL:function(){return""}};return e},a.HTMLVideoElement=function(){}),"undefined"==typeof location&&(a.location={protocol:"file:",href:"",hash:""}),"undefined"==typeof screen&&(a.screen={width:0,height:0}),void 0===g&&(a.URL={createObjectURL:function(){return""},revokeObjectURL:function(){return""}}),a.window=i);var u=window.requestAnimationFrame;if(void 0===u)if("undefined"!=typeof webkitRequestAnimationFrame)u=webkitRequestAnimationFrame;else if("undefined"!=typeof mozRequestAnimationFrame)u=mozRequestAnimationFrame;else if("undefined"!=typeof msRequestAnimationFrame)u=msRequestAnimationFrame;else if(void 0===u){var h=0;u=function(e,t){var i=(new Date).getTime(),o=Math.max(0,16-(i-h)),n=setTimeout(function(){e(i+o)},o);return h=i+o,n}}var f=window.cancelAnimationFrame;void 0===f&&("undefined"!=typeof webkitCancelAnimationFrame?f=webkitCancelAnimationFrame:"undefined"!=typeof mozCancelAnimationFrame?f=mozCancelAnimationFrame:"undefined"!=typeof msCancelAnimationFrame?f=msCancelAnimationFrame:void 0===f&&(f=function(e){clearTimeout(e)}));var l=window.AudioContext;void 0===l&&("undefined"!=typeof webkitAudioContext&&(l=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(l=mozAudioContext));var g=window.URL;void 0===g&&"undefined"!=typeof webkitURL&&(g=webkitURL),"undefined"!=typeof navigator&&void 0===navigator.getUserMedia&&(void 0!==navigator.webkitGetUserMedia&&(navigator.getUserMedia=navigator.webkitGetUserMedia),void 0!==navigator.mozGetUserMedia&&(navigator.getUserMedia=navigator.mozGetUserMedia));var m=!(-1===navigator.userAgent.indexOf("Edge")||!navigator.msSaveBlob&&!navigator.msSaveOrOpenBlob),p=!!window.opera||-1!==navigator.userAgent.indexOf("OPR/"),v=(-1!==navigator.userAgent.toLowerCase().indexOf("safari/")&&navigator.userAgent.toLowerCase().indexOf("chrome/"),!p&&!m&&!!navigator.webkitGetUserMedia||y()||-1!==navigator.userAgent.toLowerCase().indexOf("chrome/")),b=window.MediaStream;function w(e){if(0===e)return"0 Bytes";var t=parseInt(Math.floor(Math.log(e)/Math.log(1e3)),10);return(e/Math.pow(1e3,t)).toPrecision(3)+" "+["Bytes","KB","MB","GB","TB"][t]}function y(){return"undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type||!(void 0===o||"object"!=typeof o.versions||!o.versions.electron)||"object"==typeof navigator&&"string"==typeof navigator.userAgent&&0<=navigator.userAgent.indexOf("Electron")}function R(e,t,i){if("srcObject"in t)t.srcObject=e;else if("mozSrcObject"in t)t.mozSrcObject=e;else if("createObjectURL"in g&&!i)try{t.src=g.createObjectURL(e)}catch(i){return void R(e,t,!0)}else alert("createObjectURL/srcObject both are not supported.")}void 0===b&&"undefined"!=typeof webkitMediaStream&&(b=webkitMediaStream),void 0!==b&&("getVideoTracks"in b.prototype||(b.prototype.getVideoTracks=function(){if(!this.getTracks)return[];var e=[];return this.getTracks().forEach(function(t){-1!==t.kind.toString().indexOf("video")&&e.push(t)}),e},b.prototype.getAudioTracks=function(){if(!this.getTracks)return[];var e=[];return this.getTracks().forEach(function(t){-1!==t.kind.toString().indexOf("audio")&&e.push(t)}),e}),void 0===b.prototype.stop&&(b.prototype.stop=function(){this.getTracks().forEach(function(e){e.stop()})}));var T={};function S(){var e=!!window.opera||0<=navigator.userAgent.indexOf(" OPR/"),t=!!window.chrome&&!e||y();if(void 0!==window.InstallTrigger)return!0;navigator.appVersion;var i,o,n=navigator.userAgent,a=""+parseFloat(navigator.appVersion),r=parseInt(navigator.appVersion,10);return(t||e)&&(i=n.indexOf("Chrome"),a=n.substring(i+7)),-1!==(o=a.indexOf(";"))&&(a=a.substring(0,o)),-1!==(o=a.indexOf(" "))&&(a=a.substring(0,o)),r=parseInt(""+a,10),isNaN(r)&&(a=""+parseFloat(navigator.appVersion),r=parseInt(navigator.appVersion,10)),49<=r}function k(e,t){var i,o=this;if(void 0===e)throw'First argument "MediaStream" is required.';if("undefined"==typeof MediaRecorder)throw"Your browser does not supports Media Recorder API. Please try other modules e.g. WhammyRecorder or StereoAudioRecorder.";"audio"===(t=t||{mimeType:"video/webm"}).type&&(e.getVideoTracks().length&&e.getAudioTracks().length&&(navigator.mozGetUserMedia?(i=new b).addTrack(e.getAudioTracks()[0]):i=new b(e.getAudioTracks()),e=i),t.mimeType&&-1!==t.mimeType.toString().toLowerCase().indexOf("audio")||(t.mimeType=v?"audio/webm":"audio/ogg"),t.mimeType&&"audio/ogg"!==t.mimeType.toString().toLowerCase()&&navigator.mozGetUserMedia&&(t.mimeType="audio/ogg"));var n,a=[];function r(){o.timestamps.push((new Date).getTime()),"function"==typeof t.onTimeStamp&&t.onTimeStamp(o.timestamps[o.timestamps.length-1],o.timestamps)}function s(e){return n&&n.mimeType?n.mimeType:e.mimeType||"video/webm"}function d(){a=[],n=null,o.timestamps=[]}this.getArrayOfBlobs=function(){return a},this.record=function(){o.blob=null,o.clearRecordedData(),o.timestamps=[],c=[],a=[];var i=t;t.disableLogs||console.log("Passing following config over MediaRecorder API.",i),n&&(n=null),v&&!S()&&(i="video/vp8"),"function"==typeof MediaRecorder.isTypeSupported&&i.mimeType&&(MediaRecorder.isTypeSupported(i.mimeType)||(t.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",i.mimeType),i.mimeType="audio"===t.type?"audio/webm":"video/webm"));try{n=new MediaRecorder(e,i),t.mimeType=i.mimeType}catch(t){n=new MediaRecorder(e)}i.mimeType&&!MediaRecorder.isTypeSupported&&"canRecordMimeType"in n&&!1===n.canRecordMimeType(i.mimeType)&&(t.disableLogs||console.warn("MediaRecorder API seems unable to record mimeType:",i.mimeType)),n.ondataavailable=function(e){if(e.data&&c.push("ondataavailable: "+w(e.data.size)),"number"!=typeof t.timeSlice)!e.data||!e.data.size||e.data.size<100||o.blob?o.recordingCallback&&(o.recordingCallback(new Blob([],{type:s(i)})),o.recordingCallback=null):(o.blob=t.getNativeBlob?e.data:new Blob([e.data],{type:s(i)}),o.recordingCallback&&(o.recordingCallback(o.blob),o.recordingCallback=null));else if(e.data&&e.data.size&&100<e.data.size&&(a.push(e.data),r(),"function"==typeof t.ondataavailable)){var n=t.getNativeBlob?e.data:new Blob([e.data],{type:s(i)});t.ondataavailable(n)}},n.onstart=function(){c.push("started")},n.onpause=function(){c.push("paused")},n.onresume=function(){c.push("resumed")},n.onstop=function(){c.push("stopped")},n.onerror=function(e){e&&(e.name||(e.name="UnknownError"),c.push("error: "+e),t.disableLogs||(-1!==e.name.toString().toLowerCase().indexOf("invalidstate")?console.error("The MediaRecorder is not in a state in which the proposed operation is allowed to be executed.",e):-1!==e.name.toString().toLowerCase().indexOf("notsupported")?console.error("MIME type (",i.mimeType,") is not supported.",e):-1!==e.name.toString().toLowerCase().indexOf("security")?console.error("MediaRecorder security error",e):"OutOfMemory"===e.name?console.error("The UA has exhaused the available memory. User agents SHOULD provide as much additional information as possible in the message attribute.",e):"IllegalStreamModification"===e.name?console.error("A modification to the stream has occurred that makes it impossible to continue recording. An example would be the addition of a Track while recording is occurring. User agents SHOULD provide as much additional information as possible in the message attribute.",e):"OtherRecordingError"===e.name?console.error("Used for an fatal error other than those listed above. User agents SHOULD provide as much additional information as possible in the message attribute.",e):"GenericError"===e.name?console.error("The UA cannot provide the codec or recording option that has been requested.",e):console.error("MediaRecorder Error",e)),function(e){if(!o.manuallyStopped&&n&&"inactive"===n.state)return delete t.timeslice,n.start(6e5);setTimeout(void 0,1e3)}(),"inactive"!==n.state&&"stopped"!==n.state&&n.stop())},"number"==typeof t.timeSlice?(r(),n.start(t.timeSlice)):n.start(36e5),t.initCallback&&t.initCallback()},this.timestamps=[],this.stop=function(e){e=e||function(){},o.manuallyStopped=!0,n&&(this.recordingCallback=e,"recording"===n.state&&n.stop(),"number"==typeof t.timeSlice&&setTimeout(function(){o.blob=new Blob(a,{type:s(t)}),o.recordingCallback(o.blob)},100))},this.pause=function(){n&&"recording"===n.state&&n.pause()},this.resume=function(){n&&"paused"===n.state&&n.resume()},this.clearRecordedData=function(){n&&"recording"===n.state&&o.stop(d),d()},this.getInternalRecorder=function(){return n},this.blob=null,this.getState=function(){return n&&n.state||"inactive"};var c=[];this.getAllStates=function(){return c},void 0===t.checkForInactiveTracks&&(t.checkForInactiveTracks=!1),o=this,function i(){if(n&&!1!==t.checkForInactiveTracks)return!1===function(){if("active"in e){if(!e.active)return!1}else if("ended"in e&&e.ended)return!1;return!0}()?(t.disableLogs||console.log("MediaStream seems stopped."),void o.stop()):void setTimeout(i,1e3)}(),this.name="MediaStreamRecorder",this.toString=function(){return this.name}}function C(e,t){if(!e.getAudioTracks().length)throw"Your stream has no audio tracks.";var i,o=this,n=[],a=[],r=!1,s=0,d=2,c=(t=t||{}).desiredSampRate;function u(){if(!1===t.checkForInactiveTracks)return!0;if("active"in e){if(!e.active)return!1}else if("ended"in e&&e.ended)return!1;return!0}function h(e,t){function i(e,t){var i,o=e.numberOfAudioChannels,n=e.leftBuffers.slice(0),a=e.rightBuffers.slice(0),r=e.sampleRate,s=e.internalInterleavedLength,d=e.desiredSampRate;function c(e,t,i){var o,n=Math.round(e.length*(t/i)),a=[],r=Number((e.length-1)/(n-1));a[0]=e[0];for(var s=1;s<n-1;s++){var d=s*r,c=Number(Math.floor(d)).toFixed(),u=Number(Math.ceil(d)).toFixed(),h=d-c;a[s]=(o=e[c])+(e[u]-o)*h}return a[n-1]=e[e.length-1],a}function u(e,t){for(var i=new Float64Array(t),o=0,n=e.length,a=0;a<n;a++){var r=e[a];i.set(r,o),o+=r.length}return i}function h(e,t,i){for(var o=i.length,n=0;n<o;n++)e.setUint8(t+n,i.charCodeAt(n))}2===o&&(n=u(n,s),a=u(a,s),d&&(n=c(n,d,r),a=c(a,d,r))),1===o&&(n=u(n,s),d&&(n=c(n,d,r))),d&&(r=d),2===o&&(i=function(e,t){for(var i=e.length+t.length,o=new Float64Array(i),n=0,a=0;a<i;)o[a++]=e[n],o[a++]=t[n],n++;return o}(n,a)),1===o&&(i=n);var f=i.length,l=new ArrayBuffer(44+2*f),g=new DataView(l);h(g,0,"RIFF"),g.setUint32(4,44+2*f,!0),h(g,8,"WAVE"),h(g,12,"fmt "),g.setUint32(16,16,!0),g.setUint16(20,1,!0),g.setUint16(22,o,!0),g.setUint32(24,r,!0),g.setUint32(28,2*r,!0),g.setUint16(32,2*o,!0),g.setUint16(34,16,!0),h(g,36,"data"),g.setUint32(40,2*f,!0);for(var m=f,p=44,v=0;v<m;v++)g.setInt16(p,32767*i[v],!0),p+=2;if(t)return t({buffer:l,view:g});postMessage({buffer:l,view:g})}if(e.noWorker)i(e,function(e){t(e.buffer,e.view)});else{var o,n,a,r=(o=i,n=g.createObjectURL(new Blob([o.toString(),";this.onmessage =  function (eee) {"+o.name+"(eee.data);}"],{type:"application/javascript"})),(a=new Worker(n)).workerURL=n,a);r.onmessage=function(e){t(e.data.buffer,e.data.view),g.revokeObjectURL(r.workerURL),r.terminate()},r.postMessage(e)}}if(!0===t.leftChannel&&(d=1),1===t.numberOfAudioChannels&&(d=1),(!d||d<1)&&(d=2),t.disableLogs||console.log("StereoAudioRecorder is set to record number of channels: "+d),void 0===t.checkForInactiveTracks&&(t.checkForInactiveTracks=!0),this.record=function(){if(!1===u())throw"Please make sure MediaStream is active.";y(),T=w=!1,r=!0,void 0!==t.timeSlice&&k()},this.stop=function(e){e=e||function(){},r=!1,h({desiredSampRate:c,sampleRate:b,numberOfAudioChannels:d,internalInterleavedLength:s,leftBuffers:n,rightBuffers:1===d?[]:a,noWorker:t.noWorker},function(t,i){o.blob=new Blob([i],{type:"audio/wav"}),o.buffer=new ArrayBuffer(i.buffer.byteLength),o.view=i,o.sampleRate=c||b,o.bufferSize=v,o.length=s,T=!1,e&&e(o.blob)})},void 0===f)var f={AudioContextConstructor:null,AudioContext:window.AudioContext||window.webkitAudioContext};f.AudioContextConstructor||(f.AudioContextConstructor=new f.AudioContext);var l=f.AudioContextConstructor,m=l.createMediaStreamSource(e),p=[0,256,512,1024,2048,4096,8192,16384],v=void 0===t.bufferSize?4096:t.bufferSize;if(-1===p.indexOf(v)&&(t.disableLogs||console.log("Legal values for buffer-size are "+JSON.stringify(p,null,"\t"))),l.createJavaScriptNode)i=l.createJavaScriptNode(v,d,d);else{if(!l.createScriptProcessor)throw"WebAudio API has no support on this browser.";i=l.createScriptProcessor(v,d,d)}m.connect(i),t.bufferSize||(v=i.bufferSize);var b=void 0!==t.sampleRate?t.sampleRate:l.sampleRate||44100;(b<22050||96e3<b)&&(t.disableLogs||console.log("sample-rate must be under range 22050 and 96000.")),t.disableLogs||t.desiredSampRate&&console.log("Desired sample-rate: "+t.desiredSampRate);var w=!1;function y(){n=[],s=0,w=r=T=!(a=[]),l=null,o.leftchannel=n,o.rightchannel=a,o.numberOfAudioChannels=d,o.desiredSampRate=c,o.sampleRate=b,o.recordingLength=s,S={left:[],right:[],recordingLength:0}}function R(){i&&(i.onaudioprocess=null,i.disconnect(),i=null),m&&(m.disconnect(),m=null),y()}this.pause=function(){w=!0},this.resume=function(){if(!1===u())throw"Please make sure MediaStream is active.";if(!r)return t.disableLogs||console.log("Seems recording has been restarted."),void this.record();w=!1},this.clearRecordedData=function(){t.checkForInactiveTracks=!1,r&&this.stop(R),R()},this.name="StereoAudioRecorder";var T=!(this.toString=function(){return this.name});i.onaudioprocess=function(e){if(!w)if(!1===u()&&(t.disableLogs||console.log("MediaStream seems stopped."),i.disconnect(),r=!1),r){T||(T=!0,t.onAudioProcessStarted&&t.onAudioProcessStarted(),t.initCallback&&t.initCallback());var c=e.inputBuffer.getChannelData(0),h=new Float32Array(c);if(n.push(h),2===d){var f=e.inputBuffer.getChannelData(1),l=new Float32Array(f);a.push(l)}s+=v,o.recordingLength=s,void 0!==t.timeSlice&&(S.recordingLength+=v,S.left.push(h),2===d&&S.right.push(l))}else m&&(m.disconnect(),m=null)},l.createMediaStreamDestination?i.connect(l.createMediaStreamDestination()):i.connect(l.destination),this.leftchannel=n,this.rightchannel=a,this.numberOfAudioChannels=d,this.desiredSampRate=c,this.sampleRate=b,o.recordingLength=s;var S={left:[],right:[],recordingLength:0};function k(){r&&"function"==typeof t.ondataavailable&&void 0!==t.timeSlice&&(S.left.length?(h({desiredSampRate:c,sampleRate:b,numberOfAudioChannels:d,internalInterleavedLength:S.recordingLength,leftBuffers:S.left,rightBuffers:1===d?[]:S.right},function(e,i){var o=new Blob([i],{type:"audio/wav"});t.ondataavailable(o),setTimeout(k,t.timeSlice)}),S={left:[],right:[],recordingLength:0}):setTimeout(k,t.timeSlice))}}function A(e,t){if("undefined"==typeof html2canvas)throw"Please link: https://cdn.webrtc-experiment.com/screenshot.js";(t=t||{}).frameInterval||(t.frameInterval=10);var i=!1;["captureStream","mozCaptureStream","webkitCaptureStream"].forEach(function(e){e in document.createElement("canvas")&&(i=!0)});var o,n,a,r=!(!window.webkitRTCPeerConnection&&!window.webkitGetUserMedia||!window.chrome),s=50,d=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);if(r&&d&&d[2]&&(s=parseInt(d[2],10)),r&&s<52&&(i=!1),t.useWhammyRecorder&&(i=!1),i)if(t.disableLogs||console.log("Your browser supports both MediRecorder API and canvas.captureStream!"),e instanceof HTMLCanvasElement)o=e;else{if(!(e instanceof CanvasRenderingContext2D))throw"Please pass either HTMLCanvasElement or CanvasRenderingContext2D.";o=e.canvas}else navigator.mozGetUserMedia&&(t.disableLogs||console.error("Canvas recording is NOT supported in Firefox."));this.record=function(){if(a=!0,i&&!t.useWhammyRecorder){var e;"captureStream"in o?e=o.captureStream(25):"mozCaptureStream"in o?e=o.mozCaptureStream(25):"webkitCaptureStream"in o&&(e=o.webkitCaptureStream(25));try{var r=new b;r.addTrack(e.getVideoTracks()[0]),e=r}catch(e){}if(!e)throw"captureStream API are NOT available.";(n=new k(e,{mimeType:"video/webm"})).record()}else l.frames=[],f=(new Date).getTime(),h();t.initCallback&&t.initCallback()},this.getWebPImages=function(i){if("canvas"===e.nodeName.toLowerCase()){var o=l.frames.length;l.frames.forEach(function(e,i){var n=o-i;t.disableLogs||console.log(n+"/"+o+" frames remaining"),t.onEncodingCallback&&t.onEncodingCallback(n,o);var a=e.image.toDataURL("image/webp",1);l.frames[i].image=a}),t.disableLogs||console.log("Generating WebM"),i()}else i()};var c=!(this.stop=function(e){a=!1;var o=this;i&&n?n.stop(e):this.getWebPImages(function(){l.compile(function(i){t.disableLogs||console.log("Recording finished!"),o.blob=i,o.blob.forEach&&(o.blob=new Blob([],{type:"video/webm"})),e&&e(o.blob),l.frames=[]})})});function u(){l.frames=[],c=a=!1}function h(){if(c)return f=(new Date).getTime(),setTimeout(h,500);if("canvas"===e.nodeName.toLowerCase()){var i=(new Date).getTime()-f;return f=(new Date).getTime(),l.frames.push({image:(o=document.createElement("canvas"),n=o.getContext("2d"),o.width=e.width,o.height=e.height,n.drawImage(e,0,0),o),duration:i}),void(a&&setTimeout(h,t.frameInterval))}var o,n;html2canvas(e,{grabMouse:void 0===t.showMousePointer||t.showMousePointer,onrendered:function(e){var i=(new Date).getTime()-f;if(!i)return setTimeout(h,t.frameInterval);f=(new Date).getTime(),l.frames.push({image:e.toDataURL("image/webp",1),duration:i}),a&&setTimeout(h,t.frameInterval)}})}this.pause=function(){c=!0,n instanceof k&&n.pause()},this.resume=function(){c=!1,n instanceof k?n.resume():a||this.record()},this.clearRecordedData=function(){a&&this.stop(u),u()},this.name="CanvasRecorder",this.toString=function(){return this.name};var f=(new Date).getTime(),l=new L.Video(100)}function M(e,t){function i(e){e=void 0!==e?e:10;var t=(new Date).getTime()-s;return t?n?(s=(new Date).getTime(),setTimeout(i,100)):(s=(new Date).getTime(),r.paused&&r.play(),u.drawImage(r,0,0,c.width,c.height),d.frames.push({duration:t,image:c.toDataURL("image/webp")}),void(o||setTimeout(i,e,e))):setTimeout(i,e,e)}(t=t||{}).frameInterval||(t.frameInterval=10),t.disableLogs||console.log("Using frames-interval:",t.frameInterval);var o=!(this.record=function(){t.width||(t.width=320),t.height||(t.height=240),t.video||(t.video={width:t.width,height:t.height}),t.canvas||(t.canvas={width:t.width,height:t.height}),c.width=t.canvas.width||320,c.height=t.canvas.height||240,u=c.getContext("2d"),t.video&&t.video instanceof HTMLVideoElement?(r=t.video.cloneNode(),t.initCallback&&t.initCallback()):(r=document.createElement("video"),R(e,r),r.onloadedmetadata=function(){t.initCallback&&t.initCallback()},r.width=t.video.width,r.height=t.video.height),r.muted=!0,r.play(),s=(new Date).getTime(),d=new L.Video,t.disableLogs||(console.log("canvas resolutions",c.width,"*",c.height),console.log("video width/height",r.width||c.width,"*",r.height||c.height)),i(t.frameInterval)}),n=!(this.stop=function(e){e=e||function(){},o=!0;var i=this;setTimeout(function(){!function(e,t,i,o,n){var a=document.createElement("canvas");a.width=c.width,a.height=c.height;var r,s,d,u=a.getContext("2d"),h=[],f=-1===t,l=t&&0<t&&t<=e.length?t:e.length,g=Math.sqrt(Math.pow(255,2)+Math.pow(255,2)+Math.pow(255,2)),m=i&&0<=i&&i<=1?i:0,p=o&&0<=o&&o<=1?o:0,v=!1;s=-1,d=(r={length:l,functionToLoop:function(t,i){var o,n,a,r=function(){!v&&a-o<=a*p||(f&&(v=!0),h.push(e[i])),t()};if(v)r();else{var s=new Image;s.onload=function(){u.drawImage(s,0,0,c.width,c.height);var e=u.getImageData(0,0,c.width,c.height);o=0,n=e.data.length,a=e.data.length/4;for(var t=0;t<n;t+=4){var i=e.data[t],d=e.data[t+1],h=e.data[t+2];Math.sqrt(Math.pow(i-0,2)+Math.pow(d-0,2)+Math.pow(h-0,2))<=g*m&&o++}r()},s.src=e[i].image}},callback:function(){(h=h.concat(e.slice(l))).length<=0&&h.push(e[e.length-1]),n(h)}}).length,function e(){++s!==d?setTimeout(function(){r.functionToLoop(e,s)},1):r.callback()}()}(d.frames,-1,null,null,function(o){d.frames=o,t.advertisement&&t.advertisement.length&&(d.frames=t.advertisement.concat(d.frames)),d.compile(function(t){i.blob=t,i.blob.forEach&&(i.blob=new Blob([],{type:"video/webm"})),e&&e(i.blob)})})},10)});function a(){d.frames=[],n=!(o=!0)}this.pause=function(){n=!0},this.resume=function(){n=!1,o&&this.record()},this.clearRecordedData=function(){o||this.stop(a),a()},this.name="WhammyRecorder",this.toString=function(){return this.name};var r,s,d,c=document.createElement("canvas"),u=c.getContext("2d")}void 0!==l?T.AudioContext=l:"undefined"!=typeof webkitAudioContext&&(T.AudioContext=webkitAudioContext),void 0!==r&&(r.Storage=T),void 0!==r&&(r.MediaStreamRecorder=k),void 0!==r&&(r.StereoAudioRecorder=C),void 0!==r&&(r.CanvasRecorder=A),void 0!==r&&(r.WhammyRecorder=M);var L=function(){function e(e){this.frames=[],this.duration=e||1,this.quality=.8}function t(e){function t(e,t,i){return[{data:e,id:231}].concat(i.map(function(e){var i=function(e){var t=0;if(e.keyframe&&(t|=128),e.invisible&&(t|=8),e.lacing&&(t|=e.lacing<<1),e.discardable&&(t|=1),127<e.trackNum)throw"TrackNumber > 127 not supported";return[128|e.trackNum,e.timecode>>8,255&e.timecode,t].map(function(e){return String.fromCharCode(e)}).join("")+e.frame}({discardable:0,frame:e.data.slice(4),invisible:0,keyframe:1,lacing:0,trackNum:1,timecode:Math.round(t)});return t+=e.duration,{data:i,id:163}}))}function i(e){for(var t=[];0<e;)t.push(255&e),e>>=8;return new Uint8Array(t.reverse())}function o(e){var t=[];e=(e.length%8?new Array(9-e.length%8).join("0"):"")+e;for(var i=0;i<e.length;i+=8)t.push(parseInt(e.substr(i,8),2));return new Uint8Array(t)}var n=new function(e){var n=function(e){if(e[0]){for(var t=e[0].width,i=e[0].height,o=e[0].duration,n=1;n<e.length;n++)o+=e[n].duration;return{duration:o,width:t,height:i}}postMessage({error:"Something went wrong. Maybe WebP format is not supported in the current browser."})}(e);if(!n)return[];for(var a,r=[{id:440786851,data:[{data:1,id:17030},{data:1,id:17143},{data:4,id:17138},{data:8,id:17139},{data:"webm",id:17026},{data:2,id:17031},{data:2,id:17029}]},{id:408125543,data:[{id:357149030,data:[{data:1e6,id:2807729},{data:"whammy",id:19840},{data:"whammy",id:22337},{data:(a=n.duration,[].slice.call(new Uint8Array(new Float64Array([a]).buffer),0).map(function(e){return String.fromCharCode(e)}).reverse().join("")),id:17545}]},{id:374648427,data:[{id:174,data:[{data:1,id:215},{data:1,id:29637},{data:0,id:156},{data:"und",id:2274716},{data:"V_VP8",id:134},{data:"VP8",id:2459272},{data:1,id:131},{id:224,data:[{data:n.width,id:176},{data:n.height,id:186}]}]}]}]}],s=0,d=0;s<e.length;){for(var c=[],u=0;c.push(e[s]),u+=e[s].duration,++s<e.length&&u<3e4;);var h={id:524531317,data:t(d,0,c)};r[1].data.push(h),d+=u}return function e(t){for(var n=[],a=0;a<t.length;a++){var r=t[a].data;"object"==typeof r&&(r=e(r)),"number"==typeof r&&(r=o(r.toString(2))),"string"==typeof r&&(r=new Uint8Array(r.split("").map(function(e){return e.charCodeAt(0)})));var s=r.size||r.byteLength||r.length,d=Math.ceil(Math.ceil(Math.log(s)/Math.log(2))/8),c=s.toString(2),u=new Array(7*d+7+1-c.length).join("0")+c,h=new Array(d).join("0")+"1"+u;n.push(i(t[a].id)),n.push(o(h)),n.push(r)}return new Blob(n,{type:"video/webm"})}(r)}(e.map(function(e){var t=function(e){for(var t=e.RIFF[0].WEBP[0],i=t.indexOf("*"),o=0,n=[];o<4;o++)n[o]=t.charCodeAt(i+3+o);return{width:16383&(n[1]<<8|n[0]),height:16383&(n[3]<<8|n[2]),data:t,riff:e}}(function e(t){for(var i,o=0,n={};o<t.length;){var a=t.substr(o,4),r=(i=o,parseInt(t.substr(i+4,4).split("").map(function(e){var t=e.charCodeAt(0).toString(2);return new Array(8-t.length+1).join("0")+t}).join(""),2)),s=t.substr(o+4+4,r);o+=8+r,n[a]=n[a]||[],"RIFF"===a||"LIST"===a?n[a].push(e(s)):n[a].push(s)}return n}(atob(e.image.slice(23))));return t.duration=e.duration,t}));postMessage(n)}return e.prototype.add=function(e,t){if("canvas"in e&&(e=e.canvas),"toDataURL"in e&&(e=e.toDataURL("image/webp",this.quality)),!/^data:image\/webp;base64,/gi.test(e))throw"Input must be formatted properly as a base64 encoded DataURI of type image/webp";this.frames.push({image:e,duration:t||this.duration})},e.prototype.compile=function(e){var i,o,n,a=(i=t,o=g.createObjectURL(new Blob([i.toString(),"this.onmessage =  function (eee) {"+i.name+"(eee.data);}"],{type:"application/javascript"})),n=new Worker(o),g.revokeObjectURL(o),n);a.onmessage=function(t){t.data.error?console.error(t.data.error):e(t.data)},a.postMessage(this.frames)},{Video:e}}();void 0!==r&&(r.Whammy=L);var x={init:function(){var e=this;if("undefined"!=typeof indexedDB&&void 0!==indexedDB.open){var t,i=this.dbName||location.href.replace(/\/|:|#|%|\.|\[|\]/g,""),o=indexedDB.open(i,1);o.onerror=e.onError,o.onsuccess=function(){(t=o.result).onerror=e.onError,t.setVersion&&1!==t.version?t.setVersion(1).onsuccess=function(){n(t),a()}:a()},o.onupgradeneeded=function(e){n(e.target.result)}}else console.error("IndexedDB API are not available in this browser.");function n(t){t.createObjectStore(e.dataStoreName)}function a(){var i=t.transaction([e.dataStoreName],"readwrite");function o(t){i.objectStore(e.dataStoreName).get(t).onsuccess=function(i){e.callback&&e.callback(i.target.result,t)}}e.videoBlob&&i.objectStore(e.dataStoreName).put(e.videoBlob,"videoBlob"),e.gifBlob&&i.objectStore(e.dataStoreName).put(e.gifBlob,"gifBlob"),e.audioBlob&&i.objectStore(e.dataStoreName).put(e.audioBlob,"audioBlob"),o("audioBlob"),o("videoBlob"),o("gifBlob")}},Fetch:function(e){return this.callback=e,this.init(),this},Store:function(e){return this.audioBlob=e.audioBlob,this.videoBlob=e.videoBlob,this.gifBlob=e.gifBlob,this.init(),this},onError:function(e){console.error(JSON.stringify(e,null,"\t"))},dataStoreName:"recordRTC",dbName:null};function U(e,t){if("undefined"==typeof GIFEncoder){var i=document.createElement("script");i.src="https://cdn.webrtc-experiment.com/gif-recorder.js",(document.body||document.documentElement).appendChild(i)}t=t||{};var o=e instanceof CanvasRenderingContext2D||e instanceof HTMLCanvasElement;this.record=function(){"undefined"!=typeof GIFEncoder&&s?(o||(t.width||(t.width=d.offsetWidth||320),t.height||(t.height=d.offsetHeight||240),t.video||(t.video={width:t.width,height:t.height}),t.canvas||(t.canvas={width:t.width,height:t.height}),a.width=t.canvas.width||320,a.height=t.canvas.height||240,d.width=t.video.width||320,d.height=t.video.height||240),(h=new GIFEncoder).setRepeat(0),h.setDelay(t.frameRate||200),h.setQuality(t.quality||10),h.start(),"function"==typeof t.onGifRecordingStarted&&t.onGifRecordingStarted(),Date.now(),l=u(function e(i){if(!0!==g.clearedRecordedData){if(n)return setTimeout(function(){e(i)},100);l=u(e),void 0===typeof c&&(c=i),i-c<90||(!o&&d.paused&&d.play(),o||r.drawImage(d,0,0,a.width,a.height),t.onGifPreview&&t.onGifPreview(a.toDataURL("image/png")),h.addFrame(r),c=i)}}),t.initCallback&&t.initCallback()):setTimeout(g.record,1e3)};var n=!(this.stop=function(e){e=e||function(){},l&&f(l),Date.now(),this.blob=new Blob([new Uint8Array(h.stream().bin)],{type:"image/gif"}),e(this.blob),h.stream().bin=[]});this.pause=function(){n=!0},this.resume=function(){n=!1},this.clearRecordedData=function(){g.clearedRecordedData=!0,h&&(h.stream().bin=[])},this.name="GifRecorder",this.toString=function(){return this.name};var a=document.createElement("canvas"),r=a.getContext("2d");o&&(e instanceof CanvasRenderingContext2D?a=(r=e).canvas:e instanceof HTMLCanvasElement&&(r=e.getContext("2d"),a=e));var s=!0;if(!o){var d=document.createElement("video");d.muted=!0,d.autoplay=!0,s=!1,d.onloadedmetadata=function(){s=!0},R(e,d),d.play()}var c,h,l=null,g=this}function D(e,t){e=e||[];var i,o,n=this;(t=t||{mimeType:"video/webm",video:{width:360,height:240}}).frameInterval||(t.frameInterval=10),t.video||(t.video={}),t.video.width||(t.video.width=360),t.video.height||(t.video.height=240),this.record=function(){var n;i=new function(e){var t=[],i=!1,o=document.createElement("canvas"),n=o.getContext("2d");o.style="opacity:0;position:absolute;z-index:-1;top: -100000000;left:-1000000000; margin-top:-1000000000;margin-left:-1000000000;",(document.body||document.documentElement).appendChild(o),this.disableLogs=!1,this.frameInterval=10,this.width=360,this.height=240,this.useGainNode=!0;var a=this,r=window.AudioContext;void 0===r&&("undefined"!=typeof webkitAudioContext&&(r=webkitAudioContext),"undefined"!=typeof mozAudioContext&&(r=mozAudioContext));var s=window.URL;void 0===s&&"undefined"!=typeof webkitURL&&(s=webkitURL),"undefined"!=typeof navigator&&void 0===navigator.getUserMedia&&(void 0!==navigator.webkitGetUserMedia&&(navigator.getUserMedia=navigator.webkitGetUserMedia),void 0!==navigator.mozGetUserMedia&&(navigator.getUserMedia=navigator.mozGetUserMedia));var d=window.MediaStream;void 0===d&&"undefined"!=typeof webkitMediaStream&&(d=webkitMediaStream),void 0!==d&&("getVideoTracks"in d.prototype||(d.prototype.getVideoTracks=function(){if(!this.getTracks)return[];var e=[];return this.getTracks.forEach(function(t){-1!==t.kind.toString().indexOf("video")&&e.push(t)}),e},d.prototype.getAudioTracks=function(){if(!this.getTracks)return[];var e=[];return this.getTracks.forEach(function(t){-1!==t.kind.toString().indexOf("audio")&&e.push(t)}),e}),void 0===d.prototype.stop&&(d.prototype.stop=function(){this.getTracks().forEach(function(e){e.stop()})}));var c={};function u(){if(!i){var e=t.length,n=!1,r=[];if(t.forEach(function(e){e.stream||(e.stream={}),e.stream.fullcanvas?n=e:r.push(e)}),n)o.width=n.stream.width,o.height=n.stream.height;else if(r.length){o.width=1<e?2*r[0].width:r[0].width;var s=1;3!==e&&4!==e||(s=2),5!==e&&6!==e||(s=3),7!==e&&8!==e||(s=4),9!==e&&10!==e||(s=5),o.height=r[0].height*s}else o.width=a.width||360,o.height=a.height||240;n&&n instanceof HTMLVideoElement&&h(n),r.forEach(function(e,t){h(e,t)}),setTimeout(u,a.frameInterval)}}function h(e,t){if(!i){var o=0,a=0,r=e.width,s=e.height;1===t&&(o=e.width),2===t&&(a=e.height),3===t&&(o=e.width,a=e.height),4===t&&(a=2*e.height),5===t&&(o=e.width,a=2*e.height),6===t&&(a=3*e.height),7===t&&(o=e.width,a=3*e.height),void 0!==e.stream.left&&(o=e.stream.left),void 0!==e.stream.top&&(a=e.stream.top),void 0!==e.stream.width&&(r=e.stream.width),void 0!==e.stream.height&&(s=e.stream.height),n.drawImage(e,o,a,r,s),"function"==typeof e.stream.onRender&&e.stream.onRender(n,o,a,r,s,t)}}function f(e){var t=document.createElement("video");return function e(t,i,o){if("createObjectURL"in s&&!o)try{i.src=s.createObjectURL(t)}catch(o){return void e(t,i,!0)}else"srcObject"in i?i.srcObject=t:"mozSrcObject"in i?i.mozSrcObject=t:alert("createObjectURL/srcObject both are not supported.")}(e,t),t.muted=!0,t.volume=0,t.width=e.width||a.width||360,t.height=e.height||a.height||240,t.play(),t}function l(i){t=[],(i=i||e).forEach(function(e){if(e.getVideoTracks().length){var i=f(e);i.stream=e,t.push(i)}})}void 0!==r?c.AudioContext=r:"undefined"!=typeof webkitAudioContext&&(c.AudioContext=webkitAudioContext),this.startDrawingFrames=function(){u()},this.appendStreams=function(i){if(!i)throw"First parameter is required.";i instanceof Array||(i=[i]),e.concat(i),i.forEach(function(e){if(e.getVideoTracks().length){var i=f(e);i.stream=e,t.push(i)}if(e.getAudioTracks().length&&a.audioContext){var o=a.audioContext.createMediaStreamSource(e);o.connect(a.audioDestination),a.audioSources.push(o)}})},this.releaseStreams=function(){t=[],i=!0,a.gainNode&&(a.gainNode.disconnect(),a.gainNode=null),a.audioSources.length&&(a.audioSources.forEach(function(e){e.disconnect()}),a.audioSources=[]),a.audioDestination&&(a.audioDestination.disconnect(),a.audioDestination=null),a.audioContext&&a.audioContext.close(),a.audioContext=null,n.clearRect(0,0,o.width,o.height),o.stream&&(o.stream.stop(),o.stream=null)},this.resetVideoStreams=function(e){!e||e instanceof Array||(e=[e]),l(e)},this.name="MultiStreamsMixer",this.toString=function(){return this.name},this.getMixedStream=function(){i=!1;var t=function(){var e;l(),"captureStream"in o?e=o.captureStream():"mozCaptureStream"in o?e=o.mozCaptureStream():a.disableLogs||console.error("Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features");var t=new d;return e.getVideoTracks().forEach(function(e){t.addTrack(e)}),o.stream=t}(),n=function(){c.AudioContextConstructor||(c.AudioContextConstructor=new c.AudioContext),a.audioContext=c.AudioContextConstructor,a.audioSources=[],!0===a.useGainNode&&(a.gainNode=a.audioContext.createGain(),a.gainNode.connect(a.audioContext.destination),a.gainNode.gain.value=0);var t=0;return e.forEach(function(e){if(e.getAudioTracks().length){t++;var i=a.audioContext.createMediaStreamSource(e);!0===a.useGainNode&&i.connect(a.gainNode),a.audioSources.push(i)}}),t?(a.audioDestination=a.audioContext.createMediaStreamDestination(),a.audioSources.forEach(function(e){e.connect(a.audioDestination)}),a.audioDestination.stream):void 0}();return n&&n.getAudioTracks().forEach(function(e){t.addTrack(e)}),e.forEach(function(e){e.fullcanvas}),t}}(e),(n=[],e.forEach(function(e){e.getVideoTracks().forEach(function(e){n.push(e)})}),n).length&&(i.frameInterval=t.frameInterval||10,i.width=t.video.width||360,i.height=t.video.height||240,i.startDrawingFrames()),t.previewStream&&"function"==typeof t.previewStream&&t.previewStream(i.getMixedStream()),(o=new k(i.getMixedStream(),t)).record()},this.stop=function(e){o&&o.stop(function(t){n.blob=t,e(t),n.clearRecordedData()})},this.pause=function(){o&&o.pause()},this.resume=function(){o&&o.resume()},this.clearRecordedData=function(){o&&(o.clearRecordedData(),o=null),i&&(i.releaseStreams(),i=null)},this.addStreams=function(t){if(!t)throw"First parameter is required.";t instanceof Array||(t=[t]),e.concat(t),o&&i&&i.appendStreams(t)},this.resetVideoStreams=function(e){i&&(!e||e instanceof Array||(e=[e]),i.resetVideoStreams(e))},this.name="MultiStreamRecorder",this.toString=function(){return this.name}}void 0!==r&&(r.DiskStorage=x),void 0!==r&&(r.GifRecorder=U),void 0!==r&&(r.MultiStreamRecorder=D),void 0!==r&&(r.RecordRTCPromisesHandler=function(e,t){if(!this)throw'Use "new RecordRTCPromisesHandler()"';if(void 0===e)throw'First argument "MediaStream" is required.';var i=this;i.recordRTC=new r(e,t),this.startRecording=function(){return new Promise(function(e,t){try{i.recordRTC.startRecording(),e()}catch(e){t(e)}})},this.stopRecording=function(){return new Promise(function(e,t){try{i.recordRTC.stopRecording(function(t){i.blob=i.recordRTC.getBlob(),e(t)})}catch(e){t(e)}})},this.getDataURL=function(e){return new Promise(function(e,t){try{i.recordRTC.getDataURL(function(t){e(t)})}catch(e){t(e)}})},this.getBlob=function(){return i.recordRTC.getBlob()},this.blob=null}),e.exports=r}).call(this,i(0),i(4))},function(e,t){var i,o,n=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function s(e){if(i===setTimeout)return setTimeout(e,0);if((i===a||!i)&&setTimeout)return i=setTimeout,setTimeout(e,0);try{return i(e,0)}catch(t){try{return i.call(null,e,0)}catch(t){return i.call(this,e,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:a}catch(e){i=a}try{o="function"==typeof clearTimeout?clearTimeout:r}catch(e){o=r}}();var d,c=[],u=!1,h=-1;function f(){u&&d&&(u=!1,d.length?c=d.concat(c):h=-1,c.length&&l())}function l(){if(!u){var e=s(f);u=!0;for(var t=c.length;t;){for(d=c,c=[];++h<t;)d&&d[h].run();h=-1,t=c.length}d=null,u=!1,function(e){if(o===clearTimeout)return clearTimeout(e);if((o===r||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}(e)}}function g(e,t){this.fun=e,this.array=t}function m(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(1<arguments.length)for(var i=1;i<arguments.length;i++)t[i-1]=arguments[i];c.push(new g(e,t)),1!==c.length||u||s(l)},g.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=m,n.addListener=m,n.once=m,n.off=m,n.removeListener=m,n.removeAllListeners=m,n.emit=m,n.prependListener=m,n.prependOnceListener=m,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}}])});