@uploadcare/ai-enhancer 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +314 -0
  2. package/dist/UcAiEnhancer-D0mic9eT.cjs +444 -0
  3. package/dist/UcAiEnhancer-D1z2-v9q.js +3299 -0
  4. package/dist/ai-enhancer.cjs +1 -0
  5. package/dist/ai-enhancer.d.ts +532 -0
  6. package/dist/ai-enhancer.js +5 -0
  7. package/dist/ar-0rfB4z3f.js +29 -0
  8. package/dist/ar-DYF6cE7-.cjs +1 -0
  9. package/dist/az-CyK2FKx4.js +29 -0
  10. package/dist/az-UnBZVrss.cjs +1 -0
  11. package/dist/ca-CAoPN2lq.js +29 -0
  12. package/dist/ca-CuwmB1Gw.cjs +1 -0
  13. package/dist/cs-AwdVESvI.cjs +1 -0
  14. package/dist/cs-gutH5sZI.js +29 -0
  15. package/dist/da-BC58D6q4.cjs +1 -0
  16. package/dist/da-CjNgqmRE.js +29 -0
  17. package/dist/de-BC0mixOW.js +29 -0
  18. package/dist/de-DEF79Sit.cjs +1 -0
  19. package/dist/el-DFmdf7I1.cjs +1 -0
  20. package/dist/el-lfrMPw8j.js +29 -0
  21. package/dist/es-BkhHze52.cjs +1 -0
  22. package/dist/es-D0qq2qhV.js +29 -0
  23. package/dist/et-BhG8YNek.cjs +1 -0
  24. package/dist/et-Drgz7t_M.js +29 -0
  25. package/dist/fi-Cyypxkac.cjs +1 -0
  26. package/dist/fi-DA-ikQJH.js +29 -0
  27. package/dist/fr-CFVF2OgM.js +29 -0
  28. package/dist/fr-nhxYdowR.cjs +1 -0
  29. package/dist/he-0YWGAesl.cjs +1 -0
  30. package/dist/he-BZFhB0Wn.js +29 -0
  31. package/dist/hy-CY51XCFd.cjs +1 -0
  32. package/dist/hy-DvnjH66b.js +29 -0
  33. package/dist/is-DLmDXgjm.js +29 -0
  34. package/dist/is-Nssowr9F.cjs +1 -0
  35. package/dist/it-Ch7oZNp5.js +29 -0
  36. package/dist/it-DK-Xszlz.cjs +1 -0
  37. package/dist/ja-BZtfRu9w.cjs +1 -0
  38. package/dist/ja-B_rMbHKq.js +29 -0
  39. package/dist/ka-DSCPqvM4.cjs +1 -0
  40. package/dist/ka-cFaf_BUT.js +29 -0
  41. package/dist/kk-DGN5Pk5W.cjs +1 -0
  42. package/dist/kk-K2vhij8e.js +29 -0
  43. package/dist/ko-BnVYElzl.cjs +1 -0
  44. package/dist/ko-DeRxambx.js +29 -0
  45. package/dist/lv-CizQndPI.js +29 -0
  46. package/dist/lv-DxBkV0GW.cjs +1 -0
  47. package/dist/nb-BxtTiZSk.js +29 -0
  48. package/dist/nb-ByZ1aeGs.cjs +1 -0
  49. package/dist/nl-C12-qyO6.js +29 -0
  50. package/dist/nl-DaahHFo1.cjs +1 -0
  51. package/dist/pl-BRDowgAP.cjs +1 -0
  52. package/dist/pl-DnVfWHgL.js +29 -0
  53. package/dist/plugin.cjs +2 -0
  54. package/dist/plugin.d.ts +62 -0
  55. package/dist/plugin.js +200 -0
  56. package/dist/pt-DTs3scou.cjs +1 -0
  57. package/dist/pt-JpSURXrS.js +29 -0
  58. package/dist/ro-CtdLT2xS.cjs +1 -0
  59. package/dist/ro-qmi5XBhp.js +29 -0
  60. package/dist/ru-COjncrMy.cjs +1 -0
  61. package/dist/ru-C_rsFTyL.js +29 -0
  62. package/dist/sk-10Fuyb_E.js +29 -0
  63. package/dist/sk-DZF9evla.cjs +1 -0
  64. package/dist/sr-CTcREzcN.js +29 -0
  65. package/dist/sr-TVYoxU-s.cjs +1 -0
  66. package/dist/sv-BfxAcWfi.js +29 -0
  67. package/dist/sv-UPU_fRLB.cjs +1 -0
  68. package/dist/tr-B4vyEPOt.cjs +1 -0
  69. package/dist/tr-CLDSkp-W.js +29 -0
  70. package/dist/uk-BT0jZlPK.js +29 -0
  71. package/dist/uk-EP2kCiy9.cjs +1 -0
  72. package/dist/vi-BpWn9XQo.js +29 -0
  73. package/dist/vi-DI3QVinB.cjs +1 -0
  74. package/dist/zh-BxANO4fS.cjs +1 -0
  75. package/dist/zh-C0AOtYB8.js +29 -0
  76. package/dist/zh-TW-BNfdfwdz.js +29 -0
  77. package/dist/zh-TW-BxiS-SSf.cjs +1 -0
  78. package/package.json +81 -0
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./UcAiEnhancer-D0mic9eT.cjs");Object.defineProperty(exports,"UcAiEnhancer",{enumerable:!0,get:()=>e.UcAiEnhancer});exports.enLocale=e.enLocale;
@@ -0,0 +1,532 @@
1
+ import { CSSResult } from 'lit';
2
+ import { LitElement } from 'lit';
3
+ import { Metadata } from '@uploadcare/upload-client';
4
+ import { PropertyValues } from 'lit';
5
+ import { TemplateResult } from 'lit';
6
+ import { UploadcareFile } from '@uploadcare/upload-client';
7
+
8
+ /**
9
+ * The editor's modes. Currently derived from whether a source image is present
10
+ * (`generate` without one, `edit` with). Designed to grow — adding a capability
11
+ * like `'outpaint'` here is additive, and the `presets` map (keyed by this type)
12
+ * extends with it without breaking existing configs.
13
+ */
14
+ export declare type AiEditorMode = 'generate' | 'edit';
15
+
16
+ /**
17
+ * A locale's strings. Core keys are required; the per-error-code messages are
18
+ * optional (they fall back to English / the generic message), so translations
19
+ * can adopt them incrementally without every locale listing every code.
20
+ */
21
+ export declare type AiEnhancerLocale = Record<keyof typeof coreLocale, string> & Partial<Record<keyof typeof errorLocale, string>>;
22
+
23
+ /** A quick-start preset chip: clicking it fills the prompt with `prompt`. */
24
+ export declare type AiPreset = {
25
+ label: string;
26
+ prompt: string;
27
+ };
28
+
29
+ /**
30
+ * Per-mode preset overrides, keyed by {@link AiEditorMode}. Partial so a config
31
+ * may set some modes and leave the rest on their built-in defaults — and so
32
+ * future modes are additive (a new key, never a required change).
33
+ */
34
+ export declare type AiPresets = Partial<Record<AiEditorMode, AiPreset[]>>;
35
+
36
+ declare type AiProvider = {
37
+ id: string;
38
+ /** Run a text→image generate or image→image edit job, resolved to a result. */
39
+ generate(request: AiProviderRequest): Promise<AiProviderResult>;
40
+ /**
41
+ * Resolve a stored file's uuid to a display URL. Optional: only used when the
42
+ * editor opens on an existing {@link AiProviderRequest.source} image. A
43
+ * generate-only provider can omit it.
44
+ */
45
+ resolveCdnUrl?(uuid: string): Promise<string>;
46
+ /**
47
+ * Resolve a stored file's info (dimensions, original filename, …) by uuid.
48
+ * Optional: only used to frame/name an existing `source` image. A
49
+ * generate-only provider can omit it.
50
+ */
51
+ getFileInfo?(uuid: string, signal?: AbortSignal): Promise<UploadcareFile>;
52
+ };
53
+
54
+ declare type AiProviderRequest = {
55
+ prompt: string;
56
+ mode: AiEditorMode;
57
+ /**
58
+ * Target aspect ratio. Required for `generate`; optional for `edit` (omitted
59
+ * to preserve the source's ratio). Validated by the editor before the call.
60
+ */
61
+ aspectRatio?: AspectRatio;
62
+ /** UUID of the source image to edit. Required when `mode` is `edit`. */
63
+ source?: string;
64
+ /** Desired output filename. Falls back to the provider's configured default. */
65
+ filename?: string;
66
+ signal?: AbortSignal;
67
+ metadata?: Metadata;
68
+ };
69
+
70
+ declare type AiProviderResult = {
71
+ url: string;
72
+ /** UUID of the resulting Uploadcare file (same as `file.uuid`). */
73
+ uuid: string;
74
+ prompt: string;
75
+ mode: AiEditorMode;
76
+ /** The resulting file as an Uploadcare file object. */
77
+ file: UploadcareFile;
78
+ };
79
+
80
+ export declare type AspectRatio = readonly [number, number];
81
+
82
+ /**
83
+ * How the canvas sizes relative to the composer.
84
+ * - `available`: the canvas uses only the space left by the composer, which is
85
+ * docked outside the image (history chips still overlay the canvas).
86
+ * - `full`: the canvas fills the whole area and the composer floats over it.
87
+ */
88
+ export declare type CanvasFit = 'full' | 'available';
89
+
90
+ /** Which edge the composer (prompt + chips + aspect ratio) sits on. */
91
+ export declare type ComposerPlacement = 'top' | 'bottom';
92
+
93
+ /** Core UI strings — every locale must provide all of these. */
94
+ declare const coreLocale: {
95
+ 'ai-enhancer-source-label': string;
96
+ 'ai-enhancer-file-action-label': string;
97
+ 'ai-enhancer-generate-title': string;
98
+ 'ai-enhancer-edit-title': string;
99
+ 'ai-enhancer-generate-placeholder': string;
100
+ 'ai-enhancer-edit-placeholder': string;
101
+ 'ai-enhancer-cancel': string;
102
+ 'ai-enhancer-generate-btn': string;
103
+ 'ai-enhancer-done-btn': string;
104
+ 'ai-enhancer-start-over': string;
105
+ 'ai-enhancer-history-title': string;
106
+ 'ai-enhancer-busy': string;
107
+ 'ai-enhancer-error': string;
108
+ 'ai-enhancer-fullscreen': string;
109
+ 'ai-enhancer-exit-fullscreen': string;
110
+ 'ai-enhancer-aspect-ratio-aria': string;
111
+ 'ai-enhancer-aspect-original': string;
112
+ 'ai-enhancer-aspect-square': string;
113
+ 'ai-enhancer-aspect-tall': string;
114
+ 'ai-enhancer-aspect-wide': string;
115
+ 'ai-enhancer-aspect-portrait': string;
116
+ 'ai-enhancer-aspect-landscape': string;
117
+ 'ai-enhancer-aspect-vertical': string;
118
+ 'ai-enhancer-aspect-widescreen': string;
119
+ };
120
+
121
+ export declare type DoneDetail = {
122
+ url: string;
123
+ /** UUID of the committed Uploadcare file (same as `file.uuid`). */
124
+ uuid: string;
125
+ prompt: string;
126
+ mode: AiEditorMode;
127
+ aspectRatio?: AspectRatio;
128
+ /** The committed result as an Uploadcare file object. */
129
+ file: UploadcareFile;
130
+ };
131
+
132
+ export declare const enLocale: {
133
+ 'ai-enhancer-error-invalid_request': string;
134
+ 'ai-enhancer-error-invalid_source': string;
135
+ 'ai-enhancer-error-source_not_found': string;
136
+ 'ai-enhancer-error-source_not_image': string;
137
+ 'ai-enhancer-error-source_url_unavailable': string;
138
+ 'ai-enhancer-error-invalid_aspect_ratio': string;
139
+ 'ai-enhancer-error-canvas_too_large': string;
140
+ 'ai-enhancer-error-canvas_dimension_too_small': string;
141
+ 'ai-enhancer-error-source_extends_beyond_canvas': string;
142
+ 'ai-enhancer-error-derivative_disabled': string;
143
+ 'ai-enhancer-error-job_id_required': string;
144
+ 'ai-enhancer-error-job_not_found': string;
145
+ 'ai-enhancer-error-content_moderated': string;
146
+ 'ai-enhancer-error-provider_unavailable': string;
147
+ 'ai-enhancer-error-generation_timeout': string;
148
+ 'ai-enhancer-error-invalid_input': string;
149
+ 'ai-enhancer-error-RequestThrottledError': string;
150
+ 'ai-enhancer-error-DownloadFileHTTPClientError': string;
151
+ 'ai-enhancer-error-DownloadFileNotFoundError': string;
152
+ 'ai-enhancer-error-DownloadFileTaskFailedError': string;
153
+ 'ai-enhancer-source-label': string;
154
+ 'ai-enhancer-file-action-label': string;
155
+ 'ai-enhancer-generate-title': string;
156
+ 'ai-enhancer-edit-title': string;
157
+ 'ai-enhancer-generate-placeholder': string;
158
+ 'ai-enhancer-edit-placeholder': string;
159
+ 'ai-enhancer-cancel': string;
160
+ 'ai-enhancer-generate-btn': string;
161
+ 'ai-enhancer-done-btn': string;
162
+ 'ai-enhancer-start-over': string;
163
+ 'ai-enhancer-history-title': string;
164
+ 'ai-enhancer-busy': string;
165
+ 'ai-enhancer-error': string;
166
+ 'ai-enhancer-fullscreen': string;
167
+ 'ai-enhancer-exit-fullscreen': string;
168
+ 'ai-enhancer-aspect-ratio-aria': string;
169
+ 'ai-enhancer-aspect-original': string;
170
+ 'ai-enhancer-aspect-square': string;
171
+ 'ai-enhancer-aspect-tall': string;
172
+ 'ai-enhancer-aspect-wide': string;
173
+ 'ai-enhancer-aspect-portrait': string;
174
+ 'ai-enhancer-aspect-landscape': string;
175
+ 'ai-enhancer-aspect-vertical': string;
176
+ 'ai-enhancer-aspect-widescreen': string;
177
+ };
178
+
179
+ /**
180
+ * Friendly messages for known platform/job `error_code`s, keyed
181
+ * `ai-enhancer-error-<code>`. The editor looks these up by code and falls back
182
+ * to the generic `ai-enhancer-error`. They're optional per locale (English here
183
+ * is the default) and overridable via the `l10n` property like any other string.
184
+ */
185
+ declare const errorLocale: {
186
+ 'ai-enhancer-error-invalid_request': string;
187
+ 'ai-enhancer-error-invalid_source': string;
188
+ 'ai-enhancer-error-source_not_found': string;
189
+ 'ai-enhancer-error-source_not_image': string;
190
+ 'ai-enhancer-error-source_url_unavailable': string;
191
+ 'ai-enhancer-error-invalid_aspect_ratio': string;
192
+ 'ai-enhancer-error-canvas_too_large': string;
193
+ 'ai-enhancer-error-canvas_dimension_too_small': string;
194
+ 'ai-enhancer-error-source_extends_beyond_canvas': string;
195
+ 'ai-enhancer-error-derivative_disabled': string;
196
+ 'ai-enhancer-error-job_id_required': string;
197
+ 'ai-enhancer-error-job_not_found': string;
198
+ 'ai-enhancer-error-content_moderated': string;
199
+ 'ai-enhancer-error-provider_unavailable': string;
200
+ 'ai-enhancer-error-generation_timeout': string;
201
+ 'ai-enhancer-error-invalid_input': string;
202
+ 'ai-enhancer-error-RequestThrottledError': string;
203
+ 'ai-enhancer-error-DownloadFileHTTPClientError': string;
204
+ 'ai-enhancer-error-DownloadFileNotFoundError': string;
205
+ 'ai-enhancer-error-DownloadFileTaskFailedError': string;
206
+ };
207
+
208
+ /**
209
+ * Where the history strip sits.
210
+ * - `composer-above` / `composer-below`: relative to the composer (moves with it).
211
+ * - `canvas-top` / `canvas-bottom`: pinned to that canvas edge, independent of the composer.
212
+ */
213
+ export declare type HistoryPlacement = 'composer-above' | 'composer-below' | 'canvas-top' | 'canvas-bottom';
214
+
215
+ /**
216
+ * Per-file metadata callback, mirroring the file uploader's `metadata` config
217
+ * option. Called at generation time with the source image's file info (the
218
+ * uploader passes its entry's `.fileInfo`); returns the metadata bag, optionally
219
+ * async. Only invoked when there is a source (an edit); a generate-from-scratch
220
+ * gets no callback. Use the static {@link Metadata} form to cover both.
221
+ */
222
+ export declare type MetadataCallback = (fileInfo: UploadcareFile) => Promise<Metadata> | Metadata;
223
+
224
+ /**
225
+ * Resolves the filename given to a generated/edited result. Receives the source
226
+ * image's original filename (`undefined` when generating from scratch) and the
227
+ * 1-based counter of this generation within the session's history (the first is
228
+ * `1`). Returns the desired output filename.
229
+ */
230
+ export declare type OutputFilenameResolver = (originalFilename: string | undefined, counter: number) => string;
231
+
232
+ /** Consumer callback that turns a CDN url into a signed/proxied delivery url. */
233
+ export declare type SecureDeliveryProxyUrlResolver = (previewUrl: string, urlParts: SecureDeliveryUrlParts) => string | Promise<string>;
234
+
235
+ /** Parts of the source CDN url handed to a {@link SecureDeliveryProxyUrlResolver}. */
236
+ export declare type SecureDeliveryUrlParts = {
237
+ uuid: string;
238
+ cdnUrlModifiers: string;
239
+ fileName: string;
240
+ };
241
+
242
+ /* Excluded from this release type: ShimmerConfig */
243
+
244
+ /** Where the toolbar (Cancel / Done) sits within the editor. */
245
+ export declare type ToolbarPlacement = 'bottom' | 'top';
246
+
247
+ /**
248
+ * `<uc-ai-enhancer>` — the standalone AI image generate/edit editor.
249
+ *
250
+ * Generates images from a text prompt and edits an existing image (set
251
+ * {@link sourceUuid} or {@link sourceFileInfo}), backed by Uploadcare's
252
+ * derivative API (configured via {@link pubkey}).
253
+ *
254
+ * @summary AI image generation & editing web component.
255
+ *
256
+ * @fires uc:done - A `CustomEvent<DoneDetail>` fired when the user commits a
257
+ * result (the Done button). `detail` carries the result `url`, `uuid`,
258
+ * `prompt`, `mode`, optional `aspectRatio`, and the `file` object.
259
+ * @fires uc:cancel - Fired when the user cancels (the Cancel button). No detail.
260
+ * @fires uc:error - A `CustomEvent<{ error: unknown }>` fired when a generation
261
+ * throws.
262
+ *
263
+ * @cssprop [--uc-ai-background] - Editor surface background.
264
+ * @cssprop [--uc-ai-foreground] - Primary text/icon colour.
265
+ * @cssprop [--uc-ai-muted-foreground] - Secondary/muted text colour.
266
+ * @cssprop [--uc-ai-accent] - Accent colour for primary actions.
267
+ * @cssprop [--uc-ai-radius-button] - Corner radius for buttons.
268
+ * @cssprop [--uc-ai-transition] - Base transition timing.
269
+ * @cssprop [--uc-ai-dot-grid-color] - Colour of the shimmer dot grid.
270
+ *
271
+ * @see The theming guide for the full token list.
272
+ */
273
+ export declare class UcAiEnhancer extends LitElement {
274
+ /* Excluded from this release type: styles */
275
+ /**
276
+ * UUID of an image to edit. When set (or {@link sourceFileInfo} is), the editor
277
+ * opens straight in edit mode; when absent, it starts in generate mode.
278
+ *
279
+ * Use **either** `sourceUuid` **or** {@link sourceFileInfo}, not both — they're
280
+ * two ways to point at the same source (a uuid the editor looks up, vs. the
281
+ * already-resolved file). The mode is otherwise derived (see {@link _mode}).
282
+ */
283
+ sourceUuid: string | null;
284
+ /**
285
+ * The source image as an `UploadcareFile` — e.g. the object returned by
286
+ * `@uploadcare/upload-client`, or the `fileInfo` of a File Uploader output
287
+ * entry (`OutputFileEntry.fileInfo`). Hands the editor the file directly
288
+ * instead of having it look it up from a uuid.
289
+ *
290
+ * Use **either** `sourceFileInfo` **or** {@link sourceUuid}, not both. Property
291
+ * only.
292
+ */
293
+ sourceFileInfo?: UploadcareFile;
294
+ /**
295
+ * Names the generated/edited result. A string is used verbatim; a function
296
+ * receives `(originalFilename, counter)` and returns the name (see
297
+ * {@link OutputFilenameResolver}). When unset, the result keeps the source's
298
+ * original filename (and falls back to the provider's default when generating
299
+ * from scratch). Property only (the function form can't be an attribute).
300
+ */
301
+ outputFilename?: string | OutputFilenameResolver;
302
+ /**
303
+ * Metadata attached to the resulting Uploadcare file, for both generate and
304
+ * edit. Mirrors the file uploader's `metadata` config: either a static bag
305
+ * (`Record<string, string>`, e.g. `{ source: 'ai-enhancer' }`) or a
306
+ * {@link MetadataCallback} resolved at generation time against the source file.
307
+ * Property only.
308
+ */
309
+ metadata?: Metadata | MetadataCallback | null;
310
+ /** Uploadcare public key. Required to enable generate/edit. */
311
+ pubkey: string;
312
+ /* Excluded from this release type: provider */
313
+ /** Upload API base URL. Defaults to the provider's default. */
314
+ baseUrl?: string;
315
+ /** CDN cname for resolving results (maps to the provider's `cdnBaseUrl`). */
316
+ cdnCname?: string;
317
+ /** Base domain for public-key-prefixed CDN URLs. */
318
+ cdnCnamePrefixed?: string;
319
+ /** Secure-delivery resolver: signs/proxies the CDN urls the editor renders. */
320
+ secureDeliveryProxyUrlResolver?: SecureDeliveryProxyUrlResolver;
321
+ /**
322
+ * Available aspect ratios for the generate flow. When set as an attribute
323
+ * (`aspect-ratios="16:9 5:4 1:1"`), the string is parsed. Falsy / empty
324
+ * input falls back to the popular set.
325
+ */
326
+ aspectRatios: AspectRatio[] | null;
327
+ /** Active locale. The editor lazy-loads its built-in strings for this locale
328
+ * (falling back to English) and layers `localeDefinitionOverride` on top. */
329
+ localeName: string;
330
+ /**
331
+ * Locale string overrides, keyed by locale name — the same shape as the file
332
+ * uploader's `localeDefinitionOverride`. The section matching {@link localeName}
333
+ * is layered on top of that locale's built-in strings, e.g.
334
+ * `{ en: { 'ai-enhancer-generate-btn': 'Make it!' } }`.
335
+ */
336
+ localeDefinitionOverride: Record<string, Partial<AiEnhancerLocale>>;
337
+ /**
338
+ * Presets-only mode: hides the free-text prompt so only the preset chips
339
+ * remain, and selecting a preset starts the generation immediately (there's
340
+ * nothing to type, so no separate send step). Off by default.
341
+ */
342
+ presetsOnly: boolean;
343
+ /**
344
+ * Quick-prompt presets (the chips above the prompt), keyed by mode. Each preset
345
+ * is `{ label, prompt }`: clicking a chip fills the prompt with `prompt`. Modes
346
+ * left out use their built-in set; an empty array hides that mode's chips, e.g.
347
+ * `{ generate: [{ label: 'Logo', prompt: 'A logo of ' }], edit: [] }`.
348
+ *
349
+ * Keyed by {@link AiEditorMode} (and partial), so new modes/capabilities (e.g.
350
+ * `outpaint`) extend this additively — without breaking existing configs.
351
+ */
352
+ presets: AiPresets;
353
+ /** Which edge the composer sits on: `bottom` (default) or `top`. */
354
+ composerPlacement: ComposerPlacement;
355
+ /**
356
+ * How the canvas sizes relative to the composer. `available` (default) shrinks
357
+ * the canvas to the space left by the composer, which is docked outside the
358
+ * image (history chips still overlay the canvas). `full` lets the canvas fill
359
+ * the whole area with the composer floating over it. Auto-hide always floats,
360
+ * so {@link composerAutoHide} implies `full`.
361
+ */
362
+ canvasFit: CanvasFit;
363
+ /**
364
+ * Where the history strip sits. `composer-above` (default) / `composer-below`
365
+ * are relative to the composer; `canvas-top` / `canvas-bottom` pin it to the
366
+ * canvas edge.
367
+ */
368
+ historyPlacement: HistoryPlacement;
369
+ /**
370
+ * Auto-hide ("dock") the floating composer once an image exists: it drops to a
371
+ * small peek at the edge and raises when the pointer approaches its edge or it
372
+ * gains focus. Always floats the composer (implies {@link canvasFit} `full`);
373
+ * off by default.
374
+ */
375
+ composerAutoHide: boolean;
376
+ /** Where the toolbar (Cancel / Done) sits: `bottom` (default) or `top`. */
377
+ toolbarPlacement: ToolbarPlacement;
378
+ /* Excluded from this release type: shimmerConfig */
379
+ private _prompt;
380
+ private _selectedRatio;
381
+ /** Display URL for {@link source}, resolved via the provider's CDN base. */
382
+ private _inputUrl;
383
+ /** Source info fetched from {@link source} when none was injected via
384
+ * {@link sourceFileInfo}. The injected value always takes precedence. */
385
+ private _fetchedFileInfo?;
386
+ /** Last derived mode, to (re)default the ratio selection when it flips. */
387
+ private _lastMode?;
388
+ private _promptRow?;
389
+ private _canvasEl?;
390
+ private readonly _gen;
391
+ private readonly _history;
392
+ private readonly _secure;
393
+ private _provider?;
394
+ /** Effective strings for the active locale (built-ins + overrides). */
395
+ private _localeStrings;
396
+ private _localeToken;
397
+ /* Excluded from this release type: willUpdate */
398
+ /** Load the active locale's built-in strings and layer its overrides on top. */
399
+ private _resolveLocale;
400
+ private _l;
401
+ /** Friendly message for the current failure: the per-`error_code` string
402
+ * (`ai-enhancer-error-<code>`, overridable via the locale) when one is
403
+ * defined, otherwise the generic error message. */
404
+ private _errorMessage;
405
+ /** The source image's uuid, from whichever input was given. */
406
+ private get _sourceUuid();
407
+ /** UUID of the image the editor is currently operating on, if any. */
408
+ private get _currentSourceUuid();
409
+ /**
410
+ * Derived editor mode: `edit` whenever there is a current image (an input
411
+ * source or a generation result), otherwise `generate`. This makes the first
412
+ * successful generation flip the editor into edit mode for free.
413
+ */
414
+ private get _mode();
415
+ /** Resolve the source uuid to a display URL via the provider's CDN base.
416
+ * No-op for a provider that can't resolve uuids (generate-only). */
417
+ private _resolveInputUrl;
418
+ /** Persist the original source as the root node of its lineage, so it survives
419
+ * reloads as the base of the strip. Runs once both its url and file info are
420
+ * known; idempotent in storage. */
421
+ private _persistSourceEntry;
422
+ /** Effective source info: the injected value, else the fetched fallback. */
423
+ private get _effectiveSourceFileInfo();
424
+ /** Resolve the source's file info — an injected {@link sourceFileInfo} wins;
425
+ * otherwise fetch it from {@link sourceUuid}. Failures fall back silently. */
426
+ private _resolveSourceFileInfo;
427
+ private get _displayUrl();
428
+ /**
429
+ * The original source image as a strip entry, so editing always shows what you
430
+ * started from and lets you revert to it. Display-only — it's not a generation,
431
+ * so it's never persisted. `null` until the source's url and file info are
432
+ * known, or in generate mode (no source).
433
+ */
434
+ private get _sourceEntry();
435
+ /** Strip entries: the generated results (newest-first) plus the original source
436
+ * appended as the base (oldest) when editing. */
437
+ private get _historyEntries();
438
+ /**
439
+ * Intrinsic ratio of the image currently on the canvas, from metadata when
440
+ * known — the displayed result's file info, else the source's. Lets the canvas
441
+ * frame correctly before the image decodes. `null` when unknown.
442
+ */
443
+ private _displayedNaturalRatio;
444
+ /** Last non-null resolved preview, kept on screen while an async resolver runs. */
445
+ private _lastPreviewUrl;
446
+ /** CDN-optimized, secure-delivery-resolved rendition for the on-canvas preview. */
447
+ private get _previewUrl();
448
+ /** Full-resolution rendition for fullscreen, secure-delivery-resolved. */
449
+ private get _fullsizeUrl();
450
+ /** The configured (or popular) standard ratios, validated. */
451
+ private _standardRatios;
452
+ /**
453
+ * The ratio the generate flow starts on: the prototype's landscape default
454
+ * ({@link DEFAULT_GENERATE_RATIO}) when it's in the available set, else the
455
+ * first available ratio.
456
+ */
457
+ private _defaultGenerateRatio;
458
+ /**
459
+ * Options for the ratio picker. In edit mode a leading "Original" entry
460
+ * (preserve the source AR) is the default; standard ratios follow for
461
+ * reshaping.
462
+ */
463
+ private readonly _ratioOptionsCache;
464
+ private _ratioOptions;
465
+ private _labelForOption;
466
+ /**
467
+ * Resolve the result's filename from {@link outputFilename}: a function gets
468
+ * the source's original name + this generation's 1-based counter; a string is
469
+ * used verbatim. Unset preserves the source's original name (`undefined` when
470
+ * generating from scratch → the provider's default).
471
+ */
472
+ private _resolveOutputFilename;
473
+ /**
474
+ * Resolve {@link metadata}: a static bag is used as-is; a callback is invoked
475
+ * with the source file (only when one exists — a generate-from-scratch gets
476
+ * none) and may be async. A throwing callback yields no metadata.
477
+ */
478
+ private _resolveMetadata;
479
+ private _generate;
480
+ /** Discard the current image (input or result) and prompt history, returning
481
+ * to a blank generate session. */
482
+ private _onStartOver;
483
+ private _onPromptInput;
484
+ private _onSend;
485
+ private _onSelectHistoryEntry;
486
+ private _onSelectAspectRatio;
487
+ private _onSelectPreset;
488
+ private _onPrimary;
489
+ private _onCancel;
490
+ /* Excluded from this release type: render */
491
+ }
492
+
493
+ export { }
494
+
495
+
496
+ /**
497
+ * Augment the file-uploader's type system so plugin-specific config is checked
498
+ * instead of cast: the custom activity params for
499
+ * `setCurrentActivity(AI_ENHANCER_ID, params)`, the editor's locale keys so
500
+ * `localeDefinitionOverride` is typed for them, and the plugin's own config
501
+ * options on `<uc-config>`.
502
+ *
503
+ * Importing the plugin brings these augmentations into scope. If your project
504
+ * doesn't pick them up automatically, reference the plugin's types once, e.g.
505
+ * `/// <reference types="@uploadcare/ai-enhancer/plugin" />`.
506
+ */
507
+ declare module '@uploadcare/file-uploader' {
508
+ interface CustomActivities {
509
+ [AI_ENHANCER_ID]: {
510
+ params: AiEditorActivityParams;
511
+ };
512
+ }
513
+ interface CustomLocaleDefinition extends AiEnhancerLocale {
514
+ }
515
+ interface CustomConfig {
516
+ /**
517
+ * Show the **AI Edit** file action on uploaded images (default `true`); set
518
+ * `false` (attribute `use-ai-editor="false"`) to hide it. Mirrors the
519
+ * uploader's `useCloudImageEditor`. Note: the action also hides itself for
520
+ * images that already carry CDN modifiers (e.g. edited with the Cloud Image
521
+ * Editor), regardless of this flag.
522
+ */
523
+ useAiEditor: boolean;
524
+ }
525
+ }
526
+
527
+
528
+ declare module '@vitest/browser/context' {
529
+ interface BrowserPage {
530
+ render: typeof render;
531
+ }
532
+ }
@@ -0,0 +1,5 @@
1
+ import { U as c, e as n } from "./UcAiEnhancer-D1z2-v9q.js";
2
+ export {
3
+ c as UcAiEnhancer,
4
+ n as enLocale
5
+ };
@@ -0,0 +1,29 @@
1
+ const e = {
2
+ "ai-enhancer-source-label": "إنشاء صورة",
3
+ "ai-enhancer-file-action-label": "تحرير بالذكاء الاصطناعي",
4
+ "ai-enhancer-generate-title": "إنشاء صورة",
5
+ "ai-enhancer-edit-title": "تحرير الصورة",
6
+ "ai-enhancer-generate-placeholder": "إنشاء صورة...",
7
+ "ai-enhancer-edit-placeholder": "تحرير الصورة...",
8
+ "ai-enhancer-cancel": "إلغاء",
9
+ "ai-enhancer-generate-btn": "إنشاء",
10
+ "ai-enhancer-done-btn": "تم",
11
+ "ai-enhancer-start-over": "البدء من جديد",
12
+ "ai-enhancer-history-title": "المطالبات الأخيرة",
13
+ "ai-enhancer-busy": "جارٍ الإنشاء…",
14
+ "ai-enhancer-error": "حدث خطأ ما. حاول مرة أخرى.",
15
+ "ai-enhancer-fullscreen": "عرض ملء الشاشة",
16
+ "ai-enhancer-exit-fullscreen": "إنهاء ملء الشاشة",
17
+ "ai-enhancer-aspect-ratio-aria": "اختر نسبة العرض إلى الارتفاع",
18
+ "ai-enhancer-aspect-original": "الأصلي",
19
+ "ai-enhancer-aspect-square": "مربع",
20
+ "ai-enhancer-aspect-tall": "طويل",
21
+ "ai-enhancer-aspect-wide": "عريض",
22
+ "ai-enhancer-aspect-portrait": "عمودي",
23
+ "ai-enhancer-aspect-landscape": "أفقي",
24
+ "ai-enhancer-aspect-vertical": "رأسي",
25
+ "ai-enhancer-aspect-widescreen": "شاشة عريضة"
26
+ };
27
+ export {
28
+ e as default
29
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={"ai-enhancer-source-label":"إنشاء صورة","ai-enhancer-file-action-label":"تحرير بالذكاء الاصطناعي","ai-enhancer-generate-title":"إنشاء صورة","ai-enhancer-edit-title":"تحرير الصورة","ai-enhancer-generate-placeholder":"إنشاء صورة...","ai-enhancer-edit-placeholder":"تحرير الصورة...","ai-enhancer-cancel":"إلغاء","ai-enhancer-generate-btn":"إنشاء","ai-enhancer-done-btn":"تم","ai-enhancer-start-over":"البدء من جديد","ai-enhancer-history-title":"المطالبات الأخيرة","ai-enhancer-busy":"جارٍ الإنشاء…","ai-enhancer-error":"حدث خطأ ما. حاول مرة أخرى.","ai-enhancer-fullscreen":"عرض ملء الشاشة","ai-enhancer-exit-fullscreen":"إنهاء ملء الشاشة","ai-enhancer-aspect-ratio-aria":"اختر نسبة العرض إلى الارتفاع","ai-enhancer-aspect-original":"الأصلي","ai-enhancer-aspect-square":"مربع","ai-enhancer-aspect-tall":"طويل","ai-enhancer-aspect-wide":"عريض","ai-enhancer-aspect-portrait":"عمودي","ai-enhancer-aspect-landscape":"أفقي","ai-enhancer-aspect-vertical":"رأسي","ai-enhancer-aspect-widescreen":"شاشة عريضة"};exports.default=e;
@@ -0,0 +1,29 @@
1
+ const e = {
2
+ "ai-enhancer-source-label": "Şəkil yarat",
3
+ "ai-enhancer-file-action-label": "AI redaktə",
4
+ "ai-enhancer-generate-title": "Şəkil yarat",
5
+ "ai-enhancer-edit-title": "Şəkli redaktə et",
6
+ "ai-enhancer-generate-placeholder": "Şəkil yarat...",
7
+ "ai-enhancer-edit-placeholder": "Şəkli redaktə et...",
8
+ "ai-enhancer-cancel": "Ləğv et",
9
+ "ai-enhancer-generate-btn": "Yarat",
10
+ "ai-enhancer-done-btn": "Hazırdır",
11
+ "ai-enhancer-start-over": "Yenidən başla",
12
+ "ai-enhancer-history-title": "Son promptlar",
13
+ "ai-enhancer-busy": "Yaradılır…",
14
+ "ai-enhancer-error": "Nəsə səhv getdi. Yenidən cəhd edin.",
15
+ "ai-enhancer-fullscreen": "Tam ekran bax",
16
+ "ai-enhancer-exit-fullscreen": "Tam ekrandan çıx",
17
+ "ai-enhancer-aspect-ratio-aria": "Tərəf nisbətini seçin",
18
+ "ai-enhancer-aspect-original": "Orijinal",
19
+ "ai-enhancer-aspect-square": "Kvadrat",
20
+ "ai-enhancer-aspect-tall": "Hündür",
21
+ "ai-enhancer-aspect-wide": "Geniş",
22
+ "ai-enhancer-aspect-portrait": "Şaquli",
23
+ "ai-enhancer-aspect-landscape": "Üfüqi",
24
+ "ai-enhancer-aspect-vertical": "Dikey",
25
+ "ai-enhancer-aspect-widescreen": "Geniş ekran"
26
+ };
27
+ export {
28
+ e as default
29
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={"ai-enhancer-source-label":"Şəkil yarat","ai-enhancer-file-action-label":"AI redaktə","ai-enhancer-generate-title":"Şəkil yarat","ai-enhancer-edit-title":"Şəkli redaktə et","ai-enhancer-generate-placeholder":"Şəkil yarat...","ai-enhancer-edit-placeholder":"Şəkli redaktə et...","ai-enhancer-cancel":"Ləğv et","ai-enhancer-generate-btn":"Yarat","ai-enhancer-done-btn":"Hazırdır","ai-enhancer-start-over":"Yenidən başla","ai-enhancer-history-title":"Son promptlar","ai-enhancer-busy":"Yaradılır…","ai-enhancer-error":"Nəsə səhv getdi. Yenidən cəhd edin.","ai-enhancer-fullscreen":"Tam ekran bax","ai-enhancer-exit-fullscreen":"Tam ekrandan çıx","ai-enhancer-aspect-ratio-aria":"Tərəf nisbətini seçin","ai-enhancer-aspect-original":"Orijinal","ai-enhancer-aspect-square":"Kvadrat","ai-enhancer-aspect-tall":"Hündür","ai-enhancer-aspect-wide":"Geniş","ai-enhancer-aspect-portrait":"Şaquli","ai-enhancer-aspect-landscape":"Üfüqi","ai-enhancer-aspect-vertical":"Dikey","ai-enhancer-aspect-widescreen":"Geniş ekran"};exports.default=e;
@@ -0,0 +1,29 @@
1
+ const e = {
2
+ "ai-enhancer-source-label": "Genera imatge",
3
+ "ai-enhancer-file-action-label": "Edició amb IA",
4
+ "ai-enhancer-generate-title": "Genera imatge",
5
+ "ai-enhancer-edit-title": "Edita la imatge",
6
+ "ai-enhancer-generate-placeholder": "Crea una imatge...",
7
+ "ai-enhancer-edit-placeholder": "Edita la imatge...",
8
+ "ai-enhancer-cancel": "Cancel·la",
9
+ "ai-enhancer-generate-btn": "Genera",
10
+ "ai-enhancer-done-btn": "Fet",
11
+ "ai-enhancer-start-over": "Comença de nou",
12
+ "ai-enhancer-history-title": "Indicacions recents",
13
+ "ai-enhancer-busy": "S’està generant…",
14
+ "ai-enhancer-error": "Hi ha hagut un error. Torna-ho a provar.",
15
+ "ai-enhancer-fullscreen": "Veure a pantalla completa",
16
+ "ai-enhancer-exit-fullscreen": "Sortir de pantalla completa",
17
+ "ai-enhancer-aspect-ratio-aria": "Tria la relació d’aspecte",
18
+ "ai-enhancer-aspect-original": "Original",
19
+ "ai-enhancer-aspect-square": "Quadrat",
20
+ "ai-enhancer-aspect-tall": "Alt",
21
+ "ai-enhancer-aspect-wide": "Ample",
22
+ "ai-enhancer-aspect-portrait": "Retrat",
23
+ "ai-enhancer-aspect-landscape": "Horitzontal",
24
+ "ai-enhancer-aspect-vertical": "Vertical",
25
+ "ai-enhancer-aspect-widescreen": "Panoràmic"
26
+ };
27
+ export {
28
+ e as default
29
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={"ai-enhancer-source-label":"Genera imatge","ai-enhancer-file-action-label":"Edició amb IA","ai-enhancer-generate-title":"Genera imatge","ai-enhancer-edit-title":"Edita la imatge","ai-enhancer-generate-placeholder":"Crea una imatge...","ai-enhancer-edit-placeholder":"Edita la imatge...","ai-enhancer-cancel":"Cancel·la","ai-enhancer-generate-btn":"Genera","ai-enhancer-done-btn":"Fet","ai-enhancer-start-over":"Comença de nou","ai-enhancer-history-title":"Indicacions recents","ai-enhancer-busy":"S’està generant…","ai-enhancer-error":"Hi ha hagut un error. Torna-ho a provar.","ai-enhancer-fullscreen":"Veure a pantalla completa","ai-enhancer-exit-fullscreen":"Sortir de pantalla completa","ai-enhancer-aspect-ratio-aria":"Tria la relació d’aspecte","ai-enhancer-aspect-original":"Original","ai-enhancer-aspect-square":"Quadrat","ai-enhancer-aspect-tall":"Alt","ai-enhancer-aspect-wide":"Ample","ai-enhancer-aspect-portrait":"Retrat","ai-enhancer-aspect-landscape":"Horitzontal","ai-enhancer-aspect-vertical":"Vertical","ai-enhancer-aspect-widescreen":"Panoràmic"};exports.default=e;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={"ai-enhancer-source-label":"Vygenerovat obrázek","ai-enhancer-file-action-label":"Úprava s AI","ai-enhancer-generate-title":"Vygenerovat obrázek","ai-enhancer-edit-title":"Upravit obrázek","ai-enhancer-generate-placeholder":"Vytvořit obrázek...","ai-enhancer-edit-placeholder":"Upravit obrázek...","ai-enhancer-cancel":"Zrušit","ai-enhancer-generate-btn":"Vygenerovat","ai-enhancer-done-btn":"Hotovo","ai-enhancer-start-over":"Začít znovu","ai-enhancer-history-title":"Poslední prompty","ai-enhancer-busy":"Generování…","ai-enhancer-error":"Něco se pokazilo. Zkuste to znovu.","ai-enhancer-fullscreen":"Zobrazit na celou obrazovku","ai-enhancer-exit-fullscreen":"Ukončit celou obrazovku","ai-enhancer-aspect-ratio-aria":"Vyberte poměr stran","ai-enhancer-aspect-original":"Původní","ai-enhancer-aspect-square":"Čtverec","ai-enhancer-aspect-tall":"Vysoký","ai-enhancer-aspect-wide":"Široký","ai-enhancer-aspect-portrait":"Na výšku","ai-enhancer-aspect-landscape":"Na šířku","ai-enhancer-aspect-vertical":"Svislý","ai-enhancer-aspect-widescreen":"Širokoúhlý"};exports.default=e;