"use strict";window.jscolor||(window.jscolor=function(){var d={register:function(){d.attachDOMReadyEvent(d.init),d.attachEvent(document,"mousedown",d.onDocumentMouseDown),d.attachEvent(document,"touchstart",d.onDocumentTouchStart),d.attachEvent(window,"resize",d.onWindowResize)},init:function(){d.jscolor.lookupClass&&d.jscolor.installByClassName(d.jscolor.lookupClass)},tryInstallOnElements:function(a,b){for(var c=new RegExp("(^|\\s)("+b+")(\\s*(\\{[^}]*\\})|\\s|$)","i"),e=0;em[h]?-f[h]+e[h]+k[h]/2>m[h]/2&&0<=e[h]+k[h]-n[h]?e[h]+k[h]-n[h]:e[h]:e[h],-f[i]+e[i]+k[i]+n[i]-o+o*j>m[i]?-f[i]+e[i]+k[i]/2>m[i]/2&&0<=e[i]+k[i]-o-o*j?e[i]+k[i]-o-o*j:e[i]+k[i]-o+o*j:0<=e[i]+k[i]-o+o*j?e[i]+k[i]-o+o*j:e[i]+k[i]-o-o*j];var p=l[h],q=l[i],r=g.fixed?"fixed":"absolute",s=(l[0]+n[0]>e[0]||l[0]b.length?b[0]:b[1]+" "+b[0]+" "+b[0]+" "+b[1];a.btn.style.borderColor=c}(),a.btn.style.color=o.buttonColor,a.btn.style.font="12px sans-serif",a.btn.style.textAlign="center";try{a.btn.style.cursor="pointer"}catch(b){a.btn.style.cursor="hand"}a.btn.onmousedown=function(){o.hide()},a.btnT.style.lineHeight=o.buttonHeight+"px",a.btnT.innerHTML="",a.btnT.appendChild(document.createTextNode(o.closeText)),h(),i(),d.picker.owner&&d.picker.owner!==o&&d.unsetClass(d.picker.owner.targetElement,o.activeClass),d.picker.owner=o,d.isElementType(q,"body")?d.redrawPosition():d._drawPosition(o,0,0,"relative",!1),a.wrap.parentNode!=q&&q.appendChild(a.wrap),d.setClass(o.targetElement,o.activeClass)}function h(){switch(d.getPadYComponent(o)){case"s":var a=1;break;case"v":var a=2;}var b=Math.round(o.hsv[0]/360*(o.width-1)),c=Math.round((1-o.hsv[a]/100)*(o.height-1)),f=2*o.pointerBorderWidth+o.pointerThickness+2*o.crossSize,g=-Math.floor(f/2);switch(d.picker.cross.style.left=b+g+"px",d.picker.cross.style.top=c+g+"px",d.getSliderComponent(o)){case"s":var h=e(o.hsv[0],100,o.hsv[2]),i=e(o.hsv[0],0,o.hsv[2]),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])+")";d.picker.sldGrad.draw(o.sliderSize,o.height,j,k);break;case"v":var l=e(o.hsv[0],o.hsv[1],100),j="rgb("+Math.round(l[0])+","+Math.round(l[1])+","+Math.round(l[2])+")",k="#000";d.picker.sldGrad.draw(o.sliderSize,o.height,j,k);}}function i(){var a=d.getSliderComponent(o);if(a){switch(a){case"s":var b=1;break;case"v":var b=2;}var c=Math.round((1-o.hsv[b]/100)*(o.height-1));d.picker.sldPtrOB.style.top=c-(2*o.pointerBorderWidth+o.pointerThickness)-Math.floor(r/2)+"px"}}function j(){return d.picker&&d.picker.owner===o}function k(){o.importColor()}for(var l in this.value=null,this.valueElement=a,this.styleElement=a,this.required=!0,this.refine=!0,this.hash=!1,this.uppercase=!0,this.onFineChange=null,this.activeClass="jscolor-active",this.overwriteImportant=!1,this.minS=0,this.maxS=100,this.minV=0,this.maxV=100,this.hsv=[0,0,100],this.rgb=[255,255,255],this.width=181,this.height=101,this.showOnClick=!0,this.mode="HSV",this.position="bottom",this.smartPosition=!0,this.sliderSize=16,this.crossSize=8,this.closable=!1,this.closeText="Close",this.buttonColor="#000000",this.buttonHeight=18,this.padding=12,this.backgroundColor="#FFFFFF",this.borderWidth=1,this.borderColor="#BBBBBB",this.borderRadius=8,this.insetWidth=1,this.insetColor="#BBBBBB",this.shadow=!0,this.shadowBlur=15,this.shadowColor="rgba(0,0,0,0.2)",this.pointerColor="#4C4C4C",this.pointerBorderColor="#FFFFFF",this.pointerBorderWidth=1,this.pointerThickness=2,this.zIndex=1e3,this.container=null,b)b.hasOwnProperty(l)&&(this[l]=b[l]);if(this.hide=function(){j()&&f()},this.show=function(){g()},this.redraw=function(){j()&&g()},this.importColor=function(){this.valueElement?d.isElementType(this.valueElement,"input")?this.refine?!this.required&&/^\s*$/.test(this.valueElement.value)?(this.valueElement.value="",this.styleElement&&(this.styleElement.style.backgroundImage=this.styleElement._jscOrigStyle.backgroundImage,this.styleElement.style.backgroundColor=this.styleElement._jscOrigStyle.backgroundColor,this.styleElement.style.color=this.styleElement._jscOrigStyle.color),this.exportColor(d.leaveValue|d.leaveStyle)):this.fromString(this.valueElement.value)||this.exportColor():!this.fromString(this.valueElement.value,d.leaveValue)&&(this.styleElement&&(this.styleElement.style.backgroundImage=this.styleElement._jscOrigStyle.backgroundImage,this.styleElement.style.backgroundColor=this.styleElement._jscOrigStyle.backgroundColor,this.styleElement.style.color=this.styleElement._jscOrigStyle.color),this.exportColor(d.leaveValue|d.leaveStyle)):this.exportColor():this.exportColor()},this.exportColor=function(a){if(!(a&d.leaveValue)&&this.valueElement){var b=this.toString();this.uppercase&&(b=b.toUpperCase()),this.hash&&(b="#"+b),d.isElementType(this.valueElement,"input")?this.valueElement.value=b:this.valueElement.innerHTML=b}if(!(a&d.leaveStyle)&&this.styleElement){var c="#"+this.toString(),e=this.isLight()?"#000":"#FFF";this.styleElement.style.backgroundImage="none",this.styleElement.style.backgroundColor=c,this.styleElement.style.color=e,this.overwriteImportant&&this.styleElement.setAttribute("style","background: "+c+" !important; color: "+e+" !important;")}!(a&d.leavePad)&&j()&&h(),!(a&d.leaveSld)&&j()&&i()},this.fromHSV=function(a,b,c,d){if(null!==a){if(isNaN(a))return!1;a=Math.max(0,Math.min(360,a))}if(null!==b){if(isNaN(b))return!1;b=Math.max(0,Math.min(100,this.maxS,b),this.minS)}if(null!==c){if(isNaN(c))return!1;c=Math.max(0,Math.min(100,this.maxV,c),this.minV)}this.rgb=e(null===a?this.hsv[0]:this.hsv[0]=a,null===b?this.hsv[1]:this.hsv[1]=b,null===c?this.hsv[2]:this.hsv[2]=c),this.exportColor(d)},this.fromRGB=function(a,d,f,h){if(null!==a){if(isNaN(a))return!1;a=Math.max(0,Math.min(255,a))}if(null!==d){if(isNaN(d))return!1;d=Math.max(0,Math.min(255,d))}if(null!==f){if(isNaN(f))return!1;f=Math.max(0,Math.min(255,f))}var i=c(null===a?this.rgb[0]:a,null===d?this.rgb[1]:d,null===f?this.rgb[2]:f);null!==i[0]&&(this.hsv[0]=Math.max(0,Math.min(360,i[0]))),0!==i[2]&&(this.hsv[1]=null===i[1]?null:Math.max(0,this.minS,Math.min(100,this.maxS,i[1]))),this.hsv[2]=null===i[2]?null:Math.max(0,this.minV,Math.min(100,this.maxV,i[2]));var j=e(this.hsv[0],this.hsv[1],this.hsv[2]);this.rgb[0]=j[0],this.rgb[1]=j[1],this.rgb[2]=j[2],this.exportColor(h)},this.fromString=function(a,c){var d;if(d=a.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i))return 6===d[1].length?this.fromRGB(parseInt(d[1].substr(0,2),16),parseInt(d[1].substr(2,2),16),parseInt(d[1].substr(4,2),16),c):this.fromRGB(parseInt(d[1].charAt(0)+d[1].charAt(0),16),parseInt(d[1].charAt(1)+d[1].charAt(1),16),parseInt(d[1].charAt(2)+d[1].charAt(2),16),c),!0;if(d=a.match(/^\W*rgba?\(([^)]*)\)\W*$/i)){var e,f,h,i=d[1].split(","),j=/^\s*(\d*)(\.\d+)?\s*$/;if(3<=i.length&&(e=i[0].match(j))&&(f=i[1].match(j))&&(h=i[2].match(j))){var k=parseFloat((e[1]||"0")+(e[2]||"")),l=parseFloat((f[1]||"0")+(f[2]||"")),g=parseFloat((h[1]||"0")+(h[2]||""));return this.fromRGB(k,l,g,c),!0}}return!1},this.toString=function(){return(256|Math.round(this.rgb[0])).toString(16).substr(1)+(256|Math.round(this.rgb[1])).toString(16).substr(1)+(256|Math.round(this.rgb[2])).toString(16).substr(1)},this.toHEXString=function(){return"#"+this.toString().toUpperCase()},this.toRGBString=function(){return"rgb("+Math.round(this.rgb[0])+","+Math.round(this.rgb[1])+","+Math.round(this.rgb[2])+")"},this.isLight=function(){return .213*this.rgb[0]+.715*this.rgb[1]+.072*this.rgb[2]>255/2},this._processParentElementsInDOM=function(){if(!this._linkedElementsProcessed){this._linkedElementsProcessed=!0;var a=this.targetElement;do{var b=d.getStyle(a);b&&"fixed"===b.position.toLowerCase()&&(this.fixed=!0),a===this.targetElement||a._jscEventsAttached||(d.attachEvent(a,"scroll",d.onParentScroll),a._jscEventsAttached=!0)}while((a=a.parentNode)&&!d.isElementType(a,"body"))}},"string"==typeof a){var m=a,n=document.getElementById(m);n?this.targetElement=n:d.warn("Could not find target element with ID '"+m+"'")}else a?this.targetElement=a:d.warn("Invalid target element: '"+a+"'");if(this.targetElement._jscLinkedInstance)return void d.warn("Cannot link jscolor twice to the same element. Skipping.");this.targetElement._jscLinkedInstance=this,this.valueElement=d.fetchElement(this.valueElement),this.styleElement=d.fetchElement(this.styleElement);var o=this,q=this.container?d.fetchElement(this.container):document.getElementsByTagName("body")[0],r=3;if(d.isElementType(this.targetElement,"button"))if(this.targetElement.onclick){var s=this.targetElement.onclick;this.targetElement.onclick=function(a){return s.call(this,a),!1}}else this.targetElement.onclick=function(){return!1};if(this.valueElement&&d.isElementType(this.valueElement,"input")){var t=function(){o.fromString(o.valueElement.value,d.leaveValue),d.dispatchFineChange(o)};d.attachEvent(this.valueElement,"keyup",t),d.attachEvent(this.valueElement,"input",t),d.attachEvent(this.valueElement,"blur",k),this.valueElement.setAttribute("autocomplete","off")}this.styleElement&&(this.styleElement._jscOrigStyle={backgroundImage:this.styleElement.style.backgroundImage,backgroundColor:this.styleElement.style.backgroundColor,color:this.styleElement.style.color}),this.value?this.fromString(this.value)||this.exportColor():this.importColor()}};return d.jscolor.lookupClass="jscolor",d.jscolor.installByClassName=function(a){var b=document.getElementsByTagName("input"),c=document.getElementsByTagName("button");d.tryInstallOnElements(b,a),d.tryInstallOnElements(c,a)},d.register(),d.jscolor}());