visionary-image 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -1,17 +1,17 @@
1
- # visionary-image
1
+ # Visionary Image
2
2
 
3
- ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/visionary-ux/visionary-image/.github%2Fworkflows%2Fci-cd-workflow.yml?branch=master&style=flat-square)
3
+ React image component with built-in Blurhash placeholders for better UX and Core Web Vitals.
4
4
 
5
- > Visionary Image rapidly renders blurhash placeholders and boosts Core Web Vitals.
5
+ ![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/visionary-ux/visionary-image/.github%2Fworkflows%2Fci-cd-workflow.yml?branch=master&style=flat-square) ![npm package size (minzipped, via Bundlephobia)](https://img.shields.io/bundlephobia/minzip/visionary-image?style=flat-square&color=blue)
6
6
 
7
7
  **Features:**
8
8
 
9
- - Blurhash data encoded in the image URL via [visionary-url](https://github.com/visionary-ux/visionary-url) means zero latency image placeholders
10
- - Renders a true-to-size, responsive blurhash placeholder while the image loads, <u>eliminating Cumulative Layout Shift (CLS)</u>
11
- - Off-screen images are lazily loaded, reducing initial pageload size and request count, <u>improving Interaction to Next Paint (INP)</u>
9
+ - Blurhash data encoded in the image URL via [visionary-url](https://github.com/visionary-ux/visionary-url) for instant image placeholders
10
+ - Renders a true-to-size, responsive Blurhash placeholder while the image loads, eliminating Cumulative Layout Shift (CLS)
11
+ - Images below the fold are lazily loaded, reducing initial page load size and request count, optimizing Interaction to Next Paint (INP)
12
12
  - Framework-tested (Remix, Next.js, Vite) with support for both client and server-side rendering (SSR, SSG) environments
13
13
  - Additional features: Prevent dragging, user-selection of image
14
- - Improves Core Web Vitals scores (CLS, and often INP and LCP) which are a primary ranking signal in Google Search
14
+ - Improves Core Web Vitals scores which Google notes as an important ranking signal in Search.
15
15
 
16
16
  > "We highly recommend site owners achieve good Core Web Vitals for success with Search", [Google Search Central](https://developers.google.com/search/docs/appearance/core-web-vitals)
17
17
 
@@ -23,21 +23,19 @@ Install via npm, yarn, or pnpm.
23
23
  npm install --save visionary-image
24
24
  ```
25
25
 
26
- ## Getting Started
26
+ ## Usage
27
27
 
28
- To render a Visionary Image, first create a Visionary URL.
28
+ Create a Visionary image URL to get started.
29
29
 
30
30
  ### Creating a Visionary Image URL
31
31
 
32
- To create a Visionary URL from a public image URL see [Visionary URL Generator](#).
32
+ There are several ways to create a Visionary URL.
33
33
 
34
- To generate Visionary data from a local file, use the [Drag-and-Drop Blurhash Generator](#).
34
+ 1. Use the [Visionary URL Maker](https://visionary.cloud/url-maker) for public image URLs
35
+ 2. Use the [Drag & Drop Blurhash Generator](https://visionary.cloud/image-to-blurhash) for local image files
36
+ 3. Use [visionary-url](https://github.com/visionary-ux/visionary-url) to programmatically generate a URL
35
37
 
36
- - Generate a Visionary URL at [https://visionary.cloud/url-generator](https://visionary.cloud/url-generator)
37
- - Copy a URL from your [Visionary Dashboard](https://visionary.cloud/dashboard)
38
- - Use this [sample URL]()
39
-
40
- ### Render image component
38
+ ### Render Image
41
39
 
42
40
  ```tsx
43
41
  import { Image } from "visionary-image";
@@ -1,10 +1,10 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.id="v7y-styles",e.appendChild(document.createTextNode('.v7y_7587:before{content:"";display:block;padding-top:var(--v-ar)}.v7y_f2b7{display:none}.v7y_b8c0{-webkit-user-drag:none;pointer-events:none}.v7y_e0dd{-webkit-user-select:none;user-select:none}')),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
2
- import { jsx as W, jsxs as yt } from "react/jsx-runtime";
3
- import { useRef as Y, useCallback as q, useState as wt, useEffect as xt, useLayoutEffect as Et, useMemo as It } from "react";
4
- function Rt(t) {
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.id="v7y-styles",e.appendChild(document.createTextNode('.v7y_7587:before{content:"";display:block;padding-top:var(--v-ar)}.v7y_b8c0{-webkit-user-drag:none;pointer-events:none}.v7y_e0dd{-webkit-user-select:none;user-select:none}')),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
2
+ import { jsx as G, jsxs as vt } from "react/jsx-runtime";
3
+ import { useRef as Y, useCallback as q, useState as wt, useEffect as It, useLayoutEffect as Et, useMemo as At } from "react";
4
+ function xt(t) {
5
5
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
6
6
  }
7
- var et = { exports: {} };
7
+ var nt = { exports: {} };
8
8
  /*!
9
9
  Copyright (c) 2018 Jed Watson.
10
10
  Licensed under the MIT License (MIT), see
@@ -15,8 +15,8 @@ var et = { exports: {} };
15
15
  var n = {}.hasOwnProperty;
16
16
  function e() {
17
17
  for (var r = "", s = 0; s < arguments.length; s++) {
18
- var a = arguments[s];
19
- a && (r = c(r, o(a)));
18
+ var u = arguments[s];
19
+ u && (r = i(r, o(u)));
20
20
  }
21
21
  return r;
22
22
  }
@@ -30,52 +30,52 @@ var et = { exports: {} };
30
30
  if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
31
31
  return r.toString();
32
32
  var s = "";
33
- for (var a in r)
34
- n.call(r, a) && r[a] && (s = c(s, a));
33
+ for (var u in r)
34
+ n.call(r, u) && r[u] && (s = i(s, u));
35
35
  return s;
36
36
  }
37
- function c(r, s) {
37
+ function i(r, s) {
38
38
  return s ? r ? r + " " + s : r + s : r;
39
39
  }
40
40
  t.exports ? (e.default = e, t.exports = e) : window.classNames = e;
41
41
  })();
42
- })(et);
43
- var At = et.exports;
44
- const K = /* @__PURE__ */ Rt(At), Nt = (t, { root: n, rootMargin: e, threshold: o } = {}, c = []) => {
42
+ })(nt);
43
+ var Rt = nt.exports;
44
+ const St = /* @__PURE__ */ xt(Rt), Ut = (t, { root: n, rootMargin: e, threshold: o } = {}, i = []) => {
45
45
  const r = Y(null), s = Y(null);
46
- return q((i) => {
47
- r.current && s.current && (s.current.unobserve(r.current), s.current.disconnect(), s.current = null), i && (s.current = new IntersectionObserver(t, { root: n, rootMargin: e, threshold: o }), s.current.observe(i), r.current = i);
48
- }, [r, n, e, JSON.stringify(o), ...c]);
49
- }, Ot = ({ root: t, rootMargin: n, threshold: e, unobserveOnEnter: o, target: c, onEnter: r, onLeave: s, defaultInView: a } = {}, i = []) => {
50
- const [d, h] = wt({
51
- inView: a || !1,
46
+ return q((c) => {
47
+ r.current && s.current && (s.current.unobserve(r.current), s.current.disconnect(), s.current = null), c && (s.current = new IntersectionObserver(t, { root: n, rootMargin: e, threshold: o }), s.current.observe(c), r.current = c);
48
+ }, [r, n, e, JSON.stringify(o), ...i]);
49
+ }, Nt = ({ root: t, rootMargin: n, threshold: e, unobserveOnEnter: o, target: i, onEnter: r, onLeave: s, defaultInView: u } = {}, c = []) => {
50
+ const [a, p] = wt({
51
+ inView: u || !1,
52
52
  entry: null,
53
53
  observer: null
54
- }), f = q(([p], l) => {
55
- const b = l.thresholds.some((g) => p.intersectionRatio >= g) && p.isIntersecting;
56
- h({
54
+ }), l = q(([h], f) => {
55
+ const b = f.thresholds.some((g) => h.intersectionRatio >= g) && h.isIntersecting;
56
+ p({
57
57
  inView: b,
58
- entry: p,
59
- observer: l
60
- }), b && o && (l.unobserve(p.target), l.disconnect()), b ? r == null || r(p, l) : s == null || s(p, l);
61
- }, [r, s, o]), m = Nt(f, { root: t, rootMargin: n, threshold: e }, [o, ...i]);
62
- return xt(() => {
63
- c != null && c.current && m(c.current);
64
- }, [c, m]), [m, d.inView, d.entry, d.observer];
58
+ entry: h,
59
+ observer: f
60
+ }), b && o && (f.unobserve(h.target), f.disconnect()), b ? r == null || r(h, f) : s == null || s(h, f);
61
+ }, [r, s, o]), m = Ut(l, { root: t, rootMargin: n, threshold: e }, [o, ...c]);
62
+ return It(() => {
63
+ i != null && i.current && m(i.current);
64
+ }, [i, m]), [m, a.inView, a.entry, a.observer];
65
65
  };
66
- var L = /* @__PURE__ */ ((t) => (t.AUTO = "auto", t.AVIF = "avif", t.JPEG = "jpeg", t.WEBP = "webp", t))(L || {}), y = /* @__PURE__ */ ((t) => (t.xs = "xs", t.sm = "sm", t.md = "md", t.lg = "lg", t.xl = "xl", t.xxl = "xxl", t["4k"] = "4k", t["5k"] = "5k", t.full = "full", t))(y || {}), C = /* @__PURE__ */ ((t) => (t.DEBUG = "debug", t.DOWNLOAD = "download", t))(C || {});
67
- const Ut = "https://link.visionary.cloud";
68
- L.AUTO, y.lg;
66
+ var V = /* @__PURE__ */ ((t) => (t.AUTO = "auto", t.AVIF = "avif", t.JPEG = "jpeg", t.WEBP = "webp", t))(V || {}), v = /* @__PURE__ */ ((t) => (t.xs = "xs", t.sm = "sm", t.md = "md", t.lg = "lg", t.xl = "xl", t.xxl = "xxl", t["4k"] = "4k", t["5k"] = "5k", t.full = "full", t))(v || {}), T = /* @__PURE__ */ ((t) => (t.DEBUG = "debug", t.DOWNLOAD = "download", t))(T || {});
67
+ const Ot = "https://link.visionary.cloud";
68
+ V.AUTO, v.lg;
69
69
  const Z = {
70
- [y.xs]: 160,
71
- [y.sm]: 320,
72
- [y.md]: 640,
73
- [y.lg]: 1280,
74
- [y.xl]: 1920,
75
- [y.xxl]: 2560,
76
- [y["4k"]]: 3840,
77
- [y["5k"]]: 5120,
78
- [y.full]: 0
70
+ [v.xs]: 160,
71
+ [v.sm]: 320,
72
+ [v.md]: 640,
73
+ [v.lg]: 1280,
74
+ [v.xl]: 1920,
75
+ [v.xxl]: 2560,
76
+ [v["4k"]]: 3840,
77
+ [v["5k"]]: 5120,
78
+ [v.full]: 0
79
79
  };
80
80
  Object.keys(Z).reduce(
81
81
  (t, n) => {
@@ -84,118 +84,118 @@ Object.keys(Z).reduce(
84
84
  },
85
85
  {}
86
86
  );
87
- const rt = "!";
88
- var St = Object.defineProperty, Tt = (t, n, e) => n in t ? St(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e, _t = (t, n, e) => Tt(t, typeof n != "symbol" ? n + "" : n, e), J = {}, j = {};
89
- Object.defineProperty(j, "__esModule", { value: !0 });
90
- function Ct(t) {
87
+ const et = "!";
88
+ var Tt = Object.defineProperty, Ct = (t, n, e) => n in t ? Tt(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e, Dt = (t, n, e) => Ct(t, typeof n != "symbol" ? n + "" : n, e), J = {}, $ = {};
89
+ Object.defineProperty($, "__esModule", { value: !0 });
90
+ function Pt(t) {
91
91
  return String.fromCharCode(parseInt(t.slice(1), 16));
92
92
  }
93
- function Dt(t) {
94
- return btoa(encodeURIComponent(t).replace(/%[0-9A-F]{2}/g, Ct));
93
+ function _t(t) {
94
+ return btoa(encodeURIComponent(t).replace(/%[0-9A-F]{2}/g, Pt));
95
95
  }
96
- j.encode = Dt;
97
- function Pt(t) {
96
+ $.encode = _t;
97
+ function Lt(t) {
98
98
  return `%${`00${t.charCodeAt(0).toString(16)}`.slice(-2)}`;
99
99
  }
100
100
  function Vt(t) {
101
- return decodeURIComponent(Array.from(atob(t), Pt).join(""));
101
+ return decodeURIComponent(Array.from(atob(t), Lt).join(""));
102
102
  }
103
- j.decode = Vt;
103
+ $.decode = Vt;
104
104
  Object.defineProperty(J, "__esModule", { value: !0 });
105
- const ot = j;
105
+ const rt = $;
106
106
  function $t(t) {
107
- return ot.decode(t.replace(/\-/g, "+").replace(/_/g, "/"));
107
+ return rt.decode(t.replace(/\-/g, "+").replace(/_/g, "/"));
108
108
  }
109
- var Lt = J.decode = $t;
110
- function jt(t) {
111
- return ot.encode(t).replace(/\//g, "_").replace(/\+/g, "-").replace(/=+$/, "");
109
+ var jt = J.decode = $t;
110
+ function kt(t) {
111
+ return rt.encode(t).replace(/\//g, "_").replace(/\+/g, "-").replace(/=+$/, "");
112
112
  }
113
- var kt = J.encode = jt;
114
- const zt = (t) => t.filter(Boolean), Q = (t) => {
113
+ var zt = J.encode = kt;
114
+ const Bt = (t) => t.filter(Boolean), K = (t) => {
115
115
  try {
116
116
  return new URL(t);
117
117
  } catch {
118
118
  return null;
119
119
  }
120
- }, k = (t = "") => /^[A-Za-z0-9_-]*$/.test(t), Bt = (t) => {
121
- const { altText: n, bcc: e, blurhash: o, blurhashX: c, blurhashY: r, sourceHeight: s, sourceWidth: a, url: i } = t;
122
- if (!i || !a || !s)
120
+ }, j = (t = "") => /^[A-Za-z0-9_-]*$/.test(t), Mt = (t) => {
121
+ const { altText: n, bcc: e, blurhash: o, blurhashX: i, blurhashY: r, sourceHeight: s, sourceWidth: u, url: c } = t;
122
+ if (!c || !u || !s)
123
123
  return new Error("Cannot construct visionary code: missing required url/width/height");
124
- const d = [i, a, s];
125
- return !e || (d.push(e), !o || !c || !r) || (d.push(o, c, r), n && n.length && d.push(n)), Mt(d);
126
- }, Mt = (t) => kt(t.join(rt)), st = (t) => {
124
+ const a = [c, u, s];
125
+ return !e || (a.push(e), !o || !i || !r) || (a.push(o, i, r), n && n.length && a.push(n)), Gt(a);
126
+ }, Gt = (t) => zt(t.join(et)), ot = (t) => {
127
127
  if (typeof t != "string")
128
128
  return null;
129
129
  const n = t.trim();
130
- if (!n.length || !k(n))
130
+ if (!n.length || !j(n))
131
131
  return null;
132
- const e = Lt(n);
132
+ const e = jt(n);
133
133
  if (!e)
134
134
  return null;
135
- const o = e.split(rt);
135
+ const o = e.split(et);
136
136
  if (o.length < 3)
137
137
  return null;
138
- const [c, r, s, a, i, d, h, f] = o, m = c.trim();
138
+ const [i, r, s, u, c, a, p, l] = o, m = i.trim();
139
139
  if (!m.length)
140
140
  return console.error("Cannot parse code, empty file id"), null;
141
- const p = Number(r.trim()), l = Number(s.trim());
142
- if (isNaN(p) || isNaN(l) || !p || !l)
141
+ const h = Number(r.trim()), f = Number(s.trim());
142
+ if (isNaN(h) || isNaN(f) || !h || !f)
143
143
  return console.error("Cannot parse Visionary Code: invalid image dimensions", r, s), null;
144
- const v = Number(d) ?? 0, b = Number(h) ?? 0;
145
- return v < 1 || b < 1 ? (console.error(
144
+ const y = Number(a) ?? 0, b = Number(p) ?? 0;
145
+ return y < 1 || b < 1 ? (console.error(
146
146
  "Cannot parse Visionary Code: invalid blurhash x, y component dimensions",
147
- v,
147
+ y,
148
148
  b
149
149
  ), null) : {
150
- altText: f,
151
- bcc: a,
152
- blurhash: i,
153
- blurhashX: v,
150
+ altText: l,
151
+ bcc: u,
152
+ blurhash: c,
153
+ blurhashX: y,
154
154
  blurhashY: b,
155
- sourceHeight: l,
156
- sourceWidth: p,
155
+ sourceHeight: f,
156
+ sourceWidth: h,
157
157
  url: m
158
158
  };
159
159
  };
160
- class Gt extends Error {
160
+ class Wt extends Error {
161
161
  constructor() {
162
- super(...arguments), _t(this, "message", "invalid endpoint URL (does it contain http/https?)");
162
+ super(...arguments), Dt(this, "message", "invalid endpoint URL (does it contain http/https?)");
163
163
  }
164
164
  }
165
- const Wt = (t) => t === C.DEBUG, Ft = (t) => t === C.DOWNLOAD, Ht = (t) => Object.values(L).includes(t), ct = (t) => Object.values(y).includes(t), Xt = (t = []) => {
165
+ const Ft = (t) => t === T.DEBUG, Ht = (t) => t === T.DOWNLOAD, Xt = (t) => Object.values(V).includes(t), st = (t) => Object.values(v).includes(t), Yt = (t = []) => {
166
166
  const n = {};
167
167
  for (const e of t)
168
- ct(e) ? n.size = y[e] : Wt(e) ? n.debug = !0 : Ft(e) ? n.download = !0 : Ht(e) && (n.format = e);
168
+ st(e) ? n.size = v[e] : Ft(e) ? n.debug = !0 : Ht(e) ? n.download = !0 : Xt(e) && (n.format = e);
169
169
  return n;
170
- }, Yt = (t) => {
170
+ }, Zt = (t) => {
171
171
  if (!t || typeof t != "object")
172
172
  return null;
173
173
  const n = [];
174
- return t.debug && n.push(C.DEBUG), t.download && n.push(C.DOWNLOAD), t.format && t.format !== L.AUTO && n.push(t.format), t.size && ct(t.size) && n.push(t.size), n.length ? n.sort().join(",") : null;
175
- }, Zt = (t) => {
176
- if (k(t)) {
177
- const n = st(t);
174
+ return t.debug && n.push(T.DEBUG), t.download && n.push(T.DOWNLOAD), t.format && t.format !== V.AUTO && n.push(t.format), t.size && st(t.size) && n.push(t.size), n.length ? n.sort().join(",") : null;
175
+ }, qt = (t) => {
176
+ if (j(t)) {
177
+ const n = ot(t);
178
178
  if (n)
179
179
  return {
180
180
  fields: n,
181
181
  options: {}
182
182
  };
183
183
  }
184
- return qt(t);
185
- }, qt = (t) => {
184
+ return Jt(t);
185
+ }, Jt = (t) => {
186
186
  if (!t)
187
187
  return null;
188
188
  const n = t.trim();
189
189
  if (!n)
190
190
  return null;
191
191
  try {
192
- const e = Kt(n);
192
+ const e = Qt(n);
193
193
  if (!e)
194
194
  return null;
195
- const { code: o, optionTokens: c } = e, r = st(o);
195
+ const { code: o, optionTokens: i } = e, r = ot(o);
196
196
  if (!r)
197
197
  return null;
198
- const s = Xt(c);
198
+ const s = Yt(i);
199
199
  return {
200
200
  fields: r,
201
201
  options: s
@@ -204,31 +204,31 @@ const Wt = (t) => t === C.DEBUG, Ft = (t) => t === C.DOWNLOAD, Ht = (t) => Objec
204
204
  e instanceof Error ? console.error(`Error parsing URL: ${e.message}`, e) : console.error("uncaught error", e);
205
205
  }
206
206
  return null;
207
- }, Jt = (t, n) => {
208
- const e = Bt(t);
207
+ }, Kt = (t, n) => {
208
+ const e = Mt(t);
209
209
  if (e instanceof Error)
210
210
  return null;
211
211
  let o = null;
212
- if (n != null && n.endpoint && (o = Q(n == null ? void 0 : n.endpoint), !o))
213
- throw new Gt(
212
+ if (n != null && n.endpoint && (o = K(n == null ? void 0 : n.endpoint), !o))
213
+ throw new Wt(
214
214
  "Cannot construct URL: bad endpoint. Ensure endpoint starts with http:// or https://"
215
215
  );
216
- o || (o = Q(Ut));
217
- const c = [o.origin, "image", e], r = n ? Yt(n) : null;
218
- return r && c.push(r), n != null && n.filename ? c.push(n.filename) : c.push("image.jpg"), c.join("/");
219
- }, Kt = (t) => {
216
+ o || (o = K(Ot));
217
+ const i = [o.origin, "image", e], r = n ? Zt(n) : null;
218
+ return r && i.push(r), n != null && n.filename ? i.push(n.filename) : i.push("image.jpg"), i.join("/");
219
+ }, Qt = (t) => {
220
220
  try {
221
- const n = new URL(t), e = zt(n.pathname.split("/"));
221
+ const n = new URL(t), e = Bt(n.pathname.split("/"));
222
222
  if (e[0] !== "image" || ![3, 4].includes(e.length))
223
223
  throw new Error("Unrecognized URL");
224
224
  const o = e[1].trim();
225
- if (!o.length || !k(o))
225
+ if (!o.length || !j(o))
226
226
  throw new Error("URL is not formatted as base64url");
227
227
  if (e.length === 4) {
228
- const c = e[2].split(",");
228
+ const i = e[2].split(",");
229
229
  return {
230
230
  code: o,
231
- optionTokens: c
231
+ optionTokens: i
232
232
  };
233
233
  }
234
234
  if (e.length === 3)
@@ -240,107 +240,119 @@ const Wt = (t) => t === C.DEBUG, Ft = (t) => t === C.DOWNLOAD, Ht = (t) => Objec
240
240
  return null;
241
241
  }
242
242
  return null;
243
- }, it = 0.7, at = 1, O = 24, Qt = y.lg, lt = process.env.NODE_ENV, tn = lt === "development", ut = typeof document > "u", nn = lt === "test", en = ut ? () => {
244
- } : Et, rn = "<visionary>", N = (t, ...n) => {
245
- !console || typeof console.log != "function" || console.log(`${rn} ${t}`, ...n);
246
- }, on = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~", V = (t, n, e) => {
243
+ }, ct = 0.7, it = 1, S = 24, tn = v.lg, at = process.env.NODE_ENV, nn = at === "development", lt = typeof document > "u", en = at === "test", rn = lt ? () => {
244
+ } : Et, on = "<visionary>", R = (t, ...n) => {
245
+ !console || typeof console.log != "function" || console.log(`${on} ${t}`, ...n);
246
+ }, ut = new Uint8Array(128);
247
+ for (let t = 0; t < 83; t++)
248
+ ut["0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~".charCodeAt(
249
+ t
250
+ )] = t;
251
+ const _ = (t, n, e) => {
247
252
  let o = 0;
248
253
  for (; n < e; )
249
- o *= 83, o += on.indexOf(t[n++]);
254
+ o *= 83, o += ut[t.charCodeAt(n++)];
250
255
  return o;
251
- }, dt = Math.pow, D = Math.PI, sn = D * 2, ft = 3294.6, pt = 269.025, cn = (t) => t > 10.31475 ? dt(t / pt + 0.052132, 2.4) : t / ft, F = (t) => ~~(t > 1227e-8 ? pt * dt(t, 0.416666) - 13.025 : t * ft + 1), _ = (t) => (t < 0 ? -1 : 1) * t * t, tt = (t) => {
252
- for (t += D / 2; t > D; )
256
+ }, ft = Math.pow, C = Math.PI, sn = C * 2, dt = 3294.6, pt = 269.025, cn = (t) => t > 10.31475 ? ft(t / pt + 0.052132, 2.4) : t / dt, W = (t) => ~~(t > 1227e-8 ? pt * ft(t, 0.416666) - 13.025 : t * dt + 1), O = (t) => (t < 0 ? -1 : 1) * t * t, Q = (t) => {
257
+ for (t += C / 2; t > C; )
253
258
  t -= sn;
254
- const n = 1.27323954 * t - 0.405284735 * _(t);
255
- return 0.225 * (_(n) - n) + n;
259
+ const n = 1.27323954 * t - 0.405284735 * O(t);
260
+ return 0.225 * (O(n) - n) + n;
256
261
  };
257
262
  function an(t) {
258
- const n = V(t, 2, 6);
263
+ const n = _(t, 2, 6);
259
264
  return [n >> 16, n >> 8 & 255, n & 255];
260
265
  }
261
266
  function ln(t, n, e, o) {
262
- const c = V(t, 0, 1), r = c % 9 + 1, s = ~~(c / 9) + 1, a = r * s;
263
- let i = 0, d = 0, h = 0, f = 0, m = 0, p = 0, l = 0, v = 0, b = 0, g = 0, w = 0, E = 0, u = 0, I = 0;
264
- const U = (V(t, 1, 2) + 1) / 13446 * (o | 1), x = new Float64Array(a * 3), z = an(t);
265
- for (i = 0; i < 3; i++)
266
- x[i] = cn(z[i]);
267
- for (i = 1; i < a; i++)
268
- I = V(t, 4 + i * 2, 6 + i * 2), x[i * 3] = _(~~(I / (19 * 19)) - 9) * U, x[i * 3 + 1] = _(~~(I / 19) % 19 - 9) * U, x[i * 3 + 2] = _(I % 19 - 9) * U;
269
- const S = n * 4, R = new Uint8ClampedArray(S * e);
270
- for (f = 0; f < e; f++)
271
- for (E = D * f / e, h = 0; h < n; h++) {
272
- for (m = 0, p = 0, l = 0, u = D * h / n, d = 0; d < s; d++)
273
- for (b = tt(E * d), i = 0; i < r; i++)
274
- v = tt(u * i) * b, g = (i + d * r) * 3, m += x[g] * v, p += x[g + 1] * v, l += x[g + 2] * v;
275
- w = 4 * h + f * S, R[w] = F(m), R[w + 1] = F(p), R[w + 2] = F(l), R[w + 3] = 255;
267
+ const i = _(t, 0, 1), r = i % 9 + 1, s = ~~(i / 9) + 1, u = r * s;
268
+ let c = 0, a = 0, p = 0, l = 0, m = 0, h = 0, f = 0, y = 0, b = 0, g = 0, w = 0, E = 0;
269
+ const d = (_(t, 1, 2) + 1) / 13446 * (o | 1), I = new Float64Array(u * 3), k = an(t);
270
+ for (c = 0; c < 3; c++)
271
+ I[c] = cn(k[c]);
272
+ for (c = 1; c < u; c++)
273
+ E = _(t, 4 + c * 2, 6 + c * 2), I[c * 3] = O(~~(E / 361) - 9) * d, I[c * 3 + 1] = O(~~(E / 19) % 19 - 9) * d, I[c * 3 + 2] = O(E % 19 - 9) * d;
274
+ const D = new Float64Array(s * e), P = new Float64Array(r * n);
275
+ for (a = 0; a < s; a++)
276
+ for (l = 0; l < e; l++)
277
+ D[a * e + l] = Q(C * l * a / e);
278
+ for (c = 0; c < r; c++)
279
+ for (p = 0; p < n; p++)
280
+ P[c * n + p] = Q(C * p * c / n);
281
+ const U = n * 4, A = new Uint8ClampedArray(U * e);
282
+ for (l = 0; l < e; l++)
283
+ for (p = 0; p < n; p++) {
284
+ for (m = h = f = 0, a = 0; a < s; a++)
285
+ for (b = D[a * e + l], c = 0; c < r; c++)
286
+ y = P[c * n + p] * b, g = (c + a * r) * 3, m += I[g] * y, h += I[g + 1] * y, f += I[g + 2] * y;
287
+ w = 4 * p + l * U, A[w] = W(m), A[w + 1] = W(h), A[w + 2] = W(f), A[w + 3] = 255;
276
288
  }
277
- return R;
289
+ return A;
278
290
  }
279
- const $ = (t) => {
291
+ const L = (t) => {
280
292
  try {
281
293
  return new URL(t);
282
294
  } catch {
283
295
  return null;
284
296
  }
285
- }, un = (t, n) => `rgba(${t.r},${t.g},${t.b},${n})`, H = (t) => tn || nn ? {
297
+ }, un = (t, n) => `rgba(${t.r},${t.g},${t.b},${n})`, F = (t) => nn || en ? {
286
298
  "data-testid": t
287
- } : {}, dn = (t, n) => n ? {
299
+ } : {}, fn = (t, n) => n ? {
288
300
  "data-fileid": t
289
- } : {}, nt = (t, n) => Math.min(t, n), fn = (t) => {
301
+ } : {}, tt = (t, n) => Math.min(t, n), dn = (t) => {
290
302
  let n = t.replace(/^#/, "");
291
303
  if (n.length !== 3 && n.length !== 6)
292
304
  return null;
293
305
  n.length === 3 && (n = `${n[0]}${n[0]}${n[1]}${n[1]}${n[2]}${n[2]}`);
294
306
  const e = parseInt(n.slice(0, 2), 16), o = parseInt(n.slice(2, 4), 16);
295
307
  return { b: parseInt(n.slice(4, 6), 16), g: o, r: e };
296
- }, A = (t, n = 0) => {
308
+ }, x = (t, n = 0) => {
297
309
  const e = Math.pow(10, n);
298
310
  return Math.round(t * e) / e;
299
311
  }, pn = (t, n) => {
300
- const e = $(t), o = $(n);
312
+ const e = L(t), o = L(n);
301
313
  return !e || !o ? t : (o.pathname = e.pathname, o.search = e.search, o.toString());
302
- }, hn = (t, n = {}, e = it, o = at) => {
314
+ }, hn = (t, n = {}, e = ct, o = it) => {
303
315
  if (!t)
304
316
  return null;
305
317
  try {
306
- n.debug && N("input imageSrc:", t);
307
- const c = Zt(t);
308
- if (n.debug && N("Visionary URL data: ", c), !c)
318
+ n.debug && R("input imageSrc:", t);
319
+ const i = qt(t);
320
+ if (n.debug && R("Visionary URL data: ", i), !i)
309
321
  throw new Error("Could not parse Visionary URL");
310
- const { fields: r, options: s } = c;
322
+ const { fields: r, options: s } = i;
311
323
  if (r.sourceWidth < 1 || r.sourceHeight < 1)
312
324
  throw new Error("Invalid image dimensions");
313
- const a = r.sourceWidth / r.sourceHeight, i = (n == null ? void 0 : n.size) ?? s.size ?? Qt, d = Z[i];
314
- let h = 0, f = 0, m = 0;
315
- if (a >= 1) {
316
- f = h = nt(d, r.sourceWidth);
317
- const g = A(f / a);
318
- m = A(f / g, 6);
325
+ const u = r.sourceWidth / r.sourceHeight, c = (n == null ? void 0 : n.size) ?? s.size ?? tn, a = Z[c];
326
+ let p = 0, l = 0, m = 0;
327
+ if (u >= 1) {
328
+ l = p = tt(a, r.sourceWidth);
329
+ const g = x(l / u);
330
+ m = x(l / g, 6);
319
331
  } else
320
- h = nt(d, r.sourceHeight), f = A(h * a), m = A(f / h, 6);
321
- const p = A(100 / m, 6), l = {
332
+ p = tt(a, r.sourceHeight), l = x(p * u), m = x(l / p, 6);
333
+ const h = x(100 / m, 6), f = {
322
334
  ...r,
323
- arPaddingTop: `${p}%`,
335
+ arPaddingTop: `${h}%`,
324
336
  aspectRatio: m,
325
- maxWidth: f,
337
+ maxWidth: l,
326
338
  src: t
327
- }, v = $(r.url);
328
- if (v)
329
- l.src = v.toString();
330
- else if (!$(t) && k(r.url)) {
331
- const g = Jt(r, {
339
+ }, y = L(r.url);
340
+ if (y)
341
+ f.src = y.toString();
342
+ else if (!L(t) && j(r.url)) {
343
+ const g = Kt(r, {
332
344
  endpoint: n.endpoint,
333
- size: i
345
+ size: c
334
346
  });
335
- g && (l.src = g);
347
+ g && (f.src = g);
336
348
  }
337
- n.endpoint && (l.src = pn(l.src, n.endpoint));
338
- const b = r.bcc ? fn(r.bcc) : null;
339
- if (b && (l.backgroundColor = un(b, e)), !ut && r.blurhash && !n.disableBlurLayer) {
340
- const g = performance.now(), w = ln(r.blurhash, O, O, o), E = performance.now() - g;
341
- n.debug && N(`Blurhash decode time: ${A(E, 1)} ms`), w && (l.pixels = w);
349
+ n.endpoint && (f.src = pn(f.src, n.endpoint));
350
+ const b = r.bcc ? dn(r.bcc) : null;
351
+ if (b && (f.backgroundColor = un(b, e)), !lt && r.blurhash && !n.disableBlurLayer) {
352
+ const g = performance.now(), w = ln(r.blurhash, S, S, o), E = performance.now() - g;
353
+ n.debug && R(`Blurhash decode time: ${x(E, 1)} ms`), w && (f.pixels = w);
342
354
  }
343
- return n.debug && N("Visionary Image state: ", l), l;
355
+ return n.debug && R("Visionary Image state: ", f), f;
344
356
  } catch {
345
357
  return null;
346
358
  }
@@ -358,142 +370,143 @@ const $ = (t) => {
358
370
  ...ht,
359
371
  height: "100%",
360
372
  width: "100%"
361
- }, X = {
373
+ }, bn = (t) => {
374
+ const n = {
375
+ ...mn
376
+ };
377
+ return t && (n.display = "none"), n;
378
+ }, H = {
362
379
  CANVAS: "canvas",
363
380
  CONTAINER: "container",
364
381
  IMAGE: "image"
365
- }, bn = "v7y_7587", vn = "v7y_f2b7", yn = "v7y_b8c0", wn = "v7y_e0dd", P = {
366
- container: bn,
367
- hidden: vn,
368
- preventDrag: yn,
382
+ }, yn = "v7y_7587", vn = "v7y_b8c0", wn = "v7y_e0dd", X = {
383
+ container: yn,
384
+ preventDrag: vn,
369
385
  preventSelection: wn
370
- }, An = ({
386
+ }, Rn = ({
371
387
  alt: t,
372
- bgColorAlpha: n = it,
388
+ bgColorAlpha: n = ct,
373
389
  className: e,
374
390
  debug: o = !1,
375
- disableBlurLayer: c = !1,
391
+ disableBlurLayer: i = !1,
376
392
  disableImageLayer: r = !1,
377
393
  endpoint: s,
378
- height: a,
379
- hideImageLayer: i,
380
- lazy: d = !0,
381
- onClick: h,
382
- onError: f,
394
+ height: u,
395
+ hideImageLayer: c = !1,
396
+ lazy: a = !0,
397
+ onClick: p,
398
+ onError: l,
383
399
  onLoad: m,
384
- preventDrag: p = !1,
385
- preventSelection: l = !1,
386
- punch: v = at,
400
+ preventDrag: h = !1,
401
+ preventSelection: f = !1,
402
+ punch: y = it,
387
403
  size: b,
388
404
  src: g,
389
405
  style: w,
390
406
  width: E
391
407
  }) => {
392
- const u = It(() => hn(g, {
408
+ const d = At(() => hn(g, {
393
409
  debug: o,
394
- disableBlurLayer: c,
410
+ disableBlurLayer: i,
395
411
  endpoint: s,
396
412
  size: b
397
- }, n, v), [n, o, c, s, v, b, g]), I = Y(null), [U, x] = Ot();
398
- en(
413
+ }, n, y), [n, o, i, s, y, b, g]), I = Y(null), [k, D] = Nt();
414
+ rn(
399
415
  function() {
400
- if (!I.current || !(u != null && u.blurhash))
416
+ if (!I.current || !(d != null && d.blurhash))
401
417
  return;
402
- if (!u.pixels) {
418
+ if (!d.pixels) {
403
419
  console.warn("No pixel data passed in, skipping");
404
420
  return;
405
421
  }
406
- const bt = performance.now(), M = I.current.getContext("2d");
407
- if (!M) {
422
+ const bt = performance.now(), B = I.current.getContext("2d");
423
+ if (!B) {
408
424
  console.warn("Cannot access canvasRenderingContext, skipping");
409
425
  return;
410
426
  }
411
- const G = M.createImageData(O, O);
412
- if (!G) {
427
+ const M = B.createImageData(S, S);
428
+ if (!M) {
413
429
  console.warn("Could not create ImageData on CanvasRenderingContext");
414
430
  return;
415
431
  }
416
- if (G.data.set(u.pixels), M.putImageData(G, 0, 0), o) {
417
- const vt = performance.now() - bt;
418
- N(`Canvas render time: ${A(vt, 1)} ms`);
432
+ if (M.data.set(d.pixels), B.putImageData(M, 0, 0), o) {
433
+ const yt = performance.now() - bt;
434
+ R(`Canvas render time: ${x(yt, 1)} ms`);
419
435
  }
420
436
  },
421
- [u == null ? void 0 : u.blurhash, u == null ? void 0 : u.pixels, o]
437
+ [d == null ? void 0 : d.blurhash, d == null ? void 0 : d.pixels, o]
422
438
  );
423
- const z = q(
424
- (T) => {
425
- o && N("Image load error ", T), f && f();
439
+ const P = q(
440
+ (N) => {
441
+ o && R("Image load error ", N), l && l();
426
442
  },
427
- [o, f]
428
- ), S = {
443
+ [o, l]
444
+ ), U = {
429
445
  alt: t,
430
- loading: !d || x ? "eager" : "lazy",
446
+ loading: !a || D ? "eager" : "lazy",
431
447
  onLoad: m
432
448
  };
433
- if (!u) {
434
- o && N("Not a Visionary URL, rendering fallback <img />");
435
- const T = {
436
- ...S,
449
+ if (!d) {
450
+ o && R("Not a Visionary URL, rendering fallback <img />");
451
+ const N = {
452
+ ...U,
437
453
  className: e,
438
- height: a,
439
- onClick: h,
440
- onError: f,
454
+ height: u,
455
+ onClick: p,
456
+ onError: l,
441
457
  src: g,
442
458
  style: w,
443
459
  width: E
444
460
  };
445
- return /* @__PURE__ */ W("img", { ...T });
461
+ return /* @__PURE__ */ G("img", { ...N });
446
462
  }
447
- const R = K(P.container, e, {
448
- [P.preventDrag]: !!p,
449
- [P.preventSelection]: !!l
450
- }), B = {
463
+ const A = St(X.container, e, {
464
+ [X.preventDrag]: !!h,
465
+ [X.preventSelection]: !!f
466
+ }), z = {
451
467
  ...{
452
- "--v-ar": u.arPaddingTop
468
+ "--v-ar": d.arPaddingTop
453
469
  },
454
- aspectRatio: u.aspectRatio,
455
- backgroundColor: (u == null ? void 0 : u.backgroundColor) ?? void 0,
456
- maxWidth: u.maxWidth,
470
+ aspectRatio: d.aspectRatio,
471
+ backgroundColor: (d == null ? void 0 : d.backgroundColor) ?? void 0,
472
+ maxWidth: d.maxWidth,
457
473
  position: "relative",
458
474
  width: "100%",
459
475
  ...w
460
476
  };
461
- E && (B.width = E), a && (B.height = a);
477
+ E && (z.width = E), u && (z.height = u);
462
478
  const mt = {
463
- onClick: h
464
- }, gt = K({
465
- [P.hidden]: !!i
466
- });
467
- return /* @__PURE__ */ yt(
479
+ onClick: p
480
+ }, gt = bn(c);
481
+ return /* @__PURE__ */ vt(
468
482
  "div",
469
483
  {
470
- className: R,
471
- ref: U,
472
- style: B,
473
- ...dn(u.url, o),
474
- ...H(X.CONTAINER),
484
+ className: A,
485
+ ref: k,
486
+ style: z,
487
+ ...fn(d.url, o),
488
+ ...F(H.CONTAINER),
475
489
  ...mt,
476
490
  children: [
477
- !c && /* @__PURE__ */ W(
491
+ !i && /* @__PURE__ */ G(
478
492
  "canvas",
479
493
  {
480
- height: O,
494
+ height: S,
481
495
  ref: I,
482
496
  style: gn,
483
- width: O,
484
- ...H(X.CANVAS)
497
+ width: S,
498
+ ...F(H.CANVAS)
485
499
  }
486
500
  ),
487
501
  !r && // eslint-disable-next-line jsx-a11y/alt-text -- `sharedImgProps` includes alt tag
488
- /* @__PURE__ */ W(
502
+ /* @__PURE__ */ G(
489
503
  "img",
490
504
  {
491
- ...S,
492
- ...H(X.IMAGE),
493
- className: gt,
494
- onError: z,
495
- src: u.src,
496
- style: mn
505
+ ...U,
506
+ ...F(H.IMAGE),
507
+ onError: P,
508
+ src: d.src,
509
+ style: gt
497
510
  }
498
511
  )
499
512
  ]
@@ -501,5 +514,5 @@ const $ = (t) => {
501
514
  );
502
515
  };
503
516
  export {
504
- An as Image
517
+ Rn as Image
505
518
  };
@@ -1,6 +1,6 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.id="v7y-styles",e.appendChild(document.createTextNode('.v7y_7587:before{content:"";display:block;padding-top:var(--v-ar)}.v7y_f2b7{display:none}.v7y_b8c0{-webkit-user-drag:none;pointer-events:none}.v7y_e0dd{-webkit-user-select:none;user-select:none}')),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
2
- (function(E,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],R):(E=typeof globalThis<"u"?globalThis:E||self,R(E.VisionaryImage={},E.jsxRuntime,E.React))})(this,function(E,R,x){"use strict";function me(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var K={exports:{}};/*!
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.id="v7y-styles",e.appendChild(document.createTextNode('.v7y_7587:before{content:"";display:block;padding-top:var(--v-ar)}.v7y_b8c0{-webkit-user-drag:none;pointer-events:none}.v7y_e0dd{-webkit-user-select:none;user-select:none}')),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
2
+ (function(A,R){typeof exports=="object"&&typeof module<"u"?R(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],R):(A=typeof globalThis<"u"?globalThis:A||self,R(A.VisionaryImage={},A.jsxRuntime,A.React))})(this,function(A,R,x){"use strict";function me(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var K={exports:{}};/*!
3
3
  Copyright (c) 2018 Jed Watson.
4
4
  Licensed under the MIT License (MIT), see
5
5
  http://jedwatson.github.io/classnames
6
- */(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r="",s=0;s<arguments.length;s++){var a=arguments[s];a&&(r=i(r,o(a)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var s="";for(var a in r)t.call(r,a)&&r[a]&&(s=i(s,a));return s}function i(r,s){return s?r?r+" "+s:r+s:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(K);var ge=K.exports;const Q=me(ge),be=(e,{root:t,rootMargin:n,threshold:o}={},i=[])=>{const r=x.useRef(null),s=x.useRef(null);return x.useCallback(c=>{r.current&&s.current&&(s.current.unobserve(r.current),s.current.disconnect(),s.current=null),c&&(s.current=new IntersectionObserver(e,{root:t,rootMargin:n,threshold:o}),s.current.observe(c),r.current=c)},[r,t,n,JSON.stringify(o),...i])},ve=({root:e,rootMargin:t,threshold:n,unobserveOnEnter:o,target:i,onEnter:r,onLeave:s,defaultInView:a}={},c=[])=>{const[d,h]=x.useState({inView:a||!1,entry:null,observer:null}),f=x.useCallback(([p],l)=>{const b=l.thresholds.some(g=>p.intersectionRatio>=g)&&p.isIntersecting;h({inView:b,entry:p,observer:l}),b&&o&&(l.unobserve(p.target),l.disconnect()),b?r==null||r(p,l):s==null||s(p,l)},[r,s,o]),m=be(f,{root:e,rootMargin:t,threshold:n},[o,...c]);return x.useEffect(()=>{i!=null&&i.current&&m(i.current)},[i,m]),[m,d.inView,d.entry,d.observer]};var $=(e=>(e.AUTO="auto",e.AVIF="avif",e.JPEG="jpeg",e.WEBP="webp",e))($||{}),y=(e=>(e.xs="xs",e.sm="sm",e.md="md",e.lg="lg",e.xl="xl",e.xxl="xxl",e["4k"]="4k",e["5k"]="5k",e.full="full",e))(y||{}),C=(e=>(e.DEBUG="debug",e.DOWNLOAD="download",e))(C||{});const ye="https://link.visionary.cloud";$.AUTO,y.lg;const G={[y.xs]:160,[y.sm]:320,[y.md]:640,[y.lg]:1280,[y.xl]:1920,[y.xxl]:2560,[y["4k"]]:3840,[y["5k"]]:5120,[y.full]:0};Object.keys(G).reduce((e,t)=>{const n=t,o=G[n];return o&&(e[o]=n),e},{});const ee="!";var we=Object.defineProperty,xe=(e,t,n)=>t in e?we(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ie=(e,t,n)=>xe(e,typeof t!="symbol"?t+"":t,n),W={},L={};Object.defineProperty(L,"__esModule",{value:!0});function Ee(e){return String.fromCharCode(parseInt(e.slice(1),16))}function Re(e){return btoa(encodeURIComponent(e).replace(/%[0-9A-F]{2}/g,Ee))}L.encode=Re;function Ae(e){return`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`}function Se(e){return decodeURIComponent(Array.from(atob(e),Ae).join(""))}L.decode=Se,Object.defineProperty(W,"__esModule",{value:!0});const te=L;function Te(e){return te.decode(e.replace(/\-/g,"+").replace(/_/g,"/"))}var Ne=W.decode=Te;function Oe(e){return te.encode(e).replace(/\//g,"_").replace(/\+/g,"-").replace(/=+$/,"")}var Ue=W.encode=Oe;const Ce=e=>e.filter(Boolean),ne=e=>{try{return new URL(e)}catch{return null}},k=(e="")=>/^[A-Za-z0-9_-]*$/.test(e),De=e=>{const{altText:t,bcc:n,blurhash:o,blurhashX:i,blurhashY:r,sourceHeight:s,sourceWidth:a,url:c}=e;if(!c||!a||!s)return new Error("Cannot construct visionary code: missing required url/width/height");const d=[c,a,s];return!n||(d.push(n),!o||!i||!r)||(d.push(o,i,r),t&&t.length&&d.push(t)),Pe(d)},Pe=e=>Ue(e.join(ee)),re=e=>{if(typeof e!="string")return null;const t=e.trim();if(!t.length||!k(t))return null;const n=Ne(t);if(!n)return null;const o=n.split(ee);if(o.length<3)return null;const[i,r,s,a,c,d,h,f]=o,m=i.trim();if(!m.length)return console.error("Cannot parse code, empty file id"),null;const p=Number(r.trim()),l=Number(s.trim());if(isNaN(p)||isNaN(l)||!p||!l)return console.error("Cannot parse Visionary Code: invalid image dimensions",r,s),null;const v=Number(d)??0,b=Number(h)??0;return v<1||b<1?(console.error("Cannot parse Visionary Code: invalid blurhash x, y component dimensions",v,b),null):{altText:f,bcc:a,blurhash:c,blurhashX:v,blurhashY:b,sourceHeight:l,sourceWidth:p,url:m}};class _e extends Error{constructor(){super(...arguments),Ie(this,"message","invalid endpoint URL (does it contain http/https?)")}}const je=e=>e===C.DEBUG,Ve=e=>e===C.DOWNLOAD,$e=e=>Object.values($).includes(e),oe=e=>Object.values(y).includes(e),Le=(e=[])=>{const t={};for(const n of e)oe(n)?t.size=y[n]:je(n)?t.debug=!0:Ve(n)?t.download=!0:$e(n)&&(t.format=n);return t},ke=e=>{if(!e||typeof e!="object")return null;const t=[];return e.debug&&t.push(C.DEBUG),e.download&&t.push(C.DOWNLOAD),e.format&&e.format!==$.AUTO&&t.push(e.format),e.size&&oe(e.size)&&t.push(e.size),t.length?t.sort().join(","):null},ze=e=>{if(k(e)){const t=re(e);if(t)return{fields:t,options:{}}}return Be(e)},Be=e=>{if(!e)return null;const t=e.trim();if(!t)return null;try{const n=Ge(t);if(!n)return null;const{code:o,optionTokens:i}=n,r=re(o);if(!r)return null;const s=Le(i);return{fields:r,options:s}}catch(n){n instanceof Error?console.error(`Error parsing URL: ${n.message}`,n):console.error("uncaught error",n)}return null},Me=(e,t)=>{const n=De(e);if(n instanceof Error)return null;let o=null;if(t!=null&&t.endpoint&&(o=ne(t==null?void 0:t.endpoint),!o))throw new _e("Cannot construct URL: bad endpoint. Ensure endpoint starts with http:// or https://");o||(o=ne(ye));const i=[o.origin,"image",n],r=t?ke(t):null;return r&&i.push(r),t!=null&&t.filename?i.push(t.filename):i.push("image.jpg"),i.join("/")},Ge=e=>{try{const t=new URL(e),n=Ce(t.pathname.split("/"));if(n[0]!=="image"||![3,4].includes(n.length))throw new Error("Unrecognized URL");const o=n[1].trim();if(!o.length||!k(o))throw new Error("URL is not formatted as base64url");if(n.length===4){const i=n[2].split(",");return{code:o,optionTokens:i}}if(n.length===3)return{code:o,optionTokens:[]}}catch{return null}return null},se=.7,ie=1,U=24,We=y.lg,ce=process.env.NODE_ENV,Fe=ce==="development",ae=typeof document>"u",He=ce==="test",qe=ae?()=>{}:x.useLayoutEffect,Xe="<visionary>",T=(e,...t)=>{!console||typeof console.log!="function"||console.log(`${Xe} ${e}`,...t)},Ye="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~",z=(e,t,n)=>{let o=0;for(;t<n;)o*=83,o+=Ye.indexOf(e[t++]);return o},le=Math.pow,D=Math.PI,Ze=D*2,ue=3294.6,de=269.025,Je=e=>e>10.31475?le(e/de+.052132,2.4):e/ue,F=e=>~~(e>1227e-8?de*le(e,.416666)-13.025:e*ue+1),P=e=>(e<0?-1:1)*e*e,fe=e=>{for(e+=D/2;e>D;)e-=Ze;const t=1.27323954*e-.405284735*P(e);return .225*(P(t)-t)+t};function Ke(e){const t=z(e,2,6);return[t>>16,t>>8&255,t&255]}function Qe(e,t,n,o){const i=z(e,0,1),r=i%9+1,s=~~(i/9)+1,a=r*s;let c=0,d=0,h=0,f=0,m=0,p=0,l=0,v=0,b=0,g=0,w=0,A=0,u=0,S=0;const _=(z(e,1,2)+1)/13446*(o|1),I=new Float64Array(a*3),X=Ke(e);for(c=0;c<3;c++)I[c]=Je(X[c]);for(c=1;c<a;c++)S=z(e,4+c*2,6+c*2),I[c*3]=P(~~(S/(19*19))-9)*_,I[c*3+1]=P(~~(S/19)%19-9)*_,I[c*3+2]=P(S%19-9)*_;const j=t*4,O=new Uint8ClampedArray(j*n);for(f=0;f<n;f++)for(A=D*f/n,h=0;h<t;h++){for(m=0,p=0,l=0,u=D*h/t,d=0;d<s;d++)for(b=fe(A*d),c=0;c<r;c++)v=fe(u*c)*b,g=(c+d*r)*3,m+=I[g]*v,p+=I[g+1]*v,l+=I[g+2]*v;w=4*h+f*j,O[w]=F(m),O[w+1]=F(p),O[w+2]=F(l),O[w+3]=255}return O}const B=e=>{try{return new URL(e)}catch{return null}},et=(e,t)=>`rgba(${e.r},${e.g},${e.b},${t})`,H=e=>Fe||He?{"data-testid":e}:{},tt=(e,t)=>t?{"data-fileid":e}:{},pe=(e,t)=>Math.min(e,t),nt=e=>{let t=e.replace(/^#/,"");if(t.length!==3&&t.length!==6)return null;t.length===3&&(t=`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`);const n=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16);return{b:parseInt(t.slice(4,6),16),g:o,r:n}},N=(e,t=0)=>{const n=Math.pow(10,t);return Math.round(e*n)/n},rt=(e,t)=>{const n=B(e),o=B(t);return!n||!o?e:(o.pathname=n.pathname,o.search=n.search,o.toString())},ot=(e,t={},n=se,o=ie)=>{if(!e)return null;try{t.debug&&T("input imageSrc:",e);const i=ze(e);if(t.debug&&T("Visionary URL data: ",i),!i)throw new Error("Could not parse Visionary URL");const{fields:r,options:s}=i;if(r.sourceWidth<1||r.sourceHeight<1)throw new Error("Invalid image dimensions");const a=r.sourceWidth/r.sourceHeight,c=(t==null?void 0:t.size)??s.size??We,d=G[c];let h=0,f=0,m=0;if(a>=1){f=h=pe(d,r.sourceWidth);const g=N(f/a);m=N(f/g,6)}else h=pe(d,r.sourceHeight),f=N(h*a),m=N(f/h,6);const p=N(100/m,6),l={...r,arPaddingTop:`${p}%`,aspectRatio:m,maxWidth:f,src:e},v=B(r.url);if(v)l.src=v.toString();else if(!B(e)&&k(r.url)){const g=Me(r,{endpoint:t.endpoint,size:c});g&&(l.src=g)}t.endpoint&&(l.src=rt(l.src,t.endpoint));const b=r.bcc?nt(r.bcc):null;if(b&&(l.backgroundColor=et(b,n)),!ae&&r.blurhash&&!t.disableBlurLayer){const g=performance.now(),w=Qe(r.blurhash,U,U,o),A=performance.now()-g;t.debug&&T(`Blurhash decode time: ${N(A,1)} ms`),w&&(l.pixels=w)}return t.debug&&T("Visionary Image state: ",l),l}catch{return null}},he={bottom:0,left:0,position:"absolute",right:0,top:0},st={...he,maxHeight:"100%",maxWidth:"100%"},it={...he,height:"100%",width:"100%"},q={CANVAS:"canvas",CONTAINER:"container",IMAGE:"image"},M={container:"v7y_7587",hidden:"v7y_f2b7",preventDrag:"v7y_b8c0",preventSelection:"v7y_e0dd"},ct=({alt:e,bgColorAlpha:t=se,className:n,debug:o=!1,disableBlurLayer:i=!1,disableImageLayer:r=!1,endpoint:s,height:a,hideImageLayer:c,lazy:d=!0,onClick:h,onError:f,onLoad:m,preventDrag:p=!1,preventSelection:l=!1,punch:v=ie,size:b,src:g,style:w,width:A})=>{const u=x.useMemo(()=>ot(g,{debug:o,disableBlurLayer:i,endpoint:s,size:b},t,v),[t,o,i,s,v,b,g]),S=x.useRef(null),[_,I]=ve();qe(function(){if(!S.current||!(u!=null&&u.blurhash))return;if(!u.pixels){console.warn("No pixel data passed in, skipping");return}const ut=performance.now(),Z=S.current.getContext("2d");if(!Z){console.warn("Cannot access canvasRenderingContext, skipping");return}const J=Z.createImageData(U,U);if(!J){console.warn("Could not create ImageData on CanvasRenderingContext");return}if(J.data.set(u.pixels),Z.putImageData(J,0,0),o){const dt=performance.now()-ut;T(`Canvas render time: ${N(dt,1)} ms`)}},[u==null?void 0:u.blurhash,u==null?void 0:u.pixels,o]);const X=x.useCallback(V=>{o&&T("Image load error ",V),f&&f()},[o,f]),j={alt:e,loading:!d||I?"eager":"lazy",onLoad:m};if(!u){o&&T("Not a Visionary URL, rendering fallback <img />");const V={...j,className:n,height:a,onClick:h,onError:f,src:g,style:w,width:A};return R.jsx("img",{...V})}const O=Q(M.container,n,{[M.preventDrag]:!!p,[M.preventSelection]:!!l}),Y={...{"--v-ar":u.arPaddingTop},aspectRatio:u.aspectRatio,backgroundColor:(u==null?void 0:u.backgroundColor)??void 0,maxWidth:u.maxWidth,position:"relative",width:"100%",...w};A&&(Y.width=A),a&&(Y.height=a);const at={onClick:h},lt=Q({[M.hidden]:!!c});return R.jsxs("div",{className:O,ref:_,style:Y,...tt(u.url,o),...H(q.CONTAINER),...at,children:[!i&&R.jsx("canvas",{height:U,ref:S,style:it,width:U,...H(q.CANVAS)}),!r&&R.jsx("img",{...j,...H(q.IMAGE),className:lt,onError:X,src:u.src,style:st})]})};E.Image=ct,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
6
+ */(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var r="",s=0;s<arguments.length;s++){var u=arguments[s];u&&(r=i(r,o(u)))}return r}function o(r){if(typeof r=="string"||typeof r=="number")return r;if(typeof r!="object")return"";if(Array.isArray(r))return n.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var s="";for(var u in r)t.call(r,u)&&r[u]&&(s=i(s,u));return s}function i(r,s){return s?r?r+" "+s:r+s:r}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(K);var ge=K.exports;const be=me(ge),ye=(e,{root:t,rootMargin:n,threshold:o}={},i=[])=>{const r=x.useRef(null),s=x.useRef(null);return x.useCallback(c=>{r.current&&s.current&&(s.current.unobserve(r.current),s.current.disconnect(),s.current=null),c&&(s.current=new IntersectionObserver(e,{root:t,rootMargin:n,threshold:o}),s.current.observe(c),r.current=c)},[r,t,n,JSON.stringify(o),...i])},ve=({root:e,rootMargin:t,threshold:n,unobserveOnEnter:o,target:i,onEnter:r,onLeave:s,defaultInView:u}={},c=[])=>{const[a,p]=x.useState({inView:u||!1,entry:null,observer:null}),l=x.useCallback(([h],f)=>{const b=f.thresholds.some(g=>h.intersectionRatio>=g)&&h.isIntersecting;p({inView:b,entry:h,observer:f}),b&&o&&(f.unobserve(h.target),f.disconnect()),b?r==null||r(h,f):s==null||s(h,f)},[r,s,o]),m=ye(l,{root:e,rootMargin:t,threshold:n},[o,...c]);return x.useEffect(()=>{i!=null&&i.current&&m(i.current)},[i,m]),[m,a.inView,a.entry,a.observer]};var j=(e=>(e.AUTO="auto",e.AVIF="avif",e.JPEG="jpeg",e.WEBP="webp",e))(j||{}),v=(e=>(e.xs="xs",e.sm="sm",e.md="md",e.lg="lg",e.xl="xl",e.xxl="xxl",e["4k"]="4k",e["5k"]="5k",e.full="full",e))(v||{}),O=(e=>(e.DEBUG="debug",e.DOWNLOAD="download",e))(O||{});const we="https://link.visionary.cloud";j.AUTO,v.lg;const M={[v.xs]:160,[v.sm]:320,[v.md]:640,[v.lg]:1280,[v.xl]:1920,[v.xxl]:2560,[v["4k"]]:3840,[v["5k"]]:5120,[v.full]:0};Object.keys(M).reduce((e,t)=>{const n=t,o=M[n];return o&&(e[o]=n),e},{});const Q="!";var Ie=Object.defineProperty,xe=(e,t,n)=>t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ee=(e,t,n)=>xe(e,typeof t!="symbol"?t+"":t,n),G={},V={};Object.defineProperty(V,"__esModule",{value:!0});function Ae(e){return String.fromCharCode(parseInt(e.slice(1),16))}function Re(e){return btoa(encodeURIComponent(e).replace(/%[0-9A-F]{2}/g,Ae))}V.encode=Re;function Se(e){return`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`}function Te(e){return decodeURIComponent(Array.from(atob(e),Se).join(""))}V.decode=Te,Object.defineProperty(G,"__esModule",{value:!0});const ee=V;function Ue(e){return ee.decode(e.replace(/\-/g,"+").replace(/_/g,"/"))}var Ne=G.decode=Ue;function Oe(e){return ee.encode(e).replace(/\//g,"_").replace(/\+/g,"-").replace(/=+$/,"")}var Ce=G.encode=Oe;const De=e=>e.filter(Boolean),te=e=>{try{return new URL(e)}catch{return null}},L=(e="")=>/^[A-Za-z0-9_-]*$/.test(e),Pe=e=>{const{altText:t,bcc:n,blurhash:o,blurhashX:i,blurhashY:r,sourceHeight:s,sourceWidth:u,url:c}=e;if(!c||!u||!s)return new Error("Cannot construct visionary code: missing required url/width/height");const a=[c,u,s];return!n||(a.push(n),!o||!i||!r)||(a.push(o,i,r),t&&t.length&&a.push(t)),_e(a)},_e=e=>Ce(e.join(Q)),ne=e=>{if(typeof e!="string")return null;const t=e.trim();if(!t.length||!L(t))return null;const n=Ne(t);if(!n)return null;const o=n.split(Q);if(o.length<3)return null;const[i,r,s,u,c,a,p,l]=o,m=i.trim();if(!m.length)return console.error("Cannot parse code, empty file id"),null;const h=Number(r.trim()),f=Number(s.trim());if(isNaN(h)||isNaN(f)||!h||!f)return console.error("Cannot parse Visionary Code: invalid image dimensions",r,s),null;const y=Number(a)??0,b=Number(p)??0;return y<1||b<1?(console.error("Cannot parse Visionary Code: invalid blurhash x, y component dimensions",y,b),null):{altText:l,bcc:u,blurhash:c,blurhashX:y,blurhashY:b,sourceHeight:f,sourceWidth:h,url:m}};class je extends Error{constructor(){super(...arguments),Ee(this,"message","invalid endpoint URL (does it contain http/https?)")}}const Ve=e=>e===O.DEBUG,Le=e=>e===O.DOWNLOAD,$e=e=>Object.values(j).includes(e),re=e=>Object.values(v).includes(e),ke=(e=[])=>{const t={};for(const n of e)re(n)?t.size=v[n]:Ve(n)?t.debug=!0:Le(n)?t.download=!0:$e(n)&&(t.format=n);return t},ze=e=>{if(!e||typeof e!="object")return null;const t=[];return e.debug&&t.push(O.DEBUG),e.download&&t.push(O.DOWNLOAD),e.format&&e.format!==j.AUTO&&t.push(e.format),e.size&&re(e.size)&&t.push(e.size),t.length?t.sort().join(","):null},Be=e=>{if(L(e)){const t=ne(e);if(t)return{fields:t,options:{}}}return Me(e)},Me=e=>{if(!e)return null;const t=e.trim();if(!t)return null;try{const n=We(t);if(!n)return null;const{code:o,optionTokens:i}=n,r=ne(o);if(!r)return null;const s=ke(i);return{fields:r,options:s}}catch(n){n instanceof Error?console.error(`Error parsing URL: ${n.message}`,n):console.error("uncaught error",n)}return null},Ge=(e,t)=>{const n=Pe(e);if(n instanceof Error)return null;let o=null;if(t!=null&&t.endpoint&&(o=te(t==null?void 0:t.endpoint),!o))throw new je("Cannot construct URL: bad endpoint. Ensure endpoint starts with http:// or https://");o||(o=te(we));const i=[o.origin,"image",n],r=t?ze(t):null;return r&&i.push(r),t!=null&&t.filename?i.push(t.filename):i.push("image.jpg"),i.join("/")},We=e=>{try{const t=new URL(e),n=De(t.pathname.split("/"));if(n[0]!=="image"||![3,4].includes(n.length))throw new Error("Unrecognized URL");const o=n[1].trim();if(!o.length||!L(o))throw new Error("URL is not formatted as base64url");if(n.length===4){const i=n[2].split(",");return{code:o,optionTokens:i}}if(n.length===3)return{code:o,optionTokens:[]}}catch{return null}return null},oe=.7,se=1,N=24,Fe=v.lg,ce=process.env.NODE_ENV,He=ce==="development",ie=typeof document>"u",Xe=ce==="test",Ye=ie?()=>{}:x.useLayoutEffect,qe="<visionary>",S=(e,...t)=>{!console||typeof console.log!="function"||console.log(`${qe} ${e}`,...t)},ae=new Uint8Array(128);for(let e=0;e<83;e++)ae["0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#$%*+,-.:;=?@[]^_{|}~".charCodeAt(e)]=e;const $=(e,t,n)=>{let o=0;for(;t<n;)o*=83,o+=ae[e.charCodeAt(t++)];return o},le=Math.pow,C=Math.PI,Ze=C*2,ue=3294.6,fe=269.025,Je=e=>e>10.31475?le(e/fe+.052132,2.4):e/ue,W=e=>~~(e>1227e-8?fe*le(e,.416666)-13.025:e*ue+1),D=e=>(e<0?-1:1)*e*e,de=e=>{for(e+=C/2;e>C;)e-=Ze;const t=1.27323954*e-.405284735*D(e);return .225*(D(t)-t)+t};function Ke(e){const t=$(e,2,6);return[t>>16,t>>8&255,t&255]}function Qe(e,t,n,o){const i=$(e,0,1),r=i%9+1,s=~~(i/9)+1,u=r*s;let c=0,a=0,p=0,l=0,m=0,h=0,f=0,y=0,b=0,g=0,w=0,E=0;const d=($(e,1,2)+1)/13446*(o|1),I=new Float64Array(u*3),Y=Ke(e);for(c=0;c<3;c++)I[c]=Je(Y[c]);for(c=1;c<u;c++)E=$(e,4+c*2,6+c*2),I[c*3]=D(~~(E/361)-9)*d,I[c*3+1]=D(~~(E/19)%19-9)*d,I[c*3+2]=D(E%19-9)*d;const z=new Float64Array(s*n),B=new Float64Array(r*t);for(a=0;a<s;a++)for(l=0;l<n;l++)z[a*n+l]=de(C*l*a/n);for(c=0;c<r;c++)for(p=0;p<t;p++)B[c*t+p]=de(C*p*c/t);const P=t*4,U=new Uint8ClampedArray(P*n);for(l=0;l<n;l++)for(p=0;p<t;p++){for(m=h=f=0,a=0;a<s;a++)for(b=z[a*n+l],c=0;c<r;c++)y=B[c*t+p]*b,g=(c+a*r)*3,m+=I[g]*y,h+=I[g+1]*y,f+=I[g+2]*y;w=4*p+l*P,U[w]=W(m),U[w+1]=W(h),U[w+2]=W(f),U[w+3]=255}return U}const k=e=>{try{return new URL(e)}catch{return null}},et=(e,t)=>`rgba(${e.r},${e.g},${e.b},${t})`,F=e=>He||Xe?{"data-testid":e}:{},tt=(e,t)=>t?{"data-fileid":e}:{},pe=(e,t)=>Math.min(e,t),nt=e=>{let t=e.replace(/^#/,"");if(t.length!==3&&t.length!==6)return null;t.length===3&&(t=`${t[0]}${t[0]}${t[1]}${t[1]}${t[2]}${t[2]}`);const n=parseInt(t.slice(0,2),16),o=parseInt(t.slice(2,4),16);return{b:parseInt(t.slice(4,6),16),g:o,r:n}},T=(e,t=0)=>{const n=Math.pow(10,t);return Math.round(e*n)/n},rt=(e,t)=>{const n=k(e),o=k(t);return!n||!o?e:(o.pathname=n.pathname,o.search=n.search,o.toString())},ot=(e,t={},n=oe,o=se)=>{if(!e)return null;try{t.debug&&S("input imageSrc:",e);const i=Be(e);if(t.debug&&S("Visionary URL data: ",i),!i)throw new Error("Could not parse Visionary URL");const{fields:r,options:s}=i;if(r.sourceWidth<1||r.sourceHeight<1)throw new Error("Invalid image dimensions");const u=r.sourceWidth/r.sourceHeight,c=(t==null?void 0:t.size)??s.size??Fe,a=M[c];let p=0,l=0,m=0;if(u>=1){l=p=pe(a,r.sourceWidth);const g=T(l/u);m=T(l/g,6)}else p=pe(a,r.sourceHeight),l=T(p*u),m=T(l/p,6);const h=T(100/m,6),f={...r,arPaddingTop:`${h}%`,aspectRatio:m,maxWidth:l,src:e},y=k(r.url);if(y)f.src=y.toString();else if(!k(e)&&L(r.url)){const g=Ge(r,{endpoint:t.endpoint,size:c});g&&(f.src=g)}t.endpoint&&(f.src=rt(f.src,t.endpoint));const b=r.bcc?nt(r.bcc):null;if(b&&(f.backgroundColor=et(b,n)),!ie&&r.blurhash&&!t.disableBlurLayer){const g=performance.now(),w=Qe(r.blurhash,N,N,o),E=performance.now()-g;t.debug&&S(`Blurhash decode time: ${T(E,1)} ms`),w&&(f.pixels=w)}return t.debug&&S("Visionary Image state: ",f),f}catch{return null}},he={bottom:0,left:0,position:"absolute",right:0,top:0},st={...he,maxHeight:"100%",maxWidth:"100%"},ct={...he,height:"100%",width:"100%"},it=e=>{const t={...st};return e&&(t.display="none"),t},H={CANVAS:"canvas",CONTAINER:"container",IMAGE:"image"},X={container:"v7y_7587",preventDrag:"v7y_b8c0",preventSelection:"v7y_e0dd"},at=({alt:e,bgColorAlpha:t=oe,className:n,debug:o=!1,disableBlurLayer:i=!1,disableImageLayer:r=!1,endpoint:s,height:u,hideImageLayer:c=!1,lazy:a=!0,onClick:p,onError:l,onLoad:m,preventDrag:h=!1,preventSelection:f=!1,punch:y=se,size:b,src:g,style:w,width:E})=>{const d=x.useMemo(()=>ot(g,{debug:o,disableBlurLayer:i,endpoint:s,size:b},t,y),[t,o,i,s,y,b,g]),I=x.useRef(null),[Y,z]=ve();Ye(function(){if(!I.current||!(d!=null&&d.blurhash))return;if(!d.pixels){console.warn("No pixel data passed in, skipping");return}const ft=performance.now(),Z=I.current.getContext("2d");if(!Z){console.warn("Cannot access canvasRenderingContext, skipping");return}const J=Z.createImageData(N,N);if(!J){console.warn("Could not create ImageData on CanvasRenderingContext");return}if(J.data.set(d.pixels),Z.putImageData(J,0,0),o){const dt=performance.now()-ft;S(`Canvas render time: ${T(dt,1)} ms`)}},[d==null?void 0:d.blurhash,d==null?void 0:d.pixels,o]);const B=x.useCallback(_=>{o&&S("Image load error ",_),l&&l()},[o,l]),P={alt:e,loading:!a||z?"eager":"lazy",onLoad:m};if(!d){o&&S("Not a Visionary URL, rendering fallback <img />");const _={...P,className:n,height:u,onClick:p,onError:l,src:g,style:w,width:E};return R.jsx("img",{..._})}const U=be(X.container,n,{[X.preventDrag]:!!h,[X.preventSelection]:!!f}),q={...{"--v-ar":d.arPaddingTop},aspectRatio:d.aspectRatio,backgroundColor:(d==null?void 0:d.backgroundColor)??void 0,maxWidth:d.maxWidth,position:"relative",width:"100%",...w};E&&(q.width=E),u&&(q.height=u);const lt={onClick:p},ut=it(c);return R.jsxs("div",{className:U,ref:Y,style:q,...tt(d.url,o),...F(H.CONTAINER),...lt,children:[!i&&R.jsx("canvas",{height:N,ref:I,style:ct,width:N,...F(H.CANVAS)}),!r&&R.jsx("img",{...P,...F(H.IMAGE),onError:B,src:d.src,style:ut})]})};A.Image=at,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "visionary-image",
3
- "version": "1.0.0",
3
+ "description": "React image component with built-in Blurhash placeholders for better UX and Core Web Vitals.",
4
+ "version": "1.0.2",
4
5
  "type": "module",
5
6
  "main": "./dist/visionary-image.umd.js",
6
7
  "module": "./dist/visionary-image.es.js",
@@ -16,14 +17,14 @@
16
17
  "license": "ISC",
17
18
  "scripts": {
18
19
  "build": "tsc && npm run clean && vite build",
20
+ "build-storybook": "storybook build -o storybook-static",
19
21
  "clean": "rimraf dist/",
20
22
  "dev": "vite",
21
23
  "lint": "tsc --noEmit; eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
22
24
  "preview": "vite preview",
23
- "test": "vitest",
24
- "test:coverage": "vitest run --coverage",
25
25
  "storybook": "storybook dev -p 6006 --no-open",
26
- "build-storybook": "storybook build"
26
+ "test": "vitest",
27
+ "test:coverage": "vitest run --coverage"
27
28
  },
28
29
  "files": [
29
30
  "dist/",
@@ -36,7 +37,7 @@
36
37
  },
37
38
  "dependencies": {
38
39
  "classnames": "2.5.1",
39
- "fast-blurhash": "1.1.2",
40
+ "fast-blurhash": "1.1.4",
40
41
  "react-hook-inview": "4.5.1",
41
42
  "visionary-url": "1.3.1"
42
43
  },
@@ -85,12 +86,13 @@
85
86
  "core-web-vitals",
86
87
  "fid",
87
88
  "image",
88
- "lcp",
89
+ "inp",
89
90
  "performance",
90
91
  "placeholder",
91
92
  "react",
92
93
  "seo",
93
94
  "speed",
95
+ "typescript",
94
96
  "visionary",
95
97
  "web-vitals"
96
98
  ]