/**
 * Skipped minification because the original files appears to be already minified.
 * Original file: /npm/p5.rec@0.1.6/dist/p5.rec.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
function e(e,t){return e(t={exports:{}},t.exports),t.exports}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self,e(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",s=n.toStringTag||"@@toStringTag";function a(e,t,r,n){var o=Object.create((t&&t.prototype instanceof f?t:f).prototype),i=new x(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var s=r.delegate;if(s){var a=v(s,r);if(a){if(a===l)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var f=c(e,t,r);if("normal"===f.type){if(n=r.done?"completed":"suspendedYield",f.arg===l)continue;return{value:f.arg,done:r.done}}"throw"===f.type&&(n="completed",r.method="throw",r.arg=f.arg)}}}(e,r,i),o}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=a;var l={};function f(){}function u(){}function p(){}var d={};d[o]=function(){return this};var m=Object.getPrototypeOf,h=m&&m(m(E([])));h&&h!==t&&r.call(h,o)&&(d=h);var g=p.prototype=f.prototype=Object.create(d);function y(e){["next","throw","return"].forEach(function(t){e[t]=function(e){return this._invoke(t,e)}})}function w(e,t){var n;this._invoke=function(o,i){function s(){return new t(function(n,s){!function n(o,i,s,a){var l=c(e[o],e,i);if("throw"!==l.type){var f=l.arg,u=f.value;return u&&"object"==typeof u&&r.call(u,"__await")?t.resolve(u.__await).then(function(e){n("next",e,s,a)},function(e){n("throw",e,s,a)}):t.resolve(u).then(function(e){f.value=e,s(f)},function(e){return n("throw",e,s,a)})}a(l.arg)}(o,i,n,s)})}return n=n?n.then(s,s):s()}}function v(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,v(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function E(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:F}}function F(){return{value:void 0,done:!0}}return u.prototype=g.constructor=p,p.constructor=u,p[s]=u.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===u||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s in e||(e[s]="GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},y(w.prototype),w.prototype[i]=function(){return this},e.AsyncIterator=w,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var s=new w(a(t,r,n,o),i);return e.isGeneratorFunction(r)?s:s.next().then(function(e){return e.done?e.value:s.next()})},y(g),g[s]="Generator",g[o]=function(){return this},g.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=E,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return s.type="throw",s.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var s=i?i.completion:{};return s.type=e,s.arg=t,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(s)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),_(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:E(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}});var t=["./ffmpeg","-nostdin","-hide_banner"];let r=!1;var n={logging:r,setLogging:e=>{r=e},log:(e,t)=>r?console.log(`[${e}] ${t}`):null},o=e(function(e,t){e.exports=function(){var e=arguments.length;if(0===e)throw new Error("resolveUrl requires at least one argument; got none.");var t=document.createElement("base");if(t.href=arguments[0],1===e)return t.href;var r=document.getElementsByTagName("head")[0];r.insertBefore(t,r.firstChild);for(var n,o=document.createElement("a"),i=1;i<e;i++)o.href=arguments[i],t.href=n=o.href;return r.removeChild(t),n}});const i="browser"===(e=>{const t={};return"undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type||"undefined"!=typeof process&&"object"==typeof process.versions&&process.versions.electron||"object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0?t.type="electron":"object"==typeof window?t.type="browser":"function"==typeof importScripts?t.type="webworker":"object"==typeof process&&(t.type="node"),t.type})()?o:e=>e;let s=0;const a=e=>{const[t,r,n]=e.split(":");return 60*parseFloat(t)*60+60*parseFloat(r)+parseFloat(n)};var c,l=e=>{const t=[];let r=0,n=0;for(;(r=e.indexOf(" ",n))>=0;){let o=e.substring(n,r),i=o.indexOf("'"),s=o.indexOf('"');if(0===i||0===s){const i=o[0],s=e.indexOf(i,n+1);if(s<0)throw new Error(`Bad command escape sequence ${i} near ${r}`);o=e.substring(n+1,s),n=s+2,t.push(o)}else if(i>0||s>0){-1===i&&(i=Infinity),-1===s&&(s=Infinity);const a=i<s?"'":'"',c=Math.min(i,s),l=e.indexOf(a,n+c+1);if(l<0)throw new Error(`Bad command escape sequence ${a} near ${r}`);o=e.substring(n,l+1),n=l+2,t.push(o)}else""!==o?(t.push(o),n=r+1):n=r+1}return n!==e.length&&t.push(e.substring(n)),t},f="@ffmpeg/ffmpeg@0.8.3",u="sha512-VtEMXMTuAYHC7NUh3E89mxbqsLxI3geAr+Z5ZQ+8VQNIl22dBtFZ1x2g76f6w+JIDZkrmjqnZ/6oc/henIEaVw==",p={},d={type:"tag",registry:!0,raw:"@ffmpeg/ffmpeg",name:"@ffmpeg/ffmpeg",escapedName:"@ffmpeg%2fffmpeg",scope:"@ffmpeg",rawSpec:"",saveSpec:null,fetchSpec:"latest"},m=["#USER","/"],h="https://registry.npmjs.org/@ffmpeg/ffmpeg/-/ffmpeg-0.8.3.tgz",g="7266e621bef7e452d6e9cd71e188f9b7da082947",y="/Users/dominikus/Documents/Dr0pb0x/Projects/2005_p5.recorder/p5.recorder",w={name:"Jerome Wu",email:"jeromewus@gmail.com"},v={"./src/node/index.js":"./src/browser/index.js"},b={url:"https://github.com/ffmpegwasm/ffmpeg.wasm/issues"},_={"@ffmpeg/core":"^0.7.1",idb:"^4.0.5","is-electron":"^2.2.0","is-url":"^1.2.4","node-fetch":"^2.6.0","regenerator-runtime":"^0.13.5","resolve-url":"^0.2.1"},x={"@babel/core":"^7.9.0","@babel/preset-env":"^7.9.0","babel-loader":"^8.1.0",cors:"^2.8.5",eslint:"^6.8.0","eslint-config-airbnb-base":"^14.1.0","eslint-plugin-import":"^2.20.1","expect.js":"^0.3.1",express:"^4.17.1",mocha:"^5.2.0","mocha-headless-chrome":"^2.0.3","npm-run-all":"^4.1.5",nyc:"^14.1.1","wait-on":"^3.3.0",webpack:"^4.42.0","webpack-cli":"^3.3.11","webpack-dev-middleware":"^3.7.2"},E={example:"examples"},F={node:">=12.16.1"},j="https://github.com/ffmpegwasm/ffmpeg.wasm#readme",L=["ffmpeg","WebAssembly","video"],P="@ffmpeg/ffmpeg",k={type:"git",url:"git+https://github.com/ffmpegwasm/ffmpeg.wasm.git"},O={build:"rimraf dist && webpack --config scripts/webpack.config.prod.js",lint:"eslint src",prepublishOnly:"npm run build",start:"node scripts/server.js",test:"npm-run-all -p -r start test:all","test:all":"npm-run-all wait test:browser:ffmpeg test:node:all","test:browser":"mocha-headless-chrome -a allow-file-access-from-files -a incognito -a no-sandbox -a disable-setuid-sandbox -a disable-logging -t 300000","test:browser:ffmpeg":"npm run test:browser -- -f ./tests/ffmpeg.test.html","test:node":"node --experimental-wasm-threads --experimental-wasm-bulk-memory node_modules/.bin/_mocha --exit --bail --require ./scripts/test-helper.js","test:node:all":"npm run test:node -- ./tests/*.test.js",wait:"rimraf dist && wait-on http://localhost:3000/dist/ffmpeg.dev.js"},A=[{code:"ENOTSUP",required:{node:">=12.16.1"},pkgid:"@ffmpeg/ffmpeg@0.8.3"},{code:"ENOTSUP",required:{node:">=12.16.1"},pkgid:"@ffmpeg/ffmpeg@0.8.3"}],R=(c={__proto__:null,_from:"@ffmpeg/ffmpeg",_id:f,_inBundle:!1,_integrity:u,_location:"/@ffmpeg/ffmpeg",_phantomChildren:p,_requested:d,_requiredBy:m,_resolved:h,_shasum:g,_spec:"@ffmpeg/ffmpeg",_where:y,author:w,browser:v,bugs:b,bundleDependencies:!1,dependencies:_,deprecated:!1,description:"FFmpeg WebAssembly version",devDependencies:x,directories:E,engines:F,homepage:j,keywords:L,license:"MIT",main:"src/index.js",name:P,repository:k,scripts:O,version:"0.8.3",warnings:A,default:{_from:"@ffmpeg/ffmpeg",_id:f,_inBundle:!1,_integrity:u,_location:"/@ffmpeg/ffmpeg",_phantomChildren:p,_requested:d,_requiredBy:m,_resolved:h,_shasum:g,_spec:"@ffmpeg/ffmpeg",_where:y,author:w,browser:v,bugs:b,bundleDependencies:!1,dependencies:_,deprecated:!1,description:"FFmpeg WebAssembly version",devDependencies:x,directories:E,engines:F,homepage:j,keywords:L,license:"MIT",main:"src/index.js",name:P,repository:k,scripts:O,version:"0.8.3",warnings:A}})&&c.default||c;const{dependencies:N}=R;var S={log:!1,logger:()=>{},progress:()=>{},corePath:"undefined"!=typeof process&&"development"===process.env.FFMPEG_ENV?o("/node_modules/@ffmpeg/core/ffmpeg-core.js"):`https://unpkg.com/@ffmpeg/core@v${N["@ffmpeg/core"].substring(1)}/ffmpeg-core.js`};const{log:T}=n;var q={defaultOptions:S,getModule:async({corePath:e})=>{if(void 0===window.Module){T("info","fetch ffmpeg-core.worker.js script");const t=await(await fetch(e.replace("ffmpeg-core.js","ffmpeg-core.worker.js"))).blob();return window.FFMPEG_CORE_WORKER_SCRIPT=URL.createObjectURL(t),T("info","worker object URL="+window.FFMPEG_CORE_WORKER_SCRIPT),T("info","download ffmpeg-core script (~25 MB) from "+e),new Promise(t=>{const r=document.createElement("script"),n=()=>{r.removeEventListener("load",n),T("info","initialize ffmpeg-core"),window.Module.onRuntimeInitialized=()=>{T("info","ffmpeg-core initialized"),t(window.Module)}};r.src=e,r.type="text/javascript",r.addEventListener("load",n),document.getElementsByTagName("head")[0].appendChild(r)})}return T("info","ffmpeg-core is loaded already"),Promise.resolve(window.Module)},fetchFile:async e=>{let t=e;if(void 0===e)return"undefined";if("string"==typeof e)if(/data:_data\/([a-zA-Z]*);base64,([^"]*)/.test(e))t=atob(e.split(",")[1]).split("").map(e=>e.charCodeAt(0));else{const r=await fetch(o(e));t=await r.arrayBuffer()}else(e instanceof File||e instanceof Blob)&&(t=await(r=e,new Promise((e,t)=>{const n=new FileReader;n.onload=()=>{e(n.result)},n.onerror=({target:{error:{code:e}}})=>{t(Error("File could not be read! Code="+e))},n.readAsArrayBuffer(r)})));var r;return new Uint8Array(t)}};const{setLogging:$,log:B}=n,{defaultOptions:M,getModule:C,fetchFile:I}=q,U=Error("FFmpeg.js is not ready, make sure you have completed load()."),D=Error("FFmpeg.js can only run one command at a time");let G=null,W=null;var V,z,Z=/frame=\s+(\d+)\s+fps/g,Y=function(e){if(e&&e.message)for(var t;null!==(t=Z.exec(e.message));){var r=+t[1]/z.totalFrames;!isNaN(r)&&z.onProgress&&z.onProgress(r)}},H=function(e,t){try{return z=t,console.log("loading ffmpeg"),Promise.resolve(V.load()).then(function(){return console.log("start transcoding"),Promise.resolve(V.write("input.webm",e)).then(function(){return Promise.resolve(V.run("-r "+z.framerate+" -i input.webm -s "+z.width+"x"+z.height+" -crf "+z.crf+" -preset "+z.preset+" -tune animation -pix_fmt yuv420p output.mp4")).then(function(){var e=V.read("output.mp4");return Promise.resolve(V.remove("input.webm")).then(function(){return Promise.resolve(V.remove("output.mp4")).then(function(){z.onFinish(e)})})})})})}catch(e){return Promise.reject(e)}},J=["ultrafast","superfast","veryfast","faster","fast","medium","slow","slower","veryslow"];!function(){var e=!1,r=!1,n={},o=!1,c=[];p5.prototype.startRecording=function(f){var u=this;if(void 0===f&&(f={}),this.noLoop(),!o){!function(e){void 0===e&&(e=!1);var r={log:!1,logger:Y};e&&(r.corePath="/node_modules/@ffmpeg/core/ffmpeg-core.js"),V=((e={})=>{let r=null,n=!1;const{log:o,logger:c,progress:f,...u}=(e=>{const t={...e};return["corePath"].forEach(r=>{void 0!==e[r]&&(t[r]=i(t[r]))}),t})({...M,...e});$(o);const p=(e,t)=>{if(null===G)throw U;return B("info",`FS.${e} ${t[0]}`),G.FS[e](...t)},d=(e,t)=>p("writeFile",[e,t]),m=e=>{if(null===W)throw U;if(n)throw D;return n=!0,new Promise(n=>{const o=[...t,...l(e)].filter(e=>0!==e.length);B("info","ffmpeg command: "+o.join(" ")),r=n,W(o.length,((e,t)=>{const r=e._malloc(t.length*Uint32Array.BYTES_PER_ELEMENT);return t.forEach((t,n)=>{const o=((e,t)=>{const r=e._malloc((t.length+1)*Uint8Array.BYTES_PER_ELEMENT);for(let n=0;n<t.length;n+=1)e.setValue(r+n,t.charCodeAt(n),"i8");return e.setValue(r+t.length,0,"i8"),r})(e,t);e.setValue(r+4*n,o,"i32")}),r})(G,o))})};return{load:async()=>{null===G&&(B("info","load ffmpeg-core"),G=await C(u),G.setLogger(e=>{(({message:e,type:t})=>{"ffmpeg-stdout"===t&&"FFMPEG_END"===e&&null!==r&&(r(),r=null,n=!1)})(e),(({message:e},t)=>{if("string"==typeof e)if(e.startsWith("  Duration")){const t=e.split(", ")[0].split(": ")[1],r=a(t);(0===s||s>r)&&(s=r)}else if(e.startsWith("frame")){const r=e.split("time=")[1].split(" ")[0];t({ratio:a(r)/s})}else e.startsWith("video:")&&t({ratio:1})})(e,f),c(e),B(e.type,e.message)}),null===W&&(W=G.cwrap("proxy_main","number",["number","number"])),B("info","ffmpeg-core loaded"))},FS:p,write:async(e,t)=>p("writeFile",[e,await I(t)]),writeText:d,read:e=>p("readFile",[e]),remove:e=>p("unlink",[e]),ls:e=>p("readdir",[e]),run:m,transcode:(e,t,r="")=>m(`-i ${e} ${r} ${t}`),trim:(e,t,r,n,o="")=>m(`-i ${e} -ss ${r} -to ${n} ${o} ${t}`),concatDemuxer:(e,t,r="")=>{const n=e.reduce((e,t)=>`${e}\nfile ${t}`,"");return d("concat_list.txt",n),m(`-f concat -safe 0 -i concat_list.txt ${r} ${t}`)}}})(r)}(f.standalone);var p=this._draw;this._draw=function(){try{p();var t=function(){if(e)u.canvas?u.canvas.toBlob(function(e){try{return c.push(e),u._requestAnimId=window.requestAnimationFrame(u._draw),Promise.resolve()}catch(e){return Promise.reject(e)}}):u._requestAnimId=window.requestAnimationFrame(u._draw);else{var t=function(){if(!r&&c.length>0)return r=!0,n.totalFrames=c.length,console.log("got "+n.totalFrames+" frames"),Promise.resolve(new Blob(c).arrayBuffer()).then(function(e){var t=new Uint8Array(e);return c=[],r=!1,Promise.resolve(H(t,n)).then(function(){u._requestAnimId=window.requestAnimationFrame(u._draw)})});u._requestAnimId=window.requestAnimationFrame(u._draw)}();if(t&&t.then)return t.then(function(){})}}();return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},this._draw(),o=!0}e=!0;var d=f.preset,m=f.crf,h=f.onProgress,g=f.onFinish;d&&J.includes(d)||(d="slow"),(void 0===m||isNaN(m)||m<0||m>51)&&(m=18),h||(h=function(e){return console.log(e)}),g||(g=function(e){!function(e,t){var r=document.createElement("div");r.style.width="100%",r.style.height="100%",r.style.position="fixed",r.style.display="flex",r.style.top="0px",r.style.left="0px",r.style.backgroundColor="rgba(0,0,0,0.8)";var n=document.createElement("button");n.innerHTML="&times;",n.style.color="white",n.style.backgroundColor="black",n.style.border="3px solid white",n.style.borderRadius="100%",n.style.fontSize="16px",n.style.fontWeight="bold",n.style.padding="2px 6px 1px 6px",n.style.position="fixed",n.style.top="10px",n.style.right="10px",n.onclick=function(){r.remove()},r.appendChild(n);var o=document.createElement("video");o.width=t.width,o.height=t.height,o.style.display="block",o.style.margin="auto",o.loop=!0,o.controls=!0;var i=URL.createObjectURL(new Blob([e.buffer],{type:"video/mp4"}));o.src=i,r.appendChild(o),document.querySelector("body").appendChild(r)}(e,n)}),n={width:this.width,height:this.height,pixelDensity:this._pixelDensity,framerate:this._targetFrameRate,crf:m,preset:d,onProgress:h,onFinish:g},console.log(n)},p5.prototype.stopRecording=function(){e=!1}}();
//# sourceMappingURL=p5.rec.js.map
