@ew-color-picker/ew-color-picker 2.0.4 → 2.0.5

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.
@@ -3,3 +3,8 @@ import type { ewColorPickerConstructorOptions } from "@ew-color-picker/core";
3
3
  export { Core as ewColorPicker };
4
4
  export declare function createEwColorPicker(options?: ewColorPickerConstructorOptions | string | HTMLElement): Core;
5
5
  export default Core;
6
+ declare global {
7
+ interface Window {
8
+ ewColorPicker: typeof Core;
9
+ }
10
+ }
package/dist/index.esm.js CHANGED
@@ -41,8 +41,7 @@ Core.use(Gradient);
41
41
  function createEwColorPicker(options) {
42
42
  return new Core(options);
43
43
  }
44
- // 为UMD构建添加全局变量
45
- if (typeof window !== 'undefined') {
44
+ if (typeof window !== "undefined") {
46
45
  window.ewColorPicker = Core;
47
46
  }
48
47
 
package/dist/index.min.js CHANGED
@@ -1 +1 @@
1
- ((t,e)=>{"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ewColorPicker={})})(this,function(_){var z=function(t,e){return(z=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}))(t,e)};function V(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}z(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var f=function(){return(f=Object.assign||function(t){for(var e,o=1,i=arguments.length;o<i;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};function L(t,e){var o={};for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(o[n[i]]=t[n[i]]);return o}function F(t,s,a,l){return new(a=a||Promise)(function(o,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function n(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?o(t.value):((e=t.value)instanceof a?e:new a(function(t){t(e)})).then(i,n)}r((l=l.apply(t,s||[])).next())})}function j(i,n){var r,s,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return c.next=t(0),c.throw=t(1),c.return=t(2),"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function t(o){return function(t){var e=[o,t];if(r)throw new TypeError("Generator is already executing.");for(;l=c&&e[c=0]?0:l;)try{if(r=1,s&&(a=2&e[0]?s.return:e[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,e[1])).done)return a;switch(s=0,(e=a?[2&e[0],a.value]:e)[0]){case 0:case 1:a=e;break;case 4:return l.label++,{value:e[1],done:!1};case 5:l.label++,s=e[1],e=[0];continue;case 7:e=l.ops.pop(),l.trys.pop();continue;default:if(!(a=0<(a=l.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){l=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3]))l.label=e[1];else if(6===e[0]&&l.label<a[1])l.label=a[1],a=e;else{if(!(a&&l.label<a[2])){a[2]&&l.ops.pop(),l.trys.pop();continue}l.label=a[2],l.ops.push(e)}}e=n.call(i,l)}catch(t){e=[6,t],s=0}finally{r=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}}function R(t,e,o){if(o||2===arguments.length)for(var i,n=0,r=e.length;n<r;n++)!i&&n in e||((i=i||Array.prototype.slice.call(e,0,n))[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}function W(){}var U={log:W,warn:W,error:W},c=(["warn","error","log"].forEach(function(t){U[t]=function(){}}),U.warn),$=U.error,G=U.log,q="undefined"!=typeof window,X=q&&navigator.userAgent.toLowerCase(),Y=(X&&X.match(/(iPhone|iPod|Android|ios)/i),!1);if(q)try{var K={};Object.defineProperty(K,"passive",{get:function(){Y=!0}}),window.addEventListener("test-passive",function(){},K)}catch($){}function Q(t){return void 0===t}function Z(t){return"string"==typeof t}function J(t){return"object"===at.call(t).slice(8,-1).toLowerCase()}function tt(t,e){try{t()}catch(t){b(e)?e(t):$("[ewColorPicker error]: ".concat(t))}}function l(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];if(ct(t))return{};if(Object.assign)return Object.assign.apply(Object,R([t],e,!1));for(var i=Object(t),n=0,r=e.length;n<r;n++){var s=e[n];if(s)for(var a in s)lt.call(s,a)&&(i[a]=s[a])}return i}function h(t){return document.createElement(t)}function et(t,e){return new RegExp("(^|\\s)"+e+"(\\s|$)").test(t.className)}function u(t,e){for(var o=0,i=e.trim().split(/\s+/);o<i.length;o++){var n,r=i[o];r&&!et(t,r)&&((n=t.className.split(" ").filter(Boolean)).push(r),t.className=n.join(" "))}}function s(t,e){et(t,e)&&(e=new RegExp("(^|\\s)"+e+"(\\s|$)","g"),t.className=t.className.replace(e," "))}function ot(t){return t instanceof HTMLElement}function it(t,e,o){e=e.startsWith("--")?e:e.replace(/([A-Z])/g,"-$1").toLowerCase(),t.style.setProperty(e,o)}function p(o,t,e){if(Z(t=void 0===t?{}:t)&&!Q(e)){e=ht(e)?"".concat(e,"px"):e;it(o,t,e)}else if(Array.isArray(t))t.forEach(function(t){var e=t.prop;it(o,e,t.value)});else for(var i=0,n=Object.entries(t);i<n.length;i++){var r=n[i],s=r[0];it(o,s,r[1])}}function nt(t,e){for(var o=0,i=e=void 0===e?[]:e;o<i.length;o++){var n=i[o];t.style.removeProperty(n)}}function rt(e,o,i){var n;return e&&o?("float"===(o=o.replace(/([\:\_\-]+(.))/g,function(t,e,o,i){return i?o.toUpperCase():o}).replace(/^moz([A-Z])/,"Moz$1"))&&(o="cssFloat"),n=null,tt(function(){var t=(document.defaultView||window).getComputedStyle(e,i);n=e.style[o]||t?t[o]:null}),n||e.style[o]):null}function d(t,e){if(ut(e))for(var o=0,i=Object.entries(e);o<i.length;o++){var n=i[o],r=n[0];t.setAttribute(r,"".concat(n[1]))}}function g(t,e){return(e=void 0===e?document:e).querySelector(t)}function n(t){var e;null!=t&&t.parentElement?null!=(e=null==t?void 0:t.parentElement)&&e.removeChild(t):null!=t&&t.remove()}function v(t,e,o,i){i&&null!=t&&t.contains(i)?t.insertBefore(e,i):o&&null!=t&&t.contains(o)?t.replaceChild(e,o):null!=t&&t.appendChild(e)}function st(t){return Z(t)?g(t)||(c("[ewColorPicker warning]: Cannot find element with selector: ".concat(t)),document.body):ot(t)?t:document.body}var at=Object.prototype.toString,lt=Object.prototype.hasOwnProperty,ct=function(t){return null===t},ht=function(t){return"number"==typeof t},b=function(t){return"function"==typeof t},ut=function(t){return"object"==typeof t&&!ct(t)},pt=function(t){return t.replace(/\s+/g,"")},dt=function(t){return t?" ".concat(t):""};function ft(t){return{clientWidth:t.clientWidth,clientHeight:t.clientHeight,offsetWidth:t.offsetWidth,offsetHeight:t.offsetHeight,scrollWidth:t.scrollWidth,scrollHeight:t.scrollHeight}}function a(t){return t.getBoundingClientRect()}function C(t,e,o,i){i=Y?{passive:!1,capture:!!i}:!!i,t.addEventListener(e,o,i)}function m(t,e,o,i){t.removeEventListener(e,o,{capture:!!i})}(X=N=N||{}).Pre="pre",X.Post="post",gt.prototype.on=function(t,e,o){return void 0===o&&(o=this),this.hasType(t),this.events[t]||(this.events[t]=[]),this.events[t].push([e,o]),this},gt.prototype.once=function(i,n,r){var s=this,a=(void 0===r&&(r=this),this.hasType(i),function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];s.off(i,a);var o=n.apply(r,t);if(!0===o)return o});return a.fn=n,this.on(i,a),this},gt.prototype.off=function(t,e){if(!t&&!e)return this.events={},this;if(t){if(this.hasType(t),e){var o=this.events[t];if(o)for(var i=o.length;i--;)(o[i][0]===e||o[i][0]&&o[i][0].fn===e)&&o.splice(i,1)}else this.events[t]=[];return this}},gt.prototype.trigger=function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];this.hasType(t);t=this.events[t];if(t)for(var i=t.length,n=R([],t,!0),r=0;r<i;r++){var s=n[r],a=s[0],s=s[1];if(a&&!0===(a=a.apply(s,e)))return a}},gt.prototype.registerType=function(t){var e=this;t.forEach(function(t){e.eventTypes[t]=t})},gt.prototype.destroy=function(){this.events={},this.eventTypes={}},gt.prototype.hasType=function(t){var e=this.eventTypes;e[t]!==t&&c('[ewColorPicker warning]: EventEmitter has used unknown event type: "'.concat(t,'", should be oneof [')+"".concat(Object.keys(e).map(function(t){return JSON.stringify(t)}))+"]")};q=gt;function gt(t){this.events={},this.eventTypes={},this.registerType(t)}var vt=/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/,bt=/[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,Ct=/^[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}$/,mt=/^[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]*)[\)]$/,yt=/^[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 wt(t){var e,o,i={10:"A",11:"B",12:"C",13:"D",14:"E",15:"F"};return/rgba?/.test(t)?(e=t.replace(/rgba?\(/,"").replace(/\)/,"").replace(/[\s+]/g,"").split(","),o="",e.map(function(t,e){e<=2&&(o+=(e=+t,e=Math.min(Math.round(e),255),t=Math.floor(e/16),""+(i[t]||t)+(i[e%=16]||e)))}),pt("#"+o)):t}function kt(t){var e,o,i,n,r=t.a,s=t.h,a=255*t.s/100,t=255*t.v/100;return 0==a?e=o=i=t:(t=s%60*((n=t)-(a=(255-a)*t/255))/60,360===s?(e=n,o=i=0):s<60?(e=n,o=a+t,i=a):s<120?(e=n-t,o=n,i=a):s<180?(o=n,i=(e=a)+t):s<240?(e=a,o=n-t,i=n):s<300?(e=a+t,o=a,i=n):s<360?(o=a,i=(e=n)-t):e=o=i=0),r=Math.round(10*r)/10,"rgba(".concat(Math.round(e),", ").concat(Math.round(o),", ").concat(Math.round(i),", ").concat(r,")")}function y(t){if(!t||"string"!=typeof t)return{h:0,s:100,v:100,a:1};if(!/^rgba?\(/i.test(t.replace(/\s+/g," ").trim())){var e=w(t);if(!e)return{h:0,s:100,v:100,a:1};t=e}var o,i,n,r,s,a,l,e=t.replace(/\s+/g," ").trim().match(/rgba?\(([^)]+)\)/i);return e?(t=e[1].split(",").map(function(t){return t.trim()}),e=parseFloat(t[0])||0,o=parseFloat(t[1])||0,i=parseFloat(t[2])||0,t=4<=t.length&&parseFloat(t[3])||1,e=e/255,o=o/255,i=i/255,n=(l=Math.max(e,o,i))-Math.min(e,o,i),(s=r=0)!==(a=l)&&(s=n/l),0!=n?(l===e?r=(o-i)/n*60:l===o?r=60*((i-e)/n+2):l===i&&(r=60*((e-o)/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 Pt={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 w(t){if(t&&"string"==typeof t){var e=t.trim().toLowerCase();if(Pt[e])return Pt[e];if(vt.test(e))return((t,e)=>{var e=(e=void 0===e?1:e)||1,e=Math.round(10*e)/10,o=t.toLowerCase(),i=t.length,n=[];if(t&&vt.test(o)){if(4===i){for(var r="#",s=1;s<i;s++){var a=o.slice(s,s+1);r+=a.concat(a)}o=r}for(var l=1,c=o.length;l<c;l+=2)n.push(parseInt("0X"+o.slice(l,l+2),16));return"rgba(".concat(n.join(", "),", ").concat(e,")")}return pt(o)})(e).replace(/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*\)/,"rgba($1, $2, $3, $4)");var o=e.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i);if(o)return i=o[1],n=o[2],r=o[3],"rgba(".concat(i,", ").concat(n,", ").concat(r,", 1)");var i,n,r,o=e.match(/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(0|1|0?\.\d+)\s*\)$/i);if(o)return i=o[1],n=o[2],r=o[3],e=o[4],"rgba(".concat(i,", ").concat(n,", ").concat(r,", ").concat(e,")");try{var s=h("div"),a=(p(s,{"background-color":t}),rt(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 xt(t){var e="transparent"===t;if(vt.test(t))return 1;if(bt.test(t)&&!t.includes("rgba"))return 1;if(Ct.test(t))return 1;if(mt.test(t)&&!t.includes("hsla"))return 1;if(yt.test(t))return 1;if(e)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 o=document.createElement("div");return p(o,{"background-color":t}),"rgba(0, 0, 0, 0)"!==rt(o,"backgroundColor")||e}catch(t){}}function Mt(t){function e(t){return Math.round(t).toString(16).padStart(2,"0")}return"#".concat(e(t.r)).concat(e(t.g)).concat(e(t.b))}function Bt(t){try{var e=t.slice(t.indexOf("(")+1,t.lastIndexOf(")")).split(",");return e.length<3?null:{r:parseInt(e[0]),g:parseInt(e[1]),b:parseInt(e[2]),a:e.length<4?1:parseFloat(e[3])}}catch(t){return null}}Ot.prototype.show=function(){var e=this;return new Promise(function(t){p(e.element,{display:"block"}),t()})},Ot.prototype.hide=function(){var e=this;return new Promise(function(t){p(e.element,{display:"none"}),t()})},Ot.prototype.slideDown=function(){var n=this;return new Promise(function(t){p(n.element,{display:"block",visibility:"hidden"});var e=rt(n.element,"marginTop"),o=rt(n.element,"marginBottom"),i=n.element.offsetHeight+parseInt(e)+parseInt(o);p(n.element,{height:"0px",overflow:"hidden",visibility:"visible"}),n.element.offsetHeight,setTimeout(function(){p(n.element,{transition:"height ".concat(n.options.duration,"ms ").concat(n.options.easing),height:"".concat(i,"px")}),setTimeout(function(){p(n.element,{height:"",overflow:"",transition:""}),t()},n.options.duration)},n.options.delay)})},Ot.prototype.slideUp=function(){var i=this;return new Promise(function(t){var e=rt(i.element,"marginTop"),o=rt(i.element,"marginBottom"),e=i.element.offsetHeight+parseInt(e)+parseInt(o);p(i.element,{height:"".concat(e,"px"),overflow:"hidden"}),i.element.offsetHeight,setTimeout(function(){p(i.element,{height:"0px",transition:"height ".concat(i.options.duration,"ms ").concat(i.options.easing)}),setTimeout(function(){p(i.element,{height:"",overflow:"",transition:"",display:"none"}),t()},i.options.duration)},i.options.delay)})},Ot.prototype.fadeIn=function(){var t=this;return new Promise(function(o){function i(t){var t=Math.min((t-s)/r,1),e=1-Math.pow(1-t,3);p(n,{opacity:e.toString()}),t<1?requestAnimationFrame(i):(p(n,{opacity:"1"}),o())}var n=t.element,r=t.options.duration,s=(p(n,{display:"block",opacity:"0"}),n.offsetHeight,performance.now());requestAnimationFrame(i)})},Ot.prototype.fadeOut=function(){var t=this;return new Promise(function(o){function i(t){var t=Math.min((t-s)/r,1),e=Math.pow(t,3);p(n,{opacity:(1-e).toString()}),t<1?requestAnimationFrame(i):(p(n,{display:"none",opacity:"0"}),o())}var n=t.element,r=t.options.duration,s=(p(n,{display:"block",opacity:"1"}),n.offsetHeight,performance.now());requestAnimationFrame(i)})};var It=Ot;function Ot(t,e){void 0===e&&(e={}),this.element=t,this.options=f({duration:300,easing:"ease-out",delay:0},e)}var Ht={show:function(t,e){return new It(t,{duration:e=void 0===e?300:e}).show()},hide:function(t,e){return new It(t,{duration:e=void 0===e?300:e}).hide()},slideDown:function(t,e){return new It(t,{duration:e=void 0===e?300:e}).slideDown()},slideUp:function(t,e){return new It(t,{duration:e=void 0===e?300:e}).slideUp()},fadeIn:function(t,e){return new It(t,{duration:e=void 0===e?300:e}).fadeIn()},fadeOut:function(t,e){return new It(t,{duration:e=void 0===e?300:e}).fadeOut()}};function Tt(t){return(null==(t=t.options)?void 0:t.togglePickerAnimation)||"default"}function St(i,n,r){void 0===r&&(r=!1);var s=null;return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var o=r&&!s;s&&clearTimeout(s),s=setTimeout(function(){s=null,r||i.apply(void 0,t)},n),o&&i.apply(void 0,t)}}function Et(o,i){var n;return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];n||(o.apply(void 0,t),n=!0,setTimeout(function(){return n=!1},i))}}function r(t){return"string"==typeof(t=null==(t=null==t?void 0:t.options)?void 0:t.prefix)?t:k}function Dt(t,e,o){return void 0===o&&(o=k),e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"",'<svg t="1690189203554" class="'.concat(o,"color-picker-icon").concat(dt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2272" fill="currentColor"').concat(e,'><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>')}function Nt(t,e,o){return void 0===o&&(o=k),e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"",'<svg t="1717384498631" class="'.concat(o,"color-picker-icon").concat(dt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4235"').concat(e,'><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 At(t,e,o){return void 0===o&&(o=k),e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"",'<svg t="1717384498632" class="'.concat(o,"color-picker-icon").concat(dt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4236"').concat(e,'><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 k="ew-",_t=["%c ew-color-picker@2.0.4%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"],zt=!1,K=(Vt.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=l(this.options,this.ewColorPicker.options))},Vt.prototype.run=function(){zt||(zt=!0,G.apply(void 0,_t))},Vt.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),t.on&&b(t.on)&&t.on("change",function(t){}),null!=(t=this.run)&&t.call(this)},Vt.pluginName="ewColorPickerConsole",Vt);function Vt(t){this.ewColorPicker=t,this.options={},this.handleOptions(),this.run()}var Lt,Ft={disabled:!1,predefineColor:[],size:"normal",defaultColor:"",isClickOutside:!0,hueDirection:"vertical",alphaDirection:"vertical",clearText:"清空",sureText:"确定",togglePickerAnimation:"default",pickerAnimationTime:200,autoPanelPosition:!1,panelPlacement:"bottom",prefix:k,sure:function(){},clear:function(){},togglePicker:function(){},changeColor:function(){}},jt=(V(Rt,Lt=function(){}),Rt.prototype.merge=function(t,e){var t=t||{},o=t.el,t=L(t,["el"]);return l({},Ft,null!=e?e:{},f(f({},t),{el:st(o)}))},Rt.prototype.bindOptions=function(t,e){var o,i=this.merge(t,e=void 0===e?{}:e);for(o in i){var n=i[o];this[o]=n}return this},Rt);function Rt(){var t=Lt.call(this)||this;return t.el=document.body,t}(X={})[N.Pre]=-1,X[N.Post]=1;var Wt,Ut=X,$t=["destroy","change","sure","clear","toggle","options-update","mode-change"],P=(V(x,Wt=q),x.use=function(e){var o=e.pluginName;return Q(o)||ct(o)?c("[ewColorPicker warning]: Plugin Class must specify plugin's name in static property by 'pluginName' field."):x.plugins.some(function(t){return t.name===o||e===t.ctor})||(x.pluginsMap[o]=!0,x.plugins.push({name:o,applyOrder:e.applyOrder,ctor:e})),x},x.prototype.normalizeOptions=function(t,e){var o,i;return ot(t)||Z(t)?(o=e?(e.el,e=L(e,["el"]),f({el:t},e)):{el:t},this.shouldAutoMount=!0):J(o=t)&&o.el&&(this.shouldAutoMount=!0),(new jt).bindOptions(o,(i={},P.plugins.forEach(function(t){i[t.name]=!0}),i))},x.prototype.init=function(){var t=this;tt(function(){t.plugins={},t._color_picker_uid=t.generateUID(),t.initCoreProperties()})},x.prototype.initCoreProperties=function(){var t,e=this.options,o=e.defaultColor,i=e.alphaDirection,e=e.hueDirection;o?(t=o,!x.pluginsMap.ewColorPickerAlpha&&o.startsWith("rgba")&&(t=wt(o)),o=y(w(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"===i,this.colorMode=["Hex","RGB","HSV"],this.currentMode="Hex",this.pickerFlag=!1},x.prototype.createMountPoints=function(){var t=this.options.prefix||k,e=h("div"),o=(d(e,{class:"".concat(t,"color-picker"),"data-uid":this._color_picker_uid}),v(this.getContainer(),e),this.wrapper=e,this.wrapper.isEwColorPickerContainer=!0,h("div"));d(o,{class:"".concat(t,"color-picker-panel-container")}),u(o,"".concat(t,"color-picker-panel-container-hidden")),v(e,o),this.mountPoints.set("root",e),this.mountPoints.set("panelContainer",o)},x.prototype.getMountPoint=function(t){if(!this.isDestroyed)return this.mountPoints.get(t)},x.prototype.getContainer=function(){return this.options.el},x.prototype.mount=function(t){return this.isDestroyed||(t=t?st(t):this.options.el||document.body,this.options.el=t,this.createMountPoints(),this.applyPlugins(),this.notifyHuePluginUpdate(this.hsvaColor.h)),this},x.prototype.reapplyPlugins=function(){Object.values(this.plugins).forEach(function(t){b(t.run)&&t.run()})},x.prototype.showPanel=function(t,e){var o,i,n,r,s=this;this.isDestroyed||(o=this.mountPoints.get("panelContainer"))&&(i=(r=this.options||{}).pickerAnimationTime,n=r.togglePicker,this.currentColor||(r=y(w(this.currentColor=r.defaultColor||"#ff0000")||"rgba(255, 0, 0, 1)"),this.hsvaColor=r,isNaN(r.h))||this.notifyHuePluginUpdate(r.h),((t,e,o)=>{o=1e4<(o=void 0===o?300:o)?1e4:o;var i="";switch(t){case"height":i="slideDown";break;case"opacity":i="fadeIn";break;default:i="show"}return Ht[i](e,o)})(t||Tt(this),o,e||i||200).then(function(){s.pickerFlag=!0,s.trigger("toggle",!0),b(n)&&n(!0),s.syncAllPlugins(s.currentColor),setTimeout(function(){var t=s.plugins.ewColorPickerPanel;t&&b(t.handleAutoPosition)&&t.handleAutoPosition.call(t),C(document,"mousedown",s._onDocumentClick,{})},0)}).catch(function(t){c("[ewColorPicker error]: Failed to show panel: ".concat(t))}))},x.prototype.hidePanel=function(t,e){var o,i,n,r,s,a,l=this;this.isDestroyed||(o=this.mountPoints.get("panelContainer"))&&(n=(i=this.options||{}).pickerAnimationTime,r=i.togglePicker,s=i.autoPanelPosition,a=this.plugins.ewColorPickerBox||!1,((t,e,o)=>{o=1e4<(o=void 0===o?300:o)?1e4:o;var i="";switch(t){case"height":i="slideUp";break;case"opacity":i="fadeOut";break;default:i="hide"}return Ht[i](e,o)})(t||Tt(this),o,e||n||200).then(function(){l.isDestroyed||(s&&a&&!l.options.appendTo&&p(o,{position:"absolute",left:"0",top:"100%",visibility:"visible"}),l.pickerFlag=!1,l.trigger("toggle",!1),b(r)&&r(!1),m(document,"mousedown",l._onDocumentClick,{}))}).catch(function(t){c("[ewColorPicker error]: Failed to hide panel: ".concat(t))}))},x.prototype.generateUID=function(){return"ew-color-picker-".concat(Date.now(),"-").concat(Math.random().toString(36).substring(2,11))},x.prototype.applyPlugins=function(){var i=this,t=R([],x.plugins,!0).sort(function(t,e){var o,i,n=t.applyOrder?Ut[t.applyOrder]:0,r=e.applyOrder?Ut[e.applyOrder]:0;return n!==r?n-r:(o={},i=0,P.plugins.forEach(function(t){o[t.name]=i++}),((n=o)[t.name]||999)-(n[e.name]||999))});this.checkPluginDependencies(),t.forEach(function(t){var e=t.ctor,o=t.name;tt(function(){b(e)&&(i.plugins[o]=new e(i))},function(t){console.warn("[ewColorPicker warning]: Failed to apply plugin '".concat(o,"': ").concat(t))})})},x.prototype.checkPluginDependencies=function(){var o=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 e=t[0],t=t[1];o.options[e]&&t.forEach(function(t){x.pluginsMap[t]||c("[ewColorPicker warning]: Plugin '".concat(t,"' is required but not injected. Please use ewColorPicker.use(").concat(t,") to register the plugin."))})}),this.checkSpecificFeatureDependencies()},x.prototype.checkSpecificFeatureDependencies=function(){this.options.hueDirection&&!x.pluginsMap.ewColorPickerHue&&c("[ewColorPicker warning]: hueDirection is configured but ewColorPickerHue plugin is not injected. Please use ewColorPicker.use(HuePlugin) to register the plugin."),this.options.alphaDirection&&!x.pluginsMap.ewColorPickerAlpha&&c("[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&&!x.pluginsMap.ewColorPickerPredefine&&c("[ewColorPicker warning]: predefineColor is configured but ewColorPickerPredefine plugin is not injected. Please use ewColorPicker.use(PredefinePlugin) to register the plugin."),x.pluginsMap.ewColorPickerColorMode&&!x.pluginsMap.ewColorPickerInputNumber&&c("[ewColorPicker warning]: Color mode plugin requires InputNumber plugin. color-mode plugin requires InputNumber plugin. Please use ewColorPicker.use(InputNumberPlugin) to register the plugin."),x.pluginsMap.ewColorPickerPanel||c("[ewColorPicker warning]: Panel plugin is required as core plugin but not injected. Please use ewColorPicker.use(PanelPlugin) to register the plugin.")},x.prototype.syncAllPlugins=function(e){Object.values(this.plugins).forEach(function(t){b(t.syncColor)&&t.syncColor(e)})},x.prototype.updateOptions=function(t){this.isDestroyed||(this.options=l({},this.options,t),t=(this.options||{}).defaultColor,Q(t)||(w(t)?this.setColor(t):c("[ewColorPicker warning]: Invalid defaultColor '".concat(t,"', keep current color unchanged."))),this.reapplyPlugins(),this.trigger("options-update",this.options))},x.prototype.openPicker=function(){this.showPanel()},x.prototype.closePicker=function(){this.hidePanel()},x.prototype.destroy=function(){var t=this;this.isDestroyed||(this.isDestroyed=!0,m(document,"mousedown",this._onDocumentClick,{}),this.plugins&&Object.values(this.plugins).forEach(function(t){tt(function(){b(null==t?void 0:t.destroy)&&t.destroy()})}),this.mountPoints.forEach(function(t){tt(function(){n(t)})}),this.mountPoints.clear(),tt(function(){n(t.wrapper)}),this.plugins={},this.trigger("destroy"))},x.prototype.setColor=function(t){var e;(this.currentColor=t)&&(e=w(t),this.hsvaColor=e?y(e):{h:0,s:100,v:100,a:1}),this.trigger("change",t),b(null==(e=this.options)?void 0:e.changeColor)&&this.options.changeColor(t)},x.prototype.getColor=function(){return this.currentColor},x.prototype.getHsvaColor=function(){return f({},this.hsvaColor)},x.prototype.setHsvaColor=function(t){this.hsvaColor=f({},t)},x.prototype.getDestroyedStatus=function(){return this.isDestroyed},x.prototype.use=function(t){return b(t.install)&&t.install(this),this},x.prototype.emit=function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];this.trigger.apply(this,R([t],e,!1));var i=this.options||{},n=i.clear,r=i.sure,s=i.togglePicker;switch(t){case"clear":b(n)&&n();break;case"sure":b(r)&&r();break;case"toggle":b(s)&&s.apply(void 0,e)}},x.prototype.on=function(t,e,o){return Wt.prototype.on.call(this,t,e,o),this},x.prototype.off=function(t,e){return Wt.prototype.off.call(this,t,e),this},x.prototype.getOptions=function(){return this.options},x.prototype.notifyHuePluginUpdate=function(t){var e=null==(e=this.plugins)?void 0:e.ewColorPickerHue;b(null==e?void 0:e.updateHueThumbPosition)&&e.updateHueThumbPosition(t)},x.plugins=[],x.pluginsMap={},x);function x(t,e){var i=Wt.call(this,$t)||this;return i.mountPoints=new Map,i.isDestroyed=!1,i.shouldAutoMount=!1,i._onDocumentClick=function(t){var e,o;i.isDestroyed||!i.options.isClickOutside||(e=i.mountPoints.get("panelContainer"),o=i.mountPoints.get("root"),t=t.target,e&&e.contains(t))||(e=i.options.prefix||k,(o=null==o?void 0:o.querySelector(".".concat(e,"color-picker-box")))&&o.contains(t))||(o=(e=i.options).togglePickerAnimation,i.hidePanel(o,e.pickerAnimationTime))},i.options=i.normalizeOptions(t,e),i.init(),i.shouldAutoMount&&i.options.el&&tt(function(){i.mount(i.options.el)},function(t){c("[ewColorPicker warning]: Auto mount failed: ".concat(t))}),i}function Gt(t,e){var o=void 0===(o=e.boxNoColorIcon)?"":o,i=void 0===(i=e.boxHasColorIcon)?"":i,n=void 0===(n=e.prefix)?k:n,e=(t=>{var e,o;if(t){if(ut(t))return e=Yt(null!=(e=t.width)?e:32),o=Yt(null!=(o=t.height)?o:32),.5*Math.min(e,o);if(ht(t))return.5*t;if("string"==typeof t)return Xt[t]||16}return 16})(e.size);return t?i||((t,e,o)=>(void 0===o&&(o=k),e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"",'<svg t="1717384498630" class="'.concat(o,"color-picker-icon").concat(dt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4234"').concat(e,'><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"),e,n):o||Dt("".concat(n,"color-picker-box-close-icon"),e,n)}var qt={mini:"20px",small:"24px",normal:"32px",medium:"36px",large:"40px"},Xt={mini:12,small:14,normal:16,medium:18,large:20},Yt=function(t){return!ht(t)&&(t=parseInt("".concat(t)),isNaN(t))?32:t},X=(Object.defineProperty(t.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasBox",{get:function(){return this._hasBox},set:function(t){this._hasBox!==t&&((this._hasBox=t)?this.render():this.box&&this.box.parentNode&&(n(this.box),this.box=null))},enumerable:!1,configurable:!0}),t.prototype.enableBox=function(t){this.hasBox=t=void 0===t?!0:t},t.prototype.handleOptions=function(){this.options=l(this.options,this.ewColorPicker.options)},t.prototype.run=function(){this.render()},t.prototype.updateChildren=function(){var t;this.box&&(t=this.ewColorPicker.currentColor,this.hasColor=!!t,this.box.replaceChildren((t=Gt(this.hasColor,this.options),document.createRange().createContextualFragment(t))))},t.prototype.destroy=function(){this.box&&(this.unbindHandler(),n(this.box),this.box=null)},t.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()},t.prototype.render=function(){var t,e=this.options,o=e.className,e=e.style;this.hasBox&&((t=this.ewColorPicker.getMountPoint("root"))?(this.box=g(".".concat(this.prefix,"color-picker-box"),t),this.box||(this.box=h("div"),u(this.box,"".concat(this.prefix,"color-picker-box")),o&&u(this.box,o),e&&p(this.box,e),v(t,this.box)),this.updateChildren(),this.setBoxSize(),this.setBoxBgColor(this.ewColorPicker.currentColor),this.setBoxState(),this.bindHandler()):c("[ewColorPicker] Root mount point not found"))},t.prototype.setBoxSize=function(){var t,e;this.box&&(t=this.options.size,t=(t=t)?ut(t)?{width:t.width?ht(t.width)?"".concat(t.width,"px"):t.width:void 0,height:e=t.height?ht(t.height)?"".concat(t.height,"px"):t.height:void 0,lineHeight:e}:t?(e=void 0,{width:e=ht(t)?"".concat(t,"px"):"string"==typeof t?qt[t]||t:"32px",height:e,lineHeight:e}):{}:{},0<Object.keys(t).length?p(this.box,t):nt(this.box,["width","height"]))},t.prototype.setBoxBgColor=function(t){var e,o;this.box&&(t&&""!==t.trim()?(e=(e=(e=t)&&w(e))&&(o=Bt(e))?.5<.2126*(e=function(t){t=(t*o.a+255*(1-o.a))/255;return t<=.03928?t/12.92:Math.pow((.055+t)/1.055,2.4)})(o.r)+.7152*e(o.g)+.0722*e(o.b)?"#333333":"#ffffff":null,p(this.box,f({backgroundColor:t,transition:"background-color 0.3s"},e?{color:e}:{}))):this.clearBoxBgColor())},t.prototype.clearBoxBgColor=function(){this.box&&nt(this.box,["background-color","transition","color"])},t.prototype.setBoxState=function(){var t,e,o;this.box&&(t=(o=this.options).disabled,e=o.readonly,o=o.className,(t?u:s)(this.box,"is-disabled"),(e?u:s)(this.box,"is-readonly"),o)&&u(this.box,o)},t.prototype.bindHandler=function(){var t,e,o,i,n,r,s,a,l,c=this;this.box&&(t=this.options,e=t.onClick,o=t.onMouseEnter,i=t.onMouseLeave,n=t.disabled,r=t.readonly,s=t.togglePickerAnimation,a=t.pickerAnimationTime,C(this.box,"click",l=function(t){n||r?(t.preventDefault(),t.stopPropagation()):(c.ewColorPicker.pickerFlag?c.ewColorPicker.hidePanel(s,a):c.ewColorPicker.showPanel(s,a),null!=e&&e(c))}),this._handlers.push(function(){return m(c.box,"click",l)}),this.bindMouseEvents(o,i))},t.prototype.setDisabled=function(t){this.box&&(t?u:s)(this.box,"is-disabled")},t.prototype.bindMouseEvents=function(t,e){var o,i,n=this;this.box&&(t&&(C(this.box,"mouseenter",o=function(){return t(n)}),this._handlers.push(function(){return m(n.box,"mouseenter",o)})),e)&&(C(this.box,"mouseleave",i=function(){return e(n)}),this._handlers.push(function(){return m(n.box,"mouseleave",i)}))},t.prototype.unbindHandler=function(){this._handlers.forEach(function(t){return t()}),this._handlers=[]},t.pluginName="ewColorPickerBox",t);function t(t){var e=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){e.setBoxBgColor(t)}),this.run()}Object.defineProperty(e.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),e.prototype.handleOptions=function(){var t;J(null==(t=this.ewColorPicker)?void 0:t.options)&&(this.options=l(this.options,this.ewColorPicker.options),this.isHueHorizontal="horizontal"===this.options.hueDirection,this.isAlphaHorizontal="horizontal"===this.options.alphaDirection)},e.prototype.run=function(){var t=this;!1!==this.options.ewColorPickerPanel&&!1!==this.options.hasPanel&&(this.render(),this.movePanelContainer(),setTimeout(function(){t.bindEvents()},10))},e.prototype.render=function(){var t,e,o,i=this;this.ewColorPicker&&(e=this.ewColorPicker.getMountPoint("panelContainer"))&&(t=g(".".concat(this.prefix,"color-picker-panel"),e),o=285,this.isAlphaHorizontal&&this.isHueHorizontal?o=320:this.isAlphaHorizontal&&!this.isHueHorizontal?o=301:!this.isAlphaHorizontal&&this.isHueHorizontal&&(o=304),this.panel=h("div"),u(this.panel,"".concat(this.prefix,"color-picker-panel")),u(this.panel,"".concat(this.prefix,"color-picker-panel-dynamic-size")),this.panelWidth=o,this.panelHeight=180,p(this.panel,{"--panel-width":o+"px","--panel-height":this.panelHeight+"px"}),v(e,this.panel,t),this.whitePanel=h("div"),u(this.whitePanel,"".concat(this.prefix,"color-picker-white-panel")),v(this.panel,this.whitePanel),this.blackPanel=h("div"),u(this.blackPanel,"".concat(this.prefix,"color-picker-black-panel")),v(this.panel,this.blackPanel),this.cursor=h("div"),u(this.cursor,"".concat(this.prefix,"color-picker-panel-cursor")),v(this.panel,this.cursor),o=h("div"),u(o,"".concat(this.prefix,"color-picker-bottom-row")),v(e,o),setTimeout(function(){var t;i.calculateContainerSize(),b(null==(t=i.ewColorPicker)?void 0:t.getMountPoint)&&i.handleAutoPosition()},0),this.updateHueBg(),b(null==(t=this.ewColorPicker)?void 0:t.getColor)&&(e=this.ewColorPicker.getColor())?(o=y(e),this.updateCursorPosition(o.s,o.v)):this.updateCursorPosition(100,100))},e.prototype.bindEvents=function(){var e=this;this.panel&&(C(this.panel,"click",function(t){return e.handlePanelClick(t)}),C(this.panel,"mousedown",function(){return e.handlePanelMouseDown()}),C(this.panel,"touchstart",function(t){return e.handlePanelTouchStart(t)}))},e.prototype.handlePanelTouchStart=function(t){var e,o,i=this;this.panel&&!this.options.disabled&&(t.preventDefault(),this.isDragging=!0,e=function(t){i.isDragging&&0<t.touches.length&&i.handlePanelTouchMove(t)},o=function(){i.isDragging=!1,m(document,"touchmove",e),m(document,"touchend",o)},C(document,"touchmove",e),C(document,"touchend",o))},e.prototype.handlePanelTouchMove=function(t){var e,o;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],e=a(this.panel),o=t.clientX-e.left,t=t.clientY-e.top,e=Math.max(0,Math.min(100,o/this.panelWidth*100)),o=Math.max(0,Math.min(100,100*(1-t/this.panelHeight))),this.throttledUpdate(e,o))))},e.prototype.handlePanelClick=function(t){var e,o;this.panel&&this.cursor&&(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(this.panelWidth=this.panel.offsetWidth,this.panelHeight=this.panel.offsetHeight,e=a(this.panel),o=t.clientX-e.left,t=t.clientY-e.top,e=Math.max(0,Math.min(100,o/this.panelWidth*100)),o=Math.max(0,Math.min(100,100*(1-t/this.panelHeight))),this.updateCursorPosition(e,o),this.updateColor(e,o)))},e.prototype.handlePanelMouseDown=function(){var t,e,o=this;this.panel&&!this.options.disabled&&(this.isDragging=!0,t=function(t){o.isDragging&&o.handlePanelDrag(t)},e=function(){o.isDragging=!1,m(document,"mousemove",t),m(document,"mouseup",e)},C(document,"mousemove",t),C(document,"mouseup",e))},e.prototype.handlePanelDrag=function(t){var e,o;this.panel&&this.cursor&&(this.options.disabled||(t.preventDefault(),this.panelWidth=this.panel.offsetWidth,this.panelHeight=this.panel.offsetHeight,e=a(this.panel),o=t.clientX-e.left,t=t.clientY-e.top,e=Math.max(0,Math.min(100,o/this.panelWidth*100)),o=Math.max(0,Math.min(100,100*(1-t/this.panelHeight))),this.throttledUpdate(e,o)))},e.prototype.updateCursorPosition=function(t,e){var o,i,n;this.cursor&&this.panel&&(o=rt(this.panel,"display"),i=rt(this.panel,"visibility"),"none"!==o)&&"hidden"!==i&&(o=this.panel.offsetWidth,i=this.panel.offsetHeight,0!==o&&0!==i||(o=(n=a(this.panel)).width||this.panelWidth||285,i=n.height||this.panelHeight||180,0!==o&&0!==i)||(o=285,i=180),this.panelWidth=o,this.panelHeight=i,o={x:(n=ft(this.cursor)).offsetWidth/2,y:n.offsetHeight/2},0!==n.offsetWidth&&0!==n.offsetHeight||(o.x=2,o.y=2),i=t/100*this.panelWidth,n=(1-e/100)*this.panelHeight,i=Math.max(o.x,Math.min(i,this.panelWidth-o.x)),n=Math.max(o.y,Math.min(n,this.panelHeight-o.y)),p(this.cursor,{left:"".concat(i,"px"),top:"".concat(n,"px")}))},e.prototype.updateColor=function(t,e){var o=this.options.alpha?"rgba(255,0,0,1)":"#ff0000",i=this.ewColorPicker.getColor(),o=(i&&-1===i.indexOf("NaN")||this.ewColorPicker.setColor(i=o),y(i)),i=(o.s=t,o.v=e,kt(o));this.ewColorPicker.setColor(i),b(this.ewColorPicker.options.changeColor)&&this.ewColorPicker.options.changeColor(i),this.ewColorPicker.trigger("change",i)},e.prototype.updateHueBg=function(t){if(this.panel){if(void 0===(t=t)){var e=this.ewColorPicker.getColor();if(!e)return;t=y(e).h}e=kt({h:t,s:100,v:100,a:1});p(this.panel,{background:e})}},e.prototype.syncColor=function(t){this.panel&&t&&(t=y(t),isNaN(t.h)||(this.updateHueBg(t.h),this.updateCursorPosition(t.s,t.v)))},e.prototype.calculateContainerSize=function(){var t,e,o,i,n,r,s=this.ewColorPicker.getMountPoint("panelContainer");s&&(n=s.offsetWidth,r=s.offsetHeight,0!==n&&0!==r||(t=s.style.display,e=s.style.visibility,o=s.style.position,p(s,{display:"block",visibility:"hidden",position:"absolute",left:"-9999px",top:"-9999px"}),s.offsetHeight,i=a(s),n=s.offsetWidth||i.width,r=s.offsetHeight||i.height,p(s,{display:t,visibility:e,position:o,left:"",top:""})),this.containerWidth=n||320,this.containerHeight=r||200)},e.prototype.handleAutoPosition=function(){var t,e,o,i,n;this.isPanelAppended?this.updateAppendedPanelPosition():(t=(n=(null==(n=this.ewColorPicker)?void 0:n.options)||{}).autoPanelPosition,e=n.panelPlacement,t&&n.ewColorPickerBox&&(t=this.ewColorPicker.getMountPoint("root"),n=g(".".concat(this.prefix,"color-picker-box"),t),t)&&n&&(this.calculateContainerSize(),i=(n=ft(n)).offsetWidth,n=n.offsetHeight,o=(e=(e||"bottom").split("-"))[0],o=(e=this.calculatePosition(void 0===o?"bottom":o,void 0===(o=e[1])?"center":o,i,n)).left,i=this.adjustForViewport(t,o,e.top),n=this.ewColorPicker.getMountPoint("panelContainer"))&&p(n,{position:"absolute",left:"".concat(i.left,"px"),top:"".concat(i.top,"px")}))},e.prototype.movePanelContainer=function(){var t,e=this.options.appendTo;e&&(t=this.ewColorPicker.getMountPoint("panelContainer"))&&(v(st(e),t),this.isPanelAppended=!0,this.calculateContainerSize(),C(window,"scroll",this.handleReposition,{}),C(window,"resize",this.handleReposition),this.updateAppendedPanelPosition())},e.prototype.updateAppendedPanelPosition=function(){var t,e,o,i,n,r;this.isPanelAppended&&(t=this.ewColorPicker.getMountPoint("panelContainer"),e=this.ewColorPicker.getMountPoint("root"),t)&&e&&(n=(r=ft(g(".".concat(this.prefix,"color-picker-box"),e)||e)).offsetWidth,r=r.offsetHeight,i=(o=(this.options.panelPlacement||"bottom").split("-"))[0],i=(o=this.calculatePosition(void 0===i?"bottom":i,void 0===(i=o[1])?"center":i,n,r)).left,n=this.adjustForViewport(e,i,o.top),r=a(e),p(t,{position:"fixed",left:"".concat(r.left+n.left,"px"),top:"".concat(r.top+n.top,"px")}))},e.prototype.calculatePosition=function(t,e,o,i){o={top:{left:"start"===e?-this.containerWidth:"end"===e?o:(o-this.containerWidth)/2,top:-this.containerHeight-i/2},bottom:{left:"start"===e?-this.containerWidth:"end"===e?o:(o-this.containerWidth)/2,top:i},left:{left:-this.containerWidth-5,top:"start"===e?-this.containerHeight-i/2:"end"===e?i:(i-this.containerHeight)/2},right:{left:o+5,top:"start"===e?-this.containerHeight-i/2:"end"===e?i:(i-this.containerHeight)/2}};return o[t]||o.bottom},e.prototype.adjustForViewport=function(t,e,o){var t=a(t),i=window.innerWidth||document.documentElement.clientWidth,n=window.innerHeight||document.documentElement.clientHeight,r=8-(t.left+e),s=8-(t.top+o),i=t.left+e+this.containerWidth-(i-8),t=t.top+o+this.containerHeight-(n-8);return 0<r&&(e+=r),0<i&&(e-=i),0<s&&(o+=s),0<t&&(o-=t),{left:e,top:o}},e.prototype.destroy=function(){var t;this.panel&&(m(this.panel,"click",this.handlePanelClick),m(this.panel,"mousedown",this.handlePanelMouseDown)),m(window,"scroll",this.handleReposition,{}),m(window,"resize",this.handleReposition),b(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},e.prototype.install=function(t){var e=this;this.ewColorPicker=t,this.handleOptions(),b(null==t?void 0:t.on)&&t.on("change",function(t){t=y(t);e.updateCursorPosition(t.s,t.v)}),null!=(t=this.run)&&t.call(this)},e.pluginName="ewColorPickerPanel",e.applyOrder=N.Post;q=e;function e(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,e){var o=Date.now();o-i.lastUpdateTime>=i.throttleDelay&&(i.lastUpdateTime=o,isNaN(t)||isNaN(e)||t<0||100<t||e<0||100<e||(i.updateCursorPosition(t,e),i.updateColor(t,e)))},this.handleOptions(),b(null==(t=this.ewColorPicker)?void 0:t.on)&&(this.ewColorPicker.on("change",function(t){t&&i.panel&&(t=y(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 r(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=l(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,e,o,i=this.ewColorPicker.getMountPoint("panelContainer");i?(e=this.prefix,(t=g(".".concat(e,"color-picker-slider.").concat(e,"color-picker-is-vertical, .").concat(e,"color-picker-slider.").concat(e,"color-picker-is-horizontal"),i))&&n(t),t=h("div"),u(t,"".concat(e,"color-picker-slider ")+(this.isHorizontal?"".concat(e,"color-picker-is-horizontal"):"".concat(e,"color-picker-is-vertical"))),this.hueBar=h("div"),u(this.hueBar,"".concat(e,"color-picker-slider-bar")),this.hueThumb=h("div"),u(this.hueThumb,"".concat(e,"color-picker-slider-thumb")),v(this.hueBar,this.hueThumb),v(t,this.hueBar),this.isHorizontal?(o=g(".".concat(e,"color-picker-bottom-row"),i))&&o.parentNode?o.parentNode.insertBefore(t,o):v(i,t):(o=g(".".concat(e,"color-picker-panel"),i))&&o.parentNode?o.parentNode.insertBefore(t,o.nextSibling):v(i,t),(e=this.ewColorPicker.getColor())&&(o=y(e),this.updateHueThumbPosition(o.h))):c("[ewColorPicker] Panel container not found")},o.prototype.bindEvents=function(){this.hueBar&&(C(this.hueBar,"click",this.handleHueSliderClick.bind(this)),C(this.hueBar,"mousedown",this.handleHueSliderMouseDown.bind(this)))},o.prototype.handleHueSliderClick=function(t){var e,o;this.hueBar&&(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(e=a(this.hueBar),t=this.isHorizontal?(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)))),this.updateHue(t)))},o.prototype.handleHueSliderMouseDown=function(t){var i,n,e,o,r=this;this.hueBar&&!this.options.disabled&&(i=this.hueBar,n=this.isHorizontal,e=function(t){var e,o=a(i);t=n?(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)))),r.throttledUpdateHue(t)},o=function(){m(document,"mousemove",e),m(document,"mouseup",o)},C(document,"mousemove",e),C(document,"mouseup",o))},o.prototype.updateHue=function(t){var e=this.ewColorPicker.getColor(),t=Math.max(0,Math.min(360,t)),e=e?y(e):{h:t,s:100,v:100,a:1},e=(isNaN(e.h)||isNaN(e.s)||isNaN(e.v)||isNaN(e.a)?(e.h=t,e.s=100,e.v=100,e.a=1):e.h=t,kt(e)),e=(e&&!e.includes("NaN")?this.ewColorPicker.setColor(e):(e=this.ewColorPicker.options.alpha?"rgba(255, 0, 0, 1)":"#ff0000",this.ewColorPicker.setColor(e)),this.updateHueThumbPosition(t),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerPanel);e&&b(e.updateHueBg)&&e.updateHueBg(t)},o.prototype.syncColor=function(t){this.hueThumb&&this.hueBar&&t&&(t=y(t),isNaN(t.h)||this.updateHueThumbPosition(t.h))},o.prototype.updateHueThumbPosition=function(t){var e,o;this.hueThumb&&this.hueBar&&(o=this.isHorizontal,e=a(this.hueBar),o?(o=Math.max(0,Math.min(e.width,t/360*e.width)),p(this.hueThumb,"left","".concat(o,"px")),p(this.hueThumb,"top","0px")):(o=Math.max(0,Math.min(e.height,(1-t/360)*e.height)),p(this.hueThumb,"top","".concat(o,"px")),p(this.hueThumb,"left","0px")))},o.prototype.destroy=function(){this.hueBar&&(m(this.hueBar,"click",this.handleHueSliderClick.bind(this)),m(this.hueBar,"mousedown",this.handleHueSliderMouseDown.bind(this))),this.hueBar=null,this.hueThumb=null},o.prototype.install=function(t){var e=this;this.ewColorPicker=t,this.handleOptions(),t.on&&"function"==typeof t.on&&t.on("change",function(t){t=y(t);e.updateHueThumbPosition(t.h)}),null!=(t=this.run)&&t.call(this)},o.pluginName="ewColorPickerHue",o.applyOrder=N.Post;var Kt=o;function o(t){var e=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=Et(this.updateHue.bind(this),16),this.ewColorPicker.on&&"function"==typeof this.ewColorPicker.on&&this.ewColorPicker.on("change",function(t){t&&e.hueThumb&&(t=y(t),e.updateHueThumbPosition(t.h))}),this.run()}Object.defineProperty(i.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(i.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}),i.prototype.enableAlpha=function(t){this.hasAlpha=t=void 0===t?!0:t},i.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=l({},this.options,this.ewColorPicker.options),this.isHorizontal="horizontal"===this.options.alphaDirection)},i.prototype.run=function(){var t=this;this.hasAlpha&&this.render(),setTimeout(function(){t.bindEvents()},10)},i.prototype.render=function(){var t,e,o=this.ewColorPicker.getMountPoint("panelContainer");o?((t=g(".".concat(this.prefix,"color-picker-slider.ew-alpha"),o))&&n(t),t=h("div"),u(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=h("div"),u(this.alphaBar,"".concat(this.prefix,"color-picker-alpha-slider-bar")),e=h("div"),u(e,"".concat(this.prefix,"color-picker-alpha-slider-wrapper")),v(this.alphaBar,e),e=h("div"),u(e,"".concat(this.prefix,"color-picker-alpha-slider-bg")),v(this.alphaBar,e),this.alphaThumb=h("div"),u(this.alphaThumb,"".concat(this.prefix,"color-picker-alpha-slider-thumb")),v(this.alphaBar,this.alphaThumb),v(t,this.alphaBar),this.isHorizontal?(e=g(".".concat(this.prefix,"color-picker-bottom-row"),o))&&e.parentNode?e.parentNode.insertBefore(t,e):v(o,t):(e=g(".".concat(this.prefix,"color-picker-panel"),o))&&e.parentNode?e.parentNode.insertBefore(t,e.nextSibling):v(o,t),(e=this.ewColorPicker.getColor())&&(o=y(e),this.updateAlphaThumbPosition(o.a))):c("[ewColorPicker] Panel container not found, please check the ewColorPicker instance!")},i.prototype.bindEvents=function(){var e=this;this.alphaBar&&(C(this.alphaBar,"click",function(t){e.handleAlphaSliderClick(t)}),C(this.alphaBar,"mousedown",function(t){e.handleAlphaSliderMouseDown(t)}))},i.prototype.handleAlphaSliderClick=function(t){var e,o;this.alphaBar&&(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(e=a(this.alphaBar),t=this.isHorizontal?(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))),this.updateAlpha(t)))},i.prototype.handleAlphaSliderMouseDown=function(t){var i,n,e,o,r=this;this.alphaBar&&!this.options.disabled&&(i=this.alphaBar,n=this.isHorizontal,e=function(t){var e,o=a(i);t=n?(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))),r.throttledUpdateAlpha(t)},o=function(){m(document,"mousemove",e),m(document,"mouseup",o)},C(document,"mousemove",e),C(document,"mouseup",o))},i.prototype.updateAlpha=function(t){var e=this.ewColorPicker.getColor();e&&((e=y(e)).a=t,e=kt(e),this.ewColorPicker.setColor(e),this.updateAlphaThumbPosition(t),t=null==(t=this.ewColorPicker.plugins)?void 0:t.ewColorPickerColorMode)&&"hex"!==t.currentMode&&t.updateInputValues(e)},i.prototype.syncColor=function(t){this.alphaThumb&&this.alphaBar&&t&&(t=y(t),isNaN(t.a)||this.updateAlphaThumbPosition(t.a))},i.prototype.updateAlphaThumbPosition=function(t){var e,o;this.alphaThumb&&this.alphaBar&&(o=this.isHorizontal,e=a(this.alphaBar),o?(o=Math.max(0,Math.min(e.width,(1-t)*e.width)),p(this.alphaThumb,"left","".concat(o,"px")),p(this.alphaThumb,"top","0px")):(o=Math.max(0,Math.min(e.height,(1-t)*e.height)),p(this.alphaThumb,"top","".concat(o,"px")),p(this.alphaThumb,"left","0px")))},i.prototype.destroy=function(){this.alphaBar&&(m(this.alphaBar,"click",this.handleAlphaSliderClick.bind(this)),m(this.alphaBar,"mousedown",this.handleAlphaSliderMouseDown.bind(this)),n(this.alphaBar)),this.alphaBar=null,this.alphaThumb=null},i.prototype.install=function(t){var e=this;this.ewColorPicker=t,this.handleOptions(),b(t.on)&&t.on("change",function(t){t=y(t);e.updateAlphaThumbPosition(t.a)}),null!=(t=this.run)&&t.call(this)},i.pluginName="ewColorPickerAlpha",i.applyOrder=N.Post;var Qt=i;function i(t){var e=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=Et(this.updateAlpha.bind(this),16),b(this.ewColorPicker.on)&&this.ewColorPicker.on("change",function(t){t=y(t);e.updateAlphaThumbPosition(t.a)}),this.run()}Object.defineProperty(M.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(M.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&&(n(this.input),this.input=null))},enumerable:!1,configurable:!0}),M.prototype.enableInput=function(t){this.hasInput=t=void 0===t?!0:t},M.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=l(this.options,this.ewColorPicker.options))},M.prototype.updateOptions=function(){this.handleOptions(),this.hasInput?this.render():this.input&&this.input.parentNode&&(n(this.input),this.input=null)},M.prototype.run=function(){this.hasInput&&(this.render(),this.bindEvents())},M.prototype.render=function(){var t,e,o=this.ewColorPicker.getMountPoint("panelContainer");o?(o=g(".".concat(this.prefix,"color-picker-bottom-row"),o))?(e=g(".".concat(this.prefix,"color-picker-drop-btn-group"),o),(t=g(".".concat(this.prefix,"color-picker-input-container"),o))||(t=h("div"),u(t,"".concat(this.prefix,"color-picker-input-container")),u(t,"".concat(this.prefix,"color-picker-input-container-flex")),e&&e.parentNode?e.parentNode.insertBefore(t,e):v(o,t)),this.input=g("input.".concat(this.prefix,"color-picker-input"),t),this.input||(this.input=h("input"),this.input&&(u(this.input,"".concat(this.prefix,"color-picker-input")),d(this.input,{type:"text",name:"".concat(this.prefix,"color-picker-input"),placeholder:"请输入颜色值"}),v(t,this.input))),(e=this.ewColorPicker.getColor())&&-1===e.indexOf("NaN")||(e=this.getDefaultColor(),""===this.ewColorPicker.currentColor?e="":this.ewColorPicker.setColor(e)),o=this.formatColorForDisplay(e),this.input&&(this.input.value=o),this.options.disabled&&this.setDisabled(!0)):c("[ewColorPicker] Bottom row container not found"):c("[ewColorPicker] Panel container not found")},M.prototype.bindEvents=function(){var e=this;this.input&&(C(this.input,"blur",function(t){e.debouncedOnInputColor(t.target.value)}),C(this.input,"keydown",function(t){"Enter"===t.key&&e.debouncedOnInputColor(t.target.value)}),this.ewColorPicker.on("change",function(t){e.update(t)}))},M.prototype.onInputColor=function(t){var e,o,i;t.trim()&&(xt(t)?(i=w(t),this.ewColorPicker.hsvaColor=y(i),this.ewColorPicker.setColor(i),this.syncOtherPlugins(i),b(this.options.changeColor)&&null!=(o=(e=this.options).changeColor)&&o.call(e,i)):c("[ewColorPicker warning]: Invalid color format: ".concat(t)))},M.prototype.syncOtherPlugins=function(t){var e=this.ewColorPicker.hsvaColor,o=null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerColorMode,o=(o&&"hex"!==o.currentMode&&o.updateInputValues(t),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerHue),o=(o&&o.updateHueThumbPosition&&o.updateHueThumbPosition(e.h),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerAlpha),e=(o&&o.updateAlphaThumbPosition&&o.updateAlphaThumbPosition(e.a),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerPanel),e=(e&&e.updatePanelColor&&e.updatePanelColor(t),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerBox);e&&e.setBoxBgColor&&e.setBoxBgColor(t)},M.prototype.setValue=function(t){this.input&&(this.input.value=t)},M.prototype.getValue=function(){return this.input?this.input.value:""},M.prototype.setDisabled=function(t){this.input&&(t?(this.input.disabled=!0,et(this.input,"".concat(this.prefix,"input-disabled"))||u(this.input,"".concat(this.prefix,"input-disabled"))):(this.input.disabled=!1,et(this.input,"".concat(this.prefix,"input-disabled"))&&s(this.input,"".concat(this.prefix,"input-disabled"))))},M.prototype.update=function(t){t&&-1===t.indexOf("NaN")||(t=""===this.ewColorPicker.currentColor?"":this.getDefaultColor());t=this.formatColorForDisplay(t);this.setValue(t)},M.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"},M.prototype.formatColorForDisplay=function(t){var e,o;return t?(o=t,!(null==(e=this.ewColorPicker.plugins)||!e.ewColorPickerColorMode)&&(e=this.ewColorPicker.plugins.ewColorPickerColorMode)&&"hex"===e.getCurrentMode()?o&&!o.startsWith("#")&&(e=w(o))&&(e=Bt(e))&&(o=Mt(e)):this.hasAlpha&&!t.startsWith("rgba")?o=kt(y(t)):!this.hasAlpha&&t.startsWith("rgba")&&(o=wt(t)),o):""},M.prototype.destroy=function(){this.input&&(m(this.input,"blur",this.debouncedOnInputColor),m(this.input,"keydown",this.debouncedOnInputColor)),this.input=null},M.prototype.install=function(t){var e=this;this.ewColorPicker=t,this.handleOptions(),b(null==t?void 0:t.on)&&t.on("change",function(t){e.update(t)}),null!=(t=this.run)&&t.call(this)},M.pluginName="ewColorPickerInput",M.applyOrder="post";var Zt=M;function M(t){this.ewColorPicker=t,this.options={},this.input=null,this._hasInput=!0,this.handleOptions(),!1===this.options.hasInput&&(this._hasInput=!1),this.debouncedOnInputColor=St(this.onInputColor.bind(this),300),this.run(),this.hasAlpha=!!this.ewColorPicker.plugins.ewColorPickerAlpha}Object.defineProperty(B.prototype,"prefix",{get:function(){return this.options.prefix||k},enumerable:!1,configurable:!0}),B.prototype.createElements=function(){var t=this.prefix,e=(this.container=h("div"),u(this.container,"".concat(t,"input-number")),u(this.container,"".concat(t,"input-number--").concat(this.options.size)),this.input=h("input"),u(this.input,"".concat(t,"input-number__input")),d(this.input,{type:"text",inputmode:"decimal",placeholder:this.options.placeholder}),h("div"));u(e,"".concat(t,"input-number__buttons")),this.upButton=h("button"),u(this.upButton,"".concat(t,"input-number__button")),u(this.upButton,"".concat(t,"input-number__button--up")),d(this.upButton,{type:"button"}),this.upButton.innerHTML=Nt("".concat(t,"input-number__icon"),void 0,t),this.downButton=h("button"),u(this.downButton,"".concat(t,"input-number__button")),u(this.downButton,"".concat(t,"input-number__button--down")),d(this.downButton,{type:"button"}),this.downButton.innerHTML=At("".concat(t,"input-number__icon"),void 0,t),v(e,this.upButton),v(e,this.downButton),v(this.container,this.input),v(this.container,e),this.setStyles()},B.prototype.setStyles=function(){this.options.disabled&&this.setDisabled(!0)},B.prototype.bindEvents=function(){C(this.input,"input",this.handleInput.bind(this)),C(this.input,"blur",this.handleBlur.bind(this)),C(this.input,"focus",this.handleFocus.bind(this)),C(this.input,"keydown",this.handleKeydown.bind(this)),C(this.upButton,"click",this.handleUpClick.bind(this)),C(this.downButton,"click",this.handleDownClick.bind(this)),C(this.container,"wheel",this.handleWheel.bind(this))},B.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)},B.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)},B.prototype.handleFocus=function(t){this.isFocused=!0,this.addClass(this.container,"".concat(this.prefix,"input-number--focused")),this.options.onFocus(t)},B.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()}},B.prototype.handleUpClick=function(){this.options.disabled||this.increment()},B.prototype.handleDownClick=function(){this.options.disabled||this.decrement()},B.prototype.handleWheel=function(t){this.isFocused&&!this.options.disabled&&(t.preventDefault(),t.deltaY<0?this.increment():this.decrement())},B.prototype.increment=function(){var t=this.currentValue+this.options.step;this.updateValue(t)},B.prototype.decrement=function(){var t=this.currentValue-this.options.step;this.updateValue(t)},B.prototype.updateValue=function(t,e){void 0===e&&(e=!0);var o=this.options.min,i=this.options.max,o=(t<o?t=o:i<t&&(t=i),this.options.precision);t=Math.round(t*Math.pow(10,o))/Math.pow(10,o),this.currentValue=t,this.formatDisplayValue(),e&&this.debouncedOnChange(t)},B.prototype.formatDisplayValue=function(){var t=this.options.precision;this.input.value=this.currentValue.toFixed(t)},B.prototype.addClass=function(t,e){et(t,e)||u(t,e)},B.prototype.removeClass=function(t,e){et(t,e)&&s(t,e)},B.prototype.getValue=function(){return this.currentValue},B.prototype.setValue=function(t,e){this.updateValue(t,e=void 0===e?!0:e)},B.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"}))},B.prototype.getElement=function(){return this.container},B.prototype.destroy=function(){var t;m(this.input,"input",this.handleInput.bind(this)),m(this.input,"blur",this.handleBlur.bind(this)),m(this.input,"focus",this.handleFocus.bind(this)),m(this.input,"keydown",this.handleKeydown.bind(this)),m(this.upButton,"click",this.handleUpClick.bind(this)),m(this.downButton,"click",this.handleDownClick.bind(this)),m(this.container,"wheel",this.handleWheel.bind(this)),null!=(t=this.container)&&t.parentNode&&n(this.container),this.container=null,this.input=null,this.upButton=null,this.downButton=null},B.prototype.install=function(t){var e;this.ewColorPicker=t,null!=(e=this.handleOptions)&&e.call(this),!1!==(null==(e=this.ewColorPicker.options)?void 0:e.showInputNumber)&&(b(t.on)&&t.on("change",function(){}),null!=(e=this.run))&&e.call(this)};var Jt=B;function B(t){void 0===t&&(t={});var e={value:0,min:-1/0,max:1/0,step:1,precision:0,disabled:this.isFocused=!1,placeholder:"",size:"default",prefix:k,onChange:function(){},onBlur:function(){},onFocus:function(){}};this.options=l(e,t),this.currentValue=null!=(e=this.options.value)?e:0,this.debouncedOnChange=St(this.options.onChange,300),this.createElements(),this.bindEvents(),this.updateValue(this.currentValue,!1)}ee.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),this.run()},ee.prototype.updateOptions=function(){var e=this;this.handleOptions(),this.instances.forEach(function(t){Q(e.options.disabled)||t.setDisabled(e.options.disabled)})},ee.prototype.run=function(){var t,e,o;this.ewColorPicker&&(t=r(this.ewColorPicker),e=this.createInputNumber({value:0,disabled:this.options.disabled||!1,prefix:t}),this.instances.set("default",e),o=this.ewColorPicker.getMountPoint("panelContainer"))&&(o=o.querySelector(".".concat(t,"color-picker-bottom-row")))&&o.appendChild(e.getElement())},ee.prototype.handleOptions=function(){var t=null==(t=this.ewColorPicker)?void 0:t.options;t&&(this.options=f(f(f({},this.options),t),{disabled:Q(t.disabled)?this.options.disabled||!1:t.disabled}))},ee.prototype.createInputNumber=function(t){return new Jt(t)},ee.prototype.destroy=function(){this.instances.forEach(function(t){t.destroy()}),this.instances.clear(),this.ewColorPicker=null},ee.pluginName="ewColorPickerInputNumber",ee.applyOrder="post";var te=ee;function ee(t){this.options={},this.instances=new Map,this.ewColorPicker=t,this.handleOptions()}Object.defineProperty(I.prototype,"prefix",{get:function(){return this.options.prefix||k},enumerable:!1,configurable:!0}),I.prototype.createElements=function(){var t=this.prefix,e=(this.container=h("div"),u(this.container,"".concat(t,"select")),u(this.container,"".concat(t,"select--").concat(this.options.size)),this.trigger=h("button"),u(this.trigger,"".concat(t,"select__trigger")),d(this.trigger,{type:"button","aria-haspopup":"listbox","aria-expanded":"false"}),this.valueText=h("span"),u(this.valueText,"".concat(t,"select__value")),this.clearNode=h("span"),u(this.clearNode,"".concat(t,"select__clear")),u(this.clearNode,"".concat(t,"select__clear--hidden")),d(this.clearNode,{role:"button","aria-label":"Clear selection",tabindex:"-1"}),this.clearNode.innerHTML=Dt("".concat(t,"select__clear-icon"),12,t),h("span"));u(e,"".concat(t,"select__arrow")),e.innerHTML=At("".concat(t,"select__arrow-icon"),12,t),v(this.trigger,this.valueText),v(this.trigger,this.clearNode),v(this.trigger,e),this.dropdown=h("div"),u(this.dropdown,"".concat(t,"select__dropdown")),d(this.dropdown,{role:"listbox"}),v(this.container,this.trigger),v(this.container,this.dropdown),this.options.disabled&&this.setDisabled(!0)},I.prototype.renderOptions=function(){var i,n=this;this.dropdown&&(this.dropdown.textContent="",this.optionNodes=[],i=this.prefix,this.items.forEach(function(t,e){var o=h("div");u(o,"".concat(i,"select__option")),d(o,{role:"option","data-select-index":String(e)}),o.textContent=t.label,t.disabled&&(u(o,"".concat(i,"select__option--disabled")),d(o,{"aria-disabled":"true"})),v(n.dropdown,o),n.optionNodes.push(o)}),this.updateOptionStates())},I.prototype.updateOptionStates=function(){var i=this,n=this.prefix;this.optionNodes.forEach(function(t,e){var o=i.items[e];o&&(o.value!==i.currentValue||o.disabled?(s(t,"".concat(n,"select__option--selected")),d(t,{"aria-selected":"false"})):(u(t,"".concat(n,"select__option--selected")),d(t,{"aria-selected":"true"})),(e===i.activeIndex?u:s)(t,"".concat(n,"select__option--active")))})},I.prototype.updateDisplayValue=function(){var e=this,t=this.prefix,o=this.items.find(function(t){return t.value===e.currentValue}),i=void 0===this.currentValue||""===this.currentValue;this.valueText&&(i?(this.valueText.textContent=this.options.placeholder||"",u):(this.valueText.textContent=o?o.label:String(this.currentValue),s))(this.valueText,"".concat(t,"select__value--placeholder")),this.updateClearVisibility(i)},I.prototype.updateClearVisibility=function(t){var e;this.clearNode&&(e=this.prefix,(!this.options.clearable||t||Boolean(this.options.disabled)?u:s)(this.clearNode,"".concat(e,"select__clear--hidden")))},I.prototype.bindEvents=function(){this.trigger&&this.dropdown&&(C(this.trigger,"click",this.handleTriggerClick),C(this.trigger,"keydown",this.handleKeydown),C(this.dropdown,"click",this.handleDropdownClick))},I.prototype.moveActive=function(t){if(0!==this.items.length){for(var e=this.activeIndex,o=0;o<this.items.length&&(e=(e+t+this.items.length)%this.items.length,this.items[e].disabled);o++);this.activeIndex=e,this.updateOptionStates()}},I.prototype.selectIndex=function(t,e){void 0===e&&(e=!0);t=this.items[t];t&&!t.disabled&&(this.currentValue=t.value,this.updateDisplayValue(),this.close(),e)&&b(this.options.onChange)&&this.options.onChange(t.value,t)},I.prototype.open=function(){var t,e=this;this.options.disabled||this.isOpen||!this.container||(this.isOpen=!0,u(this.container,"".concat(this.prefix,"select--open")),this.trigger&&d(this.trigger,{"aria-expanded":"true"}),t=this.items.findIndex(function(t){return t.value===e.currentValue&&!t.disabled}),this.activeIndex=0<=t?t:0,this.updateOptionStates(),C(document,"mousedown",this.handleDocumentMousedown),b(this.options.onOpen)&&this.options.onOpen())},I.prototype.close=function(){this.isOpen&&this.container?(this.isOpen=!1,s(this.container,"".concat(this.prefix,"select--open")),this.trigger&&d(this.trigger,{"aria-expanded":"false"}),m(document,"mousedown",this.handleDocumentMousedown),b(this.options.onClose)&&this.options.onClose()):this.isOpen=!1},I.prototype.getValue=function(){return this.currentValue},I.prototype.setValue=function(e,t){void 0===t&&(t=!0),this.currentValue=e,this.updateDisplayValue(),this.updateOptionStates(),t&&b(this.options.onChange)&&(t=this.items.find(function(t){return t.value===e}))&&this.options.onChange(e,t)},I.prototype.clear=function(t){var e;void 0===t&&(t=!0),this.options.disabled||(e=void 0===this.currentValue||""===this.currentValue,this.currentValue=void 0,this.activeIndex=-1,this.updateDisplayValue(),this.updateOptionStates(),this.close(),!e&&t&&b(this.options.onClear)&&this.options.onClear())},I.prototype.setItems=function(t){this.items=t||[],this.activeIndex=-1,this.renderOptions(),this.updateDisplayValue()},I.prototype.setDisabled=function(t){this.options.disabled=t,this.container&&this.trigger&&(t?(u(this.container,"".concat(this.prefix,"select--disabled")),d(this.trigger,{disabled:"true"}),this.close()):(s(this.container,"".concat(this.prefix,"select--disabled")),d(this.trigger,{disabled:"false"})),this.updateDisplayValue())},I.prototype.isDropdownOpen=function(){return this.isOpen},I.prototype.getElement=function(){return this.container},I.prototype.destroy=function(){var t;this.close(),this.trigger&&(m(this.trigger,"click",this.handleTriggerClick),m(this.trigger,"keydown",this.handleKeydown)),this.dropdown&&m(this.dropdown,"click",this.handleDropdownClick),null!=(t=this.container)&&t.parentNode&&n(this.container),this.container=null,this.trigger=null,this.valueText=null,this.clearNode=null,this.dropdown=null,this.optionNodes=[]};var oe=I;function I(t){void 0===t&&(t={});var o=this;this.container=null,this.trigger=null,this.valueText=null,this.clearNode=null,this.dropdown=null,this.optionNodes=[],this.items=[],this.isOpen=!1,this.activeIndex=-1,this.handleTriggerClick=function(t){var e;o.options.disabled||(e=t.target,o.clearNode&&e&&e.closest(".".concat(o.prefix,"select__clear"))?(t.stopPropagation(),o.clear()):o.isOpen?o.close():o.open())},this.handleDropdownClick=function(t){var t=t.target;t&&(t=t.closest("[data-select-index]"))&&(t=Number(t.getAttribute("data-select-index")),o.selectIndex(t))},this.handleKeydown=function(t){if(!o.options.disabled)switch(t.key){case"ArrowDown":t.preventDefault(),o.isOpen?o.moveActive(1):o.open();break;case"ArrowUp":t.preventDefault(),o.isOpen?o.moveActive(-1):o.open();break;case"Enter":t.preventDefault(),o.isOpen?o.selectIndex(o.activeIndex):o.open();break;case"Escape":o.isOpen&&(t.preventDefault(),o.close());break;case"Tab":o.isOpen&&o.close()}},this.handleDocumentMousedown=function(t){t=t.target;t&&o.container&&(o.container.contains(t)||o.close())},this.options=l({value:void 0,items:[],placeholder:"",disabled:!1,size:"default",prefix:k,clearable:!0,onChange:function(){},onClear:function(){},onOpen:function(){},onClose:function(){}},t),this.items=this.options.items||[],this.currentValue=this.options.value,this.createElements(),this.renderOptions(),this.updateDisplayValue(),this.bindEvents()}ne.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),this.run()},ne.prototype.handleOptions=function(){var t=null==(t=this.ewColorPicker)?void 0:t.options;t&&(this.options=l({},this.options,t))},ne.prototype.updateOptions=function(){this.handleOptions(),this.run()},ne.prototype.run=function(){var t,e,o,i=this;this.ewColorPicker&&(this.removeInstance(),t=this.options.selectItems,!1!==this.options.showSelect)&&Array.isArray(t)&&0!==t.length&&(e=r(this.ewColorPicker),o=this.ewColorPicker.getMountPoint("panelContainer"))&&(this.instance=this.createSelect({items:t,value:this.options.selectValue,placeholder:this.options.selectPlaceholder,prefix:e,clearable:!1!==this.options.selectClearable,onChange:function(t,e){b(i.options.onSelectChange)&&i.options.onSelectChange(t,e)},onClear:function(){b(i.options.onSelectClear)&&i.options.onSelectClear()}}),(g(".".concat(e,"color-picker-bottom-row"),o)||o).appendChild(this.instance.getElement()))},ne.prototype.createSelect=function(t){return new oe(t=void 0===t?{}:t)},ne.prototype.removeInstance=function(){this.instance&&(this.instance.destroy(),this.instance=null)},ne.prototype.destroy=function(){this.removeInstance(),this.ewColorPicker=null},ne.pluginName="ewColorPickerSelect",ne.applyOrder=N.Post;var ie=ne;function ne(t){this.options={},this.instance=null,this.ewColorPicker=t,this.handleOptions(),this.run()}Object.defineProperty(se.prototype,"prefix",{get:function(){return this.options.prefix||k},enumerable:!1,configurable:!0}),se.prototype.createElements=function(){var t=this.prefix;this.container=h("label"),u(this.container,"".concat(t,"checkbox")),u(this.container,"".concat(t,"checkbox--").concat(this.options.size)),this.input=h("input"),u(this.input,"".concat(t,"checkbox__input")),d(this.input,{type:"checkbox"}),this.input.checked=this.currentChecked,this.box=h("span"),u(this.box,"".concat(t,"checkbox__box")),this.box.innerHTML=((t,e,o)=>(void 0===o&&(o=k),e=' width="'.concat(e,'" height="').concat(e,'"'),'<svg class="'.concat(o,"color-picker-icon").concat(dt(t),'" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"').concat(e,'><path d="M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path></svg>')))("".concat(t,"checkbox__check-icon"),10,t),this.labelText=h("span"),u(this.labelText,"".concat(t,"checkbox__label")),this.labelText.textContent=this.options.label||"",v(this.container,this.input),v(this.container,this.box),v(this.container,this.labelText),this.syncState(),this.options.disabled&&this.setDisabled(!0)},se.prototype.syncState=function(){var t;this.container&&this.input&&(t=this.prefix,this.input.checked=this.currentChecked,(this.currentChecked?u:s)(this.container,"".concat(t,"checkbox--checked")),d(this.input,{"aria-checked":String(this.currentChecked)}))},se.prototype.bindEvents=function(){this.input&&C(this.input,"change",this.handleChange)},se.prototype.isChecked=function(){return this.currentChecked},se.prototype.setChecked=function(t,e){void 0===e&&(e=!0);t=Boolean(t);this.currentChecked=t,this.syncState(),e&&b(this.options.onChange)&&this.options.onChange(t)},se.prototype.setLabel=function(t){this.labelText&&(this.labelText.textContent=t||""),this.options.label=t},se.prototype.setDisabled=function(t){this.options.disabled=t,this.container&&this.input&&((this.input.disabled=t)?u:s)(this.container,"".concat(this.prefix,"checkbox--disabled"))},se.prototype.getElement=function(){return this.container},se.prototype.destroy=function(){var t;this.input&&m(this.input,"change",this.handleChange),null!=(t=this.container)&&t.parentNode&&n(this.container),this.container=null,this.input=null,this.box=null,this.labelText=null};var re=se;function se(t){void 0===t&&(t={});var e=this;this.container=null,this.input=null,this.box=null,this.labelText=null,this.currentChecked=!1,this.handleChange=function(){e.input&&!e.options.disabled&&(e.currentChecked=e.input.checked,e.syncState(),b(e.options.onChange))&&e.options.onChange(e.currentChecked)},this.options=l({checked:!1,label:"",disabled:!1,size:"default",prefix:k,onChange:function(){}},t),this.currentChecked=Boolean(this.options.checked),this.createElements(),this.bindEvents()}le.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),this.run()},le.prototype.handleOptions=function(){var t=null==(t=this.ewColorPicker)?void 0:t.options;t&&(this.options=l({},this.options,t))},le.prototype.updateOptions=function(){this.handleOptions(),this.run()},le.prototype.run=function(){var t,e,o,i=this;this.ewColorPicker&&(this.removeInstance(),t=this.options.checkboxLabel,!1!==this.options.showCheckbox)&&"string"==typeof t&&""!==t&&(e=r(this.ewColorPicker),o=this.ewColorPicker.getMountPoint("panelContainer"))&&(this.instance=this.createCheckbox({label:t,checked:!0===this.options.checkboxChecked,disabled:!0===this.options.checkboxDisabled,prefix:e,onChange:function(t){b(i.options.onCheckboxChange)&&i.options.onCheckboxChange(t)}}),(g(".".concat(e,"color-picker-bottom-row"),o)||o).appendChild(this.instance.getElement()))},le.prototype.createCheckbox=function(t){return new re(t=void 0===t?{}:t)},le.prototype.removeInstance=function(){this.instance&&(this.instance.destroy(),this.instance=null)},le.prototype.destroy=function(){this.removeInstance(),this.ewColorPicker=null},le.pluginName="ewColorPickerCheckbox",le.applyOrder=N.Post;var ae=le;function le(t){this.options={},this.instance=null,this.ewColorPicker=t,this.handleOptions(),this.run()}Object.defineProperty(O.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(O.prototype,"hasClear",{get:function(){return this._hasClear},set:function(t){this._hasClear!==t&&(this._hasClear=t,this.render())},enumerable:!1,configurable:!0}),Object.defineProperty(O.prototype,"hasSure",{get:function(){return this._hasSure},set:function(t){this._hasSure!==t&&(this._hasSure=t,this.render())},enumerable:!1,configurable:!0}),O.prototype.enableClear=function(t){this.hasClear=t=void 0===t?!0:t},O.prototype.enableSure=function(t){this.hasSure=t=void 0===t?!0:t},O.prototype.enableButtons=function(t){this.hasClear=t=void 0===t?!0:t,this.hasSure=t},O.prototype.handleOptions=function(){this.options=l({},this.options,this.ewColorPicker.options)},O.prototype.updateOptions=function(){var t=this;this.handleOptions(),setTimeout(function(){t.render()},0)},O.prototype.run=function(){var t=this;!1!==this.options.showButton&&(this.render(),this.bindEvents(),setTimeout(function(){t.adjustButtonGroupStyle()},0))},O.prototype.render=function(){var t,e=this.ewColorPicker.getMountPoint("panelContainer");e?(e=g(".".concat(this.prefix,"color-picker-bottom-row"),e))?((t=g(".".concat(this.prefix,"color-picker-drop-btn-group"),e))||(t=h("div"),u(t,"".concat(this.prefix,"color-picker-drop-btn-group")),v(e,t)),t.textContent="",this.hasClear&&(this.clearButton=h("button"),u(this.clearButton,"".concat(this.prefix,"color-picker-clear-btn ").concat(this.prefix,"color-picker-drop-btn")),this.setClearText(this.options.clearText||"清空"),v(t,this.clearButton)),this.hasSure&&(this.sureButton=h("button"),u(this.sureButton,"".concat(this.prefix,"color-picker-sure-btn ").concat(this.prefix,"color-picker-drop-btn")),this.setSureText(this.options.sureText||"确认"),v(t,this.sureButton)),this.adjustButtonGroupStyle()):c("[ewColorPicker warning]: Bottom row container not found"):c("[ewColorPicker warning]: Panel container not found")},O.prototype.bindEvents=function(){var t=this;this.clearButton&&C(this.clearButton,"click",function(){t.debouncedOnClearColor()}),this.sureButton&&C(this.sureButton,"click",function(){t.debouncedOnSureColor()}),this.ewColorPicker.on("mode-change",function(){t.adjustButtonGroupStyle()})},O.prototype.onClearColor=function(){var t,e,o;this.ewColorPicker.options.defaultColor?(o=w(e=this.ewColorPicker.options.defaultColor))&&(t=y(o)):(e="",t=void 0),this.ewColorPicker.hsvaColor=t||{h:0,s:100,v:100,a:1},this.ewColorPicker.setColor(e),this.ewColorPicker.syncAllPlugins(e),this.ewColorPicker.hidePanel(),b(this.options.clear)&&null!=(t=(o=this.options).clear)&&t.call(o,this.ewColorPicker),this.ewColorPicker.trigger("clear")},O.prototype.onSureColor=function(){var t,e;b(this.options.sure)&&null!=(e=(t=this.options).sure)&&e.call(t,this.ewColorPicker.currentColor,this.ewColorPicker),this.ewColorPicker.trigger("sure",this.ewColorPicker.currentColor,this.ewColorPicker),this.ewColorPicker.hidePanel()},O.prototype.setClearText=function(t){this.clearButton&&(this.clearButton.textContent=t)},O.prototype.setSureText=function(t){this.sureButton&&(this.sureButton.textContent=t)},O.prototype.setDisabled=function(t){this.clearButton&&d(this.clearButton,{disabled:t.toString()}),this.sureButton&&d(this.sureButton,{disabled:t.toString()})},O.prototype.destroy=function(){this.clearButton&&m(this.clearButton,"click",this.debouncedOnClearColor),this.sureButton&&m(this.sureButton,"click",this.debouncedOnSureColor),this.clearButton=null,this.sureButton=null},O.prototype.adjustButtonGroupStyle=function(){var t,e,o=this.prefix,i=this.ewColorPicker.getMountPoint("panelContainer");i&&(t=g(".".concat(o,"color-picker-bottom-row"),i))&&(e=g(".".concat(o,"color-picker-drop-btn-group"),t))&&(null!==g(".".concat(o,"color-picker-inputs-group"),i)?(u(e,"".concat(o,"color-picker-drop-btn-group-multi")),s(e,"".concat(o,"color-picker-drop-btn-group-single")),u(t,"".concat(o,"color-picker-bottom-row-multi")),s(t,"".concat(o,"color-picker-bottom-row-single"))):(u(e,"".concat(o,"color-picker-drop-btn-group-single")),s(e,"".concat(o,"color-picker-drop-btn-group-multi")),u(t,"".concat(o,"color-picker-bottom-row-single")),s(t,"".concat(o,"color-picker-bottom-row-multi"))))},O.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),null!=(t=this.run)&&t.call(this)},O.pluginName="ewColorPickerButton",O.applyOrder="post";var ce=O;function O(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=St(this.onClearColor.bind(this),100),this.debouncedOnSureColor=St(this.onSureColor.bind(this),100),this.run()}Object.defineProperty(H.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),H.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=l(this.options,this.ewColorPicker.options),this.ewColorPicker.options.ewColorPickerPredefine)&&(this.options=l(this.options,this.ewColorPicker.options.ewColorPickerPredefine))},H.prototype.run=function(){0<this.getValidPredefineColors().length&&(this.render(),this.bindEvents(),this.bindColorChangeEvent())},H.prototype.getValidPredefineColors=function(){var e=this;return this.options.predefineColor&&Array.isArray(this.options.predefineColor)?this.options.predefineColor.filter(function(t){var t=e.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))}):[]},H.prototype.render=function(){var i=this,t=this.ewColorPicker.getMountPoint("panelContainer");t?(this.container=g(".".concat(this.prefix,"color-picker-predefine-container"),t),this.container||(this.container=h("div"),u(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,e=h("div"),o=(u(e,"".concat(i.prefix,"color-picker-predefine-color")),h("div"));u(o,"".concat(i.prefix,"color-picker-predefine-color-item")),p(o,"backgroundColor",t),v(e,o),v(i.container,e),i.predefineItems.push(e)})),this.ensureContainerAtCorrectPosition(t),this.bindToggleEvent(t)):c("[ewColorPicker warning]: Panel container not found")},H.prototype.parseColorData=function(t){return{color:Z(t)?t:t.color,disabled:!!J(t)&&t.disabled}},H.prototype.bindToggleEvent=function(e){var o=this;this.isEventBound&&this.toggleHandler&&(this.ewColorPicker.off("toggle",this.toggleHandler),this.isEventBound=!1),this.toggleHandler=function(t){t&&o.ensureContainerAtCorrectPosition(e)},this.ewColorPicker.on("toggle",this.toggleHandler),this.isEventBound=!0},H.prototype.bindColorChangeEvent=function(){var e=this;this.changeHandler&&this.ewColorPicker.off("change",this.changeHandler),this.changeHandler=function(t){e.updateActivePredefineColor(t)},this.ewColorPicker.on("change",this.changeHandler)},H.prototype.ensureContainerAtCorrectPosition=function(t){var e,o;this.container&&(e=this.prefix,(o=g(".".concat(e,"color-picker-mode-container"),t))?t.insertBefore(this.container,o):(o=g(".".concat(e,"color-picker-bottom-row"),t))?t.insertBefore(this.container,o):(o=g(".".concat(e,"color-picker-panel"),t))&&o.nextSibling?t.insertBefore(this.container,o.nextSibling):t.appendChild(this.container))},H.prototype.bindEvents=function(){var i=this;this.predefineItems.forEach(function(t,e){var e=i.getValidPredefineColors()[e],e=i.parseColorData(e),o=e.color;e.disabled?u(t,"".concat(i.prefix,"color-picker-predefine-color-disabled")):(C(t,"click",function(t){i.debouncedOnPredefineColorClick(t,o)}),C(t,"blur",function(t){s(t.target,"".concat(i.prefix,"color-picker-predefine-color-active"))}))})},H.prototype.onPredefineColorClick=function(t,e){var o,i,n=this.prefix,r=t.target;et(r,"".concat(n,"color-picker-predefine-color"))||(r=r.closest(".".concat(n,"color-picker-predefine-color"))||r),et(r,"".concat(n,"color-picker-predefine-color-disabled"))||(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(u(r,"".concat(n,"color-picker-predefine-color-active")),this.predefineItems.forEach(function(t){t!==r&&s(t,"".concat(n,"color-picker-predefine-color-active"))}),xt(e)?(t=w(e),this.ewColorPicker.hsvaColor=y(t),this.ewColorPicker.setColor(t),b(this.options.changeColor)&&null!=(i=(o=this.options).changeColor)&&i.call(o,t)):c("[ewColorPicker warning]: Invalid predefine color: ".concat(e))))},H.prototype.updatePredefineColors=function(t){this.options.predefineColor=t,this.predefineItems=[],this.render(),this.bindEvents()},H.prototype.setDisabled=function(t,e){this.predefineItems[t]&&(e?u:s)(this.predefineItems[t],"".concat(this.prefix,"color-picker-predefine-color-disabled"))},H.prototype.destroy=function(){var e=this;this.predefineItems.forEach(function(t){m(t,"click",e.debouncedOnPredefineColorClick),m(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},H.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),null!=(t=this.run)&&t.call(this)},H.prototype.updateActivePredefineColor=function(t){var o,i,n=this;t&&(o=w(t),i=this.prefix,this.predefineItems.forEach(function(t,e){e=n.getValidPredefineColors()[e],e=w(n.parseColorData(e).color);(o===e?u:s)(t,"".concat(i,"color-picker-predefine-color-active"))}))},H.pluginName="ewColorPickerPredefine";var he=H;function H(t){this.ewColorPicker=t,this.options={},this.predefineItems=[],this.container=null,this.toggleHandler=null,this.changeHandler=null,this.isEventBound=!1,this.handleOptions(),this.debouncedOnPredefineColorClick=St(this.onPredefineColorClick.bind(this),100),this.run()}Object.defineProperty(T.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"hasAlphaPlugin",{get:function(){var t;return!(null==(t=this.ewColorPicker.plugins)||!t.ewColorPickerAlpha)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"inputPlugin",{get:function(){var t;return null==(t=this.ewColorPicker.plugins)?void 0:t.ewColorPickerInput},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"alphaPlugin",{get:function(){var t;return null==(t=this.ewColorPicker.plugins)?void 0:t.ewColorPickerAlpha},enumerable:!1,configurable:!0}),T.prototype.initializePlugin=function(){function t(){e.handleOptions(),e.run()}var e=this;this.ewColorPicker.plugins?t():setTimeout(t,0)},T.prototype.install=function(e){function t(){var t;o.handleOptions(),e.on&&b(e.on)&&e.on("change",function(t){"hex"!==o.currentMode&&o.updateInputValues(t)}),null!=(t=o.run)&&t.call(o),o.hasAlphaPlugin&&"rgb"===o.currentMode&&o.updateInputStructure()}var o=this;this.ewColorPicker=e;this.ewColorPicker.plugins?t():setTimeout(t,0)},T.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=l({},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=l({},this.options,this.ewColorPicker.options.ewColorPickerColorMode))),this.hasAlphaPlugin?this.currentMode=this.options.defaultMode||"rgb":this.currentMode=this.options.defaultMode||"hex")},T.prototype.updateOptions=function(){this.handleOptions(),this.render()},T.prototype.run=function(){this.handleOptions(),!1!==this.options.showColorMode&&(this.render(),this.bindEvents(),this.hasAlphaPlugin&&"rgb"===this.currentMode&&this.updateInputStructure(),this.setupInputPluginListener())},T.prototype.render=function(){var t=this.ewColorPicker.getMountPoint("panelContainer");t?(this.modeContainer=g(".".concat(this.prefix,"color-picker-mode-container"),t),this.modeContainer||this.createModeContainer(t),this.updateModeDisplay()):c("[ewColorPicker] Panel container not found")},T.prototype.createModeContainer=function(t){var e=this.prefix,e=(this.modeContainer=h("div"),u(this.modeContainer,"".concat(e,"color-picker-mode-container")),this.upButton=h("button"),u(this.upButton,"".concat(e,"color-picker-mode-up-btn")),d(this.upButton,{type:"button",title:"上一个模式"}),this.upButton.innerHTML=Nt("",16,e),this.modeText=h("div"),u(this.modeText,"".concat(e,"color-picker-mode-text")),this.downButton=h("button"),u(this.downButton,"".concat(e,"color-picker-mode-down-btn")),d(this.downButton,{type:"button",title:"下一个模式"}),this.downButton.innerHTML=At("",16,e),v(this.modeContainer,this.upButton),v(this.modeContainer,this.modeText),v(this.modeContainer,this.downButton),g(".".concat(e,"color-picker-bottom-row"),t));e?v(t,this.modeContainer,void 0,e):v(t,this.modeContainer)},T.prototype.updateModeDisplay=function(){this.modeText&&(this.modeText.textContent=this.getModeDisplayName(this.currentMode))},T.prototype.bindEvents=function(){var t,e=this;this.upButton&&this.downButton&&(C(this.upButton,"click",t=function(){e.options.disabled||e.switchToPreviousMode()}),this.boundEventHandlers.push({element:this.upButton,event:"click",handler:t}),C(this.downButton,"click",t=function(){e.options.disabled||e.switchToNextMode()}),this.boundEventHandlers.push({element:this.downButton,event:"click",handler:t}),this.upButton&&(C(this.upButton,"mouseenter",this.handleUpButtonHover),C(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&&(C(this.downButton,"mouseenter",this.handleDownButtonHover),C(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"!==e.currentMode&&e.updateInputValues(t)}))},T.prototype.switchToPreviousMode=function(){var t=["hex","rgb","hsl"],e=t.indexOf(this.currentMode);this.debouncedOnModeChange(t[0<e?e-1:t.length-1])},T.prototype.switchToNextMode=function(){var t=["hex","rgb","hsl"],e=t.indexOf(this.currentMode);this.debouncedOnModeChange(t[(e+1)%t.length])},T.prototype.onModeChange=function(t){this.currentMode=t,this.updateModeDisplay(),this.updateInputStructure();var e,o=this.ewColorPicker.getColor();o&&"hex"!==t&&this.updateInputValues(o),b(this.options.changeMode)&&null!=(e=(o=this.options).changeMode)&&e.call(o,t,this.ewColorPicker),this.ewColorPicker.trigger("mode-change",t)},T.prototype.updateInputStructure=function(){var t=this.prefix,e=this.ewColorPicker.getMountPoint("panelContainer");e&&(e=g(".".concat(t,"color-picker-bottom-row"),e))&&(t=g(".".concat(t,"color-picker-input-container"),e))&&(this.inputPlugin&&!this.inputPlugin.hasInput?(this.clearInputNumberInstances(),t.innerHTML=""):(this.clearInputNumberInstances(),"hex"===this.currentMode?this.restoreDefaultInput():(t.innerHTML="",this.createInputsForMode(t))))},T.prototype.setupInputPluginListener=function(){},T.prototype.createInputsForMode=function(t){var s,e,a=this,l=this.prefix;(!this.inputPlugin||this.inputPlugin.hasInput)&&(t.innerHTML="",e=[],"rgb"===this.currentMode?e=this.hasAlphaPlugin?["R","G","B","A"]:["R","G","B"]:"hsl"===this.currentMode&&(e=this.hasAlphaPlugin?["H","S","L","A"]:["H","S","L"]),s=h("div"),u(s,"".concat(l,"color-picker-inputs-group")),e.forEach(function(t,e){var o,i,n=h("div"),r=(u(n,"".concat(l,"color-picker-inputs-col")),h("div"));u(r,"".concat(l,"color-picker-input-label")),r.textContent=t,v(n,r),"rgb"===a.currentMode?(o=(i=new Jt({value:0,min:0,max:3===e?1:255,step:3===e?.01:1,precision:3===e?2:0,placeholder:t,size:"small",prefix:l,onChange:function(){a.debouncedUpdateColorFromRgb()}})).getElement(),a.inputNumberInstances.set(t.toLowerCase(),i),u(o,"".concat(l,"color-picker-rgb-").concat(t.toLowerCase(),"-input"))):"hsl"===a.currentMode&&(0===e?(o=(i=new Jt({value:0,min:0,max:360,step:1,precision:0,placeholder:t,size:"small",prefix:l,onChange:function(){a.debouncedUpdateColorFromHsl()}})).getElement(),a.inputNumberInstances.set("h",i)):3===e&&a.hasAlphaPlugin?(o=(i=new Jt({value:0,min:0,max:1,step:.01,precision:2,placeholder:t,size:"small",prefix:l,onChange:function(){a.debouncedUpdateColorFromHsl()}})).getElement(),a.inputNumberInstances.set("a",i)):(o=h("input"),d(o,{type:"text",placeholder:t,class:"".concat(l,"color-picker-hsl-").concat(t.toLowerCase(),"-input ").concat(l,"color-picker-input")})),o)&&u(o,"".concat(l,"color-picker-hsl-").concat(t.toLowerCase(),"-input")),o||(o=h("input"),d(o,{type:"text",placeholder:t,class:"".concat(l,"color-picker-default-input")})),v(n,o),v(s,n)}),v(t,s),e=this.ewColorPicker.getColor())&&this.updateInputValues(e)},T.prototype.getInputContainer=function(){var t=this.prefix,e=this.ewColorPicker.getMountPoint("panelContainer");return(e=e&&g(".".concat(t,"color-picker-bottom-row"),e))&&g(".".concat(t,"color-picker-input-container"),e)||document},T.prototype.syncChannelValue=function(t,e,o){var i,t=this.inputNumberInstances.get(t);t?(i=parseFloat(o),isNaN(i)||t.setValue(i,!1)):e&&(e.value=o)},T.prototype.clearInputNumberInstances=function(){this.inputNumberInstances.forEach(function(t){return t.destroy()}),this.inputNumberInstances.clear()},T.prototype.updateInputValues=function(t){var e,o,i,n,r,s,a;t&&(t=w(t))&&(t=Bt(t))&&(e=this.getInputContainer(),o=this.prefix,"rgb"===this.currentMode?(i=g(".".concat(o,"color-picker-rgb-r-input input"),e),n=g(".".concat(o,"color-picker-rgb-g-input input"),e),r=g(".".concat(o,"color-picker-rgb-b-input input"),e),a=g(".".concat(o,"color-picker-rgb-a-input input"),e),this.syncChannelValue("r",i,Math.round(t.r).toString()),this.syncChannelValue("g",n,Math.round(t.g).toString()),this.syncChannelValue("b",r,Math.round(t.b).toString()),this.syncChannelValue("a",a,t.a.toFixed(2))):"hsl"===this.currentMode&&(i=((t,e,o)=>{t/=255,e/=255,o/=255;var i=Math.max(t,e,o),n=Math.min(t,e,o),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=(e-o)/l+(e<o?6:0);break;case e:r=(o-t)/l+2;break;case o:r=(t-e)/l+4}r/=6}return{h:360*r,s:100*s,l:100*a}})(t.r,t.g,t.b),n=g(".".concat(o,"color-picker-hsl-h-input input"),e),r=g(".".concat(o,"color-picker-hsl-s-input"),e),s=g(".".concat(o,"color-picker-hsl-l-input"),e),a=g(".".concat(o,"color-picker-hsl-a-input input"),e),this.syncChannelValue("h",n,Math.round(i.h).toString()),this.syncChannelValue("s",r,Math.round(i.s).toString()+"%"),this.syncChannelValue("l",s,Math.round(i.l).toString()+"%"),this.syncChannelValue("a",a,t.a.toFixed(2))))},T.prototype.updateColorFromRgbInputs=function(){var t=this.getInputContainer(),e=this.prefix,o=g(".".concat(e,"color-picker-rgb-r-input input"),t),i=g(".".concat(e,"color-picker-rgb-g-input input"),t),n=g(".".concat(e,"color-picker-rgb-b-input input"),t),e=g(".".concat(e,"color-picker-rgb-a-input input"),t);o&&i&&n&&(t=parseInt(o.value)||0,o=parseInt(i.value)||0,i=parseInt(n.value)||0,n=e&&parseFloat(e.value)||1,e="rgba(".concat(t,", ").concat(o,", ").concat(i,", ").concat(n,")"),this.ewColorPicker.setColor(e),this.ewColorPicker.syncAllPlugins(e),this.alphaPlugin)&&this.alphaPlugin.updateAlphaThumbPosition&&this.alphaPlugin.updateAlphaThumbPosition(n)},T.prototype.updateColorFromHslInputs=function(){var t=this.getInputContainer(),e=this.prefix,o=g(".".concat(e,"color-picker-hsl-h-input input"),t),i=g(".".concat(e,"color-picker-hsl-s-input"),t),n=g(".".concat(e,"color-picker-hsl-l-input"),t),e=g(".".concat(e,"color-picker-hsl-a-input input"),t);o&&i&&n&&(t=parseInt(o.value)||0,o=parseInt(i.value.replace("%",""))||0,i=parseInt(n.value.replace("%",""))||0,n=e&&parseFloat(e.value)||1,e="hsla(".concat(t,", ").concat(o,"%, ").concat(i,"%, ").concat(n,")"),this.ewColorPicker.setColor(e),this.ewColorPicker.syncAllPlugins(e),this.alphaPlugin)&&this.alphaPlugin.updateAlphaThumbPosition&&this.alphaPlugin.updateAlphaThumbPosition(n)},T.prototype.getModeDisplayName=function(t){return{hex:"HEX",rgb:"RGB",hsl:"HSL"}[t]||t.toUpperCase()},T.prototype.getCurrentMode=function(){return this.currentMode},T.prototype.setMode=function(t){this.debouncedOnModeChange(t)},T.prototype.restoreDefaultInput=function(){var t,e=this.prefix,o=this.ewColorPicker.getMountPoint("panelContainer");o&&(o=g(".".concat(e,"color-picker-bottom-row"),o))&&(o=g(".".concat(e,"color-picker-input-container"),o))&&(this.inputPlugin&&!this.inputPlugin.hasInput?o.innerHTML="":(o.innerHTML="",u(o,"".concat(e,"color-picker-input-container-flex")),t=h("input"),u(t,"".concat(e,"color-picker-input")),u(t,"".concat(e,"color-picker-input-default")),d(t,{type:"text",name:"".concat(e,"color-picker-input"),placeholder:"请输入颜色值"}),v(o,t),(e=this.ewColorPicker.getColor())&&-1===e.indexOf("NaN")||(e=""),"hex"===this.currentMode&&(o=w(e))&&(o=Bt(o))?(o=Mt(o),t.value=o):t.value=e,this.bindDefaultInputEvents(t)))},T.prototype.bindDefaultInputEvents=function(t){this.bindInputEvents(t)},T.prototype.rebindDefaultInputEvents=function(){var t=this.prefix,e=this.ewColorPicker.getMountPoint("panelContainer");e&&(e=g(".".concat(t,"color-picker-bottom-row"),e))&&(e=g(".".concat(t,"color-picker-input-container"),e))&&(t=g(".".concat(t,"color-picker-hex-input"),e))&&this.bindInputEvents(t)},T.prototype.bindInputEvents=function(e){function t(t){xt(t=t.target.value)&&(i.ewColorPicker.setColor(t),i.syncOtherPlugins(t))}function o(t){"Enter"===t.key&&xt(t=t.target.value)&&(i.ewColorPicker.setColor(t),i.syncOtherPlugins(t))}var i=this;C(e,"blur",t),this.boundEventHandlers.push({element:e,event:"blur",handler:t}),C(e,"keydown",o),this.boundEventHandlers.push({element:e,event:"keydown",handler:o});this.ewColorPicker.on("change",function(t){e.value="hex"===i.currentMode?i.toHexDisplay(t):t})},T.prototype.toHexDisplay=function(t){var e;return t?!t.startsWith("#")&&(e=w(t))&&(e=Bt(e))?Mt(e):t:""},T.prototype.syncOtherPlugins=function(t){var e=this.ewColorPicker.hsvaColor,o=(this.inputPlugin&&this.inputPlugin.update&&this.inputPlugin.update(t),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerHue),e=(o&&o.updateHueThumbPosition&&o.updateHueThumbPosition(e.h),this.alphaPlugin&&this.alphaPlugin.updateAlphaThumbPosition&&this.alphaPlugin.updateAlphaThumbPosition(e.a),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerPanel),e=(e&&e.updatePanelColor&&e.updatePanelColor(t),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerBox);e&&e.setBoxBgColor&&e.setBoxBgColor(t)},T.prototype.destroy=function(){this.clearInputNumberInstances(),this.boundEventHandlers.forEach(function(t){var e=t.element;m(e,t.event,t.handler)}),this.boundEventHandlers=[],this.modeContainer&&this.modeContainer.parentNode&&n(this.modeContainer),this.modeContainer=null,this.modeText=null,this.upButton=null,this.downButton=null},T.pluginName="ewColorPickerColorMode",T.applyOrder=N.Post;var ue=T;function T(t){var e=this;this.ewColorPicker=t,this.options={},this.currentMode="hex",this.modeContainer=null,this.modeText=null,this.upButton=null,this.downButton=null,this.inputNumberInstances=new Map,this.boundEventHandlers=[],this.handleUpButtonHover=function(){e.upButton&&p(e.upButton,{borderColor:"#4096ef",backgroundColor:"#f0f8ff"})},this.handleUpButtonLeave=function(){e.upButton&&p(e.upButton,{borderColor:"#ddd",backgroundColor:"#fff"})},this.handleDownButtonHover=function(){e.downButton&&p(e.downButton,{borderColor:"#4096ef",backgroundColor:"#f0f8ff"})},this.handleDownButtonLeave=function(){e.downButton&&p(e.downButton,{borderColor:"#ddd",backgroundColor:"#fff"})},this.debouncedOnModeChange=St(this.onModeChange.bind(this),100),this.debouncedUpdateColorFromRgb=St(this.updateColorFromRgbInputs.bind(this),100),this.debouncedUpdateColorFromHsl=St(this.updateColorFromHslInputs.bind(this),100),this.initializePlugin()}Object.defineProperty(S.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),S.prototype.isSupported=function(){return"undefined"!=typeof window&&"EyeDropper"in window},S.prototype.handleOptions=function(){this.options=l({},this.options,this.ewColorPicker.options)},S.prototype.updateOptions=function(){this.handleOptions(),this.run()},S.prototype.run=function(){!1!==this.options.showEyedropper&&this.isSupported()?(this.removeContainer(),this.render(),this.bindEvents()):this.removeContainer()},S.prototype.render=function(){var t,e=this.ewColorPicker.getMountPoint("panelContainer");e?(e=this.getExtraRow(e),this.container=h("div"),u(this.container,"".concat(this.prefix,"color-picker-eyedropper-group")),this.button=h("button"),u(this.button,"".concat(this.prefix,"color-picker-eyedropper-btn")),d(this.button,{type:"button",title:this.options.eyedropperText||"取色","aria-label":this.options.eyedropperText||"取色"}),this.button.innerHTML=((t,e,o)=>(void 0===o&&(o=k),e=' width="'.concat(e,'" height="').concat(e,'"'),'<svg class="'.concat(o,"color-picker-icon").concat(dt(t),'" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"').concat(e,'><path d="M17.66 5.41l.92.92-2.69 2.69-.92-.92 2.69-2.69M17.67 3c-.26 0-.51.1-.71.29l-3.12 3.12-1.93-1.91-1.41 1.41 1.42 1.42L3 16.25V21h4.75l8.92-8.92 1.42 1.42 1.41-1.41-1.92-1.92 3.12-3.12c.4-.4.29-.71.29-.71L17.67 3z"></path></svg>')))(void 0,16,this.prefix),this.options.eyedropperText&&(t=h("span"),u(t,"".concat(this.prefix,"color-picker-eyedropper-text")),t.textContent=this.options.eyedropperText,v(this.button,t)),v(this.container,this.button),v(e,this.container)):c("[ewColorPicker warning]: Panel container not found")},S.prototype.getExtraRow=function(t){var e,o=g(".".concat(this.prefix,"color-picker-extra-row"),t);return o||(o=h("div"),u(o,"".concat(this.prefix,"color-picker-extra-row")),(e=g(".".concat(this.prefix,"color-picker-bottom-row"),t))?v(t,o,null,e):v(t,o),o)},S.prototype.bindEvents=function(){this.button&&C(this.button,"click",this.handleClick)},S.prototype.removeContainer=function(){this.button&&m(this.button,"click",this.handleClick),this.container&&n(this.container),this.button=null;var t,e=(this.container=null)==(e=null==(t=this.ewColorPicker)?void 0:t.getMountPoint)?void 0:e.call(t,"panelContainer");e&&(t=g(".".concat(this.prefix,"color-picker-extra-row"),e))&&0===t.children.length&&n(t)},S.prototype.destroy=function(){this.destroyed=!0,this.removeContainer()},S.prototype.install=function(t){this.ewColorPicker=t,this.destroyed=!1,this.handleOptions(),null!=(t=this.run)&&t.call(this)},S.pluginName="ewColorPickerEyedropper",S.applyOrder=N.Post;var pe=S;function S(t){var e=this;this.ewColorPicker=t,this.options={},this.container=null,this.button=null,this.destroyed=!1,this.handleClick=function(){return F(e,void 0,void 0,function(){var e,o;return j(this,function(t){switch(t.label){case 0:if(this.destroyed)return[2];if(!(e=window.EyeDropper))return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,(new e).open()];case 2:return(o=t.sent(),!this.destroyed&&o&&o.sRGBHex)?(this.ewColorPicker.setColor(o.sRGBHex),b(this.options.onEyedropperPick)&&this.options.onEyedropperPick(o.sRGBHex),[3,4]):[2];case 3:return(o=t.sent())&&"AbortError"===o.name?[2]:(c("[ewColorPicker warning]: Failed to pick color with EyeDropper",o),[3,4]);case 4:return[2]}})})},this.ewColorPicker=t,this.handleOptions(),this.run()}var de="复制颜色到剪贴板",fe=(Object.defineProperty(E.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),E.prototype.handleOptions=function(){this.options=l({},this.options,this.ewColorPicker.options)},E.prototype.updateOptions=function(){this.handleOptions(),this.run()},E.prototype.run=function(){!1===this.options.showCopyColor?this.removeContainer():(this.removeContainer(),this.render(),this.bindEvents())},E.prototype.render=function(){var t=this.ewColorPicker.getMountPoint("panelContainer");t?(t=this.getExtraRow(t),this.defaultTitle=this.options.copyColorText||de,this.container=h("div"),u(this.container,"".concat(this.prefix,"color-picker-copy-group")),this.button=h("button"),u(this.button,"".concat(this.prefix,"color-picker-copy-btn")),d(this.button,{type:"button",title:this.defaultTitle,"aria-label":this.defaultTitle}),this.button.innerHTML=((t,e,o)=>(void 0===o&&(o=k),e=' width="'.concat(e,'" height="').concat(e,'"'),'<svg class="'.concat(o,"color-picker-icon").concat(dt(t),'" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"').concat(e,'><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg>')))(void 0,14,this.prefix),this.syncColor(this.ewColorPicker.getColor()),this.tip=h("div"),u(this.tip,"".concat(this.prefix,"color-picker-copy-tip")),d(this.tip,{role:"status","aria-live":"polite"}),this.tip.textContent=this.options.copiedText||"已复制",v(this.container,this.button),v(this.container,this.tip),v(t,this.container)):c("[ewColorPicker warning]: Panel container not found")},E.prototype.getExtraRow=function(t){var e,o=g(".".concat(this.prefix,"color-picker-extra-row"),t);return o||(o=h("div"),u(o,"".concat(this.prefix,"color-picker-extra-row")),(e=g(".".concat(this.prefix,"color-picker-bottom-row"),t))?v(t,o,null,e):v(t,o),o)},E.prototype.bindEvents=function(){this.button&&C(this.button,"click",this.handleClick)},E.prototype.bindCoreEvents=function(){this.listening||(this.ewColorPicker.on("change",this.handleChange),this.listening=!0)},E.prototype.syncColor=function(t){var e,o,i;this.button&&p(this.button,{backgroundColor:t=t||"#ffffff",color:(void 0===e&&(e="#333333"),void 0===o&&(o="#ffffff"),(t=w(t=t))&&(i=Bt(t))&&.5<.2126*(t=function(t){t=(t*i.a+255*(1-i.a))/255;return t<=.03928?t/12.92:Math.pow((.055+t)/1.055,2.4)})(i.r)+.7152*t(i.g)+.0722*t(i.b)?e:o)})},E.prototype.copyToClipboard=function(i){return F(this,void 0,void 0,function(){var e,o;return j(this,function(t){switch(t.label){case 0:if("undefined"==typeof navigator||!navigator.clipboard||!b(navigator.clipboard.writeText))return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,navigator.clipboard.writeText(i)];case 2:return t.sent(),[2,!0];case 3:return t.sent(),[3,4];case 4:if("undefined"==typeof document||!b(document.execCommand))return[2,!1];(e=h("textarea")).value=i,p(e,{position:"fixed",top:"-9999px",left:"-9999px",opacity:"0"}),v(document.body,e),e.select(),o=!1;try{o=document.execCommand("copy")}catch(t){o=!1}return n(e),[2,o]}})})},E.prototype.showCopiedState=function(){var t,e=this;this.button&&(t=this.options.copiedText||"已复制",d(this.button,{title:t,"aria-label":t}),u(this.button,"".concat(this.prefix,"color-picker-copy-btn-copied")),this.tip&&(this.tip.textContent=t,u(this.tip,"".concat(this.prefix,"color-picker-copy-tip-show"))),this.resetTitleTimer&&clearTimeout(this.resetTitleTimer),this.resetTitleTimer=setTimeout(function(){e.resetTitleTimer=null,!e.destroyed&&e.button&&(d(e.button,{title:e.defaultTitle,"aria-label":e.defaultTitle}),s(e.button,"".concat(e.prefix,"color-picker-copy-btn-copied")),e.tip)&&s(e.tip,"".concat(e.prefix,"color-picker-copy-tip-show"))},1500))},E.prototype.removeContainer=function(){this.resetTitleTimer&&(clearTimeout(this.resetTitleTimer),this.resetTitleTimer=null),this.button&&m(this.button,"click",this.handleClick),this.container&&n(this.container),this.button=null,this.container=null;var t,e=(this.tip=null)==(e=null==(t=this.ewColorPicker)?void 0:t.getMountPoint)?void 0:e.call(t,"panelContainer");e&&(t=g(".".concat(this.prefix,"color-picker-extra-row"),e))&&0===t.children.length&&n(t)},E.prototype.destroy=function(){this.destroyed=!0,this.removeContainer(),this.ewColorPicker.off("change",this.handleChange),this.listening=!1},E.prototype.install=function(t){this.listening&&(this.ewColorPicker.off("change",this.handleChange),this.listening=!1),this.ewColorPicker=t,this.destroyed=!1,this.handleOptions(),this.run(),this.bindCoreEvents()},E.pluginName="ewColorPickerCopyColor",E.applyOrder=N.Post,E);function E(t){var e=this;this.ewColorPicker=t,this.options={},this.container=null,this.button=null,this.tip=null,this.destroyed=!1,this.listening=!1,this.resetTitleTimer=null,this.defaultTitle=de,this.handleChange=function(t){e.syncColor(t)},this.handleClick=function(){return F(e,void 0,void 0,function(){var e,o;return j(this,function(t){switch(t.label){case 0:return this.destroyed?[2]:(e=this.ewColorPicker.getColor())?[4,this.copyToClipboard(e)]:[2];case 1:return o=t.sent(),this.destroyed||(o?(this.showCopiedState(),b(this.options.onCopyColor)&&this.options.onCopyColor(e)):c("[ewColorPicker warning]: Failed to copy color to clipboard")),[2]}})})},this.ewColorPicker=t,this.handleOptions(),this.run(),this.bindCoreEvents()}function ge(t){return{type:t=void 0===t?"linear":t,repeating:!1,angle:{value:180,unit:"deg"},radialShape:"ellipse",radialSize:"farthest-corner",conicFrom:{value:0,unit:"deg"},position:{x:50,y:50},interpolation:null,stops:[]}}function ve(t){return f(f({},t),{angle:f({},t.angle),conicFrom:f({},t.conicFrom),position:f({},t.position),stops:t.stops.map(function(t){return f({},t)})})}function D(t,e,o){return Math.min(Math.max(t,e),o)}function be(t,e){return void 0===e&&(e=1),void 0===t||""===t?e:t.endsWith("%")?D(Number.parseFloat(t)/100,0,1):D(Number.parseFloat(t),0,1)}function Ce(t){return t.endsWith("%")?D(255*Number.parseFloat(t)/100,0,255):D(Number.parseFloat(t),0,255)}function me(t){var t=t.trim().split("/"),e=t[0],t=t[1],e=e.trim();return{channels:e.includes(",")?e.split(",").map(function(t){return t.trim()}):e.split(/\s+/).filter(Boolean),alpha:null==t?void 0:t.trim()}}function ye(t){var e,o,t=/^hsla?\(([^)]*)\)$/i.exec(t);return!t||(e=(t=me(t[1])).channels,t=t.alpha,e.length<3)?null:(o=function(t){return t.endsWith("%"),D(Number.parseFloat(t),0,100)},o=ke((t=>{var e=/^([+-]?(?:\d+\.?\d*|\.\d+))(deg|rad|grad|turn)$/i.exec(t.trim());if(!e)return Number.parseFloat(t)||0;var o=Number.parseFloat(e[1]);switch(e[2].toLowerCase()){case"rad":return 180*o/Math.PI;case"grad":return.9*o;case"turn":return 360*o;default:return o}})(e[0]),o(e[1]),o(e[2])),f(f({},o),{a:be(null!=t?t:e[3])}))}function we(t){if(t&&"string"==typeof t){t=t.trim().toLowerCase();if("transparent"===t)return{r:0,g:0,b:0,a:0};var e=(o=/^#([0-9a-f]{3,8})$/i.exec(o=t))?(e=function(t){return parseInt(t,16)},3===(o=o[1]).length||4===o.length?{r:e(o[0]+o[0]),g:e(o[1]+o[1]),b:e(o[2]+o[2]),a:4===o.length?e(o[3]+o[3])/255:1}:6===o.length||8===o.length?{r:e(o.slice(0,2)),g:e(o.slice(2,4)),b:e(o.slice(4,6)),a:8===o.length?e(o.slice(6,8))/255:1}:null):null;if(e)return e;var o=/^rgba?\(([^)]*)\)$/i.exec(t);if(o)return i=(o=me(o[1])).channels,o=o.alpha,i.length<3?null:{r:Ce(i[0]),g:Ce(i[1]),b:Ce(i[2]),a:be(null!=o?o:i[3])};o=ye(t);if(o)return o;var i=w(t);if(i){o=Bt(i);if(o)return{r:o.r,g:o.g,b:o.b,a:D(o.a,0,1)}}}return null}function ke(t,e,o){var i,n,r,e=e/100,o=o/100,t=(t%360+360)%360/360;return 0==e?{r:r=Math.round(255*o),g:r,b:r,a:1}:(i=(r=function(t,e,o){return o<0&&(o+=1),1<o&&--o,o<1/6?t+6*(e-t)*o:o<.5?e:o<2/3?t+6*(e-t)*(2/3-o):t})(e=2*o-(o=.5<=o?o+e-o*e:o*(1+e)),o,t+1/3),n=r(e,o,t),r=r(e,o,t-1/3),{r:Math.round(255*i),g:Math.round(255*n),b:Math.round(255*r),a:1})}function Pe(t){var e=t.r/255,o=t.g/255,i=t.b/255,t=Math.max(e,o,i),n=Math.min(e,o,i),r=(t+n)/2;if(t===n)return{h:0,s:0,l:100*r};var s=t-n,n=.5<r?s/(2-t-n):s/(t+n),a=0;switch(t){case e:a=(o-i)/s+(o<i?6:0);break;case o:a=(i-e)/s+2;break;default:a=(e-o)/s+4}return{h:60*a,s:100*n,l:100*r}}function xe(t){t/=255;return t<=.04045?t/12.92:Math.pow((.055+t)/1.055,2.4)}function Me(t){t=t<=.00312989?12.92*t:1.055*Math.pow(t,1/2.4)-.055;return D(Math.round(255*t),0,255)}function Be(t){var e=xe(t.r),o=xe(t.g),t=xe(t.b),i=.2119034982*e+.6806995451*o+.1073969566*t,n=.0883024619*e+.2817188376*o+.6299787005*t,e=Math.cbrt(.4122214708*e+.5363325363*o+.0514459929*t),o=Math.cbrt(i),t=Math.cbrt(n);return{l:.2104542553*e+.793617785*o-.0040720468*t,a:1.9779984951*e-2.428592205*o+.4505937099*t,b:.0259040371*e+.7827717662*o-.808675766*t}}function Ie(t){var e=t.l+.3963377774*t.a+.2158037573*t.b,o=t.l-.1055613458*t.a-.0638541728*t.b,t=t.l-.0894841775*t.a-1.291485548*t.b,e=Math.pow(e,3),o=Math.pow(o,3),t=Math.pow(t,3),i=-1.2684380046*e+2.6097574011*o-.3413193965*t,n=-.0041960863*e-.7034186147*o+1.707614701*t;return{r:Me(4.0767416621*e-3.3077115913*o+.2309699292*t),g:Me(i),b:Me(n),a:1}}function Oe(t){var t=Be(t),e=Math.sqrt(t.a*t.a+t.b*t.b),o=180*Math.atan2(t.b,t.a)/Math.PI;return o<0&&(o+=360),{l:t.l,c:e,h:e<1e-4?0:o}}function He(t){return(t%360+360)%360}function Te(t,e,o,i){var t=He(t),n=He(e)-t;switch(i){case"longer":0<n&&n<180&&(n-=360),n<0&&-180<n&&(n+=360);break;case"increasing":n<0&&(n+=360);break;case"decreasing":0<n&&(n-=360);break;default:180<n&&(n-=360),n<-180&&(n+=360)}return He(t+n*o)}function Se(t){var e=(t||[]).map(function(t){return t.position});if(0===e.length)return[];void 0===e[0]&&(e[0]=0),void 0===e[e.length-1]&&(e[e.length-1]=100);for(var o=0;o<e.length;)if(void 0!==e[o])o+=1;else{for(var i=o;i<e.length&&void 0===e[i];)i+=1;for(var n=e[o-1],r=e[i],s=i-(o-1),a=0;a<i-o;a+=1)e[o+a]=n+(r-n)*(a+1)/s;o=i}return e.map(function(t){return D(t,0,100)})}function Ee(t){return Math.round(D(t,0,255))}function De(t,e,o){r=[],(t||[]).forEach(function(t){var e;void 0!==t.position2?(r.push({color:t.color,position:null!=(e=t.position)?e:0}),r.push({color:t.color,position:t.position2})):r.push(f({},t))}),i=Se(t=r),n=[],t.forEach(function(t,e){t=we(t.color);t&&n.push({color:t,position:D(i[e],0,100)})});var i,n,r,s=n.sort(function(t,e){return t.position-e.position});if(0===s.length)return"";var a=D(e,0,100);if(a<=s[0].position)return Ne(s[0].color);t=s[s.length-1];if(a>=t.position)return Ne(t.color);for(var l,c=s[0],h=t,u=0;u<s.length-1;u+=1){var p=s[u],d=s[u+1];if(a>=p.position&&a<=d.position){c=p,h=d;break}}return h.position===c.position?Ne(h.color):(e=(a-c.position)/(h.position-c.position),t={space:"srgb",hue:"shorter"},(o=o)&&(l=(o=o.trim().toLowerCase().split(/\s+/))[0],["srgb","srgb-linear","hsl","oklab","oklch","lab","lch","hwb"].includes(l)&&(t.space=l),0<(l=o.findIndex(function(t){return"hue"===t})))&&("shorter"!==(o=o[l-1])&&"longer"!==o&&"increasing"!==o&&"decreasing"!==o||(t.hue=o)),l=t,o=c.color.a+(h.color.a-c.color.a)*e,t=((i,n,r,t)=>{switch(t.space){case"hsl":var e=Pe(i),o=Pe(n),s=Te(e.h,o.h,r,t.hue);return f(f({},ke(s,e.s+(o.s-e.s)*r,e.l+(o.l-e.l)*r)),{a:1});case"oklab":e=Be(i),o=Be(n);return f(f({},Ie({l:e.l+(o.l-e.l)*r,a:e.a+(o.a-e.a)*r,b:e.b+(o.b-e.b)*r})),{a:1});case"oklch":e=Oe(i),o=Oe(n),s=Te(e.h,o.h,r,t.hue);return f(f({},(t=>{var e=t.h*Math.PI/180;return Ie({l:t.l,a:t.c*Math.cos(e),b:t.c*Math.sin(e)})})({l:e.l+(o.l-e.l)*r,c:e.c+(o.c-e.c)*r,h:s})),{a:1});case"srgb-linear":var a={r:0,g:0,b:0,a:1};return["r","g","b"].forEach(function(t){var e=xe(i[t]),o=xe(n[t]);a[t]=Me(e+(o-e)*r)}),a;default:return{r:Ee(i.r+(n.r-i.r)*r),g:Ee(i.g+(n.g-i.g)*r),b:Ee(i.b+(n.b-i.b)*r),a:1}}})(c.color,h.color,e,l),Ne(f(f({},t),{a:o})))}function Ne(t){var e=Math.round(D(t.r,0,255)),o=Math.round(D(t.g,0,255)),i=Math.round(D(t.b,0,255)),t=Number(D(t.a,0,1).toFixed(2));return"rgba(".concat(e,", ").concat(o,", ").concat(i,", ").concat(t,")")}var Ae=/^(repeating-)?(linear|radial|conic)-gradient\s*\(([\s\S]*)\)\s*$/i,_e=/^([+-]?(?:\d+\.?\d*|\.\d+))(deg|rad|grad|turn)$/i,ze=/^([+-]?(?:\d+\.?\d*|\.\d+))%$/,Ve=/^[+-]?(?:\d+\.?\d*|\.\d+)(px|em|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ch|ex|q)$/i,Le=["circle","ellipse"],Fe=["closest-side","closest-corner","farthest-side","farthest-corner"],je={top:0,right:90,bottom:180,left:270,"top right":45,"right top":45,"bottom right":135,"right bottom":135,"bottom left":225,"left bottom":225,"top left":315,"left top":315};function Re(t){c("[ewColorPicker warning]: Invalid gradient syntax: ".concat(t))}function We(t){var t=t.trim();return/^[+-]?0(\.0+)?$/.test(t)?{value:0,unit:"deg"}:(t=_e.exec(t))?{value:Number.parseFloat(t[1]),unit:t[2].toLowerCase()}:null}function Ue(t){var e=ze.exec(t.trim());return e?Number.parseFloat(e[1]):/^[+-]?0$/.test(t.trim())?0:null}function $e(t,e){if("center"!==t){if("x"===e){if("left"===t)return 0;if("right"===t)return 100}if("y"===e){if("top"===t)return 0;if("bottom"===t)return 100}}return 50}function Ge(t){var e,o;return 0===t.length||2<t.length?null:1===t.length?(e=t[0].trim().toLowerCase(),Ve.test(e)?null:"left"===e||"right"===e||"center"===e?{x:$e(e,"x"),y:50}:"top"===e||"bottom"===e?{x:50,y:$e(e,"y")}:null===(e=Ue(e))?null:{x:e,y:50}):(t=(e=t.map(function(t){return t.trim().toLowerCase()}))[0],e=e[1],Ve.test(t)||Ve.test(e)||(o=null,o="left"===t||"right"===t||"center"===t?$e(t,"x"):Ue(t),t=null,t="top"===e||"bottom"===e||"center"===e?$e(e,"y"):Ue(e),null===o)||null===t?null:{x:o,y:t})}function qe(t){return Math.min(Math.max(t,0),100)}function Xe(t){var e=t.trim();if(!e)return null;for(var o,i=[];i.length<2;){var n=/(?:^|\s)([+-]?(?:\d+\.?\d*|\.\d+))%\s*$/.exec(e);if(!n)break;i.unshift(qe(Number.parseFloat(n[1]))),e=e.slice(0,n.index).trim()}return/\s[+-]?(?:\d+\.?\d*|\.\d+)(px|em|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ch|ex|q)\s*$/i.test(e)?(Re('stop position must be a percentage, got "'.concat(e,'"')),null):/\s[+-]?((?:\d+\.?\d*)|(?:\.\d+))%\s*$/.test(e)?(Re('stop has more than two positions: "'.concat(t,'"')),null):(t=e.trim())&&null!==we(t)?(o={color:t},0<i.length&&(o.position=i[0]),1<i.length&&(o.position2=i[1]),o):(Re('unsupported stop color "'.concat(t,'"')),null)}function Ye(t){if(0===t.length)return{};var e={},o=0,i=t[0].toLowerCase(),i=(Le.includes(i)&&(e.radialShape=i,o=1),t.slice(o));if(0===i.length)return e.radialShape?e:null;if(1===i.length&&Fe.includes(i[0].toLowerCase()))e.radialSize=i[0].toLowerCase();else{if(!i.every(function(t){return ze.test(t)||Ve.test(t)})||2<i.length)return null;e.radialSize=i.join(" ")}return e.radialShape||(e.radialShape="ellipse"),e}function Ke(t){if("string"!=typeof t||!t.trim())return null;var e=Ae.exec(t.trim());if(!e)return Re('not a supported gradient: "'.concat(t,'"')),null;var t=Boolean(e[1]),o=e[2].toLowerCase(),i=ge(o),t=(i.repeating=t,((t,e)=>{void 0===e&&(e=",");for(var o=[],i=0,n="",r=0,s=t;r<s.length;r++){var a=s[r];"("===a&&(i+=1),")"===a&&(i=Math.max(0,i-1)),a===e&&0===i?(o.push(n),n=""):n+=a}return o.push(n),o.map(function(t){return t.trim()})})(e[3]).filter(Boolean));if(0===t.length)return null;var n,r,s=(s=/\bin\s+((?:srgb(?:-linear)?|lab|oklab|lch|oklch|hsl|hwb)(?:\s+(?:shorter|longer|increasing|decreasing)\s+hue)?)/i.exec(e=t[0]))?{interpolation:s[1].toLowerCase().replace(/\s+/g," "),remaining:(e.slice(0,s.index)+e.slice(s.index+s[0].length)).trim()}:{interpolation:null,remaining:e.trim()},e=s.interpolation,s=s.remaining,e=null!==(i.interpolation=e),a=null;(a=""!==s?"linear"===o?(n=s)?(n=n.trim().toLowerCase()).startsWith("to ")?(r=n.slice(3).trim(),void 0===(r=je[r])?null:{angle:{value:r,unit:"deg"}}):(r=We(n))?{angle:r}:null:{}:("radial"===o?t=>{if(!t)return{};var e=(t=t.trim().split(/\s+/).filter(Boolean)).findIndex(function(t){return"at"===t.toLowerCase()}),o=t,i=[];if(0<=e&&(o=t.slice(0,e),i=t.slice(e+1)),0<i.length){t=Ge(i);if(!t)return null;e={position:t};if(0<o.length){i=Ye(o);if(!i)return null;Object.assign(e,i)}return e}return Ye(o)}:t=>{if(!t)return{};var t=t.trim().split(/\s+/).filter(Boolean),e={},o=0;if("from"===(null==(i=t[o])?void 0:i.toLowerCase())){var i=We(t[o+1]||"");if(!i)return null;e.conicFrom=i,o+=2}if("at"===(null==(i=t[o])?void 0:i.toLowerCase())){i=Ge(t.slice(o+1));if(!i)return null;e.position=i,o=t.length}return o<t.length?null:e})(s):a)&&(e=!0,Object.assign(i,a));for(var l=[],c=0,h=e?t.slice(1):t;c<h.length;c++){var u=Xe(h[c]);if(!u)return null;l.push(u)}return l.length<2?(Re("gradient requires at least two color stops"),null):(i.stops=l,i)}function Qe(t){return String(Number(t.toFixed(3)))}function Ze(t){var e=t.unit||"deg";return"".concat(Qe(t.value)).concat(e)}function Je(t){var e=[t.color];return void 0!==t.position&&e.push("".concat(Qe(qe(t.position)),"%")),void 0!==t.position2&&e.push("".concat(Qe(qe(t.position2)),"%")),e.join(" ")}var to={minGradientStops:2,maxGradientStops:8,syncStopsOnChange:!0};function eo(t,e,o){return Math.min(Math.max(t,e),o)}function oo(t){return Math.round(10*eo(t,0,100))/10}Object.defineProperty(A.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),A.prototype.install=function(t){this.ewColorPicker=t,this.destroyed=!1,this.handleOptions(),this.gradientRef=this.options.gradient,this.stopsRef=this.options.gradientStops,this.initValue(),this.bindCoreEvents(),this.run()},A.prototype.handleOptions=function(){var t=null==(t=this.ewColorPicker)?void 0:t.options;this.options=l({},to,this.options,t||{})},A.prototype.updateOptions=function(){this.handleOptions();var t=this.options.gradient!==this.gradientRef,e=this.options.gradientStops!==this.stopsRef;this.gradientRef=this.options.gradient,this.stopsRef=this.options.gradientStops,(t||e)&&this.initValue(),this.run()},A.prototype.run=function(){this.ewColorPicker&&(this.shouldRender()?this.isPanelDisabled()?(c("[ewColorPicker warning]: Gradient plugin requires the panel. Set hasPanel: false disables the gradient editor."),this.removeContainer()):this.render():this.removeContainer())},A.prototype.shouldRender=function(){return!1!==this.options.showGradient&&(!0===this.options.showGradient||void 0!==this.options.gradient||Array.isArray(this.options.gradientStops)&&0<this.options.gradientStops.length)},A.prototype.isPanelDisabled=function(){return!1===this.options.hasPanel||!1===this.options.ewColorPickerPanel},A.prototype.getCurrentColor=function(){var t=this.ewColorPicker;return t&&((b(t.getColor)?t.getColor():"")||(null==(t=t.options)?void 0:t.defaultColor))||"#ff0000"},A.prototype.initValue=function(){var t,e=this.options,o=e.gradient,i=e.gradientStops,n=e.gradientType,r=e.gradientRepeating,s=e.gradientAngle,e=e.gradientInterpolation,a=null;"string"==typeof o?(t=Ke(o))?a=t:c('[ewColorPicker warning]: Unable to parse gradient "'.concat(o,'", fallback to default stops.')):o&&"object"==typeof o&&(a=ve(l(ge(o.type||"linear"),o))),a||(a=ge(n||"linear"),t=Array.isArray(i)&&0<i.length?i:[this.getCurrentColor(),"#ffffff"],a.stops=t.map(function(t){return"string"==typeof t?{color:t}:f({},t)})),n&&(a.type=n),"boolean"==typeof r&&(a.repeating=r),"number"==typeof s&&(a.angle={value:s,unit:"deg"}),void 0!==e&&(a.interpolation=e||null),a.stops=this.normalizeStops(a.stops,a),this.value=a,this.selectedIndex=0},A.prototype.normalizeStops=function(t,e){void 0===e&&(e=this.value);var o=null!=(o=this.options.maxGradientStops)?o:8,t=(t||[]).map(function(t){return f({},t)});return t.length>o?(c("[ewColorPicker warning]: maxGradientStops is ".concat(o,", extra stops are ignored.")),t.slice(0,o)):0===t.length?[{color:(null==(e=null==(o=e.stops)?void 0:o[0])?void 0:e.color)||this.getCurrentColor()},{color:"#ffffff"}]:1===t.length?[t[0],{color:"#ffffff"}]:t},A.prototype.bindCoreEvents=function(){!this.changeBound&&this.ewColorPicker&&(this.ewColorPicker.on("change",this.handleCoreChange),this.changeBound=!0)},A.prototype.emitChange=function(){b(this.options.gradientChange)&&this.options.gradientChange(this.getGradient(),this.getGradientValue())},A.prototype.applySelectedStopColor=function(){var t=this.ewColorPicker,e=this.value.stops[this.selectedIndex];if(t&&null!=e&&e.color){this.syncing=!0;try{t.setColor(e.color)}finally{this.syncing=!1}}},A.prototype.render=function(){var t,e,o=this.ewColorPicker;o&&((o=o.getMountPoint("panelContainer"))?(this.removeContainer(),e=this.prefix,t=h("div"),u(t,"".concat(e,"gradient-container")),this.container=t,this.buildPreview(t),this.buildTypeRow(t),"radial"===this.value.type&&this.buildRadialRow(t),"radial"!==this.value.type&&"conic"!==this.value.type||this.buildPositionRow(t),this.buildInterpolationRow(t),this.buildStopRow(t),e=g(".".concat(e,"color-picker-bottom-row"),o),v(o,t,null,e),this.updatePreview(),this.syncStopInputs()):(c("[ewColorPicker warning]: Panel container not found"),this.removeContainer()))},A.prototype.createRow=function(t){void 0===t&&(t="");var e=h("div");return u(e,"".concat(this.prefix,"gradient-row")),t&&u(e,t),e},A.prototype.createLabel=function(t){var e=h("span");return u(e,"".concat(this.prefix,"gradient-label")),e.textContent=t,e},A.prototype.createButton=function(t){var e=h("button");return u(e,"".concat(this.prefix,"gradient-btn")),d(e,{type:"button"}),e.textContent=t,e},A.prototype.createSelect=function(t){t=new oe(f({prefix:this.prefix,size:"small",clearable:!1},t));return this.selects.push(t),t},A.prototype.createNumber=function(t){t=new Jt(f({prefix:this.prefix,size:"small"},t));return this.numbers.push(t),t},A.prototype.createCheckbox=function(t){t=new re(f({prefix:this.prefix,size:"small"},t));return this.checkboxes.push(t),t},A.prototype.buildPreview=function(t){var e=this.prefix,o=h("div"),i=(u(o,"".concat(e,"gradient-preview")),h("div"));u(i,"".concat(e,"gradient-preview-bar")),this.bar=i,v(o,i),v(t,o),C(o,"click",this.handlePreviewClick)},A.prototype.updatePreview=function(){this.bar&&(this.bar.style.background=this.buildPreviewCss(),this.renderHandles())},A.prototype.buildPreviewCss=function(){var o=this.getResolvedPositions(),t=this.value.stops.map(function(t,e){return"".concat(t.color," ").concat(o[e],"%")}).join(", ");return"linear-gradient(90deg, ".concat(t,")")},A.prototype.getResolvedPositions=function(){return Se(this.value.stops).map(oo)},A.prototype.renderHandles=function(){var i,n,r=this;this.bar&&(i=this.prefix,this.bar.textContent="",n=this.getResolvedPositions(),this.value.stops.forEach(function(t,e){var o=h("button");u(o,"".concat(i,"gradient-handle")),e===r.selectedIndex&&u(o,"".concat(i,"gradient-handle-active")),d(o,{type:"button","data-gradient-index":e,"aria-label":"".concat(t.color," ").concat(n[e],"%"),title:"".concat(t.color," ").concat(n[e],"%")}),o.style.left="".concat(n[e],"%"),o.style.backgroundColor=t.color,C(o,"mousedown",function(t){return r.handleHandleMousedown(t,e)}),v(r.bar,o)}))},A.prototype.handleHandleMousedown=function(t,e){t.preventDefault(),t.stopPropagation(),this.selectStop(e),this.draggingIndex=e,C(document,"mousemove",this.handleDocumentMove),C(document,"mouseup",this.handleDocumentUp)},A.prototype.getPositionByClientX=function(t){var e,o=this.bar;return o?(o=(e=a(o)).width||o.offsetWidth||285,oo((t-(e.left||0))/o*100)):0},A.prototype.buildTypeRow=function(t){var e,o=this,i=this.prefix,n=this.createRow("".concat(i,"gradient-row-type")),r=(v(n,this.createLabel("类型")),h("div")),i=(u(r,"".concat(i,"gradient-select")),this.createSelect({value:this.value.type,items:[{label:"Linear",value:"linear"},{label:"Radial",value:"radial"},{label:"Conic",value:"conic"}],onChange:function(t){t!==o.value.type&&(o.value.type=t,o.render(),o.emitChange())}})),i=(v(r,i.getElement()),v(n,r),this.createCheckbox({label:"Repeating",checked:this.value.repeating,onChange:function(t){o.value.repeating=t,o.emitChange()}}));v(n,i.getElement()),"radial"!==this.value.type&&(e="conic"===this.value.type,v(n,this.createLabel(e?"起始角":"角度")),this.angleInput=this.createNumber({value:(t=>{switch(t.unit){case"rad":return 180*t.value/Math.PI;case"grad":return.9*t.value;case"turn":return 360*t.value;default:return t.value}})(e?this.value.conicFrom:this.value.angle),min:0,max:360,step:1,precision:0,onChange:function(t){e?o.value.conicFrom={value:t,unit:"deg"}:o.value.angle={value:t,unit:"deg"},o.emitChange()}}),v(n,this.angleInput.getElement())),v(t,n)},A.prototype.buildRadialRow=function(t){var e=this,o=this.prefix,i=this.createRow("".concat(o,"gradient-row-radial")),n=(v(i,this.createLabel("形状")),h("div")),r=(u(n,"".concat(o,"gradient-select")),this.createSelect({value:this.value.radialShape,items:[{label:"Ellipse",value:"ellipse"},{label:"Circle",value:"circle"}],onChange:function(t){e.value.radialShape=t,e.emitChange()}})),r=(v(n,r.getElement()),v(i,n),v(i,this.createLabel("尺寸")),h("div")),n=(u(r,"".concat(o,"gradient-select")),["closest-side","closest-corner","farthest-side","farthest-corner"]),s=this.createSelect({value:n.includes(this.value.radialSize)?this.value.radialSize:"farthest-corner",items:n.map(function(t){return{label:t,value:t}}),onChange:function(t){e.value.radialSize=String(t),e.sizeInput&&(e.sizeInput.value=""),e.emitChange()}}),a=(v(r,s.getElement()),v(i,r),h("input"));u(a,"".concat(o,"gradient-text")),d(a,{type:"text",placeholder:"自定义尺寸"}),a.value=n.includes(this.value.radialSize)?"":this.value.radialSize,C(a,"change",function(){var t=a.value.trim();e.value.radialSize=t||"farthest-corner",e.emitChange()}),this.sizeInput=a,v(i,a),v(t,i)},A.prototype.buildPositionRow=function(t){var e=this,o=this.prefix,o=this.createRow("".concat(o,"gradient-row-position"));v(o,this.createLabel("位置")),this.atXInput=this.createNumber({value:this.value.position.x,min:0,max:100,step:1,precision:0,onChange:function(t){e.value.position.x=eo(t,0,100),e.emitChange()}}),v(o,this.atXInput.getElement()),this.atYInput=this.createNumber({value:this.value.position.y,min:0,max:100,step:1,precision:0,onChange:function(t){e.value.position.y=eo(t,0,100),e.emitChange()}}),v(o,this.atYInput.getElement()),v(t,o)},A.prototype.buildInterpolationRow=function(t){var e=this,o=this.prefix,i=this.createRow("".concat(o,"gradient-row-interp")),n=(v(i,this.createLabel("插值")),h("div")),o=(u(n,"".concat(o,"gradient-select")),this.value.interpolation||"default"),o=this.createSelect({value:o,items:[{label:"Default",value:"default"},{label:"sRGB",value:"srgb"},{label:"sRGB linear",value:"srgb-linear"},{label:"OKLab",value:"oklab"},{label:"OKLCH",value:"oklch"},{label:"HSL shorter",value:"hsl shorter hue"},{label:"HSL longer",value:"hsl longer hue"},{label:"OKLCH longer",value:"oklch longer hue"}],onChange:function(t){e.value.interpolation="default"===t?null:String(t),e.emitChange()}});v(n,o.getElement()),v(i,n),v(t,i)},A.prototype.buildStopRow=function(t){var i=this,e=this.prefix,e=this.createRow("".concat(e,"gradient-row-stop")),o=(v(e,this.createLabel("停靠点")),this.value.stops[this.selectedIndex]),n=null!=(r=this.getResolvedPositions()[this.selectedIndex])?r:0,o=(this.posInput=this.createNumber({value:n,min:0,max:100,step:1,precision:0,onChange:function(t){var e=i.value.stops[i.selectedIndex];e&&(e.position=eo(t,0,100),i.updatePreview(),i.emitChange())}}),v(e,this.posInput.getElement()),v(e,this.createLabel("~")),this.pos2Input=this.createNumber({value:null!=(r=null==o?void 0:o.position2)?r:n,min:0,max:100,step:1,precision:0,onChange:function(t){var e,o=i.value.stops[i.selectedIndex];o&&(t===(null!=(e=o.position)?e:n)?delete o.position2:o.position2=eo(t,0,100),i.updatePreview(),i.emitChange())}}),v(e,this.pos2Input.getElement()),this.createButton("删除")),r=(C(o,"click",function(){i.removeStopInternal(i.selectedIndex)}),v(e,o),this.createButton("新增"));C(r,"click",function(){i.addStopInternal(De(i.value.stops,50,i.value.interpolation)||i.getCurrentColor(),50)}),v(e,r),v(t,e)},A.prototype.selectStop=function(t,e){void 0===e&&(e=!0),t<0||t>=this.value.stops.length||(this.selectedIndex=t,this.renderHandles(),this.syncStopInputs(),e&&this.applySelectedStopColor())},A.prototype.syncStopInputs=function(){var t,e=this.getResolvedPositions(),o=this.value.stops[this.selectedIndex];o&&(e=null!=(e=e[this.selectedIndex])?e:0,null!=(t=this.posInput)&&t.setValue(e,!1),null!=(t=this.pos2Input))&&t.setValue(null!=(t=o.position2)?t:e,!1)},A.prototype.addStopInternal=function(t,e){var o,i,n,r=this,s=null!=(s=this.options.maxGradientStops)?s:8;return this.value.stops.length>=s?(c("[ewColorPicker warning]: Cannot add more than ".concat(s," gradient stops.")),-1):(o={color:t},void 0!==e&&(o.position=oo(e)),i=this.getResolvedPositions(),n=void 0!==o.position?o.position:50,this.value.stops.push(o),s=this.value.stops.map(function(t,e){return{item:t,position:e===r.value.stops.length-1?n:i[e]}}).sort(function(t,e){return t.position-e.position}),this.value.stops=s.map(function(t){return t.item}),this.selectedIndex=s.findIndex(function(t){return t.item===o}),this.updatePreview(),this.syncStopInputs(),this.emitChange(),this.selectedIndex)},A.prototype.removeStopInternal=function(t){var t=void 0===t?this.selectedIndex:t,e=null!=(e=this.options.minGradientStops)?e:2;return this.value.stops.length<=e?(c("[ewColorPicker warning]: At least ".concat(e," gradient stops are required.")),!1):!(t<0||t>=this.value.stops.length||(this.value.stops.splice(t,1),this.selectedIndex=eo(t,0,Math.max(this.value.stops.length-1,0)),this.updatePreview(),this.syncStopInputs(),this.emitChange(),0))},A.prototype.removeContainer=function(){this.destroyComponents(),this.container&&n(this.container),this.container=null,this.bar=null,this.sizeInput=null,this.draggingIndex=-1},A.prototype.destroyComponents=function(){this.selects.forEach(function(t){return t.destroy()}),this.selects=[],this.numbers.forEach(function(t){return t.destroy()}),this.numbers=[],this.checkboxes.forEach(function(t){return t.destroy()}),this.checkboxes=[],this.angleInput=null,this.atXInput=null,this.atYInput=null,this.posInput=null,this.pos2Input=null},A.prototype.getGradient=function(){return t=ve(t=this.value),i="".concat(t.repeating?"repeating-":"").concat(t.type,"-gradient"),n=t.interpolation?" in ".concat(t.interpolation):"",r=t.stops.map(Je).join(", "),s="".concat(Qe(qe(t.position.x)),"% ").concat(Qe(qe(t.position.y)),"%"),("linear"===t.type?"".concat(i,"(").concat(Ze(t.angle)):("radial"===t.type?(e=t.radialShape||"ellipse",o=t.radialSize||"farthest-corner","".concat(i,"(").concat(e," ").concat(o," at ")):"".concat(i,"(from ").concat(Ze(t.conicFrom)," at ")).concat(s)).concat(n,", ").concat(r,")");var t,e,o,i,n,r,s},A.prototype.getGradientValue=function(){return ve(this.value)},A.prototype.getStops=function(){return this.value.stops.map(function(t){return f({},t)})},A.prototype.setGradient=function(t){if("string"==typeof t){var e=Ke(t);if(!e)return void c('[ewColorPicker warning]: Unable to set invalid gradient "'.concat(t,'".'));this.value=e}else t&&"object"==typeof t&&(e=ve(this.value),t.type&&(e.type=t.type),"boolean"==typeof t.repeating&&(e.repeating=t.repeating),t.angle&&(e.angle=f({},t.angle)),t.radialShape&&(e.radialShape=t.radialShape),t.radialSize&&(e.radialSize=t.radialSize),t.conicFrom&&(e.conicFrom=f({},t.conicFrom)),t.position&&(e.position=f({},t.position)),void 0!==t.interpolation&&(e.interpolation=t.interpolation||null),Array.isArray(t.stops)&&(e.stops=t.stops.map(function(t){return f({},t)})),this.value=e);this.value.stops=this.normalizeStops(this.value.stops),this.selectedIndex=eo(this.selectedIndex,0,Math.max(this.value.stops.length-1,0)),this.render()},A.prototype.setStops=function(t){t=(t||[]).map(function(t){return"string"==typeof t?{color:t}:f({},t)});this.value.stops=this.normalizeStops(t),this.selectedIndex=eo(this.selectedIndex,0,Math.max(this.value.stops.length-1,0)),this.updatePreview(),this.syncStopInputs()},A.prototype.addStop=function(t,e){return this.addStopInternal(t,e)},A.prototype.removeStop=function(t){return this.removeStopInternal(t)},A.prototype.destroy=function(){this.destroyed=!0,this.ewColorPicker&&this.changeBound&&(this.ewColorPicker.off("change",this.handleCoreChange),this.changeBound=!1),this.handleDocumentUp(),this.removeContainer()},A.pluginName="ewColorPickerGradient",A.applyOrder=N.Post;var N=A;function A(t){var i=this;this.options={},this.value=ge(),this.selectedIndex=0,this.syncing=!1,this.destroyed=!1,this.changeBound=!1,this.gradientRef=void 0,this.stopsRef=void 0,this.container=null,this.bar=null,this.sizeInput=null,this.selects=[],this.numbers=[],this.checkboxes=[],this.angleInput=null,this.atXInput=null,this.atYInput=null,this.posInput=null,this.pos2Input=null,this.draggingIndex=-1,this.handleCoreChange=function(t){var e;i.destroyed||i.syncing||!1!==i.options.syncStopsOnChange&&t&&(e=i.value.stops[i.selectedIndex])&&(w(e.color)||e.color)!==(w(t)||t)&&(e.color=t,i.updatePreview(),i.emitChange())},this.handleDocumentMove=function(t){var e,o;i.draggingIndex<0||(o=i.value.stops[i.draggingIndex])&&(t=i.getPositionByClientX(t.clientX),o.position=t,null!=(e=i.posInput)&&e.setValue(t,!1),void 0!==o.position2&&null!=(e=i.pos2Input)&&e.setValue(t,!1),i.renderHandles(),i.bar&&(i.bar.style.background=i.buildPreviewCss()),i.emitChange())},this.handleDocumentUp=function(){i.draggingIndex=-1,m(document,"mousemove",i.handleDocumentMove),m(document,"mouseup",i.handleDocumentUp)},this.handlePreviewClick=function(t){var e=t.target;e&&!e.closest(".".concat(i.prefix,"gradient-handle"))&&(e=i.getPositionByClientX(t.clientX),t=De(i.value.stops,e,i.value.interpolation)||i.getCurrentColor(),i.addStopInternal(t,e))},this.ewColorPicker=t,this.handleOptions(),this.gradientRef=this.options.gradient,this.stopsRef=this.options.gradientStops,this.initValue(),this.bindCoreEvents(),this.run()}P.use(K),P.use(X),P.use(q),P.use(Kt),P.use(Qt),P.use(Zt),P.use(te),P.use(ie),P.use(ae),P.use(ce),P.use(he),P.use(ue),P.use(pe),P.use(fe),P.use(N),"undefined"!=typeof window&&(window.ewColorPicker=P),_.createEwColorPicker=function(t){return new P(t)},_.default=P,_.ewColorPicker=P,Object.defineProperty(_,"__esModule",{value:!0})});
1
+ ((t,e)=>{"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ewColorPicker={})})(this,function(_){var z=function(t,e){return(z=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}))(t,e)};function V(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}z(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var f=function(){return(f=Object.assign||function(t){for(var e,o=1,i=arguments.length;o<i;o++)for(var n in e=arguments[o])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}).apply(this,arguments)};function L(t,e){var o={};for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(o[n[i]]=t[n[i]]);return o}function F(t,s,a,l){return new(a=a||Promise)(function(o,e){function i(t){try{r(l.next(t))}catch(t){e(t)}}function n(t){try{r(l.throw(t))}catch(t){e(t)}}function r(t){var e;t.done?o(t.value):((e=t.value)instanceof a?e:new a(function(t){t(e)})).then(i,n)}r((l=l.apply(t,s||[])).next())})}function R(i,n){var r,s,a,l={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return c.next=t(0),c.throw=t(1),c.return=t(2),"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function t(o){return function(t){var e=[o,t];if(r)throw new TypeError("Generator is already executing.");for(;l=c&&e[c=0]?0:l;)try{if(r=1,s&&(a=2&e[0]?s.return:e[0]?s.throw||((a=s.return)&&a.call(s),0):s.next)&&!(a=a.call(s,e[1])).done)return a;switch(s=0,(e=a?[2&e[0],a.value]:e)[0]){case 0:case 1:a=e;break;case 4:return l.label++,{value:e[1],done:!1};case 5:l.label++,s=e[1],e=[0];continue;case 7:e=l.ops.pop(),l.trys.pop();continue;default:if(!(a=0<(a=l.trys).length&&a[a.length-1])&&(6===e[0]||2===e[0])){l=0;continue}if(3===e[0]&&(!a||e[1]>a[0]&&e[1]<a[3]))l.label=e[1];else if(6===e[0]&&l.label<a[1])l.label=a[1],a=e;else{if(!(a&&l.label<a[2])){a[2]&&l.ops.pop(),l.trys.pop();continue}l.label=a[2],l.ops.push(e)}}e=n.call(i,l)}catch(t){e=[6,t],s=0}finally{r=a=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}}function j(t,e,o){if(o||2===arguments.length)for(var i,n=0,r=e.length;n<r;n++)!i&&n in e||((i=i||Array.prototype.slice.call(e,0,n))[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}function W(){}function U(t){return void 0===t}function $(t){return"boolean"==typeof t}function G(t){return"object"===Q.call(t).slice(8,-1).toLowerCase()}function X(t,e){try{t()}catch(t){h(e)?e(t):Y("[ewColorPicker error]: ".concat(t))}}var q={log:W,warn:W,error:W},c=(["warn","error","log"].forEach(function(t){q[t]=function(){}}),q.warn),Y=q.error,K=q.log,Q=Object.prototype.toString,Z=Object.prototype.hasOwnProperty,J=285,tt=function(t){return null===t},et=function(t){return"string"==typeof t},ot=function(t){return"number"==typeof t},h=function(t){return"function"==typeof t},it=function(t){return"object"==typeof t&&!tt(t)},nt="undefined"!=typeof window,rt=nt&&navigator.userAgent.toLowerCase(),st=(rt&&rt.match(/(iPhone|iPod|Android|ios)/i),!1);if(nt)try{var at={};Object.defineProperty(at,"passive",{get:function(){st=!0}}),window.addEventListener("test-passive",function(){},at)}catch(Y){}function l(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];if(tt(t))return{};if(Object.assign)return Object.assign.apply(Object,j([t],e,!1));for(var i=Object(t),n=0,r=e.length;n<r;n++){var s=e[n];if(s)for(var a in s)Z.call(s,a)&&(i[a]=s[a])}return i}function u(t){return document.createElement(t)}function lt(t,e){return new RegExp("(^|\\s)"+e+"(\\s|$)").test(t.className)}function p(t,e){for(var o=0,i=e.trim().split(/\s+/);o<i.length;o++){var n,r=i[o];r&&!lt(t,r)&&((n=t.className.split(" ").filter(Boolean)).push(r),t.className=n.join(" "))}}function s(t,e){lt(t,e)&&(e=new RegExp("(^|\\s)"+e+"(\\s|$)","g"),t.className=t.className.replace(e," "))}function ct(t){return t instanceof HTMLElement}function ht(t,e,o){e=e.startsWith("--")?e:e.replace(/([A-Z])/g,"-$1").toLowerCase(),t.style.setProperty(e,o)}function d(o,t,e){if(et(t=void 0===t?{}:t)&&!U(e)){e=ot(e)?"".concat(e,"px"):e;ht(o,t,e)}else if(Array.isArray(t))t.forEach(function(t){var e=t.prop;ht(o,e,t.value)});else for(var i=0,n=Object.entries(t);i<n.length;i++){var r=n[i],s=r[0];ht(o,s,r[1])}}function ut(t,e){for(var o=0,i=e=void 0===e?[]:e;o<i.length;o++){var n=i[o];t.style.removeProperty(n)}}function pt(e,o,i){var n;return e&&o?("float"===(o=o.replace(/([\:\_\-]+(.))/g,function(t,e,o,i){return i?o.toUpperCase():o}).replace(/^moz([A-Z])/,"Moz$1"))&&(o="cssFloat"),n=null,X(function(){var t=(document.defaultView||window).getComputedStyle(e,i);n=e.style[o]||t?t[o]:null}),n||e.style[o]):null}function g(t,e){if(it(e))for(var o=0,i=Object.entries(e);o<i.length;o++){var n=i[o],r=n[0];t.setAttribute(r,"".concat(n[1]))}}function v(t,e){return(e=void 0===e?document:e).querySelector(t)}function n(t){var e;null!=t&&t.parentElement?null!=(e=null==t?void 0:t.parentElement)&&e.removeChild(t):null!=t&&t.remove()}function b(t,e,o,i){i&&null!=t&&t.contains(i)?t.insertBefore(e,i):o&&null!=t&&t.contains(o)?t.replaceChild(e,o):null!=t&&t.appendChild(e)}function dt(t){return et(t)?v(t)||(c("[ewColorPicker warning]: Cannot find element with selector: ".concat(t)),document.body):ct(t)?t:document.body}var ft=function(t){return t.replace(/\s+/g,"")},gt=function(t){return t?" ".concat(t):""};function a(t){return t.getBoundingClientRect()}function C(t,e,o,i){i=st?{passive:!1,capture:!!i}:!!i,t.addEventListener(e,o,i)}function m(t,e,o,i){t.removeEventListener(e,o,{capture:!!i})}function vt(t,e,o,i){return void 0===i&&(i=!1),t=Math.max(0,Math.min(1,0<o?(t-e)/o:0)),i?1-t:t}function bt(e,t){function o(t){return e(t)}function i(){m(document,"mousemove",o),m(document,"mouseup",i),null!=t&&t()}return C(document,"mousemove",o),C(document,"mouseup",i),i}function Ct(e,t){function o(t){return e(t)}function i(){m(document,"touchmove",o),m(document,"touchend",i),null!=t&&t()}C(document,"touchmove",o,{passive:!1}),C(document,"touchend",i)}(rt=N=N||{}).Pre="pre",rt.Post="post",mt.prototype.on=function(t,e,o){return void 0===o&&(o=this),this.hasType(t),this.events[t]||(this.events[t]=[]),this.events[t].push([e,o]),this},mt.prototype.once=function(i,n,r){var s=this,a=(void 0===r&&(r=this),this.hasType(i),function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];s.off(i,a);var o=n.apply(r,t);if(!0===o)return o});return a.fn=n,this.on(i,a),this},mt.prototype.off=function(t,e){if(!t&&!e)return this.events={},this;if(t){if(this.hasType(t),e){var o=this.events[t];if(o)for(var i=o.length;i--;)(o[i][0]===e||o[i][0]&&o[i][0].fn===e)&&o.splice(i,1)}else this.events[t]=[];return this}},mt.prototype.trigger=function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];this.hasType(t);t=this.events[t];if(t)for(var i=t.length,n=j([],t,!0),r=0;r<i;r++){var s=n[r],a=s[0],s=s[1];if(a&&!0===(a=a.apply(s,e)))return a}},mt.prototype.registerType=function(t){var e=this;t.forEach(function(t){e.eventTypes[t]=t})},mt.prototype.destroy=function(){this.events={},this.eventTypes={}},mt.prototype.hasType=function(t){var e=this.eventTypes;e[t]!==t&&c('[ewColorPicker warning]: EventEmitter has used unknown event type: "'.concat(t,'", should be oneof [')+"".concat(Object.keys(e).map(function(t){return JSON.stringify(t)}))+"]")};nt=mt;function mt(t){this.events={},this.eventTypes={},this.registerType(t)}var yt=/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/,wt=/[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,kt=/^[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}$/,Pt=/^[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]*)[\)]$/,xt=/^[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 Bt(t){var e,o,i={10:"A",11:"B",12:"C",13:"D",14:"E",15:"F"};return/rgba?/.test(t)?(e=t.replace(/rgba?\(/,"").replace(/\)/,"").replace(/[\s+]/g,"").split(","),o="",e.map(function(t,e){e<=2&&(o+=(e=+t,e=Math.min(Math.round(e),255),t=Math.floor(e/16),""+(i[t]||t)+(i[e%=16]||e)))}),ft("#"+o)):t}function Mt(t,e){var o,i,n,r,s=t.a,a=t.h,l=255*t.s/100,t=255*t.v/100;return 0==l?o=i=n=t:(t=a%60*((r=t)-(l=(255-l)*t/255))/60,360===a?(o=r,i=n=0):a<60?(o=r,i=l+t,n=l):a<120?(o=r-t,i=r,n=l):a<180?(i=r,n=(o=l)+t):a<240?(o=l,i=r-t,n=r):a<300?(o=l+t,i=l,n=r):a<360?(i=l,n=(o=r)-t):o=i=n=0),void 0!==e&&0<=e&&e<=1&&(s=e),s=Math.round(10*s)/10,"rgba(".concat(Math.round(o),", ").concat(Math.round(i),", ").concat(Math.round(n),", ").concat(s,")")}function y(t){if(!t||"string"!=typeof t)return{h:0,s:100,v:100,a:1};if(!/^rgba?\(/i.test(t.replace(/\s+/g," ").trim())){var e=w(t);if(!e)return{h:0,s:100,v:100,a:1};t=e}var o,i,n,r,s,a,l,e=t.replace(/\s+/g," ").trim().match(/rgba?\(([^)]+)\)/i);return e?(t=e[1].split(",").map(function(t){return t.trim()}),e=parseFloat(t[0])||0,o=parseFloat(t[1])||0,i=parseFloat(t[2])||0,t=4<=t.length&&parseFloat(t[3])||1,e=e/255,o=o/255,i=i/255,n=(l=Math.max(e,o,i))-Math.min(e,o,i),(s=r=0)!==(a=l)&&(s=n/l),0!=n?(l===e?r=(o-i)/n*60:l===o?r=60*((i-e)/n+2):l===i&&(r=60*((e-o)/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 It={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 w(t){if(t&&"string"==typeof t){var e=t.trim().toLowerCase();if(It[e])return It[e];if(yt.test(e))return((t,e)=>{var e=(e=void 0===e?1:e)||1,e=Math.round(10*e)/10,o=t.toLowerCase(),i=t.length,n=[];if(t&&yt.test(o)){if(4===i){for(var r="#",s=1;s<i;s++){var a=o.slice(s,s+1);r+=a.concat(a)}o=r}for(var l=1,c=o.length;l<c;l+=2)n.push(parseInt("0X"+o.slice(l,l+2),16));return"rgba(".concat(n.join(", "),", ").concat(e,")")}return ft(o)})(e).replace(/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+(?:\.\d+)?)\s*\)/,"rgba($1, $2, $3, $4)");var o=e.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i);if(o)return i=o[1],n=o[2],r=o[3],"rgba(".concat(i,", ").concat(n,", ").concat(r,", 1)");var i,n,r,o=e.match(/^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(0|1|0?\.\d+)\s*\)$/i);if(o)return i=o[1],n=o[2],r=o[3],e=o[4],"rgba(".concat(i,", ").concat(n,", ").concat(r,", ").concat(e,")");try{var s=u("div"),a=(d(s,{"background-color":t}),pt(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 Ot(t){var e="transparent"===t;if(yt.test(t))return 1;if(wt.test(t)&&!t.includes("rgba"))return 1;if(kt.test(t))return 1;if(Pt.test(t)&&!t.includes("hsla"))return 1;if(xt.test(t))return 1;if(e)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 o=document.createElement("div");return d(o,{"background-color":t}),"rgba(0, 0, 0, 0)"!==pt(o,"backgroundColor")||e}catch(t){}}function Ht(t){function e(t){return Math.round(t).toString(16).padStart(2,"0")}return"#".concat(e(t.r)).concat(e(t.g)).concat(e(t.b))}function Tt(t){try{var e=t.slice(t.indexOf("(")+1,t.lastIndexOf(")")).split(",");return e.length<3?null:{r:parseInt(e[0]),g:parseInt(e[1]),b:parseInt(e[2]),a:e.length<4?1:parseFloat(e[3])}}catch(t){return null}}Et.prototype.show=function(){var e=this;return new Promise(function(t){d(e.element,{display:"block"}),t()})},Et.prototype.hide=function(){var e=this;return new Promise(function(t){d(e.element,{display:"none"}),t()})},Et.prototype.slideDown=function(){var n=this;return new Promise(function(t){d(n.element,{display:"block",visibility:"hidden"});var e=pt(n.element,"marginTop"),o=pt(n.element,"marginBottom"),i=n.element.offsetHeight+parseInt(e)+parseInt(o);d(n.element,{height:"0px",overflow:"hidden",visibility:"visible"}),n.element.offsetHeight,setTimeout(function(){d(n.element,{transition:"height ".concat(n.options.duration,"ms ").concat(n.options.easing),height:"".concat(i,"px")}),setTimeout(function(){d(n.element,{height:"",overflow:"",transition:""}),t()},n.options.duration)},n.options.delay)})},Et.prototype.slideUp=function(){var i=this;return new Promise(function(t){var e=pt(i.element,"marginTop"),o=pt(i.element,"marginBottom"),e=i.element.offsetHeight+parseInt(e)+parseInt(o);d(i.element,{height:"".concat(e,"px"),overflow:"hidden"}),i.element.offsetHeight,setTimeout(function(){d(i.element,{height:"0px",transition:"height ".concat(i.options.duration,"ms ").concat(i.options.easing)}),setTimeout(function(){d(i.element,{height:"",overflow:"",transition:"",display:"none"}),t()},i.options.duration)},i.options.delay)})},Et.prototype.fadeIn=function(){var t=this;return new Promise(function(o){function i(t){var t=Math.min((t-s)/r,1),e=1-Math.pow(1-t,3);d(n,{opacity:e.toString()}),t<1?requestAnimationFrame(i):(d(n,{opacity:"1"}),o())}var n=t.element,r=t.options.duration,s=(d(n,{display:"block",opacity:"0"}),n.offsetHeight,performance.now());requestAnimationFrame(i)})},Et.prototype.fadeOut=function(){var t=this;return new Promise(function(o){function i(t){var t=Math.min((t-s)/r,1),e=Math.pow(t,3);d(n,{opacity:(1-e).toString()}),t<1?requestAnimationFrame(i):(d(n,{display:"none",opacity:"0"}),o())}var n=t.element,r=t.options.duration,s=(d(n,{display:"block",opacity:"1"}),n.offsetHeight,performance.now());requestAnimationFrame(i)})};var St=Et;function Et(t,e){void 0===e&&(e={}),this.element=t,this.options=f({duration:300,easing:"ease-out",delay:0},e)}var Dt={show:function(t,e){return new St(t,{duration:e=void 0===e?300:e}).show()},hide:function(t,e){return new St(t,{duration:e=void 0===e?300:e}).hide()},slideDown:function(t,e){return new St(t,{duration:e=void 0===e?300:e}).slideDown()},slideUp:function(t,e){return new St(t,{duration:e=void 0===e?300:e}).slideUp()},fadeIn:function(t,e){return new St(t,{duration:e=void 0===e?300:e}).fadeIn()},fadeOut:function(t,e){return new St(t,{duration:e=void 0===e?300:e}).fadeOut()}};function Nt(t){return(null==(t=t.options)?void 0:t.togglePickerAnimation)||"default"}function At(i,n,r){void 0===r&&(r=!1);var s=null;return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var o=r&&!s;s&&clearTimeout(s),s=setTimeout(function(){s=null,r||i.apply(void 0,t)},n),o&&i.apply(void 0,t)}}function _t(o,i){var n;return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];n||(o.apply(void 0,t),n=!0,setTimeout(function(){return n=!1},i))}}function r(t){return t=null==(t=null==t?void 0:t.options)?void 0:t.prefix,et(t)?t:k}function zt(t,e,o){return void 0===o&&(o=k),e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"",'<svg t="1690189203554" class="'.concat(o,"color-picker-icon").concat(gt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2272" fill="currentColor"').concat(e,'><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>')}function Vt(t,e,o){return void 0===o&&(o=k),e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"",'<svg t="1717384498631" class="'.concat(o,"color-picker-icon").concat(gt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4235"').concat(e,'><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 Lt(t,e,o){return void 0===o&&(o=k),e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"",'<svg t="1717384498632" class="'.concat(o,"color-picker-icon").concat(gt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4236"').concat(e,'><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 k="ew-",Ft=["%c ew-color-picker@2.0.4%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"],Rt=!1,at=(jt.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=l(this.options,this.ewColorPicker.options))},jt.prototype.run=function(){Rt||(Rt=!0,K.apply(void 0,Ft))},jt.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),t.on&&h(t.on)&&t.on("change",function(t){}),null!=(t=this.run)&&t.call(this)},jt.pluginName="ewColorPickerConsole",jt);function jt(t){this.ewColorPicker=t,this.options={},this.handleOptions(),this.run()}var Wt,Ut={disabled:!1,predefineColor:[],size:"normal",defaultColor:"",isClickOutside:!0,hueDirection:"vertical",alphaDirection:"vertical",clearText:"清空",sureText:"确定",togglePickerAnimation:"default",pickerAnimationTime:200,autoPanelPosition:!1,panelPlacement:"bottom",boundary:null,prefix:k,sure:function(){},clear:function(){},togglePicker:function(){},changeColor:function(){}},$t=(V(Gt,Wt=function(){}),Gt.prototype.merge=function(t,e){var t=t||{},o=t.el,t=L(t,["el"]);return l({},Ut,null!=e?e:{},f(f({},t),{el:dt(o)}))},Gt.prototype.bindOptions=function(t,e){var o,i=this.merge(t,e=void 0===e?{}:e);for(o in i){var n=i[o];this[o]=n}return this},Gt);function Gt(){var t=Wt.call(this)||this;return t.el=document.body,t}(rt={})[N.Pre]=-1,rt[N.Post]=1;var Xt,qt=rt,Yt=["destroy","change","sure","clear","toggle","options-update","mode-change"],P=(V(x,Xt=nt),x.use=function(e){var o=e.pluginName;return U(o)||tt(o)?c("[ewColorPicker warning]: Plugin Class must specify plugin's name in static property by 'pluginName' field."):x.plugins.some(function(t){return t.name===o||e===t.ctor})||(x.pluginsMap[o]=!0,x.plugins.push({name:o,applyOrder:e.applyOrder,ctor:e})),x},x.prototype.normalizeOptions=function(t,e){var o,i;return ct(t)||et(t)?(o=e?(e.el,e=L(e,["el"]),f({el:t},e)):{el:t},this.shouldAutoMount=!0):G(o=t)&&o.el&&(this.shouldAutoMount=!0),(new $t).bindOptions(o,(i={},P.plugins.forEach(function(t){i[t.name]=!0}),i))},x.prototype.init=function(){var t=this;X(function(){t.plugins={},t._color_picker_uid=t.generateUID(),t.initCoreProperties()})},x.prototype.initCoreProperties=function(){var t,e=this.options,o=e.defaultColor,i=e.alphaDirection,e=e.hueDirection;o?(t=o,!x.pluginsMap.ewColorPickerAlpha&&o.startsWith("rgba")&&(t=Bt(o)),o=y(w(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"===i,this.colorMode=["Hex","RGB","HSV"],this.currentMode="Hex",this.pickerFlag=!1},x.prototype.createMountPoints=function(){var t=this.options.prefix||k,e=u("div"),o=(g(e,{class:"".concat(t,"color-picker"),"data-uid":this._color_picker_uid}),b(this.getContainer(),e),this.wrapper=e,this.wrapper.isEwColorPickerContainer=!0,u("div"));g(o,{class:"".concat(t,"color-picker-panel-container")}),p(o,"".concat(t,"color-picker-panel-container-hidden")),b(e,o),this.mountPoints.set("root",e),this.mountPoints.set("panelContainer",o)},x.prototype.getMountPoint=function(t){if(!this.isDestroyed)return this.mountPoints.get(t)},x.prototype.getContainer=function(){return this.options.el},x.prototype.mount=function(t){return this.isDestroyed||(t=t?dt(t):this.options.el||document.body,this.options.el=t,this.createMountPoints(),this.applyPlugins(),this.notifyHuePluginUpdate(this.hsvaColor.h)),this},x.prototype.reapplyPlugins=function(){Object.values(this.plugins).forEach(function(t){h(t.run)&&t.run()})},x.prototype.showPanel=function(t,e){var o,i,n,r,s=this;this.isDestroyed||(o=this.mountPoints.get("panelContainer"))&&(i=(r=this.options||{}).pickerAnimationTime,n=r.togglePicker,this.currentColor||(r=y(w(this.currentColor=r.defaultColor||"#ff0000")||"rgba(255, 0, 0, 1)"),this.hsvaColor=r,isNaN(r.h))||this.notifyHuePluginUpdate(r.h),((t,e,o)=>{o=1e4<(o=void 0===o?300:o)?1e4:o;var i="";switch(t){case"height":i="slideDown";break;case"opacity":i="fadeIn";break;default:i="show"}return Dt[i](e,o)})(t||Nt(this),o,e||i||200).then(function(){s.pickerFlag=!0,s.trigger("toggle",!0),h(n)&&n(!0),s.syncAllPlugins(s.currentColor),setTimeout(function(){var t;s.isDestroyed||((t=s.plugins.ewColorPickerPanel)&&h(t.handleAutoPosition)&&t.handleAutoPosition.call(t),C(document,"mousedown",s._onDocumentClick,{capture:!0}))},0)}).catch(function(t){c("[ewColorPicker error]: Failed to show panel: ".concat(t))}))},x.prototype.hidePanel=function(t,e){var o,i,n,r,s,a,l=this;this.isDestroyed||(o=this.mountPoints.get("panelContainer"))&&(n=(i=this.options||{}).pickerAnimationTime,r=i.togglePicker,s=i.autoPanelPosition,a=this.plugins.ewColorPickerBox||!1,((t,e,o)=>{o=1e4<(o=void 0===o?300:o)?1e4:o;var i="";switch(t){case"height":i="slideUp";break;case"opacity":i="fadeOut";break;default:i="hide"}return Dt[i](e,o)})(t||Nt(this),o,e||n||200).then(function(){l.isDestroyed||(s&&a&&!l.options.appendTo&&d(o,{position:"absolute",left:"0",top:"100%",visibility:"visible"}),l.pickerFlag=!1,l.trigger("toggle",!1),h(r)&&r(!1),m(document,"mousedown",l._onDocumentClick,{capture:!0}))}).catch(function(t){c("[ewColorPicker error]: Failed to hide panel: ".concat(t))}))},x.prototype.generateUID=function(){return"ew-color-picker-".concat(Date.now(),"-").concat(Math.random().toString(36).substring(2,11))},x.prototype.applyPlugins=function(){var i=this,t=j([],x.plugins,!0).sort(function(t,e){var o,i,n=t.applyOrder?qt[t.applyOrder]:0,r=e.applyOrder?qt[e.applyOrder]:0;return n!==r?n-r:(o={},i=0,P.plugins.forEach(function(t){o[t.name]=i++}),((n=o)[t.name]||999)-(n[e.name]||999))});this.checkPluginDependencies(),t.forEach(function(t){var e=t.ctor,o=t.name;X(function(){h(e)&&(i.plugins[o]=new e(i))},function(t){console.warn("[ewColorPicker warning]: Failed to apply plugin '".concat(o,"': ").concat(t))})})},x.prototype.checkPluginDependencies=function(){var o=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 e=t[0],t=t[1];o.options[e]&&t.forEach(function(t){x.pluginsMap[t]||c("[ewColorPicker warning]: Plugin '".concat(t,"' is required but not injected. Please use ewColorPicker.use(").concat(t,") to register the plugin."))})}),this.checkSpecificFeatureDependencies()},x.prototype.checkSpecificFeatureDependencies=function(){this.options.hueDirection&&!x.pluginsMap.ewColorPickerHue&&c("[ewColorPicker warning]: hueDirection is configured but ewColorPickerHue plugin is not injected. Please use ewColorPicker.use(HuePlugin) to register the plugin."),this.options.alphaDirection&&!x.pluginsMap.ewColorPickerAlpha&&c("[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&&!x.pluginsMap.ewColorPickerPredefine&&c("[ewColorPicker warning]: predefineColor is configured but ewColorPickerPredefine plugin is not injected. Please use ewColorPicker.use(PredefinePlugin) to register the plugin."),x.pluginsMap.ewColorPickerColorMode&&!x.pluginsMap.ewColorPickerInputNumber&&c("[ewColorPicker warning]: Color mode plugin requires InputNumber plugin. color-mode plugin requires InputNumber plugin. Please use ewColorPicker.use(InputNumberPlugin) to register the plugin."),x.pluginsMap.ewColorPickerPanel||c("[ewColorPicker warning]: Panel plugin is required as core plugin but not injected. Please use ewColorPicker.use(PanelPlugin) to register the plugin.")},x.prototype.syncAllPlugins=function(e){Object.values(this.plugins).forEach(function(t){h(t.syncColor)&&t.syncColor(e)})},x.prototype.updateOptions=function(t){this.isDestroyed||(this.options=l({},this.options,t),t=(this.options||{}).defaultColor,U(t)||(w(t)?this.setColor(t):c("[ewColorPicker warning]: Invalid defaultColor '".concat(t,"', keep current color unchanged."))),this.reapplyPlugins(),this.trigger("options-update",this.options))},x.prototype.openPicker=function(){this.showPanel()},x.prototype.closePicker=function(){this.hidePanel()},x.prototype.destroy=function(){var t=this;this.isDestroyed||(this.isDestroyed=!0,m(document,"mousedown",this._onDocumentClick,{capture:!0}),this.plugins&&Object.values(this.plugins).forEach(function(t){X(function(){h(null==t?void 0:t.destroy)&&t.destroy()})}),this.mountPoints.forEach(function(t){X(function(){n(t)})}),this.mountPoints.clear(),X(function(){n(t.wrapper)}),this.plugins={},this.trigger("destroy"))},x.prototype.setColor=function(t){var e;(this.currentColor=t)&&(e=w(t),this.hsvaColor=e?y(e):{h:0,s:100,v:100,a:1}),this.trigger("change",t),h(null==(e=this.options)?void 0:e.changeColor)&&this.options.changeColor(t)},x.prototype.getColor=function(){return this.currentColor},x.prototype.getHsvaColor=function(){return f({},this.hsvaColor)},x.prototype.setHsvaColor=function(t){this.hsvaColor=f({},t)},x.prototype.getDestroyedStatus=function(){return this.isDestroyed},x.prototype.use=function(t){return h(t.install)&&t.install(this),this},x.prototype.emit=function(t){for(var e=[],o=1;o<arguments.length;o++)e[o-1]=arguments[o];this.trigger.apply(this,j([t],e,!1));var i=this.options||{},n=i.clear,r=i.sure,s=i.togglePicker;switch(t){case"clear":h(n)&&n();break;case"sure":h(r)&&r();break;case"toggle":h(s)&&s.apply(void 0,e)}},x.prototype.on=function(t,e,o){return Xt.prototype.on.call(this,t,e,o),this},x.prototype.off=function(t,e){return Xt.prototype.off.call(this,t,e),this},x.prototype.getOptions=function(){return this.options},x.prototype.notifyHuePluginUpdate=function(t){var e=null==(e=this.plugins)?void 0:e.ewColorPickerHue;h(null==e?void 0:e.updateHueThumbPosition)&&e.updateHueThumbPosition(t)},x.plugins=[],x.pluginsMap={},x);function x(t,e){var i=Xt.call(this,Yt)||this;return i.mountPoints=new Map,i.isDestroyed=!1,i.shouldAutoMount=!1,i._onDocumentClick=function(t){var e,o;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||k,(o=e?v(".".concat(o,"color-picker-box"),e):null)&&o.contains(t))||(o=(e=i.options).togglePickerAnimation,i.hidePanel(o,e.pickerAnimationTime))},i.options=i.normalizeOptions(t,e),i.init(),i.shouldAutoMount&&i.options.el&&X(function(){i.mount(i.options.el)},function(t){c("[ewColorPicker warning]: Auto mount failed: ".concat(t))}),i}function Kt(t,e){var o=void 0===(o=e.boxNoColorIcon)?"":o,i=void 0===(i=e.boxHasColorIcon)?"":i,n=void 0===(n=e.prefix)?k:n,e=(t=>{var e,o;if(t){if(it(t))return e=Jt(null!=(e=t.width)?e:32),o=Jt(null!=(o=t.height)?o:32),.5*Math.min(e,o);if(ot(t))return.5*t;if(et(t))return Zt[t]||16}return 16})(e.size);return t?i||((t,e,o)=>(void 0===o&&(o=k),e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"",'<svg t="1717384498630" class="'.concat(o,"color-picker-icon").concat(gt(t),'" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4234"').concat(e,'><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"),e,n):o||zt("".concat(n,"color-picker-box-close-icon"),e,n)}var Qt={mini:"20px",small:"24px",normal:"32px",medium:"36px",large:"40px"},Zt={mini:12,small:14,normal:16,medium:18,large:20},Jt=function(t){return!ot(t)&&(t=parseInt("".concat(t)),isNaN(t))?32:t},rt=(Object.defineProperty(t.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasBox",{get:function(){return this._hasBox},set:function(t){this._hasBox!==t&&((this._hasBox=t)?this.render():this.box&&this.box.parentNode&&(n(this.box),this.box=null))},enumerable:!1,configurable:!0}),t.prototype.enableBox=function(t){this.hasBox=t=void 0===t?!0:t},t.prototype.handleOptions=function(){this.options=l(this.options,this.ewColorPicker.options)},t.prototype.run=function(){this.render()},t.prototype.updateChildren=function(){var t;this.box&&(t=this.ewColorPicker.currentColor,this.hasColor=!!t,this.box.replaceChildren((t=Kt(this.hasColor,this.options),document.createRange().createContextualFragment(t))))},t.prototype.destroy=function(){this.box&&(this.unbindHandler(),n(this.box),this.box=null)},t.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()},t.prototype.render=function(){var t,e=this.options,o=e.className,e=e.style;this.hasBox&&((t=this.ewColorPicker.getMountPoint("root"))?(this.box=v(".".concat(this.prefix,"color-picker-box"),t),this.box||(this.box=u("div"),p(this.box,"".concat(this.prefix,"color-picker-box")),o&&p(this.box,o),e&&d(this.box,e),b(t,this.box)),this.updateChildren(),this.setBoxSize(),this.setBoxBgColor(this.ewColorPicker.currentColor),this.setBoxState(),this.bindHandler()):c("[ewColorPicker] Root mount point not found"))},t.prototype.setBoxSize=function(){var t,e;this.box&&(t=this.options.size,t=(t=t)?it(t)?{width:t.width?ot(t.width)?"".concat(t.width,"px"):t.width:void 0,height:e=t.height?ot(t.height)?"".concat(t.height,"px"):t.height:void 0,lineHeight:e}:t?(e=void 0,{width:e=ot(t)?"".concat(t,"px"):et(t)?Qt[t]||t:"32px",height:e,lineHeight:e}):{}:{},0<Object.keys(t).length?d(this.box,t):ut(this.box,["width","height"]))},t.prototype.setBoxBgColor=function(t){var e,o;this.box&&(t&&""!==t.trim()?(e=(e=(e=t)&&w(e))&&(o=Tt(e))?.5<.2126*(e=function(t){t=(t*o.a+255*(1-o.a))/255;return t<=.03928?t/12.92:Math.pow((.055+t)/1.055,2.4)})(o.r)+.7152*e(o.g)+.0722*e(o.b)?"#333333":"#ffffff":null,d(this.box,f({backgroundColor:t,transition:"background-color 0.3s"},e?{color:e}:{}))):this.clearBoxBgColor())},t.prototype.clearBoxBgColor=function(){this.box&&ut(this.box,["background-color","transition","color"])},t.prototype.setBoxState=function(){var t,e,o;this.box&&(t=(o=this.options).disabled,e=o.readonly,o=o.className,(t?p:s)(this.box,"is-disabled"),(e?p:s)(this.box,"is-readonly"),o)&&p(this.box,o)},t.prototype.bindHandler=function(){var t,e,o,i,n,r,s,a,l,c=this;this.box&&(t=this.options,e=t.onClick,o=t.onMouseEnter,i=t.onMouseLeave,n=t.disabled,r=t.readonly,s=t.togglePickerAnimation,a=t.pickerAnimationTime,C(this.box,"click",l=function(t){n||r?(t.preventDefault(),t.stopPropagation()):(c.ewColorPicker.pickerFlag?c.ewColorPicker.hidePanel(s,a):c.ewColorPicker.showPanel(s,a),null!=e&&e(c))}),this._handlers.push(function(){return m(c.box,"click",l)}),this.bindMouseEvents(o,i))},t.prototype.setDisabled=function(t){this.box&&(t?p:s)(this.box,"is-disabled")},t.prototype.bindMouseEvents=function(t,e){var o,i,n=this;this.box&&(t&&(C(this.box,"mouseenter",o=function(){return t(n)}),this._handlers.push(function(){return m(n.box,"mouseenter",o)})),e)&&(C(this.box,"mouseleave",i=function(){return e(n)}),this._handlers.push(function(){return m(n.box,"mouseleave",i)}))},t.prototype.unbindHandler=function(){this._handlers.forEach(function(t){return t()}),this._handlers=[]},t.pluginName="ewColorPickerBox",t);function t(t){var e=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){e.setBoxBgColor(t)}),this.run()}Object.defineProperty(e.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),e.prototype.handleOptions=function(){var t;G(null==(t=this.ewColorPicker)?void 0:t.options)&&(this.options=l(this.options,this.ewColorPicker.options),this.isHueHorizontal="horizontal"===this.options.hueDirection,this.isAlphaHorizontal="horizontal"===this.options.alphaDirection)},e.prototype.run=function(){var t=this;!1!==this.options.ewColorPickerPanel&&!1!==this.options.hasPanel&&(this.render(),this.movePanelContainer(),setTimeout(function(){t.bindEvents()},10))},e.prototype.render=function(){var t,e,o,i=this;this.ewColorPicker&&(e=this.ewColorPicker.getMountPoint("panelContainer"))&&(t=v(".".concat(this.prefix,"color-picker-panel"),e),o=J,this.isAlphaHorizontal&&this.isHueHorizontal?o=320:this.isAlphaHorizontal&&!this.isHueHorizontal?o=301:!this.isAlphaHorizontal&&this.isHueHorizontal&&(o=304),this.panel=u("div"),p(this.panel,"".concat(this.prefix,"color-picker-panel")),p(this.panel,"".concat(this.prefix,"color-picker-panel-dynamic-size")),this.panelWidth=o,this.panelHeight=180,d(this.panel,{"--panel-width":o+"px","--panel-height":this.panelHeight+"px"}),b(e,this.panel,t),this.whitePanel=u("div"),p(this.whitePanel,"".concat(this.prefix,"color-picker-white-panel")),b(this.panel,this.whitePanel),this.blackPanel=u("div"),p(this.blackPanel,"".concat(this.prefix,"color-picker-black-panel")),b(this.panel,this.blackPanel),this.cursor=u("div"),p(this.cursor,"".concat(this.prefix,"color-picker-panel-cursor")),b(this.panel,this.cursor),o=u("div"),p(o,"".concat(this.prefix,"color-picker-bottom-row")),b(e,o),setTimeout(function(){var t;i.calculateContainerSize(),h(null==(t=i.ewColorPicker)?void 0:t.getMountPoint)&&i.handleAutoPosition()},0),this.updateHueBg(),h(null==(t=this.ewColorPicker)?void 0:t.getColor)&&(e=this.ewColorPicker.getColor())?(o=y(e),this.updateCursorPosition(o.s,o.v)):this.updateCursorPosition(100,100))},e.prototype.bindEvents=function(){var e=this;this.panel&&(C(this.panel,"click",function(t){return e.handlePanelClick(t)}),C(this.panel,"mousedown",function(){return e.handlePanelMouseDown()}),C(this.panel,"touchstart",function(t){return e.handlePanelTouchStart(t)}))},e.prototype.handlePanelTouchStart=function(t){var e=this;this.panel&&!this.options.disabled&&(t.preventDefault(),this.isDragging=!0,Ct(function(t){e.isDragging&&0<t.touches.length&&e.handlePanelTouchMove(t)},function(){e.isDragging=!1}))},e.prototype.handlePanelTouchMove=function(t){var e,o;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],e=a(this.panel),o=t.clientX-e.left,t=t.clientY-e.top,e=Math.max(0,Math.min(100,o/this.panelWidth*100)),o=Math.max(0,Math.min(100,100*(1-t/this.panelHeight))),this.throttledUpdate(e,o))))},e.prototype.handlePanelClick=function(t){var e,o;this.panel&&this.cursor&&(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(this.panelWidth=this.panel.offsetWidth,this.panelHeight=this.panel.offsetHeight,e=a(this.panel),o=t.clientX-e.left,t=t.clientY-e.top,e=Math.max(0,Math.min(100,o/this.panelWidth*100)),o=Math.max(0,Math.min(100,100*(1-t/this.panelHeight))),this.updateCursorPosition(e,o),this.updateColor(e,o)))},e.prototype.handlePanelMouseDown=function(){var e=this;this.panel&&!this.options.disabled&&(this.isDragging=!0,bt(function(t){e.isDragging&&e.handlePanelDrag(t)},function(){e.isDragging=!1}))},e.prototype.handlePanelDrag=function(t){var e,o;this.panel&&this.cursor&&(this.options.disabled||(t.preventDefault(),this.panelWidth=this.panel.offsetWidth,this.panelHeight=this.panel.offsetHeight,e=a(this.panel),o=t.clientX-e.left,t=t.clientY-e.top,e=Math.max(0,Math.min(100,o/this.panelWidth*100)),o=Math.max(0,Math.min(100,100*(1-t/this.panelHeight))),this.throttledUpdate(e,o)))},e.prototype.updateCursorPosition=function(t,e){var o,i,n;this.cursor&&this.panel&&(n=pt(this.panel,"display"),o=pt(this.panel,"visibility"),"none"!==n)&&"hidden"!==o&&(n=this.panel.offsetWidth,o=this.panel.offsetHeight,0!==n&&0!==o||(n=(i=a(this.panel)).width||this.panelWidth||J,o=i.height||this.panelHeight||180,0!==n&&0!==o)||(n=J,o=180),this.panelWidth=n,this.panelHeight=o,o={x:(n={clientWidth:(i=this.cursor).clientWidth,clientHeight:i.clientHeight,offsetWidth:i.offsetWidth,offsetHeight:i.offsetHeight,scrollWidth:i.scrollWidth,scrollHeight:i.scrollHeight}).offsetWidth/2,y:n.offsetHeight/2},0!==n.offsetWidth&&0!==n.offsetHeight||(o.x=2,o.y=2),i=t/100*this.panelWidth,n=(1-e/100)*this.panelHeight,i=Math.max(o.x,Math.min(i,this.panelWidth-o.x)),n=Math.max(o.y,Math.min(n,this.panelHeight-o.y)),d(this.cursor,{left:"".concat(i,"px"),top:"".concat(n,"px")}))},e.prototype.updateColor=function(t,e){var o=this.options.alpha?"rgba(255,0,0,1)":"#ff0000",i=this.ewColorPicker.getColor(),o=(i&&-1===i.indexOf("NaN")||this.ewColorPicker.setColor(i=o),y(i)),i=(o.s=t,o.v=e,Mt(o));this.ewColorPicker.setColor(i),h(this.ewColorPicker.options.changeColor)&&this.ewColorPicker.options.changeColor(i),this.ewColorPicker.trigger("change",i)},e.prototype.updateHueBg=function(t){if(this.panel){if(void 0===(t=t)){var e=this.ewColorPicker.getColor();if(!e)return;t=y(e).h}e=Mt({h:t,s:100,v:100,a:1});d(this.panel,{background:e})}},e.prototype.syncColor=function(t){this.panel&&t&&(t=y(t),isNaN(t.h)||(this.updateHueBg(t.h),this.updateCursorPosition(t.s,t.v)))},e.prototype.calculateContainerSize=function(){var t,e,o,i,n,r,s=this.ewColorPicker.getMountPoint("panelContainer");s&&(n=s.offsetWidth,r=s.offsetHeight,0!==n&&0!==r||(t=s.style.display,e=s.style.visibility,o=s.style.position,d(s,{display:"block",visibility:"hidden",position:"absolute",left:"-9999px",top:"-9999px"}),s.offsetHeight,i=a(s),n=s.offsetWidth||i.width,r=s.offsetHeight||i.height,d(s,{display:t,visibility:e,position:o,left:"",top:""})),this.containerWidth=n||320,this.containerHeight=r||200)},e.prototype.handleAutoPosition=function(){var t,e,o,i;this.isPanelAppended?this.updateAppendedPanelPosition():(i=(e=(null==(e=this.ewColorPicker)?void 0:e.options)||{}).autoPanelPosition,t=e.panelPlacement,i&&e.ewColorPickerBox&&(i=this.ewColorPicker.getMountPoint("root"),e=v(".".concat(this.prefix,"color-picker-box"),i),i)&&e&&(this.calculateContainerSize(),o=void 0===(o=(t=(t||"bottom").split("-"))[0])?"bottom":o,t=void 0===(t=t[1])?"center":t,e=a(e),e=this.computePanelViewportRect(e,o,t),o=this.getBoundaryRect(),e=(t=this.clampToBounds(e,o)).left,o=t.top,t=this.ewColorPicker.getMountPoint("panelContainer"))&&(o=(e=this.toContainingBlockCoords(e,o,t,i)).left,i=e.top,d(t,{position:"absolute",left:"".concat(o,"px"),top:"".concat(i,"px")})))},e.prototype.movePanelContainer=function(){var t,e=this.options.appendTo;e&&(t=this.ewColorPicker.getMountPoint("panelContainer"))&&(b(dt(e),t),this.isPanelAppended=!0,this.calculateContainerSize(),C(window,"scroll",this.handleReposition,{capture:!0}),C(window,"resize",this.handleReposition),this.updateAppendedPanelPosition())},e.prototype.updateAppendedPanelPosition=function(){var t,e,o,i;this.isPanelAppended&&(t=this.ewColorPicker.getMountPoint("panelContainer"),o=this.ewColorPicker.getMountPoint("root"),t)&&o&&(o=v(".".concat(this.prefix,"color-picker-box"),o)||o,i=void 0===(i=(e=(this.options.panelPlacement||"bottom").split("-"))[0])?"bottom":i,e=void 0===(e=e[1])?"center":e,o=a(o),o=this.computePanelViewportRect(o,i,e),i=this.getBoundaryRect(),o=(e=this.clampToBounds(o,i)).left,i=e.top,d(t,{position:"fixed",left:"".concat(o,"px"),top:"".concat(i,"px")}))},e.prototype.calculatePosition=function(t,e,o,i){o={top:{left:"start"===e?-this.containerWidth:"end"===e?o:(o-this.containerWidth)/2,top:-this.containerHeight-i/2},bottom:{left:"start"===e?-this.containerWidth:"end"===e?o:(o-this.containerWidth)/2,top:i},left:{left:-this.containerWidth-5,top:"start"===e?-this.containerHeight-i/2:"end"===e?i:(i-this.containerHeight)/2},right:{left:o+5,top:"start"===e?-this.containerHeight-i/2:"end"===e?i:(i-this.containerHeight)/2}};return o[t]||o.bottom},e.prototype.computePanelViewportRect=function(t,e,o){e=this.calculatePosition(e,o,t.width,t.height),o=e.left,e=e.top;return{left:t.left+o,top:t.top+e,right:t.left+o+this.containerWidth,bottom:t.top+e+this.containerHeight}},e.prototype.getBoundaryRect=function(){var t={left:0,top:0,right:window.innerWidth||document.documentElement.clientWidth,bottom:window.innerHeight||document.documentElement.clientHeight},e=this.options.boundary;return e&&(e=et(e)?v(e):e,ct(e))?(e=a(e),{left:Math.max(t.left,e.left),top:Math.max(t.top,e.top),right:Math.min(t.right,e.right),bottom:Math.min(t.bottom,e.bottom)}):t},e.prototype.clampToBounds=function(t,e,o){var i=t.left,n=t.top,r=e.left+(o=void 0===o?8:o)-i,s=t.right-(e.right-o),a=e.top+o-n,t=t.bottom-(e.bottom-o);return 0<r&&(i+=r),0<s&&(i-=s),0<a&&(n+=a),0<t&&(n-=t),{left:i,top:n}},e.prototype.toContainingBlockCoords=function(t,e,o,i){o=o.offsetParent||i,i=a(o);return{left:t-i.left-(o.clientLeft||0),top:e-i.top-(o.clientTop||0)}},e.prototype.adjustForViewport=function(t,e,o){t=a(t),e={left:t.left+e,top:t.top+o,right:t.left+e+this.containerWidth,bottom:t.top+o+this.containerHeight},o=this.getBoundaryRect(),e=this.clampToBounds(e,o);return{left:e.left-t.left,top:e.top-t.top}},e.prototype.destroy=function(){var t;this.panel&&(m(this.panel,"click",this.handlePanelClick),m(this.panel,"mousedown",this.handlePanelMouseDown)),m(window,"scroll",this.handleReposition,{capture:!0}),m(window,"resize",this.handleReposition),h(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},e.prototype.install=function(t){var e=this;this.ewColorPicker=t,this.handleOptions(),h(null==t?void 0:t.on)&&t.on("change",function(t){t=y(t);e.updateCursorPosition(t.s,t.v)}),null!=(t=this.run)&&t.call(this)},e.pluginName="ewColorPickerPanel",e.applyOrder=N.Post;nt=e;function e(t){var o=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){o.isPanelAppended&&t&&o.updateAppendedPanelPosition()},this.handleReposition=function(){o.isPanelAppended&&o.updateAppendedPanelPosition()},this.throttledUpdate=_t(function(t,e){isNaN(t)||isNaN(e)||t<0||100<t||e<0||100<e||(o.updateCursorPosition(t,e),o.updateColor(t,e))},16),this.handleOptions(),h(null==(t=this.ewColorPicker)?void 0:t.on)&&(this.ewColorPicker.on("change",function(t){t&&o.panel&&(t=y(t),o.updateHueBg(t.h),o.updateCursorPosition(t.s,t.v))}),this.ewColorPicker.on("toggle",this.handleToggle)),this.run()}Object.defineProperty(o.prototype,"prefix",{get:function(){return r(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=l(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,e,o,i=this.ewColorPicker.getMountPoint("panelContainer");i?(e=this.prefix,(t=v(".".concat(e,"color-picker-slider.").concat(e,"color-picker-is-vertical, .").concat(e,"color-picker-slider.").concat(e,"color-picker-is-horizontal"),i))&&n(t),t=u("div"),p(t,"".concat(e,"color-picker-slider ")+(this.isHorizontal?"".concat(e,"color-picker-is-horizontal"):"".concat(e,"color-picker-is-vertical"))),this.hueBar=u("div"),p(this.hueBar,"".concat(e,"color-picker-slider-bar")),this.hueThumb=u("div"),p(this.hueThumb,"".concat(e,"color-picker-slider-thumb")),b(this.hueBar,this.hueThumb),b(t,this.hueBar),this.isHorizontal?(o=v(".".concat(e,"color-picker-bottom-row"),i))&&o.parentNode?o.parentNode.insertBefore(t,o):b(i,t):(o=v(".".concat(e,"color-picker-panel"),i))&&o.parentNode?o.parentNode.insertBefore(t,o.nextSibling):b(i,t),(e=this.ewColorPicker.getColor())&&(o=y(e),this.updateHueThumbPosition(o.h))):c("[ewColorPicker] Panel container not found")},o.prototype.bindEvents=function(){this.hueBar&&(C(this.hueBar,"click",this.handleHueSliderClick.bind(this)),C(this.hueBar,"mousedown",this.handleHueSliderMouseDown.bind(this)))},o.prototype.handleHueSliderClick=function(t){var e;this.hueBar&&(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(e=a(this.hueBar),t=this.isHorizontal?360*vt(t.clientX,e.left,e.width):360*vt(t.clientY,e.top,e.height,!0),this.updateHue(t)))},o.prototype.handleHueSliderMouseDown=function(t){var o,i,n=this;this.hueBar&&!this.options.disabled&&(o=this.hueBar,i=this.isHorizontal,bt(function(t){var e=a(o),t=i?360*vt(t.clientX,e.left,e.width):360*vt(t.clientY,e.top,e.height,!0);n.throttledUpdateHue(t)}))},o.prototype.updateHue=function(t){var e=this.ewColorPicker.getColor(),t=Math.max(0,Math.min(360,t)),e=e?y(e):{h:t,s:100,v:100,a:1},e=(isNaN(e.h)||isNaN(e.s)||isNaN(e.v)||isNaN(e.a)?(e.h=t,e.s=100,e.v=100,e.a=1):e.h=t,Mt(e)),e=(e&&!e.includes("NaN")?this.ewColorPicker.setColor(e):(e=this.ewColorPicker.options.alpha?"rgba(255, 0, 0, 1)":"#ff0000",this.ewColorPicker.setColor(e)),this.updateHueThumbPosition(t),null==(e=this.ewColorPicker.plugins)?void 0:e.ewColorPickerPanel);e&&h(e.updateHueBg)&&e.updateHueBg(t)},o.prototype.syncColor=function(t){this.hueThumb&&this.hueBar&&t&&(t=y(t),isNaN(t.h)||this.updateHueThumbPosition(t.h))},o.prototype.updateHueThumbPosition=function(t){var e,o;this.hueThumb&&this.hueBar&&(o=this.isHorizontal,e=a(this.hueBar),o?(o=Math.max(0,Math.min(e.width,t/360*e.width)),d(this.hueThumb,"left","".concat(o,"px")),d(this.hueThumb,"top","0px")):(o=Math.max(0,Math.min(e.height,(1-t/360)*e.height)),d(this.hueThumb,"top","".concat(o,"px")),d(this.hueThumb,"left","0px")))},o.prototype.destroy=function(){this.hueBar&&(m(this.hueBar,"click",this.handleHueSliderClick.bind(this)),m(this.hueBar,"mousedown",this.handleHueSliderMouseDown.bind(this))),this.hueBar=null,this.hueThumb=null},o.prototype.install=function(t){var e=this;this.ewColorPicker=t,this.handleOptions(),t.on&&"function"==typeof t.on&&t.on("change",function(t){t=y(t);e.updateHueThumbPosition(t.h)}),null!=(t=this.run)&&t.call(this)},o.pluginName="ewColorPickerHue",o.applyOrder=N.Post;var te=o;function o(t){var e=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=_t(this.updateHue.bind(this),16),this.ewColorPicker.on&&"function"==typeof this.ewColorPicker.on&&this.ewColorPicker.on("change",function(t){t&&e.hueThumb&&(t=y(t),e.updateHueThumbPosition(t.h))}),this.run()}Object.defineProperty(i.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(i.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}),i.prototype.enableAlpha=function(t){this.hasAlpha=t=void 0===t?!0:t},i.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=l({},this.options,this.ewColorPicker.options),this.isHorizontal="horizontal"===this.options.alphaDirection)},i.prototype.run=function(){var t=this;this.hasAlpha&&this.render(),setTimeout(function(){t.bindEvents()},10)},i.prototype.render=function(){var t,e,o=this.ewColorPicker.getMountPoint("panelContainer");o?((t=v(".".concat(this.prefix,"color-picker-slider.ew-alpha"),o))&&n(t),t=u("div"),p(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=u("div"),p(this.alphaBar,"".concat(this.prefix,"color-picker-alpha-slider-bar")),e=u("div"),p(e,"".concat(this.prefix,"color-picker-alpha-slider-wrapper")),b(this.alphaBar,e),e=u("div"),p(e,"".concat(this.prefix,"color-picker-alpha-slider-bg")),b(this.alphaBar,e),this.alphaThumb=u("div"),p(this.alphaThumb,"".concat(this.prefix,"color-picker-alpha-slider-thumb")),b(this.alphaBar,this.alphaThumb),b(t,this.alphaBar),this.isHorizontal?(e=v(".".concat(this.prefix,"color-picker-bottom-row"),o))&&e.parentNode?e.parentNode.insertBefore(t,e):b(o,t):(e=v(".".concat(this.prefix,"color-picker-panel"),o))&&e.parentNode?e.parentNode.insertBefore(t,e.nextSibling):b(o,t),(e=this.ewColorPicker.getColor())&&(o=y(e),this.updateAlphaThumbPosition(o.a))):c("[ewColorPicker] Panel container not found, please check the ewColorPicker instance!")},i.prototype.bindEvents=function(){var e=this;this.alphaBar&&(C(this.alphaBar,"click",function(t){e.handleAlphaSliderClick(t)}),C(this.alphaBar,"mousedown",function(t){e.handleAlphaSliderMouseDown(t)}))},i.prototype.handleAlphaSliderClick=function(t){var e;this.alphaBar&&(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(e=a(this.alphaBar),t=this.isHorizontal?vt(t.clientX,e.left,e.width,!0):vt(t.clientY,e.top,e.height,!0),this.updateAlpha(t)))},i.prototype.handleAlphaSliderMouseDown=function(t){var o,i,n=this;this.alphaBar&&!this.options.disabled&&(o=this.alphaBar,i=this.isHorizontal,bt(function(t){var e=a(o),t=i?vt(t.clientX,e.left,e.width,!0):vt(t.clientY,e.top,e.height,!0);n.throttledUpdateAlpha(t)}))},i.prototype.updateAlpha=function(t){var e=this.ewColorPicker.getColor();e&&((e=y(e)).a=t,e=Mt(e),this.ewColorPicker.setColor(e),this.updateAlphaThumbPosition(t),t=null==(t=this.ewColorPicker.plugins)?void 0:t.ewColorPickerColorMode)&&"hex"!==t.currentMode&&t.updateInputValues(e)},i.prototype.syncColor=function(t){this.alphaThumb&&this.alphaBar&&t&&(t=y(t),isNaN(t.a)||this.updateAlphaThumbPosition(t.a))},i.prototype.updateAlphaThumbPosition=function(t){var e,o;this.alphaThumb&&this.alphaBar&&(o=this.isHorizontal,e=a(this.alphaBar),o?(o=Math.max(0,Math.min(e.width,(1-t)*e.width)),d(this.alphaThumb,"left","".concat(o,"px")),d(this.alphaThumb,"top","0px")):(o=Math.max(0,Math.min(e.height,(1-t)*e.height)),d(this.alphaThumb,"top","".concat(o,"px")),d(this.alphaThumb,"left","0px")))},i.prototype.destroy=function(){this.alphaBar&&(m(this.alphaBar,"click",this.handleAlphaSliderClick.bind(this)),m(this.alphaBar,"mousedown",this.handleAlphaSliderMouseDown.bind(this)),n(this.alphaBar)),this.alphaBar=null,this.alphaThumb=null},i.prototype.install=function(t){var e=this;this.ewColorPicker=t,this.handleOptions(),h(t.on)&&t.on("change",function(t){t=y(t);e.updateAlphaThumbPosition(t.a)}),null!=(t=this.run)&&t.call(this)},i.pluginName="ewColorPickerAlpha",i.applyOrder=N.Post;var ee=i;function i(t){var e=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=_t(this.updateAlpha.bind(this),16),h(this.ewColorPicker.on)&&this.ewColorPicker.on("change",function(t){t=y(t);e.updateAlphaThumbPosition(t.a)}),this.run()}Object.defineProperty(B.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(B.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&&(n(this.input),this.input=null))},enumerable:!1,configurable:!0}),B.prototype.enableInput=function(t){this.hasInput=t=void 0===t?!0:t},B.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=l(this.options,this.ewColorPicker.options))},B.prototype.updateOptions=function(){this.handleOptions(),this.hasInput?this.render():this.input&&this.input.parentNode&&(n(this.input),this.input=null)},B.prototype.run=function(){this.hasInput&&(this.render(),this.bindEvents())},B.prototype.render=function(){var t,e,o=this.ewColorPicker.getMountPoint("panelContainer");o?(o=v(".".concat(this.prefix,"color-picker-bottom-row"),o))?(e=v(".".concat(this.prefix,"color-picker-drop-btn-group"),o),(t=v(".".concat(this.prefix,"color-picker-input-container"),o))||(t=u("div"),p(t,"".concat(this.prefix,"color-picker-input-container")),p(t,"".concat(this.prefix,"color-picker-input-container-flex")),e&&e.parentNode?e.parentNode.insertBefore(t,e):b(o,t)),this.input=v("input.".concat(this.prefix,"color-picker-input"),t),this.input||(this.input=u("input"),this.input&&(p(this.input,"".concat(this.prefix,"color-picker-input")),g(this.input,{type:"text",name:"".concat(this.prefix,"color-picker-input"),placeholder:"请输入颜色值"}),b(t,this.input))),(e=this.ewColorPicker.getColor())&&-1===e.indexOf("NaN")||(e=this.getDefaultColor(),""===this.ewColorPicker.currentColor?e="":this.ewColorPicker.setColor(e)),o=this.formatColorForDisplay(e),this.input&&(this.input.value=o),this.options.disabled&&this.setDisabled(!0)):c("[ewColorPicker] Bottom row container not found"):c("[ewColorPicker] Panel container not found")},B.prototype.bindEvents=function(){var e=this;this.input&&(C(this.input,"blur",function(t){e.debouncedOnInputColor(t.target.value)}),C(this.input,"keydown",function(t){"Enter"===t.key&&e.debouncedOnInputColor(t.target.value)}),this.ewColorPicker.on("change",function(t){e.update(t)}))},B.prototype.onInputColor=function(t){var e,o,i;t.trim()&&(Ot(t)?(i=w(t),this.ewColorPicker.hsvaColor=y(i),this.ewColorPicker.setColor(i),this.syncOtherPlugins(i),h(this.options.changeColor)&&null!=(o=(e=this.options).changeColor)&&o.call(e,i)):c("[ewColorPicker warning]: Invalid color format: ".concat(t)))},B.prototype.syncOtherPlugins=function(t){var e=this.ewColorPicker.hsvaColor,o=null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerColorMode,o=(o&&"hex"!==o.currentMode&&o.updateInputValues(t),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerHue),o=(o&&o.updateHueThumbPosition&&o.updateHueThumbPosition(e.h),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerAlpha),e=(o&&o.updateAlphaThumbPosition&&o.updateAlphaThumbPosition(e.a),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerPanel),e=(e&&e.updatePanelColor&&e.updatePanelColor(t),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerBox);e&&e.setBoxBgColor&&e.setBoxBgColor(t)},B.prototype.setValue=function(t){this.input&&(this.input.value=t)},B.prototype.getValue=function(){return this.input?this.input.value:""},B.prototype.setDisabled=function(t){this.input&&(t?(this.input.disabled=!0,lt(this.input,"".concat(this.prefix,"input-disabled"))||p(this.input,"".concat(this.prefix,"input-disabled"))):(this.input.disabled=!1,lt(this.input,"".concat(this.prefix,"input-disabled"))&&s(this.input,"".concat(this.prefix,"input-disabled"))))},B.prototype.update=function(t){t&&-1===t.indexOf("NaN")||(t=""===this.ewColorPicker.currentColor?"":this.getDefaultColor());t=this.formatColorForDisplay(t);this.setValue(t)},B.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"},B.prototype.formatColorForDisplay=function(t){var e,o;return t?(o=t,!(null==(e=this.ewColorPicker.plugins)||!e.ewColorPickerColorMode)&&(e=this.ewColorPicker.plugins.ewColorPickerColorMode)&&"hex"===e.getCurrentMode()?o&&!o.startsWith("#")&&(e=w(o))&&(e=Tt(e))&&(o=Ht(e)):this.hasAlpha&&!t.startsWith("rgba")?o=Mt(y(t)):!this.hasAlpha&&t.startsWith("rgba")&&(o=Bt(t)),o):""},B.prototype.destroy=function(){this.input&&(m(this.input,"blur",this.debouncedOnInputColor),m(this.input,"keydown",this.debouncedOnInputColor)),this.input=null},B.prototype.install=function(t){var e=this;this.ewColorPicker=t,this.handleOptions(),h(null==t?void 0:t.on)&&t.on("change",function(t){e.update(t)}),null!=(t=this.run)&&t.call(this)},B.pluginName="ewColorPickerInput",B.applyOrder=N.Post;var oe=B;function B(t){this.ewColorPicker=t,this.options={},this.input=null,this._hasInput=!0,this.handleOptions(),!1===this.options.hasInput&&(this._hasInput=!1),this.debouncedOnInputColor=At(this.onInputColor.bind(this),300),this.run(),this.hasAlpha=!!this.ewColorPicker.plugins.ewColorPickerAlpha}Object.defineProperty(M.prototype,"prefix",{get:function(){return this.options.prefix||k},enumerable:!1,configurable:!0}),M.prototype.createElements=function(){var t=this.prefix,e=(this.container=u("div"),p(this.container,"".concat(t,"input-number")),p(this.container,"".concat(t,"input-number--").concat(this.options.size)),this.input=u("input"),p(this.input,"".concat(t,"input-number__input")),g(this.input,{type:"text",inputmode:"decimal",placeholder:this.options.placeholder}),u("div"));p(e,"".concat(t,"input-number__buttons")),this.upButton=u("button"),p(this.upButton,"".concat(t,"input-number__button")),p(this.upButton,"".concat(t,"input-number__button--up")),g(this.upButton,{type:"button"}),this.upButton.innerHTML=Vt("".concat(t,"input-number__icon"),void 0,t),this.downButton=u("button"),p(this.downButton,"".concat(t,"input-number__button")),p(this.downButton,"".concat(t,"input-number__button--down")),g(this.downButton,{type:"button"}),this.downButton.innerHTML=Lt("".concat(t,"input-number__icon"),void 0,t),b(e,this.upButton),b(e,this.downButton),b(this.container,this.input),b(this.container,e),this.setStyles()},M.prototype.setStyles=function(){this.options.disabled&&this.setDisabled(!0)},M.prototype.bindEvents=function(){C(this.input,"input",this.handleInput.bind(this)),C(this.input,"blur",this.handleBlur.bind(this)),C(this.input,"focus",this.handleFocus.bind(this)),C(this.input,"keydown",this.handleKeydown.bind(this)),C(this.upButton,"click",this.handleUpClick.bind(this)),C(this.downButton,"click",this.handleDownClick.bind(this)),C(this.container,"wheel",this.handleWheel.bind(this))},M.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)},M.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)},M.prototype.handleFocus=function(t){this.isFocused=!0,this.addClass(this.container,"".concat(this.prefix,"input-number--focused")),this.options.onFocus(t)},M.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()}},M.prototype.handleUpClick=function(){this.options.disabled||this.increment()},M.prototype.handleDownClick=function(){this.options.disabled||this.decrement()},M.prototype.handleWheel=function(t){this.isFocused&&!this.options.disabled&&(t.preventDefault(),t.deltaY<0?this.increment():this.decrement())},M.prototype.increment=function(){var t=this.currentValue+this.options.step;this.updateValue(t)},M.prototype.decrement=function(){var t=this.currentValue-this.options.step;this.updateValue(t)},M.prototype.updateValue=function(t,e){void 0===e&&(e=!0);var o=this.options.min,i=this.options.max,o=(t<o?t=o:i<t&&(t=i),this.options.precision);t=Math.round(t*Math.pow(10,o))/Math.pow(10,o),this.currentValue=t,this.formatDisplayValue(),e&&this.debouncedOnChange(t)},M.prototype.formatDisplayValue=function(){var t=this.options.precision;this.input.value=this.currentValue.toFixed(t)},M.prototype.addClass=function(t,e){lt(t,e)||p(t,e)},M.prototype.removeClass=function(t,e){lt(t,e)&&s(t,e)},M.prototype.getValue=function(){return this.currentValue},M.prototype.setValue=function(t,e){this.updateValue(t,e=void 0===e?!0:e)},M.prototype.setDisabled=function(t){(this.options.disabled=t)?(this.addClass(this.container,"".concat(this.prefix,"input-number--disabled")),g(this.input,{disabled:"true"}),g(this.upButton,{disabled:"true"}),g(this.downButton,{disabled:"true"})):(this.removeClass(this.container,"".concat(this.prefix,"input-number--disabled")),g(this.input,{disabled:"false"}),g(this.upButton,{disabled:"false"}),g(this.downButton,{disabled:"false"}))},M.prototype.getElement=function(){return this.container},M.prototype.destroy=function(){var t;m(this.input,"input",this.handleInput.bind(this)),m(this.input,"blur",this.handleBlur.bind(this)),m(this.input,"focus",this.handleFocus.bind(this)),m(this.input,"keydown",this.handleKeydown.bind(this)),m(this.upButton,"click",this.handleUpClick.bind(this)),m(this.downButton,"click",this.handleDownClick.bind(this)),m(this.container,"wheel",this.handleWheel.bind(this)),null!=(t=this.container)&&t.parentNode&&n(this.container),this.container=null,this.input=null,this.upButton=null,this.downButton=null},M.prototype.install=function(t){var e;this.ewColorPicker=t,null!=(e=this.handleOptions)&&e.call(this),!1!==(null==(e=this.ewColorPicker.options)?void 0:e.showInputNumber)&&(h(t.on)&&t.on("change",function(){}),null!=(e=this.run))&&e.call(this)};var ie=M;function M(t){void 0===t&&(t={});var e={value:0,min:-1/0,max:1/0,step:1,precision:0,disabled:this.isFocused=!1,placeholder:"",size:"default",prefix:k,onChange:function(){},onBlur:function(){},onFocus:function(){}};this.options=l(e,t),this.currentValue=null!=(e=this.options.value)?e:0,this.debouncedOnChange=At(this.options.onChange,300),this.createElements(),this.bindEvents(),this.updateValue(this.currentValue,!1)}re.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),this.run()},re.prototype.updateOptions=function(){var e=this;this.handleOptions(),this.instances.forEach(function(t){U(e.options.disabled)||t.setDisabled(e.options.disabled)})},re.prototype.run=function(){var t,e,o;this.ewColorPicker&&(o=r(this.ewColorPicker),t=this.createInputNumber({value:0,disabled:this.options.disabled||!1,prefix:o}),this.instances.set("default",t),e=this.ewColorPicker.getMountPoint("panelContainer"))&&(o=v(".".concat(o,"color-picker-bottom-row"),e))&&o.appendChild(t.getElement())},re.prototype.handleOptions=function(){var t=null==(t=this.ewColorPicker)?void 0:t.options;t&&(this.options=f(f(f({},this.options),t),{disabled:U(t.disabled)?this.options.disabled||!1:t.disabled}))},re.prototype.createInputNumber=function(t){return new ie(t)},re.prototype.destroy=function(){this.instances.forEach(function(t){t.destroy()}),this.instances.clear(),this.ewColorPicker=null},re.pluginName="ewColorPickerInputNumber",re.applyOrder=N.Post;var ne=re;function re(t){this.options={},this.instances=new Map,this.ewColorPicker=t,this.handleOptions()}Object.defineProperty(I.prototype,"prefix",{get:function(){return this.options.prefix||k},enumerable:!1,configurable:!0}),I.prototype.createElements=function(){var t=this.prefix,e=(this.container=u("div"),p(this.container,"".concat(t,"select")),p(this.container,"".concat(t,"select--").concat(this.options.size)),this.trigger=u("button"),p(this.trigger,"".concat(t,"select__trigger")),g(this.trigger,{type:"button","aria-haspopup":"listbox","aria-expanded":"false"}),this.valueText=u("span"),p(this.valueText,"".concat(t,"select__value")),this.clearNode=u("span"),p(this.clearNode,"".concat(t,"select__clear")),p(this.clearNode,"".concat(t,"select__clear--hidden")),g(this.clearNode,{role:"button","aria-label":"Clear selection",tabindex:"-1"}),this.clearNode.innerHTML=zt("".concat(t,"select__clear-icon"),12,t),u("span"));p(e,"".concat(t,"select__arrow")),e.innerHTML=Lt("".concat(t,"select__arrow-icon"),12,t),b(this.trigger,this.valueText),b(this.trigger,this.clearNode),b(this.trigger,e),this.dropdown=u("div"),p(this.dropdown,"".concat(t,"select__dropdown")),g(this.dropdown,{role:"listbox"}),b(this.container,this.trigger),b(this.container,this.dropdown),this.options.disabled&&this.setDisabled(!0)},I.prototype.renderOptions=function(){var i,n=this;this.dropdown&&(this.dropdown.textContent="",this.optionNodes=[],i=this.prefix,this.items.forEach(function(t,e){var o=u("div");p(o,"".concat(i,"select__option")),g(o,{role:"option","data-select-index":String(e)}),o.textContent=t.label,t.disabled&&(p(o,"".concat(i,"select__option--disabled")),g(o,{"aria-disabled":"true"})),b(n.dropdown,o),n.optionNodes.push(o)}),this.updateOptionStates())},I.prototype.updateOptionStates=function(){var i=this,n=this.prefix;this.optionNodes.forEach(function(t,e){var o=i.items[e];o&&(o.value!==i.currentValue||o.disabled?(s(t,"".concat(n,"select__option--selected")),g(t,{"aria-selected":"false"})):(p(t,"".concat(n,"select__option--selected")),g(t,{"aria-selected":"true"})),(e===i.activeIndex?p:s)(t,"".concat(n,"select__option--active")))})},I.prototype.updateDisplayValue=function(){var e=this,t=this.prefix,o=this.items.find(function(t){return t.value===e.currentValue}),i=void 0===this.currentValue||""===this.currentValue;this.valueText&&(i?(this.valueText.textContent=this.options.placeholder||"",p):(this.valueText.textContent=o?o.label:String(this.currentValue),s))(this.valueText,"".concat(t,"select__value--placeholder")),this.updateClearVisibility(i)},I.prototype.updateClearVisibility=function(t){var e;this.clearNode&&(e=this.prefix,(!this.options.clearable||t||Boolean(this.options.disabled)?p:s)(this.clearNode,"".concat(e,"select__clear--hidden")))},I.prototype.bindEvents=function(){this.trigger&&this.dropdown&&(C(this.trigger,"click",this.handleTriggerClick),C(this.trigger,"keydown",this.handleKeydown),C(this.dropdown,"click",this.handleDropdownClick))},I.prototype.moveActive=function(t){if(0!==this.items.length){for(var e=this.activeIndex,o=0;o<this.items.length&&(e=(e+t+this.items.length)%this.items.length,this.items[e].disabled);o++);this.activeIndex=e,this.updateOptionStates()}},I.prototype.selectIndex=function(t,e){void 0===e&&(e=!0);t=this.items[t];t&&!t.disabled&&(this.currentValue=t.value,this.updateDisplayValue(),this.close(),e)&&h(this.options.onChange)&&this.options.onChange(t.value,t)},I.prototype.open=function(){var t,e=this;this.options.disabled||this.isOpen||!this.container||(this.isOpen=!0,p(this.container,"".concat(this.prefix,"select--open")),this.trigger&&g(this.trigger,{"aria-expanded":"true"}),t=this.items.findIndex(function(t){return t.value===e.currentValue&&!t.disabled}),this.activeIndex=0<=t?t:0,this.updateOptionStates(),C(document,"mousedown",this.handleDocumentMousedown),h(this.options.onOpen)&&this.options.onOpen())},I.prototype.close=function(){this.isOpen&&this.container?(this.isOpen=!1,s(this.container,"".concat(this.prefix,"select--open")),this.trigger&&g(this.trigger,{"aria-expanded":"false"}),m(document,"mousedown",this.handleDocumentMousedown),h(this.options.onClose)&&this.options.onClose()):this.isOpen=!1},I.prototype.getValue=function(){return this.currentValue},I.prototype.setValue=function(e,t){void 0===t&&(t=!0),this.currentValue=e,this.updateDisplayValue(),this.updateOptionStates(),t&&h(this.options.onChange)&&(t=this.items.find(function(t){return t.value===e}))&&this.options.onChange(e,t)},I.prototype.clear=function(t){var e;void 0===t&&(t=!0),this.options.disabled||(e=void 0===this.currentValue||""===this.currentValue,this.currentValue=void 0,this.activeIndex=-1,this.updateDisplayValue(),this.updateOptionStates(),this.close(),!e&&t&&h(this.options.onClear)&&this.options.onClear())},I.prototype.setItems=function(t){this.items=t||[],this.activeIndex=-1,this.renderOptions(),this.updateDisplayValue()},I.prototype.setDisabled=function(t){this.options.disabled=t,this.container&&this.trigger&&(t?(p(this.container,"".concat(this.prefix,"select--disabled")),g(this.trigger,{disabled:"true"}),this.close()):(s(this.container,"".concat(this.prefix,"select--disabled")),g(this.trigger,{disabled:"false"})),this.updateDisplayValue())},I.prototype.isDropdownOpen=function(){return this.isOpen},I.prototype.getElement=function(){return this.container},I.prototype.destroy=function(){var t;this.close(),this.trigger&&(m(this.trigger,"click",this.handleTriggerClick),m(this.trigger,"keydown",this.handleKeydown)),this.dropdown&&m(this.dropdown,"click",this.handleDropdownClick),null!=(t=this.container)&&t.parentNode&&n(this.container),this.container=null,this.trigger=null,this.valueText=null,this.clearNode=null,this.dropdown=null,this.optionNodes=[]};var se=I;function I(t){void 0===t&&(t={});var o=this;this.container=null,this.trigger=null,this.valueText=null,this.clearNode=null,this.dropdown=null,this.optionNodes=[],this.items=[],this.isOpen=!1,this.activeIndex=-1,this.handleTriggerClick=function(t){var e;o.options.disabled||(e=t.target,o.clearNode&&e&&e.closest(".".concat(o.prefix,"select__clear"))?(t.stopPropagation(),o.clear()):o.isOpen?o.close():o.open())},this.handleDropdownClick=function(t){var t=t.target;t&&(t=t.closest("[data-select-index]"))&&(t=Number(t.getAttribute("data-select-index")),o.selectIndex(t))},this.handleKeydown=function(t){if(!o.options.disabled)switch(t.key){case"ArrowDown":t.preventDefault(),o.isOpen?o.moveActive(1):o.open();break;case"ArrowUp":t.preventDefault(),o.isOpen?o.moveActive(-1):o.open();break;case"Enter":t.preventDefault(),o.isOpen?o.selectIndex(o.activeIndex):o.open();break;case"Escape":o.isOpen&&(t.preventDefault(),o.close());break;case"Tab":o.isOpen&&o.close()}},this.handleDocumentMousedown=function(t){t=t.target;t&&o.container&&(o.container.contains(t)||o.close())},this.options=l({value:void 0,items:[],placeholder:"",disabled:!1,size:"default",prefix:k,clearable:!0,onChange:function(){},onClear:function(){},onOpen:function(){},onClose:function(){}},t),this.items=this.options.items||[],this.currentValue=this.options.value,this.createElements(),this.renderOptions(),this.updateDisplayValue(),this.bindEvents()}le.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),this.run()},le.prototype.handleOptions=function(){var t=null==(t=this.ewColorPicker)?void 0:t.options;t&&(this.options=l({},this.options,t))},le.prototype.updateOptions=function(){this.handleOptions(),this.run()},le.prototype.run=function(){var t,e,o,i=this;this.ewColorPicker&&(this.removeInstance(),t=this.options.selectItems,!1!==this.options.showSelect)&&Array.isArray(t)&&0!==t.length&&(e=r(this.ewColorPicker),o=this.ewColorPicker.getMountPoint("panelContainer"))&&(this.instance=this.createSelect({items:t,value:this.options.selectValue,placeholder:this.options.selectPlaceholder,prefix:e,clearable:!1!==this.options.selectClearable,onChange:function(t,e){h(i.options.onSelectChange)&&i.options.onSelectChange(t,e)},onClear:function(){h(i.options.onSelectClear)&&i.options.onSelectClear()}}),(v(".".concat(e,"color-picker-bottom-row"),o)||o).appendChild(this.instance.getElement()))},le.prototype.createSelect=function(t){return new se(t=void 0===t?{}:t)},le.prototype.removeInstance=function(){this.instance&&(this.instance.destroy(),this.instance=null)},le.prototype.destroy=function(){this.removeInstance(),this.ewColorPicker=null},le.pluginName="ewColorPickerSelect",le.applyOrder=N.Post;var ae=le;function le(t){this.options={},this.instance=null,this.ewColorPicker=t,this.handleOptions(),this.run()}Object.defineProperty(he.prototype,"prefix",{get:function(){return this.options.prefix||k},enumerable:!1,configurable:!0}),he.prototype.createElements=function(){var t=this.prefix;this.container=u("label"),p(this.container,"".concat(t,"checkbox")),p(this.container,"".concat(t,"checkbox--").concat(this.options.size)),this.input=u("input"),p(this.input,"".concat(t,"checkbox__input")),g(this.input,{type:"checkbox"}),this.input.checked=this.currentChecked,this.box=u("span"),p(this.box,"".concat(t,"checkbox__box")),this.box.innerHTML=((t,e,o)=>(void 0===o&&(o=k),e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"",'<svg class="'.concat(o,"color-picker-icon").concat(gt(t),'" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"').concat(e,'><path d="M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path></svg>')))("".concat(t,"checkbox__check-icon"),10,t),this.labelText=u("span"),p(this.labelText,"".concat(t,"checkbox__label")),this.labelText.textContent=this.options.label||"",b(this.container,this.input),b(this.container,this.box),b(this.container,this.labelText),this.syncState(),this.options.disabled&&this.setDisabled(!0)},he.prototype.syncState=function(){var t;this.container&&this.input&&(t=this.prefix,this.input.checked=this.currentChecked,(this.currentChecked?p:s)(this.container,"".concat(t,"checkbox--checked")),g(this.input,{"aria-checked":String(this.currentChecked)}))},he.prototype.bindEvents=function(){this.input&&C(this.input,"change",this.handleChange)},he.prototype.isChecked=function(){return this.currentChecked},he.prototype.setChecked=function(t,e){void 0===e&&(e=!0);t=Boolean(t);this.currentChecked=t,this.syncState(),e&&h(this.options.onChange)&&this.options.onChange(t)},he.prototype.setLabel=function(t){this.labelText&&(this.labelText.textContent=t||""),this.options.label=t},he.prototype.setDisabled=function(t){this.options.disabled=t,this.container&&this.input&&((this.input.disabled=t)?p:s)(this.container,"".concat(this.prefix,"checkbox--disabled"))},he.prototype.getElement=function(){return this.container},he.prototype.destroy=function(){var t;this.input&&m(this.input,"change",this.handleChange),null!=(t=this.container)&&t.parentNode&&n(this.container),this.container=null,this.input=null,this.box=null,this.labelText=null};var ce=he;function he(t){void 0===t&&(t={});var e=this;this.container=null,this.input=null,this.box=null,this.labelText=null,this.currentChecked=!1,this.handleChange=function(){e.input&&!e.options.disabled&&(e.currentChecked=e.input.checked,e.syncState(),h(e.options.onChange))&&e.options.onChange(e.currentChecked)},this.options=l({checked:!1,label:"",disabled:!1,size:"default",prefix:k,onChange:function(){}},t),this.currentChecked=Boolean(this.options.checked),this.createElements(),this.bindEvents()}pe.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),this.run()},pe.prototype.handleOptions=function(){var t=null==(t=this.ewColorPicker)?void 0:t.options;t&&(this.options=l({},this.options,t))},pe.prototype.updateOptions=function(){this.handleOptions(),this.run()},pe.prototype.run=function(){var t,e,o,i=this;this.ewColorPicker&&(this.removeInstance(),t=this.options.checkboxLabel,!1!==this.options.showCheckbox)&&"string"==typeof t&&""!==t&&(e=r(this.ewColorPicker),o=this.ewColorPicker.getMountPoint("panelContainer"))&&(this.instance=this.createCheckbox({label:t,checked:!0===this.options.checkboxChecked,disabled:!0===this.options.checkboxDisabled,prefix:e,onChange:function(t){h(i.options.onCheckboxChange)&&i.options.onCheckboxChange(t)}}),(v(".".concat(e,"color-picker-bottom-row"),o)||o).appendChild(this.instance.getElement()))},pe.prototype.createCheckbox=function(t){return new ce(t=void 0===t?{}:t)},pe.prototype.removeInstance=function(){this.instance&&(this.instance.destroy(),this.instance=null)},pe.prototype.destroy=function(){this.removeInstance(),this.ewColorPicker=null},pe.pluginName="ewColorPickerCheckbox",pe.applyOrder=N.Post;var ue=pe;function pe(t){this.options={},this.instance=null,this.ewColorPicker=t,this.handleOptions(),this.run()}Object.defineProperty(O.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(O.prototype,"hasClear",{get:function(){return this._hasClear},set:function(t){this._hasClear!==t&&(this._hasClear=t,this.render())},enumerable:!1,configurable:!0}),Object.defineProperty(O.prototype,"hasSure",{get:function(){return this._hasSure},set:function(t){this._hasSure!==t&&(this._hasSure=t,this.render())},enumerable:!1,configurable:!0}),O.prototype.enableClear=function(t){this.hasClear=t=void 0===t?!0:t},O.prototype.enableSure=function(t){this.hasSure=t=void 0===t?!0:t},O.prototype.enableButtons=function(t){this.hasClear=t=void 0===t?!0:t,this.hasSure=t},O.prototype.handleOptions=function(){this.options=l({},this.options,this.ewColorPicker.options)},O.prototype.updateOptions=function(){var t=this;this.handleOptions(),setTimeout(function(){t.render()},0)},O.prototype.run=function(){var t=this;!1!==this.options.showButton&&(this.render(),this.bindEvents(),setTimeout(function(){t.adjustButtonGroupStyle()},0))},O.prototype.render=function(){var t,e=this.ewColorPicker.getMountPoint("panelContainer");e?(e=v(".".concat(this.prefix,"color-picker-bottom-row"),e))?((t=v(".".concat(this.prefix,"color-picker-drop-btn-group"),e))||(t=u("div"),p(t,"".concat(this.prefix,"color-picker-drop-btn-group")),b(e,t)),t.textContent="",this.hasClear&&(this.clearButton=u("button"),p(this.clearButton,"".concat(this.prefix,"color-picker-clear-btn ").concat(this.prefix,"color-picker-drop-btn")),this.setClearText(this.options.clearText||"清空"),b(t,this.clearButton)),this.hasSure&&(this.sureButton=u("button"),p(this.sureButton,"".concat(this.prefix,"color-picker-sure-btn ").concat(this.prefix,"color-picker-drop-btn")),this.setSureText(this.options.sureText||"确认"),b(t,this.sureButton)),this.adjustButtonGroupStyle()):c("[ewColorPicker warning]: Bottom row container not found"):c("[ewColorPicker warning]: Panel container not found")},O.prototype.bindEvents=function(){var t=this;this.clearButton&&C(this.clearButton,"click",function(){t.debouncedOnClearColor()}),this.sureButton&&C(this.sureButton,"click",function(){t.debouncedOnSureColor()}),this.ewColorPicker.on("mode-change",function(){t.adjustButtonGroupStyle()})},O.prototype.onClearColor=function(){var t,e,o;this.ewColorPicker.options.defaultColor?(o=w(e=this.ewColorPicker.options.defaultColor))&&(t=y(o)):(e="",t=void 0),this.ewColorPicker.hsvaColor=t||{h:0,s:100,v:100,a:1},this.ewColorPicker.setColor(e),this.ewColorPicker.syncAllPlugins(e),this.ewColorPicker.hidePanel(),h(this.options.clear)&&null!=(t=(o=this.options).clear)&&t.call(o,this.ewColorPicker),this.ewColorPicker.trigger("clear")},O.prototype.onSureColor=function(){var t,e;h(this.options.sure)&&null!=(e=(t=this.options).sure)&&e.call(t,this.ewColorPicker.currentColor,this.ewColorPicker),this.ewColorPicker.trigger("sure",this.ewColorPicker.currentColor,this.ewColorPicker),this.ewColorPicker.hidePanel()},O.prototype.setClearText=function(t){this.clearButton&&(this.clearButton.textContent=t)},O.prototype.setSureText=function(t){this.sureButton&&(this.sureButton.textContent=t)},O.prototype.setDisabled=function(t){this.clearButton&&g(this.clearButton,{disabled:t.toString()}),this.sureButton&&g(this.sureButton,{disabled:t.toString()})},O.prototype.destroy=function(){this.clearButton&&m(this.clearButton,"click",this.debouncedOnClearColor),this.sureButton&&m(this.sureButton,"click",this.debouncedOnSureColor),this.clearButton=null,this.sureButton=null},O.prototype.adjustButtonGroupStyle=function(){var t,e,o=this.prefix,i=this.ewColorPicker.getMountPoint("panelContainer");i&&(t=v(".".concat(o,"color-picker-bottom-row"),i))&&(e=v(".".concat(o,"color-picker-drop-btn-group"),t))&&(null!==v(".".concat(o,"color-picker-inputs-group"),i)?(p(e,"".concat(o,"color-picker-drop-btn-group-multi")),s(e,"".concat(o,"color-picker-drop-btn-group-single")),p(t,"".concat(o,"color-picker-bottom-row-multi")),s(t,"".concat(o,"color-picker-bottom-row-single"))):(p(e,"".concat(o,"color-picker-drop-btn-group-single")),s(e,"".concat(o,"color-picker-drop-btn-group-multi")),p(t,"".concat(o,"color-picker-bottom-row-single")),s(t,"".concat(o,"color-picker-bottom-row-multi"))))},O.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),null!=(t=this.run)&&t.call(this)},O.pluginName="ewColorPickerButton",O.applyOrder=N.Post;var de=O;function O(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=At(this.onClearColor.bind(this),100),this.debouncedOnSureColor=At(this.onSureColor.bind(this),100),this.run()}Object.defineProperty(H.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),H.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=l(this.options,this.ewColorPicker.options),this.ewColorPicker.options.ewColorPickerPredefine)&&(this.options=l(this.options,this.ewColorPicker.options.ewColorPickerPredefine))},H.prototype.run=function(){0<this.getValidPredefineColors().length&&(this.render(),this.bindEvents(),this.bindColorChangeEvent())},H.prototype.getValidPredefineColors=function(){var e=this;return this.options.predefineColor&&Array.isArray(this.options.predefineColor)?this.options.predefineColor.filter(function(t){var t=e.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))}):[]},H.prototype.render=function(){var i=this,t=this.ewColorPicker.getMountPoint("panelContainer");t?(this.container=v(".".concat(this.prefix,"color-picker-predefine-container"),t),this.container||(this.container=u("div"),p(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,e=u("div"),o=(p(e,"".concat(i.prefix,"color-picker-predefine-color")),u("div"));p(o,"".concat(i.prefix,"color-picker-predefine-color-item")),d(o,"backgroundColor",t),b(e,o),b(i.container,e),i.predefineItems.push(e)})),this.ensureContainerAtCorrectPosition(t),this.bindToggleEvent(t)):c("[ewColorPicker warning]: Panel container not found")},H.prototype.parseColorData=function(t){return{color:et(t)?t:t.color,disabled:!!G(t)&&t.disabled}},H.prototype.bindToggleEvent=function(e){var o=this;this.isEventBound&&this.toggleHandler&&(this.ewColorPicker.off("toggle",this.toggleHandler),this.isEventBound=!1),this.toggleHandler=function(t){t&&o.ensureContainerAtCorrectPosition(e)},this.ewColorPicker.on("toggle",this.toggleHandler),this.isEventBound=!0},H.prototype.bindColorChangeEvent=function(){var e=this;this.changeHandler&&this.ewColorPicker.off("change",this.changeHandler),this.changeHandler=function(t){e.updateActivePredefineColor(t)},this.ewColorPicker.on("change",this.changeHandler)},H.prototype.ensureContainerAtCorrectPosition=function(t){var e,o;this.container&&(e=this.prefix,(o=v(".".concat(e,"color-picker-mode-container"),t))?t.insertBefore(this.container,o):(o=v(".".concat(e,"color-picker-bottom-row"),t))?t.insertBefore(this.container,o):(o=v(".".concat(e,"color-picker-panel"),t))&&o.nextSibling?t.insertBefore(this.container,o.nextSibling):t.appendChild(this.container))},H.prototype.bindEvents=function(){var i=this;this.predefineItems.forEach(function(t,e){var e=i.getValidPredefineColors()[e],e=i.parseColorData(e),o=e.color;e.disabled?p(t,"".concat(i.prefix,"color-picker-predefine-color-disabled")):(C(t,"click",function(t){i.debouncedOnPredefineColorClick(t,o)}),C(t,"blur",function(t){s(t.target,"".concat(i.prefix,"color-picker-predefine-color-active"))}))})},H.prototype.onPredefineColorClick=function(t,e){var o,i,n=this.prefix,r=t.target;lt(r,"".concat(n,"color-picker-predefine-color"))||(r=r.closest(".".concat(n,"color-picker-predefine-color"))||r),lt(r,"".concat(n,"color-picker-predefine-color-disabled"))||(this.options.disabled?(t.preventDefault(),t.stopPropagation()):(p(r,"".concat(n,"color-picker-predefine-color-active")),this.predefineItems.forEach(function(t){t!==r&&s(t,"".concat(n,"color-picker-predefine-color-active"))}),Ot(e)?(t=w(e),this.ewColorPicker.hsvaColor=y(t),this.ewColorPicker.setColor(t),h(this.options.changeColor)&&null!=(i=(o=this.options).changeColor)&&i.call(o,t)):c("[ewColorPicker warning]: Invalid predefine color: ".concat(e))))},H.prototype.updatePredefineColors=function(t){this.options.predefineColor=t,this.predefineItems=[],this.render(),this.bindEvents()},H.prototype.setDisabled=function(t,e){this.predefineItems[t]&&(e?p:s)(this.predefineItems[t],"".concat(this.prefix,"color-picker-predefine-color-disabled"))},H.prototype.destroy=function(){var e=this;this.predefineItems.forEach(function(t){m(t,"click",e.debouncedOnPredefineColorClick),m(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},H.prototype.install=function(t){this.ewColorPicker=t,this.handleOptions(),null!=(t=this.run)&&t.call(this)},H.prototype.updateActivePredefineColor=function(t){var o,i,n=this;t&&(o=w(t),i=this.prefix,this.predefineItems.forEach(function(t,e){e=n.getValidPredefineColors()[e],e=w(n.parseColorData(e).color);(o===e?p:s)(t,"".concat(i,"color-picker-predefine-color-active"))}))},H.pluginName="ewColorPickerPredefine";var fe=H;function H(t){this.ewColorPicker=t,this.options={},this.predefineItems=[],this.container=null,this.toggleHandler=null,this.changeHandler=null,this.isEventBound=!1,this.handleOptions(),this.debouncedOnPredefineColorClick=At(this.onPredefineColorClick.bind(this),100),this.run()}Object.defineProperty(T.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"hasAlphaPlugin",{get:function(){var t;return!(null==(t=this.ewColorPicker.plugins)||!t.ewColorPickerAlpha)},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"inputPlugin",{get:function(){var t;return null==(t=this.ewColorPicker.plugins)?void 0:t.ewColorPickerInput},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"alphaPlugin",{get:function(){var t;return null==(t=this.ewColorPicker.plugins)?void 0:t.ewColorPickerAlpha},enumerable:!1,configurable:!0}),T.prototype.initializePlugin=function(){function t(){e.handleOptions(),e.run()}var e=this;this.ewColorPicker.plugins?t():setTimeout(t,0)},T.prototype.install=function(e){function t(){var t;o.handleOptions(),e.on&&h(e.on)&&e.on("change",function(t){"hex"!==o.currentMode&&o.updateInputValues(t)}),null!=(t=o.run)&&t.call(o),o.hasAlphaPlugin&&"rgb"===o.currentMode&&o.updateInputStructure()}var o=this;this.ewColorPicker=e;this.ewColorPicker.plugins?t():setTimeout(t,0)},T.prototype.handleOptions=function(){this.ewColorPicker&&this.ewColorPicker.options&&(this.options=l({},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=l({},this.options,this.ewColorPicker.options.ewColorPickerColorMode))),this.hasAlphaPlugin?this.currentMode=this.options.defaultMode||"rgb":this.currentMode=this.options.defaultMode||"hex")},T.prototype.updateOptions=function(){this.handleOptions(),this.render()},T.prototype.run=function(){this.handleOptions(),!1!==this.options.showColorMode&&(this.render(),this.bindEvents(),this.hasAlphaPlugin&&"rgb"===this.currentMode&&this.updateInputStructure(),this.setupInputPluginListener())},T.prototype.render=function(){var t=this.ewColorPicker.getMountPoint("panelContainer");t?(this.modeContainer=v(".".concat(this.prefix,"color-picker-mode-container"),t),this.modeContainer||this.createModeContainer(t),this.updateModeDisplay()):c("[ewColorPicker] Panel container not found")},T.prototype.createModeContainer=function(t){var e=this.prefix,e=(this.modeContainer=u("div"),p(this.modeContainer,"".concat(e,"color-picker-mode-container")),this.upButton=u("button"),p(this.upButton,"".concat(e,"color-picker-mode-up-btn")),g(this.upButton,{type:"button",title:"上一个模式"}),this.upButton.innerHTML=Vt("",16,e),this.modeText=u("div"),p(this.modeText,"".concat(e,"color-picker-mode-text")),this.downButton=u("button"),p(this.downButton,"".concat(e,"color-picker-mode-down-btn")),g(this.downButton,{type:"button",title:"下一个模式"}),this.downButton.innerHTML=Lt("",16,e),b(this.modeContainer,this.upButton),b(this.modeContainer,this.modeText),b(this.modeContainer,this.downButton),v(".".concat(e,"color-picker-bottom-row"),t));e?b(t,this.modeContainer,void 0,e):b(t,this.modeContainer)},T.prototype.updateModeDisplay=function(){this.modeText&&(this.modeText.textContent=this.getModeDisplayName(this.currentMode))},T.prototype.bindEvents=function(){var t,e=this;this.upButton&&this.downButton&&(C(this.upButton,"click",t=function(){e.options.disabled||e.switchToPreviousMode()}),this.boundEventHandlers.push({element:this.upButton,event:"click",handler:t}),C(this.downButton,"click",t=function(){e.options.disabled||e.switchToNextMode()}),this.boundEventHandlers.push({element:this.downButton,event:"click",handler:t}),this.upButton&&(C(this.upButton,"mouseenter",this.handleUpButtonHover),C(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&&(C(this.downButton,"mouseenter",this.handleDownButtonHover),C(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"!==e.currentMode&&e.updateInputValues(t)}))},T.prototype.switchToPreviousMode=function(){var t=["hex","rgb","hsl"],e=t.indexOf(this.currentMode);this.debouncedOnModeChange(t[0<e?e-1:t.length-1])},T.prototype.switchToNextMode=function(){var t=["hex","rgb","hsl"],e=t.indexOf(this.currentMode);this.debouncedOnModeChange(t[(e+1)%t.length])},T.prototype.onModeChange=function(t){this.currentMode=t,this.updateModeDisplay(),this.updateInputStructure();var e,o=this.ewColorPicker.getColor();o&&"hex"!==t&&this.updateInputValues(o),h(this.options.changeMode)&&null!=(e=(o=this.options).changeMode)&&e.call(o,t,this.ewColorPicker),this.ewColorPicker.trigger("mode-change",t)},T.prototype.updateInputStructure=function(){var t=this.prefix,e=this.ewColorPicker.getMountPoint("panelContainer");e&&(e=v(".".concat(t,"color-picker-bottom-row"),e))&&(t=v(".".concat(t,"color-picker-input-container"),e))&&(this.inputPlugin&&!this.inputPlugin.hasInput?(this.clearInputNumberInstances(),t.innerHTML=""):(this.clearInputNumberInstances(),"hex"===this.currentMode?this.restoreDefaultInput():(t.innerHTML="",this.createInputsForMode(t))))},T.prototype.setupInputPluginListener=function(){},T.prototype.createInputsForMode=function(t){var s,e,a=this,l=this.prefix;(!this.inputPlugin||this.inputPlugin.hasInput)&&(t.innerHTML="",e=[],"rgb"===this.currentMode?e=this.hasAlphaPlugin?["R","G","B","A"]:["R","G","B"]:"hsl"===this.currentMode&&(e=this.hasAlphaPlugin?["H","S","L","A"]:["H","S","L"]),s=u("div"),p(s,"".concat(l,"color-picker-inputs-group")),e.forEach(function(t,e){var o,i,n=u("div"),r=(p(n,"".concat(l,"color-picker-inputs-col")),u("div"));p(r,"".concat(l,"color-picker-input-label")),r.textContent=t,b(n,r),"rgb"===a.currentMode?(o=(i=new ie({value:0,min:0,max:3===e?1:255,step:3===e?.01:1,precision:3===e?2:0,placeholder:t,size:"small",prefix:l,onChange:function(){a.debouncedUpdateColorFromRgb()}})).getElement(),a.inputNumberInstances.set(t.toLowerCase(),i),p(o,"".concat(l,"color-picker-rgb-").concat(t.toLowerCase(),"-input"))):"hsl"===a.currentMode&&(0===e?(o=(i=new ie({value:0,min:0,max:360,step:1,precision:0,placeholder:t,size:"small",prefix:l,onChange:function(){a.debouncedUpdateColorFromHsl()}})).getElement(),a.inputNumberInstances.set("h",i)):3===e&&a.hasAlphaPlugin?(o=(i=new ie({value:0,min:0,max:1,step:.01,precision:2,placeholder:t,size:"small",prefix:l,onChange:function(){a.debouncedUpdateColorFromHsl()}})).getElement(),a.inputNumberInstances.set("a",i)):(o=u("input"),g(o,{type:"text",placeholder:t,class:"".concat(l,"color-picker-hsl-").concat(t.toLowerCase(),"-input ").concat(l,"color-picker-input")})),o)&&p(o,"".concat(l,"color-picker-hsl-").concat(t.toLowerCase(),"-input")),o||(o=u("input"),g(o,{type:"text",placeholder:t,class:"".concat(l,"color-picker-default-input")})),b(n,o),b(s,n)}),b(t,s),e=this.ewColorPicker.getColor())&&this.updateInputValues(e)},T.prototype.getInputContainer=function(){var t=this.prefix,e=this.ewColorPicker.getMountPoint("panelContainer");return(e=e&&v(".".concat(t,"color-picker-bottom-row"),e))&&v(".".concat(t,"color-picker-input-container"),e)||document},T.prototype.syncChannelValue=function(t,e,o){var i,t=this.inputNumberInstances.get(t);t?(i=parseFloat(o),isNaN(i)||t.setValue(i,!1)):e&&(e.value=o)},T.prototype.clearInputNumberInstances=function(){this.inputNumberInstances.forEach(function(t){return t.destroy()}),this.inputNumberInstances.clear()},T.prototype.updateInputValues=function(t){var e,o,i,n,r,s,a;t&&(t=w(t))&&(t=Tt(t))&&(e=this.getInputContainer(),o=this.prefix,"rgb"===this.currentMode?(i=v(".".concat(o,"color-picker-rgb-r-input input"),e),n=v(".".concat(o,"color-picker-rgb-g-input input"),e),r=v(".".concat(o,"color-picker-rgb-b-input input"),e),a=v(".".concat(o,"color-picker-rgb-a-input input"),e),this.syncChannelValue("r",i,Math.round(t.r).toString()),this.syncChannelValue("g",n,Math.round(t.g).toString()),this.syncChannelValue("b",r,Math.round(t.b).toString()),this.syncChannelValue("a",a,t.a.toFixed(2))):"hsl"===this.currentMode&&(i=((t,e,o)=>{t/=255,e/=255,o/=255;var i=Math.max(t,e,o),n=Math.min(t,e,o),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=(e-o)/l+(e<o?6:0);break;case e:r=(o-t)/l+2;break;case o:r=(t-e)/l+4}r/=6}return{h:360*r,s:100*s,l:100*a}})(t.r,t.g,t.b),n=v(".".concat(o,"color-picker-hsl-h-input input"),e),r=v(".".concat(o,"color-picker-hsl-s-input"),e),s=v(".".concat(o,"color-picker-hsl-l-input"),e),a=v(".".concat(o,"color-picker-hsl-a-input input"),e),this.syncChannelValue("h",n,Math.round(i.h).toString()),this.syncChannelValue("s",r,Math.round(i.s).toString()+"%"),this.syncChannelValue("l",s,Math.round(i.l).toString()+"%"),this.syncChannelValue("a",a,t.a.toFixed(2))))},T.prototype.updateColorFromRgbInputs=function(){var t=this.getInputContainer(),e=this.prefix,o=v(".".concat(e,"color-picker-rgb-r-input input"),t),i=v(".".concat(e,"color-picker-rgb-g-input input"),t),n=v(".".concat(e,"color-picker-rgb-b-input input"),t),e=v(".".concat(e,"color-picker-rgb-a-input input"),t);o&&i&&n&&(t=parseInt(o.value)||0,o=parseInt(i.value)||0,i=parseInt(n.value)||0,n=e&&parseFloat(e.value)||1,e="rgba(".concat(t,", ").concat(o,", ").concat(i,", ").concat(n,")"),this.ewColorPicker.setColor(e),this.ewColorPicker.syncAllPlugins(e),this.alphaPlugin)&&this.alphaPlugin.updateAlphaThumbPosition&&this.alphaPlugin.updateAlphaThumbPosition(n)},T.prototype.updateColorFromHslInputs=function(){var t=this.getInputContainer(),e=this.prefix,o=v(".".concat(e,"color-picker-hsl-h-input input"),t),i=v(".".concat(e,"color-picker-hsl-s-input"),t),n=v(".".concat(e,"color-picker-hsl-l-input"),t),e=v(".".concat(e,"color-picker-hsl-a-input input"),t);o&&i&&n&&(t=parseInt(o.value)||0,o=parseInt(i.value.replace("%",""))||0,i=parseInt(n.value.replace("%",""))||0,n=e&&parseFloat(e.value)||1,e="hsla(".concat(t,", ").concat(o,"%, ").concat(i,"%, ").concat(n,")"),this.ewColorPicker.setColor(e),this.ewColorPicker.syncAllPlugins(e),this.alphaPlugin)&&this.alphaPlugin.updateAlphaThumbPosition&&this.alphaPlugin.updateAlphaThumbPosition(n)},T.prototype.getModeDisplayName=function(t){return{hex:"HEX",rgb:"RGB",hsl:"HSL"}[t]||t.toUpperCase()},T.prototype.getCurrentMode=function(){return this.currentMode},T.prototype.setMode=function(t){this.debouncedOnModeChange(t)},T.prototype.restoreDefaultInput=function(){var t,e=this.prefix,o=this.ewColorPicker.getMountPoint("panelContainer");o&&(o=v(".".concat(e,"color-picker-bottom-row"),o))&&(o=v(".".concat(e,"color-picker-input-container"),o))&&(this.inputPlugin&&!this.inputPlugin.hasInput?o.innerHTML="":(o.innerHTML="",p(o,"".concat(e,"color-picker-input-container-flex")),t=u("input"),p(t,"".concat(e,"color-picker-input")),p(t,"".concat(e,"color-picker-input-default")),g(t,{type:"text",name:"".concat(e,"color-picker-input"),placeholder:"请输入颜色值"}),b(o,t),(e=this.ewColorPicker.getColor())&&-1===e.indexOf("NaN")||(e=""),"hex"===this.currentMode&&(o=w(e))&&(o=Tt(o))?(o=Ht(o),t.value=o):t.value=e,this.bindDefaultInputEvents(t)))},T.prototype.bindDefaultInputEvents=function(t){this.bindInputEvents(t)},T.prototype.rebindDefaultInputEvents=function(){var t=this.prefix,e=this.ewColorPicker.getMountPoint("panelContainer");e&&(e=v(".".concat(t,"color-picker-bottom-row"),e))&&(e=v(".".concat(t,"color-picker-input-container"),e))&&(t=v(".".concat(t,"color-picker-hex-input"),e))&&this.bindInputEvents(t)},T.prototype.bindInputEvents=function(e){function t(t){Ot(t=t.target.value)&&(i.ewColorPicker.setColor(t),i.syncOtherPlugins(t))}function o(t){"Enter"===t.key&&Ot(t=t.target.value)&&(i.ewColorPicker.setColor(t),i.syncOtherPlugins(t))}var i=this;C(e,"blur",t),this.boundEventHandlers.push({element:e,event:"blur",handler:t}),C(e,"keydown",o),this.boundEventHandlers.push({element:e,event:"keydown",handler:o});this.ewColorPicker.on("change",function(t){e.value="hex"===i.currentMode?i.toHexDisplay(t):t})},T.prototype.toHexDisplay=function(t){var e;return t?!t.startsWith("#")&&(e=w(t))&&(e=Tt(e))?Ht(e):t:""},T.prototype.syncOtherPlugins=function(t){var e=this.ewColorPicker.hsvaColor,o=(this.inputPlugin&&this.inputPlugin.update&&this.inputPlugin.update(t),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerHue),e=(o&&o.updateHueThumbPosition&&o.updateHueThumbPosition(e.h),this.alphaPlugin&&this.alphaPlugin.updateAlphaThumbPosition&&this.alphaPlugin.updateAlphaThumbPosition(e.a),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerPanel),e=(e&&e.updatePanelColor&&e.updatePanelColor(t),null==(o=this.ewColorPicker.plugins)?void 0:o.ewColorPickerBox);e&&e.setBoxBgColor&&e.setBoxBgColor(t)},T.prototype.destroy=function(){this.clearInputNumberInstances(),this.boundEventHandlers.forEach(function(t){var e=t.element;m(e,t.event,t.handler)}),this.boundEventHandlers=[],this.modeContainer&&this.modeContainer.parentNode&&n(this.modeContainer),this.modeContainer=null,this.modeText=null,this.upButton=null,this.downButton=null},T.pluginName="ewColorPickerColorMode",T.applyOrder=N.Post;var ge=T;function T(t){var e=this;this.ewColorPicker=t,this.options={},this.currentMode="hex",this.modeContainer=null,this.modeText=null,this.upButton=null,this.downButton=null,this.inputNumberInstances=new Map,this.boundEventHandlers=[],this.handleUpButtonHover=function(){e.upButton&&d(e.upButton,{borderColor:"#4096ef",backgroundColor:"#f0f8ff"})},this.handleUpButtonLeave=function(){e.upButton&&d(e.upButton,{borderColor:"#ddd",backgroundColor:"#fff"})},this.handleDownButtonHover=function(){e.downButton&&d(e.downButton,{borderColor:"#4096ef",backgroundColor:"#f0f8ff"})},this.handleDownButtonLeave=function(){e.downButton&&d(e.downButton,{borderColor:"#ddd",backgroundColor:"#fff"})},this.debouncedOnModeChange=At(this.onModeChange.bind(this),100),this.debouncedUpdateColorFromRgb=At(this.updateColorFromRgbInputs.bind(this),100),this.debouncedUpdateColorFromHsl=At(this.updateColorFromHslInputs.bind(this),100),this.initializePlugin()}Object.defineProperty(S.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),S.prototype.isSupported=function(){return"undefined"!=typeof window&&"EyeDropper"in window},S.prototype.handleOptions=function(){this.options=l({},this.options,this.ewColorPicker.options)},S.prototype.updateOptions=function(){this.handleOptions(),this.run()},S.prototype.run=function(){!1!==this.options.showEyedropper&&this.isSupported()?(this.removeContainer(),this.render(),this.bindEvents()):this.removeContainer()},S.prototype.render=function(){var t,e=this.ewColorPicker.getMountPoint("panelContainer");e?(e=this.getExtraRow(e),this.container=u("div"),p(this.container,"".concat(this.prefix,"color-picker-eyedropper-group")),this.button=u("button"),p(this.button,"".concat(this.prefix,"color-picker-eyedropper-btn")),g(this.button,{type:"button",title:this.options.eyedropperText||"取色","aria-label":this.options.eyedropperText||"取色"}),this.button.innerHTML=((t,e,o)=>(void 0===o&&(o=k),e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"",'<svg class="'.concat(o,"color-picker-icon").concat(gt(t),'" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"').concat(e,'><path d="M17.66 5.41l.92.92-2.69 2.69-.92-.92 2.69-2.69M17.67 3c-.26 0-.51.1-.71.29l-3.12 3.12-1.93-1.91-1.41 1.41 1.42 1.42L3 16.25V21h4.75l8.92-8.92 1.42 1.42 1.41-1.41-1.92-1.92 3.12-3.12c.4-.4.29-.71.29-.71L17.67 3z"></path></svg>')))(void 0,16,this.prefix),this.options.eyedropperText&&(t=u("span"),p(t,"".concat(this.prefix,"color-picker-eyedropper-text")),t.textContent=this.options.eyedropperText,b(this.button,t)),b(this.container,this.button),b(e,this.container)):c("[ewColorPicker warning]: Panel container not found")},S.prototype.getExtraRow=function(t){var e,o=v(".".concat(this.prefix,"color-picker-extra-row"),t);return o||(o=u("div"),p(o,"".concat(this.prefix,"color-picker-extra-row")),(e=v(".".concat(this.prefix,"color-picker-bottom-row"),t))?b(t,o,null,e):b(t,o),o)},S.prototype.bindEvents=function(){this.button&&C(this.button,"click",this.handleClick)},S.prototype.removeContainer=function(){this.button&&m(this.button,"click",this.handleClick),this.container&&n(this.container),this.button=null;var t,e=(this.container=null)==(e=null==(t=this.ewColorPicker)?void 0:t.getMountPoint)?void 0:e.call(t,"panelContainer");e&&(t=v(".".concat(this.prefix,"color-picker-extra-row"),e))&&0===t.children.length&&n(t)},S.prototype.destroy=function(){this.destroyed=!0,this.removeContainer()},S.prototype.install=function(t){this.ewColorPicker=t,this.destroyed=!1,this.handleOptions(),null!=(t=this.run)&&t.call(this)},S.pluginName="ewColorPickerEyedropper",S.applyOrder=N.Post;var ve=S;function S(t){var e=this;this.ewColorPicker=t,this.options={},this.container=null,this.button=null,this.destroyed=!1,this.handleClick=function(){return F(e,void 0,void 0,function(){var e,o;return R(this,function(t){switch(t.label){case 0:if(this.destroyed)return[2];if(!(e=window.EyeDropper))return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,(new e).open()];case 2:return(o=t.sent(),!this.destroyed&&o&&o.sRGBHex)?(this.ewColorPicker.setColor(o.sRGBHex),h(this.options.onEyedropperPick)&&this.options.onEyedropperPick(o.sRGBHex),[3,4]):[2];case 3:return(o=t.sent())instanceof Error&&"AbortError"===o.name?[2]:(c("[ewColorPicker warning]: Failed to pick color with EyeDropper",o),[3,4]);case 4:return[2]}})})},this.ewColorPicker=t,this.handleOptions(),this.run()}var be="复制颜色到剪贴板",Ce=(Object.defineProperty(E.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),E.prototype.handleOptions=function(){this.options=l({},this.options,this.ewColorPicker.options)},E.prototype.updateOptions=function(){this.handleOptions(),this.run()},E.prototype.run=function(){!1===this.options.showCopyColor?this.removeContainer():(this.removeContainer(),this.render(),this.bindEvents())},E.prototype.render=function(){var t=this.ewColorPicker.getMountPoint("panelContainer");t?(t=this.getExtraRow(t),this.defaultTitle=this.options.copyColorText||be,this.container=u("div"),p(this.container,"".concat(this.prefix,"color-picker-copy-group")),this.button=u("button"),p(this.button,"".concat(this.prefix,"color-picker-copy-btn")),g(this.button,{type:"button",title:this.defaultTitle,"aria-label":this.defaultTitle}),this.button.innerHTML=((t,e,o)=>(void 0===o&&(o=k),e=e&&0<e?' width="'.concat(e,'" height="').concat(e,'"'):"",'<svg class="'.concat(o,"color-picker-icon").concat(gt(t),'" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" fill="currentColor"').concat(e,'><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></svg>')))(void 0,14,this.prefix),this.syncColor(this.ewColorPicker.getColor()),this.tip=u("div"),p(this.tip,"".concat(this.prefix,"color-picker-copy-tip")),g(this.tip,{role:"status","aria-live":"polite"}),this.tip.textContent=this.options.copiedText||"已复制",b(this.container,this.button),b(this.container,this.tip),b(t,this.container)):c("[ewColorPicker warning]: Panel container not found")},E.prototype.getExtraRow=function(t){var e,o=v(".".concat(this.prefix,"color-picker-extra-row"),t);return o||(o=u("div"),p(o,"".concat(this.prefix,"color-picker-extra-row")),(e=v(".".concat(this.prefix,"color-picker-bottom-row"),t))?b(t,o,null,e):b(t,o),o)},E.prototype.bindEvents=function(){this.button&&C(this.button,"click",this.handleClick)},E.prototype.bindCoreEvents=function(){this.listening||(this.ewColorPicker.on("change",this.handleChange),this.listening=!0)},E.prototype.syncColor=function(t){var e,o,i;this.button&&d(this.button,{backgroundColor:t=t||"#ffffff",color:(void 0===e&&(e="#333333"),void 0===o&&(o="#ffffff"),(t=(t=t)&&w(t))&&(i=Tt(t))&&.5<.2126*(t=function(t){t=(t*i.a+255*(1-i.a))/255;return t<=.03928?t/12.92:Math.pow((.055+t)/1.055,2.4)})(i.r)+.7152*t(i.g)+.0722*t(i.b)?e:o)})},E.prototype.copyToClipboard=function(i){return F(this,void 0,void 0,function(){var e,o;return R(this,function(t){switch(t.label){case 0:if("undefined"==typeof navigator||!navigator.clipboard||!h(navigator.clipboard.writeText))return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,navigator.clipboard.writeText(i)];case 2:return t.sent(),[2,!0];case 3:return t.sent(),[3,4];case 4:if("undefined"==typeof document||!h(document.execCommand))return[2,!1];(e=u("textarea")).value=i,d(e,{position:"fixed",top:"-9999px",left:"-9999px",opacity:"0"}),b(document.body,e),e.select(),o=!1;try{o=document.execCommand("copy")}catch(t){o=!1}return n(e),[2,o]}})})},E.prototype.showCopiedState=function(){var t,e=this;this.button&&(t=this.options.copiedText||"已复制",g(this.button,{title:t,"aria-label":t}),p(this.button,"".concat(this.prefix,"color-picker-copy-btn-copied")),this.tip&&(this.tip.textContent=t,p(this.tip,"".concat(this.prefix,"color-picker-copy-tip-show"))),this.resetTitleTimer&&clearTimeout(this.resetTitleTimer),this.resetTitleTimer=setTimeout(function(){e.resetTitleTimer=null,!e.destroyed&&e.button&&(g(e.button,{title:e.defaultTitle,"aria-label":e.defaultTitle}),s(e.button,"".concat(e.prefix,"color-picker-copy-btn-copied")),e.tip)&&s(e.tip,"".concat(e.prefix,"color-picker-copy-tip-show"))},1500))},E.prototype.removeContainer=function(){this.resetTitleTimer&&(clearTimeout(this.resetTitleTimer),this.resetTitleTimer=null),this.button&&m(this.button,"click",this.handleClick),this.container&&n(this.container),this.button=null,this.container=null;var t,e=(this.tip=null)==(e=null==(t=this.ewColorPicker)?void 0:t.getMountPoint)?void 0:e.call(t,"panelContainer");e&&(t=v(".".concat(this.prefix,"color-picker-extra-row"),e))&&0===t.children.length&&n(t)},E.prototype.destroy=function(){this.destroyed=!0,this.removeContainer(),this.ewColorPicker.off("change",this.handleChange),this.listening=!1},E.prototype.install=function(t){this.listening&&(this.ewColorPicker.off("change",this.handleChange),this.listening=!1),this.ewColorPicker=t,this.destroyed=!1,this.handleOptions(),this.run(),this.bindCoreEvents()},E.pluginName="ewColorPickerCopyColor",E.applyOrder=N.Post,E);function E(t){var e=this;this.ewColorPicker=t,this.options={},this.container=null,this.button=null,this.tip=null,this.destroyed=!1,this.listening=!1,this.resetTitleTimer=null,this.defaultTitle=be,this.handleChange=function(t){e.syncColor(t)},this.handleClick=function(){return F(e,void 0,void 0,function(){var e,o;return R(this,function(t){switch(t.label){case 0:return this.destroyed?[2]:(e=this.ewColorPicker.getColor())?[4,this.copyToClipboard(e)]:[2];case 1:return o=t.sent(),this.destroyed||(o?(this.showCopiedState(),h(this.options.onCopyColor)&&this.options.onCopyColor(e)):c("[ewColorPicker warning]: Failed to copy color to clipboard")),[2]}})})},this.ewColorPicker=t,this.handleOptions(),this.run(),this.bindCoreEvents()}function me(t){return{type:t=void 0===t?"linear":t,repeating:!1,angle:{value:180,unit:"deg"},radialShape:"ellipse",radialSize:"farthest-corner",conicFrom:{value:0,unit:"deg"},position:{x:50,y:50},interpolation:null,stops:[]}}function ye(t){return f(f({},t),{angle:f({},t.angle),conicFrom:f({},t.conicFrom),position:f({},t.position),stops:t.stops.map(function(t){return f({},t)})})}function D(t,e,o){return Math.min(Math.max(t,e),o)}function we(t,e){return void 0===e&&(e=1),void 0===t||""===t?e:t.endsWith("%")?D(Number.parseFloat(t)/100,0,1):D(Number.parseFloat(t),0,1)}function ke(t){return t.endsWith("%")?D(255*Number.parseFloat(t)/100,0,255):D(Number.parseFloat(t),0,255)}function Pe(t){var t=t.trim().split("/"),e=t[0],t=t[1],e=e.trim();return{channels:e.includes(",")?e.split(",").map(function(t){return t.trim()}):e.split(/\s+/).filter(Boolean),alpha:null==t?void 0:t.trim()}}function xe(t){var e,o,t=/^hsla?\(([^)]*)\)$/i.exec(t);return!t||(e=(t=Pe(t[1])).channels,t=t.alpha,e.length<3)?null:(o=function(t){return t.endsWith("%"),D(Number.parseFloat(t),0,100)},o=Me((t=>{var e=/^([+-]?(?:\d+\.?\d*|\.\d+))(deg|rad|grad|turn)$/i.exec(t.trim());if(!e)return Number.parseFloat(t)||0;var o=Number.parseFloat(e[1]);switch(e[2].toLowerCase()){case"rad":return 180*o/Math.PI;case"grad":return.9*o;case"turn":return 360*o;default:return o}})(e[0]),o(e[1]),o(e[2])),f(f({},o),{a:we(null!=t?t:e[3])}))}function Be(t){if(t&&"string"==typeof t){t=t.trim().toLowerCase();if("transparent"===t)return{r:0,g:0,b:0,a:0};var e=(o=/^#([0-9a-f]{3,8})$/i.exec(o=t))?(e=function(t){return parseInt(t,16)},3===(o=o[1]).length||4===o.length?{r:e(o[0]+o[0]),g:e(o[1]+o[1]),b:e(o[2]+o[2]),a:4===o.length?e(o[3]+o[3])/255:1}:6===o.length||8===o.length?{r:e(o.slice(0,2)),g:e(o.slice(2,4)),b:e(o.slice(4,6)),a:8===o.length?e(o.slice(6,8))/255:1}:null):null;if(e)return e;var o=/^rgba?\(([^)]*)\)$/i.exec(t);if(o)return i=(o=Pe(o[1])).channels,o=o.alpha,i.length<3?null:{r:ke(i[0]),g:ke(i[1]),b:ke(i[2]),a:we(null!=o?o:i[3])};o=xe(t);if(o)return o;var i=w(t);if(i){o=Tt(i);if(o)return{r:o.r,g:o.g,b:o.b,a:D(o.a,0,1)}}}return null}function Me(t,e,o){var i,n,r,e=e/100,o=o/100,t=(t%360+360)%360/360;return 0==e?{r:r=Math.round(255*o),g:r,b:r,a:1}:(i=(r=function(t,e,o){return o<0&&(o+=1),1<o&&--o,o<1/6?t+6*(e-t)*o:o<.5?e:o<2/3?t+6*(e-t)*(2/3-o):t})(e=2*o-(o=.5<=o?o+e-o*e:o*(1+e)),o,t+1/3),n=r(e,o,t),r=r(e,o,t-1/3),{r:Math.round(255*i),g:Math.round(255*n),b:Math.round(255*r),a:1})}function Ie(t){var e=t.r/255,o=t.g/255,i=t.b/255,t=Math.max(e,o,i),n=Math.min(e,o,i),r=(t+n)/2;if(t===n)return{h:0,s:0,l:100*r};var s=t-n,n=.5<r?s/(2-t-n):s/(t+n),a=0;switch(t){case e:a=(o-i)/s+(o<i?6:0);break;case o:a=(i-e)/s+2;break;default:a=(e-o)/s+4}return{h:60*a,s:100*n,l:100*r}}function Oe(t){t/=255;return t<=.04045?t/12.92:Math.pow((.055+t)/1.055,2.4)}function He(t){t=t<=.00312989?12.92*t:1.055*Math.pow(t,1/2.4)-.055;return D(Math.round(255*t),0,255)}function Te(t){var e=Oe(t.r),o=Oe(t.g),t=Oe(t.b),i=.2119034982*e+.6806995451*o+.1073969566*t,n=.0883024619*e+.2817188376*o+.6299787005*t,e=Math.cbrt(.4122214708*e+.5363325363*o+.0514459929*t),o=Math.cbrt(i),t=Math.cbrt(n);return{l:.2104542553*e+.793617785*o-.0040720468*t,a:1.9779984951*e-2.428592205*o+.4505937099*t,b:.0259040371*e+.7827717662*o-.808675766*t}}function Se(t){var e=t.l+.3963377774*t.a+.2158037573*t.b,o=t.l-.1055613458*t.a-.0638541728*t.b,t=t.l-.0894841775*t.a-1.291485548*t.b,e=Math.pow(e,3),o=Math.pow(o,3),t=Math.pow(t,3),i=-1.2684380046*e+2.6097574011*o-.3413193965*t,n=-.0041960863*e-.7034186147*o+1.707614701*t;return{r:He(4.0767416621*e-3.3077115913*o+.2309699292*t),g:He(i),b:He(n),a:1}}function Ee(t){var t=Te(t),e=Math.sqrt(t.a*t.a+t.b*t.b),o=180*Math.atan2(t.b,t.a)/Math.PI;return o<0&&(o+=360),{l:t.l,c:e,h:e<1e-4?0:o}}function De(t){return(t%360+360)%360}function Ne(t,e,o,i){var t=De(t),n=De(e)-t;switch(i){case"longer":0<n&&n<180&&(n-=360),n<0&&-180<n&&(n+=360);break;case"increasing":n<0&&(n+=360);break;case"decreasing":0<n&&(n-=360);break;default:180<n&&(n-=360),n<-180&&(n+=360)}return De(t+n*o)}function Ae(t){var e=(t||[]).map(function(t){return t.position});if(0===e.length)return[];void 0===e[0]&&(e[0]=0),void 0===e[e.length-1]&&(e[e.length-1]=100);for(var o=0;o<e.length;)if(void 0!==e[o])o+=1;else{for(var i=o;i<e.length&&void 0===e[i];)i+=1;for(var n=e[o-1],r=e[i],s=i-(o-1),a=0;a<i-o;a+=1)e[o+a]=n+(r-n)*(a+1)/s;o=i}return e.map(function(t){return D(t,0,100)})}function _e(t){return Math.round(D(t,0,255))}function ze(t,e,o){r=[],(t||[]).forEach(function(t){var e;void 0!==t.position2?(r.push({color:t.color,position:null!=(e=t.position)?e:0}),r.push({color:t.color,position:t.position2})):r.push(f({},t))}),i=Ae(t=r),n=[],t.forEach(function(t,e){t=Be(t.color);t&&n.push({color:t,position:D(i[e],0,100)})});var i,n,r,s=n.sort(function(t,e){return t.position-e.position});if(0===s.length)return"";var a=D(e,0,100);if(a<=s[0].position)return Ve(s[0].color);t=s[s.length-1];if(a>=t.position)return Ve(t.color);for(var l,c=s[0],h=t,u=0;u<s.length-1;u+=1){var p=s[u],d=s[u+1];if(a>=p.position&&a<=d.position){c=p,h=d;break}}return h.position===c.position?Ve(h.color):(e=(a-c.position)/(h.position-c.position),t={space:"srgb",hue:"shorter"},(o=o)&&(l=(o=o.trim().toLowerCase().split(/\s+/))[0],["srgb","srgb-linear","hsl","oklab","oklch","lab","lch","hwb"].includes(l)&&(t.space=l),0<(l=o.findIndex(function(t){return"hue"===t})))&&("shorter"!==(o=o[l-1])&&"longer"!==o&&"increasing"!==o&&"decreasing"!==o||(t.hue=o)),l=t,o=c.color.a+(h.color.a-c.color.a)*e,t=((i,n,r,t)=>{switch(t.space){case"hsl":var e=Ie(i),o=Ie(n),s=Ne(e.h,o.h,r,t.hue);return f(f({},Me(s,e.s+(o.s-e.s)*r,e.l+(o.l-e.l)*r)),{a:1});case"oklab":e=Te(i),o=Te(n);return f(f({},Se({l:e.l+(o.l-e.l)*r,a:e.a+(o.a-e.a)*r,b:e.b+(o.b-e.b)*r})),{a:1});case"oklch":e=Ee(i),o=Ee(n),s=Ne(e.h,o.h,r,t.hue);return f(f({},(t=>{var e=t.h*Math.PI/180;return Se({l:t.l,a:t.c*Math.cos(e),b:t.c*Math.sin(e)})})({l:e.l+(o.l-e.l)*r,c:e.c+(o.c-e.c)*r,h:s})),{a:1});case"srgb-linear":var a={r:0,g:0,b:0,a:1};return["r","g","b"].forEach(function(t){var e=Oe(i[t]),o=Oe(n[t]);a[t]=He(e+(o-e)*r)}),a;default:return{r:_e(i.r+(n.r-i.r)*r),g:_e(i.g+(n.g-i.g)*r),b:_e(i.b+(n.b-i.b)*r),a:1}}})(c.color,h.color,e,l),Ve(f(f({},t),{a:o})))}function Ve(t){var e=Math.round(D(t.r,0,255)),o=Math.round(D(t.g,0,255)),i=Math.round(D(t.b,0,255)),t=Number(D(t.a,0,1).toFixed(2));return"rgba(".concat(e,", ").concat(o,", ").concat(i,", ").concat(t,")")}var Le=/^(repeating-)?(linear|radial|conic)-gradient\s*\(([\s\S]*)\)\s*$/i,Fe=/^([+-]?(?:\d+\.?\d*|\.\d+))(deg|rad|grad|turn)$/i,Re=/^([+-]?(?:\d+\.?\d*|\.\d+))%$/,je=/^[+-]?(?:\d+\.?\d*|\.\d+)(px|em|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ch|ex|q)$/i,We=["circle","ellipse"],Ue=["closest-side","closest-corner","farthest-side","farthest-corner"],$e={top:0,right:90,bottom:180,left:270,"top right":45,"right top":45,"bottom right":135,"right bottom":135,"bottom left":225,"left bottom":225,"top left":315,"left top":315};function Ge(t){c("[ewColorPicker warning]: Invalid gradient syntax: ".concat(t))}function Xe(t){var t=t.trim();return/^[+-]?0(\.0+)?$/.test(t)?{value:0,unit:"deg"}:(t=Fe.exec(t))?{value:Number.parseFloat(t[1]),unit:t[2].toLowerCase()}:null}function qe(t){var e=Re.exec(t.trim());return e?Number.parseFloat(e[1]):/^[+-]?0$/.test(t.trim())?0:null}function Ye(t,e){if("center"!==t){if("x"===e){if("left"===t)return 0;if("right"===t)return 100}if("y"===e){if("top"===t)return 0;if("bottom"===t)return 100}}return 50}function Ke(t){var e,o;return 0===t.length||2<t.length?null:1===t.length?(e=t[0].trim().toLowerCase(),je.test(e)?null:"left"===e||"right"===e||"center"===e?{x:Ye(e,"x"),y:50}:"top"===e||"bottom"===e?{x:50,y:Ye(e,"y")}:null===(e=qe(e))?null:{x:e,y:50}):(t=(e=t.map(function(t){return t.trim().toLowerCase()}))[0],e=e[1],je.test(t)||je.test(e)||(o=null,o="left"===t||"right"===t||"center"===t?Ye(t,"x"):qe(t),t=null,t="top"===e||"bottom"===e||"center"===e?Ye(e,"y"):qe(e),null===o)||null===t?null:{x:o,y:t})}function Qe(t){return Math.min(Math.max(t,0),100)}function Ze(t){var e=t.trim();if(!e)return null;for(var o,i=[];i.length<2;){var n=/(?:^|\s)([+-]?(?:\d+\.?\d*|\.\d+))%\s*$/.exec(e);if(!n)break;i.unshift(Qe(Number.parseFloat(n[1]))),e=e.slice(0,n.index).trim()}return/\s[+-]?(?:\d+\.?\d*|\.\d+)(px|em|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ch|ex|q)\s*$/i.test(e)?(Ge('stop position must be a percentage, got "'.concat(e,'"')),null):/\s[+-]?((?:\d+\.?\d*)|(?:\.\d+))%\s*$/.test(e)?(Ge('stop has more than two positions: "'.concat(t,'"')),null):(t=e.trim())&&null!==Be(t)?(o={color:t},0<i.length&&(o.position=i[0]),1<i.length&&(o.position2=i[1]),o):(Ge('unsupported stop color "'.concat(t,'"')),null)}function Je(t){if(0===t.length)return{};var e={},o=0,i=t[0].toLowerCase(),i=(We.includes(i)&&(e.radialShape=i,o=1),t.slice(o));if(0===i.length)return e.radialShape?e:null;if(1===i.length&&Ue.includes(i[0].toLowerCase()))e.radialSize=i[0].toLowerCase();else{if(!i.every(function(t){return Re.test(t)||je.test(t)})||2<i.length)return null;e.radialSize=i.join(" ")}return e.radialShape||(e.radialShape="ellipse"),e}function to(t){if("string"!=typeof t||!t.trim())return null;var e=Le.exec(t.trim());if(!e)return Ge('not a supported gradient: "'.concat(t,'"')),null;var t=Boolean(e[1]),o=e[2].toLowerCase(),i=me(o),t=(i.repeating=t,((t,e)=>{void 0===e&&(e=",");for(var o=[],i=0,n="",r=0,s=t;r<s.length;r++){var a=s[r];"("===a&&(i+=1),")"===a&&(i=Math.max(0,i-1)),a===e&&0===i?(o.push(n),n=""):n+=a}return o.push(n),o.map(function(t){return t.trim()})})(e[3]).filter(Boolean));if(0===t.length)return null;var n,r,s=(s=/\bin\s+((?:srgb(?:-linear)?|lab|oklab|lch|oklch|hsl|hwb)(?:\s+(?:shorter|longer|increasing|decreasing)\s+hue)?)/i.exec(e=t[0]))?{interpolation:s[1].toLowerCase().replace(/\s+/g," "),remaining:(e.slice(0,s.index)+e.slice(s.index+s[0].length)).trim()}:{interpolation:null,remaining:e.trim()},e=s.interpolation,s=s.remaining,e=null!==(i.interpolation=e),a=null;(a=""!==s?"linear"===o?(n=s)?(n=n.trim().toLowerCase()).startsWith("to ")?(r=n.slice(3).trim(),void 0===(r=$e[r])?null:{angle:{value:r,unit:"deg"}}):(r=Xe(n))?{angle:r}:null:{}:("radial"===o?t=>{if(!t)return{};var e=(t=t.trim().split(/\s+/).filter(Boolean)).findIndex(function(t){return"at"===t.toLowerCase()}),o=t,i=[];if(0<=e&&(o=t.slice(0,e),i=t.slice(e+1)),0<i.length){t=Ke(i);if(!t)return null;e={position:t};if(0<o.length){i=Je(o);if(!i)return null;Object.assign(e,i)}return e}return Je(o)}:t=>{if(!t)return{};var t=t.trim().split(/\s+/).filter(Boolean),e={},o=0;if("from"===(null==(i=t[o])?void 0:i.toLowerCase())){var i=Xe(t[o+1]||"");if(!i)return null;e.conicFrom=i,o+=2}if("at"===(null==(i=t[o])?void 0:i.toLowerCase())){i=Ke(t.slice(o+1));if(!i)return null;e.position=i,o=t.length}return o<t.length?null:e})(s):a)&&(e=!0,Object.assign(i,a));for(var l=[],c=0,h=e?t.slice(1):t;c<h.length;c++){var u=Ze(h[c]);if(!u)return null;l.push(u)}return l.length<2?(Ge("gradient requires at least two color stops"),null):(i.stops=l,i)}function eo(t){return String(Number(t.toFixed(3)))}function oo(t){var e=t.unit||"deg";return"".concat(eo(t.value)).concat(e)}function io(t){var e=[t.color];return void 0!==t.position&&e.push("".concat(eo(Qe(t.position)),"%")),void 0!==t.position2&&e.push("".concat(eo(Qe(t.position2)),"%")),e.join(" ")}var no={minGradientStops:2,maxGradientStops:8,syncStopsOnChange:!0};function ro(t,e,o){return Math.min(Math.max(t,e),o)}function so(t){return Math.round(10*ro(t,0,100))/10}Object.defineProperty(A.prototype,"prefix",{get:function(){return r(this.ewColorPicker)},enumerable:!1,configurable:!0}),A.prototype.install=function(t){this.ewColorPicker=t,this.destroyed=!1,this.handleOptions(),this.gradientRef=this.options.gradient,this.stopsRef=this.options.gradientStops,this.initValue(),this.bindCoreEvents(),this.run()},A.prototype.handleOptions=function(){var t=null==(t=this.ewColorPicker)?void 0:t.options;this.options=l({},no,this.options,t||{})},A.prototype.updateOptions=function(){this.handleOptions();var t=this.options.gradient!==this.gradientRef,e=this.options.gradientStops!==this.stopsRef;this.gradientRef=this.options.gradient,this.stopsRef=this.options.gradientStops,(t||e)&&this.initValue(),this.run()},A.prototype.run=function(){this.ewColorPicker&&(this.shouldRender()?this.isPanelDisabled()?(c("[ewColorPicker warning]: Gradient plugin requires the panel. Set hasPanel: false disables the gradient editor."),this.removeContainer()):this.render():this.removeContainer())},A.prototype.shouldRender=function(){return!1!==this.options.showGradient&&(!0===this.options.showGradient||void 0!==this.options.gradient||Array.isArray(this.options.gradientStops)&&0<this.options.gradientStops.length)},A.prototype.isPanelDisabled=function(){return!1===this.options.hasPanel||!1===this.options.ewColorPickerPanel},A.prototype.getCurrentColor=function(){var t=this.ewColorPicker;return t&&((h(t.getColor)?t.getColor():"")||(null==(t=t.options)?void 0:t.defaultColor))||"#ff0000"},A.prototype.initValue=function(){var t,e=this.options,o=e.gradient,i=e.gradientStops,n=e.gradientType,r=e.gradientRepeating,s=e.gradientAngle,e=e.gradientInterpolation,a=null;et(o)?(t=to(o))?a=t:c('[ewColorPicker warning]: Unable to parse gradient "'.concat(o,'", fallback to default stops.')):G(o)&&(a=ye(l(me(o.type||"linear"),o))),a||(a=me(n||"linear"),t=Array.isArray(i)&&0<i.length?i:[this.getCurrentColor(),"#ffffff"],a.stops=t.map(function(t){return et(t)?{color:t}:f({},t)})),n&&(a.type=n),$(r)&&(a.repeating=r),ot(s)&&(a.angle={value:s,unit:"deg"}),void 0!==e&&(a.interpolation=e||null),a.stops=this.normalizeStops(a.stops,a),this.value=a,this.selectedIndex=0},A.prototype.normalizeStops=function(t,e){void 0===e&&(e=this.value);var o=null!=(o=this.options.maxGradientStops)?o:8,t=(t||[]).map(function(t){return f({},t)});return t.length>o?(c("[ewColorPicker warning]: maxGradientStops is ".concat(o,", extra stops are ignored.")),t.slice(0,o)):0===t.length?[{color:(null==(e=null==(o=e.stops)?void 0:o[0])?void 0:e.color)||this.getCurrentColor()},{color:"#ffffff"}]:1===t.length?[t[0],{color:"#ffffff"}]:t},A.prototype.bindCoreEvents=function(){!this.changeBound&&this.ewColorPicker&&(this.ewColorPicker.on("change",this.handleCoreChange),this.changeBound=!0)},A.prototype.emitChange=function(){h(this.options.gradientChange)&&this.options.gradientChange(this.getGradient(),this.getGradientValue())},A.prototype.applySelectedStopColor=function(){var t=this.ewColorPicker,e=this.value.stops[this.selectedIndex];if(t&&null!=e&&e.color){this.syncing=!0;try{t.setColor(e.color)}finally{this.syncing=!1}}},A.prototype.render=function(){var t,e,o=this.ewColorPicker;o&&((o=o.getMountPoint("panelContainer"))?(this.removeContainer(),e=this.prefix,t=u("div"),p(t,"".concat(e,"gradient-container")),this.container=t,this.buildPreview(t),this.buildTypeRow(t),"radial"===this.value.type&&this.buildRadialRow(t),"radial"!==this.value.type&&"conic"!==this.value.type||this.buildPositionRow(t),this.buildInterpolationRow(t),this.buildStopRow(t),e=v(".".concat(e,"color-picker-bottom-row"),o),b(o,t,null,e),this.updatePreview(),this.syncStopInputs()):(c("[ewColorPicker warning]: Panel container not found"),this.removeContainer()))},A.prototype.createRow=function(t){void 0===t&&(t="");var e=u("div");return p(e,"".concat(this.prefix,"gradient-row")),t&&p(e,t),e},A.prototype.createLabel=function(t){var e=u("span");return p(e,"".concat(this.prefix,"gradient-label")),e.textContent=t,e},A.prototype.createButton=function(t){var e=u("button");return p(e,"".concat(this.prefix,"gradient-btn")),g(e,{type:"button"}),e.textContent=t,e},A.prototype.createSelect=function(t){t=new se(f({prefix:this.prefix,size:"small",clearable:!1},t));return this.selects.push(t),t},A.prototype.createNumber=function(t){t=new ie(f({prefix:this.prefix,size:"small"},t));return this.numbers.push(t),t},A.prototype.createCheckbox=function(t){t=new ce(f({prefix:this.prefix,size:"small"},t));return this.checkboxes.push(t),t},A.prototype.buildPreview=function(t){var e=this.prefix,o=u("div"),i=(p(o,"".concat(e,"gradient-preview")),u("div"));p(i,"".concat(e,"gradient-preview-bar")),this.bar=i,b(o,i),b(t,o),C(o,"click",this.handlePreviewClick)},A.prototype.updatePreview=function(){this.bar&&(this.bar.style.background=this.buildPreviewCss(),this.renderHandles())},A.prototype.buildPreviewCss=function(){var o=this.getResolvedPositions(),t=this.value.stops.map(function(t,e){return"".concat(t.color," ").concat(o[e],"%")}).join(", ");return"linear-gradient(90deg, ".concat(t,")")},A.prototype.getResolvedPositions=function(){return Ae(this.value.stops).map(so)},A.prototype.renderHandles=function(){var i,n,r=this;this.bar&&(i=this.prefix,this.bar.textContent="",n=this.getResolvedPositions(),this.value.stops.forEach(function(t,e){var o=u("button");p(o,"".concat(i,"gradient-handle")),e===r.selectedIndex&&p(o,"".concat(i,"gradient-handle-active")),g(o,{type:"button","data-gradient-index":e,"aria-label":"".concat(t.color," ").concat(n[e],"%"),title:"".concat(t.color," ").concat(n[e],"%")}),o.style.left="".concat(n[e],"%"),o.style.backgroundColor=t.color,C(o,"mousedown",function(t){return r.handleHandleMousedown(t,e)}),b(r.bar,o)}))},A.prototype.handleHandleMousedown=function(t,e){t.preventDefault(),t.stopPropagation(),this.selectStop(e),this.draggingIndex=e,null!=(t=this.dragUnbind)&&t.call(this),this.dragUnbind=bt(this.handleDocumentMove,this.handleDocumentUp)},A.prototype.getPositionByClientX=function(t){var e,o=this.bar;return o?(o=(e=a(o)).width||o.offsetWidth||J,so((t-(e.left||0))/o*100)):0},A.prototype.buildTypeRow=function(t){var e,o=this,i=this.prefix,n=this.createRow("".concat(i,"gradient-row-type")),r=(b(n,this.createLabel("类型")),u("div")),i=(p(r,"".concat(i,"gradient-select")),this.createSelect({value:this.value.type,items:[{label:"Linear",value:"linear"},{label:"Radial",value:"radial"},{label:"Conic",value:"conic"}],onChange:function(t){t!==o.value.type&&(o.value.type=t,o.render(),o.emitChange())}})),i=(b(r,i.getElement()),b(n,r),this.createCheckbox({label:"Repeating",checked:this.value.repeating,onChange:function(t){o.value.repeating=t,o.emitChange()}}));b(n,i.getElement()),"radial"!==this.value.type&&(e="conic"===this.value.type,b(n,this.createLabel(e?"起始角":"角度")),this.angleInput=this.createNumber({value:(t=>{switch(t.unit){case"rad":return 180*t.value/Math.PI;case"grad":return.9*t.value;case"turn":return 360*t.value;default:return t.value}})(e?this.value.conicFrom:this.value.angle),min:0,max:360,step:1,precision:0,onChange:function(t){e?o.value.conicFrom={value:t,unit:"deg"}:o.value.angle={value:t,unit:"deg"},o.emitChange()}}),b(n,this.angleInput.getElement())),b(t,n)},A.prototype.buildRadialRow=function(t){var e=this,o=this.prefix,i=this.createRow("".concat(o,"gradient-row-radial")),n=(b(i,this.createLabel("形状")),u("div")),r=(p(n,"".concat(o,"gradient-select")),this.createSelect({value:this.value.radialShape,items:[{label:"Ellipse",value:"ellipse"},{label:"Circle",value:"circle"}],onChange:function(t){e.value.radialShape=t,e.emitChange()}})),r=(b(n,r.getElement()),b(i,n),b(i,this.createLabel("尺寸")),u("div")),n=(p(r,"".concat(o,"gradient-select")),["closest-side","closest-corner","farthest-side","farthest-corner"]),s=this.createSelect({value:n.includes(this.value.radialSize)?this.value.radialSize:"farthest-corner",items:n.map(function(t){return{label:t,value:t}}),onChange:function(t){e.value.radialSize=String(t),e.sizeInput&&(e.sizeInput.value=""),e.emitChange()}}),a=(b(r,s.getElement()),b(i,r),u("input"));p(a,"".concat(o,"gradient-text")),g(a,{type:"text",placeholder:"自定义尺寸"}),a.value=n.includes(this.value.radialSize)?"":this.value.radialSize,C(a,"change",function(){var t=a.value.trim();e.value.radialSize=t||"farthest-corner",e.emitChange()}),this.sizeInput=a,b(i,a),b(t,i)},A.prototype.buildPositionRow=function(t){var e=this,o=this.prefix,o=this.createRow("".concat(o,"gradient-row-position"));b(o,this.createLabel("位置")),this.atXInput=this.createNumber({value:this.value.position.x,min:0,max:100,step:1,precision:0,onChange:function(t){e.value.position.x=ro(t,0,100),e.emitChange()}}),b(o,this.atXInput.getElement()),this.atYInput=this.createNumber({value:this.value.position.y,min:0,max:100,step:1,precision:0,onChange:function(t){e.value.position.y=ro(t,0,100),e.emitChange()}}),b(o,this.atYInput.getElement()),b(t,o)},A.prototype.buildInterpolationRow=function(t){var e=this,o=this.prefix,i=this.createRow("".concat(o,"gradient-row-interp")),n=(b(i,this.createLabel("插值")),u("div")),o=(p(n,"".concat(o,"gradient-select")),this.value.interpolation||"default"),o=this.createSelect({value:o,items:[{label:"Default",value:"default"},{label:"sRGB",value:"srgb"},{label:"sRGB linear",value:"srgb-linear"},{label:"OKLab",value:"oklab"},{label:"OKLCH",value:"oklch"},{label:"HSL shorter",value:"hsl shorter hue"},{label:"HSL longer",value:"hsl longer hue"},{label:"OKLCH longer",value:"oklch longer hue"}],onChange:function(t){e.value.interpolation="default"===t?null:String(t),e.emitChange()}});b(n,o.getElement()),b(i,n),b(t,i)},A.prototype.buildStopRow=function(t){var i=this,e=this.prefix,e=this.createRow("".concat(e,"gradient-row-stop")),o=(b(e,this.createLabel("停靠点")),this.value.stops[this.selectedIndex]),n=null!=(r=this.getResolvedPositions()[this.selectedIndex])?r:0,o=(this.posInput=this.createNumber({value:n,min:0,max:100,step:1,precision:0,onChange:function(t){var e=i.value.stops[i.selectedIndex];e&&(e.position=ro(t,0,100),i.updatePreview(),i.emitChange())}}),b(e,this.posInput.getElement()),b(e,this.createLabel("~")),this.pos2Input=this.createNumber({value:null!=(r=null==o?void 0:o.position2)?r:n,min:0,max:100,step:1,precision:0,onChange:function(t){var e,o=i.value.stops[i.selectedIndex];o&&(t===(null!=(e=o.position)?e:n)?delete o.position2:o.position2=ro(t,0,100),i.updatePreview(),i.emitChange())}}),b(e,this.pos2Input.getElement()),this.createButton("删除")),r=(C(o,"click",function(){i.removeStopInternal(i.selectedIndex)}),b(e,o),this.createButton("新增"));C(r,"click",function(){i.addStopInternal(ze(i.value.stops,50,i.value.interpolation)||i.getCurrentColor(),50)}),b(e,r),b(t,e)},A.prototype.selectStop=function(t,e){void 0===e&&(e=!0),t<0||t>=this.value.stops.length||(this.selectedIndex=t,this.renderHandles(),this.syncStopInputs(),e&&this.applySelectedStopColor())},A.prototype.syncStopInputs=function(){var t,e=this.getResolvedPositions(),o=this.value.stops[this.selectedIndex];o&&(e=null!=(e=e[this.selectedIndex])?e:0,null!=(t=this.posInput)&&t.setValue(e,!1),null!=(t=this.pos2Input))&&t.setValue(null!=(t=o.position2)?t:e,!1)},A.prototype.addStopInternal=function(t,e){var o,i,n,r=this,s=null!=(s=this.options.maxGradientStops)?s:8;return this.value.stops.length>=s?(c("[ewColorPicker warning]: Cannot add more than ".concat(s," gradient stops.")),-1):(o={color:t},void 0!==e&&(o.position=so(e)),i=this.getResolvedPositions(),n=void 0!==o.position?o.position:50,this.value.stops.push(o),s=this.value.stops.map(function(t,e){return{item:t,position:e===r.value.stops.length-1?n:i[e]}}).sort(function(t,e){return t.position-e.position}),this.value.stops=s.map(function(t){return t.item}),this.selectedIndex=s.findIndex(function(t){return t.item===o}),this.updatePreview(),this.syncStopInputs(),this.emitChange(),this.selectedIndex)},A.prototype.removeStopInternal=function(t){var t=void 0===t?this.selectedIndex:t,e=null!=(e=this.options.minGradientStops)?e:2;return this.value.stops.length<=e?(c("[ewColorPicker warning]: At least ".concat(e," gradient stops are required.")),!1):!(t<0||t>=this.value.stops.length||(this.value.stops.splice(t,1),this.selectedIndex=ro(t,0,Math.max(this.value.stops.length-1,0)),this.updatePreview(),this.syncStopInputs(),this.emitChange(),0))},A.prototype.removeContainer=function(){this.destroyComponents(),this.container&&n(this.container),this.container=null,this.bar=null,this.sizeInput=null,this.draggingIndex=-1},A.prototype.destroyComponents=function(){this.selects.forEach(function(t){return t.destroy()}),this.selects=[],this.numbers.forEach(function(t){return t.destroy()}),this.numbers=[],this.checkboxes.forEach(function(t){return t.destroy()}),this.checkboxes=[],this.angleInput=null,this.atXInput=null,this.atYInput=null,this.posInput=null,this.pos2Input=null},A.prototype.getGradient=function(){return t=ye(t=this.value),i="".concat(t.repeating?"repeating-":"").concat(t.type,"-gradient"),n=t.interpolation?" in ".concat(t.interpolation):"",r=t.stops.map(io).join(", "),s="".concat(eo(Qe(t.position.x)),"% ").concat(eo(Qe(t.position.y)),"%"),("linear"===t.type?"".concat(i,"(").concat(oo(t.angle)):("radial"===t.type?(e=t.radialShape||"ellipse",o=t.radialSize||"farthest-corner","".concat(i,"(").concat(e," ").concat(o," at ")):"".concat(i,"(from ").concat(oo(t.conicFrom)," at ")).concat(s)).concat(n,", ").concat(r,")");var t,e,o,i,n,r,s},A.prototype.getGradientValue=function(){return ye(this.value)},A.prototype.getStops=function(){return this.value.stops.map(function(t){return f({},t)})},A.prototype.setGradient=function(t){if(et(t)){var e=to(t);if(!e)return void c('[ewColorPicker warning]: Unable to set invalid gradient "'.concat(t,'".'));this.value=e}else G(t)&&(e=ye(this.value),t.type&&(e.type=t.type),$(t.repeating)&&(e.repeating=t.repeating),t.angle&&(e.angle=f({},t.angle)),t.radialShape&&(e.radialShape=t.radialShape),t.radialSize&&(e.radialSize=t.radialSize),t.conicFrom&&(e.conicFrom=f({},t.conicFrom)),t.position&&(e.position=f({},t.position)),void 0!==t.interpolation&&(e.interpolation=t.interpolation||null),Array.isArray(t.stops)&&(e.stops=t.stops.map(function(t){return f({},t)})),this.value=e);this.value.stops=this.normalizeStops(this.value.stops),this.selectedIndex=ro(this.selectedIndex,0,Math.max(this.value.stops.length-1,0)),this.render()},A.prototype.setStops=function(t){t=(t||[]).map(function(t){return et(t)?{color:t}:f({},t)});this.value.stops=this.normalizeStops(t),this.selectedIndex=ro(this.selectedIndex,0,Math.max(this.value.stops.length-1,0)),this.updatePreview(),this.syncStopInputs()},A.prototype.addStop=function(t,e){return this.addStopInternal(t,e)},A.prototype.removeStop=function(t){return this.removeStopInternal(t)},A.prototype.destroy=function(){var t;this.destroyed=!0,this.ewColorPicker&&this.changeBound&&(this.ewColorPicker.off("change",this.handleCoreChange),this.changeBound=!1),null!=(t=this.dragUnbind)&&t.call(this),this.handleDocumentUp(),this.removeContainer()},A.pluginName="ewColorPickerGradient",A.applyOrder=N.Post;var N=A;function A(t){var i=this;this.options={},this.value=me(),this.selectedIndex=0,this.syncing=!1,this.destroyed=!1,this.changeBound=!1,this.gradientRef=void 0,this.stopsRef=void 0,this.container=null,this.bar=null,this.sizeInput=null,this.selects=[],this.numbers=[],this.checkboxes=[],this.angleInput=null,this.atXInput=null,this.atYInput=null,this.posInput=null,this.pos2Input=null,this.draggingIndex=-1,this.dragUnbind=null,this.handleCoreChange=function(t){var e;i.destroyed||i.syncing||!1!==i.options.syncStopsOnChange&&t&&(e=i.value.stops[i.selectedIndex])&&(w(e.color)||e.color)!==(w(t)||t)&&(e.color=t,i.updatePreview(),i.emitChange())},this.handleDocumentMove=function(t){var e,o;i.draggingIndex<0||(o=i.value.stops[i.draggingIndex])&&(t=i.getPositionByClientX(t.clientX),o.position=t,null!=(e=i.posInput)&&e.setValue(t,!1),void 0!==o.position2&&null!=(e=i.pos2Input)&&e.setValue(t,!1),i.renderHandles(),i.bar&&(i.bar.style.background=i.buildPreviewCss()),i.emitChange())},this.handleDocumentUp=function(){i.draggingIndex=-1,i.dragUnbind=null},this.handlePreviewClick=function(t){var e=t.target;e&&!e.closest(".".concat(i.prefix,"gradient-handle"))&&(e=i.getPositionByClientX(t.clientX),t=ze(i.value.stops,e,i.value.interpolation)||i.getCurrentColor(),i.addStopInternal(t,e))},this.ewColorPicker=t,this.handleOptions(),this.gradientRef=this.options.gradient,this.stopsRef=this.options.gradientStops,this.initValue(),this.bindCoreEvents(),this.run()}P.use(at),P.use(rt),P.use(nt),P.use(te),P.use(ee),P.use(oe),P.use(ne),P.use(ae),P.use(ue),P.use(de),P.use(fe),P.use(ge),P.use(ve),P.use(Ce),P.use(N),"undefined"!=typeof window&&(window.ewColorPicker=P),_.createEwColorPicker=function(t){return new P(t)},_.default=P,_.ewColorPicker=P,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.4",
3
+ "version": "2.0.5",
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",
@@ -31,30 +31,30 @@
31
31
  "author": "eveningwater(854806732@qq.com)",
32
32
  "license": "MIT",
33
33
  "dependencies": {
34
- "@ew-color-picker/core": "^2.0.4",
35
- "@ew-color-picker/utils": "^2.0.4",
36
- "@ew-color-picker/box": "^2.0.4",
37
- "@ew-color-picker/alpha": "^2.0.4",
38
- "@ew-color-picker/panel": "^2.0.4",
39
- "@ew-color-picker/input": "^2.0.4",
40
- "@ew-color-picker/input-number": "^2.0.4",
41
- "@ew-color-picker/select": "^2.0.4",
42
- "@ew-color-picker/predefine": "^2.0.4",
43
- "@ew-color-picker/style": "^2.0.4",
44
- "@ew-color-picker/checkbox": "^2.0.4",
45
- "@ew-color-picker/button": "^2.0.4",
46
- "@ew-color-picker/eyedropper": "^2.0.4",
47
- "@ew-color-picker/hue": "^2.0.4",
48
- "@ew-color-picker/gradient": "^2.0.4",
49
- "@ew-color-picker/copy-color": "^2.0.4",
50
- "@ew-color-picker/color-mode": "^2.0.4"
34
+ "@ew-color-picker/utils": "^2.0.5",
35
+ "@ew-color-picker/core": "^2.0.5",
36
+ "@ew-color-picker/panel": "^2.0.5",
37
+ "@ew-color-picker/input": "^2.0.5",
38
+ "@ew-color-picker/box": "^2.0.5",
39
+ "@ew-color-picker/hue": "^2.0.5",
40
+ "@ew-color-picker/alpha": "^2.0.5",
41
+ "@ew-color-picker/checkbox": "^2.0.5",
42
+ "@ew-color-picker/input-number": "^2.0.5",
43
+ "@ew-color-picker/button": "^2.0.5",
44
+ "@ew-color-picker/predefine": "^2.0.5",
45
+ "@ew-color-picker/select": "^2.0.5",
46
+ "@ew-color-picker/style": "^2.0.5",
47
+ "@ew-color-picker/gradient": "^2.0.5",
48
+ "@ew-color-picker/copy-color": "^2.0.5",
49
+ "@ew-color-picker/color-mode": "^2.0.5",
50
+ "@ew-color-picker/eyedropper": "^2.0.5"
51
51
  },
52
52
  "devDependencies": {
53
53
  "rollup": "^3.0.0",
54
54
  "rollup-plugin-typescript2": "^0.34.0",
55
55
  "typescript": "^4.9.0",
56
56
  "rimraf": "^3.0.2",
57
- "@ew-color-picker/utils": "2.0.4"
57
+ "@ew-color-picker/utils": "2.0.5"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public"