react-orchestra
Version:
A toolbox to build interactive and smart instruments on the web and mobile.
6 lines • 426 kB
JavaScript
/*!
* InstrumentJS v1.0.1
* MIT Licensed
*/
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.InstrumentJS=t():e.InstrumentJS=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0,t.InstrumentHelpers=t.INSTRUMENT_NAMES=t.Note=t.Instrument=t.AudioContext=void 0;var i=n(2),a=r(i),o=n(3),u=r(o),s=n(36),c=r(s),l=n(59),f=r(l),h=n(40),p=r(h);t.AudioContext=a.default,t.Instrument=u.default,t.Note=c.default,t.INSTRUMENT_NAMES=f.default,t.InstrumentHelpers=p.default},function(e,t){"use strict";t.__esModule=!0;var n=function(){var e=window.AudioContext||window.webkitAudioContext||!1;return e?new e:(alert("Sorry but the WebAudio API is not supported on this browser. Please consider using Chrome or Safari for the best experience "),null)},r=n();t.default=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}t.__esModule=!0;var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o=n(4),u=r(o),s=n(19),c=r(s),l=n(23),f=r(l),h=n(25),p=(r(h),n(34)),d=(r(p),n(36)),m=r(d),v=n(2),g=r(v),_=n(37),b=(r(_),n(38)),y=(r(b),n(39)),w=(r(y),n(40)),A=function(e){return new c.default(function(t){return setTimeout(t,e)})};window.delay=function(e){return new c.default(function(t){return setTimeout(t,e)})};var T=function(){function e(){i(this,e),this.instruments={},this.ac=g.default,this.playingNotes={},this.isPlayingMelody=!1}return e.prototype.get=function(e){var t=this;return new c.default(function(n,r){return f.default.has(t.instruments,e)?t.instruments[e].promise.done?n(t.instruments[e].instrument):t.instruments[e].promise.then(function(e){return n(e)}):(t.instruments[e]={},t.instruments[e].isLoading=!0,t.instruments[e].instrument={},t.instruments[e].promise=u.default.instrument(g.default,e,{nameToUrl:function(e,t,n){n="ogg"===n?n:"mp3",t="FluidR3_GM"===t?t:"MusyngKite";var r="https://d2ovwkm0xvqw0n.cloudfront.net/",i=""+r+t+"/"+e+"-"+n+".js";return i}}).then(function(r){return t.instruments[e].instrument=r,t.instruments[e].promise.done=!0,t.instruments[e].isLoading=!1,n(r),r}).catch(function(t){console.log("ERRROR ",t),r("Couldn't load instrument "+e+". Error : "+JSON.stringify(t))}),t.instruments[e].promise.done=!1,t.instruments[e].promise)})},e.prototype.startPlayingNote=function(e){var t=this,n=e.payload.id;return n in this.playingNotes||(this.playingNotes[n]=[]),A(e.payload.startTimeInMS).then(function(){t.playingNotes[n].push(t.get(e.payload.instrumentName).then(function(t){return t.start(e.payload.name,null,{loop:!0,gain:e.payload.gain,duration:e.payload.duration===-1?9999999:e.payload.duration/1e3})}));var r=t.playingNotes[n][t.playingNotes[n].length-1];return e.payload.durationInMS!==-1?A(e.payload.durationInMS).then(function(){return r}).then(function(e){return e.stop()}):r})},e.prototype.stopPlayingNote=function(e){if(!e.payload)return c.default.resolve(!1);var t=e.payload.id;if("undefined"==typeof this.playingNotes[t])return c.default.resolve(!0);var n=this.playingNotes[t],r=n[n.length-1].then();return this.playingNotes[t].pop(),0===this.playingNotes[t].length&&delete this.playingNotes[t],A(e.payload.fadeDurationInMS).then(function(){return r}).then(function(e){e.stop()}).catch(function(e){alert("Failed stopping audio. Unsupported Browser ?"+JSON.stringify(e))})},e.prototype.startPlayingChordByNoteNames=function(e,t){var n=this;return c.default.map(e,function(e){var r=new m.default(a({},t,{name:e}));return n.startPlayingNote(r)})},e.prototype.stopPlayingChordByNoteNames=function(e,t){var n=this;return c.default.map(e,function(e){var r=new m.default(a({},t,{name:e}));return n.stopPlayingNote(r)})},e.prototype.startPlayingChordByChordName=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=(0,w.getNoteNamesFromChordName)(e,t);return this.startPlayingChordByNoteNames(r,n)},e.prototype.stopPlayingChordByChordName=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=(0,w.getNoteNamesFromChordName)(e,t);return this.stopPlayingChordByNoteNames(r,n)},e.prototype.play=function(e,t){var n=this;this.isPlayingMelody=!0;var r=e[0].payload.startTimeInMS;return c.default.map(e,function(e,t){var i=e.payload.startTimeInMS-r;return window.delay(i).then(function(){if(n.isPlayingMelody===!1)throw new function(){return{code:"STOPPED_PLAYING"}};return n.startPlayingNote(e)}).then(function(){return window.delay(e.payload.durationInMS)}).then(function(){return n.stopPlayingNote(e)}).catch(function(e){if(e.code&&"STOPPED_PLAYING"===e.code)return null;throw e})})},e.prototype.stop=function(e,t){var n=this;return this.isPlayingMelody=!1,c.default.map(e,function(e,t){return n.stopPlayingNote(e.payload.instrumentName,e.payload.noteName)})},e}();t.default=T},function(e,t,n){"use strict";function r(e,t,n){if(1===arguments.length)return function(t,n){return r(e,t,n)};var s=n||{},c=s.isSoundfontURL||i,l=s.nameToUrl||a,f=c(t)?t:l(t,s.soundfont,s.format);return o(e,f,{only:s.only||s.notes}).then(function(n){var r=u(e,n,s).connect(e.destination);return r.url=f,r.name=t,r})}function i(e){return/\.js(\?.*)?$/i.test(e)}function a(e,t,n){return n="ogg"===n?n:"mp3",t="FluidR3_GM"===t?t:"MusyngKite","https://gleitz.github.io/midi-js-soundfonts/"+t+"/"+e+"-"+n+".js"}var o=n(5),u=n(8),s=n(17);s.instrument=r,s.nameToUrl=a,"object"==typeof e&&e.exports&&(e.exports=s),"undefined"!=typeof window&&(window.Soundfont=s)},function(e,t,n){"use strict";function r(e){return function(t){return"string"==typeof t&&e.test(t)}}function i(e,t){return"string"==typeof e?e+t:"function"==typeof e?e(t):t}function a(e,t,n,r){var i=o(t)?u:y(t)?s:c(t)?l:w(t)?f:h(t)?p:A(t)?d:T(t)?m:C(t)?v:null,a=n||{};return i?i(e,t,a):r?Promise.resolve(r):Promise.reject("Source not valid ("+t+")")}function o(e){return e instanceof ArrayBuffer}function u(e,t,n){return new Promise(function(n,r){e.decodeAudioData(t,function(e){n(e)},function(){r("Can't decode audio data ("+t.slice(0,30)+"...)")})})}function s(e,t,n){var r=i(n.from,t);return a(e,a.fetch(r,"arraybuffer"),n)}function c(e){return e&&"function"==typeof e.then}function l(e,t,n){return t.then(function(t){return a(e,t,n)})}function f(e,t,n){return Promise.all(t.map(function(t){return a(e,t,n,t)}))}function h(e){return e&&"object"==typeof e}function p(e,t,n){var r={},i=Object.keys(t).map(function(i){if(n.only&&n.only.indexOf(i)===-1)return null;var o=t[i];return a(e,o,n,o).then(function(e){r[i]=e})});return Promise.all(i).then(function(){return r})}function d(e,t,n){var r=i(n.from,t);return a(e,a.fetch(r,"text").then(JSON.parse),n)}function m(e,t,n){var r=t.indexOf(",");return a(e,_.decode(t.slice(r+1)).buffer,n)}function v(e,t,n){var r=i(n.from,t);return a(e,a.fetch(r,"text").then(g),n)}function g(e){var t=e.indexOf("MIDI.Soundfont.");if(t<0)throw Error("Invalid MIDI.js Soundfont format");t=e.indexOf("=",t)+2;var n=e.lastIndexOf(",");return JSON.parse(e.slice(t,n)+"}")}var _=n(6),b=n(7);a.fetch=b;var y=r(/\.(mp3|wav|ogg)(\?.*)?$/i),w=Array.isArray,A=r(/\.json(\?.*)?$/i),T=r(/^data:audio/),C=r(/\.js(\?.*)?$/i);"object"==typeof e&&e.exports&&(e.exports=a),"undefined"!=typeof window&&(window.loadAudio=a)},function(e,t){"use strict";function n(e){return e>64&&e<91?e-65:e>96&&e<123?e-71:e>47&&e<58?e+4:43===e?62:47===e?63:0}function r(e,t){for(var r,i,a=e.replace(/[^A-Za-z0-9\+\/]/g,""),o=a.length,u=t?Math.ceil((3*o+1>>2)/t)*t:3*o+1>>2,s=new Uint8Array(u),c=0,l=0,f=0;f<o;f++)if(i=3&f,c|=n(a.charCodeAt(f))<<18-6*i,3===i||o-f===1){for(r=0;r<3&&l<u;r++,l++)s[l]=c>>>(16>>>r&24)&255;c=0}return s}e.exports={decode:r}},function(e,t){"use strict";e.exports=function(e,t){return new Promise(function(n,r){var i=new XMLHttpRequest;t&&(i.responseType=t),i.open("GET",e),i.onload=function(){200===i.status?n(i.response):r(Error(i.statusText))},i.onerror=function(){r(Error("Network Error"))},i.send()})}},function(e,t,n){"use strict";function r(e,t,n){return s(u(o(a(i(e,t,n)))))}var i=n(9),a=n(11),o=n(12),u=n(14),s=n(15);"object"==typeof e&&e.exports&&(e.exports=r),"undefined"!=typeof window&&(window.SamplePlayer=r)},function(e,t,n){"use strict";function r(e,t,n){function r(t,n){return n.id=l++,f[n.id]=n,n.source.onended=function(){var t=e.currentTime;n.source.disconnect(),n.env.disconnect(),n.disconnect(),d.emit("ended",t,n.id,n)},n.id}function i(t,n,r){var i=e.createGain();return i.gain.value=0,i.connect(h),i.env=a(e,r,p),i.env.connect(i.gain),i.source=e.createBufferSource(),i.source.buffer=n,i.source.connect(i),i.source.loop=r.loop||p.loop,i.source.playbackRate.value=o(r.cents||p.cents),i.source.loopStart=r.loopStart||p.loopStart,i.source.loopEnd=r.loopEnd||p.loopEnd,i.stop=function(n){var r=n||e.currentTime;d.emit("stop",r,t);var a=i.env.stop(r);i.source.stop(a)},i}var u=!1,l=0,f={},h=e.createGain();h.gain.value=1;var p=Object.assign({},c,n),d={context:e,out:h,opts:p};return t instanceof AudioBuffer?d.buffer=t:d.buffers=t,d.start=function(t,n,a){if(d.buffer&&null!==t)return d.start(null,t,n);var o=t?d.buffers[t]:d.buffer;if(!o)return void console.warn("Buffer "+t+" not found.");if(!u)return void console.warn("SamplePlayer not connected to any node.");var c=a||s;n=Math.max(e.currentTime,n||0),d.emit("start",n,t,c);var l=i(t,o,c);return l.id=r(t,l),l.env.start(n),l.source.start(n),d.emit("started",n,l.id,l),c.duration&&l.stop(n+c.duration),l},d.play=function(e,t,n){return d.start(e,t,n)},d.stop=function(e,t){var n;return t=t||Object.keys(f),t.map(function(t){return(n=f[t])?(n.stop(e),n.id):null})},d.connect=function(e){return u=!0,h.connect(e),d},d.emit=function(e,t,n,r){d.onevent&&d.onevent(e,t,n,r);var i=d["on"+e];i&&i(t,n,r)},d}function i(e){return"number"==typeof e}function a(e,t,n){var r=u(e),a=t.adsr||n.adsr;return l.forEach(function(e,i){a?r[e]=a[i]:r[e]=t[e]||n[e]}),r.value.value=i(t.gain)?t.gain:i(n.gain)?n.gain:1,r}function o(e){return e?Math.pow(2,e/1200):1}var u=n(10),s={},c={gain:1,attack:.01,decay:.1,sustain:.9,release:.3,loop:!1,cents:0,loopStart:0,loopEnd:0},l=["attack","decay","sustain","release"];e.exports=r},function(e,t){function n(e){var t=e.createGain(),n=t._voltage=r(e),a=i(n),o=i(n),s=i(n);return t._startAmount=i(o),t._endAmount=i(s),t._multiplier=i(a),t._multiplier.connect(t),t._startAmount.connect(t),t._endAmount.connect(t),t.value=a.gain,t.startValue=o.gain,t.endValue=s.gain,t.startValue.value=0,t.endValue.value=0,Object.defineProperties(t,u),t}function r(e){var t=e.createBufferSource(),n=e.createBuffer(1,2,e.sampleRate);return n.getChannelData(0).set(s),t.buffer=n,t.loop=!0,t}function i(e){var t=e.context.createGain();return e.connect(t),t}function a(e){return Math.log(e+1)/Math.log(100)}function o(e,t,n,r,i){var a=t-e,o=r-n,u=i-n,s=u/o,c=e+s*a;return c<=e&&(c=e),c>=t&&(c=t),c}e.exports=n;var u={attack:{value:0,writable:!0},decay:{value:0,writable:!0},sustain:{value:1,writable:!0},release:{value:0,writable:!0},getReleaseDuration:{value:function(){return this.release}},start:{value:function(e){var t=this._multiplier.gain,n=this._startAmount.gain,r=this._endAmount.gain;this._voltage.start(e),this._decayFrom=this._decayFrom=e+this.attack,this._startedAt=e;var i=this.sustain;t.cancelScheduledValues(e),n.cancelScheduledValues(e),r.cancelScheduledValues(e),r.setValueAtTime(0,e),this.attack?(t.setValueAtTime(0,e),t.linearRampToValueAtTime(1,e+this.attack),n.setValueAtTime(1,e),n.linearRampToValueAtTime(0,e+this.attack)):(t.setValueAtTime(1,e),n.setValueAtTime(0,e)),this.decay&&t.setTargetAtTime(i,this._decayFrom,a(this.decay))}},stop:{value:function(e,t){t&&(e-=this.release);var n=e+this.release;if(this.release){var r=this._multiplier.gain,i=this._startAmount.gain,u=this._endAmount.gain;r.cancelScheduledValues(e),i.cancelScheduledValues(e),u.cancelScheduledValues(e);var s=a(this.release);if(this.attack&&e<this._decayFrom){var c=o(0,1,this._startedAt,this._decayFrom,e);r.linearRampToValueAtTime(c,e),i.linearRampToValueAtTime(1-c,e),i.setTargetAtTime(0,e,s)}u.setTargetAtTime(1,e,s),r.setTargetAtTime(0,e,s)}return this._voltage.stop(n),n}},onended:{get:function(){return this._voltage.onended},set:function(e){this._voltage.onended=e}}},s=new Float32Array([1,1])},function(e,t){function n(e,t){return function(n,r,i,a){e(n,r,i,a),t(n,r,i,a)}}e.exports=function(e){return e.on=function(t,r){if(1===arguments.length&&"function"==typeof t)return e.on("event",t);var i="on"+t,a=e[i];return e[i]=a?n(a,r):r,e},e}},function(e,t,n){"use strict";function r(e,t){return Object.keys(e).reduce(function(n,r){return n[t(r)]=e[r],n},{})}var i=n(13),a=function(e){return null!==e&&e!==[]&&e>=0&&e<129},o=function(e){return a(e)?+e:i.midi(e)};e.exports=function(e){if(e.buffers){var t=e.opts.map,n="function"==typeof t?t:o,i=function(e){return e?n(e)||e:null};e.buffers=r(e.buffers,i);var a=e.start;e.start=function(e,t,n){var r=i(e),o=r%1;return o&&(r=Math.floor(r),n=Object.assign(n||{},{cents:Math.floor(100*o)})),a(r,t,n)}}return e}},function(e,t){"use strict";function n(){return a}function r(e,t,n){if("string"!=typeof e)return null;var r=a.exec(e);if(!r||!t&&r[4])return null;var u={letter:r[1].toUpperCase(),acc:r[2].replace(/x/g,"##")};return u.pc=u.letter+u.acc,u.step=(u.letter.charCodeAt(0)+3)%7,u.alt="b"===u.acc[0]?-u.acc.length:u.acc.length,u.chroma=o[u.step]+u.alt,r[3]&&(u.oct=+r[3],u.midi=u.chroma+12*(u.oct+1),u.freq=i(u.midi,n)),t&&(u.tonicOf=r[4]),u}function i(e,t){return Math.pow(2,(e-69)/12)*(t||440)}var a=/^([a-gA-G])(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)\s*$/,o=[0,2,4,5,7,9,11],u={parse:r,regex:n,midiToFreq:i},s=["letter","acc","pc","step","alt","chroma","oct","midi","freq"];s.forEach(function(e){u[e]=function(t){var n=r(t);return n&&"undefined"!=typeof n[e]?n[e]:null}}),e.exports=u},function(e,t){"use strict";var n=Array.isArray,r=function(e){return e&&"object"==typeof e},i={};e.exports=function(e){return e.schedule=function(t,a){var o=e.context.currentTime,u=t<o?o:t;e.emit("schedule",u,a);var s,c,l,f;return a.map(function(t){return t?(n(t)?(s=t[0],c=t[1]):(s=t.time,c=t),r(c)?(l=c.name||c.key||c.note||c.midi||null,f=c):(l=c,f=i),e.start(l,u+(s||0),f)):null})},e}},function(e,t,n){var r=n(16);e.exports=function(e){return e.listenToMidi=function(t,n){var i={},a=n||{},o=a.gain||function(e){return e/127};return t.onmidimessage=function(t){var n=t.messageType?t:r(t);if("noteon"===n.messageType&&0===n.velocity&&(n.messageType="noteoff"),!a.channel||n.channel===a.channel)switch(n.messageType){case"noteon":i[n.key]=e.play(n.key,0,{gain:o(n.velocity)});break;case"noteoff":i[n.key]&&(i[n.key].stop(),delete i[n.key])}},e},e}},function(e,t,n){var r,r;!function(t){e.exports=t()}(function(){return function e(t,n,i){function a(u,s){if(!n[u]){if(!t[u]){var c="function"==typeof r&&r;if(!s&&c)return r(u,!0);if(o)return o(u,!0);var l=new Error("Cannot find module '"+u+"'");throw l.code="MODULE_NOT_FOUND",l}var f=n[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return a(n?n:e)},f,f.exports,e,t,n,i)}return n[u].exports}for(var o="function"==typeof r&&r,u=0;u<i.length;u++)a(i[u]);return a}({1:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=function(e){function t(e){if(this._event=e,this._data=e.data,this.receivedTime=e.receivedTime,this._data&&this._data.length<2)return void console.warn("Illegal MIDI message of length",this._data.length);switch(this._messageCode=240&e.data[0],this.channel=15&e.data[0],this._messageCode){case 128:this.messageType="noteoff",this.key=127&e.data[1],this.velocity=127&e.data[2];break;case 144:this.messageType="noteon",this.key=127&e.data[1],this.velocity=127&e.data[2];break;case 160:this.messageType="keypressure",this.key=127&e.data[1],this.pressure=127&e.data[2];break;case 176:this.messageType="controlchange",this.controllerNumber=127&e.data[1],this.controllerValue=127&e.data[2],120===this.controllerNumber&&0===this.controllerValue?this.channelModeMessage="allsoundoff":121===this.controllerNumber?this.channelModeMessage="resetallcontrollers":122===this.controllerNumber?0===this.controllerValue?this.channelModeMessage="localcontroloff":this.channelModeMessage="localcontrolon":123===this.controllerNumber&&0===this.controllerValue?this.channelModeMessage="allnotesoff":124===this.controllerNumber&&0===this.controllerValue?this.channelModeMessage="omnimodeoff":125===this.controllerNumber&&0===this.controllerValue?this.channelModeMessage="omnimodeon":126===this.controllerNumber?this.channelModeMessage="monomodeon":127===this.controllerNumber&&(this.channelModeMessage="polymodeon");break;case 192:this.messageType="programchange",this.program=e.data[1];break;case 208:this.messageType="channelpressure",this.pressure=127&e.data[1];break;case 224:this.messageType="pitchbendchange";var t=127&e.data[2],n=127&e.data[1];this.pitchBend=(t<<8)+n}}return new t(e)},t.exports=n.default},{}]},{},[1])(1)})},function(e,t,n){"use strict";function r(e,t){return console.warn("new Soundfont() is deprected"),console.log("Please use Soundfont.instrument() instead of new Soundfont().instrument()"),this instanceof r?(this.nameToUrl=t||r.nameToUrl,this.ctx=e,this.instruments={},void(this.promises=[])):new r(e)}function i(e,t,n){return console.warn("Soundfont.loadBuffers is deprecate."),console.log("Use Soundfont.instrument(..) and get buffers properties from the result."),r.instrument(e,t,n).then(function(e){return e.buffers})}function a(e,t){return t=t||{},function(n,r,i,a){console.warn("The oscillator player is deprecated."),console.log("Starting with version 0.9.0 you will have to wait until the soundfont is loaded to play sounds.");var u=n>0&&n<129?+n:o.midi(n),s=u?o.midiToFreq(u,440):null;if(s){i=i||.2,a=a||{};var c=a.destination||t.destination||e.destination,l=a.vcoType||t.vcoType||"sine",f=a.gain||t.gain||.4,h=e.createOscillator();h.type=l,h.frequency.value=s;var p=e.createGain();return p.gain.value=f,h.connect(p),p.connect(c),h.start(r),i>0&&h.stop(r+i),h}}}var o=n(18);r.prototype.onready=function(e){console.warn("deprecated API"),console.log("Please use Promise.all(Soundfont.instrument(), Soundfont.instrument()).then() instead of new Soundfont().onready()"),Promise.all(this.promises).then(e)},r.prototype.instrument=function(e,t){console.warn("new Soundfont().instrument() is deprecated."),console.log("Please use Soundfont.instrument() instead.");var n=this.ctx;if(e=e||"default",e in this.instruments)return this.instruments[e];var i={name:e,play:a(n,t)};if(this.instruments[e]=i,"default"!==e){var o=r.instrument(n,e,t).then(function(e){return i.play=e.play,i});this.promises.push(o),i.onready=function(e){console.warn("onready is deprecated. Use Soundfont.instrument().then()"),o.then(e)}}else i.onready=function(e){console.warn("onready is deprecated. Use Soundfont.instrument().then()"),e()};return i},r.loadBuffers=i,r.noteToMidi=o.midi,e.exports=r},function(e,t){"use strict";function n(e,t){return Array(t+1).join(e)}function r(e){return"number"==typeof e}function i(e){return"string"==typeof e}function a(e){return"undefined"!=typeof e}function o(e,t){return Math.pow(2,(e-69)/12)*(t||440)}function u(){return d}function s(e,t,n){if("string"!=typeof e)return null;var r=d.exec(e);if(!r||!t&&r[4])return null;var i={letter:r[1].toUpperCase(),acc:r[2].replace(/x/g,"##")};i.pc=i.letter+i.acc,i.step=(i.letter.charCodeAt(0)+3)%7,i.alt="b"===i.acc[0]?-i.acc.length:i.acc.length;var a=m[i.step]+i.alt;return i.chroma=a<0?12+a:a%12,r[3]&&(i.oct=+r[3],i.midi=a+12*(i.oct+1),i.freq=o(i.midi,n)),t&&(i.tonicOf=r[4]),i}function c(e){return r(e)?e<0?n("b",-e):n("#",e):""}function l(e){return r(e)?""+e:""}function f(e,t,n){return null===e||"undefined"==typeof e?null:e.step?f(e.step,e.alt,e.oct):e<0||e>6?null:v.charAt(e)+c(t)+l(n)}function h(e){if((r(e)||i(e))&&e>=0&&e<128)return+e;var t=s(e);return t&&a(t.midi)?t.midi:null}function p(e,t){var n=h(e);return null===n?null:o(n,t)}var d=/^([a-gA-G])(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)\s*$/,m=[0,2,4,5,7,9,11],v="CDEFGAB",g={parse:s,build:f,regex:u,midi:h,freq:p},_=["letter","acc","pc","step","alt","chroma","oct"];_.forEach(function(e){g[e]=function(t){var n=s(t);return n&&a(n[e])?n[e]:null}}),e.exports=g},function(e,t,n){(function(t,n,r){!function(t){e.exports=t()}(function(){var e,i,a;return function e(t,n,r){function i(o,u){if(!n[o]){if(!t[o]){var s="function"==typeof _dereq_&&_dereq_;if(!u&&s)return s(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return i(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var a="function"==typeof _dereq_&&_dereq_,o=0;o<r.length;o++)i(r[o]);return i}({1:[function(e,t,n){"use strict";t.exports=function(e){function t(e){var t=new n(e),r=t.promise();return t.setHowMany(1),t.setUnwrap(),t.init(),r}var n=e._SomePromiseArray;e.any=function(e){return t(e)},e.prototype.any=function(){return t(this)}}},{}],2:[function(e,n,r){"use strict";function i(){this._customScheduler=!1,this._isTickUsed=!1,this._lateQueue=new f(16),this._normalQueue=new f(16),this._haveDrainedQueues=!1,this._trampolineEnabled=!0;var e=this;this.drainQueues=function(){e._drainQueues()},this._schedule=l}function a(e,t,n){this._lateQueue.push(e,t,n),this._queueTick()}function o(e,t,n){this._normalQueue.push(e,t,n),this._queueTick()}function u(e){this._normalQueue._pushOne(e),this._queueTick()}var s;try{throw new Error}catch(c){s=c}var l=e("./schedule"),f=e("./queue"),h=e("./util");i.prototype.setScheduler=function(e){var t=this._schedule;return this._schedule=e,this._customScheduler=!0,t},i.prototype.hasCustomScheduler=function(){return this._customScheduler},i.prototype.enableTrampoline=function(){this._trampolineEnabled=!0},i.prototype.disableTrampolineIfNecessary=function(){h.hasDevTools&&(this._trampolineEnabled=!1)},i.prototype.haveItemsQueued=function(){return this._isTickUsed||this._haveDrainedQueues},i.prototype.fatalError=function(e,n){n?(t.stderr.write("Fatal "+(e instanceof Error?e.stack:e)+"\n"),t.exit(2)):this.throwLater(e)},i.prototype.throwLater=function(e,t){if(1===arguments.length&&(t=e,e=function(){throw t}),"undefined"!=typeof setTimeout)setTimeout(function(){e(t)},0);else try{this._schedule(function(){e(t)})}catch(n){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")}},h.hasDevTools?(i.prototype.invokeLater=function(e,t,n){this._trampolineEnabled?a.call(this,e,t,n):this._schedule(function(){setTimeout(function(){e.call(t,n)},100)})},i.prototype.invoke=function(e,t,n){this._trampolineEnabled?o.call(this,e,t,n):this._schedule(function(){e.call(t,n)})},i.prototype.settlePromises=function(e){this._trampolineEnabled?u.call(this,e):this._schedule(function(){e._settlePromises()})}):(i.prototype.invokeLater=a,i.prototype.invoke=o,i.prototype.settlePromises=u),i.prototype.invokeFirst=function(e,t,n){this._normalQueue.unshift(e,t,n),this._queueTick()},i.prototype._drainQueue=function(e){for(;e.length()>0;){var t=e.shift();if("function"==typeof t){var n=e.shift(),r=e.shift();t.call(n,r)}else t._settlePromises()}},i.prototype._drainQueues=function(){this._drainQueue(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,this._drainQueue(this._lateQueue)},i.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},i.prototype._reset=function(){this._isTickUsed=!1},n.exports=i,n.exports.firstLineError=s},{"./queue":26,"./schedule":29,"./util":36}],3:[function(e,t,n){"use strict";t.exports=function(e,t,n,r){var i=!1,a=function(e,t){this._reject(t)},o=function(e,t){t.promiseRejectionQueued=!0,t.bindingPromise._then(a,a,null,this,e)},u=function(e,t){0===(50397184&this._bitField)&&this._resolveCallback(t.target)},s=function(e,t){t.promiseRejectionQueued||this._reject(e)};e.prototype.bind=function(a){i||(i=!0,e.prototype._propagateFrom=r.propagateFromFunction(),e.prototype._boundValue=r.boundValueFunction());var c=n(a),l=new e(t);l._propagateFrom(this,1);var f=this._target();if(l._setBoundTo(c),c instanceof e){var h={promiseRejectionQueued:!1,promise:l,target:f,bindingPromise:c};f._then(t,o,void 0,l,h),c._then(u,s,void 0,l,h),l._setOnCancel(c)}else l._resolveCallback(f);return l},e.prototype._setBoundTo=function(e){void 0!==e?(this._bitField=2097152|this._bitField,this._boundTo=e):this._bitField=this._bitField&-2097153},e.prototype._isBound=function(){return 2097152===(2097152&this._bitField)},e.bind=function(t,n){return e.resolve(n).bind(t)}}},{}],4:[function(e,t,n){"use strict";function r(){try{Promise===a&&(Promise=i)}catch(e){}return a}var i;"undefined"!=typeof Promise&&(i=Promise);var a=e("./promise")();a.noConflict=r,t.exports=a},{"./promise":22}],5:[function(e,t,n){"use strict";var r=Object.create;if(r){var i=r(null),a=r(null);i[" size"]=a[" size"]=0}t.exports=function(t){function n(e,n){var r;if(null!=e&&(r=e[n]),"function"!=typeof r){var i="Object "+u.classString(e)+" has no method '"+u.toString(n)+"'";throw new t.TypeError(i)}return r}function r(e){var t=this.pop(),r=n(e,t);return r.apply(e,this)}function i(e){return e[this]}function a(e){var t=+this;return t<0&&(t=Math.max(0,t+e.length)),e[t]}var o,u=e("./util"),s=u.canEvaluate;u.isIdentifier;t.prototype.call=function(e){var t=[].slice.call(arguments,1);return t.push(e),this._then(r,void 0,void 0,t,void 0)},t.prototype.get=function(e){var t,n="number"==typeof e;if(n)t=a;else if(s){var r=o(e);t=null!==r?r:i}else t=i;return this._then(t,void 0,void 0,e,void 0)}}},{"./util":36}],6:[function(e,t,n){"use strict";t.exports=function(t,n,r,i){var a=e("./util"),o=a.tryCatch,u=a.errorObj,s=t._async;t.prototype.break=t.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var e=this,t=e;e._isCancellable();){if(!e._cancelBy(t)){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}var n=e._cancellationParent;if(null==n||!n._isCancellable()){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}e._isFollowing()&&e._followee().cancel(),e._setWillBeCancelled(),t=e,e=n}},t.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},t.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},t.prototype._cancelBy=function(e){return e===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),!!this._enoughBranchesHaveCancelled()&&(this._invokeOnCancel(),!0))},t.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},t.prototype._cancel=function(){this._isCancellable()&&(this._setCancelled(),s.invoke(this._cancelPromises,this,void 0))},t.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},t.prototype._unsetOnCancel=function(){this._onCancelField=void 0},t.prototype._isCancellable=function(){return this.isPending()&&!this._isCancelled()},t.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},t.prototype._doInvokeOnCancel=function(e,t){if(a.isArray(e))for(var n=0;n<e.length;++n)this._doInvokeOnCancel(e[n],t);else if(void 0!==e)if("function"==typeof e){if(!t){var r=o(e).call(this._boundValue());r===u&&(this._attachExtraTrace(r.e),s.throwLater(r.e))}}else e._resultCancelled(this)},t.prototype._invokeOnCancel=function(){var e=this._onCancel();this._unsetOnCancel(),s.invoke(this._doInvokeOnCancel,this,e)},t.prototype._invokeInternalOnCancel=function(){this._isCancellable()&&(this._doInvokeOnCancel(this._onCancel(),!0),this._unsetOnCancel())},t.prototype._resultCancelled=function(){this.cancel()}}},{"./util":36}],7:[function(e,t,n){"use strict";t.exports=function(t){function n(e,n,u){return function(s){var c=u._boundValue();e:for(var l=0;l<e.length;++l){var f=e[l];if(f===Error||null!=f&&f.prototype instanceof Error){if(s instanceof f)return a(n).call(c,s)}else if("function"==typeof f){var h=a(f).call(c,s);if(h===o)return h;if(h)return a(n).call(c,s)}else if(r.isObject(s)){for(var p=i(f),d=0;d<p.length;++d){var m=p[d];if(f[m]!=s[m])continue e}return a(n).call(c,s)}}return t}}var r=e("./util"),i=e("./es5").keys,a=r.tryCatch,o=r.errorObj;return n}},{"./es5":13,"./util":36}],8:[function(e,t,n){"use strict";t.exports=function(e){function t(){this._trace=new t.CapturedTrace(r())}function n(){if(i)return new t}function r(){var e=a.length-1;if(e>=0)return a[e]}var i=!1,a=[];return e.prototype._promiseCreated=function(){},e.prototype._pushContext=function(){},e.prototype._popContext=function(){return null},e._peekContext=e.prototype._peekContext=function(){},t.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,a.push(this._trace))},t.prototype._popContext=function(){if(void 0!==this._trace){var e=a.pop(),t=e._promiseCreated;return e._promiseCreated=null,t}return null},t.CapturedTrace=null,t.create=n,t.deactivateLongStackTraces=function(){},t.activateLongStackTraces=function(){var n=e.prototype._pushContext,a=e.prototype._popContext,o=e._peekContext,u=e.prototype._peekContext,s=e.prototype._promiseCreated;t.deactivateLongStackTraces=function(){e.prototype._pushContext=n,e.prototype._popContext=a,e._peekContext=o,e.prototype._peekContext=u,e.prototype._promiseCreated=s,i=!1},i=!0,e.prototype._pushContext=t.prototype._pushContext,e.prototype._popContext=t.prototype._popContext,e._peekContext=e.prototype._peekContext=r,e.prototype._promiseCreated=function(){var e=this._peekContext();e&&null==e._promiseCreated&&(e._promiseCreated=this)}},t}},{}],9:[function(e,n,r){"use strict";n.exports=function(n,r){function i(e,t){return{promise:t}}function a(){return!1}function o(e,t,n){var r=this;try{e(t,n,function(e){if("function"!=typeof e)throw new TypeError("onCancel must be a function, got: "+L.toString(e));r._attachCancellationCallback(e)})}catch(i){return i}}function u(e){if(!this._isCancellable())return this;var t=this._onCancel();void 0!==t?L.isArray(t)?t.push(e):this._setOnCancel([t,e]):this._setOnCancel(e)}function s(){return this._onCancelField}function c(e){this._onCancelField=e}function l(){this._cancellationParent=void 0,this._onCancelField=void 0}function f(e,t){if(0!==(1&t)){this._cancellationParent=e;var n=e._branchesRemainingToCancel;void 0===n&&(n=0),e._branchesRemainingToCancel=n+1}0!==(2&t)&&e._isBound()&&this._setBoundTo(e._boundTo)}function h(e,t){0!==(2&t)&&e._isBound()&&this._setBoundTo(e._boundTo)}function p(){var e=this._boundTo;return void 0!==e&&e instanceof n?e.isFulfilled()?e.value():void 0:e}function d(){this._trace=new R(this._peekContext())}function m(e,t){if(U(e)){var n=this._trace;if(void 0!==n&&t&&(n=n._parent),void 0!==n)n.attachExtraTrace(e);else if(!e.__stackCleaned__){var r=C(e);L.notEnumerableProp(e,"stack",r.message+"\n"+r.stack.join("\n")),L.notEnumerableProp(e,"__stackCleaned__",!0)}}}function v(e,t,n,r,i){if(void 0===e&&null!==t&&$){if(void 0!==i&&i._returnedNonUndefined())return;if(0===(65535&r._bitField))return;n&&(n+=" ");var a="",o="";if(t._trace){for(var u=t._trace.stack.split("\n"),s=A(u),c=s.length-1;c>=0;--c){var l=s[c];if(!z.test(l)){var f=l.match(V);f&&(a="at "+f[1]+":"+f[2]+":"+f[3]+" ");break}}if(s.length>0)for(var h=s[0],c=0;c<u.length;++c)if(u[c]===h){c>0&&(o="\n"+u[c-1]);break}}var p="a promise was created in a "+n+"handler "+a+"but was not returned from it, see http://goo.gl/rRqMUw"+o;r._warn(p,!0,t)}}function g(e,t){var n=e+" is deprecated and will be removed in a future version.";return t&&(n+=" Use "+t+" instead."),_(n)}function _(e,t,r){if(oe.warnings){var i,a=new O(e);if(t)r._attachExtraTrace(a);else if(oe.longStackTraces&&(i=n._peekContext()))i.attachExtraTrace(a);else{
var o=C(a);a.stack=o.message+"\n"+o.stack.join("\n")}te("warning",a)||S(a,"",!0)}}function b(e,t){for(var n=0;n<t.length-1;++n)t[n].push("From previous event:"),t[n]=t[n].join("\n");return n<t.length&&(t[n]=t[n].join("\n")),e+"\n"+t.join("\n")}function y(e){for(var t=0;t<e.length;++t)(0===e[t].length||t+1<e.length&&e[t][0]===e[t+1][0])&&(e.splice(t,1),t--)}function w(e){for(var t=e[0],n=1;n<e.length;++n){for(var r=e[n],i=t.length-1,a=t[i],o=-1,u=r.length-1;u>=0;--u)if(r[u]===a){o=u;break}for(var u=o;u>=0;--u){var s=r[u];if(t[i]!==s)break;t.pop(),i--}t=r}}function A(e){for(var t=[],n=0;n<e.length;++n){var r=e[n],i=" (No stack trace)"===r||H.test(r),a=i&&re(r);i&&!a&&(K&&" "!==r.charAt(0)&&(r=" "+r),t.push(r))}return t}function T(e){for(var t=e.stack.replace(/\s+$/g,"").split("\n"),n=0;n<t.length;++n){var r=t[n];if(" (No stack trace)"===r||H.test(r))break}return n>0&&(t=t.slice(n)),t}function C(e){var t=e.stack,n=e.toString();return t="string"==typeof t&&t.length>0?T(e):[" (No stack trace)"],{message:n,stack:A(t)}}function S(e,t,n){if("undefined"!=typeof console){var r;if(L.isObject(e)){var i=e.stack;r=t+W(i,e)}else r=t+String(e);"function"==typeof F?F(r,n):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(r)}}function M(e,t,n,r){var i=!1;try{"function"==typeof t&&(i=!0,"rejectionHandled"===e?t(r):t(n,r))}catch(a){j.throwLater(a)}"unhandledRejection"===e?te(e,n,r)||i||S(n,"Unhandled rejection "):te(e,r)}function E(e){var t;if("function"==typeof e)t="[function "+(e.name||"anonymous")+"]";else{t=e&&"function"==typeof e.toString?e.toString():L.toString(e);var n=/\[object [a-zA-Z0-9$_]+\]/;if(n.test(t))try{var r=JSON.stringify(e);t=r}catch(i){}0===t.length&&(t="(empty array)")}return"(<"+x(t)+">, no stack trace)"}function x(e){var t=41;return e.length<t?e:e.substr(0,t-3)+"..."}function k(){return"function"==typeof ae}function P(e){var t=e.match(ie);if(t)return{fileName:t[1],line:parseInt(t[2],10)}}function B(e,t){if(k()){for(var n,r,i=e.stack.split("\n"),a=t.stack.split("\n"),o=-1,u=-1,s=0;s<i.length;++s){var c=P(i[s]);if(c){n=c.fileName,o=c.line;break}}for(var s=0;s<a.length;++s){var c=P(a[s]);if(c){r=c.fileName,u=c.line;break}}o<0||u<0||!n||!r||n!==r||o>=u||(re=function(e){if(G.test(e))return!0;var t=P(e);return!!(t&&t.fileName===n&&o<=t.line&&t.line<=u)})}}function R(e){this._parent=e,this._promisesCreated=0;var t=this._length=1+(void 0===e?0:e._length);ae(this,R),t>32&&this.uncycle()}var N,I,F,D=n._getDomain,j=n._async,O=e("./errors").Warning,L=e("./util"),U=L.canAttachTrace,G=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,z=/\((?:timers\.js):\d+:\d+\)/,V=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,H=null,W=null,K=!1,q=!(0==L.env("BLUEBIRD_DEBUG")),J=!(0==L.env("BLUEBIRD_WARNINGS")||!q&&!L.env("BLUEBIRD_WARNINGS")),Y=!(0==L.env("BLUEBIRD_LONG_STACK_TRACES")||!q&&!L.env("BLUEBIRD_LONG_STACK_TRACES")),$=0!=L.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(J||!!L.env("BLUEBIRD_W_FORGOTTEN_RETURN"));n.prototype.suppressUnhandledRejections=function(){var e=this._target();e._bitField=e._bitField&-1048577|524288},n.prototype._ensurePossibleRejectionHandled=function(){0===(524288&this._bitField)&&(this._setRejectionIsUnhandled(),j.invokeLater(this._notifyUnhandledRejection,this,void 0))},n.prototype._notifyUnhandledRejectionIsHandled=function(){M("rejectionHandled",N,void 0,this)},n.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},n.prototype._returnedNonUndefined=function(){return 0!==(268435456&this._bitField)},n.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var e=this._settledValue();this._setUnhandledRejectionIsNotified(),M("unhandledRejection",I,e,this)}},n.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},n.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=this._bitField&-262145},n.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},n.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},n.prototype._unsetRejectionIsUnhandled=function(){this._bitField=this._bitField&-1048577,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},n.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},n.prototype._warn=function(e,t,n){return _(e,t,n||this)},n.onPossiblyUnhandledRejection=function(e){var t=D();I="function"==typeof e?null===t?e:L.domainBind(t,e):void 0},n.onUnhandledRejectionHandled=function(e){var t=D();N="function"==typeof e?null===t?e:L.domainBind(t,e):void 0};var Z=function(){};n.longStackTraces=function(){if(j.haveItemsQueued()&&!oe.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!oe.longStackTraces&&k()){var e=n.prototype._captureStackTrace,t=n.prototype._attachExtraTrace;oe.longStackTraces=!0,Z=function(){if(j.haveItemsQueued()&&!oe.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");n.prototype._captureStackTrace=e,n.prototype._attachExtraTrace=t,r.deactivateLongStackTraces(),j.enableTrampoline(),oe.longStackTraces=!1},n.prototype._captureStackTrace=d,n.prototype._attachExtraTrace=m,r.activateLongStackTraces(),j.disableTrampolineIfNecessary()}},n.hasLongStackTraces=function(){return oe.longStackTraces&&k()};var Q=function(){try{if("function"==typeof CustomEvent){var e=new CustomEvent("CustomEvent");return L.global.dispatchEvent(e),function(e,t){var n=new CustomEvent(e.toLowerCase(),{detail:t,cancelable:!0});return!L.global.dispatchEvent(n)}}if("function"==typeof Event){var e=new Event("CustomEvent");return L.global.dispatchEvent(e),function(e,t){var n=new Event(e.toLowerCase(),{cancelable:!0});return n.detail=t,!L.global.dispatchEvent(n)}}var e=document.createEvent("CustomEvent");return e.initCustomEvent("testingtheevent",!1,!0,{}),L.global.dispatchEvent(e),function(e,t){var n=document.createEvent("CustomEvent");return n.initCustomEvent(e.toLowerCase(),!1,!0,t),!L.global.dispatchEvent(n)}}catch(t){}return function(){return!1}}(),X=function(){return L.isNode?function(){return t.emit.apply(t,arguments)}:L.global?function(e){var t="on"+e.toLowerCase(),n=L.global[t];return!!n&&(n.apply(L.global,[].slice.call(arguments,1)),!0)}:function(){return!1}}(),ee={promiseCreated:i,promiseFulfilled:i,promiseRejected:i,promiseResolved:i,promiseCancelled:i,promiseChained:function(e,t,n){return{promise:t,child:n}},warning:function(e,t){return{warning:t}},unhandledRejection:function(e,t,n){return{reason:t,promise:n}},rejectionHandled:i},te=function(e){var t=!1;try{t=X.apply(null,arguments)}catch(n){j.throwLater(n),t=!0}var r=!1;try{r=Q(e,ee[e].apply(null,arguments))}catch(n){j.throwLater(n),r=!0}return r||t};n.config=function(e){if(e=Object(e),"longStackTraces"in e&&(e.longStackTraces?n.longStackTraces():!e.longStackTraces&&n.hasLongStackTraces()&&Z()),"warnings"in e){var t=e.warnings;oe.warnings=!!t,$=oe.warnings,L.isObject(t)&&"wForgottenReturn"in t&&($=!!t.wForgottenReturn)}if("cancellation"in e&&e.cancellation&&!oe.cancellation){if(j.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");n.prototype._clearCancellationData=l,n.prototype._propagateFrom=f,n.prototype._onCancel=s,n.prototype._setOnCancel=c,n.prototype._attachCancellationCallback=u,n.prototype._execute=o,ne=f,oe.cancellation=!0}"monitoring"in e&&(e.monitoring&&!oe.monitoring?(oe.monitoring=!0,n.prototype._fireEvent=te):!e.monitoring&&oe.monitoring&&(oe.monitoring=!1,n.prototype._fireEvent=a))},n.prototype._fireEvent=a,n.prototype._execute=function(e,t,n){try{e(t,n)}catch(r){return r}},n.prototype._onCancel=function(){},n.prototype._setOnCancel=function(e){},n.prototype._attachCancellationCallback=function(e){},n.prototype._captureStackTrace=function(){},n.prototype._attachExtraTrace=function(){},n.prototype._clearCancellationData=function(){},n.prototype._propagateFrom=function(e,t){};var ne=h,re=function(){return!1},ie=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;L.inherits(R,Error),r.CapturedTrace=R,R.prototype.uncycle=function(){var e=this._length;if(!(e<2)){for(var t=[],n={},r=0,i=this;void 0!==i;++r)t.push(i),i=i._parent;e=this._length=r;for(var r=e-1;r>=0;--r){var a=t[r].stack;void 0===n[a]&&(n[a]=r)}for(var r=0;r<e;++r){var o=t[r].stack,u=n[o];if(void 0!==u&&u!==r){u>0&&(t[u-1]._parent=void 0,t[u-1]._length=1),t[r]._parent=void 0,t[r]._length=1;var s=r>0?t[r-1]:this;u<e-1?(s._parent=t[u+1],s._parent.uncycle(),s._length=s._parent._length+1):(s._parent=void 0,s._length=1);for(var c=s._length+1,l=r-2;l>=0;--l)t[l]._length=c,c++;return}}}},R.prototype.attachExtraTrace=function(e){if(!e.__stackCleaned__){this.uncycle();for(var t=C(e),n=t.message,r=[t.stack],i=this;void 0!==i;)r.push(A(i.stack.split("\n"))),i=i._parent;w(r),y(r),L.notEnumerableProp(e,"stack",b(n,r)),L.notEnumerableProp(e,"__stackCleaned__",!0)}};var ae=function(){var e=/^\s*at\s*/,t=function(e,t){return"string"==typeof e?e:void 0!==t.name&&void 0!==t.message?t.toString():E(t)};if("number"==typeof Error.stackTraceLimit&&"function"==typeof Error.captureStackTrace){Error.stackTraceLimit+=6,H=e,W=t;var n=Error.captureStackTrace;return re=function(e){return G.test(e)},function(e,t){Error.stackTraceLimit+=6,n(e,t),Error.stackTraceLimit-=6}}var r=new Error;if("string"==typeof r.stack&&r.stack.split("\n")[0].indexOf("stackDetection@")>=0)return H=/@/,W=t,K=!0,function(e){e.stack=(new Error).stack};var i;try{throw new Error}catch(a){i="stack"in a}return"stack"in r||!i||"number"!=typeof Error.stackTraceLimit?(W=function(e,t){return"string"==typeof e?e:"object"!=typeof t&&"function"!=typeof t||void 0===t.name||void 0===t.message?E(t):t.toString()},null):(H=e,W=t,function(e){Error.stackTraceLimit+=6;try{throw new Error}catch(t){e.stack=t.stack}Error.stackTraceLimit-=6})}([]);"undefined"!=typeof console&&"undefined"!=typeof console.warn&&(F=function(e){console.warn(e)},L.isNode&&t.stderr.isTTY?F=function(e,t){var n=t?"[33m":"[31m";console.warn(n+e+"[0m\n")}:L.isNode||"string"!=typeof(new Error).stack||(F=function(e,t){console.warn("%c"+e,t?"color: darkorange":"color: red")}));var oe={warnings:J,longStackTraces:!1,cancellation:!1,monitoring:!1};return Y&&n.longStackTraces(),{longStackTraces:function(){return oe.longStackTraces},warnings:function(){return oe.warnings},cancellation:function(){return oe.cancellation},monitoring:function(){return oe.monitoring},propagateFromFunction:function(){return ne},boundValueFunction:function(){return p},checkForgottenReturns:v,setBounds:B,warn:_,deprecated:g,CapturedTrace:R,fireDomEvent:Q,fireGlobalEvent:X}}},{"./errors":12,"./util":36}],10:[function(e,t,n){"use strict";t.exports=function(e){function t(){return this.value}function n(){throw this.reason}e.prototype.return=e.prototype.thenReturn=function(n){return n instanceof e&&n.suppressUnhandledRejections(),this._then(t,void 0,void 0,{value:n},void 0)},e.prototype.throw=e.prototype.thenThrow=function(e){return this._then(n,void 0,void 0,{reason:e},void 0)},e.prototype.catchThrow=function(e){if(arguments.length<=1)return this._then(void 0,n,void 0,{reason:e},void 0);var t=arguments[1],r=function(){throw t};return this.caught(e,r)},e.prototype.catchReturn=function(n){if(arguments.length<=1)return n instanceof e&&n.suppressUnhandledRejections(),this._then(void 0,t,void 0,{value:n},void 0);var r=arguments[1];r instanceof e&&r.suppressUnhandledRejections();var i=function(){return r};return this.caught(n,i)}}},{}],11:[function(e,t,n){"use strict";t.exports=function(e,t){function n(){return a(this)}function r(e,n){return i(e,n,t,t)}var i=e.reduce,a=e.all;e.prototype.each=function(e){return i(this,e,t,0)._then(n,void 0,void 0,this,void 0)},e.prototype.mapSeries=function(e){return i(this,e,t,t)},e.each=function(e,r){return i(e,r,t,0)._then(n,void 0,void 0,e,void 0)},e.mapSeries=r}},{}],12:[function(e,t,n){"use strict";function r(e,t){function n(r){return this instanceof n?(f(this,"message","string"==typeof r?r:t),f(this,"name",e),void(Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this))):new n(r)}return l(n,Error),n}function i(e){return this instanceof i?(f(this,"name","OperationalError"),f(this,"message",e),this.cause=e,this.isOperational=!0,void(e instanceof Error?(f(this,"message",e.message),f(this,"stack",e.stack)):Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor))):new i(e)}var a,o,u=e("./es5"),s=u.freeze,c=e("./util"),l=c.inherits,f=c.notEnumerableProp,h=r("Warning","warning"),p=r("CancellationError","cancellation error"),d=r("TimeoutError","timeout error"),m=r("AggregateError","aggregate error");try{a=TypeError,o=RangeError}catch(v){a=r("TypeError","type error"),o=r("RangeError","range error")}for(var g="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),_=0;_<g.length;++_)"function"==typeof Array.prototype[g[_]]&&(m.prototype[g[_]]=Array.prototype[g[_]]);u.defineProperty(m.prototype,"length",{value:0,configurable:!1,writable:!0,enumerable:!0}),m.prototype.isOperational=!0;var b=0;m.prototype.toString=function(){var e=Array(4*b+1).join(" "),t="\n"+e+"AggregateError of:\n";b++,e=Array(4*b+1).join(" ");for(var n=0;n<this.length;++n){for(var r=this[n]===this?"[Circular AggregateError]":this[n]+"",i=r.split("\n"),a=0;a<i.length;++a)i[a]=e+i[a];r=i.join("\n"),t+=r+"\n"}return b--,t},l(i,Error);var y=Error.__BluebirdErrorTypes__;y||(y=s({CancellationError:p,TimeoutError:d,OperationalError:i,RejectionError:i,AggregateError:m}),u.defineProperty(Error,"__BluebirdErrorTypes__",{value:y,writable:!1,enumerable:!1,configurable:!1})),t.exports={Error:Error,TypeError:a,RangeError:o,CancellationError:y.CancellationError,OperationalError:y.OperationalError,TimeoutError:y.TimeoutError,AggregateError:y.AggregateError,Warning:h}},{"./es5":13,"./util":36}],13:[function(e,t,n){var r=function(){"use strict";return void 0===this}();if(r)t.exports={freeze:Object.freeze,defineProperty:Object.defineProperty,getDescriptor:Object.getOwnPropertyDescriptor,keys:Object.keys,names:Object.getOwnPropertyNames,getPrototypeOf:Object.getPrototypeOf,isArray:Array.isArray,isES5:r,propertyIsWritable:function(e,t){var n=Object.getOwnPropertyDescriptor(e,t);return!(n&&!n.writable&&!n.set)}};else{var i={}.hasOwnProperty,a={}.toString,o={}.constructor.prototype,u=function(e){var t=[];for(var n in e)i.call(e,n)&&t.push(n);return t},s=function(e,t){return{value:e[t]}},c=function(e,t,n){return e[t]=n.value,e},l=function(e){return e},f=function(e){try{return Object(e).constructor.prototype}catch(t){return o}},h=function(e){try{return"[object Array]"===a.call(e)}catch(t){return!1}};t.exports={isArray:h,keys:u,names:u,defineProperty:c,getDescriptor:s,freeze:l,getPrototypeOf:f,isES5:r,propertyIsWritable:function(){return!0}}}},{}],14:[function(e,t,n){"use strict";t.exports=function(e,t){var n=e.map;e.prototype.filter=function(e,r){return n(this,e,r,t)},e.filter=function(e,r,i){return n(e,r,i,t)}}},{}],15:[function(e,t,n){"use strict";t.exports=function(t,n){function r(e,t,n){this.promise=e,this.type=t,this.handler=n,this.called=!1,this.cancelPromise=null}function i(e){this.finallyHandler=e}function a(e,t){return null!=e.cancelPromise&&(arguments.length>1?e.cancelPromise._reject(t):e.cancelPromise._cancel(),e.cancelPromise=null,!0)}function o(){return s.call(this,this.promise._target()._settledValue())}function u(e){if(!a(this,e))return f.e=e,f}function s(e){var r=this.promise,s=this.handler;if(!this.called){this.called=!0;var c=this.isFinallyHandler()?s.call(r._boundValue()):s.call(r._boundValue(),e);if(void 0!==c){r._setReturnedNonUndefined();var h=n(c,r);if(h instanceof t){if(null!=this.cancelPromise){if(h._isCancelled()){var p=new l("late cancellation observer");return r._attachExtraTrace(p),f.e=p,f}h.isPending()&&h._attachCancellationCallback(new i(this))}return h._then(o,u,void 0,this,void 0)}}}return r.isRejected()?(a(this),f.e=e,f):(a(this),e)}var c=e("./util"),l=t.CancellationError,f=c.errorObj;return r.prototype.isFinallyHandler=function(){return 0===this.type},i.prototype._resultCancelled=function(){a(this.finallyHandler)},t.prototype._passThrough=function(e,t,n,i){return"function"!=typeof e?this.then():this._then(n,i,void 0,new r(this,t,e),void 0)},t.prototype.lastly=t.prototype.finally=function(e){return this._passThrough(e,0,s,s)},t.prototype.tap=function(e){return this._passThrough(e,1,s)},r}},{"./util":36}],16:[function(e,t,n){"use strict";t.exports=function(t,n,r,i,a,o){function u(e,n,r){for(var a=0;a<n.length;++a){r._pushContext();var o=p(n[a])(e);if(r._popContext(),o===h){r._pushContext();var u=t.reject(h.e);return r._popContext(),u}var s=i(o,r);if(s instanceof t)return s}return null}function s(e,n,i,a){if(o.cancellation()){var u=new t(r),s=this._finallyPromise=new t(r);this._promise=u.lastly(function(){return s}),u._captureStackTrace(),u._setOnCancel(this)}else{var c=this._promise=new t(r);c._captureStackTrace()}this._stack=a,this._generatorFunction=e,this._receiver=n,this._generator=void 0,this._yieldHandlers="function"==typeof i?[i].concat(d):d,this._yieldedPromise=null,this._cancellationPhase=!1}var c=e("./errors"),l=c.TypeError,f=e("./util"),h=f.errorObj,p=f.tryCatch,d=[];f.inherits(s,a),s.prototype._isResolved=function(){return null===this._promise},s.prototype._cleanup=function(){this._promise=this._generator=null,o.cancellation()&&null!==this._finallyPromise&&(this._finallyPromise._fulfill(),this._finallyPromise=null)},s.prototype._promiseCancelled=function(){if(!this._isResolved()){var e,n="undefined"!=typeof this._generator.return;if(n)this._promise._pushContext(),e=p(this._generator.return).call(this._generator,void 0),this._promise._popContext()