@kgalexander/mcreate 1.0.1 → 1.0.3

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.
package/dist/index.js CHANGED
@@ -890,15 +890,15 @@ function propertyCardTripleMockMjml(block, context) {
890
890
  ${responsiveStyles}
891
891
  <mj-table align="center" width="${width}" padding="0" css-class="${trackingClasses}">
892
892
  <tr class="property-triple-row-${uniqueId}">
893
- <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px"">
893
+ <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px">
894
894
  ${cards[0] || ""}
895
895
  </th>
896
896
  <th class="property-triple-spacer-${uniqueId}" style="font-size:0px;line-height:16px;font-weight:normal;width:4px; height:4px">&nbsp;</th>
897
- <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px" ">
897
+ <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px">
898
898
  ${cards[1] || ""}
899
899
  </th>
900
900
  <th class="property-triple-spacer-${uniqueId}" style="font-size:0px;line-height:16px;font-weight:normal;width:4px; height:4px">&nbsp;</th>
901
- <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px" ">
901
+ <th class="property-triple-card-wrapper-${uniqueId}" valign="top" align="center" width="100px">
902
902
  ${cards[2] || ""}
903
903
  </th>
904
904
  </tr>
@@ -2004,6 +2004,7 @@ var init_editor = __esm({
2004
2004
  onImageUpload: null,
2005
2005
  onDuplicate: null,
2006
2006
  onDelete: null,
2007
+ onTemplateCapture: null,
2007
2008
  previewMode: false,
2008
2009
  focusIdx: null,
2009
2010
  hoverIdx: null,
@@ -2044,7 +2045,7 @@ var init_editor = __esm({
2044
2045
  });
2045
2046
  },
2046
2047
  // Initialize store with external template (for npm package usage)
2047
- initializeWithTemplate: (templateId, template, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete) => {
2048
+ initializeWithTemplate: (templateId, template, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete, onTemplateCapture) => {
2048
2049
  set((state) => {
2049
2050
  state.templateId = templateId;
2050
2051
  state.template = template;
@@ -2054,6 +2055,7 @@ var init_editor = __esm({
2054
2055
  state.onImageUpload = onImageUpload ?? null;
2055
2056
  state.onDuplicate = onDuplicate ?? null;
2056
2057
  state.onDelete = onDelete ?? null;
2058
+ state.onTemplateCapture = onTemplateCapture ?? null;
2057
2059
  state.isPaidLevel = data?.isPaidLevel ?? 0;
2058
2060
  state.images = data?.images ?? [];
2059
2061
  state.userData = data?.userData ?? null;
@@ -10727,24 +10729,24 @@ function autolink(options) {
10727
10729
  if (!isValidLinkStructure(linksBeforeSpace)) {
10728
10730
  return false;
10729
10731
  }
10730
- linksBeforeSpace.filter((link) => link.isLink).map((link) => ({
10731
- ...link,
10732
- from: lastWordAndBlockOffset + link.start + 1,
10733
- to: lastWordAndBlockOffset + link.end + 1
10734
- })).filter((link) => {
10732
+ linksBeforeSpace.filter((link2) => link2.isLink).map((link2) => ({
10733
+ ...link2,
10734
+ from: lastWordAndBlockOffset + link2.start + 1,
10735
+ to: lastWordAndBlockOffset + link2.end + 1
10736
+ })).filter((link2) => {
10735
10737
  if (!newState.schema.marks.code) {
10736
10738
  return true;
10737
10739
  }
10738
- return !newState.doc.rangeHasMark(link.from, link.to, newState.schema.marks.code);
10739
- }).filter((link) => options.validate(link.value)).filter((link) => options.shouldAutoLink(link.value)).forEach((link) => {
10740
- if (getMarksBetween(link.from, link.to, newState.doc).some((item) => item.mark.type === options.type)) {
10740
+ return !newState.doc.rangeHasMark(link2.from, link2.to, newState.schema.marks.code);
10741
+ }).filter((link2) => options.validate(link2.value)).filter((link2) => options.shouldAutoLink(link2.value)).forEach((link2) => {
10742
+ if (getMarksBetween(link2.from, link2.to, newState.doc).some((item) => item.mark.type === options.type)) {
10741
10743
  return;
10742
10744
  }
10743
10745
  tr2.addMark(
10744
- link.from,
10745
- link.to,
10746
+ link2.from,
10747
+ link2.to,
10746
10748
  options.type.create({
10747
- href: link.href
10749
+ href: link2.href
10748
10750
  })
10749
10751
  );
10750
10752
  });
@@ -10769,21 +10771,21 @@ function clickHandler(options) {
10769
10771
  if (!view.editable) {
10770
10772
  return false;
10771
10773
  }
10772
- let link = null;
10774
+ let link2 = null;
10773
10775
  if (event.target instanceof HTMLAnchorElement) {
10774
- link = event.target;
10776
+ link2 = event.target;
10775
10777
  } else {
10776
10778
  const target = event.target;
10777
10779
  if (!target) {
10778
10780
  return false;
10779
10781
  }
10780
10782
  const root = options.editor.view.dom;
10781
- link = target.closest("a");
10782
- if (link && !root.contains(link)) {
10783
- link = null;
10783
+ link2 = target.closest("a");
10784
+ if (link2 && !root.contains(link2)) {
10785
+ link2 = null;
10784
10786
  }
10785
10787
  }
10786
- if (!link) {
10788
+ if (!link2) {
10787
10789
  return false;
10788
10790
  }
10789
10791
  let handled = false;
@@ -10793,8 +10795,8 @@ function clickHandler(options) {
10793
10795
  }
10794
10796
  if (options.openOnClick) {
10795
10797
  const attrs = getAttributes(view.state, options.type.name);
10796
- const href = (_a = link.href) != null ? _a : attrs.href;
10797
- const target = (_b = link.target) != null ? _b : attrs.target;
10798
+ const href = (_a = link2.href) != null ? _a : attrs.href;
10799
+ const target = (_b = link2.target) != null ? _b : attrs.target;
10798
10800
  if (href) {
10799
10801
  window.open(href, target);
10800
10802
  handled = true;
@@ -10821,14 +10823,14 @@ function pasteHandler(options) {
10821
10823
  slice.content.forEach((node) => {
10822
10824
  textContent += node.textContent;
10823
10825
  });
10824
- const link = find(textContent, { defaultProtocol: options.defaultProtocol }).find(
10826
+ const link2 = find(textContent, { defaultProtocol: options.defaultProtocol }).find(
10825
10827
  (item) => item.isLink && item.value === textContent
10826
10828
  );
10827
- if (!textContent || !link || shouldAutoLink !== void 0 && !shouldAutoLink(link.value)) {
10829
+ if (!textContent || !link2 || shouldAutoLink !== void 0 && !shouldAutoLink(link2.value)) {
10828
10830
  return false;
10829
10831
  }
10830
10832
  return options.editor.commands.setMark(options.type, {
10831
- href: link.href
10833
+ href: link2.href
10832
10834
  });
10833
10835
  }
10834
10836
  }
@@ -11030,16 +11032,16 @@ var init_dist2 = __esm({
11030
11032
  })
11031
11033
  );
11032
11034
  if (links.length) {
11033
- links.forEach((link) => {
11034
- if (!this.options.shouldAutoLink(link.value)) {
11035
+ links.forEach((link2) => {
11036
+ if (!this.options.shouldAutoLink(link2.value)) {
11035
11037
  return;
11036
11038
  }
11037
11039
  foundLinks.push({
11038
- text: link.value,
11040
+ text: link2.value,
11039
11041
  data: {
11040
- href: link.href
11042
+ href: link2.href
11041
11043
  },
11042
- index: link.start
11044
+ index: link2.start
11043
11045
  });
11044
11046
  });
11045
11047
  }
@@ -16967,6 +16969,46 @@ function TemplateNameDialog() {
16967
16969
 
16968
16970
  // src/core/editor/components/email-template-v2/header.tsx
16969
16971
  init_editor();
16972
+
16973
+ // src/core/editor/utils/capture-template.ts
16974
+ var import_html_to_image = require("html-to-image");
16975
+ var CAPTURE_WIDTH = 600;
16976
+ async function captureTemplateImage(compiledHtml) {
16977
+ const container = document.createElement("div");
16978
+ container.style.position = "fixed";
16979
+ container.style.top = "0";
16980
+ container.style.left = "0";
16981
+ container.style.zIndex = "99999";
16982
+ container.style.width = `${CAPTURE_WIDTH}px`;
16983
+ container.style.backgroundColor = "#FFFFFF00";
16984
+ container.style.overflow = "hidden";
16985
+ container.style.maxHeight = "100vh";
16986
+ container.style.opacity = "0";
16987
+ container.innerHTML = compiledHtml;
16988
+ document.body.appendChild(container);
16989
+ await new Promise((resolve) => requestAnimationFrame(resolve));
16990
+ await new Promise((resolve) => setTimeout(resolve, 100));
16991
+ try {
16992
+ const dataUrl = await (0, import_html_to_image.toPng)(container, {
16993
+ width: CAPTURE_WIDTH,
16994
+ quality: 0.1,
16995
+ pixelRatio: 1,
16996
+ cacheBust: true,
16997
+ imagePlaceholder: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mN88P/BfwAJhAPkD+pMGAAAAABJRU5ErkJggg==",
16998
+ backgroundColor: "#ffffff",
16999
+ fetchRequestInit: { mode: "cors" },
17000
+ skipFonts: true,
17001
+ // Override opacity on the cloned node (real element is opacity:0 to stay invisible)
17002
+ style: { opacity: "1" }
17003
+ });
17004
+ return dataUrl;
17005
+ } finally {
17006
+ document.body.removeChild(container);
17007
+ }
17008
+ }
17009
+
17010
+ // src/core/editor/components/email-template-v2/header.tsx
17011
+ init_json2mjml();
16970
17012
  init_core();
16971
17013
  var import_jsx_runtime56 = require("react/jsx-runtime");
16972
17014
  function TemplateHeader() {
@@ -16978,14 +17020,28 @@ function TemplateHeader() {
16978
17020
  const onExit = useEditorStore((s) => s.onExit);
16979
17021
  const onDuplicate = useEditorStore((s) => s.onDuplicate);
16980
17022
  const onDelete = useEditorStore((s) => s.onDelete);
17023
+ const onTemplateCapture = useEditorStore((s) => s.onTemplateCapture);
16981
17024
  const templateName = useEditorStore((s) => s.template?.name);
16982
17025
  const handleExit = async () => {
16983
17026
  console.log("handleExit - templateId:", templateId);
16984
17027
  if (isSaving || !templateId || !onSave) return;
16985
17028
  setIsSaving(true);
16986
17029
  try {
16987
- await onSave(templateId, useEditorStore.getState().template);
17030
+ const template = useEditorStore.getState().template;
17031
+ await onSave(templateId, template);
16988
17032
  markAsSaved();
17033
+ if (onTemplateCapture) {
17034
+ try {
17035
+ const { default: mjml2html } = await import("mjml-browser");
17036
+ const mjmlString = json2mjml(template, "editing");
17037
+ const result = mjml2html(mjmlString);
17038
+ console.log("Result:", result.html);
17039
+ const imageDataUrl = await captureTemplateImage(result.html);
17040
+ await onTemplateCapture(templateId, imageDataUrl);
17041
+ } catch (err) {
17042
+ console.error("[TemplateCapture] Failed:", err?.message || JSON.stringify(err) || err, err?.stack || "");
17043
+ }
17044
+ }
16989
17045
  onExit?.();
16990
17046
  console.log("handleExit - onExit called");
16991
17047
  } catch (error) {
@@ -19530,8 +19586,1579 @@ init_editor();
19530
19586
  init_label();
19531
19587
  init_popover();
19532
19588
 
19589
+ // node_modules/color-name/index.js
19590
+ var colors = {
19591
+ aliceblue: [240, 248, 255],
19592
+ antiquewhite: [250, 235, 215],
19593
+ aqua: [0, 255, 255],
19594
+ aquamarine: [127, 255, 212],
19595
+ azure: [240, 255, 255],
19596
+ beige: [245, 245, 220],
19597
+ bisque: [255, 228, 196],
19598
+ black: [0, 0, 0],
19599
+ blanchedalmond: [255, 235, 205],
19600
+ blue: [0, 0, 255],
19601
+ blueviolet: [138, 43, 226],
19602
+ brown: [165, 42, 42],
19603
+ burlywood: [222, 184, 135],
19604
+ cadetblue: [95, 158, 160],
19605
+ chartreuse: [127, 255, 0],
19606
+ chocolate: [210, 105, 30],
19607
+ coral: [255, 127, 80],
19608
+ cornflowerblue: [100, 149, 237],
19609
+ cornsilk: [255, 248, 220],
19610
+ crimson: [220, 20, 60],
19611
+ cyan: [0, 255, 255],
19612
+ darkblue: [0, 0, 139],
19613
+ darkcyan: [0, 139, 139],
19614
+ darkgoldenrod: [184, 134, 11],
19615
+ darkgray: [169, 169, 169],
19616
+ darkgreen: [0, 100, 0],
19617
+ darkgrey: [169, 169, 169],
19618
+ darkkhaki: [189, 183, 107],
19619
+ darkmagenta: [139, 0, 139],
19620
+ darkolivegreen: [85, 107, 47],
19621
+ darkorange: [255, 140, 0],
19622
+ darkorchid: [153, 50, 204],
19623
+ darkred: [139, 0, 0],
19624
+ darksalmon: [233, 150, 122],
19625
+ darkseagreen: [143, 188, 143],
19626
+ darkslateblue: [72, 61, 139],
19627
+ darkslategray: [47, 79, 79],
19628
+ darkslategrey: [47, 79, 79],
19629
+ darkturquoise: [0, 206, 209],
19630
+ darkviolet: [148, 0, 211],
19631
+ deeppink: [255, 20, 147],
19632
+ deepskyblue: [0, 191, 255],
19633
+ dimgray: [105, 105, 105],
19634
+ dimgrey: [105, 105, 105],
19635
+ dodgerblue: [30, 144, 255],
19636
+ firebrick: [178, 34, 34],
19637
+ floralwhite: [255, 250, 240],
19638
+ forestgreen: [34, 139, 34],
19639
+ fuchsia: [255, 0, 255],
19640
+ gainsboro: [220, 220, 220],
19641
+ ghostwhite: [248, 248, 255],
19642
+ gold: [255, 215, 0],
19643
+ goldenrod: [218, 165, 32],
19644
+ gray: [128, 128, 128],
19645
+ green: [0, 128, 0],
19646
+ greenyellow: [173, 255, 47],
19647
+ grey: [128, 128, 128],
19648
+ honeydew: [240, 255, 240],
19649
+ hotpink: [255, 105, 180],
19650
+ indianred: [205, 92, 92],
19651
+ indigo: [75, 0, 130],
19652
+ ivory: [255, 255, 240],
19653
+ khaki: [240, 230, 140],
19654
+ lavender: [230, 230, 250],
19655
+ lavenderblush: [255, 240, 245],
19656
+ lawngreen: [124, 252, 0],
19657
+ lemonchiffon: [255, 250, 205],
19658
+ lightblue: [173, 216, 230],
19659
+ lightcoral: [240, 128, 128],
19660
+ lightcyan: [224, 255, 255],
19661
+ lightgoldenrodyellow: [250, 250, 210],
19662
+ lightgray: [211, 211, 211],
19663
+ lightgreen: [144, 238, 144],
19664
+ lightgrey: [211, 211, 211],
19665
+ lightpink: [255, 182, 193],
19666
+ lightsalmon: [255, 160, 122],
19667
+ lightseagreen: [32, 178, 170],
19668
+ lightskyblue: [135, 206, 250],
19669
+ lightslategray: [119, 136, 153],
19670
+ lightslategrey: [119, 136, 153],
19671
+ lightsteelblue: [176, 196, 222],
19672
+ lightyellow: [255, 255, 224],
19673
+ lime: [0, 255, 0],
19674
+ limegreen: [50, 205, 50],
19675
+ linen: [250, 240, 230],
19676
+ magenta: [255, 0, 255],
19677
+ maroon: [128, 0, 0],
19678
+ mediumaquamarine: [102, 205, 170],
19679
+ mediumblue: [0, 0, 205],
19680
+ mediumorchid: [186, 85, 211],
19681
+ mediumpurple: [147, 112, 219],
19682
+ mediumseagreen: [60, 179, 113],
19683
+ mediumslateblue: [123, 104, 238],
19684
+ mediumspringgreen: [0, 250, 154],
19685
+ mediumturquoise: [72, 209, 204],
19686
+ mediumvioletred: [199, 21, 133],
19687
+ midnightblue: [25, 25, 112],
19688
+ mintcream: [245, 255, 250],
19689
+ mistyrose: [255, 228, 225],
19690
+ moccasin: [255, 228, 181],
19691
+ navajowhite: [255, 222, 173],
19692
+ navy: [0, 0, 128],
19693
+ oldlace: [253, 245, 230],
19694
+ olive: [128, 128, 0],
19695
+ olivedrab: [107, 142, 35],
19696
+ orange: [255, 165, 0],
19697
+ orangered: [255, 69, 0],
19698
+ orchid: [218, 112, 214],
19699
+ palegoldenrod: [238, 232, 170],
19700
+ palegreen: [152, 251, 152],
19701
+ paleturquoise: [175, 238, 238],
19702
+ palevioletred: [219, 112, 147],
19703
+ papayawhip: [255, 239, 213],
19704
+ peachpuff: [255, 218, 185],
19705
+ peru: [205, 133, 63],
19706
+ pink: [255, 192, 203],
19707
+ plum: [221, 160, 221],
19708
+ powderblue: [176, 224, 230],
19709
+ purple: [128, 0, 128],
19710
+ rebeccapurple: [102, 51, 153],
19711
+ red: [255, 0, 0],
19712
+ rosybrown: [188, 143, 143],
19713
+ royalblue: [65, 105, 225],
19714
+ saddlebrown: [139, 69, 19],
19715
+ salmon: [250, 128, 114],
19716
+ sandybrown: [244, 164, 96],
19717
+ seagreen: [46, 139, 87],
19718
+ seashell: [255, 245, 238],
19719
+ sienna: [160, 82, 45],
19720
+ silver: [192, 192, 192],
19721
+ skyblue: [135, 206, 235],
19722
+ slateblue: [106, 90, 205],
19723
+ slategray: [112, 128, 144],
19724
+ slategrey: [112, 128, 144],
19725
+ snow: [255, 250, 250],
19726
+ springgreen: [0, 255, 127],
19727
+ steelblue: [70, 130, 180],
19728
+ tan: [210, 180, 140],
19729
+ teal: [0, 128, 128],
19730
+ thistle: [216, 191, 216],
19731
+ tomato: [255, 99, 71],
19732
+ turquoise: [64, 224, 208],
19733
+ violet: [238, 130, 238],
19734
+ wheat: [245, 222, 179],
19735
+ white: [255, 255, 255],
19736
+ whitesmoke: [245, 245, 245],
19737
+ yellow: [255, 255, 0],
19738
+ yellowgreen: [154, 205, 50]
19739
+ };
19740
+ for (const key in colors) Object.freeze(colors[key]);
19741
+ var color_name_default = Object.freeze(colors);
19742
+
19743
+ // node_modules/color-string/index.js
19744
+ var reverseNames = /* @__PURE__ */ Object.create(null);
19745
+ for (const name in color_name_default) {
19746
+ if (Object.hasOwn(color_name_default, name)) {
19747
+ reverseNames[color_name_default[name]] = name;
19748
+ }
19749
+ }
19750
+ var cs = {
19751
+ to: {},
19752
+ get: {}
19753
+ };
19754
+ cs.get = function(string) {
19755
+ const prefix = string.slice(0, 3).toLowerCase();
19756
+ let value;
19757
+ let model;
19758
+ switch (prefix) {
19759
+ case "hsl": {
19760
+ value = cs.get.hsl(string);
19761
+ model = "hsl";
19762
+ break;
19763
+ }
19764
+ case "hwb": {
19765
+ value = cs.get.hwb(string);
19766
+ model = "hwb";
19767
+ break;
19768
+ }
19769
+ default: {
19770
+ value = cs.get.rgb(string);
19771
+ model = "rgb";
19772
+ break;
19773
+ }
19774
+ }
19775
+ if (!value) {
19776
+ return null;
19777
+ }
19778
+ return { model, value };
19779
+ };
19780
+ cs.get.rgb = function(string) {
19781
+ if (!string) {
19782
+ return null;
19783
+ }
19784
+ const abbr = /^#([a-f\d]{3,4})$/i;
19785
+ const hex = /^#([a-f\d]{6})([a-f\d]{2})?$/i;
19786
+ const rgba = /^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i;
19787
+ const per = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/i;
19788
+ const keyword = /^(\w+)$/;
19789
+ let rgb = [0, 0, 0, 1];
19790
+ let match;
19791
+ let i;
19792
+ let hexAlpha;
19793
+ if (match = string.match(hex)) {
19794
+ hexAlpha = match[2];
19795
+ match = match[1];
19796
+ for (i = 0; i < 3; i++) {
19797
+ const i2 = i * 2;
19798
+ rgb[i] = Number.parseInt(match.slice(i2, i2 + 2), 16);
19799
+ }
19800
+ if (hexAlpha) {
19801
+ rgb[3] = Number.parseInt(hexAlpha, 16) / 255;
19802
+ }
19803
+ } else if (match = string.match(abbr)) {
19804
+ match = match[1];
19805
+ hexAlpha = match[3];
19806
+ for (i = 0; i < 3; i++) {
19807
+ rgb[i] = Number.parseInt(match[i] + match[i], 16);
19808
+ }
19809
+ if (hexAlpha) {
19810
+ rgb[3] = Number.parseInt(hexAlpha + hexAlpha, 16) / 255;
19811
+ }
19812
+ } else if (match = string.match(rgba)) {
19813
+ for (i = 0; i < 3; i++) {
19814
+ rgb[i] = Number.parseFloat(match[i + 1]);
19815
+ }
19816
+ if (match[4]) {
19817
+ rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
19818
+ }
19819
+ } else if (match = string.match(per)) {
19820
+ for (i = 0; i < 3; i++) {
19821
+ rgb[i] = Math.round(Number.parseFloat(match[i + 1]) * 2.55);
19822
+ }
19823
+ if (match[4]) {
19824
+ rgb[3] = match[5] ? Number.parseFloat(match[4]) * 0.01 : Number.parseFloat(match[4]);
19825
+ }
19826
+ } else if (match = string.toLowerCase().match(keyword)) {
19827
+ if (match[1] === "transparent") {
19828
+ return [0, 0, 0, 0];
19829
+ }
19830
+ if (!Object.hasOwn(color_name_default, match[1])) {
19831
+ return null;
19832
+ }
19833
+ rgb = color_name_default[match[1]].slice();
19834
+ rgb[3] = 1;
19835
+ return rgb;
19836
+ } else {
19837
+ return null;
19838
+ }
19839
+ for (i = 0; i < 3; i++) {
19840
+ rgb[i] = clamp(rgb[i], 0, 255);
19841
+ }
19842
+ rgb[3] = clamp(rgb[3], 0, 1);
19843
+ return rgb;
19844
+ };
19845
+ cs.get.hsl = function(string) {
19846
+ if (!string) {
19847
+ return null;
19848
+ }
19849
+ const hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i;
19850
+ const match = string.match(hsl);
19851
+ if (match) {
19852
+ const alpha2 = Number.parseFloat(match[4]);
19853
+ const h = (Number.parseFloat(match[1]) % 360 + 360) % 360;
19854
+ const s = clamp(Number.parseFloat(match[2]), 0, 100);
19855
+ const l = clamp(Number.parseFloat(match[3]), 0, 100);
19856
+ const a = clamp(Number.isNaN(alpha2) ? 1 : alpha2, 0, 1);
19857
+ return [h, s, l, a];
19858
+ }
19859
+ return null;
19860
+ };
19861
+ cs.get.hwb = function(string) {
19862
+ if (!string) {
19863
+ return null;
19864
+ }
19865
+ const hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i;
19866
+ const match = string.match(hwb);
19867
+ if (match) {
19868
+ const alpha2 = Number.parseFloat(match[4]);
19869
+ const h = (Number.parseFloat(match[1]) % 360 + 360) % 360;
19870
+ const w = clamp(Number.parseFloat(match[2]), 0, 100);
19871
+ const b = clamp(Number.parseFloat(match[3]), 0, 100);
19872
+ const a = clamp(Number.isNaN(alpha2) ? 1 : alpha2, 0, 1);
19873
+ return [h, w, b, a];
19874
+ }
19875
+ return null;
19876
+ };
19877
+ cs.to.hex = function(...rgba) {
19878
+ return "#" + hexDouble(rgba[0]) + hexDouble(rgba[1]) + hexDouble(rgba[2]) + (rgba[3] < 1 ? hexDouble(Math.round(rgba[3] * 255)) : "");
19879
+ };
19880
+ cs.to.rgb = function(...rgba) {
19881
+ return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ")" : "rgba(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ", " + rgba[3] + ")";
19882
+ };
19883
+ cs.to.rgb.percent = function(...rgba) {
19884
+ const r = Math.round(rgba[0] / 255 * 100);
19885
+ const g = Math.round(rgba[1] / 255 * 100);
19886
+ const b = Math.round(rgba[2] / 255 * 100);
19887
+ return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + r + "%, " + g + "%, " + b + "%)" : "rgba(" + r + "%, " + g + "%, " + b + "%, " + rgba[3] + ")";
19888
+ };
19889
+ cs.to.hsl = function(...hsla) {
19890
+ return hsla.length < 4 || hsla[3] === 1 ? "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)" : "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, " + hsla[3] + ")";
19891
+ };
19892
+ cs.to.hwb = function(...hwba) {
19893
+ let a = "";
19894
+ if (hwba.length >= 4 && hwba[3] !== 1) {
19895
+ a = ", " + hwba[3];
19896
+ }
19897
+ return "hwb(" + hwba[0] + ", " + hwba[1] + "%, " + hwba[2] + "%" + a + ")";
19898
+ };
19899
+ cs.to.keyword = function(...rgb) {
19900
+ return reverseNames[rgb.slice(0, 3)];
19901
+ };
19902
+ function clamp(number_, min, max) {
19903
+ return Math.min(Math.max(min, number_), max);
19904
+ }
19905
+ function hexDouble(number_) {
19906
+ const string_ = Math.round(number_).toString(16).toUpperCase();
19907
+ return string_.length < 2 ? "0" + string_ : string_;
19908
+ }
19909
+ var color_string_default = cs;
19910
+
19911
+ // node_modules/color-convert/conversions.js
19912
+ var reverseKeywords = {};
19913
+ for (const key of Object.keys(color_name_default)) {
19914
+ reverseKeywords[color_name_default[key]] = key;
19915
+ }
19916
+ var convert = {
19917
+ rgb: { channels: 3, labels: "rgb" },
19918
+ hsl: { channels: 3, labels: "hsl" },
19919
+ hsv: { channels: 3, labels: "hsv" },
19920
+ hwb: { channels: 3, labels: "hwb" },
19921
+ cmyk: { channels: 4, labels: "cmyk" },
19922
+ xyz: { channels: 3, labels: "xyz" },
19923
+ lab: { channels: 3, labels: "lab" },
19924
+ oklab: { channels: 3, labels: ["okl", "oka", "okb"] },
19925
+ lch: { channels: 3, labels: "lch" },
19926
+ oklch: { channels: 3, labels: ["okl", "okc", "okh"] },
19927
+ hex: { channels: 1, labels: ["hex"] },
19928
+ keyword: { channels: 1, labels: ["keyword"] },
19929
+ ansi16: { channels: 1, labels: ["ansi16"] },
19930
+ ansi256: { channels: 1, labels: ["ansi256"] },
19931
+ hcg: { channels: 3, labels: ["h", "c", "g"] },
19932
+ apple: { channels: 3, labels: ["r16", "g16", "b16"] },
19933
+ gray: { channels: 1, labels: ["gray"] }
19934
+ };
19935
+ var conversions_default = convert;
19936
+ var LAB_FT = (6 / 29) ** 3;
19937
+ function srgbNonlinearTransform(c) {
19938
+ const cc = c > 31308e-7 ? 1.055 * c ** (1 / 2.4) - 0.055 : c * 12.92;
19939
+ return Math.min(Math.max(0, cc), 1);
19940
+ }
19941
+ function srgbNonlinearTransformInv(c) {
19942
+ return c > 0.04045 ? ((c + 0.055) / 1.055) ** 2.4 : c / 12.92;
19943
+ }
19944
+ for (const model of Object.keys(convert)) {
19945
+ if (!("channels" in convert[model])) {
19946
+ throw new Error("missing channels property: " + model);
19947
+ }
19948
+ if (!("labels" in convert[model])) {
19949
+ throw new Error("missing channel labels property: " + model);
19950
+ }
19951
+ if (convert[model].labels.length !== convert[model].channels) {
19952
+ throw new Error("channel and label counts mismatch: " + model);
19953
+ }
19954
+ const { channels, labels } = convert[model];
19955
+ delete convert[model].channels;
19956
+ delete convert[model].labels;
19957
+ Object.defineProperty(convert[model], "channels", { value: channels });
19958
+ Object.defineProperty(convert[model], "labels", { value: labels });
19959
+ }
19960
+ convert.rgb.hsl = function(rgb) {
19961
+ const r = rgb[0] / 255;
19962
+ const g = rgb[1] / 255;
19963
+ const b = rgb[2] / 255;
19964
+ const min = Math.min(r, g, b);
19965
+ const max = Math.max(r, g, b);
19966
+ const delta = max - min;
19967
+ let h;
19968
+ let s;
19969
+ switch (max) {
19970
+ case min: {
19971
+ h = 0;
19972
+ break;
19973
+ }
19974
+ case r: {
19975
+ h = (g - b) / delta;
19976
+ break;
19977
+ }
19978
+ case g: {
19979
+ h = 2 + (b - r) / delta;
19980
+ break;
19981
+ }
19982
+ case b: {
19983
+ h = 4 + (r - g) / delta;
19984
+ break;
19985
+ }
19986
+ }
19987
+ h = Math.min(h * 60, 360);
19988
+ if (h < 0) {
19989
+ h += 360;
19990
+ }
19991
+ const l = (min + max) / 2;
19992
+ if (max === min) {
19993
+ s = 0;
19994
+ } else if (l <= 0.5) {
19995
+ s = delta / (max + min);
19996
+ } else {
19997
+ s = delta / (2 - max - min);
19998
+ }
19999
+ return [h, s * 100, l * 100];
20000
+ };
20001
+ convert.rgb.hsv = function(rgb) {
20002
+ let rdif;
20003
+ let gdif;
20004
+ let bdif;
20005
+ let h;
20006
+ let s;
20007
+ const r = rgb[0] / 255;
20008
+ const g = rgb[1] / 255;
20009
+ const b = rgb[2] / 255;
20010
+ const v = Math.max(r, g, b);
20011
+ const diff = v - Math.min(r, g, b);
20012
+ const diffc = function(c) {
20013
+ return (v - c) / 6 / diff + 1 / 2;
20014
+ };
20015
+ if (diff === 0) {
20016
+ h = 0;
20017
+ s = 0;
20018
+ } else {
20019
+ s = diff / v;
20020
+ rdif = diffc(r);
20021
+ gdif = diffc(g);
20022
+ bdif = diffc(b);
20023
+ switch (v) {
20024
+ case r: {
20025
+ h = bdif - gdif;
20026
+ break;
20027
+ }
20028
+ case g: {
20029
+ h = 1 / 3 + rdif - bdif;
20030
+ break;
20031
+ }
20032
+ case b: {
20033
+ h = 2 / 3 + gdif - rdif;
20034
+ break;
20035
+ }
20036
+ }
20037
+ if (h < 0) {
20038
+ h += 1;
20039
+ } else if (h > 1) {
20040
+ h -= 1;
20041
+ }
20042
+ }
20043
+ return [
20044
+ h * 360,
20045
+ s * 100,
20046
+ v * 100
20047
+ ];
20048
+ };
20049
+ convert.rgb.hwb = function(rgb) {
20050
+ const r = rgb[0];
20051
+ const g = rgb[1];
20052
+ let b = rgb[2];
20053
+ const h = convert.rgb.hsl(rgb)[0];
20054
+ const w = 1 / 255 * Math.min(r, Math.min(g, b));
20055
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
20056
+ return [h, w * 100, b * 100];
20057
+ };
20058
+ convert.rgb.oklab = function(rgb) {
20059
+ const r = srgbNonlinearTransformInv(rgb[0] / 255);
20060
+ const g = srgbNonlinearTransformInv(rgb[1] / 255);
20061
+ const b = srgbNonlinearTransformInv(rgb[2] / 255);
20062
+ const lp = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
20063
+ const mp = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
20064
+ const sp = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
20065
+ const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
20066
+ const aa = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
20067
+ const bb = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
20068
+ return [l * 100, aa * 100, bb * 100];
20069
+ };
20070
+ convert.rgb.cmyk = function(rgb) {
20071
+ const r = rgb[0] / 255;
20072
+ const g = rgb[1] / 255;
20073
+ const b = rgb[2] / 255;
20074
+ const k = Math.min(1 - r, 1 - g, 1 - b);
20075
+ const c = (1 - r - k) / (1 - k) || 0;
20076
+ const m = (1 - g - k) / (1 - k) || 0;
20077
+ const y = (1 - b - k) / (1 - k) || 0;
20078
+ return [c * 100, m * 100, y * 100, k * 100];
20079
+ };
20080
+ function comparativeDistance(x, y) {
20081
+ return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
20082
+ }
20083
+ convert.rgb.keyword = function(rgb) {
20084
+ const reversed = reverseKeywords[rgb];
20085
+ if (reversed) {
20086
+ return reversed;
20087
+ }
20088
+ let currentClosestDistance = Number.POSITIVE_INFINITY;
20089
+ let currentClosestKeyword;
20090
+ for (const keyword of Object.keys(color_name_default)) {
20091
+ const value = color_name_default[keyword];
20092
+ const distance = comparativeDistance(rgb, value);
20093
+ if (distance < currentClosestDistance) {
20094
+ currentClosestDistance = distance;
20095
+ currentClosestKeyword = keyword;
20096
+ }
20097
+ }
20098
+ return currentClosestKeyword;
20099
+ };
20100
+ convert.keyword.rgb = function(keyword) {
20101
+ return [...color_name_default[keyword]];
20102
+ };
20103
+ convert.rgb.xyz = function(rgb) {
20104
+ const r = srgbNonlinearTransformInv(rgb[0] / 255);
20105
+ const g = srgbNonlinearTransformInv(rgb[1] / 255);
20106
+ const b = srgbNonlinearTransformInv(rgb[2] / 255);
20107
+ const x = r * 0.4124564 + g * 0.3575761 + b * 0.1804375;
20108
+ const y = r * 0.2126729 + g * 0.7151522 + b * 0.072175;
20109
+ const z = r * 0.0193339 + g * 0.119192 + b * 0.9503041;
20110
+ return [x * 100, y * 100, z * 100];
20111
+ };
20112
+ convert.rgb.lab = function(rgb) {
20113
+ const xyz = convert.rgb.xyz(rgb);
20114
+ let x = xyz[0];
20115
+ let y = xyz[1];
20116
+ let z = xyz[2];
20117
+ x /= 95.047;
20118
+ y /= 100;
20119
+ z /= 108.883;
20120
+ x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;
20121
+ y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;
20122
+ z = z > LAB_FT ? z ** (1 / 3) : 7.787 * z + 16 / 116;
20123
+ const l = 116 * y - 16;
20124
+ const a = 500 * (x - y);
20125
+ const b = 200 * (y - z);
20126
+ return [l, a, b];
20127
+ };
20128
+ convert.hsl.rgb = function(hsl) {
20129
+ const h = hsl[0] / 360;
20130
+ const s = hsl[1] / 100;
20131
+ const l = hsl[2] / 100;
20132
+ let t3;
20133
+ let value;
20134
+ if (s === 0) {
20135
+ value = l * 255;
20136
+ return [value, value, value];
20137
+ }
20138
+ const t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;
20139
+ const t1 = 2 * l - t2;
20140
+ const rgb = [0, 0, 0];
20141
+ for (let i = 0; i < 3; i++) {
20142
+ t3 = h + 1 / 3 * -(i - 1);
20143
+ if (t3 < 0) {
20144
+ t3++;
20145
+ }
20146
+ if (t3 > 1) {
20147
+ t3--;
20148
+ }
20149
+ if (6 * t3 < 1) {
20150
+ value = t1 + (t2 - t1) * 6 * t3;
20151
+ } else if (2 * t3 < 1) {
20152
+ value = t2;
20153
+ } else if (3 * t3 < 2) {
20154
+ value = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
20155
+ } else {
20156
+ value = t1;
20157
+ }
20158
+ rgb[i] = value * 255;
20159
+ }
20160
+ return rgb;
20161
+ };
20162
+ convert.hsl.hsv = function(hsl) {
20163
+ const h = hsl[0];
20164
+ let s = hsl[1] / 100;
20165
+ let l = hsl[2] / 100;
20166
+ let smin = s;
20167
+ const lmin = Math.max(l, 0.01);
20168
+ l *= 2;
20169
+ s *= l <= 1 ? l : 2 - l;
20170
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
20171
+ const v = (l + s) / 2;
20172
+ const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
20173
+ return [h, sv * 100, v * 100];
20174
+ };
20175
+ convert.hsv.rgb = function(hsv) {
20176
+ const h = hsv[0] / 60;
20177
+ const s = hsv[1] / 100;
20178
+ let v = hsv[2] / 100;
20179
+ const hi = Math.floor(h) % 6;
20180
+ const f = h - Math.floor(h);
20181
+ const p = 255 * v * (1 - s);
20182
+ const q = 255 * v * (1 - s * f);
20183
+ const t = 255 * v * (1 - s * (1 - f));
20184
+ v *= 255;
20185
+ switch (hi) {
20186
+ case 0: {
20187
+ return [v, t, p];
20188
+ }
20189
+ case 1: {
20190
+ return [q, v, p];
20191
+ }
20192
+ case 2: {
20193
+ return [p, v, t];
20194
+ }
20195
+ case 3: {
20196
+ return [p, q, v];
20197
+ }
20198
+ case 4: {
20199
+ return [t, p, v];
20200
+ }
20201
+ case 5: {
20202
+ return [v, p, q];
20203
+ }
20204
+ }
20205
+ };
20206
+ convert.hsv.hsl = function(hsv) {
20207
+ const h = hsv[0];
20208
+ const s = hsv[1] / 100;
20209
+ const v = hsv[2] / 100;
20210
+ const vmin = Math.max(v, 0.01);
20211
+ let sl;
20212
+ let l;
20213
+ l = (2 - s) * v;
20214
+ const lmin = (2 - s) * vmin;
20215
+ sl = s * vmin;
20216
+ sl /= lmin <= 1 ? lmin : 2 - lmin;
20217
+ sl = sl || 0;
20218
+ l /= 2;
20219
+ return [h, sl * 100, l * 100];
20220
+ };
20221
+ convert.hwb.rgb = function(hwb) {
20222
+ const h = hwb[0] / 360;
20223
+ let wh = hwb[1] / 100;
20224
+ let bl = hwb[2] / 100;
20225
+ const ratio = wh + bl;
20226
+ let f;
20227
+ if (ratio > 1) {
20228
+ wh /= ratio;
20229
+ bl /= ratio;
20230
+ }
20231
+ const i = Math.floor(6 * h);
20232
+ const v = 1 - bl;
20233
+ f = 6 * h - i;
20234
+ if ((i & 1) !== 0) {
20235
+ f = 1 - f;
20236
+ }
20237
+ const n = wh + f * (v - wh);
20238
+ let r;
20239
+ let g;
20240
+ let b;
20241
+ switch (i) {
20242
+ default:
20243
+ case 6:
20244
+ case 0: {
20245
+ r = v;
20246
+ g = n;
20247
+ b = wh;
20248
+ break;
20249
+ }
20250
+ case 1: {
20251
+ r = n;
20252
+ g = v;
20253
+ b = wh;
20254
+ break;
20255
+ }
20256
+ case 2: {
20257
+ r = wh;
20258
+ g = v;
20259
+ b = n;
20260
+ break;
20261
+ }
20262
+ case 3: {
20263
+ r = wh;
20264
+ g = n;
20265
+ b = v;
20266
+ break;
20267
+ }
20268
+ case 4: {
20269
+ r = n;
20270
+ g = wh;
20271
+ b = v;
20272
+ break;
20273
+ }
20274
+ case 5: {
20275
+ r = v;
20276
+ g = wh;
20277
+ b = n;
20278
+ break;
20279
+ }
20280
+ }
20281
+ return [r * 255, g * 255, b * 255];
20282
+ };
20283
+ convert.cmyk.rgb = function(cmyk) {
20284
+ const c = cmyk[0] / 100;
20285
+ const m = cmyk[1] / 100;
20286
+ const y = cmyk[2] / 100;
20287
+ const k = cmyk[3] / 100;
20288
+ const r = 1 - Math.min(1, c * (1 - k) + k);
20289
+ const g = 1 - Math.min(1, m * (1 - k) + k);
20290
+ const b = 1 - Math.min(1, y * (1 - k) + k);
20291
+ return [r * 255, g * 255, b * 255];
20292
+ };
20293
+ convert.xyz.rgb = function(xyz) {
20294
+ const x = xyz[0] / 100;
20295
+ const y = xyz[1] / 100;
20296
+ const z = xyz[2] / 100;
20297
+ let r;
20298
+ let g;
20299
+ let b;
20300
+ r = x * 3.2404542 + y * -1.5371385 + z * -0.4985314;
20301
+ g = x * -0.969266 + y * 1.8760108 + z * 0.041556;
20302
+ b = x * 0.0556434 + y * -0.2040259 + z * 1.0572252;
20303
+ r = srgbNonlinearTransform(r);
20304
+ g = srgbNonlinearTransform(g);
20305
+ b = srgbNonlinearTransform(b);
20306
+ return [r * 255, g * 255, b * 255];
20307
+ };
20308
+ convert.xyz.lab = function(xyz) {
20309
+ let x = xyz[0];
20310
+ let y = xyz[1];
20311
+ let z = xyz[2];
20312
+ x /= 95.047;
20313
+ y /= 100;
20314
+ z /= 108.883;
20315
+ x = x > LAB_FT ? x ** (1 / 3) : 7.787 * x + 16 / 116;
20316
+ y = y > LAB_FT ? y ** (1 / 3) : 7.787 * y + 16 / 116;
20317
+ z = z > LAB_FT ? z ** (1 / 3) : 7.787 * z + 16 / 116;
20318
+ const l = 116 * y - 16;
20319
+ const a = 500 * (x - y);
20320
+ const b = 200 * (y - z);
20321
+ return [l, a, b];
20322
+ };
20323
+ convert.xyz.oklab = function(xyz) {
20324
+ const x = xyz[0] / 100;
20325
+ const y = xyz[1] / 100;
20326
+ const z = xyz[2] / 100;
20327
+ const lp = Math.cbrt(0.8189330101 * x + 0.3618667424 * y - 0.1288597137 * z);
20328
+ const mp = Math.cbrt(0.0329845436 * x + 0.9293118715 * y + 0.0361456387 * z);
20329
+ const sp = Math.cbrt(0.0482003018 * x + 0.2643662691 * y + 0.633851707 * z);
20330
+ const l = 0.2104542553 * lp + 0.793617785 * mp - 0.0040720468 * sp;
20331
+ const a = 1.9779984951 * lp - 2.428592205 * mp + 0.4505937099 * sp;
20332
+ const b = 0.0259040371 * lp + 0.7827717662 * mp - 0.808675766 * sp;
20333
+ return [l * 100, a * 100, b * 100];
20334
+ };
20335
+ convert.oklab.oklch = function(oklab) {
20336
+ return convert.lab.lch(oklab);
20337
+ };
20338
+ convert.oklab.xyz = function(oklab) {
20339
+ const ll = oklab[0] / 100;
20340
+ const a = oklab[1] / 100;
20341
+ const b = oklab[2] / 100;
20342
+ const l = (0.999999998 * ll + 0.396337792 * a + 0.215803758 * b) ** 3;
20343
+ const m = (1.000000008 * ll - 0.105561342 * a - 0.063854175 * b) ** 3;
20344
+ const s = (1.000000055 * ll - 0.089484182 * a - 1.291485538 * b) ** 3;
20345
+ const x = 1.227013851 * l - 0.55779998 * m + 0.281256149 * s;
20346
+ const y = -0.040580178 * l + 1.11225687 * m - 0.071676679 * s;
20347
+ const z = -0.076381285 * l - 0.421481978 * m + 1.58616322 * s;
20348
+ return [x * 100, y * 100, z * 100];
20349
+ };
20350
+ convert.oklab.rgb = function(oklab) {
20351
+ const ll = oklab[0] / 100;
20352
+ const aa = oklab[1] / 100;
20353
+ const bb = oklab[2] / 100;
20354
+ const l = (ll + 0.3963377774 * aa + 0.2158037573 * bb) ** 3;
20355
+ const m = (ll - 0.1055613458 * aa - 0.0638541728 * bb) ** 3;
20356
+ const s = (ll - 0.0894841775 * aa - 1.291485548 * bb) ** 3;
20357
+ const r = srgbNonlinearTransform(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s);
20358
+ const g = srgbNonlinearTransform(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s);
20359
+ const b = srgbNonlinearTransform(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s);
20360
+ return [r * 255, g * 255, b * 255];
20361
+ };
20362
+ convert.oklch.oklab = function(oklch) {
20363
+ return convert.lch.lab(oklch);
20364
+ };
20365
+ convert.lab.xyz = function(lab) {
20366
+ const l = lab[0];
20367
+ const a = lab[1];
20368
+ const b = lab[2];
20369
+ let x;
20370
+ let y;
20371
+ let z;
20372
+ y = (l + 16) / 116;
20373
+ x = a / 500 + y;
20374
+ z = y - b / 200;
20375
+ const y2 = y ** 3;
20376
+ const x2 = x ** 3;
20377
+ const z2 = z ** 3;
20378
+ y = y2 > LAB_FT ? y2 : (y - 16 / 116) / 7.787;
20379
+ x = x2 > LAB_FT ? x2 : (x - 16 / 116) / 7.787;
20380
+ z = z2 > LAB_FT ? z2 : (z - 16 / 116) / 7.787;
20381
+ x *= 95.047;
20382
+ y *= 100;
20383
+ z *= 108.883;
20384
+ return [x, y, z];
20385
+ };
20386
+ convert.lab.lch = function(lab) {
20387
+ const l = lab[0];
20388
+ const a = lab[1];
20389
+ const b = lab[2];
20390
+ let h;
20391
+ const hr = Math.atan2(b, a);
20392
+ h = hr * 360 / 2 / Math.PI;
20393
+ if (h < 0) {
20394
+ h += 360;
20395
+ }
20396
+ const c = Math.sqrt(a * a + b * b);
20397
+ return [l, c, h];
20398
+ };
20399
+ convert.lch.lab = function(lch) {
20400
+ const l = lch[0];
20401
+ const c = lch[1];
20402
+ const h = lch[2];
20403
+ const hr = h / 360 * 2 * Math.PI;
20404
+ const a = c * Math.cos(hr);
20405
+ const b = c * Math.sin(hr);
20406
+ return [l, a, b];
20407
+ };
20408
+ convert.rgb.ansi16 = function(args, saturation = null) {
20409
+ const [r, g, b] = args;
20410
+ let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
20411
+ value = Math.round(value / 50);
20412
+ if (value === 0) {
20413
+ return 30;
20414
+ }
20415
+ let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
20416
+ if (value === 2) {
20417
+ ansi += 60;
20418
+ }
20419
+ return ansi;
20420
+ };
20421
+ convert.hsv.ansi16 = function(args) {
20422
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
20423
+ };
20424
+ convert.rgb.ansi256 = function(args) {
20425
+ const r = args[0];
20426
+ const g = args[1];
20427
+ const b = args[2];
20428
+ if (r >> 4 === g >> 4 && g >> 4 === b >> 4) {
20429
+ if (r < 8) {
20430
+ return 16;
20431
+ }
20432
+ if (r > 248) {
20433
+ return 231;
20434
+ }
20435
+ return Math.round((r - 8) / 247 * 24) + 232;
20436
+ }
20437
+ const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
20438
+ return ansi;
20439
+ };
20440
+ convert.ansi16.rgb = function(args) {
20441
+ args = args[0];
20442
+ let color = args % 10;
20443
+ if (color === 0 || color === 7) {
20444
+ if (args > 50) {
20445
+ color += 3.5;
20446
+ }
20447
+ color = color / 10.5 * 255;
20448
+ return [color, color, color];
20449
+ }
20450
+ const mult = (Math.trunc(args > 50) + 1) * 0.5;
20451
+ const r = (color & 1) * mult * 255;
20452
+ const g = (color >> 1 & 1) * mult * 255;
20453
+ const b = (color >> 2 & 1) * mult * 255;
20454
+ return [r, g, b];
20455
+ };
20456
+ convert.ansi256.rgb = function(args) {
20457
+ args = args[0];
20458
+ if (args >= 232) {
20459
+ const c = (args - 232) * 10 + 8;
20460
+ return [c, c, c];
20461
+ }
20462
+ args -= 16;
20463
+ let rem;
20464
+ const r = Math.floor(args / 36) / 5 * 255;
20465
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
20466
+ const b = rem % 6 / 5 * 255;
20467
+ return [r, g, b];
20468
+ };
20469
+ convert.rgb.hex = function(args) {
20470
+ const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
20471
+ const string = integer.toString(16).toUpperCase();
20472
+ return "000000".slice(string.length) + string;
20473
+ };
20474
+ convert.hex.rgb = function(args) {
20475
+ const match = args.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);
20476
+ if (!match) {
20477
+ return [0, 0, 0];
20478
+ }
20479
+ let colorString = match[0];
20480
+ if (match[0].length === 3) {
20481
+ colorString = [...colorString].map((char) => char + char).join("");
20482
+ }
20483
+ const integer = Number.parseInt(colorString, 16);
20484
+ const r = integer >> 16 & 255;
20485
+ const g = integer >> 8 & 255;
20486
+ const b = integer & 255;
20487
+ return [r, g, b];
20488
+ };
20489
+ convert.rgb.hcg = function(rgb) {
20490
+ const r = rgb[0] / 255;
20491
+ const g = rgb[1] / 255;
20492
+ const b = rgb[2] / 255;
20493
+ const max = Math.max(Math.max(r, g), b);
20494
+ const min = Math.min(Math.min(r, g), b);
20495
+ const chroma = max - min;
20496
+ let hue;
20497
+ const grayscale = chroma < 1 ? min / (1 - chroma) : 0;
20498
+ if (chroma <= 0) {
20499
+ hue = 0;
20500
+ } else if (max === r) {
20501
+ hue = (g - b) / chroma % 6;
20502
+ } else if (max === g) {
20503
+ hue = 2 + (b - r) / chroma;
20504
+ } else {
20505
+ hue = 4 + (r - g) / chroma;
20506
+ }
20507
+ hue /= 6;
20508
+ hue %= 1;
20509
+ return [hue * 360, chroma * 100, grayscale * 100];
20510
+ };
20511
+ convert.hsl.hcg = function(hsl) {
20512
+ const s = hsl[1] / 100;
20513
+ const l = hsl[2] / 100;
20514
+ const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
20515
+ let f = 0;
20516
+ if (c < 1) {
20517
+ f = (l - 0.5 * c) / (1 - c);
20518
+ }
20519
+ return [hsl[0], c * 100, f * 100];
20520
+ };
20521
+ convert.hsv.hcg = function(hsv) {
20522
+ const s = hsv[1] / 100;
20523
+ const v = hsv[2] / 100;
20524
+ const c = s * v;
20525
+ let f = 0;
20526
+ if (c < 1) {
20527
+ f = (v - c) / (1 - c);
20528
+ }
20529
+ return [hsv[0], c * 100, f * 100];
20530
+ };
20531
+ convert.hcg.rgb = function(hcg) {
20532
+ const h = hcg[0] / 360;
20533
+ const c = hcg[1] / 100;
20534
+ const g = hcg[2] / 100;
20535
+ if (c === 0) {
20536
+ return [g * 255, g * 255, g * 255];
20537
+ }
20538
+ const pure = [0, 0, 0];
20539
+ const hi = h % 1 * 6;
20540
+ const v = hi % 1;
20541
+ const w = 1 - v;
20542
+ let mg = 0;
20543
+ switch (Math.floor(hi)) {
20544
+ case 0: {
20545
+ pure[0] = 1;
20546
+ pure[1] = v;
20547
+ pure[2] = 0;
20548
+ break;
20549
+ }
20550
+ case 1: {
20551
+ pure[0] = w;
20552
+ pure[1] = 1;
20553
+ pure[2] = 0;
20554
+ break;
20555
+ }
20556
+ case 2: {
20557
+ pure[0] = 0;
20558
+ pure[1] = 1;
20559
+ pure[2] = v;
20560
+ break;
20561
+ }
20562
+ case 3: {
20563
+ pure[0] = 0;
20564
+ pure[1] = w;
20565
+ pure[2] = 1;
20566
+ break;
20567
+ }
20568
+ case 4: {
20569
+ pure[0] = v;
20570
+ pure[1] = 0;
20571
+ pure[2] = 1;
20572
+ break;
20573
+ }
20574
+ default: {
20575
+ pure[0] = 1;
20576
+ pure[1] = 0;
20577
+ pure[2] = w;
20578
+ }
20579
+ }
20580
+ mg = (1 - c) * g;
20581
+ return [
20582
+ (c * pure[0] + mg) * 255,
20583
+ (c * pure[1] + mg) * 255,
20584
+ (c * pure[2] + mg) * 255
20585
+ ];
20586
+ };
20587
+ convert.hcg.hsv = function(hcg) {
20588
+ const c = hcg[1] / 100;
20589
+ const g = hcg[2] / 100;
20590
+ const v = c + g * (1 - c);
20591
+ let f = 0;
20592
+ if (v > 0) {
20593
+ f = c / v;
20594
+ }
20595
+ return [hcg[0], f * 100, v * 100];
20596
+ };
20597
+ convert.hcg.hsl = function(hcg) {
20598
+ const c = hcg[1] / 100;
20599
+ const g = hcg[2] / 100;
20600
+ const l = g * (1 - c) + 0.5 * c;
20601
+ let s = 0;
20602
+ if (l > 0 && l < 0.5) {
20603
+ s = c / (2 * l);
20604
+ } else if (l >= 0.5 && l < 1) {
20605
+ s = c / (2 * (1 - l));
20606
+ }
20607
+ return [hcg[0], s * 100, l * 100];
20608
+ };
20609
+ convert.hcg.hwb = function(hcg) {
20610
+ const c = hcg[1] / 100;
20611
+ const g = hcg[2] / 100;
20612
+ const v = c + g * (1 - c);
20613
+ return [hcg[0], (v - c) * 100, (1 - v) * 100];
20614
+ };
20615
+ convert.hwb.hcg = function(hwb) {
20616
+ const w = hwb[1] / 100;
20617
+ const b = hwb[2] / 100;
20618
+ const v = 1 - b;
20619
+ const c = v - w;
20620
+ let g = 0;
20621
+ if (c < 1) {
20622
+ g = (v - c) / (1 - c);
20623
+ }
20624
+ return [hwb[0], c * 100, g * 100];
20625
+ };
20626
+ convert.apple.rgb = function(apple) {
20627
+ return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
20628
+ };
20629
+ convert.rgb.apple = function(rgb) {
20630
+ return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
20631
+ };
20632
+ convert.gray.rgb = function(args) {
20633
+ return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
20634
+ };
20635
+ convert.gray.hsl = function(args) {
20636
+ return [0, 0, args[0]];
20637
+ };
20638
+ convert.gray.hsv = convert.gray.hsl;
20639
+ convert.gray.hwb = function(gray) {
20640
+ return [0, 100, gray[0]];
20641
+ };
20642
+ convert.gray.cmyk = function(gray) {
20643
+ return [0, 0, 0, gray[0]];
20644
+ };
20645
+ convert.gray.lab = function(gray) {
20646
+ return [gray[0], 0, 0];
20647
+ };
20648
+ convert.gray.hex = function(gray) {
20649
+ const value = Math.round(gray[0] / 100 * 255) & 255;
20650
+ const integer = (value << 16) + (value << 8) + value;
20651
+ const string = integer.toString(16).toUpperCase();
20652
+ return "000000".slice(string.length) + string;
20653
+ };
20654
+ convert.rgb.gray = function(rgb) {
20655
+ const value = (rgb[0] + rgb[1] + rgb[2]) / 3;
20656
+ return [value / 255 * 100];
20657
+ };
20658
+
20659
+ // node_modules/color-convert/route.js
20660
+ function buildGraph() {
20661
+ const graph = {};
20662
+ const models2 = Object.keys(conversions_default);
20663
+ for (let { length } = models2, i = 0; i < length; i++) {
20664
+ graph[models2[i]] = {
20665
+ // http://jsperf.com/1-vs-infinity
20666
+ // micro-opt, but this is simple.
20667
+ distance: -1,
20668
+ parent: null
20669
+ };
20670
+ }
20671
+ return graph;
20672
+ }
20673
+ function deriveBFS(fromModel) {
20674
+ const graph = buildGraph();
20675
+ const queue = [fromModel];
20676
+ graph[fromModel].distance = 0;
20677
+ while (queue.length > 0) {
20678
+ const current = queue.pop();
20679
+ const adjacents = Object.keys(conversions_default[current]);
20680
+ for (let { length } = adjacents, i = 0; i < length; i++) {
20681
+ const adjacent = adjacents[i];
20682
+ const node = graph[adjacent];
20683
+ if (node.distance === -1) {
20684
+ node.distance = graph[current].distance + 1;
20685
+ node.parent = current;
20686
+ queue.unshift(adjacent);
20687
+ }
20688
+ }
20689
+ }
20690
+ return graph;
20691
+ }
20692
+ function link(from, to) {
20693
+ return function(args) {
20694
+ return to(from(args));
20695
+ };
20696
+ }
20697
+ function wrapConversion(toModel, graph) {
20698
+ const path = [graph[toModel].parent, toModel];
20699
+ let fn = conversions_default[graph[toModel].parent][toModel];
20700
+ let cur = graph[toModel].parent;
20701
+ while (graph[cur].parent) {
20702
+ path.unshift(graph[cur].parent);
20703
+ fn = link(conversions_default[graph[cur].parent][cur], fn);
20704
+ cur = graph[cur].parent;
20705
+ }
20706
+ fn.conversion = path;
20707
+ return fn;
20708
+ }
20709
+ function route(fromModel) {
20710
+ const graph = deriveBFS(fromModel);
20711
+ const conversion = {};
20712
+ const models2 = Object.keys(graph);
20713
+ for (let { length } = models2, i = 0; i < length; i++) {
20714
+ const toModel = models2[i];
20715
+ const node = graph[toModel];
20716
+ if (node.parent === null) {
20717
+ continue;
20718
+ }
20719
+ conversion[toModel] = wrapConversion(toModel, graph);
20720
+ }
20721
+ return conversion;
20722
+ }
20723
+ var route_default = route;
20724
+
20725
+ // node_modules/color-convert/index.js
20726
+ var convert2 = {};
20727
+ var models = Object.keys(conversions_default);
20728
+ function wrapRaw(fn) {
20729
+ const wrappedFn = function(...args) {
20730
+ const arg0 = args[0];
20731
+ if (arg0 === void 0 || arg0 === null) {
20732
+ return arg0;
20733
+ }
20734
+ if (arg0.length > 1) {
20735
+ args = arg0;
20736
+ }
20737
+ return fn(args);
20738
+ };
20739
+ if ("conversion" in fn) {
20740
+ wrappedFn.conversion = fn.conversion;
20741
+ }
20742
+ return wrappedFn;
20743
+ }
20744
+ function wrapRounded(fn) {
20745
+ const wrappedFn = function(...args) {
20746
+ const arg0 = args[0];
20747
+ if (arg0 === void 0 || arg0 === null) {
20748
+ return arg0;
20749
+ }
20750
+ if (arg0.length > 1) {
20751
+ args = arg0;
20752
+ }
20753
+ const result = fn(args);
20754
+ if (typeof result === "object") {
20755
+ for (let { length } = result, i = 0; i < length; i++) {
20756
+ result[i] = Math.round(result[i]);
20757
+ }
20758
+ }
20759
+ return result;
20760
+ };
20761
+ if ("conversion" in fn) {
20762
+ wrappedFn.conversion = fn.conversion;
20763
+ }
20764
+ return wrappedFn;
20765
+ }
20766
+ for (const fromModel of models) {
20767
+ convert2[fromModel] = {};
20768
+ Object.defineProperty(convert2[fromModel], "channels", { value: conversions_default[fromModel].channels });
20769
+ Object.defineProperty(convert2[fromModel], "labels", { value: conversions_default[fromModel].labels });
20770
+ const routes = route_default(fromModel);
20771
+ const routeModels = Object.keys(routes);
20772
+ for (const toModel of routeModels) {
20773
+ const fn = routes[toModel];
20774
+ convert2[fromModel][toModel] = wrapRounded(fn);
20775
+ convert2[fromModel][toModel].raw = wrapRaw(fn);
20776
+ }
20777
+ }
20778
+ var color_convert_default = convert2;
20779
+
20780
+ // node_modules/color/index.js
20781
+ var skippedModels = [
20782
+ // To be honest, I don't really feel like keyword belongs in color convert, but eh.
20783
+ "keyword",
20784
+ // Gray conflicts with some method names, and has its own method defined.
20785
+ "gray",
20786
+ // Shouldn't really be in color-convert either...
20787
+ "hex"
20788
+ ];
20789
+ var hashedModelKeys = {};
20790
+ for (const model of Object.keys(color_convert_default)) {
20791
+ hashedModelKeys[[...color_convert_default[model].labels].sort().join("")] = model;
20792
+ }
20793
+ var limiters = {};
20794
+ function Color2(object, model) {
20795
+ if (!(this instanceof Color2)) {
20796
+ return new Color2(object, model);
20797
+ }
20798
+ if (model && model in skippedModels) {
20799
+ model = null;
20800
+ }
20801
+ if (model && !(model in color_convert_default)) {
20802
+ throw new Error("Unknown model: " + model);
20803
+ }
20804
+ let i;
20805
+ let channels;
20806
+ if (object == null) {
20807
+ this.model = "rgb";
20808
+ this.color = [0, 0, 0];
20809
+ this.valpha = 1;
20810
+ } else if (object instanceof Color2) {
20811
+ this.model = object.model;
20812
+ this.color = [...object.color];
20813
+ this.valpha = object.valpha;
20814
+ } else if (typeof object === "string") {
20815
+ const result = color_string_default.get(object);
20816
+ if (result === null) {
20817
+ throw new Error("Unable to parse color from string: " + object);
20818
+ }
20819
+ this.model = result.model;
20820
+ channels = color_convert_default[this.model].channels;
20821
+ this.color = result.value.slice(0, channels);
20822
+ this.valpha = typeof result.value[channels] === "number" ? result.value[channels] : 1;
20823
+ } else if (object.length > 0) {
20824
+ this.model = model || "rgb";
20825
+ channels = color_convert_default[this.model].channels;
20826
+ const newArray = Array.prototype.slice.call(object, 0, channels);
20827
+ this.color = zeroArray(newArray, channels);
20828
+ this.valpha = typeof object[channels] === "number" ? object[channels] : 1;
20829
+ } else if (typeof object === "number") {
20830
+ this.model = "rgb";
20831
+ this.color = [
20832
+ object >> 16 & 255,
20833
+ object >> 8 & 255,
20834
+ object & 255
20835
+ ];
20836
+ this.valpha = 1;
20837
+ } else {
20838
+ this.valpha = 1;
20839
+ const keys = Object.keys(object);
20840
+ if ("alpha" in object) {
20841
+ keys.splice(keys.indexOf("alpha"), 1);
20842
+ this.valpha = typeof object.alpha === "number" ? object.alpha : 0;
20843
+ }
20844
+ const hashedKeys = keys.sort().join("");
20845
+ if (!(hashedKeys in hashedModelKeys)) {
20846
+ throw new Error("Unable to parse color from object: " + JSON.stringify(object));
20847
+ }
20848
+ this.model = hashedModelKeys[hashedKeys];
20849
+ const { labels } = color_convert_default[this.model];
20850
+ const color = [];
20851
+ for (i = 0; i < labels.length; i++) {
20852
+ color.push(object[labels[i]]);
20853
+ }
20854
+ this.color = zeroArray(color);
20855
+ }
20856
+ if (limiters[this.model]) {
20857
+ channels = color_convert_default[this.model].channels;
20858
+ for (i = 0; i < channels; i++) {
20859
+ const limit = limiters[this.model][i];
20860
+ if (limit) {
20861
+ this.color[i] = limit(this.color[i]);
20862
+ }
20863
+ }
20864
+ }
20865
+ this.valpha = Math.max(0, Math.min(1, this.valpha));
20866
+ if (Object.freeze) {
20867
+ Object.freeze(this);
20868
+ }
20869
+ }
20870
+ Color2.prototype = {
20871
+ toString() {
20872
+ return this.string();
20873
+ },
20874
+ toJSON() {
20875
+ return this[this.model]();
20876
+ },
20877
+ string(places) {
20878
+ let self = this.model in color_string_default.to ? this : this.rgb();
20879
+ self = self.round(typeof places === "number" ? places : 1);
20880
+ const arguments_ = self.valpha === 1 ? self.color : [...self.color, this.valpha];
20881
+ return color_string_default.to[self.model](...arguments_);
20882
+ },
20883
+ percentString(places) {
20884
+ const self = this.rgb().round(typeof places === "number" ? places : 1);
20885
+ const arguments_ = self.valpha === 1 ? self.color : [...self.color, this.valpha];
20886
+ return color_string_default.to.rgb.percent(...arguments_);
20887
+ },
20888
+ array() {
20889
+ return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
20890
+ },
20891
+ object() {
20892
+ const result = {};
20893
+ const { channels } = color_convert_default[this.model];
20894
+ const { labels } = color_convert_default[this.model];
20895
+ for (let i = 0; i < channels; i++) {
20896
+ result[labels[i]] = this.color[i];
20897
+ }
20898
+ if (this.valpha !== 1) {
20899
+ result.alpha = this.valpha;
20900
+ }
20901
+ return result;
20902
+ },
20903
+ unitArray() {
20904
+ const rgb = this.rgb().color;
20905
+ rgb[0] /= 255;
20906
+ rgb[1] /= 255;
20907
+ rgb[2] /= 255;
20908
+ if (this.valpha !== 1) {
20909
+ rgb.push(this.valpha);
20910
+ }
20911
+ return rgb;
20912
+ },
20913
+ unitObject() {
20914
+ const rgb = this.rgb().object();
20915
+ rgb.r /= 255;
20916
+ rgb.g /= 255;
20917
+ rgb.b /= 255;
20918
+ if (this.valpha !== 1) {
20919
+ rgb.alpha = this.valpha;
20920
+ }
20921
+ return rgb;
20922
+ },
20923
+ round(places) {
20924
+ places = Math.max(places || 0, 0);
20925
+ return new Color2([...this.color.map(roundToPlace(places)), this.valpha], this.model);
20926
+ },
20927
+ alpha(value) {
20928
+ if (value !== void 0) {
20929
+ return new Color2([...this.color, Math.max(0, Math.min(1, value))], this.model);
20930
+ }
20931
+ return this.valpha;
20932
+ },
20933
+ // Rgb
20934
+ red: getset("rgb", 0, maxfn(255)),
20935
+ green: getset("rgb", 1, maxfn(255)),
20936
+ blue: getset("rgb", 2, maxfn(255)),
20937
+ hue: getset(["hsl", "hsv", "hsl", "hwb", "hcg"], 0, (value) => (value % 360 + 360) % 360),
20938
+ saturationl: getset("hsl", 1, maxfn(100)),
20939
+ lightness: getset("hsl", 2, maxfn(100)),
20940
+ saturationv: getset("hsv", 1, maxfn(100)),
20941
+ value: getset("hsv", 2, maxfn(100)),
20942
+ chroma: getset("hcg", 1, maxfn(100)),
20943
+ gray: getset("hcg", 2, maxfn(100)),
20944
+ white: getset("hwb", 1, maxfn(100)),
20945
+ wblack: getset("hwb", 2, maxfn(100)),
20946
+ cyan: getset("cmyk", 0, maxfn(100)),
20947
+ magenta: getset("cmyk", 1, maxfn(100)),
20948
+ yellow: getset("cmyk", 2, maxfn(100)),
20949
+ black: getset("cmyk", 3, maxfn(100)),
20950
+ x: getset("xyz", 0, maxfn(95.047)),
20951
+ y: getset("xyz", 1, maxfn(100)),
20952
+ z: getset("xyz", 2, maxfn(108.833)),
20953
+ l: getset("lab", 0, maxfn(100)),
20954
+ a: getset("lab", 1),
20955
+ b: getset("lab", 2),
20956
+ keyword(value) {
20957
+ if (value !== void 0) {
20958
+ return new Color2(value);
20959
+ }
20960
+ return color_convert_default[this.model].keyword(this.color);
20961
+ },
20962
+ hex(value) {
20963
+ if (value !== void 0) {
20964
+ return new Color2(value);
20965
+ }
20966
+ return color_string_default.to.hex(...this.rgb().round().color);
20967
+ },
20968
+ hexa(value) {
20969
+ if (value !== void 0) {
20970
+ return new Color2(value);
20971
+ }
20972
+ const rgbArray = this.rgb().round().color;
20973
+ let alphaHex = Math.round(this.valpha * 255).toString(16).toUpperCase();
20974
+ if (alphaHex.length === 1) {
20975
+ alphaHex = "0" + alphaHex;
20976
+ }
20977
+ return color_string_default.to.hex(...rgbArray) + alphaHex;
20978
+ },
20979
+ rgbNumber() {
20980
+ const rgb = this.rgb().color;
20981
+ return (rgb[0] & 255) << 16 | (rgb[1] & 255) << 8 | rgb[2] & 255;
20982
+ },
20983
+ luminosity() {
20984
+ const rgb = this.rgb().color;
20985
+ const lum = [];
20986
+ for (const [i, element] of rgb.entries()) {
20987
+ const chan = element / 255;
20988
+ lum[i] = chan <= 0.04045 ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
20989
+ }
20990
+ return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
20991
+ },
20992
+ contrast(color2) {
20993
+ const lum1 = this.luminosity();
20994
+ const lum2 = color2.luminosity();
20995
+ if (lum1 > lum2) {
20996
+ return (lum1 + 0.05) / (lum2 + 0.05);
20997
+ }
20998
+ return (lum2 + 0.05) / (lum1 + 0.05);
20999
+ },
21000
+ level(color2) {
21001
+ const contrastRatio = this.contrast(color2);
21002
+ if (contrastRatio >= 7) {
21003
+ return "AAA";
21004
+ }
21005
+ return contrastRatio >= 4.5 ? "AA" : "";
21006
+ },
21007
+ isDark() {
21008
+ const rgb = this.rgb().color;
21009
+ const yiq = (rgb[0] * 2126 + rgb[1] * 7152 + rgb[2] * 722) / 1e4;
21010
+ return yiq < 128;
21011
+ },
21012
+ isLight() {
21013
+ return !this.isDark();
21014
+ },
21015
+ negate() {
21016
+ const rgb = this.rgb();
21017
+ for (let i = 0; i < 3; i++) {
21018
+ rgb.color[i] = 255 - rgb.color[i];
21019
+ }
21020
+ return rgb;
21021
+ },
21022
+ lighten(ratio) {
21023
+ const hsl = this.hsl();
21024
+ hsl.color[2] += hsl.color[2] * ratio;
21025
+ return hsl;
21026
+ },
21027
+ darken(ratio) {
21028
+ const hsl = this.hsl();
21029
+ hsl.color[2] -= hsl.color[2] * ratio;
21030
+ return hsl;
21031
+ },
21032
+ saturate(ratio) {
21033
+ const hsl = this.hsl();
21034
+ hsl.color[1] += hsl.color[1] * ratio;
21035
+ return hsl;
21036
+ },
21037
+ desaturate(ratio) {
21038
+ const hsl = this.hsl();
21039
+ hsl.color[1] -= hsl.color[1] * ratio;
21040
+ return hsl;
21041
+ },
21042
+ whiten(ratio) {
21043
+ const hwb = this.hwb();
21044
+ hwb.color[1] += hwb.color[1] * ratio;
21045
+ return hwb;
21046
+ },
21047
+ blacken(ratio) {
21048
+ const hwb = this.hwb();
21049
+ hwb.color[2] += hwb.color[2] * ratio;
21050
+ return hwb;
21051
+ },
21052
+ grayscale() {
21053
+ const rgb = this.rgb().color;
21054
+ const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
21055
+ return Color2.rgb(value, value, value);
21056
+ },
21057
+ fade(ratio) {
21058
+ return this.alpha(this.valpha - this.valpha * ratio);
21059
+ },
21060
+ opaquer(ratio) {
21061
+ return this.alpha(this.valpha + this.valpha * ratio);
21062
+ },
21063
+ rotate(degrees) {
21064
+ const hsl = this.hsl();
21065
+ let hue = hsl.color[0];
21066
+ hue = (hue + degrees) % 360;
21067
+ hue = hue < 0 ? 360 + hue : hue;
21068
+ hsl.color[0] = hue;
21069
+ return hsl;
21070
+ },
21071
+ mix(mixinColor, weight) {
21072
+ if (!mixinColor || !mixinColor.rgb) {
21073
+ throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
21074
+ }
21075
+ const color1 = mixinColor.rgb();
21076
+ const color2 = this.rgb();
21077
+ const p = weight === void 0 ? 0.5 : weight;
21078
+ const w = 2 * p - 1;
21079
+ const a = color1.alpha() - color2.alpha();
21080
+ const w1 = ((w * a === -1 ? w : (w + a) / (1 + w * a)) + 1) / 2;
21081
+ const w2 = 1 - w1;
21082
+ return Color2.rgb(
21083
+ w1 * color1.red() + w2 * color2.red(),
21084
+ w1 * color1.green() + w2 * color2.green(),
21085
+ w1 * color1.blue() + w2 * color2.blue(),
21086
+ color1.alpha() * p + color2.alpha() * (1 - p)
21087
+ );
21088
+ }
21089
+ };
21090
+ for (const model of Object.keys(color_convert_default)) {
21091
+ if (skippedModels.includes(model)) {
21092
+ continue;
21093
+ }
21094
+ const { channels } = color_convert_default[model];
21095
+ Color2.prototype[model] = function(...arguments_) {
21096
+ if (this.model === model) {
21097
+ return new Color2(this);
21098
+ }
21099
+ if (arguments_.length > 0) {
21100
+ return new Color2(arguments_, model);
21101
+ }
21102
+ return new Color2([...assertArray(color_convert_default[this.model][model].raw(this.color)), this.valpha], model);
21103
+ };
21104
+ Color2[model] = function(...arguments_) {
21105
+ let color = arguments_[0];
21106
+ if (typeof color === "number") {
21107
+ color = zeroArray(arguments_, channels);
21108
+ }
21109
+ return new Color2(color, model);
21110
+ };
21111
+ }
21112
+ function roundTo(number, places) {
21113
+ return Number(number.toFixed(places));
21114
+ }
21115
+ function roundToPlace(places) {
21116
+ return function(number) {
21117
+ return roundTo(number, places);
21118
+ };
21119
+ }
21120
+ function getset(model, channel, modifier) {
21121
+ model = Array.isArray(model) ? model : [model];
21122
+ for (const m of model) {
21123
+ (limiters[m] || (limiters[m] = []))[channel] = modifier;
21124
+ }
21125
+ model = model[0];
21126
+ return function(value) {
21127
+ let result;
21128
+ if (value !== void 0) {
21129
+ if (modifier) {
21130
+ value = modifier(value);
21131
+ }
21132
+ result = this[model]();
21133
+ result.color[channel] = value;
21134
+ return result;
21135
+ }
21136
+ result = this[model]().color[channel];
21137
+ if (modifier) {
21138
+ result = modifier(result);
21139
+ }
21140
+ return result;
21141
+ };
21142
+ }
21143
+ function maxfn(max) {
21144
+ return function(v) {
21145
+ return Math.max(0, Math.min(max, v));
21146
+ };
21147
+ }
21148
+ function assertArray(value) {
21149
+ return Array.isArray(value) ? value : [value];
21150
+ }
21151
+ function zeroArray(array, length) {
21152
+ for (let i = 0; i < length; i++) {
21153
+ if (typeof array[i] !== "number") {
21154
+ array[i] = 0;
21155
+ }
21156
+ }
21157
+ return array;
21158
+ }
21159
+ var color_default = Color2;
21160
+
19533
21161
  // src/components/ui/color-picker.tsx
19534
- var import_color = __toESM(require("color"));
19535
21162
  var import_lucide_react48 = require("lucide-react");
19536
21163
  var import_radix_ui = require("radix-ui");
19537
21164
  var import_react56 = require("react");
@@ -19554,8 +21181,8 @@ var ColorPicker = ({
19554
21181
  className,
19555
21182
  ...props
19556
21183
  }) => {
19557
- const selectedColor = (0, import_color.default)(value);
19558
- const defaultColor = (0, import_color.default)(defaultValue);
21184
+ const selectedColor = color_default(value);
21185
+ const defaultColor = color_default(defaultValue);
19559
21186
  const [hue, setHue] = (0, import_react56.useState)(selectedColor.hue() || defaultColor.hue() || 0);
19560
21187
  const [saturation, setSaturation] = (0, import_react56.useState)(
19561
21188
  selectedColor.saturationl() || defaultColor.saturationl() || 100
@@ -19575,7 +21202,7 @@ var ColorPicker = ({
19575
21202
  alphaRef.current = alpha2;
19576
21203
  (0, import_react56.useEffect)(() => {
19577
21204
  if (value) {
19578
- const color = (0, import_color.default)(value);
21205
+ const color = color_default(value);
19579
21206
  const hsl = color.hsl().object();
19580
21207
  setHue(hsl.h);
19581
21208
  setSaturation(hsl.s);
@@ -19609,7 +21236,7 @@ var ColorPicker = ({
19609
21236
  alphaRef.current = updates.a;
19610
21237
  }
19611
21238
  if (onChange) {
19612
- const color = import_color.default.hsl(newH, newS, newL).alpha(newA / 100);
21239
+ const color = color_default.hsl(newH, newS, newL).alpha(newA / 100);
19613
21240
  const rgba = color.rgb().array();
19614
21241
  onChange([rgba[0], rgba[1], rgba[2], newA / 100]);
19615
21242
  }
@@ -19722,7 +21349,7 @@ var ColorPickerEyeDropper = ({ className, ...props }) => {
19722
21349
  try {
19723
21350
  const eyeDropper = new EyeDropper();
19724
21351
  const result = await eyeDropper.open();
19725
- const color = (0, import_color.default)(result.sRGBHex);
21352
+ const color = color_default(result.sRGBHex);
19726
21353
  const [h, s, l] = color.hsl().array();
19727
21354
  updateColor({ h, s, l, a: 100 });
19728
21355
  } catch (error) {
@@ -19761,7 +21388,7 @@ var PercentageInput = ({ className, ...props }) => {
19761
21388
  };
19762
21389
  var ColorPickerFormat = ({ className, ...props }) => {
19763
21390
  const { hue, saturation, lightness, alpha: alpha2, mode } = useColorPicker();
19764
- const color = import_color.default.hsl(hue, saturation, lightness, alpha2 / 100);
21391
+ const color = color_default.hsl(hue, saturation, lightness, alpha2 / 100);
19765
21392
  if (mode === "hex") {
19766
21393
  const hex = color.hex();
19767
21394
  return /* @__PURE__ */ (0, import_jsx_runtime77.jsxs)(
@@ -21271,14 +22898,14 @@ init_configuration();
21271
22898
  var import_react63 = require("react");
21272
22899
  function useEditableValue(options) {
21273
22900
  const { externalValue, onChange, toLocal, toExternal } = options;
21274
- const convert = toLocal ?? String;
21275
- const [localValue, setLocalValue] = (0, import_react63.useState)(convert(externalValue));
22901
+ const convert3 = toLocal ?? String;
22902
+ const [localValue, setLocalValue] = (0, import_react63.useState)(convert3(externalValue));
21276
22903
  const [isFocused, setIsFocused] = (0, import_react63.useState)(false);
21277
- const displayValue = isFocused ? localValue : convert(externalValue);
22904
+ const displayValue = isFocused ? localValue : convert3(externalValue);
21278
22905
  const handleFocus = (0, import_react63.useCallback)(() => {
21279
- setLocalValue(convert(externalValue));
22906
+ setLocalValue(convert3(externalValue));
21280
22907
  setIsFocused(true);
21281
- }, [externalValue, convert]);
22908
+ }, [externalValue, convert3]);
21282
22909
  const handleBlur = (0, import_react63.useCallback)(() => {
21283
22910
  setIsFocused(false);
21284
22911
  if (toExternal) {
@@ -27121,10 +28748,11 @@ function TemplatePage({
27121
28748
  onImageUpload,
27122
28749
  onDuplicate,
27123
28750
  onDelete,
28751
+ onTemplateCapture,
27124
28752
  data
27125
28753
  }) {
27126
28754
  (0, import_react97.useState)(() => {
27127
- useEditorStore.getState().initializeWithTemplate(templateId, initialTemplate, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete);
28755
+ useEditorStore.getState().initializeWithTemplate(templateId, initialTemplate, onSave, onToast, data, onExit, onImageUpload, onDuplicate, onDelete, onTemplateCapture);
27128
28756
  });
27129
28757
  useAutoSave();
27130
28758
  const [editorLoading, setEditorLoading] = (0, import_react97.useState)(false);