UNPKG

@alegendstale/holly-components

Version:

Reusable UI components created using lit

61 lines (60 loc) 2.01 kB
import { parseUrl as a, isColorValid as s, pluginToPaletteSettings as u } from "../../utils/basicUtils.js"; var c = /* @__PURE__ */ ((t) => (t.Row = "row", t.Column = "column", t))(c || {}), p = /* @__PURE__ */ ((t) => (t.Both = "Both", t.Alias = "Prefer Alias", t))(p || {}), d = /* @__PURE__ */ ((t) => (t.Raw = "Raw", t.Value = "Value", t))(d || {}); const w = { noticeDuration: 1e4, errorPulse: !0, aliasMode: "Both", corners: !0, stabilizeWhileEditing: !0, reloadDelay: 5, copyFormat: "Raw", height: 150, width: 700, direction: "column", gradient: !1, preventHover: !1, hideText: !1, override: !1 }; var f = /* @__PURE__ */ ((t) => (t.VALID = "Valid", t.INVALID_COLORS = "Invalid Colors", t.INVALID_SETTINGS = "Invalid Settings", t.INVALID_COLORS_AND_SETTINGS = "Invalid Colors & Settings", t.INVALID_GRADIENT = "Invalid Gradient", t))(f || {}); const I = /(?:https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)?[a-zA-Z0-9]{2,}(?:\.[a-zA-Z0-9]{2,})(?:\.[a-zA-Z0-9]{2,})?\/(?:palette\/)?([a-zA-Z0-9-]{2,})/; class A extends Error { constructor(i, e = "") { super(e), this.status = i; } } function h(t) { try { return JSON.parse(t); } catch { return "Invalid Settings"; } } function g(t, i) { let e = t.flatMap((r) => r.includes("(") ? r.split(";").flatMap((n) => n.trim()).filter((n) => n !== "") : r.split(",").flatMap((n) => n.trim())).flatMap((r) => r.trim().replace(";", "")); const l = e.join(""); if (l.match(I)) return a(l); if (!i) { for (let r of e) if (!s(r)) return "Invalid Colors"; } return e; } function S(t, i) { const e = t.split(` `); let r = e.some((o) => o.includes("{")) ? h(e.pop() || "") : void 0, n = typeof r == "object" ? r : u(i); return { colors: g(e, n.override), settings: r }; } export { p as AliasMode, d as CopyFormat, c as Direction, A as PaletteError, f as Status, S as calcColorsAndSettings, w as defaultSettings, g as parseColors, h as parseSettings, I as urlRegex };