New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cdgplayer

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cdgplayer - npm Package Compare versions

Comparing version

to
0.1.10

2

CHANGELOG.md
Changelog
### 0.1.10 (2022-05-03)
### 0.1.9 (2021-10-18)

@@ -3,0 +5,0 @@

4

dist/cdgplayer.js
/**
* @package CDGPlayer
* @version 0.1.9
* @version 0.1.10
* @license GPLv3

@@ -28,3 +28,3 @@ * @copyright Copyright (c) 2018 Stephen G Blades, Jr (AKA 'Cutter')

*/
function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}function n(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}function s(t,e){return s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},s(t,e)}function a(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function u(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=o(t);if(e){var r=o(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return a(this,i)}}function l(t,e,i){return l="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,i){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=o(t)););return t}(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(i):r.value}},l(t,e,i||t)}function c(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==i)return;var n,r,o=[],s=!0,a=!1;try{for(i=i.call(t);!(s=(n=i.next()).done)&&(o.push(n.value),!e||o.length!==e);s=!0);}catch(t){a=!0,r=t}finally{try{s||null==i.return||i.return()}finally{if(a)throw r}}return o}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return h(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return h(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function f(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===i&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}}f(".cdg-video-wrapper{background-color:#000;position:relative;text-align:center}.cdg-video-wrapper .cdg-video-player{margin:0 auto;position:relative;width:72%}.cdg-video-wrapper .titleImage{background-color:transparent;height:100%;left:0;position:absolute;top:0;width:100%;z-index:auto}.cdg-video-wrapper .titleImage.hide{display:none}");var p=[6,12,294,204],d=["top","bottom"],v=function(){function e(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.width,o=void 0===r?300:r,s=i.height,a=void 0===s?216:s,u=i.canvas,l=void 0===u?this.createCanvas(o,a):u,c=i.ctx,h=void 0===c?this.createCanvasContext(l):c,f=i.imageData,p=void 0===f?this.createImageData(l,h,o,a):f;t(this,e),n(this,"hOffset",0),n(this,"vOffset",0),n(this,"keyColor",null),n(this,"backgroundContainer",null),n(this,"borderColor",null),n(this,"memoryColor",null),n(this,"clut",new Array(16).fill([0,0,0])),n(this,"pixels",new Array(64800).fill(0)),n(this,"buffer",new Array(64800).fill(0)),this.canvas=l,this.ctx=h,this.imageData=p}return i(e,[{key:"createCanvas",value:function(t,e){var i=document.createElement("canvas");return i.width=t,i.height=e,i}},{key:"createCanvasContext",value:function(t){var e=t.getContext("2d");return e.mozImageSmoothingEnabled=!1,e.webkitImageSmoothingEnabled=!1,e.msImageSmoothingEnabled=!1,e.imageSmoothingEnabled=!1,e}},{key:"createImageData",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.width,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.height;return e.createImageData(i,n)}},{key:"reset",value:function(){this.hOffset=0,this.vOffset=0,this.keyColor=null,this.backgroundColor=null,this.borderColor=null,this.memoryColor=null,this.pixels.fill(0)}},{key:"setCLUTEntry",value:function(t,e,i,n){this.clut[t]=[e,i,n].map((function(t){return 17*t}))}},{key:"setPixel",value:function(t,e,i){this.pixels[t+300*e]=i}},{key:"getPixel",value:function(t,e){return this.pixels[t+300*e]}},{key:"getBackground",value:function(){switch(!0){case null!=this.keyColor:return this.keyColor;case null!=this.backgroundColor:return this.backgroundColor;case null!=this.memoryColor:return this.memoryColor;case null!=this.borderColor:return this.borderColor;default:return 0}}},{key:"generateImageData",value:function(){for(var t=0;t<300;t++)for(var e=0;e<216;e++){var i=4*(t+300*e),n=(t-this.hOffset+300)%300+300*((e-this.vOffset+216)%216),r=this.pixels[n],o=c(this.clut[r],3),s=o[0],a=o[1],u=o[2];this.imageData.data[i]=s,this.imageData.data[i+1]=a,this.imageData.data[i+2]=u,this.imageData.data[i+3]=r===this.keyColor?0:255}return this.imageData}},{key:"renderFrame",value:function(){this.ctx.putImageData(this.generateImageData(),0,0)}}]),e}();function m(){var t;console&&console.warn&&(t=console).warn.apply(t,arguments)}var g=function(){function e(i){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,e),this.bytes=i.slice(n,n+24)}return i(e,[{key:"instruction",get:function(){return this.constructor.instruction}},{key:"opcode",get:function(){return this.constructor.opcode}},{key:"execute",value:function(){}},{key:"bytecodeToString",value:function(){return this.bytes.map((function(t){return t.toString(16).padStart(2,"0")})).join("")}},{key:"detailsToString",value:function(){return""}},{key:"toString",value:function(){return this.instruction}}]),e}();n(g,"instruction",""),n(g,"opcode",null);var y=function(e){r(n,g);var i=u(n);function n(){return t(this,n),i.apply(this,arguments)}return n}();n(y,"instruction","No-op"),n(y,"opcode",0);var A=function(e){r(o,g);var n=u(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,o);var s=r+4;return(i=n.call(this,e,r)).color=15&e[s],i.repeat=15&e[s+1],i}return i(o,[{key:"execute",value:function(t){t.memoryColor=this.color,t.backgroundColor=this.color,t.pixels.fill(this.color)}},{key:"detailsToString",value:function(){return"color index: ".concat(this.color)}}]),o}();n(A,"instruction","Memory Preset"),n(A,"opcode",1);var k=function(e){r(o,g);var n=u(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t(this,o),(i=n.call(this,e,r)).color=15&e[r+4],i}return i(o,[{key:"execute",value:function(t){t.borderColor=this.color,t.backgroundColor=this.color;for(var e=c(p,4),i=e[0],n=e[1],r=e[2],o=e[3],s=0;s<300;s++){for(var a=0;a<n;a++)t.setPixel(s,a,this.color);for(var u=o+1;u<216;u++)t.setPixel(s,u,this.color)}for(var l=n;l<=o;l++){for(var h=0;h<i;h++)t.setPixel(h,l,this.color);for(var f=r+1;f<300;f++)t.setPixel(f,l,this.color)}}},{key:"detailsToString",value:function(){return"color index: ".concat(this.color)}}]),o}();n(k,"instruction","Border Preset"),n(k,"opcode",2);var b=function(e){r(o,g);var n=u(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,o);var s=r+4;return(i=n.call(this,e,r)).colors=[15&e[s],15&e[s+1]],i.row=31&e[s+2],i.column=63&e[s+3],i.pixels=e.slice(s+4,s+16),i}return i(o,[{key:"execute",value:function(t){var e=6*this.column,i=12*this.row;if(e+6>300||i+12>216)m("TileBlock out of bounds (".concat(this.row,", ").concat(this.column,")"));else for(var n=0;n<12;n++)for(var r=this.pixels[n],o=0;o<6;o++){var s=this.colors[r>>5-o&1];this.op(t,e+o,i+n,s)}}},{key:"op",value:function(t,e,i,n){t.setPixel(e,i,n)}},{key:"detailsToString",value:function(){return"row: ".concat(this.row,", column: ").concat(this.column,", color indexes: [").concat(this.colors.join(", "),"]")}}]),o}();n(b,"instruction","Tile Block"),n(b,"opcode",6);var w=function(e){r(o,b);var n=u(o);function o(){return t(this,o),n.apply(this,arguments)}return i(o,[{key:"op",value:function(t,e,i,n){t.setPixel(e,i,t.getPixel(e,i)^n)}}]),o}();n(w,"instruction","Tile Block (XOR)"),n(w,"opcode",38);var B=function(e){r(o,g);var n=u(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,o);var s=r+4;(i=n.call(this,e,r)).color=15&e[s];var a=63&e[s+1];i.hCmd=(48&a)>>4,i.hOffset=7&a;var u=63&e[s+2];return i.vCmd=(48&u)>>4,i.vOffset=15&u,i}return i(o,[{key:"execute",value:function(t){t.backgroundColor=this.color,t.hOffset=Math.min(this.hOffset,5),t.vOffset=Math.min(this.vOffset,11);var e=0;switch(this.hCmd){case 2:e=6;break;case 1:e=-6}var i=0;switch(this.hCmd){case 2:i=12;break;case 1:i=-12}if(e||i){for(var n=0;n<300;n++)for(var r=0;r<216;r++)t.buffer[n+300*r]=this.getPixel(t,n+e,r+i);var o=[t.buffer,t.pixels];t.pixels=o[0],t.buffer=o[1]}}},{key:"getPixel",value:function(t,e,i){return e>0&&e<300&&i>0&&i<216?t.pixels[e+300*i]:this.color}},{key:"detailsToString",value:function(){var t=!1,e=!1;return 1===this.vCmd?t="up":2===this.vCmd&&(t="down"),1===this.vCmd?e="left":2===this.vCmd&&(e="right"),[t,e,"vOffset: ".concat(this.vOffset),"hOffset: ".concat(this.hOffset)].filter((function(t){return t})).join(" ")}}]),o}();n(B,"instruction","Scroll Preset"),n(B,"opcode",20);var x=function(e){r(o,B);var n=u(o);function o(){return t(this,o),n.apply(this,arguments)}return i(o,[{key:"getPixel",value:function(t,e,i){return e=(e+300)%300,i=(i+216)%216,t.pixels[e+300*i]}}]),o}();n(x,"instruction","Scroll Copy"),n(x,"opcode",24);var C=function(e){r(o,g);var n=u(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t(this,o),(i=n.call(this,e,r)).color=15&e[r+4],i}return i(o,[{key:"execute",value:function(t){t.keyColor=this.color}},{key:"detailsToString",value:function(){return"color index: ".concat(this.color)}}]),o}();n(C,"instruction","Set Key Color"),n(C,"opcode",28);var P=function(e){r(o,g);var n=u(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,o);var s=r+4;(i=n.call(this,e,r)).colors=[];for(var a=0;a<8;a++){var u=s+2*a,l=((63&e[u])<<6)+(63&e[u+1]);i.colors[a]=[l>>8,(240&l)>>4,15&l]}return i}return i(o,[{key:"clutOffset",get:function(){return 0}},{key:"execute",value:function(t){for(var e=0;e<8;e++)t.setCLUTEntry(e+this.clutOffset,this.colors[e][0],this.colors[e][1],this.colors[e][2])}},{key:"detailsToString",value:function(){var t=this;return"colors: [".concat(this.colors.map((function(e,i){return"".concat(i+t.clutOffset,": #").concat(e.map((function(t){return t.toString(16)})).join(""))})).join(", "),"]")}}]),o}();n(P,"instruction","Load CLUT (Low)"),n(P,"opcode",30);var S=function(e){r(o,P);var n=u(o);function o(){return t(this,o),n.apply(this,arguments)}return i(o,[{key:"clutOffset",get:function(){return 8}}]),o}();n(S,"instruction","Load CLUT (High)"),n(S,"opcode",31);var _=function(){function e(){t(this,e),n(this,"instructionClassByType",this.constructor.instructionClassByType)}return i(e,[{key:"registerInstruction",value:function(t,e){this.instructionClassByType[t]=e}},{key:"createInstruction",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;t in this.instructionClassByType||m("Unknown CDG instruction (instruction = ".concat(t,")"));var n=this.instructionClassByType[t]||y;return new n(e,i)}},{key:"parseInstruction",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=63&t[e];if(9===i){var n=63&t[e+1];return this.createInstruction(n,t,e)}return new y(t,e)}},{key:"parseInstructions",value:function(t){for(var e=[],i=t.length,n=0;n<i;n+=24)e.push(this.parseInstruction(t,n));return e.filter((function(t){return t}))}}],[{key:"instructionClassByType",get:function(){var t;return n(t={},0,y),n(t,1,A),n(t,2,k),n(t,6,b),n(t,20,B),n(t,24,x),n(t,28,C),n(t,30,P),n(t,31,S),n(t,38,w),t}}]),e}();function L(){if("undefined"!=typeof performance&&"function"==typeof performance.now)return performance.now();if("undefined"!=typeof process&&"function"==typeof process.hrtime){var t=c(process.hrtime(),2);return 1e3*t[0]+t[1]/1e6}return Date.now()}function I(t){return"function"==typeof requestAnimationFrame?window.requestAnimationFrame(t):setTimeout(t,25)}var E=function(){function e(){var i=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=r.contextOptions,s=void 0===o?{}:o,a=r.context,u=void 0===a?this.createContext(s):a,l=r.afterRender;t(this,e),n(this,"instructions",[]),n(this,"pc",-1),n(this,"frameId",null),n(this,"pos",0),n(this,"lastSyncPos",null),n(this,"lastTimestamp",null),n(this,"update",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:L();if(-1===i.pc)return i;i.frameId=I(i.update),i.lastSyncPos?i.pos=i.lastSyncPos+(t-i.lastTimestamp):(i.pos+=t-i.lastTimestamp,i.lastTimestamp=t);var e=Math.floor(i.pos/1e3*300),n=e-i.pc;return n>0&&(i.fastForward(n),i.render()),i})),this.context=u,this.afterRender=l}return i(e,[{key:"createContext",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new v(t)}},{key:"load",value:function(t){var e=new _;return this.instructions=e.parseInstructions(t),this.reset(),this}},{key:"reset",value:function(){return this.pc=0,this.pos=0,this.lastSyncPos=null,this.context.reset(),this}},{key:"render",value:function(){return this.context.renderFrame(),this.afterRender&&this.afterRender(this.context),this}},{key:"executeInstruction",value:function(t){return t&&"function"==typeof t.execute&&t.execute(this.context),this}},{key:"step",value:function(){return this.pc>=0&&this.pc<this.instructions.length?(this.executeInstruction(this.instructions[this.pc]),this.pc+=1):(this.pc=-1,this.stop()),this}},{key:"fastForward",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=this.pc+t;this.pc>=0&&this.pc<e;)this.step();return this}},{key:"play",value:function(){return this.frameId||(this.frameId=I(this.update),this.lastTimestamp=L()),this}},{key:"stop",value:function(){var t;return t=this.frameId,"function"==typeof cancelAnimationFrame?cancelAnimationFrame(t):clearTimeout(t),this.frameId=null,this.lastSyncPos=null,this}},{key:"sync",value:function(t){return this.lastSyncPos=t,this.lastTimestamp=L(),this}}]),e}(),O=function(){return"undefined"!=typeof Promise&&Promise.defer?Promise.defer():"undefined"!=typeof PromiseUtils&&PromiseUtils.defer?PromiseUtils.defer():(this.resolve=null,this.reject=null,this.promise=new Promise(function(t,e){this.resolve=t,this.reject=e}.bind(this)),void Object.freeze(this))},R=function(t){return JSZip.loadAsync(t).catch((function(t){return Promise.reject(new Error("There was an error reading the zip file.",t))}))},T=function(t){var e=t.filter((function(t){return t.endsWith(".cdg")||t.endsWith(".mp3")}));return 2===e.length?Promise.resolve(e):Promise.reject("The file is not a karaoke .zip file")},M=function(t){var e=t.filter((function(t){return t.name.endsWith(".mp3")})),i=t.filter((function(t){return t.name.endsWith(".cdg")})),n=[];if(e.length&&i.length)return n.push(e[0].async("arraybuffer").catch((function(){return Promise.reject(new Error("Unable to load the audio file"))}))),n.push(function(t){return t.async("uint8array").catch((function(){return Promise.reject(new Error("Unable to load the video file"))}))}(i[0])),n.push(function(t){return t.async("blob").then((function(e){return new Promise((function(i){new jsmediatags.Reader(e).setTagsToRead(["title","artist","album","track","year","genre","picture"]).read({onSuccess:function(t){return i(t)},onError:function(){return i((e=t.name.split(" - "),(n={tags:{}}).tags.album=e[0].trim(),n.tags.artist=e[1]?e[1].trim():n.tags.album,n.tags.title=e[2]?e[2].trim():n.tags.artist,n));var e,n}})}))})).catch((function(){return Promise.reject(new Error("Unable to parse tag data"))}))}(e[0])),Promise.all(n);var r=[];return e.length||r.push("No mp3 audio file present."),i.length||r.push("No cdg video file present."),Promise.reject(new Error(r.join(" ")))},D=function(){function e(){t(this,e)}return i(e,null,[{key:"loadZipFile",value:function(t){return function(t){var e=new O;return JSZipUtils.getBinaryContent(t,(function(i,n){i?e.reject(new Error("There was an error retrieving ".concat(t),i)):e.resolve(n)})),e.promise}(t).then((function(t){return R(t)})).then((function(t){return T(t)})).then((function(t){return M(t)})).catch((function(t){return Promise.reject(t)}))}},{key:"loadFileBuffer",value:function(t){return R(t).then((function(t){return T(t)})).then((function(t){return M(t)})).catch((function(t){return Promise.reject(t)}))}}]),e}(),j=function(){function e(){t(this,e),this._vector=new Float32Array,this._position=0,this._frameCount=0}return i(e,[{key:"vector",get:function(){return this._vector}},{key:"position",get:function(){return this._position}},{key:"startIndex",get:function(){return 2*this._position}},{key:"frameCount",get:function(){return this._frameCount}},{key:"endIndex",get:function(){return 2*(this._position+this._frameCount)}},{key:"clear",value:function(){this.receive(this._frameCount),this.rewind()}},{key:"put",value:function(t){this._frameCount+=t}},{key:"putSamples",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=2*(e=e||0);i>=0||(i=(t.length-n)/2);var r=2*i;this.ensureCapacity(i+this._frameCount);var o=this.endIndex;this.vector.set(t.subarray(n,n+r),o),this._frameCount+=i}},{key:"putBuffer",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;e=e||0,i>=0||(i=t.frameCount-e),this.putSamples(t.vector,t.position+e,i)}},{key:"receive",value:function(t){t>=0&&!(t>this._frameCount)||(t=this.frameCount),this._frameCount-=t,this._position+=t}},{key:"receiveSamples",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=2*e,n=this.startIndex;t.set(this._vector.subarray(n,n+i)),this.receive(e)}},{key:"extract",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=this.startIndex+2*e,r=2*i;t.set(this._vector.subarray(n,n+r))}},{key:"ensureCapacity",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=parseInt(2*t);if(this._vector.length<e){var i=new Float32Array(e);i.set(this._vector.subarray(this.startIndex,this.endIndex)),this._vector=i,this._position=0}else this.rewind()}},{key:"ensureAdditionalCapacity",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.ensureCapacity(this._frameCount+t)}},{key:"rewind",value:function(){this._position>0&&(this._vector.set(this._vector.subarray(this.startIndex,this.endIndex)),this._position=0)}}]),e}(),Y=function(){function e(i){t(this,e),i?(this._inputBuffer=new j,this._outputBuffer=new j):this._inputBuffer=this._outputBuffer=null}return i(e,[{key:"inputBuffer",get:function(){return this._inputBuffer},set:function(t){this._inputBuffer=t}},{key:"outputBuffer",get:function(){return this._outputBuffer},set:function(t){this._outputBuffer=t}},{key:"clear",value:function(){this._inputBuffer.clear(),this._outputBuffer.clear()}}]),e}(),F=function(e){r(o,Y);var n=u(o);function o(e){var i;return t(this,o),(i=n.call(this,e)).reset(),i._rate=1,i}return i(o,[{key:"rate",set:function(t){this._rate=t}},{key:"reset",value:function(){this.slopeCount=0,this.prevSampleL=0,this.prevSampleR=0}},{key:"clone",value:function(){var t=new o;return t.rate=this._rate,t}},{key:"process",value:function(){var t=this._inputBuffer.frameCount;this._outputBuffer.ensureAdditionalCapacity(t/this._rate+1);var e=this.transpose(t);this._inputBuffer.receive(),this._outputBuffer.put(e)}},{key:"transpose",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(0===t)return 0;for(var e=this._inputBuffer.vector,i=this._inputBuffer.startIndex,n=this._outputBuffer.vector,r=this._outputBuffer.endIndex,o=0,s=0;this.slopeCount<1;)n[r+2*s]=(1-this.slopeCount)*this.prevSampleL+this.slopeCount*e[i],n[r+2*s+1]=(1-this.slopeCount)*this.prevSampleR+this.slopeCount*e[i+1],s+=1,this.slopeCount+=this._rate;if(this.slopeCount-=1,1!==t)t:for(;;){for(;this.slopeCount>1;)if(this.slopeCount-=1,(o+=1)>=t-1)break t;var a=i+2*o;n[r+2*s]=(1-this.slopeCount)*e[a]+this.slopeCount*e[a+2],n[r+2*s+1]=(1-this.slopeCount)*e[a+1]+this.slopeCount*e[a+3],s+=1,this.slopeCount+=this._rate}return this.prevSampleL=e[i+2*t-2],this.prevSampleR=e[i+2*t-1],s}}]),o}(),H=function(){function e(i){t(this,e),this._pipe=i}return i(e,[{key:"pipe",get:function(){return this._pipe}},{key:"inputBuffer",get:function(){return this._pipe.inputBuffer}},{key:"outputBuffer",get:function(){return this._pipe.outputBuffer}},{key:"fillInputBuffer",value:function(){throw new Error("fillInputBuffer() not overridden")}},{key:"fillOutputBuffer",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.outputBuffer.frameCount<t;){var e=16384-this.inputBuffer.frameCount;if(this.fillInputBuffer(e),this.inputBuffer.frameCount<16384)break;this._pipe.process()}}},{key:"clear",value:function(){this._pipe.clear()}}]),e}(),z=function(){},q=function(e){r(s,H);var n=u(s);function s(e,i){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:z;return t(this,s),(r=n.call(this,i)).callback=o,r.sourceSound=e,r.historyBufferSize=22050,r._sourcePosition=0,r.outputBufferPosition=0,r._position=0,r}return i(s,[{key:"position",get:function(){return this._position},set:function(t){if(t>this._position)throw new RangeError("New position may not be greater than current position");var e=this.outputBufferPosition-(this._position-t);if(e<0)throw new RangeError("New position falls outside of history buffer");this.outputBufferPosition=e,this._position=t}},{key:"sourcePosition",get:function(){return this._sourcePosition},set:function(t){this.clear(),this._sourcePosition=t}},{key:"onEnd",value:function(){this.callback()}},{key:"fillInputBuffer",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=new Float32Array(2*t),i=this.sourceSound.extract(e,t,this._sourcePosition);this._sourcePosition+=i,this.inputBuffer.putSamples(e,0,i)}},{key:"extract",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.fillOutputBuffer(this.outputBufferPosition+e);var i=Math.min(e,this.outputBuffer.frameCount-this.outputBufferPosition);this.outputBuffer.extract(t,this.outputBufferPosition,i);var n=this.outputBufferPosition+i;return this.outputBufferPosition=Math.min(this.historyBufferSize,n),this.outputBuffer.receive(Math.max(n-this.historyBufferSize,0)),this._position+=i,i}},{key:"handleSampleData",value:function(t){this.extract(t.data,4096)}},{key:"clear",value:function(){l(o(s.prototype),"clear",this).call(this),this.outputBufferPosition=0}}]),s}(),N=[[124,186,248,310,372,434,496,558,620,682,744,806,868,930,992,1054,1116,1178,1240,1302,1364,1426,1488,0],[-100,-75,-50,-25,25,50,75,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-20,-15,-10,-5,5,10,15,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-4,-3,-2,-1,1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],U=function(e){r(s,Y);var n=u(s);function s(e){var i;return t(this,s),(i=n.call(this,e))._quickSeek=!0,i.midBufferDirty=!1,i.midBuffer=null,i.overlapLength=0,i.autoSeqSetting=!0,i.autoSeekSetting=!0,i._tempo=1,i.setParameters(44100,0,0,8),i}return i(s,[{key:"clear",value:function(){l(o(s.prototype),"clear",this).call(this),this.clearMidBuffer()}},{key:"clearMidBuffer",value:function(){this.midBufferDirty&&(this.midBufferDirty=!1,this.midBuffer=null)}},{key:"setParameters",value:function(t,e,i,n){t>0&&(this.sampleRate=t),n>0&&(this.overlapMs=n),e>0?(this.sequenceMs=e,this.autoSeqSetting=!1):this.autoSeqSetting=!0,i>0?(this.seekWindowMs=i,this.autoSeekSetting=!1):this.autoSeekSetting=!0,this.calculateSequenceParameters(),this.calculateOverlapLength(this.overlapMs),this.tempo=this._tempo}},{key:"tempo",get:function(){return this._tempo},set:function(t){var e;this._tempo=t,this.calculateSequenceParameters(),this.nominalSkip=this._tempo*(this.seekWindowLength-this.overlapLength),this.skipFract=0,e=Math.floor(this.nominalSkip+.5),this.sampleReq=Math.max(e+this.overlapLength,this.seekWindowLength)+this.seekLength}},{key:"inputChunkSize",get:function(){return this.sampleReq}},{key:"outputChunkSize",get:function(){return this.overlapLength+Math.max(0,this.seekWindowLength-2*this.overlapLength)}},{key:"calculateOverlapLength",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t=(t=this.sampleRate*e/1e3)<16?16:t,t-=t%8,this.overlapLength=t,this.refMidBuffer=new Float32Array(2*this.overlapLength),this.midBuffer=new Float32Array(2*this.overlapLength)}},{key:"checkLimits",value:function(t,e,i){return t<e?e:t>i?i:t}},{key:"calculateSequenceParameters",value:function(){var t,e;this.autoSeqSetting&&(t=150+-50*this._tempo,t=this.checkLimits(t,50,125),this.sequenceMs=Math.floor(t+.5)),this.autoSeekSetting&&(e=28.333333333333332+-6.666666666666667*this._tempo,e=this.checkLimits(e,15,25),this.seekWindowMs=Math.floor(e+.5)),this.seekWindowLength=Math.floor(this.sampleRate*this.sequenceMs/1e3),this.seekLength=Math.floor(this.sampleRate*this.seekWindowMs/1e3)}},{key:"quickSeek",set:function(t){this._quickSeek=t}},{key:"clone",value:function(){var t=new s;return t.tempo=this._tempo,t.setParameters(this.sampleRate,this.sequenceMs,this.seekWindowMs,this.overlapMs),t}},{key:"seekBestOverlapPosition",value:function(){return this._quickSeek?this.seekBestOverlapPositionStereoQuick():this.seekBestOverlapPositionStereo()}},{key:"seekBestOverlapPositionStereo",value:function(){var t,e,i,n=0;for(this.preCalculateCorrelationReferenceStereo(),t=0,e=Number.MIN_VALUE;n<this.seekLength;n+=1)(i=this.calculateCrossCorrelationStereo(2*n,this.refMidBuffer))>e&&(e=i,t=n);return t}},{key:"seekBestOverlapPositionStereoQuick",value:function(){var t,e,i,n,r,o=0;for(this.preCalculateCorrelationReferenceStereo(),e=Number.MIN_VALUE,t=0,n=0,r=0;o<4;o+=1){for(var s=0;N[o][s]&&!((r=n+N[o][s])>=this.seekLength);)(i=this.calculateCrossCorrelationStereo(2*r,this.refMidBuffer))>e&&(e=i,t=r),s+=1;n=t}return t}},{key:"preCalculateCorrelationReferenceStereo",value:function(){for(var t,e,i=0;i<this.overlapLength;i+=1)e=i*(this.overlapLength-i),t=2*i,this.refMidBuffer[t]=this.midBuffer[t]*e,this.refMidBuffer[t+1]=this.midBuffer[t+1]*e}},{key:"calculateCrossCorrelationStereo",value:function(t,e){var i=this._inputBuffer.vector;t+=this._inputBuffer.startIndex;for(var n,r=0,o=2,s=2*this.overlapLength;o<s;o+=2)r+=i[n=o+t]*e[o]+i[n+1]*e[o+1];return r}},{key:"overlap",value:function(t){this.overlapStereo(2*t)}},{key:"overlapStereo",value:function(t){var e=this._inputBuffer.vector;t+=this._inputBuffer.startIndex;for(var i,n,r,o,s,a=this._outputBuffer.vector,u=this._outputBuffer.endIndex,l=0,c=1/this.overlapLength;l<this.overlapLength;l+=1)n=(this.overlapLength-l)*c,r=l*c,o=(i=2*l)+t,a[(s=i+u)+0]=e[o+0]*r+this.midBuffer[i+0]*n,a[s+1]=e[o+1]*r+this.midBuffer[i+1]*n}},{key:"process",value:function(){var t,e,i;if(null===this.midBuffer){if(this._inputBuffer.frameCount<this.overlapLength)return;this.midBuffer=new Float32Array(2*this.overlapLength),this._inputBuffer.receiveSamples(this.midBuffer,this.overlapLength)}for(;this._inputBuffer.frameCount>=this.sampleReq;){t=this.seekBestOverlapPosition(),this._outputBuffer.ensureAdditionalCapacity(this.overlapLength),this.overlap(Math.floor(t)),this._outputBuffer.put(this.overlapLength),(e=this.seekWindowLength-2*this.overlapLength)>0&&this._outputBuffer.putBuffer(this._inputBuffer,t+this.overlapLength,e);var n=this._inputBuffer.startIndex+2*(t+this.seekWindowLength-this.overlapLength);this.midBuffer.set(this._inputBuffer.vector.subarray(n,n+2*this.overlapLength)),this.skipFract+=this.nominalSkip,i=Math.floor(this.skipFract),this.skipFract-=i,this._inputBuffer.receive(i)}}}]),s}(),W=function(t,e){return(t>e?t-e:e-t)>1e-10},Q=function(){function e(){t(this,e),this.transposer=new F(!1),this.stretch=new U(!1),this._inputBuffer=new j,this._intermediateBuffer=new j,this._outputBuffer=new j,this._rate=0,this._tempo=0,this.virtualPitch=1,this.virtualRate=1,this.virtualTempo=1,this.calculateEffectiveRateAndTempo()}return i(e,[{key:"clear",value:function(){this.transposer.clear(),this.stretch.clear()}},{key:"clone",value:function(){var t=new e;return t.rate=this.rate,t.tempo=this.tempo,t}},{key:"rate",get:function(){return this._rate},set:function(t){this.virtualRate=t,this.calculateEffectiveRateAndTempo()}},{key:"rateChange",set:function(t){this._rate=1+.01*t}},{key:"tempo",get:function(){return this._tempo},set:function(t){this.virtualTempo=t,this.calculateEffectiveRateAndTempo()}},{key:"tempoChange",set:function(t){this.tempo=1+.01*t}},{key:"pitch",set:function(t){this.virtualPitch=t,this.calculateEffectiveRateAndTempo()}},{key:"pitchOctaves",set:function(t){this.pitch=Math.exp(.69314718056*t),this.calculateEffectiveRateAndTempo()}},{key:"pitchSemitones",set:function(t){this.pitchOctaves=t/12}},{key:"inputBuffer",get:function(){return this._inputBuffer}},{key:"outputBuffer",get:function(){return this._outputBuffer}},{key:"calculateEffectiveRateAndTempo",value:function(){var t=this._tempo,e=this._rate;this._tempo=this.virtualTempo/this.virtualPitch,this._rate=this.virtualRate*this.virtualPitch,W(this._tempo,t)&&(this.stretch.tempo=this._tempo),W(this._rate,e)&&(this.transposer.rate=this._rate),this._rate>1?this._outputBuffer!=this.transposer.outputBuffer&&(this.stretch.inputBuffer=this._inputBuffer,this.stretch.outputBuffer=this._intermediateBuffer,this.transposer.inputBuffer=this._intermediateBuffer,this.transposer.outputBuffer=this._outputBuffer):this._outputBuffer!=this.stretch.outputBuffer&&(this.transposer.inputBuffer=this._inputBuffer,this.transposer.outputBuffer=this._intermediateBuffer,this.stretch.inputBuffer=this._intermediateBuffer,this.stretch.outputBuffer=this._outputBuffer)}},{key:"process",value:function(){this._rate>1?(this.stretch.process(),this.transposer.process()):(this.transposer.process(),this.stretch.process())}}]),e}(),G=function(){function e(i){t(this,e),this.buffer=i,this._position=0}return i(e,[{key:"dualChannel",get:function(){return this.buffer.numberOfChannels>1}},{key:"position",get:function(){return this._position},set:function(t){this._position=t}},{key:"extract",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.position=i;for(var n=this.buffer.getChannelData(0),r=this.dualChannel?this.buffer.getChannelData(1):this.buffer.getChannelData(0),o=0;o<e;o++)t[2*o]=n[o+i],t[2*o+1]=r[o+i];return Math.min(e,n.length-i)}}]),e}(),J=function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:z,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:4096,r=t.createScriptProcessor(n,2,2),o=new Float32Array(2*n);return r.onaudioprocess=function(t){var r=t.outputBuffer.getChannelData(0),s=t.outputBuffer.getChannelData(1),a=e.extract(o,n);i(e.sourcePosition),0===a&&e.onEnd();for(var u=0;u<a;u++)r[u]=o[2*u],s[u]=o[2*u+1]},r},Z=function(t){var e,i,n,r=Math.floor(t/60),o=t-60*r;return"".concat(r,":").concat((e=parseInt(o),n=n||"0",(e+="").length>=(i=2)?e:new Array(i-e.length+1).join(n)+e))},V=function(t){var e=this.timePlayed,i=this.sampleRate;if(this.sourcePosition=t,this.timePlayed=t/i,e!==this.timePlayed){var n=new CustomEvent("play",{detail:{timePlayed:this.timePlayed,formattedTimePlayed:this.formattedTimePlayed,percentagePlayed:this.percentagePlayed}});this._node.dispatchEvent(n)}},K=function(){function e(i,n,r){var o=this,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:z;t(this,e),this._soundtouch=new Q;var a=new G(n);this.timePlayed=0,this.sourcePosition=0,this._filter=new q(a,this._soundtouch,s),this._node=J(i,this._filter,(function(t){return V.call(o,t)}),r),this.tempo=1,this.rate=1,this.duration=n.duration,this.sampleRate=i.sampleRate,this.listeners=[]}return i(e,[{key:"formattedDuration",get:function(){return Z(this.duration)}},{key:"formattedTimePlayed",get:function(){return Z(this.timePlayed)}},{key:"percentagePlayed",get:function(){return 100*this._filter.sourcePosition/(this.duration*this.sampleRate)},set:function(t){this._filter.sourcePosition=parseInt(t*this.duration*this.sampleRate),this.sourcePosition=this._filter.sourcePosition,this.timePlayed=this.sourcePosition/this.sampleRate}},{key:"node",get:function(){return this._node}},{key:"pitch",set:function(t){this._soundtouch.pitch=t}},{key:"pitchSemitones",set:function(t){this._soundtouch.pitchSemitones=t}},{key:"rate",set:function(t){this._soundtouch.rate=t}},{key:"tempo",set:function(t){this._soundtouch.tempo=t}},{key:"connect",value:function(t){this._node.connect(t)}},{key:"disconnect",value:function(){this._node.disconnect()}},{key:"on",value:function(t,e){this.listeners.push({name:t,cb:e}),this._node.addEventListener(t,(function(t){return e(t.detail)}))}},{key:"off",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,i=this.listeners;e&&(i=i.filter((function(t){return t.name===e}))),i.forEach((function(e){t._node.removeEventListener(e.name,(function(t){return e.cb(t.detail)}))}))}}]),e}(),X=function(){function e(){t(this,e),this.fns={any:[]}}return i(e,[{key:"has",value:function(t){return t in this.fns&&this.fns[t].length>0||this.fns.any.length>0}},{key:"on",value:function(t,e){return t in this.fns==!1&&(this.fns[t]=[]),this.fns[t].push(e),e}},{key:"fire",value:function(t,e,i){return this.fns.any.concat(t in this.fns?this.fns[t]:[]).forEach((function(n){return n(e,i,t)})),this}},{key:"off",value:function(t){for(var e in this.fns)for(var i=this.fns[e],n=0;n<i.length;n++)if(i[n]===t)return i.splice(n,1),!0;return!1}},{key:"once",value:function(t,e){var i=this;return this.on(t,(function t(n,r,o){e(n,r,o),i.off(t)})),e}}]),e}(),$=function(t){if(t.on&&t.off)return t;var e=new X,i=new Proxy(t,{get:function(t,n){if(n in t){if(t.constructor===Array){var r=i;"pop"===n?r=t[t.length-1]:"shift"===n&&(r=t[0]),"push"!==n&&"length"!==n&&e.fire(n,r)}return t[n]}return"on"===n?e.on.bind(e):"once"===n?e.once.bind(e):"off"===n?e.off.bind(e):void 0},set:function(t,i,n){return t.constructor===Array?"length"!==i&&e.fire("change",n):e.has(i)&&e.fire(i,n,t[i]),t[i]=n,!0}});return i},tt=function(t){t.keyColor>=0&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.drawImage(t.canvas,0,0,t.canvas.width,t.canvas.height,0,0,this.canvas.width,this.canvas.height)},et=function(t,e){t.clearRect(0,0,e.width,e.height)},it=function(t){var e=this;return this.shifter&&this.shifter.off(),this.audio.decodeAudioData(t).then((function(t){e.shifter=$(new K(e.audio,t,1024,(function(){e.stop()}))),e.shifter.on("play",(function(t){e.props.timePlayed=t.formattedTimePlayed,e.props.percentagePlayed=t.percentagePlayed,e.player.sync(1e3*t.timePlayed-800)})),e.shifter.pitch=1,e.props.trackLength=e.shifter.formattedDuration})).catch((function(t){return Promise.reject(new Error("There was an error decoding the audio file",t))}))},nt=function(t){var e=new O;return t?(this.player.load(Array.from(t)),e.resolve()):e.reject(new Error("There was an error loading the video file")),e.promise},rt=function(t,e,i,n,r,o){for(var s=e.split(" "),a="",u=0;u<s.length;u++){var l=a+s[u]+" ";t.measureText(l).width>r&&u>0?(t.fillText(a.trim(),i,n),a=s[u]+" ",n+=o):a=l}t.fillText(a.trim(),i,n)},ot=function(){var t=this.ctx,e=this.canvas,i=e.width-10,n=i/2,r=60;t.font="30px sans-serif",t.fillStyle="#fff",t.textAlign="center",rt(t,this.tag.title,n,r,i,30),t.font="20px sans-serif",r=e.height-60,rt(t,"by ".concat(this.tag.artist),n,r,i,30)},st=function(t){if(this.tag=t&&t.tags,this.tag)return ot.call(this)},at=function(t){var e=this,i=[];return i.push(it.call(this,t[0])),i.push(nt.call(this,t[1])),Promise.all(i).then((function(){e.props.status="File Loaded",e.props.loaded=!0,st.call(e,t[2])})).catch((function(t){return e.props.status="File Loading Failed",Promise.reject(t)})).then((function(){e.props.loading=!1}))},ut=function(t){this.gainNode.gain.value=t},lt=function(){function e(i){var r,o,s,a=this;if(t(this,e),n(this,"audio",null),n(this,"gainNode",null),n(this,"shifter",null),n(this,"wrapper",null),n(this,"player",null),n(this,"currentSize",1),n(this,"canvas",null),n(this,"ctx",null),n(this,"props",$({status:"",loaded:!1,loading:!1,isPlaying:!1,timePlayed:"0:00",trackLength:"0:00",percentagePlayed:0,songVolume:1,destroy:!1})),this.wrapper=document.querySelector(i),!this.wrapper)throw new Error('CDGPlayer: and element was not found with the "'.concat(i,'" selector'));this.wrapper.classList.add("cdg-video-wrapper"),this.canvas=(r=300,o=216,(s=document.createElement("canvas")).width=r,s.height=o,s),this.canvas.classList.add("cdg-video-player"),this.ctx=function(t){var e=t.getContext("2d");return e.webkitImageSmoothingEnabled=!1,e.mozImageSmoothingEnabled=!1,e.msImageSmoothingEnabled=!1,e.imageSmoothingEnabled=!1,e}(this.canvas),this.player=new E({afterRender:function(t){return tt.call(a,t)}}),this.wrapper.appendChild(this.canvas);var u=document.createElement("div");u.classList.add("titleImage"),this.wrapper.appendChild(u),this.onloaded=this.props.on("loaded",(function(t){t?u.classList.add("hide"):u.classList.remove("hide")})),this.audio=new(window.AudioContext||window.webkitAudioContext),this.gainNode=this.audio.createGain(),this.onvolume=this.props.on("songVolume",(function(t){ut.call(a,t)})),this.props.songVolume=1}return i(e,[{key:"destroy",value:function(){this.wrapper.classList.remove("cdg-video-wrapper"),this.stop(),this.gainNode.disconnect(),this.shifter&&this.shifter.off(),this.shifter=null,this.gainNode=null,this.audio=null,this.canvas.remove(),this.props.destroy=!0,this.props.off("onvolume")}},{key:"load",value:function(t){var e,i=this;if(this.stop(),et(this.ctx,this.canvas),this.props.loading=!0,"string"==typeof t){if(!t.toLowerCase().endsWith(".zip"))return this.props.loading=!1,this.props.status="".concat(t,' doesn\'t appear to be a ".zip" file.'),Promise.reject(this.props.status);this.props.status="Retrieving File...",e=D.loadZipFile(t)}else this.props.status="Loading File...",e=D.loadFileBuffer(t);return e.then((function(t){return at.call(i,t)})).catch((function(t){return Promise.reject(t)}))}},{key:"togglePlay",value:function(){this.props.isPlaying?this.pause():this.start()}},{key:"start",value:function(){var t=this;et.call(this,this.ctx,this.canvas),this.shifter.connect(this.gainNode),this.gainNode.connect(this.audio.destination),this.audio.resume().then((function(){t.props.isPlaying=!0,t.player.play()}))}},{key:"pause",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.props.isPlaying=t,this.shifter.disconnect(),this.player.stop()}},{key:"stop",value:function(){this.shifter&&(this.pause(),this.changePlayerPosition(0),ot.call(this))}},{key:"changePlayerPosition",value:function(t){t=t<0?0:t>100?100:t,this.shifter.percentagePlayed=t,this.props.percentagePlayed=this.shifter.percentagePlayed,this.props.timePlayed=this.shifter.formattedTimePlayed,this.player.reset(),t||(this.props.isPlaying=!1,this.props.timePlayed="0:00")}},{key:"changeKey",value:function(t){t=t<-7?-7:t>7?7:t,this.shifter.pitchSemitones=t,this.shifter.tempo=1}},{key:"volume",value:function(t){var e=+(this.gainNode.gain.value+t).toFixed(2);this.props.songVolume=e<0?0:e>1?1:e}},{key:"toggleMute",value:function(){var t=this.gainNode.gain.value;this.props.songVolume=t?0:this.fallbackVolume,this.fallbackVolume=t}}]),e}(),ct='<div class="cdg-controls"> <span class="playControl"> <button class="playButton" disabled><i class="icofont-play-alt-1"></i></button> </span> <span class="timePlayed"></span> <div class="progress-container"> <progress class="progressMeter" ng-disabled="$ctrls.loading" value="0" max="100"></progress> </div> <span class="trackLength"></span> <span> <input type="number" class="pitch" step="1" min="-7" max="7" value="0" disabled> </span> <span class="volumeControl"> <div> <button class="volumeButton" id="song_volume_button" disabled><i class="icofont-audio"></i></button> <div class="volumeSlider"> <input type="range" min="0.00" max="1.00" step="0.01" class="volumeRange" id="song_volume"> </div> </div> </span> \x3c!-- <span class="volumeControl">\n <div>\n <button class="volumeButton" id="mic_volume_button"><i class="icofont-mic"></i></button>\n <div class="volumeSlider">\n <input type="range" min="0.0" max="1" step="0.1" class="volumeRange" id="mic_volume" />\n </div>\n </div>\n </span> --\x3e </div>';f('@font-face{font-family:IcoFont;font-style:normal;font-weight:400;src:url("data:font/woff2;base64,d09GMgABAAAAAAXMAAsAAAAACvwAAAWAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHFQGVgCDOAqJVIgXATYCJAMYCw4ABCAFhAoHVRtpCcgehXEsbKBS2ff0eD//bvrn5iZI8AbZnNUErxlUN8cqSmkqFgaZOO3UCHtqgjxR+3rwwHPL34lFvSywNDsu4naDTHgW0YYjGp7xP/z9TH/a1mBl6RiRb1HUZZE0HUfhgOLuLKK4wQ7wRPkUxHOgigy6cB9AAGgWDYilba0XlOcAPwdLkIJhBOpidJ4cD4BEtyAZVESiFxH2jb5DZ4ACxJV4DABO5BnoBdaAEEejIggutHFtHYWm//W/CtidOUJv5IH4ckEAAC0PMIDS49jQmegeg8tYKYx2IqQaIG+WIMBPN/xy069CRoKvR2KySwESdPgvD4BCwggIoBQCjVzC15ooN00aS2rtDSIHkOCXmzgAg19jJiBErSDKHo5BtOAuGo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+3N8PWEsDiQrjZfv2jnTducr70webld07v5q3j1i9KpGOwF0sLShH1zTb9xxqzqW8mKEcFqnqVMp0wZv4l5Xu+J2xV8Oj8gBoAnrT/vLVzrRWGrWs7kOpbv+YrefoAj2Zx0Tg7j/4tPLju5vMuBGbs7D+2Cc0/1+62WwB4nGNgZGBgAOIP9qt64vltvjJwM78AijBcPxB1Akb///8/i/kFczCQy8HABBIFAJztDyEAeJxjYGRgYA76nwUkX/z/DyIZgCIogA0Ai8sFm3icY37BwMCMgv//B9EAUrkHgQAAAAAAAACEAUwB3AIgAmoAAHicY2BkYGBgY+hkYGUAASYg5gJCBob/YD4DABbAAasAeJxdkE1qwzAQhZ/zS2MIhdKsStGqXRScn2UOkJBtFoYuHUd2HGzLyEogPUFP0BP0FD1A6bH6bKaLRkLSN2+epJEA3OIbHprmYdjOTeuQh8Jd0li4R74X7sPHg/CA+rPwCC8IhH3c4ZUneL0bKmPkwh3ym3CX/C7cI38I9zHBp/CA+pfwCCF+hH08eY+b2KxM6bY6PeWRzWKTMJIl1LbOTKnmwUyUtS61jZzeq91F1ed04VyiEmsK1Ryi89yoypqjjl1wcK5aTqeJ6EFsCmwQw2DFUcJhC40UJ74rgkXW5hLJ/Y9COi1qqk2sMOcfza48a3rK1hcx0tjTt8OFc40z71lQdXQrDss9BemvEs0acrJC1eaOVGLqAQ7trgpLTNmTK3/QVlD8AsE9WlYAeJxjYGKAAC4G7ICNkYmRmZGFkZWRjZGdgTk3M5kDiHVzS0tSWRNLUzLzuQpyEit1E3NKdA1ZCxJLi1MZGAD/FgxfAAA=") format("woff")}[class*=" icofont-"],[class^=icofont-]{speak:none;word-wrap:normal;-webkit-font-feature-settings:"liga";-webkit-font-smoothing:antialiased;direction:ltr;font-family:IcoFont!important;font-style:normal;font-variant:normal;font-weight:400;line-height:1;text-transform:none;white-space:nowrap}.icofont-mic:before{content:"\\ef95"}.icofont-mic-mute:before{content:"\\ef94"}.icofont-audio:before{content:"\\eea8"}.icofont-play-alt-1:before{content:"\\eca6"}.icofont-pause:before{content:"\\eca5"}.cdg-controls .playButton>i,.cdg-controls .volumeButton>i,.icofont-md{font-size:2em}.cdg-controls .playButton>i,.cdg-controls .volumeButton>i,.icofont-fw{text-align:center;width:1.25em}.cdg-controls .pitch[disabled],.cdg-controls .playButton[disabled],.cdg-controls .volumeButton[disabled],.mute{color:#a9a9a9}.cdg-controls{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;display:-ms-flexbox;display:-webkit-box;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:nowrap;flex-wrap:nowrap;font-size:1.25em;height:40px;justify-content:center;position:relative;width:100%}.cdg-controls>div,.cdg-controls>span{margin:3px 5px}.cdg-controls>div:first-child,.cdg-controls>span:first-child{margin-left:0}.cdg-controls>div:last-child,.cdg-controls>span:last-child{margin-right:0}.cdg-controls .playButton,.cdg-controls .volumeButton{border:none;border-radius:3px;height:34px;outline:none;padding:5px;width:34px}.cdg-controls .playButton[disabled],.cdg-controls .volumeButton[disabled]{cursor:not-allowed}.cdg-controls .volumeControl>div{height:100%;position:relative;width:100%}.cdg-controls .volumeControl>div:hover .volumeSlider{display:block}.cdg-controls .volumeControl>div .volumeSlider{display:none;left:-55px;padding:10px 20px;position:absolute;top:-75px;-webkit-transform:rotate(270deg);transform:rotate(270deg);width:100px;z-index:100}.cdg-controls .volumeControl>div .volumeSlider.under{top:75px;-webkit-transform:rotate(90deg);transform:rotate(90deg)}.cdg-controls .volumeControl>div .volumeSlider:hover{display:block}.cdg-controls .volumeControl>div .volumeSlider .volumeRange{-webkit-appearance:none;background:#d3d3d3;border:1px solid;border-radius:2.5px;height:5px;opacity:.7;outline:none;-webkit-transition:.2s;-webkit-transition:opacity .2s;transition:opacity .2s;width:100%}.cdg-controls .volumeControl>div .volumeSlider .volumeRange:hover{opacity:1}.cdg-controls .volumeControl>div .volumeSlider .volumeRange::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;background:#fff;border:1px solid blue;border-radius:50%;cursor:pointer;height:15px;width:15px}.cdg-controls .pitch{font-size:.8em;height:28px;text-align:right}.cdg-controls .pitch[disabled]{cursor:not-allowed}.cdg-controls .progress-container{-webkit-box-flex:0;display:inline-block;-ms-flex:0 1 auto;flex:0 1 auto;position:relative;width:100%}.cdg-controls .progress-container progress{-webkit-appearance:none;-moz-appearance:none;appearance:none;height:1em;width:100%}.cdg-controls .progress-container progress::-webkit-progress-bar{background-color:#eee;border-radius:.5em;-webkit-box-shadow:inset 0 2px 5px rgba(0,0,0,.25);box-shadow:inset 0 2px 5px rgba(0,0,0,.25)}.cdg-controls .progress-container progress::-webkit-progress-value{background-image:-webkit-linear-gradient(-45deg,transparent 33%,transparent 0,rgba(0,0,0,.1) 66%,transparent 0),-webkit-linear-gradient(top,hsla(0,0%,100%,.25),rgba(0,0,0,.25)),-webkit-linear-gradient(left,#09c,#f44);background-size:35px 20px,100% 100%,100% 100%;border-radius:.5em}');var ht=function(t){var e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild},ft=function(){var t=this,e=this.player.props;this.onloaded=e.on("loaded",(function(e){e?(t.playBtn.removeAttribute("disabled"),t.pitch.removeAttribute("disabled"),t.volumeBtn.removeAttribute("disabled")):(t.playBtn.setAttribute("disabled","disabled"),t.pitch.setAttribute("disabled","disabled"),t.volumeBtn.setAttribute("disabled","disabled"))})),this.ontimeplayed=e.on("timePlayed",(function(e,i){e!==i&&(t.timePlayed.innerHTML=e)})),this.onpercentageplayed=e.on("percentagePlayed",(function(e,i){e!==i&&(t.progress.value=e)})),this.ontracklength=e.on("trackLength",(function(e,i){e!==i&&(t.trackLength.innerHTML=e)})),this.ondestroy=e.on("destroy",(function(e){e&&pt.call(t)})),this.onplay=e.on("isPlaying",(function(e){t.playIcn.classList.remove("icofont-play-alt-1","icofont-pause"),t.playIcn.classList.add(e?"icofont-pause":"icofont-play-alt-1")})),this.onvolume=e.on("songVolume",(function(e){var i=t.volumeIcn;if(t.volumeSlider.value=e,e)return i.classList.contains("mute")?void i.classList.remove("mute"):void 0;i.classList.add("mute")})),this.playBtn.addEventListener("click",(function(){return t.player.togglePlay()})),this.progress.addEventListener("click",(function(e){return dt.call(t,e)})),this.pitch.addEventListener("change",(function(){return vt.call(t)})),this.volumeSlider.addEventListener("change",(function(){return mt.call(t)}))},pt=function(){var t=this,e=this.player.props;e.off(this.onloaded),e.off(this.ontimeplayed),e.off(this.onpercentageplayed),e.off(this.ontracklength),e.off(this.ondestroy),e.off(this.onplay),e.off(this.onvolume),this.playBtn.removeEventListener("click",(function(){return t.player.togglePlay()})),this.progress.removeEventListener("click",(function(e){return dt.call(t,e)})),this.pitch.removeEventListener("change",(function(){return vt.call(t)})),this.volumeSlider.removeEventListener("change",(function(){return mt.call(t)}))},dt=function(t){var e=t.target.getBoundingClientRect(),i=(t.pageX-e.x)/t.target.offsetWidth;this.player.changePlayerPosition(i)},vt=function(){var t=this.pitch.value;isNaN(t)?this.pitch.value=this.fallbackPitch:(this.fallbackPitch=t<-7?-7:t>7?7:t,this.player.changeKey(this.fallbackPitch))},mt=function(){this.player.props.songVolume=+(parseFloat(this.volumeSlider.value)+0).toFixed(2)},gt=function e(i,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{position:"bottom"};t(this,e),n(this,"controls",ht(ct)),n(this,"player",null),n(this,"playBtn",null),n(this,"playIcn",null),n(this,"timePlayed",null),n(this,"progress",null),n(this,"trackLength",null),n(this,"pitch",null);var s=document.querySelector(i);s.appendChild(this.controls),this.player=r;var a=this.player.props;if(this.playBtn=this.controls.querySelector(".playButton"),this.playIcn=this.playBtn.querySelector("i"),this.timePlayed=this.controls.querySelector(".timePlayed"),this.timePlayed.innerHTML=a.timePlayed,this.progress=this.controls.querySelector(".progressMeter"),this.progress.value=a.percentagePlayed,this.trackLength=this.controls.querySelector(".trackLength"),this.trackLength.innerHTML=a.trackLength,this.pitch=this.controls.querySelector(".pitch"),this.fallbackPitch=0,!d.includes(o.position))throw new Error("Panel Position must be either 'top' or 'bottom'.");if(this.volumeBtn=this.controls.querySelector("#song_volume_button"),this.volumeIcn=this.volumeBtn.querySelector("i"),this.volumeSlider=this.controls.querySelector("#song_volume"),this.volumeSlider.value=a.songVolume,"top"===o.position){var u=this.controls.querySelector(".volumeSlider");u.classList.add("under")}ft.call(this)};export{gt as CDGControls,lt as CDGPlayer};
function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function i(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function n(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&s(t,e)}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}function s(t,e){return s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},s(t,e)}function a(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function u(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}();return function(){var i,n=o(t);if(e){var r=o(this).constructor;i=Reflect.construct(n,arguments,r)}else i=n.apply(this,arguments);return a(this,i)}}function l(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=o(t)););return t}function c(){return c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,i){var n=l(t,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?t:i):r.value}},c.apply(this,arguments)}function h(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==i)return;var n,r,o=[],s=!0,a=!1;try{for(i=i.call(t);!(s=(n=i.next()).done)&&(o.push(n.value),!e||o.length!==e);s=!0);}catch(t){a=!0,r=t}finally{try{s||null==i.return||i.return()}finally{if(a)throw r}}return o}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return f(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return f(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function p(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===i&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}}p(".cdg-video-wrapper{background-color:#000;position:relative;text-align:center}.cdg-video-wrapper .cdg-video-player{margin:0 auto;position:relative;width:72%}.cdg-video-wrapper .titleImage{background-color:transparent;height:100%;left:0;position:absolute;top:0;width:100%;z-index:auto}.cdg-video-wrapper .titleImage.hide{display:none}");var d=[6,12,294,204],v=["top","bottom"],m=function(){function e(){var i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.width,o=void 0===r?300:r,s=i.height,a=void 0===s?216:s,u=i.canvas,l=void 0===u?this.createCanvas(o,a):u,c=i.ctx,h=void 0===c?this.createCanvasContext(l):c,f=i.imageData,p=void 0===f?this.createImageData(l,h,o,a):f;t(this,e),n(this,"hOffset",0),n(this,"vOffset",0),n(this,"keyColor",null),n(this,"backgroundContainer",null),n(this,"borderColor",null),n(this,"memoryColor",null),n(this,"clut",new Array(16).fill([0,0,0])),n(this,"pixels",new Array(64800).fill(0)),n(this,"buffer",new Array(64800).fill(0)),this.canvas=l,this.ctx=h,this.imageData=p}return i(e,[{key:"createCanvas",value:function(t,e){var i=document.createElement("canvas");return i.width=t,i.height=e,i}},{key:"createCanvasContext",value:function(t){var e=t.getContext("2d");return e.mozImageSmoothingEnabled=!1,e.webkitImageSmoothingEnabled=!1,e.msImageSmoothingEnabled=!1,e.imageSmoothingEnabled=!1,e}},{key:"createImageData",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.width,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:t.height;return e.createImageData(i,n)}},{key:"reset",value:function(){this.hOffset=0,this.vOffset=0,this.keyColor=null,this.backgroundColor=null,this.borderColor=null,this.memoryColor=null,this.pixels.fill(0)}},{key:"setCLUTEntry",value:function(t,e,i,n){this.clut[t]=[e,i,n].map((function(t){return 17*t}))}},{key:"setPixel",value:function(t,e,i){this.pixels[t+300*e]=i}},{key:"getPixel",value:function(t,e){return this.pixels[t+300*e]}},{key:"getBackground",value:function(){switch(!0){case null!=this.keyColor:return this.keyColor;case null!=this.backgroundColor:return this.backgroundColor;case null!=this.memoryColor:return this.memoryColor;case null!=this.borderColor:return this.borderColor;default:return 0}}},{key:"generateImageData",value:function(){for(var t=0;t<300;t++)for(var e=0;e<216;e++){var i=4*(t+300*e),n=(t-this.hOffset+300)%300+300*((e-this.vOffset+216)%216),r=this.pixels[n],o=h(this.clut[r],3),s=o[0],a=o[1],u=o[2];this.imageData.data[i]=s,this.imageData.data[i+1]=a,this.imageData.data[i+2]=u,this.imageData.data[i+3]=r===this.keyColor?0:255}return this.imageData}},{key:"renderFrame",value:function(){this.ctx.putImageData(this.generateImageData(),0,0)}}]),e}();function g(){var t;console&&console.warn&&(t=console).warn.apply(t,arguments)}var y=function(){function e(i){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,e),this.bytes=i.slice(n,n+24)}return i(e,[{key:"instruction",get:function(){return this.constructor.instruction}},{key:"opcode",get:function(){return this.constructor.opcode}},{key:"execute",value:function(){}},{key:"bytecodeToString",value:function(){return this.bytes.map((function(t){return t.toString(16).padStart(2,"0")})).join("")}},{key:"detailsToString",value:function(){return""}},{key:"toString",value:function(){return this.instruction}}]),e}();n(y,"instruction",""),n(y,"opcode",null);var A=function(e){r(o,y);var n=u(o);function o(){return t(this,o),n.apply(this,arguments)}return i(o)}();n(A,"instruction","No-op"),n(A,"opcode",0);var k=function(e){r(o,y);var n=u(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,o);var s=r+4;return(i=n.call(this,e,r)).color=15&e[s],i.repeat=15&e[s+1],i}return i(o,[{key:"execute",value:function(t){t.memoryColor=this.color,t.backgroundColor=this.color,t.pixels.fill(this.color)}},{key:"detailsToString",value:function(){return"color index: ".concat(this.color)}}]),o}();n(k,"instruction","Memory Preset"),n(k,"opcode",1);var b=function(e){r(o,y);var n=u(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t(this,o),(i=n.call(this,e,r)).color=15&e[r+4],i}return i(o,[{key:"execute",value:function(t){t.borderColor=this.color,t.backgroundColor=this.color;for(var e=h(d,4),i=e[0],n=e[1],r=e[2],o=e[3],s=0;s<300;s++){for(var a=0;a<n;a++)t.setPixel(s,a,this.color);for(var u=o+1;u<216;u++)t.setPixel(s,u,this.color)}for(var l=n;l<=o;l++){for(var c=0;c<i;c++)t.setPixel(c,l,this.color);for(var f=r+1;f<300;f++)t.setPixel(f,l,this.color)}}},{key:"detailsToString",value:function(){return"color index: ".concat(this.color)}}]),o}();n(b,"instruction","Border Preset"),n(b,"opcode",2);var w=function(e){r(o,y);var n=u(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,o);var s=r+4;return(i=n.call(this,e,r)).colors=[15&e[s],15&e[s+1]],i.row=31&e[s+2],i.column=63&e[s+3],i.pixels=e.slice(s+4,s+16),i}return i(o,[{key:"execute",value:function(t){var e=6*this.column,i=12*this.row;if(e+6>300||i+12>216)g("TileBlock out of bounds (".concat(this.row,", ").concat(this.column,")"));else for(var n=0;n<12;n++)for(var r=this.pixels[n],o=0;o<6;o++){var s=this.colors[r>>5-o&1];this.op(t,e+o,i+n,s)}}},{key:"op",value:function(t,e,i,n){t.setPixel(e,i,n)}},{key:"detailsToString",value:function(){return"row: ".concat(this.row,", column: ").concat(this.column,", color indexes: [").concat(this.colors.join(", "),"]")}}]),o}();n(w,"instruction","Tile Block"),n(w,"opcode",6);var B=function(e){r(o,w);var n=u(o);function o(){return t(this,o),n.apply(this,arguments)}return i(o,[{key:"op",value:function(t,e,i,n){t.setPixel(e,i,t.getPixel(e,i)^n)}}]),o}();n(B,"instruction","Tile Block (XOR)"),n(B,"opcode",38);var x=function(e){r(o,y);var n=u(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,o);var s=r+4;(i=n.call(this,e,r)).color=15&e[s];var a=63&e[s+1];i.hCmd=(48&a)>>4,i.hOffset=7&a;var u=63&e[s+2];return i.vCmd=(48&u)>>4,i.vOffset=15&u,i}return i(o,[{key:"execute",value:function(t){t.backgroundColor=this.color,t.hOffset=Math.min(this.hOffset,5),t.vOffset=Math.min(this.vOffset,11);var e=0;switch(this.hCmd){case 2:e=6;break;case 1:e=-6}var i=0;switch(this.hCmd){case 2:i=12;break;case 1:i=-12}if(e||i){for(var n=0;n<300;n++)for(var r=0;r<216;r++)t.buffer[n+300*r]=this.getPixel(t,n+e,r+i);var o=[t.buffer,t.pixels];t.pixels=o[0],t.buffer=o[1]}}},{key:"getPixel",value:function(t,e,i){return e>0&&e<300&&i>0&&i<216?t.pixels[e+300*i]:this.color}},{key:"detailsToString",value:function(){var t=!1,e=!1;return 1===this.vCmd?t="up":2===this.vCmd&&(t="down"),1===this.vCmd?e="left":2===this.vCmd&&(e="right"),[t,e,"vOffset: ".concat(this.vOffset),"hOffset: ".concat(this.hOffset)].filter((function(t){return t})).join(" ")}}]),o}();n(x,"instruction","Scroll Preset"),n(x,"opcode",20);var C=function(e){r(o,x);var n=u(o);function o(){return t(this,o),n.apply(this,arguments)}return i(o,[{key:"getPixel",value:function(t,e,i){return e=(e+300)%300,i=(i+216)%216,t.pixels[e+300*i]}}]),o}();n(C,"instruction","Scroll Copy"),n(C,"opcode",24);var P=function(e){r(o,y);var n=u(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t(this,o),(i=n.call(this,e,r)).color=15&e[r+4],i}return i(o,[{key:"execute",value:function(t){t.keyColor=this.color}},{key:"detailsToString",value:function(){return"color index: ".concat(this.color)}}]),o}();n(P,"instruction","Set Key Color"),n(P,"opcode",28);var S=function(e){r(o,y);var n=u(o);function o(e){var i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;t(this,o);var s=r+4;(i=n.call(this,e,r)).colors=[];for(var a=0;a<8;a++){var u=s+2*a,l=((63&e[u])<<6)+(63&e[u+1]);i.colors[a]=[l>>8,(240&l)>>4,15&l]}return i}return i(o,[{key:"clutOffset",get:function(){return 0}},{key:"execute",value:function(t){for(var e=0;e<8;e++)t.setCLUTEntry(e+this.clutOffset,this.colors[e][0],this.colors[e][1],this.colors[e][2])}},{key:"detailsToString",value:function(){var t=this;return"colors: [".concat(this.colors.map((function(e,i){return"".concat(i+t.clutOffset,": #").concat(e.map((function(t){return t.toString(16)})).join(""))})).join(", "),"]")}}]),o}();n(S,"instruction","Load CLUT (Low)"),n(S,"opcode",30);var _=function(e){r(o,S);var n=u(o);function o(){return t(this,o),n.apply(this,arguments)}return i(o,[{key:"clutOffset",get:function(){return 8}}]),o}();n(_,"instruction","Load CLUT (High)"),n(_,"opcode",31);var L=function(){function e(){t(this,e),n(this,"instructionClassByType",this.constructor.instructionClassByType)}return i(e,[{key:"registerInstruction",value:function(t,e){this.instructionClassByType[t]=e}},{key:"createInstruction",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;t in this.instructionClassByType||g("Unknown CDG instruction (instruction = ".concat(t,")"));var n=this.instructionClassByType[t]||A;return new n(e,i)}},{key:"parseInstruction",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=63&t[e];if(9===i){var n=63&t[e+1];return this.createInstruction(n,t,e)}return new A(t,e)}},{key:"parseInstructions",value:function(t){for(var e=[],i=t.length,n=0;n<i;n+=24)e.push(this.parseInstruction(t,n));return e.filter((function(t){return t}))}}],[{key:"instructionClassByType",get:function(){var t;return n(t={},0,A),n(t,1,k),n(t,2,b),n(t,6,w),n(t,20,x),n(t,24,C),n(t,28,P),n(t,30,S),n(t,31,_),n(t,38,B),t}}]),e}();function I(){if("undefined"!=typeof performance&&"function"==typeof performance.now)return performance.now();if("undefined"!=typeof process&&"function"==typeof process.hrtime){var t=h(process.hrtime(),2);return 1e3*t[0]+t[1]/1e6}return Date.now()}function E(t){return"function"==typeof requestAnimationFrame?window.requestAnimationFrame(t):setTimeout(t,25)}var O=function(){function e(){var i=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=r.contextOptions,s=void 0===o?{}:o,a=r.context,u=void 0===a?this.createContext(s):a,l=r.afterRender;t(this,e),n(this,"instructions",[]),n(this,"pc",-1),n(this,"frameId",null),n(this,"pos",0),n(this,"lastSyncPos",null),n(this,"lastTimestamp",null),n(this,"update",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:I();if(-1===i.pc)return i;i.frameId=E(i.update),i.lastSyncPos?i.pos=i.lastSyncPos+(t-i.lastTimestamp):(i.pos+=t-i.lastTimestamp,i.lastTimestamp=t);var e=Math.floor(i.pos/1e3*300),n=e-i.pc;return n>0&&(i.fastForward(n),i.render()),i})),this.context=u,this.afterRender=l}return i(e,[{key:"createContext",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new m(t)}},{key:"load",value:function(t){var e=new L;return this.instructions=e.parseInstructions(t),this.reset(),this}},{key:"reset",value:function(){return this.pc=0,this.pos=0,this.lastSyncPos=null,this.context.reset(),this}},{key:"render",value:function(){return this.context.renderFrame(),this.afterRender&&this.afterRender(this.context),this}},{key:"executeInstruction",value:function(t){return t&&"function"==typeof t.execute&&t.execute(this.context),this}},{key:"step",value:function(){return this.pc>=0&&this.pc<this.instructions.length?(this.executeInstruction(this.instructions[this.pc]),this.pc+=1):(this.pc=-1,this.stop()),this}},{key:"fastForward",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=this.pc+t;this.pc>=0&&this.pc<e;)this.step();return this}},{key:"play",value:function(){return this.frameId||(this.frameId=E(this.update),this.lastTimestamp=I()),this}},{key:"stop",value:function(){var t;return t=this.frameId,"function"==typeof cancelAnimationFrame?cancelAnimationFrame(t):clearTimeout(t),this.frameId=null,this.lastSyncPos=null,this}},{key:"sync",value:function(t){return this.lastSyncPos=t,this.lastTimestamp=I(),this}}]),e}(),R=function(){return"undefined"!=typeof Promise&&Promise.defer?Promise.defer():"undefined"!=typeof PromiseUtils&&PromiseUtils.defer?PromiseUtils.defer():(this.resolve=null,this.reject=null,this.promise=new Promise(function(t,e){this.resolve=t,this.reject=e}.bind(this)),void Object.freeze(this))},T=function(t){return JSZip.loadAsync(t).catch((function(t){return Promise.reject(new Error("There was an error reading the zip file.",t))}))},M=function(t){var e=t.filter((function(t){return t.endsWith(".cdg")||t.endsWith(".mp3")}));return 2===e.length?Promise.resolve(e):Promise.reject("The file is not a karaoke .zip file")},D=function(t){var e=t.filter((function(t){return t.name.endsWith(".mp3")})),i=t.filter((function(t){return t.name.endsWith(".cdg")})),n=[];if(e.length&&i.length)return n.push(e[0].async("arraybuffer").catch((function(){return Promise.reject(new Error("Unable to load the audio file"))}))),n.push(function(t){return t.async("uint8array").catch((function(){return Promise.reject(new Error("Unable to load the video file"))}))}(i[0])),n.push(function(t){return t.async("blob").then((function(e){return new Promise((function(i){new jsmediatags.Reader(e).setTagsToRead(["title","artist","album","track","year","genre","picture"]).read({onSuccess:function(t){return i(t)},onError:function(){return i((e=t.name.split(" - "),(n={tags:{}}).tags.album=e[0].trim(),n.tags.artist=e[1]?e[1].trim():n.tags.album,n.tags.title=e[2]?e[2].trim():n.tags.artist,n));var e,n}})}))})).catch((function(){return Promise.reject(new Error("Unable to parse tag data"))}))}(e[0])),Promise.all(n);var r=[];return e.length||r.push("No mp3 audio file present."),i.length||r.push("No cdg video file present."),Promise.reject(new Error(r.join(" ")))},j=function(){function e(){t(this,e)}return i(e,null,[{key:"loadZipFile",value:function(t){return function(t){var e=new R;return JSZipUtils.getBinaryContent(t,(function(i,n){i?e.reject(new Error("There was an error retrieving ".concat(t),i)):e.resolve(n)})),e.promise}(t).then((function(t){return T(t)})).then((function(t){return M(t)})).then((function(t){return D(t)})).catch((function(t){return Promise.reject(t)}))}},{key:"loadFileBuffer",value:function(t){return T(t).then((function(t){return M(t)})).then((function(t){return D(t)})).catch((function(t){return Promise.reject(t)}))}}]),e}(),Y=function(){function e(){t(this,e),this._vector=new Float32Array,this._position=0,this._frameCount=0}return i(e,[{key:"vector",get:function(){return this._vector}},{key:"position",get:function(){return this._position}},{key:"startIndex",get:function(){return 2*this._position}},{key:"frameCount",get:function(){return this._frameCount}},{key:"endIndex",get:function(){return 2*(this._position+this._frameCount)}},{key:"clear",value:function(){this.receive(this._frameCount),this.rewind()}},{key:"put",value:function(t){this._frameCount+=t}},{key:"putSamples",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=2*(e=e||0);i>=0||(i=(t.length-n)/2);var r=2*i;this.ensureCapacity(i+this._frameCount);var o=this.endIndex;this.vector.set(t.subarray(n,n+r),o),this._frameCount+=i}},{key:"putBuffer",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;e=e||0,i>=0||(i=t.frameCount-e),this.putSamples(t.vector,t.position+e,i)}},{key:"receive",value:function(t){t>=0&&!(t>this._frameCount)||(t=this.frameCount),this._frameCount-=t,this._position+=t}},{key:"receiveSamples",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=2*e,n=this.startIndex;t.set(this._vector.subarray(n,n+i)),this.receive(e)}},{key:"extract",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=this.startIndex+2*e,r=2*i;t.set(this._vector.subarray(n,n+r))}},{key:"ensureCapacity",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=parseInt(2*t);if(this._vector.length<e){var i=new Float32Array(e);i.set(this._vector.subarray(this.startIndex,this.endIndex)),this._vector=i,this._position=0}else this.rewind()}},{key:"ensureAdditionalCapacity",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.ensureCapacity(this._frameCount+t)}},{key:"rewind",value:function(){this._position>0&&(this._vector.set(this._vector.subarray(this.startIndex,this.endIndex)),this._position=0)}}]),e}(),F=function(){function e(i){t(this,e),i?(this._inputBuffer=new Y,this._outputBuffer=new Y):this._inputBuffer=this._outputBuffer=null}return i(e,[{key:"inputBuffer",get:function(){return this._inputBuffer},set:function(t){this._inputBuffer=t}},{key:"outputBuffer",get:function(){return this._outputBuffer},set:function(t){this._outputBuffer=t}},{key:"clear",value:function(){this._inputBuffer.clear(),this._outputBuffer.clear()}}]),e}(),H=function(e){r(o,F);var n=u(o);function o(e){var i;return t(this,o),(i=n.call(this,e)).reset(),i._rate=1,i}return i(o,[{key:"rate",set:function(t){this._rate=t}},{key:"reset",value:function(){this.slopeCount=0,this.prevSampleL=0,this.prevSampleR=0}},{key:"clone",value:function(){var t=new o;return t.rate=this._rate,t}},{key:"process",value:function(){var t=this._inputBuffer.frameCount;this._outputBuffer.ensureAdditionalCapacity(t/this._rate+1);var e=this.transpose(t);this._inputBuffer.receive(),this._outputBuffer.put(e)}},{key:"transpose",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(0===t)return 0;for(var e=this._inputBuffer.vector,i=this._inputBuffer.startIndex,n=this._outputBuffer.vector,r=this._outputBuffer.endIndex,o=0,s=0;this.slopeCount<1;)n[r+2*s]=(1-this.slopeCount)*this.prevSampleL+this.slopeCount*e[i],n[r+2*s+1]=(1-this.slopeCount)*this.prevSampleR+this.slopeCount*e[i+1],s+=1,this.slopeCount+=this._rate;if(this.slopeCount-=1,1!==t)t:for(;;){for(;this.slopeCount>1;)if(this.slopeCount-=1,(o+=1)>=t-1)break t;var a=i+2*o;n[r+2*s]=(1-this.slopeCount)*e[a]+this.slopeCount*e[a+2],n[r+2*s+1]=(1-this.slopeCount)*e[a+1]+this.slopeCount*e[a+3],s+=1,this.slopeCount+=this._rate}return this.prevSampleL=e[i+2*t-2],this.prevSampleR=e[i+2*t-1],s}}]),o}(),z=function(){function e(i){t(this,e),this._pipe=i}return i(e,[{key:"pipe",get:function(){return this._pipe}},{key:"inputBuffer",get:function(){return this._pipe.inputBuffer}},{key:"outputBuffer",get:function(){return this._pipe.outputBuffer}},{key:"fillInputBuffer",value:function(){throw new Error("fillInputBuffer() not overridden")}},{key:"fillOutputBuffer",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.outputBuffer.frameCount<t;){var e=16384-this.inputBuffer.frameCount;if(this.fillInputBuffer(e),this.inputBuffer.frameCount<16384)break;this._pipe.process()}}},{key:"clear",value:function(){this._pipe.clear()}}]),e}(),q=function(){},N=function(e){r(s,z);var n=u(s);function s(e,i){var r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:q;return t(this,s),(r=n.call(this,i)).callback=o,r.sourceSound=e,r.historyBufferSize=22050,r._sourcePosition=0,r.outputBufferPosition=0,r._position=0,r}return i(s,[{key:"position",get:function(){return this._position},set:function(t){if(t>this._position)throw new RangeError("New position may not be greater than current position");var e=this.outputBufferPosition-(this._position-t);if(e<0)throw new RangeError("New position falls outside of history buffer");this.outputBufferPosition=e,this._position=t}},{key:"sourcePosition",get:function(){return this._sourcePosition},set:function(t){this.clear(),this._sourcePosition=t}},{key:"onEnd",value:function(){this.callback()}},{key:"fillInputBuffer",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,e=new Float32Array(2*t),i=this.sourceSound.extract(e,t,this._sourcePosition);this._sourcePosition+=i,this.inputBuffer.putSamples(e,0,i)}},{key:"extract",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.fillOutputBuffer(this.outputBufferPosition+e);var i=Math.min(e,this.outputBuffer.frameCount-this.outputBufferPosition);this.outputBuffer.extract(t,this.outputBufferPosition,i);var n=this.outputBufferPosition+i;return this.outputBufferPosition=Math.min(this.historyBufferSize,n),this.outputBuffer.receive(Math.max(n-this.historyBufferSize,0)),this._position+=i,i}},{key:"handleSampleData",value:function(t){this.extract(t.data,4096)}},{key:"clear",value:function(){c(o(s.prototype),"clear",this).call(this),this.outputBufferPosition=0}}]),s}(),U=[[124,186,248,310,372,434,496,558,620,682,744,806,868,930,992,1054,1116,1178,1240,1302,1364,1426,1488,0],[-100,-75,-50,-25,25,50,75,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-20,-15,-10,-5,5,10,15,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[-4,-3,-2,-1,1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]],W=function(e){r(s,F);var n=u(s);function s(e){var i;return t(this,s),(i=n.call(this,e))._quickSeek=!0,i.midBufferDirty=!1,i.midBuffer=null,i.overlapLength=0,i.autoSeqSetting=!0,i.autoSeekSetting=!0,i._tempo=1,i.setParameters(44100,0,0,8),i}return i(s,[{key:"clear",value:function(){c(o(s.prototype),"clear",this).call(this),this.clearMidBuffer()}},{key:"clearMidBuffer",value:function(){this.midBufferDirty&&(this.midBufferDirty=!1,this.midBuffer=null)}},{key:"setParameters",value:function(t,e,i,n){t>0&&(this.sampleRate=t),n>0&&(this.overlapMs=n),e>0?(this.sequenceMs=e,this.autoSeqSetting=!1):this.autoSeqSetting=!0,i>0?(this.seekWindowMs=i,this.autoSeekSetting=!1):this.autoSeekSetting=!0,this.calculateSequenceParameters(),this.calculateOverlapLength(this.overlapMs),this.tempo=this._tempo}},{key:"tempo",get:function(){return this._tempo},set:function(t){var e;this._tempo=t,this.calculateSequenceParameters(),this.nominalSkip=this._tempo*(this.seekWindowLength-this.overlapLength),this.skipFract=0,e=Math.floor(this.nominalSkip+.5),this.sampleReq=Math.max(e+this.overlapLength,this.seekWindowLength)+this.seekLength}},{key:"inputChunkSize",get:function(){return this.sampleReq}},{key:"outputChunkSize",get:function(){return this.overlapLength+Math.max(0,this.seekWindowLength-2*this.overlapLength)}},{key:"calculateOverlapLength",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;t=(t=this.sampleRate*e/1e3)<16?16:t,t-=t%8,this.overlapLength=t,this.refMidBuffer=new Float32Array(2*this.overlapLength),this.midBuffer=new Float32Array(2*this.overlapLength)}},{key:"checkLimits",value:function(t,e,i){return t<e?e:t>i?i:t}},{key:"calculateSequenceParameters",value:function(){var t,e;this.autoSeqSetting&&(t=150+-50*this._tempo,t=this.checkLimits(t,50,125),this.sequenceMs=Math.floor(t+.5)),this.autoSeekSetting&&(e=28.333333333333332+-6.666666666666667*this._tempo,e=this.checkLimits(e,15,25),this.seekWindowMs=Math.floor(e+.5)),this.seekWindowLength=Math.floor(this.sampleRate*this.sequenceMs/1e3),this.seekLength=Math.floor(this.sampleRate*this.seekWindowMs/1e3)}},{key:"quickSeek",set:function(t){this._quickSeek=t}},{key:"clone",value:function(){var t=new s;return t.tempo=this._tempo,t.setParameters(this.sampleRate,this.sequenceMs,this.seekWindowMs,this.overlapMs),t}},{key:"seekBestOverlapPosition",value:function(){return this._quickSeek?this.seekBestOverlapPositionStereoQuick():this.seekBestOverlapPositionStereo()}},{key:"seekBestOverlapPositionStereo",value:function(){var t,e,i,n=0;for(this.preCalculateCorrelationReferenceStereo(),t=0,e=Number.MIN_VALUE;n<this.seekLength;n+=1)(i=this.calculateCrossCorrelationStereo(2*n,this.refMidBuffer))>e&&(e=i,t=n);return t}},{key:"seekBestOverlapPositionStereoQuick",value:function(){var t,e,i,n,r,o=0;for(this.preCalculateCorrelationReferenceStereo(),e=Number.MIN_VALUE,t=0,n=0,r=0;o<4;o+=1){for(var s=0;U[o][s]&&!((r=n+U[o][s])>=this.seekLength);)(i=this.calculateCrossCorrelationStereo(2*r,this.refMidBuffer))>e&&(e=i,t=r),s+=1;n=t}return t}},{key:"preCalculateCorrelationReferenceStereo",value:function(){for(var t,e,i=0;i<this.overlapLength;i+=1)e=i*(this.overlapLength-i),t=2*i,this.refMidBuffer[t]=this.midBuffer[t]*e,this.refMidBuffer[t+1]=this.midBuffer[t+1]*e}},{key:"calculateCrossCorrelationStereo",value:function(t,e){var i=this._inputBuffer.vector;t+=this._inputBuffer.startIndex;for(var n,r=0,o=2,s=2*this.overlapLength;o<s;o+=2)r+=i[n=o+t]*e[o]+i[n+1]*e[o+1];return r}},{key:"overlap",value:function(t){this.overlapStereo(2*t)}},{key:"overlapStereo",value:function(t){var e=this._inputBuffer.vector;t+=this._inputBuffer.startIndex;for(var i,n,r,o,s,a=this._outputBuffer.vector,u=this._outputBuffer.endIndex,l=0,c=1/this.overlapLength;l<this.overlapLength;l+=1)n=(this.overlapLength-l)*c,r=l*c,o=(i=2*l)+t,a[(s=i+u)+0]=e[o+0]*r+this.midBuffer[i+0]*n,a[s+1]=e[o+1]*r+this.midBuffer[i+1]*n}},{key:"process",value:function(){var t,e,i;if(null===this.midBuffer){if(this._inputBuffer.frameCount<this.overlapLength)return;this.midBuffer=new Float32Array(2*this.overlapLength),this._inputBuffer.receiveSamples(this.midBuffer,this.overlapLength)}for(;this._inputBuffer.frameCount>=this.sampleReq;){t=this.seekBestOverlapPosition(),this._outputBuffer.ensureAdditionalCapacity(this.overlapLength),this.overlap(Math.floor(t)),this._outputBuffer.put(this.overlapLength),(e=this.seekWindowLength-2*this.overlapLength)>0&&this._outputBuffer.putBuffer(this._inputBuffer,t+this.overlapLength,e);var n=this._inputBuffer.startIndex+2*(t+this.seekWindowLength-this.overlapLength);this.midBuffer.set(this._inputBuffer.vector.subarray(n,n+2*this.overlapLength)),this.skipFract+=this.nominalSkip,i=Math.floor(this.skipFract),this.skipFract-=i,this._inputBuffer.receive(i)}}}]),s}(),Q=function(t,e){return(t>e?t-e:e-t)>1e-10},G=function(){function e(){t(this,e),this.transposer=new H(!1),this.stretch=new W(!1),this._inputBuffer=new Y,this._intermediateBuffer=new Y,this._outputBuffer=new Y,this._rate=0,this._tempo=0,this.virtualPitch=1,this.virtualRate=1,this.virtualTempo=1,this.calculateEffectiveRateAndTempo()}return i(e,[{key:"clear",value:function(){this.transposer.clear(),this.stretch.clear()}},{key:"clone",value:function(){var t=new e;return t.rate=this.rate,t.tempo=this.tempo,t}},{key:"rate",get:function(){return this._rate},set:function(t){this.virtualRate=t,this.calculateEffectiveRateAndTempo()}},{key:"rateChange",set:function(t){this._rate=1+.01*t}},{key:"tempo",get:function(){return this._tempo},set:function(t){this.virtualTempo=t,this.calculateEffectiveRateAndTempo()}},{key:"tempoChange",set:function(t){this.tempo=1+.01*t}},{key:"pitch",set:function(t){this.virtualPitch=t,this.calculateEffectiveRateAndTempo()}},{key:"pitchOctaves",set:function(t){this.pitch=Math.exp(.69314718056*t),this.calculateEffectiveRateAndTempo()}},{key:"pitchSemitones",set:function(t){this.pitchOctaves=t/12}},{key:"inputBuffer",get:function(){return this._inputBuffer}},{key:"outputBuffer",get:function(){return this._outputBuffer}},{key:"calculateEffectiveRateAndTempo",value:function(){var t=this._tempo,e=this._rate;this._tempo=this.virtualTempo/this.virtualPitch,this._rate=this.virtualRate*this.virtualPitch,Q(this._tempo,t)&&(this.stretch.tempo=this._tempo),Q(this._rate,e)&&(this.transposer.rate=this._rate),this._rate>1?this._outputBuffer!=this.transposer.outputBuffer&&(this.stretch.inputBuffer=this._inputBuffer,this.stretch.outputBuffer=this._intermediateBuffer,this.transposer.inputBuffer=this._intermediateBuffer,this.transposer.outputBuffer=this._outputBuffer):this._outputBuffer!=this.stretch.outputBuffer&&(this.transposer.inputBuffer=this._inputBuffer,this.transposer.outputBuffer=this._intermediateBuffer,this.stretch.inputBuffer=this._intermediateBuffer,this.stretch.outputBuffer=this._outputBuffer)}},{key:"process",value:function(){this._rate>1?(this.stretch.process(),this.transposer.process()):(this.transposer.process(),this.stretch.process())}}]),e}(),J=function(){function e(i){t(this,e),this.buffer=i,this._position=0}return i(e,[{key:"dualChannel",get:function(){return this.buffer.numberOfChannels>1}},{key:"position",get:function(){return this._position},set:function(t){this._position=t}},{key:"extract",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.position=i;for(var n=this.buffer.getChannelData(0),r=this.dualChannel?this.buffer.getChannelData(1):this.buffer.getChannelData(0),o=0;o<e;o++)t[2*o]=n[o+i],t[2*o+1]=r[o+i];return Math.min(e,n.length-i)}}]),e}(),Z=function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:q,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:4096,r=t.createScriptProcessor(n,2,2),o=new Float32Array(2*n);return r.onaudioprocess=function(t){var r=t.outputBuffer.getChannelData(0),s=t.outputBuffer.getChannelData(1),a=e.extract(o,n);i(e.sourcePosition),0===a&&e.onEnd();for(var u=0;u<a;u++)r[u]=o[2*u],s[u]=o[2*u+1]},r},V=function(t){var e,i,n,r=Math.floor(t/60),o=t-60*r;return"".concat(r,":").concat((e=parseInt(o),n=n||"0",(e+="").length>=(i=2)?e:new Array(i-e.length+1).join(n)+e))},K=function(t){var e=this.timePlayed,i=this.sampleRate;if(this.sourcePosition=t,this.timePlayed=t/i,e!==this.timePlayed){var n=new CustomEvent("play",{detail:{timePlayed:this.timePlayed,formattedTimePlayed:this.formattedTimePlayed,percentagePlayed:this.percentagePlayed}});this._node.dispatchEvent(n)}},X=function(){function e(i,n,r){var o=this,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:q;t(this,e),this._soundtouch=new G;var a=new J(n);this.timePlayed=0,this.sourcePosition=0,this._filter=new N(a,this._soundtouch,s),this._node=Z(i,this._filter,(function(t){return K.call(o,t)}),r),this.tempo=1,this.rate=1,this.duration=n.duration,this.sampleRate=i.sampleRate,this.listeners=[]}return i(e,[{key:"formattedDuration",get:function(){return V(this.duration)}},{key:"formattedTimePlayed",get:function(){return V(this.timePlayed)}},{key:"percentagePlayed",get:function(){return 100*this._filter.sourcePosition/(this.duration*this.sampleRate)},set:function(t){this._filter.sourcePosition=parseInt(t*this.duration*this.sampleRate),this.sourcePosition=this._filter.sourcePosition,this.timePlayed=this.sourcePosition/this.sampleRate}},{key:"node",get:function(){return this._node}},{key:"pitch",set:function(t){this._soundtouch.pitch=t}},{key:"pitchSemitones",set:function(t){this._soundtouch.pitchSemitones=t}},{key:"rate",set:function(t){this._soundtouch.rate=t}},{key:"tempo",set:function(t){this._soundtouch.tempo=t}},{key:"connect",value:function(t){this._node.connect(t)}},{key:"disconnect",value:function(){this._node.disconnect()}},{key:"on",value:function(t,e){this.listeners.push({name:t,cb:e}),this._node.addEventListener(t,(function(t){return e(t.detail)}))}},{key:"off",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,i=this.listeners;e&&(i=i.filter((function(t){return t.name===e}))),i.forEach((function(e){t._node.removeEventListener(e.name,(function(t){return e.cb(t.detail)}))}))}}]),e}(),$=function(){function e(){t(this,e),this.fns={any:[]}}return i(e,[{key:"has",value:function(t){return t in this.fns&&this.fns[t].length>0||this.fns.any.length>0}},{key:"on",value:function(t,e){return t in this.fns==!1&&(this.fns[t]=[]),this.fns[t].push(e),e}},{key:"fire",value:function(t,e,i){return this.fns.any.concat(t in this.fns?this.fns[t]:[]).forEach((function(n){return n(e,i,t)})),this}},{key:"off",value:function(t){for(var e in this.fns)for(var i=this.fns[e],n=0;n<i.length;n++)if(i[n]===t)return i.splice(n,1),!0;return!1}},{key:"once",value:function(t,e){var i=this;return this.on(t,(function t(n,r,o){e(n,r,o),i.off(t)})),e}}]),e}(),tt=function(t){if(t.on&&t.off)return t;var e=new $,i=new Proxy(t,{get:function(t,n){if(n in t){if(t.constructor===Array){var r=i;"pop"===n?r=t[t.length-1]:"shift"===n&&(r=t[0]),"push"!==n&&"length"!==n&&e.fire(n,r)}return t[n]}return"on"===n?e.on.bind(e):"once"===n?e.once.bind(e):"off"===n?e.off.bind(e):void 0},set:function(t,i,n){return t.constructor===Array?"length"!==i&&e.fire("change",n):e.has(i)&&e.fire(i,n,t[i]),t[i]=n,!0}});return i},et=function(t){t.keyColor>=0&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.drawImage(t.canvas,0,0,t.canvas.width,t.canvas.height,0,0,this.canvas.width,this.canvas.height)},it=function(t,e){t.clearRect(0,0,e.width,e.height)},nt=function(t){var e=this;return this.shifter&&this.shifter.off(),this.audio.decodeAudioData(t).then((function(t){e.shifter=tt(new X(e.audio,t,1024,(function(){e.stop()}))),e.shifter.on("play",(function(t){e.props.timePlayed=t.formattedTimePlayed,e.props.percentagePlayed=t.percentagePlayed,e.player.sync(1e3*t.timePlayed-800)})),e.shifter.pitch=1,e.props.trackLength=e.shifter.formattedDuration})).catch((function(t){return Promise.reject(new Error("There was an error decoding the audio file",t))}))},rt=function(t){var e=new R;return t?(this.player.load(Array.from(t)),e.resolve()):e.reject(new Error("There was an error loading the video file")),e.promise},ot=function(t,e,i,n,r,o){for(var s=e.split(" "),a="",u=0;u<s.length;u++){var l=a+s[u]+" ";t.measureText(l).width>r&&u>0?(t.fillText(a.trim(),i,n),a=s[u]+" ",n+=o):a=l}t.fillText(a.trim(),i,n)},st=function(){var t=this.ctx,e=this.canvas,i=e.width-10,n=i/2,r=60;t.font="30px sans-serif",t.fillStyle="#fff",t.textAlign="center",ot(t,this.tag.title,n,r,i,30),t.font="20px sans-serif",r=e.height-60,ot(t,"by ".concat(this.tag.artist),n,r,i,30)},at=function(t){if(this.tag=t&&t.tags,this.tag)return st.call(this)},ut=function(t){var e=this,i=[];return i.push(nt.call(this,t[0])),i.push(rt.call(this,t[1])),Promise.all(i).then((function(){e.props.status="File Loaded",e.props.loaded=!0,at.call(e,t[2])})).catch((function(t){return e.props.status="File Loading Failed",Promise.reject(t)})).then((function(){e.props.loading=!1}))},lt=function(t){this.gainNode.gain.value=t},ct=function(){function e(i){var r,o,s,a=this;if(t(this,e),n(this,"audio",null),n(this,"gainNode",null),n(this,"shifter",null),n(this,"wrapper",null),n(this,"player",null),n(this,"currentSize",1),n(this,"canvas",null),n(this,"ctx",null),n(this,"props",tt({status:"",loaded:!1,loading:!1,isPlaying:!1,timePlayed:"0:00",trackLength:"0:00",percentagePlayed:0,songVolume:1,destroy:!1})),this.wrapper=document.querySelector(i),!this.wrapper)throw new Error('CDGPlayer: and element was not found with the "'.concat(i,'" selector'));this.wrapper.classList.add("cdg-video-wrapper"),this.canvas=(r=300,o=216,(s=document.createElement("canvas")).width=r,s.height=o,s),this.canvas.classList.add("cdg-video-player"),this.ctx=function(t){var e=t.getContext("2d");return e.webkitImageSmoothingEnabled=!1,e.mozImageSmoothingEnabled=!1,e.msImageSmoothingEnabled=!1,e.imageSmoothingEnabled=!1,e}(this.canvas),this.player=new O({afterRender:function(t){return et.call(a,t)}}),this.wrapper.appendChild(this.canvas);var u=document.createElement("div");u.classList.add("titleImage"),this.wrapper.appendChild(u),this.onloaded=this.props.on("loaded",(function(t){t?u.classList.add("hide"):u.classList.remove("hide")})),this.audio=new(window.AudioContext||window.webkitAudioContext),this.gainNode=this.audio.createGain(),this.onvolume=this.props.on("songVolume",(function(t){lt.call(a,t)})),this.props.songVolume=1}return i(e,[{key:"destroy",value:function(){this.wrapper.classList.remove("cdg-video-wrapper"),this.stop(),this.gainNode.disconnect(),this.shifter&&this.shifter.off(),this.shifter=null,this.gainNode=null,this.audio=null,this.canvas.remove(),this.props.destroy=!0,this.props.off("onvolume")}},{key:"load",value:function(t){var e,i=this;if(this.stop(),it(this.ctx,this.canvas),this.props.loading=!0,"string"==typeof t){if(!t.toLowerCase().endsWith(".zip"))return this.props.loading=!1,this.props.status="".concat(t,' doesn\'t appear to be a ".zip" file.'),Promise.reject(this.props.status);this.props.status="Retrieving File...",e=j.loadZipFile(t)}else this.props.status="Loading File...",e=j.loadFileBuffer(t);return e.then((function(t){return ut.call(i,t)})).catch((function(t){return Promise.reject(t)}))}},{key:"togglePlay",value:function(){this.props.isPlaying?this.pause():this.start()}},{key:"start",value:function(){var t=this;it.call(this,this.ctx,this.canvas),this.shifter.connect(this.gainNode),this.gainNode.connect(this.audio.destination),this.audio.resume().then((function(){t.props.isPlaying=!0,t.player.play()}))}},{key:"pause",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.props.isPlaying=t,this.shifter.disconnect(),this.player.stop()}},{key:"stop",value:function(){this.shifter&&(this.pause(),this.changePlayerPosition(0),st.call(this))}},{key:"changePlayerPosition",value:function(t){t=t<0?0:t>100?100:t,this.shifter.percentagePlayed=t,this.props.percentagePlayed=this.shifter.percentagePlayed,this.props.timePlayed=this.shifter.formattedTimePlayed,this.player.reset(),t||(this.props.isPlaying=!1,this.props.timePlayed="0:00")}},{key:"changeKey",value:function(t){t=t<-7?-7:t>7?7:t,this.shifter.pitchSemitones=t,this.shifter.tempo=1}},{key:"volume",value:function(t){var e=+(this.gainNode.gain.value+t).toFixed(2);this.props.songVolume=e<0?0:e>1?1:e}},{key:"toggleMute",value:function(){var t=this.gainNode.gain.value;this.props.songVolume=t?0:this.fallbackVolume,this.fallbackVolume=t}}]),e}(),ht='<div class="cdg-controls"> <span class="playControl"> <button class="playButton" disabled><i class="icofont-play-alt-1"></i></button> </span> <span class="timePlayed"></span> <div class="progress-container"> <progress class="progressMeter" ng-disabled="$ctrls.loading" value="0" max="100"></progress> </div> <span class="trackLength"></span> <span> <input type="number" class="pitch" step="1" min="-7" max="7" value="0" disabled> </span> <span class="volumeControl"> <div> <button class="volumeButton" id="song_volume_button" disabled><i class="icofont-audio"></i></button> <div class="volumeSlider"> <input type="range" min="0.00" max="1.00" step="0.01" class="volumeRange" id="song_volume"> </div> </div> </span> \x3c!-- <span class="volumeControl">\n <div>\n <button class="volumeButton" id="mic_volume_button"><i class="icofont-mic"></i></button>\n <div class="volumeSlider">\n <input type="range" min="0.0" max="1" step="0.1" class="volumeRange" id="mic_volume" />\n </div>\n </div>\n </span> --\x3e </div>';p('@font-face{font-family:IcoFont;font-style:normal;font-weight:400;src:url("data:font/woff2;base64,d09GMgABAAAAAAXMAAsAAAAACvwAAAWAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHFQGVgCDOAqJVIgXATYCJAMYCw4ABCAFhAoHVRtpCcgehXEsbKBS2ff0eD//bvrn5iZI8AbZnNUErxlUN8cqSmkqFgaZOO3UCHtqgjxR+3rwwHPL34lFvSywNDsu4naDTHgW0YYjGp7xP/z9TH/a1mBl6RiRb1HUZZE0HUfhgOLuLKK4wQ7wRPkUxHOgigy6cB9AAGgWDYilba0XlOcAPwdLkIJhBOpidJ4cD4BEtyAZVESiFxH2jb5DZ4ACxJV4DABO5BnoBdaAEEejIggutHFtHYWm//W/CtidOUJv5IH4ckEAAC0PMIDS49jQmegeg8tYKYx2IqQaIG+WIMBPN/xy069CRoKvR2KySwESdPgvD4BCwggIoBQCjVzC15ooN00aS2rtDSIHkOCXmzgAg19jJiBErSDKHo5BtOAuGoA2ACKHgFAKEKjwvQm47NAq9E61QafXiRardXL5+OXJZOWLaZT2zy+54plU4rWnll3mg0QwT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nqVMp0wZv4l5Xu+J2xV8Oj8gBoAnrT/vLVzrRWGrWs7kOpbv+YrefoAj2Zx0Tg7j/4tPLju5vMuBGbs7D+2Cc0/1+62WwB4nGNgZGBgAOIP9qt64vltvjJwM78AijBcPxB1Akb///8/i/kFczCQy8HABBIFAJztDyEAeJxjYGRgYA76nwUkX/z/DyIZgCIogA0Ai8sFm3icY37BwMCMgv//B9EAUrkHgQAAAAAAAACEAUwB3AIgAmoAAHicY2BkYGBgY+hkYGUAASYg5gJCBob/YD4DABbAAasAeJxdkE1qwzAQhZ/zS2MIhdKsStGqXRScn2UOkJBtFoYuHUd2HGzLyEogPUFP0BP0FD1A6bH6bKaLRkLSN2+epJEA3OIbHprmYdjOTeuQh8Jd0li4R74X7sPHg/CA+rPwCC8IhH3c4ZUneL0bKmPkwh3ym3CX/C7cI38I9zHBp/CA+pfwCCF+hH08eY+b2KxM6bY6PeWRzWKTMJIl1LbOTKnmwUyUtS61jZzeq91F1ed04VyiEmsK1Ryi89yoypqjjl1wcK5aTqeJ6EFsCmwQw2DFUcJhC40UJ74rgkXW5hLJ/Y9COi1qqk2sMOcfza48a3rK1hcx0tjTt8OFc40z71lQdXQrDss9BemvEs0acrJC1eaOVGLqAQ7trgpLTNmTK3/QVlD8AsE9WlYAeJxjYGKAAC4G7ICNkYmRmZGFkZWRjZGdgTk3M5kDiHVzS0tSWRNLUzLzuQpyEit1E3NKdA1ZCxJLi1MZGAD/FgxfAAA=") format("woff")}[class*=" icofont-"],[class^=icofont-]{speak:none;word-wrap:normal;-webkit-font-feature-settings:"liga";-webkit-font-smoothing:antialiased;direction:ltr;font-family:IcoFont!important;font-style:normal;font-variant:normal;font-weight:400;line-height:1;text-transform:none;white-space:nowrap}.icofont-mic:before{content:"\\ef95"}.icofont-mic-mute:before{content:"\\ef94"}.icofont-audio:before{content:"\\eea8"}.icofont-play-alt-1:before{content:"\\eca6"}.icofont-pause:before{content:"\\eca5"}.cdg-controls .playButton>i,.cdg-controls .volumeButton>i,.icofont-md{font-size:2em}.cdg-controls .playButton>i,.cdg-controls .volumeButton>i,.icofont-fw{text-align:center;width:1.25em}.cdg-controls .pitch[disabled],.cdg-controls .playButton[disabled],.cdg-controls .volumeButton[disabled],.mute{color:#a9a9a9}.cdg-controls{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-webkit-box-align:center;-ms-flex-align:center;-webkit-box-pack:center;-ms-flex-pack:center;align-items:center;display:-ms-flexbox;display:-webkit-box;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:nowrap;flex-wrap:nowrap;font-size:1.25em;height:40px;justify-content:center;position:relative;width:100%}.cdg-controls>div,.cdg-controls>span{margin:3px 5px}.cdg-controls>div:first-child,.cdg-controls>span:first-child{margin-left:0}.cdg-controls>div:last-child,.cdg-controls>span:last-child{margin-right:0}.cdg-controls .playButton,.cdg-controls .volumeButton{border:none;border-radius:3px;height:34px;outline:none;padding:5px;width:34px}.cdg-controls .playButton[disabled],.cdg-controls .volumeButton[disabled]{cursor:not-allowed}.cdg-controls .volumeControl>div{height:100%;position:relative;width:100%}.cdg-controls .volumeControl>div:hover .volumeSlider{display:block}.cdg-controls .volumeControl>div .volumeSlider{display:none;left:-55px;padding:10px 20px;position:absolute;top:-75px;-webkit-transform:rotate(270deg);transform:rotate(270deg);width:100px;z-index:100}.cdg-controls .volumeControl>div .volumeSlider.under{top:75px;-webkit-transform:rotate(90deg);transform:rotate(90deg)}.cdg-controls .volumeControl>div .volumeSlider:hover{display:block}.cdg-controls .volumeControl>div .volumeSlider .volumeRange{-webkit-appearance:none;background:#d3d3d3;border:1px solid;border-radius:2.5px;height:5px;opacity:.7;outline:none;-webkit-transition:.2s;-webkit-transition:opacity .2s;transition:opacity .2s;width:100%}.cdg-controls .volumeControl>div .volumeSlider .volumeRange:hover{opacity:1}.cdg-controls .volumeControl>div .volumeSlider .volumeRange::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;background:#fff;border:1px solid blue;border-radius:50%;cursor:pointer;height:15px;width:15px}.cdg-controls .pitch{font-size:.8em;height:28px;text-align:right}.cdg-controls .pitch[disabled]{cursor:not-allowed}.cdg-controls .progress-container{-webkit-box-flex:0;display:inline-block;-ms-flex:0 1 auto;flex:0 1 auto;position:relative;width:100%}.cdg-controls .progress-container progress{-webkit-appearance:none;-moz-appearance:none;appearance:none;height:1em;width:100%}.cdg-controls .progress-container progress::-webkit-progress-bar{background-color:#eee;border-radius:.5em;-webkit-box-shadow:inset 0 2px 5px rgba(0,0,0,.25);box-shadow:inset 0 2px 5px rgba(0,0,0,.25)}.cdg-controls .progress-container progress::-webkit-progress-value{background-image:-webkit-linear-gradient(-45deg,transparent 33%,transparent 0,rgba(0,0,0,.1) 66%,transparent 0),-webkit-linear-gradient(top,hsla(0,0%,100%,.25),rgba(0,0,0,.25)),-webkit-linear-gradient(left,#09c,#f44);background-size:35px 20px,100% 100%,100% 100%;border-radius:.5em}');var ft=function(t){var e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild},pt=function(){var t=this,e=this.player.props;this.onloaded=e.on("loaded",(function(e){e?(t.playBtn.removeAttribute("disabled"),t.pitch.removeAttribute("disabled"),t.volumeBtn.removeAttribute("disabled")):(t.playBtn.setAttribute("disabled","disabled"),t.pitch.setAttribute("disabled","disabled"),t.volumeBtn.setAttribute("disabled","disabled"))})),this.ontimeplayed=e.on("timePlayed",(function(e,i){e!==i&&(t.timePlayed.innerHTML=e)})),this.onpercentageplayed=e.on("percentagePlayed",(function(e,i){e!==i&&(t.progress.value=e)})),this.ontracklength=e.on("trackLength",(function(e,i){e!==i&&(t.trackLength.innerHTML=e)})),this.ondestroy=e.on("destroy",(function(e){e&&dt.call(t)})),this.onplay=e.on("isPlaying",(function(e){t.playIcn.classList.remove("icofont-play-alt-1","icofont-pause"),t.playIcn.classList.add(e?"icofont-pause":"icofont-play-alt-1")})),this.onvolume=e.on("songVolume",(function(e){var i=t.volumeIcn;if(t.volumeSlider.value=e,e)return i.classList.contains("mute")?void i.classList.remove("mute"):void 0;i.classList.add("mute")})),this.playBtn.addEventListener("click",(function(){return t.player.togglePlay()})),this.progress.addEventListener("click",(function(e){return vt.call(t,e)})),this.pitch.addEventListener("change",(function(){return mt.call(t)})),this.volumeSlider.addEventListener("change",(function(){return gt.call(t)}))},dt=function(){var t=this,e=this.player.props;e.off(this.onloaded),e.off(this.ontimeplayed),e.off(this.onpercentageplayed),e.off(this.ontracklength),e.off(this.ondestroy),e.off(this.onplay),e.off(this.onvolume),this.playBtn.removeEventListener("click",(function(){return t.player.togglePlay()})),this.progress.removeEventListener("click",(function(e){return vt.call(t,e)})),this.pitch.removeEventListener("change",(function(){return mt.call(t)})),this.volumeSlider.removeEventListener("change",(function(){return gt.call(t)}))},vt=function(t){var e=t.target.getBoundingClientRect(),i=(t.pageX-e.x)/t.target.offsetWidth;this.player.changePlayerPosition(i)},mt=function(){var t=this.pitch.value;isNaN(t)?this.pitch.value=this.fallbackPitch:(this.fallbackPitch=t<-7?-7:t>7?7:t,this.player.changeKey(this.fallbackPitch))},gt=function(){this.player.props.songVolume=+(parseFloat(this.volumeSlider.value)+0).toFixed(2)},yt=i((function e(i,r){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{position:"bottom"};t(this,e),n(this,"controls",ft(ht)),n(this,"player",null),n(this,"playBtn",null),n(this,"playIcn",null),n(this,"timePlayed",null),n(this,"progress",null),n(this,"trackLength",null),n(this,"pitch",null);var s=document.querySelector(i);s.appendChild(this.controls),this.player=r;var a=this.player.props;if(this.playBtn=this.controls.querySelector(".playButton"),this.playIcn=this.playBtn.querySelector("i"),this.timePlayed=this.controls.querySelector(".timePlayed"),this.timePlayed.innerHTML=a.timePlayed,this.progress=this.controls.querySelector(".progressMeter"),this.progress.value=a.percentagePlayed,this.trackLength=this.controls.querySelector(".trackLength"),this.trackLength.innerHTML=a.trackLength,this.pitch=this.controls.querySelector(".pitch"),this.fallbackPitch=0,!v.includes(o.position))throw new Error("Panel Position must be either 'top' or 'bottom'.");if(this.volumeBtn=this.controls.querySelector("#song_volume_button"),this.volumeIcn=this.volumeBtn.querySelector("i"),this.volumeSlider=this.controls.querySelector("#song_volume"),this.volumeSlider.value=a.songVolume,"top"===o.position){var u=this.controls.querySelector(".volumeSlider");u.classList.add("under")}pt.call(this)}));export{yt as CDGControls,ct as CDGPlayer};
//# sourceMappingURL=cdgplayer.js.map
{
"name": "cdgplayer",
"version": "0.1.9",
"version": "0.1.10",
"description": "A browser based HTML5/JS karaoke 'Player', that takes a zip file containing an mp3 and cdg file, allowing the user to render and play directly in the browser.",

@@ -35,34 +35,32 @@ "main": "dist/cdgplayer.js",

"devDependencies": {
"@babel/core": "7.15.8",
"@babel/eslint-parser": "7.15.8",
"@babel/plugin-proposal-class-properties": "7.14.5",
"@babel/preset-env": "7.15.8",
"@commitlint/cli": "13.2.1",
"@commitlint/config-conventional": "13.2.0",
"@rollup/plugin-babel": "5.3.0",
"@rollup/plugin-commonjs": "21.0.0",
"@rollup/plugin-eslint": "8.0.1",
"@rollup/plugin-node-resolve": "13.0.5",
"autoprefixer": "10.3.7",
"@babel/core": "7.17.10",
"@babel/eslint-parser": "7.17.0",
"@babel/plugin-proposal-class-properties": "7.16.7",
"@babel/preset-env": "7.17.10",
"@commitlint/cli": "16.2.4",
"@commitlint/config-conventional": "16.2.4",
"@rollup/plugin-babel": "5.3.1",
"@rollup/plugin-commonjs": "22.0.0",
"@rollup/plugin-eslint": "8.0.2",
"@rollup/plugin-node-resolve": "13.3.0",
"autoprefixer": "10.4.7",
"babel-eslint": "10.1.0",
"connect": "3.7.0",
"eslint": "8.0.1",
"eslint-plugin-class-property": "1.1.0",
"eslint": "8.14.0",
"localip": "1.0.0",
"node-sass": "6.0.1",
"open": "8.3.0",
"postcss": "8.3.9",
"open": "8.4.0",
"postcss": "8.4.13",
"postcss-assets": "6.0.0",
"prettier": "2.4.1",
"prettier": "2.6.2",
"regenerator-runtime": "0.13.9",
"rollup": "2.58.0",
"rollup": "2.71.1",
"rollup-plugin-cleanup": "3.2.1",
"rollup-plugin-clear": "2.0.7",
"rollup-plugin-embed-css": "1.0.21",
"rollup-plugin-embed-css": "1.0.24",
"rollup-plugin-html": "0.2.1",
"rollup-plugin-postcss": "4.0.1",
"rollup-plugin-postcss": "4.0.2",
"rollup-plugin-terser": "7.0.2",
"sass": "1.43.2",
"serve-static": "1.14.1",
"soundtouchjs": "0.1.29",
"sass": "1.51.0",
"serve-static": "1.15.0",
"soundtouchjs": "0.1.30",
"standard-version": "9.3.2"

@@ -72,3 +70,3 @@ },

"jsmediatags": "3.9.7",
"jszip": "3.7.1",
"jszip": "3.9.1",
"jszip-utils": "0.1.0"

@@ -75,0 +73,0 @@ },

Sorry, the diff of this file is not supported yet