light-chain-open-ui 1.0.0
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/button-Bvgi18zf.js +4535 -0
- package/dist/button-DyttCdLa.cjs +1101 -0
- package/dist/lightchain-ui.cjs +1 -0
- package/dist/lightchain-ui.mjs +5 -0
- package/dist/react.cjs +1 -0
- package/dist/react.mjs +71 -0
- package/dist/types/components/button/button.d.ts +16 -0
- package/dist/types/components/button/index.d.ts +1 -0
- package/dist/types/components/color-picker/color-picker.d.ts +19 -0
- package/dist/types/components/color-picker/index.d.ts +1 -0
- package/dist/types/components/enum-selector/enum-selector.d.ts +40 -0
- package/dist/types/components/enum-selector/index.d.ts +1 -0
- package/dist/types/components/image-compare-slider/image-compare-slider.d.ts +25 -0
- package/dist/types/components/image-compare-slider/index.d.ts +1 -0
- package/dist/types/components/image-uploader/image-uploader.d.ts +54 -0
- package/dist/types/components/image-uploader/index.d.ts +1 -0
- package/dist/types/components/mask-editor/index.d.ts +1 -0
- package/dist/types/components/mask-editor/mask-editor.d.ts +88 -0
- package/dist/types/components/prompt-input/index.d.ts +1 -0
- package/dist/types/components/prompt-input/prompt-input.d.ts +19 -0
- package/dist/types/components/result-gallery/index.d.ts +1 -0
- package/dist/types/components/result-gallery/result-gallery.d.ts +23 -0
- package/dist/types/components/strength-slider/index.d.ts +1 -0
- package/dist/types/components/strength-slider/strength-slider.d.ts +19 -0
- package/dist/types/components/task-progress-card/index.d.ts +1 -0
- package/dist/types/components/task-progress-card/task-progress-card.d.ts +28 -0
- package/dist/types/components/task-workflow/index.d.ts +3 -0
- package/dist/types/components/task-workflow/task-workflow.d.ts +56 -0
- package/dist/types/core/client.d.ts +97 -0
- package/dist/types/core/constants.d.ts +420 -0
- package/dist/types/core/image-validator.d.ts +16 -0
- package/dist/types/core/index.d.ts +6 -0
- package/dist/types/core/task-types/index.d.ts +31 -0
- package/dist/types/core/task-types/types-part-a.d.ts +3 -0
- package/dist/types/core/task-types/types-part-b.d.ts +3 -0
- package/dist/types/core/types.d.ts +65 -0
- package/dist/types/core/validate.d.ts +11 -0
- package/dist/types/index.d.ts +28 -0
- package/dist/types/react/index.d.ts +43 -0
- package/package.json +65 -0
- package/src/styles/reset.css +2 -0
- package/src/styles/themes/dark.css +14 -0
- package/src/styles/themes/default.css +2 -0
- package/src/styles/tokens.css +68 -0
|
@@ -0,0 +1,4535 @@
|
|
|
1
|
+
import { LitElement as e, css as t, html as n, nothing as r } from "lit";
|
|
2
|
+
//#region node_modules/@lit/reactive-element/decorators/custom-element.js
|
|
3
|
+
var i = (e) => (t, n) => {
|
|
4
|
+
n === void 0 ? customElements.define(e, t) : n.addInitializer(() => {
|
|
5
|
+
customElements.define(e, t);
|
|
6
|
+
});
|
|
7
|
+
}, a = globalThis, o = a.ShadowRoot && (a.ShadyCSS === void 0 || a.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s = Symbol(), c = /* @__PURE__ */ new WeakMap(), l = class {
|
|
8
|
+
constructor(e, t, n) {
|
|
9
|
+
if (this._$cssResult$ = !0, n !== s) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
10
|
+
this.cssText = e, this.t = t;
|
|
11
|
+
}
|
|
12
|
+
get styleSheet() {
|
|
13
|
+
let e = this.o, t = this.t;
|
|
14
|
+
if (o && e === void 0) {
|
|
15
|
+
let n = t !== void 0 && t.length === 1;
|
|
16
|
+
n && (e = c.get(t)), e === void 0 && ((this.o = e = new CSSStyleSheet()).replaceSync(this.cssText), n && c.set(t, e));
|
|
17
|
+
}
|
|
18
|
+
return e;
|
|
19
|
+
}
|
|
20
|
+
toString() {
|
|
21
|
+
return this.cssText;
|
|
22
|
+
}
|
|
23
|
+
}, u = (e) => new l(typeof e == "string" ? e : e + "", void 0, s), ee = (e, t) => {
|
|
24
|
+
if (o) e.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
|
|
25
|
+
else for (let n of t) {
|
|
26
|
+
let t = document.createElement("style"), r = a.litNonce;
|
|
27
|
+
r !== void 0 && t.setAttribute("nonce", r), t.textContent = n.cssText, e.appendChild(t);
|
|
28
|
+
}
|
|
29
|
+
}, te = o ? (e) => e : (e) => e instanceof CSSStyleSheet ? ((e) => {
|
|
30
|
+
let t = "";
|
|
31
|
+
for (let n of e.cssRules) t += n.cssText;
|
|
32
|
+
return u(t);
|
|
33
|
+
})(e) : e, { is: ne, defineProperty: re, getOwnPropertyDescriptor: ie, getOwnPropertyNames: ae, getOwnPropertySymbols: oe, getPrototypeOf: se } = Object, d = globalThis, ce = d.trustedTypes, le = ce ? ce.emptyScript : "", ue = d.reactiveElementPolyfillSupport, f = (e, t) => e, p = {
|
|
34
|
+
toAttribute(e, t) {
|
|
35
|
+
switch (t) {
|
|
36
|
+
case Boolean:
|
|
37
|
+
e = e ? le : null;
|
|
38
|
+
break;
|
|
39
|
+
case Object:
|
|
40
|
+
case Array: e = e == null ? e : JSON.stringify(e);
|
|
41
|
+
}
|
|
42
|
+
return e;
|
|
43
|
+
},
|
|
44
|
+
fromAttribute(e, t) {
|
|
45
|
+
let n = e;
|
|
46
|
+
switch (t) {
|
|
47
|
+
case Boolean:
|
|
48
|
+
n = e !== null;
|
|
49
|
+
break;
|
|
50
|
+
case Number:
|
|
51
|
+
n = e === null ? null : Number(e);
|
|
52
|
+
break;
|
|
53
|
+
case Object:
|
|
54
|
+
case Array: try {
|
|
55
|
+
n = JSON.parse(e);
|
|
56
|
+
} catch {
|
|
57
|
+
n = null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return n;
|
|
61
|
+
}
|
|
62
|
+
}, de = (e, t) => !ne(e, t), fe = {
|
|
63
|
+
attribute: !0,
|
|
64
|
+
type: String,
|
|
65
|
+
converter: p,
|
|
66
|
+
reflect: !1,
|
|
67
|
+
useDefault: !1,
|
|
68
|
+
hasChanged: de
|
|
69
|
+
};
|
|
70
|
+
Symbol.metadata ??= Symbol("metadata"), d.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
|
|
71
|
+
var m = class extends HTMLElement {
|
|
72
|
+
static addInitializer(e) {
|
|
73
|
+
this._$Ei(), (this.l ??= []).push(e);
|
|
74
|
+
}
|
|
75
|
+
static get observedAttributes() {
|
|
76
|
+
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
|
|
77
|
+
}
|
|
78
|
+
static createProperty(e, t = fe) {
|
|
79
|
+
if (t.state && (t.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(e) && ((t = Object.create(t)).wrapped = !0), this.elementProperties.set(e, t), !t.noAccessor) {
|
|
80
|
+
let n = Symbol(), r = this.getPropertyDescriptor(e, n, t);
|
|
81
|
+
r !== void 0 && re(this.prototype, e, r);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
static getPropertyDescriptor(e, t, n) {
|
|
85
|
+
let { get: r, set: i } = ie(this.prototype, e) ?? {
|
|
86
|
+
get() {
|
|
87
|
+
return this[t];
|
|
88
|
+
},
|
|
89
|
+
set(e) {
|
|
90
|
+
this[t] = e;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
get: r,
|
|
95
|
+
set(t) {
|
|
96
|
+
let a = r?.call(this);
|
|
97
|
+
i?.call(this, t), this.requestUpdate(e, a, n);
|
|
98
|
+
},
|
|
99
|
+
configurable: !0,
|
|
100
|
+
enumerable: !0
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
static getPropertyOptions(e) {
|
|
104
|
+
return this.elementProperties.get(e) ?? fe;
|
|
105
|
+
}
|
|
106
|
+
static _$Ei() {
|
|
107
|
+
if (this.hasOwnProperty(f("elementProperties"))) return;
|
|
108
|
+
let e = se(this);
|
|
109
|
+
e.finalize(), e.l !== void 0 && (this.l = [...e.l]), this.elementProperties = new Map(e.elementProperties);
|
|
110
|
+
}
|
|
111
|
+
static finalize() {
|
|
112
|
+
if (this.hasOwnProperty(f("finalized"))) return;
|
|
113
|
+
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(f("properties"))) {
|
|
114
|
+
let e = this.properties, t = [...ae(e), ...oe(e)];
|
|
115
|
+
for (let n of t) this.createProperty(n, e[n]);
|
|
116
|
+
}
|
|
117
|
+
let e = this[Symbol.metadata];
|
|
118
|
+
if (e !== null) {
|
|
119
|
+
let t = litPropertyMetadata.get(e);
|
|
120
|
+
if (t !== void 0) for (let [e, n] of t) this.elementProperties.set(e, n);
|
|
121
|
+
}
|
|
122
|
+
this._$Eh = /* @__PURE__ */ new Map();
|
|
123
|
+
for (let [e, t] of this.elementProperties) {
|
|
124
|
+
let n = this._$Eu(e, t);
|
|
125
|
+
n !== void 0 && this._$Eh.set(n, e);
|
|
126
|
+
}
|
|
127
|
+
this.elementStyles = this.finalizeStyles(this.styles);
|
|
128
|
+
}
|
|
129
|
+
static finalizeStyles(e) {
|
|
130
|
+
let t = [];
|
|
131
|
+
if (Array.isArray(e)) {
|
|
132
|
+
let n = new Set(e.flat(Infinity).reverse());
|
|
133
|
+
for (let e of n) t.unshift(te(e));
|
|
134
|
+
} else e !== void 0 && t.push(te(e));
|
|
135
|
+
return t;
|
|
136
|
+
}
|
|
137
|
+
static _$Eu(e, t) {
|
|
138
|
+
let n = t.attribute;
|
|
139
|
+
return !1 === n ? void 0 : typeof n == "string" ? n : typeof e == "string" ? e.toLowerCase() : void 0;
|
|
140
|
+
}
|
|
141
|
+
constructor() {
|
|
142
|
+
super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
|
|
143
|
+
}
|
|
144
|
+
_$Ev() {
|
|
145
|
+
this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach((e) => e(this));
|
|
146
|
+
}
|
|
147
|
+
addController(e) {
|
|
148
|
+
(this._$EO ??= /* @__PURE__ */ new Set()).add(e), this.renderRoot !== void 0 && this.isConnected && e.hostConnected?.();
|
|
149
|
+
}
|
|
150
|
+
removeController(e) {
|
|
151
|
+
this._$EO?.delete(e);
|
|
152
|
+
}
|
|
153
|
+
_$E_() {
|
|
154
|
+
let e = /* @__PURE__ */ new Map(), t = this.constructor.elementProperties;
|
|
155
|
+
for (let n of t.keys()) this.hasOwnProperty(n) && (e.set(n, this[n]), delete this[n]);
|
|
156
|
+
e.size > 0 && (this._$Ep = e);
|
|
157
|
+
}
|
|
158
|
+
createRenderRoot() {
|
|
159
|
+
let e = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
|
|
160
|
+
return ee(e, this.constructor.elementStyles), e;
|
|
161
|
+
}
|
|
162
|
+
connectedCallback() {
|
|
163
|
+
this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(!0), this._$EO?.forEach((e) => e.hostConnected?.());
|
|
164
|
+
}
|
|
165
|
+
enableUpdating(e) {}
|
|
166
|
+
disconnectedCallback() {
|
|
167
|
+
this._$EO?.forEach((e) => e.hostDisconnected?.());
|
|
168
|
+
}
|
|
169
|
+
attributeChangedCallback(e, t, n) {
|
|
170
|
+
this._$AK(e, n);
|
|
171
|
+
}
|
|
172
|
+
_$ET(e, t) {
|
|
173
|
+
let n = this.constructor.elementProperties.get(e), r = this.constructor._$Eu(e, n);
|
|
174
|
+
if (r !== void 0 && !0 === n.reflect) {
|
|
175
|
+
let i = (n.converter?.toAttribute === void 0 ? p : n.converter).toAttribute(t, n.type);
|
|
176
|
+
this._$Em = e, i == null ? this.removeAttribute(r) : this.setAttribute(r, i), this._$Em = null;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
_$AK(e, t) {
|
|
180
|
+
let n = this.constructor, r = n._$Eh.get(e);
|
|
181
|
+
if (r !== void 0 && this._$Em !== r) {
|
|
182
|
+
let e = n.getPropertyOptions(r), i = typeof e.converter == "function" ? { fromAttribute: e.converter } : e.converter?.fromAttribute === void 0 ? p : e.converter;
|
|
183
|
+
this._$Em = r;
|
|
184
|
+
let a = i.fromAttribute(t, e.type);
|
|
185
|
+
this[r] = a ?? this._$Ej?.get(r) ?? a, this._$Em = null;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
requestUpdate(e, t, n, r = !1, i) {
|
|
189
|
+
if (e !== void 0) {
|
|
190
|
+
let a = this.constructor;
|
|
191
|
+
if (!1 === r && (i = this[e]), n ??= a.getPropertyOptions(e), !((n.hasChanged ?? de)(i, t) || n.useDefault && n.reflect && i === this._$Ej?.get(e) && !this.hasAttribute(a._$Eu(e, n)))) return;
|
|
192
|
+
this.C(e, t, n);
|
|
193
|
+
}
|
|
194
|
+
!1 === this.isUpdatePending && (this._$ES = this._$EP());
|
|
195
|
+
}
|
|
196
|
+
C(e, t, { useDefault: n, reflect: r, wrapped: i }, a) {
|
|
197
|
+
n && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(e) && (this._$Ej.set(e, a ?? t ?? this[e]), !0 !== i || a !== void 0) || (this._$AL.has(e) || (this.hasUpdated || n || (t = void 0), this._$AL.set(e, t)), !0 === r && this._$Em !== e && (this._$Eq ??= /* @__PURE__ */ new Set()).add(e));
|
|
198
|
+
}
|
|
199
|
+
async _$EP() {
|
|
200
|
+
this.isUpdatePending = !0;
|
|
201
|
+
try {
|
|
202
|
+
await this._$ES;
|
|
203
|
+
} catch (e) {
|
|
204
|
+
Promise.reject(e);
|
|
205
|
+
}
|
|
206
|
+
let e = this.scheduleUpdate();
|
|
207
|
+
return e != null && await e, !this.isUpdatePending;
|
|
208
|
+
}
|
|
209
|
+
scheduleUpdate() {
|
|
210
|
+
return this.performUpdate();
|
|
211
|
+
}
|
|
212
|
+
performUpdate() {
|
|
213
|
+
if (!this.isUpdatePending) return;
|
|
214
|
+
if (!this.hasUpdated) {
|
|
215
|
+
if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
|
|
216
|
+
for (let [e, t] of this._$Ep) this[e] = t;
|
|
217
|
+
this._$Ep = void 0;
|
|
218
|
+
}
|
|
219
|
+
let e = this.constructor.elementProperties;
|
|
220
|
+
if (e.size > 0) for (let [t, n] of e) {
|
|
221
|
+
let { wrapped: e } = n, r = this[t];
|
|
222
|
+
!0 !== e || this._$AL.has(t) || r === void 0 || this.C(t, void 0, n, r);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
let e = !1, t = this._$AL;
|
|
226
|
+
try {
|
|
227
|
+
e = this.shouldUpdate(t), e ? (this.willUpdate(t), this._$EO?.forEach((e) => e.hostUpdate?.()), this.update(t)) : this._$EM();
|
|
228
|
+
} catch (t) {
|
|
229
|
+
throw e = !1, this._$EM(), t;
|
|
230
|
+
}
|
|
231
|
+
e && this._$AE(t);
|
|
232
|
+
}
|
|
233
|
+
willUpdate(e) {}
|
|
234
|
+
_$AE(e) {
|
|
235
|
+
this._$EO?.forEach((e) => e.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(e)), this.updated(e);
|
|
236
|
+
}
|
|
237
|
+
_$EM() {
|
|
238
|
+
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
|
|
239
|
+
}
|
|
240
|
+
get updateComplete() {
|
|
241
|
+
return this.getUpdateComplete();
|
|
242
|
+
}
|
|
243
|
+
getUpdateComplete() {
|
|
244
|
+
return this._$ES;
|
|
245
|
+
}
|
|
246
|
+
shouldUpdate(e) {
|
|
247
|
+
return !0;
|
|
248
|
+
}
|
|
249
|
+
update(e) {
|
|
250
|
+
this._$Eq &&= this._$Eq.forEach((e) => this._$ET(e, this[e])), this._$EM();
|
|
251
|
+
}
|
|
252
|
+
updated(e) {}
|
|
253
|
+
firstUpdated(e) {}
|
|
254
|
+
};
|
|
255
|
+
m.elementStyles = [], m.shadowRootOptions = { mode: "open" }, m[f("elementProperties")] = /* @__PURE__ */ new Map(), m[f("finalized")] = /* @__PURE__ */ new Map(), ue?.({ ReactiveElement: m }), (d.reactiveElementVersions ??= []).push("2.1.2");
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region node_modules/@lit/reactive-element/decorators/property.js
|
|
258
|
+
var pe = {
|
|
259
|
+
attribute: !0,
|
|
260
|
+
type: String,
|
|
261
|
+
converter: p,
|
|
262
|
+
reflect: !1,
|
|
263
|
+
hasChanged: de
|
|
264
|
+
}, me = (e = pe, t, n) => {
|
|
265
|
+
let { kind: r, metadata: i } = n, a = globalThis.litPropertyMetadata.get(i);
|
|
266
|
+
if (a === void 0 && globalThis.litPropertyMetadata.set(i, a = /* @__PURE__ */ new Map()), r === "setter" && ((e = Object.create(e)).wrapped = !0), a.set(n.name, e), r === "accessor") {
|
|
267
|
+
let { name: r } = n;
|
|
268
|
+
return {
|
|
269
|
+
set(n) {
|
|
270
|
+
let i = t.get.call(this);
|
|
271
|
+
t.set.call(this, n), this.requestUpdate(r, i, e, !0, n);
|
|
272
|
+
},
|
|
273
|
+
init(t) {
|
|
274
|
+
return t !== void 0 && this.C(r, void 0, e, t), t;
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
if (r === "setter") {
|
|
279
|
+
let { name: r } = n;
|
|
280
|
+
return function(n) {
|
|
281
|
+
let i = this[r];
|
|
282
|
+
t.call(this, n), this.requestUpdate(r, i, e, !0, n);
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
throw Error("Unsupported decorator location: " + r);
|
|
286
|
+
};
|
|
287
|
+
function h(e) {
|
|
288
|
+
return (t, n) => typeof n == "object" ? me(e, t, n) : ((e, t, n) => {
|
|
289
|
+
let r = t.hasOwnProperty(n);
|
|
290
|
+
return t.constructor.createProperty(n, e), r ? Object.getOwnPropertyDescriptor(t, n) : void 0;
|
|
291
|
+
})(e, t, n);
|
|
292
|
+
}
|
|
293
|
+
//#endregion
|
|
294
|
+
//#region node_modules/@lit/reactive-element/decorators/state.js
|
|
295
|
+
function g(e) {
|
|
296
|
+
return h({
|
|
297
|
+
...e,
|
|
298
|
+
state: !0,
|
|
299
|
+
attribute: !1
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region node_modules/@lit/reactive-element/decorators/base.js
|
|
304
|
+
var he = (e, t, n) => (n.configurable = !0, n.enumerable = !0, Reflect.decorate && typeof t != "object" && Object.defineProperty(e, t, n), n);
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region node_modules/@lit/reactive-element/decorators/query.js
|
|
307
|
+
function ge(e, t) {
|
|
308
|
+
return (n, r, i) => {
|
|
309
|
+
let a = (t) => t.renderRoot?.querySelector(e) ?? null;
|
|
310
|
+
if (t) {
|
|
311
|
+
let { get: e, set: t } = typeof r == "object" ? n : i ?? (() => {
|
|
312
|
+
let e = Symbol();
|
|
313
|
+
return {
|
|
314
|
+
get() {
|
|
315
|
+
return this[e];
|
|
316
|
+
},
|
|
317
|
+
set(t) {
|
|
318
|
+
this[e] = t;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
})();
|
|
322
|
+
return he(n, r, { get() {
|
|
323
|
+
let n = e.call(this);
|
|
324
|
+
return n === void 0 && (n = a(this), (n !== null || this.hasUpdated) && t.call(this, n)), n;
|
|
325
|
+
} });
|
|
326
|
+
}
|
|
327
|
+
return he(n, r, { get() {
|
|
328
|
+
return a(this);
|
|
329
|
+
} });
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
//#endregion
|
|
333
|
+
//#region src/core/types.ts
|
|
334
|
+
var _e = {
|
|
335
|
+
RUNNING: "running",
|
|
336
|
+
DONE: "done"
|
|
337
|
+
}, ve = {
|
|
338
|
+
DONE: "done",
|
|
339
|
+
EXCEPTION: "exception"
|
|
340
|
+
}, _ = {
|
|
341
|
+
MAX_SIZE_MB: 10,
|
|
342
|
+
MAX_WIDTH: 2048,
|
|
343
|
+
MAX_HEIGHT: 2048,
|
|
344
|
+
ASPECT_RATIO_MIN: 1 / 3,
|
|
345
|
+
ASPECT_RATIO_MAX: 3
|
|
346
|
+
}, ye = [
|
|
347
|
+
"1:1",
|
|
348
|
+
"2:3",
|
|
349
|
+
"3:4",
|
|
350
|
+
"3:2",
|
|
351
|
+
"4:3",
|
|
352
|
+
"9:16",
|
|
353
|
+
"16:9"
|
|
354
|
+
];
|
|
355
|
+
//#endregion
|
|
356
|
+
//#region src/core/image-validator.ts
|
|
357
|
+
function be(e) {
|
|
358
|
+
let t = [];
|
|
359
|
+
e.size > _.MAX_SIZE_MB * 1024 * 1024 && t.push("图片大小不能超过10MB"), (e.width > _.MAX_WIDTH || e.height > _.MAX_HEIGHT) && t.push("图片分辨率不能超过2048x2048");
|
|
360
|
+
let n = e.width / e.height;
|
|
361
|
+
return (n < _.ASPECT_RATIO_MIN || n > _.ASPECT_RATIO_MAX) && t.push("宽高比必须在1:3到3:1之间"), {
|
|
362
|
+
valid: t.length === 0,
|
|
363
|
+
errors: t
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
function xe(e, t) {
|
|
367
|
+
let n = [];
|
|
368
|
+
return (e.width !== t.width || e.height !== t.height) && n.push("蒙版尺寸必须与原图尺寸相同"), {
|
|
369
|
+
valid: n.length === 0,
|
|
370
|
+
errors: n
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
async function Se(e) {
|
|
374
|
+
let t = e.size <= _.MAX_SIZE_MB * 1024 * 1024;
|
|
375
|
+
return new Promise((n) => {
|
|
376
|
+
let r = new Image(), i = URL.createObjectURL(e);
|
|
377
|
+
r.onload = () => {
|
|
378
|
+
URL.revokeObjectURL(i);
|
|
379
|
+
let e = [];
|
|
380
|
+
(r.width > _.MAX_WIDTH || r.height > _.MAX_HEIGHT) && e.push("图片分辨率不能超过2048x2048");
|
|
381
|
+
let a = r.width / r.height;
|
|
382
|
+
(a < _.ASPECT_RATIO_MIN || a > _.ASPECT_RATIO_MAX) && e.push("宽高比必须在1:3到3:1之间"), t || e.push("图片大小不能超过10MB"), n({
|
|
383
|
+
valid: e.length === 0,
|
|
384
|
+
errors: e
|
|
385
|
+
});
|
|
386
|
+
}, r.onerror = () => {
|
|
387
|
+
URL.revokeObjectURL(i), n({
|
|
388
|
+
valid: !1,
|
|
389
|
+
errors: ["无法加载图片"]
|
|
390
|
+
});
|
|
391
|
+
}, r.src = i;
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
//#endregion
|
|
395
|
+
//#region src/core/constants.ts
|
|
396
|
+
var Ce = "https://api.lightchainai.com", we = "client-secret", Te = "/task/progress", Ee = "/task/submit", De = {
|
|
397
|
+
BAD_REQUEST: 400,
|
|
398
|
+
UNAUTHORIZED: 401,
|
|
399
|
+
RATE_LIMIT: 429,
|
|
400
|
+
SERVER_ERROR: 500
|
|
401
|
+
}, Oe = {
|
|
402
|
+
GENERATE_PRINTING: "GeneratePrinting",
|
|
403
|
+
VIRTUAL_FITTING: "VirtualFitting",
|
|
404
|
+
FIX_FACE: "FixFace",
|
|
405
|
+
CHANGE_FACE: "ChangeFace",
|
|
406
|
+
MULTI_PERSPECTIVE: "MultiPerspective",
|
|
407
|
+
PRINTING_TILING: "PrintingTiling",
|
|
408
|
+
CHANGE_DESIGN_POINT: "ChangeDesignPoint",
|
|
409
|
+
CHANGE_COLOR: "ChangeColor",
|
|
410
|
+
CHANGE_FABRIC: "ChangeFabric",
|
|
411
|
+
SR: "Sr",
|
|
412
|
+
VECTOR_CONVERT: "VectorConvert",
|
|
413
|
+
CHANGE_MODEL: "ChangeModel",
|
|
414
|
+
GENERATE_SKETCH: "GenerateSketch",
|
|
415
|
+
MODEL_GENERATE_SKETCH: "ModelGenerateSketch",
|
|
416
|
+
ELIMINATE: "Eliminate",
|
|
417
|
+
EXPAND_IMAGE: "ExpandImage",
|
|
418
|
+
CLOTHING_DESIGN: "ClothingDesign",
|
|
419
|
+
CHANGE_PATTERN: "ChangePattern",
|
|
420
|
+
GENERATE_MODEL: "GenerateModel",
|
|
421
|
+
MODIFY_PRINTING: "ModifyPrinting",
|
|
422
|
+
CUT_OUT: "CutOut",
|
|
423
|
+
LINE_ART_TO_REAL: "LineArtToReal",
|
|
424
|
+
FIX_PARTIAL: "FixPartial",
|
|
425
|
+
DETAIL_COMPENSATION: "DetailCompensation",
|
|
426
|
+
CHANGE_CLOTHES_BY_IMG: "ChangeClothesByImg",
|
|
427
|
+
CHANGE_ACCESSORIES_BY_IMG: "ChangeAccessoriesByImg",
|
|
428
|
+
VIRTUAL_FITTING_REFERENCE: "VirtualFittingReference",
|
|
429
|
+
VIRTUAL_FITTING_TEMPLATE: "VirtualFittingTemplate",
|
|
430
|
+
FIX_DEFORMITIES: "FixDeformities",
|
|
431
|
+
INTELLIGENT_CROPPING: "IntelligentCropping",
|
|
432
|
+
MODEL_TO_FLAT: "ModelToFlat",
|
|
433
|
+
GENERATE_SHORT_VIDEO: "GenerateShortVideo",
|
|
434
|
+
ONE_CLICK_MODIFY_PRINTING: "OneClickModifyPrinting",
|
|
435
|
+
ORIENTATION_DESIGN: "OrientationDesign",
|
|
436
|
+
DIRECTIONAL_INTEGRATION: "DirectionalIntegration",
|
|
437
|
+
ONE_CLICK_INTEGRATION: "OneClickIntegration",
|
|
438
|
+
CHANGE_FABRIC_V2: "ChangeFabricV2",
|
|
439
|
+
VIRTUAL_FITTING_REFERENCE_V2: "VirtualFittingReferenceV2",
|
|
440
|
+
FLOWER_SHAPED_DESIGN: "FlowerShapedDesign",
|
|
441
|
+
FLOWER_SHAPED_VIRTUAL_PRINTING: "FlowerShapedVirtualPrinting",
|
|
442
|
+
ONE_CLICK_CHANGE_COLOR: "OneClickChangeColor",
|
|
443
|
+
FITTING_MODEL_WITH_LABELS: "FittingModelWithLabels",
|
|
444
|
+
FITTING_MODEL_CUSTOM: "FittingModelCustom",
|
|
445
|
+
FITTING_MODEL_CHANGE_FACE: "FittingModelChangeFace",
|
|
446
|
+
FITTING_MODEL_CHANGE_MODEL: "FittingModelChangeModel",
|
|
447
|
+
FITTING_MODEL_CHANGE_BODY_SHAPE: "FittingModelChangeBodyShape",
|
|
448
|
+
FITTING_MODEL_CHANGE_CLOTHING_SIZE: "FittingModelChangeClothingSize",
|
|
449
|
+
FITTING_MODEL_CHANGE_POSTURE: "FittingModelChangePosture",
|
|
450
|
+
FITTING_MODEL_CHANGE_BACKGROUND: "FittingModelChangeBackground",
|
|
451
|
+
FITTING_MODEL_CHANGE_PERSPECTIVE: "FittingModelChangePerspective",
|
|
452
|
+
TRAIN_CLOTHING_MODEL: "TrainClothingModel"
|
|
453
|
+
}, ke = {
|
|
454
|
+
IMAGE: "image",
|
|
455
|
+
MASK: "mask",
|
|
456
|
+
IMAGES: "images",
|
|
457
|
+
TEXT: "text",
|
|
458
|
+
ENUM: "enum",
|
|
459
|
+
MULTI_ENUM: "multiEnum",
|
|
460
|
+
ASPECT_RATIO: "aspectRatio",
|
|
461
|
+
COLOR: "color",
|
|
462
|
+
STRENGTH: "strength",
|
|
463
|
+
NUMBER: "number"
|
|
464
|
+
}, v = {
|
|
465
|
+
IDLE: "idle",
|
|
466
|
+
SUBMITTING: "submitting",
|
|
467
|
+
POLLING: "polling",
|
|
468
|
+
SUCCESS: "success",
|
|
469
|
+
ERROR: "error"
|
|
470
|
+
}, y = {
|
|
471
|
+
POLL_INTERVAL: 1e3,
|
|
472
|
+
MAX_POLL_ATTEMPTS: 120,
|
|
473
|
+
POLL_ENDPOINT: "/task/progress"
|
|
474
|
+
}, b = {
|
|
475
|
+
CHANGE: "change",
|
|
476
|
+
SUBMIT: "submit",
|
|
477
|
+
POLL: "poll",
|
|
478
|
+
SUCCESS: "success",
|
|
479
|
+
ERROR: "error",
|
|
480
|
+
IMAGE_CLICK: "image-click",
|
|
481
|
+
COMPARE: "compare"
|
|
482
|
+
}, x = {
|
|
483
|
+
MISSING_ENDPOINT: "未指定提交端点或任务类型",
|
|
484
|
+
POLL_TIMEOUT: (e) => `轮询超时: ${e}`,
|
|
485
|
+
POLL_FAILED: "轮询失败",
|
|
486
|
+
TASK_NOT_FOUND: (e) => `未找到任务: ${e}`,
|
|
487
|
+
SUBMIT_FAILED: "提交失败",
|
|
488
|
+
FIELD_REQUIRED: (e) => `${e}为必填项`,
|
|
489
|
+
FIELD_STRING: (e) => `${e}必须为字符串`,
|
|
490
|
+
FIELD_ARRAY: (e) => `${e}必须为非空数组`,
|
|
491
|
+
FIELD_ARRAY_ELEMENTS: (e) => `${e}数组元素必须为非空字符串`,
|
|
492
|
+
FIELD_MAX_LENGTH: (e, t) => `${e}不能超过${t}个字符`,
|
|
493
|
+
FIELD_ENUM_INVALID: (e) => `${e}值不在可选项中`,
|
|
494
|
+
FIELD_COLOR_FORMAT: (e) => `${e}必须为#RRGGBB格式`,
|
|
495
|
+
FIELD_NUMBER: (e) => `${e}必须为数字`
|
|
496
|
+
}, Ae = { IMAGE: [
|
|
497
|
+
"image/jpeg",
|
|
498
|
+
"image/png",
|
|
499
|
+
"image/webp"
|
|
500
|
+
] }, je = { MAX_IMAGE_SIZE: 10 * 1024 * 1024 }, Me = [
|
|
501
|
+
{
|
|
502
|
+
label: "1:1",
|
|
503
|
+
value: "1:1"
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
label: "2:3",
|
|
507
|
+
value: "2:3"
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
label: "3:4",
|
|
511
|
+
value: "3:4"
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
label: "3:2",
|
|
515
|
+
value: "3:2"
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
label: "4:3",
|
|
519
|
+
value: "4:3"
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
label: "9:16",
|
|
523
|
+
value: "9:16"
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
label: "16:9",
|
|
527
|
+
value: "16:9"
|
|
528
|
+
}
|
|
529
|
+
], S = [
|
|
530
|
+
{
|
|
531
|
+
label: "正面",
|
|
532
|
+
value: "front"
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
label: "背面",
|
|
536
|
+
value: "back"
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
label: "左侧",
|
|
540
|
+
value: "left"
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
label: "右侧",
|
|
544
|
+
value: "right"
|
|
545
|
+
}
|
|
546
|
+
], Ne = [
|
|
547
|
+
{
|
|
548
|
+
label: "2倍",
|
|
549
|
+
value: "2"
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
label: "3倍",
|
|
553
|
+
value: "3"
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
label: "4倍",
|
|
557
|
+
value: "4"
|
|
558
|
+
}
|
|
559
|
+
], Pe = [{
|
|
560
|
+
label: "线稿",
|
|
561
|
+
value: "line"
|
|
562
|
+
}, {
|
|
563
|
+
label: "印花",
|
|
564
|
+
value: "printing"
|
|
565
|
+
}], C = [{
|
|
566
|
+
label: "女",
|
|
567
|
+
value: "female"
|
|
568
|
+
}, {
|
|
569
|
+
label: "男",
|
|
570
|
+
value: "male"
|
|
571
|
+
}], Fe = [{
|
|
572
|
+
label: "青年",
|
|
573
|
+
value: "young"
|
|
574
|
+
}, {
|
|
575
|
+
label: "中年",
|
|
576
|
+
value: "middle"
|
|
577
|
+
}], Ie = [
|
|
578
|
+
{
|
|
579
|
+
label: "亚洲",
|
|
580
|
+
value: "asian"
|
|
581
|
+
},
|
|
582
|
+
{
|
|
583
|
+
label: "欧洲",
|
|
584
|
+
value: "european"
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
label: "非洲",
|
|
588
|
+
value: "african"
|
|
589
|
+
}
|
|
590
|
+
], Le = [
|
|
591
|
+
{
|
|
592
|
+
label: "上装",
|
|
593
|
+
value: "upper"
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
label: "下装",
|
|
597
|
+
value: "lower"
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
label: "连身装",
|
|
601
|
+
value: "dress"
|
|
602
|
+
}
|
|
603
|
+
], Re = [
|
|
604
|
+
{
|
|
605
|
+
label: "袖型",
|
|
606
|
+
value: "sleeve"
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
label: "领型",
|
|
610
|
+
value: "collar"
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
label: "裤型",
|
|
614
|
+
value: "pants"
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
label: "裙型",
|
|
618
|
+
value: "skirt"
|
|
619
|
+
}
|
|
620
|
+
], ze = [
|
|
621
|
+
{
|
|
622
|
+
label: "全身",
|
|
623
|
+
value: "full"
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
label: "半身",
|
|
627
|
+
value: "half"
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
label: "服装",
|
|
631
|
+
value: "clothing"
|
|
632
|
+
}
|
|
633
|
+
], Be = [{
|
|
634
|
+
label: "黑白线稿",
|
|
635
|
+
value: "bw"
|
|
636
|
+
}, {
|
|
637
|
+
label: "彩色线稿",
|
|
638
|
+
value: "color"
|
|
639
|
+
}], Ve = [
|
|
640
|
+
{
|
|
641
|
+
label: "背包",
|
|
642
|
+
value: "bag"
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
label: "鞋子",
|
|
646
|
+
value: "shoes"
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
label: "首饰",
|
|
650
|
+
value: "jewelry"
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
label: "腰带",
|
|
654
|
+
value: "belt"
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
label: "帽子",
|
|
658
|
+
value: "hat"
|
|
659
|
+
}
|
|
660
|
+
], He = [{
|
|
661
|
+
label: "棚内瑜伽",
|
|
662
|
+
value: "yoga"
|
|
663
|
+
}, {
|
|
664
|
+
label: "极简棚拍",
|
|
665
|
+
value: "minimal"
|
|
666
|
+
}], Ue = [{
|
|
667
|
+
label: "自定义像素",
|
|
668
|
+
value: "1"
|
|
669
|
+
}, {
|
|
670
|
+
label: "比例裁剪",
|
|
671
|
+
value: "2"
|
|
672
|
+
}], We = [{
|
|
673
|
+
label: "3秒",
|
|
674
|
+
value: "3"
|
|
675
|
+
}, {
|
|
676
|
+
label: "5秒",
|
|
677
|
+
value: "5"
|
|
678
|
+
}], Ge = [{
|
|
679
|
+
label: "是",
|
|
680
|
+
value: "true"
|
|
681
|
+
}, {
|
|
682
|
+
label: "否",
|
|
683
|
+
value: "false"
|
|
684
|
+
}], Ke = [
|
|
685
|
+
{
|
|
686
|
+
label: "中国",
|
|
687
|
+
value: "china"
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
label: "美国",
|
|
691
|
+
value: "usa"
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
label: "英国",
|
|
695
|
+
value: "uk"
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
label: "法国",
|
|
699
|
+
value: "france"
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
label: "德国",
|
|
703
|
+
value: "germany"
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
label: "意大利",
|
|
707
|
+
value: "italy"
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
label: "西班牙",
|
|
711
|
+
value: "spain"
|
|
712
|
+
},
|
|
713
|
+
{
|
|
714
|
+
label: "俄罗斯",
|
|
715
|
+
value: "russia"
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
label: "日本",
|
|
719
|
+
value: "japan"
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
label: "韩国",
|
|
723
|
+
value: "korea"
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
label: "泰国",
|
|
727
|
+
value: "thailand"
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
label: "印度",
|
|
731
|
+
value: "india"
|
|
732
|
+
},
|
|
733
|
+
{
|
|
734
|
+
label: "越南",
|
|
735
|
+
value: "vietnam"
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
label: "其他",
|
|
739
|
+
value: "other"
|
|
740
|
+
}
|
|
741
|
+
], qe = [
|
|
742
|
+
{
|
|
743
|
+
label: "白皙",
|
|
744
|
+
value: "fair"
|
|
745
|
+
},
|
|
746
|
+
{
|
|
747
|
+
label: "中等",
|
|
748
|
+
value: "medium"
|
|
749
|
+
},
|
|
750
|
+
{
|
|
751
|
+
label: "小麦色",
|
|
752
|
+
value: "wheatish"
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
label: "深色",
|
|
756
|
+
value: "dark"
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
label: "其他",
|
|
760
|
+
value: "other"
|
|
761
|
+
}
|
|
762
|
+
], Je = [
|
|
763
|
+
{
|
|
764
|
+
label: "偏瘦",
|
|
765
|
+
value: "slim"
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
label: "标准",
|
|
769
|
+
value: "standard"
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
label: "微胖",
|
|
773
|
+
value: "chubby"
|
|
774
|
+
},
|
|
775
|
+
{
|
|
776
|
+
label: "肥胖",
|
|
777
|
+
value: "fat"
|
|
778
|
+
}
|
|
779
|
+
], w = [{
|
|
780
|
+
label: "一致",
|
|
781
|
+
value: "same"
|
|
782
|
+
}, {
|
|
783
|
+
label: "相似",
|
|
784
|
+
value: "similar"
|
|
785
|
+
}], Ye = [{
|
|
786
|
+
label: "偏小",
|
|
787
|
+
value: "smaller"
|
|
788
|
+
}, {
|
|
789
|
+
label: "偏大",
|
|
790
|
+
value: "larger"
|
|
791
|
+
}];
|
|
792
|
+
//#endregion
|
|
793
|
+
//#region \0@oxc-project+runtime@0.130.0/helpers/decorate.js
|
|
794
|
+
function T(e, t, n, r) {
|
|
795
|
+
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
796
|
+
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
797
|
+
else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
|
|
798
|
+
return i > 3 && a && Object.defineProperty(t, n, a), a;
|
|
799
|
+
}
|
|
800
|
+
//#endregion
|
|
801
|
+
//#region src/components/image-uploader/image-uploader.ts
|
|
802
|
+
var E = class extends e {
|
|
803
|
+
constructor(...e) {
|
|
804
|
+
super(...e), this.name = "", this.label = "", this.hint = "", this.value = "", this.file = null, this.disabled = !1, this.showMaskHint = !1, this._previewUrl = "", this._errorMessage = "", this._isDragOver = !1;
|
|
805
|
+
}
|
|
806
|
+
static {
|
|
807
|
+
this.styles = t`
|
|
808
|
+
:host {
|
|
809
|
+
display: block;
|
|
810
|
+
--lc-uploader-border-color: var(--lc-color-border);
|
|
811
|
+
--lc-uploader-border-style: dashed;
|
|
812
|
+
--lc-uploader-border-width: 2px;
|
|
813
|
+
--lc-uploader-border-radius: var(--lc-radius-component);
|
|
814
|
+
--lc-uploader-bg: var(--lc-color-bg);
|
|
815
|
+
--lc-uploader-bg-hover: var(--lc-color-primary-light);
|
|
816
|
+
--lc-uploader-padding: var(--lc-spacing-6);
|
|
817
|
+
--lc-uploader-icon-size: 48px;
|
|
818
|
+
--lc-uploader-icon-color: var(--lc-color-text-secondary);
|
|
819
|
+
--lc-uploader-placeholder-color: var(--lc-color-text-placeholder);
|
|
820
|
+
--lc-uploader-error-color: var(--lc-color-error);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
:host([disabled]) {
|
|
824
|
+
opacity: 0.5;
|
|
825
|
+
pointer-events: none;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
.container {
|
|
829
|
+
display: flex;
|
|
830
|
+
flex-direction: column;
|
|
831
|
+
gap: var(--lc-spacing-2);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
.label {
|
|
835
|
+
color: var(--lc-color-text);
|
|
836
|
+
font-size: var(--lc-font-size-sm);
|
|
837
|
+
font-weight: 500;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
.dropzone {
|
|
841
|
+
display: flex;
|
|
842
|
+
flex-direction: column;
|
|
843
|
+
align-items: center;
|
|
844
|
+
justify-content: center;
|
|
845
|
+
gap: var(--lc-spacing-2);
|
|
846
|
+
border: var(--lc-uploader-border-width) var(--lc-uploader-border-style)
|
|
847
|
+
var(--lc-uploader-border-color);
|
|
848
|
+
border-radius: var(--lc-uploader-border-radius);
|
|
849
|
+
background: var(--lc-uploader-bg);
|
|
850
|
+
padding: var(--lc-uploader-padding);
|
|
851
|
+
cursor: pointer;
|
|
852
|
+
transition: background var(--lc-transition-fast),
|
|
853
|
+
border-color var(--lc-transition-fast);
|
|
854
|
+
min-height: 160px;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
.dropzone:hover {
|
|
858
|
+
background: var(--lc-uploader-bg-hover);
|
|
859
|
+
border-color: var(--lc-color-primary);
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
.dropzone.dragover {
|
|
863
|
+
background: var(--lc-uploader-bg-hover);
|
|
864
|
+
border-color: var(--lc-color-primary);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
.dropzone-icon {
|
|
868
|
+
width: var(--lc-uploader-icon-size);
|
|
869
|
+
height: var(--lc-uploader-icon-size);
|
|
870
|
+
color: var(--lc-uploader-icon-color);
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
.dropzone-text {
|
|
874
|
+
font-size: var(--lc-font-size-sm);
|
|
875
|
+
color: var(--lc-uploader-placeholder-color);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
.hidden-input {
|
|
879
|
+
display: none;
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
.preview {
|
|
883
|
+
position: relative;
|
|
884
|
+
border-radius: var(--lc-uploader-border-radius);
|
|
885
|
+
overflow: hidden;
|
|
886
|
+
border: var(--lc-uploader-border-width) solid var(--lc-color-border);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
.preview img {
|
|
890
|
+
display: block;
|
|
891
|
+
max-width: 100%;
|
|
892
|
+
max-height: 300px;
|
|
893
|
+
object-fit: contain;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
.preview-remove {
|
|
897
|
+
position: absolute;
|
|
898
|
+
top: var(--lc-spacing-1);
|
|
899
|
+
right: var(--lc-spacing-1);
|
|
900
|
+
width: 28px;
|
|
901
|
+
height: 28px;
|
|
902
|
+
border: none;
|
|
903
|
+
border-radius: var(--lc-radius-full);
|
|
904
|
+
background: rgba(0, 0, 0, 0.5);
|
|
905
|
+
color: #fff;
|
|
906
|
+
font-size: var(--lc-font-size-base);
|
|
907
|
+
line-height: 1;
|
|
908
|
+
cursor: pointer;
|
|
909
|
+
display: flex;
|
|
910
|
+
align-items: center;
|
|
911
|
+
justify-content: center;
|
|
912
|
+
transition: background var(--lc-transition-fast);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
.preview-remove:hover {
|
|
916
|
+
background: rgba(0, 0, 0, 0.7);
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
.hint {
|
|
920
|
+
font-size: var(--lc-font-size-xs);
|
|
921
|
+
color: var(--lc-color-text-secondary);
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
.error {
|
|
925
|
+
font-size: var(--lc-font-size-xs);
|
|
926
|
+
color: var(--lc-uploader-error-color);
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
.mask-hint {
|
|
930
|
+
font-size: var(--lc-font-size-xs);
|
|
931
|
+
color: var(--lc-color-text-secondary);
|
|
932
|
+
margin-top: var(--lc-spacing-1);
|
|
933
|
+
}
|
|
934
|
+
`;
|
|
935
|
+
}
|
|
936
|
+
disconnectedCallback() {
|
|
937
|
+
super.disconnectedCallback(), this._cleanupPreview();
|
|
938
|
+
}
|
|
939
|
+
_cleanupPreview() {
|
|
940
|
+
this._previewUrl && URL.revokeObjectURL(this._previewUrl);
|
|
941
|
+
}
|
|
942
|
+
_handleClick() {
|
|
943
|
+
this._fileInput?.click();
|
|
944
|
+
}
|
|
945
|
+
_handleDragOver(e) {
|
|
946
|
+
e.preventDefault(), this._isDragOver = !0;
|
|
947
|
+
}
|
|
948
|
+
_handleDragLeave() {
|
|
949
|
+
this._isDragOver = !1;
|
|
950
|
+
}
|
|
951
|
+
_handleDrop(e) {
|
|
952
|
+
e.preventDefault(), this._isDragOver = !1;
|
|
953
|
+
let t = e.dataTransfer?.files[0];
|
|
954
|
+
t && this._processFile(t);
|
|
955
|
+
}
|
|
956
|
+
_handleFileChange(e) {
|
|
957
|
+
let t = e.target, n = t.files?.[0];
|
|
958
|
+
n && this._processFile(n), t.value = "";
|
|
959
|
+
}
|
|
960
|
+
async _processFile(e) {
|
|
961
|
+
this._errorMessage = "";
|
|
962
|
+
let t = await Se(e);
|
|
963
|
+
if (!t.valid) {
|
|
964
|
+
this._errorMessage = t.errors.join("; "), this.value = "", this.file = null, this._dispatchChange(null);
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
let n = URL.createObjectURL(e);
|
|
968
|
+
this._cleanupPreview(), this._previewUrl = n, this.file = e, this.value = n, this._dispatchChange(e);
|
|
969
|
+
}
|
|
970
|
+
_handleRemove(e) {
|
|
971
|
+
e.stopPropagation(), this._cleanupPreview(), this._previewUrl = "", this.value = "", this.file = null, this._errorMessage = "", this._dispatchChange(null);
|
|
972
|
+
}
|
|
973
|
+
_dispatchChange(e) {
|
|
974
|
+
this.dispatchEvent(new CustomEvent(b.CHANGE, {
|
|
975
|
+
detail: {
|
|
976
|
+
value: this.value,
|
|
977
|
+
file: e
|
|
978
|
+
},
|
|
979
|
+
bubbles: !0,
|
|
980
|
+
composed: !0
|
|
981
|
+
}));
|
|
982
|
+
}
|
|
983
|
+
render() {
|
|
984
|
+
let e = this._previewUrl || this.value;
|
|
985
|
+
return n`
|
|
986
|
+
<div class="container" part="container">
|
|
987
|
+
${this.label ? n`<label class="label" part="label">${this.label}</label>` : r}
|
|
988
|
+
${e ? this._renderPreview() : this._renderDropzone()}
|
|
989
|
+
${this._errorMessage ? n`<div class="error">${this._errorMessage}</div>` : r}
|
|
990
|
+
${this.hint && !this.showMaskHint ? n`<div class="hint" part="hint">${this.hint}</div>` : r}
|
|
991
|
+
${this.showMaskHint ? this._renderMaskHint() : r}
|
|
992
|
+
</div>
|
|
993
|
+
`;
|
|
994
|
+
}
|
|
995
|
+
_renderDropzone() {
|
|
996
|
+
return n`
|
|
997
|
+
<div
|
|
998
|
+
class="${this._isDragOver ? "dropzone dragover" : "dropzone"}"
|
|
999
|
+
part="dropzone"
|
|
1000
|
+
@click=${this._handleClick}
|
|
1001
|
+
@dragover=${this._handleDragOver}
|
|
1002
|
+
@dragleave=${this._handleDragLeave}
|
|
1003
|
+
@drop=${this._handleDrop}
|
|
1004
|
+
>
|
|
1005
|
+
<svg
|
|
1006
|
+
class="dropzone-icon"
|
|
1007
|
+
viewBox="0 0 48 48"
|
|
1008
|
+
fill="none"
|
|
1009
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
1010
|
+
>
|
|
1011
|
+
<path
|
|
1012
|
+
d="M24 6v24M24 6l-7 7M24 6l7 7"
|
|
1013
|
+
stroke="currentColor"
|
|
1014
|
+
stroke-width="3"
|
|
1015
|
+
stroke-linecap="round"
|
|
1016
|
+
stroke-linejoin="round"
|
|
1017
|
+
/>
|
|
1018
|
+
<path
|
|
1019
|
+
d="M8 30v8a4 4 0 004 4h24a4 4 0 004-4v-8"
|
|
1020
|
+
stroke="currentColor"
|
|
1021
|
+
stroke-width="3"
|
|
1022
|
+
stroke-linecap="round"
|
|
1023
|
+
stroke-linejoin="round"
|
|
1024
|
+
/>
|
|
1025
|
+
</svg>
|
|
1026
|
+
<span class="dropzone-text">点击或拖拽图片到此处</span>
|
|
1027
|
+
<input
|
|
1028
|
+
class="hidden-input"
|
|
1029
|
+
type="file"
|
|
1030
|
+
accept="image/*"
|
|
1031
|
+
?disabled=${this.disabled}
|
|
1032
|
+
@change=${this._handleFileChange}
|
|
1033
|
+
/>
|
|
1034
|
+
</div>
|
|
1035
|
+
`;
|
|
1036
|
+
}
|
|
1037
|
+
_renderPreview() {
|
|
1038
|
+
return n`
|
|
1039
|
+
<div class="preview" part="preview">
|
|
1040
|
+
<img src="${this._previewUrl || this.value}" alt="预览" />
|
|
1041
|
+
<button
|
|
1042
|
+
class="preview-remove"
|
|
1043
|
+
@click=${this._handleRemove}
|
|
1044
|
+
aria-label="删除图片"
|
|
1045
|
+
>
|
|
1046
|
+
×
|
|
1047
|
+
</button>
|
|
1048
|
+
</div>
|
|
1049
|
+
`;
|
|
1050
|
+
}
|
|
1051
|
+
_renderMaskHint() {
|
|
1052
|
+
return n`<div class="mask-hint" part="hint">${this.hint || "Mask hint: white keeps the area, black removes the area"}</div>`;
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
T([h({ type: String })], E.prototype, "name", void 0), T([h({ type: String })], E.prototype, "label", void 0), T([h({ type: String })], E.prototype, "hint", void 0), T([h({ type: String })], E.prototype, "value", void 0), T([h({ attribute: !1 })], E.prototype, "file", void 0), T([h({ type: Boolean })], E.prototype, "disabled", void 0), T([h({ type: Boolean })], E.prototype, "showMaskHint", void 0), T([g()], E.prototype, "_previewUrl", void 0), T([g()], E.prototype, "_errorMessage", void 0), T([g()], E.prototype, "_isDragOver", void 0), T([ge("input[type=\"file\"]")], E.prototype, "_fileInput", void 0), E = T([i("lc-image-uploader")], E);
|
|
1056
|
+
//#endregion
|
|
1057
|
+
//#region src/components/mask-editor/mask-editor.ts
|
|
1058
|
+
var D = class extends e {
|
|
1059
|
+
constructor(...e) {
|
|
1060
|
+
super(...e), this.label = "涂抹蒙版", this.name = "", this.hint = "", this.required = !1, this.value = "", this.source = "", this.disabled = !1, this.brushSize = 28, this._mode = "paint", this._isDrawing = !1, this._errorMessage = "", this._aspectRatio = "1 / 1", this._canUndo = !1, this._canRedo = !1, this._zoom = 1, this._isSpacePressed = !1, this._isPanning = !1, this._panX = 0, this._panY = 0, this._lastPoint = null, this._lastPanPoint = null, this._history = [], this._historyIndex = -1, this._sourceWidth = 0, this._sourceHeight = 0;
|
|
1061
|
+
}
|
|
1062
|
+
static {
|
|
1063
|
+
this.styles = t`
|
|
1064
|
+
:host {
|
|
1065
|
+
display: block;
|
|
1066
|
+
--lc-mask-border-color: var(--lc-color-border);
|
|
1067
|
+
--lc-mask-border-radius: var(--lc-radius-component);
|
|
1068
|
+
--lc-mask-bg: var(--lc-color-bg);
|
|
1069
|
+
--lc-mask-bg-muted: var(--lc-color-bg-secondary, #f5f5f5);
|
|
1070
|
+
--lc-mask-padding: var(--lc-spacing-4);
|
|
1071
|
+
--lc-mask-error-color: var(--lc-color-error);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
:host([disabled]) {
|
|
1075
|
+
opacity: 0.5;
|
|
1076
|
+
pointer-events: none;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
.container {
|
|
1080
|
+
display: flex;
|
|
1081
|
+
flex-direction: column;
|
|
1082
|
+
gap: var(--lc-spacing-2);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
.label {
|
|
1086
|
+
font-size: var(--lc-font-size-sm);
|
|
1087
|
+
color: var(--lc-color-text);
|
|
1088
|
+
font-weight: 500;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
.required {
|
|
1092
|
+
color: var(--lc-color-error);
|
|
1093
|
+
margin-left: 2px;
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
.empty {
|
|
1097
|
+
min-height: 160px;
|
|
1098
|
+
display: flex;
|
|
1099
|
+
align-items: center;
|
|
1100
|
+
justify-content: center;
|
|
1101
|
+
padding: var(--lc-mask-padding);
|
|
1102
|
+
border: 1px dashed var(--lc-mask-border-color);
|
|
1103
|
+
border-radius: var(--lc-mask-border-radius);
|
|
1104
|
+
background: var(--lc-mask-bg-muted);
|
|
1105
|
+
color: var(--lc-color-text-secondary);
|
|
1106
|
+
font-size: var(--lc-font-size-sm);
|
|
1107
|
+
text-align: center;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
.editor {
|
|
1111
|
+
border: 1px solid var(--lc-mask-border-color);
|
|
1112
|
+
border-radius: var(--lc-mask-border-radius);
|
|
1113
|
+
overflow: hidden;
|
|
1114
|
+
background: var(--lc-mask-bg);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
.stage {
|
|
1118
|
+
position: relative;
|
|
1119
|
+
width: 100%;
|
|
1120
|
+
aspect-ratio: var(--lc-mask-aspect-ratio, 1 / 1);
|
|
1121
|
+
max-height: 420px;
|
|
1122
|
+
background: var(--lc-mask-bg-muted);
|
|
1123
|
+
touch-action: none;
|
|
1124
|
+
overflow: hidden;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
.stage img,
|
|
1128
|
+
.stage canvas {
|
|
1129
|
+
position: absolute;
|
|
1130
|
+
inset: 0;
|
|
1131
|
+
width: 100%;
|
|
1132
|
+
height: 100%;
|
|
1133
|
+
display: block;
|
|
1134
|
+
transform: translate(var(--lc-mask-pan-x, 0px), var(--lc-mask-pan-y, 0px)) scale(var(--lc-mask-zoom, 1));
|
|
1135
|
+
transform-origin: 0 0;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
.stage:focus {
|
|
1139
|
+
outline: none;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
.stage img {
|
|
1143
|
+
object-fit: contain;
|
|
1144
|
+
user-select: none;
|
|
1145
|
+
pointer-events: none;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
canvas {
|
|
1149
|
+
cursor: crosshair;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
canvas.panning {
|
|
1153
|
+
cursor: grab;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
canvas.dragging {
|
|
1157
|
+
cursor: grabbing;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
.toolbar {
|
|
1161
|
+
display: flex;
|
|
1162
|
+
align-items: center;
|
|
1163
|
+
gap: var(--lc-spacing-2);
|
|
1164
|
+
padding: var(--lc-spacing-2);
|
|
1165
|
+
border-top: 1px solid var(--lc-mask-border-color);
|
|
1166
|
+
background: var(--lc-mask-bg);
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
.toolbar button {
|
|
1170
|
+
min-height: 30px;
|
|
1171
|
+
padding: 0 var(--lc-spacing-3);
|
|
1172
|
+
border: 1px solid var(--lc-color-border);
|
|
1173
|
+
border-radius: var(--lc-radius-sm);
|
|
1174
|
+
background: var(--lc-color-bg);
|
|
1175
|
+
color: var(--lc-color-text);
|
|
1176
|
+
cursor: pointer;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
.toolbar button.active {
|
|
1180
|
+
border-color: var(--lc-color-primary);
|
|
1181
|
+
color: var(--lc-color-primary);
|
|
1182
|
+
background: var(--lc-color-primary-light);
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
.toolbar button:disabled {
|
|
1186
|
+
opacity: 0.45;
|
|
1187
|
+
cursor: not-allowed;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
.toolbar input {
|
|
1191
|
+
width: 96px;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
.zoom-value {
|
|
1195
|
+
min-width: 44px;
|
|
1196
|
+
font-size: var(--lc-font-size-xs);
|
|
1197
|
+
color: var(--lc-color-text-secondary);
|
|
1198
|
+
text-align: right;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
.hint,
|
|
1202
|
+
.mask-hint {
|
|
1203
|
+
font-size: var(--lc-font-size-xs);
|
|
1204
|
+
color: var(--lc-color-text-secondary);
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
.error {
|
|
1208
|
+
font-size: var(--lc-font-size-xs);
|
|
1209
|
+
color: var(--lc-mask-error-color);
|
|
1210
|
+
}
|
|
1211
|
+
`;
|
|
1212
|
+
}
|
|
1213
|
+
firstUpdated() {
|
|
1214
|
+
this._setupCanvas();
|
|
1215
|
+
}
|
|
1216
|
+
updated(e) {
|
|
1217
|
+
e.has("source") && this._loadSource();
|
|
1218
|
+
}
|
|
1219
|
+
disconnectedCallback() {
|
|
1220
|
+
this._resizeObserver?.disconnect(), super.disconnectedCallback();
|
|
1221
|
+
}
|
|
1222
|
+
_setupCanvas() {
|
|
1223
|
+
if (this._ctx = this._canvas?.getContext("2d") ?? void 0, typeof ResizeObserver < "u") {
|
|
1224
|
+
this._resizeObserver = new ResizeObserver(() => this._resizeCanvas());
|
|
1225
|
+
let e = this.renderRoot.querySelector(".stage");
|
|
1226
|
+
e && this._resizeObserver.observe(e);
|
|
1227
|
+
}
|
|
1228
|
+
this._resizeCanvas();
|
|
1229
|
+
}
|
|
1230
|
+
async _loadSource() {
|
|
1231
|
+
if (this._errorMessage = "", this.value = "", await this.updateComplete, this._setupCanvas(), !this.source) {
|
|
1232
|
+
this._clearCanvas(!1), this._resetHistory();
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
let e = new Image();
|
|
1236
|
+
e.onload = () => {
|
|
1237
|
+
this._sourceWidth = e.naturalWidth, this._sourceHeight = e.naturalHeight, this._aspectRatio = `${e.naturalWidth} / ${e.naturalHeight}`, this.style.setProperty("--lc-mask-aspect-ratio", this._aspectRatio), this._setZoom(1), this._setPan(0, 0), this._clearCanvas(!1), this._resetHistory();
|
|
1238
|
+
}, e.onerror = () => {
|
|
1239
|
+
this._errorMessage = "无法加载原图,请重新上传图片";
|
|
1240
|
+
}, e.src = this.source;
|
|
1241
|
+
}
|
|
1242
|
+
_resizeCanvas() {
|
|
1243
|
+
let e = this._canvas;
|
|
1244
|
+
if (!e) return;
|
|
1245
|
+
let t = e.getBoundingClientRect(), n = Math.max(1, Math.round(t.width)), r = Math.max(1, Math.round(t.height));
|
|
1246
|
+
if (e.width === n && e.height === r) return;
|
|
1247
|
+
let i = e.width && e.height ? e.toDataURL("image/png") : "";
|
|
1248
|
+
if (e.width = n, e.height = r, this._ctx = e.getContext("2d") ?? void 0, i) {
|
|
1249
|
+
let e = new Image();
|
|
1250
|
+
e.onload = () => {
|
|
1251
|
+
this._ctx?.drawImage(e, 0, 0, n, r), this._syncValue();
|
|
1252
|
+
}, e.src = i;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
_clearCanvas(e = !0) {
|
|
1256
|
+
let t = this._canvas;
|
|
1257
|
+
!t || !this._ctx || (this._ctx.clearRect(0, 0, t.width, t.height), this._syncValue(), e && this._commitHistory());
|
|
1258
|
+
}
|
|
1259
|
+
_handlePointerDown(e) {
|
|
1260
|
+
if (!this.source || this.disabled) return;
|
|
1261
|
+
if (this._focusStage(e), this._isSpacePressed) {
|
|
1262
|
+
this._isPanning = !0, this._lastPanPoint = {
|
|
1263
|
+
x: e.clientX,
|
|
1264
|
+
y: e.clientY
|
|
1265
|
+
}, this._canvas?.setPointerCapture(e.pointerId);
|
|
1266
|
+
return;
|
|
1267
|
+
}
|
|
1268
|
+
this._isDrawing = !0, this._canvas?.setPointerCapture(e.pointerId);
|
|
1269
|
+
let t = this._getCanvasPoint(e);
|
|
1270
|
+
if (!this._isPointInCanvas(t)) {
|
|
1271
|
+
this._isDrawing = !1, this._lastPoint = null;
|
|
1272
|
+
return;
|
|
1273
|
+
}
|
|
1274
|
+
this._lastPoint = t, this._drawPoint(t);
|
|
1275
|
+
}
|
|
1276
|
+
_handleWheel(e) {
|
|
1277
|
+
if (!this.source || this.disabled) return;
|
|
1278
|
+
e.preventDefault();
|
|
1279
|
+
let t = e.deltaY < 0 ? 1.12 : .88;
|
|
1280
|
+
this._setZoomAt(this._zoom * t, e);
|
|
1281
|
+
}
|
|
1282
|
+
_handlePointerMove(e) {
|
|
1283
|
+
if (this._isPanning) {
|
|
1284
|
+
this._pan(e);
|
|
1285
|
+
return;
|
|
1286
|
+
}
|
|
1287
|
+
this._isDrawing && (typeof e.getCoalescedEvents == "function" ? e.getCoalescedEvents() : [e]).forEach((e) => {
|
|
1288
|
+
let t = this._getCanvasPoint(e);
|
|
1289
|
+
if (!this._isPointInCanvas(t)) {
|
|
1290
|
+
this._lastPoint = null;
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
this._drawLineTo(t);
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
_handlePointerUp(e) {
|
|
1297
|
+
if (this._isPanning) {
|
|
1298
|
+
this._isPanning = !1, this._lastPanPoint = null, this._canvas?.releasePointerCapture(e.pointerId);
|
|
1299
|
+
return;
|
|
1300
|
+
}
|
|
1301
|
+
if (!this._isDrawing) return;
|
|
1302
|
+
let t = this._getCanvasPoint(e);
|
|
1303
|
+
this._isPointInCanvas(t) && this._drawLineTo(t), this._isDrawing = !1, this._lastPoint = null, this._canvas?.releasePointerCapture(e.pointerId), this._syncValue(), this._commitHistory();
|
|
1304
|
+
}
|
|
1305
|
+
_focusStage(e) {
|
|
1306
|
+
(e.currentTarget?.closest(".stage"))?.focus({ preventScroll: !0 });
|
|
1307
|
+
}
|
|
1308
|
+
_handleKeyDown(e) {
|
|
1309
|
+
e.code === "Space" && (e.preventDefault(), this._isSpacePressed = !0);
|
|
1310
|
+
}
|
|
1311
|
+
_handleKeyUp(e) {
|
|
1312
|
+
e.code === "Space" && (e.preventDefault(), this._isSpacePressed = !1, this._isPanning = !1, this._lastPanPoint = null);
|
|
1313
|
+
}
|
|
1314
|
+
_handleBlur() {
|
|
1315
|
+
this._isSpacePressed = !1, this._isPanning = !1, this._lastPanPoint = null;
|
|
1316
|
+
}
|
|
1317
|
+
_pan(e) {
|
|
1318
|
+
if (!this._lastPanPoint) {
|
|
1319
|
+
this._lastPanPoint = {
|
|
1320
|
+
x: e.clientX,
|
|
1321
|
+
y: e.clientY
|
|
1322
|
+
};
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
let t = e.clientX - this._lastPanPoint.x, n = e.clientY - this._lastPanPoint.y;
|
|
1326
|
+
this._lastPanPoint = {
|
|
1327
|
+
x: e.clientX,
|
|
1328
|
+
y: e.clientY
|
|
1329
|
+
}, this._setPan(this._panX + t, this._panY + n);
|
|
1330
|
+
}
|
|
1331
|
+
_getCanvasPoint(e) {
|
|
1332
|
+
let t = this._canvas;
|
|
1333
|
+
if (!t) return {
|
|
1334
|
+
x: 0,
|
|
1335
|
+
y: 0
|
|
1336
|
+
};
|
|
1337
|
+
let n = t.getBoundingClientRect(), r = n.width ? t.width / n.width : 1, i = n.height ? t.height / n.height : 1;
|
|
1338
|
+
return {
|
|
1339
|
+
x: (e.clientX - n.left) * r,
|
|
1340
|
+
y: (e.clientY - n.top) * i
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1343
|
+
_getStagePoint(e) {
|
|
1344
|
+
let t = this.renderRoot.querySelector(".stage");
|
|
1345
|
+
if (!t) return {
|
|
1346
|
+
x: 0,
|
|
1347
|
+
y: 0
|
|
1348
|
+
};
|
|
1349
|
+
let n = t.getBoundingClientRect();
|
|
1350
|
+
return {
|
|
1351
|
+
x: e.clientX - n.left,
|
|
1352
|
+
y: e.clientY - n.top
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1355
|
+
_isPointInCanvas(e) {
|
|
1356
|
+
let t = this._getImageCanvasRect();
|
|
1357
|
+
if (t) return e.x >= t.x && e.x <= t.x + t.width && e.y >= t.y && e.y <= t.y + t.height;
|
|
1358
|
+
let n = this._canvas;
|
|
1359
|
+
return n ? e.x >= 0 && e.x <= n.width && e.y >= 0 && e.y <= n.height : !1;
|
|
1360
|
+
}
|
|
1361
|
+
_getImageCanvasRect() {
|
|
1362
|
+
let e = this._canvas;
|
|
1363
|
+
if (!e || !this._sourceWidth || !this._sourceHeight) return null;
|
|
1364
|
+
let t = this._sourceWidth / this._sourceHeight, n = e.width / e.height, r = e.width, i = e.height, a = 0, o = 0;
|
|
1365
|
+
return n > t ? (r = i * t, a = (e.width - r) / 2) : n < t && (i = r / t, o = (e.height - i) / 2), {
|
|
1366
|
+
x: a,
|
|
1367
|
+
y: o,
|
|
1368
|
+
width: r,
|
|
1369
|
+
height: i
|
|
1370
|
+
};
|
|
1371
|
+
}
|
|
1372
|
+
_drawPoint(e) {
|
|
1373
|
+
let t = this._ctx;
|
|
1374
|
+
t && this._isPointInCanvas(e) && (t.save(), this._clipToImage(t), t.globalCompositeOperation = this._mode === "paint" ? "source-over" : "destination-out", t.fillStyle = "rgba(255, 255, 255, 0.68)", t.beginPath(), t.arc(e.x, e.y, this.brushSize / 2, 0, Math.PI * 2), t.fill(), t.restore());
|
|
1375
|
+
}
|
|
1376
|
+
_drawLineTo(e) {
|
|
1377
|
+
let t = this._ctx;
|
|
1378
|
+
if (t) {
|
|
1379
|
+
if (!this._isPointInCanvas(e)) {
|
|
1380
|
+
this._lastPoint = null;
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
if (!this._lastPoint) {
|
|
1384
|
+
this._lastPoint = e, this._drawPoint(e);
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
t.save(), this._clipToImage(t), t.globalCompositeOperation = this._mode === "paint" ? "source-over" : "destination-out", t.strokeStyle = "rgba(255, 255, 255, 0.68)", t.lineWidth = this.brushSize, t.lineCap = "round", t.lineJoin = "round", t.beginPath(), t.moveTo(this._lastPoint.x, this._lastPoint.y), t.lineTo(e.x, e.y), t.stroke(), t.restore(), this._lastPoint = e;
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
_clipToImage(e) {
|
|
1391
|
+
let t = this._getImageCanvasRect();
|
|
1392
|
+
t && (e.beginPath(), e.rect(t.x, t.y, t.width, t.height), e.clip());
|
|
1393
|
+
}
|
|
1394
|
+
_syncValue() {
|
|
1395
|
+
let e = this._canvas;
|
|
1396
|
+
this.value = this.source && e ? e.toDataURL("image/png") : "", this.dispatchEvent(new CustomEvent(b.CHANGE, {
|
|
1397
|
+
detail: { value: this.value },
|
|
1398
|
+
bubbles: !0,
|
|
1399
|
+
composed: !0
|
|
1400
|
+
}));
|
|
1401
|
+
}
|
|
1402
|
+
_setZoom(e) {
|
|
1403
|
+
this._zoom = Math.min(5, Math.max(1, Number(e.toFixed(2)))), this.style.setProperty("--lc-mask-zoom", String(this._zoom)), this._zoom === 1 && this._setPan(0, 0);
|
|
1404
|
+
}
|
|
1405
|
+
_setZoomAt(e, t) {
|
|
1406
|
+
let n = this._zoom, r = Math.min(5, Math.max(1, Number(e.toFixed(2))));
|
|
1407
|
+
if (r === n) return;
|
|
1408
|
+
let i = this._getStagePoint(t), a = {
|
|
1409
|
+
x: (i.x - this._panX) / n,
|
|
1410
|
+
y: (i.y - this._panY) / n
|
|
1411
|
+
};
|
|
1412
|
+
if (this._zoom = r, this.style.setProperty("--lc-mask-zoom", String(this._zoom)), this._zoom === 1) {
|
|
1413
|
+
this._setPan(0, 0);
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
this._setPan(i.x - a.x * this._zoom, i.y - a.y * this._zoom);
|
|
1417
|
+
}
|
|
1418
|
+
_setPan(e, t) {
|
|
1419
|
+
this._zoom === 1 ? (this._panX = 0, this._panY = 0) : (this._panX = e, this._panY = t), this.style.setProperty("--lc-mask-pan-x", `${this._panX}px`), this.style.setProperty("--lc-mask-pan-y", `${this._panY}px`);
|
|
1420
|
+
}
|
|
1421
|
+
_resetView() {
|
|
1422
|
+
this._setZoom(1), this._setPan(0, 0);
|
|
1423
|
+
}
|
|
1424
|
+
_resetHistory() {
|
|
1425
|
+
this._history = [this.value], this._historyIndex = 0, this._updateHistoryState();
|
|
1426
|
+
}
|
|
1427
|
+
_commitHistory() {
|
|
1428
|
+
if (!this.source) return;
|
|
1429
|
+
let e = this.value;
|
|
1430
|
+
this._history[this._historyIndex] !== e && (this._history = this._history.slice(0, this._historyIndex + 1), this._history.push(e), this._history.length > 50 && this._history.shift(), this._historyIndex = this._history.length - 1, this._updateHistoryState());
|
|
1431
|
+
}
|
|
1432
|
+
_updateHistoryState() {
|
|
1433
|
+
this._canUndo = this._historyIndex > 0, this._canRedo = this._historyIndex >= 0 && this._historyIndex < this._history.length - 1;
|
|
1434
|
+
}
|
|
1435
|
+
_undo() {
|
|
1436
|
+
this._canUndo && (--this._historyIndex, this._restoreHistory());
|
|
1437
|
+
}
|
|
1438
|
+
_redo() {
|
|
1439
|
+
this._canRedo && (this._historyIndex += 1, this._restoreHistory());
|
|
1440
|
+
}
|
|
1441
|
+
_restoreHistory() {
|
|
1442
|
+
let e = this._history[this._historyIndex] ?? "";
|
|
1443
|
+
this._restoreSnapshot(e), this._updateHistoryState();
|
|
1444
|
+
}
|
|
1445
|
+
_restoreSnapshot(e) {
|
|
1446
|
+
let t = this._canvas, n = this._ctx;
|
|
1447
|
+
if (!t || !n) return;
|
|
1448
|
+
if (n.clearRect(0, 0, t.width, t.height), !e) {
|
|
1449
|
+
this._syncValue();
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
let r = new Image();
|
|
1453
|
+
r.onload = () => {
|
|
1454
|
+
n.clearRect(0, 0, t.width, t.height), n.drawImage(r, 0, 0, t.width, t.height), this._syncValue();
|
|
1455
|
+
}, r.src = e;
|
|
1456
|
+
}
|
|
1457
|
+
render() {
|
|
1458
|
+
return n`
|
|
1459
|
+
<div class="container" part="container">
|
|
1460
|
+
${this._renderLabel()}
|
|
1461
|
+
${this.source ? this._renderEditor() : this._renderEmpty()}
|
|
1462
|
+
${this._errorMessage ? n`<div class="error">${this._errorMessage}</div>` : r}
|
|
1463
|
+
${this.hint ? n`<div class="hint" part="hint">${this.hint}</div>` : r}
|
|
1464
|
+
<div class="mask-hint">先上传原图,再在图片上涂抹需要处理的区域。</div>
|
|
1465
|
+
</div>
|
|
1466
|
+
`;
|
|
1467
|
+
}
|
|
1468
|
+
_renderLabel() {
|
|
1469
|
+
return n`
|
|
1470
|
+
<label class="label" part="label">
|
|
1471
|
+
${this.label}${this.required ? n`<span class="required">*</span>` : r}
|
|
1472
|
+
</label>
|
|
1473
|
+
`;
|
|
1474
|
+
}
|
|
1475
|
+
_renderEmpty() {
|
|
1476
|
+
return n`
|
|
1477
|
+
<div class="empty" part="editor">
|
|
1478
|
+
请先上传原图,随后在这里涂抹生成蒙版
|
|
1479
|
+
</div>
|
|
1480
|
+
`;
|
|
1481
|
+
}
|
|
1482
|
+
_renderEditor() {
|
|
1483
|
+
return n`
|
|
1484
|
+
<div class="editor" part="editor">
|
|
1485
|
+
<div
|
|
1486
|
+
class="stage"
|
|
1487
|
+
tabindex="0"
|
|
1488
|
+
@wheel=${this._handleWheel}
|
|
1489
|
+
@keydown=${this._handleKeyDown}
|
|
1490
|
+
@keyup=${this._handleKeyUp}
|
|
1491
|
+
@blur=${this._handleBlur}
|
|
1492
|
+
@pointerenter=${this._focusStage}
|
|
1493
|
+
>
|
|
1494
|
+
<img src=${this.source} alt="原图" />
|
|
1495
|
+
<canvas
|
|
1496
|
+
class=${this._isPanning ? "dragging" : this._isSpacePressed ? "panning" : ""}
|
|
1497
|
+
part="canvas"
|
|
1498
|
+
@pointerdown=${this._handlePointerDown}
|
|
1499
|
+
@pointermove=${this._handlePointerMove}
|
|
1500
|
+
@pointerup=${this._handlePointerUp}
|
|
1501
|
+
@pointercancel=${this._handlePointerUp}
|
|
1502
|
+
></canvas>
|
|
1503
|
+
</div>
|
|
1504
|
+
<div class="toolbar">
|
|
1505
|
+
<button
|
|
1506
|
+
type="button"
|
|
1507
|
+
class=${this._mode === "paint" ? "active" : ""}
|
|
1508
|
+
@click=${() => {
|
|
1509
|
+
this._mode = "paint";
|
|
1510
|
+
}}
|
|
1511
|
+
>涂抹</button>
|
|
1512
|
+
<button
|
|
1513
|
+
type="button"
|
|
1514
|
+
class=${this._mode === "erase" ? "active" : ""}
|
|
1515
|
+
@click=${() => {
|
|
1516
|
+
this._mode = "erase";
|
|
1517
|
+
}}
|
|
1518
|
+
>擦除</button>
|
|
1519
|
+
<button type="button" ?disabled=${!this._canUndo} @click=${this._undo}>撤销</button>
|
|
1520
|
+
<button type="button" ?disabled=${!this._canRedo} @click=${this._redo}>重做</button>
|
|
1521
|
+
<input
|
|
1522
|
+
type="range"
|
|
1523
|
+
min="8"
|
|
1524
|
+
max="80"
|
|
1525
|
+
.value=${String(this.brushSize)}
|
|
1526
|
+
@input=${(e) => {
|
|
1527
|
+
this.brushSize = Number(e.target.value);
|
|
1528
|
+
}}
|
|
1529
|
+
/>
|
|
1530
|
+
<span class="zoom-value">${Math.round(this._zoom * 100)}%</span>
|
|
1531
|
+
<button type="button" @click=${() => this._resetView()}>重置视图</button>
|
|
1532
|
+
<button type="button" @click=${() => this._clearCanvas()}>清空</button>
|
|
1533
|
+
</div>
|
|
1534
|
+
</div>
|
|
1535
|
+
`;
|
|
1536
|
+
}
|
|
1537
|
+
};
|
|
1538
|
+
T([h({ type: String })], D.prototype, "label", void 0), T([h({ type: String })], D.prototype, "name", void 0), T([h({ type: String })], D.prototype, "hint", void 0), T([h({ type: Boolean })], D.prototype, "required", void 0), T([h({ type: String })], D.prototype, "value", void 0), T([h({ type: String })], D.prototype, "source", void 0), T([h({ type: Boolean })], D.prototype, "disabled", void 0), T([h({ type: Number })], D.prototype, "brushSize", void 0), T([g()], D.prototype, "_mode", void 0), T([g()], D.prototype, "_isDrawing", void 0), T([g()], D.prototype, "_errorMessage", void 0), T([g()], D.prototype, "_aspectRatio", void 0), T([g()], D.prototype, "_canUndo", void 0), T([g()], D.prototype, "_canRedo", void 0), T([g()], D.prototype, "_zoom", void 0), T([g()], D.prototype, "_isSpacePressed", void 0), T([g()], D.prototype, "_isPanning", void 0), T([g()], D.prototype, "_panX", void 0), T([g()], D.prototype, "_panY", void 0), T([ge("canvas")], D.prototype, "_canvas", void 0), D = T([i("lc-mask-editor")], D);
|
|
1539
|
+
//#endregion
|
|
1540
|
+
//#region src/components/enum-selector/enum-selector.ts
|
|
1541
|
+
var O = class extends e {
|
|
1542
|
+
constructor(...e) {
|
|
1543
|
+
super(...e), this.label = "", this.name = "", this.value = "", this.mode = "button", this.multiple = !1, this.required = !1, this.disabled = !1, this.showIcon = !1, this.options = "[]";
|
|
1544
|
+
}
|
|
1545
|
+
static {
|
|
1546
|
+
this.styles = t`
|
|
1547
|
+
:host {
|
|
1548
|
+
display: block;
|
|
1549
|
+
font-family: var(--lc-font-family);
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
.label {
|
|
1553
|
+
display: block;
|
|
1554
|
+
font-size: var(--lc-font-size-sm);
|
|
1555
|
+
color: var(--lc-color-text);
|
|
1556
|
+
margin-bottom: var(--lc-spacing-2);
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
.label .required {
|
|
1560
|
+
color: var(--lc-color-error);
|
|
1561
|
+
margin-left: 2px;
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
.button-group {
|
|
1565
|
+
display: flex;
|
|
1566
|
+
flex-wrap: wrap;
|
|
1567
|
+
gap: var(--lc-spacing-2);
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
.button-group.with-icon {
|
|
1571
|
+
gap: var(--lc-spacing-3);
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
.btn {
|
|
1575
|
+
display: inline-flex;
|
|
1576
|
+
align-items: center;
|
|
1577
|
+
justify-content: center;
|
|
1578
|
+
gap: var(--lc-spacing-1);
|
|
1579
|
+
padding: var(--lc-spacing-1) var(--lc-spacing-3);
|
|
1580
|
+
border: 1px solid var(--lc-color-border);
|
|
1581
|
+
border-radius: var(--lc-radius-sm);
|
|
1582
|
+
background: var(--lc-color-bg);
|
|
1583
|
+
color: var(--lc-color-text);
|
|
1584
|
+
cursor: pointer;
|
|
1585
|
+
font-size: var(--lc-font-size-sm);
|
|
1586
|
+
font-family: var(--lc-font-family);
|
|
1587
|
+
transition: all var(--lc-transition-fast);
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
.btn.with-icon {
|
|
1591
|
+
min-width: 64px;
|
|
1592
|
+
min-height: 64px;
|
|
1593
|
+
flex-direction: column;
|
|
1594
|
+
padding: var(--lc-spacing-2);
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
.btn:hover:not(.active):not(:disabled) {
|
|
1598
|
+
border-color: var(--lc-color-primary);
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
.btn.active {
|
|
1602
|
+
background: var(--lc-color-primary);
|
|
1603
|
+
color: white;
|
|
1604
|
+
border-color: var(--lc-color-primary);
|
|
1605
|
+
}
|
|
1606
|
+
|
|
1607
|
+
.btn:disabled {
|
|
1608
|
+
opacity: 0.5;
|
|
1609
|
+
cursor: not-allowed;
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
.radio-group {
|
|
1613
|
+
display: flex;
|
|
1614
|
+
flex-direction: column;
|
|
1615
|
+
gap: var(--lc-spacing-2);
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
.radio-item {
|
|
1619
|
+
display: flex;
|
|
1620
|
+
align-items: center;
|
|
1621
|
+
gap: var(--lc-spacing-2);
|
|
1622
|
+
cursor: pointer;
|
|
1623
|
+
font-size: var(--lc-font-size-sm);
|
|
1624
|
+
color: var(--lc-color-text);
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
.radio-item input {
|
|
1628
|
+
accent-color: var(--lc-color-primary);
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
.radio-item.disabled {
|
|
1632
|
+
opacity: 0.5;
|
|
1633
|
+
cursor: not-allowed;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
.option-icon {
|
|
1637
|
+
display: inline-flex;
|
|
1638
|
+
align-items: center;
|
|
1639
|
+
justify-content: center;
|
|
1640
|
+
color: var(--lc-color-text-secondary);
|
|
1641
|
+
line-height: 1;
|
|
1642
|
+
}
|
|
1643
|
+
|
|
1644
|
+
.btn.active .option-icon {
|
|
1645
|
+
color: white;
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
.ratio-box {
|
|
1649
|
+
border: 2px solid currentColor;
|
|
1650
|
+
border-radius: 2px;
|
|
1651
|
+
background: var(--lc-color-bg-secondary);
|
|
1652
|
+
box-sizing: border-box;
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
.select-input {
|
|
1656
|
+
width: 100%;
|
|
1657
|
+
padding: var(--lc-spacing-1) var(--lc-spacing-2);
|
|
1658
|
+
border: 1px solid var(--lc-color-border);
|
|
1659
|
+
border-radius: var(--lc-radius-sm);
|
|
1660
|
+
font-size: var(--lc-font-size-sm);
|
|
1661
|
+
font-family: var(--lc-font-family);
|
|
1662
|
+
color: var(--lc-color-text);
|
|
1663
|
+
background: var(--lc-color-bg);
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
.select-input:focus {
|
|
1667
|
+
outline: none;
|
|
1668
|
+
border-color: var(--lc-color-primary);
|
|
1669
|
+
}
|
|
1670
|
+
`;
|
|
1671
|
+
}
|
|
1672
|
+
get parsedOptions() {
|
|
1673
|
+
try {
|
|
1674
|
+
return JSON.parse(this.options);
|
|
1675
|
+
} catch {
|
|
1676
|
+
return [];
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
get selectedValues() {
|
|
1680
|
+
if (Array.isArray(this.value)) return this.value;
|
|
1681
|
+
if (this.multiple && typeof this.value == "string" && this.value) try {
|
|
1682
|
+
let e = JSON.parse(this.value);
|
|
1683
|
+
if (Array.isArray(e)) return e.map(String);
|
|
1684
|
+
} catch {
|
|
1685
|
+
return this.value.split(",").map((e) => e.trim()).filter(Boolean);
|
|
1686
|
+
}
|
|
1687
|
+
return typeof this.value == "string" && this.value ? [this.value] : [];
|
|
1688
|
+
}
|
|
1689
|
+
isSelected(e) {
|
|
1690
|
+
return this.selectedValues.includes(e);
|
|
1691
|
+
}
|
|
1692
|
+
emitChange(e) {
|
|
1693
|
+
this.dispatchEvent(new CustomEvent(b.CHANGE, {
|
|
1694
|
+
detail: { value: e },
|
|
1695
|
+
bubbles: !0,
|
|
1696
|
+
composed: !0
|
|
1697
|
+
}));
|
|
1698
|
+
}
|
|
1699
|
+
getRatioBoxDimensions(e) {
|
|
1700
|
+
let [t, n] = e.split(":").map(Number), r = 32 / Math.max(t, n);
|
|
1701
|
+
return {
|
|
1702
|
+
width: Math.round(t * r),
|
|
1703
|
+
height: Math.round(n * r)
|
|
1704
|
+
};
|
|
1705
|
+
}
|
|
1706
|
+
isRatioValue(e) {
|
|
1707
|
+
return /^\d+(?:\.\d+)?:\d+(?:\.\d+)?$/.test(e);
|
|
1708
|
+
}
|
|
1709
|
+
renderOptionIcon(e) {
|
|
1710
|
+
if (!this.showIcon) return r;
|
|
1711
|
+
if (e.icon) return n`<span class="option-icon" aria-hidden="true">${e.icon}</span>`;
|
|
1712
|
+
if (this.isRatioValue(e.value)) {
|
|
1713
|
+
let t = this.getRatioBoxDimensions(e.value);
|
|
1714
|
+
return n`
|
|
1715
|
+
<span class="option-icon" aria-hidden="true">
|
|
1716
|
+
<span class="ratio-box" style="width: ${t.width}px; height: ${t.height}px;"></span>
|
|
1717
|
+
</span>
|
|
1718
|
+
`;
|
|
1719
|
+
}
|
|
1720
|
+
return r;
|
|
1721
|
+
}
|
|
1722
|
+
handleSelect(e) {
|
|
1723
|
+
let t = e.target;
|
|
1724
|
+
this.value = this.multiple ? Array.from(t.selectedOptions).map((e) => e.value) : t.value, this.emitChange(this.value);
|
|
1725
|
+
}
|
|
1726
|
+
handleRadioChange(e) {
|
|
1727
|
+
let t = e.target;
|
|
1728
|
+
this.value = t.value, this.emitChange(this.value);
|
|
1729
|
+
}
|
|
1730
|
+
handleCheckboxChange(e) {
|
|
1731
|
+
let t = e.target, n = new Set(this.selectedValues);
|
|
1732
|
+
t.checked ? n.add(t.value) : n.delete(t.value), this.value = Array.from(n), this.emitChange(this.value);
|
|
1733
|
+
}
|
|
1734
|
+
handleButtonClick(e) {
|
|
1735
|
+
if (!this.multiple) {
|
|
1736
|
+
this.value = e, this.emitChange(e);
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
let t = new Set(this.selectedValues);
|
|
1740
|
+
t.has(e) ? t.delete(e) : t.add(e), this.value = Array.from(t), this.emitChange(this.value);
|
|
1741
|
+
}
|
|
1742
|
+
render() {
|
|
1743
|
+
let e = this.parsedOptions;
|
|
1744
|
+
return n`
|
|
1745
|
+
${this.label ? n`<label class="label">
|
|
1746
|
+
${this.label}${this.required ? n`<span class="required">*</span>` : r}
|
|
1747
|
+
</label>` : r}
|
|
1748
|
+
${this.mode === "button" ? this.renderButtonGroup(e) : this.mode === "radio" ? this.renderRadioGroup(e) : this.renderSelect(e)}
|
|
1749
|
+
`;
|
|
1750
|
+
}
|
|
1751
|
+
renderButtonGroup(e) {
|
|
1752
|
+
return n`
|
|
1753
|
+
<div class="button-group ${this.showIcon ? "with-icon" : ""}">
|
|
1754
|
+
${e.map((e) => n`
|
|
1755
|
+
<button
|
|
1756
|
+
type="button"
|
|
1757
|
+
class="btn ${this.showIcon ? "with-icon" : ""} ${this.isSelected(e.value) ? "active" : ""}"
|
|
1758
|
+
?disabled=${this.disabled}
|
|
1759
|
+
aria-pressed=${this.isSelected(e.value)}
|
|
1760
|
+
@click=${() => this.handleButtonClick(e.value)}
|
|
1761
|
+
>
|
|
1762
|
+
${this.renderOptionIcon(e)}
|
|
1763
|
+
${e.label}
|
|
1764
|
+
</button>
|
|
1765
|
+
`)}
|
|
1766
|
+
</div>
|
|
1767
|
+
`;
|
|
1768
|
+
}
|
|
1769
|
+
renderRadioGroup(e) {
|
|
1770
|
+
return n`
|
|
1771
|
+
<div class="radio-group">
|
|
1772
|
+
${e.map((e) => n`
|
|
1773
|
+
<label class="radio-item ${this.disabled ? "disabled" : ""}">
|
|
1774
|
+
<input
|
|
1775
|
+
type=${this.multiple ? "checkbox" : "radio"}
|
|
1776
|
+
name="enum-radio"
|
|
1777
|
+
.value=${e.value}
|
|
1778
|
+
.checked=${this.isSelected(e.value)}
|
|
1779
|
+
?disabled=${this.disabled}
|
|
1780
|
+
@change=${(e) => {
|
|
1781
|
+
this.multiple ? this.handleCheckboxChange(e) : this.handleRadioChange(e);
|
|
1782
|
+
}}
|
|
1783
|
+
/>
|
|
1784
|
+
${this.renderOptionIcon(e)}
|
|
1785
|
+
${e.label}
|
|
1786
|
+
</label>
|
|
1787
|
+
`)}
|
|
1788
|
+
</div>
|
|
1789
|
+
`;
|
|
1790
|
+
}
|
|
1791
|
+
renderSelect(e) {
|
|
1792
|
+
return n`
|
|
1793
|
+
<select
|
|
1794
|
+
class="select-input"
|
|
1795
|
+
.value=${this.multiple ? "" : String(this.value)}
|
|
1796
|
+
?multiple=${this.multiple}
|
|
1797
|
+
?disabled=${this.disabled}
|
|
1798
|
+
@change=${this.handleSelect}
|
|
1799
|
+
>
|
|
1800
|
+
${e.map((e) => n`<option value=${e.value} ?selected=${this.isSelected(e.value)}>
|
|
1801
|
+
${e.label}
|
|
1802
|
+
</option>`)}
|
|
1803
|
+
</select>
|
|
1804
|
+
`;
|
|
1805
|
+
}
|
|
1806
|
+
};
|
|
1807
|
+
T([h({ type: String })], O.prototype, "label", void 0), T([h({ type: String })], O.prototype, "name", void 0), T([h()], O.prototype, "value", void 0), T([h({ type: String })], O.prototype, "mode", void 0), T([h({ type: Boolean })], O.prototype, "multiple", void 0), T([h({ type: Boolean })], O.prototype, "required", void 0), T([h({ type: Boolean })], O.prototype, "disabled", void 0), T([h({
|
|
1808
|
+
type: Boolean,
|
|
1809
|
+
attribute: "show-icon"
|
|
1810
|
+
})], O.prototype, "showIcon", void 0), T([h({ type: String })], O.prototype, "options", void 0), O = T([i("lc-enum-selector")], O);
|
|
1811
|
+
//#endregion
|
|
1812
|
+
//#region src/components/prompt-input/prompt-input.ts
|
|
1813
|
+
var k = class extends e {
|
|
1814
|
+
constructor(...e) {
|
|
1815
|
+
super(...e), this.value = "", this.name = "", this.label = "", this.placeholder = "", this.maxLength = 500, this.required = !1, this.disabled = !1;
|
|
1816
|
+
}
|
|
1817
|
+
static {
|
|
1818
|
+
this.styles = t`
|
|
1819
|
+
:host {
|
|
1820
|
+
display: block;
|
|
1821
|
+
font-family: var(--lc-font-family);
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
.label {
|
|
1825
|
+
display: block;
|
|
1826
|
+
font-size: var(--lc-font-size-sm);
|
|
1827
|
+
color: var(--lc-color-text);
|
|
1828
|
+
margin-bottom: var(--lc-spacing-2);
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
.label .required {
|
|
1832
|
+
color: var(--lc-color-error);
|
|
1833
|
+
margin-left: 2px;
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
.wrapper {
|
|
1837
|
+
position: relative;
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
textarea {
|
|
1841
|
+
width: 100%;
|
|
1842
|
+
min-height: 80px;
|
|
1843
|
+
padding: var(--lc-spacing-3);
|
|
1844
|
+
border: 1px solid var(--lc-color-border);
|
|
1845
|
+
border-radius: var(--lc-radius-component);
|
|
1846
|
+
font-family: var(--lc-font-family);
|
|
1847
|
+
font-size: var(--lc-font-size-sm);
|
|
1848
|
+
color: var(--lc-color-text);
|
|
1849
|
+
resize: vertical;
|
|
1850
|
+
outline: none;
|
|
1851
|
+
transition: border-color var(--lc-transition-fast);
|
|
1852
|
+
box-sizing: border-box;
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
textarea:focus {
|
|
1856
|
+
border-color: var(--lc-color-primary);
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
textarea::placeholder {
|
|
1860
|
+
color: var(--lc-color-text-placeholder);
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
textarea:disabled {
|
|
1864
|
+
opacity: 0.5;
|
|
1865
|
+
cursor: not-allowed;
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
.counter {
|
|
1869
|
+
text-align: right;
|
|
1870
|
+
font-size: var(--lc-font-size-xs);
|
|
1871
|
+
color: var(--lc-color-text-secondary);
|
|
1872
|
+
margin-top: var(--lc-spacing-1);
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
.counter.over {
|
|
1876
|
+
color: var(--lc-color-error);
|
|
1877
|
+
}
|
|
1878
|
+
`;
|
|
1879
|
+
}
|
|
1880
|
+
emitChange(e) {
|
|
1881
|
+
this.dispatchEvent(new CustomEvent(b.CHANGE, {
|
|
1882
|
+
detail: { value: e },
|
|
1883
|
+
bubbles: !0,
|
|
1884
|
+
composed: !0
|
|
1885
|
+
}));
|
|
1886
|
+
}
|
|
1887
|
+
handleInput(e) {
|
|
1888
|
+
let t = e.target;
|
|
1889
|
+
this.value = t.value, this.emitChange(this.value);
|
|
1890
|
+
}
|
|
1891
|
+
render() {
|
|
1892
|
+
let e = this.value.length > this.maxLength;
|
|
1893
|
+
return n`
|
|
1894
|
+
${this.label ? n`<label class="label">
|
|
1895
|
+
${this.label}${this.required ? n`<span class="required">*</span>` : r}
|
|
1896
|
+
</label>` : r}
|
|
1897
|
+
<div class="wrapper">
|
|
1898
|
+
<textarea
|
|
1899
|
+
.value=${this.value}
|
|
1900
|
+
.placeholder=${this.placeholder}
|
|
1901
|
+
?disabled=${this.disabled}
|
|
1902
|
+
.maxLength=${this.maxLength}
|
|
1903
|
+
@input=${this.handleInput}
|
|
1904
|
+
></textarea>
|
|
1905
|
+
</div>
|
|
1906
|
+
<div class="counter ${e ? "over" : ""}">
|
|
1907
|
+
${this.value.length}/${this.maxLength}
|
|
1908
|
+
</div>
|
|
1909
|
+
`;
|
|
1910
|
+
}
|
|
1911
|
+
};
|
|
1912
|
+
T([h({ type: String })], k.prototype, "value", void 0), T([h({ type: String })], k.prototype, "name", void 0), T([h({ type: String })], k.prototype, "label", void 0), T([h({ type: String })], k.prototype, "placeholder", void 0), T([h({ type: Number })], k.prototype, "maxLength", void 0), T([h({ type: Boolean })], k.prototype, "required", void 0), T([h({ type: Boolean })], k.prototype, "disabled", void 0), k = T([i("lc-prompt-input")], k);
|
|
1913
|
+
//#endregion
|
|
1914
|
+
//#region node_modules/lit-html/lit-html.js
|
|
1915
|
+
var Xe = globalThis, Ze = (e) => e, A = Xe.trustedTypes, Qe = A ? A.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, $e = "$lit$", j = `lit$${Math.random().toFixed(9).slice(2)}$`, et = "?" + j, tt = `<${et}>`, M = document, N = () => M.createComment(""), P = (e) => e === null || typeof e != "object" && typeof e != "function", nt = Array.isArray, rt = (e) => nt(e) || typeof e?.[Symbol.iterator] == "function", it = "[ \n\f\r]", F = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, at = /-->/g, ot = />/g, I = RegExp(`>|${it}(?:([^\\s"'>=/]+)(${it}*=${it}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`, "g"), st = /'/g, ct = /"/g, lt = /^(?:script|style|textarea|title)$/i, L = Symbol.for("lit-noChange"), R = Symbol.for("lit-nothing"), ut = /* @__PURE__ */ new WeakMap(), z = M.createTreeWalker(M, 129);
|
|
1916
|
+
function dt(e, t) {
|
|
1917
|
+
if (!nt(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
1918
|
+
return Qe === void 0 ? t : Qe.createHTML(t);
|
|
1919
|
+
}
|
|
1920
|
+
var ft = (e, t) => {
|
|
1921
|
+
let n = e.length - 1, r = [], i, a = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", o = F;
|
|
1922
|
+
for (let t = 0; t < n; t++) {
|
|
1923
|
+
let n = e[t], s, c, l = -1, u = 0;
|
|
1924
|
+
for (; u < n.length && (o.lastIndex = u, c = o.exec(n), c !== null);) u = o.lastIndex, o === F ? c[1] === "!--" ? o = at : c[1] === void 0 ? c[2] === void 0 ? c[3] !== void 0 && (o = I) : (lt.test(c[2]) && (i = RegExp("</" + c[2], "g")), o = I) : o = ot : o === I ? c[0] === ">" ? (o = i ?? F, l = -1) : c[1] === void 0 ? l = -2 : (l = o.lastIndex - c[2].length, s = c[1], o = c[3] === void 0 ? I : c[3] === "\"" ? ct : st) : o === ct || o === st ? o = I : o === at || o === ot ? o = F : (o = I, i = void 0);
|
|
1925
|
+
let ee = o === I && e[t + 1].startsWith("/>") ? " " : "";
|
|
1926
|
+
a += o === F ? n + tt : l >= 0 ? (r.push(s), n.slice(0, l) + $e + n.slice(l) + j + ee) : n + j + (l === -2 ? t : ee);
|
|
1927
|
+
}
|
|
1928
|
+
return [dt(e, a + (e[n] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), r];
|
|
1929
|
+
}, pt = class e {
|
|
1930
|
+
constructor({ strings: t, _$litType$: n }, r) {
|
|
1931
|
+
let i;
|
|
1932
|
+
this.parts = [];
|
|
1933
|
+
let a = 0, o = 0, s = t.length - 1, c = this.parts, [l, u] = ft(t, n);
|
|
1934
|
+
if (this.el = e.createElement(l, r), z.currentNode = this.el.content, n === 2 || n === 3) {
|
|
1935
|
+
let e = this.el.content.firstChild;
|
|
1936
|
+
e.replaceWith(...e.childNodes);
|
|
1937
|
+
}
|
|
1938
|
+
for (; (i = z.nextNode()) !== null && c.length < s;) {
|
|
1939
|
+
if (i.nodeType === 1) {
|
|
1940
|
+
if (i.hasAttributes()) for (let e of i.getAttributeNames()) if (e.endsWith($e)) {
|
|
1941
|
+
let t = u[o++], n = i.getAttribute(e).split(j), r = /([.?@])?(.*)/.exec(t);
|
|
1942
|
+
c.push({
|
|
1943
|
+
type: 1,
|
|
1944
|
+
index: a,
|
|
1945
|
+
name: r[2],
|
|
1946
|
+
strings: n,
|
|
1947
|
+
ctor: r[1] === "." ? gt : r[1] === "?" ? _t : r[1] === "@" ? vt : V
|
|
1948
|
+
}), i.removeAttribute(e);
|
|
1949
|
+
} else e.startsWith(j) && (c.push({
|
|
1950
|
+
type: 6,
|
|
1951
|
+
index: a
|
|
1952
|
+
}), i.removeAttribute(e));
|
|
1953
|
+
if (lt.test(i.tagName)) {
|
|
1954
|
+
let e = i.textContent.split(j), t = e.length - 1;
|
|
1955
|
+
if (t > 0) {
|
|
1956
|
+
i.textContent = A ? A.emptyScript : "";
|
|
1957
|
+
for (let n = 0; n < t; n++) i.append(e[n], N()), z.nextNode(), c.push({
|
|
1958
|
+
type: 2,
|
|
1959
|
+
index: ++a
|
|
1960
|
+
});
|
|
1961
|
+
i.append(e[t], N());
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
} else if (i.nodeType === 8) if (i.data === et) c.push({
|
|
1965
|
+
type: 2,
|
|
1966
|
+
index: a
|
|
1967
|
+
});
|
|
1968
|
+
else {
|
|
1969
|
+
let e = -1;
|
|
1970
|
+
for (; (e = i.data.indexOf(j, e + 1)) !== -1;) c.push({
|
|
1971
|
+
type: 7,
|
|
1972
|
+
index: a
|
|
1973
|
+
}), e += j.length - 1;
|
|
1974
|
+
}
|
|
1975
|
+
a++;
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
static createElement(e, t) {
|
|
1979
|
+
let n = M.createElement("template");
|
|
1980
|
+
return n.innerHTML = e, n;
|
|
1981
|
+
}
|
|
1982
|
+
};
|
|
1983
|
+
function B(e, t, n = e, r) {
|
|
1984
|
+
if (t === L) return t;
|
|
1985
|
+
let i = r === void 0 ? n._$Cl : n._$Co?.[r], a = P(t) ? void 0 : t._$litDirective$;
|
|
1986
|
+
return i?.constructor !== a && (i?._$AO?.(!1), a === void 0 ? i = void 0 : (i = new a(e), i._$AT(e, n, r)), r === void 0 ? n._$Cl = i : (n._$Co ??= [])[r] = i), i !== void 0 && (t = B(e, i._$AS(e, t.values), i, r)), t;
|
|
1987
|
+
}
|
|
1988
|
+
var mt = class {
|
|
1989
|
+
constructor(e, t) {
|
|
1990
|
+
this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t;
|
|
1991
|
+
}
|
|
1992
|
+
get parentNode() {
|
|
1993
|
+
return this._$AM.parentNode;
|
|
1994
|
+
}
|
|
1995
|
+
get _$AU() {
|
|
1996
|
+
return this._$AM._$AU;
|
|
1997
|
+
}
|
|
1998
|
+
u(e) {
|
|
1999
|
+
let { el: { content: t }, parts: n } = this._$AD, r = (e?.creationScope ?? M).importNode(t, !0);
|
|
2000
|
+
z.currentNode = r;
|
|
2001
|
+
let i = z.nextNode(), a = 0, o = 0, s = n[0];
|
|
2002
|
+
for (; s !== void 0;) {
|
|
2003
|
+
if (a === s.index) {
|
|
2004
|
+
let t;
|
|
2005
|
+
s.type === 2 ? t = new ht(i, i.nextSibling, this, e) : s.type === 1 ? t = new s.ctor(i, s.name, s.strings, this, e) : s.type === 6 && (t = new yt(i, this, e)), this._$AV.push(t), s = n[++o];
|
|
2006
|
+
}
|
|
2007
|
+
a !== s?.index && (i = z.nextNode(), a++);
|
|
2008
|
+
}
|
|
2009
|
+
return z.currentNode = M, r;
|
|
2010
|
+
}
|
|
2011
|
+
p(e) {
|
|
2012
|
+
let t = 0;
|
|
2013
|
+
for (let n of this._$AV) n !== void 0 && (n.strings === void 0 ? n._$AI(e[t]) : (n._$AI(e, n, t), t += n.strings.length - 2)), t++;
|
|
2014
|
+
}
|
|
2015
|
+
}, ht = class e {
|
|
2016
|
+
get _$AU() {
|
|
2017
|
+
return this._$AM?._$AU ?? this._$Cv;
|
|
2018
|
+
}
|
|
2019
|
+
constructor(e, t, n, r) {
|
|
2020
|
+
this.type = 2, this._$AH = R, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = n, this.options = r, this._$Cv = r?.isConnected ?? !0;
|
|
2021
|
+
}
|
|
2022
|
+
get parentNode() {
|
|
2023
|
+
let e = this._$AA.parentNode, t = this._$AM;
|
|
2024
|
+
return t !== void 0 && e?.nodeType === 11 && (e = t.parentNode), e;
|
|
2025
|
+
}
|
|
2026
|
+
get startNode() {
|
|
2027
|
+
return this._$AA;
|
|
2028
|
+
}
|
|
2029
|
+
get endNode() {
|
|
2030
|
+
return this._$AB;
|
|
2031
|
+
}
|
|
2032
|
+
_$AI(e, t = this) {
|
|
2033
|
+
e = B(this, e, t), P(e) ? e === R || e == null || e === "" ? (this._$AH !== R && this._$AR(), this._$AH = R) : e !== this._$AH && e !== L && this._(e) : e._$litType$ === void 0 ? e.nodeType === void 0 ? rt(e) ? this.k(e) : this._(e) : this.T(e) : this.$(e);
|
|
2034
|
+
}
|
|
2035
|
+
O(e) {
|
|
2036
|
+
return this._$AA.parentNode.insertBefore(e, this._$AB);
|
|
2037
|
+
}
|
|
2038
|
+
T(e) {
|
|
2039
|
+
this._$AH !== e && (this._$AR(), this._$AH = this.O(e));
|
|
2040
|
+
}
|
|
2041
|
+
_(e) {
|
|
2042
|
+
this._$AH !== R && P(this._$AH) ? this._$AA.nextSibling.data = e : this.T(M.createTextNode(e)), this._$AH = e;
|
|
2043
|
+
}
|
|
2044
|
+
$(e) {
|
|
2045
|
+
let { values: t, _$litType$: n } = e, r = typeof n == "number" ? this._$AC(e) : (n.el === void 0 && (n.el = pt.createElement(dt(n.h, n.h[0]), this.options)), n);
|
|
2046
|
+
if (this._$AH?._$AD === r) this._$AH.p(t);
|
|
2047
|
+
else {
|
|
2048
|
+
let e = new mt(r, this), n = e.u(this.options);
|
|
2049
|
+
e.p(t), this.T(n), this._$AH = e;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
_$AC(e) {
|
|
2053
|
+
let t = ut.get(e.strings);
|
|
2054
|
+
return t === void 0 && ut.set(e.strings, t = new pt(e)), t;
|
|
2055
|
+
}
|
|
2056
|
+
k(t) {
|
|
2057
|
+
nt(this._$AH) || (this._$AH = [], this._$AR());
|
|
2058
|
+
let n = this._$AH, r, i = 0;
|
|
2059
|
+
for (let a of t) i === n.length ? n.push(r = new e(this.O(N()), this.O(N()), this, this.options)) : r = n[i], r._$AI(a), i++;
|
|
2060
|
+
i < n.length && (this._$AR(r && r._$AB.nextSibling, i), n.length = i);
|
|
2061
|
+
}
|
|
2062
|
+
_$AR(e = this._$AA.nextSibling, t) {
|
|
2063
|
+
for (this._$AP?.(!1, !0, t); e !== this._$AB;) {
|
|
2064
|
+
let t = Ze(e).nextSibling;
|
|
2065
|
+
Ze(e).remove(), e = t;
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
setConnected(e) {
|
|
2069
|
+
this._$AM === void 0 && (this._$Cv = e, this._$AP?.(e));
|
|
2070
|
+
}
|
|
2071
|
+
}, V = class {
|
|
2072
|
+
get tagName() {
|
|
2073
|
+
return this.element.tagName;
|
|
2074
|
+
}
|
|
2075
|
+
get _$AU() {
|
|
2076
|
+
return this._$AM._$AU;
|
|
2077
|
+
}
|
|
2078
|
+
constructor(e, t, n, r, i) {
|
|
2079
|
+
this.type = 1, this._$AH = R, this._$AN = void 0, this.element = e, this.name = t, this._$AM = r, this.options = i, n.length > 2 || n[0] !== "" || n[1] !== "" ? (this._$AH = Array(n.length - 1).fill(/* @__PURE__ */ new String()), this.strings = n) : this._$AH = R;
|
|
2080
|
+
}
|
|
2081
|
+
_$AI(e, t = this, n, r) {
|
|
2082
|
+
let i = this.strings, a = !1;
|
|
2083
|
+
if (i === void 0) e = B(this, e, t, 0), a = !P(e) || e !== this._$AH && e !== L, a && (this._$AH = e);
|
|
2084
|
+
else {
|
|
2085
|
+
let r = e, o, s;
|
|
2086
|
+
for (e = i[0], o = 0; o < i.length - 1; o++) s = B(this, r[n + o], t, o), s === L && (s = this._$AH[o]), a ||= !P(s) || s !== this._$AH[o], s === R ? e = R : e !== R && (e += (s ?? "") + i[o + 1]), this._$AH[o] = s;
|
|
2087
|
+
}
|
|
2088
|
+
a && !r && this.j(e);
|
|
2089
|
+
}
|
|
2090
|
+
j(e) {
|
|
2091
|
+
e === R ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
|
|
2092
|
+
}
|
|
2093
|
+
}, gt = class extends V {
|
|
2094
|
+
constructor() {
|
|
2095
|
+
super(...arguments), this.type = 3;
|
|
2096
|
+
}
|
|
2097
|
+
j(e) {
|
|
2098
|
+
this.element[this.name] = e === R ? void 0 : e;
|
|
2099
|
+
}
|
|
2100
|
+
}, _t = class extends V {
|
|
2101
|
+
constructor() {
|
|
2102
|
+
super(...arguments), this.type = 4;
|
|
2103
|
+
}
|
|
2104
|
+
j(e) {
|
|
2105
|
+
this.element.toggleAttribute(this.name, !!e && e !== R);
|
|
2106
|
+
}
|
|
2107
|
+
}, vt = class extends V {
|
|
2108
|
+
constructor(e, t, n, r, i) {
|
|
2109
|
+
super(e, t, n, r, i), this.type = 5;
|
|
2110
|
+
}
|
|
2111
|
+
_$AI(e, t = this) {
|
|
2112
|
+
if ((e = B(this, e, t, 0) ?? R) === L) return;
|
|
2113
|
+
let n = this._$AH, r = e === R && n !== R || e.capture !== n.capture || e.once !== n.once || e.passive !== n.passive, i = e !== R && (n === R || r);
|
|
2114
|
+
r && this.element.removeEventListener(this.name, this, n), i && this.element.addEventListener(this.name, this, e), this._$AH = e;
|
|
2115
|
+
}
|
|
2116
|
+
handleEvent(e) {
|
|
2117
|
+
typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, e) : this._$AH.handleEvent(e);
|
|
2118
|
+
}
|
|
2119
|
+
}, yt = class {
|
|
2120
|
+
constructor(e, t, n) {
|
|
2121
|
+
this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = n;
|
|
2122
|
+
}
|
|
2123
|
+
get _$AU() {
|
|
2124
|
+
return this._$AM._$AU;
|
|
2125
|
+
}
|
|
2126
|
+
_$AI(e) {
|
|
2127
|
+
B(this, e);
|
|
2128
|
+
}
|
|
2129
|
+
}, bt = {
|
|
2130
|
+
M: $e,
|
|
2131
|
+
P: j,
|
|
2132
|
+
A: et,
|
|
2133
|
+
C: 1,
|
|
2134
|
+
L: ft,
|
|
2135
|
+
R: mt,
|
|
2136
|
+
D: rt,
|
|
2137
|
+
V: B,
|
|
2138
|
+
I: ht,
|
|
2139
|
+
H: V,
|
|
2140
|
+
N: _t,
|
|
2141
|
+
U: vt,
|
|
2142
|
+
B: gt,
|
|
2143
|
+
F: yt
|
|
2144
|
+
}, xt = Xe.litHtmlPolyfillSupport;
|
|
2145
|
+
xt?.(pt, ht), (Xe.litHtmlVersions ??= []).push("3.3.3");
|
|
2146
|
+
//#endregion
|
|
2147
|
+
//#region node_modules/lit-html/directive-helpers.js
|
|
2148
|
+
var { I: St } = bt, Ct = (e) => e.strings === void 0, wt = {
|
|
2149
|
+
ATTRIBUTE: 1,
|
|
2150
|
+
CHILD: 2,
|
|
2151
|
+
PROPERTY: 3,
|
|
2152
|
+
BOOLEAN_ATTRIBUTE: 4,
|
|
2153
|
+
EVENT: 5,
|
|
2154
|
+
ELEMENT: 6
|
|
2155
|
+
}, Tt = (e) => (...t) => ({
|
|
2156
|
+
_$litDirective$: e,
|
|
2157
|
+
values: t
|
|
2158
|
+
}), Et = class {
|
|
2159
|
+
constructor(e) {}
|
|
2160
|
+
get _$AU() {
|
|
2161
|
+
return this._$AM._$AU;
|
|
2162
|
+
}
|
|
2163
|
+
_$AT(e, t, n) {
|
|
2164
|
+
this._$Ct = e, this._$AM = t, this._$Ci = n;
|
|
2165
|
+
}
|
|
2166
|
+
_$AS(e, t) {
|
|
2167
|
+
return this.update(e, t);
|
|
2168
|
+
}
|
|
2169
|
+
update(e, t) {
|
|
2170
|
+
return this.render(...t);
|
|
2171
|
+
}
|
|
2172
|
+
}, H = (e, t) => {
|
|
2173
|
+
let n = e._$AN;
|
|
2174
|
+
if (n === void 0) return !1;
|
|
2175
|
+
for (let e of n) e._$AO?.(t, !1), H(e, t);
|
|
2176
|
+
return !0;
|
|
2177
|
+
}, U = (e) => {
|
|
2178
|
+
let t, n;
|
|
2179
|
+
do {
|
|
2180
|
+
if ((t = e._$AM) === void 0) break;
|
|
2181
|
+
n = t._$AN, n.delete(e), e = t;
|
|
2182
|
+
} while (n?.size === 0);
|
|
2183
|
+
}, Dt = (e) => {
|
|
2184
|
+
for (let t; t = e._$AM; e = t) {
|
|
2185
|
+
let n = t._$AN;
|
|
2186
|
+
if (n === void 0) t._$AN = n = /* @__PURE__ */ new Set();
|
|
2187
|
+
else if (n.has(e)) break;
|
|
2188
|
+
n.add(e), At(t);
|
|
2189
|
+
}
|
|
2190
|
+
};
|
|
2191
|
+
function Ot(e) {
|
|
2192
|
+
this._$AN === void 0 ? this._$AM = e : (U(this), this._$AM = e, Dt(this));
|
|
2193
|
+
}
|
|
2194
|
+
function kt(e, t = !1, n = 0) {
|
|
2195
|
+
let r = this._$AH, i = this._$AN;
|
|
2196
|
+
if (i !== void 0 && i.size !== 0) if (t) if (Array.isArray(r)) for (let e = n; e < r.length; e++) H(r[e], !1), U(r[e]);
|
|
2197
|
+
else r != null && (H(r, !1), U(r));
|
|
2198
|
+
else H(this, e);
|
|
2199
|
+
}
|
|
2200
|
+
var At = (e) => {
|
|
2201
|
+
e.type == wt.CHILD && (e._$AP ??= kt, e._$AQ ??= Ot);
|
|
2202
|
+
}, jt = class extends Et {
|
|
2203
|
+
constructor() {
|
|
2204
|
+
super(...arguments), this._$AN = void 0;
|
|
2205
|
+
}
|
|
2206
|
+
_$AT(e, t, n) {
|
|
2207
|
+
super._$AT(e, t, n), Dt(this), this.isConnected = e._$AU;
|
|
2208
|
+
}
|
|
2209
|
+
_$AO(e, t = !0) {
|
|
2210
|
+
e !== this.isConnected && (this.isConnected = e, e ? this.reconnected?.() : this.disconnected?.()), t && (H(this, e), U(this));
|
|
2211
|
+
}
|
|
2212
|
+
setValue(e) {
|
|
2213
|
+
if (Ct(this._$Ct)) this._$Ct._$AI(e, this);
|
|
2214
|
+
else {
|
|
2215
|
+
let t = [...this._$Ct._$AH];
|
|
2216
|
+
t[this._$Ci] = e, this._$Ct._$AI(t, this, 0);
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
disconnected() {}
|
|
2220
|
+
reconnected() {}
|
|
2221
|
+
}, Mt = () => new Nt(), Nt = class {}, Pt = /* @__PURE__ */ new WeakMap(), Ft = Tt(class extends jt {
|
|
2222
|
+
render(e) {
|
|
2223
|
+
return R;
|
|
2224
|
+
}
|
|
2225
|
+
update(e, [t]) {
|
|
2226
|
+
let n = t !== this.G;
|
|
2227
|
+
return n && this.rt(void 0), (n || this.lt !== this.ct) && (this.G = t, this.ht = e.options?.host, this.rt(this.ct = e.element)), R;
|
|
2228
|
+
}
|
|
2229
|
+
rt(e) {
|
|
2230
|
+
if (this.G !== void 0) if (this.isConnected || (e = void 0), typeof this.G == "function") {
|
|
2231
|
+
let t = this.ht ?? globalThis, n = Pt.get(t);
|
|
2232
|
+
n === void 0 && (n = /* @__PURE__ */ new WeakMap(), Pt.set(t, n)), n.get(this.G) !== void 0 && this.G.call(this.ht, void 0), n.set(this.G, e), e !== void 0 && this.G.call(this.ht, e);
|
|
2233
|
+
} else this.G.value = e;
|
|
2234
|
+
}
|
|
2235
|
+
get lt() {
|
|
2236
|
+
return typeof this.G == "function" ? Pt.get(this.ht ?? globalThis)?.get(this.G) : this.G?.value;
|
|
2237
|
+
}
|
|
2238
|
+
disconnected() {
|
|
2239
|
+
this.lt === this.ct && this.rt(void 0);
|
|
2240
|
+
}
|
|
2241
|
+
reconnected() {
|
|
2242
|
+
this.rt(this.ct);
|
|
2243
|
+
}
|
|
2244
|
+
}), W = class extends e {
|
|
2245
|
+
constructor(...e) {
|
|
2246
|
+
super(...e), this.value = "", this.name = "", this.label = "", this.disabled = !1, this.colorInputRef = Mt();
|
|
2247
|
+
}
|
|
2248
|
+
static {
|
|
2249
|
+
this.styles = t`
|
|
2250
|
+
:host {
|
|
2251
|
+
display: block;
|
|
2252
|
+
font-family: var(--lc-font-family);
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
.label {
|
|
2256
|
+
display: block;
|
|
2257
|
+
font-size: var(--lc-font-size-sm);
|
|
2258
|
+
color: var(--lc-color-text);
|
|
2259
|
+
margin-bottom: var(--lc-spacing-2);
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
.container {
|
|
2263
|
+
display: flex;
|
|
2264
|
+
align-items: center;
|
|
2265
|
+
gap: var(--lc-spacing-3);
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
.preview {
|
|
2269
|
+
width: 40px;
|
|
2270
|
+
height: 40px;
|
|
2271
|
+
border-radius: var(--lc-radius-sm);
|
|
2272
|
+
border: 1px solid var(--lc-color-border);
|
|
2273
|
+
cursor: pointer;
|
|
2274
|
+
flex-shrink: 0;
|
|
2275
|
+
transition: border-color var(--lc-transition-fast);
|
|
2276
|
+
}
|
|
2277
|
+
|
|
2278
|
+
.preview:hover {
|
|
2279
|
+
border-color: var(--lc-color-primary);
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
.preview.disabled {
|
|
2283
|
+
opacity: 0.5;
|
|
2284
|
+
cursor: not-allowed;
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2287
|
+
.hex-input {
|
|
2288
|
+
padding: var(--lc-spacing-1) var(--lc-spacing-2);
|
|
2289
|
+
border: 1px solid var(--lc-color-border);
|
|
2290
|
+
border-radius: var(--lc-radius-sm);
|
|
2291
|
+
font-size: var(--lc-font-size-sm);
|
|
2292
|
+
font-family: var(--lc-font-family);
|
|
2293
|
+
width: 100px;
|
|
2294
|
+
color: var(--lc-color-text);
|
|
2295
|
+
outline: none;
|
|
2296
|
+
transition: border-color var(--lc-transition-fast);
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
.hex-input:focus {
|
|
2300
|
+
border-color: var(--lc-color-primary);
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
.hex-input:disabled {
|
|
2304
|
+
opacity: 0.5;
|
|
2305
|
+
cursor: not-allowed;
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2308
|
+
.hidden {
|
|
2309
|
+
position: absolute;
|
|
2310
|
+
opacity: 0;
|
|
2311
|
+
width: 0;
|
|
2312
|
+
height: 0;
|
|
2313
|
+
pointer-events: none;
|
|
2314
|
+
}
|
|
2315
|
+
`;
|
|
2316
|
+
}
|
|
2317
|
+
emitChange(e) {
|
|
2318
|
+
this.dispatchEvent(new CustomEvent(b.CHANGE, {
|
|
2319
|
+
detail: { value: e },
|
|
2320
|
+
bubbles: !0,
|
|
2321
|
+
composed: !0
|
|
2322
|
+
}));
|
|
2323
|
+
}
|
|
2324
|
+
handleHexInput(e) {
|
|
2325
|
+
let t = e.target.value.trim();
|
|
2326
|
+
t && !t.startsWith("#") && (t = "#" + t), this.value = t, this.emitChange(this.value);
|
|
2327
|
+
}
|
|
2328
|
+
handleColorInput(e) {
|
|
2329
|
+
let t = e.target;
|
|
2330
|
+
this.value = t.value, this.emitChange(this.value);
|
|
2331
|
+
}
|
|
2332
|
+
openPicker() {
|
|
2333
|
+
!this.disabled && this.colorInputRef.value && this.colorInputRef.value.click();
|
|
2334
|
+
}
|
|
2335
|
+
render() {
|
|
2336
|
+
let e = this.value || "#000000";
|
|
2337
|
+
return n`
|
|
2338
|
+
${this.label ? n`<label class="label">${this.label}</label>` : r}
|
|
2339
|
+
<div class="container">
|
|
2340
|
+
<input
|
|
2341
|
+
class="hidden"
|
|
2342
|
+
type="color"
|
|
2343
|
+
.value=${e}
|
|
2344
|
+
?disabled=${this.disabled}
|
|
2345
|
+
@input=${this.handleColorInput}
|
|
2346
|
+
${Ft(this.colorInputRef)}
|
|
2347
|
+
/>
|
|
2348
|
+
<div
|
|
2349
|
+
class="preview ${this.disabled ? "disabled" : ""}"
|
|
2350
|
+
style="background-color: ${e};"
|
|
2351
|
+
@click=${this.openPicker}
|
|
2352
|
+
></div>
|
|
2353
|
+
<input
|
|
2354
|
+
class="hex-input"
|
|
2355
|
+
type="text"
|
|
2356
|
+
.value=${this.value}
|
|
2357
|
+
?disabled=${this.disabled}
|
|
2358
|
+
placeholder="#000000"
|
|
2359
|
+
@input=${this.handleHexInput}
|
|
2360
|
+
/>
|
|
2361
|
+
</div>
|
|
2362
|
+
`;
|
|
2363
|
+
}
|
|
2364
|
+
};
|
|
2365
|
+
T([h({ type: String })], W.prototype, "value", void 0), T([h({ type: String })], W.prototype, "name", void 0), T([h({ type: String })], W.prototype, "label", void 0), T([h({ type: Boolean })], W.prototype, "disabled", void 0), W = T([i("lc-color-picker")], W);
|
|
2366
|
+
//#endregion
|
|
2367
|
+
//#region src/components/strength-slider/strength-slider.ts
|
|
2368
|
+
var G = class extends e {
|
|
2369
|
+
constructor(...e) {
|
|
2370
|
+
super(...e), this.value = .5, this.min = 0, this.max = 1, this.step = .1, this.name = "", this.label = "", this.disabled = !1;
|
|
2371
|
+
}
|
|
2372
|
+
static {
|
|
2373
|
+
this.styles = t`
|
|
2374
|
+
:host {
|
|
2375
|
+
display: block;
|
|
2376
|
+
font-family: var(--lc-font-family);
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
.label {
|
|
2380
|
+
display: block;
|
|
2381
|
+
font-size: var(--lc-font-size-sm);
|
|
2382
|
+
color: var(--lc-color-text);
|
|
2383
|
+
margin-bottom: var(--lc-spacing-2);
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
.container {
|
|
2387
|
+
display: flex;
|
|
2388
|
+
align-items: center;
|
|
2389
|
+
gap: var(--lc-spacing-3);
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
input[type='range'] {
|
|
2393
|
+
flex: 1;
|
|
2394
|
+
accent-color: var(--lc-color-primary);
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
input[type='range']:disabled {
|
|
2398
|
+
opacity: 0.5;
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
.value-display {
|
|
2402
|
+
min-width: 32px;
|
|
2403
|
+
text-align: center;
|
|
2404
|
+
font-size: var(--lc-font-size-sm);
|
|
2405
|
+
color: var(--lc-color-text);
|
|
2406
|
+
}
|
|
2407
|
+
`;
|
|
2408
|
+
}
|
|
2409
|
+
emitChange(e) {
|
|
2410
|
+
this.dispatchEvent(new CustomEvent(b.CHANGE, {
|
|
2411
|
+
detail: { value: e },
|
|
2412
|
+
bubbles: !0,
|
|
2413
|
+
composed: !0
|
|
2414
|
+
}));
|
|
2415
|
+
}
|
|
2416
|
+
handleInput(e) {
|
|
2417
|
+
let t = e.target;
|
|
2418
|
+
this.value = parseFloat(t.value), this.emitChange(this.value);
|
|
2419
|
+
}
|
|
2420
|
+
render() {
|
|
2421
|
+
return n`
|
|
2422
|
+
${this.label ? n`<label class="label">${this.label}</label>` : r}
|
|
2423
|
+
<div class="container">
|
|
2424
|
+
<input
|
|
2425
|
+
type="range"
|
|
2426
|
+
.min=${String(this.min)}
|
|
2427
|
+
.max=${String(this.max)}
|
|
2428
|
+
.step=${String(this.step)}
|
|
2429
|
+
.value=${String(this.value)}
|
|
2430
|
+
?disabled=${this.disabled}
|
|
2431
|
+
@input=${this.handleInput}
|
|
2432
|
+
/>
|
|
2433
|
+
<span class="value-display">${this.value}</span>
|
|
2434
|
+
</div>
|
|
2435
|
+
`;
|
|
2436
|
+
}
|
|
2437
|
+
};
|
|
2438
|
+
T([h({ type: Number })], G.prototype, "value", void 0), T([h({ type: Number })], G.prototype, "min", void 0), T([h({ type: Number })], G.prototype, "max", void 0), T([h({ type: Number })], G.prototype, "step", void 0), T([h({ type: String })], G.prototype, "name", void 0), T([h({ type: String })], G.prototype, "label", void 0), T([h({ type: Boolean })], G.prototype, "disabled", void 0), G = T([i("lc-strength-slider")], G);
|
|
2439
|
+
//#endregion
|
|
2440
|
+
//#region src/components/task-progress-card/task-progress-card.ts
|
|
2441
|
+
var It = {
|
|
2442
|
+
pending: "等待中",
|
|
2443
|
+
running: "运行中",
|
|
2444
|
+
done: "已完成",
|
|
2445
|
+
exception: "异常"
|
|
2446
|
+
}, K = class extends e {
|
|
2447
|
+
constructor(...e) {
|
|
2448
|
+
super(...e), this.taskId = "", this.status = "pending", this.progress = 0, this.queuePos = -1, this.errorMessage = "", this.submittedAt = 0;
|
|
2449
|
+
}
|
|
2450
|
+
static {
|
|
2451
|
+
this.styles = t`
|
|
2452
|
+
:host {
|
|
2453
|
+
display: block;
|
|
2454
|
+
--lc-progress-height: 8px;
|
|
2455
|
+
--lc-progress-bg: var(--lc-color-gray-100);
|
|
2456
|
+
--lc-progress-fill: var(--lc-color-primary);
|
|
2457
|
+
--lc-progress-radius: var(--lc-radius-full);
|
|
2458
|
+
--lc-card-padding: var(--lc-spacing-4);
|
|
2459
|
+
--lc-card-bg: var(--lc-color-bg);
|
|
2460
|
+
--lc-card-border: 1px solid var(--lc-color-border);
|
|
2461
|
+
--lc-card-radius: var(--lc-radius-lg);
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
.card {
|
|
2465
|
+
padding: var(--lc-card-padding);
|
|
2466
|
+
background: var(--lc-card-bg);
|
|
2467
|
+
border: var(--lc-card-border);
|
|
2468
|
+
border-radius: var(--lc-card-radius);
|
|
2469
|
+
font-family: var(--lc-font-family);
|
|
2470
|
+
}
|
|
2471
|
+
|
|
2472
|
+
.title {
|
|
2473
|
+
font-size: var(--lc-font-size-sm);
|
|
2474
|
+
font-weight: 500;
|
|
2475
|
+
color: var(--lc-color-text);
|
|
2476
|
+
margin-bottom: var(--lc-spacing-3);
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
.progress-track {
|
|
2480
|
+
height: var(--lc-progress-height);
|
|
2481
|
+
background: var(--lc-progress-bg);
|
|
2482
|
+
border-radius: var(--lc-progress-radius);
|
|
2483
|
+
overflow: hidden;
|
|
2484
|
+
margin-bottom: var(--lc-spacing-3);
|
|
2485
|
+
}
|
|
2486
|
+
|
|
2487
|
+
.progress-fill {
|
|
2488
|
+
height: 100%;
|
|
2489
|
+
background: var(--lc-progress-fill);
|
|
2490
|
+
border-radius: var(--lc-progress-radius);
|
|
2491
|
+
transition: width var(--lc-transition-normal);
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
.progress-text {
|
|
2495
|
+
font-size: var(--lc-font-size-xs);
|
|
2496
|
+
color: var(--lc-color-text-secondary);
|
|
2497
|
+
margin-bottom: var(--lc-spacing-2);
|
|
2498
|
+
text-align: right;
|
|
2499
|
+
}
|
|
2500
|
+
|
|
2501
|
+
.meta {
|
|
2502
|
+
display: flex;
|
|
2503
|
+
align-items: center;
|
|
2504
|
+
gap: var(--lc-spacing-2);
|
|
2505
|
+
font-size: var(--lc-font-size-xs);
|
|
2506
|
+
color: var(--lc-color-text-secondary);
|
|
2507
|
+
}
|
|
2508
|
+
|
|
2509
|
+
.status-dot {
|
|
2510
|
+
display: inline-block;
|
|
2511
|
+
width: 8px;
|
|
2512
|
+
height: 8px;
|
|
2513
|
+
border-radius: 50%;
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2516
|
+
.separator {
|
|
2517
|
+
color: var(--lc-color-gray-300);
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
.error-message {
|
|
2521
|
+
margin-top: var(--lc-spacing-2);
|
|
2522
|
+
font-size: var(--lc-font-size-xs);
|
|
2523
|
+
color: var(--lc-color-error);
|
|
2524
|
+
}
|
|
2525
|
+
`;
|
|
2526
|
+
}
|
|
2527
|
+
getStatusColor() {
|
|
2528
|
+
switch (this.status) {
|
|
2529
|
+
case "pending": return "var(--lc-color-gray-300)";
|
|
2530
|
+
case "running": return "var(--lc-color-primary)";
|
|
2531
|
+
case "done": return "var(--lc-color-success)";
|
|
2532
|
+
case "exception": return "var(--lc-color-error)";
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
formatTime(e) {
|
|
2536
|
+
return e ? new Date(e).toLocaleString("zh-CN") : "";
|
|
2537
|
+
}
|
|
2538
|
+
render() {
|
|
2539
|
+
let e = Math.max(0, Math.min(1, this.progress)), t = `width: ${e * 100}%`, r = `background: ${this.getStatusColor()}`;
|
|
2540
|
+
return n`
|
|
2541
|
+
<div class="card" part="card">
|
|
2542
|
+
<div class="title">任务 #${this.taskId}</div>
|
|
2543
|
+
<div class="progress-text">${Math.round(e * 100)}%</div>
|
|
2544
|
+
<div class="progress-track" part="progress-bar">
|
|
2545
|
+
<div class="progress-fill" style=${t} part="progress-fill"></div>
|
|
2546
|
+
</div>
|
|
2547
|
+
<div class="meta">
|
|
2548
|
+
<span class="status-dot" style=${r}></span>
|
|
2549
|
+
<span part="status">${It[this.status]}</span>
|
|
2550
|
+
${this.queuePos >= 0 ? n`<span class="separator">·</span><span>队列位置: ${this.queuePos}</span>` : null}
|
|
2551
|
+
</div>
|
|
2552
|
+
${this.submittedAt ? n`<div class="meta" style="margin-top: var(--lc-spacing-1)">
|
|
2553
|
+
提交时间: ${this.formatTime(this.submittedAt)}
|
|
2554
|
+
</div>` : null}
|
|
2555
|
+
${this.status === "exception" && this.errorMessage ? n`<div class="error-message">${this.errorMessage}</div>` : null}
|
|
2556
|
+
</div>
|
|
2557
|
+
`;
|
|
2558
|
+
}
|
|
2559
|
+
};
|
|
2560
|
+
T([h({ type: String })], K.prototype, "taskId", void 0), T([h({ type: String })], K.prototype, "status", void 0), T([h({ type: Number })], K.prototype, "progress", void 0), T([h({ type: Number })], K.prototype, "queuePos", void 0), T([h({ type: String })], K.prototype, "errorMessage", void 0), T([h({ type: Number })], K.prototype, "submittedAt", void 0), K = T([i("lc-task-progress-card")], K);
|
|
2561
|
+
//#endregion
|
|
2562
|
+
//#region src/components/result-gallery/result-gallery.ts
|
|
2563
|
+
var q = class extends e {
|
|
2564
|
+
constructor(...e) {
|
|
2565
|
+
super(...e), this.images = "[]", this.originalUrl = "", this.showDownload = !0;
|
|
2566
|
+
}
|
|
2567
|
+
static {
|
|
2568
|
+
this.styles = t`
|
|
2569
|
+
:host {
|
|
2570
|
+
display: block;
|
|
2571
|
+
--lc-gallery-gap: var(--lc-spacing-3);
|
|
2572
|
+
--lc-gallery-item-radius: var(--lc-radius-md);
|
|
2573
|
+
--lc-gallery-overlay-bg: rgba(0, 0, 0, 0.6);
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
.gallery {
|
|
2577
|
+
display: grid;
|
|
2578
|
+
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
|
2579
|
+
gap: var(--lc-gallery-gap);
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
.image-item {
|
|
2583
|
+
position: relative;
|
|
2584
|
+
border-radius: var(--lc-gallery-item-radius);
|
|
2585
|
+
overflow: hidden;
|
|
2586
|
+
cursor: pointer;
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2589
|
+
.image-item img {
|
|
2590
|
+
display: block;
|
|
2591
|
+
width: 100%;
|
|
2592
|
+
height: auto;
|
|
2593
|
+
border-radius: var(--lc-gallery-item-radius);
|
|
2594
|
+
}
|
|
2595
|
+
|
|
2596
|
+
.overlay {
|
|
2597
|
+
position: absolute;
|
|
2598
|
+
inset: 0;
|
|
2599
|
+
display: flex;
|
|
2600
|
+
align-items: center;
|
|
2601
|
+
justify-content: center;
|
|
2602
|
+
gap: var(--lc-spacing-2);
|
|
2603
|
+
background: var(--lc-gallery-overlay-bg);
|
|
2604
|
+
opacity: 0;
|
|
2605
|
+
transition: opacity var(--lc-transition-fast);
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2608
|
+
.image-item:hover .overlay {
|
|
2609
|
+
opacity: 1;
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
.action-btn {
|
|
2613
|
+
display: flex;
|
|
2614
|
+
align-items: center;
|
|
2615
|
+
justify-content: center;
|
|
2616
|
+
width: 36px;
|
|
2617
|
+
height: 36px;
|
|
2618
|
+
border-radius: var(--lc-radius-sm);
|
|
2619
|
+
background: rgba(255, 255, 255, 0.9);
|
|
2620
|
+
color: var(--lc-color-gray-900);
|
|
2621
|
+
font-size: var(--lc-font-size-base);
|
|
2622
|
+
text-decoration: none;
|
|
2623
|
+
border: none;
|
|
2624
|
+
cursor: pointer;
|
|
2625
|
+
}
|
|
2626
|
+
|
|
2627
|
+
.action-btn:hover {
|
|
2628
|
+
background: white;
|
|
2629
|
+
}
|
|
2630
|
+
`;
|
|
2631
|
+
}
|
|
2632
|
+
getParsedImages() {
|
|
2633
|
+
try {
|
|
2634
|
+
let e = JSON.parse(this.images);
|
|
2635
|
+
return Array.isArray(e) ? e : [];
|
|
2636
|
+
} catch {
|
|
2637
|
+
return [];
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
_onImageClick(e) {
|
|
2641
|
+
this.dispatchEvent(new CustomEvent(b.IMAGE_CLICK, {
|
|
2642
|
+
detail: {
|
|
2643
|
+
index: e.index,
|
|
2644
|
+
url: e.url
|
|
2645
|
+
},
|
|
2646
|
+
bubbles: !0,
|
|
2647
|
+
composed: !0
|
|
2648
|
+
}));
|
|
2649
|
+
}
|
|
2650
|
+
_onCompare(e) {
|
|
2651
|
+
this.dispatchEvent(new CustomEvent(b.COMPARE, {
|
|
2652
|
+
detail: {
|
|
2653
|
+
originalUrl: this.originalUrl,
|
|
2654
|
+
resultUrl: e
|
|
2655
|
+
},
|
|
2656
|
+
bubbles: !0,
|
|
2657
|
+
composed: !0
|
|
2658
|
+
}));
|
|
2659
|
+
}
|
|
2660
|
+
renderImageItem(e) {
|
|
2661
|
+
return n`
|
|
2662
|
+
<div class="image-item" @click=${() => this._onImageClick(e)}>
|
|
2663
|
+
<img src="${e.url}" alt="结果 ${e.index + 1}">
|
|
2664
|
+
<div class="overlay">
|
|
2665
|
+
${this.showDownload ? n`<a class="action-btn" href="${e.url}" download title="下载">⬇</a>` : r}
|
|
2666
|
+
${this.originalUrl ? n`<button class="action-btn" @click=${(t) => {
|
|
2667
|
+
t.stopPropagation(), this._onCompare(e.url);
|
|
2668
|
+
}} title="对比">≡</button>` : r}
|
|
2669
|
+
</div>
|
|
2670
|
+
</div>
|
|
2671
|
+
`;
|
|
2672
|
+
}
|
|
2673
|
+
render() {
|
|
2674
|
+
return n`
|
|
2675
|
+
<div class="gallery">
|
|
2676
|
+
${this.getParsedImages().map((e) => this.renderImageItem(e))}
|
|
2677
|
+
</div>
|
|
2678
|
+
`;
|
|
2679
|
+
}
|
|
2680
|
+
};
|
|
2681
|
+
T([h({ type: String })], q.prototype, "images", void 0), T([h({ type: String })], q.prototype, "originalUrl", void 0), T([h({ type: Boolean })], q.prototype, "showDownload", void 0), q = T([i("lc-result-gallery")], q);
|
|
2682
|
+
//#endregion
|
|
2683
|
+
//#region src/components/image-compare-slider/image-compare-slider.ts
|
|
2684
|
+
var J = class extends e {
|
|
2685
|
+
constructor(...e) {
|
|
2686
|
+
super(...e), this.beforeSrc = "", this.afterSrc = "", this.beforeLabel = "原图", this.afterLabel = "结果", this._position = 50;
|
|
2687
|
+
}
|
|
2688
|
+
static {
|
|
2689
|
+
this.styles = t`
|
|
2690
|
+
:host {
|
|
2691
|
+
display: block;
|
|
2692
|
+
--lc-compare-width: 100%;
|
|
2693
|
+
--lc-compare-max-height: 500px;
|
|
2694
|
+
--lc-slider-width: 2px;
|
|
2695
|
+
--lc-slider-color: white;
|
|
2696
|
+
--lc-handle-size: 40px;
|
|
2697
|
+
--lc-handle-color: white;
|
|
2698
|
+
--lc-handle-shadow: var(--lc-shadow-md);
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2701
|
+
.compare-container {
|
|
2702
|
+
position: relative;
|
|
2703
|
+
width: var(--lc-compare-width);
|
|
2704
|
+
max-height: var(--lc-compare-max-height);
|
|
2705
|
+
overflow: hidden;
|
|
2706
|
+
user-select: none;
|
|
2707
|
+
}
|
|
2708
|
+
|
|
2709
|
+
.compare-container img {
|
|
2710
|
+
display: block;
|
|
2711
|
+
width: 100%;
|
|
2712
|
+
height: auto;
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
.after-wrapper {
|
|
2716
|
+
position: relative;
|
|
2717
|
+
}
|
|
2718
|
+
|
|
2719
|
+
.before-image {
|
|
2720
|
+
position: absolute;
|
|
2721
|
+
top: 0;
|
|
2722
|
+
left: 0;
|
|
2723
|
+
width: 100%;
|
|
2724
|
+
height: 100%;
|
|
2725
|
+
object-fit: cover;
|
|
2726
|
+
}
|
|
2727
|
+
|
|
2728
|
+
.slider-handle {
|
|
2729
|
+
position: absolute;
|
|
2730
|
+
top: 0;
|
|
2731
|
+
bottom: 0;
|
|
2732
|
+
width: var(--lc-slider-width);
|
|
2733
|
+
background: var(--lc-slider-color);
|
|
2734
|
+
cursor: ew-resize;
|
|
2735
|
+
z-index: 2;
|
|
2736
|
+
transform: translateX(-50%);
|
|
2737
|
+
}
|
|
2738
|
+
|
|
2739
|
+
.slider-handle::after {
|
|
2740
|
+
content: '\\27F7';
|
|
2741
|
+
position: absolute;
|
|
2742
|
+
top: 50%;
|
|
2743
|
+
left: 50%;
|
|
2744
|
+
transform: translate(-50%, -50%);
|
|
2745
|
+
width: var(--lc-handle-size);
|
|
2746
|
+
height: var(--lc-handle-size);
|
|
2747
|
+
border-radius: 50%;
|
|
2748
|
+
background: var(--lc-handle-color);
|
|
2749
|
+
box-shadow: var(--lc-handle-shadow);
|
|
2750
|
+
display: flex;
|
|
2751
|
+
align-items: center;
|
|
2752
|
+
justify-content: center;
|
|
2753
|
+
font-size: 14px;
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
.label {
|
|
2757
|
+
position: absolute;
|
|
2758
|
+
bottom: 8px;
|
|
2759
|
+
padding: 2px 8px;
|
|
2760
|
+
border-radius: var(--lc-radius-sm);
|
|
2761
|
+
background: rgba(0, 0, 0, 0.5);
|
|
2762
|
+
color: white;
|
|
2763
|
+
font-size: var(--lc-font-size-xs);
|
|
2764
|
+
z-index: 3;
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
.label-before { left: 8px; }
|
|
2768
|
+
.label-after { right: 8px; }
|
|
2769
|
+
`;
|
|
2770
|
+
}
|
|
2771
|
+
_onPointerDown(e) {
|
|
2772
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
2773
|
+
}
|
|
2774
|
+
_onPointerMove(e) {
|
|
2775
|
+
let t = this.shadowRoot?.querySelector(".compare-container");
|
|
2776
|
+
if (!t) return;
|
|
2777
|
+
let n = t.getBoundingClientRect(), r = e.clientX - n.left;
|
|
2778
|
+
this._position = Math.max(0, Math.min(100, r / n.width * 100));
|
|
2779
|
+
}
|
|
2780
|
+
render() {
|
|
2781
|
+
let e = `clip-path: inset(0 0 0 ${this._position}%)`, t = `left: ${this._position}%`;
|
|
2782
|
+
return n`
|
|
2783
|
+
<div class="compare-container" part="container">
|
|
2784
|
+
<div class="after-wrapper">
|
|
2785
|
+
<img src="${this.afterSrc}" alt="${this.afterLabel}">
|
|
2786
|
+
</div>
|
|
2787
|
+
<img class="before-image" src="${this.beforeSrc}" alt="${this.beforeLabel}" style=${e}>
|
|
2788
|
+
<div
|
|
2789
|
+
class="slider-handle"
|
|
2790
|
+
part="slider"
|
|
2791
|
+
style=${t}
|
|
2792
|
+
@pointerdown=${this._onPointerDown}
|
|
2793
|
+
@pointermove=${this._onPointerMove}
|
|
2794
|
+
></div>
|
|
2795
|
+
<span class="label label-before">${this.beforeLabel}</span>
|
|
2796
|
+
<span class="label label-after">${this.afterLabel}</span>
|
|
2797
|
+
</div>
|
|
2798
|
+
`;
|
|
2799
|
+
}
|
|
2800
|
+
};
|
|
2801
|
+
T([h({ type: String })], J.prototype, "beforeSrc", void 0), T([h({ type: String })], J.prototype, "afterSrc", void 0), T([h({ type: String })], J.prototype, "beforeLabel", void 0), T([h({ type: String })], J.prototype, "afterLabel", void 0), T([g()], J.prototype, "_position", void 0), J = T([i("lc-image-compare-slider")], J);
|
|
2802
|
+
//#endregion
|
|
2803
|
+
//#region src/core/task-types/types-part-a.ts
|
|
2804
|
+
var Lt = {
|
|
2805
|
+
GeneratePrinting: {
|
|
2806
|
+
key: "GeneratePrinting",
|
|
2807
|
+
title: "图案设计",
|
|
2808
|
+
description: "上传1-2张灵感素材图进行融合发散设计",
|
|
2809
|
+
fields: [
|
|
2810
|
+
{
|
|
2811
|
+
name: "imgUrlList",
|
|
2812
|
+
label: "灵感素材图",
|
|
2813
|
+
type: "images",
|
|
2814
|
+
required: !0,
|
|
2815
|
+
hint: "上传1-2张灵感素材图"
|
|
2816
|
+
},
|
|
2817
|
+
{
|
|
2818
|
+
name: "prompt",
|
|
2819
|
+
label: "图案风格",
|
|
2820
|
+
type: "text",
|
|
2821
|
+
required: !0,
|
|
2822
|
+
placeholder: "描述想要的图案风格"
|
|
2823
|
+
},
|
|
2824
|
+
{
|
|
2825
|
+
name: "aspectRatio",
|
|
2826
|
+
label: "比例",
|
|
2827
|
+
type: "aspectRatio"
|
|
2828
|
+
}
|
|
2829
|
+
]
|
|
2830
|
+
},
|
|
2831
|
+
VirtualFitting: {
|
|
2832
|
+
key: "VirtualFitting",
|
|
2833
|
+
title: "AI试衣",
|
|
2834
|
+
description: "上传服装图片生成模特上身效果图",
|
|
2835
|
+
fields: [
|
|
2836
|
+
{
|
|
2837
|
+
name: "imgUrl",
|
|
2838
|
+
label: "上装图片",
|
|
2839
|
+
type: "image",
|
|
2840
|
+
required: !0,
|
|
2841
|
+
hint: "挂拍图/人台图/平铺图"
|
|
2842
|
+
},
|
|
2843
|
+
{
|
|
2844
|
+
name: "lowerImgUrl",
|
|
2845
|
+
label: "下装图片",
|
|
2846
|
+
type: "image"
|
|
2847
|
+
},
|
|
2848
|
+
{
|
|
2849
|
+
name: "prompt",
|
|
2850
|
+
label: "试衣需求",
|
|
2851
|
+
type: "text",
|
|
2852
|
+
placeholder: "描述试衣需求"
|
|
2853
|
+
},
|
|
2854
|
+
{
|
|
2855
|
+
name: "aspectRatio",
|
|
2856
|
+
label: "比例",
|
|
2857
|
+
type: "aspectRatio"
|
|
2858
|
+
}
|
|
2859
|
+
]
|
|
2860
|
+
},
|
|
2861
|
+
FixFace: {
|
|
2862
|
+
key: "FixFace",
|
|
2863
|
+
title: "面部优化",
|
|
2864
|
+
description: "智能修复模特脸部畸形",
|
|
2865
|
+
fields: [{
|
|
2866
|
+
name: "imgUrl",
|
|
2867
|
+
label: "模特图",
|
|
2868
|
+
type: "image",
|
|
2869
|
+
required: !0
|
|
2870
|
+
}]
|
|
2871
|
+
},
|
|
2872
|
+
ChangeFace: {
|
|
2873
|
+
key: "ChangeFace",
|
|
2874
|
+
title: "面部替换",
|
|
2875
|
+
description: "上传指定面部图片替换模特面容",
|
|
2876
|
+
fields: [{
|
|
2877
|
+
name: "imgUrl",
|
|
2878
|
+
label: "模特图",
|
|
2879
|
+
type: "image",
|
|
2880
|
+
required: !0
|
|
2881
|
+
}, {
|
|
2882
|
+
name: "refImgUrl",
|
|
2883
|
+
label: "参考面部图",
|
|
2884
|
+
type: "image",
|
|
2885
|
+
required: !0
|
|
2886
|
+
}]
|
|
2887
|
+
},
|
|
2888
|
+
MultiPerspective: {
|
|
2889
|
+
key: "MultiPerspective",
|
|
2890
|
+
title: "多视角",
|
|
2891
|
+
description: "生成不同角度的展示效果图",
|
|
2892
|
+
fields: [{
|
|
2893
|
+
name: "imgUrl",
|
|
2894
|
+
label: "图片",
|
|
2895
|
+
type: "image",
|
|
2896
|
+
required: !0
|
|
2897
|
+
}, {
|
|
2898
|
+
name: "perspective",
|
|
2899
|
+
label: "视角",
|
|
2900
|
+
type: "enum",
|
|
2901
|
+
required: !0,
|
|
2902
|
+
options: S
|
|
2903
|
+
}]
|
|
2904
|
+
},
|
|
2905
|
+
PrintingTiling: {
|
|
2906
|
+
key: "PrintingTiling",
|
|
2907
|
+
title: "图案印染上身",
|
|
2908
|
+
description: "将指定图案虚拟印染到款式图上",
|
|
2909
|
+
fields: [
|
|
2910
|
+
{
|
|
2911
|
+
name: "imgUrl",
|
|
2912
|
+
label: "款式图",
|
|
2913
|
+
type: "image",
|
|
2914
|
+
required: !0
|
|
2915
|
+
},
|
|
2916
|
+
{
|
|
2917
|
+
name: "maskUrl",
|
|
2918
|
+
label: "蒙版",
|
|
2919
|
+
type: "mask"
|
|
2920
|
+
},
|
|
2921
|
+
{
|
|
2922
|
+
name: "printingImgUrl",
|
|
2923
|
+
label: "印花图案",
|
|
2924
|
+
type: "image",
|
|
2925
|
+
required: !0
|
|
2926
|
+
},
|
|
2927
|
+
{
|
|
2928
|
+
name: "prompt",
|
|
2929
|
+
label: "印染需求",
|
|
2930
|
+
type: "text",
|
|
2931
|
+
placeholder: "描述印染需求"
|
|
2932
|
+
}
|
|
2933
|
+
]
|
|
2934
|
+
},
|
|
2935
|
+
ChangeDesignPoint: {
|
|
2936
|
+
key: "ChangeDesignPoint",
|
|
2937
|
+
title: "设计点修改",
|
|
2938
|
+
description: "通过参考图实现设计点修改或融合",
|
|
2939
|
+
fields: [
|
|
2940
|
+
{
|
|
2941
|
+
name: "imgUrl",
|
|
2942
|
+
label: "原图",
|
|
2943
|
+
type: "image",
|
|
2944
|
+
required: !0
|
|
2945
|
+
},
|
|
2946
|
+
{
|
|
2947
|
+
name: "maskUrl",
|
|
2948
|
+
label: "蒙版",
|
|
2949
|
+
type: "mask"
|
|
2950
|
+
},
|
|
2951
|
+
{
|
|
2952
|
+
name: "refImgUrl",
|
|
2953
|
+
label: "参考图",
|
|
2954
|
+
type: "image"
|
|
2955
|
+
},
|
|
2956
|
+
{
|
|
2957
|
+
name: "prompt",
|
|
2958
|
+
label: "修改需求",
|
|
2959
|
+
type: "text",
|
|
2960
|
+
placeholder: "描述修改需求"
|
|
2961
|
+
}
|
|
2962
|
+
]
|
|
2963
|
+
},
|
|
2964
|
+
ChangeColor: {
|
|
2965
|
+
key: "ChangeColor",
|
|
2966
|
+
title: "服装改色",
|
|
2967
|
+
description: "自定义区域一键换色",
|
|
2968
|
+
fields: [
|
|
2969
|
+
{
|
|
2970
|
+
name: "imgUrl",
|
|
2971
|
+
label: "原图",
|
|
2972
|
+
type: "image",
|
|
2973
|
+
required: !0
|
|
2974
|
+
},
|
|
2975
|
+
{
|
|
2976
|
+
name: "maskUrl",
|
|
2977
|
+
label: "改色区域蒙版",
|
|
2978
|
+
type: "mask",
|
|
2979
|
+
required: !0
|
|
2980
|
+
},
|
|
2981
|
+
{
|
|
2982
|
+
name: "hexCode",
|
|
2983
|
+
label: "目标颜色",
|
|
2984
|
+
type: "color",
|
|
2985
|
+
required: !0
|
|
2986
|
+
}
|
|
2987
|
+
]
|
|
2988
|
+
},
|
|
2989
|
+
ChangeFabric: {
|
|
2990
|
+
key: "ChangeFabric",
|
|
2991
|
+
title: "面料上身",
|
|
2992
|
+
description: "将指定面料一键上身到款式图",
|
|
2993
|
+
fields: [
|
|
2994
|
+
{
|
|
2995
|
+
name: "imgUrl",
|
|
2996
|
+
label: "款式图/模特图",
|
|
2997
|
+
type: "image",
|
|
2998
|
+
required: !0
|
|
2999
|
+
},
|
|
3000
|
+
{
|
|
3001
|
+
name: "maskUrl",
|
|
3002
|
+
label: "蒙版",
|
|
3003
|
+
type: "mask",
|
|
3004
|
+
required: !0
|
|
3005
|
+
},
|
|
3006
|
+
{
|
|
3007
|
+
name: "fabricImgUrl",
|
|
3008
|
+
label: "面料图",
|
|
3009
|
+
type: "image",
|
|
3010
|
+
required: !0
|
|
3011
|
+
}
|
|
3012
|
+
]
|
|
3013
|
+
},
|
|
3014
|
+
Sr: {
|
|
3015
|
+
key: "Sr",
|
|
3016
|
+
title: "高清放大",
|
|
3017
|
+
description: "无损高清放大与细节强化",
|
|
3018
|
+
fields: [{
|
|
3019
|
+
name: "imgUrl",
|
|
3020
|
+
label: "图片",
|
|
3021
|
+
type: "image",
|
|
3022
|
+
required: !0
|
|
3023
|
+
}, {
|
|
3024
|
+
name: "scale",
|
|
3025
|
+
label: "放大倍数",
|
|
3026
|
+
type: "enum",
|
|
3027
|
+
required: !0,
|
|
3028
|
+
options: Ne
|
|
3029
|
+
}]
|
|
3030
|
+
},
|
|
3031
|
+
VectorConvert: {
|
|
3032
|
+
key: "VectorConvert",
|
|
3033
|
+
title: "矢量图转换",
|
|
3034
|
+
description: "生成可编辑的矢量格式文件",
|
|
3035
|
+
fields: [{
|
|
3036
|
+
name: "imgUrl",
|
|
3037
|
+
label: "图片",
|
|
3038
|
+
type: "image",
|
|
3039
|
+
required: !0
|
|
3040
|
+
}, {
|
|
3041
|
+
name: "patternType",
|
|
3042
|
+
label: "图案类型",
|
|
3043
|
+
type: "enum",
|
|
3044
|
+
required: !0,
|
|
3045
|
+
options: Pe
|
|
3046
|
+
}]
|
|
3047
|
+
},
|
|
3048
|
+
ChangeModel: {
|
|
3049
|
+
key: "ChangeModel",
|
|
3050
|
+
title: "模特更换",
|
|
3051
|
+
description: "一键更换模特并支持自定义选择",
|
|
3052
|
+
fields: [
|
|
3053
|
+
{
|
|
3054
|
+
name: "imgUrl",
|
|
3055
|
+
label: "模特图",
|
|
3056
|
+
type: "image",
|
|
3057
|
+
required: !0
|
|
3058
|
+
},
|
|
3059
|
+
{
|
|
3060
|
+
name: "gender",
|
|
3061
|
+
label: "性别",
|
|
3062
|
+
type: "enum",
|
|
3063
|
+
options: C
|
|
3064
|
+
},
|
|
3065
|
+
{
|
|
3066
|
+
name: "age",
|
|
3067
|
+
label: "年龄",
|
|
3068
|
+
type: "enum",
|
|
3069
|
+
options: Fe
|
|
3070
|
+
},
|
|
3071
|
+
{
|
|
3072
|
+
name: "race",
|
|
3073
|
+
label: "人种",
|
|
3074
|
+
type: "enum",
|
|
3075
|
+
options: Ie
|
|
3076
|
+
}
|
|
3077
|
+
]
|
|
3078
|
+
},
|
|
3079
|
+
GenerateSketch: {
|
|
3080
|
+
key: "GenerateSketch",
|
|
3081
|
+
title: "平铺图转线稿",
|
|
3082
|
+
description: "上传平铺图生成线稿",
|
|
3083
|
+
fields: [{
|
|
3084
|
+
name: "imgUrl",
|
|
3085
|
+
label: "平铺图",
|
|
3086
|
+
type: "image",
|
|
3087
|
+
required: !0
|
|
3088
|
+
}]
|
|
3089
|
+
},
|
|
3090
|
+
ModelGenerateSketch: {
|
|
3091
|
+
key: "ModelGenerateSketch",
|
|
3092
|
+
title: "模特图转线稿",
|
|
3093
|
+
description: "上传模特图生成线稿",
|
|
3094
|
+
fields: [{
|
|
3095
|
+
name: "imgUrl",
|
|
3096
|
+
label: "模特图",
|
|
3097
|
+
type: "image",
|
|
3098
|
+
required: !0
|
|
3099
|
+
}, {
|
|
3100
|
+
name: "position",
|
|
3101
|
+
label: "服装位置",
|
|
3102
|
+
type: "enum",
|
|
3103
|
+
options: Le
|
|
3104
|
+
}]
|
|
3105
|
+
},
|
|
3106
|
+
Eliminate: {
|
|
3107
|
+
key: "Eliminate",
|
|
3108
|
+
title: "AI消除",
|
|
3109
|
+
description: "一键消除指定元素",
|
|
3110
|
+
fields: [{
|
|
3111
|
+
name: "imgUrl",
|
|
3112
|
+
label: "原图",
|
|
3113
|
+
type: "image",
|
|
3114
|
+
required: !0
|
|
3115
|
+
}, {
|
|
3116
|
+
name: "maskUrl",
|
|
3117
|
+
label: "消除区域蒙版",
|
|
3118
|
+
type: "mask",
|
|
3119
|
+
required: !0
|
|
3120
|
+
}]
|
|
3121
|
+
},
|
|
3122
|
+
ExpandImage: {
|
|
3123
|
+
key: "ExpandImage",
|
|
3124
|
+
title: "AI扩图",
|
|
3125
|
+
description: "一键扩充人物或背景",
|
|
3126
|
+
fields: [{
|
|
3127
|
+
name: "imgUrl",
|
|
3128
|
+
label: "原图",
|
|
3129
|
+
type: "image",
|
|
3130
|
+
required: !0
|
|
3131
|
+
}, {
|
|
3132
|
+
name: "maskUrl",
|
|
3133
|
+
label: "扩图区域蒙版",
|
|
3134
|
+
type: "mask",
|
|
3135
|
+
required: !0
|
|
3136
|
+
}]
|
|
3137
|
+
},
|
|
3138
|
+
ClothingDesign: {
|
|
3139
|
+
key: "ClothingDesign",
|
|
3140
|
+
title: "AI创款",
|
|
3141
|
+
description: "根据灵感图快速创款",
|
|
3142
|
+
fields: [
|
|
3143
|
+
{
|
|
3144
|
+
name: "imgUrlList",
|
|
3145
|
+
label: "灵感款式图",
|
|
3146
|
+
type: "images",
|
|
3147
|
+
hint: "上传1-3张灵感图"
|
|
3148
|
+
},
|
|
3149
|
+
{
|
|
3150
|
+
name: "fabricImgUrl",
|
|
3151
|
+
label: "面料图",
|
|
3152
|
+
type: "image",
|
|
3153
|
+
hint: "上传面料图进行面料创款"
|
|
3154
|
+
},
|
|
3155
|
+
{
|
|
3156
|
+
name: "words",
|
|
3157
|
+
label: "创款需求",
|
|
3158
|
+
type: "text",
|
|
3159
|
+
placeholder: "描述创款需求"
|
|
3160
|
+
},
|
|
3161
|
+
{
|
|
3162
|
+
name: "aspectRatio",
|
|
3163
|
+
label: "比例",
|
|
3164
|
+
type: "aspectRatio"
|
|
3165
|
+
}
|
|
3166
|
+
]
|
|
3167
|
+
},
|
|
3168
|
+
ChangePattern: {
|
|
3169
|
+
key: "ChangePattern",
|
|
3170
|
+
title: "服装改版",
|
|
3171
|
+
description: "通过选择部位和版型修改服装版型",
|
|
3172
|
+
fields: [{
|
|
3173
|
+
name: "imgUrl",
|
|
3174
|
+
label: "服装图",
|
|
3175
|
+
type: "image",
|
|
3176
|
+
required: !0
|
|
3177
|
+
}, {
|
|
3178
|
+
name: "detailList",
|
|
3179
|
+
label: "改版部位",
|
|
3180
|
+
type: "multiEnum",
|
|
3181
|
+
required: !0,
|
|
3182
|
+
options: Re
|
|
3183
|
+
}]
|
|
3184
|
+
},
|
|
3185
|
+
GenerateModel: {
|
|
3186
|
+
key: "GenerateModel",
|
|
3187
|
+
title: "定制模特",
|
|
3188
|
+
description: "生成符合需求的虚拟模特",
|
|
3189
|
+
fields: [
|
|
3190
|
+
{
|
|
3191
|
+
name: "imgUrlList",
|
|
3192
|
+
label: "参考图片",
|
|
3193
|
+
type: "images",
|
|
3194
|
+
required: !0,
|
|
3195
|
+
hint: "上传1-10张带面容的图片"
|
|
3196
|
+
},
|
|
3197
|
+
{
|
|
3198
|
+
name: "gender",
|
|
3199
|
+
label: "性别",
|
|
3200
|
+
type: "enum",
|
|
3201
|
+
required: !0,
|
|
3202
|
+
options: C
|
|
3203
|
+
},
|
|
3204
|
+
{
|
|
3205
|
+
name: "race",
|
|
3206
|
+
label: "人种",
|
|
3207
|
+
type: "enum",
|
|
3208
|
+
options: Ie
|
|
3209
|
+
}
|
|
3210
|
+
]
|
|
3211
|
+
},
|
|
3212
|
+
ModifyPrinting: {
|
|
3213
|
+
key: "ModifyPrinting",
|
|
3214
|
+
title: "图案修改",
|
|
3215
|
+
description: "上传图案和参考图AI修改",
|
|
3216
|
+
fields: [
|
|
3217
|
+
{
|
|
3218
|
+
name: "imgUrl",
|
|
3219
|
+
label: "原图",
|
|
3220
|
+
type: "image",
|
|
3221
|
+
required: !0
|
|
3222
|
+
},
|
|
3223
|
+
{
|
|
3224
|
+
name: "refImgUrl",
|
|
3225
|
+
label: "参考图",
|
|
3226
|
+
type: "image"
|
|
3227
|
+
},
|
|
3228
|
+
{
|
|
3229
|
+
name: "maskUrl",
|
|
3230
|
+
label: "蒙版",
|
|
3231
|
+
type: "mask"
|
|
3232
|
+
},
|
|
3233
|
+
{
|
|
3234
|
+
name: "prompt",
|
|
3235
|
+
label: "修改需求",
|
|
3236
|
+
type: "text",
|
|
3237
|
+
placeholder: "描述修改需求"
|
|
3238
|
+
}
|
|
3239
|
+
]
|
|
3240
|
+
},
|
|
3241
|
+
CutOut: {
|
|
3242
|
+
key: "CutOut",
|
|
3243
|
+
title: "智能抠图",
|
|
3244
|
+
description: "一键抠图修边",
|
|
3245
|
+
fields: [{
|
|
3246
|
+
name: "imgUrl",
|
|
3247
|
+
label: "图片",
|
|
3248
|
+
type: "image",
|
|
3249
|
+
required: !0
|
|
3250
|
+
}, {
|
|
3251
|
+
name: "recognitionType",
|
|
3252
|
+
label: "识别类型",
|
|
3253
|
+
type: "enum",
|
|
3254
|
+
required: !0,
|
|
3255
|
+
options: ze
|
|
3256
|
+
}]
|
|
3257
|
+
},
|
|
3258
|
+
LineArtToReal: {
|
|
3259
|
+
key: "LineArtToReal",
|
|
3260
|
+
title: "线稿转实物",
|
|
3261
|
+
description: "线稿图生成实物效果平铺图",
|
|
3262
|
+
fields: [
|
|
3263
|
+
{
|
|
3264
|
+
name: "imgUrl",
|
|
3265
|
+
label: "线稿图",
|
|
3266
|
+
type: "image",
|
|
3267
|
+
required: !0
|
|
3268
|
+
},
|
|
3269
|
+
{
|
|
3270
|
+
name: "imageType",
|
|
3271
|
+
label: "图片类型",
|
|
3272
|
+
type: "enum",
|
|
3273
|
+
required: !0,
|
|
3274
|
+
options: Be
|
|
3275
|
+
},
|
|
3276
|
+
{
|
|
3277
|
+
name: "prompt",
|
|
3278
|
+
label: "款式特征",
|
|
3279
|
+
type: "text",
|
|
3280
|
+
placeholder: "描述款式特征"
|
|
3281
|
+
}
|
|
3282
|
+
]
|
|
3283
|
+
},
|
|
3284
|
+
FixPartial: {
|
|
3285
|
+
key: "FixPartial",
|
|
3286
|
+
title: "局部修复",
|
|
3287
|
+
description: "修复或重新创造指定区域",
|
|
3288
|
+
fields: [
|
|
3289
|
+
{
|
|
3290
|
+
name: "imgUrl",
|
|
3291
|
+
label: "原图",
|
|
3292
|
+
type: "image",
|
|
3293
|
+
required: !0
|
|
3294
|
+
},
|
|
3295
|
+
{
|
|
3296
|
+
name: "maskUrl",
|
|
3297
|
+
label: "修复区域蒙版",
|
|
3298
|
+
type: "mask",
|
|
3299
|
+
required: !0
|
|
3300
|
+
},
|
|
3301
|
+
{
|
|
3302
|
+
name: "prompt",
|
|
3303
|
+
label: "修复需求",
|
|
3304
|
+
type: "text",
|
|
3305
|
+
placeholder: "描述修复需求"
|
|
3306
|
+
}
|
|
3307
|
+
]
|
|
3308
|
+
},
|
|
3309
|
+
DetailCompensation: {
|
|
3310
|
+
key: "DetailCompensation",
|
|
3311
|
+
title: "细节补偿",
|
|
3312
|
+
description: "精准还原服装细节",
|
|
3313
|
+
fields: [
|
|
3314
|
+
{
|
|
3315
|
+
name: "imgUrl",
|
|
3316
|
+
label: "原图",
|
|
3317
|
+
type: "image",
|
|
3318
|
+
required: !0
|
|
3319
|
+
},
|
|
3320
|
+
{
|
|
3321
|
+
name: "maskUrl",
|
|
3322
|
+
label: "蒙版",
|
|
3323
|
+
type: "mask"
|
|
3324
|
+
},
|
|
3325
|
+
{
|
|
3326
|
+
name: "refImgUrl",
|
|
3327
|
+
label: "参考图",
|
|
3328
|
+
type: "image"
|
|
3329
|
+
}
|
|
3330
|
+
]
|
|
3331
|
+
},
|
|
3332
|
+
ChangeClothesByImg: {
|
|
3333
|
+
key: "ChangeClothesByImg",
|
|
3334
|
+
title: "服装穿搭调整",
|
|
3335
|
+
description: "上下装搭配调整",
|
|
3336
|
+
fields: [{
|
|
3337
|
+
name: "imgUrl",
|
|
3338
|
+
label: "原图",
|
|
3339
|
+
type: "image",
|
|
3340
|
+
required: !0
|
|
3341
|
+
}, {
|
|
3342
|
+
name: "changeImgUrl",
|
|
3343
|
+
label: "搭配服装图",
|
|
3344
|
+
type: "image",
|
|
3345
|
+
required: !0
|
|
3346
|
+
}]
|
|
3347
|
+
}
|
|
3348
|
+
}, Rt = {
|
|
3349
|
+
ChangeAccessoriesByImg: {
|
|
3350
|
+
key: "ChangeAccessoriesByImg",
|
|
3351
|
+
title: "配饰穿搭调整",
|
|
3352
|
+
description: "背包鞋子首饰等搭配调整",
|
|
3353
|
+
fields: [
|
|
3354
|
+
{
|
|
3355
|
+
name: "imgUrl",
|
|
3356
|
+
label: "原图",
|
|
3357
|
+
type: "image",
|
|
3358
|
+
required: !0
|
|
3359
|
+
},
|
|
3360
|
+
{
|
|
3361
|
+
name: "changeImgUrl",
|
|
3362
|
+
label: "搭配物品图",
|
|
3363
|
+
type: "image",
|
|
3364
|
+
required: !0
|
|
3365
|
+
},
|
|
3366
|
+
{
|
|
3367
|
+
name: "accessoryType",
|
|
3368
|
+
label: "配件类型",
|
|
3369
|
+
type: "enum",
|
|
3370
|
+
required: !0,
|
|
3371
|
+
options: Ve
|
|
3372
|
+
}
|
|
3373
|
+
]
|
|
3374
|
+
},
|
|
3375
|
+
VirtualFittingReference: {
|
|
3376
|
+
key: "VirtualFittingReference",
|
|
3377
|
+
title: "AI试衣参考图模式",
|
|
3378
|
+
description: "上传模特参考图生成试衣效果",
|
|
3379
|
+
fields: [{
|
|
3380
|
+
name: "imgUrl",
|
|
3381
|
+
label: "服装图片",
|
|
3382
|
+
type: "image",
|
|
3383
|
+
required: !0
|
|
3384
|
+
}, {
|
|
3385
|
+
name: "refImgUrl",
|
|
3386
|
+
label: "模特参考图",
|
|
3387
|
+
type: "image",
|
|
3388
|
+
required: !0
|
|
3389
|
+
}]
|
|
3390
|
+
},
|
|
3391
|
+
VirtualFittingTemplate: {
|
|
3392
|
+
key: "VirtualFittingTemplate",
|
|
3393
|
+
title: "AI试衣模板模式",
|
|
3394
|
+
description: "选择试衣场景模板",
|
|
3395
|
+
fields: [{
|
|
3396
|
+
name: "imgUrl",
|
|
3397
|
+
label: "服装图片",
|
|
3398
|
+
type: "image",
|
|
3399
|
+
required: !0
|
|
3400
|
+
}, {
|
|
3401
|
+
name: "templateId",
|
|
3402
|
+
label: "试衣模板",
|
|
3403
|
+
type: "enum",
|
|
3404
|
+
required: !0,
|
|
3405
|
+
options: He
|
|
3406
|
+
}]
|
|
3407
|
+
},
|
|
3408
|
+
FixDeformities: {
|
|
3409
|
+
key: "FixDeformities",
|
|
3410
|
+
title: "畸形修复",
|
|
3411
|
+
description: "修复手部脚部脸部畸形",
|
|
3412
|
+
fields: [{
|
|
3413
|
+
name: "imgUrl",
|
|
3414
|
+
label: "模特图",
|
|
3415
|
+
type: "image",
|
|
3416
|
+
required: !0
|
|
3417
|
+
}, {
|
|
3418
|
+
name: "maskUrl",
|
|
3419
|
+
label: "修复区域蒙版",
|
|
3420
|
+
type: "mask",
|
|
3421
|
+
required: !0
|
|
3422
|
+
}]
|
|
3423
|
+
},
|
|
3424
|
+
IntelligentCropping: {
|
|
3425
|
+
key: "IntelligentCropping",
|
|
3426
|
+
title: "AI智能裁图",
|
|
3427
|
+
description: "自定义像素或比例裁图",
|
|
3428
|
+
fields: [
|
|
3429
|
+
{
|
|
3430
|
+
name: "imgUrl",
|
|
3431
|
+
label: "图片",
|
|
3432
|
+
type: "image",
|
|
3433
|
+
required: !0
|
|
3434
|
+
},
|
|
3435
|
+
{
|
|
3436
|
+
name: "mode",
|
|
3437
|
+
label: "裁剪模式",
|
|
3438
|
+
type: "enum",
|
|
3439
|
+
required: !0,
|
|
3440
|
+
options: Ue
|
|
3441
|
+
},
|
|
3442
|
+
{
|
|
3443
|
+
name: "x",
|
|
3444
|
+
label: "X坐标",
|
|
3445
|
+
type: "number"
|
|
3446
|
+
},
|
|
3447
|
+
{
|
|
3448
|
+
name: "y",
|
|
3449
|
+
label: "Y坐标",
|
|
3450
|
+
type: "number"
|
|
3451
|
+
},
|
|
3452
|
+
{
|
|
3453
|
+
name: "width",
|
|
3454
|
+
label: "宽度",
|
|
3455
|
+
type: "number"
|
|
3456
|
+
},
|
|
3457
|
+
{
|
|
3458
|
+
name: "height",
|
|
3459
|
+
label: "高度",
|
|
3460
|
+
type: "number"
|
|
3461
|
+
},
|
|
3462
|
+
{
|
|
3463
|
+
name: "aspectRatio",
|
|
3464
|
+
label: "宽高比",
|
|
3465
|
+
type: "aspectRatio"
|
|
3466
|
+
}
|
|
3467
|
+
]
|
|
3468
|
+
},
|
|
3469
|
+
ModelToFlat: {
|
|
3470
|
+
key: "ModelToFlat",
|
|
3471
|
+
title: "模特转平铺",
|
|
3472
|
+
description: "模特图生成平铺图效果",
|
|
3473
|
+
fields: [{
|
|
3474
|
+
name: "imgUrl",
|
|
3475
|
+
label: "模特图",
|
|
3476
|
+
type: "image",
|
|
3477
|
+
required: !0
|
|
3478
|
+
}, {
|
|
3479
|
+
name: "position",
|
|
3480
|
+
label: "服装位置",
|
|
3481
|
+
type: "enum",
|
|
3482
|
+
required: !0,
|
|
3483
|
+
options: Le
|
|
3484
|
+
}]
|
|
3485
|
+
},
|
|
3486
|
+
GenerateShortVideo: {
|
|
3487
|
+
key: "GenerateShortVideo",
|
|
3488
|
+
title: "短视频生成",
|
|
3489
|
+
description: "上传图片生成短视频",
|
|
3490
|
+
fields: [
|
|
3491
|
+
{
|
|
3492
|
+
name: "imgUrl",
|
|
3493
|
+
label: "首帧图片",
|
|
3494
|
+
type: "image",
|
|
3495
|
+
required: !0
|
|
3496
|
+
},
|
|
3497
|
+
{
|
|
3498
|
+
name: "tailImgUrl",
|
|
3499
|
+
label: "尾帧图片",
|
|
3500
|
+
type: "image"
|
|
3501
|
+
},
|
|
3502
|
+
{
|
|
3503
|
+
name: "prompt",
|
|
3504
|
+
label: "文本指令",
|
|
3505
|
+
type: "text",
|
|
3506
|
+
placeholder: "描述视频内容"
|
|
3507
|
+
},
|
|
3508
|
+
{
|
|
3509
|
+
name: "duration",
|
|
3510
|
+
label: "时长",
|
|
3511
|
+
type: "enum",
|
|
3512
|
+
required: !0,
|
|
3513
|
+
options: We
|
|
3514
|
+
}
|
|
3515
|
+
]
|
|
3516
|
+
},
|
|
3517
|
+
OneClickModifyPrinting: {
|
|
3518
|
+
key: "OneClickModifyPrinting",
|
|
3519
|
+
title: "一键改图案",
|
|
3520
|
+
description: "通过文本或参考图一键更改图案",
|
|
3521
|
+
fields: [
|
|
3522
|
+
{
|
|
3523
|
+
name: "imgUrl",
|
|
3524
|
+
label: "原图",
|
|
3525
|
+
type: "image",
|
|
3526
|
+
required: !0
|
|
3527
|
+
},
|
|
3528
|
+
{
|
|
3529
|
+
name: "refImgUrl",
|
|
3530
|
+
label: "参考图",
|
|
3531
|
+
type: "image"
|
|
3532
|
+
},
|
|
3533
|
+
{
|
|
3534
|
+
name: "prompt",
|
|
3535
|
+
label: "文本指令",
|
|
3536
|
+
type: "text",
|
|
3537
|
+
placeholder: "描述图案修改需求"
|
|
3538
|
+
},
|
|
3539
|
+
{
|
|
3540
|
+
name: "aspectRatio",
|
|
3541
|
+
label: "宽高比",
|
|
3542
|
+
type: "aspectRatio"
|
|
3543
|
+
}
|
|
3544
|
+
]
|
|
3545
|
+
},
|
|
3546
|
+
OrientationDesign: {
|
|
3547
|
+
key: "OrientationDesign",
|
|
3548
|
+
title: "服装定向设计",
|
|
3549
|
+
description: "通过设计点对服装进行定向设计",
|
|
3550
|
+
fields: [
|
|
3551
|
+
{
|
|
3552
|
+
name: "imgUrl",
|
|
3553
|
+
label: "原图",
|
|
3554
|
+
type: "image",
|
|
3555
|
+
required: !0
|
|
3556
|
+
},
|
|
3557
|
+
{
|
|
3558
|
+
name: "maskUrl",
|
|
3559
|
+
label: "蒙版1",
|
|
3560
|
+
type: "mask"
|
|
3561
|
+
},
|
|
3562
|
+
{
|
|
3563
|
+
name: "refImgUrl",
|
|
3564
|
+
label: "参考图1",
|
|
3565
|
+
type: "image"
|
|
3566
|
+
},
|
|
3567
|
+
{
|
|
3568
|
+
name: "prompt",
|
|
3569
|
+
label: "文本指令1",
|
|
3570
|
+
type: "text",
|
|
3571
|
+
placeholder: "描述设计需求"
|
|
3572
|
+
}
|
|
3573
|
+
]
|
|
3574
|
+
},
|
|
3575
|
+
DirectionalIntegration: {
|
|
3576
|
+
key: "DirectionalIntegration",
|
|
3577
|
+
title: "定向融合",
|
|
3578
|
+
description: "通过融合设计点对服装进行融合设计",
|
|
3579
|
+
fields: [
|
|
3580
|
+
{
|
|
3581
|
+
name: "imgUrl",
|
|
3582
|
+
label: "原图",
|
|
3583
|
+
type: "image",
|
|
3584
|
+
required: !0
|
|
3585
|
+
},
|
|
3586
|
+
{
|
|
3587
|
+
name: "maskUrl",
|
|
3588
|
+
label: "蒙版1",
|
|
3589
|
+
type: "mask"
|
|
3590
|
+
},
|
|
3591
|
+
{
|
|
3592
|
+
name: "refImgUrl",
|
|
3593
|
+
label: "参考图1",
|
|
3594
|
+
type: "image",
|
|
3595
|
+
required: !0
|
|
3596
|
+
}
|
|
3597
|
+
]
|
|
3598
|
+
},
|
|
3599
|
+
OneClickIntegration: {
|
|
3600
|
+
key: "OneClickIntegration",
|
|
3601
|
+
title: "一键融合",
|
|
3602
|
+
description: "通过参考图和文本指令一键融合",
|
|
3603
|
+
fields: [
|
|
3604
|
+
{
|
|
3605
|
+
name: "imgUrl",
|
|
3606
|
+
label: "原图",
|
|
3607
|
+
type: "image",
|
|
3608
|
+
required: !0
|
|
3609
|
+
},
|
|
3610
|
+
{
|
|
3611
|
+
name: "refImgUrl",
|
|
3612
|
+
label: "参考图",
|
|
3613
|
+
type: "image",
|
|
3614
|
+
required: !0
|
|
3615
|
+
},
|
|
3616
|
+
{
|
|
3617
|
+
name: "prompt",
|
|
3618
|
+
label: "文本指令",
|
|
3619
|
+
type: "text",
|
|
3620
|
+
placeholder: "描述融合需求"
|
|
3621
|
+
},
|
|
3622
|
+
{
|
|
3623
|
+
name: "aspectRatio",
|
|
3624
|
+
label: "宽高比",
|
|
3625
|
+
type: "aspectRatio"
|
|
3626
|
+
}
|
|
3627
|
+
]
|
|
3628
|
+
},
|
|
3629
|
+
ChangeFabricV2: {
|
|
3630
|
+
key: "ChangeFabricV2",
|
|
3631
|
+
title: "面料上身2.0",
|
|
3632
|
+
description: "支持文本指令的面料上身",
|
|
3633
|
+
fields: [
|
|
3634
|
+
{
|
|
3635
|
+
name: "imgUrl",
|
|
3636
|
+
label: "款式图",
|
|
3637
|
+
type: "image",
|
|
3638
|
+
required: !0
|
|
3639
|
+
},
|
|
3640
|
+
{
|
|
3641
|
+
name: "maskUrl",
|
|
3642
|
+
label: "蒙版",
|
|
3643
|
+
type: "mask",
|
|
3644
|
+
required: !0
|
|
3645
|
+
},
|
|
3646
|
+
{
|
|
3647
|
+
name: "fabricImgUrl",
|
|
3648
|
+
label: "面料图",
|
|
3649
|
+
type: "image",
|
|
3650
|
+
required: !0
|
|
3651
|
+
},
|
|
3652
|
+
{
|
|
3653
|
+
name: "prompt",
|
|
3654
|
+
label: "文本指令",
|
|
3655
|
+
type: "text",
|
|
3656
|
+
placeholder: "描述调整需求"
|
|
3657
|
+
},
|
|
3658
|
+
{
|
|
3659
|
+
name: "aspectRatio",
|
|
3660
|
+
label: "宽高比",
|
|
3661
|
+
type: "aspectRatio"
|
|
3662
|
+
}
|
|
3663
|
+
]
|
|
3664
|
+
},
|
|
3665
|
+
VirtualFittingReferenceV2: {
|
|
3666
|
+
key: "VirtualFittingReferenceV2",
|
|
3667
|
+
title: "AI试衣参考图2.0",
|
|
3668
|
+
description: "支持姿势和背景的试衣",
|
|
3669
|
+
fields: [
|
|
3670
|
+
{
|
|
3671
|
+
name: "imgUrl",
|
|
3672
|
+
label: "服装图片",
|
|
3673
|
+
type: "image",
|
|
3674
|
+
required: !0
|
|
3675
|
+
},
|
|
3676
|
+
{
|
|
3677
|
+
name: "refImgUrl",
|
|
3678
|
+
label: "模特参考图",
|
|
3679
|
+
type: "image",
|
|
3680
|
+
required: !0
|
|
3681
|
+
},
|
|
3682
|
+
{
|
|
3683
|
+
name: "poseImgUrl",
|
|
3684
|
+
label: "姿势图",
|
|
3685
|
+
type: "image"
|
|
3686
|
+
},
|
|
3687
|
+
{
|
|
3688
|
+
name: "bgImgUrl",
|
|
3689
|
+
label: "背景图",
|
|
3690
|
+
type: "image"
|
|
3691
|
+
},
|
|
3692
|
+
{
|
|
3693
|
+
name: "prompt",
|
|
3694
|
+
label: "文本指令",
|
|
3695
|
+
type: "text",
|
|
3696
|
+
placeholder: "描述试衣需求"
|
|
3697
|
+
},
|
|
3698
|
+
{
|
|
3699
|
+
name: "aspectRatio",
|
|
3700
|
+
label: "宽高比",
|
|
3701
|
+
type: "aspectRatio"
|
|
3702
|
+
}
|
|
3703
|
+
]
|
|
3704
|
+
},
|
|
3705
|
+
FlowerShapedDesign: {
|
|
3706
|
+
key: "FlowerShapedDesign",
|
|
3707
|
+
title: "花型创款",
|
|
3708
|
+
description: "将印花上身到指定款式效果图",
|
|
3709
|
+
fields: [
|
|
3710
|
+
{
|
|
3711
|
+
name: "imgUrl",
|
|
3712
|
+
label: "印花图案",
|
|
3713
|
+
type: "image",
|
|
3714
|
+
required: !0
|
|
3715
|
+
},
|
|
3716
|
+
{
|
|
3717
|
+
name: "prompt",
|
|
3718
|
+
label: "文本指令",
|
|
3719
|
+
type: "text",
|
|
3720
|
+
required: !0,
|
|
3721
|
+
placeholder: "描述上身效果需求"
|
|
3722
|
+
},
|
|
3723
|
+
{
|
|
3724
|
+
name: "aspectRatio",
|
|
3725
|
+
label: "宽高比",
|
|
3726
|
+
type: "aspectRatio"
|
|
3727
|
+
}
|
|
3728
|
+
]
|
|
3729
|
+
},
|
|
3730
|
+
FlowerShapedVirtualPrinting: {
|
|
3731
|
+
key: "FlowerShapedVirtualPrinting",
|
|
3732
|
+
title: "花型上身",
|
|
3733
|
+
description: "将图案上身到款式图指定区域",
|
|
3734
|
+
fields: [
|
|
3735
|
+
{
|
|
3736
|
+
name: "imgUrl",
|
|
3737
|
+
label: "印花图案",
|
|
3738
|
+
type: "image",
|
|
3739
|
+
required: !0
|
|
3740
|
+
},
|
|
3741
|
+
{
|
|
3742
|
+
name: "bodyImgUrl",
|
|
3743
|
+
label: "上身图",
|
|
3744
|
+
type: "image",
|
|
3745
|
+
required: !0
|
|
3746
|
+
},
|
|
3747
|
+
{
|
|
3748
|
+
name: "bodyMaskImgUrl",
|
|
3749
|
+
label: "目标区域蒙版",
|
|
3750
|
+
type: "mask",
|
|
3751
|
+
required: !0
|
|
3752
|
+
},
|
|
3753
|
+
{
|
|
3754
|
+
name: "removePattern",
|
|
3755
|
+
label: "是否去除参考图印花",
|
|
3756
|
+
type: "enum",
|
|
3757
|
+
options: Ge
|
|
3758
|
+
}
|
|
3759
|
+
]
|
|
3760
|
+
},
|
|
3761
|
+
OneClickChangeColor: {
|
|
3762
|
+
key: "OneClickChangeColor",
|
|
3763
|
+
title: "一键改色",
|
|
3764
|
+
description: "整合智能识别与自定义改色",
|
|
3765
|
+
fields: [
|
|
3766
|
+
{
|
|
3767
|
+
name: "imgUrl",
|
|
3768
|
+
label: "原图",
|
|
3769
|
+
type: "image",
|
|
3770
|
+
required: !0
|
|
3771
|
+
},
|
|
3772
|
+
{
|
|
3773
|
+
name: "hexCode",
|
|
3774
|
+
label: "目标颜色",
|
|
3775
|
+
type: "color"
|
|
3776
|
+
},
|
|
3777
|
+
{
|
|
3778
|
+
name: "hexImgUrl",
|
|
3779
|
+
label: "颜色参考图",
|
|
3780
|
+
type: "image"
|
|
3781
|
+
},
|
|
3782
|
+
{
|
|
3783
|
+
name: "changeColorArea",
|
|
3784
|
+
label: "改色区域",
|
|
3785
|
+
type: "text",
|
|
3786
|
+
placeholder: "如:上衣"
|
|
3787
|
+
},
|
|
3788
|
+
{
|
|
3789
|
+
name: "aspectRatio",
|
|
3790
|
+
label: "宽高比",
|
|
3791
|
+
type: "aspectRatio"
|
|
3792
|
+
}
|
|
3793
|
+
]
|
|
3794
|
+
},
|
|
3795
|
+
FittingModelWithLabels: {
|
|
3796
|
+
key: "FittingModelWithLabels",
|
|
3797
|
+
title: "模特定制标签模式",
|
|
3798
|
+
description: "通过标签选择生成虚拟模特",
|
|
3799
|
+
fields: [
|
|
3800
|
+
{
|
|
3801
|
+
name: "gender",
|
|
3802
|
+
label: "性别",
|
|
3803
|
+
type: "enum",
|
|
3804
|
+
required: !0,
|
|
3805
|
+
options: C
|
|
3806
|
+
},
|
|
3807
|
+
{
|
|
3808
|
+
name: "age",
|
|
3809
|
+
label: "年龄",
|
|
3810
|
+
type: "enum",
|
|
3811
|
+
options: Fe
|
|
3812
|
+
},
|
|
3813
|
+
{
|
|
3814
|
+
name: "nationality",
|
|
3815
|
+
label: "国籍",
|
|
3816
|
+
type: "enum",
|
|
3817
|
+
options: Ke
|
|
3818
|
+
},
|
|
3819
|
+
{
|
|
3820
|
+
name: "skinColor",
|
|
3821
|
+
label: "肤色",
|
|
3822
|
+
type: "enum",
|
|
3823
|
+
options: qe
|
|
3824
|
+
},
|
|
3825
|
+
{
|
|
3826
|
+
name: "bodyShape",
|
|
3827
|
+
label: "身材",
|
|
3828
|
+
type: "enum",
|
|
3829
|
+
options: Je
|
|
3830
|
+
}
|
|
3831
|
+
]
|
|
3832
|
+
},
|
|
3833
|
+
FittingModelCustom: {
|
|
3834
|
+
key: "FittingModelCustom",
|
|
3835
|
+
title: "模特定制自定义模式",
|
|
3836
|
+
description: "根据参考图生成虚拟模特",
|
|
3837
|
+
fields: [
|
|
3838
|
+
{
|
|
3839
|
+
name: "gender",
|
|
3840
|
+
label: "性别",
|
|
3841
|
+
type: "enum",
|
|
3842
|
+
required: !0,
|
|
3843
|
+
options: C
|
|
3844
|
+
},
|
|
3845
|
+
{
|
|
3846
|
+
name: "faceRefImgUrl",
|
|
3847
|
+
label: "脸部参考图",
|
|
3848
|
+
type: "image",
|
|
3849
|
+
required: !0
|
|
3850
|
+
},
|
|
3851
|
+
{
|
|
3852
|
+
name: "similarity",
|
|
3853
|
+
label: "相似度",
|
|
3854
|
+
type: "enum",
|
|
3855
|
+
options: w
|
|
3856
|
+
},
|
|
3857
|
+
{
|
|
3858
|
+
name: "bodyShapeRefImgUrl",
|
|
3859
|
+
label: "身材参考图",
|
|
3860
|
+
type: "image"
|
|
3861
|
+
},
|
|
3862
|
+
{
|
|
3863
|
+
name: "additionalDescription",
|
|
3864
|
+
label: "附加描述",
|
|
3865
|
+
type: "text",
|
|
3866
|
+
placeholder: "附加描述"
|
|
3867
|
+
}
|
|
3868
|
+
]
|
|
3869
|
+
},
|
|
3870
|
+
FittingModelChangeFace: {
|
|
3871
|
+
key: "FittingModelChangeFace",
|
|
3872
|
+
title: "模特换脸",
|
|
3873
|
+
description: "对模特图换脸操作",
|
|
3874
|
+
fields: [
|
|
3875
|
+
{
|
|
3876
|
+
name: "imgUrl",
|
|
3877
|
+
label: "模特图",
|
|
3878
|
+
type: "image",
|
|
3879
|
+
required: !0
|
|
3880
|
+
},
|
|
3881
|
+
{
|
|
3882
|
+
name: "refImgUrl",
|
|
3883
|
+
label: "参考面部图",
|
|
3884
|
+
type: "image",
|
|
3885
|
+
required: !0
|
|
3886
|
+
},
|
|
3887
|
+
{
|
|
3888
|
+
name: "similarity",
|
|
3889
|
+
label: "相似度",
|
|
3890
|
+
type: "enum",
|
|
3891
|
+
options: w
|
|
3892
|
+
},
|
|
3893
|
+
{
|
|
3894
|
+
name: "aspectRatio",
|
|
3895
|
+
label: "宽高比",
|
|
3896
|
+
type: "aspectRatio"
|
|
3897
|
+
}
|
|
3898
|
+
]
|
|
3899
|
+
},
|
|
3900
|
+
FittingModelChangeModel: {
|
|
3901
|
+
key: "FittingModelChangeModel",
|
|
3902
|
+
title: "模特替换",
|
|
3903
|
+
description: "随机或指定模特替换",
|
|
3904
|
+
fields: [
|
|
3905
|
+
{
|
|
3906
|
+
name: "imgUrl",
|
|
3907
|
+
label: "模特图",
|
|
3908
|
+
type: "image",
|
|
3909
|
+
required: !0
|
|
3910
|
+
},
|
|
3911
|
+
{
|
|
3912
|
+
name: "gender",
|
|
3913
|
+
label: "性别",
|
|
3914
|
+
type: "enum",
|
|
3915
|
+
options: C
|
|
3916
|
+
},
|
|
3917
|
+
{
|
|
3918
|
+
name: "similarity",
|
|
3919
|
+
label: "相似度",
|
|
3920
|
+
type: "enum",
|
|
3921
|
+
options: w
|
|
3922
|
+
},
|
|
3923
|
+
{
|
|
3924
|
+
name: "aspectRatio",
|
|
3925
|
+
label: "宽高比",
|
|
3926
|
+
type: "aspectRatio"
|
|
3927
|
+
}
|
|
3928
|
+
]
|
|
3929
|
+
},
|
|
3930
|
+
FittingModelChangeBodyShape: {
|
|
3931
|
+
key: "FittingModelChangeBodyShape",
|
|
3932
|
+
title: "模特身材调整",
|
|
3933
|
+
description: "通过标签或参考图调整身材",
|
|
3934
|
+
fields: [
|
|
3935
|
+
{
|
|
3936
|
+
name: "imgUrl",
|
|
3937
|
+
label: "模特图",
|
|
3938
|
+
type: "image",
|
|
3939
|
+
required: !0
|
|
3940
|
+
},
|
|
3941
|
+
{
|
|
3942
|
+
name: "bodyShapeRefImgUrl",
|
|
3943
|
+
label: "身材参考图",
|
|
3944
|
+
type: "image"
|
|
3945
|
+
},
|
|
3946
|
+
{
|
|
3947
|
+
name: "aspectRatio",
|
|
3948
|
+
label: "宽高比",
|
|
3949
|
+
type: "aspectRatio"
|
|
3950
|
+
}
|
|
3951
|
+
]
|
|
3952
|
+
},
|
|
3953
|
+
FittingModelChangeClothingSize: {
|
|
3954
|
+
key: "FittingModelChangeClothingSize",
|
|
3955
|
+
title: "模特尺码调整",
|
|
3956
|
+
description: "调整模特服装尺码",
|
|
3957
|
+
fields: [
|
|
3958
|
+
{
|
|
3959
|
+
name: "imgUrl",
|
|
3960
|
+
label: "模特图",
|
|
3961
|
+
type: "image",
|
|
3962
|
+
required: !0
|
|
3963
|
+
},
|
|
3964
|
+
{
|
|
3965
|
+
name: "size",
|
|
3966
|
+
label: "尺码",
|
|
3967
|
+
type: "enum",
|
|
3968
|
+
required: !0,
|
|
3969
|
+
options: Ye
|
|
3970
|
+
},
|
|
3971
|
+
{
|
|
3972
|
+
name: "aspectRatio",
|
|
3973
|
+
label: "宽高比",
|
|
3974
|
+
type: "aspectRatio"
|
|
3975
|
+
}
|
|
3976
|
+
]
|
|
3977
|
+
},
|
|
3978
|
+
FittingModelChangePosture: {
|
|
3979
|
+
key: "FittingModelChangePosture",
|
|
3980
|
+
title: "模特姿势调整",
|
|
3981
|
+
description: "调整模特姿势",
|
|
3982
|
+
fields: [
|
|
3983
|
+
{
|
|
3984
|
+
name: "imgUrl",
|
|
3985
|
+
label: "模特图",
|
|
3986
|
+
type: "image",
|
|
3987
|
+
required: !0
|
|
3988
|
+
},
|
|
3989
|
+
{
|
|
3990
|
+
name: "poseImgUrl",
|
|
3991
|
+
label: "姿势参考图",
|
|
3992
|
+
type: "image",
|
|
3993
|
+
required: !0
|
|
3994
|
+
},
|
|
3995
|
+
{
|
|
3996
|
+
name: "aspectRatio",
|
|
3997
|
+
label: "宽高比",
|
|
3998
|
+
type: "aspectRatio"
|
|
3999
|
+
}
|
|
4000
|
+
]
|
|
4001
|
+
},
|
|
4002
|
+
FittingModelChangeBackground: {
|
|
4003
|
+
key: "FittingModelChangeBackground",
|
|
4004
|
+
title: "模特换背景",
|
|
4005
|
+
description: "替换模特背景",
|
|
4006
|
+
fields: [
|
|
4007
|
+
{
|
|
4008
|
+
name: "imgUrl",
|
|
4009
|
+
label: "模特图",
|
|
4010
|
+
type: "image",
|
|
4011
|
+
required: !0
|
|
4012
|
+
},
|
|
4013
|
+
{
|
|
4014
|
+
name: "bgImgUrl",
|
|
4015
|
+
label: "背景参考图",
|
|
4016
|
+
type: "image"
|
|
4017
|
+
},
|
|
4018
|
+
{
|
|
4019
|
+
name: "prompt",
|
|
4020
|
+
label: "文本指令",
|
|
4021
|
+
type: "text",
|
|
4022
|
+
placeholder: "描述背景需求"
|
|
4023
|
+
},
|
|
4024
|
+
{
|
|
4025
|
+
name: "aspectRatio",
|
|
4026
|
+
label: "宽高比",
|
|
4027
|
+
type: "aspectRatio"
|
|
4028
|
+
}
|
|
4029
|
+
]
|
|
4030
|
+
},
|
|
4031
|
+
FittingModelChangePerspective: {
|
|
4032
|
+
key: "FittingModelChangePerspective",
|
|
4033
|
+
title: "模特视角调整",
|
|
4034
|
+
description: "调整模特视角",
|
|
4035
|
+
fields: [
|
|
4036
|
+
{
|
|
4037
|
+
name: "imgUrl",
|
|
4038
|
+
label: "模特图",
|
|
4039
|
+
type: "image",
|
|
4040
|
+
required: !0
|
|
4041
|
+
},
|
|
4042
|
+
{
|
|
4043
|
+
name: "perspective",
|
|
4044
|
+
label: "视角",
|
|
4045
|
+
type: "enum",
|
|
4046
|
+
required: !0,
|
|
4047
|
+
options: S
|
|
4048
|
+
},
|
|
4049
|
+
{
|
|
4050
|
+
name: "aspectRatio",
|
|
4051
|
+
label: "宽高比",
|
|
4052
|
+
type: "aspectRatio"
|
|
4053
|
+
}
|
|
4054
|
+
]
|
|
4055
|
+
},
|
|
4056
|
+
TrainClothingModel: {
|
|
4057
|
+
key: "TrainClothingModel",
|
|
4058
|
+
title: "服装风格模型训练",
|
|
4059
|
+
description: "训练自定义服装风格模型",
|
|
4060
|
+
fields: [
|
|
4061
|
+
{
|
|
4062
|
+
name: "imgUrlList",
|
|
4063
|
+
label: "训练图片",
|
|
4064
|
+
type: "images",
|
|
4065
|
+
required: !0,
|
|
4066
|
+
hint: "建议上传30-50张正面/斜侧面模特图"
|
|
4067
|
+
},
|
|
4068
|
+
{
|
|
4069
|
+
name: "clothingModelName",
|
|
4070
|
+
label: "模型名称",
|
|
4071
|
+
type: "text",
|
|
4072
|
+
required: !0
|
|
4073
|
+
},
|
|
4074
|
+
{
|
|
4075
|
+
name: "enhanceWordList",
|
|
4076
|
+
label: "加强词",
|
|
4077
|
+
type: "text"
|
|
4078
|
+
}
|
|
4079
|
+
]
|
|
4080
|
+
}
|
|
4081
|
+
}, Y = {
|
|
4082
|
+
...Lt,
|
|
4083
|
+
...Rt
|
|
4084
|
+
};
|
|
4085
|
+
function zt(e) {
|
|
4086
|
+
return Y[e];
|
|
4087
|
+
}
|
|
4088
|
+
function Bt() {
|
|
4089
|
+
return Object.values(Y);
|
|
4090
|
+
}
|
|
4091
|
+
//#endregion
|
|
4092
|
+
//#region src/core/validate.ts
|
|
4093
|
+
function Vt(e, t) {
|
|
4094
|
+
let n = [];
|
|
4095
|
+
for (let r of t) {
|
|
4096
|
+
let t = e[r.name], i = Ht(r, t);
|
|
4097
|
+
i && n.push(i);
|
|
4098
|
+
}
|
|
4099
|
+
return {
|
|
4100
|
+
valid: n.length === 0,
|
|
4101
|
+
errors: n
|
|
4102
|
+
};
|
|
4103
|
+
}
|
|
4104
|
+
function Ht(e, t) {
|
|
4105
|
+
let n = t == null || t === "";
|
|
4106
|
+
if (e.required && n) return {
|
|
4107
|
+
field: e.name,
|
|
4108
|
+
label: e.label,
|
|
4109
|
+
message: x.FIELD_REQUIRED(e.label)
|
|
4110
|
+
};
|
|
4111
|
+
if (t == null) return null;
|
|
4112
|
+
let r = (t) => ({
|
|
4113
|
+
field: e.name,
|
|
4114
|
+
label: e.label,
|
|
4115
|
+
message: t(e.label)
|
|
4116
|
+
});
|
|
4117
|
+
switch (e.type) {
|
|
4118
|
+
case "image":
|
|
4119
|
+
case "mask":
|
|
4120
|
+
if (typeof t != "string" && !Ut(t)) return r(x.FIELD_STRING);
|
|
4121
|
+
break;
|
|
4122
|
+
case "images":
|
|
4123
|
+
if (!Array.isArray(t) || t.length === 0) return r(x.FIELD_ARRAY);
|
|
4124
|
+
if (t.some((e) => (typeof e != "string" || e === "") && !Ut(e))) return r(x.FIELD_ARRAY_ELEMENTS);
|
|
4125
|
+
break;
|
|
4126
|
+
case "text":
|
|
4127
|
+
if (typeof t != "string") return r(x.FIELD_STRING);
|
|
4128
|
+
if (e.maxLength && t.length > e.maxLength) return r((t) => x.FIELD_MAX_LENGTH(t, e.maxLength));
|
|
4129
|
+
break;
|
|
4130
|
+
case "enum":
|
|
4131
|
+
if (typeof t != "string") return r(x.FIELD_STRING);
|
|
4132
|
+
if (e.options && !e.options.some((e) => e.value === t)) return r(x.FIELD_ENUM_INVALID);
|
|
4133
|
+
break;
|
|
4134
|
+
case "multiEnum":
|
|
4135
|
+
if (!Array.isArray(t) || t.length === 0) return r(x.FIELD_ARRAY);
|
|
4136
|
+
if (t.some((e) => typeof e != "string" || e === "")) return r(x.FIELD_ARRAY_ELEMENTS);
|
|
4137
|
+
if (e.options && t.some((t) => !e.options?.some((e) => e.value === t))) return r(x.FIELD_ENUM_INVALID);
|
|
4138
|
+
break;
|
|
4139
|
+
case "color":
|
|
4140
|
+
if (typeof t != "string" || !/^#[0-9A-Fa-f]{6}$/.test(t)) return r(x.FIELD_COLOR_FORMAT);
|
|
4141
|
+
break;
|
|
4142
|
+
case "number":
|
|
4143
|
+
if (typeof t != "number" || Number.isNaN(t)) return r(x.FIELD_NUMBER);
|
|
4144
|
+
break;
|
|
4145
|
+
case "aspectRatio":
|
|
4146
|
+
case "strength": break;
|
|
4147
|
+
}
|
|
4148
|
+
return null;
|
|
4149
|
+
}
|
|
4150
|
+
function Ut(e) {
|
|
4151
|
+
return typeof File < "u" && e instanceof File;
|
|
4152
|
+
}
|
|
4153
|
+
//#endregion
|
|
4154
|
+
//#region src/core/client.ts
|
|
4155
|
+
var Wt = class {
|
|
4156
|
+
constructor(e = {}) {
|
|
4157
|
+
this.type = "", this.submitEndpoint = "/task/submit", this.submitEndpointMode = "prefix", this.pollEndpoint = "/task/progress", this.pollInterval = 1e3, this.maxPollAttempts = 120, this.phase = v.IDLE, this.taskId = "", this.progress = 0, this.result = null, this.error = "", this.activeTasks = /* @__PURE__ */ new Map(), this.pollTimer = null, this.isPollingBatch = !1, this.configure(e);
|
|
4158
|
+
}
|
|
4159
|
+
configure(e) {
|
|
4160
|
+
e.type !== void 0 && (this.type = e.type), e.submitEndpoint !== void 0 && (this.submitEndpoint = e.submitEndpoint), e.submitEndpointMode !== void 0 && (this.submitEndpointMode = e.submitEndpointMode), e.pollEndpoint !== void 0 && (this.pollEndpoint = e.pollEndpoint), e.pollInterval !== void 0 && (this.pollInterval = e.pollInterval), e.maxPollAttempts !== void 0 && (this.maxPollAttempts = e.maxPollAttempts), e.customRequest !== void 0 && (this.customRequest = e.customRequest), e.customUploadRequest !== void 0 && (this.customUploadRequest = e.customUploadRequest), e.customUploadRequert !== void 0 && (this.customUploadRequest = e.customUploadRequert), e.onSubmit !== void 0 && (this.onSubmit = e.onSubmit), e.onPoll !== void 0 && (this.onPoll = e.onPoll), e.onSuccess !== void 0 && (this.onSuccess = e.onSuccess), e.onError !== void 0 && (this.onError = e.onError);
|
|
4161
|
+
}
|
|
4162
|
+
get typeDef() {
|
|
4163
|
+
let e = this.resolvedTaskTypeKey;
|
|
4164
|
+
return e ? zt(e) : void 0;
|
|
4165
|
+
}
|
|
4166
|
+
get taskFields() {
|
|
4167
|
+
return this.typeDef?.fields ?? [];
|
|
4168
|
+
}
|
|
4169
|
+
async submit(e, t) {
|
|
4170
|
+
let n = this.createRequestUri(e);
|
|
4171
|
+
if (!n) {
|
|
4172
|
+
this.fail(x.MISSING_ENDPOINT, v.IDLE);
|
|
4173
|
+
return;
|
|
4174
|
+
}
|
|
4175
|
+
let r = this.getTaskFields(e);
|
|
4176
|
+
if (r.length > 0) {
|
|
4177
|
+
let e = Vt(t, r);
|
|
4178
|
+
if (!e.valid) {
|
|
4179
|
+
this.fail(e.errors.map((e) => e.message).join("; "), v.IDLE);
|
|
4180
|
+
return;
|
|
4181
|
+
}
|
|
4182
|
+
}
|
|
4183
|
+
this.phase = v.SUBMITTING, this.error = "", this.progress = 0, this.result = null;
|
|
4184
|
+
try {
|
|
4185
|
+
let e = await this.resolveUploads(t, r), i = (await this.request(n, {
|
|
4186
|
+
method: "POST",
|
|
4187
|
+
body: JSON.stringify(e),
|
|
4188
|
+
headers: { "Content-Type": "application/json" }
|
|
4189
|
+
})).data.taskId;
|
|
4190
|
+
this.taskId = i;
|
|
4191
|
+
let a = {
|
|
4192
|
+
taskId: i,
|
|
4193
|
+
endpoint: n,
|
|
4194
|
+
formData: e
|
|
4195
|
+
};
|
|
4196
|
+
this.onSubmit?.(a), await this.trackTask(i);
|
|
4197
|
+
} catch (e) {
|
|
4198
|
+
this.fail(e instanceof Error ? e.message : x.SUBMIT_FAILED, this.phase);
|
|
4199
|
+
}
|
|
4200
|
+
}
|
|
4201
|
+
reset() {
|
|
4202
|
+
this.phase = v.IDLE, this.taskId = "", this.progress = 0, this.result = null, this.error = "", this.activeTasks.clear(), this.pollTimer &&= (clearTimeout(this.pollTimer), null);
|
|
4203
|
+
}
|
|
4204
|
+
createRequestUri(e = this.type) {
|
|
4205
|
+
return this.submitEndpointMode === "full" ? this.submitEndpoint : e ? `${this.submitEndpoint}/${e}` : this.submitEndpoint;
|
|
4206
|
+
}
|
|
4207
|
+
get resolvedTaskTypeKey() {
|
|
4208
|
+
return Gt(this.type);
|
|
4209
|
+
}
|
|
4210
|
+
getTaskFields(e) {
|
|
4211
|
+
let t = Gt(e);
|
|
4212
|
+
return t ? zt(t)?.fields ?? [] : [];
|
|
4213
|
+
}
|
|
4214
|
+
async resolveUploads(e, t) {
|
|
4215
|
+
let n = t.length > 0 ? t.filter((e) => e.type === "image" || e.type === "mask" || e.type === "images") : Object.keys(e).map((e) => ({
|
|
4216
|
+
name: e,
|
|
4217
|
+
type: "image"
|
|
4218
|
+
}));
|
|
4219
|
+
if (!n.length) return e;
|
|
4220
|
+
let r = { ...e };
|
|
4221
|
+
for (let e of n) {
|
|
4222
|
+
let t = r[e.name];
|
|
4223
|
+
Array.isArray(t) ? r[e.name] = await Promise.all(t.map((t) => this.resolveUploadValue(t, e))) : r[e.name] = await this.resolveUploadValue(t, e);
|
|
4224
|
+
}
|
|
4225
|
+
return r;
|
|
4226
|
+
}
|
|
4227
|
+
async resolveUploadValue(e, t) {
|
|
4228
|
+
if (!Kt(e)) return e;
|
|
4229
|
+
if (!this.customUploadRequest) throw Error(`customUploadRequest is required to upload ${t.name}`);
|
|
4230
|
+
let n = new FormData();
|
|
4231
|
+
return n.append(t.name || "file", e), qt(await this.customUploadRequest({
|
|
4232
|
+
file: e,
|
|
4233
|
+
name: t.name,
|
|
4234
|
+
formData: n,
|
|
4235
|
+
field: t
|
|
4236
|
+
}));
|
|
4237
|
+
}
|
|
4238
|
+
trackTask(e) {
|
|
4239
|
+
this.phase = v.POLLING;
|
|
4240
|
+
let t = new Promise((t) => {
|
|
4241
|
+
this.activeTasks.set(e, {
|
|
4242
|
+
taskId: e,
|
|
4243
|
+
attempts: 0,
|
|
4244
|
+
resolve: t
|
|
4245
|
+
});
|
|
4246
|
+
});
|
|
4247
|
+
return this.ensurePolling(0), t;
|
|
4248
|
+
}
|
|
4249
|
+
ensurePolling(e = this.pollInterval) {
|
|
4250
|
+
this.pollTimer || this.isPollingBatch || !this.activeTasks.size || (this.pollTimer = setTimeout(() => {
|
|
4251
|
+
this.pollTimer = null, this.pollActiveTasks();
|
|
4252
|
+
}, this.pollInterval));
|
|
4253
|
+
}
|
|
4254
|
+
async pollActiveTasks() {
|
|
4255
|
+
if (!this.activeTasks.size) return;
|
|
4256
|
+
this.isPollingBatch = !0;
|
|
4257
|
+
let e = [...this.activeTasks.keys()];
|
|
4258
|
+
try {
|
|
4259
|
+
let t = `${this.pollEndpoint}?taskIds=${e.map(encodeURIComponent).join(",")}`, n = await this.request(t, { method: "GET" }), r = new Map(n.data.map((e) => [e.aiTaskId, e]));
|
|
4260
|
+
e.forEach((e) => {
|
|
4261
|
+
let t = this.activeTasks.get(e);
|
|
4262
|
+
if (!t) return;
|
|
4263
|
+
t.attempts += 1;
|
|
4264
|
+
let n = r.get(e);
|
|
4265
|
+
if (!n) {
|
|
4266
|
+
this.failTask(t, x.TASK_NOT_FOUND(e));
|
|
4267
|
+
return;
|
|
4268
|
+
}
|
|
4269
|
+
this.taskId = e, this.progress = n.taskProgress;
|
|
4270
|
+
let i = {
|
|
4271
|
+
taskId: e,
|
|
4272
|
+
progress: n.taskProgress,
|
|
4273
|
+
status: n.aiTaskStatus,
|
|
4274
|
+
queuePos: n.queuePos
|
|
4275
|
+
};
|
|
4276
|
+
if (this.onPoll?.(i), n.aiTaskStatus === "done") {
|
|
4277
|
+
this.result = n;
|
|
4278
|
+
let r = {
|
|
4279
|
+
taskId: e,
|
|
4280
|
+
images: n.imgInfo ? [{
|
|
4281
|
+
index: 0,
|
|
4282
|
+
url: n.imgInfo
|
|
4283
|
+
}] : [],
|
|
4284
|
+
result: n
|
|
4285
|
+
};
|
|
4286
|
+
this.onSuccess?.(r), this.completeTask(t);
|
|
4287
|
+
return;
|
|
4288
|
+
}
|
|
4289
|
+
t.attempts >= this.maxPollAttempts && this.failTask(t, x.POLL_TIMEOUT(e));
|
|
4290
|
+
});
|
|
4291
|
+
} catch (e) {
|
|
4292
|
+
let t = e instanceof Error ? e.message : x.POLL_FAILED;
|
|
4293
|
+
[...this.activeTasks.values()].forEach((e) => this.failTask(e, t));
|
|
4294
|
+
} finally {
|
|
4295
|
+
this.isPollingBatch = !1, this.activeTasks.size ? (this.phase = v.POLLING, this.ensurePolling(this.pollInterval)) : this.phase === v.POLLING && (this.phase = this.error ? v.ERROR : v.SUCCESS);
|
|
4296
|
+
}
|
|
4297
|
+
}
|
|
4298
|
+
completeTask(e) {
|
|
4299
|
+
this.activeTasks.delete(e.taskId), e.resolve();
|
|
4300
|
+
}
|
|
4301
|
+
failTask(e, t) {
|
|
4302
|
+
this.activeTasks.delete(e.taskId), this.fail(t, v.POLLING, e.taskId), e.resolve();
|
|
4303
|
+
}
|
|
4304
|
+
async request(e, t) {
|
|
4305
|
+
let n = await (this.customRequest ?? fetch)(e, t);
|
|
4306
|
+
return n && typeof n.json == "function" ? n.json() : n;
|
|
4307
|
+
}
|
|
4308
|
+
fail(e, t, n) {
|
|
4309
|
+
this.phase = v.ERROR, this.error = e;
|
|
4310
|
+
let r = {
|
|
4311
|
+
message: e,
|
|
4312
|
+
phase: t,
|
|
4313
|
+
taskId: n
|
|
4314
|
+
};
|
|
4315
|
+
this.onError?.(r);
|
|
4316
|
+
}
|
|
4317
|
+
};
|
|
4318
|
+
function Gt(e) {
|
|
4319
|
+
if (!e) return "";
|
|
4320
|
+
if (Y[e]) return e;
|
|
4321
|
+
let t = e.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[-\s]+/g, "_").toUpperCase();
|
|
4322
|
+
return Y[t] ? t : "";
|
|
4323
|
+
}
|
|
4324
|
+
function Kt(e) {
|
|
4325
|
+
return typeof File < "u" && e instanceof File;
|
|
4326
|
+
}
|
|
4327
|
+
async function qt(e) {
|
|
4328
|
+
return e ? typeof e == "string" ? e : e instanceof Response ? qt(await e.json()) : typeof e.data == "string" ? e.data : e.data ? e.data.value || e.data.url || "" : e.value || e.url || "" : "";
|
|
4329
|
+
}
|
|
4330
|
+
//#endregion
|
|
4331
|
+
//#region src/components/task-workflow/task-workflow.ts
|
|
4332
|
+
var X = v, Z = b, Q = class extends e {
|
|
4333
|
+
constructor(...e) {
|
|
4334
|
+
super(...e), this.type = "", this.submitEndpoint = "", this.pollEndpoint = y.POLL_ENDPOINT, this.pollInterval = y.POLL_INTERVAL, this.maxPollAttempts = y.MAX_POLL_ATTEMPTS, this.phase = X.IDLE, this.taskId = "", this.progress = 0, this.result = null, this.error = "", this._defaultClient = new Wt();
|
|
4335
|
+
}
|
|
4336
|
+
get typeDef() {
|
|
4337
|
+
return this._syncClientConfig(), this._activeClient.typeDef;
|
|
4338
|
+
}
|
|
4339
|
+
get taskFields() {
|
|
4340
|
+
return this.typeDef?.fields ?? [];
|
|
4341
|
+
}
|
|
4342
|
+
async submit(e) {
|
|
4343
|
+
this.phase === X.SUBMITTING || this.phase === X.POLLING || (this._syncClientConfig(), this.phase = X.SUBMITTING, this.error = "", this.progress = 0, this.result = null, await this._activeClient.submit(this.type || this._activeClient.type, e), this._syncStateFromClient());
|
|
4344
|
+
}
|
|
4345
|
+
reset() {
|
|
4346
|
+
this._activeClient.reset(), this._syncStateFromClient();
|
|
4347
|
+
}
|
|
4348
|
+
async _handleFormSubmit(e) {
|
|
4349
|
+
e.preventDefault(), await this.submit(this.collectFormData());
|
|
4350
|
+
}
|
|
4351
|
+
_handleClick(e) {
|
|
4352
|
+
e.composedPath().find((e) => e instanceof HTMLElement ? (e.type || e.getAttribute("type")) === "submit" : !1) && (e.preventDefault(), this.submit(this.collectFormData()));
|
|
4353
|
+
}
|
|
4354
|
+
_handleChildChange(e) {
|
|
4355
|
+
let t = e.target;
|
|
4356
|
+
if (!(t instanceof HTMLElement)) return;
|
|
4357
|
+
let n = Jt(t);
|
|
4358
|
+
if (!n) return;
|
|
4359
|
+
let r = Zt(e) ?? Yt(t);
|
|
4360
|
+
r !== void 0 && (t.value = r, this._syncMaskSources(n, r));
|
|
4361
|
+
}
|
|
4362
|
+
_syncMaskSources(e, t) {
|
|
4363
|
+
this.taskFields.find((t) => t.name === e)?.type === "image" && (typeof t != "string" || !t || this.querySelectorAll("lc-mask-editor").forEach((e) => {
|
|
4364
|
+
let n = e;
|
|
4365
|
+
n.source ||= t;
|
|
4366
|
+
}));
|
|
4367
|
+
}
|
|
4368
|
+
collectFormData() {
|
|
4369
|
+
let e = {}, t = this.querySelectorAll("*"), n = new Map(this.taskFields.map((e) => [e.name, e]));
|
|
4370
|
+
return t.forEach((t) => {
|
|
4371
|
+
let r = Jt(t);
|
|
4372
|
+
if (!r) return;
|
|
4373
|
+
let i = Xt(t);
|
|
4374
|
+
n.get(r)?.type === "images" && typeof i == "string" && i && (i = [i]), n.get(r)?.type === "multiEnum" && typeof i == "string" && i && (i = Qt(i)), i !== void 0 && (e[r] = i);
|
|
4375
|
+
}), e;
|
|
4376
|
+
}
|
|
4377
|
+
get _activeClient() {
|
|
4378
|
+
return this.client ?? this._defaultClient;
|
|
4379
|
+
}
|
|
4380
|
+
_syncClientConfig() {
|
|
4381
|
+
let e = {
|
|
4382
|
+
customRequest: this.customRequest,
|
|
4383
|
+
customUploadRequest: this.customUploadRequest,
|
|
4384
|
+
onSubmit: (e) => {
|
|
4385
|
+
this._syncStateFromClient(), this.dispatchEvent(new CustomEvent(Z.SUBMIT, {
|
|
4386
|
+
detail: e,
|
|
4387
|
+
bubbles: !0,
|
|
4388
|
+
composed: !0
|
|
4389
|
+
}));
|
|
4390
|
+
},
|
|
4391
|
+
onPoll: (e) => {
|
|
4392
|
+
this._syncStateFromClient(), this.dispatchEvent(new CustomEvent(Z.POLL, {
|
|
4393
|
+
detail: e,
|
|
4394
|
+
bubbles: !0,
|
|
4395
|
+
composed: !0
|
|
4396
|
+
}));
|
|
4397
|
+
},
|
|
4398
|
+
onSuccess: (e) => {
|
|
4399
|
+
this._syncStateFromClient(), this.dispatchEvent(new CustomEvent(Z.SUCCESS, {
|
|
4400
|
+
detail: e,
|
|
4401
|
+
bubbles: !0,
|
|
4402
|
+
composed: !0
|
|
4403
|
+
}));
|
|
4404
|
+
},
|
|
4405
|
+
onError: (e) => this._fail(e.message, e.phase)
|
|
4406
|
+
};
|
|
4407
|
+
this.client ? (this.type && (e.type = this.type), this.submitEndpoint && (e.submitEndpoint = this.submitEndpoint), this.pollEndpoint !== y.POLL_ENDPOINT && (e.pollEndpoint = this.pollEndpoint), this.pollInterval !== y.POLL_INTERVAL && (e.pollInterval = this.pollInterval), this.maxPollAttempts !== y.MAX_POLL_ATTEMPTS && (e.maxPollAttempts = this.maxPollAttempts)) : (e.type = this.type, this.submitEndpoint && (e.submitEndpoint = this.submitEndpoint), e.pollEndpoint = this.pollEndpoint, e.pollInterval = this.pollInterval, e.maxPollAttempts = this.maxPollAttempts), this._activeClient.configure(e);
|
|
4408
|
+
}
|
|
4409
|
+
_syncStateFromClient() {
|
|
4410
|
+
let e = this._activeClient;
|
|
4411
|
+
this.phase = e.phase, this.taskId = e.taskId, this.progress = e.progress, this.result = e.result, this.error = e.error;
|
|
4412
|
+
}
|
|
4413
|
+
_fail(e, t) {
|
|
4414
|
+
this.phase = X.ERROR, this.error = e, this.dispatchEvent(new CustomEvent(Z.ERROR, {
|
|
4415
|
+
detail: {
|
|
4416
|
+
message: e,
|
|
4417
|
+
phase: t
|
|
4418
|
+
},
|
|
4419
|
+
bubbles: !0,
|
|
4420
|
+
composed: !0
|
|
4421
|
+
}));
|
|
4422
|
+
}
|
|
4423
|
+
render() {
|
|
4424
|
+
return n`
|
|
4425
|
+
<form @submit=${this._handleFormSubmit} @click=${this._handleClick} @change=${this._handleChildChange}>
|
|
4426
|
+
<slot></slot>
|
|
4427
|
+
</form>
|
|
4428
|
+
`;
|
|
4429
|
+
}
|
|
4430
|
+
};
|
|
4431
|
+
T([h({ type: String })], Q.prototype, "type", void 0), T([h({
|
|
4432
|
+
type: String,
|
|
4433
|
+
attribute: "submit-endpoint"
|
|
4434
|
+
})], Q.prototype, "submitEndpoint", void 0), T([h({
|
|
4435
|
+
type: String,
|
|
4436
|
+
attribute: "poll-endpoint"
|
|
4437
|
+
})], Q.prototype, "pollEndpoint", void 0), T([h({ type: Number })], Q.prototype, "pollInterval", void 0), T([h({ type: Number })], Q.prototype, "maxPollAttempts", void 0), T([h({ attribute: !1 })], Q.prototype, "client", void 0), T([h({ attribute: !1 })], Q.prototype, "customRequest", void 0), T([h({ attribute: !1 })], Q.prototype, "customUploadRequest", void 0), T([g()], Q.prototype, "phase", void 0), T([g()], Q.prototype, "taskId", void 0), T([g()], Q.prototype, "progress", void 0), T([g()], Q.prototype, "result", void 0), T([g()], Q.prototype, "error", void 0), Q = T([i("lc-task-workflow")], Q);
|
|
4438
|
+
function Jt(e) {
|
|
4439
|
+
return e.name || e.getAttribute("name") || "";
|
|
4440
|
+
}
|
|
4441
|
+
function Yt(e) {
|
|
4442
|
+
let t = e.value;
|
|
4443
|
+
if (t !== void 0) return t;
|
|
4444
|
+
if (e.hasAttribute("value")) return e.getAttribute("value") ?? "";
|
|
4445
|
+
}
|
|
4446
|
+
function Xt(e) {
|
|
4447
|
+
return e.file || Yt(e);
|
|
4448
|
+
}
|
|
4449
|
+
function Zt(e) {
|
|
4450
|
+
let t = e.detail;
|
|
4451
|
+
if (t) {
|
|
4452
|
+
if ("value" in t) return t.value;
|
|
4453
|
+
if ("file" in t) return t.file;
|
|
4454
|
+
}
|
|
4455
|
+
}
|
|
4456
|
+
function Qt(e) {
|
|
4457
|
+
try {
|
|
4458
|
+
let t = JSON.parse(e);
|
|
4459
|
+
if (Array.isArray(t)) return t.map(String);
|
|
4460
|
+
} catch {}
|
|
4461
|
+
return e.split(",").map((e) => e.trim()).filter(Boolean);
|
|
4462
|
+
}
|
|
4463
|
+
//#endregion
|
|
4464
|
+
//#region src/components/button/button.ts
|
|
4465
|
+
var $ = class extends e {
|
|
4466
|
+
constructor(...e) {
|
|
4467
|
+
super(...e), this.type = "button", this.variant = "primary", this.disabled = !1;
|
|
4468
|
+
}
|
|
4469
|
+
static {
|
|
4470
|
+
this.styles = t`
|
|
4471
|
+
:host {
|
|
4472
|
+
display: inline-block;
|
|
4473
|
+
--lc-button-bg: var(--lc-color-primary);
|
|
4474
|
+
--lc-button-bg-hover: var(--lc-color-primary-hover);
|
|
4475
|
+
--lc-button-color: #fff;
|
|
4476
|
+
--lc-button-border: 1px solid var(--lc-color-primary);
|
|
4477
|
+
--lc-button-radius: var(--lc-radius-component);
|
|
4478
|
+
--lc-button-padding: var(--lc-spacing-2) var(--lc-spacing-4);
|
|
4479
|
+
}
|
|
4480
|
+
|
|
4481
|
+
button {
|
|
4482
|
+
display: inline-flex;
|
|
4483
|
+
align-items: center;
|
|
4484
|
+
justify-content: center;
|
|
4485
|
+
gap: var(--lc-spacing-2);
|
|
4486
|
+
min-height: 36px;
|
|
4487
|
+
padding: var(--lc-button-padding);
|
|
4488
|
+
border: var(--lc-button-border);
|
|
4489
|
+
border-radius: var(--lc-button-radius);
|
|
4490
|
+
background: var(--lc-button-bg);
|
|
4491
|
+
color: var(--lc-button-color);
|
|
4492
|
+
font: inherit;
|
|
4493
|
+
font-family: var(--lc-font-family);
|
|
4494
|
+
cursor: pointer;
|
|
4495
|
+
transition: background var(--lc-transition-fast), border-color var(--lc-transition-fast), opacity var(--lc-transition-fast);
|
|
4496
|
+
}
|
|
4497
|
+
|
|
4498
|
+
button:hover:not(:disabled) {
|
|
4499
|
+
background: var(--lc-button-bg-hover);
|
|
4500
|
+
}
|
|
4501
|
+
|
|
4502
|
+
button:disabled {
|
|
4503
|
+
opacity: 0.5;
|
|
4504
|
+
cursor: not-allowed;
|
|
4505
|
+
}
|
|
4506
|
+
|
|
4507
|
+
:host([variant='secondary']) {
|
|
4508
|
+
--lc-button-bg: var(--lc-color-bg);
|
|
4509
|
+
--lc-button-bg-hover: var(--lc-color-bg-secondary);
|
|
4510
|
+
--lc-button-color: var(--lc-color-text);
|
|
4511
|
+
--lc-button-border: 1px solid var(--lc-color-border);
|
|
4512
|
+
}
|
|
4513
|
+
`;
|
|
4514
|
+
}
|
|
4515
|
+
handleClick(e) {
|
|
4516
|
+
e.stopPropagation(), !this.disabled && this.dispatchEvent(new MouseEvent("click", {
|
|
4517
|
+
bubbles: !0,
|
|
4518
|
+
composed: !0,
|
|
4519
|
+
cancelable: !0
|
|
4520
|
+
}));
|
|
4521
|
+
}
|
|
4522
|
+
render() {
|
|
4523
|
+
return n`
|
|
4524
|
+
<button type=${this.type} ?disabled=${this.disabled} part="button" @click=${this.handleClick}>
|
|
4525
|
+
<slot></slot>
|
|
4526
|
+
</button>
|
|
4527
|
+
`;
|
|
4528
|
+
}
|
|
4529
|
+
};
|
|
4530
|
+
T([h({ type: String })], $.prototype, "type", void 0), T([h({
|
|
4531
|
+
type: String,
|
|
4532
|
+
reflect: !0
|
|
4533
|
+
})], $.prototype, "variant", void 0), T([h({ type: Boolean })], $.prototype, "disabled", void 0), $ = T([i("lc-button")], $);
|
|
4534
|
+
//#endregion
|
|
4535
|
+
export { be as $, Je as A, Ie as B, x as C, Ve as D, je as E, Be as F, Ye as G, Ge as H, Ke as I, Te as J, qe as K, Pe as L, Re as M, We as N, Fe as O, C as P, v as Q, S as R, De as S, ke as T, Ne as U, ze as V, w as W, Oe as X, Ee as Y, y as Z, D as _, Y as a, _e as at, Ce as b, Rt as c, q as d, Se as et, K as f, O as g, k as h, Vt as i, _ as it, Ue as j, Me as k, Lt as l, W as m, Q as n, ye as nt, Bt as o, G as p, He as q, Wt as r, ve as rt, zt as s, $ as t, xe as tt, J as u, E as v, b as w, we as x, Ae as y, Le as z };
|