@ew-color-picker/ew-color-picker 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.min.js +1 -1
  2. package/package.json +14 -14
package/dist/index.min.js CHANGED
@@ -1 +1 @@
1
- ((t,o)=>{"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((t="undefined"!=typeof globalThis?globalThis:t||self).ewColorPicker={})})(this,function(_){var z=function(t,o){return(z=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,o){t.__proto__=o}:function(t,o){for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&(t[e]=o[e])}))(t,o)};function j(t,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function e(){this.constructor=t}z(t,o),t.prototype=null===o?Object.create(o):(e.prototype=o.prototype,new e)}var n=function(){return(n=Object.assign||function(t){for(var o,e=1,i=arguments.length;e<i;e++)for(var n in o=arguments[e])Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n]);return t}).apply(this,arguments)};function F(t,o){var e={};for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&o.indexOf(n)<0&&(e[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)o.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(e[n[i]]=t[n[i]]);return e}function W(t,o,e){if(e||2===arguments.length)for(var i,n=0,r=o.length;n<r;n++)!i&&n in o||((i=i||Array.prototype.slice.call(o,0,n))[n]=o[n]);return t.concat(i||Array.prototype.slice.call(o))}function V(){}var L={log:V,warn:V,error:V},h=(["warn","error","log"].forEach(function(t){L[t]=function(){}}),L.warn),U=L.error,$=L.log,R="undefined"!=typeof window,t=R&&navigator.userAgent.toLowerCase(),q=(t&&t.match(/(iPhone|iPod|Android|ios)/i),!1);if(R)try{var G={};Object.defineProperty(G,"passive",{get:function(){q=!0}}),window.addEventListener("test-passive",function(){},G)}catch(U){}function X(t){return void 0===t}function Y(t){return"string"==typeof t}function K(t){return"object"===et.call(t).slice(8,-1).toLowerCase()}function Q(t,o){try{t()}catch(t){C(o)?o(t):U("[ewColorPicker error]: ".concat(t))}}function i(t){for(var o=[],e=1;e<arguments.length;e++)o[e-1]=arguments[e];if(nt(t))return{};if(Object.assign)return Object.assign.apply(Object,W([t],o,!1));for(var i=Object(t),n=0,r=o.length;n<r;n++){var s=o[n];if(s)for(var a in s)it.call(s,a)&&(i[a]=s[a])}return i}function l(t){return document.createElement(t)}function s(t,o){return new RegExp("(^|\\s)"+o+"(\\s|$)").test(t.className)}function c(t,o){for(var e=0,i=o.trim().split(/\s+/);e<i.length;e++){var n,r=i[e];r&&!s(t,r)&&((n=t.className.split(" ").filter(Boolean)).push(r),t.className=n.join(" "))}}function a(t,o){s(t,o)&&(o=new RegExp("(^|\\s)"+o+"(\\s|$)","g"),t.className=t.className.replace(o," "))}function Z(t){return t instanceof HTMLElement}function J(t,o,e){o=o.startsWith("--")?o:o.replace(/([A-Z])/g,"-$1").toLowerCase(),t.style.setProperty(o,e)}function u(e,t,o){if(Y(t=void 0===t?{}:t)&&!X(o)){o=rt(o)?"".concat(o,"px"):o;J(e,t,o)}else if(Array.isArray(t))t.forEach(function(t){var o=t.prop;J(e,o,t.value)});else for(var i=0,n=Object.entries(t);i<n.length;i++){var r=n[i],s=r[0];J(e,s,r[1])}}function tt(t,o){for(var e=0,i=o=void 0===o?[]:o;e<i.length;e++){var n=i[e];t.style.removeProperty(n)}}function p(o,e,i){var n;return o&&e?("float"===(e=e.replace(/([\:\_\-]+(.))/g,function(t,o,e,i){return i?e.toUpperCase():e}).replace(/^moz([A-Z])/,"Moz$1"))&&(e="cssFloat"),n=null,Q(function(){var t=(document.defaultView||window).getComputedStyle(o,i);n=o.style[e]||t?t[e]:null}),n||o.style[e]):null}function d(t,o){if(st(o))for(var e=0,i=Object.entries(o);e<i.length;e++){var n=i[e],r=n[0];t.setAttribute(r,"".concat(n[1]))}}function f(t,o){return(o=void 0===o?document:o).querySelector(t)}function r(t){var o;null!=t&&t.parentElement?null!=(o=null==t?void 0:t.parentElement)&&o.removeChild(t):null!=t&&t.remove()}function g(t,o,e,i){i&&null!=t&&t.contains(i)?t.insertBefore(o,i):e&&null!=t&&t.contains(e)?t.replaceChild(o,e):null!=t&&t.appendChild(o)}function ot(t){return Y(t)?f(t)||(h("[ewColorPicker warning]: Cannot find element with selector: ".concat(t)),document.body):Z(t)?t:document.body}var et=Object.prototype.toString,it=Object.prototype.hasOwnProperty,nt=function(t){return null===t},rt=function(t){return"number"==typeof t},C=function(t){return"function"==typeof t},st=function(t){return"object"==typeof t&&!nt(t)},at=function(t){return t.replace(/\s+/g,"")},lt=function(t){return t?" ".concat(t):""};function ht(t){return{clientWidth:t.clientWidth,clientHeight:t.clientHeight,offsetWidth:t.offsetWidth,offsetHeight:t.offsetHeight,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight}}function b(t){return t.getBoundingClientRect()}function v(t,o,e,i){i=q?{passive:!1,capture:!!i}:!!i,t.addEventListener(o,e,i)}function P(t,o,e,i){t.removeEventListener(o,e,{capture:!!i})}(t=Lt=Lt||{}).Pre="pre",t.Post="post",o.prototype.on=function(t,o,e){return void 0===e&&(e=this),this.hasType(t),this.events[t]||(this.events[t]=[]),this.events[t].push([o,e]),this},o.prototype.once=function(i,n,r){var s=this,a=(void 0===r&&(r=this),this.hasType(i),function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];s.off(i,a);var e=n.apply(r,t);if(!0===e)return e});return a.fn=n,this.on(i,a),this},o.prototype.off=function(t,o){if(!t&&!o)return this.events={},this;if(t){if(this.hasType(t),o){var e=this.events[t];if(e)for(var i=e.length;i--;)(e[i][0]===o||e[i][0]&&e[i][0].fn===o)&&e.splice(i,1)}else this.events[t]=[];return this}},o.prototype.trigger=function(t){for(var o=[],e=1;e<arguments.length;e++)o[e-1]=arguments[e];this.hasType(t);t=this.events[t];if(t)for(var i=t.length,n=W([],t,!0),r=0;r<i;r++){var s=n[r],a=s[0],s=s[1];if(a&&!0===(a=a.apply(s,o)))return a}},o.prototype.registerType=function(t){var o=this;t.forEach(function(t){o.eventTypes[t]=t})},o.prototype.destroy=function(){this.events={},this.eventTypes={}},o.prototype.hasType=function(t){var o=this.eventTypes;o[t]!==t&&h('[ewColorPicker warning]: EventEmitter has used unknown event type: "'.concat(t,'", should be oneof [')+"".concat(Object.keys(o).map(function(t){return JSON.stringify(t)}))+"]")};R=o;function o(t){this.events={},this.eventTypes={},this.registerType(t)}var ct=/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/,ut=/[rR][gG][Bb][Aa]?[\(]([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?),){2}[\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?),?[\s]*(0\.\d{1,2}|1|0)?[\)]{1}/g,pt=/^[rR][gG][Bb][Aa][\(]([\\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\\s]*,){3}[\\s]*(1|1.0|0|0?.[0-9]{1,2})[\\s]*[\)]{1}$/,dt=/^[hH][Ss][Ll][\(]([\\s]*(2[0-9][0-9]|360|3[0-5][0-9]|[01]?[0-9][0-9]?)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*)[\)]$/,ft=/^[hH][Ss][Ll][Aa][\(]([\\s]*(2[0-9][0-9]|360|3[0-5][0-9]|[01]?[0-9][0-9]?)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*,){2}([\\s]*(1|1.0|0|0?.[0-9]{1,2})[\\s]*)[\)]$/;function gt(t){var o,e,i={10:"A",11:"B",12:"C",13:"D",14:"E",15:"F"};return/rgba?/.test(t)?(o=t.replace(/rgba?\(/,"").replace(/\)/,"").replace(/[\s+]/g,"").split(","),e="",o.map(function(t,o){o<=2&&(e+=(o=+t,o=Math.min(Math.round(o),255),t=Math.floor(o/16),""+(i[t]||t)+(i[o%=16]||o)))}),at("#"+e)):t}function Ct(t){var o,e,i,n,r=t.a,s=t.h,a=255*t.s/100,t=255*t.v/100;return 0==a?o=e=i=t:(t=s%60*((n=t)-(a=(255-a)*t/255))/60,360===s?(o=n,e=i=0):s<60?(o=n,e=a+t,i=a):s<120?(o=n-t,e=n,i=a):s<180?(e=n,i=(o=a)+t):s<240?(o=a,e=n-t,i=n):s<300?(o=a+t,e=a,i=n):s<360?(e=a,i=(o=n)-t):o=e=i=0),r=Math.round(10*r)/10,"rgba(".concat(Math.round(o),", ").concat(Math.round(e),", ").concat(Math.round(i),", ").concat(r,")")}function w(t){var o,e,i,n,r,s,a,l;return t&&"string"==typeof t&&(t=t.replace(/\s+/g," ").trim().match(/rgba?\(([^)]+)\)/i))?(t=t[1].split(",").map(function(t){return t.trim()}),o=parseFloat(t[0])||0,e=parseFloat(t[1])||0,i=parseFloat(t[2])||0,t=4<=t.length&&parseFloat(t[3])||1,o=o/255,e=e/255,i=i/255,n=(l=Math.max(o,e,i))-Math.min(o,e,i),(s=r=0)!==(a=l)&&(s=n/l),0!=n?(l===o?r=(e-i)/n*60:l===e?r=60*((i-o)/n+2):l===i&&(r=60*((o-e)/n+4)),r<0&&(r+=360)):r=0,l=Math.round(10*t)/10,{h:Math.round(r),s:Math.round(100*s),v:Math.round(100*a),a:l}):{h:0,s:100,v:100,a:1}}var bt={black:"rgba(0, 0, 0, 1)",silver:"rgba(192, 192, 192, 1)",gray:"rgba(128, 128, 128, 1)",white:"rgba(255, 255, 255, 1)",maroon:"rgba(128, 0, 0, 1)",red:"rgba(255, 0, 0, 1)",purple:"rgba(128, 0, 128, 1)",fuchsia:"rgba(255, 0, 255, 1)",green:"rgba(0, 128, 0, 1)",lime:"rgba(0, 255, 0, 1)",olive:"rgba(128, 128, 0, 1)",yellow:"rgba(255, 255, 0, 1)",navy:"rgba(0, 0, 128, 1)",blue:"rgba(0, 0, 255, 1)",teal:"rgba(0, 128, 128, 1)",aqua:"rgba(0, 255, 255, 1)",orange:"rgba(255, 165, 0, 1)",pink:"rgba(255, 192, 203, 1)",brown:"rgba(165, 42, 42, 1)"};function m(t){if(t&&"string"==typeof t){var o=t.trim().toLowerCase();if(bt[o])return bt[o];if(ct.test(o))return((t,o)=>{var o=(o=void 0===o?1:o)||1,o=Math.round(10*o)/10,e=t.toLowerCase(),i=t.length,n=[];if(t&&ct.test(e)){if(4===i){for(var r="#",s=1;s<i;s++){var a=e.slice(s,s+1);r+=a.concat(a)}e=r}for(var l=1,h=e.length;l<h;l+=2)n.push(parseInt("0X"+e.slice(l,l+2),16));return"rgba(".concat(n.join(", "),", ").concat(o,")")}return at(e)})(o).replace(/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*\)/,"rgba($1, $2, $3, $4)");var e=o.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i);if(e)return i=e[1],n=e[2],r=e[3],"rgba(".concat(i,", ").concat(n,", ").concat(r,", 1)");var i,n,r,e=o.match(/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(0|1|0?\.\d+)\s*\)$/i);if(e)return i=e[1],n=e[2],r=e[3],o=e[4],"rgba(".concat(i,", ").concat(n,", ").concat(r,", ").concat(o,")");try{var s=l("div"),a=(u(s,{"background-color":t}),p(s,"backgroundColor"));if(a&&"rgba(0, 0, 0, 0)"!==a)return a.replace(/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*\)/,"rgba($1, $2, $3, $4)")}catch(t){}}return""}function vt(t){var o="transparent"===t;if(ct.test(t))return 1;if(ut.test(t)&&!t.includes("rgba"))return 1;if(pt.test(t))return 1;if(dt.test(t)&&!t.includes("hsla"))return 1;if(ft.test(t))return 1;if(o)return 1;if("#invalid"!==t&&"invalid"!==t&&(!t.includes("rgb(")||!t.includes(", 0.5)"))&&(!t.includes("rgba(")||t.includes(", 0.5)")||t.includes(", 1)")))try{var e=document.createElement("div");return u(e,{"background-color":t}),"rgba(0, 0, 0, 0)"!==p(e,"backgroundColor")||o}catch(t){}}function Pt(t){function o(t){return Math.round(t).toString(16).padStart(2,"0")}return"#".concat(o(t.r)).concat(o(t.g)).concat(o(t.b))}function wt(t){try{var o=t.slice(t.indexOf("(")+1,t.lastIndexOf(")")).split(",");return o.length<3?null:{r:parseInt(o[0]),g:parseInt(o[1]),b:parseInt(o[2]),a:o.length<4?1:parseFloat(o[3])}}catch(t){return null}}kt.prototype.show=function(){var o=this;return new Promise(function(t){u(o.element,{display:"block"}),t()})},kt.prototype.hide=function(){var o=this;return new Promise(function(t){u(o.element,{display:"none"}),t()})},kt.prototype.slideDown=function(){var n=this;return new Promise(function(t){u(n.element,{display:"block",visibility:"hidden"});var o=p(n.element,"marginTop"),e=p(n.element,"marginBottom"),i=n.element.offsetHeight+parseInt(o)+parseInt(e);u(n.element,{height:"0px",overflow:"hidden",visibility:"visible"}),n.element.offsetHeight,setTimeout(function(){u(n.element,{transition:"height ".concat(n.options.duration,"ms ").concat(n.options.easing),height:"".concat(i,"px")}),setTimeout(function(){u(n.element,{height:"",overflow:"",transition:""}),t()},n.options.duration)},n.options.delay)})},kt.prototype.slideUp=function(){var i=this;return new Promise(function(t){var o=p(i.element,"marginTop"),e=p(i.element,"marginBottom"),o=i.element.offsetHeight+parseInt(o)+parseInt(e);u(i.element,{height:"".concat(o,"px"),overflow:"hidden"}),i.element.offsetHeight,setTimeout(function(){u(i.element,{height:"0px",transition:"height ".concat(i.options.duration,"ms ").concat(i.options.easing)}),setTimeout(function(){u(i.element,{height:"",overflow:"",transition:"",display:"none"}),t()},i.options.duration)},i.options.delay)})},kt.prototype.fadeIn=function(){var t=this;return new Promise(function(e){function i(t){var t=Math.min((t-s)/r,1),o=1-Math.pow(1-t,3);u(n,{opacity:o.toString()}),t<1?requestAnimationFrame(i):(u(n,{opacity:"1"}),e())}var n=t.element,r=t.options.duration,s=(u(n,{display:"block",opacity:"0"}),n.offsetHeight,performance.now());requestAnimationFrame(i)})},kt.prototype.fadeOut=function(){var t=this;return new Promise(function(e){function i(t){var t=Math.min((t-s)/r,1),o=Math.pow(t,3);u(n,{opacity:(1-o).toString()}),t<1?requestAnimationFrame(i):(u(n,{display:"none",opacity:"0"}),e())}var n=t.element,r=t.options.duration,s=(u(n,{display:"block",opacity:"1"}),n.offsetHeight,performance.now());requestAnimationFrame(i)})};var mt=kt;function kt(t,o){void 0===o&&(o={}),this.element=t,this.options=n({duration:300,easing:"ease-out",delay:0},o)}var yt={show:function(t,o){return new mt(t,{duration:o=void 0===o?300:o}).show()},hide:function(t,o){return new mt(t,{duration:o=void 0===o?300:o}).hide()},slideDown:function(t,o){return new mt(t,{duration:o=void 0===o?300:o}).slideDown()},slideUp:function(t,o){return new mt(t,{duration:o=void 0===o?300:o}).slideUp()},fadeIn:function(t,o){return new mt(t,{duration:o=void 0===o?300:o}).fadeIn()},fadeOut:function(t,o){return new mt(t,{duration:o=void 0===o?300:o}).fadeOut()}};function xt(t){return(null==(t=t.options)?void 0:t.togglePickerAnimation)||"default"}function e(i,n,r){void 0===r&&(r=!1);var s=null;return function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];var e=r&&!s;s&&clearTimeout(s),s=setTimeout(function(){s=null,r||i.apply(void 0,t)},n),e&&i.apply(void 0,t)}}function Bt(e,i){var n;return function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];n||(e.apply(void 0,t),n=!0,setTimeout(function(){return n=!1},i))}}function k(t){return"string"==typeof(t=null==(t=null==t?void 0:t.options)?void 0:t.prefix)?t:y}function Mt(t,o,e){return void 0===e&&(e=y),o=o&&0<o?' width="'.concat(o,'" height="').concat(o,'"'):"",'<svg t="1717384498631" class="'.concat(e,"color-picker-icon").concat(lt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4235"').concat(o,'><path d="M512 309.333333c8.533333 0 17.066667 2.133333 23.466667 8.533334l341.333333 341.333333c12.8 12.8 12.8 32 0 44.8-12.8 12.8-32 12.8-44.8 0L533.333333 374.4 215.466667 692.266667c-12.8 12.8-32 12.8-44.8 0-12.8-12.8-12.8-32 0-44.8L488.533333 317.866667c4.266667-8.533333 12.8-10.666667 21.333334-10.666667z" fill="#666666" p-id="4236"></path></svg>')}function Ht(t,o,e){return void 0===e&&(e=y),o=o&&0<o?' width="'.concat(o,'" height="').concat(o,'"'):"",'<svg t="1717384498632" class="'.concat(e,"color-picker-icon").concat(lt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4236"').concat(o,'><path d="M512 714.666667c-8.533333 0-17.066667-2.133333-23.466667-8.533334l-341.333333-341.333333c-12.8-12.8-12.8-32 0-44.8 12.8-12.8 32-12.8 44.8 0l320 317.866667 317.866667-320c12.8-12.8 32-12.8 44.8 0 12.8 12.8 12.8 32 0 44.8L533.333333 704c-4.266667 8.533333-12.8 10.666667-21.333333 10.666667z" fill="#666666" p-id="4237"></path></svg>')}var y="ew-",Ot=["%c ew-color-picker@2.0.1%c 联系QQ:854806732 %c 联系微信:eveningwater %c github:https://github.com/eveningwater/ew-color-picker %c ","background:#0ca6dc ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#ff7878 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:#ff7878 ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#ff7878 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent"],Tt=!1,G=(At.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=i(this.options,this.ewColorPicker.options))},At.prototype.run=function(){Tt||(Tt=!0,$.apply(void 0,Ot))},At.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),t.on&&C(t.on)&&t.on("change",function(t){}),null!=(t=this.run)&&t.call(this)},At.pluginName="ewColorPickerConsole",At);function At(t){this.ewColorPicker=t,this.options={},this.handleOptions(),this.run()}var Dt,It={disabled:!1,predefineColor:[],size:"normal",defaultColor:"",isClickOutside:!0,hueDirection:"vertical",alphaDirection:"vertical",clearText:"清空",sureText:"确定",togglePickerAnimation:"default",pickerAnimationTime:200,autoPanelPosition:!1,panelPlacement:"bottom",prefix:y,sure:function(){},clear:function(){},togglePicker:function(){},changeColor:function(){}},Et=(j(St,Dt=function(){}),St.prototype.merge=function(t,o){var t=t||{},e=t.el,t=F(t,["el"]);return i({},It,null!=o?o:{},n(n({},t),{el:ot(e)}))},St.prototype.bindOptions=function(t,o){var e,i=this.merge(t,o=void 0===o?{}:o);for(e in i){var n=i[e];this[e]=n}return this},St);function St(){var t=Dt.call(this)||this;return t.el=document.body,t}(t={})[Lt.Pre]=-1,t[Lt.Post]=1;var Nt,_t=t,zt=["destroy","change","sure","clear","toggle","options-update","mode-change"],x=(j(B,Nt=R),B.use=function(o){var e=o.pluginName;return X(e)||nt(e)?h("[ewColorPicker warning]: Plugin Class must specify plugin's name in static property by 'pluginName' field."):B.plugins.some(function(t){return t.name===e||o===t.ctor})||(B.pluginsMap[e]=!0,B.plugins.push({name:e,applyOrder:o.applyOrder,ctor:o})),B},B.prototype.normalizeOptions=function(t,o){var e,i;return Z(t)||Y(t)?(e=o?(o.el,o=F(o,["el"]),n({el:t},o)):{el:t},this.shouldAutoMount=!0):K(e=t)&&e.el&&(this.shouldAutoMount=!0),(new Et).bindOptions(e,(i={},x.plugins.forEach(function(t){i[t.name]=!0}),i))},B.prototype.init=function(){var t=this;Q(function(){t.plugins={},t._color_picker_uid=t.generateUID(),t.initCoreProperties()})},B.prototype.initCoreProperties=function(){var t,o,e=this.options,i=e.defaultColor,n=e.alphaDirection,e=e.hueDirection;i?(t=i,(null==(o=this.plugins)?void 0:o.ewColorPickerAlpha)?i.startsWith("#")&&(t=m(i)):i.startsWith("rgba")&&(t=gt(i)),o=w(m(this.currentColor=t)||"rgba(255, 0, 0, 1)"),isNaN(o.h)?this.hsvaColor={h:0,s:100,v:100,a:1}:this.hsvaColor=o):(this.currentColor="",this.hsvaColor={h:0,s:0,v:0,a:0}),this.panelWidth=0,this.panelHeight=0,this.panelLeft=0,this.panelTop=0,this.isHueHorizontal="horizontal"===e,this.isAlphaHorizontal="horizontal"===n,this.colorMode=["Hex","RGB","HSV"],this.currentMode="Hex",this.pickerFlag=!1},B.prototype.createMountPoints=function(){var t=this.options.prefix||y,o=l("div"),e=(d(o,{class:"".concat(t,"color-picker"),"data-uid":this._color_picker_uid}),g(this.getContainer(),o),this.wrapper=o,this.wrapper.isEwColorPickerContainer=!0,l("div"));d(e,{class:"".concat(t,"color-picker-panel-container")}),c(e,"".concat(t,"color-picker-panel-container-hidden")),g(o,e),this.mountPoints.set("root",o),this.mountPoints.set("panelContainer",e)},B.prototype.getMountPoint=function(t){if(!this.isDestroyed)return this.mountPoints.get(t)},B.prototype.getContainer=function(){return this.options.el},B.prototype.mount=function(t){return this.isDestroyed||(t=t?ot(t):this.options.el||document.body,this.options.el=t,this.createMountPoints(),this.applyPlugins(),this.notifyHuePluginUpdate(this.hsvaColor.h)),this},B.prototype.reapplyPlugins=function(){Object.values(this.plugins).forEach(function(t){C(t.run)&&t.run()})},B.prototype.showPanel=function(t,o){var e,i,n,r,s=this;this.isDestroyed||(e=this.mountPoints.get("panelContainer"))&&(i=(r=this.options||{}).pickerAnimationTime,n=r.togglePicker,this.currentColor||(r=w(m(this.currentColor=r.defaultColor||"#ff0000")||"rgba(255, 0, 0, 1)"),this.hsvaColor=r,isNaN(r.h))||this.notifyHuePluginUpdate(r.h),((t,o,e)=>{e=1e4<(e=void 0===e?300:e)?1e4:e;var i="";switch(t){case"height":i="slideDown";break;case"opacity":i="fadeIn";break;default:i="show"}return yt[i](o,e)})(t||xt(this),e,o||i||200).then(function(){s.pickerFlag=!0,s.trigger("toggle",!0),C(n)&&n(!0),s.syncAllPlugins(s.currentColor),setTimeout(function(){var t=s.plugins.ewColorPickerPanel;t&&C(t.handleAutoPosition)&&t.handleAutoPosition.call(t),v(document,"mousedown",s._onDocumentClick,{capture:!0})},0)}).catch(function(t){h("[ewColorPicker error]: Failed to show panel: ".concat(t))}))},B.prototype.hidePanel=function(t,o){var e,i,n,r,s,a,l=this;this.isDestroyed||(e=this.mountPoints.get("panelContainer"))&&(n=(i=this.options||{}).pickerAnimationTime,r=i.togglePicker,s=i.autoPanelPosition,a=this.plugins.ewColorPickerBox||!1,((t,o,e)=>{e=1e4<(e=void 0===e?300:e)?1e4:e;var i="";switch(t){case"height":i="slideUp";break;case"opacity":i="fadeOut";break;default:i="hide"}return yt[i](o,e)})(t||xt(this),e,o||n||200).then(function(){l.isDestroyed||(s&&a&&!l.options.appendTo&&u(e,{position:"absolute",left:"0",top:"100%",visibility:"visible"}),l.pickerFlag=!1,l.trigger("toggle",!1),C(r)&&r(!1),P(document,"mousedown",l._onDocumentClick,{capture:!0}))}).catch(function(t){h("[ewColorPicker error]: Failed to hide panel: ".concat(t))}))},B.prototype.generateUID=function(){return"ew-color-picker-".concat(Date.now(),"-").concat(Math.random().toString(36).substring(2,11))},B.prototype.applyPlugins=function(){var i=this,t=W([],B.plugins,!0).sort(function(t,o){var e,i,n=t.applyOrder?_t[t.applyOrder]:0,r=o.applyOrder?_t[o.applyOrder]:0;return n!==r?n-r:(e={},i=0,x.plugins.forEach(function(t){e[t.name]=i++}),((n=e)[t.name]||999)-(n[o.name]||999))});this.checkPluginDependencies(),t.forEach(function(t){var o=t.ctor,e=t.name;Q(function(){C(o)&&(i.plugins[e]=new o(i))},function(t){console.warn("[ewColorPicker warning]: Failed to apply plugin '".concat(e,"': ").concat(t))})})},B.prototype.checkPluginDependencies=function(){var e=this;Object.entries({hue:["ewColorPickerHue"],alpha:["ewColorPickerAlpha"],panel:["ewColorPickerPanel"],input:["ewColorPickerInput"],inputNumber:["ewColorPickerInputNumber"],button:["ewColorPickerButton"],predefine:["ewColorPickerPredefine"],colorMode:["ewColorPickerColorMode"],box:["ewColorPickerBox"],console:["ewColorPickerConsole"]}).forEach(function(t){var o=t[0],t=t[1];e.options[o]&&t.forEach(function(t){B.pluginsMap[t]||h("[ewColorPicker warning]: Plugin '".concat(t,"' is required but not injected. Please use ewColorPicker.use(").concat(t,") to register the plugin."))})}),this.checkSpecificFeatureDependencies()},B.prototype.checkSpecificFeatureDependencies=function(){this.options.hueDirection&&!B.pluginsMap.ewColorPickerHue&&h("[ewColorPicker warning]: hueDirection is configured but ewColorPickerHue plugin is not injected. Please use ewColorPicker.use(HuePlugin) to register the plugin."),this.options.alphaDirection&&!B.pluginsMap.ewColorPickerAlpha&&h("[ewColorPicker warning]: alphaDirection is configured but ewColorPickerAlpha plugin is not injected. Please use ewColorPicker.use(AlphaPlugin) to register the plugin."),this.options.predefineColor&&0<this.options.predefineColor.length&&!B.pluginsMap.ewColorPickerPredefine&&h("[ewColorPicker warning]: predefineColor is configured but ewColorPickerPredefine plugin is not injected. Please use ewColorPicker.use(PredefinePlugin) to register the plugin."),B.pluginsMap.ewColorPickerColorMode&&!B.pluginsMap.ewColorPickerInputNumber&&h("[ewColorPicker warning]: Color mode plugin requires InputNumber plugin. color-mode plugin requires InputNumber plugin. Please use ewColorPicker.use(InputNumberPlugin) to register the plugin."),B.pluginsMap.ewColorPickerPanel||h("[ewColorPicker warning]: Panel plugin is required as core plugin but not injected. Please use ewColorPicker.use(PanelPlugin) to register the plugin.")},B.prototype.syncAllPlugins=function(o){Object.values(this.plugins).forEach(function(t){C(t.syncColor)&&t.syncColor(o)})},B.prototype.updateOptions=function(t){this.isDestroyed||(this.options=i({},this.options,t),t=(this.options||{}).defaultColor,X(t)||(m(t)?this.setColor(t):h("[ewColorPicker warning]: Invalid defaultColor '".concat(t,"', keep current color unchanged."))),this.reapplyPlugins(),this.trigger("options-update",this.options))},B.prototype.openPicker=function(){this.showPanel()},B.prototype.closePicker=function(){this.hidePanel()},B.prototype.destroy=function(){var t=this;this.isDestroyed||(this.isDestroyed=!0,P(document,"mousedown",this._onDocumentClick,{capture:!0}),this.plugins&&Object.values(this.plugins).forEach(function(t){Q(function(){C(null==t?void 0:t.destroy)&&t.destroy()})}),this.mountPoints.forEach(function(t){Q(function(){r(t)})}),this.mountPoints.clear(),Q(function(){r(t.wrapper)}),this.plugins={},this.trigger("destroy"))},B.prototype.setColor=function(t){var o;(this.currentColor=t)&&(o=m(t),this.hsvaColor=o?w(o):{h:0,s:100,v:100,a:1}),this.trigger("change",t),C(null==(o=this.options)?void 0:o.changeColor)&&this.options.changeColor(t)},B.prototype.getColor=function(){return this.currentColor},B.prototype.getHsvaColor=function(){return n({},this.hsvaColor)},B.prototype.setHsvaColor=function(t){this.hsvaColor=n({},t)},B.prototype.getDestroyedStatus=function(){return this.isDestroyed},B.prototype.use=function(t){return C(t.install)&&t.install(this),this},B.prototype.emit=function(t){for(var o=[],e=1;e<arguments.length;e++)o[e-1]=arguments[e];this.trigger.apply(this,W([t],o,!1));var i=this.options||{},n=i.clear,r=i.sure,s=i.togglePicker;switch(t){case"clear":C(n)&&n();break;case"sure":C(r)&&r();break;case"toggle":C(s)&&s.apply(void 0,o)}},B.prototype.on=function(t,o,e){return Nt.prototype.on.call(this,t,o,e),this},B.prototype.off=function(t,o){return Nt.prototype.off.call(this,t,o),this},B.prototype.getOptions=function(){return this.options},B.prototype.notifyHuePluginUpdate=function(t){var o=null==(o=this.plugins)?void 0:o.ewColorPickerHue;C(null==o?void 0:o.updateHueThumbPosition)&&o.updateHueThumbPosition(t)},B.plugins=[],B.pluginsMap={},B);function B(t,o){var i=Nt.call(this,zt)||this;return i.mountPoints=new Map,i.isDestroyed=!1,i.shouldAutoMount=!1,i._onDocumentClick=function(t){var o,e;i.isDestroyed||!i.options.isClickOutside||(o=i.mountPoints.get("panelContainer"),e=i.mountPoints.get("root"),t=t.target,o&&o.contains(t))||(o=i.options.prefix||y,(e=null==e?void 0:e.querySelector(".".concat(o,"color-picker-box")))&&e.contains(t))||(e=(o=i.options).togglePickerAnimation,i.hidePanel(e,o.pickerAnimationTime))},i.options=i.normalizeOptions(t,o),i.init(),i.shouldAutoMount&&i.options.el&&Q(function(){i.mount(i.options.el)},function(t){h("[ewColorPicker warning]: Auto mount failed: ".concat(t))}),i}function jt(t,o){var e=void 0===(e=o.boxNoColorIcon)?"":e,i=void 0===(i=o.boxHasColorIcon)?"":i,n=void 0===(n=o.prefix)?y:n,o=(t=>{var o,e;if(t){if(st(t))return o=Vt(null!=(o=t.width)?o:32),e=Vt(null!=(e=t.height)?e:32),.5*Math.min(o,e);if(rt(t))return.5*t;if("string"==typeof t)return Wt[t]||16}return 16})(o.size);return t?i||((t,o,e)=>(void 0===e&&(e=y),o=o&&0<o?' width="'.concat(o,'" height="').concat(o,'"'):"",'<svg t="1717384498630" class="'.concat(e,"color-picker-icon").concat(lt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4234"').concat(o,'><path d="M512 714.666667c-8.533333 0-17.066667-2.133333-23.466667-8.533334l-341.333333-341.333333c-12.8-12.8-12.8-32 0-44.8 12.8-12.8 32-12.8 44.8 0l320 317.866667 317.866667-320c12.8-12.8 32-12.8 44.8 0 12.8 12.8 12.8 32 0 44.8L533.333333 704c-4.266667 8.533333-12.8 10.666667-21.333333 10.666667z" fill="currentColor" p-id="4235"></path></svg>')))("".concat(n,"color-picker-box-arrow-icon"),o,n):e||((t,o,e)=>(void 0===e&&(e=y),o=o&&0<o?' width="'.concat(o,'" height="').concat(o,'"'):"",'<svg t="1690189203554" class="'.concat(e,"color-picker-icon").concat(lt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2272" fill="currentColor"').concat(o,'><path d="M504.224 470.288l207.84-207.84a16 16 0 0 1 22.608 0l11.328 11.328a16 16 0 0 1 0 22.624l-207.84 207.824 207.84 207.84a16 16 0 0 1 0 22.608l-11.328 11.328a16 16 0 0 1-22.624 0l-207.824-207.84-207.84 207.84a16 16 0 0 1-22.608 0l-11.328-11.328a16 16 0 0 1 0-22.624l207.84-207.824-207.84-207.84a16 16 0 0 1 0-22.608l11.328-11.328a16 16 0 0 1 22.624 0l207.824 207.84z" p-id="2273"></path></svg>')))("".concat(n,"color-picker-box-close-icon"),o,n)}var Ft={mini:"20px",small:"24px",normal:"32px",medium:"36px",large:"40px"},Wt={mini:12,small:14,normal:16,medium:18,large:20},Vt=function(t){return!rt(t)&&(t=parseInt("".concat(t)),isNaN(t))?32:t},Lt=(Object.defineProperty(M.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"hasBox",{get:function(){return this._hasBox},set:function(t){this._hasBox!==t&&((this._hasBox=t)?this.render():this.box&&this.box.parentNode&&(r(this.box),this.box=null))},enumerable:!1,configurable:!0}),M.prototype.enableBox=function(t){this.hasBox=t=void 0===t?!0:t},M.prototype.handleOptions=function(){this.options=i(this.options,this.ewColorPicker.options)},M.prototype.run=function(){this.render()},M.prototype.updateChildren=function(){var t;this.box&&(t=this.ewColorPicker.currentColor,this.hasColor=!!t,this.box.replaceChildren((t=jt(this.hasColor,this.options),document.createRange().createContextualFragment(t))))},M.prototype.destroy=function(){this.box&&(this.unbindHandler(),r(this.box),this.box=null)},M.prototype.update=function(t){void 0===t&&(t=["defaultColor","size","disabled","readonly","className","style"]),this.box?(t.includes("defaultColor")&&(this.updateChildren(),this.setBoxBgColor(this.ewColorPicker.currentColor)),t.includes("size")&&this.setBoxSize(),(t.includes("disabled")||t.includes("readonly")||t.includes("className")||t.includes("style"))&&this.setBoxState()):this.render()},M.prototype.render=function(){var t,o=this.options,e=o.className,o=o.style;this.hasBox&&((t=this.ewColorPicker.getMountPoint("root"))?(this.box=f(".".concat(this.prefix,"color-picker-box"),t),this.box||(this.box=l("div"),c(this.box,"".concat(this.prefix,"color-picker-box")),e&&c(this.box,e),o&&u(this.box,o),g(t,this.box)),this.updateChildren(),this.setBoxSize(),this.setBoxBgColor(this.ewColorPicker.currentColor),this.setBoxState(),this.bindHandler()):h("[ewColorPicker] Root mount point not found"))},M.prototype.setBoxSize=function(){var t,o;this.box&&(t=this.options.size,t=(t=t)?st(t)?{width:t.width?rt(t.width)?"".concat(t.width,"px"):t.width:void 0,height:o=t.height?rt(t.height)?"".concat(t.height,"px"):t.height:void 0,lineHeight:o}:t?(o=void 0,{width:o=rt(t)?"".concat(t,"px"):"string"==typeof t?Ft[t]||t:"32px",height:o,lineHeight:o}):{}:{},0<Object.keys(t).length?u(this.box,t):tt(this.box,["width","height"]))},M.prototype.setBoxBgColor=function(t){var o,e;this.box&&(t&&""!==t.trim()?(o=(o=(o=t)&&m(o))&&(e=wt(o))?.5<.2126*(o=function(t){t=(t*e.a+255*(1-e.a))/255;return t<=.03928?t/12.92:Math.pow((.055+t)/1.055,2.4)})(e.r)+.7152*o(e.g)+.0722*o(e.b)?"#333333":"#ffffff":null,u(this.box,n({backgroundColor:t,transition:"background-color 0.3s"},o?{color:o}:{}))):this.clearBoxBgColor())},M.prototype.clearBoxBgColor=function(){this.box&&tt(this.box,["background-color","transition","color"])},M.prototype.setBoxState=function(){var t,o,e;this.box&&(t=(e=this.options).disabled,o=e.readonly,e=e.className,(t?c:a)(this.box,"is-disabled"),(o?c:a)(this.box,"is-readonly"),e)&&c(this.box,e)},M.prototype.bindHandler=function(){var t,o,e,i,n,r,s,a,l,h=this;this.box&&(t=this.options,o=t.onClick,e=t.onMouseEnter,i=t.onMouseLeave,n=t.disabled,r=t.readonly,s=t.togglePickerAnimation,a=t.pickerAnimationTime,v(this.box,"click",l=function(t){n||r?(t.preventDefault(),t.stopPropagation()):(h.ewColorPicker.pickerFlag?h.ewColorPicker.hidePanel(s,a):h.ewColorPicker.showPanel(s,a),null!=o&&o(h))}),this._handlers.push(function(){return P(h.box,"click",l)}),this.bindMouseEvents(e,i))},M.prototype.setDisabled=function(t){this.box&&(t?c:a)(this.box,"is-disabled")},M.prototype.bindMouseEvents=function(t,o){var e,i,n=this;this.box&&(t&&(v(this.box,"mouseenter",e=function(){return t(n)}),this._handlers.push(function(){return P(n.box,"mouseenter",e)})),o)&&(v(this.box,"mouseleave",i=function(){return o(n)}),this._handlers.push(function(){return P(n.box,"mouseleave",i)}))},M.prototype.unbindHandler=function(){this._handlers.forEach(function(t){return t()}),this._handlers=[]},M.pluginName="ewColorPickerBox",M);function M(t){var o=this;this.ewColorPicker=t,this.options={},this._handlers=[],this._hasBox=!0,this.box=null,this.hasColor=!1,this.handleOptions(),!1===this.options.hasBox&&(this._hasBox=!1),this.ewColorPicker.on&&"function"==typeof this.ewColorPicker.on&&this.ewColorPicker.on("change",function(t){o.setBoxBgColor(t)}),this.run()}Object.defineProperty(H.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),H.prototype.handleOptions=function(){var t;K(null==(t=this.ewColorPicker)?void 0:t.options)&&(this.options=i(this.options,this.ewColorPicker.options),this.isHueHorizontal="horizontal"===this.options.hueDirection,this.isAlphaHorizontal="horizontal"===this.options.alphaDirection)},H.prototype.run=function(){var t=this;!1!==this.options.ewColorPickerPanel&&!1!==this.options.hasPanel&&(this.render(),this.movePanelContainer(),setTimeout(function(){t.bindEvents()},10))},H.prototype.render=function(){var t,o,e,i=this;this.ewColorPicker&&(o=this.ewColorPicker.getMountPoint("panelContainer"))&&(t=f(".".concat(this.prefix,"color-picker-panel"),o),e=285,this.isAlphaHorizontal&&this.isHueHorizontal?e=320:(this.isAlphaHorizontal&&!this.isHueHorizontal||!this.isAlphaHorizontal&&this.isHueHorizontal)&&(e=302),this.panel=l("div"),c(this.panel,"".concat(this.prefix,"color-picker-panel")),c(this.panel,"".concat(this.prefix,"color-picker-panel-dynamic-size")),this.panelWidth=e,this.panelHeight=180,u(this.panel,{"--panel-width":e+"px","--panel-height":this.panelHeight+"px"}),g(o,this.panel,t),this.whitePanel=l("div"),c(this.whitePanel,"".concat(this.prefix,"color-picker-white-panel")),g(this.panel,this.whitePanel),this.blackPanel=l("div"),c(this.blackPanel,"".concat(this.prefix,"color-picker-black-panel")),g(this.panel,this.blackPanel),this.cursor=l("div"),c(this.cursor,"".concat(this.prefix,"color-picker-panel-cursor")),g(this.panel,this.cursor),e=l("div"),c(e,"".concat(this.prefix,"color-picker-bottom-row")),g(o,e),setTimeout(function(){var t;i.calculateContainerSize(),C(null==(t=i.ewColorPicker)?void 0:t.getMountPoint)&&i.handleAutoPosition()},0),this.updateHueBg(),C(null==(t=this.ewColorPicker)?void 0:t.getColor)&&(o=this.ewColorPicker.getColor())?(e=w(o),this.updateCursorPosition(e.s,e.v)):this.updateCursorPosition(100,100))},H.prototype.bindEvents=function(){var o=this;this.panel&&(v(this.panel,"click",function(t){return o.handlePanelClick(t)}),v(this.panel,"mousedown",function(){return o.handlePanelMouseDown()}),v(this.panel,"touchstart",function(t){return o.handlePanelTouchStart(t)}))},H.prototype.handlePanelTouchStart=function(t){var o,e,i=this;this.panel&&!this.options.disabled&&(t.preventDefault(),this.isDragging=!0,o=function(t){i.isDragging&&0<t.touches.length&&i.handlePanelTouchMove(t)},e=function(){i.isDragging=!1,P(document,"touchmove",o),P(document,"touchend",e)},v(document,"touchmove",o),v(document,"touchend",e))},H.prototype.handlePanelTouchMove=function(t){var o,e;this.panel&&this.cursor&&(this.options.disabled||(t.preventDefault(),0<t.touches.length&&(this.panelWidth=this.panel.offsetWidth,this.panelHeight=this.panel.offsetHeight,t=t.touches[0],o=b(this.panel),e=t.clientX-o.left,t=t.clientY-o.top,o=Math.max(0,Math.min(100,e/this.panelWidth*100)),e=Math.max(0,Math.min(100,100*(1-t/this.panelHeight))),this.throttledUpdate(o,e))))},H.prototype.handlePanelClick=function(t){var o,e;this.panel&&this.cursor&&(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(this.panelWidth=this.panel.offsetWidth,this.panelHeight=this.panel.offsetHeight,o=b(this.panel),e=t.clientX-o.left,t=t.clientY-o.top,o=Math.max(0,Math.min(100,e/this.panelWidth*100)),e=Math.max(0,Math.min(100,100*(1-t/this.panelHeight))),this.updateCursorPosition(o,e),this.updateColor(o,e)))},H.prototype.handlePanelMouseDown=function(){var t,o,e=this;this.panel&&!this.options.disabled&&(this.isDragging=!0,t=function(t){e.isDragging&&e.handlePanelDrag(t)},o=function(){e.isDragging=!1,P(document,"mousemove",t),P(document,"mouseup",o)},v(document,"mousemove",t),v(document,"mouseup",o))},H.prototype.handlePanelDrag=function(t){var o,e;this.panel&&this.cursor&&(this.options.disabled||(t.preventDefault(),this.panelWidth=this.panel.offsetWidth,this.panelHeight=this.panel.offsetHeight,o=b(this.panel),e=t.clientX-o.left,t=t.clientY-o.top,o=Math.max(0,Math.min(100,e/this.panelWidth*100)),e=Math.max(0,Math.min(100,100*(1-t/this.panelHeight))),this.throttledUpdate(o,e)))},H.prototype.updateCursorPosition=function(t,o){var e,i,n;this.cursor&&this.panel&&(e=p(this.panel,"display"),i=p(this.panel,"visibility"),"none"!==e)&&"hidden"!==i&&(e=this.panel.offsetWidth,i=this.panel.offsetHeight,0!==e&&0!==i||(e=(n=b(this.panel)).width||this.panelWidth||285,i=n.height||this.panelHeight||180,0!==e&&0!==i)||(e=285,i=180),this.panelWidth=e,this.panelHeight=i,e={x:(n=ht(this.cursor)).offsetWidth/2,y:n.offsetHeight/2},0!==n.offsetWidth&&0!==n.offsetHeight||(e.x=2,e.y=2),i=t/100*this.panelWidth,n=(1-o/100)*this.panelHeight,i=Math.max(e.x,Math.min(i,this.panelWidth-e.x)),n=Math.max(e.y,Math.min(n,this.panelHeight-e.y)),u(this.cursor,{left:"".concat(i,"px"),top:"".concat(n,"px")}))},H.prototype.updateColor=function(t,o){var e=this.options.alpha?"rgba(255,0,0,1)":"#ff0000",i=this.ewColorPicker.getColor(),e=(i&&-1===i.indexOf("NaN")||this.ewColorPicker.setColor(i=e),w(i)),i=(e.s=t,e.v=o,Ct(e));this.ewColorPicker.setColor(i),C(this.ewColorPicker.options.changeColor)&&this.ewColorPicker.options.changeColor(i),this.ewColorPicker.trigger("change",i)},H.prototype.updateHueBg=function(t){if(this.panel){if(void 0===(t=t)){var o=this.ewColorPicker.getColor();if(!o)return;t=w(o).h}o=Ct({h:t,s:100,v:100,a:1});u(this.panel,{background:o})}},H.prototype.calculateContainerSize=function(){var t,o,e,i,n,r,s=this.ewColorPicker.getMountPoint("panelContainer");s&&(n=s.offsetWidth,r=s.offsetHeight,0!==n&&0!==r||(t=s.style.display,o=s.style.visibility,e=s.style.position,u(s,{display:"block",visibility:"hidden",position:"absolute",left:"-9999px",top:"-9999px"}),s.offsetHeight,i=b(s),n=s.offsetWidth||i.width,r=s.offsetHeight||i.height,u(s,{display:t,visibility:o,position:e,left:"",top:""})),this.containerWidth=n||320,this.containerHeight=r||200)},H.prototype.handleAutoPosition=function(){var t,o,e,i,n;this.isPanelAppended?this.updateAppendedPanelPosition():(t=(n=(null==(n=this.ewColorPicker)?void 0:n.options)||{}).autoPanelPosition,o=n.panelPlacement,t&&n.ewColorPickerBox&&(t=this.ewColorPicker.getMountPoint("root"),n=f(".".concat(this.prefix,"color-picker-box"),t),t)&&n&&(this.calculateContainerSize(),i=(n=ht(n)).offsetWidth,n=n.offsetHeight,e=(o=(o||"bottom").split("-"))[0],e=(o=this.calculatePosition(void 0===e?"bottom":e,void 0===(e=o[1])?"center":e,i,n)).left,i=this.adjustForViewport(t,e,o.top),n=this.ewColorPicker.getMountPoint("panelContainer"))&&u(n,{position:"absolute",left:"".concat(i.left,"px"),top:"".concat(i.top,"px")}))},H.prototype.movePanelContainer=function(){var t,o=this.options.appendTo;o&&(t=this.ewColorPicker.getMountPoint("panelContainer"))&&(g(ot(o),t),this.isPanelAppended=!0,this.calculateContainerSize(),v(window,"scroll",this.handleReposition,{capture:!0}),v(window,"resize",this.handleReposition),this.updateAppendedPanelPosition())},H.prototype.updateAppendedPanelPosition=function(){var t,o,e,i,n,r;this.isPanelAppended&&(t=this.ewColorPicker.getMountPoint("panelContainer"),o=this.ewColorPicker.getMountPoint("root"),t)&&o&&(n=(r=ht(f(".".concat(this.prefix,"color-picker-box"),o)||o)).offsetWidth,r=r.offsetHeight,i=(e=(this.options.panelPlacement||"bottom").split("-"))[0],i=(e=this.calculatePosition(void 0===i?"bottom":i,void 0===(i=e[1])?"center":i,n,r)).left,n=this.adjustForViewport(o,i,e.top),r=b(o),u(t,{position:"fixed",left:"".concat(r.left+n.left,"px"),top:"".concat(r.top+n.top,"px")}))},H.prototype.calculatePosition=function(t,o,e,i){e={top:{left:"start"===o?-this.containerWidth:"end"===o?e:(e-this.containerWidth)/2,top:-this.containerHeight-i/2},bottom:{left:"start"===o?-this.containerWidth:"end"===o?e:(e-this.containerWidth)/2,top:i},left:{left:-this.containerWidth-5,top:"start"===o?-this.containerHeight-i/2:"end"===o?i:(i-this.containerHeight)/2},right:{left:e+5,top:"start"===o?-this.containerHeight-i/2:"end"===o?i:(i-this.containerHeight)/2}};return e[t]||e.bottom},H.prototype.adjustForViewport=function(t,o,e){var t=b(t),i=window.innerWidth||document.documentElement.clientWidth,n=window.innerHeight||document.documentElement.clientHeight,r=8-(t.left+o),s=8-(t.top+e),i=t.left+o+this.containerWidth-(i-8),t=t.top+e+this.containerHeight-(n-8);return 0<r&&(o+=r),0<i&&(o-=i),0<s&&(e+=s),0<t&&(e-=t),{left:o,top:e}},H.prototype.destroy=function(){var t;this.panel&&(P(this.panel,"click",this.handlePanelClick),P(this.panel,"mousedown",this.handlePanelMouseDown)),P(window,"scroll",this.handleReposition,{capture:!0}),P(window,"resize",this.handleReposition),C(null==(t=this.ewColorPicker)?void 0:t.off)&&this.ewColorPicker.off("toggle",this.handleToggle),this.panel=null,this.cursor=null,this.whitePanel=null,this.blackPanel=null,this.hueBar=null,this.hueThumb=null,this.alphaBar=null,this.alphaThumb=null,this.hueBg=null},H.prototype.install=function(t){var o=this;this.ewColorPicker=t,this.handleOptions(),C(null==t?void 0:t.on)&&t.on("change",function(t){t=w(t);o.updateCursorPosition(t.s,t.v)}),null!=(t=this.run)&&t.call(this)},H.pluginName="ewColorPickerPanel",H.applyOrder="post";t=H;function H(t){var i=this;this.ewColorPicker=t,this.options={},this.panel=null,this.cursor=null,this.whitePanel=null,this.blackPanel=null,this.hueBar=null,this.hueThumb=null,this.alphaBar=null,this.alphaThumb=null,this.hueBg=null,this.isHueHorizontal=!1,this.isAlphaHorizontal=!1,this.isDragging=!1,this.isPanelAppended=!1,this.handleToggle=function(t){i.isPanelAppended&&t&&i.updateAppendedPanelPosition()},this.handleReposition=function(){i.isPanelAppended&&i.updateAppendedPanelPosition()},this.lastUpdateTime=0,this.throttleDelay=16,this.throttledUpdate=function(t,o){var e=Date.now();e-i.lastUpdateTime>=i.throttleDelay&&(i.lastUpdateTime=e,isNaN(t)||isNaN(o)||t<0||100<t||o<0||100<o||(i.updateCursorPosition(t,o),i.updateColor(t,o)))},this.handleOptions(),C(null==(t=this.ewColorPicker)?void 0:t.on)&&(this.ewColorPicker.on("change",function(t){t&&i.panel&&(t=w(t),i.updateHueBg(t.h),i.updateCursorPosition(t.s,t.v))}),this.ewColorPicker.on("toggle",this.handleToggle)),this.run()}Object.defineProperty(O.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(O.prototype,"hasHue",{get:function(){return this._hasHue},set:function(t){this._hasHue!==t&&((this._hasHue=t)?this.render():this.hueBar&&this.hueBar.parentNode&&(this.hueBar.parentNode.removeChild(this.hueBar),this.hueBar=null))},enumerable:!1,configurable:!0}),O.prototype.enableHue=function(t){this.hasHue=t=void 0===t?!0:t},O.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=i(this.options,this.ewColorPicker.options),this.isHorizontal="horizontal"===this.options.hueDirection)},O.prototype.run=function(){var t=this;this.hasHue&&this.render(),setTimeout(function(){t.bindEvents()},10)},O.prototype.render=function(){var t,o,e,i=this.ewColorPicker.getMountPoint("panelContainer");i?(o=this.prefix,(t=f(".".concat(o,"color-picker-slider.").concat(o,"color-picker-is-vertical, .").concat(o,"color-picker-slider.").concat(o,"color-picker-is-horizontal"),i))&&r(t),t=l("div"),c(t,"".concat(o,"color-picker-slider ")+(this.isHorizontal?"".concat(o,"color-picker-is-horizontal"):"".concat(o,"color-picker-is-vertical"))),this.hueBar=l("div"),c(this.hueBar,"".concat(o,"color-picker-slider-bar")),this.hueThumb=l("div"),c(this.hueThumb,"".concat(o,"color-picker-slider-thumb")),g(this.hueBar,this.hueThumb),g(t,this.hueBar),this.isHorizontal?(e=f(".".concat(o,"color-picker-bottom-row"),i))&&e.parentNode?e.parentNode.insertBefore(t,e):g(i,t):(e=f(".".concat(o,"color-picker-panel"),i))&&e.parentNode?e.parentNode.insertBefore(t,e.nextSibling):g(i,t),(o=this.ewColorPicker.getColor())&&(e=w(o),this.updateHueThumbPosition(e.h))):h("[ewColorPicker] Panel container not found")},O.prototype.bindEvents=function(){this.hueBar&&(v(this.hueBar,"click",this.handleHueSliderClick.bind(this)),v(this.hueBar,"mousedown",this.handleHueSliderMouseDown.bind(this)))},O.prototype.handleHueSliderClick=function(t){var o,e;this.hueBar&&(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(o=b(this.hueBar),t=this.isHorizontal?(e=t.clientX-o.left,Math.max(0,Math.min(360,e/o.width*360))):(e=t.clientY-o.top,Math.max(0,Math.min(360,360*(1-e/o.height)))),this.updateHue(t)))},O.prototype.handleHueSliderMouseDown=function(t){var i,n,o,e,r=this;this.hueBar&&!this.options.disabled&&(i=this.hueBar,n=this.isHorizontal,o=function(t){var o,e=b(i);t=n?(o=t.clientX-e.left,Math.max(0,Math.min(360,o/e.width*360))):(o=t.clientY-e.top,Math.max(0,Math.min(360,360*(1-o/e.height)))),r.throttledUpdateHue(t)},e=function(){P(document,"mousemove",o),P(document,"mouseup",e)},v(document,"mousemove",o),v(document,"mouseup",e))},O.prototype.updateHue=function(t){var o=this.ewColorPicker.getColor(),t=Math.max(0,Math.min(360,t)),o=o?w(o):{h:t,s:100,v:100,a:1},o=(isNaN(o.h)||isNaN(o.s)||isNaN(o.v)||isNaN(o.a)?(o.h=t,o.s=100,o.v=100,o.a=1):o.h=t,Ct(o)),o=(o&&!o.includes("NaN")?this.ewColorPicker.setColor(o):(o=this.ewColorPicker.options.alpha?"rgba(255, 0, 0, 1)":"#ff0000",this.ewColorPicker.setColor(o)),this.updateHueThumbPosition(t),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerPanel);o&&C(o.updateHueBg)&&o.updateHueBg(t)},O.prototype.updateHueThumbPosition=function(t){var o,e;this.hueThumb&&this.hueBar&&(e=this.isHorizontal,o=b(this.hueBar),e?(e=Math.max(0,Math.min(o.width,t/360*o.width)),u(this.hueThumb,"left","".concat(e,"px")),u(this.hueThumb,"top","0px")):(e=Math.max(0,Math.min(o.height,(1-t/360)*o.height)),u(this.hueThumb,"top","".concat(e,"px")),u(this.hueThumb,"left","0px")))},O.prototype.destroy=function(){this.hueBar&&(P(this.hueBar,"click",this.handleHueSliderClick.bind(this)),P(this.hueBar,"mousedown",this.handleHueSliderMouseDown.bind(this))),this.hueBar=null,this.hueThumb=null},O.prototype.install=function(t){var o=this;this.ewColorPicker=t,this.handleOptions(),t.on&&"function"==typeof t.on&&t.on("change",function(t){t=w(t);o.updateHueThumbPosition(t.h)}),null!=(t=this.run)&&t.call(this)},O.pluginName="ewColorPickerHue",O.applyOrder="post";R=O;function O(t){var o=this;this.ewColorPicker=t,this.options={},this.hueBar=null,this.hueThumb=null,this.isHorizontal=!1,this._hasHue=!0,this.handleOptions(),!1===this.options.hue&&(this._hasHue=!1),this.throttledUpdateHue=Bt(this.updateHue.bind(this),16),this.ewColorPicker.on&&"function"==typeof this.ewColorPicker.on&&this.ewColorPicker.on("change",function(t){t&&o.hueThumb&&(t=w(t),o.updateHueThumbPosition(t.h))}),this.run()}Object.defineProperty(T.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"hasAlpha",{get:function(){return this._hasAlpha},set:function(t){this._hasAlpha!==t&&((this._hasAlpha=t)?this.render():this.alphaBar&&this.alphaBar.parentNode&&(this.alphaBar.parentNode.removeChild(this.alphaBar),this.alphaBar=null))},enumerable:!1,configurable:!0}),T.prototype.enableAlpha=function(t){this.hasAlpha=t=void 0===t?!0:t},T.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=i({},this.options,this.ewColorPicker.options),this.isHorizontal="horizontal"===this.options.alphaDirection)},T.prototype.run=function(){var t=this;this.hasAlpha&&this.render(),setTimeout(function(){t.bindEvents()},10)},T.prototype.render=function(){var t,o,e=this.ewColorPicker.getMountPoint("panelContainer");e?((t=f(".".concat(this.prefix,"color-picker-slider.ew-alpha"),e))&&r(t),t=l("div"),c(t,"".concat(this.prefix,"color-picker-slider ew-alpha ")+(this.isHorizontal?"".concat(this.prefix,"color-picker-is-horizontal"):"".concat(this.prefix,"color-picker-is-vertical"))),this.alphaBar=l("div"),c(this.alphaBar,"".concat(this.prefix,"color-picker-alpha-slider-bar")),o=l("div"),c(o,"".concat(this.prefix,"color-picker-alpha-slider-wrapper")),g(this.alphaBar,o),o=l("div"),c(o,"".concat(this.prefix,"color-picker-alpha-slider-bg")),g(this.alphaBar,o),this.alphaThumb=l("div"),c(this.alphaThumb,"".concat(this.prefix,"color-picker-alpha-slider-thumb")),g(this.alphaBar,this.alphaThumb),g(t,this.alphaBar),this.isHorizontal?(o=f(".".concat(this.prefix,"color-picker-bottom-row"),e))&&o.parentNode?o.parentNode.insertBefore(t,o):g(e,t):(o=f(".".concat(this.prefix,"color-picker-panel"),e))&&o.parentNode?o.parentNode.insertBefore(t,o.nextSibling):g(e,t),(o=this.ewColorPicker.getColor())&&(e=w(o),this.updateAlphaThumbPosition(e.a))):h("[ewColorPicker] Panel container not found, please check the ewColorPicker instance!")},T.prototype.bindEvents=function(){var o=this;this.alphaBar&&(v(this.alphaBar,"click",function(t){o.handleAlphaSliderClick(t)}),v(this.alphaBar,"mousedown",function(t){o.handleAlphaSliderMouseDown(t)}))},T.prototype.handleAlphaSliderClick=function(t){var o,e;this.alphaBar&&(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(o=b(this.alphaBar),t=this.isHorizontal?(e=t.clientX-o.left,Math.max(0,Math.min(1,1-e/o.width))):(e=t.clientY-o.top,Math.max(0,Math.min(1,1-e/o.height))),this.updateAlpha(t)))},T.prototype.handleAlphaSliderMouseDown=function(t){var i,n,o,e,r=this;this.alphaBar&&!this.options.disabled&&(i=this.alphaBar,n=this.isHorizontal,o=function(t){var o,e=b(i);t=n?(o=t.clientX-e.left,Math.max(0,Math.min(1,1-o/e.width))):(o=t.clientY-e.top,Math.max(0,Math.min(1,1-o/e.height))),r.throttledUpdateAlpha(t)},e=function(){P(document,"mousemove",o),P(document,"mouseup",e)},v(document,"mousemove",o),v(document,"mouseup",e))},T.prototype.updateAlpha=function(t){var o=this.ewColorPicker.getColor();o&&((o=w(o)).a=t,o=Ct(o),this.ewColorPicker.setColor(o),this.updateAlphaThumbPosition(t),t=null==(t=this.ewColorPicker.plugins)?void 0:t.ewColorPickerColorMode)&&"hex"!==t.currentMode&&t.updateInputValues(o)},T.prototype.updateAlphaThumbPosition=function(t){var o,e;this.alphaThumb&&this.alphaBar&&(e=this.isHorizontal,o=b(this.alphaBar),e?(e=Math.max(0,Math.min(o.width,(1-t)*o.width)),u(this.alphaThumb,"left","".concat(e,"px")),u(this.alphaThumb,"top","0px")):(e=Math.max(0,Math.min(o.height,(1-t)*o.height)),u(this.alphaThumb,"top","".concat(e,"px")),u(this.alphaThumb,"left","0px")))},T.prototype.destroy=function(){this.alphaBar&&(P(this.alphaBar,"click",this.handleAlphaSliderClick.bind(this)),P(this.alphaBar,"mousedown",this.handleAlphaSliderMouseDown.bind(this)),r(this.alphaBar)),this.alphaBar=null,this.alphaThumb=null},T.prototype.install=function(t){var o=this;this.ewColorPicker=t,this.handleOptions(),C(t.on)&&t.on("change",function(t){t=w(t);o.updateAlphaThumbPosition(t.a)}),null!=(t=this.run)&&t.call(this)},T.pluginName="ewColorPickerAlpha",T.applyOrder="post";var Ut=T;function T(t){var o=this;this.ewColorPicker=t,this.options={},this.alphaBar=null,this.alphaThumb=null,this.isHorizontal=!1,this._hasAlpha=!0,this.handleOptions(),!1===this.options.alpha&&(this._hasAlpha=!1),this.throttledUpdateAlpha=Bt(this.updateAlpha.bind(this),16),C(this.ewColorPicker.on)&&this.ewColorPicker.on("change",function(t){t=w(t);o.updateAlphaThumbPosition(t.a)}),this.run()}Object.defineProperty(A.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"hasInput",{get:function(){return this._hasInput},set:function(t){this._hasInput!==t&&((this._hasInput=t)?(this.render(),this.bindEvents()):this.input&&this.input.parentNode&&(r(this.input),this.input=null))},enumerable:!1,configurable:!0}),A.prototype.enableInput=function(t){this.hasInput=t=void 0===t?!0:t},A.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=i(this.options,this.ewColorPicker.options))},A.prototype.updateOptions=function(){this.handleOptions(),this.hasInput?this.render():this.input&&this.input.parentNode&&(r(this.input),this.input=null)},A.prototype.run=function(){this.hasInput&&(this.render(),this.bindEvents())},A.prototype.render=function(){var t,o,e=this.ewColorPicker.getMountPoint("panelContainer");e?(e=f(".".concat(this.prefix,"color-picker-bottom-row"),e))?(o=f(".".concat(this.prefix,"color-picker-drop-btn-group"),e),(t=f(".".concat(this.prefix,"color-picker-input-container"),e))||(t=l("div"),c(t,"".concat(this.prefix,"color-picker-input-container")),c(t,"".concat(this.prefix,"color-picker-input-container-flex")),o&&o.parentNode?o.parentNode.insertBefore(t,o):g(e,t)),this.input=f("input.".concat(this.prefix,"color-picker-input"),t),this.input||(this.input=l("input"),this.input&&(c(this.input,"".concat(this.prefix,"color-picker-input")),d(this.input,{type:"text",name:"".concat(this.prefix,"color-picker-input"),placeholder:"请输入颜色值"}),g(t,this.input))),(o=this.ewColorPicker.getColor())&&-1===o.indexOf("NaN")||(o=this.getDefaultColor(),""===this.ewColorPicker.currentColor?o="":this.ewColorPicker.setColor(o)),e=this.formatColorForDisplay(o),this.input&&(this.input.value=e),this.options.disabled&&this.setDisabled(!0)):h("[ewColorPicker] Bottom row container not found"):h("[ewColorPicker] Panel container not found")},A.prototype.bindEvents=function(){var o=this;this.input&&(v(this.input,"blur",function(t){o.debouncedOnInputColor(t.target.value)}),v(this.input,"keydown",function(t){"Enter"===t.key&&o.debouncedOnInputColor(t.target.value)}),this.ewColorPicker.on("change",function(t){o.update(t)}))},A.prototype.onInputColor=function(t){var o,e,i;t.trim()&&(vt(t)?(i=m(t),this.ewColorPicker.hsvaColor=w(i),this.ewColorPicker.setColor(i),this.syncOtherPlugins(i),C(this.options.changeColor)&&null!=(e=(o=this.options).changeColor)&&e.call(o,i)):h("[ewColorPicker warning]: Invalid color format: ".concat(t)))},A.prototype.syncOtherPlugins=function(t){var o=this.ewColorPicker.hsvaColor,e=null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerColorMode,e=(e&&"hex"!==e.currentMode&&e.updateInputValues(t),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerHue),e=(e&&e.updateHueThumbPosition&&e.updateHueThumbPosition(o.h),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerAlpha),o=(e&&e.updateAlphaThumbPosition&&e.updateAlphaThumbPosition(o.a),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerPanel),o=(o&&o.updatePanelColor&&o.updatePanelColor(t),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerBox);o&&o.setBoxBgColor&&o.setBoxBgColor(t)},A.prototype.setValue=function(t){this.input&&(this.input.value=t)},A.prototype.getValue=function(){return this.input?this.input.value:""},A.prototype.setDisabled=function(t){this.input&&(t?(this.input.disabled=!0,s(this.input,"".concat(this.prefix,"input-disabled"))||c(this.input,"".concat(this.prefix,"input-disabled"))):(this.input.disabled=!1,s(this.input,"".concat(this.prefix,"input-disabled"))&&a(this.input,"".concat(this.prefix,"input-disabled"))))},A.prototype.update=function(t){t&&-1===t.indexOf("NaN")||(t=""===this.ewColorPicker.currentColor?"":this.getDefaultColor());t=this.formatColorForDisplay(t);this.setValue(t)},A.prototype.getDefaultColor=function(){var t;return this.hasAlpha?"rgba(255,0,0,1)":null!=(t=this.ewColorPicker.plugins)&&t.ewColorPickerColorMode?"HSL"===(t=this.ewColorPicker.currentMode||"HSV")?"hsl(0, 100%, 50%)":"RGB"===t?"rgba(255,0,0,1)":"#ff0000":"#ff0000"},A.prototype.formatColorForDisplay=function(t){var o,e;return t?(e=t,!(null==(o=this.ewColorPicker.plugins)||!o.ewColorPickerColorMode)&&(o=this.ewColorPicker.plugins.ewColorPickerColorMode)&&"hex"===o.getCurrentMode()?e&&!e.startsWith("#")&&(o=m(e))&&(o=wt(o))&&(e=Pt(o)):this.hasAlpha&&!t.startsWith("rgba")?e=Ct(w(t)):!this.hasAlpha&&t.startsWith("rgba")&&(e=gt(t)),e):""},A.prototype.destroy=function(){this.input&&(P(this.input,"blur",this.debouncedOnInputColor),P(this.input,"keydown",this.debouncedOnInputColor)),this.input=null},A.prototype.install=function(t){var o=this;this.ewColorPicker=t,this.handleOptions(),C(null==t?void 0:t.on)&&t.on("change",function(t){o.update(t)}),null!=(t=this.run)&&t.call(this)},A.pluginName="ewColorPickerInput",A.applyOrder="post";var $t=A;function A(t){this.ewColorPicker=t,this.options={},this.input=null,this._hasInput=!0,this.handleOptions(),!1===this.options.hasInput&&(this._hasInput=!1),this.debouncedOnInputColor=e(this.onInputColor.bind(this),300),this.run(),this.hasAlpha=!!this.ewColorPicker.plugins.ewColorPickerAlpha}Object.defineProperty(D.prototype,"prefix",{get:function(){return this.options.prefix||y},enumerable:!1,configurable:!0}),D.prototype.createElements=function(){var t=this.prefix,o=(this.container=l("div"),c(this.container,"".concat(t,"input-number")),c(this.container,"".concat(t,"input-number--").concat(this.options.size)),this.input=l("input"),c(this.input,"".concat(t,"input-number__input")),d(this.input,{type:"text",inputmode:"decimal",placeholder:this.options.placeholder}),l("div"));c(o,"".concat(t,"input-number__buttons")),this.upButton=l("button"),c(this.upButton,"".concat(t,"input-number__button")),c(this.upButton,"".concat(t,"input-number__button--up")),d(this.upButton,{type:"button"}),this.upButton.innerHTML=Mt(void 0,void 0,t),this.downButton=l("button"),c(this.downButton,"".concat(t,"input-number__button")),c(this.downButton,"".concat(t,"input-number__button--down")),d(this.downButton,{type:"button"}),this.downButton.innerHTML=Ht(void 0,void 0,t),g(o,this.upButton),g(o,this.downButton),g(this.container,this.input),g(this.container,o),this.setStyles()},D.prototype.setStyles=function(){this.options.disabled&&this.setDisabled(!0)},D.prototype.bindEvents=function(){v(this.input,"input",this.handleInput.bind(this)),v(this.input,"blur",this.handleBlur.bind(this)),v(this.input,"focus",this.handleFocus.bind(this)),v(this.input,"keydown",this.handleKeydown.bind(this)),v(this.upButton,"click",this.handleUpClick.bind(this)),v(this.downButton,"click",this.handleDownClick.bind(this)),v(this.container,"wheel",this.handleWheel.bind(this))},D.prototype.handleInput=function(t){var t=t.target.value;""!==t&&"-"!==t&&"."!==t&&(t=parseFloat(t),isNaN(t)?this.input.value=this.currentValue.toString():this.currentValue=t)},D.prototype.handleBlur=function(t){this.isFocused=!1,this.removeClass(this.container,"".concat(this.prefix,"input-number--focused")),this.updateValue(this.currentValue,!1),this.options.onBlur(this.currentValue)},D.prototype.handleFocus=function(t){this.isFocused=!0,this.addClass(this.container,"".concat(this.prefix,"input-number--focused")),this.options.onFocus(t)},D.prototype.handleKeydown=function(t){switch(t.key){case"ArrowUp":t.preventDefault(),this.increment();break;case"ArrowDown":t.preventDefault(),this.decrement();break;case"Enter":t.preventDefault(),this.input.blur()}},D.prototype.handleUpClick=function(){this.options.disabled||this.increment()},D.prototype.handleDownClick=function(){this.options.disabled||this.decrement()},D.prototype.handleWheel=function(t){this.isFocused&&!this.options.disabled&&(t.preventDefault(),t.deltaY<0?this.increment():this.decrement())},D.prototype.increment=function(){var t=this.currentValue+this.options.step;this.updateValue(t)},D.prototype.decrement=function(){var t=this.currentValue-this.options.step;this.updateValue(t)},D.prototype.updateValue=function(t,o){void 0===o&&(o=!0);var e=this.options.min,i=this.options.max,e=(t<e?t=e:i<t&&(t=i),this.options.precision);t=Math.round(t*Math.pow(10,e))/Math.pow(10,e),this.currentValue=t,this.formatDisplayValue(),o&&this.debouncedOnChange(t)},D.prototype.formatDisplayValue=function(){var t=this.options.precision;this.input.value=this.currentValue.toFixed(t)},D.prototype.addClass=function(t,o){s(t,o)||c(t,o)},D.prototype.removeClass=function(t,o){s(t,o)&&a(t,o)},D.prototype.getValue=function(){return this.currentValue},D.prototype.setValue=function(t){this.updateValue(t)},D.prototype.setDisabled=function(t){(this.options.disabled=t)?(this.addClass(this.container,"".concat(this.prefix,"input-number--disabled")),d(this.input,{disabled:"true"}),d(this.upButton,{disabled:"true"}),d(this.downButton,{disabled:"true"})):(this.removeClass(this.container,"".concat(this.prefix,"input-number--disabled")),d(this.input,{disabled:"false"}),d(this.upButton,{disabled:"false"}),d(this.downButton,{disabled:"false"}))},D.prototype.getElement=function(){return this.container},D.prototype.destroy=function(){var t;P(this.input,"input",this.handleInput.bind(this)),P(this.input,"blur",this.handleBlur.bind(this)),P(this.input,"focus",this.handleFocus.bind(this)),P(this.input,"keydown",this.handleKeydown.bind(this)),P(this.upButton,"click",this.handleUpClick.bind(this)),P(this.downButton,"click",this.handleDownClick.bind(this)),P(this.container,"wheel",this.handleWheel.bind(this)),null!=(t=this.container)&&t.parentNode&&r(this.container),this.container=null,this.input=null,this.upButton=null,this.downButton=null},D.prototype.install=function(t){var o;this.ewColorPicker=t,null!=(o=this.handleOptions)&&o.call(this),!1!==(null==(o=this.ewColorPicker.options)?void 0:o.showInputNumber)&&(C(t.on)&&t.on("change",function(){}),null!=(o=this.run))&&o.call(this)};var Rt=D;function D(t){void 0===t&&(t={});var o={value:0,min:-1/0,max:1/0,step:1,precision:0,disabled:this.isFocused=!1,placeholder:"",size:"default",prefix:y,onChange:function(){},onBlur:function(){},onFocus:function(){}};this.options=i(o,t),this.currentValue=null!=(o=this.options.value)?o:0,this.debouncedOnChange=e(this.options.onChange,300),this.createElements(),this.bindEvents(),this.updateValue(this.currentValue,!1)}I.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),this.run()},I.prototype.updateOptions=function(){var o=this;this.handleOptions(),this.instances.forEach(function(t){X(o.options.disabled)||t.setDisabled(o.options.disabled)})},I.prototype.run=function(){var t,o,e;this.ewColorPicker&&(t=k(this.ewColorPicker),o=this.createInputNumber({value:0,disabled:this.options.disabled||!1,prefix:t}),this.instances.set("default",o),e=this.ewColorPicker.getMountPoint("panelContainer"))&&(e=e.querySelector(".".concat(t,"color-picker-bottom-row")))&&e.appendChild(o.getElement())},I.prototype.handleOptions=function(){var t=null==(t=this.ewColorPicker)?void 0:t.options;t&&(this.options=n(n(n({},this.options),t),{disabled:X(t.disabled)?this.options.disabled||!1:t.disabled}))},I.prototype.createInputNumber=function(t){return new Rt(t)},I.prototype.destroy=function(){this.instances.forEach(function(t){t.destroy()}),this.instances.clear(),this.ewColorPicker=null},I.pluginName="ewColorPickerInputNumber",I.applyOrder="post";var qt=I;function I(t){this.options={},this.instances=new Map,this.ewColorPicker=t,this.handleOptions()}Object.defineProperty(E.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"hasClear",{get:function(){return this._hasClear},set:function(t){this._hasClear!==t&&(this._hasClear=t,this.render())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"hasSure",{get:function(){return this._hasSure},set:function(t){this._hasSure!==t&&(this._hasSure=t,this.render())},enumerable:!1,configurable:!0}),E.prototype.enableClear=function(t){this.hasClear=t=void 0===t?!0:t},E.prototype.enableSure=function(t){this.hasSure=t=void 0===t?!0:t},E.prototype.enableButtons=function(t){this.hasClear=t=void 0===t?!0:t,this.hasSure=t},E.prototype.handleOptions=function(){this.options=i({},this.options,this.ewColorPicker.options)},E.prototype.updateOptions=function(){var t=this;this.handleOptions(),setTimeout(function(){t.render()},0)},E.prototype.run=function(){var t=this;!1!==this.options.showButton&&(this.render(),this.bindEvents(),setTimeout(function(){t.adjustButtonGroupStyle()},0))},E.prototype.render=function(){var t,o=this.ewColorPicker.getMountPoint("panelContainer");o?(o=f(".".concat(this.prefix,"color-picker-bottom-row"),o))?((t=f(".".concat(this.prefix,"color-picker-drop-btn-group"),o))||(t=l("div"),c(t,"".concat(this.prefix,"color-picker-drop-btn-group")),g(o,t)),t.textContent="",this.hasClear&&(this.clearButton=l("button"),c(this.clearButton,"".concat(this.prefix,"color-picker-clear-btn ").concat(this.prefix,"color-picker-drop-btn")),this.setClearText(this.options.clearText||"清空"),g(t,this.clearButton)),this.hasSure&&(this.sureButton=l("button"),c(this.sureButton,"".concat(this.prefix,"color-picker-sure-btn ").concat(this.prefix,"color-picker-drop-btn")),this.setSureText(this.options.sureText||"确认"),g(t,this.sureButton)),this.adjustButtonGroupStyle()):h("[ewColorPicker warning]: Bottom row container not found"):h("[ewColorPicker warning]: Panel container not found")},E.prototype.bindEvents=function(){var t=this;this.clearButton&&v(this.clearButton,"click",function(){t.debouncedOnClearColor()}),this.sureButton&&v(this.sureButton,"click",function(){t.debouncedOnSureColor()}),this.ewColorPicker.on("mode-change",function(){t.adjustButtonGroupStyle()})},E.prototype.onClearColor=function(){var t,o,e;this.ewColorPicker.options.defaultColor?(e=m(o=this.ewColorPicker.options.defaultColor))&&(t=w(e)):(o="",t=void 0),this.ewColorPicker.hsvaColor=t||{h:0,s:100,v:100,a:1},this.ewColorPicker.setColor(o),this.ewColorPicker.syncAllPlugins(o),this.ewColorPicker.hidePanel(),C(this.options.clear)&&null!=(t=(e=this.options).clear)&&t.call(e,this.ewColorPicker),this.ewColorPicker.trigger("clear")},E.prototype.onSureColor=function(){var t,o;C(this.options.sure)&&null!=(o=(t=this.options).sure)&&o.call(t,this.ewColorPicker.currentColor,this.ewColorPicker),this.ewColorPicker.trigger("sure",this.ewColorPicker.currentColor,this.ewColorPicker),this.ewColorPicker.hidePanel()},E.prototype.setClearText=function(t){this.clearButton&&(this.clearButton.textContent=t)},E.prototype.setSureText=function(t){this.sureButton&&(this.sureButton.textContent=t)},E.prototype.setDisabled=function(t){this.clearButton&&d(this.clearButton,{disabled:t.toString()}),this.sureButton&&d(this.sureButton,{disabled:t.toString()})},E.prototype.destroy=function(){this.clearButton&&P(this.clearButton,"click",this.debouncedOnClearColor),this.sureButton&&P(this.sureButton,"click",this.debouncedOnSureColor),this.clearButton=null,this.sureButton=null},E.prototype.adjustButtonGroupStyle=function(){var t,o,e=this.prefix,i=this.ewColorPicker.getMountPoint("panelContainer");i&&(t=f(".".concat(e,"color-picker-bottom-row"),i))&&(o=f(".".concat(e,"color-picker-drop-btn-group"),t))&&(null!==f(".".concat(e,"color-picker-inputs-group"),i)?(c(o,"".concat(e,"color-picker-drop-btn-group-multi")),a(o,"".concat(e,"color-picker-drop-btn-group-single")),c(t,"".concat(e,"color-picker-bottom-row-multi")),a(t,"".concat(e,"color-picker-bottom-row-single"))):(c(o,"".concat(e,"color-picker-drop-btn-group-single")),a(o,"".concat(e,"color-picker-drop-btn-group-multi")),c(t,"".concat(e,"color-picker-bottom-row-single")),a(t,"".concat(e,"color-picker-bottom-row-multi"))))},E.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),null!=(t=this.run)&&t.call(this)},E.pluginName="ewColorPickerButton",E.applyOrder="post";var Gt=E;function E(t){this.ewColorPicker=t,this.options={},this.clearButton=null,this.sureButton=null,this._hasClear=!0,this._hasSure=!0,this.handleOptions(),!1===this.options.hasClear&&(this._hasClear=!1),!1===this.options.hasSure&&(this._hasSure=!1),this.debouncedOnClearColor=e(this.onClearColor.bind(this),100),this.debouncedOnSureColor=e(this.onSureColor.bind(this),100),this.run()}Object.defineProperty(S.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),S.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=i(this.options,this.ewColorPicker.options),this.ewColorPicker.options.ewColorPickerPredefine)&&(this.options=i(this.options,this.ewColorPicker.options.ewColorPickerPredefine))},S.prototype.run=function(){0<this.getValidPredefineColors().length&&(this.render(),this.bindEvents(),this.bindColorChangeEvent())},S.prototype.getValidPredefineColors=function(){var o=this;return this.options.predefineColor&&Array.isArray(this.options.predefineColor)?this.options.predefineColor.filter(function(t){var t=o.parseColorData(t).color;return!(!(t=t)||"string"!=typeof t||!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t)&&!(/^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/.test(t)||/^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*(0|1|0?\.\d+)\s*\)$/.test(t)||/^hsl\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*\)$/.test(t)||/^hsla\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*,\s*(0|1|0?\.\d+)\s*\)$/.test(t)||"transparent"===t))}):[]},S.prototype.render=function(){var i=this,t=this.ewColorPicker.getMountPoint("panelContainer");t?(this.container=f(".".concat(this.prefix,"color-picker-predefine-container"),t),this.container||(this.container=l("div"),c(this.container,"".concat(this.prefix,"color-picker-predefine-container"))),this.container&&(this.container.textContent="",this.predefineItems=[],this.getValidPredefineColors().forEach(function(t){var t=i.parseColorData(t).color,o=l("div"),e=(c(o,"".concat(i.prefix,"color-picker-predefine-color")),l("div"));c(e,"".concat(i.prefix,"color-picker-predefine-color-item")),u(e,"backgroundColor",t),g(o,e),g(i.container,o),i.predefineItems.push(o)})),this.ensureContainerAtCorrectPosition(t),this.bindToggleEvent(t)):h("[ewColorPicker warning]: Panel container not found")},S.prototype.parseColorData=function(t){return{color:Y(t)?t:t.color,disabled:!!K(t)&&t.disabled}},S.prototype.bindToggleEvent=function(o){var e=this;this.isEventBound&&this.toggleHandler&&(this.ewColorPicker.off("toggle",this.toggleHandler),this.isEventBound=!1),this.toggleHandler=function(t){t&&e.ensureContainerAtCorrectPosition(o)},this.ewColorPicker.on("toggle",this.toggleHandler),this.isEventBound=!0},S.prototype.bindColorChangeEvent=function(){var o=this;this.changeHandler&&this.ewColorPicker.off("change",this.changeHandler),this.changeHandler=function(t){o.updateActivePredefineColor(t)},this.ewColorPicker.on("change",this.changeHandler)},S.prototype.ensureContainerAtCorrectPosition=function(t){var o,e;this.container&&(o=this.prefix,(e=f(".".concat(o,"color-picker-mode-container"),t))?t.insertBefore(this.container,e):(e=f(".".concat(o,"color-picker-bottom-row"),t))?t.insertBefore(this.container,e):(e=f(".".concat(o,"color-picker-panel"),t))&&e.nextSibling?t.insertBefore(this.container,e.nextSibling):t.appendChild(this.container))},S.prototype.bindEvents=function(){var i=this;this.predefineItems.forEach(function(t,o){var o=i.getValidPredefineColors()[o],o=i.parseColorData(o),e=o.color;o.disabled?c(t,"".concat(i.prefix,"color-picker-predefine-color-disabled")):(v(t,"click",function(t){i.debouncedOnPredefineColorClick(t,e)}),v(t,"blur",function(t){a(t.target,"".concat(i.prefix,"color-picker-predefine-color-active"))}))})},S.prototype.onPredefineColorClick=function(t,o){var e,i,n=this.prefix,r=t.target;s(r,"".concat(n,"color-picker-predefine-color"))||(r=r.closest(".".concat(n,"color-picker-predefine-color"))||r),s(r,"".concat(n,"color-picker-predefine-color-disabled"))||(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(c(r,"".concat(n,"color-picker-predefine-color-active")),this.predefineItems.forEach(function(t){t!==r&&a(t,"".concat(n,"color-picker-predefine-color-active"))}),vt(o)?(t=m(o),this.ewColorPicker.hsvaColor=w(t),this.ewColorPicker.setColor(t),C(this.options.changeColor)&&null!=(i=(e=this.options).changeColor)&&i.call(e,t)):h("[ewColorPicker warning]: Invalid predefine color: ".concat(o))))},S.prototype.updatePredefineColors=function(t){this.options.predefineColor=t,this.predefineItems=[],this.render(),this.bindEvents()},S.prototype.setDisabled=function(t,o){this.predefineItems[t]&&(o?c:a)(this.predefineItems[t],"".concat(this.prefix,"color-picker-predefine-color-disabled"))},S.prototype.destroy=function(){var o=this;this.predefineItems.forEach(function(t){P(t,"click",o.debouncedOnPredefineColorClick),P(t,"blur",function(){})}),this.isEventBound&&this.toggleHandler&&(this.ewColorPicker.off("toggle",this.toggleHandler),this.toggleHandler=null,this.isEventBound=!1),this.changeHandler&&(this.ewColorPicker.off("change",this.changeHandler),this.changeHandler=null),this.predefineItems=[],this.container=null},S.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),null!=(t=this.run)&&t.call(this)},S.prototype.updateActivePredefineColor=function(t){var e,i,n=this;t&&(e=m(t),i=this.prefix,this.predefineItems.forEach(function(t,o){o=n.getValidPredefineColors()[o],o=m(n.parseColorData(o).color);(e===o?c:a)(t,"".concat(i,"color-picker-predefine-color-active"))}))},S.pluginName="ewColorPickerPredefine";var Xt=S;function S(t){this.ewColorPicker=t,this.options={},this.predefineItems=[],this.container=null,this.toggleHandler=null,this.changeHandler=null,this.isEventBound=!1,this.handleOptions(),this.debouncedOnPredefineColorClick=e(this.onPredefineColorClick.bind(this),100),this.run()}Object.defineProperty(N.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"hasAlphaPlugin",{get:function(){var t;return!(null==(t=this.ewColorPicker.plugins)||!t.ewColorPickerAlpha)},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"inputPlugin",{get:function(){var t;return null==(t=this.ewColorPicker.plugins)?void 0:t.ewColorPickerInput},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"alphaPlugin",{get:function(){var t;return null==(t=this.ewColorPicker.plugins)?void 0:t.ewColorPickerAlpha},enumerable:!1,configurable:!0}),N.prototype.initializePlugin=function(){function t(){o.handleOptions(),o.run()}var o=this;this.ewColorPicker.plugins?t():setTimeout(t,0)},N.prototype.install=function(o){function t(){var t;e.handleOptions(),o.on&&C(o.on)&&o.on("change",function(t){"hex"!==e.currentMode&&e.updateInputValues(t)}),null!=(t=e.run)&&t.call(e),e.hasAlphaPlugin&&"rgb"===e.currentMode&&e.updateInputStructure()}var e=this;this.ewColorPicker=o;this.ewColorPicker.plugins?t():setTimeout(t,0)},N.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=i({},this.options,this.ewColorPicker.options),void 0!==this.ewColorPicker.options.ewColorPickerColorMode&&(!1===this.ewColorPicker.options.ewColorPickerColorMode?this.options.showColorMode=!1:"object"==typeof this.ewColorPicker.options.ewColorPickerColorMode&&(this.options=i({},this.options,this.ewColorPicker.options.ewColorPickerColorMode))),this.hasAlphaPlugin?this.currentMode=this.options.defaultMode||"rgb":this.currentMode=this.options.defaultMode||"hex")},N.prototype.updateOptions=function(){this.handleOptions(),this.render()},N.prototype.run=function(){this.handleOptions(),!1!==this.options.showColorMode&&(this.render(),this.bindEvents(),this.hasAlphaPlugin&&"rgb"===this.currentMode&&this.updateInputStructure(),this.setupInputPluginListener())},N.prototype.render=function(){var t=this.ewColorPicker.getMountPoint("panelContainer");t?(this.modeContainer=f(".".concat(this.prefix,"color-picker-mode-container"),t),this.modeContainer||this.createModeContainer(t),this.updateModeDisplay()):h("[ewColorPicker] Panel container not found")},N.prototype.createModeContainer=function(t){var o=this.prefix,o=(this.modeContainer=l("div"),c(this.modeContainer,"".concat(o,"color-picker-mode-container")),this.upButton=l("button"),c(this.upButton,"".concat(o,"color-picker-mode-up-btn")),d(this.upButton,{type:"button",title:"上一个模式"}),this.upButton.innerHTML=Mt("",16,o),this.modeText=l("div"),c(this.modeText,"".concat(o,"color-picker-mode-text")),this.downButton=l("button"),c(this.downButton,"".concat(o,"color-picker-mode-down-btn")),d(this.downButton,{type:"button",title:"下一个模式"}),this.downButton.innerHTML=Ht("",16,o),g(this.modeContainer,this.upButton),g(this.modeContainer,this.modeText),g(this.modeContainer,this.downButton),f(".".concat(o,"color-picker-bottom-row"),t));o?g(t,this.modeContainer,void 0,o):g(t,this.modeContainer)},N.prototype.updateModeDisplay=function(){this.modeText&&(this.modeText.textContent=this.getModeDisplayName(this.currentMode))},N.prototype.bindEvents=function(){var t,o=this;this.upButton&&this.downButton&&(v(this.upButton,"click",t=function(){o.options.disabled||o.switchToPreviousMode()}),this.boundEventHandlers.push({element:this.upButton,event:"click",handler:t}),v(this.downButton,"click",t=function(){o.options.disabled||o.switchToNextMode()}),this.boundEventHandlers.push({element:this.downButton,event:"click",handler:t}),this.upButton&&(v(this.upButton,"mouseenter",this.handleUpButtonHover),v(this.upButton,"mouseleave",this.handleUpButtonLeave),this.boundEventHandlers.push({element:this.upButton,event:"mouseenter",handler:this.handleUpButtonHover}),this.boundEventHandlers.push({element:this.upButton,event:"mouseleave",handler:this.handleUpButtonLeave})),this.downButton&&(v(this.downButton,"mouseenter",this.handleDownButtonHover),v(this.downButton,"mouseleave",this.handleDownButtonLeave),this.boundEventHandlers.push({element:this.downButton,event:"mouseenter",handler:this.handleDownButtonHover}),this.boundEventHandlers.push({element:this.downButton,event:"mouseleave",handler:this.handleDownButtonLeave})),this.ewColorPicker.on("change",function(t){"hex"!==o.currentMode&&o.updateInputValues(t)}))},N.prototype.switchToPreviousMode=function(){var t=["hex","rgb","hsl"],o=t.indexOf(this.currentMode);this.debouncedOnModeChange(t[0<o?o-1:t.length-1])},N.prototype.switchToNextMode=function(){var t=["hex","rgb","hsl"],o=t.indexOf(this.currentMode);this.debouncedOnModeChange(t[(o+1)%t.length])},N.prototype.onModeChange=function(t){this.currentMode=t,this.updateModeDisplay(),this.updateInputStructure();var o,e=this.ewColorPicker.getColor();e&&"hex"!==t&&this.updateInputValues(e),C(this.options.changeMode)&&null!=(o=(e=this.options).changeMode)&&o.call(e,t,this.ewColorPicker),this.ewColorPicker.trigger("mode-change",t)},N.prototype.updateInputStructure=function(){var t=this.prefix,o=this.ewColorPicker.getMountPoint("panelContainer");o&&(o=f(".".concat(t,"color-picker-bottom-row"),o))&&(t=f(".".concat(t,"color-picker-input-container"),o))&&(this.inputPlugin&&!this.inputPlugin.hasInput?t.innerHTML="":"hex"===this.currentMode?this.restoreDefaultInput():(t.innerHTML="",this.createInputsForMode(t)))},N.prototype.setupInputPluginListener=function(){},N.prototype.createInputsForMode=function(t){var r,o,s=this,a=this.prefix;(!this.inputPlugin||this.inputPlugin.hasInput)&&(t.innerHTML="",o=[],"rgb"===this.currentMode?o=this.hasAlphaPlugin?["R","G","B","A"]:["R","G","B"]:"hsl"===this.currentMode&&(o=this.hasAlphaPlugin?["H","S","L","A"]:["H","S","L"]),r=l("div"),c(r,"".concat(a,"color-picker-inputs-group")),o.forEach(function(t,o){var e,i=l("div"),n=(c(i,"".concat(a,"color-picker-inputs-col")),l("div"));c(n,"".concat(a,"color-picker-input-label")),n.textContent=t,g(i,n),"rgb"===s.currentMode?(e=new Rt({value:0,min:0,max:3===o?1:255,step:3===o?.01:1,precision:3===o?2:0,placeholder:t,size:"small",prefix:a,onChange:function(){s.debouncedUpdateColorFromRgb()}}).getElement(),c(e,"".concat(a,"color-picker-rgb-").concat(t.toLowerCase(),"-input"))):"hsl"===s.currentMode&&(0===o?e=new Rt({value:0,min:0,max:360,step:1,precision:0,placeholder:t,size:"small",prefix:a,onChange:function(){s.debouncedUpdateColorFromHsl()}}).getElement():3===o&&s.hasAlphaPlugin?e=new Rt({value:0,min:0,max:1,step:.01,precision:2,placeholder:t,size:"small",prefix:a,onChange:function(){s.debouncedUpdateColorFromHsl()}}).getElement():(e=l("input"),d(e,{type:"text",placeholder:t,class:"".concat(a,"color-picker-hsl-").concat(t.toLowerCase(),"-input ").concat(a,"color-picker-input")})),e)&&c(e,"".concat(a,"color-picker-hsl-").concat(t.toLowerCase(),"-input")),e||(e=l("input"),d(e,{type:"text",placeholder:t,class:"".concat(a,"color-picker-default-input")})),g(i,e),g(r,i)}),g(t,r),o=this.ewColorPicker.getColor())&&this.updateInputValues(o)},N.prototype.getInputContainer=function(){var t=this.prefix,o=this.ewColorPicker.getMountPoint("panelContainer");return(o=o&&f(".".concat(t,"color-picker-bottom-row"),o))&&f(".".concat(t,"color-picker-input-container"),o)||document},N.prototype.updateInputValues=function(t){var o,e,i,n,r,s,a;t&&(t=m(t))&&(t=wt(t))&&(o=this.getInputContainer(),e=this.prefix,"rgb"===this.currentMode?(i=f(".".concat(e,"color-picker-rgb-r-input input"),o),n=f(".".concat(e,"color-picker-rgb-g-input input"),o),r=f(".".concat(e,"color-picker-rgb-b-input input"),o),a=f(".".concat(e,"color-picker-rgb-a-input input"),o),i&&(i.value=Math.round(t.r).toString()),n&&(n.value=Math.round(t.g).toString()),r&&(r.value=Math.round(t.b).toString()),a&&(a.value=t.a.toFixed(2))):"hsl"===this.currentMode&&(i=((t,o,e)=>{t/=255,o/=255,e/=255;var i=Math.max(t,o,e),n=Math.min(t,o,e),r=0,s=0,a=(i+n)/2;if(i!==n){var l=i-n,s=.5<a?l/(2-i-n):l/(i+n);switch(i){case t:r=(o-e)/l+(o<e?6:0);break;case o:r=(e-t)/l+2;break;case e:r=(t-o)/l+4}r/=6}return{h:360*r,s:100*s,l:100*a}})(t.r,t.g,t.b),n=f(".".concat(e,"color-picker-hsl-h-input input"),o),r=f(".".concat(e,"color-picker-hsl-s-input"),o),s=f(".".concat(e,"color-picker-hsl-l-input"),o),a=f(".".concat(e,"color-picker-hsl-a-input input"),o),n&&(n.value=Math.round(i.h).toString()),r&&(r.value=Math.round(i.s).toString()+"%"),s&&(s.value=Math.round(i.l).toString()+"%"),a)&&(a.value=t.a.toFixed(2)))},N.prototype.updateColorFromRgbInputs=function(){var t=this.getInputContainer(),o=this.prefix,e=f(".".concat(o,"color-picker-rgb-r-input input"),t),i=f(".".concat(o,"color-picker-rgb-g-input input"),t),n=f(".".concat(o,"color-picker-rgb-b-input input"),t),o=f(".".concat(o,"color-picker-rgb-a-input input"),t);e&&i&&n&&(t=parseInt(e.value)||0,e=parseInt(i.value)||0,i=parseInt(n.value)||0,n=o&&parseFloat(o.value)||1,o="rgba(".concat(t,", ").concat(e,", ").concat(i,", ").concat(n,")"),this.ewColorPicker.setColor(o),this.ewColorPicker.syncAllPlugins(o),this.alphaPlugin)&&this.alphaPlugin.updateAlphaThumbPosition&&this.alphaPlugin.updateAlphaThumbPosition(n)},N.prototype.updateColorFromHslInputs=function(){var t=this.getInputContainer(),o=this.prefix,e=f(".".concat(o,"color-picker-hsl-h-input input"),t),i=f(".".concat(o,"color-picker-hsl-s-input"),t),n=f(".".concat(o,"color-picker-hsl-l-input"),t),o=f(".".concat(o,"color-picker-hsl-a-input input"),t);e&&i&&n&&(t=parseInt(e.value)||0,e=parseInt(i.value.replace("%",""))||0,i=parseInt(n.value.replace("%",""))||0,n=o&&parseFloat(o.value)||1,o="hsla(".concat(t,", ").concat(e,"%, ").concat(i,"%, ").concat(n,")"),this.ewColorPicker.setColor(o),this.ewColorPicker.syncAllPlugins(o),this.alphaPlugin)&&this.alphaPlugin.updateAlphaThumbPosition&&this.alphaPlugin.updateAlphaThumbPosition(n)},N.prototype.getModeDisplayName=function(t){return{hex:"HEX",rgb:"RGB",hsl:"HSL"}[t]||t.toUpperCase()},N.prototype.getCurrentMode=function(){return this.currentMode},N.prototype.setMode=function(t){this.debouncedOnModeChange(t)},N.prototype.restoreDefaultInput=function(){var t,o=this.prefix,e=this.ewColorPicker.getMountPoint("panelContainer");e&&(e=f(".".concat(o,"color-picker-bottom-row"),e))&&(e=f(".".concat(o,"color-picker-input-container"),e))&&(this.inputPlugin&&!this.inputPlugin.hasInput?e.innerHTML="":(e.innerHTML="",c(e,"".concat(o,"color-picker-input-container-flex")),t=l("input"),c(t,"".concat(o,"color-picker-input")),c(t,"".concat(o,"color-picker-input-default")),d(t,{type:"text",name:"".concat(o,"color-picker-input"),placeholder:"请输入颜色值"}),g(e,t),(o=this.ewColorPicker.getColor())&&-1===o.indexOf("NaN")||(o=""),"hex"===this.currentMode&&(e=m(o))&&(e=wt(e))?(e=Pt(e),t.value=e):t.value=o,this.bindDefaultInputEvents(t)))},N.prototype.bindDefaultInputEvents=function(t){this.bindInputEvents(t)},N.prototype.rebindDefaultInputEvents=function(){var t=this.prefix,o=this.ewColorPicker.getMountPoint("panelContainer");o&&(o=f(".".concat(t,"color-picker-bottom-row"),o))&&(o=f(".".concat(t,"color-picker-input-container"),o))&&(t=f(".".concat(t,"color-picker-hex-input"),o))&&this.bindInputEvents(t)},N.prototype.bindInputEvents=function(o){function t(t){vt(t=t.target.value)&&(i.ewColorPicker.setColor(t),i.syncOtherPlugins(t))}function e(t){"Enter"===t.key&&vt(t=t.target.value)&&(i.ewColorPicker.setColor(t),i.syncOtherPlugins(t))}var i=this;v(o,"blur",t),this.boundEventHandlers.push({element:o,event:"blur",handler:t}),v(o,"keydown",e),this.boundEventHandlers.push({element:o,event:"keydown",handler:e});this.ewColorPicker.on("change",function(t){o.value="hex"===i.currentMode?i.toHexDisplay(t):t})},N.prototype.toHexDisplay=function(t){var o;return t?!t.startsWith("#")&&(o=m(t))&&(o=wt(o))?Pt(o):t:""},N.prototype.syncOtherPlugins=function(t){var o=this.ewColorPicker.hsvaColor,e=(this.inputPlugin&&this.inputPlugin.update&&this.inputPlugin.update(t),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerHue),o=(e&&e.updateHueThumbPosition&&e.updateHueThumbPosition(o.h),this.alphaPlugin&&this.alphaPlugin.updateAlphaThumbPosition&&this.alphaPlugin.updateAlphaThumbPosition(o.a),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerPanel),o=(o&&o.updatePanelColor&&o.updatePanelColor(t),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerBox);o&&o.setBoxBgColor&&o.setBoxBgColor(t)},N.prototype.destroy=function(){this.boundEventHandlers.forEach(function(t){var o=t.element;P(o,t.event,t.handler)}),this.boundEventHandlers=[],this.modeContainer&&this.modeContainer.parentNode&&r(this.modeContainer),this.modeContainer=null,this.modeText=null,this.upButton=null,this.downButton=null},N.pluginName="ewColorPickerColorMode",N.applyOrder="post";var Yt=N;function N(t){var o=this;this.ewColorPicker=t,this.options={},this.currentMode="hex",this.modeContainer=null,this.modeText=null,this.upButton=null,this.downButton=null,this.boundEventHandlers=[],this.handleUpButtonHover=function(){o.upButton&&u(o.upButton,{borderColor:"#4096ef",backgroundColor:"#f0f8ff"})},this.handleUpButtonLeave=function(){o.upButton&&u(o.upButton,{borderColor:"#ddd",backgroundColor:"#fff"})},this.handleDownButtonHover=function(){o.downButton&&u(o.downButton,{borderColor:"#4096ef",backgroundColor:"#f0f8ff"})},this.handleDownButtonLeave=function(){o.downButton&&u(o.downButton,{borderColor:"#ddd",backgroundColor:"#fff"})},this.debouncedOnModeChange=e(this.onModeChange.bind(this),100),this.debouncedUpdateColorFromRgb=e(this.updateColorFromRgbInputs.bind(this),100),this.debouncedUpdateColorFromHsl=e(this.updateColorFromHslInputs.bind(this),100),this.initializePlugin()}x.use(G),x.use(Lt),x.use(t),x.use(R),x.use(Ut),x.use($t),x.use(qt),x.use(Gt),x.use(Xt),x.use(Yt),"undefined"!=typeof window&&(window.ewColorPicker=x),_.default=x,_.ewColorPicker=x,Object.defineProperty(_,"__esModule",{value:!0})});
1
+ ((t,o)=>{"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((t="undefined"!=typeof globalThis?globalThis:t||self).ewColorPicker={})})(this,function(_){var z=function(t,o){return(z=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,o){t.__proto__=o}:function(t,o){for(var e in o)Object.prototype.hasOwnProperty.call(o,e)&&(t[e]=o[e])}))(t,o)};function j(t,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function e(){this.constructor=t}z(t,o),t.prototype=null===o?Object.create(o):(e.prototype=o.prototype,new e)}var n=function(){return(n=Object.assign||function(t){for(var o,e=1,i=arguments.length;e<i;e++)for(var n in o=arguments[e])Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n]);return t}).apply(this,arguments)};function F(t,o){var e={};for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&o.indexOf(n)<0&&(e[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)o.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(e[n[i]]=t[n[i]]);return e}function W(t,o,e){if(e||2===arguments.length)for(var i,n=0,r=o.length;n<r;n++)!i&&n in o||((i=i||Array.prototype.slice.call(o,0,n))[n]=o[n]);return t.concat(i||Array.prototype.slice.call(o))}function V(){}var L={log:V,warn:V,error:V},h=(["warn","error","log"].forEach(function(t){L[t]=function(){}}),L.warn),U=L.error,$=L.log,R="undefined"!=typeof window,t=R&&navigator.userAgent.toLowerCase(),q=(t&&t.match(/(iPhone|iPod|Android|ios)/i),!1);if(R)try{var G={};Object.defineProperty(G,"passive",{get:function(){q=!0}}),window.addEventListener("test-passive",function(){},G)}catch(U){}function X(t){return void 0===t}function Y(t){return"string"==typeof t}function K(t){return"object"===et.call(t).slice(8,-1).toLowerCase()}function Q(t,o){try{t()}catch(t){C(o)?o(t):U("[ewColorPicker error]: ".concat(t))}}function i(t){for(var o=[],e=1;e<arguments.length;e++)o[e-1]=arguments[e];if(nt(t))return{};if(Object.assign)return Object.assign.apply(Object,W([t],o,!1));for(var i=Object(t),n=0,r=o.length;n<r;n++){var s=o[n];if(s)for(var a in s)it.call(s,a)&&(i[a]=s[a])}return i}function l(t){return document.createElement(t)}function s(t,o){return new RegExp("(^|\\s)"+o+"(\\s|$)").test(t.className)}function c(t,o){for(var e=0,i=o.trim().split(/\s+/);e<i.length;e++){var n,r=i[e];r&&!s(t,r)&&((n=t.className.split(" ").filter(Boolean)).push(r),t.className=n.join(" "))}}function a(t,o){s(t,o)&&(o=new RegExp("(^|\\s)"+o+"(\\s|$)","g"),t.className=t.className.replace(o," "))}function Z(t){return t instanceof HTMLElement}function J(t,o,e){o=o.startsWith("--")?o:o.replace(/([A-Z])/g,"-$1").toLowerCase(),t.style.setProperty(o,e)}function u(e,t,o){if(Y(t=void 0===t?{}:t)&&!X(o)){o=rt(o)?"".concat(o,"px"):o;J(e,t,o)}else if(Array.isArray(t))t.forEach(function(t){var o=t.prop;J(e,o,t.value)});else for(var i=0,n=Object.entries(t);i<n.length;i++){var r=n[i],s=r[0];J(e,s,r[1])}}function tt(t,o){for(var e=0,i=o=void 0===o?[]:o;e<i.length;e++){var n=i[e];t.style.removeProperty(n)}}function p(o,e,i){var n;return o&&e?("float"===(e=e.replace(/([\:\_\-]+(.))/g,function(t,o,e,i){return i?e.toUpperCase():e}).replace(/^moz([A-Z])/,"Moz$1"))&&(e="cssFloat"),n=null,Q(function(){var t=(document.defaultView||window).getComputedStyle(o,i);n=o.style[e]||t?t[e]:null}),n||o.style[e]):null}function d(t,o){if(st(o))for(var e=0,i=Object.entries(o);e<i.length;e++){var n=i[e],r=n[0];t.setAttribute(r,"".concat(n[1]))}}function f(t,o){return(o=void 0===o?document:o).querySelector(t)}function r(t){var o;null!=t&&t.parentElement?null!=(o=null==t?void 0:t.parentElement)&&o.removeChild(t):null!=t&&t.remove()}function g(t,o,e,i){i&&null!=t&&t.contains(i)?t.insertBefore(o,i):e&&null!=t&&t.contains(e)?t.replaceChild(o,e):null!=t&&t.appendChild(o)}function ot(t){return Y(t)?f(t)||(h("[ewColorPicker warning]: Cannot find element with selector: ".concat(t)),document.body):Z(t)?t:document.body}var et=Object.prototype.toString,it=Object.prototype.hasOwnProperty,nt=function(t){return null===t},rt=function(t){return"number"==typeof t},C=function(t){return"function"==typeof t},st=function(t){return"object"==typeof t&&!nt(t)},at=function(t){return t.replace(/\s+/g,"")},lt=function(t){return t?" ".concat(t):""};function ht(t){return{clientWidth:t.clientWidth,clientHeight:t.clientHeight,offsetWidth:t.offsetWidth,offsetHeight:t.offsetHeight,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight}}function b(t){return t.getBoundingClientRect()}function v(t,o,e,i){i=q?{passive:!1,capture:!!i}:!!i,t.addEventListener(o,e,i)}function P(t,o,e,i){t.removeEventListener(o,e,{capture:!!i})}(t=Lt=Lt||{}).Pre="pre",t.Post="post",o.prototype.on=function(t,o,e){return void 0===e&&(e=this),this.hasType(t),this.events[t]||(this.events[t]=[]),this.events[t].push([o,e]),this},o.prototype.once=function(i,n,r){var s=this,a=(void 0===r&&(r=this),this.hasType(i),function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];s.off(i,a);var e=n.apply(r,t);if(!0===e)return e});return a.fn=n,this.on(i,a),this},o.prototype.off=function(t,o){if(!t&&!o)return this.events={},this;if(t){if(this.hasType(t),o){var e=this.events[t];if(e)for(var i=e.length;i--;)(e[i][0]===o||e[i][0]&&e[i][0].fn===o)&&e.splice(i,1)}else this.events[t]=[];return this}},o.prototype.trigger=function(t){for(var o=[],e=1;e<arguments.length;e++)o[e-1]=arguments[e];this.hasType(t);t=this.events[t];if(t)for(var i=t.length,n=W([],t,!0),r=0;r<i;r++){var s=n[r],a=s[0],s=s[1];if(a&&!0===(a=a.apply(s,o)))return a}},o.prototype.registerType=function(t){var o=this;t.forEach(function(t){o.eventTypes[t]=t})},o.prototype.destroy=function(){this.events={},this.eventTypes={}},o.prototype.hasType=function(t){var o=this.eventTypes;o[t]!==t&&h('[ewColorPicker warning]: EventEmitter has used unknown event type: "'.concat(t,'", should be oneof [')+"".concat(Object.keys(o).map(function(t){return JSON.stringify(t)}))+"]")};R=o;function o(t){this.events={},this.eventTypes={},this.registerType(t)}var ct=/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/,ut=/[rR][gG][Bb][Aa]?[\(]([\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?),){2}[\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?),?[\s]*(0\.\d{1,2}|1|0)?[\)]{1}/g,pt=/^[rR][gG][Bb][Aa][\(]([\\s]*(2[0-4][0-9]|25[0-5]|[01]?[0-9][0-9]?)[\\s]*,){3}[\\s]*(1|1.0|0|0?.[0-9]{1,2})[\\s]*[\)]{1}$/,dt=/^[hH][Ss][Ll][\(]([\\s]*(2[0-9][0-9]|360|3[0-5][0-9]|[01]?[0-9][0-9]?)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*)[\)]$/,ft=/^[hH][Ss][Ll][Aa][\(]([\\s]*(2[0-9][0-9]|360|3[0-5][0-9]|[01]?[0-9][0-9]?)[\\s]*,)([\\s]*((100|[0-9][0-9]?)%|0)[\\s]*,){2}([\\s]*(1|1.0|0|0?.[0-9]{1,2})[\\s]*)[\)]$/;function gt(t){var o,e,i={10:"A",11:"B",12:"C",13:"D",14:"E",15:"F"};return/rgba?/.test(t)?(o=t.replace(/rgba?\(/,"").replace(/\)/,"").replace(/[\s+]/g,"").split(","),e="",o.map(function(t,o){o<=2&&(e+=(o=+t,o=Math.min(Math.round(o),255),t=Math.floor(o/16),""+(i[t]||t)+(i[o%=16]||o)))}),at("#"+e)):t}function Ct(t){var o,e,i,n,r=t.a,s=t.h,a=255*t.s/100,t=255*t.v/100;return 0==a?o=e=i=t:(t=s%60*((n=t)-(a=(255-a)*t/255))/60,360===s?(o=n,e=i=0):s<60?(o=n,e=a+t,i=a):s<120?(o=n-t,e=n,i=a):s<180?(e=n,i=(o=a)+t):s<240?(o=a,e=n-t,i=n):s<300?(o=a+t,e=a,i=n):s<360?(e=a,i=(o=n)-t):o=e=i=0),r=Math.round(10*r)/10,"rgba(".concat(Math.round(o),", ").concat(Math.round(e),", ").concat(Math.round(i),", ").concat(r,")")}function w(t){var o,e,i,n,r,s,a,l;return t&&"string"==typeof t&&(t=t.replace(/\s+/g," ").trim().match(/rgba?\(([^)]+)\)/i))?(t=t[1].split(",").map(function(t){return t.trim()}),o=parseFloat(t[0])||0,e=parseFloat(t[1])||0,i=parseFloat(t[2])||0,t=4<=t.length&&parseFloat(t[3])||1,o=o/255,e=e/255,i=i/255,n=(l=Math.max(o,e,i))-Math.min(o,e,i),(s=r=0)!==(a=l)&&(s=n/l),0!=n?(l===o?r=(e-i)/n*60:l===e?r=60*((i-o)/n+2):l===i&&(r=60*((o-e)/n+4)),r<0&&(r+=360)):r=0,l=Math.round(10*t)/10,{h:Math.round(r),s:Math.round(100*s),v:Math.round(100*a),a:l}):{h:0,s:100,v:100,a:1}}var bt={black:"rgba(0, 0, 0, 1)",silver:"rgba(192, 192, 192, 1)",gray:"rgba(128, 128, 128, 1)",white:"rgba(255, 255, 255, 1)",maroon:"rgba(128, 0, 0, 1)",red:"rgba(255, 0, 0, 1)",purple:"rgba(128, 0, 128, 1)",fuchsia:"rgba(255, 0, 255, 1)",green:"rgba(0, 128, 0, 1)",lime:"rgba(0, 255, 0, 1)",olive:"rgba(128, 128, 0, 1)",yellow:"rgba(255, 255, 0, 1)",navy:"rgba(0, 0, 128, 1)",blue:"rgba(0, 0, 255, 1)",teal:"rgba(0, 128, 128, 1)",aqua:"rgba(0, 255, 255, 1)",orange:"rgba(255, 165, 0, 1)",pink:"rgba(255, 192, 203, 1)",brown:"rgba(165, 42, 42, 1)"};function m(t){if(t&&"string"==typeof t){var o=t.trim().toLowerCase();if(bt[o])return bt[o];if(ct.test(o))return((t,o)=>{var o=(o=void 0===o?1:o)||1,o=Math.round(10*o)/10,e=t.toLowerCase(),i=t.length,n=[];if(t&&ct.test(e)){if(4===i){for(var r="#",s=1;s<i;s++){var a=e.slice(s,s+1);r+=a.concat(a)}e=r}for(var l=1,h=e.length;l<h;l+=2)n.push(parseInt("0X"+e.slice(l,l+2),16));return"rgba(".concat(n.join(", "),", ").concat(o,")")}return at(e)})(o).replace(/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*\)/,"rgba($1, $2, $3, $4)");var e=o.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i);if(e)return i=e[1],n=e[2],r=e[3],"rgba(".concat(i,", ").concat(n,", ").concat(r,", 1)");var i,n,r,e=o.match(/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(0|1|0?\.\d+)\s*\)$/i);if(e)return i=e[1],n=e[2],r=e[3],o=e[4],"rgba(".concat(i,", ").concat(n,", ").concat(r,", ").concat(o,")");try{var s=l("div"),a=(u(s,{"background-color":t}),p(s,"backgroundColor"));if(a&&"rgba(0, 0, 0, 0)"!==a)return a.replace(/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*\)/,"rgba($1, $2, $3, $4)")}catch(t){}}return""}function vt(t){var o="transparent"===t;if(ct.test(t))return 1;if(ut.test(t)&&!t.includes("rgba"))return 1;if(pt.test(t))return 1;if(dt.test(t)&&!t.includes("hsla"))return 1;if(ft.test(t))return 1;if(o)return 1;if("#invalid"!==t&&"invalid"!==t&&(!t.includes("rgb(")||!t.includes(", 0.5)"))&&(!t.includes("rgba(")||t.includes(", 0.5)")||t.includes(", 1)")))try{var e=document.createElement("div");return u(e,{"background-color":t}),"rgba(0, 0, 0, 0)"!==p(e,"backgroundColor")||o}catch(t){}}function Pt(t){function o(t){return Math.round(t).toString(16).padStart(2,"0")}return"#".concat(o(t.r)).concat(o(t.g)).concat(o(t.b))}function wt(t){try{var o=t.slice(t.indexOf("(")+1,t.lastIndexOf(")")).split(",");return o.length<3?null:{r:parseInt(o[0]),g:parseInt(o[1]),b:parseInt(o[2]),a:o.length<4?1:parseFloat(o[3])}}catch(t){return null}}kt.prototype.show=function(){var o=this;return new Promise(function(t){u(o.element,{display:"block"}),t()})},kt.prototype.hide=function(){var o=this;return new Promise(function(t){u(o.element,{display:"none"}),t()})},kt.prototype.slideDown=function(){var n=this;return new Promise(function(t){u(n.element,{display:"block",visibility:"hidden"});var o=p(n.element,"marginTop"),e=p(n.element,"marginBottom"),i=n.element.offsetHeight+parseInt(o)+parseInt(e);u(n.element,{height:"0px",overflow:"hidden",visibility:"visible"}),n.element.offsetHeight,setTimeout(function(){u(n.element,{transition:"height ".concat(n.options.duration,"ms ").concat(n.options.easing),height:"".concat(i,"px")}),setTimeout(function(){u(n.element,{height:"",overflow:"",transition:""}),t()},n.options.duration)},n.options.delay)})},kt.prototype.slideUp=function(){var i=this;return new Promise(function(t){var o=p(i.element,"marginTop"),e=p(i.element,"marginBottom"),o=i.element.offsetHeight+parseInt(o)+parseInt(e);u(i.element,{height:"".concat(o,"px"),overflow:"hidden"}),i.element.offsetHeight,setTimeout(function(){u(i.element,{height:"0px",transition:"height ".concat(i.options.duration,"ms ").concat(i.options.easing)}),setTimeout(function(){u(i.element,{height:"",overflow:"",transition:"",display:"none"}),t()},i.options.duration)},i.options.delay)})},kt.prototype.fadeIn=function(){var t=this;return new Promise(function(e){function i(t){var t=Math.min((t-s)/r,1),o=1-Math.pow(1-t,3);u(n,{opacity:o.toString()}),t<1?requestAnimationFrame(i):(u(n,{opacity:"1"}),e())}var n=t.element,r=t.options.duration,s=(u(n,{display:"block",opacity:"0"}),n.offsetHeight,performance.now());requestAnimationFrame(i)})},kt.prototype.fadeOut=function(){var t=this;return new Promise(function(e){function i(t){var t=Math.min((t-s)/r,1),o=Math.pow(t,3);u(n,{opacity:(1-o).toString()}),t<1?requestAnimationFrame(i):(u(n,{display:"none",opacity:"0"}),e())}var n=t.element,r=t.options.duration,s=(u(n,{display:"block",opacity:"1"}),n.offsetHeight,performance.now());requestAnimationFrame(i)})};var mt=kt;function kt(t,o){void 0===o&&(o={}),this.element=t,this.options=n({duration:300,easing:"ease-out",delay:0},o)}var yt={show:function(t,o){return new mt(t,{duration:o=void 0===o?300:o}).show()},hide:function(t,o){return new mt(t,{duration:o=void 0===o?300:o}).hide()},slideDown:function(t,o){return new mt(t,{duration:o=void 0===o?300:o}).slideDown()},slideUp:function(t,o){return new mt(t,{duration:o=void 0===o?300:o}).slideUp()},fadeIn:function(t,o){return new mt(t,{duration:o=void 0===o?300:o}).fadeIn()},fadeOut:function(t,o){return new mt(t,{duration:o=void 0===o?300:o}).fadeOut()}};function xt(t){return(null==(t=t.options)?void 0:t.togglePickerAnimation)||"default"}function e(i,n,r){void 0===r&&(r=!1);var s=null;return function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];var e=r&&!s;s&&clearTimeout(s),s=setTimeout(function(){s=null,r||i.apply(void 0,t)},n),e&&i.apply(void 0,t)}}function Bt(e,i){var n;return function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];n||(e.apply(void 0,t),n=!0,setTimeout(function(){return n=!1},i))}}function k(t){return"string"==typeof(t=null==(t=null==t?void 0:t.options)?void 0:t.prefix)?t:y}function Mt(t,o,e){return void 0===e&&(e=y),o=o&&0<o?' width="'.concat(o,'" height="').concat(o,'"'):"",'<svg t="1717384498631" class="'.concat(e,"color-picker-icon").concat(lt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4235"').concat(o,'><path d="M512 309.333333c8.533333 0 17.066667 2.133333 23.466667 8.533334l341.333333 341.333333c12.8 12.8 12.8 32 0 44.8-12.8 12.8-32 12.8-44.8 0L533.333333 374.4 215.466667 692.266667c-12.8 12.8-32 12.8-44.8 0-12.8-12.8-12.8-32 0-44.8L488.533333 317.866667c4.266667-8.533333 12.8-10.666667 21.333334-10.666667z" fill="#666666" p-id="4236"></path></svg>')}function Ht(t,o,e){return void 0===e&&(e=y),o=o&&0<o?' width="'.concat(o,'" height="').concat(o,'"'):"",'<svg t="1717384498632" class="'.concat(e,"color-picker-icon").concat(lt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4236"').concat(o,'><path d="M512 714.666667c-8.533333 0-17.066667-2.133333-23.466667-8.533334l-341.333333-341.333333c-12.8-12.8-12.8-32 0-44.8 12.8-12.8 32-12.8 44.8 0l320 317.866667 317.866667-320c12.8-12.8 32-12.8 44.8 0 12.8 12.8 12.8 32 0 44.8L533.333333 704c-4.266667 8.533333-12.8 10.666667-21.333333 10.666667z" fill="#666666" p-id="4237"></path></svg>')}var y="ew-",Ot=["%c ew-color-picker@2.0.2%c 联系QQ:854806732 %c 联系微信:eveningwater %c github:https://github.com/eveningwater/ew-color-picker %c ","background:#0ca6dc ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#ff7878 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:#ff7878 ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#ff7878 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent"],Tt=!1,G=(At.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=i(this.options,this.ewColorPicker.options))},At.prototype.run=function(){Tt||(Tt=!0,$.apply(void 0,Ot))},At.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),t.on&&C(t.on)&&t.on("change",function(t){}),null!=(t=this.run)&&t.call(this)},At.pluginName="ewColorPickerConsole",At);function At(t){this.ewColorPicker=t,this.options={},this.handleOptions(),this.run()}var Dt,It={disabled:!1,predefineColor:[],size:"normal",defaultColor:"",isClickOutside:!0,hueDirection:"vertical",alphaDirection:"vertical",clearText:"清空",sureText:"确定",togglePickerAnimation:"default",pickerAnimationTime:200,autoPanelPosition:!1,panelPlacement:"bottom",prefix:y,sure:function(){},clear:function(){},togglePicker:function(){},changeColor:function(){}},Et=(j(St,Dt=function(){}),St.prototype.merge=function(t,o){var t=t||{},e=t.el,t=F(t,["el"]);return i({},It,null!=o?o:{},n(n({},t),{el:ot(e)}))},St.prototype.bindOptions=function(t,o){var e,i=this.merge(t,o=void 0===o?{}:o);for(e in i){var n=i[e];this[e]=n}return this},St);function St(){var t=Dt.call(this)||this;return t.el=document.body,t}(t={})[Lt.Pre]=-1,t[Lt.Post]=1;var Nt,_t=t,zt=["destroy","change","sure","clear","toggle","options-update","mode-change"],x=(j(B,Nt=R),B.use=function(o){var e=o.pluginName;return X(e)||nt(e)?h("[ewColorPicker warning]: Plugin Class must specify plugin's name in static property by 'pluginName' field."):B.plugins.some(function(t){return t.name===e||o===t.ctor})||(B.pluginsMap[e]=!0,B.plugins.push({name:e,applyOrder:o.applyOrder,ctor:o})),B},B.prototype.normalizeOptions=function(t,o){var e,i;return Z(t)||Y(t)?(e=o?(o.el,o=F(o,["el"]),n({el:t},o)):{el:t},this.shouldAutoMount=!0):K(e=t)&&e.el&&(this.shouldAutoMount=!0),(new Et).bindOptions(e,(i={},x.plugins.forEach(function(t){i[t.name]=!0}),i))},B.prototype.init=function(){var t=this;Q(function(){t.plugins={},t._color_picker_uid=t.generateUID(),t.initCoreProperties()})},B.prototype.initCoreProperties=function(){var t,o,e=this.options,i=e.defaultColor,n=e.alphaDirection,e=e.hueDirection;i?(t=i,(null==(o=this.plugins)?void 0:o.ewColorPickerAlpha)?i.startsWith("#")&&(t=m(i)):i.startsWith("rgba")&&(t=gt(i)),o=w(m(this.currentColor=t)||"rgba(255, 0, 0, 1)"),isNaN(o.h)?this.hsvaColor={h:0,s:100,v:100,a:1}:this.hsvaColor=o):(this.currentColor="",this.hsvaColor={h:0,s:0,v:0,a:0}),this.panelWidth=0,this.panelHeight=0,this.panelLeft=0,this.panelTop=0,this.isHueHorizontal="horizontal"===e,this.isAlphaHorizontal="horizontal"===n,this.colorMode=["Hex","RGB","HSV"],this.currentMode="Hex",this.pickerFlag=!1},B.prototype.createMountPoints=function(){var t=this.options.prefix||y,o=l("div"),e=(d(o,{class:"".concat(t,"color-picker"),"data-uid":this._color_picker_uid}),g(this.getContainer(),o),this.wrapper=o,this.wrapper.isEwColorPickerContainer=!0,l("div"));d(e,{class:"".concat(t,"color-picker-panel-container")}),c(e,"".concat(t,"color-picker-panel-container-hidden")),g(o,e),this.mountPoints.set("root",o),this.mountPoints.set("panelContainer",e)},B.prototype.getMountPoint=function(t){if(!this.isDestroyed)return this.mountPoints.get(t)},B.prototype.getContainer=function(){return this.options.el},B.prototype.mount=function(t){return this.isDestroyed||(t=t?ot(t):this.options.el||document.body,this.options.el=t,this.createMountPoints(),this.applyPlugins(),this.notifyHuePluginUpdate(this.hsvaColor.h)),this},B.prototype.reapplyPlugins=function(){Object.values(this.plugins).forEach(function(t){C(t.run)&&t.run()})},B.prototype.showPanel=function(t,o){var e,i,n,r,s=this;this.isDestroyed||(e=this.mountPoints.get("panelContainer"))&&(i=(r=this.options||{}).pickerAnimationTime,n=r.togglePicker,this.currentColor||(r=w(m(this.currentColor=r.defaultColor||"#ff0000")||"rgba(255, 0, 0, 1)"),this.hsvaColor=r,isNaN(r.h))||this.notifyHuePluginUpdate(r.h),((t,o,e)=>{e=1e4<(e=void 0===e?300:e)?1e4:e;var i="";switch(t){case"height":i="slideDown";break;case"opacity":i="fadeIn";break;default:i="show"}return yt[i](o,e)})(t||xt(this),e,o||i||200).then(function(){s.pickerFlag=!0,s.trigger("toggle",!0),C(n)&&n(!0),s.syncAllPlugins(s.currentColor),setTimeout(function(){var t=s.plugins.ewColorPickerPanel;t&&C(t.handleAutoPosition)&&t.handleAutoPosition.call(t),v(document,"mousedown",s._onDocumentClick,{capture:!0})},0)}).catch(function(t){h("[ewColorPicker error]: Failed to show panel: ".concat(t))}))},B.prototype.hidePanel=function(t,o){var e,i,n,r,s,a,l=this;this.isDestroyed||(e=this.mountPoints.get("panelContainer"))&&(n=(i=this.options||{}).pickerAnimationTime,r=i.togglePicker,s=i.autoPanelPosition,a=this.plugins.ewColorPickerBox||!1,((t,o,e)=>{e=1e4<(e=void 0===e?300:e)?1e4:e;var i="";switch(t){case"height":i="slideUp";break;case"opacity":i="fadeOut";break;default:i="hide"}return yt[i](o,e)})(t||xt(this),e,o||n||200).then(function(){l.isDestroyed||(s&&a&&!l.options.appendTo&&u(e,{position:"absolute",left:"0",top:"100%",visibility:"visible"}),l.pickerFlag=!1,l.trigger("toggle",!1),C(r)&&r(!1),P(document,"mousedown",l._onDocumentClick,{capture:!0}))}).catch(function(t){h("[ewColorPicker error]: Failed to hide panel: ".concat(t))}))},B.prototype.generateUID=function(){return"ew-color-picker-".concat(Date.now(),"-").concat(Math.random().toString(36).substring(2,11))},B.prototype.applyPlugins=function(){var i=this,t=W([],B.plugins,!0).sort(function(t,o){var e,i,n=t.applyOrder?_t[t.applyOrder]:0,r=o.applyOrder?_t[o.applyOrder]:0;return n!==r?n-r:(e={},i=0,x.plugins.forEach(function(t){e[t.name]=i++}),((n=e)[t.name]||999)-(n[o.name]||999))});this.checkPluginDependencies(),t.forEach(function(t){var o=t.ctor,e=t.name;Q(function(){C(o)&&(i.plugins[e]=new o(i))},function(t){console.warn("[ewColorPicker warning]: Failed to apply plugin '".concat(e,"': ").concat(t))})})},B.prototype.checkPluginDependencies=function(){var e=this;Object.entries({hue:["ewColorPickerHue"],alpha:["ewColorPickerAlpha"],panel:["ewColorPickerPanel"],input:["ewColorPickerInput"],inputNumber:["ewColorPickerInputNumber"],button:["ewColorPickerButton"],predefine:["ewColorPickerPredefine"],colorMode:["ewColorPickerColorMode"],box:["ewColorPickerBox"],console:["ewColorPickerConsole"]}).forEach(function(t){var o=t[0],t=t[1];e.options[o]&&t.forEach(function(t){B.pluginsMap[t]||h("[ewColorPicker warning]: Plugin '".concat(t,"' is required but not injected. Please use ewColorPicker.use(").concat(t,") to register the plugin."))})}),this.checkSpecificFeatureDependencies()},B.prototype.checkSpecificFeatureDependencies=function(){this.options.hueDirection&&!B.pluginsMap.ewColorPickerHue&&h("[ewColorPicker warning]: hueDirection is configured but ewColorPickerHue plugin is not injected. Please use ewColorPicker.use(HuePlugin) to register the plugin."),this.options.alphaDirection&&!B.pluginsMap.ewColorPickerAlpha&&h("[ewColorPicker warning]: alphaDirection is configured but ewColorPickerAlpha plugin is not injected. Please use ewColorPicker.use(AlphaPlugin) to register the plugin."),this.options.predefineColor&&0<this.options.predefineColor.length&&!B.pluginsMap.ewColorPickerPredefine&&h("[ewColorPicker warning]: predefineColor is configured but ewColorPickerPredefine plugin is not injected. Please use ewColorPicker.use(PredefinePlugin) to register the plugin."),B.pluginsMap.ewColorPickerColorMode&&!B.pluginsMap.ewColorPickerInputNumber&&h("[ewColorPicker warning]: Color mode plugin requires InputNumber plugin. color-mode plugin requires InputNumber plugin. Please use ewColorPicker.use(InputNumberPlugin) to register the plugin."),B.pluginsMap.ewColorPickerPanel||h("[ewColorPicker warning]: Panel plugin is required as core plugin but not injected. Please use ewColorPicker.use(PanelPlugin) to register the plugin.")},B.prototype.syncAllPlugins=function(o){Object.values(this.plugins).forEach(function(t){C(t.syncColor)&&t.syncColor(o)})},B.prototype.updateOptions=function(t){this.isDestroyed||(this.options=i({},this.options,t),t=(this.options||{}).defaultColor,X(t)||(m(t)?this.setColor(t):h("[ewColorPicker warning]: Invalid defaultColor '".concat(t,"', keep current color unchanged."))),this.reapplyPlugins(),this.trigger("options-update",this.options))},B.prototype.openPicker=function(){this.showPanel()},B.prototype.closePicker=function(){this.hidePanel()},B.prototype.destroy=function(){var t=this;this.isDestroyed||(this.isDestroyed=!0,P(document,"mousedown",this._onDocumentClick,{capture:!0}),this.plugins&&Object.values(this.plugins).forEach(function(t){Q(function(){C(null==t?void 0:t.destroy)&&t.destroy()})}),this.mountPoints.forEach(function(t){Q(function(){r(t)})}),this.mountPoints.clear(),Q(function(){r(t.wrapper)}),this.plugins={},this.trigger("destroy"))},B.prototype.setColor=function(t){var o;(this.currentColor=t)&&(o=m(t),this.hsvaColor=o?w(o):{h:0,s:100,v:100,a:1}),this.trigger("change",t),C(null==(o=this.options)?void 0:o.changeColor)&&this.options.changeColor(t)},B.prototype.getColor=function(){return this.currentColor},B.prototype.getHsvaColor=function(){return n({},this.hsvaColor)},B.prototype.setHsvaColor=function(t){this.hsvaColor=n({},t)},B.prototype.getDestroyedStatus=function(){return this.isDestroyed},B.prototype.use=function(t){return C(t.install)&&t.install(this),this},B.prototype.emit=function(t){for(var o=[],e=1;e<arguments.length;e++)o[e-1]=arguments[e];this.trigger.apply(this,W([t],o,!1));var i=this.options||{},n=i.clear,r=i.sure,s=i.togglePicker;switch(t){case"clear":C(n)&&n();break;case"sure":C(r)&&r();break;case"toggle":C(s)&&s.apply(void 0,o)}},B.prototype.on=function(t,o,e){return Nt.prototype.on.call(this,t,o,e),this},B.prototype.off=function(t,o){return Nt.prototype.off.call(this,t,o),this},B.prototype.getOptions=function(){return this.options},B.prototype.notifyHuePluginUpdate=function(t){var o=null==(o=this.plugins)?void 0:o.ewColorPickerHue;C(null==o?void 0:o.updateHueThumbPosition)&&o.updateHueThumbPosition(t)},B.plugins=[],B.pluginsMap={},B);function B(t,o){var i=Nt.call(this,zt)||this;return i.mountPoints=new Map,i.isDestroyed=!1,i.shouldAutoMount=!1,i._onDocumentClick=function(t){var o,e;i.isDestroyed||!i.options.isClickOutside||(o=i.mountPoints.get("panelContainer"),e=i.mountPoints.get("root"),t=t.target,o&&o.contains(t))||(o=i.options.prefix||y,(e=null==e?void 0:e.querySelector(".".concat(o,"color-picker-box")))&&e.contains(t))||(e=(o=i.options).togglePickerAnimation,i.hidePanel(e,o.pickerAnimationTime))},i.options=i.normalizeOptions(t,o),i.init(),i.shouldAutoMount&&i.options.el&&Q(function(){i.mount(i.options.el)},function(t){h("[ewColorPicker warning]: Auto mount failed: ".concat(t))}),i}function jt(t,o){var e=void 0===(e=o.boxNoColorIcon)?"":e,i=void 0===(i=o.boxHasColorIcon)?"":i,n=void 0===(n=o.prefix)?y:n,o=(t=>{var o,e;if(t){if(st(t))return o=Vt(null!=(o=t.width)?o:32),e=Vt(null!=(e=t.height)?e:32),.5*Math.min(o,e);if(rt(t))return.5*t;if("string"==typeof t)return Wt[t]||16}return 16})(o.size);return t?i||((t,o,e)=>(void 0===e&&(e=y),o=o&&0<o?' width="'.concat(o,'" height="').concat(o,'"'):"",'<svg t="1717384498630" class="'.concat(e,"color-picker-icon").concat(lt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4234"').concat(o,'><path d="M512 714.666667c-8.533333 0-17.066667-2.133333-23.466667-8.533334l-341.333333-341.333333c-12.8-12.8-12.8-32 0-44.8 12.8-12.8 32-12.8 44.8 0l320 317.866667 317.866667-320c12.8-12.8 32-12.8 44.8 0 12.8 12.8 12.8 32 0 44.8L533.333333 704c-4.266667 8.533333-12.8 10.666667-21.333333 10.666667z" fill="currentColor" p-id="4235"></path></svg>')))("".concat(n,"color-picker-box-arrow-icon"),o,n):e||((t,o,e)=>(void 0===e&&(e=y),o=o&&0<o?' width="'.concat(o,'" height="').concat(o,'"'):"",'<svg t="1690189203554" class="'.concat(e,"color-picker-icon").concat(lt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2272" fill="currentColor"').concat(o,'><path d="M504.224 470.288l207.84-207.84a16 16 0 0 1 22.608 0l11.328 11.328a16 16 0 0 1 0 22.624l-207.84 207.824 207.84 207.84a16 16 0 0 1 0 22.608l-11.328 11.328a16 16 0 0 1-22.624 0l-207.824-207.84-207.84 207.84a16 16 0 0 1-22.608 0l-11.328-11.328a16 16 0 0 1 0-22.624l207.84-207.824-207.84-207.84a16 16 0 0 1 0-22.608l11.328-11.328a16 16 0 0 1 22.624 0l207.824 207.84z" p-id="2273"></path></svg>')))("".concat(n,"color-picker-box-close-icon"),o,n)}var Ft={mini:"20px",small:"24px",normal:"32px",medium:"36px",large:"40px"},Wt={mini:12,small:14,normal:16,medium:18,large:20},Vt=function(t){return!rt(t)&&(t=parseInt("".concat(t)),isNaN(t))?32:t},Lt=(Object.defineProperty(M.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(M.prototype,"hasBox",{get:function(){return this._hasBox},set:function(t){this._hasBox!==t&&((this._hasBox=t)?this.render():this.box&&this.box.parentNode&&(r(this.box),this.box=null))},enumerable:!1,configurable:!0}),M.prototype.enableBox=function(t){this.hasBox=t=void 0===t?!0:t},M.prototype.handleOptions=function(){this.options=i(this.options,this.ewColorPicker.options)},M.prototype.run=function(){this.render()},M.prototype.updateChildren=function(){var t;this.box&&(t=this.ewColorPicker.currentColor,this.hasColor=!!t,this.box.replaceChildren((t=jt(this.hasColor,this.options),document.createRange().createContextualFragment(t))))},M.prototype.destroy=function(){this.box&&(this.unbindHandler(),r(this.box),this.box=null)},M.prototype.update=function(t){void 0===t&&(t=["defaultColor","size","disabled","readonly","className","style"]),this.box?(t.includes("defaultColor")&&(this.updateChildren(),this.setBoxBgColor(this.ewColorPicker.currentColor)),t.includes("size")&&this.setBoxSize(),(t.includes("disabled")||t.includes("readonly")||t.includes("className")||t.includes("style"))&&this.setBoxState()):this.render()},M.prototype.render=function(){var t,o=this.options,e=o.className,o=o.style;this.hasBox&&((t=this.ewColorPicker.getMountPoint("root"))?(this.box=f(".".concat(this.prefix,"color-picker-box"),t),this.box||(this.box=l("div"),c(this.box,"".concat(this.prefix,"color-picker-box")),e&&c(this.box,e),o&&u(this.box,o),g(t,this.box)),this.updateChildren(),this.setBoxSize(),this.setBoxBgColor(this.ewColorPicker.currentColor),this.setBoxState(),this.bindHandler()):h("[ewColorPicker] Root mount point not found"))},M.prototype.setBoxSize=function(){var t,o;this.box&&(t=this.options.size,t=(t=t)?st(t)?{width:t.width?rt(t.width)?"".concat(t.width,"px"):t.width:void 0,height:o=t.height?rt(t.height)?"".concat(t.height,"px"):t.height:void 0,lineHeight:o}:t?(o=void 0,{width:o=rt(t)?"".concat(t,"px"):"string"==typeof t?Ft[t]||t:"32px",height:o,lineHeight:o}):{}:{},0<Object.keys(t).length?u(this.box,t):tt(this.box,["width","height"]))},M.prototype.setBoxBgColor=function(t){var o,e;this.box&&(t&&""!==t.trim()?(o=(o=(o=t)&&m(o))&&(e=wt(o))?.5<.2126*(o=function(t){t=(t*e.a+255*(1-e.a))/255;return t<=.03928?t/12.92:Math.pow((.055+t)/1.055,2.4)})(e.r)+.7152*o(e.g)+.0722*o(e.b)?"#333333":"#ffffff":null,u(this.box,n({backgroundColor:t,transition:"background-color 0.3s"},o?{color:o}:{}))):this.clearBoxBgColor())},M.prototype.clearBoxBgColor=function(){this.box&&tt(this.box,["background-color","transition","color"])},M.prototype.setBoxState=function(){var t,o,e;this.box&&(t=(e=this.options).disabled,o=e.readonly,e=e.className,(t?c:a)(this.box,"is-disabled"),(o?c:a)(this.box,"is-readonly"),e)&&c(this.box,e)},M.prototype.bindHandler=function(){var t,o,e,i,n,r,s,a,l,h=this;this.box&&(t=this.options,o=t.onClick,e=t.onMouseEnter,i=t.onMouseLeave,n=t.disabled,r=t.readonly,s=t.togglePickerAnimation,a=t.pickerAnimationTime,v(this.box,"click",l=function(t){n||r?(t.preventDefault(),t.stopPropagation()):(h.ewColorPicker.pickerFlag?h.ewColorPicker.hidePanel(s,a):h.ewColorPicker.showPanel(s,a),null!=o&&o(h))}),this._handlers.push(function(){return P(h.box,"click",l)}),this.bindMouseEvents(e,i))},M.prototype.setDisabled=function(t){this.box&&(t?c:a)(this.box,"is-disabled")},M.prototype.bindMouseEvents=function(t,o){var e,i,n=this;this.box&&(t&&(v(this.box,"mouseenter",e=function(){return t(n)}),this._handlers.push(function(){return P(n.box,"mouseenter",e)})),o)&&(v(this.box,"mouseleave",i=function(){return o(n)}),this._handlers.push(function(){return P(n.box,"mouseleave",i)}))},M.prototype.unbindHandler=function(){this._handlers.forEach(function(t){return t()}),this._handlers=[]},M.pluginName="ewColorPickerBox",M);function M(t){var o=this;this.ewColorPicker=t,this.options={},this._handlers=[],this._hasBox=!0,this.box=null,this.hasColor=!1,this.handleOptions(),!1===this.options.hasBox&&(this._hasBox=!1),this.ewColorPicker.on&&"function"==typeof this.ewColorPicker.on&&this.ewColorPicker.on("change",function(t){o.setBoxBgColor(t)}),this.run()}Object.defineProperty(H.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),H.prototype.handleOptions=function(){var t;K(null==(t=this.ewColorPicker)?void 0:t.options)&&(this.options=i(this.options,this.ewColorPicker.options),this.isHueHorizontal="horizontal"===this.options.hueDirection,this.isAlphaHorizontal="horizontal"===this.options.alphaDirection)},H.prototype.run=function(){var t=this;!1!==this.options.ewColorPickerPanel&&!1!==this.options.hasPanel&&(this.render(),this.movePanelContainer(),setTimeout(function(){t.bindEvents()},10))},H.prototype.render=function(){var t,o,e,i=this;this.ewColorPicker&&(o=this.ewColorPicker.getMountPoint("panelContainer"))&&(t=f(".".concat(this.prefix,"color-picker-panel"),o),e=285,this.isAlphaHorizontal&&this.isHueHorizontal?e=320:(this.isAlphaHorizontal&&!this.isHueHorizontal||!this.isAlphaHorizontal&&this.isHueHorizontal)&&(e=302),this.panel=l("div"),c(this.panel,"".concat(this.prefix,"color-picker-panel")),c(this.panel,"".concat(this.prefix,"color-picker-panel-dynamic-size")),this.panelWidth=e,this.panelHeight=180,u(this.panel,{"--panel-width":e+"px","--panel-height":this.panelHeight+"px"}),g(o,this.panel,t),this.whitePanel=l("div"),c(this.whitePanel,"".concat(this.prefix,"color-picker-white-panel")),g(this.panel,this.whitePanel),this.blackPanel=l("div"),c(this.blackPanel,"".concat(this.prefix,"color-picker-black-panel")),g(this.panel,this.blackPanel),this.cursor=l("div"),c(this.cursor,"".concat(this.prefix,"color-picker-panel-cursor")),g(this.panel,this.cursor),e=l("div"),c(e,"".concat(this.prefix,"color-picker-bottom-row")),g(o,e),setTimeout(function(){var t;i.calculateContainerSize(),C(null==(t=i.ewColorPicker)?void 0:t.getMountPoint)&&i.handleAutoPosition()},0),this.updateHueBg(),C(null==(t=this.ewColorPicker)?void 0:t.getColor)&&(o=this.ewColorPicker.getColor())?(e=w(o),this.updateCursorPosition(e.s,e.v)):this.updateCursorPosition(100,100))},H.prototype.bindEvents=function(){var o=this;this.panel&&(v(this.panel,"click",function(t){return o.handlePanelClick(t)}),v(this.panel,"mousedown",function(){return o.handlePanelMouseDown()}),v(this.panel,"touchstart",function(t){return o.handlePanelTouchStart(t)}))},H.prototype.handlePanelTouchStart=function(t){var o,e,i=this;this.panel&&!this.options.disabled&&(t.preventDefault(),this.isDragging=!0,o=function(t){i.isDragging&&0<t.touches.length&&i.handlePanelTouchMove(t)},e=function(){i.isDragging=!1,P(document,"touchmove",o),P(document,"touchend",e)},v(document,"touchmove",o),v(document,"touchend",e))},H.prototype.handlePanelTouchMove=function(t){var o,e;this.panel&&this.cursor&&(this.options.disabled||(t.preventDefault(),0<t.touches.length&&(this.panelWidth=this.panel.offsetWidth,this.panelHeight=this.panel.offsetHeight,t=t.touches[0],o=b(this.panel),e=t.clientX-o.left,t=t.clientY-o.top,o=Math.max(0,Math.min(100,e/this.panelWidth*100)),e=Math.max(0,Math.min(100,100*(1-t/this.panelHeight))),this.throttledUpdate(o,e))))},H.prototype.handlePanelClick=function(t){var o,e;this.panel&&this.cursor&&(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(this.panelWidth=this.panel.offsetWidth,this.panelHeight=this.panel.offsetHeight,o=b(this.panel),e=t.clientX-o.left,t=t.clientY-o.top,o=Math.max(0,Math.min(100,e/this.panelWidth*100)),e=Math.max(0,Math.min(100,100*(1-t/this.panelHeight))),this.updateCursorPosition(o,e),this.updateColor(o,e)))},H.prototype.handlePanelMouseDown=function(){var t,o,e=this;this.panel&&!this.options.disabled&&(this.isDragging=!0,t=function(t){e.isDragging&&e.handlePanelDrag(t)},o=function(){e.isDragging=!1,P(document,"mousemove",t),P(document,"mouseup",o)},v(document,"mousemove",t),v(document,"mouseup",o))},H.prototype.handlePanelDrag=function(t){var o,e;this.panel&&this.cursor&&(this.options.disabled||(t.preventDefault(),this.panelWidth=this.panel.offsetWidth,this.panelHeight=this.panel.offsetHeight,o=b(this.panel),e=t.clientX-o.left,t=t.clientY-o.top,o=Math.max(0,Math.min(100,e/this.panelWidth*100)),e=Math.max(0,Math.min(100,100*(1-t/this.panelHeight))),this.throttledUpdate(o,e)))},H.prototype.updateCursorPosition=function(t,o){var e,i,n;this.cursor&&this.panel&&(e=p(this.panel,"display"),i=p(this.panel,"visibility"),"none"!==e)&&"hidden"!==i&&(e=this.panel.offsetWidth,i=this.panel.offsetHeight,0!==e&&0!==i||(e=(n=b(this.panel)).width||this.panelWidth||285,i=n.height||this.panelHeight||180,0!==e&&0!==i)||(e=285,i=180),this.panelWidth=e,this.panelHeight=i,e={x:(n=ht(this.cursor)).offsetWidth/2,y:n.offsetHeight/2},0!==n.offsetWidth&&0!==n.offsetHeight||(e.x=2,e.y=2),i=t/100*this.panelWidth,n=(1-o/100)*this.panelHeight,i=Math.max(e.x,Math.min(i,this.panelWidth-e.x)),n=Math.max(e.y,Math.min(n,this.panelHeight-e.y)),u(this.cursor,{left:"".concat(i,"px"),top:"".concat(n,"px")}))},H.prototype.updateColor=function(t,o){var e=this.options.alpha?"rgba(255,0,0,1)":"#ff0000",i=this.ewColorPicker.getColor(),e=(i&&-1===i.indexOf("NaN")||this.ewColorPicker.setColor(i=e),w(i)),i=(e.s=t,e.v=o,Ct(e));this.ewColorPicker.setColor(i),C(this.ewColorPicker.options.changeColor)&&this.ewColorPicker.options.changeColor(i),this.ewColorPicker.trigger("change",i)},H.prototype.updateHueBg=function(t){if(this.panel){if(void 0===(t=t)){var o=this.ewColorPicker.getColor();if(!o)return;t=w(o).h}o=Ct({h:t,s:100,v:100,a:1});u(this.panel,{background:o})}},H.prototype.calculateContainerSize=function(){var t,o,e,i,n,r,s=this.ewColorPicker.getMountPoint("panelContainer");s&&(n=s.offsetWidth,r=s.offsetHeight,0!==n&&0!==r||(t=s.style.display,o=s.style.visibility,e=s.style.position,u(s,{display:"block",visibility:"hidden",position:"absolute",left:"-9999px",top:"-9999px"}),s.offsetHeight,i=b(s),n=s.offsetWidth||i.width,r=s.offsetHeight||i.height,u(s,{display:t,visibility:o,position:e,left:"",top:""})),this.containerWidth=n||320,this.containerHeight=r||200)},H.prototype.handleAutoPosition=function(){var t,o,e,i,n;this.isPanelAppended?this.updateAppendedPanelPosition():(t=(n=(null==(n=this.ewColorPicker)?void 0:n.options)||{}).autoPanelPosition,o=n.panelPlacement,t&&n.ewColorPickerBox&&(t=this.ewColorPicker.getMountPoint("root"),n=f(".".concat(this.prefix,"color-picker-box"),t),t)&&n&&(this.calculateContainerSize(),i=(n=ht(n)).offsetWidth,n=n.offsetHeight,e=(o=(o||"bottom").split("-"))[0],e=(o=this.calculatePosition(void 0===e?"bottom":e,void 0===(e=o[1])?"center":e,i,n)).left,i=this.adjustForViewport(t,e,o.top),n=this.ewColorPicker.getMountPoint("panelContainer"))&&u(n,{position:"absolute",left:"".concat(i.left,"px"),top:"".concat(i.top,"px")}))},H.prototype.movePanelContainer=function(){var t,o=this.options.appendTo;o&&(t=this.ewColorPicker.getMountPoint("panelContainer"))&&(g(ot(o),t),this.isPanelAppended=!0,this.calculateContainerSize(),v(window,"scroll",this.handleReposition,{capture:!0}),v(window,"resize",this.handleReposition),this.updateAppendedPanelPosition())},H.prototype.updateAppendedPanelPosition=function(){var t,o,e,i,n,r;this.isPanelAppended&&(t=this.ewColorPicker.getMountPoint("panelContainer"),o=this.ewColorPicker.getMountPoint("root"),t)&&o&&(n=(r=ht(f(".".concat(this.prefix,"color-picker-box"),o)||o)).offsetWidth,r=r.offsetHeight,i=(e=(this.options.panelPlacement||"bottom").split("-"))[0],i=(e=this.calculatePosition(void 0===i?"bottom":i,void 0===(i=e[1])?"center":i,n,r)).left,n=this.adjustForViewport(o,i,e.top),r=b(o),u(t,{position:"fixed",left:"".concat(r.left+n.left,"px"),top:"".concat(r.top+n.top,"px")}))},H.prototype.calculatePosition=function(t,o,e,i){e={top:{left:"start"===o?-this.containerWidth:"end"===o?e:(e-this.containerWidth)/2,top:-this.containerHeight-i/2},bottom:{left:"start"===o?-this.containerWidth:"end"===o?e:(e-this.containerWidth)/2,top:i},left:{left:-this.containerWidth-5,top:"start"===o?-this.containerHeight-i/2:"end"===o?i:(i-this.containerHeight)/2},right:{left:e+5,top:"start"===o?-this.containerHeight-i/2:"end"===o?i:(i-this.containerHeight)/2}};return e[t]||e.bottom},H.prototype.adjustForViewport=function(t,o,e){var t=b(t),i=window.innerWidth||document.documentElement.clientWidth,n=window.innerHeight||document.documentElement.clientHeight,r=8-(t.left+o),s=8-(t.top+e),i=t.left+o+this.containerWidth-(i-8),t=t.top+e+this.containerHeight-(n-8);return 0<r&&(o+=r),0<i&&(o-=i),0<s&&(e+=s),0<t&&(e-=t),{left:o,top:e}},H.prototype.destroy=function(){var t;this.panel&&(P(this.panel,"click",this.handlePanelClick),P(this.panel,"mousedown",this.handlePanelMouseDown)),P(window,"scroll",this.handleReposition,{capture:!0}),P(window,"resize",this.handleReposition),C(null==(t=this.ewColorPicker)?void 0:t.off)&&this.ewColorPicker.off("toggle",this.handleToggle),this.panel=null,this.cursor=null,this.whitePanel=null,this.blackPanel=null,this.hueBar=null,this.hueThumb=null,this.alphaBar=null,this.alphaThumb=null,this.hueBg=null},H.prototype.install=function(t){var o=this;this.ewColorPicker=t,this.handleOptions(),C(null==t?void 0:t.on)&&t.on("change",function(t){t=w(t);o.updateCursorPosition(t.s,t.v)}),null!=(t=this.run)&&t.call(this)},H.pluginName="ewColorPickerPanel",H.applyOrder="post";t=H;function H(t){var i=this;this.ewColorPicker=t,this.options={},this.panel=null,this.cursor=null,this.whitePanel=null,this.blackPanel=null,this.hueBar=null,this.hueThumb=null,this.alphaBar=null,this.alphaThumb=null,this.hueBg=null,this.isHueHorizontal=!1,this.isAlphaHorizontal=!1,this.isDragging=!1,this.isPanelAppended=!1,this.handleToggle=function(t){i.isPanelAppended&&t&&i.updateAppendedPanelPosition()},this.handleReposition=function(){i.isPanelAppended&&i.updateAppendedPanelPosition()},this.lastUpdateTime=0,this.throttleDelay=16,this.throttledUpdate=function(t,o){var e=Date.now();e-i.lastUpdateTime>=i.throttleDelay&&(i.lastUpdateTime=e,isNaN(t)||isNaN(o)||t<0||100<t||o<0||100<o||(i.updateCursorPosition(t,o),i.updateColor(t,o)))},this.handleOptions(),C(null==(t=this.ewColorPicker)?void 0:t.on)&&(this.ewColorPicker.on("change",function(t){t&&i.panel&&(t=w(t),i.updateHueBg(t.h),i.updateCursorPosition(t.s,t.v))}),this.ewColorPicker.on("toggle",this.handleToggle)),this.run()}Object.defineProperty(O.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(O.prototype,"hasHue",{get:function(){return this._hasHue},set:function(t){this._hasHue!==t&&((this._hasHue=t)?this.render():this.hueBar&&this.hueBar.parentNode&&(this.hueBar.parentNode.removeChild(this.hueBar),this.hueBar=null))},enumerable:!1,configurable:!0}),O.prototype.enableHue=function(t){this.hasHue=t=void 0===t?!0:t},O.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=i(this.options,this.ewColorPicker.options),this.isHorizontal="horizontal"===this.options.hueDirection)},O.prototype.run=function(){var t=this;this.hasHue&&this.render(),setTimeout(function(){t.bindEvents()},10)},O.prototype.render=function(){var t,o,e,i=this.ewColorPicker.getMountPoint("panelContainer");i?(o=this.prefix,(t=f(".".concat(o,"color-picker-slider.").concat(o,"color-picker-is-vertical, .").concat(o,"color-picker-slider.").concat(o,"color-picker-is-horizontal"),i))&&r(t),t=l("div"),c(t,"".concat(o,"color-picker-slider ")+(this.isHorizontal?"".concat(o,"color-picker-is-horizontal"):"".concat(o,"color-picker-is-vertical"))),this.hueBar=l("div"),c(this.hueBar,"".concat(o,"color-picker-slider-bar")),this.hueThumb=l("div"),c(this.hueThumb,"".concat(o,"color-picker-slider-thumb")),g(this.hueBar,this.hueThumb),g(t,this.hueBar),this.isHorizontal?(e=f(".".concat(o,"color-picker-bottom-row"),i))&&e.parentNode?e.parentNode.insertBefore(t,e):g(i,t):(e=f(".".concat(o,"color-picker-panel"),i))&&e.parentNode?e.parentNode.insertBefore(t,e.nextSibling):g(i,t),(o=this.ewColorPicker.getColor())&&(e=w(o),this.updateHueThumbPosition(e.h))):h("[ewColorPicker] Panel container not found")},O.prototype.bindEvents=function(){this.hueBar&&(v(this.hueBar,"click",this.handleHueSliderClick.bind(this)),v(this.hueBar,"mousedown",this.handleHueSliderMouseDown.bind(this)))},O.prototype.handleHueSliderClick=function(t){var o,e;this.hueBar&&(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(o=b(this.hueBar),t=this.isHorizontal?(e=t.clientX-o.left,Math.max(0,Math.min(360,e/o.width*360))):(e=t.clientY-o.top,Math.max(0,Math.min(360,360*(1-e/o.height)))),this.updateHue(t)))},O.prototype.handleHueSliderMouseDown=function(t){var i,n,o,e,r=this;this.hueBar&&!this.options.disabled&&(i=this.hueBar,n=this.isHorizontal,o=function(t){var o,e=b(i);t=n?(o=t.clientX-e.left,Math.max(0,Math.min(360,o/e.width*360))):(o=t.clientY-e.top,Math.max(0,Math.min(360,360*(1-o/e.height)))),r.throttledUpdateHue(t)},e=function(){P(document,"mousemove",o),P(document,"mouseup",e)},v(document,"mousemove",o),v(document,"mouseup",e))},O.prototype.updateHue=function(t){var o=this.ewColorPicker.getColor(),t=Math.max(0,Math.min(360,t)),o=o?w(o):{h:t,s:100,v:100,a:1},o=(isNaN(o.h)||isNaN(o.s)||isNaN(o.v)||isNaN(o.a)?(o.h=t,o.s=100,o.v=100,o.a=1):o.h=t,Ct(o)),o=(o&&!o.includes("NaN")?this.ewColorPicker.setColor(o):(o=this.ewColorPicker.options.alpha?"rgba(255, 0, 0, 1)":"#ff0000",this.ewColorPicker.setColor(o)),this.updateHueThumbPosition(t),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerPanel);o&&C(o.updateHueBg)&&o.updateHueBg(t)},O.prototype.updateHueThumbPosition=function(t){var o,e;this.hueThumb&&this.hueBar&&(e=this.isHorizontal,o=b(this.hueBar),e?(e=Math.max(0,Math.min(o.width,t/360*o.width)),u(this.hueThumb,"left","".concat(e,"px")),u(this.hueThumb,"top","0px")):(e=Math.max(0,Math.min(o.height,(1-t/360)*o.height)),u(this.hueThumb,"top","".concat(e,"px")),u(this.hueThumb,"left","0px")))},O.prototype.destroy=function(){this.hueBar&&(P(this.hueBar,"click",this.handleHueSliderClick.bind(this)),P(this.hueBar,"mousedown",this.handleHueSliderMouseDown.bind(this))),this.hueBar=null,this.hueThumb=null},O.prototype.install=function(t){var o=this;this.ewColorPicker=t,this.handleOptions(),t.on&&"function"==typeof t.on&&t.on("change",function(t){t=w(t);o.updateHueThumbPosition(t.h)}),null!=(t=this.run)&&t.call(this)},O.pluginName="ewColorPickerHue",O.applyOrder="post";R=O;function O(t){var o=this;this.ewColorPicker=t,this.options={},this.hueBar=null,this.hueThumb=null,this.isHorizontal=!1,this._hasHue=!0,this.handleOptions(),!1===this.options.hue&&(this._hasHue=!1),this.throttledUpdateHue=Bt(this.updateHue.bind(this),16),this.ewColorPicker.on&&"function"==typeof this.ewColorPicker.on&&this.ewColorPicker.on("change",function(t){t&&o.hueThumb&&(t=w(t),o.updateHueThumbPosition(t.h))}),this.run()}Object.defineProperty(T.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"hasAlpha",{get:function(){return this._hasAlpha},set:function(t){this._hasAlpha!==t&&((this._hasAlpha=t)?this.render():this.alphaBar&&this.alphaBar.parentNode&&(this.alphaBar.parentNode.removeChild(this.alphaBar),this.alphaBar=null))},enumerable:!1,configurable:!0}),T.prototype.enableAlpha=function(t){this.hasAlpha=t=void 0===t?!0:t},T.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=i({},this.options,this.ewColorPicker.options),this.isHorizontal="horizontal"===this.options.alphaDirection)},T.prototype.run=function(){var t=this;this.hasAlpha&&this.render(),setTimeout(function(){t.bindEvents()},10)},T.prototype.render=function(){var t,o,e=this.ewColorPicker.getMountPoint("panelContainer");e?((t=f(".".concat(this.prefix,"color-picker-slider.ew-alpha"),e))&&r(t),t=l("div"),c(t,"".concat(this.prefix,"color-picker-slider ew-alpha ")+(this.isHorizontal?"".concat(this.prefix,"color-picker-is-horizontal"):"".concat(this.prefix,"color-picker-is-vertical"))),this.alphaBar=l("div"),c(this.alphaBar,"".concat(this.prefix,"color-picker-alpha-slider-bar")),o=l("div"),c(o,"".concat(this.prefix,"color-picker-alpha-slider-wrapper")),g(this.alphaBar,o),o=l("div"),c(o,"".concat(this.prefix,"color-picker-alpha-slider-bg")),g(this.alphaBar,o),this.alphaThumb=l("div"),c(this.alphaThumb,"".concat(this.prefix,"color-picker-alpha-slider-thumb")),g(this.alphaBar,this.alphaThumb),g(t,this.alphaBar),this.isHorizontal?(o=f(".".concat(this.prefix,"color-picker-bottom-row"),e))&&o.parentNode?o.parentNode.insertBefore(t,o):g(e,t):(o=f(".".concat(this.prefix,"color-picker-panel"),e))&&o.parentNode?o.parentNode.insertBefore(t,o.nextSibling):g(e,t),(o=this.ewColorPicker.getColor())&&(e=w(o),this.updateAlphaThumbPosition(e.a))):h("[ewColorPicker] Panel container not found, please check the ewColorPicker instance!")},T.prototype.bindEvents=function(){var o=this;this.alphaBar&&(v(this.alphaBar,"click",function(t){o.handleAlphaSliderClick(t)}),v(this.alphaBar,"mousedown",function(t){o.handleAlphaSliderMouseDown(t)}))},T.prototype.handleAlphaSliderClick=function(t){var o,e;this.alphaBar&&(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(o=b(this.alphaBar),t=this.isHorizontal?(e=t.clientX-o.left,Math.max(0,Math.min(1,1-e/o.width))):(e=t.clientY-o.top,Math.max(0,Math.min(1,1-e/o.height))),this.updateAlpha(t)))},T.prototype.handleAlphaSliderMouseDown=function(t){var i,n,o,e,r=this;this.alphaBar&&!this.options.disabled&&(i=this.alphaBar,n=this.isHorizontal,o=function(t){var o,e=b(i);t=n?(o=t.clientX-e.left,Math.max(0,Math.min(1,1-o/e.width))):(o=t.clientY-e.top,Math.max(0,Math.min(1,1-o/e.height))),r.throttledUpdateAlpha(t)},e=function(){P(document,"mousemove",o),P(document,"mouseup",e)},v(document,"mousemove",o),v(document,"mouseup",e))},T.prototype.updateAlpha=function(t){var o=this.ewColorPicker.getColor();o&&((o=w(o)).a=t,o=Ct(o),this.ewColorPicker.setColor(o),this.updateAlphaThumbPosition(t),t=null==(t=this.ewColorPicker.plugins)?void 0:t.ewColorPickerColorMode)&&"hex"!==t.currentMode&&t.updateInputValues(o)},T.prototype.updateAlphaThumbPosition=function(t){var o,e;this.alphaThumb&&this.alphaBar&&(e=this.isHorizontal,o=b(this.alphaBar),e?(e=Math.max(0,Math.min(o.width,(1-t)*o.width)),u(this.alphaThumb,"left","".concat(e,"px")),u(this.alphaThumb,"top","0px")):(e=Math.max(0,Math.min(o.height,(1-t)*o.height)),u(this.alphaThumb,"top","".concat(e,"px")),u(this.alphaThumb,"left","0px")))},T.prototype.destroy=function(){this.alphaBar&&(P(this.alphaBar,"click",this.handleAlphaSliderClick.bind(this)),P(this.alphaBar,"mousedown",this.handleAlphaSliderMouseDown.bind(this)),r(this.alphaBar)),this.alphaBar=null,this.alphaThumb=null},T.prototype.install=function(t){var o=this;this.ewColorPicker=t,this.handleOptions(),C(t.on)&&t.on("change",function(t){t=w(t);o.updateAlphaThumbPosition(t.a)}),null!=(t=this.run)&&t.call(this)},T.pluginName="ewColorPickerAlpha",T.applyOrder="post";var Ut=T;function T(t){var o=this;this.ewColorPicker=t,this.options={},this.alphaBar=null,this.alphaThumb=null,this.isHorizontal=!1,this._hasAlpha=!0,this.handleOptions(),!1===this.options.alpha&&(this._hasAlpha=!1),this.throttledUpdateAlpha=Bt(this.updateAlpha.bind(this),16),C(this.ewColorPicker.on)&&this.ewColorPicker.on("change",function(t){t=w(t);o.updateAlphaThumbPosition(t.a)}),this.run()}Object.defineProperty(A.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"hasInput",{get:function(){return this._hasInput},set:function(t){this._hasInput!==t&&((this._hasInput=t)?(this.render(),this.bindEvents()):this.input&&this.input.parentNode&&(r(this.input),this.input=null))},enumerable:!1,configurable:!0}),A.prototype.enableInput=function(t){this.hasInput=t=void 0===t?!0:t},A.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=i(this.options,this.ewColorPicker.options))},A.prototype.updateOptions=function(){this.handleOptions(),this.hasInput?this.render():this.input&&this.input.parentNode&&(r(this.input),this.input=null)},A.prototype.run=function(){this.hasInput&&(this.render(),this.bindEvents())},A.prototype.render=function(){var t,o,e=this.ewColorPicker.getMountPoint("panelContainer");e?(e=f(".".concat(this.prefix,"color-picker-bottom-row"),e))?(o=f(".".concat(this.prefix,"color-picker-drop-btn-group"),e),(t=f(".".concat(this.prefix,"color-picker-input-container"),e))||(t=l("div"),c(t,"".concat(this.prefix,"color-picker-input-container")),c(t,"".concat(this.prefix,"color-picker-input-container-flex")),o&&o.parentNode?o.parentNode.insertBefore(t,o):g(e,t)),this.input=f("input.".concat(this.prefix,"color-picker-input"),t),this.input||(this.input=l("input"),this.input&&(c(this.input,"".concat(this.prefix,"color-picker-input")),d(this.input,{type:"text",name:"".concat(this.prefix,"color-picker-input"),placeholder:"请输入颜色值"}),g(t,this.input))),(o=this.ewColorPicker.getColor())&&-1===o.indexOf("NaN")||(o=this.getDefaultColor(),""===this.ewColorPicker.currentColor?o="":this.ewColorPicker.setColor(o)),e=this.formatColorForDisplay(o),this.input&&(this.input.value=e),this.options.disabled&&this.setDisabled(!0)):h("[ewColorPicker] Bottom row container not found"):h("[ewColorPicker] Panel container not found")},A.prototype.bindEvents=function(){var o=this;this.input&&(v(this.input,"blur",function(t){o.debouncedOnInputColor(t.target.value)}),v(this.input,"keydown",function(t){"Enter"===t.key&&o.debouncedOnInputColor(t.target.value)}),this.ewColorPicker.on("change",function(t){o.update(t)}))},A.prototype.onInputColor=function(t){var o,e,i;t.trim()&&(vt(t)?(i=m(t),this.ewColorPicker.hsvaColor=w(i),this.ewColorPicker.setColor(i),this.syncOtherPlugins(i),C(this.options.changeColor)&&null!=(e=(o=this.options).changeColor)&&e.call(o,i)):h("[ewColorPicker warning]: Invalid color format: ".concat(t)))},A.prototype.syncOtherPlugins=function(t){var o=this.ewColorPicker.hsvaColor,e=null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerColorMode,e=(e&&"hex"!==e.currentMode&&e.updateInputValues(t),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerHue),e=(e&&e.updateHueThumbPosition&&e.updateHueThumbPosition(o.h),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerAlpha),o=(e&&e.updateAlphaThumbPosition&&e.updateAlphaThumbPosition(o.a),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerPanel),o=(o&&o.updatePanelColor&&o.updatePanelColor(t),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerBox);o&&o.setBoxBgColor&&o.setBoxBgColor(t)},A.prototype.setValue=function(t){this.input&&(this.input.value=t)},A.prototype.getValue=function(){return this.input?this.input.value:""},A.prototype.setDisabled=function(t){this.input&&(t?(this.input.disabled=!0,s(this.input,"".concat(this.prefix,"input-disabled"))||c(this.input,"".concat(this.prefix,"input-disabled"))):(this.input.disabled=!1,s(this.input,"".concat(this.prefix,"input-disabled"))&&a(this.input,"".concat(this.prefix,"input-disabled"))))},A.prototype.update=function(t){t&&-1===t.indexOf("NaN")||(t=""===this.ewColorPicker.currentColor?"":this.getDefaultColor());t=this.formatColorForDisplay(t);this.setValue(t)},A.prototype.getDefaultColor=function(){var t;return this.hasAlpha?"rgba(255,0,0,1)":null!=(t=this.ewColorPicker.plugins)&&t.ewColorPickerColorMode?"HSL"===(t=this.ewColorPicker.currentMode||"HSV")?"hsl(0, 100%, 50%)":"RGB"===t?"rgba(255,0,0,1)":"#ff0000":"#ff0000"},A.prototype.formatColorForDisplay=function(t){var o,e;return t?(e=t,!(null==(o=this.ewColorPicker.plugins)||!o.ewColorPickerColorMode)&&(o=this.ewColorPicker.plugins.ewColorPickerColorMode)&&"hex"===o.getCurrentMode()?e&&!e.startsWith("#")&&(o=m(e))&&(o=wt(o))&&(e=Pt(o)):this.hasAlpha&&!t.startsWith("rgba")?e=Ct(w(t)):!this.hasAlpha&&t.startsWith("rgba")&&(e=gt(t)),e):""},A.prototype.destroy=function(){this.input&&(P(this.input,"blur",this.debouncedOnInputColor),P(this.input,"keydown",this.debouncedOnInputColor)),this.input=null},A.prototype.install=function(t){var o=this;this.ewColorPicker=t,this.handleOptions(),C(null==t?void 0:t.on)&&t.on("change",function(t){o.update(t)}),null!=(t=this.run)&&t.call(this)},A.pluginName="ewColorPickerInput",A.applyOrder="post";var $t=A;function A(t){this.ewColorPicker=t,this.options={},this.input=null,this._hasInput=!0,this.handleOptions(),!1===this.options.hasInput&&(this._hasInput=!1),this.debouncedOnInputColor=e(this.onInputColor.bind(this),300),this.run(),this.hasAlpha=!!this.ewColorPicker.plugins.ewColorPickerAlpha}Object.defineProperty(D.prototype,"prefix",{get:function(){return this.options.prefix||y},enumerable:!1,configurable:!0}),D.prototype.createElements=function(){var t=this.prefix,o=(this.container=l("div"),c(this.container,"".concat(t,"input-number")),c(this.container,"".concat(t,"input-number--").concat(this.options.size)),this.input=l("input"),c(this.input,"".concat(t,"input-number__input")),d(this.input,{type:"text",inputmode:"decimal",placeholder:this.options.placeholder}),l("div"));c(o,"".concat(t,"input-number__buttons")),this.upButton=l("button"),c(this.upButton,"".concat(t,"input-number__button")),c(this.upButton,"".concat(t,"input-number__button--up")),d(this.upButton,{type:"button"}),this.upButton.innerHTML=Mt(void 0,void 0,t),this.downButton=l("button"),c(this.downButton,"".concat(t,"input-number__button")),c(this.downButton,"".concat(t,"input-number__button--down")),d(this.downButton,{type:"button"}),this.downButton.innerHTML=Ht(void 0,void 0,t),g(o,this.upButton),g(o,this.downButton),g(this.container,this.input),g(this.container,o),this.setStyles()},D.prototype.setStyles=function(){this.options.disabled&&this.setDisabled(!0)},D.prototype.bindEvents=function(){v(this.input,"input",this.handleInput.bind(this)),v(this.input,"blur",this.handleBlur.bind(this)),v(this.input,"focus",this.handleFocus.bind(this)),v(this.input,"keydown",this.handleKeydown.bind(this)),v(this.upButton,"click",this.handleUpClick.bind(this)),v(this.downButton,"click",this.handleDownClick.bind(this)),v(this.container,"wheel",this.handleWheel.bind(this))},D.prototype.handleInput=function(t){var t=t.target.value;""!==t&&"-"!==t&&"."!==t&&(t=parseFloat(t),isNaN(t)?this.input.value=this.currentValue.toString():this.currentValue=t)},D.prototype.handleBlur=function(t){this.isFocused=!1,this.removeClass(this.container,"".concat(this.prefix,"input-number--focused")),this.updateValue(this.currentValue,!1),this.options.onBlur(this.currentValue)},D.prototype.handleFocus=function(t){this.isFocused=!0,this.addClass(this.container,"".concat(this.prefix,"input-number--focused")),this.options.onFocus(t)},D.prototype.handleKeydown=function(t){switch(t.key){case"ArrowUp":t.preventDefault(),this.increment();break;case"ArrowDown":t.preventDefault(),this.decrement();break;case"Enter":t.preventDefault(),this.input.blur()}},D.prototype.handleUpClick=function(){this.options.disabled||this.increment()},D.prototype.handleDownClick=function(){this.options.disabled||this.decrement()},D.prototype.handleWheel=function(t){this.isFocused&&!this.options.disabled&&(t.preventDefault(),t.deltaY<0?this.increment():this.decrement())},D.prototype.increment=function(){var t=this.currentValue+this.options.step;this.updateValue(t)},D.prototype.decrement=function(){var t=this.currentValue-this.options.step;this.updateValue(t)},D.prototype.updateValue=function(t,o){void 0===o&&(o=!0);var e=this.options.min,i=this.options.max,e=(t<e?t=e:i<t&&(t=i),this.options.precision);t=Math.round(t*Math.pow(10,e))/Math.pow(10,e),this.currentValue=t,this.formatDisplayValue(),o&&this.debouncedOnChange(t)},D.prototype.formatDisplayValue=function(){var t=this.options.precision;this.input.value=this.currentValue.toFixed(t)},D.prototype.addClass=function(t,o){s(t,o)||c(t,o)},D.prototype.removeClass=function(t,o){s(t,o)&&a(t,o)},D.prototype.getValue=function(){return this.currentValue},D.prototype.setValue=function(t){this.updateValue(t)},D.prototype.setDisabled=function(t){(this.options.disabled=t)?(this.addClass(this.container,"".concat(this.prefix,"input-number--disabled")),d(this.input,{disabled:"true"}),d(this.upButton,{disabled:"true"}),d(this.downButton,{disabled:"true"})):(this.removeClass(this.container,"".concat(this.prefix,"input-number--disabled")),d(this.input,{disabled:"false"}),d(this.upButton,{disabled:"false"}),d(this.downButton,{disabled:"false"}))},D.prototype.getElement=function(){return this.container},D.prototype.destroy=function(){var t;P(this.input,"input",this.handleInput.bind(this)),P(this.input,"blur",this.handleBlur.bind(this)),P(this.input,"focus",this.handleFocus.bind(this)),P(this.input,"keydown",this.handleKeydown.bind(this)),P(this.upButton,"click",this.handleUpClick.bind(this)),P(this.downButton,"click",this.handleDownClick.bind(this)),P(this.container,"wheel",this.handleWheel.bind(this)),null!=(t=this.container)&&t.parentNode&&r(this.container),this.container=null,this.input=null,this.upButton=null,this.downButton=null},D.prototype.install=function(t){var o;this.ewColorPicker=t,null!=(o=this.handleOptions)&&o.call(this),!1!==(null==(o=this.ewColorPicker.options)?void 0:o.showInputNumber)&&(C(t.on)&&t.on("change",function(){}),null!=(o=this.run))&&o.call(this)};var Rt=D;function D(t){void 0===t&&(t={});var o={value:0,min:-1/0,max:1/0,step:1,precision:0,disabled:this.isFocused=!1,placeholder:"",size:"default",prefix:y,onChange:function(){},onBlur:function(){},onFocus:function(){}};this.options=i(o,t),this.currentValue=null!=(o=this.options.value)?o:0,this.debouncedOnChange=e(this.options.onChange,300),this.createElements(),this.bindEvents(),this.updateValue(this.currentValue,!1)}I.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),this.run()},I.prototype.updateOptions=function(){var o=this;this.handleOptions(),this.instances.forEach(function(t){X(o.options.disabled)||t.setDisabled(o.options.disabled)})},I.prototype.run=function(){var t,o,e;this.ewColorPicker&&(t=k(this.ewColorPicker),o=this.createInputNumber({value:0,disabled:this.options.disabled||!1,prefix:t}),this.instances.set("default",o),e=this.ewColorPicker.getMountPoint("panelContainer"))&&(e=e.querySelector(".".concat(t,"color-picker-bottom-row")))&&e.appendChild(o.getElement())},I.prototype.handleOptions=function(){var t=null==(t=this.ewColorPicker)?void 0:t.options;t&&(this.options=n(n(n({},this.options),t),{disabled:X(t.disabled)?this.options.disabled||!1:t.disabled}))},I.prototype.createInputNumber=function(t){return new Rt(t)},I.prototype.destroy=function(){this.instances.forEach(function(t){t.destroy()}),this.instances.clear(),this.ewColorPicker=null},I.pluginName="ewColorPickerInputNumber",I.applyOrder="post";var qt=I;function I(t){this.options={},this.instances=new Map,this.ewColorPicker=t,this.handleOptions()}Object.defineProperty(E.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"hasClear",{get:function(){return this._hasClear},set:function(t){this._hasClear!==t&&(this._hasClear=t,this.render())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"hasSure",{get:function(){return this._hasSure},set:function(t){this._hasSure!==t&&(this._hasSure=t,this.render())},enumerable:!1,configurable:!0}),E.prototype.enableClear=function(t){this.hasClear=t=void 0===t?!0:t},E.prototype.enableSure=function(t){this.hasSure=t=void 0===t?!0:t},E.prototype.enableButtons=function(t){this.hasClear=t=void 0===t?!0:t,this.hasSure=t},E.prototype.handleOptions=function(){this.options=i({},this.options,this.ewColorPicker.options)},E.prototype.updateOptions=function(){var t=this;this.handleOptions(),setTimeout(function(){t.render()},0)},E.prototype.run=function(){var t=this;!1!==this.options.showButton&&(this.render(),this.bindEvents(),setTimeout(function(){t.adjustButtonGroupStyle()},0))},E.prototype.render=function(){var t,o=this.ewColorPicker.getMountPoint("panelContainer");o?(o=f(".".concat(this.prefix,"color-picker-bottom-row"),o))?((t=f(".".concat(this.prefix,"color-picker-drop-btn-group"),o))||(t=l("div"),c(t,"".concat(this.prefix,"color-picker-drop-btn-group")),g(o,t)),t.textContent="",this.hasClear&&(this.clearButton=l("button"),c(this.clearButton,"".concat(this.prefix,"color-picker-clear-btn ").concat(this.prefix,"color-picker-drop-btn")),this.setClearText(this.options.clearText||"清空"),g(t,this.clearButton)),this.hasSure&&(this.sureButton=l("button"),c(this.sureButton,"".concat(this.prefix,"color-picker-sure-btn ").concat(this.prefix,"color-picker-drop-btn")),this.setSureText(this.options.sureText||"确认"),g(t,this.sureButton)),this.adjustButtonGroupStyle()):h("[ewColorPicker warning]: Bottom row container not found"):h("[ewColorPicker warning]: Panel container not found")},E.prototype.bindEvents=function(){var t=this;this.clearButton&&v(this.clearButton,"click",function(){t.debouncedOnClearColor()}),this.sureButton&&v(this.sureButton,"click",function(){t.debouncedOnSureColor()}),this.ewColorPicker.on("mode-change",function(){t.adjustButtonGroupStyle()})},E.prototype.onClearColor=function(){var t,o,e;this.ewColorPicker.options.defaultColor?(e=m(o=this.ewColorPicker.options.defaultColor))&&(t=w(e)):(o="",t=void 0),this.ewColorPicker.hsvaColor=t||{h:0,s:100,v:100,a:1},this.ewColorPicker.setColor(o),this.ewColorPicker.syncAllPlugins(o),this.ewColorPicker.hidePanel(),C(this.options.clear)&&null!=(t=(e=this.options).clear)&&t.call(e,this.ewColorPicker),this.ewColorPicker.trigger("clear")},E.prototype.onSureColor=function(){var t,o;C(this.options.sure)&&null!=(o=(t=this.options).sure)&&o.call(t,this.ewColorPicker.currentColor,this.ewColorPicker),this.ewColorPicker.trigger("sure",this.ewColorPicker.currentColor,this.ewColorPicker),this.ewColorPicker.hidePanel()},E.prototype.setClearText=function(t){this.clearButton&&(this.clearButton.textContent=t)},E.prototype.setSureText=function(t){this.sureButton&&(this.sureButton.textContent=t)},E.prototype.setDisabled=function(t){this.clearButton&&d(this.clearButton,{disabled:t.toString()}),this.sureButton&&d(this.sureButton,{disabled:t.toString()})},E.prototype.destroy=function(){this.clearButton&&P(this.clearButton,"click",this.debouncedOnClearColor),this.sureButton&&P(this.sureButton,"click",this.debouncedOnSureColor),this.clearButton=null,this.sureButton=null},E.prototype.adjustButtonGroupStyle=function(){var t,o,e=this.prefix,i=this.ewColorPicker.getMountPoint("panelContainer");i&&(t=f(".".concat(e,"color-picker-bottom-row"),i))&&(o=f(".".concat(e,"color-picker-drop-btn-group"),t))&&(null!==f(".".concat(e,"color-picker-inputs-group"),i)?(c(o,"".concat(e,"color-picker-drop-btn-group-multi")),a(o,"".concat(e,"color-picker-drop-btn-group-single")),c(t,"".concat(e,"color-picker-bottom-row-multi")),a(t,"".concat(e,"color-picker-bottom-row-single"))):(c(o,"".concat(e,"color-picker-drop-btn-group-single")),a(o,"".concat(e,"color-picker-drop-btn-group-multi")),c(t,"".concat(e,"color-picker-bottom-row-single")),a(t,"".concat(e,"color-picker-bottom-row-multi"))))},E.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),null!=(t=this.run)&&t.call(this)},E.pluginName="ewColorPickerButton",E.applyOrder="post";var Gt=E;function E(t){this.ewColorPicker=t,this.options={},this.clearButton=null,this.sureButton=null,this._hasClear=!0,this._hasSure=!0,this.handleOptions(),!1===this.options.hasClear&&(this._hasClear=!1),!1===this.options.hasSure&&(this._hasSure=!1),this.debouncedOnClearColor=e(this.onClearColor.bind(this),100),this.debouncedOnSureColor=e(this.onSureColor.bind(this),100),this.run()}Object.defineProperty(S.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),S.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=i(this.options,this.ewColorPicker.options),this.ewColorPicker.options.ewColorPickerPredefine)&&(this.options=i(this.options,this.ewColorPicker.options.ewColorPickerPredefine))},S.prototype.run=function(){0<this.getValidPredefineColors().length&&(this.render(),this.bindEvents(),this.bindColorChangeEvent())},S.prototype.getValidPredefineColors=function(){var o=this;return this.options.predefineColor&&Array.isArray(this.options.predefineColor)?this.options.predefineColor.filter(function(t){var t=o.parseColorData(t).color;return!(!(t=t)||"string"!=typeof t||!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t)&&!(/^rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)$/.test(t)||/^rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*(0|1|0?\.\d+)\s*\)$/.test(t)||/^hsl\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*\)$/.test(t)||/^hsla\(\s*\d+\s*,\s*\d+%\s*,\s*\d+%\s*,\s*(0|1|0?\.\d+)\s*\)$/.test(t)||"transparent"===t))}):[]},S.prototype.render=function(){var i=this,t=this.ewColorPicker.getMountPoint("panelContainer");t?(this.container=f(".".concat(this.prefix,"color-picker-predefine-container"),t),this.container||(this.container=l("div"),c(this.container,"".concat(this.prefix,"color-picker-predefine-container"))),this.container&&(this.container.textContent="",this.predefineItems=[],this.getValidPredefineColors().forEach(function(t){var t=i.parseColorData(t).color,o=l("div"),e=(c(o,"".concat(i.prefix,"color-picker-predefine-color")),l("div"));c(e,"".concat(i.prefix,"color-picker-predefine-color-item")),u(e,"backgroundColor",t),g(o,e),g(i.container,o),i.predefineItems.push(o)})),this.ensureContainerAtCorrectPosition(t),this.bindToggleEvent(t)):h("[ewColorPicker warning]: Panel container not found")},S.prototype.parseColorData=function(t){return{color:Y(t)?t:t.color,disabled:!!K(t)&&t.disabled}},S.prototype.bindToggleEvent=function(o){var e=this;this.isEventBound&&this.toggleHandler&&(this.ewColorPicker.off("toggle",this.toggleHandler),this.isEventBound=!1),this.toggleHandler=function(t){t&&e.ensureContainerAtCorrectPosition(o)},this.ewColorPicker.on("toggle",this.toggleHandler),this.isEventBound=!0},S.prototype.bindColorChangeEvent=function(){var o=this;this.changeHandler&&this.ewColorPicker.off("change",this.changeHandler),this.changeHandler=function(t){o.updateActivePredefineColor(t)},this.ewColorPicker.on("change",this.changeHandler)},S.prototype.ensureContainerAtCorrectPosition=function(t){var o,e;this.container&&(o=this.prefix,(e=f(".".concat(o,"color-picker-mode-container"),t))?t.insertBefore(this.container,e):(e=f(".".concat(o,"color-picker-bottom-row"),t))?t.insertBefore(this.container,e):(e=f(".".concat(o,"color-picker-panel"),t))&&e.nextSibling?t.insertBefore(this.container,e.nextSibling):t.appendChild(this.container))},S.prototype.bindEvents=function(){var i=this;this.predefineItems.forEach(function(t,o){var o=i.getValidPredefineColors()[o],o=i.parseColorData(o),e=o.color;o.disabled?c(t,"".concat(i.prefix,"color-picker-predefine-color-disabled")):(v(t,"click",function(t){i.debouncedOnPredefineColorClick(t,e)}),v(t,"blur",function(t){a(t.target,"".concat(i.prefix,"color-picker-predefine-color-active"))}))})},S.prototype.onPredefineColorClick=function(t,o){var e,i,n=this.prefix,r=t.target;s(r,"".concat(n,"color-picker-predefine-color"))||(r=r.closest(".".concat(n,"color-picker-predefine-color"))||r),s(r,"".concat(n,"color-picker-predefine-color-disabled"))||(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(c(r,"".concat(n,"color-picker-predefine-color-active")),this.predefineItems.forEach(function(t){t!==r&&a(t,"".concat(n,"color-picker-predefine-color-active"))}),vt(o)?(t=m(o),this.ewColorPicker.hsvaColor=w(t),this.ewColorPicker.setColor(t),C(this.options.changeColor)&&null!=(i=(e=this.options).changeColor)&&i.call(e,t)):h("[ewColorPicker warning]: Invalid predefine color: ".concat(o))))},S.prototype.updatePredefineColors=function(t){this.options.predefineColor=t,this.predefineItems=[],this.render(),this.bindEvents()},S.prototype.setDisabled=function(t,o){this.predefineItems[t]&&(o?c:a)(this.predefineItems[t],"".concat(this.prefix,"color-picker-predefine-color-disabled"))},S.prototype.destroy=function(){var o=this;this.predefineItems.forEach(function(t){P(t,"click",o.debouncedOnPredefineColorClick),P(t,"blur",function(){})}),this.isEventBound&&this.toggleHandler&&(this.ewColorPicker.off("toggle",this.toggleHandler),this.toggleHandler=null,this.isEventBound=!1),this.changeHandler&&(this.ewColorPicker.off("change",this.changeHandler),this.changeHandler=null),this.predefineItems=[],this.container=null},S.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),null!=(t=this.run)&&t.call(this)},S.prototype.updateActivePredefineColor=function(t){var e,i,n=this;t&&(e=m(t),i=this.prefix,this.predefineItems.forEach(function(t,o){o=n.getValidPredefineColors()[o],o=m(n.parseColorData(o).color);(e===o?c:a)(t,"".concat(i,"color-picker-predefine-color-active"))}))},S.pluginName="ewColorPickerPredefine";var Xt=S;function S(t){this.ewColorPicker=t,this.options={},this.predefineItems=[],this.container=null,this.toggleHandler=null,this.changeHandler=null,this.isEventBound=!1,this.handleOptions(),this.debouncedOnPredefineColorClick=e(this.onPredefineColorClick.bind(this),100),this.run()}Object.defineProperty(N.prototype,"prefix",{get:function(){return k(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"hasAlphaPlugin",{get:function(){var t;return!(null==(t=this.ewColorPicker.plugins)||!t.ewColorPickerAlpha)},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"inputPlugin",{get:function(){var t;return null==(t=this.ewColorPicker.plugins)?void 0:t.ewColorPickerInput},enumerable:!1,configurable:!0}),Object.defineProperty(N.prototype,"alphaPlugin",{get:function(){var t;return null==(t=this.ewColorPicker.plugins)?void 0:t.ewColorPickerAlpha},enumerable:!1,configurable:!0}),N.prototype.initializePlugin=function(){function t(){o.handleOptions(),o.run()}var o=this;this.ewColorPicker.plugins?t():setTimeout(t,0)},N.prototype.install=function(o){function t(){var t;e.handleOptions(),o.on&&C(o.on)&&o.on("change",function(t){"hex"!==e.currentMode&&e.updateInputValues(t)}),null!=(t=e.run)&&t.call(e),e.hasAlphaPlugin&&"rgb"===e.currentMode&&e.updateInputStructure()}var e=this;this.ewColorPicker=o;this.ewColorPicker.plugins?t():setTimeout(t,0)},N.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=i({},this.options,this.ewColorPicker.options),void 0!==this.ewColorPicker.options.ewColorPickerColorMode&&(!1===this.ewColorPicker.options.ewColorPickerColorMode?this.options.showColorMode=!1:"object"==typeof this.ewColorPicker.options.ewColorPickerColorMode&&(this.options=i({},this.options,this.ewColorPicker.options.ewColorPickerColorMode))),this.hasAlphaPlugin?this.currentMode=this.options.defaultMode||"rgb":this.currentMode=this.options.defaultMode||"hex")},N.prototype.updateOptions=function(){this.handleOptions(),this.render()},N.prototype.run=function(){this.handleOptions(),!1!==this.options.showColorMode&&(this.render(),this.bindEvents(),this.hasAlphaPlugin&&"rgb"===this.currentMode&&this.updateInputStructure(),this.setupInputPluginListener())},N.prototype.render=function(){var t=this.ewColorPicker.getMountPoint("panelContainer");t?(this.modeContainer=f(".".concat(this.prefix,"color-picker-mode-container"),t),this.modeContainer||this.createModeContainer(t),this.updateModeDisplay()):h("[ewColorPicker] Panel container not found")},N.prototype.createModeContainer=function(t){var o=this.prefix,o=(this.modeContainer=l("div"),c(this.modeContainer,"".concat(o,"color-picker-mode-container")),this.upButton=l("button"),c(this.upButton,"".concat(o,"color-picker-mode-up-btn")),d(this.upButton,{type:"button",title:"上一个模式"}),this.upButton.innerHTML=Mt("",16,o),this.modeText=l("div"),c(this.modeText,"".concat(o,"color-picker-mode-text")),this.downButton=l("button"),c(this.downButton,"".concat(o,"color-picker-mode-down-btn")),d(this.downButton,{type:"button",title:"下一个模式"}),this.downButton.innerHTML=Ht("",16,o),g(this.modeContainer,this.upButton),g(this.modeContainer,this.modeText),g(this.modeContainer,this.downButton),f(".".concat(o,"color-picker-bottom-row"),t));o?g(t,this.modeContainer,void 0,o):g(t,this.modeContainer)},N.prototype.updateModeDisplay=function(){this.modeText&&(this.modeText.textContent=this.getModeDisplayName(this.currentMode))},N.prototype.bindEvents=function(){var t,o=this;this.upButton&&this.downButton&&(v(this.upButton,"click",t=function(){o.options.disabled||o.switchToPreviousMode()}),this.boundEventHandlers.push({element:this.upButton,event:"click",handler:t}),v(this.downButton,"click",t=function(){o.options.disabled||o.switchToNextMode()}),this.boundEventHandlers.push({element:this.downButton,event:"click",handler:t}),this.upButton&&(v(this.upButton,"mouseenter",this.handleUpButtonHover),v(this.upButton,"mouseleave",this.handleUpButtonLeave),this.boundEventHandlers.push({element:this.upButton,event:"mouseenter",handler:this.handleUpButtonHover}),this.boundEventHandlers.push({element:this.upButton,event:"mouseleave",handler:this.handleUpButtonLeave})),this.downButton&&(v(this.downButton,"mouseenter",this.handleDownButtonHover),v(this.downButton,"mouseleave",this.handleDownButtonLeave),this.boundEventHandlers.push({element:this.downButton,event:"mouseenter",handler:this.handleDownButtonHover}),this.boundEventHandlers.push({element:this.downButton,event:"mouseleave",handler:this.handleDownButtonLeave})),this.ewColorPicker.on("change",function(t){"hex"!==o.currentMode&&o.updateInputValues(t)}))},N.prototype.switchToPreviousMode=function(){var t=["hex","rgb","hsl"],o=t.indexOf(this.currentMode);this.debouncedOnModeChange(t[0<o?o-1:t.length-1])},N.prototype.switchToNextMode=function(){var t=["hex","rgb","hsl"],o=t.indexOf(this.currentMode);this.debouncedOnModeChange(t[(o+1)%t.length])},N.prototype.onModeChange=function(t){this.currentMode=t,this.updateModeDisplay(),this.updateInputStructure();var o,e=this.ewColorPicker.getColor();e&&"hex"!==t&&this.updateInputValues(e),C(this.options.changeMode)&&null!=(o=(e=this.options).changeMode)&&o.call(e,t,this.ewColorPicker),this.ewColorPicker.trigger("mode-change",t)},N.prototype.updateInputStructure=function(){var t=this.prefix,o=this.ewColorPicker.getMountPoint("panelContainer");o&&(o=f(".".concat(t,"color-picker-bottom-row"),o))&&(t=f(".".concat(t,"color-picker-input-container"),o))&&(this.inputPlugin&&!this.inputPlugin.hasInput?t.innerHTML="":"hex"===this.currentMode?this.restoreDefaultInput():(t.innerHTML="",this.createInputsForMode(t)))},N.prototype.setupInputPluginListener=function(){},N.prototype.createInputsForMode=function(t){var r,o,s=this,a=this.prefix;(!this.inputPlugin||this.inputPlugin.hasInput)&&(t.innerHTML="",o=[],"rgb"===this.currentMode?o=this.hasAlphaPlugin?["R","G","B","A"]:["R","G","B"]:"hsl"===this.currentMode&&(o=this.hasAlphaPlugin?["H","S","L","A"]:["H","S","L"]),r=l("div"),c(r,"".concat(a,"color-picker-inputs-group")),o.forEach(function(t,o){var e,i=l("div"),n=(c(i,"".concat(a,"color-picker-inputs-col")),l("div"));c(n,"".concat(a,"color-picker-input-label")),n.textContent=t,g(i,n),"rgb"===s.currentMode?(e=new Rt({value:0,min:0,max:3===o?1:255,step:3===o?.01:1,precision:3===o?2:0,placeholder:t,size:"small",prefix:a,onChange:function(){s.debouncedUpdateColorFromRgb()}}).getElement(),c(e,"".concat(a,"color-picker-rgb-").concat(t.toLowerCase(),"-input"))):"hsl"===s.currentMode&&(0===o?e=new Rt({value:0,min:0,max:360,step:1,precision:0,placeholder:t,size:"small",prefix:a,onChange:function(){s.debouncedUpdateColorFromHsl()}}).getElement():3===o&&s.hasAlphaPlugin?e=new Rt({value:0,min:0,max:1,step:.01,precision:2,placeholder:t,size:"small",prefix:a,onChange:function(){s.debouncedUpdateColorFromHsl()}}).getElement():(e=l("input"),d(e,{type:"text",placeholder:t,class:"".concat(a,"color-picker-hsl-").concat(t.toLowerCase(),"-input ").concat(a,"color-picker-input")})),e)&&c(e,"".concat(a,"color-picker-hsl-").concat(t.toLowerCase(),"-input")),e||(e=l("input"),d(e,{type:"text",placeholder:t,class:"".concat(a,"color-picker-default-input")})),g(i,e),g(r,i)}),g(t,r),o=this.ewColorPicker.getColor())&&this.updateInputValues(o)},N.prototype.getInputContainer=function(){var t=this.prefix,o=this.ewColorPicker.getMountPoint("panelContainer");return(o=o&&f(".".concat(t,"color-picker-bottom-row"),o))&&f(".".concat(t,"color-picker-input-container"),o)||document},N.prototype.updateInputValues=function(t){var o,e,i,n,r,s,a;t&&(t=m(t))&&(t=wt(t))&&(o=this.getInputContainer(),e=this.prefix,"rgb"===this.currentMode?(i=f(".".concat(e,"color-picker-rgb-r-input input"),o),n=f(".".concat(e,"color-picker-rgb-g-input input"),o),r=f(".".concat(e,"color-picker-rgb-b-input input"),o),a=f(".".concat(e,"color-picker-rgb-a-input input"),o),i&&(i.value=Math.round(t.r).toString()),n&&(n.value=Math.round(t.g).toString()),r&&(r.value=Math.round(t.b).toString()),a&&(a.value=t.a.toFixed(2))):"hsl"===this.currentMode&&(i=((t,o,e)=>{t/=255,o/=255,e/=255;var i=Math.max(t,o,e),n=Math.min(t,o,e),r=0,s=0,a=(i+n)/2;if(i!==n){var l=i-n,s=.5<a?l/(2-i-n):l/(i+n);switch(i){case t:r=(o-e)/l+(o<e?6:0);break;case o:r=(e-t)/l+2;break;case e:r=(t-o)/l+4}r/=6}return{h:360*r,s:100*s,l:100*a}})(t.r,t.g,t.b),n=f(".".concat(e,"color-picker-hsl-h-input input"),o),r=f(".".concat(e,"color-picker-hsl-s-input"),o),s=f(".".concat(e,"color-picker-hsl-l-input"),o),a=f(".".concat(e,"color-picker-hsl-a-input input"),o),n&&(n.value=Math.round(i.h).toString()),r&&(r.value=Math.round(i.s).toString()+"%"),s&&(s.value=Math.round(i.l).toString()+"%"),a)&&(a.value=t.a.toFixed(2)))},N.prototype.updateColorFromRgbInputs=function(){var t=this.getInputContainer(),o=this.prefix,e=f(".".concat(o,"color-picker-rgb-r-input input"),t),i=f(".".concat(o,"color-picker-rgb-g-input input"),t),n=f(".".concat(o,"color-picker-rgb-b-input input"),t),o=f(".".concat(o,"color-picker-rgb-a-input input"),t);e&&i&&n&&(t=parseInt(e.value)||0,e=parseInt(i.value)||0,i=parseInt(n.value)||0,n=o&&parseFloat(o.value)||1,o="rgba(".concat(t,", ").concat(e,", ").concat(i,", ").concat(n,")"),this.ewColorPicker.setColor(o),this.ewColorPicker.syncAllPlugins(o),this.alphaPlugin)&&this.alphaPlugin.updateAlphaThumbPosition&&this.alphaPlugin.updateAlphaThumbPosition(n)},N.prototype.updateColorFromHslInputs=function(){var t=this.getInputContainer(),o=this.prefix,e=f(".".concat(o,"color-picker-hsl-h-input input"),t),i=f(".".concat(o,"color-picker-hsl-s-input"),t),n=f(".".concat(o,"color-picker-hsl-l-input"),t),o=f(".".concat(o,"color-picker-hsl-a-input input"),t);e&&i&&n&&(t=parseInt(e.value)||0,e=parseInt(i.value.replace("%",""))||0,i=parseInt(n.value.replace("%",""))||0,n=o&&parseFloat(o.value)||1,o="hsla(".concat(t,", ").concat(e,"%, ").concat(i,"%, ").concat(n,")"),this.ewColorPicker.setColor(o),this.ewColorPicker.syncAllPlugins(o),this.alphaPlugin)&&this.alphaPlugin.updateAlphaThumbPosition&&this.alphaPlugin.updateAlphaThumbPosition(n)},N.prototype.getModeDisplayName=function(t){return{hex:"HEX",rgb:"RGB",hsl:"HSL"}[t]||t.toUpperCase()},N.prototype.getCurrentMode=function(){return this.currentMode},N.prototype.setMode=function(t){this.debouncedOnModeChange(t)},N.prototype.restoreDefaultInput=function(){var t,o=this.prefix,e=this.ewColorPicker.getMountPoint("panelContainer");e&&(e=f(".".concat(o,"color-picker-bottom-row"),e))&&(e=f(".".concat(o,"color-picker-input-container"),e))&&(this.inputPlugin&&!this.inputPlugin.hasInput?e.innerHTML="":(e.innerHTML="",c(e,"".concat(o,"color-picker-input-container-flex")),t=l("input"),c(t,"".concat(o,"color-picker-input")),c(t,"".concat(o,"color-picker-input-default")),d(t,{type:"text",name:"".concat(o,"color-picker-input"),placeholder:"请输入颜色值"}),g(e,t),(o=this.ewColorPicker.getColor())&&-1===o.indexOf("NaN")||(o=""),"hex"===this.currentMode&&(e=m(o))&&(e=wt(e))?(e=Pt(e),t.value=e):t.value=o,this.bindDefaultInputEvents(t)))},N.prototype.bindDefaultInputEvents=function(t){this.bindInputEvents(t)},N.prototype.rebindDefaultInputEvents=function(){var t=this.prefix,o=this.ewColorPicker.getMountPoint("panelContainer");o&&(o=f(".".concat(t,"color-picker-bottom-row"),o))&&(o=f(".".concat(t,"color-picker-input-container"),o))&&(t=f(".".concat(t,"color-picker-hex-input"),o))&&this.bindInputEvents(t)},N.prototype.bindInputEvents=function(o){function t(t){vt(t=t.target.value)&&(i.ewColorPicker.setColor(t),i.syncOtherPlugins(t))}function e(t){"Enter"===t.key&&vt(t=t.target.value)&&(i.ewColorPicker.setColor(t),i.syncOtherPlugins(t))}var i=this;v(o,"blur",t),this.boundEventHandlers.push({element:o,event:"blur",handler:t}),v(o,"keydown",e),this.boundEventHandlers.push({element:o,event:"keydown",handler:e});this.ewColorPicker.on("change",function(t){o.value="hex"===i.currentMode?i.toHexDisplay(t):t})},N.prototype.toHexDisplay=function(t){var o;return t?!t.startsWith("#")&&(o=m(t))&&(o=wt(o))?Pt(o):t:""},N.prototype.syncOtherPlugins=function(t){var o=this.ewColorPicker.hsvaColor,e=(this.inputPlugin&&this.inputPlugin.update&&this.inputPlugin.update(t),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerHue),o=(e&&e.updateHueThumbPosition&&e.updateHueThumbPosition(o.h),this.alphaPlugin&&this.alphaPlugin.updateAlphaThumbPosition&&this.alphaPlugin.updateAlphaThumbPosition(o.a),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerPanel),o=(o&&o.updatePanelColor&&o.updatePanelColor(t),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerBox);o&&o.setBoxBgColor&&o.setBoxBgColor(t)},N.prototype.destroy=function(){this.boundEventHandlers.forEach(function(t){var o=t.element;P(o,t.event,t.handler)}),this.boundEventHandlers=[],this.modeContainer&&this.modeContainer.parentNode&&r(this.modeContainer),this.modeContainer=null,this.modeText=null,this.upButton=null,this.downButton=null},N.pluginName="ewColorPickerColorMode",N.applyOrder="post";var Yt=N;function N(t){var o=this;this.ewColorPicker=t,this.options={},this.currentMode="hex",this.modeContainer=null,this.modeText=null,this.upButton=null,this.downButton=null,this.boundEventHandlers=[],this.handleUpButtonHover=function(){o.upButton&&u(o.upButton,{borderColor:"#4096ef",backgroundColor:"#f0f8ff"})},this.handleUpButtonLeave=function(){o.upButton&&u(o.upButton,{borderColor:"#ddd",backgroundColor:"#fff"})},this.handleDownButtonHover=function(){o.downButton&&u(o.downButton,{borderColor:"#4096ef",backgroundColor:"#f0f8ff"})},this.handleDownButtonLeave=function(){o.downButton&&u(o.downButton,{borderColor:"#ddd",backgroundColor:"#fff"})},this.debouncedOnModeChange=e(this.onModeChange.bind(this),100),this.debouncedUpdateColorFromRgb=e(this.updateColorFromRgbInputs.bind(this),100),this.debouncedUpdateColorFromHsl=e(this.updateColorFromHslInputs.bind(this),100),this.initializePlugin()}x.use(G),x.use(Lt),x.use(t),x.use(R),x.use(Ut),x.use($t),x.use(qt),x.use(Gt),x.use(Xt),x.use(Yt),"undefined"!=typeof window&&(window.ewColorPicker=x),_.default=x,_.ewColorPicker=x,Object.defineProperty(_,"__esModule",{value:!0})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ew-color-picker/ew-color-picker",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "EW Color Picker - A modern color picker component with plugin architecture",
5
5
  "main": "dist/index.min.js",
6
6
  "module": "dist/index.esm.js",
@@ -19,25 +19,25 @@
19
19
  "author": "eveningwater(854806732@qq.com)",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@ew-color-picker/core": "^2.0.0",
23
- "@ew-color-picker/utils": "^2.0.0",
24
- "@ew-color-picker/box": "^2.0.0",
25
- "@ew-color-picker/panel": "^2.0.0",
26
- "@ew-color-picker/hue": "^2.0.0",
27
- "@ew-color-picker/alpha": "^2.0.0",
28
- "@ew-color-picker/input": "^2.0.0",
29
- "@ew-color-picker/input-number": "^2.0.0",
30
- "@ew-color-picker/button": "^2.0.0",
31
- "@ew-color-picker/predefine": "^2.0.0",
32
- "@ew-color-picker/style": "^2.0.0",
33
- "@ew-color-picker/color-mode": "^2.0.0"
22
+ "@ew-color-picker/core": "^2.0.2",
23
+ "@ew-color-picker/box": "^2.0.2",
24
+ "@ew-color-picker/alpha": "^2.0.2",
25
+ "@ew-color-picker/utils": "^2.0.2",
26
+ "@ew-color-picker/input": "^2.0.2",
27
+ "@ew-color-picker/hue": "^2.0.2",
28
+ "@ew-color-picker/input-number": "^2.0.2",
29
+ "@ew-color-picker/panel": "^2.0.2",
30
+ "@ew-color-picker/predefine": "^2.0.2",
31
+ "@ew-color-picker/style": "^2.0.2",
32
+ "@ew-color-picker/color-mode": "^2.0.2",
33
+ "@ew-color-picker/button": "^2.0.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "rollup": "^3.0.0",
37
37
  "rollup-plugin-typescript2": "^0.34.0",
38
38
  "typescript": "^4.9.0",
39
39
  "rimraf": "^3.0.2",
40
- "@ew-color-picker/utils": "2.0.1"
40
+ "@ew-color-picker/utils": "2.0.2"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"