!function(i){function r(i){var r;return(i=i.replace(/ /g,"")).match(/rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/)?(r=100*parseFloat(i.match(/rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/)[1]).toFixed(2),r=parseInt(r)):r=100,r}function a(i,r,a,n){var o,e,c;o=r.data("a8cIris"),e=r.data("wpWpColorPicker"),o._color._alpha=i,c=o._color.toString(),r.val(c),e.toggler.css({"background-color":c}),n&&t(i,a),r.wpColorPicker("color",c)}function t(i,r){r.slider("value",i),r.find(".ui-slider-handle").text(i.toString())}Color.prototype.toString=function(i){if("no-alpha"==i)return this.toCSS("rgba","1").replace(/\s+/g,"");if(1>this._alpha)return this.toCSS("rgba",this._alpha).replace(/\s+/g,"");var r=parseInt(this._color,10).toString(16);if(this.error)return"";if(r.length<6)for(var a=6-r.length-1;a>=0;a--)r="0"+r;return"#"+r},i.fn.alphaColorPicker=function(){return this.each((function(){var n,o,e,c,l,s,d,p,u,f;(n=i(this)).wrap('<div class="alpha-color-picker-wrap"></div>'),e=n.attr("data-palette")||"true",c=n.attr("data-show-opacity")||"true",l=n.attr("data-default-color")||"",s=-1!==e.indexOf("|")?e.split("|"):"false"!=e,""==(o=n.val().replace(/\s+/g,""))&&(o=l),d={change:function(i,a){var t,o,e;t=n.attr("data-customize-setting-link"),o=n.wpColorPicker("color"),l==o&&(e=r(o),u.find(".ui-slider-handle").text(e)),void 0!==wp.customize&&wp.customize(t,(function(i){i.set(o)})),p.find(".transparency").css("background-color",a.color.toString("no-alpha")),n.trigger("colorChange")},palettes:s},n.wpColorPicker(d),p=n.parents(".wp-picker-container:first"),i('<div class="alpha-color-picker-container"><div class="min-click-zone click-zone"></div><div class="max-click-zone click-zone"></div><div class="alpha-slider"></div><div class="transparency"></div></div>').appendTo(p.find(".wp-picker-holder")),u=p.find(".alpha-slider"),f={create:function(r,a){var t=i(this).slider("value");i(this).find(".ui-slider-handle").text(t),i(this).siblings(".transparency ").css("background-color",o)},value:r(o),range:"max",step:1,min:0,max:100,animate:300},u.slider(f),"true"==c&&u.find(".ui-slider-handle").addClass("show-opacity"),p.find(".min-click-zone").on("click",(function(){a(0,n,u,!0)})),p.find(".max-click-zone").on("click",(function(){a(100,n,u,!0)})),p.find(".iris-palette").on("click",(function(){var a,o;t(o=r(a=i(this).css("background-color")),u),100!=o&&(a=a.replace(/[^,]+(?=\))/,(o/100).toFixed(2))),n.wpColorPicker("color",a)})),p.find(".button.wp-picker-default").on("click",(function(){t(r(l),u)})),n.on("input",(function(){t(r(i(this).val()),u)})),u.slider().on("slide",(function(r,t){a(parseFloat(t.value)/100,n,u,!1),i(this).find(".ui-slider-handle").text(t.value)}))}))}}(jQuery);