(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["CanvasCaptureLib"] = factory(); else root["CanvasCaptureLib"] = factory(); })(self, () => { return /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ 76: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const resolveURL = __webpack_require__(72); const { devDependencies } = __webpack_require__(681); /* * Default options for browser environment */ module.exports = { corePath: false ? 0 : `https://unpkg.com/@ffmpeg/core@${devDependencies['@ffmpeg/core'].substring(1)}/dist/ffmpeg-core.js`, }; /***/ }), /***/ 339: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const resolveURL = __webpack_require__(72); const readFromBlobOrFile = (blob) => ( new Promise((resolve, reject) => { const fileReader = new FileReader(); fileReader.onload = () => { resolve(fileReader.result); }; fileReader.onerror = ({ target: { error: { code } } }) => { reject(Error(`File could not be read! Code=${code}`)); }; fileReader.readAsArrayBuffer(blob); }) ); module.exports = async (_data) => { let data = _data; if (typeof _data === 'undefined') { return new Uint8Array(); } if (typeof _data === 'string') { /* From base64 format */ if (/data:_data\/([a-zA-Z]*);base64,([^"]*)/.test(_data)) { data = atob(_data.split(',')[1]) .split('') .map((c) => c.charCodeAt(0)); /* From remote server/URL */ } else { const res = await fetch(resolveURL(_data)); data = await res.arrayBuffer(); } /* From Blob or File */ } else if (_data instanceof File || _data instanceof Blob) { data = await readFromBlobOrFile(_data); } return new Uint8Array(data); }; /***/ }), /***/ 440: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /* eslint-disable no-undef */ const resolveURL = __webpack_require__(72); const { log } = __webpack_require__(888); /* * Fetch data from remote URL and convert to blob URL * to avoid CORS issue */ const toBlobURL = async (url, mimeType) => { log('info', `fetch ${url}`); const buf = await (await fetch(url)).arrayBuffer(); log('info', `${url} file size = ${buf.byteLength} bytes`); const blob = new Blob([buf], { type: mimeType }); const blobURL = URL.createObjectURL(blob); log('info', `${url} blob URL = ${blobURL}`); return blobURL; }; module.exports = async ({ corePath: _corePath }) => { if (typeof _corePath !== 'string') { throw Error('corePath should be a string!'); } const coreRemotePath = resolveURL(_corePath); const corePath = await toBlobURL( coreRemotePath, 'application/javascript', ); const wasmPath = await toBlobURL( coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.wasm'), 'application/wasm', ); const workerPath = await toBlobURL( coreRemotePath.replace('ffmpeg-core.js', 'ffmpeg-core.worker.js'), 'application/javascript', ); if (typeof createFFmpegCore === 'undefined') { return new Promise((resolve) => { const script = document.createElement('script'); const eventHandler = () => { script.removeEventListener('load', eventHandler); log('info', 'ffmpeg-core.js script loaded'); resolve({ createFFmpegCore, corePath, wasmPath, workerPath, }); }; script.src = corePath; script.type = 'text/javascript'; script.addEventListener('load', eventHandler); document.getElementsByTagName('head')[0].appendChild(script); }); } log('info', 'ffmpeg-core.js script is loaded already'); return Promise.resolve({ createFFmpegCore, corePath, wasmPath, workerPath, }); }; /***/ }), /***/ 451: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const defaultOptions = __webpack_require__(76); const getCreateFFmpegCore = __webpack_require__(440); const fetchFile = __webpack_require__(339); module.exports = { defaultOptions, getCreateFFmpegCore, fetchFile, }; /***/ }), /***/ 617: /***/ ((module) => { module.exports = { defaultArgs: [ /* args[0] is always the binary path */ './ffmpeg', /* Disable interaction mode */ '-nostdin', /* Force to override output file */ '-y', ], baseOptions: { /* Flag to turn on/off log messages in console */ log: false, /* * Custom logger to get ffmpeg.wasm output messages. * a sample logger looks like this: * * ``` * logger = ({ type, message }) => { * console.log(type, message); * } * ``` * * type can be one of following: * * info: internal workflow debug messages * fferr: ffmpeg native stderr output * ffout: ffmpeg native stdout output */ logger: () => {}, /* * Progress handler to get current progress of ffmpeg command. * a sample progress handler looks like this: * * ``` * progress = ({ ratio }) => { * console.log(ratio); * } * ``` * * ratio is a float number between 0 to 1. */ progress: () => {}, /* * Path to find/download ffmpeg.wasm-core, * this value should be overwriten by `defaultOptions` in * each environment. */ corePath: '', }, }; /***/ }), /***/ 648: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const { defaultArgs, baseOptions } = __webpack_require__(617); const { setLogging, setCustomLogger, log } = __webpack_require__(888); const parseProgress = __webpack_require__(405); const parseArgs = __webpack_require__(10); const { defaultOptions, getCreateFFmpegCore } = __webpack_require__(451); const { version } = __webpack_require__(681); const NO_LOAD = Error('ffmpeg.wasm is not ready, make sure you have completed load().'); module.exports = (_options = {}) => { const { log: logging, logger, progress: optProgress, ...options } = { ...baseOptions, ...defaultOptions, ..._options, }; let Core = null; let ffmpeg = null; let runResolve = null; let running = false; let progress = optProgress; const detectCompletion = (message) => { if (message === 'FFMPEG_END' && runResolve !== null) { runResolve(); runResolve = null; running = false; } }; const parseMessage = ({ type, message }) => { log(type, message); parseProgress(message, progress); detectCompletion(message); }; /* * Load ffmpeg.wasm-core script. * In browser environment, the ffmpeg.wasm-core script is fetch from * CDN and can be assign to a local path by assigning `corePath`. * In node environment, we use dynamic require and the default `corePath` * is `$ffmpeg/core`. * * Typically the load() func might take few seconds to minutes to complete, * better to do it as early as possible. * */ const load = async () => { log('info', 'load ffmpeg-core'); if (Core === null) { log('info', 'loading ffmpeg-core'); /* * In node environment, all paths are undefined as there * is no need to set them. */ const { createFFmpegCore, corePath, workerPath, wasmPath, } = await getCreateFFmpegCore(options); Core = await createFFmpegCore({ /* * Assign mainScriptUrlOrBlob fixes chrome extension web worker issue * as there is no document.currentScript in the context of content_scripts */ mainScriptUrlOrBlob: corePath, printErr: (message) => parseMessage({ type: 'fferr', message }), print: (message) => parseMessage({ type: 'ffout', message }), /* * locateFile overrides paths of files that is loaded by main script (ffmpeg-core.js). * It is critical for browser environment and we override both wasm and worker paths * as we are using blob URL instead of original URL to avoid cross origin issues. */ locateFile: (path, prefix) => { if (typeof window !== 'undefined') { if (typeof wasmPath !== 'undefined' && path.endsWith('ffmpeg-core.wasm')) { return wasmPath; } if (typeof workerPath !== 'undefined' && path.endsWith('ffmpeg-core.worker.js')) { return workerPath; } } return prefix + path; }, }); ffmpeg = Core.cwrap('proxy_main', 'number', ['number', 'number']); log('info', 'ffmpeg-core loaded'); } else { throw Error('ffmpeg.wasm was loaded, you should not load it again, use ffmpeg.isLoaded() to check next time.'); } }; /* * Determine whether the Core is loaded. */ const isLoaded = () => Core !== null; /* * Run ffmpeg command. * This is the major function in ffmpeg.wasm, you can just imagine it * as ffmpeg native cli and what you need to pass is the same. * * For example, you can convert native command below: * * ``` * $ ffmpeg -i video.avi -c:v libx264 video.mp4 * ``` * * To * * ``` * await ffmpeg.run('-i', 'video.avi', '-c:v', 'libx264', 'video.mp4'); * ``` * */ const run = (..._args) => { log('info', `run ffmpeg command: ${_args.join(' ')}`); if (Core === null) { throw NO_LOAD; } else if (running) { throw Error('ffmpeg.wasm can only run one command at a time'); } else { running = true; return new Promise((resolve) => { const args = [...defaultArgs, ..._args].filter((s) => s.length !== 0); runResolve = resolve; ffmpeg(...parseArgs(Core, args)); }); } }; /* * Run FS operations. * For input/output file of ffmpeg.wasm, it is required to save them to MEMFS * first so that ffmpeg.wasm is able to consume them. Here we rely on the FS * methods provided by Emscripten. * * Common methods to use are: * ffmpeg.FS('writeFile', 'video.avi', new Uint8Array(...)): writeFile writes * data to MEMFS. You need to use Uint8Array for binary data. * ffmpeg.FS('readFile', 'video.mp4'): readFile from MEMFS. * ffmpeg.FS('unlink', 'video.map'): delete file from MEMFS. * * For more info, check https://emscripten.org/docs/api_reference/Filesystem-API.html * */ const FS = (method, ...args) => { log('info', `run FS.${method} ${args.map((arg) => (typeof arg === 'string' ? arg : `<${arg.length} bytes binary file>`)).join(' ')}`); if (Core === null) { throw NO_LOAD; } else { let ret = null; try { ret = Core.FS[method](...args); } catch (e) { if (method === 'readdir') { throw Error(`ffmpeg.FS('readdir', '${args[0]}') error. Check if the path exists, ex: ffmpeg.FS('readdir', '/')`); } else if (method === 'readFile') { throw Error(`ffmpeg.FS('readFile', '${args[0]}') error. Check if the path exists`); } else { throw Error('Oops, something went wrong in FS operation.'); } } return ret; } }; /** * forcibly terminate the ffmpeg program. */ const exit = () => { if (Core === null) { throw NO_LOAD; } else { running = false; Core.exit(1); Core = null; ffmpeg = null; runResolve = null; } }; const setProgress = (_progress) => { progress = _progress; }; const setLogger = (_logger) => { setCustomLogger(_logger); }; setLogging(logging); setCustomLogger(logger); log('info', `use ffmpeg.wasm v${version}`); return { setProgress, setLogger, setLogging, load, isLoaded, run, exit, FS, }; }; /***/ }), /***/ 888: /***/ ((module) => { let logging = false; let customLogger = () => {}; const setLogging = (_logging) => { logging = _logging; }; const setCustomLogger = (logger) => { customLogger = logger; }; const log = (type, message) => { customLogger({ type, message }); if (logging) { console.log(`[${type}] ${message}`); } }; module.exports = { logging, setLogging, setCustomLogger, log, }; /***/ }), /***/ 10: /***/ ((module) => { module.exports = (Core, args) => { const argsPtr = Core._malloc(args.length * Uint32Array.BYTES_PER_ELEMENT); args.forEach((s, idx) => { const buf = Core._malloc(s.length + 1); Core.writeAsciiToMemory(s, buf); Core.setValue(argsPtr + (Uint32Array.BYTES_PER_ELEMENT * idx), buf, 'i32'); }); return [args.length, argsPtr]; }; /***/ }), /***/ 405: /***/ ((module) => { let duration = 0; let ratio = 0; const ts2sec = (ts) => { const [h, m, s] = ts.split(':'); return (parseFloat(h) * 60 * 60) + (parseFloat(m) * 60) + parseFloat(s); }; module.exports = (message, progress) => { if (typeof message === 'string') { if (message.startsWith(' Duration')) { const ts = message.split(', ')[0].split(': ')[1]; const d = ts2sec(ts); progress({ duration: d, ratio }); if (duration === 0 || duration > d) { duration = d; } } else if (message.startsWith('frame') || message.startsWith('size')) { const ts = message.split('time=')[1].split(' ')[0]; const t = ts2sec(ts); ratio = t / duration; progress({ ratio, time: t }); } else if (message.startsWith('video:')) { progress({ ratio: 1 }); duration = 0; } } }; /***/ }), /***/ 809: /***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.changeDpiBlob = changeDpiBlob; exports.changeDpiDataUrl = changeDpiDataUrl; function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } function createPngDataTable() { /* Table of CRCs of all 8-bit messages. */ var crcTable = new Int32Array(256); for (var n = 0; n < 256; n++) { var c = n; for (var k = 0; k < 8; k++) { c = c & 1 ? 0xedb88320 ^ c >>> 1 : c >>> 1; } crcTable[n] = c; } return crcTable; } function calcCrc(buf) { var c = -1; if (!pngDataTable) pngDataTable = createPngDataTable(); for (var n = 0; n < buf.length; n++) { c = pngDataTable[(c ^ buf[n]) & 0xFF] ^ c >>> 8; } return c ^ -1; } var pngDataTable = void 0; var PNG = 'image/png'; var JPEG = 'image/jpeg'; // those are 3 possible signature of the physBlock in base64. // the pHYs signature block is preceed by the 4 bytes of lenght. The length of // the block is always 9 bytes. So a phys block has always this signature: // 0 0 0 9 p H Y s. // However the data64 encoding aligns we will always find one of those 3 strings. // this allow us to find this particular occurence of the pHYs block without // converting from b64 back to string var b64PhysSignature1 = 'AAlwSFlz'; var b64PhysSignature2 = 'AAAJcEhZ'; var b64PhysSignature3 = 'AAAACXBI'; var _P = 'p'.charCodeAt(0); var _H = 'H'.charCodeAt(0); var _Y = 'Y'.charCodeAt(0); var _S = 's'.charCodeAt(0); function changeDpiBlob(blob, dpi) { // 33 bytes are ok for pngs and jpegs // to contain the information. var headerChunk = blob.slice(0, 33); return new Promise(function (resolve, reject) { var fileReader = new FileReader(); fileReader.onload = function () { var dataArray = new Uint8Array(fileReader.result); var tail = blob.slice(33); var changedArray = changeDpiOnArray(dataArray, dpi, blob.type); resolve(new Blob([changedArray, tail], { type: blob.type })); }; fileReader.readAsArrayBuffer(headerChunk); }); } function changeDpiDataUrl(base64Image, dpi) { var dataSplitted = base64Image.split(','); var format = dataSplitted[0]; var body = dataSplitted[1]; var type = void 0; var headerLength = void 0; var overwritepHYs = false; if (format.indexOf(PNG) !== -1) { type = PNG; var b64Index = detectPhysChunkFromDataUrl(body); // 28 bytes in dataUrl are 21bytes, length of phys chunk with everything inside. if (b64Index >= 0) { headerLength = Math.ceil((b64Index + 28) / 3) * 4; overwritepHYs = true; } else { headerLength = 33 / 3 * 4; } } if (format.indexOf(JPEG) !== -1) { type = JPEG; headerLength = 18 / 3 * 4; } // 33 bytes are ok for pngs and jpegs // to contain the information. var stringHeader = body.substring(0, headerLength); var restOfData = body.substring(headerLength); var headerBytes = atob(stringHeader); var dataArray = new Uint8Array(headerBytes.length); for (var i = 0; i < dataArray.length; i++) { dataArray[i] = headerBytes.charCodeAt(i); } var finalArray = changeDpiOnArray(dataArray, dpi, type, overwritepHYs); var base64Header = btoa(String.fromCharCode.apply(String, _toConsumableArray(finalArray))); return [format, ',', base64Header, restOfData].join(''); } function detectPhysChunkFromDataUrl(data) { var b64index = data.indexOf(b64PhysSignature1); if (b64index === -1) { b64index = data.indexOf(b64PhysSignature2); } if (b64index === -1) { b64index = data.indexOf(b64PhysSignature3); } // if b64index === -1 chunk is not found return b64index; } function searchStartOfPhys(data) { var length = data.length - 1; // we check from the end since we cut the string in proximity of the header // the header is within 21 bytes from the end. for (var i = length; i >= 4; i--) { if (data[i - 4] === 9 && data[i - 3] === _P && data[i - 2] === _H && data[i - 1] === _Y && data[i] === _S) { return i - 3; } } } function changeDpiOnArray(dataArray, dpi, format, overwritepHYs) { if (format === JPEG) { dataArray[13] = 1; // 1 pixel per inch or 2 pixel per cm dataArray[14] = dpi >> 8; // dpiX high byte dataArray[15] = dpi & 0xff; // dpiX low byte dataArray[16] = dpi >> 8; // dpiY high byte dataArray[17] = dpi & 0xff; // dpiY low byte return dataArray; } if (format === PNG) { var physChunk = new Uint8Array(13); // chunk header pHYs // 9 bytes of data // 4 bytes of crc // this multiplication is because the standard is dpi per meter. dpi *= 39.3701; physChunk[0] = _P; physChunk[1] = _H; physChunk[2] = _Y; physChunk[3] = _S; physChunk[4] = dpi >>> 24; // dpiX highest byte physChunk[5] = dpi >>> 16; // dpiX veryhigh byte physChunk[6] = dpi >>> 8; // dpiX high byte physChunk[7] = dpi & 0xff; // dpiX low byte physChunk[8] = physChunk[4]; // dpiY highest byte physChunk[9] = physChunk[5]; // dpiY veryhigh byte physChunk[10] = physChunk[6]; // dpiY high byte physChunk[11] = physChunk[7]; // dpiY low byte physChunk[12] = 1; // dot per meter.... var crc = calcCrc(physChunk); var crcChunk = new Uint8Array(4); crcChunk[0] = crc >>> 24; crcChunk[1] = crc >>> 16; crcChunk[2] = crc >>> 8; crcChunk[3] = crc & 0xff; if (overwritepHYs) { var startingIndex = searchStartOfPhys(dataArray); dataArray.set(physChunk, startingIndex); dataArray.set(crcChunk, startingIndex + 13); return dataArray; } else { // i need to give back an array of data that is divisible by 3 so that // dataurl encoding gives me integers, for luck this chunk is 17 + 4 = 21 // if it was we could add a text chunk contaning some info, untill desired // length is met. // chunk structur 4 bytes for length is 9 var chunkLength = new Uint8Array(4); chunkLength[0] = 0; chunkLength[1] = 0; chunkLength[2] = 0; chunkLength[3] = 9; var finalHeader = new Uint8Array(54); finalHeader.set(dataArray, 0); finalHeader.set(chunkLength, 33); finalHeader.set(physChunk, 37); finalHeader.set(crcChunk, 50); return finalHeader; } } } /***/ }), /***/ 162: /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function(a,b){if(true)!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (b), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));else {}})(this,function(){"use strict";function b(a,b){return"undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Deprecated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(a,b,c){var d=new XMLHttpRequest;d.open("GET",a),d.responseType="blob",d.onload=function(){g(d.response,b,c)},d.onerror=function(){console.error("could not download file")},d.send()}function d(a){var b=new XMLHttpRequest;b.open("HEAD",a,!1);try{b.send()}catch(a){}return 200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"))}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b)}}var f="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof __webpack_require__.g&&__webpack_require__.g.global===__webpack_require__.g?__webpack_require__.g:void 0,a=f.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),g=f.saveAs||("object"!=typeof window||window!==f?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(b,g,h){var i=f.URL||f.webkitURL,j=document.createElement("a");g=g||b.name||"download",j.download=g,j.rel="noopener","string"==typeof b?(j.href=b,j.origin===location.origin?e(j):d(j.href)?c(b,g,h):e(j,j.target="_blank")):(j.href=i.createObjectURL(b),setTimeout(function(){i.revokeObjectURL(j.href)},4E4),setTimeout(function(){e(j)},0))}:"msSaveOrOpenBlob"in navigator?function(f,g,h){if(g=g||f.name||"download","string"!=typeof f)navigator.msSaveOrOpenBlob(b(f,h),g);else if(d(f))c(f,g,h);else{var i=document.createElement("a");i.href=f,i.target="_blank",setTimeout(function(){e(i)})}}:function(b,d,e,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),"string"==typeof b)return c(b,d,e);var h="application/octet-stream"===b.type,i=/constructor/i.test(f.HTMLElement)||f.safari,j=/CriOS\/[\d]+/.test(navigator.userAgent);if((j||h&&i||a)&&"undefined"!=typeof FileReader){var k=new FileReader;k.onloadend=function(){var a=k.result;a=j?a:a.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=a:location=a,g=null},k.readAsDataURL(b)}else{var l=f.URL||f.webkitURL,m=l.createObjectURL(b);g?g.location=m:location.href=m,g=null,setTimeout(function(){l.revokeObjectURL(m)},4E4)}});f.saveAs=g.saveAs=g, true&&(module.exports=g)}); //# sourceMappingURL=FileSaver.min.js.map /***/ }), /***/ 733: /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /*! JSZip v3.7.1 - A JavaScript class for generating and reading zip files (c) 2009-2016 Stuart Knightley Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown. JSZip uses the library pako released under the MIT license : https://github.com/nodeca/pako/blob/master/LICENSE */ !function(t){if(true)module.exports=t();else {}}(function(){return function s(a,o,h){function u(r,t){if(!o[r]){if(!a[r]){var e=undefined;if(!t&&e)return require(r,!0);if(l)return l(r,!0);var i=new Error("Cannot find module '"+r+"'");throw i.code="MODULE_NOT_FOUND",i}var n=o[r]={exports:{}};a[r][0].call(n.exports,function(t){var e=a[r][1][t];return u(e||t)},n,n.exports,s,a,o,h)}return o[r].exports}for(var l=undefined,t=0;t>2,s=(3&e)<<4|r>>4,a=1>6:64,o=2>4,r=(15&n)<<4|(s=p.indexOf(t.charAt(o++)))>>2,i=(3&s)<<6|(a=p.indexOf(t.charAt(o++))),l[h++]=e,64!==s&&(l[h++]=r),64!==a&&(l[h++]=i);return l}},{"./support":30,"./utils":32}],2:[function(t,e,r){"use strict";var i=t("./external"),n=t("./stream/DataWorker"),s=t("./stream/Crc32Probe"),a=t("./stream/DataLengthProbe");function o(t,e,r,i,n){this.compressedSize=t,this.uncompressedSize=e,this.crc32=r,this.compression=i,this.compressedContent=n}o.prototype={getContentWorker:function(){var t=new n(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new a("data_length")),e=this;return t.on("end",function(){if(this.streamInfo.data_length!==e.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),t},getCompressedWorker:function(){return new n(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},o.createWorkerFrom=function(t,e,r){return t.pipe(new s).pipe(new a("uncompressedSize")).pipe(e.compressWorker(r)).pipe(new a("compressedSize")).withStreamInfo("compression",e)},e.exports=o},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,e,r){"use strict";var i=t("./stream/GenericWorker");r.STORE={magic:"\0\0",compressWorker:function(t){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},r.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,e,r){"use strict";var i=t("./utils");var o=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();e.exports=function(t,e){return void 0!==t&&t.length?"string"!==i.getTypeOf(t)?function(t,e,r,i){var n=o,s=i+r;t^=-1;for(var a=i;a>>8^n[255&(t^e[a])];return-1^t}(0|e,t,t.length,0):function(t,e,r,i){var n=o,s=i+r;t^=-1;for(var a=i;a>>8^n[255&(t^e.charCodeAt(a))];return-1^t}(0|e,t,t.length,0):0}},{"./utils":32}],5:[function(t,e,r){"use strict";r.base64=!1,r.binary=!1,r.dir=!1,r.createFolders=!0,r.date=null,r.compression=null,r.compressionOptions=null,r.comment=null,r.unixPermissions=null,r.dosPermissions=null},{}],6:[function(t,e,r){"use strict";var i=null;i="undefined"!=typeof Promise?Promise:t("lie"),e.exports={Promise:i}},{lie:37}],7:[function(t,e,r){"use strict";var i="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,n=t("pako"),s=t("./utils"),a=t("./stream/GenericWorker"),o=i?"uint8array":"array";function h(t,e){a.call(this,"FlateWorker/"+t),this._pako=null,this._pakoAction=t,this._pakoOptions=e,this.meta={}}r.magic="\b\0",s.inherits(h,a),h.prototype.processChunk=function(t){this.meta=t.meta,null===this._pako&&this._createPako(),this._pako.push(s.transformTo(o,t.data),!1)},h.prototype.flush=function(){a.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){a.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new n[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},r.compressWorker=function(t){return new h("Deflate",t)},r.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,e,r){"use strict";function A(t,e){var r,i="";for(r=0;r>>=8;return i}function i(t,e,r,i,n,s){var a,o,h=t.file,u=t.compression,l=s!==O.utf8encode,f=I.transformTo("string",s(h.name)),d=I.transformTo("string",O.utf8encode(h.name)),c=h.comment,p=I.transformTo("string",s(c)),m=I.transformTo("string",O.utf8encode(c)),_=d.length!==h.name.length,g=m.length!==c.length,b="",v="",y="",w=h.dir,k=h.date,x={crc32:0,compressedSize:0,uncompressedSize:0};e&&!r||(x.crc32=t.crc32,x.compressedSize=t.compressedSize,x.uncompressedSize=t.uncompressedSize);var S=0;e&&(S|=8),l||!_&&!g||(S|=2048);var z=0,C=0;w&&(z|=16),"UNIX"===n?(C=798,z|=function(t,e){var r=t;return t||(r=e?16893:33204),(65535&r)<<16}(h.unixPermissions,w)):(C=20,z|=function(t){return 63&(t||0)}(h.dosPermissions)),a=k.getUTCHours(),a<<=6,a|=k.getUTCMinutes(),a<<=5,a|=k.getUTCSeconds()/2,o=k.getUTCFullYear()-1980,o<<=4,o|=k.getUTCMonth()+1,o<<=5,o|=k.getUTCDate(),_&&(v=A(1,1)+A(B(f),4)+d,b+="up"+A(v.length,2)+v),g&&(y=A(1,1)+A(B(p),4)+m,b+="uc"+A(y.length,2)+y);var E="";return E+="\n\0",E+=A(S,2),E+=u.magic,E+=A(a,2),E+=A(o,2),E+=A(x.crc32,4),E+=A(x.compressedSize,4),E+=A(x.uncompressedSize,4),E+=A(f.length,2),E+=A(b.length,2),{fileRecord:R.LOCAL_FILE_HEADER+E+f+b,dirRecord:R.CENTRAL_FILE_HEADER+A(C,2)+E+A(p.length,2)+"\0\0\0\0"+A(z,4)+A(i,4)+f+b+p}}var I=t("../utils"),n=t("../stream/GenericWorker"),O=t("../utf8"),B=t("../crc32"),R=t("../signature");function s(t,e,r,i){n.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=e,this.zipPlatform=r,this.encodeFileName=i,this.streamFiles=t,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}I.inherits(s,n),s.prototype.push=function(t){var e=t.meta.percent||0,r=this.entriesCount,i=this._sources.length;this.accumulate?this.contentBuffer.push(t):(this.bytesWritten+=t.data.length,n.prototype.push.call(this,{data:t.data,meta:{currentFile:this.currentFile,percent:r?(e+100*(r-i-1))/r:100}}))},s.prototype.openedSource=function(t){this.currentSourceOffset=this.bytesWritten,this.currentFile=t.file.name;var e=this.streamFiles&&!t.file.dir;if(e){var r=i(t,e,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},s.prototype.closedSource=function(t){this.accumulate=!1;var e=this.streamFiles&&!t.file.dir,r=i(t,e,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),e)this.push({data:function(t){return R.DATA_DESCRIPTOR+A(t.crc32,4)+A(t.compressedSize,4)+A(t.uncompressedSize,4)}(t),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},s.prototype.flush=function(){for(var t=this.bytesWritten,e=0;e=this.index;e--)r=(r<<8)+this.byteAt(e);return this.index+=t,r},readString:function(t){return i.transformTo("string",this.readData(t))},readData:function(t){},lastIndexOfSignature:function(t){},readAndCheckSignature:function(t){},readDate:function(){var t=this.readInt(4);return new Date(Date.UTC(1980+(t>>25&127),(t>>21&15)-1,t>>16&31,t>>11&31,t>>5&63,(31&t)<<1))}},e.exports=n},{"../utils":32}],19:[function(t,e,r){"use strict";var i=t("./Uint8ArrayReader");function n(t){i.call(this,t)}t("../utils").inherits(n,i),n.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,e,r){"use strict";var i=t("./DataReader");function n(t){i.call(this,t)}t("../utils").inherits(n,i),n.prototype.byteAt=function(t){return this.data.charCodeAt(this.zero+t)},n.prototype.lastIndexOfSignature=function(t){return this.data.lastIndexOf(t)-this.zero},n.prototype.readAndCheckSignature=function(t){return t===this.readData(4)},n.prototype.readData=function(t){this.checkOffset(t);var e=this.data.slice(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./DataReader":18}],21:[function(t,e,r){"use strict";var i=t("./ArrayReader");function n(t){i.call(this,t)}t("../utils").inherits(n,i),n.prototype.readData=function(t){if(this.checkOffset(t),0===t)return new Uint8Array(0);var e=this.data.subarray(this.zero+this.index,this.zero+this.index+t);return this.index+=t,e},e.exports=n},{"../utils":32,"./ArrayReader":17}],22:[function(t,e,r){"use strict";var i=t("../utils"),n=t("../support"),s=t("./ArrayReader"),a=t("./StringReader"),o=t("./NodeBufferReader"),h=t("./Uint8ArrayReader");e.exports=function(t){var e=i.getTypeOf(t);return i.checkSupport(e),"string"!==e||n.uint8array?"nodebuffer"===e?new o(t):n.uint8array?new h(i.transformTo("uint8array",t)):new s(i.transformTo("array",t)):new a(t)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,e,r){"use strict";r.LOCAL_FILE_HEADER="PK",r.CENTRAL_FILE_HEADER="PK",r.CENTRAL_DIRECTORY_END="PK",r.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",r.ZIP64_CENTRAL_DIRECTORY_END="PK",r.DATA_DESCRIPTOR="PK\b"},{}],24:[function(t,e,r){"use strict";var i=t("./GenericWorker"),n=t("../utils");function s(t){i.call(this,"ConvertWorker to "+t),this.destType=t}n.inherits(s,i),s.prototype.processChunk=function(t){this.push({data:n.transformTo(this.destType,t.data),meta:t.meta})},e.exports=s},{"../utils":32,"./GenericWorker":28}],25:[function(t,e,r){"use strict";var i=t("./GenericWorker"),n=t("../crc32");function s(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(s,i),s.prototype.processChunk=function(t){this.streamInfo.crc32=n(t.data,this.streamInfo.crc32||0),this.push(t)},e.exports=s},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,e,r){"use strict";var i=t("../utils"),n=t("./GenericWorker");function s(t){n.call(this,"DataLengthProbe for "+t),this.propName=t,this.withStreamInfo(t,0)}i.inherits(s,n),s.prototype.processChunk=function(t){if(t){var e=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=e+t.data.length}n.prototype.processChunk.call(this,t)},e.exports=s},{"../utils":32,"./GenericWorker":28}],27:[function(t,e,r){"use strict";var i=t("../utils"),n=t("./GenericWorker");function s(t){n.call(this,"DataWorker");var e=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,t.then(function(t){e.dataIsReady=!0,e.data=t,e.max=t&&t.length||0,e.type=i.getTypeOf(t),e.isPaused||e._tickAndRepeat()},function(t){e.error(t)})}i.inherits(s,n),s.prototype.cleanUp=function(){n.prototype.cleanUp.call(this),this.data=null},s.prototype.resume=function(){return!!n.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},s.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},s.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var t=null,e=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":t=this.data.substring(this.index,e);break;case"uint8array":t=this.data.subarray(this.index,e);break;case"array":case"nodebuffer":t=this.data.slice(this.index,e)}return this.index=e,this.push({data:t,meta:{percent:this.max?this.index/this.max*100:0}})},e.exports=s},{"../utils":32,"./GenericWorker":28}],28:[function(t,e,r){"use strict";function i(t){this.name=t||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(t){this.emit("data",t)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(t){this.emit("error",t)}return!0},error:function(t){return!this.isFinished&&(this.isPaused?this.generatedError=t:(this.isFinished=!0,this.emit("error",t),this.previous&&this.previous.error(t),this.cleanUp()),!0)},on:function(t,e){return this._listeners[t].push(e),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(t,e){if(this._listeners[t])for(var r=0;r "+t:t}},e.exports=i},{}],29:[function(t,e,r){"use strict";var h=t("../utils"),n=t("./ConvertWorker"),s=t("./GenericWorker"),u=t("../base64"),i=t("../support"),a=t("../external"),o=null;if(i.nodestream)try{o=t("../nodejs/NodejsStreamOutputAdapter")}catch(t){}function l(t,o){return new a.Promise(function(e,r){var i=[],n=t._internalType,s=t._outputType,a=t._mimeType;t.on("data",function(t,e){i.push(t),o&&o(e)}).on("error",function(t){i=[],r(t)}).on("end",function(){try{var t=function(t,e,r){switch(t){case"blob":return h.newBlob(h.transformTo("arraybuffer",e),r);case"base64":return u.encode(e);default:return h.transformTo(t,e)}}(s,function(t,e){var r,i=0,n=null,s=0;for(r=0;r>>6:(r<65536?e[s++]=224|r>>>12:(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63),e[s++]=128|r>>>6&63),e[s++]=128|63&r);return e}(t)},s.utf8decode=function(t){return h.nodebuffer?o.transformTo("nodebuffer",t).toString("utf-8"):function(t){var e,r,i,n,s=t.length,a=new Array(2*s);for(e=r=0;e>10&1023,a[r++]=56320|1023&i)}return a.length!==r&&(a.subarray?a=a.subarray(0,r):a.length=r),o.applyFromCharCode(a)}(t=o.transformTo(h.uint8array?"uint8array":"array",t))},o.inherits(a,i),a.prototype.processChunk=function(t){var e=o.transformTo(h.uint8array?"uint8array":"array",t.data);if(this.leftOver&&this.leftOver.length){if(h.uint8array){var r=e;(e=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),e.set(r,this.leftOver.length)}else e=this.leftOver.concat(e);this.leftOver=null}var i=function(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;0<=r&&128==(192&t[r]);)r--;return r<0?e:0===r?e:r+u[t[r]]>e?r:e}(e),n=e;i!==e.length&&(h.uint8array?(n=e.subarray(0,i),this.leftOver=e.subarray(i,e.length)):(n=e.slice(0,i),this.leftOver=e.slice(i,e.length))),this.push({data:s.utf8decode(n),meta:t.meta})},a.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=a,o.inherits(l,i),l.prototype.processChunk=function(t){this.push({data:s.utf8encode(t.data),meta:t.meta})},s.Utf8EncodeWorker=l},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,e,a){"use strict";var o=t("./support"),h=t("./base64"),r=t("./nodejsUtils"),i=t("set-immediate-shim"),u=t("./external");function n(t){return t}function l(t,e){for(var r=0;r>8;this.dir=!!(16&this.externalFileAttributes),0==t&&(this.dosPermissions=63&this.externalFileAttributes),3==t&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(t){if(this.extraFields[1]){var e=i(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(t){var e,r,i,n=t.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});t.index+4>>6:(r<65536?e[s++]=224|r>>>12:(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63),e[s++]=128|r>>>6&63),e[s++]=128|63&r);return e},r.buf2binstring=function(t){return l(t,t.length)},r.binstring2buf=function(t){for(var e=new h.Buf8(t.length),r=0,i=e.length;r>10&1023,o[i++]=56320|1023&n)}return l(o,i)},r.utf8border=function(t,e){var r;for((e=e||t.length)>t.length&&(e=t.length),r=e-1;0<=r&&128==(192&t[r]);)r--;return r<0?e:0===r?e:r+u[t[r]]>e?r:e}},{"./common":41}],43:[function(t,e,r){"use strict";e.exports=function(t,e,r,i){for(var n=65535&t|0,s=t>>>16&65535|0,a=0;0!==r;){for(r-=a=2e3>>1:t>>>1;e[r]=t}return e}();e.exports=function(t,e,r,i){var n=o,s=i+r;t^=-1;for(var a=i;a>>8^n[255&(t^e[a])];return-1^t}},{}],46:[function(t,e,r){"use strict";var h,d=t("../utils/common"),u=t("./trees"),c=t("./adler32"),p=t("./crc32"),i=t("./messages"),l=0,f=4,m=0,_=-2,g=-1,b=4,n=2,v=8,y=9,s=286,a=30,o=19,w=2*s+1,k=15,x=3,S=258,z=S+x+1,C=42,E=113,A=1,I=2,O=3,B=4;function R(t,e){return t.msg=i[e],e}function T(t){return(t<<1)-(4t.avail_out&&(r=t.avail_out),0!==r&&(d.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))}function N(t,e){u._tr_flush_block(t,0<=t.block_start?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,F(t.strm)}function U(t,e){t.pending_buf[t.pending++]=e}function P(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function L(t,e){var r,i,n=t.max_chain_length,s=t.strstart,a=t.prev_length,o=t.nice_match,h=t.strstart>t.w_size-z?t.strstart-(t.w_size-z):0,u=t.window,l=t.w_mask,f=t.prev,d=t.strstart+S,c=u[s+a-1],p=u[s+a];t.prev_length>=t.good_match&&(n>>=2),o>t.lookahead&&(o=t.lookahead);do{if(u[(r=e)+a]===p&&u[r+a-1]===c&&u[r]===u[s]&&u[++r]===u[s+1]){s+=2,r++;do{}while(u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&u[++s]===u[++r]&&sh&&0!=--n);return a<=t.lookahead?a:t.lookahead}function j(t){var e,r,i,n,s,a,o,h,u,l,f=t.w_size;do{if(n=t.window_size-t.lookahead-t.strstart,t.strstart>=f+(f-z)){for(d.arraySet(t.window,t.window,f,f,0),t.match_start-=f,t.strstart-=f,t.block_start-=f,e=r=t.hash_size;i=t.head[--e],t.head[e]=f<=i?i-f:0,--r;);for(e=r=f;i=t.prev[--e],t.prev[e]=f<=i?i-f:0,--r;);n+=f}if(0===t.strm.avail_in)break;if(a=t.strm,o=t.window,h=t.strstart+t.lookahead,u=n,l=void 0,l=a.avail_in,u=x)for(s=t.strstart-t.insert,t.ins_h=t.window[s],t.ins_h=(t.ins_h<=x&&(t.ins_h=(t.ins_h<=x)if(i=u._tr_tally(t,t.strstart-t.match_start,t.match_length-x),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=x){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<=x&&(t.ins_h=(t.ins_h<=x&&t.match_length<=t.prev_length){for(n=t.strstart+t.lookahead-x,i=u._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-x),t.lookahead-=t.prev_length-1,t.prev_length-=2;++t.strstart<=n&&(t.ins_h=(t.ins_h<t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(j(t),0===t.lookahead&&e===l)return A;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var i=t.block_start+r;if((0===t.strstart||t.strstart>=i)&&(t.lookahead=t.strstart-i,t.strstart=i,N(t,!1),0===t.strm.avail_out))return A;if(t.strstart-t.block_start>=t.w_size-z&&(N(t,!1),0===t.strm.avail_out))return A}return t.insert=0,e===f?(N(t,!0),0===t.strm.avail_out?O:B):(t.strstart>t.block_start&&(N(t,!1),t.strm.avail_out),A)}),new M(4,4,8,4,Z),new M(4,5,16,8,Z),new M(4,6,32,32,Z),new M(4,4,16,16,W),new M(8,16,32,32,W),new M(8,16,128,128,W),new M(8,32,128,256,W),new M(32,128,258,1024,W),new M(32,258,258,4096,W)],r.deflateInit=function(t,e){return Y(t,e,v,15,8,0)},r.deflateInit2=Y,r.deflateReset=K,r.deflateResetKeep=G,r.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?_:(t.state.gzhead=e,m):_},r.deflate=function(t,e){var r,i,n,s;if(!t||!t.state||5>8&255),U(i,i.gzhead.time>>16&255),U(i,i.gzhead.time>>24&255),U(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),U(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(U(i,255&i.gzhead.extra.length),U(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=p(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(U(i,0),U(i,0),U(i,0),U(i,0),U(i,0),U(i,9===i.level?2:2<=i.strategy||i.level<2?4:0),U(i,3),i.status=E);else{var a=v+(i.w_bits-8<<4)<<8;a|=(2<=i.strategy||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(a|=32),a+=31-a%31,i.status=E,P(i,a),0!==i.strstart&&(P(i,t.adler>>>16),P(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(n=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>n&&(t.adler=p(t.adler,i.pending_buf,i.pending-n,n)),F(t),n=i.pending,i.pending!==i.pending_buf_size));)U(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(t.adler=p(t.adler,i.pending_buf,i.pending-n,n)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=p(t.adler,i.pending_buf,i.pending-n,n)),F(t),n=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindexn&&(t.adler=p(t.adler,i.pending_buf,i.pending-n,n)),0===s&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(t.adler=p(t.adler,i.pending_buf,i.pending-n,n)),F(t),n=i.pending,i.pending===i.pending_buf_size)){s=1;break}s=i.gzindexn&&(t.adler=p(t.adler,i.pending_buf,i.pending-n,n)),0===s&&(i.status=103)}else i.status=103;if(103===i.status&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&F(t),i.pending+2<=i.pending_buf_size&&(U(i,255&t.adler),U(i,t.adler>>8&255),t.adler=0,i.status=E)):i.status=E),0!==i.pending){if(F(t),0===t.avail_out)return i.last_flush=-1,m}else if(0===t.avail_in&&T(e)<=T(r)&&e!==f)return R(t,-5);if(666===i.status&&0!==t.avail_in)return R(t,-5);if(0!==t.avail_in||0!==i.lookahead||e!==l&&666!==i.status){var o=2===i.strategy?function(t,e){for(var r;;){if(0===t.lookahead&&(j(t),0===t.lookahead)){if(e===l)return A;break}if(t.match_length=0,r=u._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(N(t,!1),0===t.strm.avail_out))return A}return t.insert=0,e===f?(N(t,!0),0===t.strm.avail_out?O:B):t.last_lit&&(N(t,!1),0===t.strm.avail_out)?A:I}(i,e):3===i.strategy?function(t,e){for(var r,i,n,s,a=t.window;;){if(t.lookahead<=S){if(j(t),t.lookahead<=S&&e===l)return A;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=x&&0t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=x?(r=u._tr_tally(t,1,t.match_length-x),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=u._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(N(t,!1),0===t.strm.avail_out))return A}return t.insert=0,e===f?(N(t,!0),0===t.strm.avail_out?O:B):t.last_lit&&(N(t,!1),0===t.strm.avail_out)?A:I}(i,e):h[i.level].func(i,e);if(o!==O&&o!==B||(i.status=666),o===A||o===O)return 0===t.avail_out&&(i.last_flush=-1),m;if(o===I&&(1===e?u._tr_align(i):5!==e&&(u._tr_stored_block(i,0,0,!1),3===e&&(D(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),F(t),0===t.avail_out))return i.last_flush=-1,m}return e!==f?m:i.wrap<=0?1:(2===i.wrap?(U(i,255&t.adler),U(i,t.adler>>8&255),U(i,t.adler>>16&255),U(i,t.adler>>24&255),U(i,255&t.total_in),U(i,t.total_in>>8&255),U(i,t.total_in>>16&255),U(i,t.total_in>>24&255)):(P(i,t.adler>>>16),P(i,65535&t.adler)),F(t),0=r.w_size&&(0===s&&(D(r.head),r.strstart=0,r.block_start=0,r.insert=0),u=new d.Buf8(r.w_size),d.arraySet(u,e,l-r.w_size,r.w_size,0),e=u,l=r.w_size),a=t.avail_in,o=t.next_in,h=t.input,t.avail_in=l,t.next_in=0,t.input=e,j(r);r.lookahead>=x;){for(i=r.strstart,n=r.lookahead-(x-1);r.ins_h=(r.ins_h<>>=y=v>>>24,p-=y,0===(y=v>>>16&255))C[s++]=65535&v;else{if(!(16&y)){if(0==(64&y)){v=m[(65535&v)+(c&(1<>>=y,p-=y),p<15&&(c+=z[i++]<>>=y=v>>>24,p-=y,!(16&(y=v>>>16&255))){if(0==(64&y)){v=_[(65535&v)+(c&(1<>>=y,p-=y,(y=s-a)>3,c&=(1<<(p-=w<<3))-1,t.next_in=i,t.next_out=s,t.avail_in=i>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function s(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new I.Buf16(320),this.work=new I.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=P,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new I.Buf32(i),e.distcode=e.distdyn=new I.Buf32(n),e.sane=1,e.back=-1,N):U}function o(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,a(t)):U}function h(t,e){var r,i;return t&&t.state?(i=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||15=s.wsize?(I.arraySet(s.window,e,r-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(i<(n=s.wsize-s.wnext)&&(n=i),I.arraySet(s.window,e,r-i,n,s.wnext),(i-=n)?(I.arraySet(s.window,e,r-i,i,0),s.wnext=i,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,r.check=B(r.check,E,2,0),l=u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){t.msg="incorrect header check",r.mode=30;break}if(8!=(15&u)){t.msg="unknown compression method",r.mode=30;break}if(l-=4,k=8+(15&(u>>>=4)),0===r.wbits)r.wbits=k;else if(k>r.wbits){t.msg="invalid window size",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=3;case 3:for(;l<32;){if(0===o)break t;o--,u+=i[s++]<>>8&255,E[2]=u>>>16&255,E[3]=u>>>24&255,r.check=B(r.check,E,4,0)),l=u=0,r.mode=4;case 4:for(;l<16;){if(0===o)break t;o--,u+=i[s++]<>8),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===o)break t;o--,u+=i[s++]<>>8&255,r.check=B(r.check,E,2,0)),l=u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(o<(c=r.length)&&(c=o),c&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),I.arraySet(r.head.extra,i,s,c,k)),512&r.flags&&(r.check=B(r.check,i,c,s)),o-=c,s+=c,r.length-=c),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break t;for(c=0;k=i[s+c++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k)),k&&c>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=12;break;case 10:for(;l<32;){if(0===o)break t;o--,u+=i[s++]<>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===o)break t;o--,u+=i[s++]<>>=1)){case 0:r.mode=14;break;case 1:if(j(r),r.mode=20,6!==e)break;u>>>=2,l-=2;break t;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=30}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===o)break t;o--,u+=i[s++]<>>16^65535)){t.msg="invalid stored block lengths",r.mode=30;break}if(r.length=65535&u,l=u=0,r.mode=15,6===e)break t;case 15:r.mode=16;case 16:if(c=r.length){if(o>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,286>>=3,l-=3}for(;r.have<19;)r.lens[A[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},x=T(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,x){t.msg="invalid code lengths set",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break t;o--,u+=i[s++]<>>=_,l-=_,r.lens[r.have++]=b;else{if(16===b){for(z=_+2;l>>=_,l-=_,0===r.have){t.msg="invalid bit length repeat",r.mode=30;break}k=r.lens[r.have-1],c=3+(3&u),u>>>=2,l-=2}else if(17===b){for(z=_+3;l>>=_)),u>>>=3,l-=3}else{for(z=_+7;l>>=_)),u>>>=7,l-=7}if(r.have+c>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=30;break}for(;c--;)r.lens[r.have++]=k}}if(30===r.mode)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},x=T(D,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,x){t.msg="invalid literal/lengths set",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},x=T(F,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,x){t.msg="invalid distances set",r.mode=30;break}if(r.mode=20,6===e)break t;case 20:r.mode=21;case 21:if(6<=o&&258<=h){t.next_out=a,t.avail_out=h,t.next_in=s,t.avail_in=o,r.hold=u,r.bits=l,R(t,d),a=t.next_out,n=t.output,h=t.avail_out,s=t.next_in,i=t.input,o=t.avail_in,u=r.hold,l=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(C=r.lencode[u&(1<>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break t;o--,u+=i[s++]<>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break t;o--,u+=i[s++]<>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,r.length=b,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=12;break}if(64&g){t.msg="invalid literal/length code",r.mode=30;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(z=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(C=r.distcode[u&(1<>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break t;o--,u+=i[s++]<>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break t;o--,u+=i[s++]<>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,64&g){t.msg="invalid distance code",r.mode=30;break}r.offset=b,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(z=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=30;break}r.mode=25;case 25:if(0===h)break t;if(c=d-h,r.offset>c){if((c=r.offset-c)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=30;break}p=c>r.wnext?(c-=r.wnext,r.wsize-c):r.wnext-c,c>r.length&&(c=r.length),m=r.window}else m=n,p=a-r.offset,c=r.length;for(hc?(m=R[T+a[v]],A[I+a[v]]):(m=96,0),h=1<>S)+(u-=h)]=p<<24|m<<16|_|0,0!==u;);for(h=1<>=1;if(0!==h?(E&=h-1,E+=h):E=0,v++,0==--O[b]){if(b===w)break;b=e[r+a[v]]}if(k>>7)]}function U(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function P(t,e,r){t.bi_valid>c-r?(t.bi_buf|=e<>c-t.bi_valid,t.bi_valid+=r-c):(t.bi_buf|=e<>>=1,r<<=1,0<--e;);return r>>>1}function Z(t,e,r){var i,n,s=new Array(g+1),a=0;for(i=1;i<=g;i++)s[i]=a=a+r[i-1]<<1;for(n=0;n<=e;n++){var o=t[2*n+1];0!==o&&(t[2*n]=j(s[o]++,o))}}function W(t){var e;for(e=0;e>1;1<=r;r--)G(t,s,r);for(n=h;r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],G(t,s,1),i=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=i,s[2*n]=s[2*r]+s[2*i],t.depth[n]=(t.depth[r]>=t.depth[i]?t.depth[r]:t.depth[i])+1,s[2*r+1]=s[2*i+1]=n,t.heap[1]=n++,G(t,s,1),2<=t.heap_len;);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,i,n,s,a,o,h=e.dyn_tree,u=e.max_code,l=e.stat_desc.static_tree,f=e.stat_desc.has_stree,d=e.stat_desc.extra_bits,c=e.stat_desc.extra_base,p=e.stat_desc.max_length,m=0;for(s=0;s<=g;s++)t.bl_count[s]=0;for(h[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<_;r++)p<(s=h[2*h[2*(i=t.heap[r])+1]+1]+1)&&(s=p,m++),h[2*i+1]=s,u>=7;i>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return o;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return h;for(e=32;e>>3,(s=t.static_len+3+7>>>3)<=n&&(n=s)):n=s=r+5,r+4<=n&&-1!==e?J(t,e,r,i):4===t.strategy||s===n?(P(t,2+(i?1:0),3),K(t,z,C)):(P(t,4+(i?1:0),3),function(t,e,r,i){var n;for(P(t,e-257,5),P(t,r-1,5),P(t,i-4,4),n=0;n>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(A[r]+u+1)]++,t.dyn_dtree[2*N(e)]++),t.last_lit===t.lit_bufsize-1},r._tr_align=function(t){P(t,2,3),L(t,m,z),function(t){16===t.bi_valid?(U(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):8<=t.bi_valid&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},{"../utils/common":41}],53:[function(t,e,r){"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,e,r){"use strict";e.exports="function"==typeof setImmediate?setImmediate:function(){var t=[].slice.apply(arguments);t.splice(1,0,0),setTimeout.apply(null,t)}},{}]},{},[10])(10)}); /***/ }), /***/ 560: /***/ (() => { HTMLCanvasElement.prototype.toBlob||(HTMLCanvasElement.prototype.toBlob=function(a,r,t){var i=this.toDataURL(r,t).split(",")[1];setTimeout(function(){for(var t=atob(i),o=t.length,e=new Uint8Array(o),n=0;n { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var MicroModal = function () { var FOCUSABLE_ELEMENTS = ['a[href]', 'area[href]', 'input:not([disabled]):not([type="hidden"]):not([aria-hidden])', 'select:not([disabled]):not([aria-hidden])', 'textarea:not([disabled]):not([aria-hidden])', 'button:not([disabled]):not([aria-hidden])', 'iframe', 'object', 'embed', '[contenteditable]', '[tabindex]:not([tabindex^="-"])']; var Modal = /*#__PURE__*/function () { function Modal(_ref) { var targetModal = _ref.targetModal, _ref$triggers = _ref.triggers, triggers = _ref$triggers === void 0 ? [] : _ref$triggers, _ref$onShow = _ref.onShow, onShow = _ref$onShow === void 0 ? function () {} : _ref$onShow, _ref$onClose = _ref.onClose, onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose, _ref$openTrigger = _ref.openTrigger, openTrigger = _ref$openTrigger === void 0 ? 'data-micromodal-trigger' : _ref$openTrigger, _ref$closeTrigger = _ref.closeTrigger, closeTrigger = _ref$closeTrigger === void 0 ? 'data-micromodal-close' : _ref$closeTrigger, _ref$openClass = _ref.openClass, openClass = _ref$openClass === void 0 ? 'is-open' : _ref$openClass, _ref$disableScroll = _ref.disableScroll, disableScroll = _ref$disableScroll === void 0 ? false : _ref$disableScroll, _ref$disableFocus = _ref.disableFocus, disableFocus = _ref$disableFocus === void 0 ? false : _ref$disableFocus, _ref$awaitCloseAnimat = _ref.awaitCloseAnimation, awaitCloseAnimation = _ref$awaitCloseAnimat === void 0 ? false : _ref$awaitCloseAnimat, _ref$awaitOpenAnimati = _ref.awaitOpenAnimation, awaitOpenAnimation = _ref$awaitOpenAnimati === void 0 ? false : _ref$awaitOpenAnimati, _ref$debugMode = _ref.debugMode, debugMode = _ref$debugMode === void 0 ? false : _ref$debugMode; _classCallCheck(this, Modal); // Save a reference of the modal this.modal = document.getElementById(targetModal); // Save a reference to the passed config this.config = { debugMode: debugMode, disableScroll: disableScroll, openTrigger: openTrigger, closeTrigger: closeTrigger, openClass: openClass, onShow: onShow, onClose: onClose, awaitCloseAnimation: awaitCloseAnimation, awaitOpenAnimation: awaitOpenAnimation, disableFocus: disableFocus }; // Register click events only if pre binding eventListeners if (triggers.length > 0) this.registerTriggers.apply(this, _toConsumableArray(triggers)); // pre bind functions for event listeners this.onClick = this.onClick.bind(this); this.onKeydown = this.onKeydown.bind(this); } /** * Loops through all openTriggers and binds click event * @param {array} triggers [Array of node elements] * @return {void} */ _createClass(Modal, [{ key: "registerTriggers", value: function registerTriggers() { var _this = this; for (var _len = arguments.length, triggers = new Array(_len), _key = 0; _key < _len; _key++) { triggers[_key] = arguments[_key]; } triggers.filter(Boolean).forEach(function (trigger) { trigger.addEventListener('click', function (event) { return _this.showModal(event); }); }); } }, { key: "showModal", value: function showModal() { var _this2 = this; var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; this.activeElement = document.activeElement; this.modal.setAttribute('aria-hidden', 'false'); this.modal.classList.add(this.config.openClass); this.scrollBehaviour('disable'); this.addEventListeners(); if (this.config.awaitOpenAnimation) { var handler = function handler() { _this2.modal.removeEventListener('animationend', handler, false); _this2.setFocusToFirstNode(); }; this.modal.addEventListener('animationend', handler, false); } else { this.setFocusToFirstNode(); } this.config.onShow(this.modal, this.activeElement, event); } }, { key: "closeModal", value: function closeModal() { var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; var modal = this.modal; this.modal.setAttribute('aria-hidden', 'true'); this.removeEventListeners(); this.scrollBehaviour('enable'); if (this.activeElement && this.activeElement.focus) { this.activeElement.focus(); } this.config.onClose(this.modal, this.activeElement, event); if (this.config.awaitCloseAnimation) { var openClass = this.config.openClass; // <- old school ftw this.modal.addEventListener('animationend', function handler() { modal.classList.remove(openClass); modal.removeEventListener('animationend', handler, false); }, false); } else { modal.classList.remove(this.config.openClass); } } }, { key: "closeModalById", value: function closeModalById(targetModal) { this.modal = document.getElementById(targetModal); if (this.modal) this.closeModal(); } }, { key: "scrollBehaviour", value: function scrollBehaviour(toggle) { if (!this.config.disableScroll) return; var body = document.querySelector('body'); switch (toggle) { case 'enable': Object.assign(body.style, { overflow: '' }); break; case 'disable': Object.assign(body.style, { overflow: 'hidden' }); break; } } }, { key: "addEventListeners", value: function addEventListeners() { this.modal.addEventListener('touchstart', this.onClick); this.modal.addEventListener('click', this.onClick); document.addEventListener('keydown', this.onKeydown); } }, { key: "removeEventListeners", value: function removeEventListeners() { this.modal.removeEventListener('touchstart', this.onClick); this.modal.removeEventListener('click', this.onClick); document.removeEventListener('keydown', this.onKeydown); } }, { key: "onClick", value: function onClick(event) { if (event.target.hasAttribute(this.config.closeTrigger)) { this.closeModal(event); } } }, { key: "onKeydown", value: function onKeydown(event) { if (event.keyCode === 27) this.closeModal(event); // esc if (event.keyCode === 9) this.retainFocus(event); // tab } }, { key: "getFocusableNodes", value: function getFocusableNodes() { var nodes = this.modal.querySelectorAll(FOCUSABLE_ELEMENTS); return Array.apply(void 0, _toConsumableArray(nodes)); } /** * Tries to set focus on a node which is not a close trigger * if no other nodes exist then focuses on first close trigger */ }, { key: "setFocusToFirstNode", value: function setFocusToFirstNode() { var _this3 = this; if (this.config.disableFocus) return; var focusableNodes = this.getFocusableNodes(); // no focusable nodes if (focusableNodes.length === 0) return; // remove nodes on whose click, the modal closes // could not think of a better name :( var nodesWhichAreNotCloseTargets = focusableNodes.filter(function (node) { return !node.hasAttribute(_this3.config.closeTrigger); }); if (nodesWhichAreNotCloseTargets.length > 0) nodesWhichAreNotCloseTargets[0].focus(); if (nodesWhichAreNotCloseTargets.length === 0) focusableNodes[0].focus(); } }, { key: "retainFocus", value: function retainFocus(event) { var focusableNodes = this.getFocusableNodes(); // no focusable nodes if (focusableNodes.length === 0) return; /** * Filters nodes which are hidden to prevent * focus leak outside modal */ focusableNodes = focusableNodes.filter(function (node) { return node.offsetParent !== null; }); // if disableFocus is true if (!this.modal.contains(document.activeElement)) { focusableNodes[0].focus(); } else { var focusedItemIndex = focusableNodes.indexOf(document.activeElement); if (event.shiftKey && focusedItemIndex === 0) { focusableNodes[focusableNodes.length - 1].focus(); event.preventDefault(); } if (!event.shiftKey && focusableNodes.length > 0 && focusedItemIndex === focusableNodes.length - 1) { focusableNodes[0].focus(); event.preventDefault(); } } } }]); return Modal; }(); /** * Modal prototype ends. * Here on code is responsible for detecting and * auto binding event handlers on modal triggers */ // Keep a reference to the opened modal var activeModal = null; /** * Generates an associative array of modals and it's * respective triggers * @param {array} triggers An array of all triggers * @param {string} triggerAttr The data-attribute which triggers the module * @return {array} */ var generateTriggerMap = function generateTriggerMap(triggers, triggerAttr) { var triggerMap = []; triggers.forEach(function (trigger) { var targetModal = trigger.attributes[triggerAttr].value; if (triggerMap[targetModal] === undefined) triggerMap[targetModal] = []; triggerMap[targetModal].push(trigger); }); return triggerMap; }; /** * Validates whether a modal of the given id exists * in the DOM * @param {number} id The id of the modal * @return {boolean} */ var validateModalPresence = function validateModalPresence(id) { if (!document.getElementById(id)) { console.warn("MicroModal: \u2757Seems like you have missed %c'".concat(id, "'"), 'background-color: #f8f9fa;color: #50596c;font-weight: bold;', 'ID somewhere in your code. Refer example below to resolve it.'); console.warn("%cExample:", 'background-color: #f8f9fa;color: #50596c;font-weight: bold;', "
")); return false; } }; /** * Validates if there are modal triggers present * in the DOM * @param {array} triggers An array of data-triggers * @return {boolean} */ var validateTriggerPresence = function validateTriggerPresence(triggers) { if (triggers.length <= 0) { console.warn("MicroModal: \u2757Please specify at least one %c'micromodal-trigger'", 'background-color: #f8f9fa;color: #50596c;font-weight: bold;', 'data attribute.'); console.warn("%cExample:", 'background-color: #f8f9fa;color: #50596c;font-weight: bold;', ""); return false; } }; /** * Checks if triggers and their corresponding modals * are present in the DOM * @param {array} triggers Array of DOM nodes which have data-triggers * @param {array} triggerMap Associative array of modals and their triggers * @return {boolean} */ var validateArgs = function validateArgs(triggers, triggerMap) { validateTriggerPresence(triggers); if (!triggerMap) return true; for (var id in triggerMap) { validateModalPresence(id); } return true; }; /** * Binds click handlers to all modal triggers * @param {object} config [description] * @return void */ var init = function init(config) { // Create an config object with default openTrigger var options = Object.assign({}, { openTrigger: 'data-micromodal-trigger' }, config); // Collects all the nodes with the trigger var triggers = _toConsumableArray(document.querySelectorAll("[".concat(options.openTrigger, "]"))); // Makes a mappings of modals with their trigger nodes var triggerMap = generateTriggerMap(triggers, options.openTrigger); // Checks if modals and triggers exist in dom if (options.debugMode === true && validateArgs(triggers, triggerMap) === false) return; // For every target modal creates a new instance for (var key in triggerMap) { var value = triggerMap[key]; options.targetModal = key; options.triggers = _toConsumableArray(value); activeModal = new Modal(options); // eslint-disable-line no-new } }; /** * Shows a particular modal * @param {string} targetModal [The id of the modal to display] * @param {object} config [The configuration object to pass] * @return {void} */ var show = function show(targetModal, config) { var options = config || {}; options.targetModal = targetModal; // Checks if modals and triggers exist in dom if (options.debugMode === true && validateModalPresence(targetModal) === false) return; // clear events in case previous modal wasn't close if (activeModal) activeModal.removeEventListeners(); // stores reference to active modal activeModal = new Modal(options); // eslint-disable-line no-new activeModal.showModal(); }; /** * Closes the active modal * @param {string} targetModal [The id of the modal to close] * @return {void} */ var close = function close(targetModal) { targetModal ? activeModal.closeModalById(targetModal) : activeModal.closeModal(); }; return { init: init, show: show, close: close }; }(); window.MicroModal = MicroModal; /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (MicroModal); /***/ }), /***/ 57: /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) /* harmony export */ }); /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ("(function(b){function a(b,d){if({}.hasOwnProperty.call(a.cache,b))return a.cache[b];var e=a.resolve(b);if(!e)throw new Error('Failed to resolve module '+b);var c={id:b,require:a,filename:b,exports:{},loaded:!1,parent:d,children:[]};d&&d.children.push(c);var f=b.slice(0,b.lastIndexOf('/')+1);return a.cache[b]=c.exports,e.call(c.exports,c,c.exports,f,b),c.loaded=!0,a.cache[b]=c.exports}a.modules={},a.cache={},a.resolve=function(b){return{}.hasOwnProperty.call(a.modules,b)?a.modules[b]:void 0},a.define=function(b,c){a.modules[b]=c},a.define('/gif.worker.coffee',function(d,e,f,g){var b,c;b=a('/GIFEncoder.js',d),c=function(a){var c,e,d,f;return c=new b(a.width,a.height),a.index===0?c.writeHeader():c.firstFrame=!1,c.setTransparent(a.transparent),c.setRepeat(a.repeat),c.setDelay(a.delay),c.setQuality(a.quality),c.addFrame(a.data),a.last&&c.finish(),d=c.stream(),a.data=d.pages,a.cursor=d.cursor,a.pageSize=d.constructor.pageSize,a.canTransfer?(f=function(c){for(var b=0,d=a.data.length;b=c.pageSize&&this.newPage(),this.pages[this.page][this.cursor++]=a},c.prototype.writeUTFBytes=function(b){for(var c=b.length,a=0;a=0&&(this.dispose=a)},b.prototype.setRepeat=function(a){this.repeat=a},b.prototype.setTransparent=function(a){this.transparent=a},b.prototype.addFrame=function(a){this.image=a,this.getImagePixels(),this.analyzePixels(),this.firstFrame&&(this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.writePalette(),this.writePixels(),this.firstFrame=!1},b.prototype.finish=function(){this.out.writeByte(59)},b.prototype.setQuality=function(a){a<1&&(a=1),this.sample=a},b.prototype.writeHeader=function(){this.out.writeUTFBytes('GIF89a')},b.prototype.analyzePixels=function(){var g=this.pixels.length,d=g/3;this.indexedPixels=new Uint8Array(d);var a=new f(this.pixels,this.sample);a.buildColormap(),this.colorTab=a.getColormap();var b=0;for(var c=0;c>16,l=(e&65280)>>8,m=e&255,c=0,d=16777216,j=this.colorTab.length;for(var a=0;a=0&&(a=dispose&7),a<<=2,this.out.writeByte(0|a|0|b),this.writeShort(this.delay),this.out.writeByte(this.transIndex),this.out.writeByte(0)},b.prototype.writeImageDesc=function(){this.out.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame?this.out.writeByte(0):this.out.writeByte(128|this.palSize)},b.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.out.writeByte(240|this.palSize),this.out.writeByte(0),this.out.writeByte(0)},b.prototype.writeNetscapeExt=function(){this.out.writeByte(33),this.out.writeByte(255),this.out.writeByte(11),this.out.writeUTFBytes('NETSCAPE2.0'),this.out.writeByte(3),this.out.writeByte(1),this.writeShort(this.repeat),this.out.writeByte(0)},b.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);var b=768-this.colorTab.length;for(var a=0;a>8&255)},b.prototype.writePixels=function(){var a=new g(this.width,this.height,this.indexedPixels,this.colorDepth);a.encode(this.out)},b.prototype.stream=function(){return this.out},e.exports=b}),a.define('/LZWEncoder.js',function(e,g,h,i){function f(y,D,C,B){function w(a,b){r[f++]=a,f>=254&&t(b)}function x(b){u(a),k=i+2,j=!0,l(i,b)}function u(b){for(var a=0;a=0){y=w-d,d===0&&(y=1);do if((d-=y)<0&&(d+=w),h[d]===g){e=n[d];continue a}while(h[d]>=0)}l(e,r),e=t,k<1<0&&(a.writeByte(f),a.writeBytes(r,0,f),f=0)}function p(a){return(1<0?g|=a<=8)w(g&255,c),g>>=8,e-=8;if((k>m||j)&&(j?(m=p(n_bits=q),j=!1):(++n_bits,n_bits==b?m=1<0)w(g&255,c),g>>=8,e-=8;t(c)}}var s=Math.max(2,B),r=new Uint8Array(256),h=new Int32Array(a),n=new Int32Array(a),g,e=0,f,k=0,m,j=!1,q,i,o;this.encode=z}var c=-1,b=12,a=5003,d=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];e.exports=f}),a.define('/TypedNeuQuant.js',function(A,F,E,D){function C(A,B){function I(){o=[],q=new Int32Array(256),t=new Int32Array(a),y=new Int32Array(a),z=new Int32Array(a>>3);var c,d;for(c=0;c>=b,o[c][1]>>=b,o[c][2]>>=b,o[c][3]=c}function K(b,a,c,e,f){o[a][0]-=b*(o[a][0]-c)/d,o[a][1]-=b*(o[a][1]-e)/d,o[a][2]-=b*(o[a][2]-f)/d}function L(j,e,n,l,k){var h=Math.abs(e-j),i=Math.min(e+j,a),g=e+1,f=e-1,m=1,b,d;while(gh)d=z[m++],gh&&(b=o[f--],b[0]-=d*(b[0]-n)/c,b[1]-=d*(b[1]-l)/c,b[2]-=d*(b[2]-k)/c)}function C(p,s,q){var h=2147483647,k=h,d=-1,m=d,c,j,e,n,l;for(c=0;c>i-b),n>g,y[c]-=l,t[c]+=l<>1,b=f+1;b>1,b=f+1;b<256;b++)q[b]=n}function E(j,i,k){var b,d,c,e=1e3,h=-1,f=q[i],g=f-1;while(f=0)f=e?f=a:(f++,c<0&&(c=-c),b=d[0]-j,b<0&&(b=-b),c+=b,c=0&&(d=o[g],c=i-d[1],c>=e?g=-1:(g--,c<0&&(c=-c),b=d[0]-j,b<0&&(b=-b),c+=b,c>h;for(a<=1&&(a=0),c=0;c=f&&(g-=f),c++,q===0&&(q=1),c%q===0)for(n-=n/D,o-=o/v,a=o>>h,a<=1&&(a=0),e=0;e>g,r=e<>3,h=6,t=1< 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.browserSupportsGIF = exports.browserSupportsMP4 = exports.browserSupportsWEBM = exports.checkHotkeys = exports.isRecording = exports.stopRecord = exports.recordFrame = exports.takeJPEGSnapshot = exports.takePNGSnapshot = exports.beginJPEGFramesRecord = exports.beginPNGFramesRecord = exports.beginGIFRecord = exports.beginVideoRecord = exports.bindKeyToJPEGSnapshot = exports.bindKeyToPNGSnapshot = exports.bindKeyToJPEGFramesRecord = exports.bindKeyToPNGFramesRecord = exports.bindKeyToGIFRecord = exports.bindKeyToVideoRecord = exports.setVerbose = exports.dispose = exports.init = exports.MP4 = exports.WEBM = exports.showDialog = void 0; var CCapture_1 = __webpack_require__(886); var file_saver_1 = __webpack_require__(162); // Polyfill for canvas.toBlob needed for some browsers. __webpack_require__(560); // @ts-ignore var changedpi_1 = __webpack_require__(809); var params_1 = __webpack_require__(848); var modals_1 = __webpack_require__(330); // Make it so we don't have to specify workersPath for CCapture gif recorder. // This is not a large file, so no need to separate from lib. // @ts-ignore var gif_worker_js_1 = __webpack_require__(57); // @ts-ignore var JSZip = __webpack_require__(733); var gifWorkersPath = URL.createObjectURL(new Blob([gif_worker_js_1.default])); var ffmpegPath; var ffmpeg = undefined; // Export showDialog method in case it is useful. var modals_2 = __webpack_require__(330); Object.defineProperty(exports, "showDialog", ({ enumerable: true, get: function () { return modals_2.showDialog; } })); var GIF = 'gif'; exports.WEBM = 'webm'; exports.MP4 = 'mp4'; var JPEGZIP = 'jpegzip'; var PNGZIP = 'pngzip'; var JPEG = 'jpeg'; var PNG = 'png'; var activeCaptures = []; // This is an unused variable, // but needed for proper import of CCapture at the moment. // See https://github.com/spite/ccapture.js/issues/78 var temp = CCapture_1.default; var hotkeysSinceLastCheck = []; var hotkeyOptions = {}; var hotkeys = {}; var canvas = null; function init(_canvas, options) { canvas = _canvas; // Use public address if you don't want to host your own. ffmpegPath = (options === null || options === void 0 ? void 0 : options.ffmpegCorePath) || 'https://unpkg.com/@ffmpeg/core@0.10.0/dist/ffmpeg-core.js'; if (options && options.verbose !== undefined) setVerbose(options.verbose); if (options && options.showAlerts !== undefined) params_1.PARAMS.SHOW_ALERTS = options.showAlerts; if (options && options.showDialogs !== undefined) params_1.PARAMS.SHOW_DIALOGS = options.showDialogs; if (options && options.showRecDot !== undefined) params_1.PARAMS.SHOW_REC_DOT = options.showRecDot; if (params_1.PARAMS.SHOW_REC_DOT) { (0, modals_1.initDotWithCSS)(options === null || options === void 0 ? void 0 : options.recDotCSS); } canvas.addEventListener('resize', onResize); window.addEventListener('keydown', onKeydown); } exports.init = init; function onKeydown(e) { hotkeysSinceLastCheck.push({ key: e.key, }); if (!params_1.PARAMS.IS_MANUALLY_CHECKING_HOTKEYS) { // Apply hotkeys immediately. applyHotkeys(); } // Otherwise wait until checkHotkeys() is called. } function onResize() { if (activeCaptures.length) { var warningMsg = "Don't resize while recording canvas!"; (0, modals_1.showWarning)(warningMsg); } } function dispose() { canvas === null || canvas === void 0 ? void 0 : canvas.removeEventListener('resize', onResize); canvas = null; window.removeEventListener('keydown', onKeydown); } exports.dispose = dispose; function setVerbose(state) { params_1.PARAMS.VERBOSE = !!state; if (ffmpeg) ffmpeg.setLogging(params_1.PARAMS.VERBOSE); } exports.setVerbose = setVerbose; function checkCanvas() { if (canvas === null) { throw new Error('No canvas supplied, please call CanvasCapture.init() and pass in canvas element.'); } } function setHotkey(key, type) { // Unbind other hotkeys attached to same key. Object.keys(hotkeys).forEach(function (keyName) { if (hotkeys[keyName] === key) { delete hotkeys[keyName]; } }); hotkeys[type] = key; } // Pressing key once will start record, press again to stop. function bindKeyToVideoRecord(key, options) { if ((options === null || options === void 0 ? void 0 : options.format) === exports.WEBM) { hotkeyOptions.webm = options; setHotkey(key, exports.WEBM); } else { // Default to MP4. hotkeyOptions.mp4 = options; setHotkey(key, exports.MP4); } } exports.bindKeyToVideoRecord = bindKeyToVideoRecord; function bindKeyToGIFRecord(key, options) { hotkeyOptions.gif = options; setHotkey(key, GIF); } exports.bindKeyToGIFRecord = bindKeyToGIFRecord; function bindKeyToPNGFramesRecord(key, options) { hotkeyOptions.pngzip = options; setHotkey(key, PNGZIP); } exports.bindKeyToPNGFramesRecord = bindKeyToPNGFramesRecord; function bindKeyToJPEGFramesRecord(key, options) { hotkeyOptions.jpegzip = options; setHotkey(key, JPEGZIP); } exports.bindKeyToJPEGFramesRecord = bindKeyToJPEGFramesRecord; // Snapshots just take a single shot. function bindKeyToPNGSnapshot(key, options) { hotkeyOptions.png = options; setHotkey(key, PNG); } exports.bindKeyToPNGSnapshot = bindKeyToPNGSnapshot; function bindKeyToJPEGSnapshot(key, options) { hotkeyOptions.jpeg = options; setHotkey(key, JPEG); } exports.bindKeyToJPEGSnapshot = bindKeyToJPEGSnapshot; function applyHotkeys() { var _a, _b; for (var i = 0; i < hotkeysSinceLastCheck.length; i++) { var key = hotkeysSinceLastCheck[i].key; if (hotkeys.mp4 && key === hotkeys[exports.MP4]) { var MP4s = activeCapturesOfType(exports.MP4); if (MP4s.length) stopRecord(MP4s); else { if (!browserSupportsMP4()) { var errorMsg = "This browser does not support MP4 video recording, please try again in Chrome as be sure to set the correct server headers: https://github.com/amandaghassaei/canvas-capture#caveats."; var onError = (_a = hotkeyOptions[exports.MP4]) === null || _a === void 0 ? void 0 : _a.onError; if (onError) onError(new Error(errorMsg)); (0, modals_1.showWarning)(errorMsg); } beginVideoRecord(hotkeyOptions[exports.MP4]); } } if (hotkeys.webm && key === hotkeys[exports.WEBM]) { var WEBMs = activeCapturesOfType(exports.WEBM); if (WEBMs.length) stopRecord(WEBMs); else { if (!browserSupportsWEBM()) { var errorMsg = "This browser does not support WEBM video recording, please try again in Chrome."; var onError = (_b = hotkeyOptions[exports.WEBM]) === null || _b === void 0 ? void 0 : _b.onError; if (onError) onError(new Error(errorMsg)); (0, modals_1.showWarning)(errorMsg); } beginVideoRecord(hotkeyOptions[exports.WEBM]); } } if (hotkeys.gif && key === hotkeys[GIF]) { var GIFs = activeCapturesOfType(GIF); if (GIFs.length) stopRecord(GIFs); else beginGIFRecord(hotkeyOptions[GIF]); } if (hotkeys.pngzip && key === hotkeys[PNGZIP]) { var pngzips = activeCapturesOfType(PNGZIP); if (pngzips.length) stopRecord(pngzips); else beginPNGFramesRecord(hotkeyOptions[PNGZIP]); } if (hotkeys.jpegzip && key === hotkeys[JPEGZIP]) { var jpgzips = activeCapturesOfType(JPEGZIP); if (jpgzips.length) stopRecord(jpgzips); else beginJPEGFramesRecord(hotkeyOptions[JPEGZIP]); } if (hotkeys.png && key === hotkeys[PNG]) { takePNGSnapshot(hotkeyOptions[PNG]); } if (hotkeys.jpeg && key === hotkeys[JPEG]) { takeJPEGSnapshot(hotkeyOptions[JPEG]); } } hotkeysSinceLastCheck.length = 0; } function startCapture(capture) { activeCaptures.push(capture); if (capture.type !== PNGZIP && capture.type !== JPEGZIP) capture.capturer.start(); // For multi-frame records, we should also throw up an indicator to show that we're in record mode. (0, modals_1.showDot)(isRecording()); } function beginVideoRecord(options) { try { var format = (options === null || options === void 0 ? void 0 : options.format) || exports.MP4; // Default to MP4 record. if (format === exports.MP4) { if (!browserSupportsMP4()) { var errorMsg = "This browser does not support MP4 video recording, please try again in Chrome."; (0, modals_1.showWarning)(errorMsg); throw new Error(errorMsg); } } else if (format === exports.WEBM) { if (!browserSupportsWEBM()) { var errorMsg = "This browser does not support WEBM video recording, please try again in Chrome."; (0, modals_1.showWarning)(errorMsg); throw new Error(errorMsg); } } else { throw new Error("invalid video format ".concat(format, ".")); } if (activeVideoGifCaptures().length) { var errorMsg = "CCapture.js only supports one video/gif capture at a time."; (0, modals_1.showWarning)(errorMsg); throw new Error(errorMsg); } var quality = 1; if (options && options.quality) { quality = options.quality; } var name_1 = (options === null || options === void 0 ? void 0 : options.name) || 'Video_Capture'; // Create a capturer that exports a WebM video. // @ts-ignore var capturer = new window.CCapture({ format: exports.WEBM, name: name_1, framerate: (options === null || options === void 0 ? void 0 : options.fps) || 60, quality: quality * 100, verbose: params_1.PARAMS.VERBOSE, motionBlurFrames: options === null || options === void 0 ? void 0 : options.motionBlurFrames, }); var capture = { name: name_1, capturer: capturer, numFrames: 0, type: format, ffmpegOptions: options === null || options === void 0 ? void 0 : options.ffmpegOptions, onExportProgress: options === null || options === void 0 ? void 0 : options.onExportProgress, onExport: options === null || options === void 0 ? void 0 : options.onExport, onExportFinish: options === null || options === void 0 ? void 0 : options.onExportFinish, onError: options === null || options === void 0 ? void 0 : options.onError, }; startCapture(capture); return capture; } catch (error) { if (options === null || options === void 0 ? void 0 : options.onError) options.onError(error); else throw error; } } exports.beginVideoRecord = beginVideoRecord; function beginGIFRecord(options) { try { if (activeVideoGifCaptures().length) { var errorMsg = "CCapture.js only supports one video/gif capture at a time."; (0, modals_1.showWarning)(errorMsg); throw new Error(errorMsg); } // CCapture seems to expect a quality between 0 and 100. var quality = 100; if (options && options.quality) { quality = options.quality * 100; } var name_2 = (options === null || options === void 0 ? void 0 : options.name) || 'GIF_Capture'; // Create a capturer that exports a GIF. // @ts-ignore var capturer = new window.CCapture({ format: GIF, name: name_2, framerate: (options === null || options === void 0 ? void 0 : options.fps) || 60, workersPath: gifWorkersPath, quality: quality, verbose: params_1.PARAMS.VERBOSE, onProgress: options === null || options === void 0 ? void 0 : options.onExportProgress, motionBlurFrames: options === null || options === void 0 ? void 0 : options.motionBlurFrames, }); var capture = { name: name_2, capturer: capturer, numFrames: 0, type: GIF, onExport: options === null || options === void 0 ? void 0 : options.onExport, onExportFinish: options === null || options === void 0 ? void 0 : options.onExportFinish, onError: options === null || options === void 0 ? void 0 : options.onError, }; startCapture(capture); return capture; } catch (error) { if (options === null || options === void 0 ? void 0 : options.onError) options.onError(error); else throw error; } } exports.beginGIFRecord = beginGIFRecord; function beginPNGFramesRecord(options) { try { var name_3 = (options === null || options === void 0 ? void 0 : options.name) || 'PNG_Frames_Capture'; var zipOptions = { dpi: options === null || options === void 0 ? void 0 : options.dpi }; var capture = { name: name_3, zipOptions: zipOptions, zipPromises: [], capturer: new JSZip(), numFrames: 0, type: PNGZIP, onExportProgress: options === null || options === void 0 ? void 0 : options.onExportProgress, onExport: options === null || options === void 0 ? void 0 : options.onExport, onExportFinish: options === null || options === void 0 ? void 0 : options.onExportFinish, onError: options === null || options === void 0 ? void 0 : options.onError, }; startCapture(capture); return capture; } catch (error) { if (options === null || options === void 0 ? void 0 : options.onError) options.onError(error); else throw error; } } exports.beginPNGFramesRecord = beginPNGFramesRecord; function beginJPEGFramesRecord(options) { try { var name_4 = (options === null || options === void 0 ? void 0 : options.name) || 'JPEG_Frames_Capture'; var zipOptions = { dpi: options === null || options === void 0 ? void 0 : options.dpi, quality: options === null || options === void 0 ? void 0 : options.quality }; var capture = { name: name_4, zipOptions: zipOptions, zipPromises: [], capturer: new JSZip(), numFrames: 0, type: JPEGZIP, onExportProgress: options === null || options === void 0 ? void 0 : options.onExportProgress, onExport: options === null || options === void 0 ? void 0 : options.onExport, onExportFinish: options === null || options === void 0 ? void 0 : options.onExportFinish, onError: options === null || options === void 0 ? void 0 : options.onError, }; startCapture(capture); return capture; } catch (error) { if (options === null || options === void 0 ? void 0 : options.onError) options.onError(error); else throw error; } } exports.beginJPEGFramesRecord = beginJPEGFramesRecord; function canvasToBlobAsync(canvas, type, quality) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/, new Promise(function (resolve) { canvas.toBlob(function (blob) { resolve(blob); }, "image/".concat(type), quality); })]; }); }); } function takeImageSnapshot(filename, type, quality, options) { return __awaiter(this, void 0, void 0, function () { var onExportFinish, blob, errorMsg, onExport; return __generator(this, function (_a) { switch (_a.label) { case 0: checkCanvas(); onExportFinish = options === null || options === void 0 ? void 0 : options.onExportFinish; return [4 /*yield*/, canvasToBlobAsync(canvas, type, quality)]; case 1: blob = _a.sent(); if (!blob) { errorMsg = "Problem saving ".concat(type.toUpperCase(), ", please try again!"); (0, modals_1.showWarning)(errorMsg); throw new Error(errorMsg); } onExport = (options === null || options === void 0 ? void 0 : options.onExport) || file_saver_1.saveAs; if (!(options === null || options === void 0 ? void 0 : options.dpi)) return [3 /*break*/, 3]; return [4 /*yield*/, (0, changedpi_1.changeDpiBlob)(blob, options === null || options === void 0 ? void 0 : options.dpi).then(function (blob) { onExport(blob, filename); if (onExportFinish) onExportFinish(); })]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: onExport(blob, filename); if (onExportFinish) onExportFinish(); _a.label = 4; case 4: return [2 /*return*/]; } }); }); } function takePNGSnapshot(options) { return __awaiter(this, void 0, void 0, function () { var name_5, filename, error_1; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); name_5 = (options === null || options === void 0 ? void 0 : options.name) || 'PNG_Capture'; filename = "".concat(name_5, ".png"); return [4 /*yield*/, takeImageSnapshot(filename, PNG, undefined, options)]; case 1: _a.sent(); return [3 /*break*/, 3]; case 2: error_1 = _a.sent(); if (options === null || options === void 0 ? void 0 : options.onError) options.onError(error_1); else throw error_1; return [3 /*break*/, 3]; case 3: return [2 /*return*/]; } }); }); } exports.takePNGSnapshot = takePNGSnapshot; function takeJPEGSnapshot(options) { return __awaiter(this, void 0, void 0, function () { var name_6, filename, error_2; return __generator(this, function (_a) { switch (_a.label) { case 0: _a.trys.push([0, 2, , 3]); name_6 = (options === null || options === void 0 ? void 0 : options.name) || 'JPEG_Capture'; filename = "".concat(name_6, ".jpg"); // Quality is a number between 0 and 1 https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob return [4 /*yield*/, takeImageSnapshot(filename, JPEG, (options === null || options === void 0 ? void 0 : options.quality) || 1, options)]; case 1: // Quality is a number between 0 and 1 https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob _a.sent(); return [3 /*break*/, 3]; case 2: error_2 = _a.sent(); if (options === null || options === void 0 ? void 0 : options.onError) options.onError(error_2); else throw error_2; return [3 /*break*/, 3]; case 3: return [2 /*return*/]; } }); }); } exports.takeJPEGSnapshot = takeJPEGSnapshot; function recordFrame(capture) { var captures = activeCaptures; if (capture) { if (!Array.isArray(capture)) { captures = [capture]; } else { captures = capture; } } try { checkCanvas(); if (captures.length === 0) { var errorMsg = 'No valid capturer inited, please call CanvasCapture.beginVideoRecord(), CanvasCapture.beginGIFRecord(), CanvasCapture.beginPNGFramesRecord(), or CanvasCapture.beginJPEGFramesRecord() first.'; (0, modals_1.showWarning)(errorMsg); throw new Error(errorMsg); } var _loop_1 = function (i) { var _a = captures[i], capturer = _a.capturer, type = _a.type, zipOptions = _a.zipOptions, zipPromises = _a.zipPromises, numFrames = _a.numFrames; if (type === JPEGZIP || type === PNGZIP) { // Name should correspond to current frame. var frameName_1 = "frame_".concat(numFrames + 1); var promise = new Promise(function (resolve, reject) { var options = { dpi: zipOptions === null || zipOptions === void 0 ? void 0 : zipOptions.dpi, quality: zipOptions.quality, name: frameName_1, onExport: function (blob, filename) { capturer.file(filename, blob); }, onExportFinish: resolve, onError: reject, }; if (type === JPEGZIP) { takeJPEGSnapshot(options); } else { takePNGSnapshot(options); } }); zipPromises.push(promise); } else { capturer.capture(canvas); } captures[i].numFrames = numFrames + 1; }; for (var i = 0; i < captures.length; i++) { _loop_1(i); } } catch (error) { var handled = true; for (var i = 0; i < captures.length; i++) { var capture_1 = captures[i]; if (capture_1.onError) capture_1.onError(error); else handled = false; } if (!captures.length || !handled) { throw error; } } } exports.recordFrame = recordFrame; function CCaptureSaveAsync(capturer) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/, new Promise(function (resolve) { capturer.save(function (blob) { resolve(blob); }); })]; }); }); } function stopRecordAtIndex(index) { return __awaiter(this, void 0, void 0, function () { var _a, name, capturer, numFrames, type, zipPromises, onExportProgress, onExport, onExportFinish, onError, ffmpegOptions, errorMsg, _b, blob, blob, filename, blob, filename; return __generator(this, function (_c) { switch (_c.label) { case 0: _a = activeCaptures[index], name = _a.name, capturer = _a.capturer, numFrames = _a.numFrames, type = _a.type, zipPromises = _a.zipPromises, onExportProgress = _a.onExportProgress, onExport = _a.onExport, onExportFinish = _a.onExportFinish, onError = _a.onError, ffmpegOptions = _a.ffmpegOptions; // Remove ref to capturer. activeCaptures.splice(index, 1); if (type !== PNGZIP && type !== JPEGZIP) capturer.stop(); if (numFrames === 0) { errorMsg = 'No frames recorded, call CanvasCapture.recordFrame().'; (0, modals_1.showWarning)(errorMsg); throw new Error(errorMsg); } _b = type; switch (_b) { case exports.MP4: return [3 /*break*/, 1]; case exports.WEBM: return [3 /*break*/, 4]; case GIF: return [3 /*break*/, 6]; case PNGZIP: return [3 /*break*/, 8]; case JPEGZIP: return [3 /*break*/, 8]; } return [3 /*break*/, 11]; case 1: return [4 /*yield*/, CCaptureSaveAsync(capturer)]; case 2: blob = _c.sent(); // Tell the user that mp4s take a sec to process. (0, modals_1.showDialog)('Processing...', 'MP4 is processing and may take a minute to save. You can close this dialog in the meantime.', { autoCloseDelay: 7000 }); return [4 /*yield*/, convertWEBMtoMP4({ name: name, blob: blob, onExportProgress: onExportProgress, onExport: onExport, onExportFinish: onExportFinish, ffmpegOptions: ffmpegOptions, })]; case 3: _c.sent(); return [3 /*break*/, 12]; case 4: if (onExportProgress) onExportProgress(0); return [4 /*yield*/, CCaptureSaveAsync(capturer)]; case 5: blob = _c.sent(); if (onExportProgress) onExportProgress(1); // Save is nearly immediate. filename = "".concat(name, ".webm"); if (onExport) { onExport(blob, filename); } else { (0, file_saver_1.saveAs)(blob, filename); } if (onExportFinish) onExportFinish(); return [3 /*break*/, 12]; case 6: // Tell the user that gifs take a sec to process. (0, modals_1.showDialog)('Processing...', 'GIF is processing and may take a minute to save. You can close this dialog in the meantime.', { autoCloseDelay: 7000 }); return [4 /*yield*/, CCaptureSaveAsync(capturer)]; case 7: blob = _c.sent(); filename = "".concat(name, ".gif"); if (onExport) { onExport(blob, filename); } else { (0, file_saver_1.saveAs)(blob, filename); } if (onExportFinish) onExportFinish(); return [3 /*break*/, 12]; case 8: // Wait for all frames to finish saving. return [4 /*yield*/, Promise.all(zipPromises)]; case 9: // Wait for all frames to finish saving. _c.sent(); // Tell the user that frames take a sec to zip. (0, modals_1.showDialog)('Processing...', 'Frames are being zipped and may take a minute to save. You can close this dialog in the meantime.', { autoCloseDelay: 7000 }); return [4 /*yield*/, capturer.generateAsync({ type: 'blob' }, function (metadata) { if (onExportProgress) onExportProgress(metadata.percent / 100); }).then(function (blob) { var filename = "".concat(name, ".zip"); if (onExport) { onExport(blob, filename); } else { (0, file_saver_1.saveAs)(blob, filename); } if (onExportFinish) onExportFinish(); })]; case 10: _c.sent(); return [3 /*break*/, 12]; case 11: throw new Error("Need to handle saving type ".concat(type, ".")); case 12: return [2 /*return*/]; } }); }); } function stopRecord(capture) { return __awaiter(this, void 0, void 0, function () { var captures, errorMsg, promises, i, index, error_3, handled, i, capture_2; return __generator(this, function (_a) { switch (_a.label) { case 0: if (capture && !Array.isArray(capture)) { capture = [capture]; } captures = capture || activeCaptures; _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); if (activeCaptures.length === 0) { errorMsg = 'No valid capturer inited, please call CanvasCapture.beginVideoRecord(), CanvasCapture.beginGIFRecord(), CanvasCapture.beginPNGFramesRecord(), or CanvasCapture.beginJPEGFramesRecord() first.'; (0, modals_1.showWarning)(errorMsg); throw new Error(errorMsg); } promises = []; for (i = 0; i < captures.length; i++) { index = activeCaptures.indexOf(captures[i]); if (index < 0) throw new Error("Invalid capture ".concat(captures[i], " \u2013 may have already been stopped.")); promises.push(stopRecordAtIndex(index)); } (0, modals_1.showDot)(isRecording()); return [4 /*yield*/, Promise.all(promises)]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: error_3 = _a.sent(); handled = true; for (i = 0; i < captures.length; i++) { capture_2 = captures[i]; if (capture_2.onError) capture_2.onError(error_3); else handled = false; } if (!captures.length || !handled) { throw error_3; } return [3 /*break*/, 4]; case 4: return [2 /*return*/]; } }); }); } exports.stopRecord = stopRecord; function activeCapturesOfType(type) { var captures = []; for (var i = 0; i < activeCaptures.length; i++) { if (activeCaptures[i].type === type) { captures.push(activeCaptures[i]); } } return captures; } function activeVideoGifCaptures() { return activeCapturesOfType(exports.WEBM).concat(activeCapturesOfType(exports.MP4)).concat(activeCapturesOfType(GIF)); } function isRecording() { return activeCaptures.length > 0; } exports.isRecording = isRecording; function checkHotkeys() { params_1.PARAMS.IS_MANUALLY_CHECKING_HOTKEYS = true; applyHotkeys(); } exports.checkHotkeys = checkHotkeys; var ffmpegLoaded = false; function convertWEBMtoMP4(options) { return __awaiter(this, void 0, void 0, function () { var createFFmpeg, name, blob, onExportProgress, onExport, onExportFinish, ffmpegOptions, _data, data, defaultFFMPEGOptions, combinedOptions, _ffmpegOptions, filename, output, outputBlob; var _a; return __generator(this, function (_b) { switch (_b.label) { case 0: if (!ffmpeg) { createFFmpeg = __webpack_require__(648); ffmpeg = createFFmpeg({ corePath: ffmpegPath, }); } if (!!ffmpegLoaded) return [3 /*break*/, 2]; return [4 /*yield*/, ffmpeg.load().catch(function () { var errorMsg = 'MP4 export not supported in this browser, try again in the latest version of Chrome.'; (0, modals_1.showWarning)(errorMsg); throw new Error(errorMsg); })]; case 1: _b.sent(); ffmpegLoaded = true; _b.label = 2; case 2: name = options.name, blob = options.blob, onExportProgress = options.onExportProgress, onExport = options.onExport, onExportFinish = options.onExportFinish, ffmpegOptions = options.ffmpegOptions; return [4 /*yield*/, blob.arrayBuffer()]; case 3: _data = _b.sent(); data = new Uint8Array(_data); // Write data to MEMFS, need to use Uint8Array for binary data. ffmpeg.FS('writeFile', "".concat(name, ".webm"), data); // Convert to MP4. // TODO: onProgress callback is not working quite right yet. // https://github.com/ffmpegwasm/ffmpeg.wasm/issues/112 if (onExportProgress) ffmpeg.setProgress(function (progress) { onExportProgress(Math.max(0, Math.min(progress.ratio, 1))); }); defaultFFMPEGOptions = { '-c:v': 'libx264', '-preset': 'slow', '-crf': '22', '-pix_fmt': 'yuv420p', }; combinedOptions = __assign(__assign({}, defaultFFMPEGOptions), (ffmpegOptions || {})); _ffmpegOptions = []; Object.keys(combinedOptions).forEach(function (key) { _ffmpegOptions.push(key, combinedOptions[key]); }); filename = "".concat(name, ".mp4"); return [4 /*yield*/, (_a = ffmpeg).run.apply(_a, __spreadArray(__spreadArray(['-i', "".concat(name, ".webm")], _ffmpegOptions, false), ['-vf', 'crop=trunc(iw/2)*2:trunc(ih/2)*2', '-an', filename], false))]; case 4: _b.sent(); return [4 /*yield*/, ffmpeg.FS('readFile', filename)]; case 5: output = _b.sent(); outputBlob = new Blob([output], { type: 'video/mp4' }); if (onExport) { onExport(outputBlob, filename); } else { (0, file_saver_1.saveAs)(outputBlob, filename); } // Delete files in MEMFS. ffmpeg.FS('unlink', "".concat(name, ".webm")); ffmpeg.FS('unlink', filename); if (onExportFinish) onExportFinish(); return [2 /*return*/]; } }); }); } function browserSupportsWEBP() { var _canvas = document.createElement('canvas'); var url = _canvas.toDataURL('image/webp', { quality: 1 }); if (typeof url !== "string" || !url.match(/^data:image\/webp;base64,/i)) { return false; } return true; } function browserSupportsSharedArrayBuffer() { try { var test = new SharedArrayBuffer(1024); } catch (_a) { return false; } return true; } function browserSupportsWebWorkers() { return !!window.Worker; } function browserSupportsWEBM() { return browserSupportsWEBP(); } exports.browserSupportsWEBM = browserSupportsWEBM; function browserSupportsMP4() { // Also web workers? // && browserSupportsWebWorkers() return browserSupportsWEBP() && browserSupportsSharedArrayBuffer(); } exports.browserSupportsMP4 = browserSupportsMP4; function browserSupportsGIF() { return browserSupportsWebWorkers(); } exports.browserSupportsGIF = browserSupportsGIF; /***/ }), /***/ 713: /***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.css = void 0; exports.css = "\n/************************** Basic Modal Styles\n**************************/\n\n.modal {\n font-family: -apple-system,BlinkMacSystemFont,avenir next,avenir,helvetica neue,helvetica,ubuntu,roboto,noto,segoe ui,arial,sans-serif;\n}\n\n.modal__overlay {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0,0,0,0.6);\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.modal__container {\n background-color: #fff;\n padding: 30px;\n max-width: 500px;\n max-height: 100vh;\n overflow-y: auto;\n box-sizing: border-box;\n}\n\n.modal__header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.modal__title {\n margin-top: 0;\n margin-bottom: 0;\n font-weight: 600;\n font-size: 1.25rem;\n line-height: 1.25;\n color: #222;\n box-sizing: border-box;\n}\n\n.modal__footer {\n text-align: right;\n}\n\n.modal__footer>.modal__btn {\n margin-right: 8px;\n}\n\n.modal__close {\n background: transparent;\n border: 0;\n}\n\n.modal__header .modal__close:before { content: \"\u2715\"; }\n\n.modal__content {\n margin-top: 2rem;\n margin-bottom: 2rem;\n line-height: 1.5;\n color: rgba(0,0,0,.8);\n}\n\n.modal__btn {\n font-size: .875rem;\n padding-left: 1rem;\n padding-right: 1rem;\n padding-top: .5rem;\n padding-bottom: .5rem;\n background-color: #e6e6e6;\n color: rgba(0,0,0,.8);\n border-radius: .25rem;\n border-style: none;\n border-width: 0;\n cursor: pointer;\n -webkit-appearance: button;\n text-transform: none;\n overflow: visible;\n line-height: 1.15;\n margin: 0;\n will-change: transform;\n -moz-osx-font-smoothing: grayscale;\n -webkit-backface-visibility: hidden;\n backface-visibility: hidden;\n -webkit-transform: translateZ(0);\n transform: translateZ(0);\n transition: -webkit-transform .25s ease-out;\n transition: transform .25s ease-out;\n transition: transform .25s ease-out,-webkit-transform .25s ease-out;\n}\n\n.modal__btn:focus, .modal__btn:hover {\n -webkit-transform: scale(1.05);\n transform: scale(1.05);\n}\n\n.modal__btn-primary {\n background-color: #333;\n color: #fff;\n}\n\n\n\n/************************** Demo Animation Style\n**************************/\n@keyframes mmfadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n@keyframes mmfadeOut {\n from { opacity: 1; }\n to { opacity: 0; }\n}\n\n@keyframes mmslideIn {\n from { transform: translateY(15%); }\n to { transform: translateY(0); }\n}\n\n@keyframes mmslideOut {\n from { transform: translateY(0); }\n to { transform: translateY(-10%); }\n}\n\n.micromodal-slide {\n display: none;\n}\n\n.micromodal-slide.is-open {\n display: block;\n}\n\n.micromodal-slide[aria-hidden=\"false\"] .modal__overlay {\n animation: mmfadeIn .3s cubic-bezier(0.0, 0.0, 0.2, 1);\n}\n\n.micromodal-slide[aria-hidden=\"false\"] .modal__container {\n animation: mmslideIn .3s cubic-bezier(0, 0, .2, 1);\n}\n\n.micromodal-slide[aria-hidden=\"true\"] .modal__overlay {\n animation: mmfadeOut .3s cubic-bezier(0.0, 0.0, 0.2, 1);\n}\n\n.micromodal-slide[aria-hidden=\"true\"] .modal__container {\n animation: mmslideOut .3s cubic-bezier(0, 0, .2, 1);\n}\n\n.micromodal-slide .modal__container,\n.micromodal-slide .modal__overlay {\n will-change: transform;\n}\n"; /***/ }), /***/ 330: /***/ (function(__unused_webpack_module, exports, __webpack_require__) { "use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.showDot = exports.initDotWithCSS = exports.showDialog = exports.showWarning = void 0; var micromodal_1 = __webpack_require__(650); var micromodal_css_1 = __webpack_require__(713); var params_1 = __webpack_require__(848); // Add modal styling. var style = document.createElement('style'); style.textContent = micromodal_css_1.css; document.head.append(style); function initModalHTML(modalID, title, content) { if (content === void 0) { content = ''; } var modalString = "
\n\t\t
\n\t\t
\n\t\t\t
\n\t\t\t\t

\n\t\t\t\t\t").concat(title, "\n\t\t\t\t

\n\t\t\t\t\n\t\t\t
\n\t\t\t
\n\t\t\t\t

\n\t\t\t\t\t").concat(content, "\n\t\t\t\t

\n\t\t\t
\n\t\t
\n\t\t
\n\t
"); // This is a trick to create an element from string. var temp = document.createElement('div'); temp.innerHTML = modalString; return temp.firstChild; } ; var alertModalInited = false; var dialogModalInited = false; var ALERT_MODAL_ID = 'alert'; var alertModal = initModalHTML(ALERT_MODAL_ID, 'Warning'); var DIALOG_MODAL_ID = 'dialog'; var dialogModal = initModalHTML(DIALOG_MODAL_ID, 'Saving...'); function showWarning(message) { console.warn(message); if (!params_1.PARAMS.SHOW_ALERTS) { return; } if (!alertModalInited) { alertModalInited = true; document.getElementsByTagName('body')[0].appendChild(alertModal); } document.getElementById("modal-".concat(ALERT_MODAL_ID, "-content")).innerHTML = message; micromodal_1.default.show("modal-".concat(ALERT_MODAL_ID)); } exports.showWarning = showWarning; function showDialog(title, message, options) { if (params_1.PARAMS.VERBOSE) console.log(title, message); if (!params_1.PARAMS.SHOW_DIALOGS) { return; } if (!dialogModalInited) { dialogModalInited = true; document.getElementsByTagName('body')[0].appendChild(dialogModal); } document.getElementById("modal-".concat(DIALOG_MODAL_ID, "-title")).innerHTML = title; document.getElementById("modal-".concat(DIALOG_MODAL_ID, "-content")).innerHTML = message; micromodal_1.default.show("modal-".concat(DIALOG_MODAL_ID)); var autoCloseDelay = (options === null || options === void 0 ? void 0 : options.autoCloseDelay) !== undefined ? options.autoCloseDelay : -1; if (autoCloseDelay > 0) { setTimeout(function () { micromodal_1.default.close("modal-".concat(DIALOG_MODAL_ID)); }, autoCloseDelay); } } exports.showDialog = showDialog; // Create record red dot vis to overlay when recording is happening. var dot = document.createElement('div'); function initDotWithCSS(css) { dot.id = 'recordingDot'; var dotCSS = __assign({ background: "red", width: "20px", height: "20px", "border-radius": "50%", display: "none", position: "absolute", top: "0", right: "0", "z-index": "10", margin: "20px" }, css); Object.assign(dot.style, dotCSS); document.getElementsByTagName('body')[0].appendChild(dot); } exports.initDotWithCSS = initDotWithCSS; function showDot(visible) { if (!params_1.PARAMS.SHOW_REC_DOT) return; if (visible) { dot.style.display = "inline-block"; } else { dot.style.display = "none"; } } exports.showDot = showDot; /***/ }), /***/ 848: /***/ ((__unused_webpack_module, exports) => { "use strict"; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.PARAMS = void 0; // Params. exports.PARAMS = { VERBOSE: false, SHOW_ALERTS: false, SHOW_DIALOGS: false, SHOW_REC_DOT: false, IS_MANUALLY_CHECKING_HOTKEYS: false, }; /***/ }), /***/ 886: /***/ ((module, exports, __webpack_require__) => { /* module decorator */ module = __webpack_require__.nmd(module); var __WEBPACK_AMD_DEFINE_RESULT__;;(function() { if ( true && typeof module.exports !== 'undefined') { var Tar = __webpack_require__(846); var download = __webpack_require__(173); var GIF = __webpack_require__(769); var WebMWriter = __webpack_require__(166); } "use strict"; var objectTypes = { 'function': true, 'object': true }; function checkGlobal(value) { return (value && value.Object === Object) ? value : null; } /** Built-in method references without a dependency on `root`. */ var freeParseFloat = parseFloat, freeParseInt = parseInt; /** Detect free variable `exports`. */ var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : undefined; /** Detect free variable `module`. */ var freeModule = (objectTypes["object"] && module && !module.nodeType) ? module : undefined; /** Detect the popular CommonJS extension `module.exports`. */ var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : undefined; /** Detect free variable `global` from Node.js. */ var freeGlobal = checkGlobal(freeExports && freeModule && typeof __webpack_require__.g == 'object' && __webpack_require__.g); /** Detect free variable `self`. */ var freeSelf = checkGlobal(objectTypes[typeof self] && self); /** Detect free variable `window`. */ var freeWindow = checkGlobal(objectTypes[typeof window] && window); /** Detect `this` as the global object. */ var thisGlobal = checkGlobal(objectTypes[typeof this] && this); /** * Used as a reference to the global object. * * The `this` value is used if it's the global object to avoid Greasemonkey's * restricted `window` object, otherwise the `window` object is used. */ var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')(); if( !('gc' in window ) ) { window.gc = function(){} } if (!HTMLCanvasElement.prototype.toBlob) { Object.defineProperty(HTMLCanvasElement.prototype, 'toBlob', { value: function (callback, type, quality) { var binStr = atob( this.toDataURL(type, quality).split(',')[1] ), len = binStr.length, arr = new Uint8Array(len); for (var i=0; i 0 && ( this.frames.length / this.settings.framerate ) >= this.settings.autoSaveTime ) { this.count++; this.step(); }.bind( this ); fileReader.readAsArrayBuffer(blob); } CCTarEncoder.prototype.save = function( callback ) { callback( this.tape.save() ); } CCTarEncoder.prototype.dispose = function() { this.tape = new Tar(); this.count = 0; } function CCPNGEncoder( settings ) { CCTarEncoder.call( this, settings ); this.type = 'image/png'; this.fileExtension = '.png'; } CCPNGEncoder.prototype = Object.create( CCTarEncoder.prototype ); CCPNGEncoder.prototype.add = function( canvas ) { canvas.toBlob( function( blob ) { CCTarEncoder.prototype.add.call( this, blob ); }.bind( this ), this.type ) } function CCJPEGEncoder( settings ) { CCTarEncoder.call( this, settings ); this.type = 'image/jpeg'; this.fileExtension = '.jpg'; this.quality = ( settings.quality / 100 ) || .8; } CCJPEGEncoder.prototype = Object.create( CCTarEncoder.prototype ); CCJPEGEncoder.prototype.add = function( canvas ) { canvas.toBlob( function( blob ) { CCTarEncoder.prototype.add.call( this, blob ); }.bind( this ), this.type, this.quality ) } /* WebM Encoder */ function CCWebMEncoder( settings ) { var canvas = document.createElement( 'canvas' ); if( canvas.toDataURL( 'image/webp' ).substr(5,10) !== 'image/webp' ){ console.log( "WebP not supported - try another export format" ) } CCFrameEncoder.call( this, settings ); this.quality = ( settings.quality / 100 ) || .8; this.extension = '.webm' this.mimeType = 'video/webm' this.baseFilename = this.filename; this.frames = []; this.part = 1; this.videoWriter = new WebMWriter({ quality: this.quality, fileWriter: null, fd: null, frameRate: settings.framerate }); } CCWebMEncoder.prototype = Object.create( CCFrameEncoder.prototype ); CCWebMEncoder.prototype.start = function( canvas ) { this.dispose(); } CCWebMEncoder.prototype.add = function( canvas ) { this.videoWriter.addFrame(canvas); //this.frames.push( canvas.toDataURL('image/webp', this.quality) ); if( this.settings.autoSaveTime > 0 && ( this.frames.length / this.settings.framerate ) >= this.settings.autoSaveTime ) { this.save( function( blob ) { this.filename = this.baseFilename + '-part-' + pad( this.part ); download( blob, this.filename + this.extension, this.mimeType ); this.dispose(); this.part++; this.filename = this.baseFilename + '-part-' + pad( this.part ); this.step(); }.bind( this ) ) } else { this.step(); } } CCWebMEncoder.prototype.save = function( callback ) { // if( !this.frames.length ) return; this.videoWriter.complete().then(callback); /*var webm = Whammy.fromImageArray( this.frames, this.settings.framerate ) var blob = new Blob( [ webm ], { type: "octet/stream" } ); callback( blob );*/ } CCWebMEncoder.prototype.dispose = function( canvas ) { this.frames = []; } function CCFFMpegServerEncoder( settings ) { CCFrameEncoder.call( this, settings ); settings.quality = ( settings.quality / 100 ) || .8; this.encoder = new FFMpegServer.Video( settings ); this.encoder.on( 'process', function() { this.emit( 'process' ) }.bind( this ) ); this.encoder.on('finished', function( url, size ) { var cb = this.callback; if ( cb ) { this.callback = undefined; cb( url, size ); } }.bind( this ) ); this.encoder.on( 'progress', function( progress ) { if ( this.settings.onProgress ) { this.settings.onProgress( progress ) } }.bind( this ) ); this.encoder.on( 'error', function( data ) { alert(JSON.stringify(data, null, 2)); }.bind( this ) ); } CCFFMpegServerEncoder.prototype = Object.create( CCFrameEncoder.prototype ); CCFFMpegServerEncoder.prototype.start = function() { this.encoder.start( this.settings ); }; CCFFMpegServerEncoder.prototype.add = function( canvas ) { this.encoder.add( canvas ); } CCFFMpegServerEncoder.prototype.save = function( callback ) { this.callback = callback; this.encoder.end(); } CCFFMpegServerEncoder.prototype.safeToProceed = function() { return this.encoder.safeToProceed(); }; /* HTMLCanvasElement.captureStream() */ function CCStreamEncoder( settings ) { CCFrameEncoder.call( this, settings ); this.framerate = this.settings.framerate; this.type = 'video/webm'; this.extension = '.webm'; this.stream = null; this.mediaRecorder = null; this.chunks = []; } CCStreamEncoder.prototype = Object.create( CCFrameEncoder.prototype ); CCStreamEncoder.prototype.add = function( canvas ) { if( !this.stream ) { this.stream = canvas.captureStream( this.framerate ); this.mediaRecorder = new MediaRecorder( this.stream ); this.mediaRecorder.start(); this.mediaRecorder.ondataavailable = function(e) { this.chunks.push(e.data); }.bind( this ); } this.step(); } CCStreamEncoder.prototype.save = function( callback ) { this.mediaRecorder.onstop = function( e ) { var blob = new Blob( this.chunks, { 'type' : 'video/webm' }); this.chunks = []; callback( blob ); }.bind( this ); this.mediaRecorder.stop(); } /*function CCGIFEncoder( settings ) { CCFrameEncoder.call( this ); settings.quality = settings.quality || 6; this.settings = settings; this.encoder = new GIFEncoder(); this.encoder.setRepeat( 1 ); this.encoder.setDelay( settings.step ); this.encoder.setQuality( 6 ); this.encoder.setTransparent( null ); this.encoder.setSize( 150, 150 ); this.canvas = document.createElement( 'canvas' ); this.ctx = this.canvas.getContext( '2d' ); } CCGIFEncoder.prototype = Object.create( CCFrameEncoder ); CCGIFEncoder.prototype.start = function() { this.encoder.start(); } CCGIFEncoder.prototype.add = function( canvas ) { this.canvas.width = canvas.width; this.canvas.height = canvas.height; this.ctx.drawImage( canvas, 0, 0 ); this.encoder.addFrame( this.ctx ); this.encoder.setSize( canvas.width, canvas.height ); var readBuffer = new Uint8Array(canvas.width * canvas.height * 4); var context = canvas.getContext( 'webgl' ); context.readPixels(0, 0, canvas.width, canvas.height, context.RGBA, context.UNSIGNED_BYTE, readBuffer); this.encoder.addFrame( readBuffer, true ); } CCGIFEncoder.prototype.stop = function() { this.encoder.finish(); } CCGIFEncoder.prototype.save = function( callback ) { var binary_gif = this.encoder.stream().getData(); var data_url = 'data:image/gif;base64,'+encode64(binary_gif); window.location = data_url; return; var blob = new Blob( [ binary_gif ], { type: "octet/stream" } ); var url = window.URL.createObjectURL( blob ); callback( url ); }*/ function CCGIFEncoder( settings ) { CCFrameEncoder.call( this, settings ); settings.quality = 31 - ( ( settings.quality * 30 / 100 ) || 10 ); settings.workers = settings.workers || 4; this.extension = '.gif' this.mimeType = 'image/gif' this.canvas = document.createElement( 'canvas' ); this.ctx = this.canvas.getContext( '2d' ); this.sizeSet = false; this.encoder = new GIF({ workers: settings.workers, quality: settings.quality, workerScript: settings.workersPath, } ); this.encoder.on( 'progress', function( progress ) { if ( this.settings.onProgress ) { this.settings.onProgress( progress ) } }.bind( this ) ); this.encoder.on('finished', function( blob ) { var cb = this.callback; if ( cb ) { this.callback = undefined; cb( blob ); } }.bind( this ) ); } CCGIFEncoder.prototype = Object.create( CCFrameEncoder.prototype ); CCGIFEncoder.prototype.add = function( canvas ) { if( !this.sizeSet ) { this.encoder.setOption( 'width',canvas.width ); this.encoder.setOption( 'height',canvas.height ); this.sizeSet = true; } this.canvas.width = canvas.width; this.canvas.height = canvas.height; this.ctx.drawImage( canvas, 0, 0 ); this.encoder.addFrame( this.ctx, { copy: true, delay: this.settings.step } ); this.step(); /*this.encoder.setSize( canvas.width, canvas.height ); var readBuffer = new Uint8Array(canvas.width * canvas.height * 4); var context = canvas.getContext( 'webgl' ); context.readPixels(0, 0, canvas.width, canvas.height, context.RGBA, context.UNSIGNED_BYTE, readBuffer); this.encoder.addFrame( readBuffer, true );*/ } CCGIFEncoder.prototype.save = function( callback ) { this.callback = callback; this.encoder.render(); } function CCapture( settings ) { var _settings = settings || {}, _date = new Date(), _verbose, _display, _time, _startTime, _performanceTime, _performanceStartTime, _step, _encoder, _timeouts = [], _intervals = [], _frameCount = 0, _intermediateFrameCount = 0, _lastFrame = null, _requestAnimationFrameCallbacks = [], _capturing = false, _handlers = {}; _settings.framerate = _settings.framerate || 60; _settings.motionBlurFrames = 2 * ( _settings.motionBlurFrames || 1 ); _verbose = _settings.verbose || false; _display = _settings.display || false; _settings.step = 1000.0 / _settings.framerate ; _settings.timeLimit = _settings.timeLimit || 0; _settings.frameLimit = _settings.frameLimit || 0; _settings.startTime = _settings.startTime || 0; var _timeDisplay = document.createElement( 'div' ); _timeDisplay.style.position = 'absolute'; _timeDisplay.style.left = _timeDisplay.style.top = 0 _timeDisplay.style.backgroundColor = 'black'; _timeDisplay.style.fontFamily = 'monospace' _timeDisplay.style.fontSize = '11px' _timeDisplay.style.padding = '5px' _timeDisplay.style.color = 'red'; _timeDisplay.style.zIndex = 100000 if( _settings.display ) document.body.appendChild( _timeDisplay ); var canvasMotionBlur = document.createElement( 'canvas' ); var ctxMotionBlur = canvasMotionBlur.getContext( '2d' ); var bufferMotionBlur; var imageData; _log( 'Step is set to ' + _settings.step + 'ms' ); var _encoders = { gif: CCGIFEncoder, webm: CCWebMEncoder, ffmpegserver: CCFFMpegServerEncoder, png: CCPNGEncoder, jpg: CCJPEGEncoder, 'webm-mediarecorder': CCStreamEncoder }; var ctor = _encoders[ _settings.format ]; if ( !ctor ) { throw "Error: Incorrect or missing format: Valid formats are " + Object.keys(_encoders).join(", "); } _encoder = new ctor( _settings ); _encoder.step = _step _encoder.on('process', _process); _encoder.on('progress', _progress); if ("performance" in window == false) { window.performance = {}; } Date.now = (Date.now || function () { // thanks IE8 return new Date().getTime(); }); if ("now" in window.performance == false){ var nowOffset = Date.now(); if (performance.timing && performance.timing.navigationStart){ nowOffset = performance.timing.navigationStart } window.performance.now = function now(){ return Date.now() - nowOffset; } } var _oldSetTimeout = window.setTimeout, _oldSetInterval = window.setInterval, _oldClearInterval = window.clearInterval, _oldClearTimeout = window.clearTimeout, _oldRequestAnimationFrame = window.requestAnimationFrame, _oldNow = window.Date.now, _oldPerformanceNow = window.performance.now, _oldGetTime = window.Date.prototype.getTime; // Date.prototype._oldGetTime = Date.prototype.getTime; var media = []; function _init() { _log( 'Capturer start' ); _startTime = window.Date.now(); _time = _startTime + _settings.startTime; _performanceStartTime = window.performance.now(); _performanceTime = _performanceStartTime + _settings.startTime; window.Date.prototype.getTime = function(){ return _time; }; window.Date.now = function() { return _time; }; window.setTimeout = function( callback, time ) { var t = { callback: callback, time: time, triggerTime: _time + time }; _timeouts.push( t ); _log( 'Timeout set to ' + t.time ); return t; }; window.clearTimeout = function( id ) { for( var j = 0; j < _timeouts.length; j++ ) { if( _timeouts[ j ] == id ) { _timeouts.splice( j, 1 ); _log( 'Timeout cleared' ); continue; } } }; window.setInterval = function( callback, time ) { var t = { callback: callback, time: time, triggerTime: _time + time }; _intervals.push( t ); _log( 'Interval set to ' + t.time ); return t; }; window.clearInterval = function( id ) { _log( 'clear Interval' ); return null; }; window.requestAnimationFrame = function( callback ) { _requestAnimationFrameCallbacks.push( callback ); }; window.performance.now = function(){ return _performanceTime; }; function hookCurrentTime() { if( !this._hooked ) { this._hooked = true; this._hookedTime = this.currentTime || 0; this.pause(); media.push( this ); } return this._hookedTime + _settings.startTime; }; try { Object.defineProperty( HTMLVideoElement.prototype, 'currentTime', { get: hookCurrentTime } ) Object.defineProperty( HTMLAudioElement.prototype, 'currentTime', { get: hookCurrentTime } ) } catch (err) { _log(err); } } function _start() { _init(); _encoder.start(); _capturing = true; } function _stop() { _capturing = false; _encoder.stop(); _destroy(); } function _call( fn, p ) { _oldSetTimeout( fn, 0, p ); } function _step() { //_oldRequestAnimationFrame( _process ); _call( _process ); } function _destroy() { _log( 'Capturer stop' ); window.setTimeout = _oldSetTimeout; window.setInterval = _oldSetInterval; window.clearInterval = _oldClearInterval; window.clearTimeout = _oldClearTimeout; window.requestAnimationFrame = _oldRequestAnimationFrame; window.Date.prototype.getTime = _oldGetTime; window.Date.now = _oldNow; window.performance.now = _oldPerformanceNow; } function _updateTime() { var seconds = _frameCount / _settings.framerate; if( ( _settings.frameLimit && _frameCount >= _settings.frameLimit ) || ( _settings.timeLimit && seconds >= _settings.timeLimit ) ) { _stop(); _save(); } var d = new Date( null ); d.setSeconds( seconds ); if( _settings.motionBlurFrames > 2 ) { _timeDisplay.textContent = 'CCapture ' + _settings.format + ' | ' + _frameCount + ' frames (' + _intermediateFrameCount + ' inter) | ' + d.toISOString().substr( 11, 8 ); } else { _timeDisplay.textContent = 'CCapture ' + _settings.format + ' | ' + _frameCount + ' frames | ' + d.toISOString().substr( 11, 8 ); } } function _checkFrame( canvas ) { if( canvasMotionBlur.width !== canvas.width || canvasMotionBlur.height !== canvas.height ) { canvasMotionBlur.width = canvas.width; canvasMotionBlur.height = canvas.height; bufferMotionBlur = new Uint16Array( canvasMotionBlur.height * canvasMotionBlur.width * 4 ); ctxMotionBlur.fillStyle = '#0' ctxMotionBlur.fillRect( 0, 0, canvasMotionBlur.width, canvasMotionBlur.height ); } } function _blendFrame( canvas ) { //_log( 'Intermediate Frame: ' + _intermediateFrameCount ); ctxMotionBlur.drawImage( canvas, 0, 0 ); imageData = ctxMotionBlur.getImageData( 0, 0, canvasMotionBlur.width, canvasMotionBlur.height ); for( var j = 0; j < bufferMotionBlur.length; j+= 4 ) { bufferMotionBlur[ j ] += imageData.data[ j ]; bufferMotionBlur[ j + 1 ] += imageData.data[ j + 1 ]; bufferMotionBlur[ j + 2 ] += imageData.data[ j + 2 ]; } _intermediateFrameCount++; } function _saveFrame(){ var data = imageData.data; for( var j = 0; j < bufferMotionBlur.length; j+= 4 ) { data[ j ] = bufferMotionBlur[ j ] * 2 / _settings.motionBlurFrames; data[ j + 1 ] = bufferMotionBlur[ j + 1 ] * 2 / _settings.motionBlurFrames; data[ j + 2 ] = bufferMotionBlur[ j + 2 ] * 2 / _settings.motionBlurFrames; } ctxMotionBlur.putImageData( imageData, 0, 0 ); _encoder.add( canvasMotionBlur ); _frameCount++; _intermediateFrameCount = 0; _log( 'Full MB Frame! ' + _frameCount + ' ' + _time ); for( var j = 0; j < bufferMotionBlur.length; j+= 4 ) { bufferMotionBlur[ j ] = 0; bufferMotionBlur[ j + 1 ] = 0; bufferMotionBlur[ j + 2 ] = 0; } gc(); } function _capture( canvas ) { if( _capturing ) { if( _settings.motionBlurFrames > 2 ) { _checkFrame( canvas ); _blendFrame( canvas ); if( _intermediateFrameCount >= .5 * _settings.motionBlurFrames ) { _saveFrame(); } else { _step(); } } else { _encoder.add( canvas ); _frameCount++; _log( 'Full Frame! ' + _frameCount ); } } } function _process() { var step = 1000 / _settings.framerate; var dt = ( _frameCount + _intermediateFrameCount / _settings.motionBlurFrames ) * step; _time = _startTime + dt; _performanceTime = _performanceStartTime + dt; media.forEach( function( v ) { v._hookedTime = dt / 1000; } ); _updateTime(); _log( 'Frame: ' + _frameCount + ' ' + _intermediateFrameCount ); for( var j = 0; j < _timeouts.length; j++ ) { if( _time >= _timeouts[ j ].triggerTime ) { _call( _timeouts[ j ].callback ) //console.log( 'timeout!' ); _timeouts.splice( j, 1 ); continue; } } for( var j = 0; j < _intervals.length; j++ ) { if( _time >= _intervals[ j ].triggerTime ) { _call( _intervals[ j ].callback ); _intervals[ j ].triggerTime += _intervals[ j ].time; //console.log( 'interval!' ); continue; } } _requestAnimationFrameCallbacks.forEach( function( cb ) { _call( cb, _time - g_startTime ); } ); _requestAnimationFrameCallbacks = []; } function _save( callback ) { if( !callback ) { callback = function( blob ) { download( blob, _encoder.filename + _encoder.extension, _encoder.mimeType ); return false; } } _encoder.save( callback ); } function _log( message ) { if( _verbose ) console.log( message ); } function _on( event, handler ) { _handlers[event] = handler; } function _emit( event ) { var handler = _handlers[event]; if ( handler ) { handler.apply( null, Array.prototype.slice.call( arguments, 1 ) ); } } function _progress( progress ) { _emit( 'progress', progress ); } return { start: _start, capture: _capture, stop: _stop, save: _save, on: _on } } (freeWindow || freeSelf || {}).CCapture = CCapture; // Some AMD build optimizers like r.js check for condition patterns like the following: if (true) { // Define as an anonymous module so, through path mapping, it can be // referenced as the "underscore" module. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { return CCapture; }).call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } // Check for `exports` after `define` in case a build optimizer adds an `exports` object. else {} }()); /***/ }), /***/ 173: /***/ ((module) => { //download.js v3.0, by dandavis; 2008-2014. [CCBY2] see http://danml.com/download.html for tests/usage // v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime // v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs // v3 added dataURL and Blob Input, bind-toggle arity, and legacy dataURL fallback was improved with force-download mime and base64 support // data can be a string, Blob, File, or dataURL function download(data, strFileName, strMimeType) { var self = window, // this script is only for browsers anyway... u = "application/octet-stream", // this default mime also triggers iframe downloads m = strMimeType || u, x = data, D = document, a = D.createElement("a"), z = function(a){return String(a);}, B = self.Blob || self.MozBlob || self.WebKitBlob || z, BB = self.MSBlobBuilder || self.WebKitBlobBuilder || self.BlobBuilder, fn = strFileName || "download", blob, b, ua, fr; //if(typeof B.bind === 'function' ){ B=B.bind(self); } if(String(this)==="true"){ //reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback x=[x, m]; m=x[0]; x=x[1]; } //go ahead and download dataURLs right away if(String(x).match(/^data\:[\w+\-]+\/[\w+\-]+[,;]/)){ return navigator.msSaveBlob ? // IE10 can't do a[download], only Blobs: navigator.msSaveBlob(d2b(x), fn) : saver(x) ; // everyone else can save dataURLs un-processed }//end if dataURL passed? try{ blob = x instanceof B ? x : new B([x], {type: m}) ; }catch(y){ if(BB){ b = new BB(); b.append([x]); blob = b.getBlob(m); // the blob } } function d2b(u) { var p= u.split(/[:;,]/), t= p[1], dec= p[2] == "base64" ? atob : decodeURIComponent, bin= dec(p.pop()), mx= bin.length, i= 0, uia= new Uint8Array(mx); for(i;i { // gif.js 0.2.0 - https://github.com/jnordberg/gif.js (function(f){if(true){module.exports=f()}else { var g; }})(function(){var define,module,exports;return function(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=undefined;if(!u&&a)return require(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=undefined;for(var o=0;o0&&this._events[type].length>m){this._events[type].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[type].length);if(typeof console.trace==="function"){console.trace()}}}return this};EventEmitter.prototype.on=EventEmitter.prototype.addListener;EventEmitter.prototype.once=function(type,listener){if(!isFunction(listener))throw TypeError("listener must be a function");var fired=false;function g(){this.removeListener(type,g);if(!fired){fired=true;listener.apply(this,arguments)}}g.listener=listener;this.on(type,g);return this};EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;list=this._events[type];length=list.length;position=-1;if(list===listener||isFunction(list.listener)&&list.listener===listener){delete this._events[type];if(this._events.removeListener)this.emit("removeListener",type,listener)}else if(isObject(list)){for(i=length;i-- >0;){if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}}if(position<0)return this;if(list.length===1){list.length=0;delete this._events[type]}else{list.splice(position,1)}if(this._events.removeListener)this.emit("removeListener",type,listener)}return this};EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[type])delete this._events[type];return this}if(arguments.length===0){for(key in this._events){if(key==="removeListener")continue;this.removeAllListeners(key)}this.removeAllListeners("removeListener");this._events={};return this}listeners=this._events[type];if(isFunction(listeners)){this.removeListener(type,listeners)}else if(listeners){while(listeners.length)this.removeListener(type,listeners[listeners.length-1])}delete this._events[type];return this};EventEmitter.prototype.listeners=function(type){var ret;if(!this._events||!this._events[type])ret=[];else if(isFunction(this._events[type]))ret=[this._events[type]];else ret=this._events[type].slice();return ret};EventEmitter.prototype.listenerCount=function(type){if(this._events){var evlistener=this._events[type];if(isFunction(evlistener))return 1;else if(evlistener)return evlistener.length}return 0};EventEmitter.listenerCount=function(emitter,type){return emitter.listenerCount(type)};function isFunction(arg){return typeof arg==="function"}function isNumber(arg){return typeof arg==="number"}function isObject(arg){return typeof arg==="object"&&arg!==null}function isUndefined(arg){return arg===void 0}},{}],2:[function(require,module,exports){var NeuQuant=require("./TypedNeuQuant.js");var LZWEncoder=require("./LZWEncoder.js");function ByteArray(){this.page=-1;this.pages=[];this.newPage()}ByteArray.pageSize=4096;ByteArray.charMap={};for(var i=0;i<256;i++)ByteArray.charMap[i]=String.fromCharCode(i);ByteArray.prototype.newPage=function(){this.pages[++this.page]=new Uint8Array(ByteArray.pageSize);this.cursor=0};ByteArray.prototype.getData=function(){var rv="";for(var p=0;p=ByteArray.pageSize)this.newPage();this.pages[this.page][this.cursor++]=val};ByteArray.prototype.writeUTFBytes=function(string){for(var l=string.length,i=0;i=0)this.dispose=disposalCode};GIFEncoder.prototype.setRepeat=function(repeat){this.repeat=repeat};GIFEncoder.prototype.setTransparent=function(color){this.transparent=color};GIFEncoder.prototype.addFrame=function(imageData){this.image=imageData;this.colorTab=this.globalPalette&&this.globalPalette.slice?this.globalPalette:null;this.getImagePixels();this.analyzePixels();if(this.globalPalette===true)this.globalPalette=this.colorTab;if(this.firstFrame){this.writeLSD();this.writePalette();if(this.repeat>=0){this.writeNetscapeExt()}}this.writeGraphicCtrlExt();this.writeImageDesc();if(!this.firstFrame&&!this.globalPalette)this.writePalette();this.writePixels();this.firstFrame=false};GIFEncoder.prototype.finish=function(){this.out.writeByte(59)};GIFEncoder.prototype.setQuality=function(quality){if(quality<1)quality=1;this.sample=quality};GIFEncoder.prototype.setDither=function(dither){if(dither===true)dither="FloydSteinberg";this.dither=dither};GIFEncoder.prototype.setGlobalPalette=function(palette){this.globalPalette=palette};GIFEncoder.prototype.getGlobalPalette=function(){return this.globalPalette&&this.globalPalette.slice&&this.globalPalette.slice(0)||this.globalPalette};GIFEncoder.prototype.writeHeader=function(){this.out.writeUTFBytes("GIF89a")};GIFEncoder.prototype.analyzePixels=function(){if(!this.colorTab){this.neuQuant=new NeuQuant(this.pixels,this.sample);this.neuQuant.buildColormap();this.colorTab=this.neuQuant.getColormap()}if(this.dither){this.ditherPixels(this.dither.replace("-serpentine",""),this.dither.match(/-serpentine/)!==null)}else{this.indexPixels()}this.pixels=null;this.colorDepth=8;this.palSize=7;if(this.transparent!==null){this.transIndex=this.findClosest(this.transparent,true)}};GIFEncoder.prototype.indexPixels=function(imgq){var nPix=this.pixels.length/3;this.indexedPixels=new Uint8Array(nPix);var k=0;for(var j=0;j=0&&x1+x=0&&y1+y>16,(c&65280)>>8,c&255,used)};GIFEncoder.prototype.findClosestRGB=function(r,g,b,used){if(this.colorTab===null)return-1;if(this.neuQuant&&!used){return this.neuQuant.lookupRGB(r,g,b)}var c=b|g<<8|r<<16;var minpos=0;var dmin=256*256*256;var len=this.colorTab.length;for(var i=0,index=0;i=0){disp=this.dispose&7}disp<<=2;this.out.writeByte(0|disp|0|transp);this.writeShort(this.delay);this.out.writeByte(this.transIndex);this.out.writeByte(0)};GIFEncoder.prototype.writeImageDesc=function(){this.out.writeByte(44);this.writeShort(0);this.writeShort(0);this.writeShort(this.width);this.writeShort(this.height);if(this.firstFrame||this.globalPalette){this.out.writeByte(0)}else{this.out.writeByte(128|0|0|0|this.palSize)}};GIFEncoder.prototype.writeLSD=function(){this.writeShort(this.width);this.writeShort(this.height);this.out.writeByte(128|112|0|this.palSize);this.out.writeByte(0);this.out.writeByte(0)};GIFEncoder.prototype.writeNetscapeExt=function(){this.out.writeByte(33);this.out.writeByte(255);this.out.writeByte(11);this.out.writeUTFBytes("NETSCAPE2.0");this.out.writeByte(3);this.out.writeByte(1);this.writeShort(this.repeat);this.out.writeByte(0)};GIFEncoder.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);var n=3*256-this.colorTab.length;for(var i=0;i>8&255)};GIFEncoder.prototype.writePixels=function(){var enc=new LZWEncoder(this.width,this.height,this.indexedPixels,this.colorDepth);enc.encode(this.out)};GIFEncoder.prototype.stream=function(){return this.out};module.exports=GIFEncoder},{"./LZWEncoder.js":3,"./TypedNeuQuant.js":4}],3:[function(require,module,exports){var EOF=-1;var BITS=12;var HSIZE=5003;var masks=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];function LZWEncoder(width,height,pixels,colorDepth){var initCodeSize=Math.max(2,colorDepth);var accum=new Uint8Array(256);var htab=new Int32Array(HSIZE);var codetab=new Int32Array(HSIZE);var cur_accum,cur_bits=0;var a_count;var free_ent=0;var maxcode;var clear_flg=false;var g_init_bits,ClearCode,EOFCode;function char_out(c,outs){accum[a_count++]=c;if(a_count>=254)flush_char(outs)}function cl_block(outs){cl_hash(HSIZE);free_ent=ClearCode+2;clear_flg=true;output(ClearCode,outs)}function cl_hash(hsize){for(var i=0;i=0){disp=hsize_reg-i;if(i===0)disp=1;do{if((i-=disp)<0)i+=hsize_reg;if(htab[i]===fcode){ent=codetab[i];continue outer_loop}}while(htab[i]>=0)}output(ent,outs);ent=c;if(free_ent<1<0){outs.writeByte(a_count);outs.writeBytes(accum,0,a_count);a_count=0}}function MAXCODE(n_bits){return(1<0)cur_accum|=code<=8){char_out(cur_accum&255,outs);cur_accum>>=8;cur_bits-=8}if(free_ent>maxcode||clear_flg){if(clear_flg){maxcode=MAXCODE(n_bits=g_init_bits);clear_flg=false}else{++n_bits;if(n_bits==BITS)maxcode=1<0){char_out(cur_accum&255,outs);cur_accum>>=8;cur_bits-=8}flush_char(outs)}}this.encode=encode}module.exports=LZWEncoder},{}],4:[function(require,module,exports){var ncycles=100;var netsize=256;var maxnetpos=netsize-1;var netbiasshift=4;var intbiasshift=16;var intbias=1<>betashift;var betagamma=intbias<>3;var radiusbiasshift=6;var radiusbias=1<>3);var i,v;for(i=0;i>=netbiasshift;network[i][1]>>=netbiasshift;network[i][2]>>=netbiasshift;network[i][3]=i}}function altersingle(alpha,i,b,g,r){network[i][0]-=alpha*(network[i][0]-b)/initalpha;network[i][1]-=alpha*(network[i][1]-g)/initalpha;network[i][2]-=alpha*(network[i][2]-r)/initalpha}function alterneigh(radius,i,b,g,r){var lo=Math.abs(i-radius);var hi=Math.min(i+radius,netsize);var j=i+1;var k=i-1;var m=1;var p,a;while(jlo){a=radpower[m++];if(jlo){p=network[k--];p[0]-=a*(p[0]-b)/alpharadbias;p[1]-=a*(p[1]-g)/alpharadbias;p[2]-=a*(p[2]-r)/alpharadbias}}}function contest(b,g,r){var bestd=~(1<<31);var bestbiasd=bestd;var bestpos=-1;var bestbiaspos=bestpos;var i,n,dist,biasdist,betafreq;for(i=0;i>intbiasshift-netbiasshift);if(biasdist>betashift;freq[i]-=betafreq;bias[i]+=betafreq<>1;for(j=previouscol+1;j>1;for(j=previouscol+1;j<256;j++)netindex[j]=maxnetpos}function inxsearch(b,g,r){var a,p,dist;var bestd=1e3;var best=-1;var i=netindex[g];var j=i-1;while(i=0){if(i=bestd)i=netsize;else{i++;if(dist<0)dist=-dist;a=p[0]-b;if(a<0)a=-a;dist+=a;if(dist=0){p=network[j];dist=g-p[1];if(dist>=bestd)j=-1;else{j--;if(dist<0)dist=-dist;a=p[0]-b;if(a<0)a=-a;dist+=a;if(dist>radiusbiasshift;if(rad<=1)rad=0;for(i=0;i=lengthcount)pix-=lengthcount;i++;if(delta===0)delta=1;if(i%delta===0){alpha-=alpha/alphadec;radius-=radius/radiusdec;rad=radius>>radiusbiasshift;if(rad<=1)rad=0;for(j=0;jref;i=0<=ref?++j:--j){results.push(null)}return results}.call(this);numWorkers=this.spawnWorkers();if(this.options.globalPalette===true){this.renderNextFrame()}else{for(i=j=0,ref=numWorkers;0<=ref?jref;i=0<=ref?++j:--j){this.renderNextFrame()}}this.emit("start");return this.emit("progress",0)};GIF.prototype.abort=function(){var worker;while(true){worker=this.activeWorkers.shift();if(worker==null){break}this.log("killing active worker");worker.terminate()}this.running=false;return this.emit("abort")};GIF.prototype.spawnWorkers=function(){var j,numWorkers,ref,results;numWorkers=Math.min(this.options.workers,this.frames.length);(function(){results=[];for(var j=ref=this.freeWorkers.length;ref<=numWorkers?jnumWorkers;ref<=numWorkers?j++:j--){results.push(j)}return results}).apply(this).forEach(function(_this){return function(i){var worker;_this.log("spawning worker "+i);worker=new Worker(_this.options.workerScript);worker.onmessage=function(event){_this.activeWorkers.splice(_this.activeWorkers.indexOf(worker),1);_this.freeWorkers.push(worker);return _this.frameFinished(event.data)};return _this.freeWorkers.push(worker)}}(this));return numWorkers};GIF.prototype.frameFinished=function(frame){var i,j,ref;this.log("frame "+frame.index+" finished - "+this.activeWorkers.length+" active");this.finishedFrames++;this.emit("progress",this.finishedFrames/this.frames.length);this.imageParts[frame.index]=frame;if(this.options.globalPalette===true){this.options.globalPalette=frame.globalPalette;this.log("global palette analyzed");if(this.frames.length>2){for(i=j=1,ref=this.freeWorkers.length;1<=ref?jref;i=1<=ref?++j:--j){this.renderNextFrame()}}}if(indexOf.call(this.imageParts,null)>=0){return this.renderNextFrame()}else{return this.finishRendering()}};GIF.prototype.finishRendering=function(){var data,frame,i,image,j,k,l,len,len1,len2,len3,offset,page,ref,ref1,ref2;len=0;ref=this.imageParts;for(j=0,len1=ref.length;j=this.frames.length){return}frame=this.frames[this.nextFrame++];worker=this.freeWorkers.shift();task=this.getTask(frame);this.log("starting frame "+(task.index+1)+" of "+this.frames.length);this.activeWorkers.push(worker);return worker.postMessage(task)};GIF.prototype.getContextData=function(ctx){return ctx.getImageData(0,0,this.options.width,this.options.height).data};GIF.prototype.getImageData=function(image){var ctx;if(this._canvas==null){this._canvas=document.createElement("canvas");this._canvas.width=this.options.width;this._canvas.height=this.options.height}ctx=this._canvas.getContext("2d");ctx.setFill=this.options.background;ctx.fillRect(0,0,this.options.width,this.options.height);ctx.drawImage(image,0,0);return this.getContextData(ctx)};GIF.prototype.getTask=function(frame){var index,task;index=this.frames.indexOf(frame);task={index:index,last:index===this.frames.length-1,delay:frame.delay,dispose:frame.dispose,transparent:frame.transparent,width:this.options.width,height:this.options.height,quality:this.options.quality,dither:this.options.dither,globalPalette:this.options.globalPalette,repeat:this.options.repeat,canTransfer:browser.name==="chrome"};if(frame.data!=null){task.data=frame.data}else if(frame.context!=null){task.data=this.getContextData(frame.context)}else if(frame.image!=null){task.data=this.getImageData(frame.image)}else{throw new Error("Invalid frame")}return task};GIF.prototype.log=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];if(!this.options.debug){return}return console.log.apply(console,args)};return GIF}(EventEmitter)},{"./GIFEncoder.js":2,"./browser.coffee":5,"./gif.worker.coffee":7,events:1}],7:[function(require,module,exports){var GIFEncoder,renderFrame;GIFEncoder=require("./GIFEncoder.js");renderFrame=function(frame){var encoder,page,stream,transfer;encoder=new GIFEncoder(frame.width,frame.height);if(frame.index===0){encoder.writeHeader()}else{encoder.firstFrame=false}encoder.setTransparent(frame.transparent);encoder.setDispose(frame.dispose);encoder.setRepeat(frame.repeat);encoder.setDelay(frame.delay);encoder.setQuality(frame.quality);encoder.setDither(frame.dither);encoder.setGlobalPalette(frame.globalPalette);encoder.addFrame(frame.data);if(frame.last){encoder.finish()}if(frame.globalPalette===true){frame.globalPalette=encoder.getGlobalPalette()}stream=encoder.stream();frame.data=stream.pages;frame.cursor=stream.cursor;frame.pageSize=stream.constructor.pageSize;if(frame.canTransfer){transfer=function(){var i,len,ref,results;ref=frame.data;results=[];for(i=0,len=ref.length;i { (function () { "use strict"; var lookup = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' ]; function clean(length) { var i, buffer = new Uint8Array(length); for (i = 0; i < length; i += 1) { buffer[i] = 0; } return buffer; } function extend(orig, length, addLength, multipleOf) { var newSize = length + addLength, buffer = clean((parseInt(newSize / multipleOf) + 1) * multipleOf); buffer.set(orig); return buffer; } function pad(num, bytes, base) { num = num.toString(base || 8); return "000000000000".substr(num.length + 12 - bytes) + num; } function stringToUint8 (input, out, offset) { var i, length; out = out || clean(input.length); offset = offset || 0; for (i = 0, length = input.length; i < length; i += 1) { out[offset] = input.charCodeAt(i); offset += 1; } return out; } function uint8ToBase64(uint8) { var i, extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes output = "", temp, length; function tripletToBase64 (num) { return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]; }; // go through the array every three bytes, we'll deal with trailing stuff later for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]); output += tripletToBase64(temp); } // this prevents an ERR_INVALID_URL in Chrome (Firefox okay) switch (output.length % 4) { case 1: output += '='; break; case 2: output += '=='; break; default: break; } return output; } window.utils = {} window.utils.clean = clean; window.utils.pad = pad; window.utils.extend = extend; window.utils.stringToUint8 = stringToUint8; window.utils.uint8ToBase64 = uint8ToBase64; }()); (function () { "use strict"; /* struct posix_header { // byte offset char name[100]; // 0 char mode[8]; // 100 char uid[8]; // 108 char gid[8]; // 116 char size[12]; // 124 char mtime[12]; // 136 char chksum[8]; // 148 char typeflag; // 156 char linkname[100]; // 157 char magic[6]; // 257 char version[2]; // 263 char uname[32]; // 265 char gname[32]; // 297 char devmajor[8]; // 329 char devminor[8]; // 337 char prefix[155]; // 345 // 500 }; */ var utils = window.utils, headerFormat; headerFormat = [ { 'field': 'fileName', 'length': 100 }, { 'field': 'fileMode', 'length': 8 }, { 'field': 'uid', 'length': 8 }, { 'field': 'gid', 'length': 8 }, { 'field': 'fileSize', 'length': 12 }, { 'field': 'mtime', 'length': 12 }, { 'field': 'checksum', 'length': 8 }, { 'field': 'type', 'length': 1 }, { 'field': 'linkName', 'length': 100 }, { 'field': 'ustar', 'length': 8 }, { 'field': 'owner', 'length': 32 }, { 'field': 'group', 'length': 32 }, { 'field': 'majorNumber', 'length': 8 }, { 'field': 'minorNumber', 'length': 8 }, { 'field': 'filenamePrefix', 'length': 155 }, { 'field': 'padding', 'length': 12 } ]; function formatHeader(data, cb) { var buffer = utils.clean(512), offset = 0; headerFormat.forEach(function (value) { var str = data[value.field] || "", i, length; for (i = 0, length = str.length; i < length; i += 1) { buffer[offset] = str.charCodeAt(i); offset += 1; } offset += value.length - i; // space it out with nulls }); if (typeof cb === 'function') { return cb(buffer, offset); } return buffer; } window.header = {} window.header.structure = headerFormat; window.header.format = formatHeader; }()); (function () { "use strict"; var header = window.header, utils = window.utils, recordSize = 512, blockSize; function Tar(recordsPerBlock) { this.written = 0; blockSize = (recordsPerBlock || 20) * recordSize; this.out = utils.clean(blockSize); this.blocks = []; this.length = 0; } Tar.prototype.append = function (filepath, input, opts, callback) { var data, checksum, mode, mtime, uid, gid, headerArr; if (typeof input === 'string') { input = utils.stringToUint8(input); } else if (input.constructor !== Uint8Array.prototype.constructor) { throw 'Invalid input type. You gave me: ' + input.constructor.toString().match(/function\s*([$A-Za-z_][0-9A-Za-z_]*)\s*\(/)[1]; } if (typeof opts === 'function') { callback = opts; opts = {}; } opts = opts || {}; mode = opts.mode || parseInt('777', 8) & 0xfff; mtime = opts.mtime || Math.floor(+new Date() / 1000); uid = opts.uid || 0; gid = opts.gid || 0; data = { fileName: filepath, fileMode: utils.pad(mode, 7), uid: utils.pad(uid, 7), gid: utils.pad(gid, 7), fileSize: utils.pad(input.length, 11), mtime: utils.pad(mtime, 11), checksum: ' ', type: '0', // just a file ustar: 'ustar ', owner: opts.owner || '', group: opts.group || '' }; // calculate the checksum checksum = 0; Object.keys(data).forEach(function (key) { var i, value = data[key], length; for (i = 0, length = value.length; i < length; i += 1) { checksum += value.charCodeAt(i); } }); data.checksum = utils.pad(checksum, 6) + "\u0000 "; headerArr = header.format(data); var headerLength = Math.ceil( headerArr.length / recordSize ) * recordSize; var inputLength = Math.ceil( input.length / recordSize ) * recordSize; this.blocks.push( { header: headerArr, input: input, headerLength: headerLength, inputLength: inputLength } ); }; Tar.prototype.save = function() { var buffers = []; var chunks = []; var length = 0; var max = Math.pow( 2, 20 ); var chunk = []; this.blocks.forEach( function( b ) { if( length + b.headerLength + b.inputLength > max ) { chunks.push( { blocks: chunk, length: length } ); chunk = []; length = 0; } chunk.push( b ); length += b.headerLength + b.inputLength; } ); chunks.push( { blocks: chunk, length: length } ); chunks.forEach( function( c ) { var buffer = new Uint8Array( c.length ); var written = 0; c.blocks.forEach( function( b ) { buffer.set( b.header, written ); written += b.headerLength; buffer.set( b.input, written ); written += b.inputLength; } ); buffers.push( buffer ); } ); buffers.push( new Uint8Array( 2 * recordSize ) ); return new Blob( buffers, { type: 'octet/stream' } ); }; Tar.prototype.clear = function () { this.written = 0; this.out = utils.clean(blockSize); }; if ( true && typeof module.exports !== 'undefined') { module.exports = Tar; } else { window.Tar = Tar; } }()); /***/ }), /***/ 166: /***/ ((module) => { "use strict"; /** * A tool for presenting an ArrayBuffer as a stream for writing some simple data types. * * By Nicholas Sherlock * * Released under the WTFPLv2 https://en.wikipedia.org/wiki/WTFPL */ // (function(){ /* * Create an ArrayBuffer of the given length and present it as a writable stream with methods * for writing data in different formats. */ var ArrayBufferDataStream = function(length) { this.data = new Uint8Array(length); this.pos = 0; }; ArrayBufferDataStream.prototype.seek = function(offset) { this.pos = offset; }; ArrayBufferDataStream.prototype.writeBytes = function(arr) { for (var i = 0; i < arr.length; i++) { this.data[this.pos++] = arr[i]; } }; ArrayBufferDataStream.prototype.writeByte = function(b) { this.data[this.pos++] = b; }; //Synonym: ArrayBufferDataStream.prototype.writeU8 = ArrayBufferDataStream.prototype.writeByte; ArrayBufferDataStream.prototype.writeU16BE = function(u) { this.data[this.pos++] = u >> 8; this.data[this.pos++] = u; }; ArrayBufferDataStream.prototype.writeDoubleBE = function(d) { var bytes = new Uint8Array(new Float64Array([d]).buffer); for (var i = bytes.length - 1; i >= 0; i--) { this.writeByte(bytes[i]); } }; ArrayBufferDataStream.prototype.writeFloatBE = function(d) { var bytes = new Uint8Array(new Float32Array([d]).buffer); for (var i = bytes.length - 1; i >= 0; i--) { this.writeByte(bytes[i]); } }; /** * Write an ASCII string to the stream */ ArrayBufferDataStream.prototype.writeString = function(s) { for (var i = 0; i < s.length; i++) { this.data[this.pos++] = s.charCodeAt(i); } }; /** * Write the given 32-bit integer to the stream as an EBML variable-length integer using the given byte width * (use measureEBMLVarInt). * * No error checking is performed to ensure that the supplied width is correct for the integer. * * @param i Integer to be written * @param width Number of bytes to write to the stream */ ArrayBufferDataStream.prototype.writeEBMLVarIntWidth = function(i, width) { switch (width) { case 1: this.writeU8((1 << 7) | i); break; case 2: this.writeU8((1 << 6) | (i >> 8)); this.writeU8(i); break; case 3: this.writeU8((1 << 5) | (i >> 16)); this.writeU8(i >> 8); this.writeU8(i); break; case 4: this.writeU8((1 << 4) | (i >> 24)); this.writeU8(i >> 16); this.writeU8(i >> 8); this.writeU8(i); break; case 5: /* * JavaScript converts its doubles to 32-bit integers for bitwise operations, so we need to do a * division by 2^32 instead of a right-shift of 32 to retain those top 3 bits */ this.writeU8((1 << 3) | ((i / 4294967296) & 0x7)); this.writeU8(i >> 24); this.writeU8(i >> 16); this.writeU8(i >> 8); this.writeU8(i); break; default: throw new RuntimeException("Bad EBML VINT size " + width); } }; /** * Return the number of bytes needed to encode the given integer as an EBML VINT. */ ArrayBufferDataStream.prototype.measureEBMLVarInt = function(val) { if (val < (1 << 7) - 1) { /* Top bit is set, leaving 7 bits to hold the integer, but we can't store 127 because * "all bits set to one" is a reserved value. Same thing for the other cases below: */ return 1; } else if (val < (1 << 14) - 1) { return 2; } else if (val < (1 << 21) - 1) { return 3; } else if (val < (1 << 28) - 1) { return 4; } else if (val < 34359738367) { // 2 ^ 35 - 1 (can address 32GB) return 5; } else { throw new RuntimeException("EBML VINT size not supported " + val); } }; ArrayBufferDataStream.prototype.writeEBMLVarInt = function(i) { this.writeEBMLVarIntWidth(i, this.measureEBMLVarInt(i)); }; /** * Write the given unsigned 32-bit integer to the stream in big-endian order using the given byte width. * No error checking is performed to ensure that the supplied width is correct for the integer. * * Omit the width parameter to have it determined automatically for you. * * @param u Unsigned integer to be written * @param width Number of bytes to write to the stream */ ArrayBufferDataStream.prototype.writeUnsignedIntBE = function(u, width) { if (width === undefined) { width = this.measureUnsignedInt(u); } // Each case falls through: switch (width) { case 5: this.writeU8(Math.floor(u / 4294967296)); // Need to use division to access >32 bits of floating point var case 4: this.writeU8(u >> 24); case 3: this.writeU8(u >> 16); case 2: this.writeU8(u >> 8); case 1: this.writeU8(u); break; default: throw new RuntimeException("Bad UINT size " + width); } }; /** * Return the number of bytes needed to hold the non-zero bits of the given unsigned integer. */ ArrayBufferDataStream.prototype.measureUnsignedInt = function(val) { // Force to 32-bit unsigned integer if (val < (1 << 8)) { return 1; } else if (val < (1 << 16)) { return 2; } else if (val < (1 << 24)) { return 3; } else if (val < 4294967296) { return 4; } else { return 5; } }; /** * Return a view on the portion of the buffer from the beginning to the current seek position as a Uint8Array. */ ArrayBufferDataStream.prototype.getAsDataArray = function() { if (this.pos < this.data.byteLength) { return this.data.subarray(0, this.pos); } else if (this.pos == this.data.byteLength) { return this.data; } else { throw "ArrayBufferDataStream's pos lies beyond end of buffer"; } }; // if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { // module.exports = ArrayBufferDataStream; // } else { // window.ArrayBufferDataStream = ArrayBufferDataStream; // } // }());"use strict"; /** * Allows a series of Blob-convertible objects (ArrayBuffer, Blob, String, etc) to be added to a buffer. Seeking and * overwriting of blobs is allowed. * * You can supply a FileWriter, in which case the BlobBuffer is just used as temporary storage before it writes it * through to the disk. * * By Nicholas Sherlock * * Released under the WTFPLv2 https://en.wikipedia.org/wiki/WTFPL */ // (function() { var BlobBuffer = function(fs) { return function(destination) { var buffer = [], writePromise = Promise.resolve(), fileWriter = null, fd = null; if (typeof FileWriter !== "undefined" && destination instanceof FileWriter) { fileWriter = destination; } else if (fs && destination) { fd = destination; } // Current seek offset this.pos = 0; // One more than the index of the highest byte ever written this.length = 0; // Returns a promise that converts the blob to an ArrayBuffer function readBlobAsBuffer(blob) { return new Promise(function (resolve, reject) { var reader = new FileReader(); reader.addEventListener("loadend", function () { resolve(reader.result); }); reader.readAsArrayBuffer(blob); }); } function convertToUint8Array(thing) { return new Promise(function (resolve, reject) { if (thing instanceof Uint8Array) { resolve(thing); } else if (thing instanceof ArrayBuffer || ArrayBuffer.isView(thing)) { resolve(new Uint8Array(thing)); } else if (thing instanceof Blob) { resolve(readBlobAsBuffer(thing).then(function (buffer) { return new Uint8Array(buffer); })); } else { //Assume that Blob will know how to read this thing resolve(readBlobAsBuffer(new Blob([thing])).then(function (buffer) { return new Uint8Array(buffer); })); } }); } function measureData(data) { var result = data.byteLength || data.length || data.size; if (!Number.isInteger(result)) { throw "Failed to determine size of element"; } return result; } /** * Seek to the given absolute offset. * * You may not seek beyond the end of the file (this would create a hole and/or allow blocks to be written in non- * sequential order, which isn't currently supported by the memory buffer backend). */ this.seek = function (offset) { if (offset < 0) { throw "Offset may not be negative"; } if (isNaN(offset)) { throw "Offset may not be NaN"; } if (offset > this.length) { throw "Seeking beyond the end of file is not allowed"; } this.pos = offset; }; /** * Write the Blob-convertible data to the buffer at the current seek position. * * Note: If overwriting existing data, the write must not cross preexisting block boundaries (written data must * be fully contained by the extent of a previous write). */ this.write = function (data) { var newEntry = { offset: this.pos, data: data, length: measureData(data) }, isAppend = newEntry.offset >= this.length; this.pos += newEntry.length; this.length = Math.max(this.length, this.pos); // After previous writes complete, perform our write writePromise = writePromise.then(function () { if (fd) { return new Promise(function(resolve, reject) { convertToUint8Array(newEntry.data).then(function(dataArray) { var totalWritten = 0, buffer = Buffer.from(dataArray.buffer), handleWriteComplete = function(err, written, buffer) { totalWritten += written; if (totalWritten >= buffer.length) { resolve(); } else { // We still have more to write... fs.write(fd, buffer, totalWritten, buffer.length - totalWritten, newEntry.offset + totalWritten, handleWriteComplete); } }; fs.write(fd, buffer, 0, buffer.length, newEntry.offset, handleWriteComplete); }); }); } else if (fileWriter) { return new Promise(function (resolve, reject) { fileWriter.onwriteend = resolve; fileWriter.seek(newEntry.offset); fileWriter.write(new Blob([newEntry.data])); }); } else if (!isAppend) { // We might be modifying a write that was already buffered in memory. // Slow linear search to find a block we might be overwriting for (var i = 0; i < buffer.length; i++) { var entry = buffer[i]; // If our new entry overlaps the old one in any way... if (!(newEntry.offset + newEntry.length <= entry.offset || newEntry.offset >= entry.offset + entry.length)) { if (newEntry.offset < entry.offset || newEntry.offset + newEntry.length > entry.offset + entry.length) { throw new Error("Overwrite crosses blob boundaries"); } if (newEntry.offset == entry.offset && newEntry.length == entry.length) { // We overwrote the entire block entry.data = newEntry.data; // We're done return; } else { return convertToUint8Array(entry.data) .then(function (entryArray) { entry.data = entryArray; return convertToUint8Array(newEntry.data); }).then(function (newEntryArray) { newEntry.data = newEntryArray; entry.data.set(newEntry.data, newEntry.offset - entry.offset); }); } } } // Else fall through to do a simple append, as we didn't overwrite any pre-existing blocks } buffer.push(newEntry); }); }; /** * Finish all writes to the buffer, returning a promise that signals when that is complete. * * If a FileWriter was not provided, the promise is resolved with a Blob that represents the completed BlobBuffer * contents. You can optionally pass in a mimeType to be used for this blob. * * If a FileWriter was provided, the promise is resolved with null as the first argument. */ this.complete = function (mimeType) { if (fd || fileWriter) { writePromise = writePromise.then(function () { return null; }); } else { // After writes complete we need to merge the buffer to give to the caller writePromise = writePromise.then(function () { var result = []; for (var i = 0; i < buffer.length; i++) { result.push(buffer[i].data); } return new Blob(result, {mimeType: mimeType}); }); } return writePromise; }; }; }(null); // if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { // module.exports = BlobBuffer(require('fs')); // } else { // window.BlobBuffer = BlobBuffer(null); // } // })(); /** * WebM video encoder for Google Chrome. This implementation is suitable for creating very large video files, because * it can stream Blobs directly to a FileWriter without buffering the entire video in memory. * * When FileWriter is not available or not desired, it can buffer the video in memory as a series of Blobs which are * eventually returned as one composite Blob. * * By Nicholas Sherlock. * * Based on the ideas from Whammy: https://github.com/antimatter15/whammy * * Released under the WTFPLv2 https://en.wikipedia.org/wiki/WTFPL */ "use strict"; (function() { var WebMWriter = function(ArrayBufferDataStream, BlobBuffer) { function extend(base, top) { var target = {}; [base, top].forEach(function(obj) { for (var prop in obj) { if (Object.prototype.hasOwnProperty.call(obj, prop)) { target[prop] = obj[prop]; } } }); return target; } /** * Decode a Base64 data URL into a binary string. * * Returns the binary string, or false if the URL could not be decoded. */ function decodeBase64WebPDataURL(url) { if (typeof url !== "string" || !url.match(/^data:image\/webp;base64,/i)) { return false; } return window.atob(url.substring("data:image\/webp;base64,".length)); } /** * Convert a raw binary string (one character = one output byte) to an ArrayBuffer */ function stringToArrayBuffer(string) { var buffer = new ArrayBuffer(string.length), int8Array = new Uint8Array(buffer); for (var i = 0; i < string.length; i++) { int8Array[i] = string.charCodeAt(i); } return buffer; } /** * Convert the given canvas to a WebP encoded image and return the image data as a string. */ function renderAsWebP(canvas, quality) { var frame = canvas.toDataURL('image/webp', {quality: quality}); return decodeBase64WebPDataURL(frame); } function extractKeyframeFromWebP(webP) { // Assume that Chrome will generate a Simple Lossy WebP which has this header: var keyframeStartIndex = webP.indexOf('VP8 '); if (keyframeStartIndex == -1) { throw "Failed to identify beginning of keyframe in WebP image"; } // Skip the header and the 4 bytes that encode the length of the VP8 chunk keyframeStartIndex += 'VP8 '.length + 4; return webP.substring(keyframeStartIndex); } // Just a little utility so we can tag values as floats for the EBML encoder's benefit function EBMLFloat32(value) { this.value = value; } function EBMLFloat64(value) { this.value = value; } /** * Write the given EBML object to the provided ArrayBufferStream. * * The buffer's first byte is at bufferFileOffset inside the video file. This is used to complete offset and * dataOffset fields in each EBML structure, indicating the file offset of the first byte of the EBML element and * its data payload. */ function writeEBML(buffer, bufferFileOffset, ebml) { // Is the ebml an array of sibling elements? if (Array.isArray(ebml)) { for (var i = 0; i < ebml.length; i++) { writeEBML(buffer, bufferFileOffset, ebml[i]); } // Is this some sort of raw data that we want to write directly? } else if (typeof ebml === "string") { buffer.writeString(ebml); } else if (ebml instanceof Uint8Array) { buffer.writeBytes(ebml); } else if (ebml.id){ // We're writing an EBML element ebml.offset = buffer.pos + bufferFileOffset; buffer.writeUnsignedIntBE(ebml.id); // ID field // Now we need to write the size field, so we must know the payload size: if (Array.isArray(ebml.data)) { // Writing an array of child elements. We won't try to measure the size of the children up-front var sizePos, dataBegin, dataEnd; if (ebml.size === -1) { // Write the reserved all-one-bits marker to note that the size of this element is unknown/unbounded buffer.writeByte(0xFF); } else { sizePos = buffer.pos; /* Write a dummy size field to overwrite later. 4 bytes allows an element maximum size of 256MB, * which should be plenty (we don't want to have to buffer that much data in memory at one time * anyway!) */ buffer.writeBytes([0, 0, 0, 0]); } dataBegin = buffer.pos; ebml.dataOffset = dataBegin + bufferFileOffset; writeEBML(buffer, bufferFileOffset, ebml.data); if (ebml.size !== -1) { dataEnd = buffer.pos; ebml.size = dataEnd - dataBegin; buffer.seek(sizePos); buffer.writeEBMLVarIntWidth(ebml.size, 4); // Size field buffer.seek(dataEnd); } } else if (typeof ebml.data === "string") { buffer.writeEBMLVarInt(ebml.data.length); // Size field ebml.dataOffset = buffer.pos + bufferFileOffset; buffer.writeString(ebml.data); } else if (typeof ebml.data === "number") { // Allow the caller to explicitly choose the size if they wish by supplying a size field if (!ebml.size) { ebml.size = buffer.measureUnsignedInt(ebml.data); } buffer.writeEBMLVarInt(ebml.size); // Size field ebml.dataOffset = buffer.pos + bufferFileOffset; buffer.writeUnsignedIntBE(ebml.data, ebml.size); } else if (ebml.data instanceof EBMLFloat64) { buffer.writeEBMLVarInt(8); // Size field ebml.dataOffset = buffer.pos + bufferFileOffset; buffer.writeDoubleBE(ebml.data.value); } else if (ebml.data instanceof EBMLFloat32) { buffer.writeEBMLVarInt(4); // Size field ebml.dataOffset = buffer.pos + bufferFileOffset; buffer.writeFloatBE(ebml.data.value); } else if (ebml.data instanceof Uint8Array) { buffer.writeEBMLVarInt(ebml.data.byteLength); // Size field ebml.dataOffset = buffer.pos + bufferFileOffset; buffer.writeBytes(ebml.data); } else { throw "Bad EBML datatype " + typeof ebml.data; } } else { throw "Bad EBML datatype " + typeof ebml.data; } } return function(options) { var MAX_CLUSTER_DURATION_MSEC = 5000, DEFAULT_TRACK_NUMBER = 1, writtenHeader = false, videoWidth, videoHeight, clusterFrameBuffer = [], clusterStartTime = 0, clusterDuration = 0, optionDefaults = { quality: 0.95, // WebM image quality from 0.0 (worst) to 1.0 (best) fileWriter: null, // Chrome FileWriter in order to stream to a file instead of buffering to memory (optional) fd: null, // Node.JS file descriptor to write to instead of buffering (optional) // You must supply one of: frameDuration: null, // Duration of frames in milliseconds frameRate: null, // Number of frames per second }, seekPoints = { Cues: {id: new Uint8Array([0x1C, 0x53, 0xBB, 0x6B]), positionEBML: null}, SegmentInfo: {id: new Uint8Array([0x15, 0x49, 0xA9, 0x66]), positionEBML: null}, Tracks: {id: new Uint8Array([0x16, 0x54, 0xAE, 0x6B]), positionEBML: null}, }, ebmlSegment, segmentDuration = { "id": 0x4489, // Duration "data": new EBMLFloat64(0) }, seekHead, cues = [], blobBuffer = new BlobBuffer(options.fileWriter || options.fd); function fileOffsetToSegmentRelative(fileOffset) { return fileOffset - ebmlSegment.dataOffset; } /** * Create a SeekHead element with descriptors for the points in the global seekPoints array. * * 5 bytes of position values are reserved for each node, which lie at the offset point.positionEBML.dataOffset, * to be overwritten later. */ function createSeekHead() { var seekPositionEBMLTemplate = { "id": 0x53AC, // SeekPosition "size": 5, // Allows for 32GB video files "data": 0 // We'll overwrite this when the file is complete }, result = { "id": 0x114D9B74, // SeekHead "data": [] }; for (var name in seekPoints) { var seekPoint = seekPoints[name]; seekPoint.positionEBML = Object.create(seekPositionEBMLTemplate); result.data.push({ "id": 0x4DBB, // Seek "data": [ { "id": 0x53AB, // SeekID "data": seekPoint.id }, seekPoint.positionEBML ] }); } return result; } /** * Write the WebM file header to the stream. */ function writeHeader() { seekHead = createSeekHead(); var ebmlHeader = { "id": 0x1a45dfa3, // EBML "data": [ { "id": 0x4286, // EBMLVersion "data": 1 }, { "id": 0x42f7, // EBMLReadVersion "data": 1 }, { "id": 0x42f2, // EBMLMaxIDLength "data": 4 }, { "id": 0x42f3, // EBMLMaxSizeLength "data": 8 }, { "id": 0x4282, // DocType "data": "webm" }, { "id": 0x4287, // DocTypeVersion "data": 2 }, { "id": 0x4285, // DocTypeReadVersion "data": 2 } ] }, segmentInfo = { "id": 0x1549a966, // Info "data": [ { "id": 0x2ad7b1, // TimecodeScale "data": 1e6 // Times will be in miliseconds (1e6 nanoseconds per step = 1ms) }, { "id": 0x4d80, // MuxingApp "data": "webm-writer-js", }, { "id": 0x5741, // WritingApp "data": "webm-writer-js" }, segmentDuration // To be filled in later ] }, tracks = { "id": 0x1654ae6b, // Tracks "data": [ { "id": 0xae, // TrackEntry "data": [ { "id": 0xd7, // TrackNumber "data": DEFAULT_TRACK_NUMBER }, { "id": 0x73c5, // TrackUID "data": DEFAULT_TRACK_NUMBER }, { "id": 0x9c, // FlagLacing "data": 0 }, { "id": 0x22b59c, // Language "data": "und" }, { "id": 0x86, // CodecID "data": "V_VP8" }, { "id": 0x258688, // CodecName "data": "VP8" }, { "id": 0x83, // TrackType "data": 1 }, { "id": 0xe0, // Video "data": [ { "id": 0xb0, // PixelWidth "data": videoWidth }, { "id": 0xba, // PixelHeight "data": videoHeight } ] } ] } ] }; ebmlSegment = { "id": 0x18538067, // Segment "size": -1, // Unbounded size "data": [ seekHead, segmentInfo, tracks, ] }; var bufferStream = new ArrayBufferDataStream(256); writeEBML(bufferStream, blobBuffer.pos, [ebmlHeader, ebmlSegment]); blobBuffer.write(bufferStream.getAsDataArray()); // Now we know where these top-level elements lie in the file: seekPoints.SegmentInfo.positionEBML.data = fileOffsetToSegmentRelative(segmentInfo.offset); seekPoints.Tracks.positionEBML.data = fileOffsetToSegmentRelative(tracks.offset); }; /** * Create a SimpleBlock keyframe header using these fields: * timecode - Time of this keyframe * trackNumber - Track number from 1 to 126 (inclusive) * frame - Raw frame data payload string * * Returns an EBML element. */ function createKeyframeBlock(keyframe) { var bufferStream = new ArrayBufferDataStream(1 + 2 + 1); if (!(keyframe.trackNumber > 0 && keyframe.trackNumber < 127)) { throw "TrackNumber must be > 0 and < 127"; } bufferStream.writeEBMLVarInt(keyframe.trackNumber); // Always 1 byte since we limit the range of trackNumber bufferStream.writeU16BE(keyframe.timecode); // Flags byte bufferStream.writeByte( 1 << 7 // Keyframe ); return { "id": 0xA3, // SimpleBlock "data": [ bufferStream.getAsDataArray(), keyframe.frame ] }; } /** * Create a Cluster node using these fields: * * timecode - Start time for the cluster * * Returns an EBML element. */ function createCluster(cluster) { return { "id": 0x1f43b675, "data": [ { "id": 0xe7, // Timecode "data": Math.round(cluster.timecode) } ] }; } function addCuePoint(trackIndex, clusterTime, clusterFileOffset) { cues.push({ "id": 0xBB, // Cue "data": [ { "id": 0xB3, // CueTime "data": clusterTime }, { "id": 0xB7, // CueTrackPositions "data": [ { "id": 0xF7, // CueTrack "data": trackIndex }, { "id": 0xF1, // CueClusterPosition "data": fileOffsetToSegmentRelative(clusterFileOffset) } ] } ] }); } /** * Write a Cues element to the blobStream using the global `cues` array of CuePoints (use addCuePoint()). * The seek entry for the Cues in the SeekHead is updated. */ function writeCues() { var ebml = { "id": 0x1C53BB6B, "data": cues }, cuesBuffer = new ArrayBufferDataStream(16 + cues.length * 32); // Pretty crude estimate of the buffer size we'll need writeEBML(cuesBuffer, blobBuffer.pos, ebml); blobBuffer.write(cuesBuffer.getAsDataArray()); // Now we know where the Cues element has ended up, we can update the SeekHead seekPoints.Cues.positionEBML.data = fileOffsetToSegmentRelative(ebml.offset); } /** * Flush the frames in the current clusterFrameBuffer out to the stream as a Cluster. */ function flushClusterFrameBuffer() { if (clusterFrameBuffer.length == 0) { return; } // First work out how large of a buffer we need to hold the cluster data var rawImageSize = 0; for (var i = 0; i < clusterFrameBuffer.length; i++) { rawImageSize += clusterFrameBuffer[i].frame.length; } var buffer = new ArrayBufferDataStream(rawImageSize + clusterFrameBuffer.length * 32), // Estimate 32 bytes per SimpleBlock header cluster = createCluster({ timecode: Math.round(clusterStartTime), }); for (var i = 0; i < clusterFrameBuffer.length; i++) { cluster.data.push(createKeyframeBlock(clusterFrameBuffer[i])); } writeEBML(buffer, blobBuffer.pos, cluster); blobBuffer.write(buffer.getAsDataArray()); addCuePoint(DEFAULT_TRACK_NUMBER, Math.round(clusterStartTime), cluster.offset); clusterFrameBuffer = []; clusterStartTime += clusterDuration; clusterDuration = 0; } function validateOptions() { // Derive frameDuration setting if not already supplied if (!options.frameDuration) { if (options.frameRate) { options.frameDuration = 1000 / options.frameRate; } else { throw "Missing required frameDuration or frameRate setting"; } } } function addFrameToCluster(frame) { frame.trackNumber = DEFAULT_TRACK_NUMBER; // Frame timecodes are relative to the start of their cluster: frame.timecode = Math.round(clusterDuration); clusterFrameBuffer.push(frame); clusterDuration += frame.duration; if (clusterDuration >= MAX_CLUSTER_DURATION_MSEC) { flushClusterFrameBuffer(); } } /** * Rewrites the SeekHead element that was initially written to the stream with the offsets of top level elements. * * Call once writing is complete (so the offset of all top level elements is known). */ function rewriteSeekHead() { var seekHeadBuffer = new ArrayBufferDataStream(seekHead.size), oldPos = blobBuffer.pos; // Write the rewritten SeekHead element's data payload to the stream (don't need to update the id or size) writeEBML(seekHeadBuffer, seekHead.dataOffset, seekHead.data); // And write that through to the file blobBuffer.seek(seekHead.dataOffset); blobBuffer.write(seekHeadBuffer.getAsDataArray()); blobBuffer.seek(oldPos); } /** * Rewrite the Duration field of the Segment with the newly-discovered video duration. */ function rewriteDuration() { var buffer = new ArrayBufferDataStream(8), oldPos = blobBuffer.pos; // Rewrite the data payload (don't need to update the id or size) buffer.writeDoubleBE(clusterStartTime); // And write that through to the file blobBuffer.seek(segmentDuration.dataOffset); blobBuffer.write(buffer.getAsDataArray()); blobBuffer.seek(oldPos); } /** * Add a frame to the video. Currently the frame must be a Canvas element. */ this.addFrame = function(canvas) { if (writtenHeader) { if (canvas.width != videoWidth || canvas.height != videoHeight) { throw "Frame size differs from previous frames"; } } else { videoWidth = canvas.width; videoHeight = canvas.height; writeHeader(); writtenHeader = true; } var webP = renderAsWebP(canvas, {quality: options.quality}); if (!webP) { throw "Couldn't decode WebP frame, does the browser support WebP?"; } addFrameToCluster({ frame: extractKeyframeFromWebP(webP), duration: options.frameDuration }); }; /** * Finish writing the video and return a Promise to signal completion. * * If the destination device was memory (i.e. options.fileWriter was not supplied), the Promise is resolved with * a Blob with the contents of the entire video. */ this.complete = function() { flushClusterFrameBuffer(); writeCues(); rewriteSeekHead(); rewriteDuration(); return blobBuffer.complete('video/webm'); }; this.getWrittenSize = function() { return blobBuffer.length; }; options = extend(optionDefaults, options || {}); validateOptions(); }; }; if ( true && typeof module.exports !== 'undefined') { // module.exports = WebMWriter(require("./ArrayBufferDataStream"), require("./BlobBuffer")); module.exports = WebMWriter(ArrayBufferDataStream,BlobBuffer); } else { window.WebMWriter = WebMWriter(ArrayBufferDataStream, BlobBuffer); } })(); /***/ }), /***/ 681: /***/ ((module) => { "use strict"; module.exports = JSON.parse('{"_from":"@ffmpeg/ffmpeg","_id":"@ffmpeg/ffmpeg@0.10.1","_inBundle":false,"_integrity":"sha512-ChQkH7Rh57hmVo1LhfQFibWX/xqneolJKSwItwZdKPcLZuKigtYAYDIvB55pDfP17VtR1R77SxgkB2/UApB+Og==","_location":"/@ffmpeg/ffmpeg","_phantomChildren":{},"_requested":{"type":"tag","registry":true,"raw":"@ffmpeg/ffmpeg","name":"@ffmpeg/ffmpeg","escapedName":"@ffmpeg%2fffmpeg","scope":"@ffmpeg","rawSpec":"","saveSpec":null,"fetchSpec":"latest"},"_requiredBy":["#USER","/"],"_resolved":"https://registry.npmjs.org/@ffmpeg/ffmpeg/-/ffmpeg-0.10.1.tgz","_shasum":"3dacf3985de9c83a95fbf79fe709920cc009b00a","_spec":"@ffmpeg/ffmpeg","_where":"/Users/amandaghassaei/Projects/canvas-capture","author":{"name":"Jerome Wu","email":"jeromewus@gmail.com"},"browser":{"./src/node/index.js":"./src/browser/index.js"},"bugs":{"url":"https://github.com/ffmpegwasm/ffmpeg.wasm/issues"},"bundleDependencies":false,"dependencies":{"is-url":"^1.2.4","node-fetch":"^2.6.1","regenerator-runtime":"^0.13.7","resolve-url":"^0.2.1"},"deprecated":false,"description":"FFmpeg WebAssembly version","devDependencies":{"@babel/core":"^7.12.3","@babel/preset-env":"^7.12.1","@ffmpeg/core":"^0.10.0","@types/emscripten":"^1.39.4","babel-loader":"^8.1.0","chai":"^4.2.0","cors":"^2.8.5","eslint":"^7.12.1","eslint-config-airbnb-base":"^14.1.0","eslint-plugin-import":"^2.22.1","express":"^4.17.1","mocha":"^8.2.1","mocha-headless-chrome":"^2.0.3","npm-run-all":"^4.1.5","wait-on":"^5.3.0","webpack":"^5.3.2","webpack-cli":"^4.1.0","webpack-dev-middleware":"^4.0.0"},"directories":{"example":"examples"},"engines":{"node":">=12.16.1"},"homepage":"https://github.com/ffmpegwasm/ffmpeg.wasm#readme","keywords":["ffmpeg","WebAssembly","video"],"license":"MIT","main":"src/index.js","name":"@ffmpeg/ffmpeg","repository":{"type":"git","url":"git+https://github.com/ffmpegwasm/ffmpeg.wasm.git"},"scripts":{"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"},"types":"src/index.d.ts","version":"0.10.1"}'); /***/ }) /******/ }); /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ var cachedModule = __webpack_module_cache__[moduleId]; /******/ if (cachedModule !== undefined) { /******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { /******/ id: moduleId, /******/ loaded: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.loaded = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /************************************************************************/ /******/ /* webpack/runtime/define property getters */ /******/ (() => { /******/ // define getter functions for harmony exports /******/ __webpack_require__.d = (exports, definition) => { /******/ for(var key in definition) { /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); /******/ } /******/ } /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/global */ /******/ (() => { /******/ __webpack_require__.g = (function() { /******/ if (typeof globalThis === 'object') return globalThis; /******/ try { /******/ return this || new Function('return this')(); /******/ } catch (e) { /******/ if (typeof window === 'object') return window; /******/ } /******/ })(); /******/ })(); /******/ /******/ /* webpack/runtime/hasOwnProperty shorthand */ /******/ (() => { /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) /******/ })(); /******/ /******/ /* webpack/runtime/make namespace object */ /******/ (() => { /******/ // define __esModule on exports /******/ __webpack_require__.r = (exports) => { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ })(); /******/ /******/ /* webpack/runtime/node module decorator */ /******/ (() => { /******/ __webpack_require__.nmd = (module) => { /******/ module.paths = []; /******/ if (!module.children) module.children = []; /******/ return module; /******/ }; /******/ })(); /******/ /************************************************************************/ var __webpack_exports__ = {}; // This entry need to be wrapped in an IIFE because it need to be in strict mode. (() => { "use strict"; var exports = __webpack_exports__; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.CanvasCapture = void 0; // Default export. var CanvasCapture = __webpack_require__(914); exports.CanvasCapture = CanvasCapture; exports["default"] = CanvasCapture; })(); /******/ return __webpack_exports__; /******/ })() ; }); //# sourceMappingURL=canvas-capture.js.map