@uploadcare/ai-enhancer 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{UcAiEnhancer-qk-y4FHK.js → UcAiEnhancer-BZeCfJ6W.js} +537 -517
- package/dist/{UcAiEnhancer-OUmStG-E.cjs → UcAiEnhancer-h1VGkbGn.cjs} +46 -46
- package/dist/ai-enhancer.cjs +1 -1
- package/dist/ai-enhancer.d.ts +100 -54
- package/dist/ai-enhancer.js +5 -3
- package/dist/errors.cjs +1 -0
- package/dist/errors.d.ts +81 -0
- package/dist/errors.js +8 -0
- package/dist/plugin.cjs +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +6 -1
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var yt = Object.defineProperty;
|
|
2
|
+
var Ie = (t) => {
|
|
3
3
|
throw TypeError(t);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var b = (t, e, i) =>
|
|
7
|
-
var
|
|
8
|
-
import { unsafeCSS as j, LitElement as G, html as f, nothing as
|
|
5
|
+
var wt = (t, e, i) => e in t ? yt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
|
|
6
|
+
var b = (t, e, i) => wt(t, typeof e != "symbol" ? e + "" : e, i), ce = (t, e, i) => e.has(t) || Ie("Cannot " + i);
|
|
7
|
+
var k = (t, e, i) => (ce(t, e, "read from private field"), i ? i.call(t) : e.get(t)), he = (t, e, i) => e.has(t) ? Ie("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i), Pe = (t, e, i, r) => (ce(t, e, "write to private field"), r ? r.call(t, i) : e.set(t, i), i), J = (t, e, i) => (ce(t, e, "access private method"), i);
|
|
8
|
+
import { unsafeCSS as j, LitElement as G, html as f, nothing as g } from "lit";
|
|
9
9
|
import { property as c, state as C, query as F, customElement as H } from "lit/decorators.js";
|
|
10
10
|
import { classMap as S } from "lit/directives/class-map.js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
11
|
+
import { AiEnhancerError as Z } from "./errors.js";
|
|
12
|
+
import { unsafeSVG as re } from "lit/directives/unsafe-svg.js";
|
|
13
|
+
import { nothing as st } from "lit/html.js";
|
|
14
|
+
import { directive as ot, PartType as at } from "lit/directive.js";
|
|
15
|
+
import { AsyncDirective as nt } from "lit/async-directive.js";
|
|
16
|
+
import { repeat as xt } from "lit/directives/repeat.js";
|
|
17
|
+
import { ifDefined as Et } from "lit/directives/if-defined.js";
|
|
17
18
|
const V = "original";
|
|
18
|
-
function
|
|
19
|
+
function I(t) {
|
|
19
20
|
return t != null && t !== V;
|
|
20
21
|
}
|
|
21
|
-
function
|
|
22
|
-
return t === V || e === V ? t === e :
|
|
22
|
+
function _e(t, e) {
|
|
23
|
+
return t === V || e === V ? t === e : Ft(t, e);
|
|
23
24
|
}
|
|
24
|
-
const
|
|
25
|
+
const kt = [
|
|
25
26
|
[2, 3],
|
|
26
27
|
[3, 2],
|
|
27
28
|
[1, 1],
|
|
28
29
|
[9, 16],
|
|
29
30
|
[16, 9]
|
|
30
|
-
],
|
|
31
|
+
], Rt = [3, 2], St = {
|
|
31
32
|
"1:1": "ai-enhancer-aspect-square",
|
|
32
33
|
"2:3": "ai-enhancer-aspect-tall",
|
|
33
34
|
"3:2": "ai-enhancer-aspect-wide",
|
|
@@ -35,23 +36,23 @@ const xt = [
|
|
|
35
36
|
"5:4": "ai-enhancer-aspect-landscape",
|
|
36
37
|
"9:16": "ai-enhancer-aspect-vertical",
|
|
37
38
|
"16:9": "ai-enhancer-aspect-widescreen"
|
|
38
|
-
},
|
|
39
|
-
function
|
|
39
|
+
}, Ct = 0.1, $t = 10;
|
|
40
|
+
function Ee(t) {
|
|
40
41
|
const [e, i] = t;
|
|
41
42
|
if (!Number.isFinite(e) || !Number.isFinite(i) || e <= 0 || i <= 0) return !1;
|
|
42
43
|
const r = e / i;
|
|
43
|
-
return r >=
|
|
44
|
+
return r >= Ct && r <= $t;
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function ee(t) {
|
|
46
47
|
return `${t[0]}:${t[1]}`;
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
49
|
+
function At(t) {
|
|
50
|
+
return St[ee(t)] ?? null;
|
|
50
51
|
}
|
|
51
|
-
function
|
|
52
|
-
return { value: t, labelKey:
|
|
52
|
+
function Ut(t) {
|
|
53
|
+
return { value: t, labelKey: At(t) };
|
|
53
54
|
}
|
|
54
|
-
function
|
|
55
|
+
function Tt(t) {
|
|
55
56
|
const e = [];
|
|
56
57
|
for (const i of t.split(/[\s,]+/)) {
|
|
57
58
|
const r = i.trim();
|
|
@@ -59,90 +60,29 @@ function At(t) {
|
|
|
59
60
|
const s = r.indexOf(":");
|
|
60
61
|
if (s === -1) continue;
|
|
61
62
|
const o = Number(r.slice(0, s)), a = Number(r.slice(s + 1)), n = [o, a];
|
|
62
|
-
|
|
63
|
+
Ee(n) && e.push(n);
|
|
63
64
|
}
|
|
64
65
|
return e;
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
+
function Ft(t, e) {
|
|
67
68
|
return t[0] === e[0] && t[1] === e[1];
|
|
68
69
|
}
|
|
69
|
-
function
|
|
70
|
+
function Mt(t) {
|
|
70
71
|
const [e, i] = t, r = 12, s = e >= i ? r : r * (e / i), o = i >= e ? r : r * (i / e), a = (16 - s) / 2, n = (16 - o) / 2;
|
|
71
72
|
return `<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><rect x="${a.toFixed(2)}" y="${n.toFixed(2)}" width="${s.toFixed(2)}" height="${o.toFixed(2)}" rx="1.5" stroke="currentColor" stroke-width="1.4"/></svg>`;
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
-
generate: {
|
|
75
|
-
id: "generate",
|
|
76
|
-
placeholderKey: "ai-enhancer-generate-placeholder",
|
|
77
|
-
// Complete, descriptive starting prompts. Flux responds best to rich
|
|
78
|
-
// natural-language descriptions, and clicking a chip fills the prompt so the
|
|
79
|
-
// user can run it as-is or tweak it.
|
|
80
|
-
presets: [
|
|
81
|
-
{
|
|
82
|
-
label: "Portrait",
|
|
83
|
-
prompt: "A photorealistic close-up portrait of a woman with freckles and windswept hair, soft natural window light, shallow depth of field, shot on an 85mm lens, ultra-detailed skin texture"
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
label: "Cinematic",
|
|
87
|
-
prompt: "Cinematic film still of a lone traveler on a neon-lit Tokyo street at night, rain-slicked pavement, glowing reflections, moody atmosphere, anamorphic, shot on 35mm"
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
label: "Product",
|
|
91
|
-
prompt: "Product photography of a frosted glass perfume bottle on a polished marble surface, soft studio lighting, gentle reflections, minimalist composition, high detail"
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
label: "Landscape",
|
|
95
|
-
prompt: "A serene mountain landscape at golden hour, low mist drifting through the valley, dramatic clouds, mirror-still lake reflections, photorealistic, ultra-detailed"
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
label: "Illustration",
|
|
99
|
-
prompt: "A flat vector illustration of a cozy bookshop café, warm color palette, clean bold shapes, soft shadows, modern editorial style"
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
label: "3D character",
|
|
103
|
-
prompt: "A cute 3D-rendered robot character, Pixar style, big expressive eyes, soft studio lighting, pastel color palette, smooth glossy materials, octane render"
|
|
104
|
-
}
|
|
105
|
-
]
|
|
106
|
-
},
|
|
107
|
-
edit: {
|
|
108
|
-
id: "edit",
|
|
109
|
-
placeholderKey: "ai-enhancer-edit-placeholder",
|
|
110
|
-
// Instruction-style edits Flux Kontext handles well — restyling, relighting,
|
|
111
|
-
// and background/subject changes that preserve the source image.
|
|
112
|
-
presets: [
|
|
113
|
-
{
|
|
114
|
-
label: "Enhance",
|
|
115
|
-
prompt: "Enhance the photo: improve the lighting, sharpen details, and make the colors richer while keeping it natural"
|
|
116
|
-
},
|
|
117
|
-
{ label: "Golden hour", prompt: "Relight the scene with warm golden-hour sunlight and long, soft shadows" },
|
|
118
|
-
{
|
|
119
|
-
label: "White studio",
|
|
120
|
-
prompt: "Place the subject on a clean seamless white studio backdrop with soft, even lighting"
|
|
121
|
-
},
|
|
122
|
-
{ label: "Remove people", prompt: "Remove all other people from the scene, keeping the main subject intact" },
|
|
123
|
-
{
|
|
124
|
-
label: "Watercolor",
|
|
125
|
-
prompt: "Restyle the image as a soft watercolor painting with delicate, visible brush strokes"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
label: "Black & white",
|
|
129
|
-
prompt: "Convert to dramatic high-contrast black and white film photography with subtle grain"
|
|
130
|
-
}
|
|
131
|
-
]
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
class xe extends Error {
|
|
74
|
+
class se extends Error {
|
|
135
75
|
constructor(e, i, r) {
|
|
136
76
|
super(i), this.name = "AiProviderError", this.errorCode = e, this.errorSource = r;
|
|
137
77
|
}
|
|
138
78
|
}
|
|
139
|
-
function
|
|
79
|
+
function Ot(t) {
|
|
140
80
|
const e = t == null ? void 0 : t.error;
|
|
141
81
|
return !!e && typeof e == "object" && typeof e.error_code == "string";
|
|
142
82
|
}
|
|
143
|
-
async function
|
|
83
|
+
async function Q(t, e) {
|
|
144
84
|
}
|
|
145
|
-
async function
|
|
85
|
+
async function Le(t, e) {
|
|
146
86
|
const i = await t.text().catch(() => "");
|
|
147
87
|
let r = null;
|
|
148
88
|
if (i)
|
|
@@ -150,9 +90,9 @@ async function Oe(t, e) {
|
|
|
150
90
|
r = JSON.parse(i);
|
|
151
91
|
} catch {
|
|
152
92
|
}
|
|
153
|
-
if (
|
|
93
|
+
if (Ot(r)) {
|
|
154
94
|
const { error_code: s, content: o } = r.error;
|
|
155
|
-
throw new
|
|
95
|
+
throw new se(s, o ?? s);
|
|
156
96
|
}
|
|
157
97
|
if (!t.ok)
|
|
158
98
|
throw new Error(
|
|
@@ -160,7 +100,7 @@ async function Oe(t, e) {
|
|
|
160
100
|
);
|
|
161
101
|
return r;
|
|
162
102
|
}
|
|
163
|
-
class
|
|
103
|
+
class It {
|
|
164
104
|
constructor(e) {
|
|
165
105
|
if (!e.publicKey)
|
|
166
106
|
throw new Error("UploadcareApiClient: publicKey is required");
|
|
@@ -174,7 +114,7 @@ class Mt {
|
|
|
174
114
|
aspect_ratio: [e.aspectRatio[0], e.aspectRatio[1]],
|
|
175
115
|
filename: e.filename
|
|
176
116
|
};
|
|
177
|
-
return e.store !== void 0 && (i.store = e.store), e.metadata && (i.metadata = e.metadata), await
|
|
117
|
+
return e.store !== void 0 && (i.store = e.store), e.metadata && (i.metadata = e.metadata), await Q(), this.startJob(new URL("/derivative/image/generate/", this.baseUrl), i, "generate", e.signal);
|
|
178
118
|
}
|
|
179
119
|
/** Start an image→image edit job. Resolves to the job handle. */
|
|
180
120
|
async edit(e) {
|
|
@@ -184,14 +124,14 @@ class Mt {
|
|
|
184
124
|
source: e.source,
|
|
185
125
|
filename: e.filename
|
|
186
126
|
};
|
|
187
|
-
return e.aspectRatio && (i.aspect_ratio = [e.aspectRatio[0], e.aspectRatio[1]]), e.store !== void 0 && (i.store = e.store), e.metadata && (i.metadata = e.metadata), await
|
|
127
|
+
return e.aspectRatio && (i.aspect_ratio = [e.aspectRatio[0], e.aspectRatio[1]]), e.store !== void 0 && (i.store = e.store), e.metadata && (i.metadata = e.metadata), await Q(), this.startJob(new URL("/derivative/image/edit/", this.baseUrl), i, "edit", e.signal);
|
|
188
128
|
}
|
|
189
129
|
/** Fetch the current state of a generation/edit job. */
|
|
190
130
|
async getJobStatus(e, i) {
|
|
191
131
|
const r = new URL("/derivative/status/", this.baseUrl);
|
|
192
132
|
r.searchParams.set("pub_key", this.publicKey), r.searchParams.set("job_id", e);
|
|
193
|
-
const s = await this.doFetch(r.href, { method: "GET", headers: { Accept: "application/json" }, signal: i }), o = await
|
|
194
|
-
return await
|
|
133
|
+
const s = await this.doFetch(r.href, { method: "GET", headers: { Accept: "application/json" }, signal: i }), o = await Le(s, "generate status");
|
|
134
|
+
return await Q(), o;
|
|
195
135
|
}
|
|
196
136
|
async startJob(e, i, r, s) {
|
|
197
137
|
const o = await this.doFetch(e.href, {
|
|
@@ -199,36 +139,36 @@ class Mt {
|
|
|
199
139
|
headers: { "Content-Type": "application/json", Accept: "application/json" },
|
|
200
140
|
body: JSON.stringify(i),
|
|
201
141
|
signal: s
|
|
202
|
-
}), a = await
|
|
203
|
-
return await
|
|
142
|
+
}), a = await Le(o, r);
|
|
143
|
+
return await Q(), a;
|
|
204
144
|
}
|
|
205
145
|
}
|
|
206
|
-
const
|
|
146
|
+
const lt = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", Pt = new RegExp(`^${lt}$`, "i"), Lt = new RegExp(`^(${lt})~([0-9]+)$`, "i");
|
|
207
147
|
function ke(t) {
|
|
208
148
|
return t.replace(/\/+$/, "");
|
|
209
149
|
}
|
|
210
|
-
function
|
|
150
|
+
function ge(t, e = "size") {
|
|
211
151
|
return typeof t == "number" ? String(t) : t.replace("%", "p");
|
|
212
152
|
}
|
|
213
|
-
function
|
|
214
|
-
const r = t == null ? "" :
|
|
153
|
+
function ct(t, e, i = "dimensions") {
|
|
154
|
+
const r = t == null ? "" : ge(t, `${i} width`), s = e == null ? "" : ge(e, `${i} height`);
|
|
215
155
|
return `${r}x${s}`;
|
|
216
156
|
}
|
|
217
|
-
function
|
|
218
|
-
return typeof t == "number" ? String(t) :
|
|
157
|
+
function ze(t, e) {
|
|
158
|
+
return typeof t == "number" ? String(t) : ge(t, e);
|
|
219
159
|
}
|
|
220
|
-
function
|
|
221
|
-
return typeof t == "string" ? t : `${
|
|
160
|
+
function zt(t, e = "alignment") {
|
|
161
|
+
return typeof t == "string" ? t : `${ze(t.x, `${e} x`)},${ze(t.y, `${e} y`)}`;
|
|
222
162
|
}
|
|
223
|
-
const
|
|
163
|
+
const Dt = [
|
|
224
164
|
"video",
|
|
225
165
|
"document",
|
|
226
166
|
"gif2video"
|
|
227
|
-
],
|
|
228
|
-
function
|
|
229
|
-
return t != null &&
|
|
167
|
+
], Nt = /\/(https?:\/\/.+)$/i;
|
|
168
|
+
function Bt(t) {
|
|
169
|
+
return t != null && Dt.includes(t);
|
|
230
170
|
}
|
|
231
|
-
function
|
|
171
|
+
function ht(t) {
|
|
232
172
|
var _;
|
|
233
173
|
let e;
|
|
234
174
|
try {
|
|
@@ -236,20 +176,20 @@ function lt(t) {
|
|
|
236
176
|
} catch {
|
|
237
177
|
throw new TypeError(`Invalid URL: "${t}"`);
|
|
238
178
|
}
|
|
239
|
-
const i = `${e.protocol}//${e.host}`, r = e.pathname, s = (_ = r.match(
|
|
179
|
+
const i = `${e.protocol}//${e.host}`, r = e.pathname, s = (_ = r.match(Nt)) == null ? void 0 : _[1];
|
|
240
180
|
if (s !== void 0) {
|
|
241
181
|
const x = r.slice(0, r.length - s.length);
|
|
242
182
|
return {
|
|
243
183
|
kind: "proxy",
|
|
244
184
|
origin: i,
|
|
245
|
-
operations:
|
|
185
|
+
operations: ue(De(x), "proxy prefix"),
|
|
246
186
|
sourceUrl: s + e.search + e.hash
|
|
247
187
|
};
|
|
248
188
|
}
|
|
249
|
-
const o = r.endsWith("/"), a =
|
|
189
|
+
const o = r.endsWith("/"), a = De(r), n = a.shift();
|
|
250
190
|
if (n === void 0)
|
|
251
191
|
throw new TypeError(`Not a CDN URL (empty path): "${t}"`);
|
|
252
|
-
const l = { origin: i, search: e.search, hash: e.hash }, h = n.match(
|
|
192
|
+
const l = { origin: i, search: e.search, hash: e.hash }, h = n.match(Lt);
|
|
253
193
|
if ((h == null ? void 0 : h[1]) !== void 0) {
|
|
254
194
|
const x = {
|
|
255
195
|
uuid: h[1],
|
|
@@ -260,13 +200,13 @@ function lt(t) {
|
|
|
260
200
|
if (!Number.isInteger(w))
|
|
261
201
|
throw new TypeError(`Invalid group element index in "${t}"`);
|
|
262
202
|
a.splice(0, 2);
|
|
263
|
-
const $ =
|
|
203
|
+
const $ = Ne(a, o);
|
|
264
204
|
return {
|
|
265
205
|
kind: "group-element",
|
|
266
206
|
...l,
|
|
267
207
|
group: x,
|
|
268
208
|
nth: w,
|
|
269
|
-
operations:
|
|
209
|
+
operations: ue(a, t),
|
|
270
210
|
filename: $
|
|
271
211
|
};
|
|
272
212
|
}
|
|
@@ -274,29 +214,29 @@ function lt(t) {
|
|
|
274
214
|
throw new TypeError(`Unexpected path after group id in "${t}"`);
|
|
275
215
|
return { kind: "group", ...l, group: x };
|
|
276
216
|
}
|
|
277
|
-
if (!
|
|
217
|
+
if (!Pt.test(n))
|
|
278
218
|
throw new TypeError(
|
|
279
219
|
`Not a CDN URL (no uuid, group or proxy source): "${t}"`
|
|
280
220
|
);
|
|
281
221
|
let p = null;
|
|
282
|
-
|
|
283
|
-
const u =
|
|
222
|
+
Bt(a[0]) && (p = a[0], a.shift());
|
|
223
|
+
const u = Ne(a, o);
|
|
284
224
|
return {
|
|
285
225
|
kind: "file",
|
|
286
226
|
...l,
|
|
287
227
|
uuid: n,
|
|
288
228
|
conversion: p,
|
|
289
|
-
operations:
|
|
229
|
+
operations: ue(a, t),
|
|
290
230
|
filename: u
|
|
291
231
|
};
|
|
292
232
|
}
|
|
293
|
-
function
|
|
233
|
+
function De(t) {
|
|
294
234
|
return t.split("/").filter((e) => e !== "");
|
|
295
235
|
}
|
|
296
|
-
function
|
|
236
|
+
function Ne(t, e) {
|
|
297
237
|
return e || t.length === 0 ? null : t.pop() ?? null;
|
|
298
238
|
}
|
|
299
|
-
function
|
|
239
|
+
function ue(t, e) {
|
|
300
240
|
const i = [];
|
|
301
241
|
let r = 0;
|
|
302
242
|
for (; r < t.length; ) {
|
|
@@ -319,11 +259,11 @@ function ce(t, e) {
|
|
|
319
259
|
}
|
|
320
260
|
return i;
|
|
321
261
|
}
|
|
322
|
-
function
|
|
262
|
+
function ut(t) {
|
|
323
263
|
return t.map((e) => `-/${[e.name, ...e.params].join("/")}/`).join("");
|
|
324
264
|
}
|
|
325
|
-
function
|
|
326
|
-
const e = ke(t.origin), i =
|
|
265
|
+
function dt(t) {
|
|
266
|
+
const e = ke(t.origin), i = ut(t.operations ?? []);
|
|
327
267
|
if ("sourceUrl" in t && t.sourceUrl != null)
|
|
328
268
|
return `${e}/${i}${t.sourceUrl}`;
|
|
329
269
|
const r = ("search" in t ? t.search : "") ?? "", s = ("hash" in t ? t.hash : "") ?? "";
|
|
@@ -337,59 +277,59 @@ function ht(t) {
|
|
|
337
277
|
}
|
|
338
278
|
throw new TypeError("serializeCdnUrl requires one of: uuid, group, sourceUrl");
|
|
339
279
|
}
|
|
340
|
-
function
|
|
280
|
+
function jt(t) {
|
|
341
281
|
return typeof t == "string" ? t : "opName" in t ? t.opName : t.name;
|
|
342
282
|
}
|
|
343
|
-
function
|
|
344
|
-
const i =
|
|
283
|
+
function de(t, e) {
|
|
284
|
+
const i = jt(e);
|
|
345
285
|
return t.name === i || t.name.startsWith(`${i}~`);
|
|
346
286
|
}
|
|
347
|
-
function
|
|
287
|
+
function pt(t, e) {
|
|
348
288
|
return Object.assign(e, { opName: t });
|
|
349
289
|
}
|
|
350
|
-
const
|
|
290
|
+
const Gt = (t, e) => {
|
|
351
291
|
const i = new URL(e);
|
|
352
292
|
return i.hostname = `${t}.${i.hostname}`, i.toString().replace(/\/$/, "");
|
|
353
|
-
},
|
|
293
|
+
}, Ht = "0123456789abcdefghijklmnopqrstuvwxyz", Wt = (t) => {
|
|
354
294
|
if (t <= 0n)
|
|
355
295
|
return "0";
|
|
356
296
|
let e = "";
|
|
357
297
|
for (; t > 0n; ) {
|
|
358
298
|
const i = t % 36n;
|
|
359
|
-
e =
|
|
299
|
+
e = Ht[Number(i)] + e, t = t / 36n;
|
|
360
300
|
}
|
|
361
301
|
return e;
|
|
362
|
-
},
|
|
302
|
+
}, Vt = (t, e) => {
|
|
363
303
|
try {
|
|
364
304
|
const i = new URL(t), r = new URL(e);
|
|
365
305
|
return i.hostname.endsWith(r.hostname);
|
|
366
306
|
} catch {
|
|
367
307
|
return !1;
|
|
368
308
|
}
|
|
369
|
-
},
|
|
309
|
+
}, qt = async (t) => {
|
|
370
310
|
const e = new TextEncoder().encode(t), i = await window.crypto.subtle.digest("SHA-256", e), r = Array.from(new Uint8Array(i)).map((s) => s.toString(16).padStart(2, "0")).join("");
|
|
371
311
|
return BigInt(`0x${r}`);
|
|
372
|
-
},
|
|
373
|
-
const e = await
|
|
374
|
-
return
|
|
375
|
-
},
|
|
376
|
-
const i = await
|
|
377
|
-
return
|
|
312
|
+
}, Kt = 10, Yt = async (t) => {
|
|
313
|
+
const e = await qt(t);
|
|
314
|
+
return Wt(e).slice(0, Kt);
|
|
315
|
+
}, Xt = async (t, e) => {
|
|
316
|
+
const i = await Yt(t);
|
|
317
|
+
return Gt(i, e);
|
|
378
318
|
};
|
|
379
|
-
function
|
|
319
|
+
function Be(t) {
|
|
380
320
|
return Object.prototype.toString.call(t) === "[object Object]";
|
|
381
321
|
}
|
|
382
|
-
const
|
|
383
|
-
function
|
|
384
|
-
return t.split(
|
|
322
|
+
const Jt = /\W|_/g;
|
|
323
|
+
function Zt(t) {
|
|
324
|
+
return t.split(Jt).map((e, i) => e.charAt(0)[i > 0 ? "toUpperCase" : "toLowerCase"]() + e.slice(1)).join("");
|
|
385
325
|
}
|
|
386
|
-
function
|
|
387
|
-
return Array.isArray(t) ? t.map((i) =>
|
|
326
|
+
function je(t, { ignoreKeys: e } = { ignoreKeys: [] }) {
|
|
327
|
+
return Array.isArray(t) ? t.map((i) => Re(i, { ignoreKeys: e })) : t;
|
|
388
328
|
}
|
|
389
|
-
function
|
|
329
|
+
function Re(t, { ignoreKeys: e } = { ignoreKeys: [] }) {
|
|
390
330
|
if (Array.isArray(t))
|
|
391
|
-
return
|
|
392
|
-
if (!
|
|
331
|
+
return je(t, { ignoreKeys: e });
|
|
332
|
+
if (!Be(t))
|
|
393
333
|
return t;
|
|
394
334
|
const i = {};
|
|
395
335
|
for (const r of Object.keys(t)) {
|
|
@@ -398,12 +338,12 @@ function Ee(t, { ignoreKeys: e } = { ignoreKeys: [] }) {
|
|
|
398
338
|
i[r] = s;
|
|
399
339
|
continue;
|
|
400
340
|
}
|
|
401
|
-
|
|
341
|
+
Be(s) ? s = Re(s, { ignoreKeys: e }) : Array.isArray(s) && (s = je(s, { ignoreKeys: e })), i[Zt(r)] = s;
|
|
402
342
|
}
|
|
403
343
|
return i;
|
|
404
344
|
}
|
|
405
|
-
const
|
|
406
|
-
function
|
|
345
|
+
const Qt = (t) => new Promise((e) => setTimeout(e, t));
|
|
346
|
+
function ei({ libraryName: t, libraryVersion: e, userAgent: i, publicKey: r = "", integration: s = "" }) {
|
|
407
347
|
const o = "JavaScript";
|
|
408
348
|
if (typeof i == "string")
|
|
409
349
|
return i;
|
|
@@ -418,53 +358,53 @@ function Zt({ libraryName: t, libraryVersion: e, userAgent: i, publicKey: r = ""
|
|
|
418
358
|
const a = [t, e, r].filter(Boolean).join("/"), n = [o, s].filter(Boolean).join("; ");
|
|
419
359
|
return `${a} (${n})`;
|
|
420
360
|
}
|
|
421
|
-
const
|
|
361
|
+
const ti = {
|
|
422
362
|
factor: 2,
|
|
423
363
|
time: 100
|
|
424
364
|
};
|
|
425
|
-
function
|
|
365
|
+
function ii(t, e = ti) {
|
|
426
366
|
let i = 0;
|
|
427
367
|
function r(s) {
|
|
428
368
|
const o = Math.round(e.time * e.factor ** i);
|
|
429
369
|
return s({
|
|
430
370
|
attempt: i,
|
|
431
|
-
retry: (n) =>
|
|
371
|
+
retry: (n) => Qt(n ?? o).then(() => (i += 1, r(s)))
|
|
432
372
|
});
|
|
433
373
|
}
|
|
434
374
|
return r(t);
|
|
435
375
|
}
|
|
436
|
-
class
|
|
376
|
+
class Se extends Error {
|
|
437
377
|
}
|
|
438
|
-
class
|
|
378
|
+
class oe extends Se {
|
|
439
379
|
constructor(i) {
|
|
440
380
|
super();
|
|
441
381
|
b(this, "originalProgressEvent");
|
|
442
|
-
this.name = "NetworkError", this.message = "Network error", Object.setPrototypeOf(this,
|
|
382
|
+
this.name = "NetworkError", this.message = "Network error", Object.setPrototypeOf(this, oe.prototype), this.originalProgressEvent = i;
|
|
443
383
|
}
|
|
444
384
|
}
|
|
445
|
-
const
|
|
385
|
+
const ri = (t, e) => {
|
|
446
386
|
t && (t.aborted ? Promise.resolve().then(e) : t.addEventListener("abort", () => e(), { once: !0 }));
|
|
447
387
|
};
|
|
448
|
-
class
|
|
388
|
+
class Ce extends Se {
|
|
449
389
|
constructor(i = "Request canceled") {
|
|
450
390
|
super(i);
|
|
451
391
|
b(this, "isCancel", !0);
|
|
452
|
-
this.name = "CancelError", Object.setPrototypeOf(this,
|
|
392
|
+
this.name = "CancelError", Object.setPrototypeOf(this, Ce.prototype);
|
|
453
393
|
}
|
|
454
394
|
}
|
|
455
|
-
const
|
|
395
|
+
const te = {
|
|
456
396
|
baseCDN: "https://ucarecdn.com",
|
|
457
397
|
baseURL: "https://upload.uploadcare.com",
|
|
458
398
|
retryThrottledRequestMaxTimes: 1,
|
|
459
399
|
retryNetworkErrorMaxTimes: 3
|
|
460
|
-
},
|
|
400
|
+
}, si = ({ method: t, url: e, data: i, headers: r = {}, signal: s, onProgress: o }) => new Promise((a, n) => {
|
|
461
401
|
const l = new XMLHttpRequest(), h = (t == null ? void 0 : t.toUpperCase()) || "GET";
|
|
462
402
|
let p = !1;
|
|
463
403
|
l.open(h, e, !0), r && Object.entries(r).forEach((u) => {
|
|
464
404
|
const [_, x] = u;
|
|
465
405
|
typeof x < "u" && !Array.isArray(x) && l.setRequestHeader(_, x);
|
|
466
|
-
}), l.responseType = "text",
|
|
467
|
-
p = !0, l.abort(), n(new
|
|
406
|
+
}), l.responseType = "text", ri(s, () => {
|
|
407
|
+
p = !0, l.abort(), n(new Ce());
|
|
468
408
|
}), l.onload = () => {
|
|
469
409
|
if (l.status != 200)
|
|
470
410
|
n(new Error(`Error ${l.status}: ${l.statusText}`));
|
|
@@ -478,7 +418,7 @@ const ee = {
|
|
|
478
418
|
onProgress: o
|
|
479
419
|
}, _ = l.getAllResponseHeaders().trim().split(/[\r\n]+/), x = {};
|
|
480
420
|
_.forEach(function(R) {
|
|
481
|
-
const
|
|
421
|
+
const O = R.split(": "), W = O.shift(), X = O.join(": ");
|
|
482
422
|
W && typeof W < "u" && (x[W] = X);
|
|
483
423
|
});
|
|
484
424
|
const w = l.response, $ = l.status;
|
|
@@ -490,7 +430,7 @@ const ee = {
|
|
|
490
430
|
});
|
|
491
431
|
}
|
|
492
432
|
}, l.onerror = (u) => {
|
|
493
|
-
p || n(new
|
|
433
|
+
p || n(new oe(u));
|
|
494
434
|
}, o && typeof o == "function" && (l.upload.onprogress = (u) => {
|
|
495
435
|
u.lengthComputable ? o({
|
|
496
436
|
isComputable: !0,
|
|
@@ -498,69 +438,69 @@ const ee = {
|
|
|
498
438
|
}) : o({ isComputable: !1 });
|
|
499
439
|
}), i ? l.send(i) : l.send();
|
|
500
440
|
});
|
|
501
|
-
class
|
|
441
|
+
class $e extends Se {
|
|
502
442
|
constructor(i, r, s, o, a) {
|
|
503
443
|
super();
|
|
504
444
|
b(this, "code");
|
|
505
445
|
b(this, "request");
|
|
506
446
|
b(this, "response");
|
|
507
447
|
b(this, "headers");
|
|
508
|
-
this.name = "UploadError", this.message = i, this.code = r, this.request = s, this.response = o, this.headers = a, Object.setPrototypeOf(this,
|
|
448
|
+
this.name = "UploadError", this.message = i, this.code = r, this.request = s, this.response = o, this.headers = a, Object.setPrototypeOf(this, $e.prototype);
|
|
509
449
|
}
|
|
510
450
|
}
|
|
511
|
-
const
|
|
451
|
+
const oi = (t) => {
|
|
512
452
|
const e = new URLSearchParams();
|
|
513
453
|
for (const [i, r] of Object.entries(t))
|
|
514
454
|
r && typeof r == "object" && !Array.isArray(r) ? Object.entries(r).filter((s) => s[1] ?? !1).forEach((s) => e.set(`${i}[${s[0]}]`, String(s[1]))) : Array.isArray(r) ? r.forEach((s) => {
|
|
515
455
|
e.append(`${i}[]`, s);
|
|
516
456
|
}) : typeof r == "string" && r ? e.set(i, r) : typeof r == "number" && e.set(i, r.toString());
|
|
517
457
|
return e.toString();
|
|
518
|
-
},
|
|
458
|
+
}, ve = (t, e, i) => {
|
|
519
459
|
const r = new URL(t);
|
|
520
|
-
return r.pathname = (r.pathname + e).replace("//", "/"), i && (r.search =
|
|
460
|
+
return r.pathname = (r.pathname + e).replace("//", "/"), i && (r.search = oi(i)), r.toString();
|
|
521
461
|
};
|
|
522
|
-
var
|
|
523
|
-
const
|
|
524
|
-
function
|
|
525
|
-
return
|
|
526
|
-
libraryName:
|
|
527
|
-
libraryVersion:
|
|
462
|
+
var ai = "6.18.4";
|
|
463
|
+
const ni = "UploadcareUploadClient", li = ai;
|
|
464
|
+
function ci(t) {
|
|
465
|
+
return ei({
|
|
466
|
+
libraryName: ni,
|
|
467
|
+
libraryVersion: li,
|
|
528
468
|
...t
|
|
529
469
|
});
|
|
530
470
|
}
|
|
531
|
-
const
|
|
532
|
-
function
|
|
471
|
+
const hi = "RequestThrottledError", Ge = 15e3, ui = 1e3;
|
|
472
|
+
function di(t) {
|
|
533
473
|
const { headers: e } = t || {};
|
|
534
474
|
if (!e || typeof e["retry-after"] != "string")
|
|
535
|
-
return
|
|
475
|
+
return Ge;
|
|
536
476
|
const i = parseInt(e["retry-after"], 10);
|
|
537
|
-
return Number.isFinite(i) ? i * 1e3 :
|
|
477
|
+
return Number.isFinite(i) ? i * 1e3 : Ge;
|
|
538
478
|
}
|
|
539
|
-
function
|
|
479
|
+
function pi(t, e) {
|
|
540
480
|
const { retryThrottledRequestMaxTimes: i, retryNetworkErrorMaxTimes: r } = e;
|
|
541
|
-
return
|
|
542
|
-
if ("response" in a && (a == null ? void 0 : a.code) ===
|
|
543
|
-
return o(
|
|
544
|
-
if (a instanceof
|
|
545
|
-
return o((s + 1) *
|
|
481
|
+
return ii(({ attempt: s, retry: o }) => t().catch((a) => {
|
|
482
|
+
if ("response" in a && (a == null ? void 0 : a.code) === hi && s < i)
|
|
483
|
+
return o(di(a));
|
|
484
|
+
if (a instanceof oe && s < r)
|
|
485
|
+
return o((s + 1) * ui);
|
|
546
486
|
throw a;
|
|
547
487
|
}));
|
|
548
488
|
}
|
|
549
|
-
var
|
|
489
|
+
var He;
|
|
550
490
|
(function(t) {
|
|
551
491
|
t.Token = "token", t.FileInfo = "file_info";
|
|
552
|
-
})(
|
|
553
|
-
var
|
|
492
|
+
})(He || (He = {}));
|
|
493
|
+
var We;
|
|
554
494
|
(function(t) {
|
|
555
495
|
t.Unknown = "unknown", t.Waiting = "waiting", t.Progress = "progress", t.Error = "error", t.Success = "success";
|
|
556
|
-
})(
|
|
557
|
-
function
|
|
558
|
-
return
|
|
496
|
+
})(We || (We = {}));
|
|
497
|
+
function fi(t, { publicKey: e, baseURL: i = te.baseURL, signal: r, source: s, integration: o, userAgent: a, retryThrottledRequestMaxTimes: n = te.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes: l = te.retryNetworkErrorMaxTimes }) {
|
|
498
|
+
return pi(() => si({
|
|
559
499
|
method: "GET",
|
|
560
500
|
headers: {
|
|
561
|
-
"X-UC-User-Agent":
|
|
501
|
+
"X-UC-User-Agent": ci({ publicKey: e, integration: o, userAgent: a })
|
|
562
502
|
},
|
|
563
|
-
url:
|
|
503
|
+
url: ve(i, "/info/", {
|
|
564
504
|
jsonerrors: 1,
|
|
565
505
|
pub_key: e,
|
|
566
506
|
file_id: t,
|
|
@@ -568,17 +508,17 @@ function di(t, { publicKey: e, baseURL: i = ee.baseURL, signal: r, source: s, in
|
|
|
568
508
|
}),
|
|
569
509
|
signal: r
|
|
570
510
|
}).then(({ data: h, headers: p, request: u }) => {
|
|
571
|
-
const _ =
|
|
511
|
+
const _ = Re(JSON.parse(h));
|
|
572
512
|
if ("error" in _)
|
|
573
|
-
throw new
|
|
513
|
+
throw new $e(_.error.content, _.error.errorCode, u, _, p);
|
|
574
514
|
return _;
|
|
575
515
|
}), { retryThrottledRequestMaxTimes: n, retryNetworkErrorMaxTimes: l });
|
|
576
516
|
}
|
|
577
|
-
function
|
|
517
|
+
function mi(t) {
|
|
578
518
|
return "defaultEffects" in t;
|
|
579
519
|
}
|
|
580
|
-
class
|
|
581
|
-
constructor(e, { baseCDN: i =
|
|
520
|
+
class Ve {
|
|
521
|
+
constructor(e, { baseCDN: i = te.baseCDN, fileName: r } = {}) {
|
|
582
522
|
b(this, "uuid");
|
|
583
523
|
b(this, "name");
|
|
584
524
|
b(this, "size");
|
|
@@ -594,29 +534,29 @@ class He {
|
|
|
594
534
|
b(this, "metadata");
|
|
595
535
|
b(this, "s3Bucket");
|
|
596
536
|
b(this, "defaultEffects", null);
|
|
597
|
-
const { uuid: s, s3Bucket: o } = e, a =
|
|
598
|
-
this.uuid = s, this.name = r || e.filename, this.size = e.size, this.isStored = e.isStored, this.isImage = e.isImage, this.mimeType = e.mimeType, this.cdnUrl = a, this.originalFilename = e.originalFilename, this.imageInfo = e.imageInfo, this.videoInfo = e.videoInfo, this.contentInfo = e.contentInfo, this.metadata = e.metadata || null, this.s3Bucket = o || null, this.s3Url = n,
|
|
537
|
+
const { uuid: s, s3Bucket: o } = e, a = ve(i, `${s}/`), n = o ? ve(`https://${o}.s3.amazonaws.com/`, `${s}/${e.filename}`) : null;
|
|
538
|
+
this.uuid = s, this.name = r || e.filename, this.size = e.size, this.isStored = e.isStored, this.isImage = e.isImage, this.mimeType = e.mimeType, this.cdnUrl = a, this.originalFilename = e.originalFilename, this.imageInfo = e.imageInfo, this.videoInfo = e.videoInfo, this.contentInfo = e.contentInfo, this.metadata = e.metadata || null, this.s3Bucket = o || null, this.s3Url = n, mi(e) && (this.defaultEffects = e.defaultEffects);
|
|
599
539
|
}
|
|
600
540
|
}
|
|
601
|
-
const
|
|
602
|
-
function
|
|
541
|
+
const _i = /\W|_/g;
|
|
542
|
+
function gi(t) {
|
|
603
543
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
604
544
|
}
|
|
605
|
-
function
|
|
606
|
-
return t.split(
|
|
545
|
+
function vi(t) {
|
|
546
|
+
return t.split(_i).map((e, i) => e && e.charAt(0)[i > 0 ? "toUpperCase" : "toLowerCase"]() + e.slice(1)).join("");
|
|
607
547
|
}
|
|
608
|
-
function
|
|
548
|
+
function be(t) {
|
|
609
549
|
if (Array.isArray(t))
|
|
610
|
-
return t.map((i) =>
|
|
611
|
-
if (!
|
|
550
|
+
return t.map((i) => be(i));
|
|
551
|
+
if (!gi(t))
|
|
612
552
|
return t;
|
|
613
553
|
const e = {};
|
|
614
554
|
for (const i of Object.keys(t))
|
|
615
|
-
e[
|
|
555
|
+
e[vi(i)] = be(t[i]);
|
|
616
556
|
return e;
|
|
617
557
|
}
|
|
618
|
-
const
|
|
619
|
-
function
|
|
558
|
+
const bi = [1, 1], qe = "https://ucarecdn.com", yi = 1500, wi = 1e6;
|
|
559
|
+
function xi(t, e) {
|
|
620
560
|
return new Promise((i, r) => {
|
|
621
561
|
if (e != null && e.aborted) {
|
|
622
562
|
r(new DOMException("Aborted", "AbortError"));
|
|
@@ -630,18 +570,18 @@ function yi(t, e) {
|
|
|
630
570
|
e == null || e.addEventListener("abort", o, { once: !0 });
|
|
631
571
|
});
|
|
632
572
|
}
|
|
633
|
-
function
|
|
573
|
+
function Ke() {
|
|
634
574
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
635
575
|
}
|
|
636
|
-
class
|
|
576
|
+
class Ei {
|
|
637
577
|
constructor(e) {
|
|
638
578
|
if (this.id = "uploadcare-derivative", !e.publicKey)
|
|
639
579
|
throw new Error("UploadcareDerivativeApi: publicKey is required");
|
|
640
|
-
this.api = new
|
|
580
|
+
this.api = new It({
|
|
641
581
|
publicKey: e.publicKey,
|
|
642
582
|
baseUrl: e.baseUrl,
|
|
643
583
|
fetch: e.fetch
|
|
644
|
-
}), this.publicKey = e.publicKey, this.baseUrl = e.baseUrl, this.filename = e.filename ?? "generated.png", this.store = e.store, this.cname = e.cdnBaseUrl ??
|
|
584
|
+
}), this.publicKey = e.publicKey, this.baseUrl = e.baseUrl, this.filename = e.filename ?? "generated.png", this.store = e.store, this.cname = e.cdnBaseUrl ?? qe, this.cnamePrefixed = e.cdnCnamePrefixed ?? "https://ucarecd.net", this.pollIntervalMs = e.pollIntervalMs ?? yi, this.pollTimeoutMs = e.pollTimeoutMs ?? wi;
|
|
645
585
|
}
|
|
646
586
|
async generate(e) {
|
|
647
587
|
const i = await this.startJob(e);
|
|
@@ -653,7 +593,7 @@ class wi {
|
|
|
653
593
|
* the editor produced.
|
|
654
594
|
*/
|
|
655
595
|
async resolveCdnUrl(e) {
|
|
656
|
-
return
|
|
596
|
+
return dt({ origin: await this.getCdnBase(), uuid: e });
|
|
657
597
|
}
|
|
658
598
|
/**
|
|
659
599
|
* Resolve a stored file's full info (image dimensions, original filename,
|
|
@@ -662,13 +602,13 @@ class wi {
|
|
|
662
602
|
* true aspect ratio before the image decodes, and name outputs after it.
|
|
663
603
|
*/
|
|
664
604
|
async getFileInfo(e, i) {
|
|
665
|
-
const r = await
|
|
666
|
-
return new
|
|
605
|
+
const r = await fi(e, { publicKey: this.publicKey, baseURL: this.baseUrl, signal: i });
|
|
606
|
+
return new Ve(r, { baseCDN: await this.getCdnBase() });
|
|
667
607
|
}
|
|
668
608
|
async startJob(e) {
|
|
669
|
-
const i = e.aspectRatio &&
|
|
609
|
+
const i = e.aspectRatio && Ee(e.aspectRatio) ? [e.aspectRatio[0], e.aspectRatio[1]] : void 0, r = e.filename ?? this.filename, s = e.mode === "edit" ? await this.startEditJob(e, i, r, e.metadata) : await this.api.generate({
|
|
670
610
|
prompt: e.prompt,
|
|
671
|
-
aspectRatio: i ??
|
|
611
|
+
aspectRatio: i ?? bi,
|
|
672
612
|
filename: r,
|
|
673
613
|
store: this.store,
|
|
674
614
|
signal: e.signal,
|
|
@@ -692,22 +632,22 @@ class wi {
|
|
|
692
632
|
});
|
|
693
633
|
}
|
|
694
634
|
async pollUntilDone(e, i) {
|
|
695
|
-
const r = this.pollTimeoutMs +
|
|
635
|
+
const r = this.pollTimeoutMs + Ke();
|
|
696
636
|
for (; ; ) {
|
|
697
637
|
const s = await this.api.getJobStatus(e, i.signal);
|
|
698
638
|
if (s.status === "success") {
|
|
699
639
|
if (!s.uuid)
|
|
700
640
|
throw new Error("Uploadcare derivative: response did not include a uuid");
|
|
701
|
-
const o =
|
|
641
|
+
const o = be(s), a = new Ve(o, { baseCDN: await this.getCdnBase() });
|
|
702
642
|
return { url: a.cdnUrl, uuid: a.uuid, prompt: i.prompt, mode: i.mode, file: a };
|
|
703
643
|
}
|
|
704
644
|
if (s.status === "error") {
|
|
705
645
|
const o = s.error_code ?? "unknown", a = s.error ?? o;
|
|
706
|
-
throw new
|
|
646
|
+
throw new se(o, a, s.error_source);
|
|
707
647
|
}
|
|
708
|
-
if (
|
|
648
|
+
if (Ke() >= r)
|
|
709
649
|
throw new Error(`Uploadcare derivative: timed out waiting for job ${e}`);
|
|
710
|
-
await
|
|
650
|
+
await xi(this.pollIntervalMs, i.signal);
|
|
711
651
|
}
|
|
712
652
|
}
|
|
713
653
|
/**
|
|
@@ -716,11 +656,74 @@ class wi {
|
|
|
716
656
|
* applies in its `cdnCname` computed config. Computed once and cached.
|
|
717
657
|
*/
|
|
718
658
|
getCdnBase() {
|
|
719
|
-
return this.cdnBasePromise || (this.cdnBasePromise = this.cname ===
|
|
659
|
+
return this.cdnBasePromise || (this.cdnBasePromise = this.cname === qe || Vt(this.cname, this.cnamePrefixed) ? Xt(this.publicKey, this.cnamePrefixed) : Promise.resolve(this.cname)), this.cdnBasePromise;
|
|
720
660
|
}
|
|
721
661
|
}
|
|
722
|
-
|
|
723
|
-
|
|
662
|
+
function ki(t) {
|
|
663
|
+
return t instanceof Z ? t : t instanceof se ? new Z(t.message, { code: t.errorCode, source: t.errorSource, cause: t }) : t instanceof Error ? new Z(t.message, { cause: t }) : new Z(typeof t == "string" && t ? t : "Generation failed", { cause: t });
|
|
664
|
+
}
|
|
665
|
+
const ye = {
|
|
666
|
+
generate: {
|
|
667
|
+
id: "generate",
|
|
668
|
+
placeholderKey: "ai-enhancer-generate-placeholder",
|
|
669
|
+
// Complete, descriptive starting prompts. Flux responds best to rich
|
|
670
|
+
// natural-language descriptions, and clicking a chip fills the prompt so the
|
|
671
|
+
// user can run it as-is or tweak it.
|
|
672
|
+
presets: [
|
|
673
|
+
{
|
|
674
|
+
label: "Portrait",
|
|
675
|
+
prompt: "A photorealistic close-up portrait of a woman with freckles and windswept hair, soft natural window light, shallow depth of field, shot on an 85mm lens, ultra-detailed skin texture"
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
label: "Cinematic",
|
|
679
|
+
prompt: "Cinematic film still of a lone traveler on a neon-lit Tokyo street at night, rain-slicked pavement, glowing reflections, moody atmosphere, anamorphic, shot on 35mm"
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
label: "Product",
|
|
683
|
+
prompt: "Product photography of a frosted glass perfume bottle on a polished marble surface, soft studio lighting, gentle reflections, minimalist composition, high detail"
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
label: "Landscape",
|
|
687
|
+
prompt: "A serene mountain landscape at golden hour, low mist drifting through the valley, dramatic clouds, mirror-still lake reflections, photorealistic, ultra-detailed"
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
label: "Illustration",
|
|
691
|
+
prompt: "A flat vector illustration of a cozy bookshop café, warm color palette, clean bold shapes, soft shadows, modern editorial style"
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
label: "3D character",
|
|
695
|
+
prompt: "A cute 3D-rendered robot character, Pixar style, big expressive eyes, soft studio lighting, pastel color palette, smooth glossy materials, octane render"
|
|
696
|
+
}
|
|
697
|
+
]
|
|
698
|
+
},
|
|
699
|
+
edit: {
|
|
700
|
+
id: "edit",
|
|
701
|
+
placeholderKey: "ai-enhancer-edit-placeholder",
|
|
702
|
+
// Instruction-style edits Flux Kontext handles well — restyling, relighting,
|
|
703
|
+
// and background/subject changes that preserve the source image.
|
|
704
|
+
presets: [
|
|
705
|
+
{
|
|
706
|
+
label: "Enhance",
|
|
707
|
+
prompt: "Enhance the photo: improve the lighting, sharpen details, and make the colors richer while keeping it natural"
|
|
708
|
+
},
|
|
709
|
+
{ label: "Golden hour", prompt: "Relight the scene with warm golden-hour sunlight and long, soft shadows" },
|
|
710
|
+
{
|
|
711
|
+
label: "White studio",
|
|
712
|
+
prompt: "Place the subject on a clean seamless white studio backdrop with soft, even lighting"
|
|
713
|
+
},
|
|
714
|
+
{ label: "Remove people", prompt: "Remove all other people from the scene, keeping the main subject intact" },
|
|
715
|
+
{
|
|
716
|
+
label: "Watercolor",
|
|
717
|
+
prompt: "Restyle the image as a soft watercolor painting with delicate, visible brush strokes"
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
label: "Black & white",
|
|
721
|
+
prompt: "Convert to dramatic high-contrast black and white film photography with subtle grain"
|
|
722
|
+
}
|
|
723
|
+
]
|
|
724
|
+
}
|
|
725
|
+
}, Ye = 20;
|
|
726
|
+
class Ri {
|
|
724
727
|
constructor(e) {
|
|
725
728
|
this.busy = !1, this.resultUrl = null, this.result = null, this.error = null, this.errorCode = null, this.history = [], this._abortController = null, this._host = e, e.addController(this);
|
|
726
729
|
}
|
|
@@ -741,7 +744,7 @@ class xi {
|
|
|
741
744
|
/** Replace the strip with entries hydrated from storage (e.g. when the editor
|
|
742
745
|
* opens on a source whose lineage was generated in a past session). */
|
|
743
746
|
setHistory(e) {
|
|
744
|
-
this.history = e.slice(0,
|
|
747
|
+
this.history = e.slice(0, Ye), this._host.requestUpdate();
|
|
745
748
|
}
|
|
746
749
|
setResult(e) {
|
|
747
750
|
this.resultUrl = e.url, this.result = e, this.error = null, this.errorCode = null, this._host.requestUpdate();
|
|
@@ -772,16 +775,16 @@ class xi {
|
|
|
772
775
|
ratio: e.ratioValue ?? null
|
|
773
776
|
},
|
|
774
777
|
...this.history
|
|
775
|
-
].slice(0,
|
|
778
|
+
].slice(0, Ye), s);
|
|
776
779
|
} catch (s) {
|
|
777
780
|
if ((s == null ? void 0 : s.name) === "AbortError") return null;
|
|
778
|
-
throw this.error = s.message || "Generation failed", this.errorCode = s instanceof
|
|
781
|
+
throw this.error = s.message || "Generation failed", this.errorCode = s instanceof se ? s.errorCode : null, s;
|
|
779
782
|
} finally {
|
|
780
783
|
this._abortController === i && (this.busy = !1, this._abortController = null), this._host.requestUpdate();
|
|
781
784
|
}
|
|
782
785
|
}
|
|
783
786
|
}
|
|
784
|
-
const
|
|
787
|
+
const Si = {
|
|
785
788
|
"ai-enhancer-source-label": "Generate image",
|
|
786
789
|
"ai-enhancer-file-action-label": "AI Edit",
|
|
787
790
|
"ai-enhancer-generate-title": "Generate image",
|
|
@@ -806,7 +809,7 @@ const ki = {
|
|
|
806
809
|
"ai-enhancer-aspect-landscape": "Landscape",
|
|
807
810
|
"ai-enhancer-aspect-vertical": "Vertical",
|
|
808
811
|
"ai-enhancer-aspect-widescreen": "Widescreen"
|
|
809
|
-
},
|
|
812
|
+
}, Ci = {
|
|
810
813
|
// Platform validation (POST generate/edit/outpaint, GET status)
|
|
811
814
|
"ai-enhancer-error-invalid_request": "Something went wrong with the request. Please try again.",
|
|
812
815
|
"ai-enhancer-error-invalid_source": "The source image couldn't be read. Please try a different image.",
|
|
@@ -830,7 +833,7 @@ const ki = {
|
|
|
830
833
|
"ai-enhancer-error-DownloadFileHTTPClientError": "Couldn't retrieve the generated image. Please try again.",
|
|
831
834
|
"ai-enhancer-error-DownloadFileNotFoundError": "The generated image couldn't be found. Please try again.",
|
|
832
835
|
"ai-enhancer-error-DownloadFileTaskFailedError": "Couldn't save the generated image. Please try again."
|
|
833
|
-
}, B = { ...
|
|
836
|
+
}, B = { ...Si, ...Ci }, pe = {
|
|
834
837
|
en: async () => B,
|
|
835
838
|
ar: () => import("./ar-0rfB4z3f.js").then((t) => t.default),
|
|
836
839
|
az: () => import("./az-CyK2FKx4.js").then((t) => t.default),
|
|
@@ -867,10 +870,10 @@ const ki = {
|
|
|
867
870
|
zh: () => import("./zh-C0AOtYB8.js").then((t) => t.default),
|
|
868
871
|
"zh-TW": () => import("./zh-TW-BNfdfwdz.js").then((t) => t.default)
|
|
869
872
|
};
|
|
870
|
-
function
|
|
873
|
+
function $i(t, e) {
|
|
871
874
|
return (e == null ? void 0 : e[t]) ?? B[t];
|
|
872
875
|
}
|
|
873
|
-
function
|
|
876
|
+
function Ai(t) {
|
|
874
877
|
if ("kind" in t) return t;
|
|
875
878
|
const e = ke(t.origin);
|
|
876
879
|
if ("sourceUrl" in t)
|
|
@@ -901,12 +904,12 @@ function Si(t) {
|
|
|
901
904
|
hash: r
|
|
902
905
|
};
|
|
903
906
|
}
|
|
904
|
-
var
|
|
905
|
-
let
|
|
907
|
+
var E, q, ie, M;
|
|
908
|
+
let Ui = (M = class {
|
|
906
909
|
constructor(e) {
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
+
he(this, q);
|
|
911
|
+
he(this, E);
|
|
912
|
+
Pe(this, E, Ai(e));
|
|
910
913
|
}
|
|
911
914
|
/**
|
|
912
915
|
* Parses an existing CDN URL.
|
|
@@ -914,15 +917,15 @@ let Ci = (M = class {
|
|
|
914
917
|
* @throws TypeError when the URL cannot be interpreted as a CDN URL.
|
|
915
918
|
*/
|
|
916
919
|
static parse(e) {
|
|
917
|
-
return new M(
|
|
920
|
+
return new M(ht(e));
|
|
918
921
|
}
|
|
919
922
|
/** A defensive copy of the operation chain (empty for group root urls). */
|
|
920
923
|
get operations() {
|
|
921
|
-
return "operations" in
|
|
924
|
+
return "operations" in k(this, E) ? [...k(this, E).operations] : [];
|
|
922
925
|
}
|
|
923
926
|
/** The serialized URL string. */
|
|
924
927
|
get href() {
|
|
925
|
-
return
|
|
928
|
+
return dt(k(this, E));
|
|
926
929
|
}
|
|
927
930
|
/** Alias of {@link CdnUrl.href} for string coercion. */
|
|
928
931
|
toString() {
|
|
@@ -930,7 +933,7 @@ let Ci = (M = class {
|
|
|
930
933
|
}
|
|
931
934
|
/** The underlying {@link ParsedCdnUrl}, discriminated by `kind`. */
|
|
932
935
|
toJSON() {
|
|
933
|
-
return "operations" in
|
|
936
|
+
return "operations" in k(this, E) ? { ...k(this, E), operations: [...k(this, E).operations] } : { ...k(this, E) };
|
|
934
937
|
}
|
|
935
938
|
/**
|
|
936
939
|
* Appends operations to the chain.
|
|
@@ -938,18 +941,18 @@ let Ci = (M = class {
|
|
|
938
941
|
* @throws TypeError on group root urls, which cannot carry operations.
|
|
939
942
|
*/
|
|
940
943
|
with(...e) {
|
|
941
|
-
return J(this, q,
|
|
944
|
+
return J(this, q, ie).call(this, (i) => [...i, ...e]);
|
|
942
945
|
}
|
|
943
946
|
/**
|
|
944
947
|
* Removes every occurrence of an operation. Accepts the operation name,
|
|
945
948
|
* an operation object, or the creator itself: `url.without(resize)`.
|
|
946
949
|
*/
|
|
947
950
|
without(e) {
|
|
948
|
-
return J(this, q,
|
|
951
|
+
return J(this, q, ie).call(this, (i) => i.filter((r) => !de(r, e)));
|
|
949
952
|
}
|
|
950
953
|
/** Replaces the first same-named operation in place, or appends it. */
|
|
951
954
|
replace(e) {
|
|
952
|
-
return J(this, q,
|
|
955
|
+
return J(this, q, ie).call(this, (i) => {
|
|
953
956
|
const r = i.findIndex((o) => o.name === e.name);
|
|
954
957
|
if (r === -1) return [...i, e];
|
|
955
958
|
const s = [...i];
|
|
@@ -958,11 +961,11 @@ let Ci = (M = class {
|
|
|
958
961
|
}
|
|
959
962
|
/** Whether a matching operation is present (name, object or creator ref). */
|
|
960
963
|
has(e) {
|
|
961
|
-
return this.operations.some((i) =>
|
|
964
|
+
return this.operations.some((i) => de(i, e));
|
|
962
965
|
}
|
|
963
966
|
/** First matching operation (name, object or creator ref), or null. */
|
|
964
967
|
get(e) {
|
|
965
|
-
return this.operations.find((i) =>
|
|
968
|
+
return this.operations.find((i) => de(i, e)) ?? null;
|
|
966
969
|
}
|
|
967
970
|
/**
|
|
968
971
|
* Sets or clears (`null`) the trailing filename.
|
|
@@ -970,55 +973,55 @@ let Ci = (M = class {
|
|
|
970
973
|
* @throws TypeError on group root and proxy urls.
|
|
971
974
|
*/
|
|
972
975
|
setFilename(e) {
|
|
973
|
-
return
|
|
976
|
+
return k(this, E).kind === "group" || k(this, E).kind === "proxy" ? this : new M({ ...k(this, E), filename: e });
|
|
974
977
|
}
|
|
975
978
|
/** Rebases the url onto another domain. */
|
|
976
979
|
setOrigin(e) {
|
|
977
|
-
return new M({ ...
|
|
980
|
+
return new M({ ...k(this, E), origin: ke(e) });
|
|
978
981
|
}
|
|
979
|
-
},
|
|
980
|
-
return "operations" in
|
|
981
|
-
...
|
|
982
|
-
operations: e(
|
|
982
|
+
}, E = new WeakMap(), q = new WeakSet(), ie = function(e) {
|
|
983
|
+
return "operations" in k(this, E) ? new M({
|
|
984
|
+
...k(this, E),
|
|
985
|
+
operations: e(k(this, E).operations)
|
|
983
986
|
}) : this;
|
|
984
987
|
}, M);
|
|
985
|
-
const
|
|
988
|
+
const we = (t, ...e) => ({
|
|
986
989
|
name: t,
|
|
987
990
|
params: e
|
|
988
|
-
}),
|
|
991
|
+
}), Ti = /* @__PURE__ */ pt(
|
|
989
992
|
"preview",
|
|
990
993
|
function(t, e) {
|
|
991
|
-
return t == null && e == null ?
|
|
994
|
+
return t == null && e == null ? we("preview") : we("preview", ct(t, e, "preview"));
|
|
992
995
|
}
|
|
993
|
-
),
|
|
996
|
+
), Fi = /* @__PURE__ */ pt(
|
|
994
997
|
"scale_crop",
|
|
995
998
|
function(t, e, i = {}) {
|
|
996
|
-
const r = [
|
|
997
|
-
return i.type != null && r.push(i.type), i.align != null && r.push(
|
|
999
|
+
const r = [ct(t, e, "scale_crop")];
|
|
1000
|
+
return i.type != null && r.push(i.type), i.align != null && r.push(zt(i.align, "scale_crop alignment")), we("scale_crop", ...r);
|
|
998
1001
|
}
|
|
999
|
-
),
|
|
1000
|
-
function
|
|
1002
|
+
), Mi = 3e3;
|
|
1003
|
+
function ft(t) {
|
|
1001
1004
|
const e = typeof window < "u" ? window.devicePixelRatio : 1;
|
|
1002
|
-
return Math.min(Math.ceil(t * Math.max(e, 1)),
|
|
1005
|
+
return Math.min(Math.ceil(t * Math.max(e, 1)), Mi);
|
|
1003
1006
|
}
|
|
1004
|
-
function
|
|
1007
|
+
function mt(t, e) {
|
|
1005
1008
|
if (e.length === 0) return t;
|
|
1006
1009
|
try {
|
|
1007
|
-
return
|
|
1010
|
+
return Ui.parse(t).with(...e).href;
|
|
1008
1011
|
} catch {
|
|
1009
1012
|
return t;
|
|
1010
1013
|
}
|
|
1011
1014
|
}
|
|
1012
|
-
function
|
|
1013
|
-
const i =
|
|
1014
|
-
return
|
|
1015
|
+
function Oi(t, e) {
|
|
1016
|
+
const i = ft(e);
|
|
1017
|
+
return mt(t, [Ti(i, i)]);
|
|
1015
1018
|
}
|
|
1016
|
-
function
|
|
1017
|
-
const i =
|
|
1018
|
-
return
|
|
1019
|
+
function Ii(t, e) {
|
|
1020
|
+
const i = ft(e);
|
|
1021
|
+
return mt(t, [Fi(i, i, { align: "center" })]);
|
|
1019
1022
|
}
|
|
1020
|
-
const
|
|
1021
|
-
class
|
|
1023
|
+
const Pi = "uc-ai-enhancer/history", Xe = 200, Li = 10080 * 60 * 1e3;
|
|
1024
|
+
class zi {
|
|
1022
1025
|
constructor(e) {
|
|
1023
1026
|
this._key = null, e.addController(this);
|
|
1024
1027
|
}
|
|
@@ -1026,7 +1029,7 @@ class Oi {
|
|
|
1026
1029
|
}
|
|
1027
1030
|
/** Namespace the store by pubkey. Passing an empty key disables persistence. */
|
|
1028
1031
|
setNamespace(e) {
|
|
1029
|
-
this._key = e ? `${
|
|
1032
|
+
this._key = e ? `${Pi}/${e}` : null;
|
|
1030
1033
|
}
|
|
1031
1034
|
/** Upsert the result as a node and persist (evicting expired/overflowing nodes). */
|
|
1032
1035
|
record(e) {
|
|
@@ -1057,7 +1060,7 @@ class Oi {
|
|
|
1057
1060
|
*/
|
|
1058
1061
|
lineage(e) {
|
|
1059
1062
|
const i = this._key;
|
|
1060
|
-
return !i || !e ? [] : this._component(this._read(i), e).sort((r, s) => s.createdAt - r.createdAt).map(
|
|
1063
|
+
return !i || !e ? [] : this._component(this._read(i), e).sort((r, s) => s.createdAt - r.createdAt).map(Di);
|
|
1061
1064
|
}
|
|
1062
1065
|
/** Nodes in `start`'s connected component, walking both parent and child edges.
|
|
1063
1066
|
* `start` may be a node itself or only a parent uuid (a source not yet edited). */
|
|
@@ -1083,8 +1086,8 @@ class Oi {
|
|
|
1083
1086
|
* middle node just orphans its descendants (their lineage walk stops early). */
|
|
1084
1087
|
_evict(e) {
|
|
1085
1088
|
const i = Date.now();
|
|
1086
|
-
let r = Object.values(e).filter((o) => i - o.createdAt <
|
|
1087
|
-
r.length >
|
|
1089
|
+
let r = Object.values(e).filter((o) => i - o.createdAt < Li);
|
|
1090
|
+
r.length > Xe && (r = r.sort((o, a) => a.createdAt - o.createdAt).slice(0, Xe));
|
|
1088
1091
|
const s = {};
|
|
1089
1092
|
for (const o of r) s[o.uuid] = o;
|
|
1090
1093
|
return s;
|
|
@@ -1108,7 +1111,7 @@ class Oi {
|
|
|
1108
1111
|
}
|
|
1109
1112
|
}
|
|
1110
1113
|
}
|
|
1111
|
-
function
|
|
1114
|
+
function Di(t) {
|
|
1112
1115
|
return {
|
|
1113
1116
|
id: t.uuid,
|
|
1114
1117
|
prompt: t.prompt,
|
|
@@ -1118,23 +1121,23 @@ function Pi(t) {
|
|
|
1118
1121
|
ratio: t.ratio
|
|
1119
1122
|
};
|
|
1120
1123
|
}
|
|
1121
|
-
function
|
|
1124
|
+
function Ni(t) {
|
|
1122
1125
|
try {
|
|
1123
|
-
const e =
|
|
1126
|
+
const e = ht(t);
|
|
1124
1127
|
if (e.kind === "file")
|
|
1125
1128
|
return {
|
|
1126
1129
|
uuid: e.uuid,
|
|
1127
|
-
cdnUrlModifiers:
|
|
1130
|
+
cdnUrlModifiers: ut(e.operations),
|
|
1128
1131
|
fileName: e.filename ?? ""
|
|
1129
1132
|
};
|
|
1130
1133
|
} catch {
|
|
1131
1134
|
}
|
|
1132
1135
|
return { uuid: "", cdnUrlModifiers: "", fileName: "" };
|
|
1133
1136
|
}
|
|
1134
|
-
function
|
|
1135
|
-
return e ? e(t,
|
|
1137
|
+
function Bi(t, e) {
|
|
1138
|
+
return e ? e(t, Ni(t)) : t;
|
|
1136
1139
|
}
|
|
1137
|
-
class
|
|
1140
|
+
class _t {
|
|
1138
1141
|
constructor(e) {
|
|
1139
1142
|
this._cache = /* @__PURE__ */ new Map(), this._pending = /* @__PURE__ */ new Set(), this._host = e, e.addController(this);
|
|
1140
1143
|
}
|
|
@@ -1151,39 +1154,39 @@ class ft {
|
|
|
1151
1154
|
const i = this._cache.get(e);
|
|
1152
1155
|
if (i !== void 0) return i;
|
|
1153
1156
|
if (this._pending.has(e)) return null;
|
|
1154
|
-
const r =
|
|
1157
|
+
const r = Bi(e, this._resolver);
|
|
1155
1158
|
return typeof r == "string" ? (this._cache.set(e, r), r) : (this._pending.add(e), r.then((s) => this._cache.set(e, s)).catch(() => this._cache.set(e, e)).finally(() => {
|
|
1156
1159
|
this._pending.delete(e), this._host.requestUpdate();
|
|
1157
1160
|
}), null);
|
|
1158
1161
|
}
|
|
1159
1162
|
}
|
|
1160
|
-
const
|
|
1163
|
+
const qr = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
1161
1164
|
<path d="M9.5 3 11 6.5 14.5 8 11 9.5 9.5 13 8 9.5 4.5 8 8 6.5 9.5 3Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>
|
|
1162
1165
|
<path d="M17.5 12 18.4 14.1 20.5 15 18.4 15.9 17.5 18 16.6 15.9 14.5 15 16.6 14.1 17.5 12Z" stroke="currentColor" stroke-width="1.25" stroke-linejoin="round"/>
|
|
1163
1166
|
<path d="M5.5 16 6.1 17.4 7.5 18 6.1 18.6 5.5 20 4.9 18.6 3.5 18 4.9 17.4 5.5 16Z" stroke="currentColor" stroke-width="1.25" stroke-linejoin="round"/>
|
|
1164
|
-
</svg>`,
|
|
1167
|
+
</svg>`, Kr = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
1165
1168
|
<path d="m14.5 4.5 5 5L9 20H4v-5L14.5 4.5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>
|
|
1166
1169
|
<path d="m13 6 5 5" stroke="currentColor" stroke-width="1.5"/>
|
|
1167
1170
|
<path d="M18.5 14.5 19 16l1.5.5L19 17l-.5 1.5L18 17l-1.5-.5L18 16l.5-1.5Z" stroke="currentColor" stroke-width="1.1" stroke-linejoin="round"/>
|
|
1168
|
-
</svg>`,
|
|
1171
|
+
</svg>`, ji = `<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
1169
1172
|
<path d="M3 6.74251L8 2L13 6.74251M7.99961 14V2.10636" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1170
|
-
</svg>`,
|
|
1173
|
+
</svg>`, Gi = `<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
1171
1174
|
<rect x="2" y="3" width="12" height="10" rx="1.6" stroke="currentColor" stroke-width="1.4"/>
|
|
1172
1175
|
<circle cx="5.75" cy="6.25" r="1.05" stroke="currentColor" stroke-width="1.2"/>
|
|
1173
1176
|
<path d="M3 11.5l3-2.6 2.3 1.8L11 8l2 2.4" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1174
|
-
</svg>`,
|
|
1177
|
+
</svg>`, Hi = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
1175
1178
|
<path d="M9 4H4v5M15 4h5v5M9 20H4v-5M15 20h5v-5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1176
|
-
</svg>`,
|
|
1179
|
+
</svg>`, Wi = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
1177
1180
|
<path d="M4 9h5V4M20 9h-5V4M4 15h5v5M20 15h-5v5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1178
|
-
</svg>`,
|
|
1179
|
-
var
|
|
1180
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1181
|
+
</svg>`, Vi = ":host{display:inline-flex;position:relative}.trigger{anchor-name:--ai-aspect-anchor;display:inline-flex;align-items:center;gap:8px;height:var(--uc-ai-button-size);padding:0 10px;background:var(--uc-ai-secondary);border:0;border-radius:var(--uc-ai-radius-button);color:var(--uc-ai-foreground);cursor:pointer;font:inherit;transition:background var(--uc-ai-transition),transform .14s var(--uc-ai-ease-out, ease)}.trigger:hover,.trigger[aria-expanded=true]{background:var(--uc-ai-secondary-hover)}.trigger:active{transform:scale(.97)}.trigger:disabled{opacity:.4;cursor:not-allowed}.trigger svg{width:14px;height:14px;color:var(--uc-ai-foreground)}.trigger-label{font-variant-numeric:tabular-nums;font-size:12px;font-weight:500;letter-spacing:.02em;line-height:20px}.popover{margin:0 0 6px;padding:0;border:0;background:transparent;color:inherit;overflow:visible;width:max-content;min-width:180px;max-width:320px;position-anchor:--ai-aspect-anchor;inset:auto;bottom:anchor(top);right:anchor(right);transform-origin:bottom right;transition:opacity .15s var(--uc-ai-ease-out, ease),transform .15s var(--uc-ai-ease-out, ease),display .15s allow-discrete,overlay .15s allow-discrete}.popover:not(:popover-open){display:none;opacity:0;transform:scale(.96) translateY(4px)}@starting-style{.popover:popover-open{opacity:0;transform:scale(.96) translateY(4px)}}.popover-inner{background:var(--uc-ai-background);border:1px solid var(--uc-ai-border);border-radius:var(--uc-ai-radius-input, 12px);box-shadow:var(--uc-ai-dialog-shadow);padding:5px;display:flex;flex-direction:column;gap:2px}.option{display:flex;align-items:center;gap:10px;width:100%;padding:6px 10px;background:transparent;border:0;border-radius:max(0px,calc(var(--uc-ai-radius-input) - 5px));cursor:pointer;color:var(--uc-ai-foreground);font:inherit;font-size:13px;text-align:left;transition:background .12s ease}.option:hover{background:var(--uc-ai-secondary)}.option[aria-selected=true]{background:var(--uc-ai-secondary-hover)}.option svg{width:16px;height:16px;flex:0 0 16px;color:var(--uc-ai-foreground)}.option-ratio{flex:0 0 36px;font-variant-numeric:tabular-nums;font-weight:500;white-space:nowrap;color:var(--uc-ai-foreground)}.option-label{flex:1;min-width:0;color:var(--uc-ai-muted-foreground);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(prefers-reduced-motion:reduce){.trigger,.popover{transition-property:opacity,background,display,overlay}.trigger:active{transform:none}.popover:not(:popover-open){transform:none}}";
|
|
1182
|
+
var qi = Object.defineProperty, Ki = Object.getOwnPropertyDescriptor, L = (t, e, i, r) => {
|
|
1183
|
+
for (var s = r > 1 ? void 0 : r ? Ki(e, i) : e, o = t.length - 1, a; o >= 0; o--)
|
|
1181
1184
|
(a = t[o]) && (s = (r ? a(e, i, s) : a(s)) || s);
|
|
1182
|
-
return r && s &&
|
|
1185
|
+
return r && s && qi(e, i, s), s;
|
|
1183
1186
|
};
|
|
1184
1187
|
let A = class extends G {
|
|
1185
1188
|
constructor() {
|
|
1186
|
-
super(...arguments), this.options = [], this.selected = null, this.busy = !1, this.labelText = null, this.labelFor = (t) =>
|
|
1189
|
+
super(...arguments), this.options = [], this.selected = null, this.busy = !1, this.labelText = null, this.labelFor = (t) => I(t.value) ? ee(t.value) : "", this.open = !1, this._onToggle = (t) => {
|
|
1187
1190
|
t.newState === "closed" && this.open && (this.open = !1);
|
|
1188
1191
|
};
|
|
1189
1192
|
}
|
|
@@ -1208,12 +1211,12 @@ let A = class extends G {
|
|
|
1208
1211
|
}
|
|
1209
1212
|
/** Icon for a selection: the ratio's shape, or the generic "Original" glyph. */
|
|
1210
1213
|
_iconFor(t) {
|
|
1211
|
-
return
|
|
1214
|
+
return I(t) ? Mt(t) : Gi;
|
|
1212
1215
|
}
|
|
1213
1216
|
_triggerLabel() {
|
|
1214
1217
|
const t = this.selected;
|
|
1215
1218
|
if (!t) return "";
|
|
1216
|
-
if (
|
|
1219
|
+
if (I(t)) return ee(t);
|
|
1217
1220
|
const e = this.options.find((i) => i.value === t);
|
|
1218
1221
|
return e ? this.labelFor(e) : "";
|
|
1219
1222
|
}
|
|
@@ -1229,13 +1232,13 @@ let A = class extends G {
|
|
|
1229
1232
|
?disabled=${this.busy}
|
|
1230
1233
|
@click=${this._toggle}
|
|
1231
1234
|
>
|
|
1232
|
-
${this.selected ?
|
|
1235
|
+
${this.selected ? re(this._iconFor(this.selected)) : null}
|
|
1233
1236
|
${t ? f`<span class="trigger-label">${t}</span>` : null}
|
|
1234
1237
|
</button>
|
|
1235
1238
|
<div class="popover" popover="auto" role="listbox" @toggle=${this._onToggle}>
|
|
1236
1239
|
<div class="popover-inner">
|
|
1237
1240
|
${this.options.map((e) => {
|
|
1238
|
-
const i = this.selected ?
|
|
1241
|
+
const i = this.selected ? _e(e.value, this.selected) : !1;
|
|
1239
1242
|
return f`
|
|
1240
1243
|
<button
|
|
1241
1244
|
type="button"
|
|
@@ -1244,8 +1247,8 @@ let A = class extends G {
|
|
|
1244
1247
|
aria-selected="${i ? "true" : "false"}"
|
|
1245
1248
|
@click=${() => this._select(e.value)}
|
|
1246
1249
|
>
|
|
1247
|
-
${
|
|
1248
|
-
<span class="option-ratio">${
|
|
1250
|
+
${re(this._iconFor(e.value))}
|
|
1251
|
+
<span class="option-ratio">${I(e.value) ? ee(e.value) : ""}</span>
|
|
1249
1252
|
<span class="option-label">${this.labelFor(e)}</span>
|
|
1250
1253
|
</button>
|
|
1251
1254
|
`;
|
|
@@ -1255,59 +1258,59 @@ let A = class extends G {
|
|
|
1255
1258
|
`;
|
|
1256
1259
|
}
|
|
1257
1260
|
};
|
|
1258
|
-
A.styles = j(
|
|
1259
|
-
|
|
1261
|
+
A.styles = j(Vi);
|
|
1262
|
+
L([
|
|
1260
1263
|
c({ attribute: !1 })
|
|
1261
1264
|
], A.prototype, "options", 2);
|
|
1262
|
-
|
|
1265
|
+
L([
|
|
1263
1266
|
c({ attribute: !1 })
|
|
1264
1267
|
], A.prototype, "selected", 2);
|
|
1265
|
-
|
|
1268
|
+
L([
|
|
1266
1269
|
c({ type: Boolean })
|
|
1267
1270
|
], A.prototype, "busy", 2);
|
|
1268
|
-
|
|
1271
|
+
L([
|
|
1269
1272
|
c({ attribute: "aria-label-text" })
|
|
1270
1273
|
], A.prototype, "labelText", 2);
|
|
1271
|
-
|
|
1274
|
+
L([
|
|
1272
1275
|
c({ attribute: !1 })
|
|
1273
1276
|
], A.prototype, "labelFor", 2);
|
|
1274
|
-
|
|
1277
|
+
L([
|
|
1275
1278
|
C()
|
|
1276
1279
|
], A.prototype, "open", 2);
|
|
1277
|
-
|
|
1280
|
+
L([
|
|
1278
1281
|
F(".popover")
|
|
1279
1282
|
], A.prototype, "_popover", 2);
|
|
1280
|
-
A =
|
|
1283
|
+
A = L([
|
|
1281
1284
|
H("uc-ai-aspect-ratio")
|
|
1282
1285
|
], A);
|
|
1283
|
-
const
|
|
1284
|
-
let
|
|
1285
|
-
const
|
|
1286
|
+
const Yi = /* @__PURE__ */ new WeakMap();
|
|
1287
|
+
let Je = 0;
|
|
1288
|
+
const fe = /* @__PURE__ */ new Map(), Ze = /* @__PURE__ */ new WeakSet(), Qe = () => new Promise((t) => requestAnimationFrame(t)), et = (t, e) => {
|
|
1286
1289
|
const i = t - e;
|
|
1287
1290
|
return i === 0 ? void 0 : i;
|
|
1288
|
-
},
|
|
1291
|
+
}, tt = (t, e) => {
|
|
1289
1292
|
const i = t / e;
|
|
1290
1293
|
return i === 1 ? void 0 : i;
|
|
1291
|
-
},
|
|
1292
|
-
const i =
|
|
1294
|
+
}, me = { left: (t, e) => {
|
|
1295
|
+
const i = et(t, e);
|
|
1293
1296
|
return { value: i, transform: i == null || isNaN(i) ? void 0 : `translateX(${i}px)` };
|
|
1294
1297
|
}, top: (t, e) => {
|
|
1295
|
-
const i =
|
|
1298
|
+
const i = et(t, e);
|
|
1296
1299
|
return { value: i, transform: i == null || isNaN(i) ? void 0 : `translateY(${i}px)` };
|
|
1297
1300
|
}, width: (t, e) => {
|
|
1298
1301
|
let i;
|
|
1299
1302
|
e === 0 && (e = 1, i = { width: "1px" });
|
|
1300
|
-
const r =
|
|
1303
|
+
const r = tt(t, e);
|
|
1301
1304
|
return { value: r, overrideFrom: i, transform: r == null || isNaN(r) ? void 0 : `scaleX(${r})` };
|
|
1302
1305
|
}, height: (t, e) => {
|
|
1303
1306
|
let i;
|
|
1304
1307
|
e === 0 && (e = 1, i = { height: "1px" });
|
|
1305
|
-
const r =
|
|
1308
|
+
const r = tt(t, e);
|
|
1306
1309
|
return { value: r, overrideFrom: i, transform: r == null || isNaN(r) ? void 0 : `scaleY(${r})` };
|
|
1307
|
-
} },
|
|
1308
|
-
class
|
|
1310
|
+
} }, Xi = { duration: 333, easing: "ease-in-out" }, Ji = ["left", "top", "width", "height", "opacity", "color", "background"], it = /* @__PURE__ */ new WeakMap();
|
|
1311
|
+
class Zi extends nt {
|
|
1309
1312
|
constructor(e) {
|
|
1310
|
-
if (super(e), this.t = !1, this.i = null, this.o = null, this.h = !0, this.shouldLog = !1, e.type ===
|
|
1313
|
+
if (super(e), this.t = !1, this.i = null, this.o = null, this.h = !0, this.shouldLog = !1, e.type === at.CHILD) throw Error("The `animate` directive must be used in attribute position.");
|
|
1311
1314
|
this.createFinished();
|
|
1312
1315
|
}
|
|
1313
1316
|
createFinished() {
|
|
@@ -1321,10 +1324,10 @@ class Yi extends ot {
|
|
|
1321
1324
|
(e = this.l) == null || e.call(this), this.l = void 0;
|
|
1322
1325
|
}
|
|
1323
1326
|
render(e) {
|
|
1324
|
-
return
|
|
1327
|
+
return st;
|
|
1325
1328
|
}
|
|
1326
1329
|
getController() {
|
|
1327
|
-
return
|
|
1330
|
+
return Yi.get(this.u);
|
|
1328
1331
|
}
|
|
1329
1332
|
isDisabled() {
|
|
1330
1333
|
var e;
|
|
@@ -1333,17 +1336,17 @@ class Yi extends ot {
|
|
|
1333
1336
|
update(e, [i]) {
|
|
1334
1337
|
var s;
|
|
1335
1338
|
const r = this.u === void 0;
|
|
1336
|
-
return r && (this.u = (s = e.options) == null ? void 0 : s.host, this.u.addController(this), this.u.updateComplete.then((o) => this.t = !0), this.element = e.element,
|
|
1339
|
+
return r && (this.u = (s = e.options) == null ? void 0 : s.host, this.u.addController(this), this.u.updateComplete.then((o) => this.t = !0), this.element = e.element, it.set(this.element, this)), this.optionsOrCallback = i, (r || typeof i != "function") && this.m(i), this.render(i);
|
|
1337
1340
|
}
|
|
1338
1341
|
m(e) {
|
|
1339
1342
|
e = e ?? {};
|
|
1340
1343
|
const i = this.getController();
|
|
1341
|
-
i !== void 0 && ((e = { ...i.defaultOptions, ...e }).keyframeOptions = { ...i.defaultOptions.keyframeOptions, ...e.keyframeOptions }), e.properties ?? (e.properties =
|
|
1344
|
+
i !== void 0 && ((e = { ...i.defaultOptions, ...e }).keyframeOptions = { ...i.defaultOptions.keyframeOptions, ...e.keyframeOptions }), e.properties ?? (e.properties = Ji), this.options = e;
|
|
1342
1345
|
}
|
|
1343
1346
|
p() {
|
|
1344
1347
|
const e = {}, i = this.element.getBoundingClientRect(), r = getComputedStyle(this.element);
|
|
1345
1348
|
return this.options.properties.forEach((s) => {
|
|
1346
|
-
const o = i[s] ?? (
|
|
1349
|
+
const o = i[s] ?? (me[s] ? void 0 : r[s]), a = Number(o);
|
|
1347
1350
|
e[s] = isNaN(a) ? o + "" : a;
|
|
1348
1351
|
}), e;
|
|
1349
1352
|
}
|
|
@@ -1362,17 +1365,17 @@ class Yi extends ot {
|
|
|
1362
1365
|
async hostUpdated() {
|
|
1363
1366
|
if (!this.h || !this.element.isConnected || this.options.skipInitial && !this.isHostRendered) return;
|
|
1364
1367
|
let e;
|
|
1365
|
-
this.prepare(), await
|
|
1368
|
+
this.prepare(), await Qe;
|
|
1366
1369
|
const i = this.P(), r = this.V(this.options.keyframeOptions, i), s = this.p();
|
|
1367
1370
|
if (this.A !== void 0) {
|
|
1368
1371
|
const { from: o, to: a } = this.O(this.A, s, i);
|
|
1369
1372
|
this.log("measured", [this.A, s, o, a]), e = this.calculateKeyframes(o, a);
|
|
1370
1373
|
} else {
|
|
1371
|
-
const o =
|
|
1374
|
+
const o = fe.get(this.options.inId);
|
|
1372
1375
|
if (o) {
|
|
1373
|
-
|
|
1376
|
+
fe.delete(this.options.inId);
|
|
1374
1377
|
const { from: a, to: n } = this.O(o, s, i);
|
|
1375
|
-
e = this.calculateKeyframes(a, n), e = this.options.in ? [{ ...this.options.in[0], ...e[0] }, ...this.options.in.slice(1), e[1]] : e,
|
|
1378
|
+
e = this.calculateKeyframes(a, n), e = this.options.in ? [{ ...this.options.in[0], ...e[0] }, ...this.options.in.slice(1), e[1]] : e, Je++, e.forEach((l) => l.zIndex = Je);
|
|
1376
1379
|
} else this.options.in && (e = [...this.options.in, {}]);
|
|
1377
1380
|
}
|
|
1378
1381
|
this.animate(e, r);
|
|
@@ -1388,8 +1391,8 @@ class Yi extends ot {
|
|
|
1388
1391
|
}
|
|
1389
1392
|
async disconnected() {
|
|
1390
1393
|
var i;
|
|
1391
|
-
if (!this.h || (this.options.id !== void 0 &&
|
|
1392
|
-
if (this.prepare(), await
|
|
1394
|
+
if (!this.h || (this.options.id !== void 0 && fe.set(this.options.id, this.A), this.options.out === void 0)) return;
|
|
1395
|
+
if (this.prepare(), await Qe(), (i = this.i) == null ? void 0 : i.isConnected) {
|
|
1393
1396
|
const r = this.o && this.o.parentNode === this.i ? this.o : null;
|
|
1394
1397
|
if (this.i.insertBefore(this.element, r), this.options.stabilizeOut) {
|
|
1395
1398
|
const s = this.p();
|
|
@@ -1415,19 +1418,19 @@ class Yi extends ot {
|
|
|
1415
1418
|
P() {
|
|
1416
1419
|
const e = [];
|
|
1417
1420
|
for (let i = this.element.parentNode; i; i = i == null ? void 0 : i.parentNode) {
|
|
1418
|
-
const r =
|
|
1421
|
+
const r = it.get(i);
|
|
1419
1422
|
r && !r.isDisabled() && r && e.push(r);
|
|
1420
1423
|
}
|
|
1421
1424
|
return e;
|
|
1422
1425
|
}
|
|
1423
1426
|
get isHostRendered() {
|
|
1424
|
-
const e =
|
|
1427
|
+
const e = Ze.has(this.u);
|
|
1425
1428
|
return e || this.u.updateComplete.then(() => {
|
|
1426
|
-
|
|
1429
|
+
Ze.add(this.u);
|
|
1427
1430
|
}), e;
|
|
1428
1431
|
}
|
|
1429
1432
|
V(e, i = this.P()) {
|
|
1430
|
-
const r = { ...
|
|
1433
|
+
const r = { ...Xi };
|
|
1431
1434
|
return i.forEach((s) => Object.assign(r, s.options.keyframeOptions)), Object.assign(r, e), r;
|
|
1432
1435
|
}
|
|
1433
1436
|
O(e, i, r) {
|
|
@@ -1444,8 +1447,8 @@ class Yi extends ot {
|
|
|
1444
1447
|
const n = {};
|
|
1445
1448
|
for (const l in i) {
|
|
1446
1449
|
const h = e[l], p = i[l];
|
|
1447
|
-
if (l in
|
|
1448
|
-
const u =
|
|
1450
|
+
if (l in me) {
|
|
1451
|
+
const u = me[l];
|
|
1449
1452
|
if (h === void 0 || p === void 0) continue;
|
|
1450
1453
|
const _ = u(h, p);
|
|
1451
1454
|
_.transform !== void 0 && (n[l] = _.value, a = !0, s.transform = `${s.transform ?? ""} ${_.transform}`, _.overrideFrom !== void 0 && Object.assign(s, _.overrideFrom));
|
|
@@ -1476,13 +1479,13 @@ class Yi extends ot {
|
|
|
1476
1479
|
this.shouldLog && !this.isDisabled() && console.log(e, this.options.id, i);
|
|
1477
1480
|
}
|
|
1478
1481
|
}
|
|
1479
|
-
const
|
|
1480
|
-
class
|
|
1482
|
+
const Qi = ot(Zi), er = ["top", "right", "bottom", "left"];
|
|
1483
|
+
class tr extends nt {
|
|
1481
1484
|
constructor(e) {
|
|
1482
|
-
if (super(e), e.type !==
|
|
1485
|
+
if (super(e), e.type !== at.ELEMENT) throw Error("The `position` directive must be used in attribute position.");
|
|
1483
1486
|
}
|
|
1484
1487
|
render(e, i) {
|
|
1485
|
-
return
|
|
1488
|
+
return st;
|
|
1486
1489
|
}
|
|
1487
1490
|
update(e, [i, r]) {
|
|
1488
1491
|
var s;
|
|
@@ -1497,22 +1500,22 @@ class Zi extends ot {
|
|
|
1497
1500
|
if (e === void 0 || !i) return;
|
|
1498
1501
|
const r = e.getBoundingClientRect(), s = i.getBoundingClientRect();
|
|
1499
1502
|
(a = this.S) == null || a.forEach((n) => {
|
|
1500
|
-
const l =
|
|
1503
|
+
const l = er.includes(n) ? r[n] - s[n] : r[n];
|
|
1501
1504
|
this.C.style[n] = l + "px";
|
|
1502
1505
|
});
|
|
1503
1506
|
}
|
|
1504
1507
|
}
|
|
1505
|
-
|
|
1506
|
-
const
|
|
1507
|
-
var
|
|
1508
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1508
|
+
ot(tr);
|
|
1509
|
+
const ir = ':host{display:flex;justify-content:center}.strip{position:relative;display:inline-flex;align-items:center;min-height:44px}.chip{display:flex;align-items:center;padding:2px;margin-right:-11px;background:var(--uc-ai-floating, var(--uc-ai-background));border:1px solid transparent;border-radius:calc(var(--uc-ai-radius-button, 8px) + 2px);box-shadow:0 1px 8px #0000004d;cursor:pointer;transform:scale(1);transition:margin .3s var(--uc-ai-ease-out, ease),border-color 225ms ease,transform .27s var(--uc-ai-ease-out, ease),opacity .33s var(--uc-ai-ease-out, ease)}.chip:disabled{cursor:not-allowed}.chip:last-child{margin-right:0}@media(hover:hover)and (pointer:fine){.chip:hover:not(:disabled){transform:scale(1.1)}.strip:hover .chip:not(:disabled){margin-right:7px}.strip:hover .chip:not(:disabled):last-child{margin-right:0}}.chip--selected{border-color:var(--uc-ai-primary);transform:scale(1.2)}.thumb{position:relative;display:block;width:40px;height:40px;border-radius:var(--uc-ai-radius-button, 8px);background-color:var(--uc-ai-muted);overflow:hidden}.thumb:not(.thumb--loaded):after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(100deg,transparent 30%,color-mix(in srgb,var(--uc-ai-foreground) 9%,transparent) 50%,transparent 70%);transform:translate(-100%);animation:thumb-shimmer 1.2s ease-in-out infinite}@keyframes thumb-shimmer{to{transform:translate(100%)}}.thumb__img{display:block;width:100%;height:100%;object-fit:cover;opacity:0;transition:opacity .24s var(--uc-ai-ease-out, ease)}.thumb--loaded .thumb__img{opacity:1}@media(prefers-reduced-motion:reduce){.thumb:not(.thumb--loaded):after{animation:none}.thumb__img{transition:none}}.startover{position:absolute;right:calc(100% + 10px);top:50%;display:flex;align-items:center;background:var(--uc-ai-floating, var(--uc-ai-background));border:1px solid var(--uc-ai-floating-border, transparent);border-radius:calc(var(--uc-ai-radius-button, 8px) + 2px);box-shadow:var(--uc-ai-dialog-shadow);white-space:nowrap;opacity:0;transform:translateY(-50%) translate(-6px) scale(.95);transform-origin:right center;pointer-events:none;transition:opacity .26s var(--uc-ai-ease-out, ease),transform .26s var(--uc-ai-ease-out, ease)}.strip:hover .startover,.strip:focus-within .startover{opacity:1;transform:translateY(-50%) translate(0) scale(1);pointer-events:auto}.strip--empty .startover{position:static;opacity:1;transform:none;pointer-events:auto}.startover__btn{height:var(--uc-ai-button-size, 32px);padding:0 12px;background:transparent;border:0;border-radius:inherit;color:var(--uc-ai-foreground);font:inherit;font-size:13px;cursor:pointer}.startover__btn:disabled{cursor:not-allowed}.startover__btn:hover{background:var(--uc-ai-secondary)}.strip:before{content:"";position:absolute;right:100%;top:-12px;bottom:-12px;width:200px}.strip--empty:before{content:none}@media(prefers-reduced-motion:reduce){.chip,.startover{transition-property:opacity,border-color,margin}.chip:hover,.chip--selected{transform:scale(1)}.strip:not(.strip--empty) .startover,.strip:not(.strip--empty):hover .startover,.strip:not(.strip--empty):focus-within .startover{transform:translateY(-50%)}}';
|
|
1510
|
+
var rr = Object.defineProperty, sr = Object.getOwnPropertyDescriptor, z = (t, e, i, r) => {
|
|
1511
|
+
for (var s = r > 1 ? void 0 : r ? sr(e, i) : e, o = t.length - 1, a; o >= 0; o--)
|
|
1509
1512
|
(a = t[o]) && (s = (r ? a(e, i, s) : a(s)) || s);
|
|
1510
|
-
return r && s &&
|
|
1513
|
+
return r && s && rr(e, i, s), s;
|
|
1511
1514
|
};
|
|
1512
|
-
const
|
|
1515
|
+
const or = 80;
|
|
1513
1516
|
let U = class extends G {
|
|
1514
1517
|
constructor() {
|
|
1515
|
-
super(...arguments), this.entries = [], this.selectedUuid = null, this.showStartOver = !1, this.startOverLabel = "", this.listLabel = "Generation history", this.busy = !1, this._secure = new
|
|
1518
|
+
super(...arguments), this.entries = [], this.selectedUuid = null, this.showStartOver = !1, this.startOverLabel = "", this.listLabel = "Generation history", this.busy = !1, this._secure = new _t(this), this._loaded = /* @__PURE__ */ new Set();
|
|
1516
1519
|
}
|
|
1517
1520
|
willUpdate(t) {
|
|
1518
1521
|
if (t.has("secureResolver") && this._secure.setResolver(this.secureResolver), t.has("entries")) {
|
|
@@ -1534,7 +1537,7 @@ let U = class extends G {
|
|
|
1534
1537
|
}
|
|
1535
1538
|
render() {
|
|
1536
1539
|
const t = this.entries.length > 0;
|
|
1537
|
-
if (!t && !this.showStartOver) return f`${
|
|
1540
|
+
if (!t && !this.showStartOver) return f`${g}`;
|
|
1538
1541
|
const e = { strip: !0, "strip--empty": !t }, i = [...this.entries].reverse();
|
|
1539
1542
|
return f`
|
|
1540
1543
|
<div class=${S(e)} role="toolbar" aria-label="${this.listLabel}">
|
|
@@ -1544,12 +1547,12 @@ let U = class extends G {
|
|
|
1544
1547
|
${this.startOverLabel}
|
|
1545
1548
|
</button>
|
|
1546
1549
|
</div>
|
|
1547
|
-
` :
|
|
1548
|
-
${
|
|
1550
|
+
` : g}
|
|
1551
|
+
${xt(
|
|
1549
1552
|
i,
|
|
1550
1553
|
(r) => r.id,
|
|
1551
1554
|
(r) => {
|
|
1552
|
-
const s = this._secure.resolve(
|
|
1555
|
+
const s = this._secure.resolve(Ii(r.url, or)), o = this.selectedUuid != null && r.file.uuid === this.selectedUuid, a = this._loaded.has(r.id);
|
|
1553
1556
|
return f`
|
|
1554
1557
|
<button
|
|
1555
1558
|
type="button"
|
|
@@ -1559,7 +1562,7 @@ let U = class extends G {
|
|
|
1559
1562
|
aria-label=${r.prompt || "Result"}
|
|
1560
1563
|
title=${r.prompt}
|
|
1561
1564
|
@click=${() => this._select(r)}
|
|
1562
|
-
${
|
|
1565
|
+
${Qi({ keyframeOptions: { duration: 300, easing: "cubic-bezier(0.23, 1, 0.32, 1)" } })}
|
|
1563
1566
|
>
|
|
1564
1567
|
<span class=${S({ thumb: !0, "thumb--loaded": a })}>
|
|
1565
1568
|
${// Rendering the <img> preloads it; the skeleton shows until it
|
|
@@ -1572,7 +1575,7 @@ let U = class extends G {
|
|
|
1572
1575
|
decoding="async"
|
|
1573
1576
|
@load=${() => this._onThumbSettled(r.id)}
|
|
1574
1577
|
@error=${() => this._onThumbSettled(r.id)}
|
|
1575
|
-
/>` :
|
|
1578
|
+
/>` : g}
|
|
1576
1579
|
</span>
|
|
1577
1580
|
</button>
|
|
1578
1581
|
`;
|
|
@@ -1582,36 +1585,36 @@ let U = class extends G {
|
|
|
1582
1585
|
`;
|
|
1583
1586
|
}
|
|
1584
1587
|
};
|
|
1585
|
-
U.styles = j(
|
|
1586
|
-
|
|
1588
|
+
U.styles = j(ir);
|
|
1589
|
+
z([
|
|
1587
1590
|
c({ attribute: !1 })
|
|
1588
1591
|
], U.prototype, "entries", 2);
|
|
1589
|
-
|
|
1592
|
+
z([
|
|
1590
1593
|
c({ attribute: "selected-uuid" })
|
|
1591
1594
|
], U.prototype, "selectedUuid", 2);
|
|
1592
|
-
|
|
1595
|
+
z([
|
|
1593
1596
|
c({ type: Boolean, attribute: "show-start-over" })
|
|
1594
1597
|
], U.prototype, "showStartOver", 2);
|
|
1595
|
-
|
|
1598
|
+
z([
|
|
1596
1599
|
c({ attribute: "start-over-label" })
|
|
1597
1600
|
], U.prototype, "startOverLabel", 2);
|
|
1598
|
-
|
|
1601
|
+
z([
|
|
1599
1602
|
c({ attribute: "list-label" })
|
|
1600
1603
|
], U.prototype, "listLabel", 2);
|
|
1601
|
-
|
|
1604
|
+
z([
|
|
1602
1605
|
c({ type: Boolean })
|
|
1603
1606
|
], U.prototype, "busy", 2);
|
|
1604
|
-
|
|
1607
|
+
z([
|
|
1605
1608
|
c({ attribute: !1 })
|
|
1606
1609
|
], U.prototype, "secureResolver", 2);
|
|
1607
|
-
U =
|
|
1610
|
+
U = z([
|
|
1608
1611
|
H("uc-ai-history")
|
|
1609
1612
|
], U);
|
|
1610
|
-
const
|
|
1611
|
-
var
|
|
1612
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1613
|
+
const ar = ':host{display:block}.card{width:100%;box-sizing:border-box;background:color-mix(in srgb,var(--uc-ai-floating, var(--uc-ai-background)) 80%,transparent);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);border:1px solid var(--uc-ai-floating-border, transparent);border-radius:var(--uc-ai-composer-radius-top) var(--uc-ai-composer-radius-top) var(--uc-ai-composer-radius-bottom) var(--uc-ai-composer-radius-bottom);transition:border-radius .4s var(--uc-ai-ease-out),box-shadow .4s var(--uc-ai-ease-out);box-shadow:var(--uc-ai-composer-shadow);overflow:visible;--uc-ai-radius-button: max(0px, calc(var(--uc-ai-composer-radius) - var(--uc-ai-padding)))}.body{display:flex;flex-direction:column;gap:var(--uc-ai-padding);padding:var(--uc-ai-padding)}.input{box-sizing:border-box;width:100%;min-height:40px;max-height:var(--uc-ai-prompt-max-height, calc(var(--uc-ai-prompt-max-lines, 6) * 1.5em + 10px));resize:none;border:0;outline:none;padding:0 3px;background:transparent;font-family:inherit;font-size:var(--uc-ai-font-size);line-height:20px;color:var(--uc-ai-foreground);overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--uc-ai-border) transparent;transition:height .16s var(--uc-ai-ease-out, ease)}@supports (field-sizing: content){.input{field-sizing:content;transition:none}}.input::placeholder{color:var(--uc-ai-muted-foreground)}.input:disabled{color:var(--uc-ai-muted-foreground);-webkit-text-fill-color:var(--uc-ai-muted-foreground);cursor:not-allowed}.row{display:flex;align-items:center;gap:10px}.actions{flex:1;min-width:0;display:flex;align-items:center}.actions::slotted(*){min-width:0}.controls{display:flex;align-items:center;gap:0;flex:none}.send{margin-left:5px;width:var(--uc-ai-button-size, 32px);height:var(--uc-ai-button-size, 32px);flex:none;min-width:0;display:inline-flex;align-items:center;justify-content:center;position:relative;background:var(--uc-ai-primary);color:var(--uc-ai-primary-foreground);border:none;border-radius:var(--uc-ai-radius-button);cursor:pointer;overflow:hidden;transition:width .22s var(--uc-ai-ease-out, ease),margin-left .22s var(--uc-ai-ease-out, ease),opacity .15s var(--uc-ai-ease-out, ease),transform .15s var(--uc-ai-ease-out, ease),background var(--uc-ai-transition)}.send:hover:not(:disabled){background:var(--uc-ai-primary-hover)}.send:active:not(:disabled){transform:scale(.95)}.send:disabled{cursor:default}.send[hidden]{display:inline-flex;width:0;min-width:0;padding:0;margin-left:0;opacity:0;transform:scale(.8);pointer-events:none}.send__icon,.send__spinner{position:absolute;top:50%;left:50%;width:16px;height:16px;transition:opacity .2s var(--uc-ai-ease-out, ease),transform .2s var(--uc-ai-ease-out, ease),filter .2s var(--uc-ai-ease-out, ease)}.send__icon{opacity:1;transform:translate(-50%,-50%) scale(1);filter:blur(0)}.send__icon svg{width:16px;height:16px;display:block}.send__spinner{opacity:0;transform:translate(-50%,-50%) scale(.95);filter:blur(3px)}.send__spinner:before,.send__spinner:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:50%;border:1.5px solid currentColor}.send__spinner:before{opacity:.3}.send__spinner:after{border-top-color:transparent;animation:send-spin .7s linear infinite;will-change:transform}@keyframes send-spin{to{transform:rotate(360deg)}}.send--busy .send__icon{opacity:0;transform:translate(-50%,-50%) scale(.95);filter:blur(3px)}.send--busy .send__spinner{opacity:1;transform:translate(-50%,-50%) scale(1);filter:blur(0)}.send--busy:disabled{opacity:1}@media(prefers-reduced-motion:reduce){.input,.send{transition-property:opacity,background,width,margin-left}.send__icon,.send__spinner{transition-property:opacity}.send__spinner:after{animation:none}.send:active:not(:disabled){transform:none}}';
|
|
1614
|
+
var nr = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, D = (t, e, i, r) => {
|
|
1615
|
+
for (var s = r > 1 ? void 0 : r ? lr(e, i) : e, o = t.length - 1, a; o >= 0; o--)
|
|
1613
1616
|
(a = t[o]) && (s = (r ? a(e, i, s) : a(s)) || s);
|
|
1614
|
-
return r && s &&
|
|
1617
|
+
return r && s && nr(e, i, s), s;
|
|
1615
1618
|
};
|
|
1616
1619
|
let T = class extends G {
|
|
1617
1620
|
constructor() {
|
|
@@ -1666,7 +1669,7 @@ let T = class extends G {
|
|
|
1666
1669
|
@input=${this._onInput}
|
|
1667
1670
|
@keydown=${this._onKeydown}
|
|
1668
1671
|
?disabled=${this.busy}
|
|
1669
|
-
></textarea>` :
|
|
1672
|
+
></textarea>` : g}
|
|
1670
1673
|
|
|
1671
1674
|
<div class="row">
|
|
1672
1675
|
<div class="actions">
|
|
@@ -1682,7 +1685,7 @@ let T = class extends G {
|
|
|
1682
1685
|
?disabled=${this.busy || t}
|
|
1683
1686
|
@click=${this._emitSend}
|
|
1684
1687
|
>
|
|
1685
|
-
<span class="send__icon">${
|
|
1688
|
+
<span class="send__icon">${re(ji)}</span>
|
|
1686
1689
|
<span class="send__spinner" aria-hidden="true"></span>
|
|
1687
1690
|
</button>
|
|
1688
1691
|
</div>
|
|
@@ -1692,7 +1695,7 @@ let T = class extends G {
|
|
|
1692
1695
|
`;
|
|
1693
1696
|
}
|
|
1694
1697
|
};
|
|
1695
|
-
T.styles = j(
|
|
1698
|
+
T.styles = j(ar);
|
|
1696
1699
|
D([
|
|
1697
1700
|
c()
|
|
1698
1701
|
], T.prototype, "mode", 2);
|
|
@@ -1717,11 +1720,11 @@ D([
|
|
|
1717
1720
|
T = D([
|
|
1718
1721
|
H("uc-ai-prompt-row")
|
|
1719
1722
|
], T);
|
|
1720
|
-
const
|
|
1721
|
-
var
|
|
1722
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1723
|
+
const cr = ":host{display:block;min-width:0}.row{display:flex;flex-wrap:nowrap;align-items:center;gap:5px;overflow-x:auto;scrollbar-width:none}.row::-webkit-scrollbar{display:none}.row.fade-left.fade-right{-webkit-mask-image:linear-gradient(to right,transparent 0,#000 10px,#000 calc(100% - 10px),transparent 100%);mask-image:linear-gradient(to right,transparent 0,#000 10px,#000 calc(100% - 10px),transparent 100%)}.row.fade-left:not(.fade-right){-webkit-mask-image:linear-gradient(to right,transparent 0,#000 10px);mask-image:linear-gradient(to right,transparent 0,#000 10px)}.row.fade-right:not(.fade-left){-webkit-mask-image:linear-gradient(to right,#000 calc(100% - 10px),transparent 100%);mask-image:linear-gradient(to right,#000 calc(100% - 10px),transparent 100%)}.chip{flex:none;height:var(--uc-ai-button-size, 32px);display:inline-flex;align-items:center;justify-content:center;padding:0 10px;background:var(--uc-ai-secondary);border:0;border-radius:var(--uc-ai-radius-button);font-family:inherit;font-size:13px;line-height:20px;color:var(--uc-ai-secondary-foreground);cursor:pointer;white-space:nowrap;transition:background .15s ease,transform .14s var(--uc-ai-ease-out, ease)}@media(hover:hover)and (pointer:fine){.chip:hover{background:var(--uc-ai-secondary-hover)}}.chip:active{background:var(--uc-ai-secondary-hover);transform:scale(.97)}.chip:disabled{opacity:.5;cursor:not-allowed}@media(prefers-reduced-motion:reduce){.chip{transition-property:background}.chip:active{transform:none}}";
|
|
1724
|
+
var hr = Object.defineProperty, ur = Object.getOwnPropertyDescriptor, Y = (t, e, i, r) => {
|
|
1725
|
+
for (var s = r > 1 ? void 0 : r ? ur(e, i) : e, o = t.length - 1, a; o >= 0; o--)
|
|
1723
1726
|
(a = t[o]) && (s = (r ? a(e, i, s) : a(s)) || s);
|
|
1724
|
-
return r && s &&
|
|
1727
|
+
return r && s && hr(e, i, s), s;
|
|
1725
1728
|
};
|
|
1726
1729
|
let P = class extends G {
|
|
1727
1730
|
constructor() {
|
|
@@ -1760,7 +1763,7 @@ let P = class extends G {
|
|
|
1760
1763
|
);
|
|
1761
1764
|
}
|
|
1762
1765
|
render() {
|
|
1763
|
-
const t = this.presets ??
|
|
1766
|
+
const t = this.presets ?? ye[this.mode].presets;
|
|
1764
1767
|
return f`
|
|
1765
1768
|
<div
|
|
1766
1769
|
class="row"
|
|
@@ -1780,7 +1783,7 @@ let P = class extends G {
|
|
|
1780
1783
|
`;
|
|
1781
1784
|
}
|
|
1782
1785
|
};
|
|
1783
|
-
P.styles = j(
|
|
1786
|
+
P.styles = j(cr);
|
|
1784
1787
|
Y([
|
|
1785
1788
|
c()
|
|
1786
1789
|
], P.prototype, "mode", 2);
|
|
@@ -1803,7 +1806,7 @@ function N(t, e) {
|
|
|
1803
1806
|
if (t === null) throw new Error(`DotGrid GL: failed to create ${e} (context lost?)`);
|
|
1804
1807
|
return t;
|
|
1805
1808
|
}
|
|
1806
|
-
const
|
|
1809
|
+
const xe = 8, dr = `#version 300 es
|
|
1807
1810
|
precision highp float;
|
|
1808
1811
|
precision highp int;
|
|
1809
1812
|
in vec2 aCorner; // unit quad corner, -0.5..0.5
|
|
@@ -1822,7 +1825,7 @@ uniform float uMinScale;
|
|
|
1822
1825
|
uniform float uPeakScale;
|
|
1823
1826
|
uniform float uIdleScale;
|
|
1824
1827
|
uniform int uEpiCount;
|
|
1825
|
-
uniform vec2 uEpis[${
|
|
1828
|
+
uniform vec2 uEpis[${xe}];
|
|
1826
1829
|
uniform float uEpiRadius;
|
|
1827
1830
|
uniform float uEpiFalloff;
|
|
1828
1831
|
uniform float uColorA;
|
|
@@ -1839,7 +1842,7 @@ float epiIntensity(vec2 p) {
|
|
|
1839
1842
|
// Low-frequency warp of the distance field — dissolves ring banding.
|
|
1840
1843
|
float k = uFalloffWarp > 0.0 ? (6.2831853 / (uEpiRadius * 0.7)) : 0.0;
|
|
1841
1844
|
float warp = k > 0.0 ? uFalloffWarp * uEpiRadius * sin(p.x * k + 1.3) * cos(p.y * k * 0.9) : 0.0;
|
|
1842
|
-
for (int i = 0; i < ${
|
|
1845
|
+
for (int i = 0; i < ${xe}; i++) {
|
|
1843
1846
|
if (i >= uEpiCount) break;
|
|
1844
1847
|
float d = max(0.0, distance(p, uEpis[i]) + warp);
|
|
1845
1848
|
if (d >= uEpiRadius) continue;
|
|
@@ -1900,7 +1903,7 @@ void main() {
|
|
|
1900
1903
|
gl_Position = vec4(ndc.x, -ndc.y, 0.0, 1.0);
|
|
1901
1904
|
|
|
1902
1905
|
vAlpha = (uMask == 1) ? 1.0 : uColorA;
|
|
1903
|
-
}`,
|
|
1906
|
+
}`, pr = `#version 300 es
|
|
1904
1907
|
precision highp float;
|
|
1905
1908
|
precision highp int;
|
|
1906
1909
|
in float vAlpha;
|
|
@@ -1919,7 +1922,7 @@ void main() {
|
|
|
1919
1922
|
float cov = clamp(0.5 - sd / aaw, 0.0, 1.0);
|
|
1920
1923
|
vec3 rgb = (uMask == 1) ? vec3(1.0) : uColorRGB;
|
|
1921
1924
|
frag = vec4(rgb * vAlpha * cov, vAlpha * cov); // premultiplied
|
|
1922
|
-
}`,
|
|
1925
|
+
}`, fr = `#version 300 es
|
|
1923
1926
|
precision highp float;
|
|
1924
1927
|
in vec2 aQuad; // 0..1
|
|
1925
1928
|
uniform vec2 uResolution;
|
|
@@ -1930,7 +1933,7 @@ void main() {
|
|
|
1930
1933
|
vFramePx = px - uFrame.xy;
|
|
1931
1934
|
vec2 ndc = (px / uResolution) * 2.0 - 1.0;
|
|
1932
1935
|
gl_Position = vec4(ndc.x, -ndc.y, 0.0, 1.0);
|
|
1933
|
-
}`,
|
|
1936
|
+
}`, mr = `#version 300 es
|
|
1934
1937
|
precision highp float;
|
|
1935
1938
|
in vec2 vFramePx;
|
|
1936
1939
|
uniform sampler2D uImage;
|
|
@@ -1945,9 +1948,9 @@ void main() {
|
|
|
1945
1948
|
vec2 uv = (vFramePx - off) / dsz;
|
|
1946
1949
|
frag = vec4(texture(uImage, uv).rgb, 1.0);
|
|
1947
1950
|
}`;
|
|
1948
|
-
class
|
|
1951
|
+
class Ae {
|
|
1949
1952
|
constructor(e) {
|
|
1950
|
-
this._dotUniforms = {}, this._imgUniforms = {}, this._appliedW = 0, this._appliedH = 0, this._appliedScale = 0, this._texImage = null, this._texOk = !1, this._gl = e, this._dotProgram = this._link(
|
|
1953
|
+
this._dotUniforms = {}, this._imgUniforms = {}, this._appliedW = 0, this._appliedH = 0, this._appliedScale = 0, this._texImage = null, this._texOk = !1, this._gl = e, this._dotProgram = this._link(dr, pr), this._imgProgram = this._link(fr, mr), this._cornerBuf = this._staticBuffer([-0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5]), this._quadBuf = this._staticBuffer([0, 0, 1, 0, 0, 1, 1, 1]), this._clipBuf = N(e.createBuffer(), "buffer"), this._dotVao = N(e.createVertexArray(), "vertex array"), e.bindVertexArray(this._dotVao);
|
|
1951
1954
|
const i = e.getAttribLocation(this._dotProgram, "aCorner");
|
|
1952
1955
|
e.bindBuffer(e.ARRAY_BUFFER, this._cornerBuf), e.enableVertexAttribArray(i), e.vertexAttribPointer(i, 2, e.FLOAT, !1, 0, 0);
|
|
1953
1956
|
const r = e.getAttribLocation(this._dotProgram, "aClip");
|
|
@@ -1997,7 +2000,7 @@ class $e {
|
|
|
1997
2000
|
}
|
|
1998
2001
|
if (!i) return null;
|
|
1999
2002
|
try {
|
|
2000
|
-
return new
|
|
2003
|
+
return new Ae(i);
|
|
2001
2004
|
} catch (r) {
|
|
2002
2005
|
return typeof console < "u" && console.warn("[dot-grid] WebGL init failed, using 2D:", r), null;
|
|
2003
2006
|
}
|
|
@@ -2030,7 +2033,7 @@ class $e {
|
|
|
2030
2033
|
}
|
|
2031
2034
|
i.bindBuffer(i.ARRAY_BUFFER, this._clipBuf), i.bufferData(i.ARRAY_BUFFER, e.clip, i.DYNAMIC_DRAW), i.enable(i.BLEND), i.blendFunc(i.ONE, i.ONE_MINUS_SRC_ALPHA), i.useProgram(this._dotProgram), i.bindVertexArray(this._dotVao);
|
|
2032
2035
|
const s = this._dotUniforms;
|
|
2033
|
-
if (i.uniform2f(s.uResolution, e.cssW, e.cssH), i.uniform1f(s.uCols, e.cols), i.uniform2f(s.uOffset, e.offsetX, e.offsetY), i.uniform1f(s.uCell, e.cell), i.uniform1f(s.uBaseRadius, e.baseRadius), i.uniform1f(s.uFullHalf, e.fullHalf), i.uniform1f(s.uEnv, e.env), i.uniform1f(s.uShimMix, e.shimMix), i.uniform1i(s.uMask, e.mask ? 1 : 0), i.uniform1i(s.uGenerating, e.generating ? 1 : 0), i.uniform1f(s.uMinScale, e.minScale), i.uniform1f(s.uPeakScale, e.peakScale), i.uniform1f(s.uIdleScale, e.idleScale), i.uniform1i(s.uEpiCount, Math.min(e.epiCount,
|
|
2036
|
+
if (i.uniform2f(s.uResolution, e.cssW, e.cssH), i.uniform1f(s.uCols, e.cols), i.uniform2f(s.uOffset, e.offsetX, e.offsetY), i.uniform1f(s.uCell, e.cell), i.uniform1f(s.uBaseRadius, e.baseRadius), i.uniform1f(s.uFullHalf, e.fullHalf), i.uniform1f(s.uEnv, e.env), i.uniform1f(s.uShimMix, e.shimMix), i.uniform1i(s.uMask, e.mask ? 1 : 0), i.uniform1i(s.uGenerating, e.generating ? 1 : 0), i.uniform1f(s.uMinScale, e.minScale), i.uniform1f(s.uPeakScale, e.peakScale), i.uniform1f(s.uIdleScale, e.idleScale), i.uniform1i(s.uEpiCount, Math.min(e.epiCount, xe)), i.uniform2fv(s.uEpis, e.epis), i.uniform1f(s.uEpiRadius, e.epiRadius), i.uniform1f(s.uEpiFalloff, e.epiFalloff), i.uniform1f(s.uColorA, e.color[3]), i.uniform3f(s.uColorRGB, e.color[0], e.color[1], e.color[2]), i.uniform1f(s.uFalloffWarp, e.falloffWarp), i.uniform1f(s.uDither, e.dither), i.drawArraysInstanced(i.TRIANGLE_STRIP, 0, 4, r), e.mask && this._texOk && this._texImage) {
|
|
2034
2037
|
i.blendFunc(i.DST_ALPHA, i.ZERO), i.useProgram(this._imgProgram), i.bindVertexArray(this._imgVao);
|
|
2035
2038
|
const o = this._imgUniforms;
|
|
2036
2039
|
i.uniform2f(o.uResolution, e.cssW, e.cssH), i.uniform4f(o.uFrame, e.frameLeft, e.frameTop, e.frameRight, e.frameBottom), i.uniform2f(o.uFrameSize, e.frameRight - e.frameLeft, e.frameBottom - e.frameTop), i.uniform2f(o.uImageSize, this._texImage.naturalWidth, this._texImage.naturalHeight), i.activeTexture(i.TEXTURE0), i.bindTexture(i.TEXTURE_2D, this._texture), i.uniform1i(o.uImage, 0), i.drawArrays(i.TRIANGLE_STRIP, 0, 4);
|
|
@@ -2068,7 +2071,7 @@ class $e {
|
|
|
2068
2071
|
return s;
|
|
2069
2072
|
}
|
|
2070
2073
|
}
|
|
2071
|
-
const
|
|
2074
|
+
const _r = 1200, gr = 800, vr = 1.5, rt = (t) => 1 - (1 - t) ** 3, br = {
|
|
2072
2075
|
cellSize: 6,
|
|
2073
2076
|
dotRatio: 0.46,
|
|
2074
2077
|
sizeScale: 1,
|
|
@@ -2089,19 +2092,19 @@ const pr = 1200, fr = 800, mr = 1.5, tt = (t) => 1 - (1 - t) ** 3, _r = {
|
|
|
2089
2092
|
shimEnterMs: 450,
|
|
2090
2093
|
shimExitMs: 450
|
|
2091
2094
|
};
|
|
2092
|
-
class
|
|
2095
|
+
class yr {
|
|
2093
2096
|
constructor(e, i) {
|
|
2094
|
-
this._refs = null, this._ctx = null, this._gl = null, this._glImageEl = null, this._glImageReady = !1, this._cfg = { ...
|
|
2097
|
+
this._refs = null, this._ctx = null, this._gl = null, this._glImageEl = null, this._glImageReady = !1, this._cfg = { ...br }, this._sizeMul = 1, this._dotColor = "rgba(0, 0, 0, 0.16)", this._dotColorRGBA = [0, 0, 0, 0.16], this._w = 0, this._h = 0, this._cols = 0, this._rows = 0, this._offsetX = 0, this._offsetY = 0, this._epiRadius = 1, this._appliedScale = 0, this._clip = new Float32Array(0), this._env = 0, this._envFrom = 0, this._envTo = 0, this._envStart = 0, this._envDur = 0, this._envAnimating = !1, this._shimMix = 0, this._shimFrom = 0, this._shimTo = 0, this._shimStart = 0, this._shimDur = 0, this._shimAnimating = !1, this._exitPending = !1, this._prevShim = !1, this._opacityManual = !1, this._hiddenImage = null, this._rafId = null, this._lastTime = 0, this._state = { shimmering: !1, empty: !0, generating: !1 }, this._epis = [], this._onThemeChange = () => {
|
|
2095
2098
|
this.refreshColor();
|
|
2096
2099
|
}, this._rectCache = null, this._glEpis = new Float32Array(16), this._tick = (r) => {
|
|
2097
2100
|
const s = this._lastTime ? Math.min(64, r - this._lastTime) : 16;
|
|
2098
2101
|
if (this._lastTime = r, this._rectCache = this._frameRect(), this._envAnimating) {
|
|
2099
2102
|
const a = Math.min(1, (r - this._envStart) / this._envDur);
|
|
2100
|
-
this._env = this._envFrom + (this._envTo - this._envFrom) *
|
|
2103
|
+
this._env = this._envFrom + (this._envTo - this._envFrom) * rt(a), a >= 1 && (this._env = this._envTo, this._envAnimating = !1);
|
|
2101
2104
|
}
|
|
2102
2105
|
if (this._shimAnimating) {
|
|
2103
2106
|
const a = Math.min(1, (r - this._shimStart) / this._shimDur);
|
|
2104
|
-
this._shimMix = this._shimFrom + (this._shimTo - this._shimFrom) *
|
|
2107
|
+
this._shimMix = this._shimFrom + (this._shimTo - this._shimFrom) * rt(a), a >= 1 && (this._shimMix = this._shimTo, this._shimAnimating = !1);
|
|
2105
2108
|
}
|
|
2106
2109
|
this._state.generating && !this._reduceMotion && this._moveEpicenters(s);
|
|
2107
2110
|
const o = this._followFrame(s);
|
|
@@ -2121,11 +2124,11 @@ class gr {
|
|
|
2121
2124
|
* proportional, >1 exaggerates, <0 inverts). Always positive, so it never
|
|
2122
2125
|
* produces a negative radius/speed however far it's pushed. */
|
|
2123
2126
|
_computeSizeMul() {
|
|
2124
|
-
return this._w <= 0 || this._h <= 0 ? 1 : Math.sqrt(this._w * this._h / (
|
|
2127
|
+
return this._w <= 0 || this._h <= 0 ? 1 : Math.sqrt(this._w * this._h / (_r * gr)) ** this._cfg.sizeScale;
|
|
2125
2128
|
}
|
|
2126
2129
|
/** Wire the painter to the canvas's rendered elements. */
|
|
2127
2130
|
attach(e) {
|
|
2128
|
-
if (this._refs = e, this._cfg.useWebgl !== !1 && (this._gl =
|
|
2131
|
+
if (this._refs = e, this._cfg.useWebgl !== !1 && (this._gl = Ae.create(e.surface)), this._gl || (this._ctx = e.surface.getContext("2d")), !!this._canDraw) {
|
|
2129
2132
|
if (this._readDotColor(), typeof ResizeObserver == "function" && (this._resizeObserver = new ResizeObserver(() => {
|
|
2130
2133
|
this._resize(), this.sync(this._state);
|
|
2131
2134
|
}), this._resizeObserver.observe(e.viewport), this._frameObserver = new ResizeObserver(() => this._ensureLoop()), this._frameObserver.observe(e.frame)), typeof window < "u" && typeof window.matchMedia == "function" && (this._schemeMql = window.matchMedia("(prefers-color-scheme: dark)"), this._schemeMql.addEventListener("change", this._onThemeChange)), typeof MutationObserver == "function" && typeof document < "u") {
|
|
@@ -2279,7 +2282,7 @@ class gr {
|
|
|
2279
2282
|
* {@link MAX_ANIMATED_DPR} so per-frame raster stays cheap on hi-dpi. */
|
|
2280
2283
|
_scale(e = !1) {
|
|
2281
2284
|
const i = Math.min(window.devicePixelRatio || 1, this._cfg.maxDpr);
|
|
2282
|
-
return e ? Math.min(i,
|
|
2285
|
+
return e ? Math.min(i, vr) : i;
|
|
2283
2286
|
}
|
|
2284
2287
|
/** Size the backing store to `scale`× the viewport. Note: setting width/height
|
|
2285
2288
|
* clears the canvas and resets the context, so the transform is re-applied. */
|
|
@@ -2393,13 +2396,13 @@ class gr {
|
|
|
2393
2396
|
const x = this._offsetX + u * o;
|
|
2394
2397
|
let w;
|
|
2395
2398
|
if (i) {
|
|
2396
|
-
const R = this._reduceMotion ? 1 : this._state.generating ? this._shimmerScale(u, h, x, p) : this._cfg.minScale,
|
|
2397
|
-
w = (a + this._env * (
|
|
2399
|
+
const R = this._reduceMotion ? 1 : this._state.generating ? this._shimmerScale(u, h, x, p) : this._cfg.minScale, O = this._baseRadius * R;
|
|
2400
|
+
w = (a + this._env * (O - a)) * _;
|
|
2398
2401
|
} else {
|
|
2399
2402
|
let R = this._staticScale();
|
|
2400
2403
|
if (!this._reduceMotion && this._shimMix > 0) {
|
|
2401
|
-
const
|
|
2402
|
-
R += (
|
|
2404
|
+
const O = this._shimmerScale(u, h, x, p);
|
|
2405
|
+
R += (O - R) * this._shimMix;
|
|
2403
2406
|
}
|
|
2404
2407
|
w = this._baseRadius * R * _;
|
|
2405
2408
|
}
|
|
@@ -2467,16 +2470,16 @@ class gr {
|
|
|
2467
2470
|
this._exitPending && this._hasImage() && (this._exitPending = !1, this._env = 1, this._startEnv(0, this._cfg.exitMs));
|
|
2468
2471
|
}
|
|
2469
2472
|
}
|
|
2470
|
-
const
|
|
2471
|
-
var
|
|
2472
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
2473
|
+
const wr = ":host{display:block;width:100%;height:100%;container-type:inline-size}.canvas{position:relative;width:100%;height:100%;min-height:240px;overflow:hidden}.canvas__bg{position:absolute;top:0;right:0;bottom:0;left:0;background:var(--uc-ai-background)}.canvas__viewport{position:absolute;top:20px;right:20px;bottom:20px;left:20px;display:grid;place-items:center;pointer-events:none}.canvas__frame{position:relative;overflow:hidden}.canvas.is-ready .canvas__frame{transition:width .46s var(--uc-ai-ease-in-out, ease),height .46s var(--uc-ai-ease-in-out, ease)}.canvas__image{position:relative;z-index:1;width:100%;height:100%;display:block;object-fit:cover;transition:opacity .3s var(--uc-ai-ease-out, ease)}.canvas__under{position:absolute;top:0;right:0;bottom:0;left:0;z-index:0;width:100%;height:100%;display:block;object-fit:cover}.dot-grid{position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none;opacity:0;color:var(--uc-ai-dot-grid-color, color-mix(in srgb, currentColor 15%, transparent));transition:opacity .2s ease}.canvas.is-empty .dot-grid,.canvas.is-loading .dot-grid{opacity:1}.preload{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}.layer.full{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;object-fit:contain;z-index:4}.fullscreen-btn{position:absolute;top:12px;right:12px;z-index:5;display:grid;place-items:center;width:var(--uc-ai-button-size, 32px);height:var(--uc-ai-button-size, 32px);padding:0;border:0;border-radius:var(--uc-ai-radius-button, 8px);background:color-mix(in oklch,var(--uc-ai-background) 75%,transparent);backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);color:var(--uc-ai-foreground);cursor:pointer;opacity:0;transition:opacity var(--uc-ai-transition, .2s ease),background var(--uc-ai-transition, .2s ease)}.fullscreen-btn svg{width:18px;height:18px}.canvas:hover .fullscreen-btn,.fullscreen-btn:focus-visible{opacity:1}.fullscreen-btn:hover{background:var(--uc-ai-background)}@media(hover:none){.fullscreen-btn{opacity:1}}.canvas:fullscreen{background:#000}.canvas:fullscreen .canvas__bg{background:#000}.error-state{position:absolute;top:0;right:0;bottom:0;left:0;display:grid;place-items:center;padding:16px;text-align:center;color:var(--uc-ai-muted-foreground);font-size:.875em;z-index:3}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media(prefers-reduced-motion:reduce){.canvas__viewport,.canvas__frame,.canvas__image,.fullscreen-btn{transition:none}}";
|
|
2474
|
+
var xr = Object.defineProperty, Er = Object.getOwnPropertyDescriptor, y = (t, e, i, r) => {
|
|
2475
|
+
for (var s = r > 1 ? void 0 : r ? Er(e, i) : e, o = t.length - 1, a; o >= 0; o--)
|
|
2473
2476
|
(a = t[o]) && (s = (r ? a(e, i, s) : a(s)) || s);
|
|
2474
|
-
return r && s &&
|
|
2477
|
+
return r && s && xr(e, i, s), s;
|
|
2475
2478
|
};
|
|
2476
|
-
const
|
|
2477
|
-
let
|
|
2479
|
+
const kr = 3 / 2, Rr = 70;
|
|
2480
|
+
let v = class extends G {
|
|
2478
2481
|
constructor() {
|
|
2479
|
-
super(...arguments), this.url = null, this.ratio = null, this.naturalRatio = null, this.busy = !1, this.alt = "", this.busyLabel = "", this.errorLabel = "", this.fullscreenLabel = "", this.exitFullscreenLabel = "", this.fullsizeUrl = null, this._displayedUrl = null, this._fadingUrl = null, this._failed = !1, this._frameReady = !1, this._fullscreen = !1, this._dotGrid = new
|
|
2482
|
+
super(...arguments), this.url = null, this.ratio = null, this.naturalRatio = null, this.busy = !1, this.alt = "", this.busyLabel = "", this.errorLabel = "", this.fullscreenLabel = "", this.exitFullscreenLabel = "", this.fullsizeUrl = null, this._displayedUrl = null, this._fadingUrl = null, this._failed = !1, this._frameReady = !1, this._fullscreen = !1, this._dotGrid = new yr(this), this._switchCovering = !1, this._seenUrls = /* @__PURE__ */ new Set(), this._instantSwap = !1, this._onVisibilityChange = () => {
|
|
2480
2483
|
document.visibilityState !== "visible" || this.busy || !this._displayedUrl || (this._clearCoverTimer(), this._switchCovering = !1, this._dotGrid.settle());
|
|
2481
2484
|
}, this._preloadedFullsizeUrl = null, this._onFullscreenKeydown = (t) => {
|
|
2482
2485
|
t.key === "Escape" && document.fullscreenElement && (t.preventDefault(), t.stopPropagation(), document.exitFullscreen());
|
|
@@ -2540,7 +2543,7 @@ let g = class extends G {
|
|
|
2540
2543
|
}
|
|
2541
2544
|
this._instantSwap = !1, !(this._switchCovering || this._coverTimer != null) && (this._coverTimer = window.setTimeout(() => {
|
|
2542
2545
|
this._coverTimer = void 0, this.url != null && this.url !== this._displayedUrl && !this._failed && !this.busy && !this._switchCovering && (this._switchCovering = !0, this._syncGrid());
|
|
2543
|
-
},
|
|
2546
|
+
}, Rr));
|
|
2544
2547
|
}
|
|
2545
2548
|
_clearCoverTimer() {
|
|
2546
2549
|
this._coverTimer != null && (clearTimeout(this._coverTimer), this._coverTimer = void 0);
|
|
@@ -2553,7 +2556,7 @@ let g = class extends G {
|
|
|
2553
2556
|
if (this.ratio && this.ratio > 0) return this.ratio;
|
|
2554
2557
|
if (this.naturalRatio && this.naturalRatio > 0) return this.naturalRatio;
|
|
2555
2558
|
const t = this._imageEl;
|
|
2556
|
-
return t && t.naturalWidth > 0 && t.naturalHeight > 0 ? t.naturalWidth / t.naturalHeight :
|
|
2559
|
+
return t && t.naturalWidth > 0 && t.naturalHeight > 0 ? t.naturalWidth / t.naturalHeight : kr;
|
|
2557
2560
|
}
|
|
2558
2561
|
/** Size the frame to the largest box of the chosen ratio that fits the viewport. */
|
|
2559
2562
|
_updateFrame() {
|
|
@@ -2614,7 +2617,7 @@ let g = class extends G {
|
|
|
2614
2617
|
${// Previous image held underneath during an instant (cached) swap so
|
|
2615
2618
|
// the frame never blanks for the frame it takes the new <img> to
|
|
2616
2619
|
// paint; dropped on the new image's load.
|
|
2617
|
-
this._fadingUrl ? f`<img class="canvas__under" src="${this._fadingUrl}" alt="" aria-hidden="true" crossorigin="anonymous" />` :
|
|
2620
|
+
this._fadingUrl ? f`<img class="canvas__under" src="${this._fadingUrl}" alt="" aria-hidden="true" crossorigin="anonymous" />` : g}
|
|
2618
2621
|
${this._displayedUrl ? f`<img
|
|
2619
2622
|
class="canvas__image"
|
|
2620
2623
|
src="${this._displayedUrl}"
|
|
@@ -2622,24 +2625,24 @@ let g = class extends G {
|
|
|
2622
2625
|
decoding="async"
|
|
2623
2626
|
crossorigin="anonymous"
|
|
2624
2627
|
@load=${this._onDisplayedLoad}
|
|
2625
|
-
/>` :
|
|
2628
|
+
/>` : g}
|
|
2626
2629
|
</div>
|
|
2627
2630
|
<canvas class="dot-grid" aria-hidden="true"></canvas>
|
|
2628
2631
|
</div>
|
|
2629
2632
|
|
|
2630
2633
|
${// Full-quality rendition overlays the preview while fullscreen.
|
|
2631
|
-
this._fullscreen && this.fullsizeUrl ? f`<img class="layer full" src="${this.fullsizeUrl}" alt="${this.alt || "AI image"}" decoding="async" />` :
|
|
2634
|
+
this._fullscreen && this.fullsizeUrl ? f`<img class="layer full" src="${this.fullsizeUrl}" alt="${this.alt || "AI image"}" decoding="async" />` : g}
|
|
2632
2635
|
${t ? f`<img
|
|
2633
2636
|
class="preload"
|
|
2634
|
-
src="${
|
|
2637
|
+
src="${Et(this.url ?? void 0)}"
|
|
2635
2638
|
alt=""
|
|
2636
2639
|
aria-hidden="true"
|
|
2637
2640
|
decoding="async"
|
|
2638
2641
|
crossorigin="anonymous"
|
|
2639
2642
|
@load=${this._onLoaded}
|
|
2640
2643
|
@error=${this._onError}
|
|
2641
|
-
/>` :
|
|
2642
|
-
${this._failed ? f`<div class="error-state" role="alert">${this.errorLabel || "Failed to load image"}</div>` :
|
|
2644
|
+
/>` : g}
|
|
2645
|
+
${this._failed ? f`<div class="error-state" role="alert">${this.errorLabel || "Failed to load image"}</div>` : g}
|
|
2643
2646
|
${i ? f`
|
|
2644
2647
|
<button
|
|
2645
2648
|
type="button"
|
|
@@ -2650,86 +2653,86 @@ let g = class extends G {
|
|
|
2650
2653
|
@focus=${this._preloadFullsize}
|
|
2651
2654
|
@click=${this._toggleFullscreen}
|
|
2652
2655
|
>
|
|
2653
|
-
${
|
|
2656
|
+
${re(this._fullscreen ? Wi : Hi)}
|
|
2654
2657
|
</button>
|
|
2655
|
-
` :
|
|
2658
|
+
` : g}
|
|
2656
2659
|
<span class="sr-only" role="status" aria-live="polite">${this.busy ? this.busyLabel : ""}</span>
|
|
2657
2660
|
</div>
|
|
2658
2661
|
`;
|
|
2659
2662
|
}
|
|
2660
2663
|
};
|
|
2661
|
-
|
|
2664
|
+
v.styles = j(wr);
|
|
2662
2665
|
y([
|
|
2663
2666
|
c()
|
|
2664
|
-
],
|
|
2667
|
+
], v.prototype, "url", 2);
|
|
2665
2668
|
y([
|
|
2666
2669
|
c({ type: Number })
|
|
2667
|
-
],
|
|
2670
|
+
], v.prototype, "ratio", 2);
|
|
2668
2671
|
y([
|
|
2669
2672
|
c({ type: Number, attribute: "natural-ratio" })
|
|
2670
|
-
],
|
|
2673
|
+
], v.prototype, "naturalRatio", 2);
|
|
2671
2674
|
y([
|
|
2672
2675
|
c({ type: Boolean })
|
|
2673
|
-
],
|
|
2676
|
+
], v.prototype, "busy", 2);
|
|
2674
2677
|
y([
|
|
2675
2678
|
c()
|
|
2676
|
-
],
|
|
2679
|
+
], v.prototype, "alt", 2);
|
|
2677
2680
|
y([
|
|
2678
2681
|
c({ attribute: "busy-label" })
|
|
2679
|
-
],
|
|
2682
|
+
], v.prototype, "busyLabel", 2);
|
|
2680
2683
|
y([
|
|
2681
2684
|
c({ attribute: "error-label" })
|
|
2682
|
-
],
|
|
2685
|
+
], v.prototype, "errorLabel", 2);
|
|
2683
2686
|
y([
|
|
2684
2687
|
c({ attribute: "fullscreen-label" })
|
|
2685
|
-
],
|
|
2688
|
+
], v.prototype, "fullscreenLabel", 2);
|
|
2686
2689
|
y([
|
|
2687
2690
|
c({ attribute: "exit-fullscreen-label" })
|
|
2688
|
-
],
|
|
2691
|
+
], v.prototype, "exitFullscreenLabel", 2);
|
|
2689
2692
|
y([
|
|
2690
2693
|
c({ attribute: "fullsize-url" })
|
|
2691
|
-
],
|
|
2694
|
+
], v.prototype, "fullsizeUrl", 2);
|
|
2692
2695
|
y([
|
|
2693
2696
|
c({ attribute: !1 })
|
|
2694
|
-
],
|
|
2697
|
+
], v.prototype, "shimmerConfig", 2);
|
|
2695
2698
|
y([
|
|
2696
2699
|
C()
|
|
2697
|
-
],
|
|
2700
|
+
], v.prototype, "_displayedUrl", 2);
|
|
2698
2701
|
y([
|
|
2699
2702
|
C()
|
|
2700
|
-
],
|
|
2703
|
+
], v.prototype, "_fadingUrl", 2);
|
|
2701
2704
|
y([
|
|
2702
2705
|
C()
|
|
2703
|
-
],
|
|
2706
|
+
], v.prototype, "_failed", 2);
|
|
2704
2707
|
y([
|
|
2705
2708
|
C()
|
|
2706
|
-
],
|
|
2709
|
+
], v.prototype, "_frameReady", 2);
|
|
2707
2710
|
y([
|
|
2708
2711
|
C()
|
|
2709
|
-
],
|
|
2712
|
+
], v.prototype, "_fullscreen", 2);
|
|
2710
2713
|
y([
|
|
2711
2714
|
F(".canvas")
|
|
2712
|
-
],
|
|
2715
|
+
], v.prototype, "_canvasEl", 2);
|
|
2713
2716
|
y([
|
|
2714
2717
|
F(".canvas__viewport")
|
|
2715
|
-
],
|
|
2718
|
+
], v.prototype, "_viewportEl", 2);
|
|
2716
2719
|
y([
|
|
2717
2720
|
F(".canvas__frame")
|
|
2718
|
-
],
|
|
2721
|
+
], v.prototype, "_frameEl", 2);
|
|
2719
2722
|
y([
|
|
2720
2723
|
F(".canvas__image")
|
|
2721
|
-
],
|
|
2724
|
+
], v.prototype, "_imageEl", 2);
|
|
2722
2725
|
y([
|
|
2723
2726
|
F(".dot-grid")
|
|
2724
|
-
],
|
|
2725
|
-
|
|
2727
|
+
], v.prototype, "_dotGridEl", 2);
|
|
2728
|
+
v = y([
|
|
2726
2729
|
H("uc-ai-canvas")
|
|
2727
|
-
],
|
|
2728
|
-
const
|
|
2729
|
-
var
|
|
2730
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
2730
|
+
], v);
|
|
2731
|
+
const Sr = ":host{display:block;container-type:inline-size}.footer{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:var(--uc-ai-padding);background:transparent}.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:var(--uc-ai-button-size);padding:0 14px;border:0;border-radius:var(--uc-ai-radius-button);font-family:inherit;font-size:14px;font-weight:500;cursor:pointer;transition:background .15s ease,filter .15s ease,transform .14s var(--uc-ai-ease-out, ease)}.btn:active{transform:scale(.97)}.btn--ghost{background:var(--uc-ai-secondary);color:var(--uc-ai-secondary-foreground)}.btn--primary{background:var(--uc-ai-primary);color:var(--uc-ai-primary-foreground)}@media(hover:hover)and (pointer:fine){.btn--ghost:hover{background:var(--uc-ai-secondary-hover)}.btn--primary:hover{background:var(--uc-ai-primary-hover)}}.btn--primary:disabled{opacity:.5;cursor:not-allowed;background:var(--uc-ai-primary)}.btn svg{width:14px;height:14px}@media(prefers-reduced-motion:reduce){.btn{transition-property:background,filter}.btn:active{transform:none}}";
|
|
2732
|
+
var Cr = Object.defineProperty, $r = Object.getOwnPropertyDescriptor, ae = (t, e, i, r) => {
|
|
2733
|
+
for (var s = r > 1 ? void 0 : r ? $r(e, i) : e, o = t.length - 1, a; o >= 0; o--)
|
|
2731
2734
|
(a = t[o]) && (s = (r ? a(e, i, s) : a(s)) || s);
|
|
2732
|
-
return r && s &&
|
|
2735
|
+
return r && s && Cr(e, i, s), s;
|
|
2733
2736
|
};
|
|
2734
2737
|
let K = class extends G {
|
|
2735
2738
|
constructor() {
|
|
@@ -2759,26 +2762,26 @@ let K = class extends G {
|
|
|
2759
2762
|
`;
|
|
2760
2763
|
}
|
|
2761
2764
|
};
|
|
2762
|
-
K.styles = j(
|
|
2763
|
-
|
|
2765
|
+
K.styles = j(Sr);
|
|
2766
|
+
ae([
|
|
2764
2767
|
c({ attribute: "cancel-label" })
|
|
2765
2768
|
], K.prototype, "cancelLabel", 2);
|
|
2766
|
-
|
|
2769
|
+
ae([
|
|
2767
2770
|
c({ attribute: "primary-label" })
|
|
2768
2771
|
], K.prototype, "primaryLabel", 2);
|
|
2769
|
-
|
|
2772
|
+
ae([
|
|
2770
2773
|
c({ type: Boolean, attribute: "primary-disabled" })
|
|
2771
2774
|
], K.prototype, "primaryDisabled", 2);
|
|
2772
|
-
K =
|
|
2775
|
+
K = ae([
|
|
2773
2776
|
H("uc-ai-footer")
|
|
2774
2777
|
], K);
|
|
2775
|
-
const
|
|
2776
|
-
var
|
|
2777
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
2778
|
+
const Ar = ":host{--uc-ai-foreground: light-dark(#181818, #e1e1e1);--uc-ai-background: light-dark(#ffffff, #1b1b1b);--uc-ai-floating: var(--uc-floating, light-dark(#ffffff, #242424));--uc-ai-floating-border: var(--uc-floating-border, light-dark(transparent, rgba(255, 255, 255, .05)));--uc-ai-muted: light-dark(#f5f5f5, #242424);--uc-ai-muted-foreground: light-dark(#717171, #989898);--uc-ai-primary: light-dark(#174bd7, #579aff);--uc-ai-primary-hover: light-dark(#1141c0, #4a8aef);--uc-ai-primary-foreground: light-dark(#ffffff, #000000);--uc-ai-primary-transparent: light-dark(rgba(23, 75, 215, .07), rgba(87, 154, 255, .07));--uc-ai-secondary: light-dark(rgba(24, 24, 24, .05), rgba(225, 225, 225, .07));--uc-ai-secondary-hover: light-dark(rgba(24, 24, 24, .08), rgba(225, 225, 225, .1));--uc-ai-secondary-foreground: light-dark(#181818, #e1e1e1);--uc-ai-border: light-dark(#e4e4e8, #3d3d3d);--uc-ai-shadow-color: light-dark(rgba(24, 24, 24, .18), rgba(0, 0, 0, .5));--uc-ai-dialog-shadow: 0 6px 20px light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .25));--uc-ai-composer-shadow: 0 4px 14px light-dark(rgba(0, 0, 0, .18), rgba(0, 0, 0, .34)), 0 0 26px light-dark(rgba(0, 0, 0, .2), rgba(0, 0, 0, .42));--uc-ai-composer-shadow-peek: 0 2px 10px light-dark(rgba(0, 0, 0, .16), rgba(0, 0, 0, .34));--uc-ai-composer-radius: var(--uc-ai-radius-frame);--uc-ai-composer-radius-top: var(--uc-ai-composer-radius);--uc-ai-composer-radius-bottom: var(--uc-ai-composer-radius);--uc-ai-destructive: #d8473e;--uc-ai-destructive-foreground: light-dark(#b3261e, #ff9d96);--uc-ai-radius: 8px;--uc-ai-radius-button: var(--uc-ai-radius);--uc-ai-radius-input: calc(var(--uc-ai-radius) * 1.5);--uc-ai-radius-card: calc(var(--uc-ai-radius) * 2);--uc-ai-radius-frame: calc(var(--uc-ai-radius) * 2.25);--uc-ai-padding: 10px;--uc-ai-button-size: 32px;--uc-ai-font-family: system-ui, -apple-system, sans-serif;--uc-ai-font-size: 14px;--uc-ai-transition: .2s ease;--uc-ai-ease-out: cubic-bezier(.23, 1, .32, 1);--uc-ai-ease-in-out: cubic-bezier(.77, 0, .175, 1);--uc-ai-dot-grid-color: light-dark(rgba(0, 0, 0, .21), rgba(255, 255, 255, .1));--uc-ai-prompt-max-lines: 6;--uc-ai-prompt-max-height: calc(var(--uc-ai-prompt-max-lines) * 1.5em + 10px);display:block;width:100%;height:100%;font-family:var(--uc-ai-font-family);font-size:var(--uc-ai-font-size);color:var(--uc-ai-foreground);color-scheme:light dark;container-type:inline-size}:host([hidden]){display:none}:host(.uc-light),:host-context(.uc-light){color-scheme:light}:host(.uc-dark),:host-context(.uc-dark){color-scheme:dark}.shell{display:flex;flex-direction:column;background:var(--uc-ai-background);border-radius:var(--uc-ai-radius-card);overflow:hidden;box-shadow:var(--uc-ai-dialog-shadow);height:100%}.stage{position:relative;flex:1;min-height:360px;overflow:hidden;background:var(--uc-ai-background)}uc-ai-canvas{position:absolute;top:0;right:0;bottom:0;left:0}.composer{width:700px;max-width:calc(100% - 40px)}.composer__content{display:flex;flex-direction:column;gap:14px;align-items:center}.composer--overlay{position:absolute;left:50%;transform:translate(-50%);z-index:5;transition:transform .48s var(--uc-ai-ease-out)}.composer--overlay-bottom{bottom:32px}.composer--overlay-top{top:32px}.composer--docked{margin-inline:auto;padding:14px 20px;position:relative;z-index:1}.composer--docked-bottom{padding-top:8px}.composer--docked-top{padding-bottom:8px}.history-pinned{position:absolute;left:50%;transform:translate(-50%);width:700px;max-width:calc(100% - 40px);z-index:5}.history-pinned--canvas-top{top:20px}.history-pinned--canvas-bottom{bottom:20px}.history-pinned--docked.history-pinned--canvas-top{top:6px}.history-pinned--docked.history-pinned--canvas-bottom{bottom:6px}.dock-hotzone{position:absolute;left:0;right:0;height:100px;z-index:4;pointer-events:none}.dock-hotzone--bottom{bottom:0}.dock-hotzone--top{top:0}:host([composer-auto-hide]) .stage:not(.is-empty) .dock-hotzone{pointer-events:auto}.composer-fade{position:absolute;left:0;right:0;height:26px;z-index:6;pointer-events:none;opacity:0;transition:opacity .3s var(--uc-ai-ease-out)}.composer-fade--bottom{bottom:0;background:linear-gradient(to top,var(--uc-ai-background) 0,var(--uc-ai-background) 8px,transparent)}.composer-fade--top{top:0;background:linear-gradient(to bottom,var(--uc-ai-background) 0,var(--uc-ai-background) 8px,transparent)}:host([composer-auto-hide]) .stage:not(.is-empty) .composer-fade{opacity:1}:host([composer-auto-hide]) .stage:not(.is-empty):has(.dock-hotzone:hover) .composer-fade,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay:hover) .composer-fade,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay:focus-within) .composer-fade{opacity:0}:host([composer-auto-hide]) .stage:not(.is-empty) .composer--overlay-bottom{transform:translate(-50%,calc(100% + 4px))}:host([composer-auto-hide]) .stage:not(.is-empty) .composer--overlay-top{transform:translate(-50%,calc(-100% - 4px))}:host([composer-auto-hide]) .stage:not(.is-empty):not(:has(.composer--overlay:hover)):not(:has(.composer--overlay:focus-within)):not(:has(.dock-hotzone:hover)) .composer--overlay{--uc-ai-composer-shadow: var(--uc-ai-composer-shadow-peek)}:host([composer-auto-hide]) .stage:not(.is-empty):not(:has(.composer--overlay:hover)):not(:has(.composer--overlay:focus-within)):not(:has(.dock-hotzone:hover)) .composer--overlay-bottom{--uc-ai-composer-radius-bottom: 0px}:host([composer-auto-hide]) .stage:not(.is-empty):not(:has(.composer--overlay:hover)):not(:has(.composer--overlay:focus-within)):not(:has(.dock-hotzone:hover)) .composer--overlay-top{--uc-ai-composer-radius-top: 0px}:host([composer-auto-hide]) .stage:not(.is-empty):has(.dock-hotzone--bottom:hover) .composer--overlay-bottom,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay-bottom:hover) .composer--overlay-bottom,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay-bottom:focus-within) .composer--overlay-bottom,:host([composer-auto-hide]) .stage:not(.is-empty):has(.dock-hotzone--top:hover) .composer--overlay-top,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay-top:hover) .composer--overlay-top,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay-top:focus-within) .composer--overlay-top{transform:translate(-50%)}:host([composer-auto-hide]) .stage:not(.is-empty):has(.dock-hotzone:hover) .dock-hotzone,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay:hover) .dock-hotzone,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay:focus-within) .dock-hotzone{height:320px}:host([composer-auto-hide]) .shell--has-image .composer--docked{margin-block:8px 14px;position:relative}:host([composer-auto-hide]) .shell--has-image .composer--docked .composer__content{position:relative;transition:transform .5s var(--uc-ai-ease-out)}:host([composer-auto-hide]) .shell--has-image .composer--docked .composer__content uc-ai-history{position:absolute;left:0;right:0}:host([composer-auto-hide]) .shell--has-image .composer--docked-bottom .composer__content uc-ai-history{bottom:calc(100% + 14px)}:host([composer-auto-hide]) .shell--has-image .composer--docked-top .composer__content uc-ai-history{top:calc(100% + 14px)}:host([composer-auto-hide]) .shell--has-image .composer--docked-bottom{clip-path:inset(-200px -200px 0 -200px)}:host([composer-auto-hide]) .shell--has-image .composer--docked-top{clip-path:inset(0 -200px -200px -200px)}:host([composer-auto-hide]) .shell--has-image:not(:has(.composer--docked:hover)):not(:has(.composer--docked:focus-within)) .composer--docked{--uc-ai-composer-shadow: var(--uc-ai-composer-shadow-peek)}:host([composer-auto-hide]) .shell--has-image:not(:has(.composer--docked:hover)):not(:has(.composer--docked:focus-within)) .composer--docked-bottom .composer__content{transform:translateY(calc(100% - 22px))}:host([composer-auto-hide]) .shell--has-image:not(:has(.composer--docked:hover)):not(:has(.composer--docked:focus-within)) .composer--docked-top .composer__content{transform:translateY(calc(-100% + 22px))}uc-ai-history,uc-ai-prompt-row{width:100%}.error-box{position:absolute;top:0;right:0;bottom:0;left:0;z-index:6;display:grid;place-items:center;padding:20px;pointer-events:none}.error-box__card{pointer-events:auto;max-width:75%;padding:10px 15px;background:var(--uc-ai-floating, var(--uc-ai-background));border:1px solid var(--uc-ai-floating-border, transparent);border-radius:var(--uc-ai-radius-card);box-shadow:var(--uc-ai-dialog-shadow);color:var(--uc-ai-destructive-foreground);font-size:14px;line-height:1.4;text-align:center}";
|
|
2779
|
+
var Ur = Object.defineProperty, Tr = Object.getOwnPropertyDescriptor, m = (t, e, i, r) => {
|
|
2780
|
+
for (var s = r > 1 ? void 0 : r ? Tr(e, i) : e, o = t.length - 1, a; o >= 0; o--)
|
|
2778
2781
|
(a = t[o]) && (s = (r ? a(e, i, s) : a(s)) || s);
|
|
2779
|
-
return r && s &&
|
|
2782
|
+
return r && s && Ur(e, i, s), s;
|
|
2780
2783
|
};
|
|
2781
|
-
const
|
|
2784
|
+
const Fr = ["top", "bottom"], Mr = ["bottom", "top", "none"], Or = ["full", "available"], Ir = [
|
|
2782
2785
|
"composer-above",
|
|
2783
2786
|
"composer-below",
|
|
2784
2787
|
"canvas-top",
|
|
@@ -2786,12 +2789,12 @@ const Ar = ["top", "bottom"], Ur = ["full", "available"], Tr = [
|
|
|
2786
2789
|
];
|
|
2787
2790
|
let d = class extends G {
|
|
2788
2791
|
constructor() {
|
|
2789
|
-
super(...arguments), this.sourceUuid = null, this.pubkey = "", this.aspectRatios = null, this.localeName = "en", this.localeDefinitionOverride = {}, this.presetsOnly = !1, this.presets = {}, this.composerPlacement = "bottom", this.canvasFit = "available", this.historyPlacement = "composer-above", this.composerAutoHide = !1, this.toolbarPlacement = "bottom", this._prompt = "", this._selectedRatio = null, this._inputUrl = null, this._gen = new
|
|
2792
|
+
super(...arguments), this.sourceUuid = null, this.pubkey = "", this.aspectRatios = null, this.localeName = "en", this.localeDefinitionOverride = {}, this.presetsOnly = !1, this.presets = {}, this.composerPlacement = "bottom", this.canvasFit = "available", this.historyPlacement = "composer-above", this.composerAutoHide = !1, this.toolbarPlacement = "bottom", this._prompt = "", this._selectedRatio = null, this._inputUrl = null, this._gen = new Ri(this), this._history = new zi(this), this._secure = new _t(this), this._localeStrings = B, this._localeToken = 0, this._lastPreviewUrl = null, this._ratioOptionsCache = /* @__PURE__ */ new Map(), this._labelForOption = (t) => t.labelKey ? this._l(t.labelKey) : "", this._lastResult = null;
|
|
2790
2793
|
}
|
|
2791
2794
|
/** @internal */
|
|
2792
2795
|
willUpdate(t) {
|
|
2793
2796
|
const e = t.has("provider") || t.has("pubkey") || t.has("baseUrl") || t.has("cdnCname") || t.has("cdnCnamePrefixed");
|
|
2794
|
-
e && (this._provider = this.provider ?? (this.pubkey ? new
|
|
2797
|
+
e && (this._provider = this.provider ?? (this.pubkey ? new Ei({
|
|
2795
2798
|
publicKey: this.pubkey,
|
|
2796
2799
|
baseUrl: this.baseUrl,
|
|
2797
2800
|
cdnBaseUrl: this.cdnCname,
|
|
@@ -2816,7 +2819,7 @@ let d = class extends G {
|
|
|
2816
2819
|
this._lastMode = r, this._selectedRatio = r === "edit" ? V : this._defaultGenerateRatio();
|
|
2817
2820
|
else if (t.has("aspectRatios")) {
|
|
2818
2821
|
const s = this._selectedRatio;
|
|
2819
|
-
|
|
2822
|
+
I(s) && !this._standardRatios().some((o) => _e(o, s)) && (this._selectedRatio = this._defaultGenerateRatio());
|
|
2820
2823
|
}
|
|
2821
2824
|
t.has("aspectRatios") && this._ratioOptionsCache.clear(), (t.has("localeName") || t.has("localeDefinitionOverride")) && this._resolveLocale();
|
|
2822
2825
|
}
|
|
@@ -2827,7 +2830,7 @@ let d = class extends G {
|
|
|
2827
2830
|
let i = B;
|
|
2828
2831
|
if (t !== "en")
|
|
2829
2832
|
try {
|
|
2830
|
-
i = await ((s =
|
|
2833
|
+
i = await ((s = pe[t]) == null ? void 0 : s.call(pe)) ?? B;
|
|
2831
2834
|
} catch {
|
|
2832
2835
|
i = B;
|
|
2833
2836
|
}
|
|
@@ -2836,7 +2839,7 @@ let d = class extends G {
|
|
|
2836
2839
|
this._localeStrings = r ? { ...i, ...r } : i;
|
|
2837
2840
|
}
|
|
2838
2841
|
_l(t) {
|
|
2839
|
-
return
|
|
2842
|
+
return $i(t, this._localeStrings);
|
|
2840
2843
|
}
|
|
2841
2844
|
/** Friendly message for the current failure: the per-`error_code` string
|
|
2842
2845
|
* (`ai-enhancer-error-<code>`, overridable via the locale) when one is
|
|
@@ -2944,7 +2947,7 @@ let d = class extends G {
|
|
|
2944
2947
|
const t = this._displayUrl;
|
|
2945
2948
|
if (!t)
|
|
2946
2949
|
return this._lastPreviewUrl = null, null;
|
|
2947
|
-
const e = this._secure.resolve(
|
|
2950
|
+
const e = this._secure.resolve(Oi(t, this.clientWidth || 1024));
|
|
2948
2951
|
return e != null && (this._lastPreviewUrl = e), this._lastPreviewUrl;
|
|
2949
2952
|
}
|
|
2950
2953
|
/** Full-resolution rendition for fullscreen, secure-delivery-resolved. */
|
|
@@ -2953,8 +2956,8 @@ let d = class extends G {
|
|
|
2953
2956
|
}
|
|
2954
2957
|
/** The configured (or popular) standard ratios, validated. */
|
|
2955
2958
|
_standardRatios() {
|
|
2956
|
-
const t = (this.aspectRatios ?? []).filter(
|
|
2957
|
-
return t.length > 0 ? t : [...
|
|
2959
|
+
const t = (this.aspectRatios ?? []).filter(Ee);
|
|
2960
|
+
return t.length > 0 ? t : [...kt];
|
|
2958
2961
|
}
|
|
2959
2962
|
/**
|
|
2960
2963
|
* The ratio the generate flow starts on: the prototype's landscape default
|
|
@@ -2963,12 +2966,12 @@ let d = class extends G {
|
|
|
2963
2966
|
*/
|
|
2964
2967
|
_defaultGenerateRatio() {
|
|
2965
2968
|
const t = this._standardRatios();
|
|
2966
|
-
return t.find((e) =>
|
|
2969
|
+
return t.find((e) => _e(e, Rt)) ?? t[0] ?? null;
|
|
2967
2970
|
}
|
|
2968
2971
|
_ratioOptions(t) {
|
|
2969
2972
|
const e = this._ratioOptionsCache.get(t);
|
|
2970
2973
|
if (e) return e;
|
|
2971
|
-
const i = this._standardRatios().map(
|
|
2974
|
+
const i = this._standardRatios().map(Ut), r = t === "edit" ? [{ value: V, labelKey: "ai-enhancer-aspect-original" }, ...i] : i;
|
|
2972
2975
|
return this._ratioOptionsCache.set(t, r), r;
|
|
2973
2976
|
}
|
|
2974
2977
|
/**
|
|
@@ -3009,7 +3012,7 @@ let d = class extends G {
|
|
|
3009
3012
|
mode: i,
|
|
3010
3013
|
// "Original" (and generate's null) omit the ratio; only a concrete pick
|
|
3011
3014
|
// is sent — in edit that reshapes, otherwise the source AR is preserved.
|
|
3012
|
-
aspectRatio:
|
|
3015
|
+
aspectRatio: I(this._selectedRatio) ? this._selectedRatio : void 0,
|
|
3013
3016
|
// Record the full selection (incl. "Original") so the history entry can
|
|
3014
3017
|
// restore the picker when re-selected.
|
|
3015
3018
|
ratioValue: this._selectedRatio,
|
|
@@ -3029,7 +3032,8 @@ let d = class extends G {
|
|
|
3029
3032
|
file: o.file
|
|
3030
3033
|
}));
|
|
3031
3034
|
} catch (o) {
|
|
3032
|
-
|
|
3035
|
+
const a = { error: ki(o) };
|
|
3036
|
+
this.dispatchEvent(new CustomEvent("uc:error", { detail: a, bubbles: !0, composed: !0 }));
|
|
3033
3037
|
}
|
|
3034
3038
|
}
|
|
3035
3039
|
/** Discard the current image (input or result) and prompt history, returning
|
|
@@ -3067,33 +3071,49 @@ let d = class extends G {
|
|
|
3067
3071
|
return (e = this._promptRow) == null ? void 0 : e.focusInput();
|
|
3068
3072
|
});
|
|
3069
3073
|
}
|
|
3070
|
-
|
|
3074
|
+
/** Snapshot of the current generation result in the `uc:done` payload shape. */
|
|
3075
|
+
_resultDetail() {
|
|
3071
3076
|
const t = this._gen.result;
|
|
3072
|
-
|
|
3073
|
-
const e = {
|
|
3077
|
+
return t ? {
|
|
3074
3078
|
url: t.url,
|
|
3075
3079
|
uuid: t.uuid,
|
|
3076
3080
|
prompt: t.prompt,
|
|
3077
3081
|
mode: t.mode,
|
|
3078
|
-
aspectRatio:
|
|
3082
|
+
aspectRatio: I(this._selectedRatio) ? this._selectedRatio : void 0,
|
|
3079
3083
|
file: t.file
|
|
3080
|
-
};
|
|
3081
|
-
|
|
3084
|
+
} : null;
|
|
3085
|
+
}
|
|
3086
|
+
_onPrimary() {
|
|
3087
|
+
const t = this._resultDetail();
|
|
3088
|
+
t && this.dispatchEvent(new CustomEvent("uc:done", { detail: t, bubbles: !0, composed: !0 }));
|
|
3082
3089
|
}
|
|
3083
3090
|
_onCancel(t) {
|
|
3084
3091
|
t.stopPropagation(), this.dispatchEvent(new CustomEvent("uc:cancel", { bubbles: !0, composed: !0 }));
|
|
3085
3092
|
}
|
|
3093
|
+
/**
|
|
3094
|
+
* Every result mutation (generation, history selection, reset) goes through
|
|
3095
|
+
* the generation controller's requestUpdate, so comparing here catches them
|
|
3096
|
+
* all with one code path.
|
|
3097
|
+
* @internal
|
|
3098
|
+
*/
|
|
3099
|
+
updated(t) {
|
|
3100
|
+
if (super.updated(t), this._gen.result !== this._lastResult) {
|
|
3101
|
+
this._lastResult = this._gen.result;
|
|
3102
|
+
const e = { result: this._resultDetail() };
|
|
3103
|
+
this.dispatchEvent(new CustomEvent("uc:change", { detail: e, bubbles: !0, composed: !0 }));
|
|
3104
|
+
}
|
|
3105
|
+
}
|
|
3086
3106
|
/** @internal */
|
|
3087
3107
|
render() {
|
|
3088
|
-
var
|
|
3089
|
-
const t = this._mode, e = t === "edit" && !this.sourceUuid && !this.sourceFileInfo, i =
|
|
3108
|
+
var Me, Oe;
|
|
3109
|
+
const t = this._mode, e = t === "edit" && !this.sourceUuid && !this.sourceFileInfo, i = ye[t].placeholderKey, r = ((Me = this.presets) == null ? void 0 : Me[t]) ?? ye[t].presets, s = this._gen.busy || !this._gen.result, o = this._ratioOptions(t), a = this._displayUrl != null, n = I(this._selectedRatio) ? this._selectedRatio[0] / this._selectedRatio[1] : null, l = {
|
|
3090
3110
|
stage: !0,
|
|
3091
3111
|
"is-empty": !a
|
|
3092
|
-
}, h =
|
|
3112
|
+
}, h = Fr.includes(this.composerPlacement) ? this.composerPlacement : "bottom", u = (Or.includes(this.canvasFit) ? this.canvasFit : "available") === "full", _ = !u, x = `${u ? "overlay" : "docked"}-${h}`, w = Ir.includes(this.historyPlacement) ? this.historyPlacement : "composer-above", $ = w === "composer-above" || w === "composer-below", R = (u || _ && this.composerAutoHide) && $, O = w === "canvas-top" ? "top" : w === "canvas-bottom" ? "bottom" : h, W = this._historyEntries, X = W.length > 0 || e, ne = X ? f`
|
|
3093
3113
|
<uc-ai-history
|
|
3094
3114
|
.busy=${this._gen.busy}
|
|
3095
3115
|
.entries=${W}
|
|
3096
|
-
.selectedUuid=${((
|
|
3116
|
+
.selectedUuid=${((Oe = this._gen.result) == null ? void 0 : Oe.uuid) ?? this._sourceUuid}
|
|
3097
3117
|
?show-start-over=${e}
|
|
3098
3118
|
start-over-label="${this._l("ai-enhancer-start-over")}"
|
|
3099
3119
|
list-label="${this._l("ai-enhancer-history-title")}"
|
|
@@ -3101,7 +3121,7 @@ let d = class extends G {
|
|
|
3101
3121
|
@uc:select=${this._onSelectHistoryEntry}
|
|
3102
3122
|
@uc:start-over=${this._onStartOver}
|
|
3103
3123
|
></uc-ai-history>
|
|
3104
|
-
` :
|
|
3124
|
+
` : g, gt = f`
|
|
3105
3125
|
<uc-ai-prompt-row
|
|
3106
3126
|
.mode=${t}
|
|
3107
3127
|
.value=${this._prompt}
|
|
@@ -3120,7 +3140,7 @@ let d = class extends G {
|
|
|
3120
3140
|
.busy=${this._gen.busy}
|
|
3121
3141
|
@uc:select=${this._onSelectPreset}
|
|
3122
3142
|
></uc-ai-chips>
|
|
3123
|
-
` :
|
|
3143
|
+
` : g}
|
|
3124
3144
|
${o.length > 0 ? f`
|
|
3125
3145
|
<uc-ai-aspect-ratio
|
|
3126
3146
|
slot="aspect-ratio"
|
|
@@ -3131,9 +3151,9 @@ let d = class extends G {
|
|
|
3131
3151
|
aria-label-text="${this._l("ai-enhancer-aspect-ratio-aria")}"
|
|
3132
3152
|
@uc:select=${this._onSelectAspectRatio}
|
|
3133
3153
|
></uc-ai-aspect-ratio>
|
|
3134
|
-
` :
|
|
3154
|
+
` : g}
|
|
3135
3155
|
</uc-ai-prompt-row>
|
|
3136
|
-
`,
|
|
3156
|
+
`, le = f`
|
|
3137
3157
|
<div
|
|
3138
3158
|
class=${S({
|
|
3139
3159
|
composer: !0,
|
|
@@ -3143,23 +3163,23 @@ let d = class extends G {
|
|
|
3143
3163
|
})}
|
|
3144
3164
|
>
|
|
3145
3165
|
<div class="composer__content">
|
|
3146
|
-
${R && w === "composer-above" ?
|
|
3147
|
-
${
|
|
3148
|
-
${R && w === "composer-below" ?
|
|
3166
|
+
${R && w === "composer-above" ? ne : g}
|
|
3167
|
+
${gt}
|
|
3168
|
+
${R && w === "composer-below" ? ne : g}
|
|
3149
3169
|
</div>
|
|
3150
3170
|
</div>
|
|
3151
|
-
`,
|
|
3171
|
+
`, vt = X && !R ? f`<div
|
|
3152
3172
|
class=${S({
|
|
3153
3173
|
"history-pinned": !0,
|
|
3154
3174
|
"history-pinned--docked": _,
|
|
3155
|
-
[`history-pinned--canvas-${
|
|
3175
|
+
[`history-pinned--canvas-${O}`]: !0
|
|
3156
3176
|
})}
|
|
3157
3177
|
>
|
|
3158
|
-
${
|
|
3159
|
-
</div>` :
|
|
3178
|
+
${ne}
|
|
3179
|
+
</div>` : g, bt = this.composerAutoHide && u ? f`
|
|
3160
3180
|
<div class=${S({ "dock-hotzone": !0, [`dock-hotzone--${h}`]: !0 })}></div>
|
|
3161
3181
|
<div class=${S({ "composer-fade": !0, [`composer-fade--${h}`]: !0 })}></div>
|
|
3162
|
-
` :
|
|
3182
|
+
` : g, Ue = Mr.includes(this.toolbarPlacement) ? this.toolbarPlacement : "bottom", Te = Ue === "top", Fe = Ue === "none" ? g : f`
|
|
3163
3183
|
<uc-ai-footer
|
|
3164
3184
|
cancel-label="${this._l("ai-enhancer-cancel")}"
|
|
3165
3185
|
primary-label="${this._l("ai-enhancer-done-btn")}"
|
|
@@ -3174,8 +3194,8 @@ let d = class extends G {
|
|
|
3174
3194
|
role="region"
|
|
3175
3195
|
aria-label="${this._l(t === "edit" ? "ai-enhancer-edit-title" : "ai-enhancer-generate-title")}"
|
|
3176
3196
|
>
|
|
3177
|
-
${
|
|
3178
|
-
${_ && h === "top" ?
|
|
3197
|
+
${Te ? Fe : g}
|
|
3198
|
+
${_ && h === "top" ? le : g}
|
|
3179
3199
|
<div class=${S(l)}>
|
|
3180
3200
|
<uc-ai-canvas
|
|
3181
3201
|
.url=${this._previewUrl}
|
|
@@ -3191,21 +3211,21 @@ let d = class extends G {
|
|
|
3191
3211
|
exit-fullscreen-label="${this._l("ai-enhancer-exit-fullscreen")}"
|
|
3192
3212
|
></uc-ai-canvas>
|
|
3193
3213
|
|
|
3194
|
-
${
|
|
3195
|
-
${
|
|
3196
|
-
${u ?
|
|
3214
|
+
${bt}
|
|
3215
|
+
${vt}
|
|
3216
|
+
${u ? le : g}
|
|
3197
3217
|
|
|
3198
3218
|
${this._gen.error ? f`<div class="error-box" role="alert">
|
|
3199
3219
|
<div class="error-box__card">${this._errorMessage()}</div>
|
|
3200
|
-
</div>` :
|
|
3220
|
+
</div>` : g}
|
|
3201
3221
|
</div>
|
|
3202
|
-
${_ && h === "bottom" ?
|
|
3203
|
-
${
|
|
3222
|
+
${_ && h === "bottom" ? le : g}
|
|
3223
|
+
${Te ? g : Fe}
|
|
3204
3224
|
</div>
|
|
3205
3225
|
`;
|
|
3206
3226
|
}
|
|
3207
3227
|
};
|
|
3208
|
-
d.styles = j(
|
|
3228
|
+
d.styles = j(Ar);
|
|
3209
3229
|
m([
|
|
3210
3230
|
c({ attribute: "source-uuid" })
|
|
3211
3231
|
], d.prototype, "sourceUuid", 2);
|
|
@@ -3237,7 +3257,7 @@ m([
|
|
|
3237
3257
|
c({ attribute: !1 })
|
|
3238
3258
|
], d.prototype, "secureDeliveryProxyUrlResolver", 2);
|
|
3239
3259
|
m([
|
|
3240
|
-
c({ type: Array, attribute: "aspect-ratios", converter: (t) => t ?
|
|
3260
|
+
c({ type: Array, attribute: "aspect-ratios", converter: (t) => t ? Tt(t) : null })
|
|
3241
3261
|
], d.prototype, "aspectRatios", 2);
|
|
3242
3262
|
m([
|
|
3243
3263
|
c({ attribute: "locale-name" })
|
|
@@ -3294,11 +3314,11 @@ d = m([
|
|
|
3294
3314
|
H("uc-ai-enhancer")
|
|
3295
3315
|
], d);
|
|
3296
3316
|
export {
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3317
|
+
Kr as I,
|
|
3318
|
+
pe as L,
|
|
3319
|
+
kt as P,
|
|
3300
3320
|
d as U,
|
|
3301
|
-
|
|
3321
|
+
qr as a,
|
|
3302
3322
|
B as e,
|
|
3303
|
-
|
|
3323
|
+
Ee as i
|
|
3304
3324
|
};
|