@thednp/color-picker 2.0.0-alpha1 → 2.0.0-alpha10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. package/.eslintrc.cjs +1 -1
  2. package/.lgtm.yml +0 -0
  3. package/.prettierrc.json +0 -0
  4. package/.stylelintrc.json +0 -0
  5. package/LICENSE +0 -0
  6. package/README.md +8 -7
  7. package/compile.js +6 -3
  8. package/cypress/e2e/color-palette.cy.ts +0 -0
  9. package/cypress/e2e/color-picker.cy.ts +58 -69
  10. package/cypress/fixtures/colorNamesFrench.js +0 -0
  11. package/cypress/fixtures/componentLabelsFrench.js +0 -0
  12. package/cypress/fixtures/format.js +0 -0
  13. package/cypress/fixtures/getMarkup.js +8 -1
  14. package/cypress/fixtures/getRandomInt.js +0 -0
  15. package/cypress/fixtures/sampleWebcolors.js +0 -0
  16. package/cypress/fixtures/testSample.js +0 -0
  17. package/cypress/plugins/esbuild-istanbul.ts +0 -0
  18. package/cypress/plugins/tsCompile.ts +0 -0
  19. package/cypress/support/commands.ts +0 -0
  20. package/cypress/support/e2e.ts +0 -0
  21. package/cypress/test.html +0 -0
  22. package/cypress.config.ts +0 -0
  23. package/dist/css/color-picker.css +13 -18
  24. package/dist/css/color-picker.min.css +2 -2
  25. package/dist/css/color-picker.rtl.css +13 -18
  26. package/dist/css/color-picker.rtl.min.css +2 -2
  27. package/dist/js/color-picker.cjs +3 -3
  28. package/dist/js/color-picker.cjs.map +1 -1
  29. package/dist/js/color-picker.d.ts +42 -24
  30. package/dist/js/color-picker.js +3 -3
  31. package/dist/js/color-picker.js.map +1 -1
  32. package/dist/js/color-picker.mjs +408 -421
  33. package/dist/js/color-picker.mjs.map +1 -1
  34. package/dts.config.ts +0 -0
  35. package/package.json +116 -98
  36. package/src/scss/_variables.scss +0 -0
  37. package/src/scss/color-picker.rtl.scss +0 -0
  38. package/src/scss/color-picker.scss +20 -14
  39. package/src/ts/colorPalette.ts +0 -0
  40. package/src/ts/index.ts +40 -54
  41. package/src/ts/interface/ColorNames.ts +20 -0
  42. package/src/ts/interface/colorPickerLabels.ts +0 -0
  43. package/src/ts/interface/colorPickerOptions.ts +0 -0
  44. package/src/ts/interface/paletteOptions.ts +0 -0
  45. package/src/ts/util/colorNames.ts +0 -0
  46. package/src/ts/util/colorPickerLabels.ts +0 -0
  47. package/src/ts/util/getColorControls.ts +0 -0
  48. package/src/ts/util/getColorForm.ts +0 -0
  49. package/src/ts/util/getColorMenu.ts +0 -0
  50. package/src/ts/util/isValidJSON.ts +0 -0
  51. package/src/ts/util/setMarkup.ts +6 -4
  52. package/src/ts/util/vHidden.ts +0 -0
  53. package/tsconfig.json +1 -1
  54. package/vite.config.ts +0 -0
  55. package/cypress/downloads/downloads.htm +0 -0
  56. package/cypress/fixtures/getCEMarkup.js +0 -29
@@ -49,6 +49,26 @@ export interface ColorPickerOptions {
49
49
  colorPresets: string | string[] | ColorPalette | false;
50
50
  colorKeywords: string | string[] | false;
51
51
  }
52
+ export interface ColorNames {
53
+ white: string;
54
+ black: string;
55
+ grey: string;
56
+ red: string;
57
+ orange: string;
58
+ brown: string;
59
+ gold: string;
60
+ olive: string;
61
+ yellow: string;
62
+ lime: string;
63
+ green: string;
64
+ teal: string;
65
+ cyan: string;
66
+ blue: string;
67
+ violet: string;
68
+ magenta: string;
69
+ pink: string;
70
+ [key: string]: string;
71
+ }
52
72
  /**
53
73
  * Color Picker Web Component
54
74
  *
@@ -65,6 +85,8 @@ export default class ColorPicker {
65
85
  static setAttribute: (element: HTMLElement, att: string, value: string) => void;
66
86
  static getBoundingClientRect: (element: HTMLElement, includeScale?: boolean | undefined) => import("@thednp/shorty").BoundingClientRect;
67
87
  static version: string;
88
+ static colorNames: string[];
89
+ static colorPickerLabels: ColorPickerLabels;
68
90
  id: number;
69
91
  input: HTMLInputElement;
70
92
  color: Color;
@@ -78,7 +100,7 @@ export default class ColorPicker {
78
100
  c2y: number;
79
101
  c3y: number;
80
102
  };
81
- colorLabels: Record<string, string>;
103
+ colorLabels: ColorNames;
82
104
  colorKeywords: string[] | false;
83
105
  colorPresets: ColorPalette | string[] | false;
84
106
  componentLabels: ColorPickerLabels;
@@ -136,74 +158,70 @@ export default class ColorPicker {
136
158
  * @param e
137
159
  * @this {ColorPicker}
138
160
  */
139
- handleFocusOut({ relatedTarget }: FocusEvent & {
161
+ handleFocusOut: ({ relatedTarget }: FocusEvent & {
140
162
  relatedTarget: HTMLElement;
141
- }): void;
163
+ }) => void;
142
164
  /**
143
165
  * The `ColorPicker` *keyup* event listener when open.
144
166
  *
145
167
  * @param e
146
168
  * @this {ColorPicker}
147
169
  */
148
- handleDismiss({ code }: KeyboardEvent): void;
170
+ handleDismiss: ({ code }: KeyboardEvent) => void;
149
171
  /**
150
172
  * The `ColorPicker` *scroll* event listener when open.
151
173
  *
152
174
  * @param e
153
- * @this {ColorPicker}
154
175
  */
155
- handleScroll(e: Event): void;
176
+ handleScroll: (e: Event) => void;
156
177
  /**
157
178
  * The `ColorPicker` keyboard event listener for menu navigation.
158
179
  *
159
180
  * @param e
160
181
  */
161
- menuKeyHandler(e: Event & {
182
+ menuKeyHandler: (e: KeyboardEvent & {
162
183
  target: HTMLElement;
163
- code: string;
164
- }): void;
184
+ }) => void;
165
185
  /**
166
186
  * The `ColorPicker` click event listener for the colour menu presets / defaults.
167
187
  *
168
188
  * @param e
169
189
  * @this {ColorPicker}
170
190
  */
171
- menuClickHandler(e: Event): void;
191
+ menuClickHandler: (e: Event) => void;
172
192
  /**
173
193
  * The `ColorPicker` *touchstart* / *mousedown* events listener for control knobs.
174
194
  *
175
195
  * @param e
176
196
  */
177
- pointerDown(e: Event & {
197
+ pointerDown: (e: PointerEvent & {
178
198
  target: HTMLElement;
179
- pageX: number;
180
- pageY: number;
181
- }): void;
199
+ }) => void;
182
200
  /**
183
201
  * The `ColorPicker` *touchend* / *mouseup* events listener for control knobs.
184
202
  *
185
203
  * @param e
186
204
  * @this
187
205
  */
188
- pointerUp({ target }: PointerEvent & {
206
+ pointerUp: ({ target }: PointerEvent & {
189
207
  target: HTMLElement;
190
- }): void;
208
+ }) => void;
191
209
  /**
192
210
  * The `ColorPicker` *touchmove* / *mousemove* events listener for control knobs.
193
211
  *
194
212
  * @param {PointerEvent} e
195
213
  */
196
- pointerMove(e: PointerEvent): void;
214
+ pointerMove: (e: PointerEvent) => void;
197
215
  /**
198
216
  * The `ColorPicker` *keydown* event listener for control knobs.
199
217
  *
200
218
  * @param e
201
219
  */
202
- handleKnobs(e: Event & {
220
+ handleKnobs: (e: Event & {
203
221
  code: string;
204
- }): void;
222
+ }) => void;
205
223
  /** The event listener of the colour form inputs. */
206
- changeHandler(): void;
224
+ changeHandler: () => void;
207
225
  /**
208
226
  * Updates `ColorPicker` first control:
209
227
  * * `lightness` and `saturation` for HEX/RGB;
@@ -233,7 +251,7 @@ export default class ColorPicker {
233
251
  * * initialization
234
252
  * * window resize
235
253
  */
236
- update(): void;
254
+ update: () => void;
237
255
  /** Updates the open dropdown position on *scroll* event. */
238
256
  updateDropdownPosition(): void;
239
257
  /** Updates control knobs' positions. */
