function e(e,t){var n=e.__state.conversionName.toString(),o=Math.round(e.r),i=Math.round(e.g),r=Math.round(e.b),s=e.a,a=Math.round(e.h),l=e.s.toFixed(1),d=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var c=e.hex.toString(16);c.length<6;)c="0"+c;return"#"+c}return"CSS_RGB"===n?"rgb("+o+","+i+","+r+")":"CSS_RGBA"===n?"rgba("+o+","+i+","+r+","+s+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+o+","+i+","+r+"]":"RGBA_ARRAY"===n?"["+o+","+i+","+r+","+s+"]":"RGB_OBJ"===n?"{r:"+o+",g:"+i+",b:"+r+"}":"RGBA_OBJ"===n?"{r:"+o+",g:"+i+",b:"+r+",a:"+s+"}":"HSV_OBJ"===n?"{h:"+a+",s:"+l+",v:"+d+"}":"HSVA_OBJ"===n?"{h:"+a+",s:"+l+",v:"+d+",a:"+s+"}":"unknown format"}var t=Array.prototype.forEach,n=Array.prototype.slice,o={BREAK:{},extend:function(e){return this.each(n.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))}),this),e},defaults:function(e){return this.each(n.call(arguments,1),(function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))}),this),e},compose:function(){var e=n.call(arguments);return function(){for(var t=n.call(arguments),o=e.length-1;o>=0;o--)t=[e[o].apply(this,t)];return t[0]}},each:function(e,n,o){if(e)if(t&&e.forEach&&e.forEach===t)e.forEach(n,o);else if(e.length===e.length+0){var i,r=void 0;for(r=0,i=e.length;r<i;r++)if(r in e&&n.call(o,e[r],r)===this.BREAK)return}else for(var s in e)if(n.call(o,e[s],s)===this.BREAK)return},defer:function(e){setTimeout(e,0)},debounce:function(e,t,n){var o=void 0;return function(){var i=this,r=arguments;var s=n||!o;clearTimeout(o),o=setTimeout((function(){o=null,n||e.apply(i,r)}),t),s&&e.apply(i,r)}},toArray:function(e){return e.toArray?e.toArray():n.call(e)},isUndefined:function(e){return void 0===e},isNull:function(e){return null===e},isNaN:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e){return isNaN(e)})),isArray:Array.isArray||function(e){return e.constructor===Array},isObject:function(e){return e===Object(e)},isNumber:function(e){return e===e+0},isString:function(e){return e===e+""},isBoolean:function(e){return!1===e||!0===e},isFunction:function(e){return e instanceof Function}},i=[{litmus:o.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString(),0)}},write:e},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString(),0)}},write:e},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:e},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:e}}},{litmus:o.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:o.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return 4===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:o.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(o.isNumber(e.r)&&o.isNumber(e.g)&&o.isNumber(e.b)&&o.isNumber(e.a))&&{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return!!(o.isNumber(e.r)&&o.isNumber(e.g)&&o.isNumber(e.b))&&{space:"RGB",r:e.r,g:e.g,b:e.b}},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return!!(o.isNumber(e.h)&&o.isNumber(e.s)&&o.isNumber(e.v)&&o.isNumber(e.a))&&{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return!!(o.isNumber(e.h)&&o.isNumber(e.s)&&o.isNumber(e.v))&&{space:"HSV",h:e.h,s:e.s,v:e.v}},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}],r=void 0,s=void 0,a=function(){s=!1;var e=arguments.length>1?o.toArray(arguments):arguments[0];return o.each(i,(function(t){if(t.litmus(e))return o.each(t.conversions,(function(t,n){if(r=t.read(e),!1===s&&!1!==r)return s=r,r.conversionName=n,r.conversion=t,o.BREAK})),o.BREAK})),s},l=void 0,d={hsv_to_rgb:function(e,t,n){var o=Math.floor(e/60)%6,i=e/60-Math.floor(e/60),r=n*(1-t),s=n*(1-i*t),a=n*(1-(1-i)*t),l=[[n,a,r],[s,n,r],[r,n,a],[r,s,n],[a,r,n],[n,r,s]][o];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var o=Math.min(e,t,n),i=Math.max(e,t,n),r=i-o,s=void 0;return 0===i?{h:NaN,s:0,v:0}:(s=e===i?(t-n)/r:t===i?2+(n-e)/r:4+(e-t)/r,(s/=6)<0&&(s+=1),{h:360*s,s:r/i,v:i/255})},rgb_to_hex:function(e,t,n){var o=this.hex_with_component(0,2,e);return o=this.hex_with_component(o,1,t),o=this.hex_with_component(o,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(l=8*t)|e&~(255<<l)}},c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},_=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),h=function e(t,n,o){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var r=Object.getPrototypeOf(t);return null===r?void 0:e(r,n,o)}if("value"in i)return i.value;var s=i.get;return void 0!==s?s.call(o):void 0},p=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},f=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},m=function(){function t(){if(u(this,t),this.__state=a.apply(this,arguments),!1===this.__state)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}return _(t,[{key:"toString",value:function(){return e(this)}},{key:"toHexString",value:function(){return e(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),t}();function g(e,t,n){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space||m.recalculateRGB(this,t,n),this.__state[t]},set:function(e){"RGB"!==this.__state.space&&(m.recalculateRGB(this,t,n),this.__state.space="RGB"),this.__state[t]=e}})}function b(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space||m.recalculateHSV(this),this.__state[t]},set:function(e){"HSV"!==this.__state.space&&(m.recalculateHSV(this),this.__state.space="HSV"),this.__state[t]=e}})}m.recalculateRGB=function(e,t,n){if("HEX"===e.__state.space)e.__state[t]=d.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw new Error("Corrupted color state");o.extend(e.__state,d.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}},m.recalculateHSV=function(e){var t=d.rgb_to_hsv(e.r,e.g,e.b);o.extend(e.__state,{s:t.s,v:t.v}),o.isNaN(t.h)?o.isUndefined(e.__state.h)&&(e.__state.h=0):e.__state.h=t.h},m.COMPONENTS=["r","g","b","h","s","v","hex","a"],g(m.prototype,"r",2),g(m.prototype,"g",1),g(m.prototype,"b",0),b(m.prototype,"h"),b(m.prototype,"s"),b(m.prototype,"v"),Object.defineProperty(m.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(m.prototype,"hex",{get:function(){return"HEX"!==this.__state.space&&(this.__state.hex=d.rgb_to_hex(this.r,this.g,this.b),this.__state.space="HEX"),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}});var v=function(){function e(t,n){u(this,e),this.initialValue=t[n],this.domElement=document.createElement("div"),this.object=t,this.property=n,this.__onChange=void 0,this.__onFinishChange=void 0}return _(e,[{key:"onChange",value:function(e){return this.__onChange=e,this}},{key:"onFinishChange",value:function(e){return this.__onFinishChange=e,this}},{key:"setValue",value:function(e){return this.object[this.property]=e,this.__onChange&&this.__onChange.call(this,e),this.updateDisplay(),this}},{key:"getValue",value:function(){return this.object[this.property]}},{key:"updateDisplay",value:function(){return this}},{key:"isModified",value:function(){return this.initialValue!==this.getValue()}}]),e}(),y={};o.each({HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},(function(e,t){o.each(e,(function(e){y[e]=t}))}));var w=/(\d+(\.\d+)?)px/;function x(e){if("0"===e||o.isUndefined(e))return 0;var t=e.match(w);return o.isNull(t)?0:parseFloat(t[1])}var E={makeSelectable:function(e,t){void 0!==e&&void 0!==e.style&&(e.onselectstart=t?function(){return!1}:function(){},e.style.MozUserSelect=t?"auto":"none",e.style.KhtmlUserSelect=t?"auto":"none",e.unselectable=t?"on":"off")},makeFullscreen:function(e,t,n){var i=n,r=t;o.isUndefined(r)&&(r=!0),o.isUndefined(i)&&(i=!0),e.style.position="absolute",r&&(e.style.left=0,e.style.right=0),i&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,t,n,i){var r=n||{},s=y[t];if(!s)throw new Error("Event type "+t+" not supported.");var a=document.createEvent(s);switch(s){case"MouseEvents":var l=r.x||r.clientX||0,d=r.y||r.clientY||0;a.initMouseEvent(t,r.bubbles||!1,r.cancelable||!0,window,r.clickCount||1,0,0,l,d,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var c=a.initKeyboardEvent||a.initKeyEvent;o.defaults(r,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),c(t,r.bubbles||!1,r.cancelable,window,r.ctrlKey,r.altKey,r.shiftKey,r.metaKey,r.keyCode,r.charCode);break;default:a.initEvent(t,r.bubbles||!1,r.cancelable||!0)}o.defaults(a,i),e.dispatchEvent(a)},bind:function(e,t,n,o){var i=o||!1;return e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on"+t,n),E},unbind:function(e,t,n,o){var i=o||!1;return e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent&&e.detachEvent("on"+t,n),E},addClass:function(e,t){if(void 0===e.className)e.className=t;else if(e.className!==t){var n=e.className.split(/ +/);-1===n.indexOf(t)&&(n.push(t),e.className=n.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return E},removeClass:function(e,t){if(t)if(e.className===t)e.removeAttribute("class");else{var n=e.className.split(/ +/),o=n.indexOf(t);-1!==o&&(n.splice(o,1),e.className=n.join(" "))}else e.className=void 0;return E},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return x(t["border-left-width"])+x(t["border-right-width"])+x(t["padding-left"])+x(t["padding-right"])+x(t.width)},getHeight:function(e){var t=getComputedStyle(e);return x(t["border-top-width"])+x(t["border-bottom-width"])+x(t["padding-top"])+x(t["padding-bottom"])+x(t.height)},getOffset:function(e){var t=e,n={left:0,top:0};if(t.offsetParent)do{n.left+=t.offsetLeft,n.top+=t.offsetTop,t=t.offsetParent}while(t);return n},isActive:function(e){return e===document.activeElement&&(e.type||e.href)}},C=function(){function e(t,n){u(this,e);var o=f(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),i=o;return o.__prev=o.getValue(),o.__checkbox=document.createElement("input"),o.__checkbox.setAttribute("type","checkbox"),E.bind(o.__checkbox,"change",(function(){i.setValue(!i.__prev)}),!1),o.domElement.appendChild(o.__checkbox),o.updateDisplay(),o}return p(e,v),_(e,[{key:"setValue",value:function(t){var n=h(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,t);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),n}},{key:"updateDisplay",value:function(){return!0===this.getValue()?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0,this.__prev=!0):(this.__checkbox.checked=!1,this.__prev=!1),h(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}(),A=function(){function e(t,n,i){u(this,e);var r=f(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),s=i,a=r;if(r.__select=document.createElement("select"),o.isArray(s)){var l={};o.each(s,(function(e){l[e]=e})),s=l}return o.each(s,(function(e,t){var n=document.createElement("option");n.innerHTML=t,n.setAttribute("value",e),a.__select.appendChild(n)})),r.updateDisplay(),E.bind(r.__select,"change",(function(){var e=this.options[this.selectedIndex].value;a.setValue(e)})),r.domElement.appendChild(r.__select),r}return p(e,v),_(e,[{key:"setValue",value:function(t){var n=h(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,t);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),n}},{key:"updateDisplay",value:function(){return E.isActive(this.__select)?this:(this.__select.value=this.getValue(),h(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this))}}]),e}(),k=function(){function e(t,n){u(this,e);var o=f(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),i=o;function r(){i.setValue(i.__input.value)}return o.__input=document.createElement("input"),o.__input.setAttribute("type","text"),E.bind(o.__input,"keyup",r),E.bind(o.__input,"change",r),E.bind(o.__input,"blur",(function(){i.__onFinishChange&&i.__onFinishChange.call(i,i.getValue())})),E.bind(o.__input,"keydown",(function(e){13===e.keyCode&&this.blur()})),o.updateDisplay(),o.domElement.appendChild(o.__input),o}return p(e,v),_(e,[{key:"updateDisplay",value:function(){return E.isActive(this.__input)||(this.__input.value=this.getValue()),h(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}();function S(e){var t=e.toString();return t.indexOf(".")>-1?t.length-t.indexOf(".")-1:0}var O=function(){function e(t,n,i){u(this,e);var r=f(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),s=i||{};return r.__min=s.min,r.__max=s.max,r.__step=s.step,o.isUndefined(r.__step)?0===r.initialValue?r.__impliedStep=1:r.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(r.initialValue))/Math.LN10))/10:r.__impliedStep=r.__step,r.__precision=S(r.__impliedStep),r}return p(e,v),_(e,[{key:"setValue",value:function(t){var n=t;return void 0!==this.__min&&n<this.__min?n=this.__min:void 0!==this.__max&&n>this.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),h(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=S(e),this}}]),e}();var T=function(){function e(t,n,i){u(this,e);var r=f(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,i));r.__truncationSuspended=!1;var s=r,a=void 0;function l(){s.__onFinishChange&&s.__onFinishChange.call(s,s.getValue())}function d(e){var t=a-e.clientY;s.setValue(s.getValue()+t*s.__impliedStep),a=e.clientY}function c(){E.unbind(window,"mousemove",d),E.unbind(window,"mouseup",c),l()}return r.__input=document.createElement("input"),r.__input.setAttribute("type","text"),E.bind(r.__input,"change",(function(){var e=parseFloat(s.__input.value);o.isNaN(e)||s.setValue(e)})),E.bind(r.__input,"blur",(function(){l()})),E.bind(r.__input,"mousedown",(function(e){E.bind(window,"mousemove",d),E.bind(window,"mouseup",c),a=e.clientY})),E.bind(r.__input,"keydown",(function(e){13===e.keyCode&&(s.__truncationSuspended=!0,this.blur(),s.__truncationSuspended=!1,l())})),r.updateDisplay(),r.domElement.appendChild(r.__input),r}return p(e,O),_(e,[{key:"updateDisplay",value:function(){var t,n,o;return this.__input.value=this.__truncationSuspended?this.getValue():(t=this.getValue(),n=this.__precision,o=Math.pow(10,n),Math.round(t*o)/o),h(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}();function L(e,t,n,o,i){return o+(e-t)/(n-t)*(i-o)}var R=function(){function e(t,n,o,i,r){u(this,e);var s=f(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,{min:o,max:i,step:r})),a=s;function l(e){e.preventDefault();var t=a.__background.getBoundingClientRect();return a.setValue(L(e.clientX,t.left,t.right,a.__min,a.__max)),!1}function d(){E.unbind(window,"mousemove",l),E.unbind(window,"mouseup",d),a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}function c(e){var t=e.touches[0].clientX,n=a.__background.getBoundingClientRect();a.setValue(L(t,n.left,n.right,a.__min,a.__max))}function _(){E.unbind(window,"touchmove",c),E.unbind(window,"touchend",_),a.__onFinishChange&&a.__onFinishChange.call(a,a.getValue())}return s.__background=document.createElement("div"),s.__foreground=document.createElement("div"),E.bind(s.__background,"mousedown",(function(e){document.activeElement.blur(),E.bind(window,"mousemove",l),E.bind(window,"mouseup",d),l(e)})),E.bind(s.__background,"touchstart",(function(e){if(1!==e.touches.length)return;E.bind(window,"touchmove",c),E.bind(window,"touchend",_),c(e)})),E.addClass(s.__background,"slider"),E.addClass(s.__foreground,"slider-fg"),s.updateDisplay(),s.__background.appendChild(s.__foreground),s.domElement.appendChild(s.__background),s}return p(e,O),_(e,[{key:"updateDisplay",value:function(){var t=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*t+"%",h(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"updateDisplay",this).call(this)}}]),e}(),B=function(){function e(t,n,o){u(this,e);var i=f(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n)),r=i;return i.__button=document.createElement("div"),i.__button.innerHTML=void 0===o?"Fire":o,E.bind(i.__button,"click",(function(e){return e.preventDefault(),r.fire(),!1})),E.addClass(i.__button,"button"),i.domElement.appendChild(i.__button),i}return p(e,v),_(e,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),e}(),N=function(){function e(t,n){u(this,e);var i=f(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n));i.__color=new m(i.getValue()),i.__temp=new m(0);var r=i;i.domElement=document.createElement("div"),E.makeSelectable(i.domElement,!1),i.__selector=document.createElement("div"),i.__selector.className="selector",i.__saturation_field=document.createElement("div"),i.__saturation_field.className="saturation-field",i.__field_knob=document.createElement("div"),i.__field_knob.className="field-knob",i.__field_knob_border="2px solid ",i.__hue_knob=document.createElement("div"),i.__hue_knob.className="hue-knob",i.__hue_field=document.createElement("div"),i.__hue_field.className="hue-field",i.__input=document.createElement("input"),i.__input.type="text",i.__input_textShadow="0 1px 1px ",E.bind(i.__input,"keydown",(function(e){13===e.keyCode&&p.call(this)})),E.bind(i.__input,"blur",p),E.bind(i.__selector,"mousedown",(function(){E.addClass(this,"drag").bind(window,"mouseup",(function(){E.removeClass(r.__selector,"drag")}))})),E.bind(i.__selector,"touchstart",(function(){E.addClass(this,"drag").bind(window,"touchend",(function(){E.removeClass(r.__selector,"drag")}))}));var s,l=document.createElement("div");function d(e){b(e),E.bind(window,"mousemove",b),E.bind(window,"touchmove",b),E.bind(window,"mouseup",_),E.bind(window,"touchend",_)}function c(e){v(e),E.bind(window,"mousemove",v),E.bind(window,"touchmove",v),E.bind(window,"mouseup",h),E.bind(window,"touchend",h)}function _(){E.unbind(window,"mousemove",b),E.unbind(window,"touchmove",b),E.unbind(window,"mouseup",_),E.unbind(window,"touchend",_),g()}function h(){E.unbind(window,"mousemove",v),E.unbind(window,"touchmove",v),E.unbind(window,"mouseup",h),E.unbind(window,"touchend",h),g()}function p(){var e=a(this.value);!1!==e?(r.__color.__state=e,r.setValue(r.__color.toOriginal())):this.value=r.__color.toString()}function g(){r.__onFinishChange&&r.__onFinishChange.call(r,r.__color.toOriginal())}function b(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,o=n.clientX,i=n.clientY,s=(o-t.left)/(t.right-t.left),a=1-(i-t.top)/(t.bottom-t.top);return a>1?a=1:a<0&&(a=0),s>1?s=1:s<0&&(s=0),r.__color.v=a,r.__color.s=s,r.setValue(r.__color.toOriginal()),!1}function v(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=r.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),r.__color.h=360*n,r.setValue(r.__color.toOriginal()),!1}return o.extend(i.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),o.extend(i.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:i.__field_knob_border+(i.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),o.extend(i.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),o.extend(i.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),o.extend(l.style,{width:"100%",height:"100%",background:"none"}),F(l,"top","rgba(0,0,0,0)","#000"),o.extend(i.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),(s=i.__hue_field).style.background="",s.style.cssText+="background: -moz-linear-gradient(top,  #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",s.style.cssText+="background: -webkit-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: -o-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: -ms-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",s.style.cssText+="background: linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",o.extend(i.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:i.__input_textShadow+"rgba(0,0,0,0.7)"}),E.bind(i.__saturation_field,"mousedown",d),E.bind(i.__saturation_field,"touchstart",d),E.bind(i.__field_knob,"mousedown",d),E.bind(i.__field_knob,"touchstart",d),E.bind(i.__hue_field,"mousedown",c),E.bind(i.__hue_field,"touchstart",c),i.__saturation_field.appendChild(l),i.__selector.appendChild(i.__field_knob),i.__selector.appendChild(i.__saturation_field),i.__selector.appendChild(i.__hue_field),i.__hue_field.appendChild(i.__hue_knob),i.domElement.appendChild(i.__input),i.domElement.appendChild(i.__selector),i.updateDisplay(),i}return p(e,v),_(e,[{key:"updateDisplay",value:function(){var e=a(this.getValue());if(!1!==e){var t=!1;o.each(m.COMPONENTS,(function(n){if(!o.isUndefined(e[n])&&!o.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}}),this),t&&o.extend(this.__color.__state,e)}o.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,i=255-n;o.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,F(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),o.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+i+","+i+","+i+",.7)"})}}]),e}(),H=["-moz-","-o-","-webkit-","-ms-",""];function F(e,t,n,i){e.style.background="",o.each(H,(function(o){e.style.cssText+="background: "+o+"linear-gradient("+t+", "+n+" 0%, "+i+" 100%); "}))}var P=function(e,t){var n=t||document,o=document.createElement("style");o.type="text/css",o.innerHTML=e;var i=n.getElementsByTagName("head")[0];try{i.appendChild(o)}catch(e){}},D=function(e,t){var n=e[t];return o.isArray(arguments[2])||o.isObject(arguments[2])?new A(e,t,arguments[2]):o.isNumber(n)?o.isNumber(arguments[2])&&o.isNumber(arguments[3])?o.isNumber(arguments[4])?new R(e,t,arguments[2],arguments[3],arguments[4]):new R(e,t,arguments[2],arguments[3]):o.isNumber(arguments[4])?new T(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new T(e,t,{min:arguments[2],max:arguments[3]}):o.isString(n)?new k(e,t):o.isFunction(n)?new B(e,t,""):o.isBoolean(n)?new C(e,t):null};var V=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},j=function(){function e(){u(this,e),this.backgroundElement=document.createElement("div"),o.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),E.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),o.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;E.bind(this.backgroundElement,"click",(function(){t.hide()}))}return _(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),o.defer((function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"}))}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",E.unbind(e.domElement,"webkitTransitionEnd",t),E.unbind(e.domElement,"transitionend",t),E.unbind(e.domElement,"oTransitionEnd",t)};E.bind(this.domElement,"webkitTransitionEnd",t),E.bind(this.domElement,"transitionend",t),E.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-E.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-E.getHeight(this.domElement)/2+"px"}}]),e}(),I=function(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n");P(I);var z="Default",M=function(){try{return!!window.localStorage}catch(e){return!1}}(),G=void 0,U=!0,X=void 0,K=!1,Y=[],J=function e(t){var n=this,i=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),E.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],i=o.defaults(i,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),i=o.defaults(i,{resizable:i.autoPlace,hideable:i.autoPlace}),o.isUndefined(i.load)?i.load={preset:z}:i.preset&&(i.load.preset=i.preset),o.isUndefined(i.parent)&&i.hideable&&Y.push(this),i.resizable=o.isUndefined(i.parent)&&i.resizable,i.autoPlace&&o.isUndefined(i.scrollable)&&(i.scrollable=!0);var r,s=M&&"true"===localStorage.getItem(ee(this,"isLocal")),a=void 0,l=void 0;if(Object.defineProperties(this,{parent:{get:function(){return i.parent}},scrollable:{get:function(){return i.scrollable}},autoPlace:{get:function(){return i.autoPlace}},closeOnTop:{get:function(){return i.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:i.load.preset},set:function(e){n.parent?n.getRoot().preset=e:i.load.preset=e,function(e){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].value===e.preset&&(e.__preset_select.selectedIndex=t)}(this),n.revert()}},width:{get:function(){return i.width},set:function(e){i.width=e,ie(n,e)}},name:{get:function(){return i.name},set:function(e){i.name=e,l&&(l.innerHTML=i.name)}},closed:{get:function(){return i.closed},set:function(t){i.closed=t,i.closed?E.addClass(n.__ul,e.CLASS_CLOSED):E.removeClass(n.__ul,e.CLASS_CLOSED),this.onResize(),n.__closeButton&&(n.__closeButton.innerHTML=t?e.TEXT_OPEN:e.TEXT_CLOSED)}},load:{get:function(){return i.load}},useLocalStorage:{get:function(){return s},set:function(e){M&&(s=e,e?E.bind(window,"unload",a):E.unbind(window,"unload",a),localStorage.setItem(ee(n,"isLocal"),e))}}}),o.isUndefined(i.parent)){if(this.closed=i.closed||!1,E.addClass(this.domElement,e.CLASS_MAIN),E.makeSelectable(this.domElement,!1),M&&s){n.useLocalStorage=!0;var d=localStorage.getItem(ee(this,"gui"));d&&(i.load=JSON.parse(d))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,E.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),i.closeOnTop?(E.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(E.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),E.bind(this.__closeButton,"click",(function(){n.closed=!n.closed}))}else{void 0===i.closed&&(i.closed=!0);var c=document.createTextNode(i.name);E.addClass(c,"controller-name"),l=W(n,c);E.addClass(this.__ul,e.CLASS_CLOSED),E.addClass(l,"title"),E.bind(l,"click",(function(e){return e.preventDefault(),n.closed=!n.closed,!1})),i.closed||(this.closed=!1)}i.autoPlace&&(o.isUndefined(i.parent)&&(U&&(X=document.createElement("div"),E.addClass(X,"dg"),E.addClass(X,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(X),U=!1),X.appendChild(this.domElement),E.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||ie(n,i.width)),this.__resizeHandler=function(){n.onResizeDebounced()},E.bind(window,"resize",this.__resizeHandler),E.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),E.bind(this.__ul,"transitionend",this.__resizeHandler),E.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),i.resizable&&oe(this),a=function(){M&&"true"===localStorage.getItem(ee(n,"isLocal"))&&localStorage.setItem(ee(n,"gui"),JSON.stringify(n.getSaveObject()))},this.saveToLocalStorageIfPossible=a,i.parent||((r=n.getRoot()).width+=1,o.defer((function(){r.width-=1})))};function W(e,t,n){var o=document.createElement("li");return t&&o.appendChild(t),n?e.__ul.insertBefore(o,n):e.__ul.appendChild(o),e.onResize(),o}function Q(e){E.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&E.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function q(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];n.innerHTML=t?n.value+"*":n.value}function Z(e,t){var n=e.getRoot(),o=n.__rememberedObjects.indexOf(t.object);if(-1!==o){var i=n.__rememberedObjectIndecesToControllers[o];if(void 0===i&&(i={},n.__rememberedObjectIndecesToControllers[o]=i),i[t.property]=t,n.load&&n.load.remembered){var r=n.load.remembered,s=void 0;if(r[e.preset])s=r[e.preset];else{if(!r[z])return;s=r[z]}if(s[o]&&void 0!==s[o][t.property]){var a=s[o][t.property];t.initialValue=a,t.setValue(a)}}}}function $(e,t,n,i){if(void 0===t[n])throw new Error('Object "'+t+'" has no property "'+n+'"');var r=void 0;if(i.color)r=new N(t,n);else{var s=[t,n].concat(i.factoryArgs);r=D.apply(e,s)}i.before instanceof v&&(i.before=i.before.__li),Z(e,r),E.addClass(r.domElement,"c");var a=document.createElement("span");E.addClass(a,"property-name"),a.innerHTML=r.property;var l=document.createElement("div");l.appendChild(a),l.appendChild(r.domElement);var d=W(e,l,i.before);return E.addClass(d,J.CLASS_CONTROLLER_ROW),r instanceof N?E.addClass(d,"color"):E.addClass(d,c(r.getValue())),function(e,t,n){if(n.__li=t,n.__gui=e,o.extend(n,{options:function(t){if(arguments.length>1){var i=n.__li.nextElementSibling;return n.remove(),$(e,n.object,n.property,{before:i,factoryArgs:[o.toArray(arguments)]})}if(o.isArray(t)||o.isObject(t)){var r=n.__li.nextElementSibling;return n.remove(),$(e,n.object,n.property,{before:r,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof R){var i=new T(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});o.each(["updateDisplay","onChange","onFinishChange","step","min","max"],(function(e){var t=n[e],o=i[e];n[e]=i[e]=function(){var e=Array.prototype.slice.call(arguments);return o.apply(i,e),t.apply(n,e)}})),E.addClass(t,"has-slider"),n.domElement.insertBefore(i.domElement,n.domElement.firstElementChild)}else if(n instanceof T){var r=function(t){if(o.isNumber(n.__min)&&o.isNumber(n.__max)){var i=n.__li.firstElementChild.firstElementChild.innerHTML,r=n.__gui.__listening.indexOf(n)>-1;n.remove();var s=$(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return s.name(i),r&&s.listen(),s}return t};n.min=o.compose(r,n.min),n.max=o.compose(r,n.max)}else n instanceof C?(E.bind(t,"click",(function(){E.fakeEvent(n.__checkbox,"click")})),E.bind(n.__checkbox,"click",(function(e){e.stopPropagation()}))):n instanceof B?(E.bind(t,"click",(function(){E.fakeEvent(n.__button,"click")})),E.bind(t,"mouseover",(function(){E.addClass(n.__button,"hover")})),E.bind(t,"mouseout",(function(){E.removeClass(n.__button,"hover")}))):n instanceof N&&(E.addClass(t,"color"),n.updateDisplay=o.compose((function(e){return t.style.borderLeftColor=n.__color.toString(),e}),n.updateDisplay),n.updateDisplay());n.setValue=o.compose((function(t){return e.getRoot().__preset_select&&n.isModified()&&q(e.getRoot(),!0),t}),n.setValue)}(e,d,r),e.__controllers.push(r),r}function ee(e,t){return document.location.href+"."+t}function te(e,t,n){var o=document.createElement("option");o.innerHTML=t,o.value=t,e.__preset_select.appendChild(o),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function ne(e,t){t.style.display=e.useLocalStorage?"block":"none"}function oe(e){var t=void 0;function n(n){return n.preventDefault(),e.width+=t-n.clientX,e.onResize(),t=n.clientX,!1}function i(){E.removeClass(e.__closeButton,J.CLASS_DRAG),E.unbind(window,"mousemove",n),E.unbind(window,"mouseup",i)}function r(o){return o.preventDefault(),t=o.clientX,E.addClass(e.__closeButton,J.CLASS_DRAG),E.bind(window,"mousemove",n),E.bind(window,"mouseup",i),!1}e.__resize_handle=document.createElement("div"),o.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),E.bind(e.__resize_handle,"mousedown",r),E.bind(e.__closeButton,"mousedown",r),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function ie(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function re(e,t){var n={};return o.each(e.__rememberedObjects,(function(i,r){var s={},a=e.__rememberedObjectIndecesToControllers[r];o.each(a,(function(e,n){s[n]=t?e.initialValue:e.getValue()})),n[r]=s})),n}function se(e){0!==e.length&&V.call(window,(function(){se(e)})),o.each(e,(function(e){e.updateDisplay()}))}J.toggleHide=function(){K=!K,o.each(Y,(function(e){e.domElement.style.display=K?"none":""}))},J.CLASS_AUTO_PLACE="a",J.CLASS_AUTO_PLACE_CONTAINER="ac",J.CLASS_MAIN="main",J.CLASS_CONTROLLER_ROW="cr",J.CLASS_TOO_TALL="taller-than-window",J.CLASS_CLOSED="closed",J.CLASS_CLOSE_BUTTON="close-button",J.CLASS_CLOSE_TOP="close-top",J.CLASS_CLOSE_BOTTOM="close-bottom",J.CLASS_DRAG="drag",J.DEFAULT_WIDTH=245,J.TEXT_CLOSED="Close Controls",J.TEXT_OPEN="Open Controls",J._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||J.toggleHide()},E.bind(window,"keydown",J._keydownHandler,!1),o.extend(J.prototype,{add:function(e,t){return $(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return $(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;o.defer((function(){t.onResize()}))},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&X.removeChild(this.domElement);var e=this;o.each(this.__folders,(function(t){e.removeFolder(t)})),E.unbind(window,"keydown",J._keydownHandler,!1),Q(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new J(t);this.__folders[e]=n;var o=W(this,n.domElement);return E.addClass(o,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],Q(e);var t=this;o.each(e.__folders,(function(t){e.removeFolder(t)})),o.defer((function(){t.onResize()}))},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=E.getOffset(e.__ul).top,n=0;o.each(e.__ul.childNodes,(function(t){e.autoPlace&&t===e.__save_row||(n+=E.getHeight(t))})),window.innerHeight-t-20<n?(E.addClass(e.domElement,J.CLASS_TOO_TALL),e.__ul.style.height=window.innerHeight-t-20+"px"):(E.removeClass(e.domElement,J.CLASS_TOO_TALL),e.__ul.style.height="auto")}e.__resize_handle&&o.defer((function(){e.__resize_handle.style.height=e.__ul.offsetHeight+"px"})),e.__closeButton&&(e.__closeButton.style.width=e.width+"px")},onResizeDebounced:o.debounce((function(){this.onResize()}),50),remember:function(){if(o.isUndefined(G)&&((G=new j).domElement.innerHTML='<div id="dg-save" class="dg dialogue">\n\n  Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n  <textarea id="dg-new-constructor"></textarea>\n\n  <div id="dg-save-locally">\n\n    <input id="dg-local-storage" type="checkbox"/> Automatically save\n    values to <code>localStorage</code> on exit.\n\n    <div id="dg-local-explain">The values saved to <code>localStorage</code> will\n      override those passed to <code>dat.GUI</code>\'s constructor. This makes it\n      easier to work incrementally, but <code>localStorage</code> is fragile,\n      and your friends may not see the same values you do.\n\n    </div>\n\n  </div>\n\n</div>'),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;o.each(Array.prototype.slice.call(arguments),(function(t){0===e.__rememberedObjects.length&&function(e){var t=e.__save_row=document.createElement("li");E.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),E.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML="&nbsp;",E.addClass(n,"button gears");var i=document.createElement("span");i.innerHTML="Save",E.addClass(i,"button"),E.addClass(i,"save");var r=document.createElement("span");r.innerHTML="New",E.addClass(r,"button"),E.addClass(r,"save-as");var s=document.createElement("span");s.innerHTML="Revert",E.addClass(s,"button"),E.addClass(s,"revert");var a=e.__preset_select=document.createElement("select");e.load&&e.load.remembered?o.each(e.load.remembered,(function(t,n){te(e,n,n===e.preset)})):te(e,z,!1);if(E.bind(a,"change",(function(){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].innerHTML=e.__preset_select[t].value;e.preset=this.value})),t.appendChild(a),t.appendChild(n),t.appendChild(i),t.appendChild(r),t.appendChild(s),M){var l=document.getElementById("dg-local-explain"),d=document.getElementById("dg-local-storage");document.getElementById("dg-save-locally").style.display="block","true"===localStorage.getItem(ee(e,"isLocal"))&&d.setAttribute("checked","checked"),ne(e,l),E.bind(d,"change",(function(){e.useLocalStorage=!e.useLocalStorage,ne(e,l)}))}var c=document.getElementById("dg-new-constructor");E.bind(c,"keydown",(function(e){!e.metaKey||67!==e.which&&67!==e.keyCode||G.hide()})),E.bind(n,"click",(function(){c.innerHTML=JSON.stringify(e.getSaveObject(),void 0,2),G.show(),c.focus(),c.select()})),E.bind(i,"click",(function(){e.save()})),E.bind(r,"click",(function(){var t=prompt("Enter a new preset name.");t&&e.saveAs(t)})),E.bind(s,"click",(function(){e.revert()}))}(e),-1===e.__rememberedObjects.indexOf(t)&&e.__rememberedObjects.push(t)})),this.autoPlace&&ie(this,this.width)},getRoot:function(){for(var e=this;e.parent;)e=e.parent;return e},getSaveObject:function(){var e=this.load;return e.closed=this.closed,this.__rememberedObjects.length>0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=re(this)),e.folders={},o.each(this.__folders,(function(t,n){e.folders[n]=t.getSaveObject()})),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=re(this),q(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[z]=re(this,!0)),this.load.remembered[e]=re(this),this.preset=e,te(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){o.each(this.__controllers,(function(t){this.getRoot().load.remembered?Z(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())}),this),o.each(this.__folders,(function(e){e.revert(e)})),e||q(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&se(this.__listening)},updateDisplay:function(){o.each(this.__controllers,(function(e){e.updateDisplay()})),o.each(this.__folders,(function(e){e.updateDisplay()}))}});var ae={Color:m,math:d,interpret:a},le={Controller:v,BooleanController:C,OptionController:A,StringController:k,NumberController:O,NumberControllerBox:T,NumberControllerSlider:R,FunctionController:B,ColorController:N},de={dom:E},ce={GUI:J},ue=J,_e={color:ae,controllers:le,dom:de,gui:ce,GUI:ue};export{ue as GUI,ae as color,le as controllers,_e as default,de as dom,ce as gui};
