eddyter 1.4.14 → 1.4.16

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