/*
   evol-colorpicker 3.4.3
   (c) 2021 Olivier Giulieri
   http://evoluteur.github.io/colorpicker/
*/

!function(a){function e(t){return t=1==(t=t.toString(16)).length?"0"+t:t}function i(t){return e(Number(t))}function h(t){return(t=e(t))+t+t}function s(t){if(10<t.length){var e=1+t.indexOf("("),o=t.indexOf(")"),o=t.substring(e,o).split(",");return["#",i(o[0]),i(o[1]),i(o[2])].join("")}return t}var r=0,t=window.navigator.userAgent,d=0<t.indexOf("MSIE "),p=d?"-ie":"",l=!d&&(/mozilla/.test(t.toLowerCase())&&!/webkit/.test(t.toLowerCase())),u=[],v=["ffffff","000000","eeece1","1f497d","4f81bd","c0504d","9bbb59","8064a2","4bacc6","f79646"],_=["f2f2f2","7f7f7f","ddd9c3","c6d9f0","dbe5f1","f2dcdb","ebf1dd","e5e0ec","dbeef3","fdeada","d8d8d8","595959","c4bd97","8db3e2","b8cce4","e5b9b7","d7e3bc","ccc1d9","b7dde8","fbd5b5","bfbfbf","3f3f3f","938953","548dd4","95b3d7","d99694","c3d69b","b2a2c7","92cddc","fac08f","a5a5a5","262626","494429","17365d","366092","953734","76923c","5f497a","31859b","e36c09","7f7f7f","0c0c0c","1d1b10","0f243e","244061","632423","4f6128","3f3151","205867","974806"],b=["c00000","ff0000","ffc000","ffff00","92d050","00b050","00b0f0","0070c0","002060","7030a0"],m=[["003366","336699","3366cc","003399","000099","0000cc","000066"],["006666","006699","0099cc","0066cc","0033cc","0000ff","3333ff","333399"],["669999","009999","33cccc","00ccff","0099ff","0066ff","3366ff","3333cc","666699"],["339966","00cc99","00ffcc","00ffff","33ccff","3399ff","6699ff","6666ff","6600ff","6600cc"],["339933","00cc66","00ff99","66ffcc","66ffff","66ccff","99ccff","9999ff","9966ff","9933ff","9900ff"],["006600","00cc00","00ff00","66ff99","99ffcc","ccffff","ccccff","cc99ff","cc66ff","cc33ff","cc00ff","9900cc"],["003300","009933","33cc33","66ff66","99ff99","ccffcc","ffffff","ffccff","ff99ff","ff66ff","ff00ff","cc00cc","660066"],["333300","009900","66ff33","99ff66","ccff99","ffffcc","ffcccc","ff99cc","ff66cc","ff33cc","cc0099","993399"],["336600","669900","99ff33","ccff66","ffff99","ffcc99","ff9999","ff6699","ff3399","cc3399","990099"],["666633","99cc00","ccff33","ffff66","ffcc66","ff9966","ff6666","ff0066","d60094","993366"],["a58800","cccc00","ffff00","ffcc00","ff9933","ff6600","ff0033","cc0066","660033"],["996633","cc9900","ff9900","cc6600","ff3300","ff0000","cc0000","990033"],["663300","996600","cc3300","993300","990000","800000","993333"]],g="#0000ffff";a.widget("evol.colorpicker",{version:"3.4.0",options:{color:null,customTheme:null,showOn:"both",hideButton:!1,displayIndicator:!0,transparentColor:!1,history:!0,defaultPalette:"theme",strings:"Theme Colors,Standard Colors,Web Colors,Theme Colors,Back to Palette,History,No history yet."},_active:!1,_create:function(){var t,e,o,i,s=this,f=this.options.color;if(this._paletteIdx="theme"==this.options.defaultPalette?1:2,this._id="evo-cp"+r++,this._enabled=!0,this.options.showOn=this.options.hideButton?"focus":this.options.showOn,"INPUT"===this.element.get(0).tagName?(t=this.element,e=("focus"===this.options.showOn?"":"evo-pointer ")+"evo-colorind"+(l?"-ff":p)+(this.options.hideButton?" evo-hidden-button":""),this._isPopup=!(i=""),this._palette=null,o=t.val(),null!==f?f!=o&&t.val(f).change():""!==o&&(f=this.options.color=o),f===g?e+=" evo-transparent":i=null!==f?"background-color:"+f:"",t.addClass("colorPicker "+this._id).wrap('<div style="width:'+(this.options.hideButton?this.element.width():this.element.width()+32)+"px;"+(d?"margin-bottom:-21px;":"")+(l?"padding:1px 0;":"")+'" class="evo-cp-wrap"></div>').after('<div class="'+e+'" style="'+i+'"></div>').on("keyup onpaste",function(t){var e=a(this).val();e!=s.options.color&&s._setValue(e,!0)}),"both"!==(i=this.options.showOn)&&"focus"!==i||t.on("focus",function(){s.showPalette()}),"both"!==i&&"button"!==i||t.next().on("click",function(t){return t.stopPropagation(),s.showPalette(),!1})):(this._isPopup=!1,this._palette=this.element.html(this._paletteHTML()).attr("aria-haspopup","true"),this._bindColors()),this.options.history){f&&this._add2History(f);var n=this.options.initialHistory;if(n)for(var c in n)this._add2History(n[c])}},_paletteHTML:function(){var t=this._paletteIdx=Math.abs(this._paletteIdx),e=this.options,o=e.strings.split(","),t='<div class="evo-pop'+p+' ui-widget ui-widget-content ui-corner-all"'+(this._isPopup?' style="position:absolute"':"")+"><span>"+this["_paletteHTML"+t]()+'</span><div class="evo-more"><a href="javascript:void(0)">'+o[1+t]+"</a>";return e.history&&(t+='<a href="javascript:void(0)" class="evo-hist">'+o[5]+"</a>"),t+="</div>",e.displayIndicator&&(t+=this._colorIndHTML(this.options.color)+this._colorIndHTML("")),t+="</div>"},_colorIndHTML:function(t){var e=d?"evo-colorbox-ie ":"",o="";return t?t===g?e+="evo-transparent":o="background-color:"+t:o="display:none",'<div class="evo-color" style="float:left"><div style="'+o+'" class="'+e+'"></div><span>'+(t||"")+"</span></div>"},_paletteHTML1:function(){var t,e=this.options,o=e.strings.split(","),i='<td style="background-color:',s=d?'"><div style="width:2px;"></div></td>':'"><span></span></td>',f='<tr><th colspan="10" class="ui-widget-content">',n='<table class="'+("evo-palette"+p+(e.customTheme?" cust-theme":""))+'">'+f+o[0]+"</th></tr><tr>";if(e.customTheme)for(t=0,ml=e.customTheme.length;t<ml;t++)n+=i+e.customTheme[t]+s,t%10==9&&(n+="</tr><tr>");else{for(i+="#",t=0;t<10;t++)n+=i+v[t]+s;for(n+="</tr>",d||(n+='<tr><th colspan="10"></th></tr>'),n+='<tr class="top">',t=0;t<10;t++)n+=i+_[t]+s;for(var c=1;c<4;c++)for(n+='</tr><tr class="in">',t=0;t<10;t++)n+=i+_[10*c+t]+s;for(n+='</tr><tr class="bottom">',t=40;t<50;t++)n+=i+_[t]+s;for(n+="</tr>"+f,e.transparentColor&&(n+='<div class="evo-transparent evo-tr-box"></div>'),n+=o[1]+"</th></tr><tr>",t=0;t<10;t++)n+=i+b[t]+s}return n+="</tr></table>"},_paletteHTML2:function(){for(var t='<td style="background-color:#',e=d?'"><div style="width:5px;"></div></td>':'"><span></span></td>',o='<table class="evo-palette2'+p+'"><tr>',i="</tr></table>",s='<div class="evo-palcenter">',f=0,n=m.length;f<n;f++){s+=o;for(var c=m[f],a=0,r=c.length;a<r;a++)s+=t+c[a]+e;s+=i}s+='<div class="evo-sep"></div>';var l="";for(s+=o,a=255;10<a;a-=10)s+=t+h(a)+e,l+=t+h(a-=10)+e;return s+=i+o+l+i+"</div>"},_switchPalette:function(t){if(this._enabled){var e,o,i=this.options,s=i.strings.split(",");if(a(t).hasClass("evo-hist")){var f='<table class="evo-palette"><tr><th class="ui-widget-content">'+s[5]+'</th></tr></tr></table><div class="evo-cHist">';if(0===u.length)f+="<p>&nbsp;"+s[6]+"</p>";else for(var n=u.length-1;-1<n;n--)9===u[n].length?i.transparentColor&&(f+='<div class="evo-transparent"></div>'):f+='<div style="background-color:'+u[n]+'"></div>';e=-this._paletteIdx,o=f+="</div>",c=s[4]}else this._paletteIdx<0?(e=-this._paletteIdx,this._palette.find(".evo-hist").show()):e=2==this._paletteIdx?1:2,o=this["_paletteHTML"+e](),c=s[e+1],this._paletteIdx=e;this._paletteIdx=e;var c=this._palette.find(".evo-more").prev().html(o).end().children().eq(0).html(c);e<0&&c.next().hide()}},_downOrUpPositioning:function(){for(var t=this.element,e=0;null!==t&&e<100;){if("visible"!=t.css("overflow")){var o=this._palette.offset().top+this._palette.height(),i=t.offset().top+t.height(),s=this._palette.offset().top-this._palette.height()-this.element.outerHeight(),f=t.offset().top;i<o&&f<s?this._palette.css({bottom:this.element.outerHeight()+"px"}):this._palette.css({bottom:"auto"});break}if("HTML"==t[0].tagName)break;t=t.offsetParent(),e++}},showPalette:function(){var e;return this._enabled&&(this._active=!0,a(".colorPicker").not("."+this._id).colorpicker("hidePalette"),null===this._palette&&(this._palette=this.element.next().after(this._paletteHTML()).next().on("click",function(t){return t.stopPropagation(),!1}),this._bindColors(),(e=this)._isPopup&&(this._downOrUpPositioning(),a(document.body).on("click."+e._id,function(t){t.target!=e.element.get(0)&&e.hidePalette()}).on("keyup."+e._id,function(t){27===t.keyCode&&e.hidePalette()})))),this},hidePalette:function(){var t;return this._isPopup&&this._palette&&(a(document.body).off("click."+this._id),(t=this)._palette.off("mouseover click","td,.evo-transparent").fadeOut(function(){t._palette.remove(),t._palette=t._cTxt=null}).find(".evo-more a").off("click")),this},_bindColors:function(){var o=this,t=this.options,e=this._palette.find("div.evo-color"),i=t.history?"td,.evo-cHist>div":"td";t.transparentColor&&(i+=",.evo-transparent"),this._cTxt1=e.eq(0).children().eq(0),this._cTxt2=e.eq(1).children().eq(0),this._palette.on("click",i,function(t){var e;o._enabled&&(e=a(this),o._setValue(e.hasClass("evo-transparent")?g:s(e.attr("style").substring(17))),o._active=!1)}).on("mouseover",i,function(t){var e;o._enabled&&(e=(e=a(this)).hasClass("evo-transparent")?g:s(e.attr("style").substring(17)),o.options.displayIndicator&&o._setColorInd(e,2),o._active&&o.element.trigger("mouseover.color",e))}).find(".evo-more a").on("click",function(){return o._switchPalette(this),!1})},val:function(t){return void 0===t?this.options.color:(this._setValue(t),this)},_setValue:function(t,e){t=t.replace(/ /g,""),this.options.color=t,this._isPopup?(e||this.hidePalette(),this._setBoxColor(this.element.val(t).change().next(),t)):this._setColorInd(t,1),this.options.history&&0<this._paletteIdx&&this._add2History(t),this.element.trigger("change.color",t)},_setColorInd:function(t,e){e=this["_cTxt"+e];this._setBoxColor(e,t),e.next().html(t)},_setBoxColor:function(t,e){e===g?t.addClass("evo-transparent").removeAttr("style"):t.removeClass("evo-transparent").attr("style","background-color:"+e)},_setOption:function(t,e){"color"==t?this._setValue(e,!0):this.options[t]=e},_add2History:function(t){for(var e=u.length,o=0;o<e;o++)if(t==u[o])return;27<e&&u.shift(),u.push(t)},clear:function(){this.hidePalette().val("")},enable:function(){var t=this.element;return this._isPopup?t.removeAttr("disabled"):t.css({opacity:"1","pointer-events":"auto"}),"focus"!==this.options.showOn&&this.element.next().addClass("evo-pointer"),t.removeAttr("aria-disabled"),this._enabled=!0,this},disable:function(){var t=this.element;return this._isPopup?t.attr("disabled","disabled"):(this.hidePalette(),t.css({opacity:"0.3","pointer-events":"none"})),"focus"!==this.options.showOn&&this.element.next().removeClass("evo-pointer"),t.attr("aria-disabled","true"),this._enabled=!1,this},isDisabled:function(){return!this._enabled},destroy:function(){a(document.body).off("click."+this._id),this._palette&&(this._palette.off("mouseover click","td,.evo-cHist>div,.evo-transparent").find(".evo-more a").off("click"),this._isPopup&&this._palette.remove(),this._palette=this._cTxt=null),this._isPopup&&this.element.next().off("click").remove().end().off("focus").unwrap(),this.element.removeClass("colorPicker "+this.id).empty(),a.Widget.prototype.destroy.call(this)}})}(jQuery);