react-img-cutout 1.0.0

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 ADDED
@@ -0,0 +1,1245 @@
1
+ import kt, { useState as tt, useRef as B, useCallback as O, useMemo as D, useEffect as N, useContext as F, createContext as at } from "react";
2
+ var Q = { exports: {} }, G = {};
3
+ var ct;
4
+ function Et() {
5
+ if (ct) return G;
6
+ ct = 1;
7
+ var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), r = /* @__PURE__ */ Symbol.for("react.fragment");
8
+ function o(n, a, l) {
9
+ var i = null;
10
+ if (l !== void 0 && (i = "" + l), a.key !== void 0 && (i = "" + a.key), "key" in a) {
11
+ l = {};
12
+ for (var s in a)
13
+ s !== "key" && (l[s] = a[s]);
14
+ } else l = a;
15
+ return a = l.ref, {
16
+ $$typeof: t,
17
+ type: n,
18
+ key: i,
19
+ ref: a !== void 0 ? a : null,
20
+ props: l
21
+ };
22
+ }
23
+ return G.Fragment = r, G.jsx = o, G.jsxs = o, G;
24
+ }
25
+ var X = {};
26
+ var ft;
27
+ function It() {
28
+ return ft || (ft = 1, process.env.NODE_ENV !== "production" && (function() {
29
+ function t(e) {
30
+ if (e == null) return null;
31
+ if (typeof e == "function")
32
+ return e.$$typeof === y ? null : e.displayName || e.name || null;
33
+ if (typeof e == "string") return e;
34
+ switch (e) {
35
+ case S:
36
+ return "Fragment";
37
+ case m:
38
+ return "Profiler";
39
+ case T:
40
+ return "StrictMode";
41
+ case M:
42
+ return "Suspense";
43
+ case V:
44
+ return "SuspenseList";
45
+ case k:
46
+ return "Activity";
47
+ }
48
+ if (typeof e == "object")
49
+ switch (typeof e.tag == "number" && console.error(
50
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
51
+ ), e.$$typeof) {
52
+ case w:
53
+ return "Portal";
54
+ case P:
55
+ return e.displayName || "Context";
56
+ case j:
57
+ return (e._context.displayName || "Context") + ".Consumer";
58
+ case b:
59
+ var c = e.render;
60
+ return e = e.displayName, e || (e = c.displayName || c.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
61
+ case z:
62
+ return c = e.displayName || null, c !== null ? c : t(e.type) || "Memo";
63
+ case E:
64
+ c = e._payload, e = e._init;
65
+ try {
66
+ return t(e(c));
67
+ } catch {
68
+ }
69
+ }
70
+ return null;
71
+ }
72
+ function r(e) {
73
+ return "" + e;
74
+ }
75
+ function o(e) {
76
+ try {
77
+ r(e);
78
+ var c = !1;
79
+ } catch {
80
+ c = !0;
81
+ }
82
+ if (c) {
83
+ c = console;
84
+ var x = c.error, I = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
85
+ return x.call(
86
+ c,
87
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
88
+ I
89
+ ), r(e);
90
+ }
91
+ }
92
+ function n(e) {
93
+ if (e === S) return "<>";
94
+ if (typeof e == "object" && e !== null && e.$$typeof === E)
95
+ return "<...>";
96
+ try {
97
+ var c = t(e);
98
+ return c ? "<" + c + ">" : "<...>";
99
+ } catch {
100
+ return "<...>";
101
+ }
102
+ }
103
+ function a() {
104
+ var e = v.A;
105
+ return e === null ? null : e.getOwner();
106
+ }
107
+ function l() {
108
+ return Error("react-stack-top-frame");
109
+ }
110
+ function i(e) {
111
+ if ($.call(e, "key")) {
112
+ var c = Object.getOwnPropertyDescriptor(e, "key").get;
113
+ if (c && c.isReactWarning) return !1;
114
+ }
115
+ return e.key !== void 0;
116
+ }
117
+ function s(e, c) {
118
+ function x() {
119
+ W || (W = !0, console.error(
120
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
121
+ c
122
+ ));
123
+ }
124
+ x.isReactWarning = !0, Object.defineProperty(e, "key", {
125
+ get: x,
126
+ configurable: !0
127
+ });
128
+ }
129
+ function d() {
130
+ var e = t(this.type);
131
+ return Y[e] || (Y[e] = !0, console.error(
132
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
133
+ )), e = this.props.ref, e !== void 0 ? e : null;
134
+ }
135
+ function u(e, c, x, I, Z, nt) {
136
+ var A = x.ref;
137
+ return e = {
138
+ $$typeof: g,
139
+ type: e,
140
+ key: c,
141
+ props: x,
142
+ _owner: I
143
+ }, (A !== void 0 ? A : null) !== null ? Object.defineProperty(e, "ref", {
144
+ enumerable: !1,
145
+ get: d
146
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
147
+ configurable: !1,
148
+ enumerable: !1,
149
+ writable: !0,
150
+ value: 0
151
+ }), Object.defineProperty(e, "_debugInfo", {
152
+ configurable: !1,
153
+ enumerable: !1,
154
+ writable: !0,
155
+ value: null
156
+ }), Object.defineProperty(e, "_debugStack", {
157
+ configurable: !1,
158
+ enumerable: !1,
159
+ writable: !0,
160
+ value: Z
161
+ }), Object.defineProperty(e, "_debugTask", {
162
+ configurable: !1,
163
+ enumerable: !1,
164
+ writable: !0,
165
+ value: nt
166
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
167
+ }
168
+ function p(e, c, x, I, Z, nt) {
169
+ var A = c.children;
170
+ if (A !== void 0)
171
+ if (I)
172
+ if (L(A)) {
173
+ for (I = 0; I < A.length; I++)
174
+ R(A[I]);
175
+ Object.freeze && Object.freeze(A);
176
+ } else
177
+ console.error(
178
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
179
+ );
180
+ else R(A);
181
+ if ($.call(c, "key")) {
182
+ A = t(e);
183
+ var H = Object.keys(c).filter(function(wt) {
184
+ return wt !== "key";
185
+ });
186
+ I = 0 < H.length ? "{key: someKey, " + H.join(": ..., ") + ": ...}" : "{key: someKey}", ut[A + I] || (H = 0 < H.length ? "{" + H.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ `A props object containing a "key" prop is being spread into JSX:
188
+ let props = %s;
189
+ <%s {...props} />
190
+ React keys must be passed directly to JSX without using spread:
191
+ let props = %s;
192
+ <%s key={someKey} {...props} />`,
193
+ I,
194
+ A,
195
+ H,
196
+ A
197
+ ), ut[A + I] = !0);
198
+ }
199
+ if (A = null, x !== void 0 && (o(x), A = "" + x), i(c) && (o(c.key), A = "" + c.key), "key" in c) {
200
+ x = {};
201
+ for (var st in c)
202
+ st !== "key" && (x[st] = c[st]);
203
+ } else x = c;
204
+ return A && s(
205
+ x,
206
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
207
+ ), u(
208
+ e,
209
+ A,
210
+ x,
211
+ a(),
212
+ Z,
213
+ nt
214
+ );
215
+ }
216
+ function R(e) {
217
+ h(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === E && (e._payload.status === "fulfilled" ? h(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
218
+ }
219
+ function h(e) {
220
+ return typeof e == "object" && e !== null && e.$$typeof === g;
221
+ }
222
+ var f = kt, g = /* @__PURE__ */ Symbol.for("react.transitional.element"), w = /* @__PURE__ */ Symbol.for("react.portal"), S = /* @__PURE__ */ Symbol.for("react.fragment"), T = /* @__PURE__ */ Symbol.for("react.strict_mode"), m = /* @__PURE__ */ Symbol.for("react.profiler"), j = /* @__PURE__ */ Symbol.for("react.consumer"), P = /* @__PURE__ */ Symbol.for("react.context"), b = /* @__PURE__ */ Symbol.for("react.forward_ref"), M = /* @__PURE__ */ Symbol.for("react.suspense"), V = /* @__PURE__ */ Symbol.for("react.suspense_list"), z = /* @__PURE__ */ Symbol.for("react.memo"), E = /* @__PURE__ */ Symbol.for("react.lazy"), k = /* @__PURE__ */ Symbol.for("react.activity"), y = /* @__PURE__ */ Symbol.for("react.client.reference"), v = f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, $ = Object.prototype.hasOwnProperty, L = Array.isArray, _ = console.createTask ? console.createTask : function() {
223
+ return null;
224
+ };
225
+ f = {
226
+ react_stack_bottom_frame: function(e) {
227
+ return e();
228
+ }
229
+ };
230
+ var W, Y = {}, U = f.react_stack_bottom_frame.bind(
231
+ f,
232
+ l
233
+ )(), lt = _(n(l)), ut = {};
234
+ X.Fragment = S, X.jsx = function(e, c, x) {
235
+ var I = 1e4 > v.recentlyCreatedOwnerStacks++;
236
+ return p(
237
+ e,
238
+ c,
239
+ x,
240
+ !1,
241
+ I ? Error("react-stack-top-frame") : U,
242
+ I ? _(n(e)) : lt
243
+ );
244
+ }, X.jsxs = function(e, c, x) {
245
+ var I = 1e4 > v.recentlyCreatedOwnerStacks++;
246
+ return p(
247
+ e,
248
+ c,
249
+ x,
250
+ !0,
251
+ I ? Error("react-stack-top-frame") : U,
252
+ I ? _(n(e)) : lt
253
+ );
254
+ };
255
+ })()), X;
256
+ }
257
+ var dt;
258
+ function At() {
259
+ return dt || (dt = 1, process.env.NODE_ENV === "production" ? Q.exports = Et() : Q.exports = It()), Q.exports;
260
+ }
261
+ var C = At();
262
+ function Rt(t, r) {
263
+ const o = new Uint8Array(r);
264
+ for (let n = 0; n < r; n++)
265
+ o[n] = t[n * 4 + 3];
266
+ return o;
267
+ }
268
+ function _t(t, r, o, n) {
269
+ if (r <= 0 || o <= 0) return { x: 0, y: 0, w: 1, h: 1 };
270
+ let a = r, l = o, i = 0, s = 0, d = !1;
271
+ for (let u = 0; u < o; u++)
272
+ for (let p = 0; p < r; p++)
273
+ t[u * r + p] > n && (p < a && (a = p), p > i && (i = p), u < l && (l = u), u > s && (s = u), d = !0);
274
+ return d ? {
275
+ x: a / r,
276
+ y: l / o,
277
+ w: (i - a + 1) / r,
278
+ h: (s - l + 1) / o
279
+ } : { x: 0, y: 0, w: 1, h: 1 };
280
+ }
281
+ class Ct {
282
+ id;
283
+ bounds = { x: 0, y: 0, w: 1, h: 1 };
284
+ /** URL of the cutout mask image */
285
+ src;
286
+ /** Alpha value (0-255) a pixel must exceed to be considered "visible" */
287
+ threshold;
288
+ /** Pre-extracted alpha channel — one byte per pixel, for fast lookups */
289
+ alpha = new Uint8Array(0);
290
+ /** Source image dimensions (pixels) — needed to map normalized coords to pixel indices */
291
+ width = 0;
292
+ height = 0;
293
+ constructor(r, o) {
294
+ this.id = r.id, this.src = r.src, this.threshold = o;
295
+ }
296
+ /**
297
+ * Loads the cutout image and pre-computes the alpha buffer + bounding box.
298
+ *
299
+ * Steps:
300
+ * 1. Create an <img> element and wait for it to load.
301
+ * 2. Draw the image onto a temporary offscreen <canvas>.
302
+ * 3. Read the raw RGBA pixel data from the canvas.
303
+ * 4. Extract only the alpha channel into a compact buffer (see `extractAlpha`).
304
+ * 5. Compute the tight bounding box of visible pixels (see `computeBoundsFromAlpha`).
305
+ *
306
+ * If the canvas is CORS-tainted (image from a different origin without proper
307
+ * headers), reading pixel data will throw. In that case we fall back to an
308
+ * empty alpha buffer, which means hitTest will always return false.
309
+ */
310
+ async prepare() {
311
+ const r = new Image();
312
+ r.crossOrigin = "anonymous", r.src = this.src, await new Promise((i) => {
313
+ r.onload = () => i(), r.onerror = () => i();
314
+ });
315
+ const o = r.naturalWidth, n = r.naturalHeight;
316
+ if (o <= 0 || n <= 0) return;
317
+ const a = document.createElement("canvas");
318
+ a.width = o, a.height = n;
319
+ const l = a.getContext("2d", { willReadFrequently: !0 });
320
+ if (l)
321
+ try {
322
+ l.drawImage(r, 0, 0);
323
+ const i = l.getImageData(0, 0, o, n);
324
+ this.alpha = Rt(i.data, o * n), this.width = o, this.height = n, this.bounds = _t(this.alpha, o, n, this.threshold);
325
+ } catch {
326
+ this.alpha = new Uint8Array(0);
327
+ }
328
+ }
329
+ /**
330
+ * Tests whether the normalized point (nx, ny) is over a visible pixel.
331
+ *
332
+ * Three-phase approach:
333
+ * 1. **Alpha buffer check** — if the buffer is empty (image failed to load or
334
+ * was CORS-tainted), return false immediately.
335
+ * 2. **Bounding-box check** — reject points outside the pre-computed AABB of
336
+ * visible pixels (very cheap).
337
+ * 3. **Per-pixel alpha lookup** — convert the normalized coordinates to pixel
338
+ * indices, look up the alpha value in the pre-extracted buffer, and compare
339
+ * it against the threshold.
340
+ *
341
+ * @param nx - normalized x-coordinate (0-1, relative to the image width)
342
+ * @param ny - normalized y-coordinate (0-1, relative to the image height)
343
+ */
344
+ hitTest(r, o) {
345
+ if (this.alpha.length === 0) return !1;
346
+ const n = this.bounds;
347
+ if (r < n.x || r > n.x + n.w || o < n.y || o > n.y + n.h) return !1;
348
+ const a = Math.min(this.width - 1, Math.max(0, Math.floor(r * this.width))), l = Math.min(
349
+ this.height - 1,
350
+ Math.max(0, Math.floor(o * this.height))
351
+ );
352
+ return this.alpha[l * this.width + a] > this.threshold;
353
+ }
354
+ }
355
+ class Tt {
356
+ id;
357
+ bounds;
358
+ constructor(r) {
359
+ this.id = r.id, this.bounds = { ...r.bounds };
360
+ }
361
+ hitTest(r, o) {
362
+ const n = this.bounds;
363
+ return r >= n.x && r <= n.x + n.w && o >= n.y && o <= n.y + n.h;
364
+ }
365
+ }
366
+ function St(t, r, o) {
367
+ let n = !1;
368
+ for (let a = 0, l = o.length - 1; a < o.length; l = a++) {
369
+ const i = o[a][0], s = o[a][1], d = o[l][0], u = o[l][1];
370
+ s > r != u > r && t < (d - i) * (r - s) / (u - s) + i && (n = !n);
371
+ }
372
+ return n;
373
+ }
374
+ class jt {
375
+ id;
376
+ bounds;
377
+ points;
378
+ constructor(r) {
379
+ this.id = r.id, this.points = r.points;
380
+ let o = 1 / 0, n = 1 / 0, a = -1 / 0, l = -1 / 0;
381
+ for (const [i, s] of r.points)
382
+ i < o && (o = i), i > a && (a = i), s < n && (n = s), s > l && (l = s);
383
+ this.bounds = {
384
+ x: o,
385
+ y: n,
386
+ w: a - o,
387
+ h: l - n
388
+ };
389
+ }
390
+ /**
391
+ * Tests whether the normalized point (nx, ny) is inside this polygon.
392
+ *
393
+ * Two-phase approach for performance:
394
+ * 1. **Bounding-box check** — if the point is outside the AABB, return false
395
+ * immediately (very cheap).
396
+ * 2. **Ray-cast check** — run the full point-in-polygon algorithm for precise
397
+ * hit detection only if the point passed the bounding-box check.
398
+ *
399
+ * @param nx - normalized x-coordinate (0-1, relative to the image width)
400
+ * @param ny - normalized y-coordinate (0-1, relative to the image height)
401
+ */
402
+ hitTest(r, o) {
403
+ const n = this.bounds;
404
+ return r < n.x || r > n.x + n.w || o < n.y || o > n.y + n.h ? !1 : St(r, o, this.points);
405
+ }
406
+ }
407
+ function $t(t, r) {
408
+ switch (t.type) {
409
+ case "image":
410
+ return new Ct(t, r);
411
+ case "bbox":
412
+ return new Tt(t);
413
+ case "polygon":
414
+ return new jt(t);
415
+ }
416
+ }
417
+ function Pt(t) {
418
+ switch (t.type) {
419
+ case "image":
420
+ return `${t.id}:image:${t.src}:${t.label ?? ""}`;
421
+ case "bbox":
422
+ return `${t.id}:bbox:${t.bounds.x},${t.bounds.y},${t.bounds.w},${t.bounds.h}:${t.label ?? ""}`;
423
+ case "polygon":
424
+ return `${t.id}:polygon:${t.points.flat().join(",")}:${t.label ?? ""}`;
425
+ }
426
+ }
427
+ function Mt(t, r = !0, o = 30, n = 150) {
428
+ const [a, l] = tt(null), [i, s] = tt(null), d = B(null), u = B([]), [p, R] = tt({}), h = Math.min(255, Math.max(0, o)), f = B(null), g = O(() => {
429
+ f.current === null && (f.current = setTimeout(() => {
430
+ f.current = null, l(null);
431
+ }, n));
432
+ }, [n]), w = O(() => {
433
+ f.current !== null && (clearTimeout(f.current), f.current = null);
434
+ }, []), S = t.map(Pt).join("|"), T = D(() => t, [S]);
435
+ N(() => {
436
+ if (!r) {
437
+ u.current = [];
438
+ return;
439
+ }
440
+ let E = !1, k = [];
441
+ async function y() {
442
+ const v = [], $ = {};
443
+ for (const L of T) {
444
+ const _ = $t(L, h);
445
+ if (_.prepare && await _.prepare(), E) return;
446
+ v.push(_), $[_.id] = _.bounds;
447
+ }
448
+ E || (k = v, u.current = v, R($));
449
+ }
450
+ return y(), () => {
451
+ E = !0;
452
+ for (const v of k)
453
+ v.dispose?.();
454
+ };
455
+ }, [T, r, h]);
456
+ const m = O(
457
+ (E, k) => {
458
+ const y = u.current;
459
+ for (let v = y.length - 1; v >= 0; v--)
460
+ if (y[v].hitTest(E, k))
461
+ return y[v].id;
462
+ return null;
463
+ },
464
+ []
465
+ ), j = O(
466
+ (E) => {
467
+ const k = d.current;
468
+ if (!k) return null;
469
+ const y = k.getBoundingClientRect(), v = (E.clientX - y.left) / y.width, $ = (E.clientY - y.top) / y.height;
470
+ return v < 0 || v > 1 || $ < 0 || $ > 1 ? null : { nx: v, ny: $ };
471
+ },
472
+ []
473
+ ), P = O(
474
+ (E) => {
475
+ if (!r) return;
476
+ const k = j(E);
477
+ if (!k) {
478
+ g();
479
+ return;
480
+ }
481
+ const y = m(k.nx, k.ny);
482
+ if (y === null) {
483
+ if (E.target?.closest('[data-cutout-overlay="true"]')) {
484
+ w();
485
+ return;
486
+ }
487
+ g();
488
+ return;
489
+ }
490
+ w(), l(y);
491
+ },
492
+ [r, j, m, g, w]
493
+ ), b = O(() => {
494
+ g();
495
+ }, [g]), M = O(
496
+ (E) => {
497
+ if (!r) return;
498
+ const k = j(E);
499
+ if (!k) {
500
+ s(null);
501
+ return;
502
+ }
503
+ const y = m(k.nx, k.ny);
504
+ s(y === i || y === null ? null : y);
505
+ },
506
+ [r, j, m, i]
507
+ ), V = i ?? a, z = r ? p : {};
508
+ return N(() => () => {
509
+ w();
510
+ }, [w]), {
511
+ hoveredId: a,
512
+ selectedId: i,
513
+ activeId: V,
514
+ boundsMap: z,
515
+ containerRef: d,
516
+ containerProps: {
517
+ onPointerMove: P,
518
+ onPointerLeave: b,
519
+ onClick: M
520
+ }
521
+ };
522
+ }
523
+ function it(t, r) {
524
+ return { name: t, css: r };
525
+ }
526
+ const pt = /* @__PURE__ */ new Set();
527
+ function Wt(t) {
528
+ if (!(!t.keyframes?.length || typeof document > "u"))
529
+ for (const r of t.keyframes) {
530
+ if (pt.has(r.name)) continue;
531
+ pt.add(r.name);
532
+ const o = document.createElement("style");
533
+ o.setAttribute("data-ricut-kf", r.name), o.textContent = `@keyframes ${r.name} {
534
+ ${r.css}
535
+ }`, document.head.appendChild(o);
536
+ }
537
+ }
538
+ const J = "all 0.5s cubic-bezier(0.22, 1, 0.36, 1)", Ot = {
539
+ name: "elevate",
540
+ transition: J,
541
+ mainImageHovered: {
542
+ filter: "brightness(0.45) saturate(0.7)"
543
+ },
544
+ vignetteStyle: {
545
+ background: "radial-gradient(ellipse at center, transparent 20%, rgba(0,0,0,0.4) 100%)"
546
+ },
547
+ cutoutActive: {
548
+ transform: "scale(1.04) translateY(-6px)",
549
+ filter: "drop-shadow(0 0 28px rgba(130, 190, 255, 0.5)) drop-shadow(0 16px 48px rgba(0, 0, 0, 0.55))",
550
+ opacity: 1
551
+ },
552
+ cutoutInactive: {
553
+ transform: "scale(1)",
554
+ filter: "brightness(0.45) saturate(0.6)",
555
+ opacity: 0.55
556
+ },
557
+ cutoutIdle: {
558
+ transform: "scale(1)",
559
+ filter: "drop-shadow(0 1px 4px rgba(0, 0, 0, 0.12))",
560
+ opacity: 1
561
+ },
562
+ geometryActive: {
563
+ fill: "rgba(130, 190, 255, 0.2)",
564
+ stroke: "rgba(130, 190, 255, 0.9)",
565
+ strokeWidth: 2,
566
+ glow: "0 0 24px rgba(130, 190, 255, 0.5), 0 0 56px rgba(130, 190, 255, 0.2), 0 12px 40px rgba(0, 0, 0, 0.4)"
567
+ },
568
+ geometryInactive: {
569
+ fill: "rgba(100, 150, 200, 0.06)",
570
+ stroke: "rgba(100, 150, 200, 0.2)",
571
+ strokeWidth: 1
572
+ },
573
+ geometryIdle: {
574
+ fill: "transparent",
575
+ stroke: "transparent",
576
+ strokeWidth: 1
577
+ }
578
+ }, Nt = {
579
+ name: "glow",
580
+ transition: J,
581
+ mainImageHovered: {
582
+ filter: "brightness(0.55) saturate(0.8)"
583
+ },
584
+ vignetteStyle: {
585
+ background: "radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.3) 100%)"
586
+ },
587
+ cutoutActive: {
588
+ transform: "scale(1)",
589
+ filter: "drop-shadow(0 0 20px rgba(255, 200, 100, 0.6)) drop-shadow(0 0 60px rgba(255, 200, 100, 0.25))",
590
+ opacity: 1
591
+ },
592
+ cutoutInactive: {
593
+ transform: "scale(1)",
594
+ filter: "brightness(0.5) saturate(0.5)",
595
+ opacity: 0.5
596
+ },
597
+ cutoutIdle: {
598
+ transform: "scale(1)",
599
+ filter: "none",
600
+ opacity: 1
601
+ },
602
+ geometryActive: {
603
+ fill: "rgba(255, 200, 100, 0.15)",
604
+ stroke: "rgba(255, 200, 100, 0.85)",
605
+ strokeWidth: 2,
606
+ glow: "0 0 20px rgba(255, 200, 100, 0.5), 0 0 56px rgba(255, 200, 100, 0.2)"
607
+ },
608
+ geometryInactive: {
609
+ fill: "rgba(200, 160, 80, 0.05)",
610
+ stroke: "rgba(200, 160, 80, 0.2)",
611
+ strokeWidth: 1
612
+ },
613
+ geometryIdle: {
614
+ fill: "transparent",
615
+ stroke: "transparent",
616
+ strokeWidth: 1
617
+ }
618
+ }, Yt = {
619
+ name: "lift",
620
+ transition: J,
621
+ mainImageHovered: {
622
+ filter: "brightness(0.4)"
623
+ },
624
+ vignetteStyle: {
625
+ background: "rgba(0,0,0,0.25)"
626
+ },
627
+ cutoutActive: {
628
+ transform: "scale(1.06) translateY(-10px)",
629
+ filter: "drop-shadow(0 24px 64px rgba(0, 0, 0, 0.7))",
630
+ opacity: 1
631
+ },
632
+ cutoutInactive: {
633
+ transform: "scale(0.97)",
634
+ filter: "brightness(0.35)",
635
+ opacity: 0.4
636
+ },
637
+ cutoutIdle: {
638
+ transform: "scale(1)",
639
+ filter: "none",
640
+ opacity: 1
641
+ },
642
+ geometryActive: {
643
+ fill: "rgba(255, 255, 255, 0.1)",
644
+ stroke: "rgba(255, 255, 255, 0.7)",
645
+ strokeWidth: 2,
646
+ glow: "0 20px 56px rgba(0, 0, 0, 0.6), 0 0 16px rgba(255, 255, 255, 0.1)"
647
+ },
648
+ geometryInactive: {
649
+ fill: "rgba(255, 255, 255, 0.02)",
650
+ stroke: "rgba(255, 255, 255, 0.1)",
651
+ strokeWidth: 1
652
+ },
653
+ geometryIdle: {
654
+ fill: "transparent",
655
+ stroke: "transparent",
656
+ strokeWidth: 1
657
+ }
658
+ }, Dt = {
659
+ name: "subtle",
660
+ transition: "all 0.3s ease",
661
+ mainImageHovered: {
662
+ filter: "brightness(0.7)"
663
+ },
664
+ vignetteStyle: {
665
+ background: "transparent"
666
+ },
667
+ cutoutActive: {
668
+ transform: "scale(1)",
669
+ filter: "none",
670
+ opacity: 1
671
+ },
672
+ cutoutInactive: {
673
+ transform: "scale(1)",
674
+ filter: "none",
675
+ opacity: 0.35
676
+ },
677
+ cutoutIdle: {
678
+ transform: "scale(1)",
679
+ filter: "none",
680
+ opacity: 1
681
+ },
682
+ geometryActive: {
683
+ fill: "rgba(255, 255, 255, 0.08)",
684
+ stroke: "rgba(255, 255, 255, 0.5)",
685
+ strokeWidth: 1
686
+ },
687
+ geometryInactive: {
688
+ fill: "transparent",
689
+ stroke: "rgba(255, 255, 255, 0.1)",
690
+ strokeWidth: 1
691
+ },
692
+ geometryIdle: {
693
+ fill: "transparent",
694
+ stroke: "transparent",
695
+ strokeWidth: 1
696
+ }
697
+ }, ht = it(
698
+ "_ricut-trace-stroke",
699
+ `from { stroke-dashoffset: 0; }
700
+ to { stroke-dashoffset: -1; }`
701
+ ), gt = it(
702
+ "_ricut-trace-glow",
703
+ `0% { filter: drop-shadow(-3px -3px 6px rgba(255,255,255,0.6)) drop-shadow(0 0 2px rgba(255,255,255,0.15)); }
704
+ 25% { filter: drop-shadow(3px -3px 6px rgba(255,255,255,0.6)) drop-shadow(0 0 2px rgba(255,255,255,0.15)); }
705
+ 50% { filter: drop-shadow(3px 3px 6px rgba(255,255,255,0.6)) drop-shadow(0 0 2px rgba(255,255,255,0.15)); }
706
+ 75% { filter: drop-shadow(-3px 3px 6px rgba(255,255,255,0.6)) drop-shadow(0 0 2px rgba(255,255,255,0.15)); }
707
+ 100% { filter: drop-shadow(-3px -3px 6px rgba(255,255,255,0.6)) drop-shadow(0 0 2px rgba(255,255,255,0.15)); }`
708
+ ), Vt = {
709
+ name: "trace",
710
+ transition: J,
711
+ keyframes: [ht, gt],
712
+ mainImageHovered: {
713
+ filter: "brightness(0.35) saturate(0.5)"
714
+ },
715
+ vignetteStyle: {
716
+ background: "radial-gradient(ellipse at center, transparent 20%, rgba(0,0,0,0.5) 100%)"
717
+ },
718
+ cutoutActive: {
719
+ transform: "scale(1)",
720
+ filter: "drop-shadow(-3px -3px 6px rgba(255,255,255,0.6)) drop-shadow(0 0 2px rgba(255,255,255,0.15))",
721
+ opacity: 1,
722
+ animation: `${gt.name} 3s linear infinite`
723
+ },
724
+ cutoutInactive: {
725
+ transform: "scale(1)",
726
+ filter: "brightness(0.35) saturate(0.4)",
727
+ opacity: 0.4
728
+ },
729
+ cutoutIdle: {
730
+ transform: "scale(1)",
731
+ filter: "none",
732
+ opacity: 1
733
+ },
734
+ geometryActive: {
735
+ fill: "rgba(255, 255, 255, 0.03)",
736
+ stroke: "rgba(255, 255, 255, 0.9)",
737
+ strokeWidth: 2.5,
738
+ strokeDasharray: "0.15 0.85",
739
+ animation: `${ht.name} 3s linear infinite`,
740
+ glow: "0 0 10px rgba(255, 255, 255, 0.25)"
741
+ },
742
+ geometryInactive: {
743
+ fill: "transparent",
744
+ stroke: "rgba(255, 255, 255, 0.15)",
745
+ strokeWidth: 1
746
+ },
747
+ geometryIdle: {
748
+ fill: "transparent",
749
+ stroke: "transparent",
750
+ strokeWidth: 1
751
+ }
752
+ }, mt = it(
753
+ "_ricut-shimmer",
754
+ `0%, 100% {
755
+ filter: brightness(1.05) contrast(1.02)
756
+ drop-shadow(0 0 6px rgba(255, 255, 255, 0.12))
757
+ drop-shadow(0 12px 32px rgba(0, 0, 0, 0.4));
758
+ }
759
+ 18% {
760
+ filter: brightness(1.4) contrast(1.08)
761
+ drop-shadow(0 0 14px rgba(255, 255, 255, 0.4))
762
+ drop-shadow(0 12px 32px rgba(0, 0, 0, 0.4));
763
+ }
764
+ 36% {
765
+ filter: brightness(1.05) contrast(1.02)
766
+ drop-shadow(0 0 6px rgba(255, 255, 255, 0.12))
767
+ drop-shadow(0 12px 32px rgba(0, 0, 0, 0.4));
768
+ }`
769
+ ), Ht = {
770
+ name: "shimmer",
771
+ transition: J,
772
+ keyframes: [mt],
773
+ mainImageHovered: {
774
+ filter: "brightness(0.35) saturate(0.6)"
775
+ },
776
+ vignetteStyle: {
777
+ background: "radial-gradient(ellipse at center, transparent 20%, rgba(0,0,0,0.5) 100%)"
778
+ },
779
+ cutoutActive: {
780
+ transform: "scale(1.04) translateY(-6px)",
781
+ /* The resting filter is overridden by the animation keyframes, but
782
+ we set it here so there's a graceful look before the first frame. */
783
+ filter: "brightness(1.05) contrast(1.02) drop-shadow(0 0 6px rgba(255,255,255,0.12)) drop-shadow(0 12px 32px rgba(0,0,0,0.4))",
784
+ opacity: 1,
785
+ animation: `${mt.name} 2.4s ease-in-out infinite`
786
+ },
787
+ cutoutInactive: {
788
+ transform: "scale(1)",
789
+ filter: "brightness(0.35) saturate(0.5)",
790
+ opacity: 0.4
791
+ },
792
+ cutoutIdle: {
793
+ transform: "scale(1)",
794
+ filter: "drop-shadow(0 1px 4px rgba(0, 0, 0, 0.1))",
795
+ opacity: 1
796
+ },
797
+ geometryActive: {
798
+ fill: "rgba(255, 255, 255, 0.1)",
799
+ stroke: "rgba(255, 255, 255, 0.7)",
800
+ strokeWidth: 2,
801
+ glow: "0 0 14px rgba(255, 255, 255, 0.35), 0 12px 32px rgba(0, 0, 0, 0.4)"
802
+ },
803
+ geometryInactive: {
804
+ fill: "rgba(255, 255, 255, 0.02)",
805
+ stroke: "rgba(255, 255, 255, 0.1)",
806
+ strokeWidth: 1
807
+ },
808
+ geometryIdle: {
809
+ fill: "transparent",
810
+ stroke: "transparent",
811
+ strokeWidth: 1
812
+ }
813
+ }, q = {
814
+ elevate: Ot,
815
+ glow: Nt,
816
+ lift: Yt,
817
+ subtle: Dt,
818
+ trace: Vt,
819
+ shimmer: Ht
820
+ }, et = at(null), xt = at(null);
821
+ function rt() {
822
+ const t = F(xt);
823
+ if (!t) throw new Error("Must be used inside <CutoutViewer>");
824
+ return t;
825
+ }
826
+ const K = at(null);
827
+ function qt() {
828
+ const t = F(K);
829
+ if (!t)
830
+ throw new Error("useCutout must be used inside <CutoutViewer.Cutout>");
831
+ return t;
832
+ }
833
+ function Bt({ id: t, src: r, label: o, effect: n, children: a, renderLayer: l }) {
834
+ const i = F(et), s = rt();
835
+ if (!i)
836
+ throw new Error("<CutoutViewer.Cutout> must be used inside <CutoutViewer>");
837
+ N(() => (i.registerCutout({ type: "image", id: t, src: r, label: o }), () => i.unregisterCutout(t)), [t, r, o, i]);
838
+ const d = n ? typeof n == "string" ? q[n] ?? s.effect : n : s.effect, u = s.activeId === t, p = s.hoveredId === t, R = s.selectedId === t, h = { x: 0, y: 0, w: 1, h: 1 }, f = s.boundsMap[t] ?? h;
839
+ let g;
840
+ !s.enabled || !s.isAnyActive && !s.showAll ? g = d.cutoutIdle : s.showAll || u ? g = d.cutoutActive : g = d.cutoutInactive;
841
+ const w = D(
842
+ () => ({
843
+ id: t,
844
+ label: o,
845
+ bounds: f,
846
+ isActive: u,
847
+ isHovered: p,
848
+ isSelected: R,
849
+ effect: d
850
+ }),
851
+ [t, o, f, u, p, R, d]
852
+ );
853
+ return /* @__PURE__ */ C.jsxs(K.Provider, { value: w, children: [
854
+ /* @__PURE__ */ C.jsx(
855
+ "div",
856
+ {
857
+ "data-cutout-id": t,
858
+ style: {
859
+ pointerEvents: "none",
860
+ position: "absolute",
861
+ inset: 0,
862
+ zIndex: u ? 20 : 10,
863
+ transition: d.transition,
864
+ ...g
865
+ },
866
+ children: l ? l({ isActive: u, isHovered: p, isSelected: R, bounds: f, effect: d }) : /* @__PURE__ */ C.jsx(
867
+ "img",
868
+ {
869
+ src: r,
870
+ alt: o || t,
871
+ draggable: !1,
872
+ style: {
873
+ width: "100%",
874
+ height: "100%",
875
+ objectFit: "fill",
876
+ userSelect: "none"
877
+ }
878
+ }
879
+ )
880
+ }
881
+ ),
882
+ a
883
+ ] });
884
+ }
885
+ function bt(t) {
886
+ const { filter: r, ...o } = t;
887
+ return o;
888
+ }
889
+ function Ft({
890
+ id: t,
891
+ bounds: r,
892
+ label: o,
893
+ effect: n,
894
+ children: a,
895
+ renderLayer: l
896
+ }) {
897
+ const i = F(et), s = rt();
898
+ if (!i)
899
+ throw new Error(
900
+ "<CutoutViewer.BBoxCutout> must be used inside <CutoutViewer>"
901
+ );
902
+ const { x: d, y: u, w: p, h: R } = r;
903
+ N(() => (i.registerCutout({ type: "bbox", id: t, bounds: { x: d, y: u, w: p, h: R }, label: o }), () => i.unregisterCutout(t)), [t, d, u, p, R, o, i]);
904
+ const h = n ? typeof n == "string" ? q[n] ?? s.effect : n : s.effect, f = s.activeId === t, g = s.hoveredId === t, w = s.selectedId === t, S = { x: 0, y: 0, w: 1, h: 1 }, T = s.boundsMap[t] ?? S;
905
+ let m, j;
906
+ !s.enabled || !s.isAnyActive && !s.showAll ? (j = { ...h.cutoutIdle, filter: "none", opacity: 0 }, m = h.geometryIdle) : s.showAll || f ? (j = bt(h.cutoutActive), m = h.geometryActive) : (j = bt(h.cutoutInactive), m = h.geometryInactive);
907
+ const b = m ?? {
908
+ fill: "rgba(37, 99, 235, 0.15)",
909
+ stroke: "rgba(37, 99, 235, 0.6)",
910
+ strokeWidth: 2
911
+ }, M = D(
912
+ () => ({
913
+ id: t,
914
+ label: o,
915
+ bounds: T,
916
+ isActive: f,
917
+ isHovered: g,
918
+ isSelected: w,
919
+ effect: h
920
+ }),
921
+ [t, o, T, f, g, w, h]
922
+ );
923
+ return /* @__PURE__ */ C.jsxs(K.Provider, { value: M, children: [
924
+ /* @__PURE__ */ C.jsx(
925
+ "div",
926
+ {
927
+ "data-cutout-id": t,
928
+ style: {
929
+ pointerEvents: "none",
930
+ position: "absolute",
931
+ inset: 0,
932
+ zIndex: f ? 20 : 10,
933
+ transition: h.transition,
934
+ ...j
935
+ },
936
+ children: l ? l({ isActive: f, isHovered: g, isSelected: w, bounds: T, effect: h }) : /* @__PURE__ */ C.jsx(
937
+ "svg",
938
+ {
939
+ viewBox: "0 0 1 1",
940
+ preserveAspectRatio: "none",
941
+ style: {
942
+ position: "absolute",
943
+ inset: 0,
944
+ width: "100%",
945
+ height: "100%",
946
+ overflow: "visible",
947
+ filter: b.glow ? `drop-shadow(${b.glow.split(",")[0]?.trim() ?? ""})` : "none"
948
+ },
949
+ children: /* @__PURE__ */ C.jsx(
950
+ "rect",
951
+ {
952
+ x: T.x,
953
+ y: T.y,
954
+ width: T.w,
955
+ height: T.h,
956
+ rx: 4e-3,
957
+ fill: b.fill,
958
+ stroke: b.stroke,
959
+ strokeWidth: (b.strokeWidth ?? 2) * 15e-4,
960
+ strokeLinecap: b.strokeDasharray ? "round" : void 0,
961
+ strokeDasharray: b.strokeDasharray,
962
+ pathLength: b.strokeDasharray ? 1 : void 0,
963
+ style: {
964
+ transition: h.transition,
965
+ animation: b.animation
966
+ }
967
+ }
968
+ )
969
+ }
970
+ )
971
+ }
972
+ ),
973
+ a
974
+ ] });
975
+ }
976
+ function yt(t) {
977
+ const { filter: r, ...o } = t;
978
+ return o;
979
+ }
980
+ function zt({
981
+ id: t,
982
+ points: r,
983
+ label: o,
984
+ effect: n,
985
+ children: a,
986
+ renderLayer: l
987
+ }) {
988
+ const i = F(et), s = rt();
989
+ if (!i)
990
+ throw new Error(
991
+ "<CutoutViewer.PolygonCutout> must be used inside <CutoutViewer>"
992
+ );
993
+ const d = r.flat().join(",");
994
+ N(() => (i.registerCutout({ type: "polygon", id: t, points: r, label: o }), () => i.unregisterCutout(t)), [t, d, o, i]);
995
+ const u = n ? typeof n == "string" ? q[n] ?? s.effect : n : s.effect, p = s.activeId === t, R = s.hoveredId === t, h = s.selectedId === t, f = { x: 0, y: 0, w: 1, h: 1 }, g = s.boundsMap[t] ?? f;
996
+ let w, S;
997
+ !s.enabled || !s.isAnyActive && !s.showAll ? (S = { ...u.cutoutIdle, filter: "none", opacity: 0 }, w = u.geometryIdle) : s.showAll || p ? (S = yt(u.cutoutActive), w = u.geometryActive) : (S = yt(u.cutoutInactive), w = u.geometryInactive);
998
+ const m = w ?? {
999
+ fill: "rgba(37, 99, 235, 0.15)",
1000
+ stroke: "rgba(37, 99, 235, 0.6)",
1001
+ strokeWidth: 2
1002
+ }, j = D(
1003
+ () => ({
1004
+ id: t,
1005
+ label: o,
1006
+ bounds: g,
1007
+ isActive: p,
1008
+ isHovered: R,
1009
+ isSelected: h,
1010
+ effect: u
1011
+ }),
1012
+ [t, o, g, p, R, h, u]
1013
+ );
1014
+ return /* @__PURE__ */ C.jsxs(K.Provider, { value: j, children: [
1015
+ /* @__PURE__ */ C.jsx(
1016
+ "div",
1017
+ {
1018
+ "data-cutout-id": t,
1019
+ style: {
1020
+ pointerEvents: "none",
1021
+ position: "absolute",
1022
+ inset: 0,
1023
+ zIndex: p ? 20 : 10,
1024
+ transition: u.transition,
1025
+ ...S
1026
+ },
1027
+ children: l ? l({ isActive: p, isHovered: R, isSelected: h, bounds: g, effect: u }) : /* @__PURE__ */ C.jsx(
1028
+ "svg",
1029
+ {
1030
+ viewBox: "0 0 1 1",
1031
+ preserveAspectRatio: "none",
1032
+ style: {
1033
+ position: "absolute",
1034
+ inset: 0,
1035
+ width: "100%",
1036
+ height: "100%",
1037
+ overflow: "visible",
1038
+ filter: m.glow ? `drop-shadow(${m.glow.split(",")[0]?.trim() ?? ""})` : "none"
1039
+ },
1040
+ children: /* @__PURE__ */ C.jsx(
1041
+ "polygon",
1042
+ {
1043
+ points: r.map(([P, b]) => `${P},${b}`).join(" "),
1044
+ fill: m.fill,
1045
+ stroke: m.stroke,
1046
+ strokeWidth: (m.strokeWidth ?? 2) * 15e-4,
1047
+ strokeLinejoin: "round",
1048
+ strokeLinecap: m.strokeDasharray ? "round" : void 0,
1049
+ strokeDasharray: m.strokeDasharray,
1050
+ pathLength: m.strokeDasharray ? 1 : void 0,
1051
+ style: {
1052
+ transition: u.transition,
1053
+ animation: m.animation
1054
+ }
1055
+ }
1056
+ )
1057
+ }
1058
+ )
1059
+ }
1060
+ ),
1061
+ a
1062
+ ] });
1063
+ }
1064
+ function Lt(t, r) {
1065
+ const { x: o, y: n, w: a, h: l } = r;
1066
+ let i, s;
1067
+ t.includes("left") ? (i = `${o * 100}%`, s = "0") : t.includes("right") ? (i = `${(o + a) * 100}%`, s = "-100%") : (i = `${(o + a / 2) * 100}%`, s = "-50%");
1068
+ let d, u;
1069
+ return t.startsWith("top") ? (d = `${n * 100}%`, u = "-100%") : t.startsWith("bottom") ? (d = `${(n + l) * 100}%`, u = "0") : (d = `${(n + l / 2) * 100}%`, u = "-50%"), {
1070
+ position: "absolute",
1071
+ left: i,
1072
+ top: d,
1073
+ transform: `translate(${s}, ${u})`
1074
+ };
1075
+ }
1076
+ function Ut({
1077
+ placement: t = "top-center",
1078
+ children: r,
1079
+ className: o = "",
1080
+ style: n
1081
+ }) {
1082
+ const a = F(K), l = rt();
1083
+ if (!a)
1084
+ throw new Error(
1085
+ "<CutoutViewer.Overlay> must be used inside <CutoutViewer.Cutout>"
1086
+ );
1087
+ const i = l.enabled && (l.showAll || a.isActive), s = Lt(t, a.bounds);
1088
+ return /* @__PURE__ */ C.jsx(
1089
+ "div",
1090
+ {
1091
+ "data-cutout-overlay": "true",
1092
+ className: o,
1093
+ style: {
1094
+ zIndex: 30,
1095
+ transition: a.effect.transition,
1096
+ opacity: i ? 1 : 0,
1097
+ pointerEvents: i ? "auto" : "none",
1098
+ ...s,
1099
+ ...n
1100
+ },
1101
+ children: r
1102
+ }
1103
+ );
1104
+ }
1105
+ function vt(t) {
1106
+ switch (t.type) {
1107
+ case "image":
1108
+ return `image:${t.src}:${t.label ?? ""}`;
1109
+ case "bbox":
1110
+ return `bbox:${t.bounds.x},${t.bounds.y},${t.bounds.w},${t.bounds.h}:${t.label ?? ""}`;
1111
+ case "polygon":
1112
+ return `polygon:${t.points.flat().join(",")}:${t.label ?? ""}`;
1113
+ }
1114
+ }
1115
+ function Gt({
1116
+ mainImage: t,
1117
+ mainImageAlt: r = "Main image",
1118
+ effect: o = "elevate",
1119
+ enabled: n = !0,
1120
+ showAll: a = !1,
1121
+ alphaThreshold: l = 30,
1122
+ hoverLeaveDelay: i = 150,
1123
+ children: s,
1124
+ className: d = "",
1125
+ style: u,
1126
+ onHover: p,
1127
+ onActiveChange: R,
1128
+ onSelect: h
1129
+ }) {
1130
+ const f = typeof o == "string" ? q[o] ?? q.elevate : o;
1131
+ N(() => {
1132
+ Wt(f);
1133
+ }, [f]);
1134
+ const [g, w] = tt(() => /* @__PURE__ */ new Map()), S = O(
1135
+ (_) => {
1136
+ w((W) => {
1137
+ const Y = W.get(_.id);
1138
+ if (Y && vt(Y) === vt(_))
1139
+ return W;
1140
+ const U = new Map(W);
1141
+ return U.set(_.id, _), U;
1142
+ });
1143
+ },
1144
+ []
1145
+ ), T = O((_) => {
1146
+ w((W) => {
1147
+ if (!W.has(_)) return W;
1148
+ const Y = new Map(W);
1149
+ return Y.delete(_), Y;
1150
+ });
1151
+ }, []), m = D(
1152
+ () => ({ registerCutout: S, unregisterCutout: T }),
1153
+ [S, T]
1154
+ ), j = D(() => Array.from(g.values()), [g]), { activeId: P, selectedId: b, hoveredId: M, boundsMap: V, containerRef: z, containerProps: E } = Mt(j, n, l, i), k = B(null), y = B(null), v = B(null);
1155
+ N(() => {
1156
+ M !== k.current && (k.current = M, p?.(M));
1157
+ }, [M, p]), N(() => {
1158
+ P !== y.current && (y.current = P, R?.(P));
1159
+ }, [P, R]), N(() => {
1160
+ b !== v.current && (v.current = b, h?.(b));
1161
+ }, [b, h]);
1162
+ const $ = a || P !== null, L = D(
1163
+ () => ({
1164
+ activeId: P,
1165
+ selectedId: b,
1166
+ hoveredId: M,
1167
+ effect: f,
1168
+ enabled: n,
1169
+ showAll: a,
1170
+ boundsMap: V,
1171
+ isAnyActive: $
1172
+ }),
1173
+ [P, b, M, f, n, a, V, $]
1174
+ );
1175
+ return /* @__PURE__ */ C.jsx(et.Provider, { value: m, children: /* @__PURE__ */ C.jsx(xt.Provider, { value: L, children: /* @__PURE__ */ C.jsxs(
1176
+ "div",
1177
+ {
1178
+ ref: z,
1179
+ className: d,
1180
+ style: {
1181
+ position: "relative",
1182
+ width: "100%",
1183
+ overflow: "hidden",
1184
+ cursor: $ && n ? "pointer" : "default",
1185
+ ...u
1186
+ },
1187
+ ...E,
1188
+ children: [
1189
+ /* @__PURE__ */ C.jsx(
1190
+ "img",
1191
+ {
1192
+ src: t,
1193
+ alt: r,
1194
+ draggable: !1,
1195
+ style: {
1196
+ display: "block",
1197
+ width: "100%",
1198
+ height: "auto",
1199
+ userSelect: "none",
1200
+ transition: f.transition,
1201
+ ...$ && n ? f.mainImageHovered : {}
1202
+ }
1203
+ }
1204
+ ),
1205
+ /* @__PURE__ */ C.jsx(
1206
+ "div",
1207
+ {
1208
+ style: {
1209
+ pointerEvents: "none",
1210
+ position: "absolute",
1211
+ inset: 0,
1212
+ transition: f.transition,
1213
+ opacity: $ && n ? 1 : 0,
1214
+ ...f.vignetteStyle
1215
+ }
1216
+ }
1217
+ ),
1218
+ s
1219
+ ]
1220
+ }
1221
+ ) }) });
1222
+ }
1223
+ const ot = Gt;
1224
+ ot.Cutout = Bt;
1225
+ ot.BBoxCutout = Ft;
1226
+ ot.PolygonCutout = zt;
1227
+ ot.Overlay = Ut;
1228
+ export {
1229
+ Ut as CutoutOverlay,
1230
+ ot as CutoutViewer,
1231
+ Ct as ImageHitTestStrategy,
1232
+ jt as PolygonHitTestStrategy,
1233
+ Tt as RectHitTestStrategy,
1234
+ $t as createHitTestStrategy,
1235
+ it as defineKeyframes,
1236
+ Ot as elevateEffect,
1237
+ Nt as glowEffect,
1238
+ q as hoverEffects,
1239
+ Yt as liftEffect,
1240
+ Ht as shimmerEffect,
1241
+ Dt as subtleEffect,
1242
+ Vt as traceEffect,
1243
+ qt as useCutout,
1244
+ Mt as useCutoutHitTest
1245
+ };