eddyter 1.3.76 → 1.3.78

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.
@@ -0,0 +1,1498 @@
1
+ import { jsx as r, jsxs as f, Fragment as Se } from "react/jsx-runtime";
2
+ import { I as Me } from "./ImageResizer-o0eMm1Mg.js";
3
+ import { CodeNode as Ot } from "@lexical/code";
4
+ import { LinkNode as Ht } from "@lexical/link";
5
+ import { AutoFocusPlugin as ze } from "@lexical/react/LexicalAutoFocusPlugin";
6
+ import { useCollaborationContext as Ae } from "@lexical/react/LexicalCollaborationContext";
7
+ import { useLexicalComposerContext as De } from "@lexical/react/LexicalComposerContext";
8
+ import { ContentEditable as Ft } from "@lexical/react/LexicalContentEditable";
9
+ import { LexicalErrorBoundary as Xt } from "@lexical/react/LexicalErrorBoundary";
10
+ import { HistoryPlugin as Bt } from "@lexical/react/LexicalHistoryPlugin";
11
+ import { LexicalNestedComposer as Kt } from "@lexical/react/LexicalNestedComposer";
12
+ import { OnChangePlugin as Ut } from "@lexical/react/LexicalOnChangePlugin";
13
+ import { RichTextPlugin as Gt } from "@lexical/react/LexicalRichTextPlugin";
14
+ import { useLexicalEditable as Le } from "@lexical/react/useLexicalEditable";
15
+ import { useLexicalNodeSelection as $e } from "@lexical/react/useLexicalNodeSelection";
16
+ import { mergeRegister as _e } from "@lexical/utils";
17
+ import { RootNode as qt, TextNode as Vt, LineBreakNode as Jt, ParagraphNode as Qt, $getSelection as st, $isNodeSelection as dt, $isParagraphNode as Et, $setSelection as bt, $isRangeSelection as Te, SELECTION_CHANGE_COMMAND as We, COMMAND_PRIORITY_LOW as U, CLICK_COMMAND as Ye, DRAGSTART_COMMAND as je, KEY_DELETE_COMMAND as Oe, KEY_BACKSPACE_COMMAND as He, KEY_ENTER_COMMAND as Fe, KEY_ESCAPE_COMMAND as Xe, $getNodeByKey as ct, createCommand as Be } from "lexical";
18
+ import mt, { useState as P, useRef as G, useMemo as $t, useCallback as S, useEffect as q, useLayoutEffect as Ke, Suspense as Ue } from "react";
19
+ import { a as gt, D as Zt, b as te, d as ee, e as re, f as oe, h as ae, B as _t, L as ie, i as ne, C as yt, I as Ge, u as qe, $ as tt, t as z, j as Ve, k as Je, W as Qe, l as Ze, A as tr, m as er, n as rr, T as or, o as ar, S as ir, E as nr, p as sr, q as dr, r as cr, s as lr } from "./index-BDzAe_Dw.js";
20
+ import "react-dom";
21
+ const se = gt("Crop", [
22
+ ["path", { d: "M6 2v14a2 2 0 0 0 2 2h14", key: "ron5a4" }],
23
+ ["path", { d: "M18 22V8a2 2 0 0 0-2-2H2", key: "7s9ehn" }]
24
+ ]);
25
+ const ur = gt("Link2", [
26
+ ["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
27
+ ["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
28
+ ["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
29
+ ]);
30
+ const Tt = gt("RectangleHorizontal", [
31
+ ["rect", { width: "20", height: "12", x: "2", y: "6", rx: "2", key: "9lu3g6" }]
32
+ ]);
33
+ const Wt = gt("RectangleVertical", [
34
+ ["rect", { width: "12", height: "20", x: "6", y: "2", rx: "2", key: "1oxtiu" }]
35
+ ]);
36
+ const mr = gt("Square", [
37
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }]
38
+ ]), gr = ({
39
+ open: a,
40
+ onOpenChange: o,
41
+ oldImageUrl: e,
42
+ newImageUrl: d,
43
+ onReplace: R,
44
+ onCancel: y
45
+ }) => /* @__PURE__ */ r(Zt, { open: a, onOpenChange: o, children: /* @__PURE__ */ f(te, { className: "sm:max-w-[800px] max-h-[90vh] overflow-y-auto", children: [
46
+ /* @__PURE__ */ f(ee, { children: [
47
+ /* @__PURE__ */ f(re, { className: "flex items-center gap-2 text-xl", children: [
48
+ /* @__PURE__ */ r("span", { className: "text-2xl", children: "🔄" }),
49
+ "Compare Images"
50
+ ] }),
51
+ /* @__PURE__ */ r(oe, { className: "text-sm pt-1", children: "Choose whether to replace the original image with the refined version." })
52
+ ] }),
53
+ /* @__PURE__ */ f("div", { className: "space-y-4 py-4", children: [
54
+ /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: /* @__PURE__ */ f("div", { className: "space-y-2", children: [
55
+ /* @__PURE__ */ f("div", { className: "flex items-center justify-between", children: [
56
+ /* @__PURE__ */ r("span", { className: "text-sm font-semibold text-gray-700 dark:text-gray-300", children: "Refined Image" }),
57
+ /* @__PURE__ */ r("span", { className: "text-xs px-2 py-1 rounded-full bg-blue-100 dark:bg-blue-950/30 text-blue-600 dark:text-blue-400", children: "New" })
58
+ ] }),
59
+ /* @__PURE__ */ r("div", { className: "relative aspect-square rounded-lg overflow-hidden bg-gray-100 dark:bg-gray-800 border-2 border-blue-500 dark:border-blue-600", children: /* @__PURE__ */ r(
60
+ "img",
61
+ {
62
+ src: d,
63
+ alt: "Refined",
64
+ className: "w-full h-full object-contain"
65
+ }
66
+ ) })
67
+ ] }) }),
68
+ /* @__PURE__ */ r("div", { className: "p-3 rounded-lg bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800", children: /* @__PURE__ */ f("p", { className: "text-sm text-blue-800 dark:text-blue-200", children: [
69
+ /* @__PURE__ */ r("span", { className: "font-semibold", children: "Note:" }),
70
+ ' Clicking "Replace" will update the image in your document. This action cannot be undone.'
71
+ ] }) })
72
+ ] }),
73
+ /* @__PURE__ */ f(ae, { className: "gap-2", children: [
74
+ /* @__PURE__ */ r(
75
+ _t,
76
+ {
77
+ variant: "outline",
78
+ onClick: y,
79
+ children: "Keep Original"
80
+ }
81
+ ),
82
+ /* @__PURE__ */ f(
83
+ _t,
84
+ {
85
+ onClick: R,
86
+ className: "bg-blue-500 hover:bg-blue-600 text-white",
87
+ children: [
88
+ /* @__PURE__ */ r("span", { className: "mr-2", children: "✓" }),
89
+ "Replace Image"
90
+ ]
91
+ }
92
+ )
93
+ ] })
94
+ ] }) });
95
+ function hr({
96
+ caption: a
97
+ }) {
98
+ return /* @__PURE__ */ r("div", { className: "signature-caption-container", children: /* @__PURE__ */ f(
99
+ Kt,
100
+ {
101
+ initialEditor: a,
102
+ initialNodes: [
103
+ qt,
104
+ Vt,
105
+ Jt,
106
+ Qt,
107
+ Ht,
108
+ Ot
109
+ ],
110
+ children: [
111
+ /* @__PURE__ */ r(
112
+ Gt,
113
+ {
114
+ contentEditable: /* @__PURE__ */ r(
115
+ Ft,
116
+ {
117
+ "aria-placeholder": "Enter signature name...",
118
+ placeholder: /* @__PURE__ */ r("div", { style: {
119
+ position: "absolute",
120
+ top: "4px",
121
+ left: "8px",
122
+ right: "8px",
123
+ textAlign: "center",
124
+ pointerEvents: "none",
125
+ color: "hsla(var(--cteditorf47ac10b-foreground) / 0.4)",
126
+ fontStyle: "italic"
127
+ }, children: "Enter signature name..." }),
128
+ className: "signature-caption-editable"
129
+ }
130
+ ),
131
+ ErrorBoundary: Xt
132
+ }
133
+ ),
134
+ /* @__PURE__ */ r(Ut, { onChange: () => {
135
+ } }),
136
+ /* @__PURE__ */ r(Bt, {}),
137
+ /* @__PURE__ */ r(ie, { namespace: ne.namespace })
138
+ ]
139
+ }
140
+ ) });
141
+ }
142
+ const fr = "/transform-image/";
143
+ function ht(a) {
144
+ if (!yt || a.startsWith("data:") || a.toLowerCase().endsWith(".svg"))
145
+ return !1;
146
+ try {
147
+ const o = new URL(a).origin, e = new URL(yt).origin;
148
+ return o === e;
149
+ } catch {
150
+ return !1;
151
+ }
152
+ }
153
+ function de(a) {
154
+ if (!ht(a))
155
+ return null;
156
+ try {
157
+ const e = new URL(a).pathname.replace(/^\//, ""), d = "transform-image/";
158
+ return e.startsWith(d) ? e.slice(d.length) || null : e || null;
159
+ } catch {
160
+ return null;
161
+ }
162
+ }
163
+ function pr(a, o) {
164
+ if (!ht(a))
165
+ return a;
166
+ const e = de(a);
167
+ if (!e)
168
+ return a;
169
+ const d = `${o.x},${o.y},${o.width},${o.height}`;
170
+ return `${yt.replace(/\/$/, "")}${fr}${e}?crop=${d}`;
171
+ }
172
+ function Yt(a) {
173
+ if (!ht(a))
174
+ return a;
175
+ try {
176
+ const o = new URL(a);
177
+ return o.searchParams.delete("crop"), o.toString();
178
+ } catch {
179
+ return a;
180
+ }
181
+ }
182
+ function ce(a) {
183
+ if (!ht(a))
184
+ return Yt(a);
185
+ const o = de(a);
186
+ return o ? `${yt.replace(/\/$/, "")}/${o}` : Yt(a);
187
+ }
188
+ function br(a) {
189
+ if (typeof document > "u")
190
+ return;
191
+ let o = document.head || document.getElementsByTagName("head")[0], e = document.createElement("style");
192
+ e.type = "text/css", o.appendChild(e), e.styleSheet ? e.styleSheet.cssText = a : e.appendChild(document.createTextNode(a));
193
+ }
194
+ Array(12).fill(0);
195
+ let It = 1;
196
+ class yr {
197
+ constructor() {
198
+ this.subscribe = (o) => (this.subscribers.push(o), () => {
199
+ const e = this.subscribers.indexOf(o);
200
+ this.subscribers.splice(e, 1);
201
+ }), this.publish = (o) => {
202
+ this.subscribers.forEach((e) => e(o));
203
+ }, this.addToast = (o) => {
204
+ this.publish(o), this.toasts = [
205
+ ...this.toasts,
206
+ o
207
+ ];
208
+ }, this.create = (o) => {
209
+ var e;
210
+ const { message: d, ...R } = o, y = typeof o?.id == "number" || ((e = o.id) == null ? void 0 : e.length) > 0 ? o.id : It++, D = this.toasts.find((C) => C.id === y), I = o.dismissible === void 0 ? !0 : o.dismissible;
211
+ return this.dismissedToasts.has(y) && this.dismissedToasts.delete(y), D ? this.toasts = this.toasts.map((C) => C.id === y ? (this.publish({
212
+ ...C,
213
+ ...o,
214
+ id: y,
215
+ title: d
216
+ }), {
217
+ ...C,
218
+ ...o,
219
+ id: y,
220
+ dismissible: I,
221
+ title: d
222
+ }) : C) : this.addToast({
223
+ title: d,
224
+ ...R,
225
+ dismissible: I,
226
+ id: y
227
+ }), y;
228
+ }, this.dismiss = (o) => (o ? (this.dismissedToasts.add(o), requestAnimationFrame(() => this.subscribers.forEach((e) => e({
229
+ id: o,
230
+ dismiss: !0
231
+ })))) : this.toasts.forEach((e) => {
232
+ this.subscribers.forEach((d) => d({
233
+ id: e.id,
234
+ dismiss: !0
235
+ }));
236
+ }), o), this.message = (o, e) => this.create({
237
+ ...e,
238
+ message: o
239
+ }), this.error = (o, e) => this.create({
240
+ ...e,
241
+ message: o,
242
+ type: "error"
243
+ }), this.success = (o, e) => this.create({
244
+ ...e,
245
+ type: "success",
246
+ message: o
247
+ }), this.info = (o, e) => this.create({
248
+ ...e,
249
+ type: "info",
250
+ message: o
251
+ }), this.warning = (o, e) => this.create({
252
+ ...e,
253
+ type: "warning",
254
+ message: o
255
+ }), this.loading = (o, e) => this.create({
256
+ ...e,
257
+ type: "loading",
258
+ message: o
259
+ }), this.promise = (o, e) => {
260
+ if (!e)
261
+ return;
262
+ let d;
263
+ e.loading !== void 0 && (d = this.create({
264
+ ...e,
265
+ promise: o,
266
+ type: "loading",
267
+ message: e.loading,
268
+ description: typeof e.description != "function" ? e.description : void 0
269
+ }));
270
+ const R = Promise.resolve(o instanceof Function ? o() : o);
271
+ let y = d !== void 0, D;
272
+ const I = R.then(async (v) => {
273
+ if (D = [
274
+ "resolve",
275
+ v
276
+ ], mt.isValidElement(v))
277
+ y = !1, this.create({
278
+ id: d,
279
+ type: "default",
280
+ message: v
281
+ });
282
+ else if (vr(v) && !v.ok) {
283
+ y = !1;
284
+ const c = typeof e.error == "function" ? await e.error(`HTTP error! status: ${v.status}`) : e.error, k = typeof e.description == "function" ? await e.description(`HTTP error! status: ${v.status}`) : e.description, A = typeof c == "object" && !mt.isValidElement(c) ? c : {
285
+ message: c
286
+ };
287
+ this.create({
288
+ id: d,
289
+ type: "error",
290
+ description: k,
291
+ ...A
292
+ });
293
+ } else if (v instanceof Error) {
294
+ y = !1;
295
+ const c = typeof e.error == "function" ? await e.error(v) : e.error, k = typeof e.description == "function" ? await e.description(v) : e.description, A = typeof c == "object" && !mt.isValidElement(c) ? c : {
296
+ message: c
297
+ };
298
+ this.create({
299
+ id: d,
300
+ type: "error",
301
+ description: k,
302
+ ...A
303
+ });
304
+ } else if (e.success !== void 0) {
305
+ y = !1;
306
+ const c = typeof e.success == "function" ? await e.success(v) : e.success, k = typeof e.description == "function" ? await e.description(v) : e.description, A = typeof c == "object" && !mt.isValidElement(c) ? c : {
307
+ message: c
308
+ };
309
+ this.create({
310
+ id: d,
311
+ type: "success",
312
+ description: k,
313
+ ...A
314
+ });
315
+ }
316
+ }).catch(async (v) => {
317
+ if (D = [
318
+ "reject",
319
+ v
320
+ ], e.error !== void 0) {
321
+ y = !1;
322
+ const E = typeof e.error == "function" ? await e.error(v) : e.error, c = typeof e.description == "function" ? await e.description(v) : e.description, x = typeof E == "object" && !mt.isValidElement(E) ? E : {
323
+ message: E
324
+ };
325
+ this.create({
326
+ id: d,
327
+ type: "error",
328
+ description: c,
329
+ ...x
330
+ });
331
+ }
332
+ }).finally(() => {
333
+ y && (this.dismiss(d), d = void 0), e.finally == null || e.finally.call(e);
334
+ }), C = () => new Promise((v, E) => I.then(() => D[0] === "reject" ? E(D[1]) : v(D[1])).catch(E));
335
+ return typeof d != "string" && typeof d != "number" ? {
336
+ unwrap: C
337
+ } : Object.assign(d, {
338
+ unwrap: C
339
+ });
340
+ }, this.custom = (o, e) => {
341
+ const d = e?.id || It++;
342
+ return this.create({
343
+ jsx: o(d),
344
+ id: d,
345
+ ...e
346
+ }), d;
347
+ }, this.getActiveToasts = () => this.toasts.filter((o) => !this.dismissedToasts.has(o.id)), this.subscribers = [], this.toasts = [], this.dismissedToasts = /* @__PURE__ */ new Set();
348
+ }
349
+ }
350
+ const _ = new yr(), xr = (a, o) => {
351
+ const e = o?.id || It++;
352
+ return _.addToast({
353
+ title: a,
354
+ ...o,
355
+ id: e
356
+ }), e;
357
+ }, vr = (a) => a && typeof a == "object" && "ok" in a && typeof a.ok == "boolean" && "status" in a && typeof a.status == "number", wr = xr, Cr = () => _.toasts, kr = () => _.getActiveToasts(), Nr = Object.assign(wr, {
358
+ success: _.success,
359
+ info: _.info,
360
+ warning: _.warning,
361
+ error: _.error,
362
+ custom: _.custom,
363
+ message: _.message,
364
+ promise: _.promise,
365
+ dismiss: _.dismiss,
366
+ loading: _.loading
367
+ }, {
368
+ getHistory: Cr,
369
+ getToasts: kr
370
+ });
371
+ br("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");
372
+ function Er({
373
+ open: a,
374
+ onOpenChange: o,
375
+ src: e,
376
+ altText: d,
377
+ width: R,
378
+ height: y,
379
+ onCropApply: D
380
+ }) {
381
+ const [I, C] = P("freeform"), [v, E] = P(e), [c, k] = P(!1), x = G(null), A = G(null), [n, $] = P({ x: 0, y: 0, width: 0, height: 0 }), [N, L] = P({ x: 0, y: 0, width: 0, height: 0 }), V = G(null), et = $t(() => typeof R == "number" && typeof y == "number" && y > 0 ? R / y : n.width > 0 && n.height > 0 ? n.width / n.height : null, [n.height, n.width, y, R]), lt = $t(() => {
382
+ switch (I) {
383
+ case "original":
384
+ return et;
385
+ case "1:1":
386
+ return 1;
387
+ case "4:3":
388
+ return 4 / 3;
389
+ case "16:9":
390
+ return 16 / 9;
391
+ case "3:4":
392
+ return 3 / 4;
393
+ case "9:16":
394
+ return 9 / 16;
395
+ default:
396
+ return null;
397
+ }
398
+ }, [et, I]), m = 24, Y = S(
399
+ (s) => {
400
+ let { x: g, y: p, width: l, height: b } = s;
401
+ const j = n.width, ot = n.height;
402
+ return g = Math.max(0, Math.min(g, j - m)), p = Math.max(0, Math.min(p, ot - m)), l = Math.max(m, Math.min(l, j - g)), b = Math.max(m, Math.min(b, ot - p)), { x: g, y: p, width: l, height: b };
403
+ },
404
+ [n.height, n.width]
405
+ ), ut = S(
406
+ (s) => {
407
+ if (n.width <= 0 || n.height <= 0)
408
+ return;
409
+ if (s == null) {
410
+ L({
411
+ x: 0,
412
+ y: 0,
413
+ width: n.width,
414
+ height: n.height
415
+ });
416
+ return;
417
+ }
418
+ const g = n.width * 0.9, p = n.height * 0.9;
419
+ let l = g, b = l / s;
420
+ b > p && (b = p, l = b * s), L(
421
+ Y({
422
+ x: (n.width - l) / 2,
423
+ y: (n.height - b) / 2,
424
+ width: l,
425
+ height: b
426
+ })
427
+ );
428
+ },
429
+ [n.height, n.width, Y]
430
+ ), J = S(() => {
431
+ const s = x.current, g = A.current;
432
+ if (!s || !g)
433
+ return;
434
+ let p = 0, l = 0, b = g;
435
+ for (; b && b !== s; )
436
+ p += b.offsetLeft, l += b.offsetTop, b = b.offsetParent;
437
+ $({
438
+ x: p,
439
+ y: l,
440
+ width: g.offsetWidth,
441
+ height: g.offsetHeight
442
+ });
443
+ }, []), rt = S(
444
+ (s) => {
445
+ n.width <= 0 || n.height <= 0 || (s.preventDefault(), s.stopPropagation(), s.target.setPointerCapture?.(s.pointerId), V.current = {
446
+ mode: "move",
447
+ startX: s.clientX,
448
+ startY: s.clientY,
449
+ initialRect: { ...N }
450
+ });
451
+ },
452
+ [n.height, n.width, N]
453
+ ), xt = S(
454
+ (s, g) => {
455
+ n.width <= 0 || n.height <= 0 || (s.preventDefault(), s.stopPropagation(), s.target.setPointerCapture?.(s.pointerId), V.current = {
456
+ mode: g,
457
+ startX: s.clientX,
458
+ startY: s.clientY,
459
+ initialRect: { ...N }
460
+ });
461
+ },
462
+ [n.height, n.width, N]
463
+ ), vt = S(async () => {
464
+ if (n.width <= 0 || n.height <= 0) {
465
+ o(!1);
466
+ return;
467
+ }
468
+ const s = A.current;
469
+ if (!s || !s.naturalWidth || !s.naturalHeight) {
470
+ Nr.error("Could not read image dimensions");
471
+ return;
472
+ }
473
+ const g = s.naturalWidth / n.width, p = s.naturalHeight / n.height, l = {
474
+ x: Math.max(0, Math.round(N.x * g)),
475
+ y: Math.max(0, Math.round(N.y * p)),
476
+ width: Math.max(1, Math.round(N.width * g)),
477
+ height: Math.max(1, Math.round(N.height * p)),
478
+ naturalWidth: s.naturalWidth,
479
+ naturalHeight: s.naturalHeight
480
+ };
481
+ l.width = Math.min(l.width, s.naturalWidth - l.x), l.height = Math.min(l.height, s.naturalHeight - l.y), await Promise.resolve(D(l)), o(!1);
482
+ }, [n, N, D, o]);
483
+ return q(() => {
484
+ a && ($({ x: 0, y: 0, width: 0, height: 0 }), L({ x: 0, y: 0, width: 0, height: 0 }), k(!1), E(ce(e)));
485
+ }, [a, e]), q(() => {
486
+ if (!a)
487
+ return;
488
+ const s = x.current;
489
+ if (!s)
490
+ return;
491
+ const g = new ResizeObserver(() => {
492
+ J();
493
+ });
494
+ g.observe(s);
495
+ const p = A.current;
496
+ p && g.observe(p);
497
+ const l = () => J();
498
+ return window.addEventListener("resize", l), () => {
499
+ g.disconnect(), window.removeEventListener("resize", l);
500
+ };
501
+ }, [a, J]), q(() => {
502
+ if (!a)
503
+ return;
504
+ const s = (p) => {
505
+ const l = V.current;
506
+ if (!l)
507
+ return;
508
+ p.preventDefault();
509
+ const b = p.clientX - l.startX, j = p.clientY - l.startY, ot = n.width, at = n.height, K = lt ?? null, { x: X, y: Q, width: T, height: B } = l.initialRect;
510
+ if (l.mode === "move") {
511
+ const it = Math.max(0, ot - T), Pt = Math.max(0, at - B);
512
+ L(
513
+ Y({
514
+ x: Math.max(0, Math.min(it, X + b)),
515
+ y: Math.max(0, Math.min(Pt, Q + j)),
516
+ width: T,
517
+ height: B
518
+ })
519
+ );
520
+ return;
521
+ }
522
+ const M = l.mode;
523
+ let W = X, Z = Q, O = T, H = B;
524
+ M.includes("e") && (O = T + b), M.includes("w") && (W = X + b, O = T - b), M.includes("s") && (H = B + j), M.includes("n") && (Z = Q + j, H = B - j), K != null && K > 0 && (M === "e" || M === "w" ? (H = O / K, M.includes("n") && (Z = Q + B - H)) : M === "n" || M === "s" ? (O = H * K, M.includes("w") && (W = X + T - O)) : (H = O / K, M.includes("n") && (Z = Q + B - H), M.includes("w") && (W = X + T - O))), L(Y({ x: W, y: Z, width: O, height: H }));
525
+ }, g = () => {
526
+ V.current = null;
527
+ };
528
+ return window.addEventListener("pointermove", s), window.addEventListener("pointerup", g), () => {
529
+ window.removeEventListener("pointermove", s), window.removeEventListener("pointerup", g);
530
+ };
531
+ }, [
532
+ a,
533
+ n.width,
534
+ n.height,
535
+ lt,
536
+ Y
537
+ ]), q(() => {
538
+ a && ut(lt);
539
+ }, [a, lt, n, ut]), /* @__PURE__ */ r(Zt, { open: a, onOpenChange: o, children: /* @__PURE__ */ r(
540
+ te,
541
+ {
542
+ className: "sm:cteditor-max-w-[860px] cteditor-max-w-[calc(100%-2rem)] cteditor-rounded-xl cteditor-overflow-hidden cteditor-p-0",
543
+ onClick: (s) => s.stopPropagation(),
544
+ onPointerDown: (s) => s.stopPropagation(),
545
+ children: /* @__PURE__ */ f("div", { className: "cteditor-grid md:cteditor-grid-cols-[1.4fr_320px]", children: [
546
+ /* @__PURE__ */ r("div", { className: "cteditor-bg-muted/20 cteditor-p-4 md:cteditor-p-6", children: /* @__PURE__ */ f(
547
+ "div",
548
+ {
549
+ ref: x,
550
+ className: "cteditor-relative cteditor-min-h-[340px] cteditor-rounded-lg cteditor-bg-black/70 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-select-none cteditor-touch-none",
551
+ children: [
552
+ /* @__PURE__ */ r("div", { className: "cteditor-overflow-hidden cteditor-rounded-lg cteditor-flex cteditor-items-center cteditor-justify-center cteditor-w-full", children: c ? /* @__PURE__ */ r("div", { className: "cteditor-text-sm cteditor-text-muted-foreground", children: "Failed to load image preview" }) : /* @__PURE__ */ r(
553
+ "img",
554
+ {
555
+ ref: A,
556
+ src: v,
557
+ alt: d || "Crop preview",
558
+ className: "cteditor-max-w-full cteditor-max-h-[460px] cteditor-w-auto cteditor-h-auto cteditor-select-none cteditor-block",
559
+ draggable: !1,
560
+ onLoad: () => {
561
+ k(!1), J();
562
+ },
563
+ onError: () => {
564
+ k(!0);
565
+ }
566
+ }
567
+ ) }),
568
+ n.width > 0 && n.height > 0 && !c && /* @__PURE__ */ f(
569
+ "div",
570
+ {
571
+ className: "cteditor-absolute cteditor-border-2 cteditor-border-blue-500 cteditor-shadow-[0_0_0_9999px_rgba(0,0,0,0.45)] cteditor-cursor-move cteditor-select-none",
572
+ style: {
573
+ left: n.x + N.x,
574
+ top: n.y + N.y,
575
+ width: N.width,
576
+ height: N.height
577
+ },
578
+ children: [
579
+ /* @__PURE__ */ r(
580
+ "div",
581
+ {
582
+ className: "cteditor-absolute cteditor-inset-0 cteditor-grid cteditor-grid-cols-3 cteditor-grid-rows-3 cteditor-pointer-events-none",
583
+ "aria-hidden": !0,
584
+ children: Array.from({ length: 9 }).map((s, g) => /* @__PURE__ */ r(
585
+ "div",
586
+ {
587
+ className: "cteditor-border cteditor-border-white/30"
588
+ },
589
+ g
590
+ ))
591
+ }
592
+ ),
593
+ /* @__PURE__ */ r(
594
+ "div",
595
+ {
596
+ className: "cteditor-absolute cteditor-inset-0 cteditor-pointer-events-auto",
597
+ onPointerDown: rt,
598
+ "aria-label": "Move crop area"
599
+ }
600
+ ),
601
+ [
602
+ ["n", "cteditor-top-0 cteditor-left-1/2 cteditor--translate-x-1/2 cteditor--translate-y-1/2", "cteditor-cursor-n-resize", "cteditor-w-8 cteditor-h-2"],
603
+ ["s", "cteditor-bottom-0 cteditor-left-1/2 cteditor--translate-x-1/2 cteditor-translate-y-1/2", "cteditor-cursor-s-resize", "cteditor-w-8 cteditor-h-2"],
604
+ ["e", "cteditor-right-0 cteditor-top-1/2 cteditor-translate-x-1/2 cteditor--translate-y-1/2", "cteditor-cursor-e-resize", "cteditor-w-2 cteditor-h-8"],
605
+ ["w", "cteditor-left-0 cteditor-top-1/2 cteditor--translate-x-1/2 cteditor--translate-y-1/2", "cteditor-cursor-w-resize", "cteditor-w-2 cteditor-h-8"],
606
+ ["nw", "cteditor-left-0 cteditor-top-0 cteditor--translate-x-1/2 cteditor--translate-y-1/2", "cteditor-cursor-nw-resize", "cteditor-size-4"],
607
+ ["ne", "cteditor-right-0 cteditor-top-0 cteditor-translate-x-1/2 cteditor--translate-y-1/2", "cteditor-cursor-ne-resize", "cteditor-size-4"],
608
+ ["sw", "cteditor-left-0 cteditor-bottom-0 cteditor--translate-x-1/2 cteditor-translate-y-1/2", "cteditor-cursor-sw-resize", "cteditor-size-4"],
609
+ ["se", "cteditor-right-0 cteditor-bottom-0 cteditor-translate-x-1/2 cteditor-translate-y-1/2", "cteditor-cursor-se-resize", "cteditor-size-4"]
610
+ ].map(([s, g, p, l]) => /* @__PURE__ */ r(
611
+ "div",
612
+ {
613
+ className: `cteditor-absolute cteditor-border-2 cteditor-border-white cteditor-bg-blue-500 cteditor-rounded-sm cteditor-pointer-events-auto cteditor-shadow ${g} ${p} ${l}`,
614
+ onPointerDown: (b) => xt(b, s),
615
+ "aria-label": `Resize ${s}`
616
+ },
617
+ s
618
+ ))
619
+ ]
620
+ }
621
+ )
622
+ ]
623
+ }
624
+ ) }),
625
+ /* @__PURE__ */ f("div", { className: "cteditor-p-4 md:cteditor-p-5 cteditor-border-l cteditor-border-border cteditor-bg-background", children: [
626
+ /* @__PURE__ */ f(ee, { className: "cteditor-mb-4 cteditor-space-y-1", children: [
627
+ /* @__PURE__ */ r(re, { children: "Crop" }),
628
+ /* @__PURE__ */ r(oe, { children: "Choose an aspect ratio and adjust the crop area, then click Apply." })
629
+ ] }),
630
+ /* @__PURE__ */ f("div", { className: "cteditor-space-y-4", children: [
631
+ /* @__PURE__ */ f("div", { children: [
632
+ /* @__PURE__ */ r("p", { className: "cteditor-text-sm cteditor-font-medium cteditor-mb-2", children: "Aspect ratio" }),
633
+ /* @__PURE__ */ r("div", { className: "cteditor-grid cteditor-grid-cols-3 cteditor-gap-2", children: [
634
+ { id: "freeform", label: "Freeform", icon: se },
635
+ { id: "original", label: "Original", icon: Ge },
636
+ { id: "1:1", label: "1:1", icon: mr },
637
+ { id: "4:3", label: "4:3", icon: Tt },
638
+ { id: "16:9", label: "16:9", icon: Tt },
639
+ { id: "3:4", label: "3:4", icon: Wt },
640
+ { id: "9:16", label: "9:16", icon: Wt }
641
+ ].map((s) => {
642
+ const g = s.icon, p = I === s.id;
643
+ return /* @__PURE__ */ f(
644
+ "button",
645
+ {
646
+ type: "button",
647
+ onClick: () => {
648
+ C(s.id);
649
+ },
650
+ className: `cteditor-h-20 cteditor-rounded-md cteditor-border cteditor-text-sm cteditor-transition-colors cteditor-flex cteditor-flex-col cteditor-items-center cteditor-justify-center cteditor-gap-1.5 ${p ? "cteditor-border-primary cteditor-bg-primary/10 cteditor-text-primary" : "cteditor-border-border hover:cteditor-bg-accent"}`,
651
+ children: [
652
+ /* @__PURE__ */ r(g, { className: "cteditor-w-4 cteditor-h-4" }),
653
+ /* @__PURE__ */ r("span", { children: s.label })
654
+ ]
655
+ },
656
+ s.id
657
+ );
658
+ }) })
659
+ ] }),
660
+ /* @__PURE__ */ f("div", { className: "cteditor-rounded-md cteditor-border cteditor-border-border cteditor-p-3 cteditor-bg-muted/20 cteditor-space-y-2", children: [
661
+ /* @__PURE__ */ f("div", { children: [
662
+ /* @__PURE__ */ r("p", { className: "cteditor-text-xs cteditor-text-muted-foreground cteditor-mb-0.5", children: "Crop size" }),
663
+ /* @__PURE__ */ f("p", { className: "cteditor-text-sm cteditor-font-medium", children: [
664
+ Math.round(N.width),
665
+ " × ",
666
+ Math.round(N.height),
667
+ " px"
668
+ ] })
669
+ ] }),
670
+ /* @__PURE__ */ f("div", { children: [
671
+ /* @__PURE__ */ r("p", { className: "cteditor-text-xs cteditor-text-muted-foreground cteditor-mb-0.5", children: "Aspect ratio" }),
672
+ /* @__PURE__ */ r("p", { className: "cteditor-text-sm", children: I === "freeform" ? "Free" : I === "original" ? "Original" : I })
673
+ ] })
674
+ ] })
675
+ ] }),
676
+ /* @__PURE__ */ f(ae, { className: "cteditor-gap-2 cteditor-mt-4", children: [
677
+ /* @__PURE__ */ r(
678
+ "button",
679
+ {
680
+ type: "button",
681
+ onClick: () => {
682
+ C("freeform"), ut(null);
683
+ },
684
+ className: "cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-rounded-md cteditor-bg-background cteditor-border cteditor-border-border cteditor-text-foreground hover:cteditor-bg-accent cteditor-transition-colors",
685
+ children: "Reset"
686
+ }
687
+ ),
688
+ /* @__PURE__ */ r(
689
+ "button",
690
+ {
691
+ type: "button",
692
+ onClick: () => o(!1),
693
+ className: "cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-rounded-md cteditor-bg-background cteditor-border cteditor-border-border cteditor-text-foreground hover:cteditor-bg-accent cteditor-transition-colors",
694
+ children: "Cancel"
695
+ }
696
+ ),
697
+ /* @__PURE__ */ r(
698
+ "button",
699
+ {
700
+ type: "button",
701
+ onClick: vt,
702
+ className: "cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-rounded-md cteditor-bg-primary cteditor-text-primary-foreground hover:cteditor-bg-primary/90 cteditor-transition-colors",
703
+ children: "Apply"
704
+ }
705
+ )
706
+ ] })
707
+ ] })
708
+ ] })
709
+ }
710
+ ) });
711
+ }
712
+ const Rt = /* @__PURE__ */ new Set(), jt = Be("RIGHT_CLICK_IMAGE_COMMAND");
713
+ function Rr(a) {
714
+ if (!Rt.has(a))
715
+ throw new Promise((o) => {
716
+ const e = new Image();
717
+ e.src = a, e.onload = () => {
718
+ Rt.add(a), o(null);
719
+ }, e.onerror = () => {
720
+ Rt.add(a);
721
+ };
722
+ });
723
+ }
724
+ function Ir({
725
+ altText: a,
726
+ className: o,
727
+ imageRef: e,
728
+ src: d,
729
+ width: R,
730
+ height: y,
731
+ maxWidth: D,
732
+ onError: I,
733
+ onLoad: C
734
+ }) {
735
+ Rr(d);
736
+ const v = typeof R == "number" && typeof y == "number", E = typeof R == "number" ? R : "auto";
737
+ return /* @__PURE__ */ r(
738
+ "img",
739
+ {
740
+ className: o || void 0,
741
+ src: d,
742
+ alt: a,
743
+ ref: e,
744
+ style: v ? {
745
+ width: E,
746
+ // Use height: auto + aspect-ratio so the image scales
747
+ // proportionally when max-width constrains on small screens.
748
+ // The useLayoutEffect in ImageComponent widens the container
749
+ // to fit the explicit width on desktop.
750
+ height: "auto",
751
+ aspectRatio: `${E} / ${typeof y == "number" ? y : "auto"}`,
752
+ maxWidth: "100%"
753
+ } : {
754
+ // No dimensions specified - use original image size.
755
+ // max-width from CSS rule prevents overflow.
756
+ height: "auto"
757
+ },
758
+ onError: I,
759
+ onLoad: C,
760
+ draggable: "false"
761
+ }
762
+ );
763
+ }
764
+ function Pr() {
765
+ return /* @__PURE__ */ r(
766
+ "img",
767
+ {
768
+ src: "",
769
+ style: {
770
+ height: 200,
771
+ opacity: 0.2,
772
+ width: 200
773
+ },
774
+ draggable: "false"
775
+ }
776
+ );
777
+ }
778
+ function Zr({
779
+ src: a,
780
+ altText: o,
781
+ nodeKey: e,
782
+ width: d,
783
+ height: R,
784
+ maxWidth: y,
785
+ resizable: D,
786
+ showCaption: I,
787
+ caption: C,
788
+ captionsEnabled: v,
789
+ originalPrompt: E,
790
+ position: c = "none",
791
+ linkUrl: k
792
+ }) {
793
+ const x = G(null), A = G(null), [n, $, N] = $e(e), [L, V] = P(!1), et = G(!1), { isCollabActive: lt } = Ae(), [m] = De(), [Y, ut] = P(null), J = G(null), [rt, xt] = P(!1), vt = Le(), [s, g] = P(!1), [p, l] = P(""), [b, j] = P(!1), [ot, at] = P(!1), [K, X] = P(""), [Q, T] = P(""), [B, M] = P(!1), W = G(null), [Z, O] = P(0), [H, it] = P(!1), ft = qe()?.apiKey, le = Z > 0 && Z < 350;
794
+ q(() => {
795
+ if (x.current) {
796
+ const t = () => {
797
+ et.current || x.current && O(x.current.offsetWidth);
798
+ };
799
+ t();
800
+ const i = new ResizeObserver(t);
801
+ return i.observe(x.current), () => i.disconnect();
802
+ }
803
+ }, [d, R, n]), Ke(() => {
804
+ if ((c === "left" || c === "right") && typeof d == "number" && x.current) {
805
+ const t = x.current.closest(".editor-image"), i = t?.parentElement, u = m.getRootElement(), h = u ? u.getBoundingClientRect().width : d + 32, w = `${Math.min(d + 32, h)}px`;
806
+ return t && (t.style.removeProperty("display"), t.style.setProperty("max-width", w, "important")), i && i.style.setProperty("max-width", w, "important"), () => {
807
+ t && (t.style.removeProperty("max-width"), t.style.removeProperty("display")), i && i.style.removeProperty("max-width");
808
+ };
809
+ }
810
+ }, [c, d, m]);
811
+ const wt = S(
812
+ (t) => {
813
+ const i = st();
814
+ return n && dt(i) && (t.preventDefault(), m.update(() => {
815
+ i.getNodes().forEach((h) => {
816
+ if (tt(h)) {
817
+ const w = h.getParent();
818
+ h.remove(), w && Et(w) && w.getChildrenSize() === 0 && w.setFormat("left");
819
+ }
820
+ });
821
+ })), !1;
822
+ },
823
+ [m, n]
824
+ ), St = S(
825
+ (t) => {
826
+ const i = st(), u = A.current;
827
+ if (n && dt(i) && i.getNodes().length === 1) {
828
+ if (I)
829
+ return bt(null), t.preventDefault(), C.focus(), !0;
830
+ if (u !== null && u !== document.activeElement)
831
+ return t.preventDefault(), u.focus(), !0;
832
+ }
833
+ return !1;
834
+ },
835
+ [C, n, I]
836
+ ), Mt = S(
837
+ (t) => J.current === C || A.current === t.target ? (bt(null), m.update(() => {
838
+ $(!0);
839
+ const i = m.getRootElement();
840
+ i !== null && i.focus();
841
+ }), !0) : !1,
842
+ [C, m, $]
843
+ ), Ct = S(
844
+ (t) => {
845
+ const i = t;
846
+ if (L)
847
+ return !0;
848
+ const u = i.target;
849
+ if (u.closest("button") && x.current && u.closest(".editor-image") === x.current.closest(".editor-image"))
850
+ return !0;
851
+ const h = u === x.current;
852
+ let w = !1;
853
+ if (!h && x.current) {
854
+ const F = x.current.getBoundingClientRect();
855
+ w = i.clientX >= F.left && i.clientX <= F.right && i.clientY >= F.top && i.clientY <= F.bottom;
856
+ }
857
+ return h || w ? (i.shiftKey ? $(!n) : (N(), $(!0)), !0) : !1;
858
+ },
859
+ [L, n, $, N]
860
+ ), kt = S(
861
+ (t) => {
862
+ m.getEditorState().read(() => {
863
+ const i = st();
864
+ t.target.tagName === "IMG" && Te(i) && i.getNodes().length === 1 && m.dispatchCommand(
865
+ jt,
866
+ t
867
+ );
868
+ });
869
+ },
870
+ [m]
871
+ );
872
+ q(() => {
873
+ let t = !0;
874
+ const i = m.getRootElement(), u = _e(
875
+ m.registerUpdateListener(({ editorState: h }) => {
876
+ t && ut(h.read(() => st()));
877
+ }),
878
+ m.registerCommand(
879
+ We,
880
+ (h, w) => (J.current = w, !1),
881
+ U
882
+ ),
883
+ m.registerCommand(
884
+ Ye,
885
+ Ct,
886
+ U
887
+ ),
888
+ m.registerCommand(
889
+ jt,
890
+ Ct,
891
+ U
892
+ ),
893
+ m.registerCommand(
894
+ je,
895
+ (h) => h.target === x.current ? (h.preventDefault(), !0) : !1,
896
+ U
897
+ ),
898
+ m.registerCommand(
899
+ Oe,
900
+ wt,
901
+ U
902
+ ),
903
+ m.registerCommand(
904
+ He,
905
+ wt,
906
+ U
907
+ ),
908
+ m.registerCommand(Fe, St, U),
909
+ m.registerCommand(
910
+ Xe,
911
+ Mt,
912
+ U
913
+ )
914
+ );
915
+ return i?.addEventListener("contextmenu", kt), () => {
916
+ t = !1, u(), i?.removeEventListener("contextmenu", kt);
917
+ };
918
+ }, [
919
+ N,
920
+ m,
921
+ L,
922
+ n,
923
+ e,
924
+ wt,
925
+ St,
926
+ Mt,
927
+ Ct,
928
+ kt,
929
+ $
930
+ ]);
931
+ const ue = () => {
932
+ m.update(() => {
933
+ const t = ct(e);
934
+ tt(t) && t.setShowCaption(!0);
935
+ });
936
+ }, me = (t, i) => {
937
+ et.current = !1, setTimeout(() => {
938
+ V(!1);
939
+ }, 200), m.update(() => {
940
+ const u = ct(e);
941
+ tt(u) && u.setWidthAndHeight(t, i);
942
+ });
943
+ }, ge = () => {
944
+ et.current = !0, V(!0);
945
+ }, he = (t) => {
946
+ if (t.preventDefault(), t.stopPropagation(), a.startsWith("data:")) {
947
+ const i = window.open("", "_blank");
948
+ i && (i.document.write(`
949
+ <!DOCTYPE html>
950
+ <html>
951
+ <head>
952
+ <title>${o || "Image"}</title>
953
+ <style>
954
+ body {
955
+ margin: 0;
956
+ display: flex;
957
+ justify-content: center;
958
+ align-items: center;
959
+ min-height: 100vh;
960
+ background-color: #1a1a1a;
961
+ }
962
+ img {
963
+ max-width: 100%;
964
+ max-height: 100vh;
965
+ object-fit: contain;
966
+ }
967
+ </style>
968
+ </head>
969
+ <body>
970
+ <img src="${a}" alt="${o || "Image"}" />
971
+ </body>
972
+ </html>
973
+ `), i.document.close());
974
+ } else
975
+ window.open(a, "_blank");
976
+ }, fe = (t) => {
977
+ t.preventDefault(), t.stopPropagation(), m.update(() => {
978
+ const i = ct(e);
979
+ if (tt(i)) {
980
+ const u = i.getParent();
981
+ i.remove(), u && Et(u) && u.getChildrenSize() === 0 && u.setFormat("left");
982
+ }
983
+ });
984
+ }, nt = (t, i) => {
985
+ t.preventDefault(), t.stopPropagation(), m.update(() => {
986
+ const u = ct(e);
987
+ if (tt(u)) {
988
+ u.setPosition(i);
989
+ const h = u.getParent();
990
+ h && Et(h) && (i === "left" ? h.setFormat("left") : i === "right" ? h.setFormat("right") : h.setFormat(""));
991
+ }
992
+ });
993
+ }, pe = (t) => {
994
+ t.preventDefault(), t.stopPropagation(), g(!s);
995
+ }, be = S((t) => {
996
+ t.preventDefault(), t.stopPropagation(), it(!0);
997
+ }, []), ye = S(
998
+ async (t) => {
999
+ let i = a;
1000
+ if (ht(a))
1001
+ i = ce(a);
1002
+ else {
1003
+ if (!ft) {
1004
+ z.error("API key is required to upload and crop external images.");
1005
+ return;
1006
+ }
1007
+ const h = z.loading("Uploading image…");
1008
+ try {
1009
+ i = (await Ve.post(
1010
+ Je.project.fileUploadFromUrl,
1011
+ { url: a, prefix: "uploads" },
1012
+ { headers: { "x-api-key": ft } }
1013
+ )).data.fileUrl, z.dismiss(h);
1014
+ } catch {
1015
+ z.dismiss(h), z.error("Failed to upload image. Try again.");
1016
+ return;
1017
+ }
1018
+ }
1019
+ const u = pr(i, t);
1020
+ if (u === i) {
1021
+ z.error("Cropping is only supported for images hosted on the CDN.");
1022
+ return;
1023
+ }
1024
+ m.update(() => {
1025
+ const h = ct(e);
1026
+ if (!tt(h))
1027
+ return;
1028
+ h.setSrc(u), h.setWidthAndHeight(t.width, t.height);
1029
+ const w = st();
1030
+ w && bt(w.clone());
1031
+ }), z.success("Image cropped");
1032
+ },
1033
+ [m, e, a, ft]
1034
+ ), xe = S(() => {
1035
+ k && !n && (W.current = setTimeout(() => {
1036
+ M(!0);
1037
+ }, 300));
1038
+ }, [k, n]), ve = S(() => {
1039
+ W.current && (clearTimeout(W.current), W.current = null), M(!1);
1040
+ }, []), zt = S((t) => {
1041
+ t.preventDefault(), t.stopPropagation(), k && window.open(k, "_blank", "noopener,noreferrer");
1042
+ }, [k]);
1043
+ q(() => () => {
1044
+ W.current && clearTimeout(W.current);
1045
+ }, []), q(() => {
1046
+ n || it(!1);
1047
+ }, [n]);
1048
+ const At = async () => {
1049
+ if (!p.trim() || b)
1050
+ return;
1051
+ j(!0);
1052
+ const t = z.loading("Refining image...", {
1053
+ description: "This may take 10-30 seconds. Please wait."
1054
+ });
1055
+ try {
1056
+ let i = p.trim();
1057
+ const h = p.trim().replace(/^(add|also add|include|with|and)\s+(some|a|an)\s+/gi, "").replace(/^(add|also add|include|with|and)\s+/gi, "").trim(), w = (pt) => {
1058
+ const Ie = pt.toLowerCase();
1059
+ return [
1060
+ "article",
1061
+ "write",
1062
+ "blog",
1063
+ "post",
1064
+ "essay",
1065
+ "content",
1066
+ "generate an article",
1067
+ "create an article",
1068
+ "write about",
1069
+ "and add some pictures",
1070
+ "with pictures",
1071
+ "with images",
1072
+ "add some images",
1073
+ "include images",
1074
+ "include pictures"
1075
+ ].some((Pe) => Ie.includes(Pe));
1076
+ };
1077
+ let F = "";
1078
+ if (E && E.trim()) {
1079
+ const pt = E.trim();
1080
+ w(pt) && o && o !== "Generated image" && o.trim() ? F = o.trim() : F = pt;
1081
+ } else
1082
+ o && o !== "Generated image" && o.trim() && (F = o.trim());
1083
+ F ? i = `${F} with ${h}` : i = h;
1084
+ const Lt = (await dr({
1085
+ content: `Generate Image: ${i}`,
1086
+ apiKey: ft || void 0
1087
+ }))?.data;
1088
+ if (!Lt)
1089
+ throw new Error("Failed to generate image - empty response");
1090
+ const Nt = new DOMParser().parseFromString(Lt, "text/html").querySelector("img");
1091
+ if (!Nt || !Nt.src)
1092
+ throw new Error("No image found in response");
1093
+ const Re = Nt.src;
1094
+ z.dismiss(t), z.success("Image refined successfully!", {
1095
+ description: "Compare the images and choose which to keep."
1096
+ }), X(Re), T(i), at(!0), l(""), g(!1);
1097
+ } catch (i) {
1098
+ if (z.dismiss(t), i instanceof cr) {
1099
+ const u = i.code === "API_KEYS_DISABLED" ? "API Keys Disabled" : "API Key Required";
1100
+ z.error(u, {
1101
+ description: i.message,
1102
+ duration: 8e3
1103
+ });
1104
+ } else
1105
+ i instanceof lr ? z.error("Credits Issue", {
1106
+ description: i.message,
1107
+ duration: 8e3
1108
+ }) : z.error("Failed to refine image", {
1109
+ description: i instanceof Error ? i.message : "Unknown error. Please try again."
1110
+ });
1111
+ } finally {
1112
+ j(!1);
1113
+ }
1114
+ }, we = () => {
1115
+ m.update(() => {
1116
+ const t = ct(e);
1117
+ if (tt(t)) {
1118
+ t.setSrc(K), t.setOriginalPrompt(Q);
1119
+ const i = st();
1120
+ i && bt(i.clone());
1121
+ }
1122
+ }), at(!1), X(""), T(""), z.success("Image replaced successfully!", {
1123
+ description: "The image has been updated with the refined version."
1124
+ });
1125
+ }, Ce = () => {
1126
+ at(!1), X(""), T("");
1127
+ }, ke = n && dt(Y) && !L, Dt = (n || L) && vt, Ne = () => c === "left" || c === "right" ? {
1128
+ position: "relative",
1129
+ display: "block",
1130
+ width: "100%"
1131
+ // Fill the floated container
1132
+ } : c === "full" ? {
1133
+ position: "relative",
1134
+ display: "block",
1135
+ width: "fit-content",
1136
+ margin: "0 auto"
1137
+ } : c === "inline-left" ? {
1138
+ position: "relative",
1139
+ display: "block",
1140
+ width: "fit-content",
1141
+ marginRight: "auto"
1142
+ } : c === "inline-center" ? {
1143
+ position: "relative",
1144
+ display: "block",
1145
+ width: "fit-content",
1146
+ margin: "0 auto"
1147
+ } : c === "inline-right" ? {
1148
+ position: "relative",
1149
+ display: "block",
1150
+ width: "fit-content",
1151
+ marginLeft: "auto"
1152
+ } : {
1153
+ position: "relative",
1154
+ display: "inline-block"
1155
+ }, Ee = S(
1156
+ (t) => {
1157
+ if (L || t.target.closest("button"))
1158
+ return;
1159
+ const u = t.target === x.current;
1160
+ let h = !1;
1161
+ if (!u && x.current) {
1162
+ const w = x.current.getBoundingClientRect();
1163
+ h = t.clientX >= w.left && t.clientX <= w.right && t.clientY >= w.top && t.clientY <= w.bottom;
1164
+ }
1165
+ !u && !h || (t.stopPropagation(), t.shiftKey ? $(!n) : (N(), $(!0)));
1166
+ },
1167
+ [L, n, $, N]
1168
+ );
1169
+ return /* @__PURE__ */ r(Ue, { fallback: null, children: /* @__PURE__ */ f(Se, { children: [
1170
+ /* @__PURE__ */ f(
1171
+ "div",
1172
+ {
1173
+ draggable: ke,
1174
+ style: Ne(),
1175
+ onClick: Ee,
1176
+ onMouseEnter: xe,
1177
+ onMouseLeave: ve,
1178
+ children: [
1179
+ rt ? /* @__PURE__ */ r(Pr, {}) : /* @__PURE__ */ r(
1180
+ Ir,
1181
+ {
1182
+ className: Dt ? `focused ${dt(Y) ? "draggable" : ""}` : k ? "cteditor-cursor-pointer" : null,
1183
+ src: a,
1184
+ altText: o,
1185
+ imageRef: x,
1186
+ width: d,
1187
+ height: R,
1188
+ maxWidth: y,
1189
+ onError: () => xt(!0)
1190
+ }
1191
+ ),
1192
+ B && k && !n && /* @__PURE__ */ f(
1193
+ "div",
1194
+ {
1195
+ className: "cteditor-absolute cteditor-bottom-2 cteditor-left-2 cteditor-right-2 cteditor-bg-background cteditor-rounded-lg cteditor-shadow-lg cteditor-border cteditor-border-border cteditor-p-2 cteditor-flex cteditor-items-center cteditor-gap-2",
1196
+ style: { zIndex: 10 },
1197
+ children: [
1198
+ /* @__PURE__ */ r(ur, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-muted-foreground cteditor-flex-shrink-0" }),
1199
+ /* @__PURE__ */ r("span", { className: "cteditor-text-sm cteditor-text-foreground cteditor-truncate cteditor-flex-1", children: k }),
1200
+ /* @__PURE__ */ r(
1201
+ "button",
1202
+ {
1203
+ onClick: zt,
1204
+ className: "cteditor-px-2 cteditor-py-1.5 cteditor-text-xs cteditor-rounded cteditor-bg-primary cteditor-text-primary-foreground hover:cteditor-bg-primary/90 cteditor-transition-colors cteditor-flex-shrink-0",
1205
+ children: "Open"
1206
+ }
1207
+ )
1208
+ ]
1209
+ }
1210
+ ),
1211
+ n && dt(Y) && !rt && /* @__PURE__ */ f(
1212
+ "div",
1213
+ {
1214
+ className: `cteditor-absolute cteditor-flex cteditor-gap-1 z-10 ${le ? "cteditor-left-1/2 cteditor--translate-x-1/2 cteditor-bottom-0 cteditor-translate-y-full cteditor-mt-1" : "cteditor-top-2 cteditor-right-2"}`,
1215
+ children: [
1216
+ /* @__PURE__ */ f("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-0.5 cteditor-bg-background/80 cteditor-rounded-md cteditor-shadow-md cteditor-border cteditor-border-border cteditor-p-0.5", children: [
1217
+ /* @__PURE__ */ r(
1218
+ "button",
1219
+ {
1220
+ onClick: (t) => nt(t, "left"),
1221
+ className: ` cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${c === "left" ? "cteditor-bg-accent" : ""}`,
1222
+ "aria-label": "Wrap text left",
1223
+ title: "Wrap text left",
1224
+ children: /* @__PURE__ */ r(Qe, {})
1225
+ }
1226
+ ),
1227
+ /* @__PURE__ */ r(
1228
+ "button",
1229
+ {
1230
+ onClick: (t) => nt(t, "right"),
1231
+ className: ` cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${c === "right" ? "cteditor-bg-accent" : ""}`,
1232
+ "aria-label": "Wrap text right",
1233
+ title: "Wrap text right",
1234
+ children: /* @__PURE__ */ r(Ze, {})
1235
+ }
1236
+ ),
1237
+ /* @__PURE__ */ r("div", { className: "cteditor-w-px cteditor-h-5 cteditor-bg-border cteditor-mx-0.5" }),
1238
+ /* @__PURE__ */ r(
1239
+ "button",
1240
+ {
1241
+ onClick: (t) => nt(t, "inline-left"),
1242
+ className: `cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${c === "inline-left" ? "cteditor-bg-accent" : ""}`,
1243
+ "aria-label": "Align left",
1244
+ title: "Align left (no text wrap)",
1245
+ children: /* @__PURE__ */ r(tr, {})
1246
+ }
1247
+ ),
1248
+ /* @__PURE__ */ r(
1249
+ "button",
1250
+ {
1251
+ onClick: (t) => nt(t, "inline-center"),
1252
+ className: `cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${c === "inline-center" || c === "full" ? "cteditor-bg-accent" : ""}`,
1253
+ "aria-label": "Align center",
1254
+ title: "Align center (no text wrap)",
1255
+ children: /* @__PURE__ */ r(er, {})
1256
+ }
1257
+ ),
1258
+ /* @__PURE__ */ r(
1259
+ "button",
1260
+ {
1261
+ onClick: (t) => nt(t, "inline-right"),
1262
+ className: `cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${c === "inline-right" ? "cteditor-bg-accent" : ""}`,
1263
+ "aria-label": "Align right",
1264
+ title: "Align right (no text wrap)",
1265
+ children: /* @__PURE__ */ r(rr, {})
1266
+ }
1267
+ ),
1268
+ /* @__PURE__ */ r("div", { className: "cteditor-w-px cteditor-h-5 cteditor-bg-border cteditor-mx-0.5" }),
1269
+ /* @__PURE__ */ r(
1270
+ "button",
1271
+ {
1272
+ onClick: (t) => nt(t, "none"),
1273
+ className: `cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${c === "none" ? "cteditor-bg-accent" : ""}`,
1274
+ "aria-label": "Inline",
1275
+ title: "Inline with text",
1276
+ children: /* @__PURE__ */ r(or, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
1277
+ }
1278
+ ),
1279
+ /* @__PURE__ */ r("div", { className: "cteditor-w-px cteditor-h-5 cteditor-bg-border cteditor-mx-0.5" }),
1280
+ !a.startsWith("data:") && !a.toLowerCase().endsWith(".svg") && /* @__PURE__ */ r(
1281
+ "button",
1282
+ {
1283
+ onClick: be,
1284
+ className: "cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors",
1285
+ "aria-label": "Crop image",
1286
+ title: "Crop image",
1287
+ children: /* @__PURE__ */ r(se, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
1288
+ }
1289
+ )
1290
+ ] }),
1291
+ k && /* @__PURE__ */ r(
1292
+ "button",
1293
+ {
1294
+ onClick: zt,
1295
+ className: " cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-bg-background/80 hover:cteditor-bg-accent cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-border",
1296
+ "aria-label": "Visit link",
1297
+ title: `Visit: ${k}`,
1298
+ children: /* @__PURE__ */ r(ar, {})
1299
+ }
1300
+ ),
1301
+ E && /* @__PURE__ */ r(
1302
+ "button",
1303
+ {
1304
+ onClick: (t) => {
1305
+ t.stopPropagation(), pe(t);
1306
+ },
1307
+ className: " cteditor-size-6 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-bg-background/80 hover:cteditor-bg-accent cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-border",
1308
+ "aria-label": "Refine image",
1309
+ title: "Refine image",
1310
+ children: /* @__PURE__ */ r(ir, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
1311
+ }
1312
+ ),
1313
+ /* @__PURE__ */ r(
1314
+ "button",
1315
+ {
1316
+ onClick: (t) => {
1317
+ t.stopPropagation(), he(t);
1318
+ },
1319
+ className: " cteditor-size-8 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-bg-background/80 hover:cteditor-bg-accent cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-border",
1320
+ "aria-label": "Open image in new tab",
1321
+ title: "Open in new tab",
1322
+ children: /* @__PURE__ */ r(nr, {})
1323
+ }
1324
+ ),
1325
+ /* @__PURE__ */ r(
1326
+ "button",
1327
+ {
1328
+ onClick: (t) => {
1329
+ t.stopPropagation(), fe(t);
1330
+ },
1331
+ className: " cteditor-size-8 cteditor-flex cteditor-items-center cteditor-justify-center cteditor-rounded-md cteditor-bg-background/80 hover:cteditor-bg-destructive hover:cteditor-text-destructive-foreground cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-border",
1332
+ "aria-label": "Delete image",
1333
+ title: "Delete image",
1334
+ children: /* @__PURE__ */ r(sr, {})
1335
+ }
1336
+ )
1337
+ ]
1338
+ }
1339
+ ),
1340
+ s && n && !rt && E && /* @__PURE__ */ r(
1341
+ "div",
1342
+ {
1343
+ className: "cteditor-absolute cteditor-bottom-2 cteditor-left-2 cteditor-right-2 cteditor-bg-background cteditor-rounded-lg cteditor-shadow-xl cteditor-border cteditor-border-border cteditor-p-3",
1344
+ style: { zIndex: 10 },
1345
+ onClick: (t) => t.stopPropagation(),
1346
+ onKeyDown: (t) => t.stopPropagation(),
1347
+ onKeyUp: (t) => t.stopPropagation(),
1348
+ children: /* @__PURE__ */ f("div", { className: "cteditor-flex cteditor-flex-col cteditor-gap-2", children: [
1349
+ /* @__PURE__ */ r("label", { className: "cteditor-text-xs cteditor-font-medium cteditor-text-foreground", children: "What else do you want in this scene?" }),
1350
+ /* @__PURE__ */ r(
1351
+ "input",
1352
+ {
1353
+ type: "text",
1354
+ value: p,
1355
+ onChange: (t) => l(t.target.value),
1356
+ onKeyDown: (t) => {
1357
+ t.stopPropagation(), t.key === "Enter" && p.trim() && !b && At(), t.key === "Escape" && (g(!1), l(""));
1358
+ },
1359
+ onKeyUp: (t) => {
1360
+ t.stopPropagation();
1361
+ },
1362
+ onClick: (t) => {
1363
+ t.stopPropagation();
1364
+ },
1365
+ placeholder: "e.g., flying birds, golden sunset, stormy clouds...",
1366
+ className: "cteditor-w-full cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-border cteditor-border-border cteditor-rounded-md cteditor-bg-background cteditor-text-foreground focus:cteditor-outline-none focus:cteditor-ring-2 focus:cteditor-ring-blue-500",
1367
+ disabled: b,
1368
+ autoFocus: !0
1369
+ }
1370
+ ),
1371
+ /* @__PURE__ */ f("div", { className: "cteditor-flex cteditor-gap-2", children: [
1372
+ /* @__PURE__ */ r(
1373
+ "button",
1374
+ {
1375
+ onClick: (t) => {
1376
+ t.stopPropagation(), At();
1377
+ },
1378
+ disabled: b || !p.trim(),
1379
+ className: "cteditor-flex-1 cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-rounded-md cteditor-bg-blue-500 cteditor-text-white hover:cteditor-bg-blue-600 disabled:cteditor-opacity-50 disabled:cteditor-cursor-not-allowed cteditor-transition-colors",
1380
+ children: b ? /* @__PURE__ */ f("span", { className: "cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-2", children: [
1381
+ /* @__PURE__ */ r("span", { className: "cteditor-inline-block cteditor-w-4 cteditor-h-4 cteditor-border-2 cteditor-border-white cteditor-border-t-transparent cteditor-rounded-full cteditor-animate-spin" }),
1382
+ "Refining..."
1383
+ ] }) : "Refine Image"
1384
+ }
1385
+ ),
1386
+ /* @__PURE__ */ r(
1387
+ "button",
1388
+ {
1389
+ onClick: (t) => {
1390
+ t.stopPropagation(), g(!1), l("");
1391
+ },
1392
+ disabled: b,
1393
+ className: "cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-rounded-md cteditor-bg-background cteditor-border cteditor-border-border cteditor-text-foreground hover:cteditor-bg-accent disabled:cteditor-opacity-50 disabled:cteditor-cursor-not-allowed cteditor-transition-colors",
1394
+ children: "Cancel"
1395
+ }
1396
+ )
1397
+ ] })
1398
+ ] })
1399
+ }
1400
+ ),
1401
+ D && dt(Y) && Dt && /* @__PURE__ */ r(
1402
+ Me,
1403
+ {
1404
+ showCaption: I,
1405
+ setShowCaption: ue,
1406
+ editor: m,
1407
+ buttonRef: A,
1408
+ imageRef: x,
1409
+ maxWidth: y,
1410
+ onResizeStart: ge,
1411
+ onResizeEnd: me,
1412
+ captionsEnabled: !rt && v
1413
+ }
1414
+ )
1415
+ ]
1416
+ }
1417
+ ),
1418
+ I && (o.startsWith("Signature by") ? /* @__PURE__ */ r(hr, { caption: C }) : /* @__PURE__ */ r(
1419
+ "div",
1420
+ {
1421
+ className: "image-caption-container",
1422
+ style: {
1423
+ width: typeof d == "number" ? `${d}px` : "100%",
1424
+ maxWidth: "100%",
1425
+ // Match the image's alignment
1426
+ ...c === "inline-center" || c === "full" ? { margin: "0 auto" } : c === "inline-right" ? { marginLeft: "auto" } : c === "left" ? { float: "left", clear: "left" } : c === "right" ? { float: "right", clear: "right" } : {}
1427
+ },
1428
+ children: /* @__PURE__ */ f(
1429
+ Kt,
1430
+ {
1431
+ initialEditor: C,
1432
+ initialNodes: [
1433
+ qt,
1434
+ Vt,
1435
+ Jt,
1436
+ Qt,
1437
+ Ht,
1438
+ Ot
1439
+ ],
1440
+ children: [
1441
+ /* @__PURE__ */ r(ze, {}),
1442
+ /* @__PURE__ */ r(
1443
+ Gt,
1444
+ {
1445
+ contentEditable: /* @__PURE__ */ r(
1446
+ Ft,
1447
+ {
1448
+ "aria-placeholder": "Enter a caption...",
1449
+ placeholder: () => /* @__PURE__ */ r("span", { className: "cteditor-text-xs", children: "Enter a caption..." }),
1450
+ className: "ImageNode__contentEditable"
1451
+ }
1452
+ ),
1453
+ ErrorBoundary: Xt
1454
+ }
1455
+ ),
1456
+ /* @__PURE__ */ r(
1457
+ Ut,
1458
+ {
1459
+ onChange: () => {
1460
+ }
1461
+ }
1462
+ ),
1463
+ /* @__PURE__ */ r(Bt, {}),
1464
+ /* @__PURE__ */ r(ie, { namespace: ne.namespace })
1465
+ ]
1466
+ }
1467
+ )
1468
+ }
1469
+ )),
1470
+ /* @__PURE__ */ r(
1471
+ Er,
1472
+ {
1473
+ open: H,
1474
+ onOpenChange: it,
1475
+ src: a,
1476
+ altText: o,
1477
+ width: d,
1478
+ height: R,
1479
+ onCropApply: ye
1480
+ }
1481
+ ),
1482
+ /* @__PURE__ */ r(
1483
+ gr,
1484
+ {
1485
+ open: ot,
1486
+ onOpenChange: at,
1487
+ oldImageUrl: a,
1488
+ newImageUrl: K,
1489
+ onReplace: we,
1490
+ onCancel: Ce
1491
+ }
1492
+ )
1493
+ ] }) });
1494
+ }
1495
+ export {
1496
+ jt as RIGHT_CLICK_IMAGE_COMMAND,
1497
+ Zr as default
1498
+ };