@@ -253,16 +271,16 @@ export default class ColorPicker {
253
271
  *
254
272
  * @param e
255
273
  */
256
- togglePicker(e?: Event): void;
274
+ togglePicker: (e?: Event) => void;
257
275
  /** Shows the `ColorPicker` dropdown. */
258
- showPicker(): void;
276
+ showPicker: () => void;
259
277
  /**
260
278
  * Toggles the visibility of the `ColorPicker` presets menu.
261
279
  *
262
280
  * @param e
263
281
  * @this {ColorPicker}
264
282
  */
265
- toggleMenu(e?: Event): void;
283
+ toggleMenu: (e?: Event) => void;
266
284
  /**
267
285
  * Hides the currently open `ColorPicker` dropdown.
268
286
  *
@@ -1,8 +1,8 @@
1
- var ColorPicker=function(){"use strict";const W={},zt=o=>{const{type:t,currentTarget:e}=o;[...W[t]].forEach(([s,n])=>{e===s&&[...n].forEach(([r,i])=>{r.apply(s,[o]),typeof i=="object"&&i.once&&xt(s,t,r,i)})})},Gt=(o,t,e,s)=>{W[t]||(W[t]=new Map);const n=W[t];n.has(o)||n.set(o,new Map);const r=n.get(o),{size:i}=r;r.set(e,s),i||o.addEventListener(t,zt,s)},xt=(o,t,e,s)=>{const n=W[t],r=n&&n.get(o),i=r&&r.get(e),a=i!==void 0?i:s;r&&r.has(e)&&r.delete(e),n&&(!r||!r.size)&&n.delete(o),(!n||!n.size)&&delete W[t],(!r||!r.size)&&o.removeEventListener(t,zt,a)},Ut="aria-description",Pt="aria-expanded",Te="aria-hidden",St="aria-selected",tt="aria-valuenow",et="aria-valuetext",Re="change",De="DOMContentLoaded",Oe="focusin",Fe="focusout",_t="keydown",Ie="keyup",Ct="click",Ke="pointerdown",Wt="pointermove",Ve="pointerup",Be="resize",je="scroll",qe="touchmove",j="ArrowDown",ot="ArrowUp",ht="ArrowLeft",G="ArrowRight",ze="Enter",Ge="Escape",Xt="Space",Ue="transitionDuration",_e="transitionProperty",X="tabindex",We=navigator.userAgentData,gt=We,{userAgent:Xe}=navigator,ut=Xe,Jt=/iPhone|iPad|iPod|Android/i;gt?gt.brands.some(o=>Jt.test(o.brand)):Jt.test(ut);const Yt=/(iPhone|iPod|iPad)/;gt?gt.brands.some(o=>Yt.test(o.brand)):Yt.test(ut),ut&&ut.includes("Firefox");const{head:bt}=document;["webkitPerspective","perspective"].some(o=>o in bt.style);const Je=(o,t,e,s)=>{const n=s||!1;o.addEventListener(t,e,n)},Ye=(o,t,e,s)=>{const n=s||!1;o.removeEventListener(t,e,n)},Ze=(o,t,e,s)=>{const n=r=>{(r.target===o||r.currentTarget===o)&&(e.apply(o,[r]),Ye(o,t,n,s))};Je(o,t,n,s)},Qe=()=>{};(()=>{let o=!1;try{const t=Object.defineProperty({},"passive",{get:()=>(o=!0,o)});Ze(document,De,Qe,t)}catch{}return o})(),["webkitTransform","transform"].some(o=>o in bt.style),["webkitAnimation","animation"].some(o=>o in bt.style),["webkitTransition","transition"].some(o=>o in bt.style);const pt=(o,t)=>o.getAttribute(t),m=(o,t,e)=>o.setAttribute(t,e),Lt=(o,t)=>o.removeAttribute(t),q=(o,...t)=>{o.classList.add(...t)},D=(o,...t)=>{o.classList.remove(...t)},M=(o,t)=>o.classList.contains(t),At=o=>o!=null&&typeof o=="object"||!1,J=o=>At(o)&&typeof o.nodeType=="number"&&[1,2,3,4,5,6,7,8,9,10,11].some(t=>o.nodeType===t)||!1,st=o=>J(o)&&o.nodeType===1||!1,Y=new Map,nt={data:Y,set:(o,t,e)=>{st(o)&&(Y.has(t)||Y.set(t,new Map),Y.get(t).set(o,e))},getAllFor:o=>Y.get(o)||null,get:(o,t)=>{if(!st(o)||!t)return null;const e=nt.getAllFor(t);return o&&e&&e.get(o)||null},remove:(o,t)=>{const e=nt.getAllFor(t);!e||!st(o)||(e.delete(o),e.size===0&&Y.delete(t))}},to=(o,t)=>nt.get(o,t),V=o=>typeof o=="string"||!1,eo=o=>At(o)&&o.constructor.name==="Window"||!1,Zt=o=>J(o)&&o.nodeType===9||!1,F=o=>eo(o)?o.document:Zt(o)?o:J(o)?o.ownerDocument:window.document,B=(o,...t)=>Object.assign(o,...t),x=o=>{if(!o)return;if(V(o))return F().createElement(o);const{tagName:t}=o,e=x(t);if(!e)return;const s={...o};return delete s.tagName,B(e,s)},Ht=(o,t)=>{if(!o||!t)return;if(V(t))return F().createElementNS(o,t);const{tagName:e}=t,s=Ht(o,e);if(!s)return;const n={...t};return delete n.tagName,B(s,n)},oo=(o,t)=>o.dispatchEvent(t),Nt=(o,t)=>{const e=getComputedStyle(o),s=t.replace("webkit","Webkit").replace(/([A-Z])/g,"-$1").toLowerCase();return e.getPropertyValue(s)},so=o=>{const t=Nt(o,_e),e=Nt(o,Ue),s=e.includes("ms")?1:1e3,n=t&&t!=="none"?parseFloat(e)*s:0;return Number.isNaN(n)?0:n},U=(o,t)=>o.focus(t),Qt=o=>["true",!0].includes(o)?!0:["false",!1].includes(o)?!1:["null","",null,void 0].includes(o)?null:o!==""&&!Number.isNaN(+o)?+o:o,dt=o=>Object.entries(o),no=o=>o.toLowerCase(),ro=(o,t,e,s)=>{const n={...e},r={...o.dataset},i={...t},a={},l="title";return dt(r).forEach(([c,h])=>{const b=s&&typeof c=="string"&&c.includes(s)?c.replace(s,"").replace(/[A-Z]/g,u=>no(u)):c;a[b]=Qt(h)}),dt(n).forEach(([c,h])=>{n[c]=Qt(h)}),dt(t).forEach(([c,h])=>{c in n?i[c]=n[c]:c in a?i[c]=a[c]:i[c]=c===l?pt(o,l):h}),i},io=o=>o.offsetHeight,O=(o,t)=>{dt(t).forEach(([e,s])=>{if(s&&V(e)&&e.includes("--"))o.style.setProperty(e,s);else{const n={};n[e]=s,B(o.style,n)}})},ao=o=>At(o)&&o.constructor.name==="Map"||!1,te=o=>o.toUpperCase(),ft=(o,t)=>{const{width:e,height:s,top:n,right:r,bottom:i,left:a}=o.getBoundingClientRect();let l=1,c=1;if(t&&st(o)){const{offsetWidth:h,offsetHeight:b}=o;l=h>0?Math.round(e)/h:1,c=b>0?Math.round(s)/b:1}return{width:e/l,height:s/c,top:n/c,right:r/l,bottom:i/c,left:a/l,x:a/l,y:n/c}},Et=o=>F(o).documentElement;let ee=0,oe=0;const Z=new Map,se=(o,t)=>{let e=t?ee:oe;if(t){const s=se(o),n=Z.get(s)||new Map;Z.has(s)||Z.set(s,n),ao(n)&&!n.has(t)?(n.set(t,e),ee+=1):e=n.get(t)}else{const s=o.id||o;Z.has(s)?e=Z.get(s):(Z.set(s,e),oe+=1)}return e},lo=o=>{var t;return o?Zt(o)?o.defaultView:J(o)?(t=o?.ownerDocument)==null?void 0:t.defaultView:o:window},Mt=o=>Array.isArray(o)||!1,ne=(o,t)=>o?o.closest(t)||ne(o.getRootNode().host,t):null,_=(o,t)=>st(o)?o:(J(t)?t:F()).querySelector(o),rt=(o,t)=>(t&&J(t)?t:F()).getElementsByClassName(o),Tt=["transparent","currentColor","inherit","revert","initial"],v=o=>{const t=Math.floor(o);return o-t<.5?t:Math.round(o)},mt=[["aliceblue",{r:240,g:248,b:255}],["antiquewhite",{r:250,g:235,b:215}],["aqua",{r:0,g:255,b:255}],["aquamarine",{r:127,g:255,b:212}],["azure",{r:240,g:255,b:255}],["beige",{r:245,g:245,b:220}],["bisque",{r:255,g:228,b:196}],["black",{r:0,g:0,b:0}],["blanchedalmond",{r:255,g:235,b:205}],["blue",{r:0,g:0,b:255}],["blueviolet",{r:138,g:43,b:226}],["brown",{r:165,g:42,b:42}],["burlywood",{r:222,g:184,b:135}],["cadetblue",{r:95,g:158,b:160}],["chartreuse",{r:127,g:255,b:0}],["chocolate",{r:210,g:105,b:30}],["coral",{r:255,g:127,b:80}],["cornflowerblue",{r:100,g:149,b:237}],["cornsilk",{r:255,g:248,b:220}],["crimson",{r:220,g:20,b:60}],["cyan",{r:0,g:255,b:255}],["darkblue",{r:0,g:0,b:139}],["darkcyan",{r:0,g:139,b:139}],["darkgoldenrod",{r:184,g:134,b:11}],["darkgray",{r:169,g:169,b:169}],["darkgreen",{r:0,g:100,b:0}],["darkgrey",{r:169,g:169,b:169}],["darkkhaki",{r:189,g:183,b:107}],["darkmagenta",{r:139,g:0,b:139}],["darkolivegreen",{r:85,g:107,b:47}],["darkorange",{r:255,g:140,b:0}],["darkorchid",{r:153,g:50,b:204}],["darkred",{r:139,g:0,b:0}],["darksalmon",{r:233,g:150,b:122}],["darkseagreen",{r:143,g:188,b:143}],["darkslateblue",{r:72,g:61,b:139}],["darkslategray",{r:47,g:79,b:79}],["darkslategrey",{r:47,g:79,b:79}],["darkturquoise",{r:0,g:206,b:209}],["darkviolet",{r:148,g:0,b:211}],["deeppink",{r:255,g:20,b:147}],["deepskyblue",{r:0,g:191,b:255}],["dimgray",{r:105,g:105,b:105}],["dimgrey",{r:105,g:105,b:105}],["dodgerblue",{r:30,g:144,b:255}],["firebrick",{r:178,g:34,b:34}],["floralwhite",{r:255,g:250,b:240}],["forestgreen",{r:34,g:139,b:34}],["fuchsia",{r:255,g:0,b:255}],["gainsboro",{r:220,g:220,b:220}],["ghostwhite",{r:248,g:248,b:255}],["goldenrod",{r:218,g:165,b:32}],["gold",{r:255,g:215,b:0}],["gray",{r:128,g:128,b:128}],["green",{r:0,g:128,b:0}],["greenyellow",{r:173,g:255,b:47}],["grey",{r:128,g:128,b:128}],["honeydew",{r:240,g:255,b:240}],["hotpink",{r:255,g:105,b:180}],["indianred",{r:205,g:92,b:92}],["indigo",{r:75,g:0,b:130}],["ivory",{r:255,g:255,b:240}],["khaki",{r:240,g:230,b:140}],["lavenderblush",{r:255,g:240,b:245}],["lavender",{r:230,g:230,b:250}],["lawngreen",{r:124,g:252,b:0}],["lemonchiffon",{r:255,g:250,b:205}],["lightblue",{r:173,g:216,b:230}],["lightcoral",{r:240,g:128,b:128}],["lightcyan",{r:224,g:255,b:255}],["lightgoldenrodyellow",{r:250,g:250,b:210}],["lightgray",{r:211,g:211,b:211}],["lightgreen",{r:144,g:238,b:144}],["lightgrey",{r:211,g:211,b:211}],["lightpink",{r:255,g:182,b:193}],["lightsalmon",{r:255,g:160,b:122}],["lightseagreen",{r:32,g:178,b:170}],["lightskyblue",{r:135,g:206,b:250}],["lightslategray",{r:119,g:136,b:153}],["lightslategrey",{r:119,g:136,b:153}],["lightsteelblue",{r:176,g:196,b:222}],["lightyellow",{r:255,g:255,b:224}],["lime",{r:0,g:255,b:0}],["limegreen",{r:50,g:205,b:50}],["linen",{r:250,g:240,b:230}],["magenta",{r:255,g:0,b:255}],["maroon",{r:128,g:0,b:0}],["mediumaquamarine",{r:102,g:205,b:170}],["mediumblue",{r:0,g:0,b:205}],["mediumorchid",{r:186,g:85,b:211}],["mediumpurple",{r:147,g:112,b:219}],["mediumseagreen",{r:60,g:179,b:113}],["mediumslateblue",{r:123,g:104,b:238}],["mediumspringgreen",{r:0,g:250,b:154}],["mediumturquoise",{r:72,g:209,b:204}],["mediumvioletred",{r:199,g:21,b:133}],["midnightblue",{r:25,g:25,b:112}],["mintcream",{r:245,g:255,b:250}],["mistyrose",{r:255,g:228,b:225}],["moccasin",{r:255,g:228,b:181}],["navajowhite",{r:255,g:222,b:173}],["navy",{r:0,g:0,b:128}],["oldlace",{r:253,g:245,b:230}],["olive",{r:128,g:128,b:0}],["olivedrab",{r:107,g:142,b:35}],["orange",{r:255,g:165,b:0}],["orangered",{r:255,g:69,b:0}],["orchid",{r:218,g:112,b:214}],["palegoldenrod",{r:238,g:232,b:170}],["palegreen",{r:152,g:251,b:152}],["paleturquoise",{r:175,g:238,b:238}],["palevioletred",{r:219,g:112,b:147}],["papayawhip",{r:255,g:239,b:213}],["peachpuff",{r:255,g:218,b:185}],["peru",{r:205,g:133,b:63}],["pink",{r:255,g:192,b:203}],["plum",{r:221,g:160,b:221}],["powderblue",{r:176,g:224,b:230}],["purple",{r:128,g:0,b:128}],["rebeccapurple",{r:102,g:51,b:153}],["red",{r:255,g:0,b:0}],["rosybrown",{r:188,g:143,b:143}],["royalblue",{r:65,g:105,b:225}],["saddlebrown",{r:139,g:69,b:19}],["salmon",{r:250,g:128,b:114}],["sandybrown",{r:244,g:164,b:96}],["seagreen",{r:46,g:139,b:87}],["seashell",{r:255,g:245,b:238}],["sienna",{r:160,g:82,b:45}],["silver",{r:192,g:192,b:192}],["skyblue",{r:135,g:206,b:235}],["slateblue",{r:106,g:90,b:205}],["slategray",{r:112,g:128,b:144}],["slategrey",{r:112,g:128,b:144}],["snow",{r:255,g:250,b:250}],["springgreen",{r:0,g:255,b:127}],["steelblue",{r:70,g:130,b:180}],["tan",{r:210,g:180,b:140}],["teal",{r:0,g:128,b:128}],["thistle",{r:216,g:191,b:216}],["tomato",{r:255,g:99,b:71}],["turquoise",{r:64,g:224,b:208}],["violet",{r:238,g:130,b:238}],["wheat",{r:245,g:222,b:179}],["white",{r:255,g:255,b:255}],["whitesmoke",{r:245,g:245,b:245}],["yellow",{r:255,g:255,b:0}],["yellowgreen",{r:154,g:205,b:50}]],re="deg|rad|grad|turn",ie="[-\\+]?\\d+%?",ae="[-\\+]?\\d*\\.\\d+%?",le=`[-\\+]?\\d*\\.?\\d+(?:${re})?`,vt=`(?:${ae})|(?:${ie})`,Rt=`(?:${vt})|(?:${le}?)`,co="(?:[\\s|\\(\\s|\\s\\(\\s]+)?",ho="(?:[\\s|\\)\\s]+)?",ce="(?:[,|\\s]+)",go="(?:[,|\\/\\s]*)?",it=`${co}(${Rt})${ce}(${vt})${ce}(${vt})${go}(${vt})?${ho}`,I={CSS_UNIT:new RegExp(Rt),ANGLES:re,CSS_ANGLE:le,CSS_INTEGER:ie,CSS_NUMBER:ae,CSS_UNIT2:Rt,PERMISSIVE_MATCH:it,hwb:new RegExp(`hwb${it}`),rgb:new RegExp(`rgb(?:a)?${it}`),hsl:new RegExp(`hsl(?:a)?${it}`),hsv:new RegExp(`hsv(?:a)?${it}`),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/},he=o=>Tt.includes(o),at=(o,t)=>o!==null&&typeof o=="object"&&Object.keys(t).every(e=>e in o),ge=o=>`${o}`.includes(".")&&parseFloat(o)===1,wt=o=>typeof o=="string"&&o.includes("%"),L=o=>!!I.CSS_UNIT.exec(`${o}`),ue=["rgb","hex","hsl","hsv","hwb"],be=o=>Tt.includes(o)||["#",...ue].some(t=>o.includes(t))?!1:mt.some(([t])=>o===t),T=(o,t)=>{let e=o;if(typeof o=="number"&&Math.min(o,0)===0&&Math.max(o,1)===1)return o;ge(o)&&(e="100%");const s=wt(e);return e=t===360?parseFloat(e):Math.min(t,Math.max(0,parseFloat(e))),s&&(e=e*t/100),Math.abs(e-t)<1e-6?1:(t===360?e=(e<0?e%t+t:e%t)/t:e=e%t/t,e)},Dt=o=>{let t=parseFloat(o);return(Number.isNaN(t)||t<0||t>1)&&(t=1),t},$t=o=>Math.min(1,Math.max(0,o)),z=o=>o.length===1?`0${o}`:String(o),pe=o=>{const[[,t]]=mt.filter(([e])=>e===o.toLowerCase());return t},A=o=>parseInt(o,16),Ot=o=>A(o)/255,de=o=>v(o*255).toString(16),fe=(o,t,e)=>{const s=Math.max(o,t,e),n=Math.min(o,t,e);let r=0,i=0;const a=(s+n)/2;if(s===n)i=0,r=0;else{const l=s-n;i=a>.5?l/(2-s-n):l/(s+n),s===o&&(r=(t-e)/l+(t<e?6:0)),s===t&&(r=(e-o)/l+2),s===e&&(r=(o-t)/l+4),r/=6}return{h:r,s:i,l:a}},kt=(o,t,e)=>{let s=e;return s<0&&(s+=1),s>1&&(s-=1),s<1/6?o+(t-o)*(6*s):s<1/2?t:s<2/3?o+(t-o)*(2/3-s)*6:o},lt=(o,t,e)=>{let s=0,n=0,r=0;if(t===0)n=e,r=e,s=e;else if(e){const i=e<.5?e*(1+t):e+t-e*t,a=2*e-i;s=kt(a,i,o+1/3),n=kt(a,i,o),r=kt(a,i,o-1/3)}return{r:s,g:n,b:r}},me=(o,t,e)=>{let s=0,n=0;const r=Math.min(o,t,e),i=Math.max(o,t,e),a=1-i;if(i===r)return{h:0,w:r,b:a};o===r?(s=t-e,n=3):(s=t===r?e-o:o-t,n=t===r?5:1);const l=(n-s/(i-r))/6;return{h:l===1?0:l,w:r,b:a}},ve=(o,t,e)=>{if(t+e>=1){const i=t/(t+e);return{r:i,g:i,b:i}}let{r:s,g:n,b:r}=lt(o,1,.5);return[s,n,r]=[s,n,r].map(i=>i*(1-t-e)+t),{r:s,g:n,b:r}},we=(o,t,e)=>{const s=Math.max(o,t,e),n=Math.min(o,t,e);let r=0;const i=s,a=s-n,l=s===0?0:a/s;return s===n?r=0:(o===s&&(r=(t-e)/a+(t<e?6:0)),t===s&&(r=(e-o)/a+2),e===s&&(r=(o-t)/a+4),r/=6),{h:r,s:l,v:i}},Ft=(o,t,e)=>{const s=o*6,n=t,r=e,i=Math.floor(s),a=s-i,l=r*(1-n),c=r*(1-a*n),h=r*(1-(1-a)*n),b=i%6,u=[r,c,l,l,h,r][b],d=[h,r,r,c,l,l][b],g=[l,l,h,r,r,c][b];return{r:u,g:d,b:g}},$e=(o,t,e,s)=>{const n=[z(v(o).toString(16)),z(v(t).toString(16)),z(v(e).toString(16))];return s&&n[0].charAt(0)===n[0].charAt(1)&&n[1].charAt(0)===n[1].charAt(1)&&n[2].charAt(0)===n[2].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0):n.join("")},It=(o,t,e,s,n)=>{const r=[z(v(o).toString(16)),z(v(t).toString(16)),z(v(e).toString(16)),z(de(s))];return n&&r[0].charAt(0)===r[0].charAt(1)&&r[1].charAt(0)===r[1].charAt(1)&&r[2].charAt(0)===r[2].charAt(1)&&r[3].charAt(0)===r[3].charAt(1)?r[0].charAt(0)+r[1].charAt(0)+r[2].charAt(0)+r[3].charAt(0):r.join("")},ke=o=>{const t=String(o).trim().toLowerCase();if(be(t))return Object.assign(pe(t),{a:1,format:"rgb",ok:!0});if(he(t))return{r:0,g:0,b:0,a:t==="transparent"?0:1,format:"rgb",ok:!0};let[,e,s,n,r]=I.rgb.exec(t)||[];return e&&s&&n?{r:e,g:s,b:n,a:r!==void 0?r:1,format:"rgb",ok:!0}:([,e,s,n,r]=I.hsl.exec(t)||[],e&&s&&n?{h:e,s,l:n,a:r!==void 0?r:1,format:"hsl",ok:!0}:([,e,s,n,r]=I.hsv.exec(t)||[],e&&s&&n?{h:e,s,v:n,a:r!==void 0?r:1,format:"hsv",ok:!0}:([,e,s,n,r]=I.hwb.exec(t)||[],e&&s&&n?{h:e,w:s,b:n,a:r!==void 0?r:1,format:"hwb",ok:!0}:([,e,s,n,r]=I.hex8.exec(t)||[],e&&s&&n&&r?{r:A(e),g:A(s),b:A(n),a:Ot(r),format:"hex",ok:!0}:([,e,s,n]=I.hex6.exec(t)||[],e&&s&&n?{r:A(e),g:A(s),b:A(n),a:1,format:"hex",ok:!0}:([,e,s,n,r]=I.hex4.exec(t)||[],e&&s&&n&&r?{r:A(e+e),g:A(s+s),b:A(n+n),a:Ot(r+r),format:"hex",ok:!0}:([,e,s,n]=I.hex3.exec(t)||[],e&&s&&n?{r:A(e+e),g:A(s+s),b:A(n+n),a:1,format:"hex",ok:!0}:{r:0,g:0,b:0,a:1,format:"rgb",ok:!o})))))))},ye=o=>{let t={r:0,g:0,b:0},e=o,s=1,n,r,i,a,l,c,h,b,u="rgb",d=!1;return(!e||typeof e=="string")&&(e=ke(e),d=e.ok),at(e,t)&&L(e.r)&&L(e.g)&&L(e.b)&&({r:h,g:b,b:l}=e,[h,b,l]=[h,b,l].map(g=>T(g,wt(g)?100:255)),t={r:h,g:b,b:l},u="format"in e?e.format:"rgb"),at(e,{h:0,s:0,v:0})&&L(e.h)&&L(e.s)&&L(e.v)&&({h:c,s:n,v:r}=e,c=T(c,360),n=T(n,100),r=T(r,100),t=Ft(c,n,r),u="hsv"),at(e,{h:0,s:0,l:0})&&L(e.h)&&L(e.s)&&L(e.l)&&({h:c,s:n,l:i}=e,c=T(c,360),n=T(n,100),i=T(i,100),t=lt(c,n,i),u="hsl"),at(e,{h:0,w:0,b:0})&&L(e.h)&&L(e.w)&&L(e.b)&&({h:c,w:a,b:l}=e,c=T(c,360),a=T(a,100),l=T(l,100),t=ve(c,a,l),u="hwb"),L(e.a)&&(s=e.a,s=wt(s)||parseFloat(`${s}`)>1?T(s,100):s),{r:t.r,g:t.g,b:t.b,a:Dt(s),format:u,ok:d}},uo="1.0.6";class k{static matchers=I;static isOnePointZero=ge;static isPercentage=wt;static isValidCSSUnit=L;static isNonColor=he;static isColorName=be;static isColorType=at;static pad2=z;static clamp01=$t;static bound01=T;static boundAlpha=Dt;static getRGBFromName=pe;static convertHexToDecimal=Ot;static convertDecimalToHex=de;static rgbToHsl=fe;static rgbToHex=$e;static rgbToHsv=we;static rgbToHwb=me;static rgbaToHex=It;static hslToRgb=Ft;static hsvToRgb=Ft;static hueToRgb=kt;static hwbToRgb=ve;static parseIntFromHex=A;static stringInputToObject=ke;static inputToRGB=ye;static roundPart=v;static webColors=mt;static nonColors=Tt;static version=uo;r;g;b;a;format;ok;originalInput;constructor(t,e){const s=e&&ue.includes(e)?e:"",{r:n,g:r,b:i,a,ok:l,format:c}=ye(t);this.originalInput=t,this.r=n,this.g=r,this.b=i,this.a=a,this.ok=l,this.format=s||c}get isValid(){return this.ok}get isDark(){return this.brightness<120}get luminance(){const{r:t,g:e,b:s}=this;let n=0,r=0,i=0;return t<=.03928?n=t/12.92:n=((t+.055)/1.055)**2.4,e<=.03928?r=e/12.92:r=((e+.055)/1.055)**2.4,s<=.03928?i=s/12.92:i=((s+.055)/1.055)**2.4,.2126*n+.7152*r+.0722*i}get brightness(){const{r:t,g:e,b:s}=this.toRgb();return(t*299+e*587+s*114)/1e3}get name(){const{r:t,g:e,b:s}=this.toRgb(),[n]=mt.map(([r,i])=>{const a=(((i.r-t)*.3)**2+((i.g-e)*.6)**2+((i.b-s)*.1)**2)**.5;return[r,a]}).find(([,r],i,a)=>r===Math.min(...a.map(([,l])=>l)));return n}toRgb(){let{r:t,g:e,b:s,a:n}=this;return[t,e,s]=[t,e,s].map(r=>v(r*255*100)/100),n=v(n*100)/100,{r:t,g:e,b:s,a:n}}toRgbString(){const{r:t,g:e,b:s,a:n}=this.toRgb(),[r,i,a]=[t,e,s].map(v);return n===1?`rgb(${r}, ${i}, ${a})`:`rgba(${r}, ${i}, ${a}, ${n})`}toRgbCSS4String(){const{r:t,g:e,b:s,a:n}=this.toRgb(),[r,i,a]=[t,e,s].map(v),l=n===1?"":` / ${v(n*100)}%`;return`rgb(${r} ${i} ${a}${l})`}toHex(t){const{r:e,g:s,b:n,a:r}=this.toRgb();return r===1?$e(e,s,n,t):It(e,s,n,r,t)}toHexString(t){return`#${this.toHex(t)}`}toHex8(t){const{r:e,g:s,b:n,a:r}=this.toRgb();return It(e,s,n,r,t)}toHex8String(t){return`#${this.toHex8(t)}`}toHsv(){const{r:t,g:e,b:s,a:n}=this,{h:r,s:i,v:a}=we(t,e,s);return{h:r,s:i,v:a,a:n}}toHsl(){const{r:t,g:e,b:s,a:n}=this,{h:r,s:i,l:a}=fe(t,e,s);return{h:r,s:i,l:a,a:n}}toHslString(){let{h:t,s:e,l:s,a:n}=this.toHsl();return t=v(t*360),e=v(e*100),s=v(s*100),n=v(n*100)/100,n===1?`hsl(${t}, ${e}%, ${s}%)`:`hsla(${t}, ${e}%, ${s}%, ${n})`}toHslCSS4String(){let{h:t,s:e,l:s,a:n}=this.toHsl();t=v(t*360),e=v(e*100),s=v(s*100),n=v(n*100);const r=n<100?` / ${v(n)}%`:"";return`hsl(${t}deg ${e}% ${s}%${r})`}toHwb(){const{r:t,g:e,b:s,a:n}=this,{h:r,w:i,b:a}=me(t,e,s);return{h:r,w:i,b:a,a:n}}toHwbString(){let{h:t,w:e,b:s,a:n}=this.toHwb();t=v(t*360),e=v(e*100),s=v(s*100),n=v(n*100);const r=n<100?` / ${v(n)}%`:"";return`hwb(${t}deg ${e}% ${s}%${r})`}setAlpha(t){return typeof t!="number"?this:(this.a=Dt(t),this)}saturate(t){if(typeof t!="number")return this;const{h:e,s,l:n}=this.toHsl(),{r,g:i,b:a}=lt(e,$t(s+t/100),n);return Object.assign(this,{r,g:i,b:a}),this}desaturate(t){return typeof t=="number"?this.saturate(-t):this}greyscale(){return this.saturate(-100)}lighten(t){if(typeof t!="number")return this;const{h:e,s,l:n}=this.toHsl(),{r,g:i,b:a}=lt(e,s,$t(n+t/100));return Object.assign(this,{r,g:i,b:a}),this}darken(t){return typeof t=="number"?this.lighten(-t):this}spin(t){if(typeof t!="number")return this;const{h:e,s,l:n}=this.toHsl(),{r,g:i,b:a}=lt($t((e*360+t)%360/360),s,n);return Object.assign(this,{r,g:i,b:a}),this}clone(){return new k(this)}toString(t){const{format:e}=this;return e==="hex"?this.toHexString(t):e==="hsl"?this.toHslString():e==="hwb"?this.toHwbString():this.toRgbString()}}class Kt{static Color=k;hue;hueSteps;lightSteps;saturation;colors;constructor(...t){let e=0,s=12,n=10,r=[.5],i=100;if(t.length===4)[e,s,n,i]=t;else if(t.length===3)[e,s,n]=t;else if(t.length===2&&([s,n]=t,[s,n].some(g=>g<1)))throw TypeError("ColorPalette: the two minimum arguments must be numbers higher than 0.");const a=[],l=360/s,c=k.roundPart((n-(n%2?1:0))/2),h=[.25,.2,.15,.11,.09,.075],b=[[1,2,3],[4,5],[6,7],[8,9],[10,11],[12,13]],u=b.find(g=>g.includes(n)),d=u?h[b.indexOf(u)]:100/(n+(n%2?0:1))/100;for(let g=1;g<c+1;g+=1)r=[...r,.5+d*g];for(let g=1;g<n-c;g+=1)r=[.5-d*g,...r];for(let g=0;g<s;g+=1){const p=(e+g*l)%360/360;r.forEach(f=>{const w=new k({h:p,s:1,l:f});a.push(i<100?w.saturate(i-100):w)})}this.hue=e,this.hueSteps=s,this.lightSteps=n,this.saturation=i,this.colors=a}}const xe={pickerLabel:"Colour Picker",appearanceLabel:"Colour Appearance",valueLabel:"Colour Value",toggleLabel:"Select Colour",presetsLabel:"Colour Presets",defaultsLabel:"Colour Defaults",formatLabel:"Format",alphaLabel:"Alpha",hexLabel:"Hexadecimal",hueLabel:"Hue",whitenessLabel:"Whiteness",blacknessLabel:"Blackness",saturationLabel:"Saturation",lightnessLabel:"Lightness",redLabel:"Red",greenLabel:"Green",blueLabel:"Blue"},Vt=["white","black","grey","red","orange","brown","gold","olive","yellow","lime","green","teal","cyan","blue","violet","magenta","pink"],Pe=o=>{if(!V(o))return!1;try{JSON.parse(o)}catch{return!1}return!0},Bt="v-hidden",bo=o=>{const{format:t,id:e,componentLabels:s}=o,n=x({tagName:"div",className:`color-form ${t}`});let r=["hex"];return t==="rgb"?r=["red","green","blue","alpha"]:t==="hsl"?r=["hue","saturation","lightness","alpha"]:t==="hwb"&&(r=["hue","whiteness","blackness","alpha"]),r.forEach(i=>{const[a]=t==="hex"?["#"]:te(i).split(""),l=`color_${t}_${i}_${e}`,c=s[`${i}Label`],h=x({tagName:"label"});m(h,"for",l),h.append(x({tagName:"span",ariaHidden:"true",innerText:`${a}:`}),x({tagName:"span",className:Bt,innerText:c}));const b=x({tagName:"input",id:l,type:t==="hex"?"text":"number",value:i==="alpha"?"100":"0",className:`color-input ${i}`,autocomplete:"off",spellcheck:!1});let u="100",d="1";i!=="alpha"&&(t==="rgb"?(u="255",d="1"):i==="hue"&&(u="360",d="1")),B(b,{min:"0",max:u,step:d}),n.append(h,b)}),n},po=o=>{const{format:t,componentLabels:e}=o,{hueLabel:s,alphaLabel:n,lightnessLabel:r,saturationLabel:i,whitenessLabel:a,blacknessLabel:l}=e,c=t==="hsl"?360:100,h=t==="hsl"?100:360,b=100;let u=t==="hsl"?`${s} & ${r}`:`${r} & ${i}`;u=t==="hwb"?`${a} & ${l}`:u;const d=t==="hsl"?`${i}`:`${s}`,g=x({tagName:"div",className:`color-controls ${t}`}),p="color-pointer",f="color-slider";return[{i:1,c:p,l:u,min:0,max:c},{i:2,c:f,l:d,min:0,max:h},{i:3,c:f,l:n,min:0,max:b}].forEach($=>{const{i:P,c:H,l:S,min:C,max:R}=$,E=x({tagName:"div",className:"color-control",role:"presentation"});E.append(x({tagName:"div",className:`visual-control visual-control${P}`}));const N=x({tagName:"div",className:`${H} knob`,ariaLive:"polite",ariaLabel:S,role:"slider",tabIndex:0,ariaValueMin:`${C}`,ariaValueMax:`${R}`});E.append(N),g.append(E)}),g},Se=(o,t,e)=>{const{input:s,format:n,componentLabels:r}=o,{defaultsLabel:i,presetsLabel:a}=r,l=e==="color-options",c=t instanceof Kt,h=l?a:i,b=c?t.colors:t,u=b.length,{lightSteps:d}=c?t:{lightSteps:null},g=d||[9,10].find(N=>u>=N*2&&!(u%N))||5,p=l&&u>g;let f=2;f=p&&u>g*2?3:f,f=p&&u>g*3?4:f,f=p&&u>g*4?5:f;const w=f-(u<=g*3?1:2),$=p&&u>w*g;let P=e;P+=$?" scrollable":"",P+=p?" multiline":"";const H=p?"1px":"0.25rem";let S=p?1.75:2;S=g>5&&p?1.5:S;const C=`${w*S}rem`,R=`calc(${f} * ${S}rem + ${f-1} * ${H})`,E=x({tagName:"ul",className:P,role:"listbox",ariaLabel:h});return $&&O(E,{"--grid-item-size":`${S}rem`,"--grid-fit":`${g}`,"--grid-gap":H,"--grid-height":C,"--grid-hover-height":R}),b.forEach(N=>{let[K,ct]=typeof N=="string"?N.trim().split(":"):[];N instanceof k&&(K=N.toHexString(),ct=K);const Me=new k(N instanceof k?N:K,n).toString()===pt(s,"value"),qt=x({tagName:"li",className:`color-option${Me?" active":""}`,innerText:`${ct||K}`,tabIndex:0,role:"option",ariaSelected:Me?"true":"false"});m(qt,"data-value",`${K}`),l&&O(qt,{backgroundColor:K}),E.append(qt)}),E},fo=o=>{const{input:t,parent:e,format:s,id:n,componentLabels:r,colorKeywords:i,colorPresets:a}=o,l=pt(t,"value")||"#fff",{nonColors:c}=k,{toggleLabel:h,pickerLabel:b,formatLabel:u,hexLabel:d}=r,g=c.includes(l)?"#fff":l;o.color=new k(g,s);const p=s==="hex"?d:te(s),f=x({id:`picker-btn-${n}`,tagName:"button",className:"picker-toggle btn-appearance",ariaExpanded:"false",ariaHasPopup:"true"});f.append(x({tagName:"span",className:Bt,innerText:`${b}. ${u}: ${p}`}));const w=x({tagName:"div",className:"color-dropdown picker",role:"group",ariaLabelledBy:`picker-btn-${n}`}),$=po(o),P=bo(o);if(w.append($,P),t.before(f),e.append(w),i||a){const H=x({tagName:"div",className:"color-dropdown scrollable menu"});a&&H.append(Se(o,a,"color-options")),i&&i.length&&H.append(Se(o,i,"color-defaults"));const S=x({tagName:"button",className:"menu-toggle btn-appearance",tabIndex:-1,ariaExpanded:"false",ariaHasPopup:"true"}),C=encodeURI("http://www.w3.org/2000/svg"),R=Ht(C,{tagName:"svg"});m(R,"xmlns",C),m(R,"viewBox","0 0 512 512"),m(R,Te,"true");const E=Ht(C,{tagName:"path"});m(E,"d","M98,158l157,156L411,158l27,27L255,368L71,185L98,158z"),m(E,"fill","#fff"),R.append(E),S.append(x({tagName:"span",className:Bt,innerText:`${h}`}),R),e.append(S,H)}i&&c.includes(l)&&(o.value=l),m(t,X,"-1")},mo="2.0.0-alpha1",Q="color-picker",vo=`[data-function="${Q}"]`,Ce=`.${Q}`,wo={componentLabels:xe,colorLabels:Vt,format:"rgb",colorPresets:!1,colorKeywords:!1},{roundPart:y,nonColors:yt}=k,$o=o=>to(o,Q),ko=o=>new Ee(o),Le=(o,t)=>{const e=t?Gt:xt,{input:s,pickerToggle:n,menuToggle:r}=o;e(s,Oe,o.showPicker),e(n,Ct,o.togglePicker),r&&e(r,Ct,o.toggleMenu)},Ae=(o,t)=>{const e=t?Gt:xt,{input:s,colorMenu:n,parent:r}=o,i=F(s),a=lo(i);e(o.controls,Ke,o.pointerDown),o.controlKnobs.forEach(l=>e(l,_t,o.handleKnobs)),e(a,je,o.handleScroll),e(a,Be,o.update),[s,...o.inputs].forEach(l=>e(l,Re,o.changeHandler)),n&&(e(n,Ct,o.menuClickHandler),e(n,_t,o.menuKeyHandler)),e(i,Wt,o.pointerMove),e(i,Ve,o.pointerUp),e(r,Fe,o.handleFocusOut),e(i,Ie,o.handleDismiss)},He=o=>{oo(o.input,new CustomEvent("colorpicker.change"))},Ne=o=>{o&&["bottom","top"].forEach(t=>D(o,t))},jt=(o,t)=>{const{colorPicker:e,colorMenu:s,menuToggle:n,pickerToggle:r,parent:i}=o,a=t===e,l=a?s:e,c=a?n:r,h=a?r:n;M(i,"open")||q(i,"open"),l&&(D(l,"show"),Ne(l)),q(t,"bottom"),io(t),q(t,"show"),a&&o.update(),o.isOpen||(Ae(o,!0),o.updateDropdownPosition(),o.isOpen=!0,m(o.input,X,"0"),n&&m(n,X,"0")),m(h,Pt,"true"),c&&m(c,Pt,"false")};class Ee{static Color=k;static ColorPalette=Kt;static getInstance=$o;static init=ko;static selector=vo;static roundPart=y;static setElementStyle=O;static setAttribute=m;static getBoundingClientRect=ft;static version=mo;id;input;color;format="rgb";parent;dragElement;isOpen=!1;controlPositions;colorLabels={};colorKeywords;colorPresets;componentLabels;pickerToggle;menuToggle;colorPicker;colorMenu;controls;inputs;controlKnobs;visuals;constructor(t,e){const s=_(t);if(typeof t>"u")throw new TypeError("ColorPicker target not specified.");if(V(t)&&!s)throw new TypeError(`ColorPicker target "${t}" cannot be found.`);this.input=s;const n=ne(s,Ce);if(!n)throw new TypeError("ColorPicker requires a specific markup to work.");this.parent=n,this.id=se(s,Q),this.dragElement=void 0,this.isOpen=!1,this.controlPositions={c1x:0,c1y:0,c2y:0,c3y:0},this.colorLabels={},this.colorKeywords=!1,this.colorPresets=!1;const{format:r,componentLabels:i,colorLabels:a,colorKeywords:l,colorPresets:c}=ro(s,wo,e||{});let h=Vt;Mt(a)&&a.length===17?h=a:V(a)&&a.split(",").length===17&&(h=a.split(",")),Vt.forEach((p,f)=>{this.colorLabels[p]=h[f].trim()});const b=V(i)&&Pe(i)?JSON.parse(i):i;if(this.componentLabels=B({...xe},b),this.color=new k(s.value||"#fff",r),this.format=r,Mt(l)&&l.length?this.colorKeywords=l:V(l)&&l.length&&(this.colorKeywords=l.split(",").map(p=>p.trim())),Mt(c)&&c.length)this.colorPresets=c;else if(c&&Pe(c)){const{hue:p,hueSteps:f,lightSteps:w,saturation:$}=JSON.parse(c);this.colorPresets=new Kt(p,f,w,$)}else V(c)&&(this.colorPresets=c.split(",").map(p=>p.trim()));this.showPicker=this.showPicker.bind(this),this.togglePicker=this.togglePicker.bind(this),this.toggleMenu=this.toggleMenu.bind(this),this.menuClickHandler=this.menuClickHandler.bind(this),this.menuKeyHandler=this.menuKeyHandler.bind(this),this.pointerDown=this.pointerDown.bind(this),this.pointerMove=this.pointerMove.bind(this),this.pointerUp=this.pointerUp.bind(this),this.update=this.update.bind(this),this.handleScroll=this.handleScroll.bind(this),this.handleFocusOut=this.handleFocusOut.bind(this),this.changeHandler=this.changeHandler.bind(this),this.handleDismiss=this.handleDismiss.bind(this),this.handleKnobs=this.handleKnobs.bind(this),fo(this);const[u,d]=rt("color-dropdown",n);this.pickerToggle=_(".picker-toggle",n),this.menuToggle=_(".menu-toggle",n),this.colorPicker=u,this.colorMenu=d,this.inputs=[...rt("color-input",n)];const[g]=rt("color-controls",n);this.controls=g,this.controlKnobs=[...rt("knob",g)],this.visuals=[...rt("visual-control",g)],this.update(),Le(this,!0),nt.set(s,Q,this)}get value(){return this.input.value}set value(t){this.input.value=t}get hasNonColor(){return this.colorKeywords instanceof Array&&this.colorKeywords.some(t=>yt.includes(t))}get hex(){return this.color.toHex(!0)}get hsv(){return this.color.toHsv()}get hsl(){return this.color.toHsl()}get hwb(){return this.color.toHwb()}get rgb(){return this.color.toRgb()}get brightness(){return this.color.brightness}get luminance(){return this.color.luminance}get isDark(){const{color:t,brightness:e}=this;return e<120&&t.a>.33}get isValid(){const t=this.input.value;return t!==""&&new k(t).isValid}get appearance(){const{colorLabels:t,hsl:e,hsv:s,format:n}=this,r=y(e.h*360),i=n==="hsl"?e.s:s.s,a=y(i*100),l=y(e.l*100),c=s.v*100;let h="black";if(l===100&&a===0)h=t.white;else if(l===0)h=t.black;else if(a===0)h=t.grey;else if(r<15||r>=345)h=t.red;else if(r>=15&&r<45)h=c>80&&a>80?t.orange:t.brown;else if(r>=45&&r<75){const b=r>46&&r<54&&c<80&&a>90,u=r>=54&&r<75&&c<80;h=b?t.gold:t.yellow,h=u?t.olive:h}else r>=75&&r<155?h=c<68?t.green:t.lime:r>=155&&r<175?h=t.teal:r>=175&&r<195?h=t.cyan:r>=195&&r<255?h=t.blue:r>=255&&r<270?h=t.violet:r>=270&&r<295?h=t.magenta:r>=295&&r<345&&(h=t.pink);return h}updateVisuals(){const{controlPositions:t,visuals:e}=this,[s,n,r]=e,{offsetHeight:i}=s,a=t.c2y/i,{r:l,g:c,b:h}=new k({h:a,s:1,l:.5}).toRgb(),b="linear-gradient(rgb(255,255,255) 0%, rgb(255,255,255) 100%)",u=1-t.c3y/i,d=y(u*100)/100,g=new k({h:a,s:1,l:.5,a:u}).toRgbString(),p=`linear-gradient(
1
+ var ColorPicker=function(){"use strict";const Ut="aria-description",xt="aria-expanded",Me="aria-hidden",Pt="aria-selected",Q="aria-valuenow",tt="aria-valuetext",Te="change",Re="DOMContentLoaded",Oe="focusin",De="focusout",_t="keydown",Fe="keyup",St="click",Ie="pointerdown",zt="pointermove",Ke="pointerup",Ve="resize",Be="scroll",je="touchmove",j="ArrowDown",et="ArrowUp",ht="ArrowLeft",U="ArrowRight",qe="Enter",Ge="Escape",Wt="Space",Ue="transitionDuration",_e="transitionProperty",W="tabindex",ze=navigator.userAgentData,gt=ze,{userAgent:We}=navigator,ut=We,Jt=/iPhone|iPad|iPod|Android/i;gt?gt.brands.some(o=>Jt.test(o.brand)):Jt.test(ut);const Xt=/(iPhone|iPod|iPad)/;gt?gt.brands.some(o=>Xt.test(o.brand)):Xt.test(ut),ut&&ut.includes("Firefox");const{head:bt}=document;["webkitPerspective","perspective"].some(o=>o in bt.style);const Ct=(o,t,e,s)=>{const r=s||!1;o.addEventListener(t,e,r)},Lt=(o,t,e,s)=>{const r=s||!1;o.removeEventListener(t,e,r)},Je=(o,t,e,s)=>{const r=n=>{(n.target===o||n.currentTarget===o)&&(e.apply(o,[n]),Lt(o,t,r,s))};Ct(o,t,r,s)},Xe=()=>{};(()=>{let o=!1;try{const t=Object.defineProperty({},"passive",{get:()=>(o=!0,o)});Je(document,Re,Xe,t)}catch{}return o})(),["webkitTransform","transform"].some(o=>o in bt.style),["webkitAnimation","animation"].some(o=>o in bt.style),["webkitTransition","transition"].some(o=>o in bt.style);const pt=(o,t)=>o.getAttribute(t),m=(o,t,e)=>o.setAttribute(t,e),At=(o,t)=>o.removeAttribute(t),q=(o,...t)=>{o.classList.add(...t)},O=(o,...t)=>{o.classList.remove(...t)},M=(o,t)=>o.classList.contains(t),Ht=o=>o!=null&&typeof o=="object"||!1,J=o=>Ht(o)&&typeof o.nodeType=="number"&&[1,2,3,4,5,6,7,8,9,10,11].some(t=>o.nodeType===t)||!1,ot=o=>J(o)&&o.nodeType===1||!1,X=new Map,st={data:X,set:(o,t,e)=>{ot(o)&&(X.has(t)||X.set(t,new Map),X.get(t).set(o,e))},getAllFor:o=>X.get(o)||null,get:(o,t)=>{if(!ot(o)||!t)return null;const e=st.getAllFor(t);return o&&e&&e.get(o)||null},remove:(o,t)=>{const e=st.getAllFor(t);!e||!ot(o)||(e.delete(o),e.size===0&&X.delete(t))}},Ze=(o,t)=>st.get(o,t),B=o=>typeof o=="string"||!1,Ye=o=>Ht(o)&&o.constructor.name==="Window"||!1,Zt=o=>J(o)&&o.nodeType===9||!1,F=o=>Ye(o)?o.document:Zt(o)?o:J(o)?o.ownerDocument:window.document,I=(o,...t)=>Object.assign(o,...t),x=o=>{if(!o)return;if(B(o))return F().createElement(o);const{tagName:t}=o,e=x(t);if(!e)return;const s={...o};return delete s.tagName,I(e,s)},Nt=(o,t)=>{if(!o||!t)return;if(B(t))return F().createElementNS(o,t);const{tagName:e}=t,s=Nt(o,e);if(!s)return;const r={...t};return delete r.tagName,I(s,r)},Qe=(o,t)=>o.dispatchEvent(t),Et=(o,t)=>{const e=getComputedStyle(o),s=t.replace("webkit","Webkit").replace(/([A-Z])/g,"-$1").toLowerCase();return e.getPropertyValue(s)},to=o=>{const t=Et(o,_e),e=Et(o,Ue),s=e.includes("ms")?1:1e3,r=t&&t!=="none"?parseFloat(e)*s:0;return Number.isNaN(r)?0:r},_=(o,t)=>o.focus(t),Yt=o=>["true",!0].includes(o)?!0:["false",!1].includes(o)?!1:["null","",null,void 0].includes(o)?null:o!==""&&!Number.isNaN(+o)?+o:o,dt=o=>Object.entries(o),eo=o=>o.toLowerCase(),oo=(o,t,e,s)=>{const r={...e},n={...o.dataset},i={...t},a={},l="title";return dt(n).forEach(([c,h])=>{const b=s&&typeof c=="string"&&c.includes(s)?c.replace(s,"").replace(/[A-Z]/g,u=>eo(u)):c;a[b]=Yt(h)}),dt(r).forEach(([c,h])=>{r[c]=Yt(h)}),dt(t).forEach(([c,h])=>{c in r?i[c]=r[c]:c in a?i[c]=a[c]:i[c]=c===l?pt(o,l):h}),i},Qt=o=>Object.fromEntries(o),so=o=>o.offsetHeight,D=(o,t)=>{dt(t).forEach(([e,s])=>{if(s&&B(e)&&e.includes("--"))o.style.setProperty(e,s);else{const r={};r[e]=s,I(o.style,r)}})},ro=o=>Ht(o)&&o.constructor.name==="Map"||!1,te=o=>o.toUpperCase(),ft=(o,t)=>{const{width:e,height:s,top:r,right:n,bottom:i,left:a}=o.getBoundingClientRect();let l=1,c=1;if(t&&ot(o)){const{offsetWidth:h,offsetHeight:b}=o;l=h>0?Math.round(e)/h:1,c=b>0?Math.round(s)/b:1}return{width:e/l,height:s/c,top:r/c,right:n/l,bottom:i/c,left:a/l,x:a/l,y:r/c}},Mt=o=>F(o).documentElement;let ee=0,oe=0;const Z=new Map,se=(o,t)=>{let e=t?ee:oe;if(t){const s=se(o),r=Z.get(s)||new Map;Z.has(s)||Z.set(s,r),ro(r)&&!r.has(t)?(r.set(t,e),ee+=1):e=r.get(t)}else{const s=o.id||o;Z.has(s)?e=Z.get(s):(Z.set(s,e),oe+=1)}return e},no=o=>{var t;return o?Zt(o)?o.defaultView:J(o)?(t=o?.ownerDocument)==null?void 0:t.defaultView:o:window},Tt=o=>Array.isArray(o)||!1,re=(o,t)=>o?o.closest(t)||re(o.getRootNode().host,t):null,z=(o,t)=>ot(o)?o:(J(t)?t:F()).querySelector(o),rt=(o,t)=>(t&&J(t)?t:F()).getElementsByClassName(o),Rt=["transparent","currentColor","inherit","revert","initial"],v=o=>{const t=Math.floor(o);return o-t<.5?t:Math.round(o)},mt=[["aliceblue",{r:240,g:248,b:255}],["antiquewhite",{r:250,g:235,b:215}],["aqua",{r:0,g:255,b:255}],["aquamarine",{r:127,g:255,b:212}],["azure",{r:240,g:255,b:255}],["beige",{r:245,g:245,b:220}],["bisque",{r:255,g:228,b:196}],["black",{r:0,g:0,b:0}],["blanchedalmond",{r:255,g:235,b:205}],["blue",{r:0,g:0,b:255}],["blueviolet",{r:138,g:43,b:226}],["brown",{r:165,g:42,b:42}],["burlywood",{r:222,g:184,b:135}],["cadetblue",{r:95,g:158,b:160}],["chartreuse",{r:127,g:255,b:0}],["chocolate",{r:210,g:105,b:30}],["coral",{r:255,g:127,b:80}],["cornflowerblue",{r:100,g:149,b:237}],["cornsilk",{r:255,g:248,b:220}],["crimson",{r:220,g:20,b:60}],["cyan",{r:0,g:255,b:255}],["darkblue",{r:0,g:0,b:139}],["darkcyan",{r:0,g:139,b:139}],["darkgoldenrod",{r:184,g:134,b:11}],["darkgray",{r:169,g:169,b:169}],["darkgreen",{r:0,g:100,b:0}],["darkgrey",{r:169,g:169,b:169}],["darkkhaki",{r:189,g:183,b:107}],["darkmagenta",{r:139,g:0,b:139}],["darkolivegreen",{r:85,g:107,b:47}],["darkorange",{r:255,g:140,b:0}],["darkorchid",{r:153,g:50,b:204}],["darkred",{r:139,g:0,b:0}],["darksalmon",{r:233,g:150,b:122}],["darkseagreen",{r:143,g:188,b:143}],["darkslateblue",{r:72,g:61,b:139}],["darkslategray",{r:47,g:79,b:79}],["darkslategrey",{r:47,g:79,b:79}],["darkturquoise",{r:0,g:206,b:209}],["darkviolet",{r:148,g:0,b:211}],["deeppink",{r:255,g:20,b:147}],["deepskyblue",{r:0,g:191,b:255}],["dimgray",{r:105,g:105,b:105}],["dimgrey",{r:105,g:105,b:105}],["dodgerblue",{r:30,g:144,b:255}],["firebrick",{r:178,g:34,b:34}],["floralwhite",{r:255,g:250,b:240}],["forestgreen",{r:34,g:139,b:34}],["fuchsia",{r:255,g:0,b:255}],["gainsboro",{r:220,g:220,b:220}],["ghostwhite",{r:248,g:248,b:255}],["goldenrod",{r:218,g:165,b:32}],["gold",{r:255,g:215,b:0}],["gray",{r:128,g:128,b:128}],["green",{r:0,g:128,b:0}],["greenyellow",{r:173,g:255,b:47}],["grey",{r:128,g:128,b:128}],["honeydew",{r:240,g:255,b:240}],["hotpink",{r:255,g:105,b:180}],["indianred",{r:205,g:92,b:92}],["indigo",{r:75,g:0,b:130}],["ivory",{r:255,g:255,b:240}],["khaki",{r:240,g:230,b:140}],["lavenderblush",{r:255,g:240,b:245}],["lavender",{r:230,g:230,b:250}],["lawngreen",{r:124,g:252,b:0}],["lemonchiffon",{r:255,g:250,b:205}],["lightblue",{r:173,g:216,b:230}],["lightcoral",{r:240,g:128,b:128}],["lightcyan",{r:224,g:255,b:255}],["lightgoldenrodyellow",{r:250,g:250,b:210}],["lightgray",{r:211,g:211,b:211}],["lightgreen",{r:144,g:238,b:144}],["lightgrey",{r:211,g:211,b:211}],["lightpink",{r:255,g:182,b:193}],["lightsalmon",{r:255,g:160,b:122}],["lightseagreen",{r:32,g:178,b:170}],["lightskyblue",{r:135,g:206,b:250}],["lightslategray",{r:119,g:136,b:153}],["lightslategrey",{r:119,g:136,b:153}],["lightsteelblue",{r:176,g:196,b:222}],["lightyellow",{r:255,g:255,b:224}],["lime",{r:0,g:255,b:0}],["limegreen",{r:50,g:205,b:50}],["linen",{r:250,g:240,b:230}],["magenta",{r:255,g:0,b:255}],["maroon",{r:128,g:0,b:0}],["mediumaquamarine",{r:102,g:205,b:170}],["mediumblue",{r:0,g:0,b:205}],["mediumorchid",{r:186,g:85,b:211}],["mediumpurple",{r:147,g:112,b:219}],["mediumseagreen",{r:60,g:179,b:113}],["mediumslateblue",{r:123,g:104,b:238}],["mediumspringgreen",{r:0,g:250,b:154}],["mediumturquoise",{r:72,g:209,b:204}],["mediumvioletred",{r:199,g:21,b:133}],["midnightblue",{r:25,g:25,b:112}],["mintcream",{r:245,g:255,b:250}],["mistyrose",{r:255,g:228,b:225}],["moccasin",{r:255,g:228,b:181}],["navajowhite",{r:255,g:222,b:173}],["navy",{r:0,g:0,b:128}],["oldlace",{r:253,g:245,b:230}],["olive",{r:128,g:128,b:0}],["olivedrab",{r:107,g:142,b:35}],["orange",{r:255,g:165,b:0}],["orangered",{r:255,g:69,b:0}],["orchid",{r:218,g:112,b:214}],["palegoldenrod",{r:238,g:232,b:170}],["palegreen",{r:152,g:251,b:152}],["paleturquoise",{r:175,g:238,b:238}],["palevioletred",{r:219,g:112,b:147}],["papayawhip",{r:255,g:239,b:213}],["peachpuff",{r:255,g:218,b:185}],["peru",{r:205,g:133,b:63}],["pink",{r:255,g:192,b:203}],["plum",{r:221,g:160,b:221}],["powderblue",{r:176,g:224,b:230}],["purple",{r:128,g:0,b:128}],["rebeccapurple",{r:102,g:51,b:153}],["red",{r:255,g:0,b:0}],["rosybrown",{r:188,g:143,b:143}],["royalblue",{r:65,g:105,b:225}],["saddlebrown",{r:139,g:69,b:19}],["salmon",{r:250,g:128,b:114}],["sandybrown",{r:244,g:164,b:96}],["seagreen",{r:46,g:139,b:87}],["seashell",{r:255,g:245,b:238}],["sienna",{r:160,g:82,b:45}],["silver",{r:192,g:192,b:192}],["skyblue",{r:135,g:206,b:235}],["slateblue",{r:106,g:90,b:205}],["slategray",{r:112,g:128,b:144}],["slategrey",{r:112,g:128,b:144}],["snow",{r:255,g:250,b:250}],["springgreen",{r:0,g:255,b:127}],["steelblue",{r:70,g:130,b:180}],["tan",{r:210,g:180,b:140}],["teal",{r:0,g:128,b:128}],["thistle",{r:216,g:191,b:216}],["tomato",{r:255,g:99,b:71}],["turquoise",{r:64,g:224,b:208}],["violet",{r:238,g:130,b:238}],["wheat",{r:245,g:222,b:179}],["white",{r:255,g:255,b:255}],["whitesmoke",{r:245,g:245,b:245}],["yellow",{r:255,g:255,b:0}],["yellowgreen",{r:154,g:205,b:50}]],ne="deg|rad|grad|turn",ie="[-\\+]?\\d+%?",ae="[-\\+]?\\d*\\.\\d+%?",le=`[-\\+]?\\d*\\.?\\d+(?:${ne})?`,vt=`(?:${ae})|(?:${ie})`,Ot=`(?:${vt})|(?:${le}?)`,io="(?:[\\s|\\(\\s|\\s\\(\\s]+)?",ao="(?:[\\s|\\)\\s]+)?",ce="(?:[,|\\s]+)",lo="(?:[,|\\/\\s]*)?",nt=`${io}(${Ot})${ce}(${vt})${ce}(${vt})${lo}(${vt})?${ao}`,K={CSS_UNIT:new RegExp(Ot),ANGLES:ne,CSS_ANGLE:le,CSS_INTEGER:ie,CSS_NUMBER:ae,CSS_UNIT2:Ot,PERMISSIVE_MATCH:nt,hwb:new RegExp(`hwb${nt}`),rgb:new RegExp(`rgb(?:a)?${nt}`),hsl:new RegExp(`hsl(?:a)?${nt}`),hsv:new RegExp(`hsv(?:a)?${nt}`),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/},he=o=>Rt.includes(o),it=(o,t)=>o!==null&&typeof o=="object"&&Object.keys(t).every(e=>e in o),ge=o=>`${o}`.includes(".")&&parseFloat(o)===1,wt=o=>typeof o=="string"&&o.includes("%"),L=o=>!!K.CSS_UNIT.exec(`${o}`),ue=["rgb","hex","hsl","hsv","hwb"],be=o=>Rt.includes(o)||["#",...ue].some(t=>o.includes(t))?!1:mt.some(([t])=>o===t),T=(o,t)=>{let e=o;if(typeof o=="number"&&Math.min(o,0)===0&&Math.max(o,1)===1)return o;ge(o)&&(e="100%");const s=wt(e);return e=t===360?parseFloat(e):Math.min(t,Math.max(0,parseFloat(e))),s&&(e=e*t/100),Math.abs(e-t)<1e-6?1:(t===360?e=(e<0?e%t+t:e%t)/t:e=e%t/t,e)},Dt=o=>{let t=parseFloat(o);return(Number.isNaN(t)||t<0||t>1)&&(t=1),t},$t=o=>Math.min(1,Math.max(0,o)),G=o=>o.length===1?`0${o}`:String(o),pe=o=>{const[[,t]]=mt.filter(([e])=>e===o.toLowerCase());return t},A=o=>parseInt(o,16),Ft=o=>A(o)/255,de=o=>v(o*255).toString(16),fe=(o,t,e)=>{const s=Math.max(o,t,e),r=Math.min(o,t,e);let n=0,i=0;const a=(s+r)/2;if(s===r)i=0,n=0;else{const l=s-r;i=a>.5?l/(2-s-r):l/(s+r),s===o&&(n=(t-e)/l+(t<e?6:0)),s===t&&(n=(e-o)/l+2),s===e&&(n=(o-t)/l+4),n/=6}return{h:n,s:i,l:a}},kt=(o,t,e)=>{let s=e;return s<0&&(s+=1),s>1&&(s-=1),s<1/6?o+(t-o)*(6*s):s<1/2?t:s<2/3?o+(t-o)*(2/3-s)*6:o},at=(o,t,e)=>{let s=0,r=0,n=0;if(t===0)r=e,n=e,s=e;else if(e){const i=e<.5?e*(1+t):e+t-e*t,a=2*e-i;s=kt(a,i,o+1/3),r=kt(a,i,o),n=kt(a,i,o-1/3)}return{r:s,g:r,b:n}},me=(o,t,e)=>{let s=0,r=0;const n=Math.min(o,t,e),i=Math.max(o,t,e),a=1-i;if(i===n)return{h:0,w:n,b:a};o===n?(s=t-e,r=3):(s=t===n?e-o:o-t,r=t===n?5:1);const l=(r-s/(i-n))/6;return{h:l===1?0:l,w:n,b:a}},ve=(o,t,e)=>{if(t+e>=1){const i=t/(t+e);return{r:i,g:i,b:i}}let{r:s,g:r,b:n}=at(o,1,.5);return[s,r,n]=[s,r,n].map(i=>i*(1-t-e)+t),{r:s,g:r,b:n}},we=(o,t,e)=>{const s=Math.max(o,t,e),r=Math.min(o,t,e);let n=0;const i=s,a=s-r,l=s===0?0:a/s;return s===r?n=0:(o===s&&(n=(t-e)/a+(t<e?6:0)),t===s&&(n=(e-o)/a+2),e===s&&(n=(o-t)/a+4),n/=6),{h:n,s:l,v:i}},It=(o,t,e)=>{const s=o*6,r=t,n=e,i=Math.floor(s),a=s-i,l=n*(1-r),c=n*(1-a*r),h=n*(1-(1-a)*r),b=i%6,u=[n,c,l,l,h,n][b],d=[h,n,n,c,l,l][b],g=[l,l,h,n,n,c][b];return{r:u,g:d,b:g}},$e=(o,t,e,s)=>{const r=[G(v(o).toString(16)),G(v(t).toString(16)),G(v(e).toString(16))];return s&&r[0].charAt(0)===r[0].charAt(1)&&r[1].charAt(0)===r[1].charAt(1)&&r[2].charAt(0)===r[2].charAt(1)?r[0].charAt(0)+r[1].charAt(0)+r[2].charAt(0):r.join("")},Kt=(o,t,e,s,r)=>{const n=[G(v(o).toString(16)),G(v(t).toString(16)),G(v(e).toString(16)),G(de(s))];return r&&n[0].charAt(0)===n[0].charAt(1)&&n[1].charAt(0)===n[1].charAt(1)&&n[2].charAt(0)===n[2].charAt(1)&&n[3].charAt(0)===n[3].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0)+n[3].charAt(0):n.join("")},ke=o=>{const t=String(o).trim().toLowerCase();if(be(t))return Object.assign(pe(t),{a:1,format:"rgb",ok:!0});if(he(t))return{r:0,g:0,b:0,a:t==="transparent"?0:1,format:"rgb",ok:!0};let[,e,s,r,n]=K.rgb.exec(t)||[];return e&&s&&r?{r:e,g:s,b:r,a:n!==void 0?n:1,format:"rgb",ok:!0}:([,e,s,r,n]=K.hsl.exec(t)||[],e&&s&&r?{h:e,s,l:r,a:n!==void 0?n:1,format:"hsl",ok:!0}:([,e,s,r,n]=K.hsv.exec(t)||[],e&&s&&r?{h:e,s,v:r,a:n!==void 0?n:1,format:"hsv",ok:!0}:([,e,s,r,n]=K.hwb.exec(t)||[],e&&s&&r?{h:e,w:s,b:r,a:n!==void 0?n:1,format:"hwb",ok:!0}:([,e,s,r,n]=K.hex8.exec(t)||[],e&&s&&r&&n?{r:A(e),g:A(s),b:A(r),a:Ft(n),format:"hex",ok:!0}:([,e,s,r]=K.hex6.exec(t)||[],e&&s&&r?{r:A(e),g:A(s),b:A(r),a:1,format:"hex",ok:!0}:([,e,s,r,n]=K.hex4.exec(t)||[],e&&s&&r&&n?{r:A(e+e),g:A(s+s),b:A(r+r),a:Ft(n+n),format:"hex",ok:!0}:([,e,s,r]=K.hex3.exec(t)||[],e&&s&&r?{r:A(e+e),g:A(s+s),b:A(r+r),a:1,format:"hex",ok:!0}:{r:0,g:0,b:0,a:1,format:"rgb",ok:!o})))))))},ye=o=>{let t={r:0,g:0,b:0},e=o,s=1,r,n,i,a,l,c,h,b,u="rgb",d=!1;return(!e||typeof e=="string")&&(e=ke(e),d=e.ok),it(e,t)&&L(e.r)&&L(e.g)&&L(e.b)&&({r:h,g:b,b:l}=e,[h,b,l]=[h,b,l].map(g=>T(g,wt(g)?100:255)),t={r:h,g:b,b:l},u="format"in e?e.format:"rgb"),it(e,{h:0,s:0,v:0})&&L(e.h)&&L(e.s)&&L(e.v)&&({h:c,s:r,v:n}=e,c=T(c,360),r=T(r,100),n=T(n,100),t=It(c,r,n),u="hsv"),it(e,{h:0,s:0,l:0})&&L(e.h)&&L(e.s)&&L(e.l)&&({h:c,s:r,l:i}=e,c=T(c,360),r=T(r,100),i=T(i,100),t=at(c,r,i),u="hsl"),it(e,{h:0,w:0,b:0})&&L(e.h)&&L(e.w)&&L(e.b)&&({h:c,w:a,b:l}=e,c=T(c,360),a=T(a,100),l=T(l,100),t=ve(c,a,l),u="hwb"),L(e.a)&&(s=e.a,s=wt(s)||parseFloat(`${s}`)>1?T(s,100):s),{r:t.r,g:t.g,b:t.b,a:Dt(s),format:u,ok:d}},co="1.0.8";class k{static matchers=K;static isOnePointZero=ge;static isPercentage=wt;static isValidCSSUnit=L;static isNonColor=he;static isColorName=be;static isColorType=it;static pad2=G;static clamp01=$t;static bound01=T;static boundAlpha=Dt;static getRGBFromName=pe;static convertHexToDecimal=Ft;static convertDecimalToHex=de;static rgbToHsl=fe;static rgbToHex=$e;static rgbToHsv=we;static rgbToHwb=me;static rgbaToHex=Kt;static hslToRgb=It;static hsvToRgb=It;static hueToRgb=kt;static hwbToRgb=ve;static parseIntFromHex=A;static stringInputToObject=ke;static inputToRGB=ye;static roundPart=v;static webColors=mt;static nonColors=Rt;static version=co;r;g;b;a;format;ok;originalInput;constructor(t,e){const s=e&&ue.includes(e)?e:"",{r,g:n,b:i,a,ok:l,format:c}=ye(t);this.originalInput=t,this.r=r,this.g=n,this.b=i,this.a=a,this.ok=l,this.format=s||c}get isValid(){return this.ok}get isDark(){return this.brightness<120}get luminance(){const{r:t,g:e,b:s}=this;let r=0,n=0,i=0;return t<=.03928?r=t/12.92:r=((t+.055)/1.055)**2.4,e<=.03928?n=e/12.92:n=((e+.055)/1.055)**2.4,s<=.03928?i=s/12.92:i=((s+.055)/1.055)**2.4,.2126*r+.7152*n+.0722*i}get brightness(){const{r:t,g:e,b:s}=this.toRgb();return(t*299+e*587+s*114)/1e3}get name(){const{r:t,g:e,b:s}=this.toRgb(),[r]=mt.map(([n,i])=>{const a=(((i.r-t)*.3)**2+((i.g-e)*.6)**2+((i.b-s)*.1)**2)**.5;return[n,a]}).find(([,n],i,a)=>n===Math.min(...a.map(([,l])=>l)));return r}toRgb(){let{r:t,g:e,b:s,a:r}=this;return[t,e,s]=[t,e,s].map(n=>v(n*255*100)/100),r=v(r*100)/100,{r:t,g:e,b:s,a:r}}toRgbString(){const{r:t,g:e,b:s,a:r}=this.toRgb(),[n,i,a]=[t,e,s].map(v);return r===1?`rgb(${n}, ${i}, ${a})`:`rgba(${n}, ${i}, ${a}, ${r})`}toRgbCSS4String(){const{r:t,g:e,b:s,a:r}=this.toRgb(),[n,i,a]=[t,e,s].map(v),l=r===1?"":` / ${v(r*100)}%`;return`rgb(${n} ${i} ${a}${l})`}toHex(t){const{r:e,g:s,b:r,a:n}=this.toRgb();return n===1?$e(e,s,r,t):Kt(e,s,r,n,t)}toHexString(t){return`#${this.toHex(t)}`}toHex8(t){const{r:e,g:s,b:r,a:n}=this.toRgb();return Kt(e,s,r,n,t)}toHex8String(t){return`#${this.toHex8(t)}`}toHsv(){const{r:t,g:e,b:s,a:r}=this,{h:n,s:i,v:a}=we(t,e,s);return{h:n,s:i,v:a,a:r}}toHsl(){const{r:t,g:e,b:s,a:r}=this,{h:n,s:i,l:a}=fe(t,e,s);return{h:n,s:i,l:a,a:r}}toHslString(){let{h:t,s:e,l:s,a:r}=this.toHsl();return t=v(t*360),e=v(e*100),s=v(s*100),r=v(r*100)/100,r===1?`hsl(${t}, ${e}%, ${s}%)`:`hsla(${t}, ${e}%, ${s}%, ${r})`}toHslCSS4String(){let{h:t,s:e,l:s,a:r}=this.toHsl();t=v(t*360),e=v(e*100),s=v(s*100),r=v(r*100);const n=r<100?` / ${v(r)}%`:"";return`hsl(${t}deg ${e}% ${s}%${n})`}toHwb(){const{r:t,g:e,b:s,a:r}=this,{h:n,w:i,b:a}=me(t,e,s);return{h:n,w:i,b:a,a:r}}toHwbString(){let{h:t,w:e,b:s,a:r}=this.toHwb();t=v(t*360),e=v(e*100),s=v(s*100),r=v(r*100);const n=r<100?` / ${v(r)}%`:"";return`hwb(${t}deg ${e}% ${s}%${n})`}setAlpha(t){return typeof t!="number"?this:(this.a=Dt(t),this)}saturate(t){if(typeof t!="number")return this;const{h:e,s,l:r}=this.toHsl(),{r:n,g:i,b:a}=at(e,$t(s+t/100),r);return Object.assign(this,{r:n,g:i,b:a}),this}desaturate(t){return typeof t=="number"?this.saturate(-t):this}greyscale(){return this.saturate(-100)}lighten(t){if(typeof t!="number")return this;const{h:e,s,l:r}=this.toHsl(),{r:n,g:i,b:a}=at(e,s,$t(r+t/100));return Object.assign(this,{r:n,g:i,b:a}),this}darken(t){return typeof t=="number"?this.lighten(-t):this}spin(t){if(typeof t!="number")return this;const{h:e,s,l:r}=this.toHsl(),{r:n,g:i,b:a}=at($t((e*360+t)%360/360),s,r);return Object.assign(this,{r:n,g:i,b:a}),this}clone(){return new k(this)}toString(t){const{format:e}=this;return e==="hex"?this.toHexString(t):e==="hsl"?this.toHslString():e==="hwb"?this.toHwbString():this.toRgbString()}}class Vt{static Color=k;hue;hueSteps;lightSteps;saturation;colors;constructor(...t){let e=0,s=12,r=10,n=[.5],i=100;if(t.length===4)[e,s,r,i]=t;else if(t.length===3)[e,s,r]=t;else if(t.length===2&&([s,r]=t,[s,r].some(g=>g<1)))throw TypeError("ColorPalette: the two minimum arguments must be numbers higher than 0.");const a=[],l=360/s,c=k.roundPart((r-(r%2?1:0))/2),h=[.25,.2,.15,.11,.09,.075],b=[[1,2,3],[4,5],[6,7],[8,9],[10,11],[12,13]],u=b.find(g=>g.includes(r)),d=u?h[b.indexOf(u)]:100/(r+(r%2?0:1))/100;for(let g=1;g<c+1;g+=1)n=[...n,.5+d*g];for(let g=1;g<r-c;g+=1)n=[.5-d*g,...n];for(let g=0;g<s;g+=1){const p=(e+g*l)%360/360;n.forEach(f=>{const w=new k({h:p,s:1,l:f});a.push(i<100?w.saturate(i-100):w)})}this.hue=e,this.hueSteps=s,this.lightSteps=r,this.saturation=i,this.colors=a}}const Bt={pickerLabel:"Colour Picker",appearanceLabel:"Colour Appearance",valueLabel:"Colour Value",toggleLabel:"Select Colour",presetsLabel:"Colour Presets",defaultsLabel:"Colour Defaults",formatLabel:"Format",alphaLabel:"Alpha",hexLabel:"Hexadecimal",hueLabel:"Hue",whitenessLabel:"Whiteness",blacknessLabel:"Blackness",saturationLabel:"Saturation",lightnessLabel:"Lightness",redLabel:"Red",greenLabel:"Green",blueLabel:"Blue"},lt=["white","black","grey","red","orange","brown","gold","olive","yellow","lime","green","teal","cyan","blue","violet","magenta","pink"],xe=o=>{if(!B(o))return!1;try{JSON.parse(o)}catch{return!1}return!0},jt="v-hidden",ho=o=>{const{format:t,id:e,componentLabels:s}=o,r=x({tagName:"div",className:`color-form ${t}`});let n=["hex"];return t==="rgb"?n=["red","green","blue","alpha"]:t==="hsl"?n=["hue","saturation","lightness","alpha"]:t==="hwb"&&(n=["hue","whiteness","blackness","alpha"]),n.forEach(i=>{const[a]=t==="hex"?["#"]:te(i).split(""),l=`color_${t}_${i}_${e}`,c=s[`${i}Label`],h=x({tagName:"label"});m(h,"for",l),h.append(x({tagName:"span",ariaHidden:"true",innerText:`${a}:`}),x({tagName:"span",className:jt,innerText:c}));const b=x({tagName:"input",id:l,type:t==="hex"?"text":"number",value:i==="alpha"?"100":"0",className:`color-input ${i}`,autocomplete:"off",spellcheck:!1});let u="100",d="1";i!=="alpha"&&(t==="rgb"?(u="255",d="1"):i==="hue"&&(u="360",d="1")),I(b,{min:"0",max:u,step:d}),r.append(h,b)}),r},go=o=>{const{format:t,componentLabels:e}=o,{hueLabel:s,alphaLabel:r,lightnessLabel:n,saturationLabel:i,whitenessLabel:a,blacknessLabel:l}=e,c=t==="hsl"?360:100,h=t==="hsl"?100:360,b=100;let u=t==="hsl"?`${s} & ${n}`:`${n} & ${i}`;u=t==="hwb"?`${a} & ${l}`:u;const d=t==="hsl"?`${i}`:`${s}`,g=x({tagName:"div",className:`color-controls ${t}`}),p="color-pointer",f="color-slider";return[{i:1,c:p,l:u,min:0,max:c},{i:2,c:f,l:d,min:0,max:h},{i:3,c:f,l:r,min:0,max:b}].forEach($=>{const{i:P,c:H,l:S,min:C,max:R}=$,E=x({tagName:"div",className:"color-control",role:"presentation"});E.append(x({tagName:"div",className:`visual-control visual-control${P}`}));const N=x({tagName:"div",className:`${H} knob`,ariaLive:"polite",ariaLabel:S,role:"slider",tabIndex:0,ariaValueMin:`${C}`,ariaValueMax:`${R}`});E.append(N),g.append(E)}),g},Pe=(o,t,e)=>{const{input:s,format:r,componentLabels:n}=o,{defaultsLabel:i,presetsLabel:a}=n,l=e==="color-options",c=t instanceof Vt,h=l?a:i,b=c?t.colors:t,u=b.length,{lightSteps:d}=c?t:{lightSteps:null},g=d||[9,10].find(N=>u>=N*2&&!(u%N))||5,p=l&&u>g;let f=2;f=p&&u>g*2?3:f,f=p&&u>g*3?4:f,f=p&&u>g*4?5:f;const w=f-(u<=g*3?1:2),$=p&&u>w*g;let P=e;P+=$?" scrollable":"",P+=p?" multiline":"";const H=p?"1px":"0.25rem";let S=p?1.75:2;S=g>5&&p?1.5:S;const C=`${w*S}rem`,R=`calc(${f} * ${S}rem + ${f-1} * ${H})`,E=x({tagName:"ul",className:P,role:"listbox",ariaLabel:h});return $&&D(E,{"--grid-item-size":`${S}rem`,"--grid-fit":`${g}`,"--grid-gap":H,"--grid-height":C,"--grid-hover-height":R}),b.forEach(N=>{let[V,ct]=typeof N=="string"?N.trim().split(":"):[];N instanceof k&&(V=N.toHexString(),ct=V);const Ee=new k(N instanceof k?N:V,r).toString()===pt(s,"value"),Gt=x({tagName:"li",className:`color-option${Ee?" active":""}`,innerText:`${ct||V}`,tabIndex:0,role:"option",ariaSelected:Ee?"true":"false"});m(Gt,"data-value",`${V}`),l&&D(Gt,{backgroundColor:V}),E.append(Gt)}),E},uo=o=>{const{input:t,parent:e,format:s,id:r,componentLabels:n,colorKeywords:i,colorPresets:a}=o,l=pt(t,"value")||"#fff",{nonColors:c}=k,{toggleLabel:h,pickerLabel:b,formatLabel:u,hexLabel:d}=n,g=c.includes(l)?"#fff":l;o.color=new k(g,s);const p=s==="hex"?d:te(s),f=x({id:`picker-btn-${r}`,tagName:"button",type:"button",className:"picker-toggle btn-appearance",ariaExpanded:"false",ariaHasPopup:"true"});f.append(x({tagName:"span",className:jt,innerText:`${b}. ${u}: ${p}`}));const w=x({tagName:"div",className:"color-dropdown picker",role:"group",ariaLabelledBy:`picker-btn-${r}`}),$=go(o),P=ho(o);if(w.append($,P),t.before(f),e.append(w),i||a){const H=x({tagName:"div",className:"color-dropdown scrollable menu"});a&&H.append(Pe(o,a,"color-options")),i&&i.length&&H.append(Pe(o,i,"color-defaults"));const S=x({tagName:"button",type:"button",className:"menu-toggle btn-appearance",tabIndex:-1,ariaExpanded:"false",ariaHasPopup:"true"}),C=encodeURI("http://www.w3.org/2000/svg"),R=Nt(C,{tagName:"svg"});m(R,"xmlns",C),m(R,"viewBox","0 0 512 512"),m(R,Me,"true");const E=Nt(C,{tagName:"path"});m(E,"d","M98,158l157,156L411,158l27,27L255,368L71,185L98,158z"),m(E,"fill","#fff"),R.append(E),S.append(x({tagName:"span",className:jt,innerText:`${h}`}),R),e.append(S,H)}i&&c.includes(l)&&(o.value=l),m(t,W,"-1")},bo="2.0.0-alpha10",Y="color-picker",po=`[data-function="${Y}"]`,Se=`.${Y}`,fo={componentLabels:Bt,colorLabels:lt,format:"rgb",colorPresets:!1,colorKeywords:!1},{roundPart:y,nonColors:yt}=k,mo=o=>Ze(o,Y),vo=o=>new Ne(o),Ce=(o,t)=>{const e=t?Ct:Lt,{input:s,pickerToggle:r,menuToggle:n}=o;e(s,Oe,o.showPicker),e(r,St,o.togglePicker),n&&e(n,St,o.toggleMenu)},Le=(o,t)=>{const e=t?Ct:Lt,{input:s,colorMenu:r,parent:n}=o,i=F(s),a=no(i);e(o.controls,Ie,o.pointerDown),o.controlKnobs.forEach(l=>e(l,_t,o.handleKnobs)),e(a,Be,o.handleScroll),e(a,Ve,o.update),[s,...o.inputs].forEach(l=>e(l,Te,o.changeHandler)),r&&(e(r,St,o.menuClickHandler),e(r,_t,o.menuKeyHandler)),e(i,zt,o.pointerMove),e(i,Ke,o.pointerUp),e(n,De,o.handleFocusOut),e(i,Fe,o.handleDismiss)},Ae=o=>{Qe(o.input,new CustomEvent("colorpicker.change"))},He=o=>{o&&["bottom","top"].forEach(t=>O(o,t))},qt=(o,t)=>{const{colorPicker:e,colorMenu:s,menuToggle:r,pickerToggle:n,parent:i}=o,a=t===e,l=a?s:e,c=a?r:n,h=a?n:r;M(i,"open")||q(i,"open"),l&&(O(l,"show"),He(l)),q(t,"bottom"),so(t),q(t,"show"),a&&o.update(),o.isOpen||(Le(o,!0),o.updateDropdownPosition(),o.isOpen=!0,m(o.input,W,"0"),r&&m(r,W,"0")),m(h,xt,"true"),c&&m(c,xt,"false")};class Ne{static Color=k;static ColorPalette=Vt;static getInstance=mo;static init=vo;static selector=po;static roundPart=y;static setElementStyle=D;static setAttribute=m;static getBoundingClientRect=ft;static version=bo;static colorNames=lt;static colorPickerLabels=Bt;id;input;color;format="rgb";parent;dragElement;isOpen=!1;controlPositions;colorLabels=Qt(lt.map(t=>[t,t]));colorKeywords;colorPresets;componentLabels;pickerToggle;menuToggle;colorPicker;colorMenu;controls;inputs;controlKnobs;visuals;constructor(t,e){const s=z(t);if(typeof t>"u")throw new TypeError("ColorPicker target not specified.");if(B(t)&&!s)throw new TypeError(`ColorPicker target "${t}" cannot be found.`);this.input=s;const r=re(s,Se);if(!r)throw new TypeError("ColorPicker requires a specific markup to work.");this.parent=r,this.id=se(s,Y),this.dragElement=void 0,this.isOpen=!1,this.controlPositions={c1x:0,c1y:0,c2y:0,c3y:0},this.colorKeywords=!1,this.colorPresets=!1;const{format:n,componentLabels:i,colorLabels:a,colorKeywords:l,colorPresets:c}=oo(s,fo,e||{});let h=lt;Tt(a)&&a.length===17?h=a:B(a)&&a.split(",").length===17&&(h=a.split(",")),I(this.colorLabels,Qt(h.map((p,f)=>[lt[f],p])));const b=B(i)&&xe(i)?JSON.parse(i):i;if(this.componentLabels=I({...Bt},b),this.color=new k(s.value||"#fff",n),this.format=n,Tt(l)&&l.length?this.colorKeywords=l:B(l)&&l.length&&(this.colorKeywords=l.split(",").map(p=>p.trim())),Tt(c)&&c.length)this.colorPresets=c;else if(c&&xe(c)){const{hue:p,hueSteps:f,lightSteps:w,saturation:$}=JSON.parse(c);this.colorPresets=new Vt(p,f,w,$)}else B(c)&&(this.colorPresets=c.split(",").map(p=>p.trim()));uo(this);const[u,d]=rt("color-dropdown",r);this.pickerToggle=z(".picker-toggle",r),this.menuToggle=z(".menu-toggle",r),this.colorPicker=u,this.colorMenu=d,this.inputs=[...rt("color-input",r)];const[g]=rt("color-controls",r);this.controls=g,this.controlKnobs=[...rt("knob",g)],this.visuals=[...rt("visual-control",g)],this.update(),Ce(this,!0),st.set(s,Y,this)}get value(){return this.input.value}set value(t){this.input.value=t}get hasNonColor(){return this.colorKeywords instanceof Array&&this.colorKeywords.some(t=>yt.includes(t))}get hex(){return this.color.toHex(!0)}get hsv(){return this.color.toHsv()}get hsl(){return this.color.toHsl()}get hwb(){return this.color.toHwb()}get rgb(){return this.color.toRgb()}get brightness(){return this.color.brightness}get luminance(){return this.color.luminance}get isDark(){const{color:t,brightness:e}=this;return e<120&&t.a>.33}get isValid(){const t=this.input.value;return t!==""&&new k(t).isValid}get appearance(){const{colorLabels:t,hsl:e,hsv:s,format:r}=this,n=y(e.h*360),i=r==="hsl"?e.s:s.s,a=y(i*100),l=y(e.l*100),c=s.v*100;let h="black";if(l===100&&a===0)h=t.white;else if(l===0)h=t.black;else if(a===0)h=t.grey;else if(n<15||n>=345)h=t.red;else if(n>=15&&n<45)h=c>80&&a>80?t.orange:t.brown;else if(n>=45&&n<75){const b=n>46&&n<54&&c<80&&a>90,u=n>=54&&n<75&&c<80;h=b?t.gold:t.yellow,h=u?t.olive:h}else n>=75&&n<155?h=c<68?t.green:t.lime:n>=155&&n<175?h=t.teal:n>=175&&n<195?h=t.cyan:n>=195&&n<255?h=t.blue:n>=255&&n<270?h=t.violet:n>=270&&n<295?h=t.magenta:n>=295&&n<345&&(h=t.pink);return h}updateVisuals(){const{controlPositions:t,visuals:e}=this,[s,r,n]=e,{offsetHeight:i}=s,a=t.c2y/i,{r:l,g:c,b:h}=new k({h:a,s:1,l:.5}).toRgb(),b="linear-gradient(rgb(255,255,255) 0%, rgb(255,255,255) 100%)",u=1-t.c3y/i,d=y(u*100)/100,g=new k({h:a,s:1,l:.5,a:u}).toRgbString(),p=`linear-gradient(
2
2
  rgb(255,0,0) 0%, rgb(255,255,0) 16.67%,
3
3
  rgb(0,255,0) 33.33%, rgb(0,255,255) 50%,
4
4
  rgb(0,0,255) 66.67%, rgb(255,0,255) 83.33%,
5
- rgb(255,0,0) 100%)`;O(s,{background:`linear-gradient(rgba(0,0,0,0) 0%, rgba(0,0,0,${d}) 100%),
5
+ rgb(255,0,0) 100%)`;D(s,{background:`linear-gradient(rgba(0,0,0,0) 0%, rgba(0,0,0,${d}) 100%),
6
6
  linear-gradient(to right, rgba(255,255,255,${d}) 0%, ${g} 100%),
7
- ${b}`}),O(n,{background:p}),O(r,{background:`linear-gradient(rgba(${l},${c},${h},1) 0%,rgba(${l},${c},${h},0) 100%)`})}handleFocusOut({relatedTarget:t}){t&&!this.parent.contains(t)&&this.hide(!0)}handleDismiss({code:t}){this.isOpen&&t===Ge&&this.hide()}handleScroll(t){const{activeElement:e}=F(this.input);this.updateDropdownPosition(),([Wt,qe].includes(t.type)&&this.dragElement||e&&this.controlKnobs.includes(e))&&(t.stopPropagation(),t.preventDefault())}menuKeyHandler(t){const{target:e,code:s}=t,{previousElementSibling:n,nextElementSibling:r,parentElement:i}=e,a=i&&M(i,"color-options"),l=i?[...i.children]:[],c=a&&Nt(i,"grid-template-columns").split(" ").length,h=l.indexOf(e),b=h>-1&&c&&l[h-c],u=h>-1&&c&&l[h+c];[j,ot,Xt].includes(s)&&t.preventDefault(),a?b&&s===ot?U(b):u&&s===j?U(u):n&&s===ht?U(n):r&&s===G&&U(r):n&&[ht,ot].includes(s)?U(n):r&&[G,j].includes(s)&&U(r),[ze,Xt].includes(s)&&this.menuClickHandler(t)}menuClickHandler(t){const{target:e}=t,{colorMenu:s}=this,n=(pt(e,"data-value")||"").trim();if(!n.length)return;const r=_("li.active",s);let i=n;i=yt.includes(i)?"white":i,i=i==="transparent"?"rgba(0,0,0,0)":i;const{r:a,g:l,b:c,a:h}=new k(i);B(this.color,{r:a,g:l,b:c,a:h}),this.update(),r!==e&&(r&&(D(r,"active"),Lt(r,St)),q(e,"active"),m(e,St,"true"),yt.includes(n)&&(this.value=n),He(this))}pointerDown(t){const{target:e,pageX:s,pageY:n}=t,{colorMenu:r,visuals:i,controlKnobs:a}=this,[l,c,h]=i,[b,u,d]=a,g=a.includes(e)?e.previousElementSibling:e,p=ft(g),f=Et(l),w=s-f.scrollLeft-p.left,$=n-f.scrollTop-p.top;if(e===l||e===b?(this.dragElement=g,this.changeControl1(w,$)):e===c||e===u?(this.dragElement=g,this.changeControl2($)):(e===h||e===d)&&(this.dragElement=g,this.changeAlpha($)),r){const P=_("li.active",r);P&&(D(P,"active"),Lt(P,St))}t.preventDefault()}pointerUp({target:t}){const{parent:e}=this,s=F(e),n=_(`${Ce}.open`,s)!==null,r=s.getSelection();!this.dragElement&&(!r||!r.toString().length)&&!e.contains(t)&&this.hide(n),this.dragElement=void 0}pointerMove(t){const{dragElement:e,visuals:s}=this,[n,r,i]=s,{pageX:a,pageY:l}=t;if(!e)return;const c=ft(e),h=Et(n),b=a-h.scrollLeft-c.left,u=l-h.scrollTop-c.top;e===n&&this.changeControl1(b,u),e===r&&this.changeControl2(u),e===i&&this.changeAlpha(u)}handleKnobs(t){const{target:e,code:s}=t;if(![ot,j,ht,G].includes(s))return;t.preventDefault();const{controlKnobs:n,visuals:r}=this,{offsetWidth:i,offsetHeight:a}=r[0],[l,c,h]=n,{activeElement:b}=F(l),u=n.find(g=>g===b),d=a/360;if(u){let g=0,p=0;if(e===l){const f=i/100;[ht,G].includes(s)?this.controlPositions.c1x+=s===G?f:-f:[ot,j].includes(s)&&(this.controlPositions.c1y+=s===j?d:-d),g=this.controlPositions.c1x,p=this.controlPositions.c1y,this.changeControl1(g,p)}else e===c?(this.controlPositions.c2y+=[j,G].includes(s)?d:-d,p=this.controlPositions.c2y,this.changeControl2(p)):e===h&&(this.controlPositions.c3y+=[j,G].includes(s)?d:-d,p=this.controlPositions.c3y,this.changeAlpha(p));this.handleScroll(t)}}changeHandler(){let t;const{inputs:e,format:s,value:n,input:r,controlPositions:i,visuals:a}=this,{activeElement:l}=F(r),{offsetHeight:c}=a[0],[h,,,b]=e,[u,d,g,p]=s==="rgb"?e.map($=>parseFloat($.value)/($===b?100:1)):e.map($=>parseFloat($.value)/($!==h?100:360)),f=this.hasNonColor&&yt.includes(n),w=b?p:1-i.c3y/c;if(l===r||l&&e.includes(l)){l===r?f?t=n==="transparent"?"rgba(0,0,0,0)":"rgb(0,0,0)":t=n:s==="hex"?t=h.value:s==="hsl"?t={h:u,s:d,l:g,a:w}:s==="hwb"?t={h:u,w:d,b:g,a:w}:t={r:u,g:d,b:g,a:w};const{r:$,g:P,b:H,a:S}=new k(t);B(this.color,{r:$,g:P,b:H,a:S}),this.setControlPositions(),this.updateAppearance(),this.updateInputs(),this.updateControls(),this.updateVisuals(),l===r&&f&&(this.value=n)}}changeControl1(t,e){let[s,n]=[0,0];const{controlPositions:r,visuals:i}=this,{offsetHeight:a,offsetWidth:l}=i[0];t>l?s=l:t>=0&&(s=t),e>a?n=a:e>=0&&(n=e);const c=r.c2y/a,h=s/l,b=1-n/a,u=1-r.c3y/a,{r:d,g,b:p,a:f}=new k({h:c,s:h,v:b,a:u});B(this.color,{r:d,g,b:p,a:f}),this.controlPositions.c1x=s,this.controlPositions.c1y=n,this.updateAppearance(),this.updateInputs(),this.updateControls(),this.updateVisuals()}changeControl2(t){const{controlPositions:e,visuals:s}=this,{offsetHeight:n,offsetWidth:r}=s[0];let i=0;t>n?i=n:t>=0&&(i=t);const a=i/n,l=e.c1x/r,c=1-e.c1y/n,h=1-e.c3y/n,{r:b,g:u,b:d,a:g}=new k({h:a,s:l,v:c,a:h});B(this.color,{r:b,g:u,b:d,a:g}),this.controlPositions.c2y=i,this.updateAppearance(),this.updateInputs(),this.updateControls(),this.updateVisuals()}changeAlpha(t){const{visuals:e}=this,{offsetHeight:s}=e[0];let n=0;t>s?n=s:t>=0&&(n=t);const r=1-n/s;this.color.setAlpha(r),this.controlPositions.c3y=n,this.updateAppearance(),this.updateInputs(),this.updateControls(),this.updateVisuals()}update(){this.updateDropdownPosition(),this.updateAppearance(),this.setControlPositions(),this.updateInputs(!0),this.updateControls(),this.updateVisuals()}updateDropdownPosition(){const{input:t,colorPicker:e,colorMenu:s}=this,n=ft(t),{top:r,bottom:i}=n,{offsetHeight:a}=t,l=Et(t).clientHeight,h=M(e,"show")?e:s;if(!h)return;const{offsetHeight:b}=h,u=l-i,d=r,g=r+b+a>l,p=r-b<0;(M(h,"bottom")||!p)&&u<d&&g?(D(h,"bottom"),q(h,"top")):(D(h,"top"),q(h,"bottom"))}setControlPositions(){const{visuals:t,color:e,hsv:s}=this,{offsetHeight:n,offsetWidth:r}=t[0],i=e.a,a=s.h,l=s.s,c=s.v;this.controlPositions.c1x=l*r,this.controlPositions.c1y=(1-c)*n,this.controlPositions.c2y=a*n,this.controlPositions.c3y=(1-i)*n}updateAppearance(){const{componentLabels:t,color:e,parent:s,hsv:n,hex:r,format:i,controlKnobs:a}=this,{appearanceLabel:l,hexLabel:c,valueLabel:h}=t;let{r:b,g:u,b:d}=e.toRgb();const[g,p,f]=a,w=y(n.h*360),$=e.a,P=y(n.s*100),H=y(n.v*100),S=this.appearance;let C=`${c} ${r.split("").join(" ")}`;if(i==="hwb"){const{hwb:N}=this,K=y(N.w*100),ct=y(N.b*100);C=`HWB: ${w}°, ${K}%, ${ct}%`,m(g,et,`${K}% & ${ct}%`),m(g,tt,`${K}`),m(p,Ut,`${h}: ${C}. ${l}: ${S}.`),m(p,et,`${w}%`),m(p,tt,`${w}`)}else[b,u,d]=[b,u,d].map(y),C=i==="hsl"?`HSL: ${w}°, ${P}%, ${H}%`:C,C=i==="rgb"?`RGB: ${b}, ${u}, ${d}`:C,m(g,et,`${H}% & ${P}%`),m(g,tt,`${H}`),m(p,Ut,`${h}: ${C}. ${l}: ${S}.`),m(p,et,`${w}°`),m(p,tt,`${w}`);const R=y($*100);m(f,et,`${R}%`),m(f,tt,`${R}`);const E=e.toString();O(this.input,{backgroundColor:E}),this.isDark?(M(s,"txt-light")&&D(s,"txt-light"),M(s,"txt-dark")||q(s,"txt-dark")):(M(s,"txt-dark")&&D(s,"txt-dark"),M(s,"txt-light")||q(s,"txt-light"))}updateControls(){const{controlKnobs:t,controlPositions:e}=this;let{c1x:s,c1y:n,c2y:r,c3y:i}=e;const[a,l,c]=t;[s,n,r,i]=[s,n,r,i].map(y),O(a,{transform:`translate3d(${s-4}px,${n-4}px,0)`}),O(l,{transform:`translate3d(0,${r-4}px,0)`}),O(c,{transform:`translate3d(0,${i-4}px,0)`})}updateInputs(t){const{value:e,format:s,inputs:n,color:r,hsl:i}=this,[a,l,c,h]=n,b=y(r.a*100),u=y(i.h*360);let d=r.toString();if(s==="hex")d=this.color.toHexString(!0),a.value=this.hex;else if(s==="hsl"){const g=y(i.l*100),p=y(i.s*100);d=this.color.toHslString(),a.value=`${u}`,l.value=`${p}`,c.value=`${g}`,h.value=`${b}`}else if(s==="hwb"){const{w:g,b:p}=this.hwb,f=y(g*100),w=y(p*100);d=this.color.toHwbString(),a.value=`${u}`,l.value=`${f}`,c.value=`${w}`,h.value=`${b}`}else if(s==="rgb"){let{r:g,g:p,b:f}=this.rgb;[g,p,f]=[g,p,f].map(y),d=this.color.toRgbString(),a.value=`${g}`,l.value=`${p}`,c.value=`${f}`,h.value=`${b}`}this.value=d,!t&&d!==e&&He(this)}togglePicker(t){t&&t.preventDefault();const{colorPicker:e}=this;this.isOpen&&M(e,"show")?this.hide(!0):jt(this,e)}showPicker(){const{colorPicker:t}=this;["top","bottom"].some(e=>M(t,e))||jt(this,t)}toggleMenu(t){t&&t.preventDefault();const{colorMenu:e}=this;this.isOpen&&M(e,"show")?this.hide(!0):jt(this,e)}hide(t){if(this.isOpen){const{pickerToggle:e,menuToggle:s,colorPicker:n,colorMenu:r,parent:i,input:a}=this,l=M(n,"show"),c=l?n:r,h=l?e:s,b=c&&so(c);this.value=this.color.toString(!0),c&&(D(c,"show"),m(h,Pt,"false"),setTimeout(()=>{Ne(c),_(".show",i)||(D(i,"open"),Ae(this),this.isOpen=!1)},b)),t||U(e),m(a,X,"-1"),h===s&&m(s,X,"-1")}}dispose(){const{input:t,parent:e}=this;this.hide(!0),Le(this),[...e.children].forEach(s=>{s!==t&&s.remove()}),Lt(t,X),O(t,{backgroundColor:""}),["txt-light","txt-dark"].forEach(s=>D(e,s)),nt.remove(t,Q)}}return Ee}();
7
+ ${b}`}),D(r,{background:p}),D(n,{background:`linear-gradient(rgba(${l},${c},${h},1) 0%,rgba(${l},${c},${h},0) 100%)`})}handleFocusOut=({relatedTarget:t})=>{t&&!this.parent.contains(t)&&this.hide(!0)};handleDismiss=({code:t})=>{this.isOpen&&t===Ge&&this.hide()};handleScroll=t=>{const{activeElement:e}=F(this.input);this.updateDropdownPosition(),([zt,je].includes(t.type)&&this.dragElement||e&&this.controlKnobs.includes(e))&&(t.stopPropagation(),t.preventDefault())};menuKeyHandler=t=>{const{target:e,code:s}=t,{previousElementSibling:r,nextElementSibling:n,parentElement:i}=e,a=i&&M(i,"color-options"),l=i?[...i.children]:[],c=a&&Et(i,"grid-template-columns").split(" ").length,h=l.indexOf(e),b=h>-1&&c&&l[h-c],u=h>-1&&c&&l[h+c];[j,et,Wt].includes(s)&&t.preventDefault(),a?b&&s===et?_(b):u&&s===j?_(u):r&&s===ht?_(r):n&&s===U&&_(n):r&&[ht,et].includes(s)?_(r):n&&[U,j].includes(s)&&_(n),[qe,Wt].includes(s)&&this.menuClickHandler(t)};menuClickHandler=t=>{const{target:e}=t,{colorMenu:s}=this,r=(pt(e,"data-value")||"").trim();if(!r.length)return;const n=z("li.active",s);let i=r;i=yt.includes(i)?"white":i,i=i==="transparent"?"rgba(0,0,0,0)":i;const{r:a,g:l,b:c,a:h}=new k(i);I(this.color,{r:a,g:l,b:c,a:h}),this.update(),n!==e&&(n&&(O(n,"active"),At(n,Pt)),q(e,"active"),m(e,Pt,"true"),yt.includes(r)&&(this.value=r),Ae(this))};pointerDown=t=>{if(t.button!==0)return;const{target:e,pageX:s,pageY:r}=t,{colorMenu:n,visuals:i,controlKnobs:a}=this,[l,c,h]=i,[b,u,d]=a,g=a.includes(e)?e.previousElementSibling:e,p=ft(g),f=Mt(l),w=s-f.scrollLeft-p.left,$=r-f.scrollTop-p.top;if(e===l||e===b?(this.dragElement=g,this.changeControl1(w,$)):e===c||e===u?(this.dragElement=g,this.changeControl2($)):(e===h||e===d)&&(this.dragElement=g,this.changeAlpha($)),n){const P=z("li.active",n);P&&(O(P,"active"),At(P,Pt))}t.preventDefault()};pointerUp=({target:t})=>{const{parent:e}=this,s=F(e),r=z(`${Se}.open`,s)!==null,n=s.getSelection();!this.dragElement&&(!n||!n.toString().length)&&!e.contains(t)&&this.hide(r),this.dragElement=void 0};pointerMove=t=>{const{dragElement:e,visuals:s}=this,[r,n,i]=s,{pageX:a,pageY:l}=t;if(!e)return;const c=ft(e),h=Mt(r),b=a-h.scrollLeft-c.left,u=l-h.scrollTop-c.top;e===r&&this.changeControl1(b,u),e===n&&this.changeControl2(u),e===i&&this.changeAlpha(u)};handleKnobs=t=>{const{target:e,code:s}=t;if(![et,j,ht,U].includes(s))return;t.preventDefault();const{controlKnobs:r,visuals:n}=this,{offsetWidth:i,offsetHeight:a}=n[0],[l,c,h]=r,{activeElement:b}=F(l),u=r.find(g=>g===b),d=a/360;if(u){let g=0,p=0;if(e===l){const f=i/100;[ht,U].includes(s)?this.controlPositions.c1x+=s===U?f:-f:[et,j].includes(s)&&(this.controlPositions.c1y+=s===j?d:-d),g=this.controlPositions.c1x,p=this.controlPositions.c1y,this.changeControl1(g,p)}else e===c?(this.controlPositions.c2y+=[j,U].includes(s)?d:-d,p=this.controlPositions.c2y,this.changeControl2(p)):e===h&&(this.controlPositions.c3y+=[j,U].includes(s)?d:-d,p=this.controlPositions.c3y,this.changeAlpha(p));this.handleScroll(t)}};changeHandler=()=>{let t;const{inputs:e,format:s,value:r,input:n,controlPositions:i,visuals:a}=this,{activeElement:l}=F(n),{offsetHeight:c}=a[0],[h,,,b]=e,[u,d,g,p]=s==="rgb"?e.map($=>parseFloat($.value)/($===b?100:1)):e.map($=>parseFloat($.value)/($!==h?100:360)),f=this.hasNonColor&&yt.includes(r),w=b?p:1-i.c3y/c;if(l===n||l&&e.includes(l)){l===n?f?t=r==="transparent"?"rgba(0,0,0,0)":"rgb(0,0,0)":t=r:s==="hex"?t=h.value:s==="hsl"?t={h:u,s:d,l:g,a:w}:s==="hwb"?t={h:u,w:d,b:g,a:w}:t={r:u,g:d,b:g,a:w};const{r:$,g:P,b:H,a:S}=new k(t);I(this.color,{r:$,g:P,b:H,a:S}),this.setControlPositions(),this.updateAppearance(),this.updateInputs(),this.updateControls(),this.updateVisuals(),l===n&&f&&(this.value=r)}};changeControl1(t,e){let[s,r]=[0,0];const{controlPositions:n,visuals:i}=this,{offsetHeight:a,offsetWidth:l}=i[0];t>l?s=l:t>=0&&(s=t),e>a?r=a:e>=0&&(r=e);const c=n.c2y/a,h=s/l,b=1-r/a,u=1-n.c3y/a,{r:d,g,b:p,a:f}=new k({h:c,s:h,v:b,a:u});I(this.color,{r:d,g,b:p,a:f}),this.controlPositions.c1x=s,this.controlPositions.c1y=r,this.updateAppearance(),this.updateInputs(),this.updateControls(),this.updateVisuals()}changeControl2(t){const{controlPositions:e,visuals:s}=this,{offsetHeight:r,offsetWidth:n}=s[0];let i=0;t>r?i=r:t>=0&&(i=t);const a=i/r,l=e.c1x/n,c=1-e.c1y/r,h=1-e.c3y/r,{r:b,g:u,b:d,a:g}=new k({h:a,s:l,v:c,a:h});I(this.color,{r:b,g:u,b:d,a:g}),this.controlPositions.c2y=i,this.updateAppearance(),this.updateInputs(),this.updateControls(),this.updateVisuals()}changeAlpha(t){const{visuals:e}=this,{offsetHeight:s}=e[0];let r=0;t>s?r=s:t>=0&&(r=t);const n=1-r/s;this.color.setAlpha(n),this.controlPositions.c3y=r,this.updateAppearance(),this.updateInputs(),this.updateControls(),this.updateVisuals()}update=()=>{this.updateDropdownPosition(),this.updateAppearance(),this.setControlPositions(),this.updateInputs(!0),this.updateControls(),this.updateVisuals()};updateDropdownPosition(){const{input:t,colorPicker:e,colorMenu:s}=this,r=ft(t),{top:n,bottom:i}=r,{offsetHeight:a}=t,l=Mt(t).clientHeight,h=M(e,"show")?e:s;if(!h)return;const{offsetHeight:b}=h,u=l-i,d=n,g=n+b+a>l,p=n-b<0;(M(h,"bottom")||!p)&&u<d&&g?(O(h,"bottom"),q(h,"top")):(O(h,"top"),q(h,"bottom"))}setControlPositions(){const{visuals:t,color:e,hsv:s}=this,{offsetHeight:r,offsetWidth:n}=t[0],i=e.a,a=s.h,l=s.s,c=s.v;this.controlPositions.c1x=l*n,this.controlPositions.c1y=(1-c)*r,this.controlPositions.c2y=a*r,this.controlPositions.c3y=(1-i)*r}updateAppearance(){const{componentLabels:t,color:e,parent:s,hsv:r,hex:n,format:i,controlKnobs:a}=this,{appearanceLabel:l,hexLabel:c,valueLabel:h}=t;let{r:b,g:u,b:d}=e.toRgb();const[g,p,f]=a,w=y(r.h*360),$=e.a,P=y(r.s*100),H=y(r.v*100),S=this.appearance;let C=`${c} ${n.split("").join(" ")}`;if(i==="hwb"){const{hwb:N}=this,V=y(N.w*100),ct=y(N.b*100);C=`HWB: ${w}°, ${V}%, ${ct}%`,m(g,tt,`${V}% & ${ct}%`),m(g,Q,`${V}`),m(p,Ut,`${h}: ${C}. ${l}: ${S}.`),m(p,tt,`${w}%`),m(p,Q,`${w}`)}else[b,u,d]=[b,u,d].map(y),C=i==="hsl"?`HSL: ${w}°, ${P}%, ${H}%`:C,C=i==="rgb"?`RGB: ${b}, ${u}, ${d}`:C,m(g,tt,`${H}% & ${P}%`),m(g,Q,`${H}`),m(p,Ut,`${h}: ${C}. ${l}: ${S}.`),m(p,tt,`${w}°`),m(p,Q,`${w}`);const R=y($*100);m(f,tt,`${R}%`),m(f,Q,`${R}`);const E=e.toString();D(this.input,{backgroundColor:E}),this.isDark?(M(s,"txt-light")&&O(s,"txt-light"),M(s,"txt-dark")||q(s,"txt-dark")):(M(s,"txt-dark")&&O(s,"txt-dark"),M(s,"txt-light")||q(s,"txt-light"))}updateControls(){const{controlKnobs:t,controlPositions:e}=this;let{c1x:s,c1y:r,c2y:n,c3y:i}=e;const[a,l,c]=t;[s,r,n,i]=[s,r,n,i].map(y),D(a,{transform:`translate3d(${s-4}px,${r-4}px,0)`}),D(l,{transform:`translate3d(0,${n-4}px,0)`}),D(c,{transform:`translate3d(0,${i-4}px,0)`})}updateInputs(t){const{value:e,format:s,inputs:r,color:n,hsl:i}=this,[a,l,c,h]=r,b=y(n.a*100),u=y(i.h*360);let d=n.toString();if(s==="hex")d=this.color.toHexString(!0),a.value=this.hex;else if(s==="hsl"){const g=y(i.l*100),p=y(i.s*100);d=this.color.toHslString(),a.value=`${u}`,l.value=`${p}`,c.value=`${g}`,h.value=`${b}`}else if(s==="hwb"){const{w:g,b:p}=this.hwb,f=y(g*100),w=y(p*100);d=this.color.toHwbString(),a.value=`${u}`,l.value=`${f}`,c.value=`${w}`,h.value=`${b}`}else if(s==="rgb"){let{r:g,g:p,b:f}=this.rgb;[g,p,f]=[g,p,f].map(y),d=this.color.toRgbString(),a.value=`${g}`,l.value=`${p}`,c.value=`${f}`,h.value=`${b}`}this.value=d,!t&&d!==e&&Ae(this)}togglePicker=t=>{t&&t.preventDefault();const{colorPicker:e}=this;this.isOpen&&M(e,"show")?this.hide(!0):qt(this,e)};showPicker=()=>{const{colorPicker:t}=this;["top","bottom"].some(e=>M(t,e))||qt(this,t)};toggleMenu=t=>{t&&t.preventDefault();const{colorMenu:e}=this;this.isOpen&&M(e,"show")?this.hide(!0):qt(this,e)};hide(t){if(this.isOpen){const{pickerToggle:e,menuToggle:s,colorPicker:r,colorMenu:n,parent:i,input:a}=this,l=M(r,"show"),c=l?r:n,h=l?e:s,b=c&&to(c);this.value=this.color.toString(!0),c&&(O(c,"show"),m(h,xt,"false"),setTimeout(()=>{He(c),z(".show",i)||(O(i,"open"),Le(this),this.isOpen=!1)},b)),t||_(e),m(a,W,"-1"),h===s&&m(s,W,"-1")}}dispose(){const{input:t,parent:e}=this;this.hide(!0),Ce(this),[...e.children].forEach(s=>{s!==t&&s.remove()}),At(t,W),D(t,{backgroundColor:""}),["txt-light","txt-dark"].forEach(s=>O(e,s)),st.remove(t,Y)}}return Ne}();
8
8
  //# sourceMappingURL=color-picker.js.map