EasyImages2.0/public/static/jscolor.js

2 lines
49 KiB
JavaScript
Executable File
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

!function(a,b){"use strict";return"object"==typeof module&&"object"==typeof module.exports?(module.exports=a.document?b(a):function(a){if(!a.document)throw new Error("jscolor needs a window with document");return b(a)},void 0):(b(a),void 0)}("undefined"!=typeof window?window:this,function(a){"use strict";var b=function(){var b={initialized:!1,instances:[],readyQueue:[],register:function(){"undefined"!=typeof a&&a.document&&a.document.addEventListener("DOMContentLoaded",b.pub.init,!1)},installBySelector:function(c,d){var e,f,g,h,i,j,k,l;if(d=d?b.node(d):a.document,!d)throw new Error("Missing root node");for(e=d.querySelectorAll(c),f=new RegExp("(^|\\s)("+b.pub.lookupClass+")(\\s*(\\{[^}]*\\})|\\s|$)","i"),g=0;g<e.length;g+=1)if(!(e[g].jscolor&&e[g].jscolor instanceof b.pub||void 0!==e[g].type&&"color"==e[g].type.toLowerCase()&&b.isColorAttrSupported||!(null!==(h=b.getDataAttr(e[g],"jscolor"))||e[g].className&&(i=e[g].className.match(f))))){if(j=e[g],k="",null!==h?k=h:i&&(console.warn('Installation using class name is DEPRECATED. Use data-jscolor="" attribute instead.'+b.docsRef),i[4]&&(k=i[4])),l=null,k.trim())try{l=b.parseOptionsStr(k)}catch(m){console.warn(m+"\n"+k)}try{new b.pub(j,l)}catch(m){console.warn(m)}}},parseOptionsStr:function(a){var c=null;try{c=JSON.parse(a)}catch(d){if(!b.pub.looseJSON)throw new Error("Could not parse jscolor options as JSON: "+d);try{c=new Function("var opts = ("+a+'); return typeof opts === "object" ? opts : {};')()}catch(e){throw new Error("Could not evaluate jscolor options: "+e)}}return c},getInstances:function(){var c,a=[];for(c=0;c<b.instances.length;c+=1)b.instances[c]&&b.instances[c].targetElement&&a.push(b.instances[c]);return a},createEl:function(c){var d=a.document.createElement(c);return b.setData(d,"gui",!0),d},node:function(c){var d,e;if(!c)return null;if("string"==typeof c){d=c,e=null;try{e=a.document.querySelector(d)}catch(f){return console.warn(f),null}return e||console.warn("No element matches the selector: %s",d),e}return b.isNode(c)?c:(console.warn("Invalid node of type %s: %s",typeof c,c),null)},isNode:function(a){return"object"==typeof Node?a instanceof Node:a&&"object"==typeof a&&"number"==typeof a.nodeType&&"string"==typeof a.nodeName},nodeName:function(a){return a&&a.nodeName?a.nodeName.toLowerCase():!1},removeChildren:function(a){for(;a.firstChild;)a.removeChild(a.firstChild)},isTextInput:function(a){return a&&"input"===b.nodeName(a)&&"text"===a.type.toLowerCase()},isButton:function(a){if(!a)return!1;var c=b.nodeName(a);return"button"===c||"input"===c&&["button","submit","reset"].indexOf(a.type.toLowerCase())>-1},isButtonEmpty:function(a){switch(b.nodeName(a)){case"input":return!a.value||""===a.value.trim();case"button":return""===a.textContent.trim()}return null},isPassiveEventSupported:function(){var c,b=!1;try{c=Object.defineProperty({},"passive",{get:function(){b=!0}}),a.addEventListener("testPassive",null,c),a.removeEventListener("testPassive",null,c)}catch(d){}return b}(),isColorAttrSupported:function(){var b=a.document.createElement("input");return b.setAttribute&&(b.setAttribute("type","color"),"color"==b.type.toLowerCase())?!0:!1}(),dataProp:"_data_jscolor",setData:function(){var c,d,e,f,a=arguments[0];if(3===arguments.length)return c=a.hasOwnProperty(b.dataProp)?a[b.dataProp]:a[b.dataProp]={},d=arguments[1],e=arguments[2],c[d]=e,!0;if(2===arguments.length&&"object"==typeof arguments[1]){c=a.hasOwnProperty(b.dataProp)?a[b.dataProp]:a[b.dataProp]={},f=arguments[1];for(d in f)f.hasOwnProperty(d)&&(c[d]=f[d]);return!0}throw new Error("Invalid arguments")},removeData:function(){var c,d,a=arguments[0];if(!a.hasOwnProperty(b.dataProp))return!0;for(c=1;c<arguments.length;c+=1)d=arguments[c],delete a[b.dataProp][d];return!0},getData:function(a,c,d){if(!a.hasOwnProperty(b.dataProp)){if(void 0===d)return void 0;a[b.dataProp]={}}var e=a[b.dataProp];return e.hasOwnProperty(c)||void 0===d||(e[c]=d),e[c]},getDataAttr:function(a,b){var c="data-"+b,d=a.getAttribute(c);return d},setDataAttr:function(a,b,c){var d="data-"+b;a.setAttribute(d,c)},_attachedGroupEvents:{},attachGroupEvent:function(a,c,d,e){b._attachedGroupEvents.hasOwnProperty(a)||(b._attachedGroupEvents[a]=[]),b._attachedGroupEvents[a].push([c,d,e]),c.addEventListener(d,e,!1)},detachGroupEvents:function(a){var c,d;if(b._attachedGroupEvents.hasOwnProperty(a)){for(c=0;c<b._attachedGroupEvents[a].length;c+=1)d=b._attachedGroupEvents[a][c],d[0].removeEventListener(d[1],d[2],!1);delete b._attachedGroupEvents[a]}},preventDefault:function(a){a.preventDefault&&a.preventDefault(),a.returnValue=!1},captureTarget:function(a){a.setCapture&&(b._capturedTarget=a,b._capturedTarget.setCapture())},releaseTarget:function(){b._capturedTarget&&(b._capturedTarget.releaseCapture(),b._capturedTarget=null)},triggerEvent:function(c,d,e,f){if(c){var g=null;return"function"==typeof Event?g=new Event(d,{bubbles:e,cancelable:f}):(g=a.document.createEvent("Event"),g.initEvent(d,e,f)),g?(b.setData(g,"internal",!0),c.dispatchEvent(g),!0):!1}},triggerInputEvent:function(a,c,d,e){a&&b.isTextInput(a)&&b.triggerEvent(a,c,d,e)},eventKey:function(a){var b={9:"Tab",13:"Enter",27:"Escape"};return"string"==typeof a.code?a.code:void 0!==a.keyCode&&b.hasOwnProperty(a.keyCode)?b[a.keyCode]:null},strList:function(a){return a?a.replace(/^\s+|\s+$/g,"").split(/\s+/):[]},hasClass:function(a,b){return b?void 0!==a.classList?a.classList.contains(b):-1!=(" "+a.className.replace(/\s+/g," ")+" ").indexOf(" "+b+" "):!1},addClass:function(a,c){var e,d=b.strList(c);if(void 0===a.classList)for(e=0;e<d.length;e+=1)b.hasClass(a,d[e])||(a.className+=(a.className?" ":"")+d[e]);else for(e=0;e<d.length;e+=1)a.classList.add(d[e])},removeClass:function(a,c){var e,f,d=b.strList(c);if(void 0===a.classList)for(e=0;e<d.length;e+=1)f=new RegExp("^\\s*"+d[e]+"\\s*|"+"\\s*"+d[e]+"\\s*$|"+"\\s+"+d[e]+"(\\s+)","g"),a.className=a.className.replace(f,"$1");else for(e=0;e<d.length;e+=1)a.classList.remove(d[e])},getCompStyle:function(b){var c=a.getComputedStyle?a.getComputedStyle(b):b.currentStyle;return c?c:{}},setStyle:function(a,c,d,e){var h,i,f=d?"important":"",g=null;for(h in c)c.hasOwnProperty(h)&&(i=null,null===c[h]?(g||(g=b.getData(a,"origStyle")),g&&g.hasOwnProperty(h)&&(i=g[h])):(e&&(g||(g=b.getData(a,"origStyle",{})),g.hasOwnProperty(h)||(g[h]=a.style[h])),i=c[h]),null!==i&&a.style.setProperty(h,i,f))},hexColor:function(a,b,c){return"#"+(("0"+Math.round(a).toString(16)).substr(-2)+("0"+Math.round(b).toString(16)).substr(-2)+("0"+Math.round(c).toString(16)).substr(-2)).toUpperCase()},hexaColor:function(a,b,c,d){return"#"+(("0"+Math.round(a).toString(16)).substr(-2)+("0"+Math.round(b).toString(16)).substr(-2)+("0"+Math.round(c).toString(16)).substr(-2)+("0"+Math.round(255*d).toString(16)).substr(-2)).toUpperCase()},rgbColor:function(a,b,c){return"rgb("+Math.round(a)+","+Math.round(b)+","+Math.round(c)+")"},rgbaColor:function(a,b,c,d){return+Math.round(a)+","+Math.round(b)+","+Math.round(c)+","+Math.round(100*(void 0===d||null===d?1:d))/100},linearGradient:function(){function b(){var e,f,g,b="linear-gradient",c=["","-webkit-","-moz-","-o-","-ms-"],d=a.document.createElement("div");for(e=0;e<c.length;e+=1)if(f=c[e]+b,g=f+"(to right, rgba(0,0,0,0), rgba(0,0,0,0))",d.style.background=g,d.style.background)return f;return b}var c=b();return function(){return c+"("+Array.prototype.join.call(arguments,", ")+")"}}(),setBorderRadius:function(a,c){b.setStyle(a,{"border-radius":c||"0"})},setBoxShadow:function(a,c){b.setStyle(a,{"box-shadow":c||"none"})},getElementPos:function(a,c){var g,d=0,e=0,f=a.getBoundingClientRect();return d=f.left,e=f.top,c||(g=b.getViewPos(),d+=g[0],e+=g[1]),[d,e]},getElementSize:function(a){return[a.offsetWidth,a.offsetHeight]},getAbsPointerPos:function(a){var b=0,c=0;return"undefined"!=typeof a.changedTouches&&a.changedTouches.length?(b=a.changedTouches[0].clientX,c=a.changedTouches[0].clientY):"number"==typeof a.clientX&&(b=a.clientX,c=a.clientY),{x:b,y:c}},getRelPointerPos:function(a){var b=a.target||a.srcElement,c=b.getBoundingClientRect(),d=0,e=0,f=0,g=0;return"undefined"!=typeof a.changedTouches&&a.changedTouches.length?(f=a.changedTouches[0].clientX,g=a.changedTouches[0].clientY):"number"==typeof a.clientX&&(f=a.clientX,g=a.clientY),d=f-c.left,e=g-c.top,{x:d,y:e}},getViewPos:function(){var b=a.document.documentElement;return[(a.pageXOffset||b.scrollLeft)-(b.clientLeft||0),(a.pageYOffset||b.scrollTop)-(b.clientTop||0)]},getViewSize:function(){var b=a.document.documentElement;return[a.innerWidth||b.clientWidth,a.innerHeight||b.clientHeight]},RGB_HSV:function(a,b,c){var d,e,f,g;return a/=255,b/=255,c/=255,d=Math.min(Math.min(a,b),c),e=Math.max(Math.max(a,b),c),f=e-d,0===f?[null,0,100*e]:(g=a===d?3+(c-b)/f:b===d?5+(a-c)/f:1+(b-a)/f,[60*(6===g?0:g),100*(f/e),100*e])},HSV_RGB:function(a,b,c){var e,f,g,h,d=255*(c/100);if(null===a)return[d,d,d];switch(a/=60,b/=100,e=Math.floor(a),f=e%2?a-e:1-(a-e),g=d*(1-b),h=d*(1-b*f),e){case 6:case 0:return[d,h,g];case 1:return[h,d,g];case 2:return[g,d,h];case 3:return[g,h,d];case 4:return[h,g,d];case 5:return[d,g,h]}},parseColorString:function(a){var c,d,e,f,g,h,i,b={rgba:null,format:null};if(c=a.match(/^\W*([0-9A-F]{3,8})\W*$/i)){if(8===c[1].length)b.format="hexa",b.rgba=[parseInt(c[1].substr(0,2),16),parseInt(c[1].substr(2,2),16),parseInt(c[1].substr(4,2),16),parseInt(c[1].substr(6,2),16)/255];else if(6===c[1].length)b.format="hex",b.rgba=[parseInt(c[1].substr(0,2),16),parseInt(c[1].substr(2,2),16),parseInt(c[1].substr(4,2),16),null];else{if(3!==c[1].length)return!1;b.format="hex",b.rgba=[parseInt(c[1].charAt(0)+c[1].charAt(0),16),parseInt(c[1].charAt(1)+c[1].charAt(1),16),parseInt(c[1].charAt(2)+c[1].charAt(2),16),null]}return b}return(c=a.match(/^\W*rgba?\(([^)]*)\)\W*$/i))&&(d=c[1].split(","),e=/^\s*(\d+|\d*\.\d+|\d+\.\d*)\s*$/,d.length>=3&&(f=d[0].match(e))&&(g=d[1].match(e))&&(h=d[2].match(e)))?(b.format="rgb",b.rgba=[parseFloat(f[1])||0,parseFloat(g[1])||0,parseFloat(h[1])||0,null],d.length>=4&&(i=d[3].match(e))&&(b.format="rgba",b.rgba[3]=parseFloat(i[1])||0),b):!1},parsePaletteValue:function(a){var d,e,f,c=[];for("string"==typeof a?a.replace(/#[0-9A-F]{3}([0-9A-F]{3})?|rgba?\(([^)]*)\)/gi,function(a){c.push(a)}):Array.isArray(a)&&(c=a),d=[],e=0;e<c.length;e++)f=b.parseColorString(c[e]),f&&d.push(f);return d},containsTranparentColor:function(a){var b,c;for(b=0;b<a.length;b++)if(c=a[b].rgba[3],null!==c&&1>c)return!0;return!1},isAlphaFormat:function(a){switch(a.toLowerCase()){case"hexa":case"rgba":return!0}return!1},scaleCanvasForHighDPR:function(b){var d,c=a.devicePixelRatio||1;b.width*=c,b.height*=c,d=b.getContext("2d"),d.scale(c,c)},genColorPreviewCanvas:function(a,c,d,e){var n,o,p,f=Math.round(b.pub.previewSeparator.length),g=b.pub.chessboardSize,h=b.pub.chessboardColor1,i=b.pub.chessboardColor2,j=d?d:2*g,k=2*g,l=b.createEl("canvas"),m=l.getContext("2d");for(l.width=j,l.height=k,e&&b.scaleCanvasForHighDPR(l),m.fillStyle=h,m.fillRect(0,0,j,k),m.fillStyle=i,n=0;j>n;n+=2*g)m.fillRect(n,0,g,g),m.fillRect(n+g,g,g,g);switch(a&&(m.fillStyle=a,m.fillRect(0,0,j,k)),o=null,c){case"left":o=0,m.clearRect(0,0,f/2,k);break;case"right":o=j-f,m.clearRect(j-f/2,0,f/2,k)}if(null!==o)for(m.lineWidth=1,p=0;p<b.pub.previewSeparator.length;p+=1)m.beginPath(),m.strokeStyle=b.pub.previewSeparator[p],m.moveTo(.5+o+p,0),m.lineTo(.5+o+p,k),m.stroke();return{canvas:l,width:j,height:k}},genColorPreviewGradient:function(a,c,d){var e=[];return e=c&&d?["to "+{left:"right",right:"left"}[c],a+" 0%",a+" "+d+"px","rgba(0,0,0,0) "+(d+1)+"px","rgba(0,0,0,0) 100%"]:["to right",a+" 0%",a+" 100%"],b.linearGradient.apply(this,e)},redrawPosition:function(){var a,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;if(b.picker&&b.picker.owner){switch(a=b.picker.owner,a.fixed?(c=b.getElementPos(a.targetElement,!0),d=[0,0]):(c=b.getElementPos(a.targetElement),d=b.getViewPos()),e=b.getElementSize(a.targetElement),f=b.getViewSize(),g=b.getPickerDims(a),h=[g.borderW,g.borderH],a.position.toLowerCase()){case"left":i=1,j=0,k=-1;break;case"right":i=1,j=0,k=1;break;case"top":i=0,j=1,k=-1;break;default:i=0,j=1,k=1}l=(e[j]+h[j])/2,m=a.smartPosition?[-d[i]+c[i]+h[i]>f[i]?-d[i]+c[i]+e[i]/2>f[i]/2&&c[i]+e[i]-h[i]>=0?c[i]+e[i]-h[i]:c[i]:c[i],-d[j]+c[j]+e[j]+h[j]-l+l*k>f[j]?-d[j]+c[j]+e[j]/2>f[j]/2&&c[j]+e[j]-l-l*k>=0?c[j]+e[j]-l-l*k:c[j]+e[j]-l+l*k:c[j]+e[j]-l+l*k>=0?c[j]+e[j]-l+l*k:c[j]+e[j]-l-l*k]:[c[i],c[j]+e[j]-l+l*k],n=m[i],o=m[j],p=a.fixed?"fixed":"absolute",q=(m[0]+h[0]>c[0]||m[0]<c[0]+e[0])&&m[1]+h[1]<c[1]+e[1],b._drawPosition(a,n,o,p,q)}},_drawPosition:function(a,c,d,e,f){var g=f?0:a.shadowBlur;b.picker.wrap.style.position=e,b.picker.wrap.style.left=c+"px",b.picker.wrap.style.top=d+"px",b.setBoxShadow(b.picker.boxS,a.shadow?new b.BoxShadow(0,g,a.shadowBlur,0,a.shadowColor):null)},getPickerDims:function(a){var f,g,h,c=2*a.controlBorderWidth+a.width,d=2*a.controlBorderWidth+a.height,e=2*a.controlBorderWidth+2*b.getControlPadding(a)+a.sliderSize;return b.getSliderChannel(a)&&(c+=e),a.hasAlphaChannel()&&(c+=e),f=b.getPaletteDims(a,c),f.height&&(d+=f.height+a.padding),a.closeButton&&(d+=2*a.controlBorderWidth+a.padding+a.buttonHeight),g=c+2*a.padding,h=d+2*a.padding,{contentW:c,contentH:d,paddedW:g,paddedH:h,borderW:g+2*a.borderWidth,borderH:h+2*a.borderWidth,palette:f}},getPaletteDims:function(a,b){var c=0,d=0,e=0,f=0,g=0,h=a._palette?a._palette.length:0;return h&&(c=a.paletteCols,d=c>0?Math.ceil(h/c):0,e=Math.max(1,Math.floor((b-(c-1)*a.paletteSpacing)/c)),f=a.paletteHeight?Math.min(a.paletteHeight,e):e),d&&(g=d*f+(d-1)*a.paletteSpacing),{cols:c,rows:d,cellW:e,cellH:f,width:b,height:g}},getControlPadding:function(a){return Math.max(a.padding/2,2*a.pointerBorderWidth+a.pointerThickness-a.controlBorderWidth)},getPadYChannel:function(a){switch(a.mode.charAt(1).toLowerCase()){case"v":return"v"}return"s"},getSliderChannel:function(a){if(a.mode.length>2)switch(a.mode.charAt(2).toLowerCase()){case"s":return"s";case"v":return"v"}return null},triggerCallback:function(a,b){if(a[b]){var c=null;if("string"==typeof a[b])try{c=new Function(a[b])}catch(d){console.error(d)}else c=a[b];c&&c.call(a)}},triggerGlobal:function(a){var d,c=b.getInstances();for(d=0;d<c.length;d+=1)c[d].trigger(a)},_pointerMoveEvent:{mouse:"mousemove",touch:"touchmove"},_pointerEndEvent:{mouse:"mouseup",touch:"touchend"},_pointerOrigin:null,_capturedTarget:null,onDocumentKeyUp:function(a){-1!==["Tab","Escape"].indexOf(b.eventKey(a))&&b.picker&&b.picker.owner&&b.picker.owner.tryHide()},onWindowResize:function(){b.redrawPosition()},onWindowScroll:function(){b.redrawPosition()},onParentScroll:function(){b.picker&&b.picker.owner&&b.picker.owner.tryHide()},onDocumentMouseDown:function(a){var d,c=a.target||a.srcElement;c.jscolor&&c.jscolor instanceof b.pub?c.jscolor.showOnClick&&!c.disabled&&c.jscolor.show():b.getData(c,"gui")?(d=b.getData(c,"control"),d&&b.onControlPointerStart(a,c,b.getData(c,"control"),"mouse")):b.picker&&b.picker.owner&&b.picker.owner.tryHide()},onPickerTouchStart:function(a){var c=a.target||a.srcElement;b.getData(c,"control")&&b.onControlPointerStart(a,c,b.getData(c,"control"),"touch")},onControlPointerStart:function(c,d,e,f){var h,i,j,k,l,g=b.getData(d,"instance");switch(b.preventDefault(c),b.captureTarget(d),h=function(a,g){b.attachGroupEvent("drag",a,b._pointerMoveEvent[f],b.onDocumentPointerMove(c,d,e,f,g)),b.attachGroupEvent("drag",a,b._pointerEndEvent[f],b.onDocumentPointerEnd(c,d,e,f))},h(a.document,[0,0]),a.parent&&a.frameElement&&(i=a.frameElement.getBoundingClientRect(),j=[-i.left,-i.top],h(a.parent.window.document,j)),k=b.getAbsPointerPos(c),l=b.getRelPointerPos(c),b._pointerOrigin={x:k.x-l.x,y:k.y-l.y},e){case"pad":"v"===b.getSliderChannel(g)&&0===g.channels.v&&g.fromHSVA(null,null,100,null),b.setPad(g,c,0,0);break;case"sld":b.setSld(g,c,0);break;case"asld":b.setASld(g,c,0)}g.trigger("input")},onDocumentPointerMove:function(a,c,d,e,f){return function(a){var e=b.getData(c,"instance");switch(d){case"pad":b.setPad(e,a,f[0],f[1]);break;case"sld":b.setSld(e,a,f[1]);break;case"asld":b.setASld(e,a,f[1])}e.trigger("input")}},onDocumentPointerEnd:function(a,c){return function(){var d=b.getData(c,"instance");b.detachGroupEvents("drag"),b.releaseTarget(),d.trigger("input"),d.trigger("change")}},onPaletteSampleClick:function(a){var c=a.currentTarget,d=b.getData(c,"instance"),e=b.getData(c,"color");"any"===d.format.toLowerCase()&&(d._setFormat(e.format),b.isAlphaFormat(d.getFormat())||(e.rgba[3]=1)),null===e.rgba[3]&&(d.paletteSetsAlpha===!0||"auto"===d.paletteSetsAlpha&&d._paletteHasTransparency)&&(e.rgba[3]=1),d.fromRGBA.apply(d,e.rgba),d.trigger("input"),d.trigger("change"),d.hideOnPaletteClick&&d.hide()},setPad:function(a,c,d,e){var f=b.getAbsPointerPos(c),g=d+f.x-b._pointerOrigin.x-a.padding-a.controlBorderWidth,h=e+f.y-b._pointerOrigin.y-a.padding-a.controlBorderWidth,i=g*(360/(a.width-1)),j=100-h*(100/(a.height-1));switch(b.getPadYChannel(a)){case"s":a.fromHSVA(i,j,null,null);break;case"v":a.fromHSVA(i,null,j,null)}},setSld:function(a,c,d){var e=b.getAbsPointerPos(c),f=d+e.y-b._pointerOrigin.y-a.padding-a.controlBorderWidth,g=100-f*(100/(a.height-1));switch(b.getSliderChannel(a)){case"s":a.fromHSVA(null,g,null,null);break;case"v":a.fromHSVA(null,null,g,null)}},setASld:function(a,c,d){var h,e=b.getAbsPointerPos(c),f=d+e.y-b._pointerOrigin.y-a.padding-a.controlBorderWidth,g=1-f*(1/(a.height-1));1>g&&(h=a.getFormat(),"any"!==a.format.toLowerCase()||b.isAlphaFormat(h)||a._setFormat("hex"===h?"hexa":"rgba")),a.fromHSVA(null,null,null,g)},createPadCanvas:function(){var a={elm:null,draw:null},c=b.createEl("canvas"),d=c.getContext("2d"),e=function(a,b,e){var f,g;switch(c.width=a,c.height=b,d.clearRect(0,0,c.width,c.height),f=d.createLinearGradient(0,0,c.width,0),f.addColorStop(0,"#F00"),f.addColorStop(1/6,"#FF0"),f.addColorStop(2/6,"#0F0"),f.addColorStop(.5,"#0FF"),f.addColorStop(4/6,"#00F"),f.addColorStop(5/6,"#F0F"),f.addColorStop(1,"#F00"),d.fillStyle=f,d.fillRect(0,0,c.width,c.height),g=d.createLinearGradient(0,0,0,c.height),e.toLowerCase()){case"s":g.addColorStop(0,"rgba(255,255,255,0)"),g.addColorStop(1,"rgba(255,255,255,1)");break;case"v":g.addColorStop(0,"rgba(0,0,0,0)"),g.addColorStop(1,"rgba(0,0,0,1)")}d.fillStyle=g,d.fillRect(0,0,c.width,c.height)};return a.elm=c,a.draw=e,a},createSliderGradient:function(){var a={elm:null,draw:null},c=b.createEl("canvas"),d=c.getContext("2d"),e=function(a,b,e,f){c.width=a,c.height=b,d.clearRect(0,0,c.width,c.height);var g=d.createLinearGradient(0,0,0,c.height);g.addColorStop(0,e),g.addColorStop(1,f),d.fillStyle=g,d.fillRect(0,0,c.width,c.height)};return a.elm=c,a.draw=e,a},createASliderGradient:function(){var a={elm:null,draw:null},c=b.createEl("canvas"),d=c.getContext("2d"),e=function(a,e,f){var g,h,i,j,k;if(c.width=a,c.height=e,d.clearRect(0,0,c.width,c.height),g=c.width/2,h=b.pub.chessboardColor1,i=b.pub.chessboardColor2,d.fillStyle=h,d.fillRect(0,0,c.width,c.height),g>0)for(j=0;j<c.height;j+=2*g)d.fillStyle=i,d.fillRect(0,j,g,g),d.fillRect(g,j+g,g,g);k=d.createLinearGradient(0,0,0,c.height),k.addColorStop(0,f),k.addColorStop(1,"rgba(0,0,0,0)"),d.fillStyle=k,d.fillRect(0,0,c.width,c.height)};return a.elm=c,a.draw=e,a},BoxShadow:function(){var a=function(a,b,c,d,e,f){this.hShadow=a,this.vShadow=b,this.blur=c,this.spread=d,this.color=e,this.inset=!!f};return a.prototype.toString=function(){var a=[Math.round(this.hShadow)+"px",Math.round(this.vShadow)+"px",Math.round(this.blur)+"px",Math.round(this.spread)+"px",this.color];return this.inset&&a.push("inset"),a.join(" ")},a}(),flags:{leaveValue:1,leaveAlpha:2,leavePreview:4},enumOpts:{format:["auto","any","hex","hexa","rgb","rgba"],previewPosition:["left","right"],mode:["hsv","hvs","hs","hv"],position:["left","right","top","bottom"],alphaChannel:["auto",!0,!1],paletteSetsAlpha:["auto",!0,!1]},deprecatedOpts:{styleElement:"previewElement",onFineChange:"onInput",overwriteImportant:"forceStyle",closable:"closeButton",insetWidth:"controlBorderWidth",insetColor:"controlBorderColor",refine:null},docsRef:" See https://jscolor.com/docs/",pub:function(c,d){function f(a,c){var d,f,g;if("string"!=typeof a)throw new Error("Invalid value for option name: "+a);if(b.enumOpts.hasOwnProperty(a)&&("string"==typeof c&&(c=c.toLowerCase()),-1===b.enumOpts[a].indexOf(c)))throw new Error("Option '"+a+"' has invalid value: "+c);if(b.deprecatedOpts.hasOwnProperty(a)){if(d=a,f=b.deprecatedOpts[a],!f)throw new Error("Option '"+a+"' is DEPRECATED");console.warn("Option '%s' is DEPRECATED, using '%s' instead."+b.docsRef,d,f),a=f}if(g="set__"+a,"function"==typeof e[g])return e[g](c),!0;if(a in e)return e[a]=c,!0;throw new Error("Unrecognized configuration option: "+a)}function g(a){var c,d,f;if("string"!=typeof a)throw new Error("Invalid value for option name: "+a);if(b.deprecatedOpts.hasOwnProperty(a)){if(c=a,d=b.deprecatedOpts[a],!d)throw new Error("Option '"+a+"' is DEPRECATED");console.warn("Option '%s' is DEPRECATED, using '%s' instead."+b.docsRef,c,d),a=d}if(f="get__"+a,"function"==typeof e[f])return e[f](value);if(a in e)return e[a];throw new Error("Unrecognized configuration option: "+a)}function h(){b.removeClass(e.targetElement,b.pub.activeClassName),b.picker.wrap.parentNode.removeChild(b.picker.wrap),delete b.picker.owner}function i(){function w(){var a=e.controlBorderColor.split(/\s+/),b=a.length<2?a[0]:a[1]+" "+a[0]+" "+a[0]+" "+a[1];c.btn.style.borderColor=b}var c,d,f,g,h,i,m,n,o,p,q,r,s,t,u,v,x;for(e._processParentElementsInDOM(),b.picker||(b.picker={owner:null,wrap:b.createEl("div"),box:b.createEl("div"),boxS:b.createEl("div"),boxB:b.createEl("div"),pad:b.createEl("div"),padB:b.createEl("div"),padM:b.createEl("div"),padCanvas:b.createPadCanvas(),cross:b.createEl("div"),crossBY:b.createEl("div"),crossBX:b.createEl("div"),crossLY:b.createEl("div"),crossLX:b.createEl("div"),sld:b.createEl("div"),sldB:b.createEl("div"),sldM:b.createEl("div"),sldGrad:b.createSliderGradient(),sldPtrS:b.createEl("div"),sldPtrIB:b.createEl("div"),sldPtrMB:b.createEl("div"),sldPtrOB:b.createEl("div"),asld:b.createEl("div"),asldB:b.createEl("div"),asldM:b.createEl("div"),asldGrad:b.createASliderGradient(),asldPtrS:b.createEl("div"),asldPtrIB:b.createEl("div"),asldPtrMB:b.createEl("div"),asldPtrOB:b.createEl("div"),pal:b.createEl("div"),btn:b.createEl("div"),btnT:b.createEl("span")},b.picker.pad.appendChild(b.picker.padCanvas.elm),b.picker.padB.appendChild(b.picker.pad),b.picker.cross.appendChild(b.picker.crossBY),b.picker.cross.appendChild(b.picker.crossBX),b.picker.cross.appendChild(b.picker.crossLY),b.picker.cross.appendChild(b.picker.crossLX),b.picker.padB.appendChild(b.picker.cross),b.picker.box.appendChild(b.picker.padB),b.picker.box.appendChild(b.picker.padM),b.picker.sld.appendChild(b.picker.sldGrad.elm),b.picker.sldB.appendChild(b.picker.sld),b.picker.sldB.appendChild(b.picker.sldPtrOB),b.picker.sldPtrOB.appendChild(b.picker.sldPtrMB),b.picker.sldPtrMB.appendChild(b.picker.sldPtrIB),b.picker.sldPtrIB.appendChild(b.picker.sldPtrS),b.picker.box.appendChild(b.picker.sldB),b.picker.box.appendChild(b.picker.sldM),b.picker.asld.appendChild(b.picker.asldGrad.elm),b.picker.asldB.appendChild(b.picker.asld),b.picker.asldB.appendChild(b.picker.asldPtrOB),b.picker.asldPtrOB.appendChild(b.picker.asldPtrMB),b.picker.asldPtrMB.appendChild(b.picker.asldPtrIB),b.picker.asldPtrIB.appendChild(b.picker.asldPtrS),b.picker.box.appendChild(b.picker.asldB),b.picker.box.appendChild(b.picker.asldM),b.picker.box.appendChild(b.picker.pal),b.picker.btn.appendChild(b.picker.btnT),b.picker.box.appendChild(b.picker.btn),b.picker.boxB.appendChild(b.picker.box),b.picker.wrap.appendChild(b.picker.boxS),b.picker.wrap.appendChild(b.picker.boxB),b.picker.wrap.addEventListener("touchstart",b.onPickerTouchStart,b.isPassiveEventSupported?{passive:!1}:!1)),c=b.picker,d=!!b.getSliderChannel(e),f=e.hasAlphaChannel(),g=b.getPickerDims(e),h=2*e.pointerBorderWidth+e.pointerThickness+2*e.crossSize,i=b.getControlPadding(e),m=Math.min(e.borderRadius,Math.round(e.padding*Math.PI)),n="crosshair",c.wrap.className="jscolor-picker-wrap",c.wrap.style.clear="both",c.wrap.style.width=g.borderW+"px",c.wrap.style.height=g.borderH+"px",c.wrap.style.zIndex=e.zIndex,c.box.className="jscolor-picker",c.box.style.width=g.paddedW+"px",c.box.style.height=g.paddedH+"px",c.box.style.position="relative",c.boxS.className="jscolor-picker-shadow",c.boxS.style.position="absolute",c.boxS.style.left="0",c.boxS.style.top="0",c.boxS.style.width="100%",c.boxS.style.height="100%",b.setBorderRadius(c.boxS,m+"px"),c.boxB.className="jscolor-picker-border",c.boxB.style.position="relative",c.boxB.style.border=e.borderWidth+"px solid",c.boxB.style.borderColor=e.borderColor,c.boxB.style.background=e.backgroundColor,b.setBorderRadius(c.boxB,m+"px"),c.padM.style.background="rgba(255,0,0,.2)",c.sldM.style.background="rgba(0,255,0,.2)",c.asldM.style.background="rgba(0,0,255,.2)",c.padM.style.opacity=c.sldM.style.opacity=c.asldM.style.opacity="0",c.pad.style.position="relative",c.pad.style.width=e.width+"px",c.pad.style.height=e.height+"px",c.padCanvas.draw(e.width,e.height,b.getPadYChannel(e)),c.padB.style.position="absolute",c.padB.style.left=e.padding+"px",c.padB.style.top=e.padding+"px",c.padB.style.border=e.controlBorderWidth+"px solid",c.padB.style.borderColor=e.controlBorderColor,c.padM.style.position="absolute",c.padM.style.left="0px",c.padM.style.top="0px",c.padM.style.width=e.padding+2*e.controlBorderWidth+e.width+i+"px",c.padM.style.height=2*e.controlBorderWidth+2*e.padding+e.height+"px",c.padM.style.cursor=n,b.setData(c.padM,{instance:e,control:"pad"}),c.cross.style.position="absolute",c.cross.style.left=c.cross.style.top="0",c.cross.style.width=c.cross.style.height=h+"px",c.crossBY.style.position=c.crossBX.style.position="absolute",c.crossBY.style.background=c.crossBX.style.background=e.pointerBorderColor,c.crossBY.style.width=c.crossBX.style.height=2*e.pointerBorderWidth+e.pointerThickness+"px",c.crossBY.style.height=c.crossBX.style.width=h+"px",c.crossBY.style.left=c.crossBX.style.top=Math.floor(h/2)-Math.floor(e.pointerThickness/2)-e.pointerBorderWidth+"px",c.crossBY.style.top=c.crossBX.style.left="0",c.crossLY.style.position=c.crossLX.style.position="absolute",c.crossLY.style.background=c.crossLX.style.background=e.pointerColor,c.crossLY.style.height=c.crossLX.style.width=h-2*e.pointerBorderWidth+"px",c.crossLY.style.width=c.crossLX.style.height=e.pointerThickness+"px",c.crossLY.style.left=c.crossLX.style.top=Math.floor(h/2)-Math.floor(e.pointerThickness/2)+"px",c.crossLY.style.top=c.crossLX.style.left=e.pointerBorderWidth+"px",c.sld.style.overflow="hidden",c.sld.style.width=e.sliderSize+"px",c.sld.style.height=e.height+"px",c.sldGrad.draw(e.sliderSize,e.height,"#000","#000"),c.sldB.style.display=d?"block":"none",c.sldB.style.position="absolute",c.sldB.style.left=e.padding+e.width+2*e.controlBorderWidth+2*i+"px",c.sldB.style.top=e.padding+"px",c.sldB.style.border=e.controlBorderWidth+"px solid",c.sldB.style.borderColor=e.controlBorderColor,c.sldM.style.display=d?"block":"none",c.sldM.style.position="absolute",c.sldM.style.left=e.padding+e.width+2*e.controlBorderWidth+i+"px",c.sldM.style.top="0px",c.sldM.style.width=e.sliderSize+2*i+2*e.controlBorderWidth+(f?0:Math.max(0,e.padding-i))+"px",c.sldM.style.height=2*e.controlBorderWidth+2*e.padding+e.height+"px",c.sldM.style.cursor="default",b.setData(c.sldM,{instance:e,control:"sld"}),c.sldPtrIB.style.border=c.sldPtrOB.style.border=e.pointerBorderWidth+"px solid "+e.pointerBorderColor,c.sldPtrOB.style.position="absolute",c.sldPtrOB.style.left=-(2*e.pointerBorderWidth+e.pointerThickness)+"px",c.sldPtrOB.style.top="0",c.sldPtrMB.style.border=e.pointerThickness+"px solid "+e.pointerColor,c.sldPtrS.style.width=e.sliderSize+"px",c.sldPtrS.style.height=b.pub.sliderInnerSpace+"px",c.asld.style.overflow="hidden",c.asld.style.width=e.sliderSize+"px",c.asld.style.height=e.height+"px",c.asldGrad.draw(e.sliderSize,e.height,"#000"),c.asldB.style.display=f?"block":"none",c.asldB.style.position="absolute",c.asldB.style.left=e.padding+e.width+2*e.controlBorderWidth+i+(d?e.sliderSize+3*i+2*e.controlBorderWidth:0)+"px",c.asldB.style.top=e.padding+"px",c.asldB.style.border=e.controlBorderWidth+"px solid",c.asldB.style.borderColor=e.controlBorderColor,c.asldM.style.display=f?"block":"none",c.asldM.style.position="absolute",c.asldM.style.left=e.padding+e.width+2*e.controlBorderWidth+i+(d?e.sliderSize+2*i+2*e.controlBorderWidth:0)+"px",c.asldM.style.top="0px",c.asldM.style.width=e.sliderSize+2*i+2*e.controlBorderWidth+Math.max(0,e.padding-i)+"px",c.asldM.style.height=2*e.controlBorderWidth+2*e.padding+e.height+"px",c.asldM.style.cursor="default",b.setData(c.asldM,{instance:e,control:"asld"}),c.asldPtrIB.style.border=c.asldPtrOB.style.border=e.pointerBorderWidth+"px solid "+e.pointerBorderColor,c.asldPtrOB.style.position="absolute",c.asldPtrOB.style.left=-(2*e.pointerBorderWidth+e.pointerThickness)+"px",c.asldPtrOB.style.top="0",c.asldPtrMB.style.border=e.pointerThickness+"px solid "+e.pointerColor,c.asldPtrS.style.width=e.sliderSize+"px",c.asldPtrS.style.height=b.pub.sliderInnerSpace+"px",c.pal.className="jscolor-palette",c.pal.style.display=g.palette.rows?"block":"none",c.pal.style.position="absolute",c.pal.style.left=e.padding+"px",c.pal.style.top=2*e.controlBorderWidth+2*e.padding+e.height+"px",c.pal.innerHTML="",o=b.genColorPreviewCanvas("rgba(0,0,0,0)"),p=0,q=0;q<g.palette.rows;q++)for(r=0;r<g.palette.cols&&p<e._palette.length;r++,p++)s=e._palette[p],t=b.rgbaColor.apply(null,s.rgba),u=b.createEl("div"),u.style.width=g.palette.cellW-2*e.controlBorderWidth+"px",u.style.height=g.palette.cellH-2*e.controlBorderWidth+"px",u.style.backgroundColor=t,v=b.createEl("div"),v.className="jscolor-palette-sample",v.style.display="block",v.style.position="absolute",v.style.left=(g.palette.cols<=1?0:Math.round(10*r*((g.contentW-g.palette.cellW)/(g.palette.cols-1)))/10)+"px",v.style.top=q*(g.palette.cellH+e.paletteSpacing)+"px",v.style.border=e.controlBorderWidth+"px solid",v.style.borderColor=e.controlBorderColor,v.style.cursor="pointer",null!==s.rgba[3]&&s.rgba[3]<1&&(v.style.backgroundImage="url('"+o.canvas.toDataURL()+"')",v.style.backgroundRepeat="repeat",v.style.backgroundPosition="center center"),b.setData(v,{instance:e,control:"palette-sample",color:s}),v.addEventListener("click",b.onPaletteSampleClick,!1),v.appendChild(u),c.pal.appendChild(v);x=15,c.btn.className="jscolor-btn-close",c.btn.style.display=e.closeButton?"block":"none",c.btn.style.position="absolute",c.btn.style.left=e.padding+"px",c.btn.style.bottom=e.padding+"px",c.btn.style.padding="0 "+x+"px",c.btn.style.maxWidth=g.contentW-2*e.controlBorderWidth-2*x+"px",c.btn.style.overflow="hidden",c.btn.style.height=e.buttonHeight+"px",c.btn.style.whiteSpace="nowrap",c.btn.style.border=e.controlBorderWidth+"px solid",w(),c.btn.style.color=e.buttonColor,c.btn.style.font="12px sans-serif",c.btn.style.textAlign="center",c.btn.style.cursor="pointer",c.btn.onmousedown=function(){e.hide()},c.btnT.style.lineHeight=e.buttonHeight+"px",c.btnT.innerHTML="",c.btnT.appendChild(a.document.createTextNode(e.closeText)),j(),k(),l(),b.picker.owner&&b.picker.owner!==e&&b.removeClass(b.picker.owner.targetElement,b.pub.activeClassName),b.picker.owner=e,e.container===a.document.body?b.redrawPosition():b._drawPosition(e,0,0,"relative",!1),c.wrap.parentNode!==e.container&&e.container.appendChild(c.wrap),b.addClass(e.targetElement,b.pub.activeClassName)}function j(){var h,i,j,k,l,a=b.getPadYChannel(e),c=Math.round(e.channels.h/360*(e.width-1)),d=Math.round((1-e.channels[a]/100)*(e.height-1)),f=2*e.pointerBorderWidth+e.pointerThickness+2*e.crossSize,g=-Math.floor(f/2);switch(b.picker.cross.style.left=c+g+"px",b.picker.cross.style.top=d+g+"px",b.getSliderChannel(e)){case"s":h=b.HSV_RGB(e.channels.h,100,e.channels.v),i=b.HSV_RGB(e.channels.h,0,e.channels.v),j="rgb("+Math.round(h[0])+","+Math.round(h[1])+","+Math.round(h[2])+")",k="rgb("+Math.round(i[0])+","+Math.round(i[1])+","+Math.round(i[2])+")",b.picker.sldGrad.draw(e.sliderSize,e.height,j,k);
break;case"v":l=b.HSV_RGB(e.channels.h,e.channels.s,100),j="rgb("+Math.round(l[0])+","+Math.round(l[1])+","+Math.round(l[2])+")",k="#000",b.picker.sldGrad.draw(e.sliderSize,e.height,j,k)}b.picker.asldGrad.draw(e.sliderSize,e.height,e.toHEXString())}function k(){var c,a=b.getSliderChannel(e);a&&(c=Math.round((1-e.channels[a]/100)*(e.height-1)),b.picker.sldPtrOB.style.top=c-(2*e.pointerBorderWidth+e.pointerThickness)-Math.floor(b.pub.sliderInnerSpace/2)+"px"),b.picker.asldGrad.draw(e.sliderSize,e.height,e.toHEXString())}function l(){var a=Math.round((1-e.channels.a)*(e.height-1));b.picker.asldPtrOB.style.top=a-(2*e.pointerBorderWidth+e.pointerThickness)-Math.floor(b.pub.sliderInnerSpace/2)+"px"}function m(){return b.picker&&b.picker.owner===e}function n(a){"Enter"===b.eventKey(a)&&(e.valueElement&&e.processValueInput(e.valueElement.value),e.tryHide())}function o(a){"Enter"===b.eventKey(a)&&(e.alphaElement&&e.processAlphaInput(e.alphaElement.value),e.tryHide())}function p(a){if(!b.getData(a,"internal")){var c=e.valueElement.value;e.processValueInput(e.valueElement.value),b.triggerCallback(e,"onChange"),e.valueElement.value!==c&&b.triggerInputEvent(e.valueElement,"change",!0,!0)}}function q(a){if(!b.getData(a,"internal")){var c=e.alphaElement.value;e.processAlphaInput(e.alphaElement.value),b.triggerCallback(e,"onChange"),b.triggerInputEvent(e.valueElement,"change",!0,!0),e.alphaElement.value!==c&&b.triggerInputEvent(e.alphaElement,"change",!0,!0)}}function r(a){b.getData(a,"internal")||(e.valueElement&&e.fromString(e.valueElement.value,b.flags.leaveValue),b.triggerCallback(e,"onInput"))}function s(a){b.getData(a,"internal")||(e.alphaElement&&e.fromHSVA(null,null,null,parseFloat(e.alphaElement.value),b.flags.leaveAlpha),b.triggerCallback(e,"onInput"),b.triggerInputEvent(e.valueElement,"input",!0,!0))}var t,v,w,x,y,z,A,B,C,D,E,F,e=this;if(d||(d={}),this.channels={r:255,g:255,b:255,h:0,s:0,v:100,a:1},this.format="auto",this.value=void 0,this.alpha=void 0,this.random=!1,this.onChange=void 0,this.onInput=void 0,this.valueElement=void 0,this.alphaElement=void 0,this.previewElement=void 0,this.previewPosition="left",this.previewSize=32,this.previewPadding=8,this.required=!0,this.hash=!0,this.uppercase=!0,this.forceStyle=!0,this.width=181,this.height=101,this.mode="HSV",this.alphaChannel="auto",this.position="bottom",this.smartPosition=!0,this.showOnClick=!0,this.hideOnLeave=!0,this.palette=[],this.paletteCols=10,this.paletteSetsAlpha="auto",this.paletteHeight=16,this.paletteSpacing=4,this.hideOnPaletteClick=!1,this.sliderSize=16,this.crossSize=8,this.closeButton=!1,this.closeText="Close",this.buttonColor="rgba(0,0,0,1)",this.buttonHeight=18,this.padding=12,this.backgroundColor="rgba(255,255,255,1)",this.borderWidth=1,this.borderColor="rgba(187,187,187,1)",this.borderRadius=8,this.controlBorderWidth=1,this.controlBorderColor="rgba(187,187,187,1)",this.shadow=!0,this.shadowBlur=15,this.shadowColor="rgba(0,0,0,0.2)",this.pointerColor="rgba(76,76,76,1)",this.pointerBorderWidth=1,this.pointerBorderColor="rgba(255,255,255,1)",this.pointerThickness=2,this.zIndex=5e3,this.container=void 0,this.minS=0,this.maxS=100,this.minV=0,this.maxV=100,this.minA=0,this.maxA=1,this.option=function(){var b,c,d;if(!arguments.length)throw new Error("No option specified");if(1===arguments.length&&"string"==typeof arguments[0]){try{return g(arguments[0])}catch(a){console.warn(a)}return!1}if(arguments.length>=2&&"string"==typeof arguments[0]){try{if(!f(arguments[0],arguments[1]))return!1}catch(a){return console.warn(a),!1}return this.redraw(),this.exposeColor(),!0}if(1===arguments.length&&"object"==typeof arguments[0]){b=arguments[0],c=!0;for(d in b)if(b.hasOwnProperty(d))try{f(d,b[d])||(c=!1)}catch(a){console.warn(a),c=!1}return this.redraw(),this.exposeColor(),c}throw new Error("Invalid arguments")},this.channel=function(a,b){if("string"!=typeof a)throw new Error("Invalid value for channel name: "+a);if(void 0===b)return this.channels.hasOwnProperty(a.toLowerCase())?this.channels[a.toLowerCase()]:(console.warn("Getting unknown channel: "+a),!1);var c=!1;switch(a.toLowerCase()){case"r":c=this.fromRGBA(b,null,null,null);break;case"g":c=this.fromRGBA(null,b,null,null);break;case"b":c=this.fromRGBA(null,null,b,null);break;case"h":c=this.fromHSVA(b,null,null,null);break;case"s":c=this.fromHSVA(null,b,null,null);break;case"v":c=this.fromHSVA(null,null,b,null);break;case"a":c=this.fromHSVA(null,null,null,b);break;default:return console.warn("Setting unknown channel: "+a),!1}return c?(this.redraw(),!0):!1},this.trigger=function(a){var d,e,f,c=b.strList(a);for(d=0;d<c.length;d+=1){switch(e=c[d].toLowerCase(),f=null,e){case"input":f="onInput";break;case"change":f="onChange"}f&&b.triggerCallback(this,f),b.triggerInputEvent(this.valueElement,e,!0,!0)}},this.fromHSVA=function(a,c,d,e,f){if(void 0===a&&(a=null),void 0===c&&(c=null),void 0===d&&(d=null),void 0===e&&(e=null),null!==a){if(isNaN(a))return!1;this.channels.h=Math.max(0,Math.min(360,a))}if(null!==c){if(isNaN(c))return!1;this.channels.s=Math.max(0,Math.min(100,this.maxS,c),this.minS)}if(null!==d){if(isNaN(d))return!1;this.channels.v=Math.max(0,Math.min(100,this.maxV,d),this.minV)}if(null!==e){if(isNaN(e))return!1;this.channels.a=this.hasAlphaChannel()?Math.max(0,Math.min(1,this.maxA,e),this.minA):1}var g=b.HSV_RGB(this.channels.h,this.channels.s,this.channels.v);return this.channels.r=g[0],this.channels.g=g[1],this.channels.b=g[2],this.exposeColor(f),!0},this.fromRGBA=function(a,c,d,e,f){var g,h;if(void 0===a&&(a=null),void 0===c&&(c=null),void 0===d&&(d=null),void 0===e&&(e=null),null!==a){if(isNaN(a))return!1;a=Math.max(0,Math.min(255,a))}if(null!==c){if(isNaN(c))return!1;c=Math.max(0,Math.min(255,c))}if(null!==d){if(isNaN(d))return!1;d=Math.max(0,Math.min(255,d))}if(null!==e){if(isNaN(e))return!1;this.channels.a=this.hasAlphaChannel()?Math.max(0,Math.min(1,this.maxA,e),this.minA):1}return g=b.RGB_HSV(null===a?this.channels.r:a,null===c?this.channels.g:c,null===d?this.channels.b:d),null!==g[0]&&(this.channels.h=Math.max(0,Math.min(360,g[0]))),0!==g[2]&&(this.channels.s=Math.max(0,this.minS,Math.min(100,this.maxS,g[1]))),this.channels.v=Math.max(0,this.minV,Math.min(100,this.maxV,g[2])),h=b.HSV_RGB(this.channels.h,this.channels.s,this.channels.v),this.channels.r=h[0],this.channels.g=h[1],this.channels.b=h[2],this.exposeColor(f),!0},this.fromHSV=function(a,c,d,e){return console.warn("fromHSV() method is DEPRECATED. Using fromHSVA() instead."+b.docsRef),this.fromHSVA(a,c,d,null,e)},this.fromRGB=function(a,c,d,e){return console.warn("fromRGB() method is DEPRECATED. Using fromRGBA() instead."+b.docsRef),this.fromRGBA(a,c,d,null,e)},this.fromString=function(a,c){if(!this.required&&""===a.trim())return this.setPreviewElementBg(null),this.setValueElementValue(""),!0;var d=b.parseColorString(a);return d?("any"===this.format.toLowerCase()&&(this._setFormat(d.format),b.isAlphaFormat(this.getFormat())||(d.rgba[3]=1)),this.fromRGBA(d.rgba[0],d.rgba[1],d.rgba[2],d.rgba[3],c),!0):!1},this.randomize=function(a,b,c,d,e,f,g,h){void 0===a&&(a=0),void 0===b&&(b=100),void 0===c&&(c=0),void 0===d&&(d=100),void 0===e&&(e=0),void 0===f&&(f=359),void 0===g&&(g=1),void 0===h&&(h=1),this.fromHSVA(e+Math.floor(Math.random()*(f-e+1)),c+Math.floor(Math.random()*(d-c+1)),a+Math.floor(Math.random()*(b-a+1)),(100*g+Math.floor(Math.random()*(100*(h-g)+1)))/100)},this.toString=function(a){switch(void 0===a&&(a=this.getFormat()),a.toLowerCase()){case"hex":return this.toHEXString();case"hexa":return this.toHEXAString();case"rgb":return this.toRGBString();case"rgba":return this.toRGBAString()}return!1},this.toHEXString=function(){return b.hexColor(this.channels.r,this.channels.g,this.channels.b)},this.toHEXAString=function(){return b.hexaColor(this.channels.r,this.channels.g,this.channels.b,this.channels.a)},this.toRGBString=function(){return b.rgbColor(this.channels.r,this.channels.g,this.channels.b)},this.toRGBAString=function(){return b.rgbaColor(this.channels.r,this.channels.g,this.channels.b,this.channels.a)},this.toGrayscale=function(){return.213*this.channels.r+.715*this.channels.g+.072*this.channels.b},this.toCanvas=function(){return b.genColorPreviewCanvas(this.toRGBAString()).canvas},this.toDataURL=function(){return this.toCanvas().toDataURL()},this.toBackground=function(){return b.pub.background(this.toRGBAString())},this.isLight=function(){return this.toGrayscale()>127.5},this.hide=function(){m()&&h()},this.show=function(){i()},this.redraw=function(){m()&&i()},this.getFormat=function(){return this._currentFormat},this._setFormat=function(a){this._currentFormat=a.toLowerCase()},this.hasAlphaChannel=function(){return"auto"===this.alphaChannel?"any"===this.format.toLowerCase()||b.isAlphaFormat(this.getFormat())||void 0!==this.alpha||void 0!==this.alphaElement:this.alphaChannel},this.processValueInput=function(a){this.fromString(a)||this.exposeColor()},this.processAlphaInput=function(a){this.fromHSVA(null,null,null,parseFloat(a))||this.exposeColor()},this.exposeColor=function(a){var e,f,c=this.toString(),d=this.getFormat();b.setDataAttr(this.targetElement,"current-color",c),a&b.flags.leaveValue||!this.valueElement||(("hex"===d||"hexa"===d)&&(this.uppercase||(c=c.toLowerCase()),this.hash||(c=c.replace(/^#/,""))),this.setValueElementValue(c)),a&b.flags.leaveAlpha||!this.alphaElement||(e=Math.round(100*this.channels.a)/100,this.setAlphaElementValue(e)),a&b.flags.leavePreview||!this.previewElement||(f=null,(b.isTextInput(this.previewElement)||b.isButton(this.previewElement)&&!b.isButtonEmpty(this.previewElement))&&(f=this.previewPosition),this.setPreviewElementBg(this.toRGBAString())),m()&&(j(),k(),l())},this.setPreviewElementBg=function(a){var c,d,e,f,g,h,i,j;if(this.previewElement){for(c=null,d=null,(b.isTextInput(this.previewElement)||b.isButton(this.previewElement)&&!b.isButtonEmpty(this.previewElement))&&(c=this.previewPosition,d=this.previewSize),e=[],a?(e.push({image:b.genColorPreviewGradient(a,c,d?d-b.pub.previewSeparator.length:null),position:"left top",size:"auto",repeat:c?"repeat-y":"repeat",origin:"padding-box"}),f=b.genColorPreviewCanvas("rgba(0,0,0,0)",c?{left:"right",right:"left"}[c]:null,d,!0),e.push({image:"url('"+f.canvas.toDataURL()+"')",position:(c||"left")+" top",size:f.width+"px "+f.height+"px",repeat:c?"repeat-y":"repeat",origin:"padding-box"})):e.push({image:"none",position:"left top",size:"auto",repeat:"no-repeat",origin:"padding-box"}),g={image:[],position:[],size:[],repeat:[],origin:[]},h=0;h<e.length;h+=1)g.image.push(e[h].image),g.position.push(e[h].position),g.size.push(e[h].size),g.repeat.push(e[h].repeat),g.origin.push(e[h].origin);i={"background-image":g.image.join(", "),"background-position":g.position.join(", "),"background-size":g.size.join(", "),"background-repeat":g.repeat.join(", "),"background-origin":g.origin.join(", ")},b.setStyle(this.previewElement,i,this.forceStyle),j={left:null,right:null},c&&(j[c]=this.previewSize+this.previewPadding+"px"),i={"padding-left":j.left,"padding-right":j.right},b.setStyle(this.previewElement,i,this.forceStyle,!0)}},this.setValueElementValue=function(a){this.valueElement&&("input"===b.nodeName(this.valueElement)?this.valueElement.value=a:this.valueElement.innerHTML=a)},this.setAlphaElementValue=function(a){this.alphaElement&&("input"===b.nodeName(this.alphaElement)?this.alphaElement.value=a:this.alphaElement.innerHTML=a)},this._processParentElementsInDOM=function(){var a,c;if(!this._parentElementsProcessed){this._parentElementsProcessed=!0,a=this.targetElement;do c=b.getCompStyle(a),c.position&&"fixed"===c.position.toLowerCase()&&(this.fixed=!0),a!==this.targetElement&&(b.getData(a,"hasScrollListener")||(a.addEventListener("scroll",b.onParentScroll,!1),b.setData(a,"hasScrollListener",!0)));while((a=a.parentNode)&&"body"!==b.nodeName(a))}},this.tryHide=function(){this.hideOnLeave&&this.hide()},this.set__palette=function(a){this.palette=a,this._palette=b.parsePaletteValue(a),this._paletteHasTransparency=b.containsTranparentColor(this._palette)},b.pub.options)for(t in b.pub.options)if(b.pub.options.hasOwnProperty(t))try{f(t,b.pub.options[t])}catch(u){console.warn(u)}for(v=[],d.preset&&("string"==typeof d.preset?v=d.preset.split(/\s+/):Array.isArray(d.preset)?v=d.preset.slice():console.warn("Unrecognized preset value")),-1===v.indexOf("default")&&v.push("default"),w=v.length-1;w>=0;w-=1)if(x=v[w])if(b.pub.presets.hasOwnProperty(x)){for(t in b.pub.presets[x])if(b.pub.presets[x].hasOwnProperty(t))try{f(t,b.pub.presets[x][t])}catch(u){console.warn(u)}}else console.warn("Unknown preset: %s",x);y=["preset"];for(t in d)if(d.hasOwnProperty(t)&&-1===y.indexOf(t))try{f(t,d[t])}catch(u){console.warn(u)}if(this.container=void 0===this.container?a.document.body:b.node(this.container),!this.container)throw new Error("Cannot instantiate color picker without a container element");if(this.targetElement=b.node(c),!this.targetElement){if("string"==typeof c&&/^[a-zA-Z][\w:.-]*$/.test(c))throw z=c,new Error("If '"+z+"' is supposed to be an ID, please use '#"+z+"' or any valid CSS selector.");throw new Error("Cannot instantiate color picker without a target element")}if(this.targetElement.jscolor&&this.targetElement.jscolor instanceof b.pub)throw new Error("Color picker already installed on this element");this.targetElement.jscolor=this,b.addClass(this.targetElement,b.pub.className),b.instances.push(this),b.isButton(this.targetElement)&&("button"!==this.targetElement.type.toLowerCase()&&(this.targetElement.type="button"),b.isButtonEmpty(this.targetElement)&&(b.removeChildren(this.targetElement),this.targetElement.appendChild(a.document.createTextNode(" ")),A=b.getCompStyle(this.targetElement),B=parseFloat(A["min-width"])||0,B<this.previewSize&&b.setStyle(this.targetElement,{"min-width":this.previewSize+"px"},this.forceStyle))),void 0===this.valueElement?b.isTextInput(this.targetElement)&&(this.valueElement=this.targetElement):null===this.valueElement||(this.valueElement=b.node(this.valueElement)),this.alphaElement&&(this.alphaElement=b.node(this.alphaElement)),void 0===this.previewElement?this.previewElement=this.targetElement:null===this.previewElement||(this.previewElement=b.node(this.previewElement)),this.valueElement&&b.isTextInput(this.valueElement)&&(C={onInput:this.valueElement.oninput},this.valueElement.oninput=null,this.valueElement.addEventListener("keydown",n,!1),this.valueElement.addEventListener("change",p,!1),this.valueElement.addEventListener("input",r,!1),C.onInput&&this.valueElement.addEventListener("input",C.onInput,!1),this.valueElement.setAttribute("autocomplete","off"),this.valueElement.setAttribute("autocorrect","off"),this.valueElement.setAttribute("autocapitalize","off"),this.valueElement.setAttribute("spellcheck",!1)),this.alphaElement&&b.isTextInput(this.alphaElement)&&(this.alphaElement.addEventListener("keydown",o,!1),this.alphaElement.addEventListener("change",q,!1),this.alphaElement.addEventListener("input",s,!1),this.alphaElement.setAttribute("autocomplete","off"),this.alphaElement.setAttribute("autocorrect","off"),this.alphaElement.setAttribute("autocapitalize","off"),this.alphaElement.setAttribute("spellcheck",!1)),D="FFFFFF",void 0!==this.value?D=this.value:this.valueElement&&void 0!==this.valueElement.value&&(D=this.valueElement.value),E=void 0,void 0!==this.alpha?E=""+this.alpha:this.alphaElement&&void 0!==this.alphaElement.value&&(E=this.alphaElement.value),this._currentFormat=null,["auto","any"].indexOf(this.format.toLowerCase())>-1?(F=b.parseColorString(D),this._currentFormat=F?F.format:"hex"):this._currentFormat=this.format.toLowerCase(),this.processValueInput(D),void 0!==E&&this.processAlphaInput(E),this.random&&this.randomize.apply(this,Array.isArray(this.random)?this.random:[])}};return b.pub.className="jscolor",b.pub.activeClassName="jscolor-active",b.pub.looseJSON=!0,b.pub.presets={},b.pub.presets["default"]={},b.pub.presets["light"]={backgroundColor:"rgba(255,255,255,1)",controlBorderColor:"rgba(187,187,187,1)",buttonColor:"rgba(0,0,0,1)"},b.pub.presets["dark"]={backgroundColor:"rgba(51,51,51,1)",controlBorderColor:"rgba(153,153,153,1)",buttonColor:"rgba(240,240,240,1)"},b.pub.presets["small"]={width:101,height:101,padding:10,sliderSize:14,paletteCols:8},b.pub.presets["medium"]={width:181,height:101,padding:12,sliderSize:16,paletteCols:10},b.pub.presets["large"]={width:271,height:151,padding:12,sliderSize:24,paletteCols:15},b.pub.presets["thin"]={borderWidth:1,controlBorderWidth:1,pointerBorderWidth:1},b.pub.presets["thick"]={borderWidth:2,controlBorderWidth:2,pointerBorderWidth:2},b.pub.sliderInnerSpace=3,b.pub.chessboardSize=8,b.pub.chessboardColor1="#666666",b.pub.chessboardColor2="#999999",b.pub.previewSeparator=["rgba(255,255,255,.65)","rgba(128,128,128,.65)"],b.pub.init=function(){if(!b.initialized)for(a.document.addEventListener("mousedown",b.onDocumentMouseDown,!1),a.document.addEventListener("keyup",b.onDocumentKeyUp,!1),a.addEventListener("resize",b.onWindowResize,!1),a.addEventListener("scroll",b.onWindowScroll,!1),b.pub.install(),b.initialized=!0;b.readyQueue.length;){var c=b.readyQueue.shift();c()}},b.pub.install=function(a){var c=!0;try{b.installBySelector("[data-jscolor]",a)}catch(d){c=!1,console.warn(d)}if(b.pub.lookupClass)try{b.installBySelector("input."+b.pub.lookupClass+", "+"button."+b.pub.lookupClass,a)}catch(d){}return c},b.pub.ready=function(a){return"function"!=typeof a?(console.warn("Passed value is not a function"),!1):(b.initialized?a():b.readyQueue.push(a),!0)},b.pub.trigger=function(a){var c=function(){b.triggerGlobal(a)};b.initialized?c():b.pub.ready(c)},b.pub.hide=function(){b.picker&&b.picker.owner&&b.picker.owner.hide()},b.pub.chessboard=function(a){a||(a="rgba(0,0,0,0)");var c=b.genColorPreviewCanvas(a);return c.canvas.toDataURL()},b.pub.background=function(a){var d,c=[];return c.push(b.genColorPreviewGradient(a)),d=b.genColorPreviewCanvas(),c.push(["url('"+d.canvas.toDataURL()+"')","left top","repeat"].join(" ")),c.join(", ")},b.pub.options={},b.pub.lookupClass="jscolor",b.pub.installByClassName=function(){return console.error('jscolor.installByClassName() is DEPRECATED. Use data-jscolor="" attribute instead of a class name.'+b.docsRef),!1},b.register(),b.pub}();return"undefined"==typeof a.jscolor&&(a.jscolor=a.JSColor=b),b});