!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports&&"object"==typeof module?module.exports=t(require("jquery")):t(jQuery)}(function(jt,Et){"use strict";var Dt={beforeShow:t,move:t,change:t,show:t,hide:t,color:!1,flat:!1,showInput:!1,allowEmpty:!1,showButtons:!0,clickoutFiresChange:!0,showInitial:!1,showPalette:!1,showPaletteOnly:!1,hideAfterPaletteSelect:!1,togglePaletteOnly:!1,showSelectionPalette:!0,localStorageKey:!1,appendTo:"body",maxSelectionSize:7,cancelText:"cancel",chooseText:"choose",togglePaletteMoreText:"more",togglePaletteLessText:"less",clearText:"Clear Color Selection",noColorSelectedText:"No Color Selected",preferredFormat:!1,className:"",containerClassName:"",replacerClassName:"",showAlpha:!1,theme:"sp-light",palette:[["#ffffff","#000000","#ff0000","#ff8000","#ffff00","#008000","#0000ff","#4b0082","#9400d3"]],selectionPalette:[],disabled:!1,offset:null},It=[],zt=!!/msie/i.exec(window.navigator.userAgent),Bt=function(){function t(t,e){return!!~(""+t).indexOf(e)}var e=document.createElement("div").style;return e.cssText="background-color:rgba(0,0,0,.5)",t(e.backgroundColor,"rgba")||t(e.backgroundColor,"hsla")}(),Lt=["
","
","
","
"].join(""),Kt=function(){var t="";if(zt)for(var e=1;e<=6;e++)t+="
";return["
","
","
","
","","
","
","
","
","
","
","
","
","
","
","
","
","
","
","
","
","
",t,"
","
","
","
","
","","
","
","
","","","
","
","
"].join("")}();function Vt(t,e,r,a){for(var n=[],i=0;i')}else{n.push(jt("
").append(jt('').attr("title",a.noColorSelectedText)).html())}}return"
"+n.join("")+"
"}function e(t,e){var r,a,n,i,s,o,l,f=(s=e,o=t,(l=jt.extend({},Dt,s)).callbacks={move:Wt(l.move,o),change:Wt(l.change,o),show:Wt(l.show,o),hide:Wt(l.hide,o),beforeShow:Wt(l.beforeShow,o)},l),u=f.flat,c=f.showSelectionPalette,h=f.localStorageKey,d=f.theme,p=f.callbacks,g=(r=Ot,a=10,function(){var t=this,e=arguments;n&&clearTimeout(i),!n&&i||(i=setTimeout(function(){i=null,r.apply(t,e)},a))}),b=!1,v=!1,m=0,y=0,w=0,_=0,x=0,k=0,S=0,C=0,P=0,A=0,M=1,R=[],H=[],F={},T=f.selectionPalette.slice(0),O=f.maxSelectionSize,q="sp-dragging",N=null,j=t.ownerDocument,E=(j.body,jt(t)),D=!1,I=jt(Kt,j).addClass(d),z=I.find(".sp-picker-container"),B=I.find(".sp-color"),L=I.find(".sp-dragger"),K=I.find(".sp-hue"),V=I.find(".sp-slider"),$=I.find(".sp-alpha-inner"),W=I.find(".sp-alpha"),X=I.find(".sp-alpha-handle"),Y=I.find(".sp-input"),G=I.find(".sp-palette"),Q=I.find(".sp-initial"),J=I.find(".sp-cancel"),U=I.find(".sp-clear"),Z=I.find(".sp-choose"),tt=I.find(".sp-palette-toggle"),et=E.is("input"),rt=et&&"color"===E.attr("type")&&Yt(),at=et&&!u,nt=at?jt(Lt).addClass(d).addClass(f.className).addClass(f.replacerClassName):jt([]),it=at?nt:E,st=nt.find(".sp-preview-inner"),ot=f.color||et&&E.val(),lt=!1,ct=f.preferredFormat,ft=!f.showButtons||f.clickoutFiresChange,ut=!ot,ht=f.allowEmpty&&!rt;function dt(){if(f.showPaletteOnly&&(f.showPalette=!0),tt.text(f.showPaletteOnly?f.togglePaletteMoreText:f.togglePaletteLessText),f.palette){R=f.palette.slice(0),H=jt.isArray(R[0])?R:[R],F={};for(var t=0;tO;)T.shift();if(h&&window.localStorage)try{window.localStorage[h]=T.join(";")}catch(t){}}}function bt(){var r=Mt(),t=jt.map(H,function(t,e){return Vt(t,r,"sp-palette-row sp-palette-row-"+e,f)});pt(),T&&t.push(Vt(function(){var t=[];if(f.showPalette)for(var e=0;eo&&rl&&aMath.abs(e-n);N=i?"x":"y"}}else N=null;var s=!N||"y"===N;(!N||"x"===N)&&(P=parseFloat(t/m)),s&&(A=parseFloat((y-e)/y)),ut=!1,f.showAlpha||(M=1),Rt()},mt,yt),ot?(At(ot),Ht(),ct=f.preferredFormat||tinycolor(ot).format,gt(ot)):Ht(),u&&xt();var r=zt?"mousedown.spectrum":"click.spectrum touchstart.spectrum";G.delegate(".sp-thumb-el",r,e),Q.delegate(".sp-thumb-el:nth-child(1)",r,{ignore:!0},e)}();var Nt={show:xt,hide:Ct,toggle:_t,reflow:Ot,option:function(t,e){return t===Et?jt.extend({},f):e===Et?f[t]:(f[t]=e,"preferredFormat"===t&&(ct=f.preferredFormat),void dt())},enable:function(){D=!1,E.attr("disabled",!1),it.removeClass("sp-disabled")},disable:qt,offset:function(t){f.offset=t,Ot()},set:function(t){At(t),Tt()},get:Mt,destroy:function(){E.show(),it.unbind("click.spectrum touchstart.spectrum"),I.remove(),nt.remove(),It[Nt.id]=null},container:I};return Nt.id=It.push(Nt)-1,Nt}function t(){}function $t(t){t.stopPropagation()}function Wt(t,e){var r=Array.prototype.slice,a=r.call(arguments,2);return function(){return t.apply(e,a.concat(r.call(arguments)))}}function Xt(s,o,e,t){o=o||function(){},e=e||function(){},t=t||function(){};var l=document,c=!1,f={},u=0,h=0,d="ontouchstart"in window,r={};function p(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.returnValue=!1}function a(t){if(c){if(zt&&l.documentMode<9&&!t.button)return g();var e=t.originalEvent&&t.originalEvent.touches&&t.originalEvent.touches[0],r=e&&e.pageX||t.pageX,a=e&&e.pageY||t.pageY,n=Math.max(0,Math.min(r-f.left,h)),i=Math.max(0,Math.min(a-f.top,u));d&&p(t),o.apply(s,[n,i,t])}}function g(){c&&(jt(l).unbind(r),jt(l.body).removeClass("sp-dragging"),setTimeout(function(){t.apply(s,arguments)},0)),c=!1}r.selectstart=p,r.dragstart=p,r["touchmove mousemove"]=a,r["touchend mouseup"]=g,jt(s).bind("touchstart mousedown",function(t){(t.which?3==t.which:2==t.button)||c||!1!==e.apply(s,arguments)&&(c=!0,u=jt(s).height(),h=jt(s).width(),f=jt(s).offset(),jt(l).bind(r),jt(l.body).addClass("sp-dragging"),a(t),p(t))})}function Yt(){return jt.fn.spectrum.inputTypeColorSupport()}var i="spectrum.id";jt.fn.spectrum=function(r,t){if("string"==typeof r){var a=this,n=Array.prototype.slice.call(arguments,1);return this.each(function(){var t=It[jt(this).data(i)];if(t){var e=t[r];if(!e)throw new Error("Spectrum: no such method: '"+r+"'");"get"==r?a=t.get():"container"==r?a=t.container:"option"==r?a=t.option.apply(t,n):"destroy"==r?(t.destroy(),jt(this).removeData(i)):e.apply(t,n)}}),a}return this.spectrum("destroy").each(function(){var t=e(this,jt.extend({},r,jt(this).data()));jt(this).data(i,t.id)})},jt.fn.spectrum.load=!0,jt.fn.spectrum.loadOpts={},jt.fn.spectrum.draggable=Xt,jt.fn.spectrum.defaults=Dt,jt.fn.spectrum.inputTypeColorSupport=function t(){if(void 0===t._cachedResult){var e=jt("")[0];t._cachedResult="color"===e.type&&""!==e.value}return t._cachedResult},jt.spectrum={},jt.spectrum.localization={},jt.spectrum.palettes={},jt.fn.spectrum.processNativeColorInputs=function(){var t=jt("input[type=color]");t.length&&!Yt()&&t.spectrum({preferredFormat:"hex6"})},function(){var l=/^[\s,#]+/,c=/\s+$/,a=0,f=Math,i=f.round,u=f.min,h=f.max,t=f.random,d=function(t,e){if(e=e||{},(t=t||"")instanceof d)return t;if(!(this instanceof d))return new d(t,e);var r=function(t){var e={r:0,g:0,b:0},r=1,a=!1,n=!1;"string"==typeof t&&(t=function(t){t=t.replace(l,"").replace(c,"").toLowerCase();var e,r=!1;if(P[t])t=P[t],r=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};if(e=E.rgb.exec(t))return{r:e[1],g:e[2],b:e[3]};if(e=E.rgba.exec(t))return{r:e[1],g:e[2],b:e[3],a:e[4]};if(e=E.hsl.exec(t))return{h:e[1],s:e[2],l:e[3]};if(e=E.hsla.exec(t))return{h:e[1],s:e[2],l:e[3],a:e[4]};if(e=E.hsv.exec(t))return{h:e[1],s:e[2],v:e[3]};if(e=E.hsva.exec(t))return{h:e[1],s:e[2],v:e[3],a:e[4]};if(e=E.hex8.exec(t))return{a:(a=e[1],F(a)/255),r:F(e[2]),g:F(e[3]),b:F(e[4]),format:r?"name":"hex8"};var a;if(e=E.hex6.exec(t))return{r:F(e[1]),g:F(e[2]),b:F(e[3]),format:r?"name":"hex"};if(e=E.hex3.exec(t))return{r:F(e[1]+""+e[1]),g:F(e[2]+""+e[2]),b:F(e[3]+""+e[3]),format:r?"name":"hex"};return!1}(t));"object"==typeof t&&(t.hasOwnProperty("r")&&t.hasOwnProperty("g")&&t.hasOwnProperty("b")?(i=t.r,s=t.g,o=t.b,e={r:255*R(i,255),g:255*R(s,255),b:255*R(o,255)},a=!0,n="%"===String(t.r).substr(-1)?"prgb":"rgb"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("v")?(t.s=O(t.s),t.v=O(t.v),e=function(t,e,r){t=6*R(t,360),e=R(e,100),r=R(r,100);var a=f.floor(t),n=t-a,i=r*(1-e),s=r*(1-n*e),o=r*(1-(1-n)*e),l=a%6;return{r:255*[r,s,i,i,o,r][l],g:255*[o,r,r,s,i,i][l],b:255*[i,i,o,r,r,s][l]}}(t.h,t.s,t.v),a=!0,n="hsv"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("l")&&(t.s=O(t.s),t.l=O(t.l),e=function(t,e,r){var a,n,i;function s(t,e,r){return r<0&&(r+=1),1>1)+720)%360;--e;)a.h=(a.h+n)%360,i.push(d(a));return i}function C(t,e){e=e||6;for(var r=d(t).toHsv(),a=r.h,n=r.s,i=r.v,s=[],o=1/e;e--;)s.push(d({h:a,s:n,v:i})),i=(i+o)%1;return s}d.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},setAlpha:function(t){return this._a=M(t),this._roundA=i(100*this._a)/100,this},toHsv:function(){var t=s(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=s(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),a=i(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+a+"%)":"hsva("+e+", "+r+"%, "+a+"%, "+this._roundA+")"},toHsl:function(){var t=n(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=n(this._r,this._g,this._b),e=i(360*t.h),r=i(100*t.s),a=i(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+a+"%)":"hsla("+e+", "+r+"%, "+a+"%, "+this._roundA+")"},toHex:function(t){return e(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return o(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:i(this._r),g:i(this._g),b:i(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+i(this._r)+", "+i(this._g)+", "+i(this._b)+")":"rgba("+i(this._r)+", "+i(this._g)+", "+i(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:i(100*R(this._r,255))+"%",g:i(100*R(this._g,255))+"%",b:i(100*R(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+i(100*R(this._r,255))+"%, "+i(100*R(this._g,255))+"%, "+i(100*R(this._b,255))+"%)":"rgba("+i(100*R(this._r,255))+"%, "+i(100*R(this._g,255))+"%, "+i(100*R(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&(A[e(this._r,this._g,this._b,!0)]||!1)},toFilter:function(t){var e="#"+o(this._r,this._g,this._b,this._a),r=e,a=this._gradientType?"GradientType = 1, ":"";t&&(r=d(t).toHex8String());return"progid:DXImageTransform.Microsoft.gradient("+a+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,a=this._a<1&&0<=this._a;return e||!a||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(b,arguments)},brighten:function(){return this._applyModification(v,arguments)},darken:function(){return this._applyModification(m,arguments)},desaturate:function(){return this._applyModification(r,arguments)},saturate:function(){return this._applyModification(p,arguments)},greyscale:function(){return this._applyModification(g,arguments)},spin:function(){return this._applyModification(y,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(S,arguments)},complement:function(){return this._applyCombination(w,arguments)},monochromatic:function(){return this._applyCombination(C,arguments)},splitcomplement:function(){return this._applyCombination(k,arguments)},triad:function(){return this._applyCombination(_,arguments)},tetrad:function(){return this._applyCombination(x,arguments)}},d.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var a in t)t.hasOwnProperty(a)&&(r[a]="a"===a?t[a]:O(t[a]));t=r}return d(t,e)},d.equals=function(t,e){return!(!t||!e)&&d(t).toRgbString()==d(e).toRgbString()},d.random=function(){return d.fromRatio({r:t(),g:t(),b:t()})},d.mix=function(t,e,r){r=0===r?0:r||50;var a,n=d(t).toRgb(),i=d(e).toRgb(),s=r/100,o=2*s-1,l=i.a-n.a,c=1-(a=((a=o*l==-1?o:(o+l)/(1+o*l))+1)/2),f={r:i.r*a+n.r*c,g:i.g*a+n.g*c,b:i.b*a+n.b*c,a:i.a*s+n.a*(1-s)};return d(f)},d.readability=function(t,e){var r=d(t),a=d(e),n=r.toRgb(),i=a.toRgb(),s=r.getBrightness(),o=a.getBrightness(),l=Math.max(n.r,i.r)-Math.min(n.r,i.r)+Math.max(n.g,i.g)-Math.min(n.g,i.g)+Math.max(n.b,i.b)-Math.min(n.b,i.b);return{brightness:Math.abs(s-o),color:l}},d.isReadable=function(t,e){var r=d.readability(t,e);return 125