@uploadcare/ai-enhancer 0.1.2 → 0.1.3
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-OUmStG-E.cjs → UcAiEnhancer-Co-HZ72E.cjs} +45 -45
- package/dist/{UcAiEnhancer-qk-y4FHK.js → UcAiEnhancer-DK6rhHp7.js} +447 -443
- package/dist/ai-enhancer.cjs +1 -1
- package/dist/ai-enhancer.d.ts +72 -53
- 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 bt = Object.defineProperty;
|
|
2
|
+
var Ie = (t) => {
|
|
3
3
|
throw TypeError(t);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var b = (t, e, i) =>
|
|
7
|
-
var E = (t, e, i) => (
|
|
5
|
+
var yt = (t, e, i) => e in t ? bt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
|
|
6
|
+
var b = (t, e, i) => yt(t, typeof e != "symbol" ? e + "" : e, i), ce = (t, e, i) => e.has(t) || Ie("Cannot " + i);
|
|
7
|
+
var E = (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), Oe = (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
8
|
import { unsafeCSS as j, LitElement as G, html as f, nothing as v } 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 rt } from "lit/html.js";
|
|
14
|
+
import { directive as st, PartType as ot } from "lit/directive.js";
|
|
15
|
+
import { AsyncDirective as at } from "lit/async-directive.js";
|
|
16
|
+
import { repeat as wt } from "lit/directives/repeat.js";
|
|
17
|
+
import { ifDefined as xt } from "lit/directives/if-defined.js";
|
|
17
18
|
const V = "original";
|
|
18
19
|
function O(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 : Tt(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
|
+
], Et = [3, 2], Rt = {
|
|
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
|
+
}, St = 0.1, Ct = 10;
|
|
40
|
+
function ke(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 >= St && r <= Ct;
|
|
44
45
|
}
|
|
45
|
-
function
|
|
46
|
+
function ee(t) {
|
|
46
47
|
return `${t[0]}:${t[1]}`;
|
|
47
48
|
}
|
|
48
|
-
function Ct(t) {
|
|
49
|
-
return Et[Q(t)] ?? null;
|
|
50
|
-
}
|
|
51
49
|
function $t(t) {
|
|
52
|
-
return
|
|
50
|
+
return Rt[ee(t)] ?? null;
|
|
53
51
|
}
|
|
54
52
|
function At(t) {
|
|
53
|
+
return { value: t, labelKey: $t(t) };
|
|
54
|
+
}
|
|
55
|
+
function Ut(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
|
+
ke(n) && e.push(n);
|
|
63
64
|
}
|
|
64
65
|
return e;
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
+
function Tt(t, e) {
|
|
67
68
|
return t[0] === e[0] && t[1] === e[1];
|
|
68
69
|
}
|
|
69
|
-
function
|
|
70
|
+
function Ft(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 Mt(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 Pe(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 (Mt(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 Pe(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 Pe(o, r);
|
|
143
|
+
return await Q(), a;
|
|
204
144
|
}
|
|
205
145
|
}
|
|
206
|
-
const
|
|
207
|
-
function
|
|
146
|
+
const nt = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", Ot = new RegExp(`^${nt}$`, "i"), Pt = new RegExp(`^(${nt})~([0-9]+)$`, "i");
|
|
147
|
+
function Ee(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 lt(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 Lt = [
|
|
224
164
|
"video",
|
|
225
165
|
"document",
|
|
226
166
|
"gif2video"
|
|
227
|
-
],
|
|
228
|
-
function
|
|
229
|
-
return t != null &&
|
|
167
|
+
], Dt = /\/(https?:\/\/.+)$/i;
|
|
168
|
+
function Nt(t) {
|
|
169
|
+
return t != null && Lt.includes(t);
|
|
230
170
|
}
|
|
231
|
-
function
|
|
171
|
+
function ct(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(Dt)) == 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(Le(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 = Le(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(Pt);
|
|
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 $ = De(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 (!Ot.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
|
+
Nt(a[0]) && (p = a[0], a.shift());
|
|
223
|
+
const u = De(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 Le(t) {
|
|
294
234
|
return t.split("/").filter((e) => e !== "");
|
|
295
235
|
}
|
|
296
|
-
function
|
|
236
|
+
function De(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 ht(t) {
|
|
323
263
|
return t.map((e) => `-/${[e.name, ...e.params].join("/")}/`).join("");
|
|
324
264
|
}
|
|
325
|
-
function
|
|
326
|
-
const e =
|
|
265
|
+
function ut(t) {
|
|
266
|
+
const e = Ee(t.origin), i = ht(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 Bt(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 = Bt(e);
|
|
345
285
|
return t.name === i || t.name.startsWith(`${i}~`);
|
|
346
286
|
}
|
|
347
|
-
function
|
|
287
|
+
function dt(t, e) {
|
|
348
288
|
return Object.assign(e, { opName: t });
|
|
349
289
|
}
|
|
350
|
-
const
|
|
290
|
+
const jt = (t, e) => {
|
|
351
291
|
const i = new URL(e);
|
|
352
292
|
return i.hostname = `${t}.${i.hostname}`, i.toString().replace(/\/$/, "");
|
|
353
|
-
},
|
|
293
|
+
}, Gt = "0123456789abcdefghijklmnopqrstuvwxyz", Ht = (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 = Gt[Number(i)] + e, t = t / 36n;
|
|
360
300
|
}
|
|
361
301
|
return e;
|
|
362
|
-
},
|
|
302
|
+
}, Wt = (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
|
+
}, Vt = 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
|
+
}, qt = 10, Kt = async (t) => {
|
|
313
|
+
const e = await Vt(t);
|
|
314
|
+
return Ht(e).slice(0, qt);
|
|
315
|
+
}, Yt = async (t, e) => {
|
|
316
|
+
const i = await Kt(t);
|
|
317
|
+
return jt(i, e);
|
|
378
318
|
};
|
|
379
|
-
function
|
|
319
|
+
function Ne(t) {
|
|
380
320
|
return Object.prototype.toString.call(t) === "[object Object]";
|
|
381
321
|
}
|
|
382
|
-
const
|
|
383
|
-
function
|
|
384
|
-
return t.split(
|
|
322
|
+
const Xt = /\W|_/g;
|
|
323
|
+
function Jt(t) {
|
|
324
|
+
return t.split(Xt).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 Be(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 Be(t, { ignoreKeys: e });
|
|
332
|
+
if (!Ne(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
|
+
Ne(s) ? s = Re(s, { ignoreKeys: e }) : Array.isArray(s) && (s = Be(s, { ignoreKeys: e })), i[Jt(r)] = s;
|
|
402
342
|
}
|
|
403
343
|
return i;
|
|
404
344
|
}
|
|
405
|
-
const
|
|
406
|
-
function
|
|
345
|
+
const Zt = (t) => new Promise((e) => setTimeout(e, t));
|
|
346
|
+
function Qt({ 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 ei = {
|
|
422
362
|
factor: 2,
|
|
423
363
|
time: 100
|
|
424
364
|
};
|
|
425
|
-
function
|
|
365
|
+
function ti(t, e = ei) {
|
|
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) => Zt(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 ii = (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
|
+
}, ri = ({ 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", ii(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}`));
|
|
@@ -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 si = (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 = si(i)), r.toString();
|
|
521
461
|
};
|
|
522
|
-
var
|
|
523
|
-
const
|
|
524
|
-
function
|
|
525
|
-
return
|
|
526
|
-
libraryName:
|
|
527
|
-
libraryVersion:
|
|
462
|
+
var oi = "6.18.4";
|
|
463
|
+
const ai = "UploadcareUploadClient", ni = oi;
|
|
464
|
+
function li(t) {
|
|
465
|
+
return Qt({
|
|
466
|
+
libraryName: ai,
|
|
467
|
+
libraryVersion: ni,
|
|
528
468
|
...t
|
|
529
469
|
});
|
|
530
470
|
}
|
|
531
|
-
const
|
|
532
|
-
function
|
|
471
|
+
const ci = "RequestThrottledError", je = 15e3, hi = 1e3;
|
|
472
|
+
function ui(t) {
|
|
533
473
|
const { headers: e } = t || {};
|
|
534
474
|
if (!e || typeof e["retry-after"] != "string")
|
|
535
|
-
return
|
|
475
|
+
return je;
|
|
536
476
|
const i = parseInt(e["retry-after"], 10);
|
|
537
|
-
return Number.isFinite(i) ? i * 1e3 :
|
|
477
|
+
return Number.isFinite(i) ? i * 1e3 : je;
|
|
538
478
|
}
|
|
539
|
-
function
|
|
479
|
+
function di(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 ti(({ attempt: s, retry: o }) => t().catch((a) => {
|
|
482
|
+
if ("response" in a && (a == null ? void 0 : a.code) === ci && s < i)
|
|
483
|
+
return o(ui(a));
|
|
484
|
+
if (a instanceof oe && s < r)
|
|
485
|
+
return o((s + 1) * hi);
|
|
546
486
|
throw a;
|
|
547
487
|
}));
|
|
548
488
|
}
|
|
549
|
-
var
|
|
489
|
+
var Ge;
|
|
550
490
|
(function(t) {
|
|
551
491
|
t.Token = "token", t.FileInfo = "file_info";
|
|
552
|
-
})(
|
|
553
|
-
var
|
|
492
|
+
})(Ge || (Ge = {}));
|
|
493
|
+
var He;
|
|
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
|
+
})(He || (He = {}));
|
|
497
|
+
function pi(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 di(() => ri({
|
|
559
499
|
method: "GET",
|
|
560
500
|
headers: {
|
|
561
|
-
"X-UC-User-Agent":
|
|
501
|
+
"X-UC-User-Agent": li({ 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 fi(t) {
|
|
578
518
|
return "defaultEffects" in t;
|
|
579
519
|
}
|
|
580
|
-
class
|
|
581
|
-
constructor(e, { baseCDN: i =
|
|
520
|
+
class We {
|
|
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, fi(e) && (this.defaultEffects = e.defaultEffects);
|
|
599
539
|
}
|
|
600
540
|
}
|
|
601
|
-
const
|
|
602
|
-
function
|
|
541
|
+
const mi = /\W|_/g;
|
|
542
|
+
function _i(t) {
|
|
603
543
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
604
544
|
}
|
|
605
|
-
function
|
|
606
|
-
return t.split(
|
|
545
|
+
function gi(t) {
|
|
546
|
+
return t.split(mi).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 (!_i(t))
|
|
612
552
|
return t;
|
|
613
553
|
const e = {};
|
|
614
554
|
for (const i of Object.keys(t))
|
|
615
|
-
e[
|
|
555
|
+
e[gi(i)] = be(t[i]);
|
|
616
556
|
return e;
|
|
617
557
|
}
|
|
618
|
-
const
|
|
619
|
-
function
|
|
558
|
+
const vi = [1, 1], Ve = "https://ucarecdn.com", bi = 1500, yi = 1e6;
|
|
559
|
+
function wi(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 qe() {
|
|
634
574
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
635
575
|
}
|
|
636
|
-
class
|
|
576
|
+
class xi {
|
|
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 ?? Ve, this.cnamePrefixed = e.cdnCnamePrefixed ?? "https://ucarecd.net", this.pollIntervalMs = e.pollIntervalMs ?? bi, this.pollTimeoutMs = e.pollTimeoutMs ?? yi;
|
|
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 ut({ 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 pi(e, { publicKey: this.publicKey, baseURL: this.baseUrl, signal: i });
|
|
606
|
+
return new We(r, { baseCDN: await this.getCdnBase() });
|
|
667
607
|
}
|
|
668
608
|
async startJob(e) {
|
|
669
|
-
const i = e.aspectRatio &&
|
|
609
|
+
const i = e.aspectRatio && ke(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 ?? vi,
|
|
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 + qe();
|
|
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 We(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 (qe() >= r)
|
|
709
649
|
throw new Error(`Uploadcare derivative: timed out waiting for job ${e}`);
|
|
710
|
-
await
|
|
650
|
+
await wi(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 === Ve || Wt(this.cname, this.cnamePrefixed) ? Yt(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
|
+
}, Ke = 20;
|
|
726
|
+
class Ei {
|
|
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, Ke), 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, Ke), 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 Ri = {
|
|
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
|
+
}, Si = {
|
|
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 = { ...Ri, ...Si }, 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,12 +870,12 @@ 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 Ci(t, e) {
|
|
871
874
|
return (e == null ? void 0 : e[t]) ?? B[t];
|
|
872
875
|
}
|
|
873
|
-
function
|
|
876
|
+
function $i(t) {
|
|
874
877
|
if ("kind" in t) return t;
|
|
875
|
-
const e =
|
|
878
|
+
const e = Ee(t.origin);
|
|
876
879
|
if ("sourceUrl" in t)
|
|
877
880
|
return {
|
|
878
881
|
kind: "proxy",
|
|
@@ -901,12 +904,12 @@ function Si(t) {
|
|
|
901
904
|
hash: r
|
|
902
905
|
};
|
|
903
906
|
}
|
|
904
|
-
var k, q,
|
|
905
|
-
let
|
|
907
|
+
var k, q, ie, M;
|
|
908
|
+
let Ai = (M = class {
|
|
906
909
|
constructor(e) {
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
+
he(this, q);
|
|
911
|
+
he(this, k);
|
|
912
|
+
Oe(this, k, $i(e));
|
|
910
913
|
}
|
|
911
914
|
/**
|
|
912
915
|
* Parses an existing CDN URL.
|
|
@@ -914,7 +917,7 @@ 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(ct(e));
|
|
918
921
|
}
|
|
919
922
|
/** A defensive copy of the operation chain (empty for group root urls). */
|
|
920
923
|
get operations() {
|
|
@@ -922,7 +925,7 @@ let Ci = (M = class {
|
|
|
922
925
|
}
|
|
923
926
|
/** The serialized URL string. */
|
|
924
927
|
get href() {
|
|
925
|
-
return
|
|
928
|
+
return ut(E(this, k));
|
|
926
929
|
}
|
|
927
930
|
/** Alias of {@link CdnUrl.href} for string coercion. */
|
|
928
931
|
toString() {
|
|
@@ -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.
|
|
@@ -974,51 +977,51 @@ let Ci = (M = class {
|
|
|
974
977
|
}
|
|
975
978
|
/** Rebases the url onto another domain. */
|
|
976
979
|
setOrigin(e) {
|
|
977
|
-
return new M({ ...E(this, k), origin:
|
|
980
|
+
return new M({ ...E(this, k), origin: Ee(e) });
|
|
978
981
|
}
|
|
979
|
-
}, k = new WeakMap(), q = new WeakSet(),
|
|
982
|
+
}, k = new WeakMap(), q = new WeakSet(), ie = function(e) {
|
|
980
983
|
return "operations" in E(this, k) ? new M({
|
|
981
984
|
...E(this, k),
|
|
982
985
|
operations: e(E(this, k).operations)
|
|
983
986
|
}) : this;
|
|
984
987
|
}, M);
|
|
985
|
-
const
|
|
988
|
+
const we = (t, ...e) => ({
|
|
986
989
|
name: t,
|
|
987
990
|
params: e
|
|
988
|
-
}),
|
|
991
|
+
}), Ui = /* @__PURE__ */ dt(
|
|
989
992
|
"preview",
|
|
990
993
|
function(t, e) {
|
|
991
|
-
return t == null && e == null ?
|
|
994
|
+
return t == null && e == null ? we("preview") : we("preview", lt(t, e, "preview"));
|
|
992
995
|
}
|
|
993
|
-
),
|
|
996
|
+
), Ti = /* @__PURE__ */ dt(
|
|
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 = [lt(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
|
+
), Fi = 3e3;
|
|
1003
|
+
function pt(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)), Fi);
|
|
1003
1006
|
}
|
|
1004
|
-
function
|
|
1007
|
+
function ft(t, e) {
|
|
1005
1008
|
if (e.length === 0) return t;
|
|
1006
1009
|
try {
|
|
1007
|
-
return
|
|
1010
|
+
return Ai.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 Mi(t, e) {
|
|
1016
|
+
const i = pt(e);
|
|
1017
|
+
return ft(t, [Ui(i, i)]);
|
|
1015
1018
|
}
|
|
1016
|
-
function
|
|
1017
|
-
const i =
|
|
1018
|
-
return
|
|
1019
|
+
function Ii(t, e) {
|
|
1020
|
+
const i = pt(e);
|
|
1021
|
+
return ft(t, [Ti(i, i, { align: "center" })]);
|
|
1019
1022
|
}
|
|
1020
|
-
const
|
|
1021
|
-
class
|
|
1023
|
+
const Oi = "uc-ai-enhancer/history", Ye = 200, Pi = 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 ? `${Oi}/${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(Li);
|
|
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 < Pi);
|
|
1090
|
+
r.length > Ye && (r = r.sort((o, a) => a.createdAt - o.createdAt).slice(0, Ye));
|
|
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 Li(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 Di(t) {
|
|
1122
1125
|
try {
|
|
1123
|
-
const e =
|
|
1126
|
+
const e = ct(t);
|
|
1124
1127
|
if (e.kind === "file")
|
|
1125
1128
|
return {
|
|
1126
1129
|
uuid: e.uuid,
|
|
1127
|
-
cdnUrlModifiers:
|
|
1130
|
+
cdnUrlModifiers: ht(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 Ni(t, e) {
|
|
1138
|
+
return e ? e(t, Di(t)) : t;
|
|
1136
1139
|
}
|
|
1137
|
-
class
|
|
1140
|
+
class mt {
|
|
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 = Ni(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 Wr = `<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>`, Vr = `<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>`, Bi = `<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>`, ji = `<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>`, Gi = `<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>`, Hi = `<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>`, Wi = ":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 Vi = Object.defineProperty, qi = Object.getOwnPropertyDescriptor, z = (t, e, i, r) => {
|
|
1183
|
+
for (var s = r > 1 ? void 0 : r ? qi(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 && Vi(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) => O(t.value) ?
|
|
1189
|
+
super(...arguments), this.options = [], this.selected = null, this.busy = !1, this.labelText = null, this.labelFor = (t) => O(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 O(t) ?
|
|
1214
|
+
return O(t) ? Ft(t) : ji;
|
|
1212
1215
|
}
|
|
1213
1216
|
_triggerLabel() {
|
|
1214
1217
|
const t = this.selected;
|
|
1215
1218
|
if (!t) return "";
|
|
1216
|
-
if (O(t)) return
|
|
1219
|
+
if (O(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">${O(e.value) ?
|
|
1250
|
+
${re(this._iconFor(e.value))}
|
|
1251
|
+
<span class="option-ratio">${O(e.value) ? ee(e.value) : ""}</span>
|
|
1249
1252
|
<span class="option-label">${this.labelFor(e)}</span>
|
|
1250
1253
|
</button>
|
|
1251
1254
|
`;
|
|
@@ -1255,7 +1258,7 @@ let A = class extends G {
|
|
|
1255
1258
|
`;
|
|
1256
1259
|
}
|
|
1257
1260
|
};
|
|
1258
|
-
A.styles = j(
|
|
1261
|
+
A.styles = j(Wi);
|
|
1259
1262
|
z([
|
|
1260
1263
|
c({ attribute: !1 })
|
|
1261
1264
|
], A.prototype, "options", 2);
|
|
@@ -1280,34 +1283,34 @@ z([
|
|
|
1280
1283
|
A = z([
|
|
1281
1284
|
H("uc-ai-aspect-ratio")
|
|
1282
1285
|
], A);
|
|
1283
|
-
const
|
|
1284
|
-
let
|
|
1285
|
-
const
|
|
1286
|
+
const Ki = /* @__PURE__ */ new WeakMap();
|
|
1287
|
+
let Xe = 0;
|
|
1288
|
+
const fe = /* @__PURE__ */ new Map(), Je = /* @__PURE__ */ new WeakSet(), Ze = () => new Promise((t) => requestAnimationFrame(t)), Qe = (t, e) => {
|
|
1286
1289
|
const i = t - e;
|
|
1287
1290
|
return i === 0 ? void 0 : i;
|
|
1288
|
-
},
|
|
1291
|
+
}, et = (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 = Qe(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 = Qe(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 = et(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 = et(t, e);
|
|
1306
1309
|
return { value: r, overrideFrom: i, transform: r == null || isNaN(r) ? void 0 : `scaleY(${r})` };
|
|
1307
|
-
} },
|
|
1308
|
-
class
|
|
1310
|
+
} }, Yi = { duration: 333, easing: "ease-in-out" }, Xi = ["left", "top", "width", "height", "opacity", "color", "background"], tt = /* @__PURE__ */ new WeakMap();
|
|
1311
|
+
class Ji extends at {
|
|
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 === ot.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 rt;
|
|
1325
1328
|
}
|
|
1326
1329
|
getController() {
|
|
1327
|
-
return
|
|
1330
|
+
return Ki.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, tt.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 = Xi), 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 Ze;
|
|
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, Xe++, e.forEach((l) => l.zIndex = Xe);
|
|
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 Ze(), (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 = tt.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 = Je.has(this.u);
|
|
1425
1428
|
return e || this.u.updateComplete.then(() => {
|
|
1426
|
-
|
|
1429
|
+
Je.add(this.u);
|
|
1427
1430
|
}), e;
|
|
1428
1431
|
}
|
|
1429
1432
|
V(e, i = this.P()) {
|
|
1430
|
-
const r = { ...
|
|
1433
|
+
const r = { ...Yi };
|
|
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 Zi = st(Ji), Qi = ["top", "right", "bottom", "left"];
|
|
1483
|
+
class er extends at {
|
|
1481
1484
|
constructor(e) {
|
|
1482
|
-
if (super(e), e.type !==
|
|
1485
|
+
if (super(e), e.type !== ot.ELEMENT) throw Error("The `position` directive must be used in attribute position.");
|
|
1483
1486
|
}
|
|
1484
1487
|
render(e, i) {
|
|
1485
|
-
return
|
|
1488
|
+
return rt;
|
|
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 = Qi.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
|
+
st(er);
|
|
1509
|
+
const tr = ':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 ir = Object.defineProperty, rr = Object.getOwnPropertyDescriptor, L = (t, e, i, r) => {
|
|
1511
|
+
for (var s = r > 1 ? void 0 : r ? rr(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 && ir(e, i, s), s;
|
|
1511
1514
|
};
|
|
1512
|
-
const
|
|
1515
|
+
const sr = 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 mt(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")) {
|
|
@@ -1545,11 +1548,11 @@ let U = class extends G {
|
|
|
1545
1548
|
</button>
|
|
1546
1549
|
</div>
|
|
1547
1550
|
` : v}
|
|
1548
|
-
${
|
|
1551
|
+
${wt(
|
|
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, sr)), 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
|
+
${Zi({ 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
|
|
@@ -1582,7 +1585,7 @@ let U = class extends G {
|
|
|
1582
1585
|
`;
|
|
1583
1586
|
}
|
|
1584
1587
|
};
|
|
1585
|
-
U.styles = j(
|
|
1588
|
+
U.styles = j(tr);
|
|
1586
1589
|
L([
|
|
1587
1590
|
c({ attribute: !1 })
|
|
1588
1591
|
], U.prototype, "entries", 2);
|
|
@@ -1607,11 +1610,11 @@ L([
|
|
|
1607
1610
|
U = L([
|
|
1608
1611
|
H("uc-ai-history")
|
|
1609
1612
|
], U);
|
|
1610
|
-
const
|
|
1611
|
-
var
|
|
1612
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1613
|
+
const or = ':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 ar = Object.defineProperty, nr = Object.getOwnPropertyDescriptor, D = (t, e, i, r) => {
|
|
1615
|
+
for (var s = r > 1 ? void 0 : r ? nr(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 && ar(e, i, s), s;
|
|
1615
1618
|
};
|
|
1616
1619
|
let T = class extends G {
|
|
1617
1620
|
constructor() {
|
|
@@ -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(Bi)}</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(or);
|
|
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 lr = ":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 cr = Object.defineProperty, hr = Object.getOwnPropertyDescriptor, Y = (t, e, i, r) => {
|
|
1725
|
+
for (var s = r > 1 ? void 0 : r ? hr(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 && cr(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(lr);
|
|
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, ur = `#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
|
+
}`, dr = `#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
|
+
}`, pr = `#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
|
+
}`, fr = `#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(ur, dr), this._imgProgram = this._link(pr, fr), 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 mr = 1200, _r = 800, gr = 1.5, it = (t) => 1 - (1 - t) ** 3, vr = {
|
|
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 br {
|
|
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 = { ...vr }, 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) * it(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) * it(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 / (mr * _r)) ** 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, gr) : 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. */
|
|
@@ -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 yr = ":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 wr = Object.defineProperty, xr = Object.getOwnPropertyDescriptor, y = (t, e, i, r) => {
|
|
2475
|
+
for (var s = r > 1 ? void 0 : r ? xr(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 && wr(e, i, s), s;
|
|
2475
2478
|
};
|
|
2476
|
-
const
|
|
2479
|
+
const kr = 3 / 2, Er = 70;
|
|
2477
2480
|
let g = 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 br(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
|
+
}, Er));
|
|
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() {
|
|
@@ -2631,7 +2634,7 @@ let g = class extends G {
|
|
|
2631
2634
|
this._fullscreen && this.fullsizeUrl ? f`<img class="layer full" src="${this.fullsizeUrl}" alt="${this.alt || "AI image"}" decoding="async" />` : v}
|
|
2632
2635
|
${t ? f`<img
|
|
2633
2636
|
class="preload"
|
|
2634
|
-
src="${
|
|
2637
|
+
src="${xt(this.url ?? void 0)}"
|
|
2635
2638
|
alt=""
|
|
2636
2639
|
aria-hidden="true"
|
|
2637
2640
|
decoding="async"
|
|
@@ -2650,7 +2653,7 @@ let g = class extends G {
|
|
|
2650
2653
|
@focus=${this._preloadFullsize}
|
|
2651
2654
|
@click=${this._toggleFullscreen}
|
|
2652
2655
|
>
|
|
2653
|
-
${
|
|
2656
|
+
${re(this._fullscreen ? Hi : Gi)}
|
|
2654
2657
|
</button>
|
|
2655
2658
|
` : v}
|
|
2656
2659
|
<span class="sr-only" role="status" aria-live="polite">${this.busy ? this.busyLabel : ""}</span>
|
|
@@ -2658,7 +2661,7 @@ let g = class extends G {
|
|
|
2658
2661
|
`;
|
|
2659
2662
|
}
|
|
2660
2663
|
};
|
|
2661
|
-
g.styles = j(
|
|
2664
|
+
g.styles = j(yr);
|
|
2662
2665
|
y([
|
|
2663
2666
|
c()
|
|
2664
2667
|
], g.prototype, "url", 2);
|
|
@@ -2725,11 +2728,11 @@ y([
|
|
|
2725
2728
|
g = y([
|
|
2726
2729
|
H("uc-ai-canvas")
|
|
2727
2730
|
], g);
|
|
2728
|
-
const
|
|
2729
|
-
var
|
|
2730
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
2731
|
+
const Rr = ":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 Sr = Object.defineProperty, Cr = Object.getOwnPropertyDescriptor, ae = (t, e, i, r) => {
|
|
2733
|
+
for (var s = r > 1 ? void 0 : r ? Cr(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 && Sr(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(Rr);
|
|
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 $r = ":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 Ar = Object.defineProperty, Ur = Object.getOwnPropertyDescriptor, m = (t, e, i, r) => {
|
|
2780
|
+
for (var s = r > 1 ? void 0 : r ? Ur(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 && Ar(e, i, s), s;
|
|
2780
2783
|
};
|
|
2781
|
-
const
|
|
2784
|
+
const Tr = ["top", "bottom"], Fr = ["full", "available"], Mr = [
|
|
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 Ei(this), this._history = new zi(this), this._secure = new mt(this), this._localeStrings = B, this._localeToken = 0, this._lastPreviewUrl = null, this._ratioOptionsCache = /* @__PURE__ */ new Map(), this._labelForOption = (t) => t.labelKey ? this._l(t.labelKey) : "";
|
|
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 xi({
|
|
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
|
-
O(s) && !this._standardRatios().some((o) =>
|
|
2822
|
+
O(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 Ci(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(Mi(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(ke);
|
|
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, Et)) ?? 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(At), 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
|
/**
|
|
@@ -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
|
|
@@ -3085,15 +3089,15 @@ let d = class extends G {
|
|
|
3085
3089
|
}
|
|
3086
3090
|
/** @internal */
|
|
3087
3091
|
render() {
|
|
3088
|
-
var
|
|
3089
|
-
const t = this._mode, e = t === "edit" && !this.sourceUuid && !this.sourceFileInfo, i =
|
|
3092
|
+
var Fe, Me;
|
|
3093
|
+
const t = this._mode, e = t === "edit" && !this.sourceUuid && !this.sourceFileInfo, i = ye[t].placeholderKey, r = ((Fe = this.presets) == null ? void 0 : Fe[t]) ?? ye[t].presets, s = this._gen.busy || !this._gen.result, o = this._ratioOptions(t), a = this._displayUrl != null, n = O(this._selectedRatio) ? this._selectedRatio[0] / this._selectedRatio[1] : null, l = {
|
|
3090
3094
|
stage: !0,
|
|
3091
3095
|
"is-empty": !a
|
|
3092
|
-
}, h =
|
|
3096
|
+
}, h = Tr.includes(this.composerPlacement) ? this.composerPlacement : "bottom", u = (Fr.includes(this.canvasFit) ? this.canvasFit : "available") === "full", _ = !u, x = `${u ? "overlay" : "docked"}-${h}`, w = Mr.includes(this.historyPlacement) ? this.historyPlacement : "composer-above", $ = w === "composer-above" || w === "composer-below", R = (u || _ && this.composerAutoHide) && $, I = w === "canvas-top" ? "top" : w === "canvas-bottom" ? "bottom" : h, W = this._historyEntries, X = W.length > 0 || e, ne = X ? f`
|
|
3093
3097
|
<uc-ai-history
|
|
3094
3098
|
.busy=${this._gen.busy}
|
|
3095
3099
|
.entries=${W}
|
|
3096
|
-
.selectedUuid=${((
|
|
3100
|
+
.selectedUuid=${((Me = this._gen.result) == null ? void 0 : Me.uuid) ?? this._sourceUuid}
|
|
3097
3101
|
?show-start-over=${e}
|
|
3098
3102
|
start-over-label="${this._l("ai-enhancer-start-over")}"
|
|
3099
3103
|
list-label="${this._l("ai-enhancer-history-title")}"
|
|
@@ -3101,7 +3105,7 @@ let d = class extends G {
|
|
|
3101
3105
|
@uc:select=${this._onSelectHistoryEntry}
|
|
3102
3106
|
@uc:start-over=${this._onStartOver}
|
|
3103
3107
|
></uc-ai-history>
|
|
3104
|
-
` : v,
|
|
3108
|
+
` : v, _t = f`
|
|
3105
3109
|
<uc-ai-prompt-row
|
|
3106
3110
|
.mode=${t}
|
|
3107
3111
|
.value=${this._prompt}
|
|
@@ -3133,7 +3137,7 @@ let d = class extends G {
|
|
|
3133
3137
|
></uc-ai-aspect-ratio>
|
|
3134
3138
|
` : v}
|
|
3135
3139
|
</uc-ai-prompt-row>
|
|
3136
|
-
`,
|
|
3140
|
+
`, le = f`
|
|
3137
3141
|
<div
|
|
3138
3142
|
class=${S({
|
|
3139
3143
|
composer: !0,
|
|
@@ -3143,23 +3147,23 @@ let d = class extends G {
|
|
|
3143
3147
|
})}
|
|
3144
3148
|
>
|
|
3145
3149
|
<div class="composer__content">
|
|
3146
|
-
${R && w === "composer-above" ?
|
|
3147
|
-
${
|
|
3148
|
-
${R && w === "composer-below" ?
|
|
3150
|
+
${R && w === "composer-above" ? ne : v}
|
|
3151
|
+
${_t}
|
|
3152
|
+
${R && w === "composer-below" ? ne : v}
|
|
3149
3153
|
</div>
|
|
3150
3154
|
</div>
|
|
3151
|
-
`,
|
|
3155
|
+
`, gt = X && !R ? f`<div
|
|
3152
3156
|
class=${S({
|
|
3153
3157
|
"history-pinned": !0,
|
|
3154
3158
|
"history-pinned--docked": _,
|
|
3155
3159
|
[`history-pinned--canvas-${I}`]: !0
|
|
3156
3160
|
})}
|
|
3157
3161
|
>
|
|
3158
|
-
${
|
|
3159
|
-
</div>` : v,
|
|
3162
|
+
${ne}
|
|
3163
|
+
</div>` : v, vt = this.composerAutoHide && u ? f`
|
|
3160
3164
|
<div class=${S({ "dock-hotzone": !0, [`dock-hotzone--${h}`]: !0 })}></div>
|
|
3161
3165
|
<div class=${S({ "composer-fade": !0, [`composer-fade--${h}`]: !0 })}></div>
|
|
3162
|
-
` : v,
|
|
3166
|
+
` : v, Ue = this.toolbarPlacement === "top", Te = f`
|
|
3163
3167
|
<uc-ai-footer
|
|
3164
3168
|
cancel-label="${this._l("ai-enhancer-cancel")}"
|
|
3165
3169
|
primary-label="${this._l("ai-enhancer-done-btn")}"
|
|
@@ -3174,8 +3178,8 @@ let d = class extends G {
|
|
|
3174
3178
|
role="region"
|
|
3175
3179
|
aria-label="${this._l(t === "edit" ? "ai-enhancer-edit-title" : "ai-enhancer-generate-title")}"
|
|
3176
3180
|
>
|
|
3177
|
-
${
|
|
3178
|
-
${_ && h === "top" ?
|
|
3181
|
+
${Ue ? Te : v}
|
|
3182
|
+
${_ && h === "top" ? le : v}
|
|
3179
3183
|
<div class=${S(l)}>
|
|
3180
3184
|
<uc-ai-canvas
|
|
3181
3185
|
.url=${this._previewUrl}
|
|
@@ -3191,21 +3195,21 @@ let d = class extends G {
|
|
|
3191
3195
|
exit-fullscreen-label="${this._l("ai-enhancer-exit-fullscreen")}"
|
|
3192
3196
|
></uc-ai-canvas>
|
|
3193
3197
|
|
|
3198
|
+
${vt}
|
|
3194
3199
|
${gt}
|
|
3195
|
-
${
|
|
3196
|
-
${u ? ae : v}
|
|
3200
|
+
${u ? le : v}
|
|
3197
3201
|
|
|
3198
3202
|
${this._gen.error ? f`<div class="error-box" role="alert">
|
|
3199
3203
|
<div class="error-box__card">${this._errorMessage()}</div>
|
|
3200
3204
|
</div>` : v}
|
|
3201
3205
|
</div>
|
|
3202
|
-
${_ && h === "bottom" ?
|
|
3203
|
-
${
|
|
3206
|
+
${_ && h === "bottom" ? le : v}
|
|
3207
|
+
${Ue ? v : Te}
|
|
3204
3208
|
</div>
|
|
3205
3209
|
`;
|
|
3206
3210
|
}
|
|
3207
3211
|
};
|
|
3208
|
-
d.styles = j(
|
|
3212
|
+
d.styles = j($r);
|
|
3209
3213
|
m([
|
|
3210
3214
|
c({ attribute: "source-uuid" })
|
|
3211
3215
|
], d.prototype, "sourceUuid", 2);
|
|
@@ -3237,7 +3241,7 @@ m([
|
|
|
3237
3241
|
c({ attribute: !1 })
|
|
3238
3242
|
], d.prototype, "secureDeliveryProxyUrlResolver", 2);
|
|
3239
3243
|
m([
|
|
3240
|
-
c({ type: Array, attribute: "aspect-ratios", converter: (t) => t ?
|
|
3244
|
+
c({ type: Array, attribute: "aspect-ratios", converter: (t) => t ? Ut(t) : null })
|
|
3241
3245
|
], d.prototype, "aspectRatios", 2);
|
|
3242
3246
|
m([
|
|
3243
3247
|
c({ attribute: "locale-name" })
|
|
@@ -3294,11 +3298,11 @@ d = m([
|
|
|
3294
3298
|
H("uc-ai-enhancer")
|
|
3295
3299
|
], d);
|
|
3296
3300
|
export {
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3301
|
+
Vr as I,
|
|
3302
|
+
pe as L,
|
|
3303
|
+
kt as P,
|
|
3300
3304
|
d as U,
|
|
3301
|
-
|
|
3305
|
+
Wr as a,
|
|
3302
3306
|
B as e,
|
|
3303
|
-
|
|
3307
|
+
ke as i
|
|
3304
3308
|
};
|