UNPKG

images-viewer-vue3

Version:
149 lines (148 loc) 3.76 kB
let l = []; const w = /* @__PURE__ */ new WeakMap(); function d() { l.forEach((t) => t(...w.get(t))), l = []; } function q(t, ...e) { w.set(t, e), !l.includes(t) && l.push(t) === 1 && requestAnimationFrame(d); } function O(t) { return t.composedPath()[0] || null; } function P(t) { return typeof t == "string" ? t.endsWith("px") ? Number(t.slice(0, t.length - 2)) : Number(t) : t; } function S(t, e) { const n = t.trim().split(/\s+/g), r = { top: n[0] }; switch (n.length) { case 1: r.right = n[0], r.bottom = n[0], r.left = n[0]; break; case 2: r.right = n[1], r.left = n[1], r.bottom = n[0]; break; case 3: r.right = n[1], r.bottom = n[2], r.left = n[1]; break; case 4: r.right = n[1], r.bottom = n[2], r.left = n[3]; break; default: throw new Error("[seemly/getMargin]:" + t + " is not a valid value."); } return r; } const F = { black: "#000", silver: "#C0C0C0", gray: "#808080", white: "#FFF", maroon: "#800000", red: "#F00", purple: "#800080", fuchsia: "#F0F", green: "#008000", lime: "#0F0", olive: "#808000", yellow: "#FF0", navy: "#000080", blue: "#00F", teal: "#008080", aqua: "#0FF", transparent: "#0000" }, f = "^\\s*", $ = "\\s*$", o = "\\s*((\\.\\d+)|(\\d+(\\.\\d*)?))\\s*", c = "([0-9A-Fa-f])", u = "([0-9A-Fa-f]{2})", A = new RegExp(`${f}rgb\\s*\\(${o},${o},${o}\\)${$}`), y = new RegExp(`${f}rgba\\s*\\(${o},${o},${o},${o}\\)${$}`), E = new RegExp(`${f}#${c}${c}${c}${$}`), C = new RegExp(`${f}#${u}${u}${u}${$}`), M = new RegExp(`${f}#${c}${c}${c}${c}${$}`), N = new RegExp(`${f}#${u}${u}${u}${u}${$}`); function i(t) { return parseInt(t, 16); } function h(t) { try { let e; if (e = C.exec(t)) return [i(e[1]), i(e[2]), i(e[3]), 1]; if (e = A.exec(t)) return [s(e[1]), s(e[5]), s(e[9]), 1]; if (e = y.exec(t)) return [ s(e[1]), s(e[5]), s(e[9]), g(e[13]) ]; if (e = E.exec(t)) return [ i(e[1] + e[1]), i(e[2] + e[2]), i(e[3] + e[3]), 1 ]; if (e = N.exec(t)) return [ i(e[1]), i(e[2]), i(e[3]), g(i(e[4]) / 255) ]; if (e = M.exec(t)) return [ i(e[1] + e[1]), i(e[2] + e[2]), i(e[3] + e[3]), g(i(e[4] + e[4]) / 255) ]; if (t in F) return h(F[t]); throw new Error(`[seemly/rgba]: Invalid color value ${t}.`); } catch (e) { throw e; } } function H(t) { return t > 1 ? 1 : t < 0 ? 0 : t; } function b(t, e, n, r) { return `rgba(${s(t)}, ${s(e)}, ${s(n)}, ${H(r)})`; } function m(t, e, n, r, a) { return s((t * e * (1 - r) + n * r) / a); } function W(t, e) { Array.isArray(t) || (t = h(t)), Array.isArray(e) || (e = h(e)); const n = t[3], r = e[3], a = g(n + r - n * r); return b(m(t[0], n, e[0], r, a), m(t[1], n, e[1], r, a), m(t[2], n, e[2], r, a), a); } function k(t, e) { const [n, r, a, x = 1] = Array.isArray(t) ? t : h(t); return e.alpha ? b(n, r, a, e.alpha) : b(n, r, a, x); } function z(t, e) { const [n, r, a, x = 1] = Array.isArray(t) ? t : h(t), { lightness: p = 1, alpha: R = 1 } = e; return I([n * p, r * p, a * p, x * R]); } function g(t) { const e = Math.round(Number(t) * 100) / 100; return e > 1 ? 1 : e < 0 ? 0 : e; } function s(t) { const e = Math.round(Number(t)); return e > 255 ? 255 : e < 0 ? 0 : e; } function I(t) { const [e, n, r] = t; return 3 in t ? `rgba(${s(e)}, ${s(n)}, ${s(r)}, ${g(t[3])})` : `rgba(${s(e)}, ${s(n)}, ${s(r)}, 1)`; } function T(t = 8) { return Math.random().toString(16).slice(2, 2 + t); } export { O as a, k as b, W as c, P as d, T as e, q as f, S as g, h as r, z as s };