/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/json-midi-message-encoder@4.1.65/build/es5/bundle.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@babel/runtime/helpers/slicedToArray")):"function"==typeof define&&define.amd?define(["exports","@babel/runtime/helpers/slicedToArray"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jsonMidiMessageEncoder={},e._slicedToArray)}(this,(function(e,t){"use strict";var r=function(e){var t=new ArrayBuffer(e);return{arrayBuffer:t,dataView:new DataView(t)}},n=function(e){var r=e.reduce((function(e,t){return e+t.byteLength}),0),n=e.reduce((function(e,r){var n=t(e,2),i=n[0],a=n[1];return a.set(new Uint8Array(r),i),[i+r.byteLength,a]}),[0,new Uint8Array(r)]);return t(n,2)[1].buffer},i=function(e){return function(t){for(var r=Math.max(1,Math.floor(Math.log(t)/Math.log(2)/7)+1),n=e(r),i=n.arrayBuffer,a=n.dataView,f=1;f<r;f+=1)a.setUint8(r-1-f,t>>7*f&127|128);return a.setUint8(r-1,127&t),i}}(r),a=function(e,t,r,n){return function(i){if(function(e){return void 0!==e.channelPrefix}(i)){var a=e(4),f=a.arrayBuffer,u=a.dataView;return u.setUint8(0,255),u.setUint8(1,32),u.setUint8(2,1),u.setUint8(3,i.channelPrefix),f}if(function(e){return void 0!==e.channelPressure}(i)){var s=e(2),o=s.arrayBuffer,c=s.dataView;return c.setUint8(0,13|15&i.channel),c.setUint8(1,i.channelPressure.pressure),o}if(function(e){return void 0!==e.controlChange}(i)){var d=e(3),U=d.arrayBuffer,m=d.dataView;return m.setUint8(0,176|15&i.channel),m.setUint8(1,i.controlChange.type),m.setUint8(2,i.controlChange.value),U}if(function(e){return void 0!==e.copyrightNotice}(i))return t(i,2,"copyrightNotice");if(function(e){return void 0!==e.cuePoint&&void 0===e.metaTypeByte}(i))return t(i,7,"cuePoint");if(function(e){return void 0!==e.deviceName}(i))return t(i,9,"deviceName");if(function(e){return void 0!==e.endOfTrack}(i)){var y=e(3),v=y.arrayBuffer,l=y.dataView;return l.setUint8(0,255),l.setUint8(1,47),l.setUint8(2,0),v}if(function(e){return void 0!==e.instrumentName}(i))return t(i,4,"instrumentName");if(function(e){return void 0!==e.keyPressure}(i)){var p=e(3),h=p.arrayBuffer,g=p.dataView;return g.setUint8(0,10|15&i.channel),g.setUint8(1,i.keyPressure.noteNumber),g.setUint8(2,i.keyPressure.pressure),h}if(function(e){return void 0!==e.keySignature}(i)){var w=e(5),B=w.arrayBuffer,V=w.dataView;return V.setUint8(0,255),V.setUint8(1,89),V.setUint8(2,2),V.setUint8(3,i.keySignature.key),V.setUint8(4,i.keySignature.scale),B}if(function(e){return void 0!==e.lyric}(i))return t(i,5,"lyric");if(function(e){return void 0!==e.marker}(i))return t(i,6,"marker");if(function(e){return void 0!==e.midiPort}(i)){var b=e(4),O=b.arrayBuffer,T=b.dataView;return T.setUint8(0,255),T.setUint8(1,33),T.setUint8(2,1),T.setUint8(3,i.midiPort),O}if(function(e){return void 0!==e.noteOff}(i)){var x=e(3),N=x.arrayBuffer,P=x.dataView;return P.setUint8(0,128|15&i.channel),P.setUint8(1,i.noteOff.noteNumber),P.setUint8(2,i.noteOff.velocity),N}if(function(e){return void 0!==e.noteOn}(i)){var k=e(3),S=k.arrayBuffer,A=k.dataView;return A.setUint8(0,144|15&i.channel),A.setUint8(1,i.noteOn.noteNumber),A.setUint8(2,i.noteOn.velocity),S}if(function(e){return void 0!==e.pitchBend}(i)){var M=e(3),q=M.arrayBuffer,C=M.dataView;return C.setUint8(0,224|15&i.channel),C.setUint8(1,127&i.pitchBend),C.setUint8(2,i.pitchBend>>7),q}if(function(e){return void 0!==e.programChange}(i)){var D=e(2),E=D.arrayBuffer,L=D.dataView;return L.setUint8(0,192|15&i.channel),L.setUint8(1,i.programChange.programNumber),E}if(function(e){return void 0!==e.programName}(i))return t(i,8,"programName");if(function(e){return void 0!==e.sequencerSpecificData}(i)){var Q=e(2),R=Q.arrayBuffer,I=Q.dataView;I.setUint8(0,255),I.setUint8(1,127);for(var j=i.sequencerSpecificData.length/2,F=n(j),_=e(j),z=_.arrayBuffer,G=_.dataView,H=0;H<i.sequencerSpecificData.length;H+=2)G.setUint8(H/2,parseInt(i.sequencerSpecificData.slice(H,H+2),16));return r([R,F,z])}if(function(e){return void 0!==e.setTempo}(i)){var J=e(6),K=J.arrayBuffer,W=J.dataView;return W.setUint8(0,255),W.setUint8(1,81),W.setUint8(2,3),W.setUint8(3,i.setTempo.microsecondsPerQuarter>>16),W.setUint8(4,i.setTempo.microsecondsPerQuarter>>8),W.setUint8(5,i.setTempo.microsecondsPerQuarter),K}if(function(e){return void 0!==e.smpteOffset}(i)){var X,Y=e(8),Z=Y.arrayBuffer,$=Y.dataView;if(24===i.smpteOffset.frameRate)X=0;else if(25===i.smpteOffset.frameRate)X=32;else if(29===i.smpteOffset.frameRate)X=64;else{if(30!==i.smpteOffset.frameRate)throw new Error;X=96}return $.setUint8(0,255),$.setUint8(1,84),$.setUint8(2,5),$.setUint8(3,i.smpteOffset.hour|X),$.setUint8(4,i.smpteOffset.minutes),$.setUint8(5,i.smpteOffset.seconds),$.setUint8(6,i.smpteOffset.frame),$.setUint8(7,i.smpteOffset.subFrame),Z}if(function(e){return void 0!==e.sysex}(i)){var ee=e(1),te=ee.arrayBuffer;ee.dataView.setUint8(0,240);for(var re=i.sysex.length/2,ne=n(re),ie=e(re),ae=ie.arrayBuffer,fe=ie.dataView,ue=0;ue<i.sysex.length;ue+=2)fe.setUint8(ue/2,parseInt(i.sysex.slice(ue,ue+2),16));return r([te,ne,ae])}if(function(e){return void 0!==e.timeSignature}(i)){for(var se=e(7),oe=se.arrayBuffer,ce=se.dataView,de=i.timeSignature.denominator,Ue=0;de>1;)de/=2,Ue+=1;return ce.setUint8(0,255),ce.setUint8(1,88),ce.setUint8(2,4),ce.setUint8(3,i.timeSignature.numerator),ce.setUint8(4,Ue),ce.setUint8(5,i.timeSignature.metronome),ce.setUint8(6,i.timeSignature.thirtyseconds),oe}if(function(e){return void 0!==e.metaTypeByte}(i))return t(i,parseInt(i.metaTypeByte,16),"text");if(function(e){return void 0!==e.text&&void 0===e.metaTypeByte}(i))return t(i,1,"text");if(function(e){return void 0!==e.trackName}(i))return t(i,3,"trackName");throw new Error('Unencodable event with a delta of "'.concat(i.delta,'".'))}}(r,function(e,t,r,n){return function(i,a,f){var u=e(2),s=u.arrayBuffer,o=u.dataView;o.setUint8(0,255),o.setUint8(1,a);var c=r.encode(i[f]).buffer,d=n(c.byteLength);return t([s,d,c])}}(r,n,new TextEncoder,i),n,i);e.encode=a,e.writeVariableLengthQuantity=i}));
//# sourceMappingURL=/sm/9e272dee374e0e9db1d95046d0d02c3a9612e2b7cdf6926acd2ee4868911e4b5.map