diff --git a/build/nsis/Mixxx.nsi b/build/nsis/Mixxx.nsi
index 5370ab4167e7..5866fc2ea49f 100644
--- a/build/nsis/Mixxx.nsi
+++ b/build/nsis/Mixxx.nsi
@@ -427,6 +427,7 @@ Section "Uninstall"
Delete "$INSTDIR\controllers\Hercules DJ Control MP3.hid.xml"
Delete "$INSTDIR\controllers\Hercules DJ Control MP3.midi.xml"
Delete "$INSTDIR\controllers\Hercules DJ Control Steel.midi.xml"
+ Delete "$INSTDIR\controllers\Hercules P32 DJ.midi.xml"
Delete "$INSTDIR\controllers\Hercules-DJ-Console-4-Mx-scripts.js"
Delete "$INSTDIR\controllers\Hercules-DJ-Console-Mk1-hid-scripts.js"
Delete "$INSTDIR\controllers\Hercules-DJ-Console-Mk2-hid-scripts.js"
@@ -443,6 +444,7 @@ Section "Uninstall"
Delete "$INSTDIR\controllers\Hercules-DJ-Control-MP3-scripts.js"
Delete "$INSTDIR\controllers\Hercules-DJ-Control-Steel-scripts.js"
Delete "$INSTDIR\controllers\Hercules-mp3e2-compat.js"
+ Delete "$INSTDIR\controllers\Hercules-P32-scripts.js"
Delete "$INSTDIR\controllers\HID-Keyboard.js"
Delete "$INSTDIR\controllers\HID-Trackpad.js"
Delete "$INSTDIR\controllers\Ion Discover DJ.midi.xml"
@@ -456,6 +458,9 @@ Section "Uninstall"
Delete "$INSTDIR\controllers\Korg nanoPAD2.midi.xml"
Delete "$INSTDIR\controllers\Korg-nanoKONTROL-2-scripts.js"
Delete "$INSTDIR\controllers\Korg-nanoPAD2-scripts.js"
+ Delete "$INSTDIR\controllers\lodash.mixxx.js"
+ Delete "$INSTDIR\controllers\M-Audio-Xponent-scripts.js"
+ Delete "$INSTDIR\controllers\M-Audio_Xponent.midi.xml"
Delete "$INSTDIR\controllers\korg_nanokontrol2.mixco.output.js"
Delete "$INSTDIR\controllers\korg_nanokontrol2.mixco.output.midi.xml"
Delete "$INSTDIR\controllers\M-Audio_Xsession_pro.midi.xml"
diff --git a/res/controllers/Hercules P32 DJ.midi.xml b/res/controllers/Hercules P32 DJ.midi.xml
new file mode 100644
index 000000000000..4e74fcb05b62
--- /dev/null
+++ b/res/controllers/Hercules P32 DJ.midi.xml
@@ -0,0 +1,2541 @@
+
+
+
+ Hercules P32 DJ
+ Be
+ 4-deck mapping for Hercules P32 controller
+ http://mixxx.org/forums/viewtopic.php?f=7&t=8132
+ http://mixxx.org/wiki/doku.php/hercules_p32_dj
+
+
+
+
+
+
+
+
+ [Master]
+ maximize_library
+ 0x90
+ 0x01
+
+
+
+
+
+ [Master]
+ headSplit
+ 0x93
+ 0x01
+
+
+
+
+
+ [Master]
+ P32.headMixEncoder
+ 0xB3
+ 0x02
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.loopIn.input
+ 0x91
+ 0x50
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.loopOut.input
+ 0x91
+ 0x51
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.loopTogglePad.input
+ 0x91
+ 0x52
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.loopIn.input
+ 0x94
+ 0x50
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.loopOut.input
+ 0x94
+ 0x51
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.loopTogglePad.input
+ 0x94
+ 0x52
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[1].input
+ 0x91
+ 0x60
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[2].input
+ 0x91
+ 0x61
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[3].input
+ 0x91
+ 0x62
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[4].input
+ 0x91
+ 0x63
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[5].input
+ 0x91
+ 0x5C
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[6].input
+ 0x91
+ 0x5D
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[7].input
+ 0x91
+ 0x5E
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[8].input
+ 0x91
+ 0x5F
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[9].input
+ 0x91
+ 0x58
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[10].input
+ 0x91
+ 0x59
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[11].input
+ 0x91
+ 0x5A
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[12].input
+ 0x91
+ 0x5B
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[13].input
+ 0x91
+ 0x54
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[14].input
+ 0x91
+ 0x55
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[15].input
+ 0x91
+ 0x56
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[16].input
+ 0x91
+ 0x57
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[1].input
+ 0x94
+ 0x60
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[2].input
+ 0x94
+ 0x61
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[3].input
+ 0x94
+ 0x62
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[4].input
+ 0x94
+ 0x63
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[5].input
+ 0x94
+ 0x5C
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[6].input
+ 0x94
+ 0x5D
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[7].input
+ 0x94
+ 0x5E
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[8].input
+ 0x94
+ 0x5F
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[9].input
+ 0x94
+ 0x58
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[10].input
+ 0x94
+ 0x59
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[11].input
+ 0x94
+ 0x5A
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[12].input
+ 0x94
+ 0x5B
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[13].input
+ 0x94
+ 0x54
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[14].input
+ 0x94
+ 0x55
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[15].input
+ 0x94
+ 0x56
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.hotcueButton[16].input
+ 0x94
+ 0x57
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.knobs[1].input
+ 0xB1
+ 0x06
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.knobs[2].input
+ 0xB1
+ 0x07
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.knobs[3].input
+ 0xB1
+ 0x08
+
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.knobs[1].input
+ 0xB4
+ 0x06
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.knobs[2].input
+ 0xB4
+ 0x07
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.knobs[3].input
+ 0xB4
+ 0x08
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.dryWetKnob.input
+ 0xB1
+ 0x09
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.dryWetKnob.input
+ 0xB4
+ 0x09
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableButtons[1].input
+ 0x91
+ 0x03
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableButtons[2].input
+ 0x91
+ 0x04
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableButtons[3].input
+ 0x91
+ 0x05
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.showParametersButton.input
+ 0x91
+ 0x06
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableButtons[1].input
+ 0x94
+ 0x03
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableButtons[2].input
+ 0x94
+ 0x04
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableButtons[3].input
+ 0x94
+ 0x05
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.showParametersButton.input
+ 0x94
+ 0x06
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Channel1.input
+ 0x91
+ 0x40
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Channel1.input
+ 0x94
+ 0x40
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Channel2.input
+ 0x91
+ 0x41
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Channel2.input
+ 0x94
+ 0x41
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Channel3.input
+ 0x91
+ 0x42
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Channel3.input
+ 0x94
+ 0x42
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Channel4.input
+ 0x91
+ 0x43
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Channel4.input
+ 0x94
+ 0x43
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Headphone.input
+ 0x91
+ 0x34
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Master.input
+ 0x91
+ 0x35
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Microphone.input
+ 0x91
+ 0x36
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Auxiliary1.input
+ 0x91
+ 0x37
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Headphone.input
+ 0x94
+ 0x34
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Master.input
+ 0x94
+ 0x35
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Microphone.input
+ 0x94
+ 0x36
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.effectUnit.enableOnChannelButtons.Auxiliary1.input
+ 0x94
+ 0x37
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.loopMoveEncoder
+ 0xB4
+ 0x0A
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.play.input
+ 0x91
+ 0x0A
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.cue.input
+ 0x91
+ 0x09
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.cue.input
+ 0x94
+ 0x09
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.play.input
+ 0x94
+ 0x0A
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.sync.input
+ 0x91
+ 0x08
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.sync.input
+ 0x94
+ 0x08
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.tempSlow.input
+ 0x91
+ 0x44
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.tempSlow.input
+ 0x94
+ 0x44
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.tempFast.input
+ 0x91
+ 0x45
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.tempFast.input
+ 0x94
+ 0x45
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.alignBeats.input
+ 0x91
+ 0x46
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.alignBeats.input
+ 0x94
+ 0x46
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.quantize.input
+ 0x91
+ 0x47
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.quantize.input
+ 0x94
+ 0x47
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.shiftButton
+ 0x91
+ 0x07
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.tempoEncoder
+ 0xB1
+ 0x05
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.eqKnob[3].input
+ 0xB1
+ 0x04
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.eqKnob[2].input
+ 0xB1
+ 0x03
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.eqKnob[3].input
+ 0xB4
+ 0x04
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.beatJumpEncoder
+ 0xB4
+ 0x05
+
+
+
+
+
+ [Playlist]
+ P32.browseEncoder
+ 0xB0
+ 0x02
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.pfl.input
+ 0x91
+ 0x10
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.eqKnob[1].input
+ 0xB1
+ 0x02
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.eqKnob[2].input
+ 0xB4
+ 0x03
+
+
+
+
+
+ [Master]
+ crossfader
+ 0xB0
+ 0x01
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.loadTrack
+ 0x91
+ 0x0F
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.volume.input
+ 0xB1
+ 0x01
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.eqKnob[1].input
+ 0xB4
+ 0x02
+
+
+
+
+
+ [Recording]
+ P32.recordButton.input
+ 0x90
+ 0x02
+
+
+
+
+
+ [Recording]
+ P32.slipButton.input
+ 0x90
+ 0x03
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.tempoEncoderPress
+ 0x91
+ 0x02
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.ejectTrack
+ 0x94
+ 0x0F
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.volume.input
+ 0xB4
+ 0x01
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.loopToggleEncoderPress
+ 0x91
+ 0x01
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.beatJumpEncoderPress
+ 0x94
+ 0x02
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.loopToggleEncoderPress
+ 0x94
+ 0x01
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.loopSizeEncoder.input
+ 0xB1
+ 0x0A
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.loopMoveEncoder
+ 0xB5
+ 0x0A
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.play.input
+ 0x92
+ 0x0A
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.cue.input
+ 0x92
+ 0x09
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.cue.input
+ 0x95
+ 0x09
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.play.input
+ 0x95
+ 0x0A
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.sync.input
+ 0x92
+ 0x08
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.sync.input
+ 0x95
+ 0x08
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.shiftButton
+ 0x92
+ 0x07
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.tempoEncoder
+ 0xB2
+ 0x05
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.eqKnob[3].input
+ 0xB2
+ 0x04
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.beatJumpEncoder
+ 0xB5
+ 0x05
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.eqKnob[2].input
+ 0xB2
+ 0x03
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.eqKnob[3].input
+ 0xB5
+ 0x04
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.pfl.input
+ 0x92
+ 0x10
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.eqKnob[1].input
+ 0xB2
+ 0x02
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.eqKnob[2].input
+ 0xB5
+ 0x03
+
+
+
+
+
+ [Master]
+ crossfader
+ 0xB0
+ 0x01
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.loadTrack
+ 0x92
+ 0x0F
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.volume.input
+ 0xB2
+ 0x01
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.eqKnob[1].input
+ 0xB5
+ 0x02
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.tempoEncoderPress
+ 0x92
+ 0x02
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.ejectTrack
+ 0x95
+ 0x0F
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.volume.input
+ 0xB5
+ 0x01
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.loopToggleEncoderPress
+ 0x92
+ 0x01
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.beatJumpEncoderPress
+ 0x95
+ 0x02
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.loopToggleEncoderPress
+ 0x95
+ 0x01
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.loopSizeEncoder.input
+ 0xB2
+ 0x0A
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[1].input
+ 0x92
+ 0x60
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[2].input
+ 0x92
+ 0x61
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[3].input
+ 0x92
+ 0x62
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[4].input
+ 0x92
+ 0x63
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[5].input
+ 0x92
+ 0x5C
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[6].input
+ 0x92
+ 0x5D
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[7].input
+ 0x92
+ 0x5E
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[8].input
+ 0x92
+ 0x5F
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[9].input
+ 0x92
+ 0x58
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[10].input
+ 0x92
+ 0x59
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[11].input
+ 0x92
+ 0x5A
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[12].input
+ 0x92
+ 0x5B
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[13].input
+ 0x92
+ 0x54
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[14].input
+ 0x92
+ 0x55
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[15].input
+ 0x92
+ 0x56
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[16].input
+ 0x92
+ 0x57
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[1].input
+ 0x95
+ 0x60
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[2].input
+ 0x95
+ 0x61
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[3].input
+ 0x95
+ 0x62
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[4].input
+ 0x95
+ 0x63
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[5].input
+ 0x95
+ 0x5C
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[6].input
+ 0x95
+ 0x5D
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[7].input
+ 0x95
+ 0x5E
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[8].input
+ 0x95
+ 0x5F
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[9].input
+ 0x95
+ 0x58
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[10].input
+ 0x95
+ 0x59
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[11].input
+ 0x95
+ 0x5A
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[12].input
+ 0x95
+ 0x5B
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[13].input
+ 0x95
+ 0x54
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[14].input
+ 0x95
+ 0x55
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[15].input
+ 0x95
+ 0x56
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.hotcueButton[16].input
+ 0x95
+ 0x57
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.knobs[1].input
+ 0xB2
+ 0x06
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.knobs[2].input
+ 0xB2
+ 0x07
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.knobs[3].input
+ 0xB2
+ 0x08
+
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.knobs[1].input
+ 0xB5
+ 0x06
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.knobs[2].input
+ 0xB5
+ 0x07
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.knobs[3].input
+ 0xB5
+ 0x08
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.dryWetKnob.input
+ 0xB2
+ 0x09
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.dryWetKnob.input
+ 0xB5
+ 0x09
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableButtons[1].input
+ 0x92
+ 0x03
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableButtons[2].input
+ 0x92
+ 0x04
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableButtons[3].input
+ 0x92
+ 0x05
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.showParametersButton.input
+ 0x92
+ 0x06
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableButtons[1].input
+ 0x95
+ 0x03
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableButtons[2].input
+ 0x95
+ 0x04
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableButtons[3].input
+ 0x95
+ 0x05
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.showParametersButton.input
+ 0x95
+ 0x06
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Headphone.input
+ 0x92
+ 0x34
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Master.input
+ 0x92
+ 0x35
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Microphone.input
+ 0x92
+ 0x36
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Auxiliary1.input
+ 0x92
+ 0x37
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Headphone.input
+ 0x95
+ 0x34
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Master.input
+ 0x95
+ 0x35
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Microphone.input
+ 0x95
+ 0x36
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Auxiliary1.input
+ 0x95
+ 0x37
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Channel1.input
+ 0x92
+ 0x40
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Channel1.input
+ 0x95
+ 0x40
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Channel2.input
+ 0x92
+ 0x41
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Channel2.input
+ 0x95
+ 0x41
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Channel3.input
+ 0x92
+ 0x42
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Channel3.input
+ 0x95
+ 0x42
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Channel4.input
+ 0x92
+ 0x43
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.effectUnit.enableOnChannelButtons.Channel4.input
+ 0x95
+ 0x43
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[1].input
+ 0x91
+ 0x30
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[2].input
+ 0x91
+ 0x31
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[3].input
+ 0x91
+ 0x32
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[4].input
+ 0x91
+ 0x33
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[5].input
+ 0x91
+ 0x2C
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[6].input
+ 0x91
+ 0x2D
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[7].input
+ 0x91
+ 0x2E
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[8].input
+ 0x91
+ 0x2F
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[9].input
+ 0x91
+ 0x28
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[10].input
+ 0x91
+ 0x29
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[11].input
+ 0x91
+ 0x2A
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[12].input
+ 0x91
+ 0x2B
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[13].input
+ 0x91
+ 0x24
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[14].input
+ 0x91
+ 0x25
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[15].input
+ 0x91
+ 0x26
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[16].input
+ 0x91
+ 0x27
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[1].input
+ 0x94
+ 0x30
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[2].input
+ 0x94
+ 0x31
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[3].input
+ 0x94
+ 0x32
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[4].input
+ 0x94
+ 0x33
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[5].input
+ 0x94
+ 0x2C
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[6].input
+ 0x94
+ 0x2D
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[7].input
+ 0x94
+ 0x2E
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[8].input
+ 0x94
+ 0x2F
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[9].input
+ 0x94
+ 0x28
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[10].input
+ 0x94
+ 0x29
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[11].input
+ 0x94
+ 0x2A
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[12].input
+ 0x94
+ 0x2B
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[13].input
+ 0x94
+ 0x24
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[14].input
+ 0x94
+ 0x25
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[15].input
+ 0x94
+ 0x26
+
+
+
+
+
+ [Channel1]
+ P32.leftDeck.samplerButton[16].input
+ 0x94
+ 0x27
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[17].input
+ 0x92
+ 0x30
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[18].input
+ 0x92
+ 0x31
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[19].input
+ 0x92
+ 0x32
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[20].input
+ 0x92
+ 0x33
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[21].input
+ 0x92
+ 0x2C
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[22].input
+ 0x92
+ 0x2D
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[23].input
+ 0x92
+ 0x2E
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[24].input
+ 0x92
+ 0x2F
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[25].input
+ 0x92
+ 0x28
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[26].input
+ 0x92
+ 0x29
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[27].input
+ 0x92
+ 0x2A
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[28].input
+ 0x92
+ 0x2B
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[29].input
+ 0x92
+ 0x24
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[30].input
+ 0x92
+ 0x25
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[31].input
+ 0x92
+ 0x26
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[32].input
+ 0x92
+ 0x27
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[17].input
+ 0x95
+ 0x30
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[18].input
+ 0x95
+ 0x31
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[19].input
+ 0x95
+ 0x32
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[20].input
+ 0x95
+ 0x33
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[21].input
+ 0x95
+ 0x2C
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[22].input
+ 0x95
+ 0x2D
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[23].input
+ 0x95
+ 0x2E
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[24].input
+ 0x95
+ 0x2F
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[25].input
+ 0x95
+ 0x28
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[26].input
+ 0x95
+ 0x29
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[27].input
+ 0x95
+ 0x2A
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[28].input
+ 0x95
+ 0x2B
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[29].input
+ 0x95
+ 0x24
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[30].input
+ 0x95
+ 0x25
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[31].input
+ 0x95
+ 0x26
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.samplerButton[32].input
+ 0x95
+ 0x27
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.loopIn.input
+ 0x92
+ 0x50
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.loopOut.input
+ 0x92
+ 0x51
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.loopTogglePad.input
+ 0x92
+ 0x52
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.loopIn.input
+ 0x95
+ 0x50
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.loopOut.input
+ 0x95
+ 0x51
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.loopTogglePad.input
+ 0x95
+ 0x52
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.tempSlow.input
+ 0x92
+ 0x44
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.tempSlow.input
+ 0x95
+ 0x44
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.tempFast.input
+ 0x92
+ 0x45
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.tempFast.input
+ 0x95
+ 0x45
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.alignBeats.input
+ 0x92
+ 0x46
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.alignBeats.input
+ 0x95
+ 0x46
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.quantize.input
+ 0x92
+ 0x47
+
+
+
+
+
+ [Channel1]
+ P32.rightDeck.quantize.input
+ 0x95
+ 0x47
+
+
+
+
+
+
+
+
diff --git a/res/controllers/Hercules-P32-scripts.js b/res/controllers/Hercules-P32-scripts.js
new file mode 100644
index 000000000000..7091daabd007
--- /dev/null
+++ b/res/controllers/Hercules-P32-scripts.js
@@ -0,0 +1,1501 @@
+// USER CONFIGURABLE OPTIONS
+// loop size (in beats) when Mixxx starts
+var defaultLoopSize = 8;
+// beat jump size when Mixxx starts
+var defaultBeatJumpSize = 4;
+// Set to "true" to use the dot on the loop size LED display to indicate
+// that a loop is active. This restricts loop sizes to 2-32 beats and
+// may be helpful if you never use loops less than 2 beats long.
+// Otherwise the dot indicates a loop size equal to 1/(# on the LED display).
+var loopEnabledDot = false;
+// Assign samplers on left side of the controller to left side of the crossfader
+// and samplers on right side of the controller to the right side of the crossfader
+var samplerCrossfaderAssign = true;
+
+/**
+ * Hercules P32 DJ controller script for Mixxx 2.0
+ * Thanks to Hercules for supporting the development of this mapping by providing a controller
+ * See http://mixxx.org/wiki/doku.php/hercules_p32_dj for instructions on how to use this mapping
+ *
+ * Copyright (C) 2017 Be
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+**/
+'use strict';
+
+/**
+A Control is a JavaScript object that represents a physical component on a controller, such as a
+button, knob, encoder, or fader. It encapsulates all the information needed to receive MIDI input
+from that component and send MIDI signals out to the controller to activate its LED(s). It provides
+generic functions that can be made to work for most use cases just by changing some attributes
+of the Control, without having to write many or any custom functions.
+
+Controls should generally be properties of a ControlContainer object, which provides functions for
+conveniently iterating over a collection of related Controls. Most Controls should be properties of
+a custom Deck object, which is a derivative of ControlContainer. Refer to the Deck documentation for
+more details and an example.
+
+The input function needs to be mapped to the incoming MIDI signals in the XML file. For example:
+
+ [Channel1]
+
+ MyController.leftDeck.quantizeButton.input
+ 0x90
+ 0x01
+
+
+
+
+The output does not need to be mapped in XML. It is handled by the library in JavaScript.
+
+A handful of derivative Control objects are available that are more convenient for common use cases.
+These derivative objects will cover most use cases. In practice, most Controls are derivatives
+of the Button or Pot Controls. Only if you need to make a lot of changes to the default Control
+attributes should you use the Control constructor directly.
+
+Create Controls by calling the constructor with JavaScript's "new" keyword. The Control constructor
+takes a single argument. This is an options object containing properties that get merged with the
+Control when it is created, making it easy to customize the functionality of the Control. Most
+Controls will need at least their midi, group, inCo, and outCo attributes specified.
+
+The midi attribute is a two member array corresponding to the first two MIDI bytes that the
+controller sends/receives when the physical component changes state. Currently, this is only used
+to send out MIDI messages and is not relevant for receiving input because that is handled by
+the XML file. The group property specifies the group that both the inCo and outCo manipulate, for
+example '[Channel1]' for deck 1. The inCo property is the name of the Mixxx ControlObject (see
+http://mixxx.org/wiki/doku.php/mixxxcontrols for a list of them) that this JavaScript Control
+manipulates when it receives a MIDI input signal. When the Mixxx CO specified by outCo changes, this
+JavaScript Control sends MIDI signals back out to the controller. For example:
+
+var quantizeButton = new Button({
+ midi: [0x91, 0x01],
+ group: '[Channel1]'
+ inCo: 'quantize',
+ outCo: 'quantize'
+});
+
+The output callback is automatically connected by the constructor function if the outCo, group,
+and midi properties are specified to the constructor (unless the outConnect property is set to false
+to intentionally avoid that). This makes it easy to map the controller so its LEDs stay synchronized
+with the status of Mixxx, whether the outCo changes because of the Control receiving MIDI input or
+the user changing it with the keyboard, mouse, or another controller. The output callback can be
+easily connected and disconnected by calling the Control's connect() and disconnect() functions. The
+output callback can also be manually run with the appropriate arguments simply by calling the
+Control's trigger() function. The connect(), disconnect(), and trigger() functions are automatically
+called by ControlContainer's reconnectControls and applyLayer functions to make activating different
+layers of functionality easy.
+
+Controls can be used to manage alternate behaviors in different conditions. The most common use case
+for this is for shift buttons. For that case, assign functions to the shift and unshift properties
+that manipulate the Control appropriately. In some cases, using the shift/unshift functions to
+change the Control's inCo, outCo, or group properties will be sufficient. Refer to HotcueButton for
+an example. In more complex cases, changing input() and output() may be required. Refer to
+SamplerButton and EffectUnit for examples. To avoid redundancy (like typing the name of the inCo
+both as the inCo property and in the unshift function), the Control constructor will automatically
+call the unshift function if it exists. The shift() and unshift() functions of ControlContainer will
+call the appropriate function of all the Controls within it that have that function defined
+and will recursively decend into ControlContainers that are properties of the parent
+ControlContainer.
+
+
+Control and its derivative objects use constructor functions with a minimal amount of logic. Most of
+the functionality of Controls comes from their prototype objects. In JavaScript, making a change to
+an object's prototype immediately changes all existing and future objects that have it in their
+prototype chain (regardless of the context in which the derivative objects were created). This
+makes it easy to change the behavior for all (of a subtype) of Control to accomodate the MIDI
+signals used by a particular controller. For example, the Hercules P32 controller sends and receives
+two sets of MIDI signals for most physical components, one for when the shift button is pressed and
+one for when the shift button is not pressed. The controller changes the state of its LEDs when the
+shift buttons are pressed, which is controlled by the alternate set of MIDI signals. These alternate
+MIDI signals are the same as the unshifted ones, but the MIDI channel is 3 higher. So, to avoid
+having the LEDs flicker when the shift button is pressed or having to define separate JavaScript
+Controls for every physical controller component in its shifted and unshifted state, the P32's
+init function has this code:
+
+Control.prototype.shiftOffset = 3;
+Control.prototype.shiftChannel = true;
+Button.prototype.sendShifted = true;
+This causes the Control.prototype.send function to send both the shifted and unshifted MIDI
+signals when the Control's outCo changes. If your controller uses the same MIDI channel but
+different MIDI control numbers when a shift button is pressed, set Control.prototype.shiftControl to
+true instead of Control.prototype.shiftChannel.
+
+
+This library provides more convenient shortcuts for common situations. If inCo and outCo are the
+same, you can specify 'co' in the options object for the constructor to set both inCo and outCo.
+For example:
+
+var quantizeButton = new Button({
+ midi: [0x91, 0x01],
+ group: '[Channel1]'
+ co: 'quantize'
+});
+
+Setting the co property after calling the constructor will not automatically set inCo and outCo;
+you would need to do that manually if necessary.
+
+Also, if a Control only needs its midi property specified for its constructor, this can be provided
+simply as an array without wrapping it in an object. For example:
+
+var playButton = new PlayButton([0x90 + channel, 0x0A]);
+instead of
+var playButton = new PlayButton({
+ midi: [0x90 + channel, 0x0A]
+});
+
+To avoid typing out the group for the constructor of each Control, Controls that share a group can
+be part of a ControlContainer and the ControlContainer's reconnectControls method can assign the
+group to all of them. Refer to the Deck ControlContainer documentation for an example.
+**/
+//
+var Control = function (options) {
+ if (Array.isArray(options) && typeof options[0] === 'number') {
+ this.midi = options;
+ } else {
+ _.assign(this, options);
+ }
+
+ if (typeof this.unshift === 'function') {
+ this.unshift();
+ }
+ // These cannot be in the prototype; they must be unique to each instance.
+ this.isShifted = false;
+ this.connections = [];
+
+ if (options !== undefined && typeof options.co === 'string') {
+ this.inCo = options.co;
+ this.outCo = options.co;
+ }
+
+ if (this.outConnect && this.group !== undefined && this.outCo !== undefined) {
+ this.connect();
+ if (this.outTrigger) {
+ this.trigger();
+ }
+ }
+};
+Control.prototype = {
+ // default attributes
+ // You should probably overwrite at least some of these.
+ inValueScale: function (value) {
+ return value / this.max;
+ },
+ // map input in the XML file, not inValueScale
+ input: function (channel, control, value, status, group) {
+ this.setParameter(this.inValueScale(value));
+ },
+ max: 127, // for MIDI. When adapting for HID this may change.
+ outValueScale: function (value) {return value * this.max;},
+ output: function (value, group, control) {
+ this.send(this.outValueScale(value));
+ },
+ outConnect: true,
+ outTrigger: true,
+
+ // common functions
+ // In most cases, you should not overwrite these.
+ setValue: function (value) {
+ engine.setValue(this.group, this.inCo, value);
+ },
+ setParameter: function (value) {
+ print (this.inCo);
+ engine.setParameter(this.group, this.inCo, value);
+ },
+ // outCo value generally shouldn't be set directly,
+ // only by the output() callback when its value changes,
+ // or by calling trigger()
+ // so don't provide separate setValueIn/setValueOut functions.
+ getValueIn: function () {
+ return engine.getValue(this.group, this.inCo);
+ },
+ getValueOut: function () {
+ return engine.getValue(this.group, this.outCo);
+ },
+ getParameterIn: function () {
+ return engine.getParameter(this.group, this.inCo);
+ },
+ getParameterOut: function () {
+ return engine.getParameter(this.group, this.outCo);
+ },
+ toggle: function () {
+ this.setValue( ! this.getValueIn());
+ },
+ connect: function () {
+ /**
+ Override this method with a custom one to connect multiple Mixxx COs for a single Control.
+ Add the connection objects to the this.connections array so they all get disconnected just
+ by calling this.disconnect(). This can be helpful for multicolor LEDs that show a
+ different color depending on the state of different Mixxx COs. See SamplerButton.connect()
+ and SamplerButton.output() for an example.
+ **/
+ if (undefined !== this.group &&
+ undefined !== this.outCo &&
+ undefined !== this.output &&
+ typeof this.output === 'function') {
+ this.connections[0] = engine.connectControl(this.group, this.outCo, this.output);
+ }
+ },
+ disconnect: function () {
+ if (this.connections[0] !== undefined) {
+ this.connections.forEach(function (connection) {
+ connection.disconnect();
+ });
+ }
+ },
+ trigger: function() {
+ engine.trigger(this.group, this.outCo);
+ },
+ shiftOffset: 0,
+ sendShifted: false,
+ shiftChannel: false,
+ shiftControl: false,
+ send: function (value) {
+ if (this.midi === undefined || this.midi[0] === undefined || this.midi[1] === undefined) {
+ return;
+ }
+ midi.sendShortMsg(this.midi[0], this.midi[1], value);
+ if (this.sendShifted) {
+ if (this.shiftChannel) {
+ midi.sendShortMsg(this.midi[0] + this.shiftOffset, this.midi[1], value);
+ } else if (this.shiftControl) {
+ midi.sendShortMsg(this.midi[0], this.midi[1] + this.shiftOffset, value);
+ }
+ }
+ },
+};
+
+/**
+A Button is a Control derivative for buttons/pads.
+
+For example:
+var quantize = new Button({
+ midi: [0x91, 0x01],
+ group: '[Channel1]',
+ co: 'quantize',
+});
+
+By default, the inCo is toggled only when the button is pressed. For buttons that activate an inCo
+only while they are held down, set the onlyOnPress property to false. For example:
+var tempSlow = new Button({
+ midi: [0x91, 0x44],
+ inCo: 'rate_temp_down',
+ onlyOnPress: false,
+});
+
+The button's LED is sent the value of the "on" property when outCo > 0 and "off" when outCo <= 0.
+By default, on is 127 and off is 0. For buttons/pads with multicolor LEDs, you can change the color
+of the LED by defining the on and off properties to be the MIDI value to send for that state. For
+example, if the LED turns red when sent a MIDI value of 127 and blue when sent a value of 126:
+
+MyController.padColors = {
+ red: 127,
+ blue: 126
+};
+MyController.quantize = new Button({
+ midi: [0x91, 0x01],
+ group: '[Channel1]',
+ co: 'quantize',
+ on: MyController.padColors.red,
+ off: MyController.padColors.blue,
+});
+
+Derivative Buttons are provided for many common use cases, including:
+PlayButton
+CueButton
+SyncButton
+LoopToggleButton
+HotcueButton
+SamplerButton
+These make it easy to map those kinds of buttons without having to worry about particularities
+of Mixxx's ControlObjects that can make mapping them not so straightforward. The PlayButton,
+SyncButton, HotcueButton, and SamplerButton objects also provide alternate functionality for when a
+shift button is pressed.
+
+By default, this works for controllers that send MIDI messages with a different 3rd byte of the
+MIDI message (value) to indicate the button being pressed/released, with the first two bytes
+(status and control) remaining the same for both press and release. If your controller sends
+separate MIDI note on/off messages with on indicated by the first nybble (hexadecimal digit) of
+the first (status) byte being 9 and note off with the first nybble being 8, in your script's init
+function, set Button.prototype.separateNoteOnOff to true and map both the note on and off messages
+in XML to the Button object's input property.
+**/
+var Button = function (options) {
+ Control.call(this, options);
+};
+Button.prototype = new Control({
+ onlyOnPress: true,
+ on: 127,
+ off: 0,
+ inValueScale: function () { return ! this.getValueIn(); },
+ separateNoteOnOff: false,
+ input: function (channel, control, value, status, group) {
+ if (this.onlyOnPress) {
+ var pressed;
+ if (this.separateNoteOnOff) {
+ // Does the first nybble of the first MIDI byte indicate a
+ // note on or note off message?
+ pressed = (status & 0xF0) === 0x90;
+ } else {
+ pressed = value > 0;
+ }
+ if (pressed) {
+ this.setValue(this.inValueScale(value));
+ }
+ } else {
+ this.setValue(this.inValueScale(value));
+ }
+ },
+ outValueScale: function() {
+ return (this.getValueOut()) ? this.on : this.off;
+ },
+});
+
+/**
+PlayButton
+Default behavior: play/pause
+Shift behavior: go to start of track and stop
+
+LED behavior depends on cue mode selected by the user in the preferences
+Refer to http://mixxx.org/manual/latest/chapters/user_interface.html#interface-cue-modes
+**/
+var PlayButton = function (options) {
+ Button.call(this, options);
+};
+PlayButton.prototype = new Button({
+ unshift: function () {
+ this.inCo = 'play';
+ },
+ shift: function () {
+ this.inCo = 'start_stop';
+ },
+ outCo: 'play_indicator'
+});
+
+/**
+CueButton
+Behavior depends on cue mode configured by the user in the preferences
+Refer to http://mixxx.org/manual/latest/chapters/user_interface.html#interface-cue-modes
+**/
+var CueButton = function (options) {
+ Button.call(this, options);
+};
+CueButton.prototype = new Button({
+ inCo: 'cue_default',
+ outCo: 'cue_indicator',
+ onlyOnPress: false
+});
+
+/**
+SyncButton
+Default behavior: momentary sync without toggling sync lock
+Shift behavior: toggle sync lock (master sync)
+**/
+var SyncButton = function (options) {
+ Button.call(this, options);
+};
+SyncButton.prototype = new Button({
+ unshift: function () {
+ this.inCo = 'beatsync';
+ },
+ shift: function () {
+ this.inCo = 'sync_enabled';
+ },
+ outCo: 'sync_enabled'
+});
+
+// Toggle a loop on/off
+var LoopToggleButton = function (options) {
+ Button.call(this, options);
+};
+LoopToggleButton.prototype = new Button({
+ inCo: 'reloop_exit',
+ inValueScale: function () {
+ return 1;
+ },
+ outCo: 'loop_enabled',
+ outValueScale: function (value) {
+ return (value) ? this.on : this.off;
+ }
+});
+
+/**
+HotcueButton
+Default behavior: set hotcue if it is not set. If it is set, jump to it.
+Shift behavior: delete hotcue
+
+The LED indicates whether the hotcue is set.
+
+Pass the number of the hotcue as the number property of the options argument for the constructor.
+For example:
+
+var hotcues = [];
+for (var i = 1; i <= 8; i++) {
+ hotcues[i] = new HotcueButton({
+ number: i,
+ group: '[Channel1]',
+ midi: [0x91, 0x26 + i],
+ });
+}
+
+**/
+var HotcueButton = function (options) {
+ if (options.number === undefined) {
+ print('WARNING: No hotcue number specified for new HotcueButton.');
+ }
+ this.number = options.number;
+ this.outCo = 'hotcue_' + this.number + '_enabled';
+ Button.call(this, options);
+};
+HotcueButton.prototype = new Button({
+ unshift: function () {
+ this.inCo = 'hotcue_' + this.number + '_activate';
+ },
+ shift: function () {
+ this.inCo = 'hotcue_' + this.number + '_clear';
+ },
+ onlyOnPress: false
+});
+
+/**
+SamplerButton
+Default behavior:
+Press the button to load the track selected in the library into an empty sampler. Press a loaded
+sampler to play it from its cue point. Press again while playing to jump back to the cue point.
+Shift behavior:
+If the sampler is playing, stop it. If the sampler is stopped, eject it.
+
+Specify the sampler number as the number property of the object passed to the constructor. There
+is no need to manually specify the group. For example:
+
+var samplerButtons = [];
+for (var n = 1; n <= 8; n++) {
+ samplerButtons[n] = new SamplerButton({
+ number: n,
+ midi: [0x91, 0x02],
+ });
+)};
+
+When the sampler is loaded, the LED will be set to the value of the "on" property. When the sampler
+is empty, the LED will be set to the value of the "off" property. These are inherited from
+Button.prototype if they are not manually specified. If your controller's pads have multicolor LEDs,
+specify the value to send for a different LED color with the playing property to set the LED to a
+different color while the sampler is playing. For example:
+
+MyController.padColors = {
+// These values are just examples, consult the MIDI documentation from your controller's
+manufacturer to find the values for your controller. If that information is not available,
+guess and check to find the values.
+ red: 125,
+ blue: 126,
+ purple: 127,
+ off: 0
+};
+var samplerButton = [];
+var samplerButton[1] = new SamplerButton(
+ midi: [0x91, 0x02],
+ number: 1,
+ on: MyController.padColors.blue,
+ playing: MyController.padColors.red,
+ // off is inherited from Button.prototype
+)};
+**/
+var SamplerButton = function (options) {
+ if (options.number === undefined) {
+ print('WARNING: No sampler number specified for new SamplerButton.');
+ }
+ this.number = options.number;
+ this.group = '[Sampler' + this.number + ']';
+ Button.call(this, options);
+};
+SamplerButton.prototype = new Button({
+ unshift: function () {
+ this.input = function (channel, control, value, status, group) {
+ if (value > 0) {
+ // track_samples is 0 when the sampler is empty and > 0 when a sample is loaded
+ if (engine.getValue(this.group, 'track_samples') === 0) {
+ engine.setValue(this.group, 'LoadSelectedTrack', 1);
+ } else {
+ engine.setValue(this.group, 'cue_gotoandplay', 1);
+ }
+ }
+ };
+ },
+ shift: function() {
+ this.input = function (channel, control, value, status, group) {
+ if (value > 0) {
+ if (engine.getValue(this.group, 'play') === 1) {
+ engine.setValue(this.group, 'play', 0);
+ } else {
+ engine.setValue(this.group, 'eject', 1);
+ }
+ }
+ };
+ },
+ output: function (value, group, control) {
+ if (engine.getValue(this.group, 'track_samples') > 0) {
+ if (this.playing === undefined) {
+ this.send(this.on);
+ } else {
+ if (engine.getValue(this.group, 'play') === 1) {
+ this.send(this.on);
+ } else {
+ this.send(this.playing);
+ }
+ }
+ } else {
+ this.send(this.off);
+ }
+ },
+ connect: function() {
+ this.connections[0] = engine.connectControl(this.group, 'track_samples', this.output);
+ if (this.playing !== undefined) {
+ this.connections[1] = engine.connectControl(this.group, 'play', this.output);
+ }
+ },
+ outCo: null, // hack to get Control constructor to call connect()
+});
+
+/**
+A Pot is a Control for potentiometers (faders and knobs) with finite ranges, although it can be
+adapted for infintely turning encoders. Using a Pot Control is helpful because Pot.connect() and
+Pot.disconnect() take care of soft takeover when switching layers with
+ControlContainer.reconnectControls() and ControlContainer.applyLayer(). Soft takeover is not
+activated until the first input is received so it does not interfere with setting initial values
+for controllers that can report that information.
+
+The midi attribute does not need to be specified because Pots do not send any MIDI output. You may
+want to specify it anyway to make the code self-documenting.
+
+To adapt a Pot for an infinitely rotating encoder, replace its inValueScale() function with a
+function that increments or decrements the parameter depending on the direction the encoder is
+turned. For example, if the encoder sends a MIDI value of 1 for a left turn and 127 for a right
+turn:
+
+MyController.SomePot.inValueScale = function (value) {
+ if (value === 1) {
+ return this.getParameterIn() - .05;
+ } else if (value === 127) {
+ return this.getParameterIn() + .05;
+ }
+}
+**/
+var Pot = function (options) {
+ Control.call(this, options);
+
+ this.firstValueReceived = false;
+};
+Pot.prototype = new Control({
+ inValueScale: function (value) { return value / this.max; },
+ input: function (channel, control, value, status, group) {
+ this.setParameter(this.inValueScale(value));
+ if (! this.firstValueReceived) {
+ this.firstValueReceived = true;
+ this.connect();
+ }
+ },
+ connect: function () {
+ if (this.firstValueReceived) {
+ engine.softTakeover(this.group, this.inCo, true);
+ }
+ },
+ disconnect: function () {
+ engine.softTakeoverIgnoreNextValue(this.group, this.inCo);
+ },
+ trigger: function () {},
+});
+
+/**
+RingEncoder is a Control for encoders with LED rings around them. These are different from Pots
+because they are sent MIDI messages to keep their LED rings in sync with the state of Mixxx and
+do not require soft takeover.
+
+These encoders can often be pushed like a button. Usually, it is best to use a separate Button
+Control to handle the MIDI signals from pushing it.
+
+The generic Control code provides everything to implement a RingEncoder. This RingEncoder Control
+to be able to use instanceof to separate RingEncoders from other Controls and make code more
+self-documenting.
+**/
+var RingEncoder = function (options) {
+ Control.call(this, options);
+};
+RingEncoder.prototype = new Control();
+
+/**
+A ControlContainer is an object that contains Controls as properties, with methods to help
+iterate over those Controls. Documentation for each method is inline below.
+**/
+var ControlContainer = function (initialLayer) {
+ if (typeof initialLayer === 'object') {
+ this.applyLayer(initialLayer);
+ }
+};
+ControlContainer.prototype = {
+ /**
+ forEachControl
+ Iterate over all Controls in this ControlContainer and perform an operation on them.
+
+ operation, function that takes 1 argument:
+ the function to call for each Control. Takes each Control as its first argument.
+ "this" in the context of the function refers to the ControlContainer.
+ recursive, boolean, optional:
+ whether to call forEachControl recursively for each ControlContainer within this
+ ControlContainer. Defaults to true if ommitted.
+ **/
+ forEachControl: function (operation, recursive) {
+ if (typeof operation !== 'function') {
+ print('ERROR: ControlContainer.forEachContainer requires a function argument');
+ return;
+ }
+ if (recursive === undefined) { recursive = true; }
+
+ var that = this;
+ var applyOperationTo = function (obj) {
+ if (obj instanceof Control) {
+ operation.call(that, obj);
+ } else if (recursive && obj instanceof ControlContainer) {
+ obj.forEachControl(operation);
+ } else if (Array.isArray(obj)) {
+ obj.forEach(function (element) {
+ applyOperationTo(element);
+ });
+ }
+ };
+
+ for (var memberName in this) {
+ if (this.hasOwnProperty(memberName)) {
+ applyOperationTo(this[memberName]);
+ }
+ }
+ },
+ /**
+ reconnectControls
+ Disconnect and reconnect output callbacks for each Control. Optionally perform an operation
+ on each Control between disconnecting and reconnecting the output callbacks. Arguments are
+ the same as forEachControl().
+ **/
+ reconnectControls: function (operation, recursive) {
+ this.forEachControl(function (control) {
+ control.disconnect();
+ if (typeof operation === 'function') {
+ operation.call(this, control);
+ }
+ control.connect();
+ control.trigger();
+ }, recursive);
+ },
+ isShifted: false,
+ /**
+ shift
+ Call each Control's shift() function if it exists. This iterates recursively on any
+ Controls in ControlContainers that are properties of this, so there is no need to call
+ shift() on each child ControlContainer.
+ **/
+ shift: function () {
+ this.forEachControl(function (control) {
+ if (typeof control.shift === 'function') {
+ control.shift();
+ }
+ // Set isShifted for child ControlContainers forEachControl is iterating through recursively
+ this.isShifted = true;
+ });
+ },
+ /**
+ unshift
+ Call each Control's unshift() function if it exists. This iterates recursively on any
+ Controls in ControlContainers that are properties of this, so there is no need to call
+ unshift() on each child ControlContainer.
+ **/
+ unshift: function () {
+ this.forEachControl(function (control) {
+ if (typeof control.unshift === 'function') {
+ control.unshift();
+ }
+ // Set isShifted for child ControlContainers forEachControl is iterating through recursively
+ this.isShifted = false;
+ });
+ },
+ /**
+ applyLayer
+ Activate a new layer of functionality. Layers are merely objects with properties to overwrite
+ the properties of the Controls within this ControlContainer. Layer objects are deeply merged.
+ If a new layer does not define a property for a Control, the Control's old property will be
+ retained.
+
+ In the most common case, for providing alternate functionality when a shift button is pressed,
+ using applyLayer() is likely overcomplicated and may be slow. Use shift()/unshift() instead.
+ applyLayer() may be useful for cycling through more than two alternate layers.
+
+ For example:
+ someControlContainer.applyLayer({
+ someButton: { inCo: 'alternate inCo' },
+ anotherButton: { outCo: 'alternate outCo' }
+ });
+
+ By default, the old layer's output callbacks are disconnected and the new layer's output
+ callbacks are connected. To avoid this behavior, which would be desirable if you are not
+ changing any output functionality, pass false as the second argument to applyLayer().
+ **/
+ applyLayer: function (newLayer, reconnectControls) {
+ if (reconnectControls !== false) {
+ reconnectControls = true;
+ }
+ if (reconnectControls === true) {
+ this.forEachControl(function (control) {
+ control.disconnect();
+ });
+ }
+
+ _.merge(this, newLayer);
+
+ if (reconnectControls === true) {
+ this.forEachControl(function (control) {
+ control.connect();
+ control.trigger();
+ });
+ }
+ },
+};
+
+script.samplerRegEx = /\[Sampler(\d+)\]/ ;
+script.channelRegEx = /\[Channel(\d+)\]/ ;
+script.eqKnobRegEx = /\[EqualizerRack1_\[(.*)\]_Effect1\]/ ;
+script.quickEffectRegEx = /\[QuickEffectRack1_\[(.*)\]\]/ ;
+
+/**
+Deck
+This is a ControlContainer with methods for conveniently changing the group attributes of
+contained Controls to switch the deck that a set of Controls is manipulating. The setCurrentDeck()
+method takes the new deck as a string and sets the Controls' group property appropriately, including
+for equalizer knobs and QuickEffect (filter) knobs.
+
+The Deck constructor takes one argument, which is an array of deck numbers to cycle through with the\
+toggle() method. Typically this will be [1, 3] or [2, 4].
+
+To map your own controller, create a custom derivative of Deck and create instances of your custom
+Deck objects in your controller's init() function. Use a constructor function to create all the
+Controls you need for your particular controller and assign your custom derivative's prototype
+to Deck. For example:
+
+MyController.init = function () {
+ this.leftDeck = new MyController.Deck([1, 2]);
+ this.rightDeck = new MyController.Deck([2, 4]);
+};
+MyController.Deck = function (deckNumbers, midiChannel) {
+ // Call the Deck constructor to setup the currentDeck and deckNumbers properties.
+ Deck.call(this, deckNumbers);
+ this.playButton = new PlayButton([0x90 + midiChannel, 0x01]);
+ this.CueButton = new CueButton([0x90 + midiChannel, 0x02]);
+ this.hotcueButtons = [];
+ for (var i = 1; i <= 8; i++) {
+ this.hotcueButtons[i] = new HotcueButton({
+ midi: [0x90 + midiChannel, 0x10 + i],
+ number: i
+ });
+ }
+ // ... define as many other Controls as necessary ...
+
+ // Set the group properties of the above Controls and connect their output callback functions
+ // Without this, the group property for each Control would have to be specified to its
+ // constructor.
+ this.reconnectControls(function (c) {
+ if (c.group === undefined) {
+ // 'this' inside a function passed to reconnectControls refers to the ControlContainer.
+ c.group = this.currentDeck;
+ }
+ });
+};
+MyController.Deck.prototype = new Deck();
+**/
+var Deck = function (deckNumbers) {
+ if (deckNumbers !== undefined && Array.isArray(deckNumbers)) {
+ // These must be unique to each instance, so they cannot be in the prototype.
+ this.currentDeck = '[Channel' + deckNumbers[0] + ']';
+ this.deckNumbers = deckNumbers;
+ }
+};
+Deck.prototype = new ControlContainer({
+ setCurrentDeck: function (newGroup) {
+ this.currentDeck = newGroup;
+ this.reconnectControls(function (control) {
+ if (control.group.search(script.channelRegEx) !== -1) {
+ control.group = this.currentDeck;
+ } else if (control.group.search(script.eqKnobRegEx) !== -1) {
+ control.group = '[EqualizerRack1_' + this.currentDeck + '_Effect1]';
+ } else if (control.group.search(script.quickEffectRegEx) !== -1) {
+ control.group = '[QuickEffectRack1_' + this.currentDeck + ']';
+ }
+ // Do not alter the Control's group if it does not match any of those RegExs because
+ // that could break effects Controls.
+ });
+ },
+ toggle: function () {
+ var index = this.deckNumbers.indexOf(parseInt(
+ script.channelRegEx.exec(this.currentDeck)[1]
+ ));
+ if (index === (this.deckNumbers.length - 1)) {
+ index = 0;
+ } else {
+ index += 1;
+ }
+ this.setCurrentDeck("[Channel" + this.deckNumbers[index] + "]");
+ }
+});
+
+/**
+EffectUnit
+This ControlContainer provides Controls designed to be mapped to the common arrangement of 4 knobs
+and 4 buttons for controlling effects. 3 knobs are used for controlling effect metaknobs
+or parameters, depending on whether the effects' parameters are shown. The other knob is used for
+the dry/wet knob of the whole chain or the superknob when shift is pressed. 3 buttons are used for
+enabling effects and the other button toggles the effect unit between hiding and showing effect
+parameters. The Controls provided are:
+
+dryWetKnob (Pot)
+showParametersButton (Button)
+enableButtons[1-3] (ControlContainer of Buttons)
+knobs[1-3] (ControlContainer of Pots)
+enableOnChannelButtons (ControlContainer of Buttons)
+
+When the effect unit is showing the metaknobs of the effects but not each parameter, the knobs
+control the metaknobs. The enableButtons control whether each effect is enabled. Pressing an
+enableButton with shift switches to the next available effect.
+
+When the effect unit is showing all the parameters, the knobs behave differently depending on
+whether an effect is focused. When there is no focused effect (the default state), the knobs control
+the effect metaknobs like they do when parameters are not showing. When an effect is focused, the
+knobs control the first 3 parameters of the focused effect. An effect can be focused by pressing
+shift + its enableButton or clicking the focus button on screen. Pressing shift + the enableButton
+for the focused effect again unfocuses the effect.
+
+The enableOnChannelButtons allow assigning the effect unit to different channels and are named after
+the Mixxx channel they affect. Not all controllers have buttons to map these. The following Buttons
+are provided by default:
+Channel1
+Channel2
+Channel3
+Channel4
+Headphones
+Master
+Microphone
+Auxiliary1
+You can easily add more, for example for additional microphones, auxiliary inputs, or samplers by
+calling enableOnChannelButtons.addButton('CHANNEL_NAME') (do not put brackets around the
+CHANNEL_NAME).
+
+To map an EffectUnit for your controller, call the constructor with the unit number of the effect
+unit as the only argument. Then, set the midi attributes for the showParametersButton,
+enableButtons[1-3], and optionally enableOnChannelButtons (setting the midi attributes for the Pots
+is not necessary because they do not send any output). After the midi attributes are set up, call
+EffectUnit.init() to set up the output callbacks. For example:
+
+MyController.effectUnit = new EffectUnit(1);
+MyController.effectUnit.enableButtons[1].midi = [0x90, 0x01];
+MyController.effectUnit.enableButtons[2].midi = [0x90, 0x02];
+MyController.effectUnit.enableButtons[3].midi = [0x90, 0x03];
+MyController.effectUnit.showParametersButton.midi = [0x90, 0x04];
+MyController.effectUnit.enableOnChannelButtons.Channel1 = [0x90, 0x05];
+MyController.effectUnit.enableOnChannelButtons.Channel2 = [0x90, 0x06];
+MyController.effectUnit.init();
+
+Controllers designed for Serato and Rekordbox often have an encoder instead of a dry/wet knob
+(labeled "Beats" for Serato or "Release FX" for Rekordbox) and a button labeled "Tap". If the
+encoder sends a MIDI signal when pushed, it is recommended to map the encoder push to the
+EffectUnit's showParametersButton, otherwise map that to the "Tap" button. To use the dryWetKnob
+Pot with an encoder, replace its inValueScale() function with a function that can appropriately
+handle the signals sent by your controller. Refer to the Pot documentation for an example.
+
+For the shift functionality to work, the shift button of your controller must be mapped to a
+function that calls the shift()/unshift() functions of the EffectUnit on button press/release. If
+the EffectUnit is a property of another ControlContainer (for example a Deck), calling shift()
+and unshift() on the parent ControlContainer will recursively call it on the EffectUnit too (just
+like it will for any other ControlContainer).
+**/
+EffectUnit = function (unitNumber) {
+ var eu = this;
+ this.group = '[EffectRack1_EffectUnit' + unitNumber + ']';
+
+ this.dryWetKnob = new Pot({
+ group: this.group,
+ unshift: function () {
+ this.inCo = 'mix';
+ // for soft takeover
+ this.disconnect();
+ this.connect();
+ },
+ shift: function () {
+ this.inCo = 'super1';
+ // for soft takeover
+ this.disconnect();
+ this.connect();
+ eu.knobs.reconnectControls();
+ },
+ outConnect: false,
+ });
+
+ this.enableOnChannelButtons = new ControlContainer();
+ this.enableOnChannelButtons.addButton = function (channel) {
+ this[channel] = new Button({
+ group: eu.group,
+ co: 'group_[' + channel + ']_enable',
+ outConnect: false,
+ });
+ };
+ this.enableOnChannelButtons.addButton('Channel1');
+ this.enableOnChannelButtons.addButton('Channel2');
+ this.enableOnChannelButtons.addButton('Channel3');
+ this.enableOnChannelButtons.addButton('Channel4');
+ this.enableOnChannelButtons.addButton('Headphone');
+ this.enableOnChannelButtons.addButton('Master');
+ this.enableOnChannelButtons.addButton('Microphone');
+ this.enableOnChannelButtons.addButton('Auxiliary1');
+
+ this.EffectUnitKnob = function (number) {
+ this.number = number;
+ Pot.call(this);
+ };
+ this.EffectUnitKnob.prototype = new Pot({
+ onParametersHide: function () {
+ this.group = '[EffectRack1_EffectUnit' + unitNumber + '_Effect' + this.number + ']';
+ this.inCo = 'meta';
+ },
+ onParametersShow: function () {
+ var focused_effect = engine.getValue(eu.group, "focused_effect");
+ if (focused_effect === 0) {
+ // manipulate metaknobs
+ this.onParametersHide();
+ } else {
+ this.group = '[EffectRack1_EffectUnit' + unitNumber + '_Effect' +
+ focused_effect + ']';
+ this.inCo = 'parameter' + this.number;
+ }
+ },
+ });
+
+ this.EffectEnableButton = function (number) {
+ this.number = number;
+ this.group = '[EffectRack1_EffectUnit' + unitNumber + '_Effect' + number + ']';
+ Button.call(this);
+ };
+ this.EffectEnableButton.prototype = new Button({
+ onParametersHide: function () {
+ this.input = Button.prototype.input;
+ this.outCo = 'enabled';
+ this.unshift = function () {
+ this.isShifted = false;
+ this.inCo = 'enabled';
+ this.onlyOnPress = true;
+ };
+ this.shift = function () {
+ this.isShifted = true;
+ this.inCo = 'next_effect';
+ this.onlyOnPress = false;
+ };
+ if (this.isShifted) {
+ this.shift();
+ } else {
+ this.unshift();
+ }
+ },
+ onParametersShow: function () {
+ this.inCo = 'enabled';
+ this.outCo = 'enabled';
+ this.unshift = function () {
+ this.isShifted = false;
+ this.input = Button.prototype.input;
+ this.onlyOnPress = true;
+ };
+ this.shift = function () {
+ this.isShifted = true;
+ this.input = function (channel, control, value, status, group) {
+ if (value > 0) {
+ if (engine.getValue(eu.group, "focused_effect") === this.number) {
+ // focus this effect
+ engine.setValue(eu.group, "focused_effect", 0);
+ } else {
+ // unfocus and make knobs control metaknobs
+ engine.setValue(eu.group, "focused_effect", this.number);
+ }
+ }
+ };
+ };
+ this.connect = function () {
+ this.connections[0] = engine.connectControl(this.group, "enabled", Button.prototype.output);
+ this.connections[1] = engine.connectControl(eu.group, "focused_effect", this.onFocusChanged);
+ };
+ this.onFocusChanged = function (value, group, control) {
+ if (value === this.number) {
+ // make knobs control first 3 parameters of the focused effect
+ eu.knobs.reconnectControls(function (knob) {
+ if (typeof knob.onParametersShow === 'function') {
+ knob.onParametersShow(); // to set new group property
+ }
+ });
+ } else if (value === 0) {
+ // make knobs control metaknobs
+ eu.knobs.reconnectControls(function (knob) {
+ if (typeof knob.onParametersShow === 'function') {
+ knob.onParametersHide(); // to set new group property
+ }
+ });
+ }
+ };
+ if (this.isShifted) {
+ this.shift();
+ } else {
+ this.unshift();
+ }
+ },
+ });
+
+ this.knobs = new ControlContainer();
+ this.enableButtons = new ControlContainer();
+ for (var n = 1; n <= 3; n++) {
+ this.knobs[n] = new this.EffectUnitKnob(n);
+ this.enableButtons[n] = new this.EffectEnableButton(n);
+ }
+
+ this.showParametersButton = new Button({
+ group: this.group,
+ co: 'show_parameters',
+ output: function (value, group, control) {
+ this.send((value > 0) ? this.on : this.off);
+ if (value === 0) {
+ engine.setValue(this.group, "show_focus", 0);
+ // NOTE: calling eu.reconnectControls() here would cause an infinite loop when
+ // calling EffectUnit.reconnectControls().
+ eu.forEachControl(function (c) {
+ if (typeof c.onParametersHide === 'function') {
+ c.disconnect();
+ c.onParametersHide();
+ c.connect();
+ c.trigger();
+ }
+ });
+ } else {
+ engine.setValue(this.group, "show_focus", 1);
+ eu.forEachControl(function (c) {
+ if (typeof c.onParametersShow === 'function') {
+ c.disconnect();
+ c.onParametersShow();
+ c.connect();
+ c.trigger();
+ }
+ });
+ }
+ },
+ outConnect: false,
+ });
+
+ this.init = function () {
+ this.showParametersButton.connect();
+ this.showParametersButton.trigger();
+
+ this.enableOnChannelButtons.forEachControl(function (button) {
+ if (button.midi !== undefined) {
+ button.disconnect();
+ button.connect();
+ button.trigger();
+ }
+ });
+
+ this.forEachControl(function (control) {
+ if (control.group === undefined) {
+ control.group = eu.group;
+ }
+ });
+ };
+};
+EffectUnit.prototype = new ControlContainer();
+
+var P32 = {};
+
+P32.init = function () {
+ Control.prototype.shiftOffset = 3;
+ Control.prototype.shiftChannel = true;
+ Button.prototype.sendShifted = true;
+
+ /**
+ The P32 has encoders for changing tempo, so the actual tempo getting out of sync with a hardware
+ fader and dealing with soft takeover in that situation is not an issue. So, make toggling master
+ sync the default unshifted behavior and momentary sync the shifted behavior.
+ **/
+ SyncButton.prototype.unshift = function () {
+ this.inCo = 'sync_enabled';
+ };
+ SyncButton.prototype.shift = function () {
+ this.inCo = 'beatsync';
+ };
+
+ P32.leftDeck = new P32.Deck([1,3], 1);
+ P32.rightDeck = new P32.Deck([2,4], 2);
+
+ if (engine.getValue('[Master]', 'num_samplers') < 32) {
+ engine.setValue('[Master]', 'num_samplers', 32);
+ }
+
+ // tell controller to send MIDI messages with positions of faders and knobs
+ midi.sendShortMsg(0xB0, 0x7F, 0x7F);
+};
+
+P32.shutdown = function () {
+ for (var channel = 0; channel <= 5; channel++) {
+ for (var button = 1; button <= 0x63; button++) {
+ midi.sendShortMsg(0x90 + channel, button, 0);
+ }
+ }
+};
+
+P32.shiftOffset = 3;
+
+P32.padColors = {
+ red: 125,
+ blue: 126,
+ purple: 127,
+ off: 0
+};
+
+P32.PadNumToMIDIControl = function (PadNum, layer) {
+ // The MIDI control numbers for the pad grid are numbered bottom to top, so
+ // this returns the MIDI control numbers for the pads numbered top to bottom
+ // layer argument is the 0-indexed pad mode, from bottom (sampler) to top (hotcue)
+ PadNum -= 1;
+ var midiRow = 3 - Math.floor(PadNum/4);
+ return 0x24 + 16 * layer + midiRow*4 + PadNum%4;
+};
+
+P32.browseEncoder = function (channel, control, value, status, group) {
+ if (value > 64) {
+ engine.setValue('[Playlist]', 'SelectPrevTrack', 1);
+ } else {
+ engine.setValue('[Playlist]', 'SelectNextTrack', 1);
+ }
+};
+
+P32.headMixEncoder = function (channel, control, value, status, group) {
+ var direction = (value > 64) ? -1 : 1;
+ engine.setValue('[Master]', 'headMix', engine.getValue('[Master]', 'headMix') + (0.25 * direction));
+};
+
+P32.recordButton = new Button({
+ midi: [0x90, 0x02],
+ group: '[Recording]',
+ inCo: 'toggle_recording',
+ onlyOnPress: false,
+ outCo: 'status',
+ sendShifted: false,
+});
+
+P32.slipButton = new Button({
+ midi: [0x90, 0x03],
+ input: function (channel, control, value, status, group) {
+ if (P32.leftDeck.isShifted) {
+ P32.leftDeck.toggle();
+ } else if (P32.rightDeck.isShifted) {
+ P32.rightDeck.toggle();
+ } else {
+ for (var i = 1; i <= 4; i++) {
+ script.toggleControl('[Channel' + i + ']', 'slip_enabled');
+ }
+ }
+ },
+ connect: function () {
+ for (var d = 1; d <= 4; d++) {
+ this.connections.push(
+ engine.connectControl('[Channel' + d + ']', 'slip_enabled', this.output)
+ );
+ }
+ },
+ output: function (value, group, control) {
+ var slipEnabledOnAnyDeck = false;
+ for (var d = 1; d <= 4; d++) {
+ if (engine.getValue('[Channel' + d + ']', 'slip_enabled')) {
+ slipEnabledOnAnyDeck = true;
+ break;
+ }
+ }
+ this.send(slipEnabledOnAnyDeck ? this.on : this.off);
+ },
+ co: 'slip_enabled',
+ sendShifted: false,
+ group: null // hack to get Control constructor to call this.connect()
+});
+
+P32.Deck = function (deckNumbers, channel) {
+ Deck.call(this, deckNumbers);
+
+ var loopSize = defaultLoopSize;
+ var beatJumpSize = defaultBeatJumpSize;
+ var theDeck = this;
+
+ this.shiftButton = function (channel, control, value, status, group) {
+ if (value === 127) {
+ this.shift();
+ } else {
+ this.unshift();
+ }
+ };
+
+ // ===================================== TRANSPORT =========================================
+ this.sync = new SyncButton([0x90 + channel, 0x08]);
+ this.cue = new CueButton([0x90 + channel, 0x09]);
+ this.play = new PlayButton([0x90 + channel, 0x0A]);
+
+ // ===================================== MIXER ==============================================
+ this.eqKnob = [];
+ for (var k = 1; k <= 3; k++) {
+ this.eqKnob[k] = new Pot({
+ midi: [0xB0 + channel, 0x02 + k],
+ group: '[EqualizerRack1_' + this.currentDeck + '_Effect1]',
+ inCo: 'parameter' + k,
+ });
+ }
+
+ this.pfl = new Button({
+ midi: [0x90 + channel, 0x10],
+ co: 'pfl',
+ });
+
+ this.volume = new Pot({
+ midi: [0xB0 + channel, 0x01],
+ inCo: 'volume',
+ });
+
+ // ==================================== PAD GRID ============================================
+ // The slicer layer is handled by this.effectUnit.enableOnChannelButtons, set up under the
+ // EFFECTS section.
+
+ this.hotcueButton = [];
+ this.samplerButton = [];
+ for (var i = 1; i <= 16; i++) {
+ this.hotcueButton[i] = new HotcueButton({
+ midi: [0x90 + channel,
+ P32.PadNumToMIDIControl(i, 3)],
+ number: i,
+ on: P32.padColors.red
+ });
+ var samplerNumber = i + (channel - 1) * 16;
+ this.samplerButton[samplerNumber] = new SamplerButton({
+ midi: [0x90 + channel, P32.PadNumToMIDIControl(i, 0)],
+ number: samplerNumber,
+ on: P32.padColors.red,
+ off: P32.padColors.off,
+ playing: P32.padColors.blue
+ });
+ if (samplerCrossfaderAssign) {
+ engine.setValue('[Sampler' + samplerNumber + ']',
+ 'orientation',
+ (channel === 1) ? 0 : 2
+ );
+ }
+ }
+
+ this.loopIn = new Button({
+ midi: [0x90 + channel, 0x50],
+ inCo: 'loop_in',
+ });
+ this.loopOut = new Button({
+ midi: [0x90 + channel, 0x51],
+ inCo: 'loop_out',
+ });
+ this.loopTogglePad = new LoopToggleButton({
+ midi: [0x90 + channel, 0x52],
+ on: P32.padColors.red,
+ off: P32.padColors.blue,
+ });
+ this.loopIn.send(P32.padColors.purple);
+ this.loopOut.send(P32.padColors.purple);
+
+ this.tempSlow = new Button({
+ midi: [0x90 + channel, 0x44],
+ inCo: 'rate_temp_down',
+ onlyOnPress: false,
+ });
+ this.tempFast = new Button({
+ midi: [0x90 + channel, 0x45],
+ inCo: 'rate_temp_down',
+ onlyOnPress: false,
+ });
+ this.alignBeats = new Button({
+ midi: [0x90 + channel, 0x46],
+ inCo: 'beats_translate_curpos',
+ });
+ this.quantize = new Button({
+ midi: [0x90 + channel, 0x47],
+ co: 'quantize',
+ on: P32.padColors.red,
+ off: P32.padColors.blue,
+ });
+ this.tempSlow.send(P32.padColors.purple);
+ this.tempFast.send(P32.padColors.purple);
+ this.alignBeats.send(P32.padColors.blue);
+
+ // =================================== ENCODERS ==============================================
+ this.loopSizeEncoder = new Control({
+ midi: [0xB0 + channel, 0x1B], // Note: these are the MIDI bytes for the LED readout, not
+ // input from the encoder.
+ input: function (channel, control, value, status, group) {
+ if (loopEnabledDot) {
+ if (value > 64 && loopSize > 2) { // turn left
+ /**
+ Unfortunately, there is no way to show 1 with a dot on the
+ loop size LED.
+ **/
+ loopSize /= 2;
+ engine.setValue(this.group, 'loop_halve', 1);
+ engine.setValue(this.group, 'loop_halve', 0);
+ } else if (value < 64 && loopSize < 32) { // turn right
+ /**
+ Mixxx supports loops longer than 32 beats, but there is no way
+ to show 64 with a dot on the loop size LED.
+ **/
+ loopSize *= 2;
+ engine.setValue(this.group, 'loop_double', 1);
+ engine.setValue(this.group, 'loop_double', 0);
+ }
+ } else {
+ if (value > 64 && loopSize > 1/32) { // turn left
+ /**
+ Mixxx supports loops shorter than 1/32 beats, but there is no
+ way to set the loop size LED less than 1/32 (even though it
+ should be able to show 1/64)
+ **/
+ loopSize /= 2;
+ engine.setValue(this.group, 'loop_halve', 1);
+ engine.setValue(this.group, 'loop_halve', 0);
+ } else if (value < 64 && loopSize < 64) { // turn right
+ /**
+ Mixxx supports loops longer than 64 beats, but the loop size LED
+ only has 2 digits, so it couldn't show 128
+ **/
+ loopSize *= 2;
+ engine.setValue(this.group, 'loop_double', 1);
+ engine.setValue(this.group, 'loop_double', 0);
+ }
+ }
+ this.trigger();
+ },
+ outCo: 'loop_enabled',
+ output: function (value, group, control) {
+ if (loopEnabledDot && value) {
+ this.send(5 - Math.log(loopSize) / Math.log(2));
+ } else {
+ this.send(5 + Math.log(loopSize) / Math.log(2));
+ }
+ }
+ });
+
+ this.loopMoveEncoder = function (channel, control, value, status, group) {
+ var direction = (value > 64) ? -1 : 1;
+ if (loopSize < 1) {
+ engine.setValue(this.currentDeck, 'loop_move', loopSize * direction);
+ } else {
+ engine.setValue(this.currentDeck, 'loop_move', 1 * direction);
+ }
+ };
+
+ this.loopToggleEncoderPress = function (channel, control, value, status, group) {
+ if (value) {
+ if (engine.getValue(this.currentDeck, 'loop_enabled')) {
+ engine.setValue(this.currentDeck, 'reloop_exit', 1);
+ } else {
+ engine.setValue(this.currentDeck, 'beatloop_' + loopSize + '_activate', 1);
+ }
+ } else {
+ if (loopSize <= 1 && engine.getValue(this.currentDeck, 'loop_enabled')) {
+ engine.setValue(this.currentDeck, 'reloop_exit', 1);
+ }
+ }
+ };
+
+ this.tempoEncoder = function (channel, control, value, status, group) {
+ var direction = (value > 64) ? -1 : 1;
+ engine.setValue(this.currentDeck, 'rate', engine.getValue(this.currentDeck, 'rate') + (0.01 * direction));
+ };
+
+ this.tempoEncoderPress = function (channel, control, value, status, group) {
+ if (value) {
+ engine.setValue(this.currentDeck, 'rate', 0);
+ }
+ };
+
+ this.beatJumpEncoder = function (channel, control, value, status, group) {
+ var direction = (value > 64) ? -1 : 1;
+ if (this.beatJumpEncoderPressed) {
+ if (value > 64 && beatJumpSize > 1/32) { // turn left
+ beatJumpSize /= 2;
+ } else if (value < 64 && beatJumpSize < 64) { // turn right
+ beatJumpSize *= 2;
+ }
+ // The firmware will only change the numeric LED readout when sent messages
+ // on the unshifted channel.
+ midi.sendShortMsg(0xB0 + channel - P32.shiftOffset, 0x1B, 5 + Math.log(beatJumpSize) / Math.log(2));
+ } else {
+ engine.setValue(this.currentDeck, 'beatjump', direction * beatJumpSize);
+ }
+ };
+
+ this.beatJumpEncoderPress = function (channel, control, value, status, group) {
+ // The firmware will only change the numeric LED readout when sent messages
+ // on the unshifted channel.
+ if (value === 127) {
+ this.beatJumpEncoderPressed = true;
+ midi.sendShortMsg(0xB0 + channel - P32.shiftOffset, 0x1B, 5 + Math.log(beatJumpSize) / Math.log(2));
+ } else {
+ this.beatJumpEncoderPressed = false;
+ midi.sendShortMsg(0xB0 + channel - P32.shiftOffset, 0x1B, 5 + Math.log(loopSize) / Math.log(2));
+ }
+ };
+
+ this.loadTrack = function (channel, control, value, status, group) {
+ if (value === 127) {
+ engine.setValue(this.currentDeck, 'LoadSelectedTrack', 1);
+ }
+ };
+
+ this.ejectTrack = function (channel, control, value, status, group) {
+ if (value === 127) {
+ engine.setValue(this.currentDeck, 'eject', 1);
+ engine.beginTimer(250, 'engine.setValue("'+this.currentDeck+'", "eject", 0)', true);
+ }
+ };
+
+ this.reconnectControls(function (control) {
+ if (control.group === undefined) {
+ control.group = this.currentDeck;
+ }
+ });
+
+ // ==================================== EFFECTS ==============================================
+ this.effectUnit = new EffectUnit(deckNumbers[0]);
+ this.effectUnit.enableButtons[1].midi = [0x90 + channel, 0x03];
+ this.effectUnit.enableButtons[2].midi = [0x90 + channel, 0x04];
+ this.effectUnit.enableButtons[3].midi = [0x90 + channel, 0x05];
+ this.effectUnit.showParametersButton.midi = [0x90 + channel, 0x06];
+ this.effectUnit.enableOnChannelButtons.Channel1.midi = [0x90 + channel, 0x40];
+ this.effectUnit.enableOnChannelButtons.Channel2.midi = [0x90 + channel, 0x41];
+ this.effectUnit.enableOnChannelButtons.Channel3.midi = [0x90 + channel, 0x42];
+ this.effectUnit.enableOnChannelButtons.Channel4.midi = [0x90 + channel, 0x43];
+ this.effectUnit.enableOnChannelButtons.Headphone.midi = [0x90 + channel, 0x34];
+ this.effectUnit.enableOnChannelButtons.Master.midi = [0x90 + channel, 0x35];
+ this.effectUnit.enableOnChannelButtons.Microphone.midi = [0x90 + channel, 0x36];
+ this.effectUnit.enableOnChannelButtons.Auxiliary1.midi = [0x90 + channel, 0x37];
+ this.effectUnit.enableOnChannelButtons.forEachControl(function (button) {
+ button.on = P32.padColors.red;
+ button.off = P32.padColors.blue;
+ });
+ this.effectUnit.init();
+};
+P32.Deck.prototype = new Deck();
diff --git a/res/controllers/lodash.mixxx.js b/res/controllers/lodash.mixxx.js
new file mode 100644
index 000000000000..2fd971121480
--- /dev/null
+++ b/res/controllers/lodash.mixxx.js
@@ -0,0 +1,2242 @@
+/**
+ * @license
+ * Lodash (Custom Build)
+ * Build: `lodash strict exports="global" include="assign,merge"`
+ * Copyright JS Foundation and other contributors
+ * Released under MIT license
+ * Based on Underscore.js 1.8.3
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
+ */
+;(function() {
+ 'use strict';
+
+ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
+ var undefined;
+
+ /** Used as the semantic version number. */
+ var VERSION = '4.17.1';
+
+ /** Used as the size to enable large array optimizations. */
+ var LARGE_ARRAY_SIZE = 200;
+
+ /** Used to stand-in for `undefined` hash values. */
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
+
+ /** Used to detect hot functions by number of calls within a span of milliseconds. */
+ var HOT_COUNT = 800,
+ HOT_SPAN = 16;
+
+ /** Used as references for various `Number` constants. */
+ var MAX_SAFE_INTEGER = 9007199254740991;
+
+ /** `Object#toString` result references. */
+ var argsTag = '[object Arguments]',
+ arrayTag = '[object Array]',
+ asyncTag = '[object AsyncFunction]',
+ boolTag = '[object Boolean]',
+ dateTag = '[object Date]',
+ errorTag = '[object Error]',
+ funcTag = '[object Function]',
+ genTag = '[object GeneratorFunction]',
+ mapTag = '[object Map]',
+ numberTag = '[object Number]',
+ nullTag = '[object Null]',
+ objectTag = '[object Object]',
+ proxyTag = '[object Proxy]',
+ regexpTag = '[object RegExp]',
+ setTag = '[object Set]',
+ stringTag = '[object String]',
+ undefinedTag = '[object Undefined]',
+ weakMapTag = '[object WeakMap]';
+
+ var arrayBufferTag = '[object ArrayBuffer]',
+ dataViewTag = '[object DataView]',
+ float32Tag = '[object Float32Array]',
+ float64Tag = '[object Float64Array]',
+ int8Tag = '[object Int8Array]',
+ int16Tag = '[object Int16Array]',
+ int32Tag = '[object Int32Array]',
+ uint8Tag = '[object Uint8Array]',
+ uint8ClampedTag = '[object Uint8ClampedArray]',
+ uint16Tag = '[object Uint16Array]',
+ uint32Tag = '[object Uint32Array]';
+
+ /**
+ * Used to match `RegExp`
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
+ */
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
+
+ /** Used to detect host constructors (Safari). */
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
+
+ /** Used to detect unsigned integer values. */
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
+
+ /** Used to identify `toStringTag` values of typed arrays. */
+ var typedArrayTags = {};
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
+ typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
+ typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
+ typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
+ typedArrayTags[uint32Tag] = true;
+ typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
+ typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
+ typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
+ typedArrayTags[errorTag] = typedArrayTags[funcTag] =
+ typedArrayTags[mapTag] = typedArrayTags[numberTag] =
+ typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
+ typedArrayTags[setTag] = typedArrayTags[stringTag] =
+ typedArrayTags[weakMapTag] = false;
+
+ /** Detect free variable `global` from Node.js. */
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
+
+ /** Detect free variable `self`. */
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
+
+ /** Used as a reference to the global object. */
+ var root = freeGlobal || freeSelf || Function('return this')();
+
+ /** Detect free variable `exports`. */
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
+
+ /** Detect free variable `module`. */
+ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
+
+ /** Detect the popular CommonJS extension `module.exports`. */
+ var moduleExports = freeModule && freeModule.exports === freeExports;
+
+ /** Detect free variable `process` from Node.js. */
+ var freeProcess = moduleExports && freeGlobal.process;
+
+ /** Used to access faster Node.js helpers. */
+ var nodeUtil = (function() {
+ try {
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
+ } catch (e) {}
+ }());
+
+ /* Node.js helper references. */
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
+
+ /*--------------------------------------------------------------------------*/
+
+ /**
+ * A faster alternative to `Function#apply`, this function invokes `func`
+ * with the `this` binding of `thisArg` and the arguments of `args`.
+ *
+ * @private
+ * @param {Function} func The function to invoke.
+ * @param {*} thisArg The `this` binding of `func`.
+ * @param {Array} args The arguments to invoke `func` with.
+ * @returns {*} Returns the result of `func`.
+ */
+ function apply(func, thisArg, args) {
+ switch (args.length) {
+ case 0: return func.call(thisArg);
+ case 1: return func.call(thisArg, args[0]);
+ case 2: return func.call(thisArg, args[0], args[1]);
+ case 3: return func.call(thisArg, args[0], args[1], args[2]);
+ }
+ return func.apply(thisArg, args);
+ }
+
+ /**
+ * The base implementation of `_.times` without support for iteratee shorthands
+ * or max array length checks.
+ *
+ * @private
+ * @param {number} n The number of times to invoke `iteratee`.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @returns {Array} Returns the array of results.
+ */
+ function baseTimes(n, iteratee) {
+ var index = -1,
+ result = Array(n);
+
+ while (++index < n) {
+ result[index] = iteratee(index);
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.unary` without support for storing metadata.
+ *
+ * @private
+ * @param {Function} func The function to cap arguments for.
+ * @returns {Function} Returns the new capped function.
+ */
+ function baseUnary(func) {
+ return function(value) {
+ return func(value);
+ };
+ }
+
+ /**
+ * Gets the value at `key` of `object`.
+ *
+ * @private
+ * @param {Object} [object] The object to query.
+ * @param {string} key The key of the property to get.
+ * @returns {*} Returns the property value.
+ */
+ function getValue(object, key) {
+ return object == null ? undefined : object[key];
+ }
+
+ /**
+ * Creates a unary function that invokes `func` with its argument transformed.
+ *
+ * @private
+ * @param {Function} func The function to wrap.
+ * @param {Function} transform The argument transform.
+ * @returns {Function} Returns the new function.
+ */
+ function overArg(func, transform) {
+ return function(arg) {
+ return func(transform(arg));
+ };
+ }
+
+ /*--------------------------------------------------------------------------*/
+
+ /** Used for built-in method references. */
+ var arrayProto = Array.prototype,
+ funcProto = Function.prototype,
+ objectProto = Object.prototype;
+
+ /** Used to detect overreaching core-js shims. */
+ var coreJsData = root['__core-js_shared__'];
+
+ /** Used to resolve the decompiled source of functions. */
+ var funcToString = funcProto.toString;
+
+ /** Used to check objects for own properties. */
+ var hasOwnProperty = objectProto.hasOwnProperty;
+
+ /** Used to detect methods masquerading as native. */
+ var maskSrcKey = (function() {
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
+ return uid ? ('Symbol(src)_1.' + uid) : '';
+ }());
+
+ /**
+ * Used to resolve the
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
+ * of values.
+ */
+ var nativeObjectToString = objectProto.toString;
+
+ /** Used to infer the `Object` constructor. */
+ var objectCtorString = funcToString.call(Object);
+
+ /** Used to detect if a method is native. */
+ var reIsNative = RegExp('^' +
+ funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
+ );
+
+ /** Built-in value references. */
+ var Buffer = moduleExports ? root.Buffer : undefined,
+ Symbol = root.Symbol,
+ Uint8Array = root.Uint8Array,
+ allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined,
+ getPrototype = overArg(Object.getPrototypeOf, Object),
+ objectCreate = Object.create,
+ propertyIsEnumerable = objectProto.propertyIsEnumerable,
+ splice = arrayProto.splice,
+ symToStringTag = Symbol ? Symbol.toStringTag : undefined;
+
+ var defineProperty = (function() {
+ try {
+ var func = getNative(Object, 'defineProperty');
+ func({}, '', {});
+ return func;
+ } catch (e) {}
+ }());
+
+ /* Built-in method references for those with the same name as other `lodash` methods. */
+ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
+ nativeKeys = overArg(Object.keys, Object),
+ nativeMax = Math.max,
+ nativeNow = Date.now;
+
+ /* Built-in method references that are verified to be native. */
+ var Map = getNative(root, 'Map'),
+ nativeCreate = getNative(Object, 'create');
+
+ /** Used to lookup unminified function names. */
+ var realNames = {};
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a `lodash` object which wraps `value` to enable implicit method
+ * chain sequences. Methods that operate on and return arrays, collections,
+ * and functions can be chained together. Methods that retrieve a single value
+ * or may return a primitive value will automatically end the chain sequence
+ * and return the unwrapped value. Otherwise, the value must be unwrapped
+ * with `_#value`.
+ *
+ * Explicit chain sequences, which must be unwrapped with `_#value`, may be
+ * enabled using `_.chain`.
+ *
+ * The execution of chained methods is lazy, that is, it's deferred until
+ * `_#value` is implicitly or explicitly called.
+ *
+ * Lazy evaluation allows several methods to support shortcut fusion.
+ * Shortcut fusion is an optimization to merge iteratee calls; this avoids
+ * the creation of intermediate arrays and can greatly reduce the number of
+ * iteratee executions. Sections of a chain sequence qualify for shortcut
+ * fusion if the section is applied to an array of at least `200` elements
+ * and any iteratees accept only one argument. The heuristic for whether a
+ * section qualifies for shortcut fusion is subject to change.
+ *
+ * Chaining is supported in custom builds as long as the `_#value` method is
+ * directly or indirectly included in the build.
+ *
+ * In addition to lodash methods, wrappers have `Array` and `String` methods.
+ *
+ * The wrapper `Array` methods are:
+ * `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
+ *
+ * The wrapper `String` methods are:
+ * `replace` and `split`
+ *
+ * The wrapper methods that support shortcut fusion are:
+ * `at`, `compact`, `drop`, `dropRight`, `dropWhile`, `filter`, `find`,
+ * `findLast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
+ * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
+ *
+ * The chainable wrapper methods are:
+ * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
+ * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
+ * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
+ * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`,
+ * `difference`, `differenceBy`, `differenceWith`, `drop`, `dropRight`,
+ * `dropRightWhile`, `dropWhile`, `extend`, `extendWith`, `fill`, `filter`,
+ * `flatMap`, `flatMapDeep`, `flatMapDepth`, `flatten`, `flattenDeep`,
+ * `flattenDepth`, `flip`, `flow`, `flowRight`, `fromPairs`, `functions`,
+ * `functionsIn`, `groupBy`, `initial`, `intersection`, `intersectionBy`,
+ * `intersectionWith`, `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`,
+ * `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
+ * `memoize`, `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`,
+ * `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`,
+ * `overEvery`, `overSome`, `partial`, `partialRight`, `partition`, `pick`,
+ * `pickBy`, `plant`, `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`,
+ * `pullAllWith`, `pullAt`, `push`, `range`, `rangeRight`, `rearg`, `reject`,
+ * `remove`, `rest`, `reverse`, `sampleSize`, `set`, `setWith`, `shuffle`,
+ * `slice`, `sort`, `sortBy`, `splice`, `spread`, `tail`, `take`, `takeRight`,
+ * `takeRightWhile`, `takeWhile`, `tap`, `throttle`, `thru`, `toArray`,
+ * `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`, `transform`, `unary`,
+ * `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`,
+ * `unshift`, `unzip`, `unzipWith`, `update`, `updateWith`, `values`,
+ * `valuesIn`, `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`,
+ * `zipObject`, `zipObjectDeep`, and `zipWith`
+ *
+ * The wrapper methods that are **not** chainable by default are:
+ * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
+ * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `conformsTo`, `deburr`,
+ * `defaultTo`, `divide`, `each`, `eachRight`, `endsWith`, `eq`, `escape`,
+ * `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, `findLast`,
+ * `findLastIndex`, `findLastKey`, `first`, `floor`, `forEach`, `forEachRight`,
+ * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`,
+ * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`,
+ * `isArguments`, `isArray`, `isArrayBuffer`, `isArrayLike`, `isArrayLikeObject`,
+ * `isBoolean`, `isBuffer`, `isDate`, `isElement`, `isEmpty`, `isEqual`,
+ * `isEqualWith`, `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`,
+ * `isMap`, `isMatch`, `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`,
+ * `isNumber`, `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`,
+ * `isSafeInteger`, `isSet`, `isString`, `isUndefined`, `isTypedArray`,
+ * `isWeakMap`, `isWeakSet`, `join`, `kebabCase`, `last`, `lastIndexOf`,
+ * `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`,
+ * `min`, `minBy`, `multiply`, `noConflict`, `noop`, `now`, `nth`, `pad`,
+ * `padEnd`, `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`,
+ * `repeat`, `result`, `round`, `runInContext`, `sample`, `shift`, `size`,
+ * `snakeCase`, `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`,
+ * `sortedLastIndexBy`, `startCase`, `startsWith`, `stubArray`, `stubFalse`,
+ * `stubObject`, `stubString`, `stubTrue`, `subtract`, `sum`, `sumBy`,
+ * `template`, `times`, `toFinite`, `toInteger`, `toJSON`, `toLength`,
+ * `toLower`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, `trim`,
+ * `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, `upperCase`,
+ * `upperFirst`, `value`, and `words`
+ *
+ * @name _
+ * @constructor
+ * @category Seq
+ * @param {*} value The value to wrap in a `lodash` instance.
+ * @returns {Object} Returns the new `lodash` wrapper instance.
+ * @example
+ *
+ * function square(n) {
+ * return n * n;
+ * }
+ *
+ * var wrapped = _([1, 2, 3]);
+ *
+ * // Returns an unwrapped value.
+ * wrapped.reduce(_.add);
+ * // => 6
+ *
+ * // Returns a wrapped value.
+ * var squares = wrapped.map(square);
+ *
+ * _.isArray(squares);
+ * // => false
+ *
+ * _.isArray(squares.value());
+ * // => true
+ */
+ function lodash() {
+ // No operation performed.
+ }
+
+ /**
+ * The base implementation of `_.create` without support for assigning
+ * properties to the created object.
+ *
+ * @private
+ * @param {Object} proto The object to inherit from.
+ * @returns {Object} Returns the new object.
+ */
+ var baseCreate = (function() {
+ function object() {}
+ return function(proto) {
+ if (!isObject(proto)) {
+ return {};
+ }
+ if (objectCreate) {
+ return objectCreate(proto);
+ }
+ object.prototype = proto;
+ var result = new object;
+ object.prototype = undefined;
+ return result;
+ };
+ }());
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a hash object.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+ function Hash(entries) {
+ var index = -1,
+ length = entries == null ? 0 : entries.length;
+
+ this.clear();
+ while (++index < length) {
+ var entry = entries[index];
+ this.set(entry[0], entry[1]);
+ }
+ }
+
+ /**
+ * Removes all key-value entries from the hash.
+ *
+ * @private
+ * @name clear
+ * @memberOf Hash
+ */
+ function hashClear() {
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
+ this.size = 0;
+ }
+
+ /**
+ * Removes `key` and its value from the hash.
+ *
+ * @private
+ * @name delete
+ * @memberOf Hash
+ * @param {Object} hash The hash to modify.
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+ function hashDelete(key) {
+ var result = this.has(key) && delete this.__data__[key];
+ this.size -= result ? 1 : 0;
+ return result;
+ }
+
+ /**
+ * Gets the hash value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf Hash
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+ function hashGet(key) {
+ var data = this.__data__;
+ if (nativeCreate) {
+ var result = data[key];
+ return result === HASH_UNDEFINED ? undefined : result;
+ }
+ return hasOwnProperty.call(data, key) ? data[key] : undefined;
+ }
+
+ /**
+ * Checks if a hash value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf Hash
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+ function hashHas(key) {
+ var data = this.__data__;
+ return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
+ }
+
+ /**
+ * Sets the hash `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf Hash
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the hash instance.
+ */
+ function hashSet(key, value) {
+ var data = this.__data__;
+ this.size += this.has(key) ? 0 : 1;
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
+ return this;
+ }
+
+ // Add methods to `Hash`.
+ Hash.prototype.clear = hashClear;
+ Hash.prototype['delete'] = hashDelete;
+ Hash.prototype.get = hashGet;
+ Hash.prototype.has = hashHas;
+ Hash.prototype.set = hashSet;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates an list cache object.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+ function ListCache(entries) {
+ var index = -1,
+ length = entries == null ? 0 : entries.length;
+
+ this.clear();
+ while (++index < length) {
+ var entry = entries[index];
+ this.set(entry[0], entry[1]);
+ }
+ }
+
+ /**
+ * Removes all key-value entries from the list cache.
+ *
+ * @private
+ * @name clear
+ * @memberOf ListCache
+ */
+ function listCacheClear() {
+ this.__data__ = [];
+ this.size = 0;
+ }
+
+ /**
+ * Removes `key` and its value from the list cache.
+ *
+ * @private
+ * @name delete
+ * @memberOf ListCache
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+ function listCacheDelete(key) {
+ var data = this.__data__,
+ index = assocIndexOf(data, key);
+
+ if (index < 0) {
+ return false;
+ }
+ var lastIndex = data.length - 1;
+ if (index == lastIndex) {
+ data.pop();
+ } else {
+ splice.call(data, index, 1);
+ }
+ --this.size;
+ return true;
+ }
+
+ /**
+ * Gets the list cache value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf ListCache
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+ function listCacheGet(key) {
+ var data = this.__data__,
+ index = assocIndexOf(data, key);
+
+ return index < 0 ? undefined : data[index][1];
+ }
+
+ /**
+ * Checks if a list cache value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf ListCache
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+ function listCacheHas(key) {
+ return assocIndexOf(this.__data__, key) > -1;
+ }
+
+ /**
+ * Sets the list cache `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf ListCache
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the list cache instance.
+ */
+ function listCacheSet(key, value) {
+ var data = this.__data__,
+ index = assocIndexOf(data, key);
+
+ if (index < 0) {
+ ++this.size;
+ data.push([key, value]);
+ } else {
+ data[index][1] = value;
+ }
+ return this;
+ }
+
+ // Add methods to `ListCache`.
+ ListCache.prototype.clear = listCacheClear;
+ ListCache.prototype['delete'] = listCacheDelete;
+ ListCache.prototype.get = listCacheGet;
+ ListCache.prototype.has = listCacheHas;
+ ListCache.prototype.set = listCacheSet;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a map cache object to store key-value pairs.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+ function MapCache(entries) {
+ var index = -1,
+ length = entries == null ? 0 : entries.length;
+
+ this.clear();
+ while (++index < length) {
+ var entry = entries[index];
+ this.set(entry[0], entry[1]);
+ }
+ }
+
+ /**
+ * Removes all key-value entries from the map.
+ *
+ * @private
+ * @name clear
+ * @memberOf MapCache
+ */
+ function mapCacheClear() {
+ this.size = 0;
+ this.__data__ = {
+ 'hash': new Hash,
+ 'map': new (Map || ListCache),
+ 'string': new Hash
+ };
+ }
+
+ /**
+ * Removes `key` and its value from the map.
+ *
+ * @private
+ * @name delete
+ * @memberOf MapCache
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+ function mapCacheDelete(key) {
+ var result = getMapData(this, key)['delete'](key);
+ this.size -= result ? 1 : 0;
+ return result;
+ }
+
+ /**
+ * Gets the map value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf MapCache
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+ function mapCacheGet(key) {
+ return getMapData(this, key).get(key);
+ }
+
+ /**
+ * Checks if a map value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf MapCache
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+ function mapCacheHas(key) {
+ return getMapData(this, key).has(key);
+ }
+
+ /**
+ * Sets the map `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf MapCache
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the map cache instance.
+ */
+ function mapCacheSet(key, value) {
+ var data = getMapData(this, key),
+ size = data.size;
+
+ data.set(key, value);
+ this.size += data.size == size ? 0 : 1;
+ return this;
+ }
+
+ // Add methods to `MapCache`.
+ MapCache.prototype.clear = mapCacheClear;
+ MapCache.prototype['delete'] = mapCacheDelete;
+ MapCache.prototype.get = mapCacheGet;
+ MapCache.prototype.has = mapCacheHas;
+ MapCache.prototype.set = mapCacheSet;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a stack cache object to store key-value pairs.
+ *
+ * @private
+ * @constructor
+ * @param {Array} [entries] The key-value pairs to cache.
+ */
+ function Stack(entries) {
+ var data = this.__data__ = new ListCache(entries);
+ this.size = data.size;
+ }
+
+ /**
+ * Removes all key-value entries from the stack.
+ *
+ * @private
+ * @name clear
+ * @memberOf Stack
+ */
+ function stackClear() {
+ this.__data__ = new ListCache;
+ this.size = 0;
+ }
+
+ /**
+ * Removes `key` and its value from the stack.
+ *
+ * @private
+ * @name delete
+ * @memberOf Stack
+ * @param {string} key The key of the value to remove.
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
+ */
+ function stackDelete(key) {
+ var data = this.__data__,
+ result = data['delete'](key);
+
+ this.size = data.size;
+ return result;
+ }
+
+ /**
+ * Gets the stack value for `key`.
+ *
+ * @private
+ * @name get
+ * @memberOf Stack
+ * @param {string} key The key of the value to get.
+ * @returns {*} Returns the entry value.
+ */
+ function stackGet(key) {
+ return this.__data__.get(key);
+ }
+
+ /**
+ * Checks if a stack value for `key` exists.
+ *
+ * @private
+ * @name has
+ * @memberOf Stack
+ * @param {string} key The key of the entry to check.
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
+ */
+ function stackHas(key) {
+ return this.__data__.has(key);
+ }
+
+ /**
+ * Sets the stack `key` to `value`.
+ *
+ * @private
+ * @name set
+ * @memberOf Stack
+ * @param {string} key The key of the value to set.
+ * @param {*} value The value to set.
+ * @returns {Object} Returns the stack cache instance.
+ */
+ function stackSet(key, value) {
+ var data = this.__data__;
+ if (data instanceof ListCache) {
+ var pairs = data.__data__;
+ if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
+ pairs.push([key, value]);
+ this.size = ++data.size;
+ return this;
+ }
+ data = this.__data__ = new MapCache(pairs);
+ }
+ data.set(key, value);
+ this.size = data.size;
+ return this;
+ }
+
+ // Add methods to `Stack`.
+ Stack.prototype.clear = stackClear;
+ Stack.prototype['delete'] = stackDelete;
+ Stack.prototype.get = stackGet;
+ Stack.prototype.has = stackHas;
+ Stack.prototype.set = stackSet;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates an array of the enumerable property names of the array-like `value`.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @param {boolean} inherited Specify returning inherited property names.
+ * @returns {Array} Returns the array of property names.
+ */
+ function arrayLikeKeys(value, inherited) {
+ var isArr = isArray(value),
+ isArg = !isArr && isArguments(value),
+ isBuff = !isArr && !isArg && isBuffer(value),
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
+ skipIndexes = isArr || isArg || isBuff || isType,
+ result = skipIndexes ? baseTimes(value.length, String) : [],
+ length = result.length;
+
+ for (var key in value) {
+ if ((inherited || hasOwnProperty.call(value, key)) &&
+ !(skipIndexes && (
+ // Safari 9 has enumerable `arguments.length` in strict mode.
+ key == 'length' ||
+ // Node.js 0.10 has enumerable non-index properties on buffers.
+ (isBuff && (key == 'offset' || key == 'parent')) ||
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
+ // Skip index properties.
+ isIndex(key, length)
+ ))) {
+ result.push(key);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * This function is like `assignValue` except that it doesn't assign
+ * `undefined` values.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {string} key The key of the property to assign.
+ * @param {*} value The value to assign.
+ */
+ function assignMergeValue(object, key, value) {
+ if ((value !== undefined && !eq(object[key], value)) ||
+ (value === undefined && !(key in object))) {
+ baseAssignValue(object, key, value);
+ }
+ }
+
+ /**
+ * Assigns `value` to `key` of `object` if the existing value is not equivalent
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * for equality comparisons.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {string} key The key of the property to assign.
+ * @param {*} value The value to assign.
+ */
+ function assignValue(object, key, value) {
+ var objValue = object[key];
+ if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
+ (value === undefined && !(key in object))) {
+ baseAssignValue(object, key, value);
+ }
+ }
+
+ /**
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {*} key The key to search for.
+ * @returns {number} Returns the index of the matched value, else `-1`.
+ */
+ function assocIndexOf(array, key) {
+ var length = array.length;
+ while (length--) {
+ if (eq(array[length][0], key)) {
+ return length;
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * The base implementation of `assignValue` and `assignMergeValue` without
+ * value checks.
+ *
+ * @private
+ * @param {Object} object The object to modify.
+ * @param {string} key The key of the property to assign.
+ * @param {*} value The value to assign.
+ */
+ function baseAssignValue(object, key, value) {
+ if (key == '__proto__' && defineProperty) {
+ defineProperty(object, key, {
+ 'configurable': true,
+ 'enumerable': true,
+ 'value': value,
+ 'writable': true
+ });
+ } else {
+ object[key] = value;
+ }
+ }
+
+ /**
+ * The base implementation of `baseForOwn` which iterates over `object`
+ * properties returned by `keysFunc` and invokes `iteratee` for each property.
+ * Iteratee functions may exit iteration early by explicitly returning `false`.
+ *
+ * @private
+ * @param {Object} object The object to iterate over.
+ * @param {Function} iteratee The function invoked per iteration.
+ * @param {Function} keysFunc The function to get the keys of `object`.
+ * @returns {Object} Returns `object`.
+ */
+ var baseFor = createBaseFor();
+
+ /**
+ * The base implementation of `getTag` without fallbacks for buggy environments.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the `toStringTag`.
+ */
+ function baseGetTag(value) {
+ if (value == null) {
+ return value === undefined ? undefinedTag : nullTag;
+ }
+ value = Object(value);
+ return (symToStringTag && symToStringTag in value)
+ ? getRawTag(value)
+ : objectToString(value);
+ }
+
+ /**
+ * The base implementation of `_.isArguments`.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ */
+ function baseIsArguments(value) {
+ return isObjectLike(value) && baseGetTag(value) == argsTag;
+ }
+
+ /**
+ * The base implementation of `_.isNative` without bad shim checks.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a native function,
+ * else `false`.
+ */
+ function baseIsNative(value) {
+ if (!isObject(value) || isMasked(value)) {
+ return false;
+ }
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
+ return pattern.test(toSource(value));
+ }
+
+ /**
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ */
+ function baseIsTypedArray(value) {
+ return isObjectLike(value) &&
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
+ }
+
+ /**
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+ function baseKeys(object) {
+ if (!isPrototype(object)) {
+ return nativeKeys(object);
+ }
+ var result = [];
+ for (var key in Object(object)) {
+ if (hasOwnProperty.call(object, key) && key != 'constructor') {
+ result.push(key);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+ function baseKeysIn(object) {
+ if (!isObject(object)) {
+ return nativeKeysIn(object);
+ }
+ var isProto = isPrototype(object),
+ result = [];
+
+ for (var key in object) {
+ if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
+ result.push(key);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * The base implementation of `_.merge` without support for multiple sources.
+ *
+ * @private
+ * @param {Object} object The destination object.
+ * @param {Object} source The source object.
+ * @param {number} srcIndex The index of `source`.
+ * @param {Function} [customizer] The function to customize merged values.
+ * @param {Object} [stack] Tracks traversed source values and their merged
+ * counterparts.
+ */
+ function baseMerge(object, source, srcIndex, customizer, stack) {
+ if (object === source) {
+ return;
+ }
+ baseFor(source, function(srcValue, key) {
+ if (isObject(srcValue)) {
+ stack || (stack = new Stack);
+ baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
+ }
+ else {
+ var newValue = customizer
+ ? customizer(object[key], srcValue, (key + ''), object, source, stack)
+ : undefined;
+
+ if (newValue === undefined) {
+ newValue = srcValue;
+ }
+ assignMergeValue(object, key, newValue);
+ }
+ }, keysIn);
+ }
+
+ /**
+ * A specialized version of `baseMerge` for arrays and objects which performs
+ * deep merges and tracks traversed objects enabling objects with circular
+ * references to be merged.
+ *
+ * @private
+ * @param {Object} object The destination object.
+ * @param {Object} source The source object.
+ * @param {string} key The key of the value to merge.
+ * @param {number} srcIndex The index of `source`.
+ * @param {Function} mergeFunc The function to merge values.
+ * @param {Function} [customizer] The function to customize assigned values.
+ * @param {Object} [stack] Tracks traversed source values and their merged
+ * counterparts.
+ */
+ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
+ var objValue = object[key],
+ srcValue = source[key],
+ stacked = stack.get(srcValue);
+
+ if (stacked) {
+ assignMergeValue(object, key, stacked);
+ return;
+ }
+ var newValue = customizer
+ ? customizer(objValue, srcValue, (key + ''), object, source, stack)
+ : undefined;
+
+ var isCommon = newValue === undefined;
+
+ if (isCommon) {
+ var isArr = isArray(srcValue),
+ isBuff = !isArr && isBuffer(srcValue),
+ isTyped = !isArr && !isBuff && isTypedArray(srcValue);
+
+ newValue = srcValue;
+ if (isArr || isBuff || isTyped) {
+ if (isArray(objValue)) {
+ newValue = objValue;
+ }
+ else if (isArrayLikeObject(objValue)) {
+ newValue = copyArray(objValue);
+ }
+ else if (isBuff) {
+ isCommon = false;
+ newValue = cloneBuffer(srcValue, true);
+ }
+ else if (isTyped) {
+ isCommon = false;
+ newValue = cloneTypedArray(srcValue, true);
+ }
+ else {
+ newValue = [];
+ }
+ }
+ else if (isPlainObject(srcValue) || isArguments(srcValue)) {
+ newValue = objValue;
+ if (isArguments(objValue)) {
+ newValue = toPlainObject(objValue);
+ }
+ else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
+ newValue = initCloneObject(srcValue);
+ }
+ }
+ else {
+ isCommon = false;
+ }
+ }
+ if (isCommon) {
+ // Recursively merge objects and arrays (susceptible to call stack limits).
+ stack.set(srcValue, newValue);
+ mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
+ stack['delete'](srcValue);
+ }
+ assignMergeValue(object, key, newValue);
+ }
+
+ /**
+ * The base implementation of `_.rest` which doesn't validate or coerce arguments.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @returns {Function} Returns the new function.
+ */
+ function baseRest(func, start) {
+ return setToString(overRest(func, start, identity), func + '');
+ }
+
+ /**
+ * The base implementation of `setToString` without support for hot loop shorting.
+ *
+ * @private
+ * @param {Function} func The function to modify.
+ * @param {Function} string The `toString` result.
+ * @returns {Function} Returns `func`.
+ */
+ var baseSetToString = !defineProperty ? identity : function(func, string) {
+ return defineProperty(func, 'toString', {
+ 'configurable': true,
+ 'enumerable': false,
+ 'value': constant(string),
+ 'writable': true
+ });
+ };
+
+ /**
+ * Creates a clone of `buffer`.
+ *
+ * @private
+ * @param {Buffer} buffer The buffer to clone.
+ * @param {boolean} [isDeep] Specify a deep clone.
+ * @returns {Buffer} Returns the cloned buffer.
+ */
+ function cloneBuffer(buffer, isDeep) {
+ if (isDeep) {
+ return buffer.slice();
+ }
+ var length = buffer.length,
+ result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
+
+ buffer.copy(result);
+ return result;
+ }
+
+ /**
+ * Creates a clone of `arrayBuffer`.
+ *
+ * @private
+ * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
+ * @returns {ArrayBuffer} Returns the cloned array buffer.
+ */
+ function cloneArrayBuffer(arrayBuffer) {
+ var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
+ new Uint8Array(result).set(new Uint8Array(arrayBuffer));
+ return result;
+ }
+
+ /**
+ * Creates a clone of `typedArray`.
+ *
+ * @private
+ * @param {Object} typedArray The typed array to clone.
+ * @param {boolean} [isDeep] Specify a deep clone.
+ * @returns {Object} Returns the cloned typed array.
+ */
+ function cloneTypedArray(typedArray, isDeep) {
+ var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
+ return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
+ }
+
+ /**
+ * Copies the values of `source` to `array`.
+ *
+ * @private
+ * @param {Array} source The array to copy values from.
+ * @param {Array} [array=[]] The array to copy values to.
+ * @returns {Array} Returns `array`.
+ */
+ function copyArray(source, array) {
+ var index = -1,
+ length = source.length;
+
+ array || (array = Array(length));
+ while (++index < length) {
+ array[index] = source[index];
+ }
+ return array;
+ }
+
+ /**
+ * Copies properties of `source` to `object`.
+ *
+ * @private
+ * @param {Object} source The object to copy properties from.
+ * @param {Array} props The property identifiers to copy.
+ * @param {Object} [object={}] The object to copy properties to.
+ * @param {Function} [customizer] The function to customize copied values.
+ * @returns {Object} Returns `object`.
+ */
+ function copyObject(source, props, object, customizer) {
+ var isNew = !object;
+ object || (object = {});
+
+ var index = -1,
+ length = props.length;
+
+ while (++index < length) {
+ var key = props[index];
+
+ var newValue = customizer
+ ? customizer(object[key], source[key], key, object, source)
+ : undefined;
+
+ if (newValue === undefined) {
+ newValue = source[key];
+ }
+ if (isNew) {
+ baseAssignValue(object, key, newValue);
+ } else {
+ assignValue(object, key, newValue);
+ }
+ }
+ return object;
+ }
+
+ /**
+ * Creates a function like `_.assign`.
+ *
+ * @private
+ * @param {Function} assigner The function to assign values.
+ * @returns {Function} Returns the new assigner function.
+ */
+ function createAssigner(assigner) {
+ return baseRest(function(object, sources) {
+ var index = -1,
+ length = sources.length,
+ customizer = length > 1 ? sources[length - 1] : undefined,
+ guard = length > 2 ? sources[2] : undefined;
+
+ customizer = (assigner.length > 3 && typeof customizer == 'function')
+ ? (length--, customizer)
+ : undefined;
+
+ if (guard && isIterateeCall(sources[0], sources[1], guard)) {
+ customizer = length < 3 ? undefined : customizer;
+ length = 1;
+ }
+ object = Object(object);
+ while (++index < length) {
+ var source = sources[index];
+ if (source) {
+ assigner(object, source, index, customizer);
+ }
+ }
+ return object;
+ });
+ }
+
+ /**
+ * Creates a base function for methods like `_.forIn` and `_.forOwn`.
+ *
+ * @private
+ * @param {boolean} [fromRight] Specify iterating from right to left.
+ * @returns {Function} Returns the new base function.
+ */
+ function createBaseFor(fromRight) {
+ return function(object, iteratee, keysFunc) {
+ var index = -1,
+ iterable = Object(object),
+ props = keysFunc(object),
+ length = props.length;
+
+ while (length--) {
+ var key = props[fromRight ? length : ++index];
+ if (iteratee(iterable[key], key, iterable) === false) {
+ break;
+ }
+ }
+ return object;
+ };
+ }
+
+ /**
+ * Gets the data for `map`.
+ *
+ * @private
+ * @param {Object} map The map to query.
+ * @param {string} key The reference key.
+ * @returns {*} Returns the map data.
+ */
+ function getMapData(map, key) {
+ var data = map.__data__;
+ return isKeyable(key)
+ ? data[typeof key == 'string' ? 'string' : 'hash']
+ : data.map;
+ }
+
+ /**
+ * Gets the native function at `key` of `object`.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @param {string} key The key of the method to get.
+ * @returns {*} Returns the function if it's native, else `undefined`.
+ */
+ function getNative(object, key) {
+ var value = getValue(object, key);
+ return baseIsNative(value) ? value : undefined;
+ }
+
+ /**
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
+ *
+ * @private
+ * @param {*} value The value to query.
+ * @returns {string} Returns the raw `toStringTag`.
+ */
+ function getRawTag(value) {
+ var isOwn = hasOwnProperty.call(value, symToStringTag),
+ tag = value[symToStringTag];
+
+ try {
+ value[symToStringTag] = undefined;
+ var unmasked = true;
+ } catch (e) {}
+
+ var result = nativeObjectToString.call(value);
+ if (unmasked) {
+ if (isOwn) {
+ value[symToStringTag] = tag;
+ } else {
+ delete value[symToStringTag];
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Initializes an object clone.
+ *
+ * @private
+ * @param {Object} object The object to clone.
+ * @returns {Object} Returns the initialized clone.
+ */
+ function initCloneObject(object) {
+ return (typeof object.constructor == 'function' && !isPrototype(object))
+ ? baseCreate(getPrototype(object))
+ : {};
+ }
+
+ /**
+ * Checks if `value` is a valid array-like index.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
+ */
+ function isIndex(value, length) {
+ length = length == null ? MAX_SAFE_INTEGER : length;
+ return !!length &&
+ (typeof value == 'number' || reIsUint.test(value)) &&
+ (value > -1 && value % 1 == 0 && value < length);
+ }
+
+ /**
+ * Checks if the given arguments are from an iteratee call.
+ *
+ * @private
+ * @param {*} value The potential iteratee value argument.
+ * @param {*} index The potential iteratee index or key argument.
+ * @param {*} object The potential iteratee object argument.
+ * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
+ * else `false`.
+ */
+ function isIterateeCall(value, index, object) {
+ if (!isObject(object)) {
+ return false;
+ }
+ var type = typeof index;
+ if (type == 'number'
+ ? (isArrayLike(object) && isIndex(index, object.length))
+ : (type == 'string' && index in object)
+ ) {
+ return eq(object[index], value);
+ }
+ return false;
+ }
+
+ /**
+ * Checks if `value` is suitable for use as unique object key.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
+ */
+ function isKeyable(value) {
+ var type = typeof value;
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
+ ? (value !== '__proto__')
+ : (value === null);
+ }
+
+ /**
+ * Checks if `func` has its source masked.
+ *
+ * @private
+ * @param {Function} func The function to check.
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
+ */
+ function isMasked(func) {
+ return !!maskSrcKey && (maskSrcKey in func);
+ }
+
+ /**
+ * Checks if `value` is likely a prototype object.
+ *
+ * @private
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
+ */
+ function isPrototype(value) {
+ var Ctor = value && value.constructor,
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
+
+ return value === proto;
+ }
+
+ /**
+ * This function is like
+ * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
+ * except that it includes inherited enumerable properties.
+ *
+ * @private
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ */
+ function nativeKeysIn(object) {
+ var result = [];
+ if (object != null) {
+ for (var key in Object(object)) {
+ result.push(key);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Converts `value` to a string using `Object.prototype.toString`.
+ *
+ * @private
+ * @param {*} value The value to convert.
+ * @returns {string} Returns the converted string.
+ */
+ function objectToString(value) {
+ return nativeObjectToString.call(value);
+ }
+
+ /**
+ * A specialized version of `baseRest` which transforms the rest array.
+ *
+ * @private
+ * @param {Function} func The function to apply a rest parameter to.
+ * @param {number} [start=func.length-1] The start position of the rest parameter.
+ * @param {Function} transform The rest array transform.
+ * @returns {Function} Returns the new function.
+ */
+ function overRest(func, start, transform) {
+ start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
+ return function() {
+ var args = arguments,
+ index = -1,
+ length = nativeMax(args.length - start, 0),
+ array = Array(length);
+
+ while (++index < length) {
+ array[index] = args[start + index];
+ }
+ index = -1;
+ var otherArgs = Array(start + 1);
+ while (++index < start) {
+ otherArgs[index] = args[index];
+ }
+ otherArgs[start] = transform(array);
+ return apply(func, this, otherArgs);
+ };
+ }
+
+ /**
+ * Sets the `toString` method of `func` to return `string`.
+ *
+ * @private
+ * @param {Function} func The function to modify.
+ * @param {Function} string The `toString` result.
+ * @returns {Function} Returns `func`.
+ */
+ var setToString = shortOut(baseSetToString);
+
+ /**
+ * Creates a function that'll short out and invoke `identity` instead
+ * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
+ * milliseconds.
+ *
+ * @private
+ * @param {Function} func The function to restrict.
+ * @returns {Function} Returns the new shortable function.
+ */
+ function shortOut(func) {
+ var count = 0,
+ lastCalled = 0;
+
+ return function() {
+ var stamp = nativeNow(),
+ remaining = HOT_SPAN - (stamp - lastCalled);
+
+ lastCalled = stamp;
+ if (remaining > 0) {
+ if (++count >= HOT_COUNT) {
+ return arguments[0];
+ }
+ } else {
+ count = 0;
+ }
+ return func.apply(undefined, arguments);
+ };
+ }
+
+ /**
+ * Converts `func` to its source code.
+ *
+ * @private
+ * @param {Function} func The function to convert.
+ * @returns {string} Returns the source code.
+ */
+ function toSource(func) {
+ if (func != null) {
+ try {
+ return funcToString.call(func);
+ } catch (e) {}
+ try {
+ return (func + '');
+ } catch (e) {}
+ }
+ return '';
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Performs a
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
+ * comparison between two values to determine if they are equivalent.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to compare.
+ * @param {*} other The other value to compare.
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ * var other = { 'a': 1 };
+ *
+ * _.eq(object, object);
+ * // => true
+ *
+ * _.eq(object, other);
+ * // => false
+ *
+ * _.eq('a', 'a');
+ * // => true
+ *
+ * _.eq('a', Object('a'));
+ * // => false
+ *
+ * _.eq(NaN, NaN);
+ * // => true
+ */
+ function eq(value, other) {
+ return value === other || (value !== value && other !== other);
+ }
+
+ /**
+ * Checks if `value` is likely an `arguments` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
+ * else `false`.
+ * @example
+ *
+ * _.isArguments(function() { return arguments; }());
+ * // => true
+ *
+ * _.isArguments([1, 2, 3]);
+ * // => false
+ */
+ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
+ return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
+ !propertyIsEnumerable.call(value, 'callee');
+ };
+
+ /**
+ * Checks if `value` is classified as an `Array` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
+ * @example
+ *
+ * _.isArray([1, 2, 3]);
+ * // => true
+ *
+ * _.isArray(document.body.children);
+ * // => false
+ *
+ * _.isArray('abc');
+ * // => false
+ *
+ * _.isArray(_.noop);
+ * // => false
+ */
+ var isArray = Array.isArray;
+
+ /**
+ * Checks if `value` is array-like. A value is considered array-like if it's
+ * not a function and has a `value.length` that's an integer greater than or
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
+ * @example
+ *
+ * _.isArrayLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isArrayLike(document.body.children);
+ * // => true
+ *
+ * _.isArrayLike('abc');
+ * // => true
+ *
+ * _.isArrayLike(_.noop);
+ * // => false
+ */
+ function isArrayLike(value) {
+ return value != null && isLength(value.length) && !isFunction(value);
+ }
+
+ /**
+ * This method is like `_.isArrayLike` except that it also checks if `value`
+ * is an object.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an array-like object,
+ * else `false`.
+ * @example
+ *
+ * _.isArrayLikeObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isArrayLikeObject(document.body.children);
+ * // => true
+ *
+ * _.isArrayLikeObject('abc');
+ * // => false
+ *
+ * _.isArrayLikeObject(_.noop);
+ * // => false
+ */
+ function isArrayLikeObject(value) {
+ return isObjectLike(value) && isArrayLike(value);
+ }
+
+ /**
+ * Checks if `value` is a buffer.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.3.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
+ * @example
+ *
+ * _.isBuffer(new Buffer(2));
+ * // => true
+ *
+ * _.isBuffer(new Uint8Array(2));
+ * // => false
+ */
+ var isBuffer = nativeIsBuffer || stubFalse;
+
+ /**
+ * Checks if `value` is classified as a `Function` object.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
+ * @example
+ *
+ * _.isFunction(_);
+ * // => true
+ *
+ * _.isFunction(/abc/);
+ * // => false
+ */
+ function isFunction(value) {
+ if (!isObject(value)) {
+ return false;
+ }
+ // The use of `Object#toString` avoids issues with the `typeof` operator
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
+ var tag = baseGetTag(value);
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
+ }
+
+ /**
+ * Checks if `value` is a valid array-like length.
+ *
+ * **Note:** This method is loosely based on
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
+ * @example
+ *
+ * _.isLength(3);
+ * // => true
+ *
+ * _.isLength(Number.MIN_VALUE);
+ * // => false
+ *
+ * _.isLength(Infinity);
+ * // => false
+ *
+ * _.isLength('3');
+ * // => false
+ */
+ function isLength(value) {
+ return typeof value == 'number' &&
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
+ }
+
+ /**
+ * Checks if `value` is the
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
+ *
+ * @static
+ * @memberOf _
+ * @since 0.1.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
+ * @example
+ *
+ * _.isObject({});
+ * // => true
+ *
+ * _.isObject([1, 2, 3]);
+ * // => true
+ *
+ * _.isObject(_.noop);
+ * // => true
+ *
+ * _.isObject(null);
+ * // => false
+ */
+ function isObject(value) {
+ var type = typeof value;
+ return value != null && (type == 'object' || type == 'function');
+ }
+
+ /**
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
+ * and has a `typeof` result of "object".
+ *
+ * @static
+ * @memberOf _
+ * @since 4.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
+ * @example
+ *
+ * _.isObjectLike({});
+ * // => true
+ *
+ * _.isObjectLike([1, 2, 3]);
+ * // => true
+ *
+ * _.isObjectLike(_.noop);
+ * // => false
+ *
+ * _.isObjectLike(null);
+ * // => false
+ */
+ function isObjectLike(value) {
+ return value != null && typeof value == 'object';
+ }
+
+ /**
+ * Checks if `value` is a plain object, that is, an object created by the
+ * `Object` constructor or one with a `[[Prototype]]` of `null`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.8.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * }
+ *
+ * _.isPlainObject(new Foo);
+ * // => false
+ *
+ * _.isPlainObject([1, 2, 3]);
+ * // => false
+ *
+ * _.isPlainObject({ 'x': 0, 'y': 0 });
+ * // => true
+ *
+ * _.isPlainObject(Object.create(null));
+ * // => true
+ */
+ function isPlainObject(value) {
+ if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
+ return false;
+ }
+ var proto = getPrototype(value);
+ if (proto === null) {
+ return true;
+ }
+ var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
+ return typeof Ctor == 'function' && Ctor instanceof Ctor &&
+ funcToString.call(Ctor) == objectCtorString;
+ }
+
+ /**
+ * Checks if `value` is classified as a typed array.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to check.
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
+ * @example
+ *
+ * _.isTypedArray(new Uint8Array);
+ * // => true
+ *
+ * _.isTypedArray([]);
+ * // => false
+ */
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
+
+ /**
+ * Converts `value` to a plain object flattening inherited enumerable string
+ * keyed properties of `value` to own properties of the plain object.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Lang
+ * @param {*} value The value to convert.
+ * @returns {Object} Returns the converted plain object.
+ * @example
+ *
+ * function Foo() {
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.assign({ 'a': 1 }, new Foo);
+ * // => { 'a': 1, 'b': 2 }
+ *
+ * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
+ * // => { 'a': 1, 'b': 2, 'c': 3 }
+ */
+ function toPlainObject(value) {
+ return copyObject(value, keysIn(value));
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Assigns own enumerable string keyed properties of source objects to the
+ * destination object. Source objects are applied from left to right.
+ * Subsequent sources overwrite property assignments of previous sources.
+ *
+ * **Note:** This method mutates `object` and is loosely based on
+ * [`Object.assign`](https://mdn.io/Object/assign).
+ *
+ * @static
+ * @memberOf _
+ * @since 0.10.0
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @see _.assignIn
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * }
+ *
+ * function Bar() {
+ * this.c = 3;
+ * }
+ *
+ * Foo.prototype.b = 2;
+ * Bar.prototype.d = 4;
+ *
+ * _.assign({ 'a': 0 }, new Foo, new Bar);
+ * // => { 'a': 1, 'c': 3 }
+ */
+ var assign = createAssigner(function(object, source) {
+ if (isPrototype(source) || isArrayLike(source)) {
+ copyObject(source, keys(source), object);
+ return;
+ }
+ for (var key in source) {
+ if (hasOwnProperty.call(source, key)) {
+ assignValue(object, key, source[key]);
+ }
+ }
+ });
+
+ /**
+ * Creates an array of the own enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects. See the
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
+ * for more details.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keys(new Foo);
+ * // => ['a', 'b'] (iteration order is not guaranteed)
+ *
+ * _.keys('hi');
+ * // => ['0', '1']
+ */
+ function keys(object) {
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
+ }
+
+ /**
+ * Creates an array of the own and inherited enumerable property names of `object`.
+ *
+ * **Note:** Non-object values are coerced to objects.
+ *
+ * @static
+ * @memberOf _
+ * @since 3.0.0
+ * @category Object
+ * @param {Object} object The object to query.
+ * @returns {Array} Returns the array of property names.
+ * @example
+ *
+ * function Foo() {
+ * this.a = 1;
+ * this.b = 2;
+ * }
+ *
+ * Foo.prototype.c = 3;
+ *
+ * _.keysIn(new Foo);
+ * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
+ */
+ function keysIn(object) {
+ return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
+ }
+
+ /**
+ * This method is like `_.assign` except that it recursively merges own and
+ * inherited enumerable string keyed properties of source objects into the
+ * destination object. Source properties that resolve to `undefined` are
+ * skipped if a destination value exists. Array and plain object properties
+ * are merged recursively. Other objects and value types are overridden by
+ * assignment. Source objects are applied from left to right. Subsequent
+ * sources overwrite property assignments of previous sources.
+ *
+ * **Note:** This method mutates `object`.
+ *
+ * @static
+ * @memberOf _
+ * @since 0.5.0
+ * @category Object
+ * @param {Object} object The destination object.
+ * @param {...Object} [sources] The source objects.
+ * @returns {Object} Returns `object`.
+ * @example
+ *
+ * var object = {
+ * 'a': [{ 'b': 2 }, { 'd': 4 }]
+ * };
+ *
+ * var other = {
+ * 'a': [{ 'c': 3 }, { 'e': 5 }]
+ * };
+ *
+ * _.merge(object, other);
+ * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
+ */
+ var merge = createAssigner(function(object, source, srcIndex) {
+ baseMerge(object, source, srcIndex);
+ });
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * Creates a function that returns `value`.
+ *
+ * @static
+ * @memberOf _
+ * @since 2.4.0
+ * @category Util
+ * @param {*} value The value to return from the new function.
+ * @returns {Function} Returns the new constant function.
+ * @example
+ *
+ * var objects = _.times(2, _.constant({ 'a': 1 }));
+ *
+ * console.log(objects);
+ * // => [{ 'a': 1 }, { 'a': 1 }]
+ *
+ * console.log(objects[0] === objects[1]);
+ * // => true
+ */
+ function constant(value) {
+ return function() {
+ return value;
+ };
+ }
+
+ /**
+ * This method returns the first argument it receives.
+ *
+ * @static
+ * @since 0.1.0
+ * @memberOf _
+ * @category Util
+ * @param {*} value Any value.
+ * @returns {*} Returns `value`.
+ * @example
+ *
+ * var object = { 'a': 1 };
+ *
+ * console.log(_.identity(object) === object);
+ * // => true
+ */
+ function identity(value) {
+ return value;
+ }
+
+ /**
+ * This method returns `false`.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.13.0
+ * @category Util
+ * @returns {boolean} Returns `false`.
+ * @example
+ *
+ * _.times(2, _.stubFalse);
+ * // => [false, false]
+ */
+ function stubFalse() {
+ return false;
+ }
+
+ /*------------------------------------------------------------------------*/
+
+ // Add methods that return wrapped values in chain sequences.
+ lodash.assign = assign;
+ lodash.constant = constant;
+ lodash.keys = keys;
+ lodash.keysIn = keysIn;
+ lodash.merge = merge;
+ lodash.toPlainObject = toPlainObject;
+
+ /*------------------------------------------------------------------------*/
+
+ // Add methods that return unwrapped values in chain sequences.
+ lodash.eq = eq;
+ lodash.identity = identity;
+ lodash.isArguments = isArguments;
+ lodash.isArray = isArray;
+ lodash.isArrayLike = isArrayLike;
+ lodash.isArrayLikeObject = isArrayLikeObject;
+ lodash.isBuffer = isBuffer;
+ lodash.isFunction = isFunction;
+ lodash.isLength = isLength;
+ lodash.isObject = isObject;
+ lodash.isObjectLike = isObjectLike;
+ lodash.isPlainObject = isPlainObject;
+ lodash.isTypedArray = isTypedArray;
+ lodash.stubFalse = stubFalse;
+
+ /*------------------------------------------------------------------------*/
+
+ /**
+ * The semantic version number.
+ *
+ * @static
+ * @memberOf _
+ * @type {string}
+ */
+ lodash.VERSION = VERSION;
+
+ /*--------------------------------------------------------------------------*/
+
+ // Export to the global object.
+ root._ = lodash;
+}.call(this));