light-chain-open-ui 1.0.6 → 1.0.7

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/README.md CHANGED
@@ -1,224 +1,233 @@
1
- # light-chain-open-ui
2
-
3
- LightChain Open UI 是一组用于发起 AI 任务 workflow 的 Web Components、React 组件和前端任务客户端。
4
-
5
- 它适合两种接入方式:
6
-
7
- - 使用 `lc-task-workflow` / `LcTaskWorkflowReact` 自动收集表单、校验字段、提交任务和轮询结果。
8
- - 使用 `LightChainClient` 手动提交多个任务,并让同一个客户端合并轮询。
9
-
10
- ## 安装
11
-
12
- ```bash
13
- npm install light-chain-open-ui
14
- ```
15
-
16
- React 项目需要同时安装 React:
17
-
18
- ```bash
19
- npm install react react-dom
20
- ```
21
-
22
- ## 导入入口
23
-
24
- ```ts
25
- import 'light-chain-open-ui'
26
- import { LightChainClient } from 'light-chain-open-ui'
27
- import { LcTaskWorkflowReact } from 'light-chain-open-ui/react'
28
- import { OPTIONS_ASPECT_RATIO } from 'light-chain-open-ui/options'
29
- import { TASK_WORKFLOW_TYPES } from 'light-chain-open-ui/contants'
30
- import type { TaskWorkflowType } from 'light-chain-open-ui/types'
31
- ```
32
-
33
- 入口说明:
34
-
35
- - `light-chain-open-ui`:注册 Web Components,并导出 `LightChainClient` 等核心能力。
36
- - `light-chain-open-ui/react`:导出 React 封装组件。
37
- - `light-chain-open-ui/options`:导出可选值参数,例如 `OPTIONS_ASPECT_RATIO`、`OPTIONS_GENDER`。
38
- - `light-chain-open-ui/contants`:导出常量,例如 `TASK_WORKFLOW_TYPES`、`WORKFLOW_DEFAULTS`。
39
- - `light-chain-open-ui/types`:导出 TypeScript 类型。
40
-
41
- ## React 自动任务
42
-
43
- 自动任务适合单个独立任务。组件内部会创建任务客户端,收集子组件字段并完成提交和轮询。
44
-
45
- ```tsx
46
- import {
47
- LcButtonReact,
48
- LcImageUploaderReact,
49
- LcPromptInputReact,
50
- LcTaskWorkflowReact,
51
- } from 'light-chain-open-ui/react'
52
- import { TASK_WORKFLOW_TYPES } from 'light-chain-open-ui/contants'
53
-
54
- export function FixFaceForm() {
55
- return (
56
- <LcTaskWorkflowReact
57
- type={TASK_WORKFLOW_TYPES.FIX_FACE}
58
- customRequest={customRequest}
59
- customUploadRequest={customUploadRequest}
60
- onSubmit={(event) => console.log(event.detail.taskId)}
61
- onSuccess={(event) => console.log(event.detail.images)}
62
- onError={(event) => console.error(event.detail.message)}
63
- >
64
- <LcImageUploaderReact name="imgUrl" label="模特图" required />
65
- <LcPromptInputReact name="prompt" label="修复要求" maxLength={500} />
66
- <LcButtonReact type="submit">开始生成</LcButtonReact>
67
- </LcTaskWorkflowReact>
68
- )
69
- }
70
- ```
71
-
72
- ## 原生/Vue 自动任务
73
-
74
- Web Components 通过属性和 DOM property 配置。函数类型参数需要通过 property 赋值。
75
-
76
- ```ts
77
- import 'light-chain-open-ui'
78
- import { TASK_WORKFLOW_TYPES } from 'light-chain-open-ui/contants'
79
-
80
- const workflow = document.querySelector('lc-task-workflow')
81
-
82
- workflow.type = TASK_WORKFLOW_TYPES.FIX_FACE
83
- workflow.customRequest = customRequest
84
- workflow.customUploadRequest = customUploadRequest
85
-
86
- workflow.addEventListener('success', (event) => {
87
- console.log(event.detail.images)
88
- })
89
- ```
90
-
91
- ```html
92
- <lc-task-workflow>
93
- <lc-image-uploader name="imgUrl" label="模特图" required></lc-image-uploader>
94
- <lc-prompt-input name="prompt" label="修复要求"></lc-prompt-input>
95
- <lc-button type="submit">开始生成</lc-button>
96
- </lc-task-workflow>
97
- ```
98
-
99
- ## 手动任务客户端
100
-
101
- 手动模式适合批量任务或跨页面共享任务状态。`LightChainClient` 建议只创建一次,多个 `submit(type, formData)` 会基于同一个客户端合并轮询。
102
-
103
- ```ts
104
- import { LightChainClient } from 'light-chain-open-ui'
105
- import { TASK_WORKFLOW_TYPES } from 'light-chain-open-ui/contants'
106
-
107
- const client = new LightChainClient({
108
- customRequest,
109
- customUploadRequest,
110
- onSubmit: ({ taskId }) => console.log('submitted', taskId),
111
- onPoll: ({ taskId, progress }) => console.log('polling', taskId, progress),
112
- onSuccess: ({ taskId, images }) => console.log('success', taskId, images),
113
- onError: ({ message }) => console.error(message),
114
- })
115
-
116
- await client.submit(TASK_WORKFLOW_TYPES.FIX_FACE, {
117
- imgUrl: 'https://example.com/model.png',
118
- prompt: '修复面部细节',
119
- })
120
-
121
- await client.submit(TASK_WORKFLOW_TYPES.SR, {
122
- imgUrl: 'https://example.com/image.png',
123
- scale: '2',
124
- })
125
- ```
126
-
127
- ## 自定义请求
128
-
129
- `customRequest` 用于接入业务后端。组件会根据 `type` 自动生成提交地址,例如 `/task/submit/FixFace`。
130
-
131
- ```ts
132
- const customRequest = async (input: RequestInfo | URL, init?: RequestInit) => {
133
- const endpoint = typeof input === 'string' ? input : input.toString()
134
- const url = new URL(endpoint, 'https://api.example.com')
135
-
136
- return fetch(url.toString(), {
137
- ...init,
138
- headers: {
139
- ...init?.headers,
140
- 'client-secret': getClientSecret(),
141
- },
142
- })
143
- }
144
- ```
145
-
146
- `customUploadRequest` 用于把 `File` 上传成 URL,再提交给任务接口。
147
-
148
- ```ts
149
- const customUploadRequest = async ({ formData }) => {
150
- const response = await fetch('/upload', {
151
- method: 'POST',
152
- body: formData,
153
- })
154
- const data = await response.json()
155
- return data.url
156
- }
157
- ```
158
-
159
- ## 枚举参数
160
-
161
- 枚举选择器可以直接使用 `light-chain-open-ui/options` 导出的参数。
162
-
163
- ```tsx
164
- import { LcEnumSelectorReact } from 'light-chain-open-ui/react'
165
- import { OPTIONS_ASPECT_RATIO } from 'light-chain-open-ui/options'
166
-
167
- <LcEnumSelectorReact
168
- name="aspectRatio"
169
- label="宽高比"
170
- mode="select"
171
- options={OPTIONS_ASPECT_RATIO}
172
- />
173
- ```
174
-
175
- ## 主题
176
-
177
- 默认样式会随组件一起工作。需要切换暗色主题时,引入主题样式并在页面上添加主题标记。
178
-
179
- ```ts
180
- import 'light-chain-open-ui/styles/themes/default.css'
181
- import 'light-chain-open-ui/styles/themes/dark.css'
182
-
183
- document.documentElement.dataset.theme = 'dark'
184
- ```
185
-
186
- ## 后端接入约定
187
-
188
- 前端提交任务后,业务后端应立即调用外部 AI 接口、落库任务记录,并返回任务 ID。前端随后通过轮询接口获取任务状态。
189
-
190
- 推荐接口:
191
-
192
- - `POST /task/submit/{type}`:根据 `type` 调用对应外部接口,创建任务记录,返回 `{ code, success, data: { taskId } }`。
193
- - `GET /task/progress?taskIds=a,b,c`:批量查询任务状态,返回 `{ code, success, data: TaskProgressResult[] }`。
194
-
195
- 响应示例:
196
-
197
- ```json
198
- {
199
- "code": 200,
200
- "success": true,
201
- "data": {
202
- "taskId": "task_123"
203
- }
204
- }
205
- ```
206
-
207
- 进度结果示例:
208
-
209
- ```json
210
- {
211
- "code": 200,
212
- "success": true,
213
- "data": [
214
- {
215
- "aiTaskId": "task_123",
216
- "aiTaskStatus": "done",
217
- "queuePos": null,
218
- "taskProgress": 1,
219
- "aiTaskResult": null,
220
- "imgInfo": "https://example.com/result.png"
221
- }
222
- ]
223
- }
224
- ```
1
+ # light-chain-open-ui
2
+
3
+ LightChain Open UI 是一组用于发起 AI 任务 workflow 的 Web Components、React 组件和前端任务客户端。
4
+
5
+ 它适合两种接入方式:
6
+
7
+ - 使用 `lc-task-workflow` / `LcTaskWorkflowReact` 自动收集表单、校验字段、提交任务和轮询结果。
8
+ - 使用 `LightChainClient` 手动提交多个任务,并让同一个客户端合并轮询。
9
+
10
+ ## 安装
11
+
12
+ ```bash
13
+ npm install light-chain-open-ui
14
+ ```
15
+
16
+ ## 导入入口
17
+
18
+ ```ts
19
+ import 'light-chain-open-ui'
20
+ import { LightChainClient } from 'light-chain-open-ui'
21
+ import { LcTaskWorkflowReact } from 'light-chain-open-ui/react'
22
+ import { OPTIONS_ASPECT_RATIO } from 'light-chain-open-ui/options'
23
+ import { TASK_WORKFLOW_TYPES } from 'light-chain-open-ui/contants'
24
+ import type { TaskWorkflowType } from 'light-chain-open-ui/types'
25
+ ```
26
+
27
+ 入口说明:
28
+
29
+ - `light-chain-open-ui`:注册 Web Components,并导出 `LightChainClient` 等核心能力。
30
+ - `light-chain-open-ui/react`:导出 React 封装组件。
31
+ - `light-chain-open-ui/options`:导出可选值参数,例如 `OPTIONS_ASPECT_RATIO`、`OPTIONS_GENDER`。
32
+ - `light-chain-open-ui/contants`:导出常量,例如 `TASK_WORKFLOW_TYPES`、`WORKFLOW_DEFAULTS`。
33
+ - `light-chain-open-ui/types`:导出 TypeScript 类型。
34
+
35
+ ## React 自动任务
36
+
37
+ 自动任务适合单个独立任务。组件内部会创建任务客户端,收集子组件字段并完成提交和轮询。
38
+
39
+ ```tsx
40
+ import {
41
+ LcButtonReact,
42
+ LcImageUploaderReact,
43
+ LcPromptInputReact,
44
+ LcTaskWorkflowReact,
45
+ } from 'light-chain-open-ui/react'
46
+ import { TASK_WORKFLOW_TYPES } from 'light-chain-open-ui/contants'
47
+
48
+ export function FixFaceForm() {
49
+ return (
50
+ <LcTaskWorkflowReact
51
+ type={TASK_WORKFLOW_TYPES.FIX_FACE}
52
+ customRequest={customRequest}
53
+ customUploadRequest={customUploadRequest}
54
+ onSubmit={(event) => console.log(event.detail.taskId)}
55
+ onSuccess={(event) => console.log(event.detail.images)}
56
+ onError={(event) => console.error(event.detail.message)}
57
+ >
58
+ <LcImageUploaderReact name="imgUrl" label="模特图" required />
59
+ <LcPromptInputReact name="prompt" label="修复要求" maxLength={500} />
60
+ <LcButtonReact type="submit">开始生成</LcButtonReact>
61
+ </LcTaskWorkflowReact>
62
+ )
63
+ }
64
+ ```
65
+
66
+ ## 原生/Vue 自动任务
67
+
68
+ Web Components 通过属性和 DOM property 配置。函数类型参数需要通过 property 赋值。
69
+
70
+ ```ts
71
+ import 'light-chain-open-ui'
72
+ import { TASK_WORKFLOW_TYPES } from 'light-chain-open-ui/contants'
73
+
74
+ const workflow = document.querySelector('lc-task-workflow')
75
+
76
+ workflow.type = TASK_WORKFLOW_TYPES.FIX_FACE
77
+ workflow.customRequest = customRequest
78
+ workflow.customUploadRequest = customUploadRequest
79
+
80
+ workflow.addEventListener('success', (event) => {
81
+ console.log(event.detail.images)
82
+ })
83
+ ```
84
+
85
+ ```html
86
+ <lc-task-workflow>
87
+ <lc-image-uploader name="imgUrl" label="模特图" required></lc-image-uploader>
88
+ <lc-prompt-input name="prompt" label="修复要求"></lc-prompt-input>
89
+ <lc-button type="submit">开始生成</lc-button>
90
+ </lc-task-workflow>
91
+ ```
92
+
93
+ ## 手动任务客户端
94
+
95
+ 手动模式适合批量任务或跨页面共享任务状态。`LightChainClient` 建议只创建一次,多个 `submit(type, formData)` 会基于同一个客户端合并轮询。
96
+
97
+ ```ts
98
+ import { LightChainClient } from 'light-chain-open-ui'
99
+ import { TASK_WORKFLOW_TYPES } from 'light-chain-open-ui/contants'
100
+
101
+ const client = new LightChainClient({
102
+ customRequest,
103
+ customUploadRequest,
104
+ onSubmit: ({ taskId }) => console.log('submitted', taskId),
105
+ onPoll: ({ taskId, progress }) => console.log('polling', taskId, progress),
106
+ onSuccess: ({ taskId, images }) => console.log('success', taskId, images),
107
+ onError: ({ message }) => console.error(message),
108
+ })
109
+
110
+ await client.submit(TASK_WORKFLOW_TYPES.FIX_FACE, {
111
+ imgUrl: 'https://example.com/model.png',
112
+ prompt: '修复面部细节',
113
+ })
114
+
115
+ await client.submit(TASK_WORKFLOW_TYPES.SR, {
116
+ imgUrl: 'https://example.com/image.png',
117
+ scale: '2',
118
+ })
119
+ ```
120
+
121
+ ## 自定义请求
122
+
123
+ `customRequest` 用于接入业务后端。组件会根据 `type` 自动生成提交地址,例如 `/task/submit/FixFace`。
124
+ `customRequest` 只约定函数入参和返回结构,不限制内部用什么请求库。第一个参数是请求地址,第二个参数是请求数据;轮询请求没有请求数据。
125
+
126
+ ```ts
127
+ const customRequest = async (url: string, data?: Record<string, unknown>) => {
128
+ const endpoint = new URL(url, 'https://api.example.com')
129
+
130
+ return fetch(endpoint.toString(), {
131
+ method: data === undefined ? 'GET' : 'POST',
132
+ body: data === undefined ? undefined : JSON.stringify(data),
133
+ headers: {
134
+ 'content-type': 'application/json',
135
+ 'client-secret': getClientSecret(),
136
+ },
137
+ })
138
+ }
139
+ ```
140
+
141
+ 也可以使用 axios、umi-request 或业务封装请求。只要返回值符合 `{ data }`、`{ code, success, data }`,或 axios 风格 `{ data: { code, success, data } }` 即可:
142
+
143
+ ```ts
144
+ const customRequest = (url: string, data?: Record<string, unknown>) => {
145
+ return request(url, {
146
+ method: data === undefined ? 'GET' : 'POST',
147
+ data,
148
+ })
149
+ }
150
+ ```
151
+
152
+ `customUploadRequest` 用于把 `File` 上传成 URL,再提交给任务接口。
153
+
154
+ ```ts
155
+ const customUploadRequest = async (file: File) => {
156
+ const formData = new FormData()
157
+ formData.append('file', file)
158
+
159
+ const response = await fetch('/upload', {
160
+ method: 'POST',
161
+ body: formData,
162
+ })
163
+ const data = await response.json()
164
+ return data.url
165
+ }
166
+ ```
167
+
168
+ ## 枚举参数
169
+
170
+ 枚举选择器可以直接使用 `light-chain-open-ui/options` 导出的参数。
171
+
172
+ ```tsx
173
+ import { LcEnumSelectorReact } from 'light-chain-open-ui/react'
174
+ import { OPTIONS_ASPECT_RATIO } from 'light-chain-open-ui/options'
175
+
176
+ <LcEnumSelectorReact
177
+ name="aspectRatio"
178
+ label="宽高比"
179
+ mode="select"
180
+ options={OPTIONS_ASPECT_RATIO}
181
+ />
182
+ ```
183
+
184
+ ## 主题
185
+
186
+ 默认样式会随组件一起工作。需要切换暗色主题时,引入主题样式并在页面上添加主题标记。
187
+
188
+ ```ts
189
+ import 'light-chain-open-ui/styles/themes/default.css'
190
+ import 'light-chain-open-ui/styles/themes/dark.css'
191
+
192
+ document.documentElement.dataset.theme = 'dark'
193
+ ```
194
+
195
+ ## 后端接入约定
196
+
197
+ 前端提交任务后,业务后端应立即调用外部 AI 接口、落库任务记录,并返回任务 ID。前端随后通过轮询接口获取任务状态。
198
+
199
+ 推荐接口:
200
+
201
+ - `POST /task/submit/{type}`:根据 `type` 调用对应外部接口,创建任务记录,返回 `{ code, success, data: { taskId } }`。
202
+ - `GET /task/progress?taskIds=a,b,c`:批量查询任务状态,返回 `{ code, success, data: TaskProgressResult[] }`。
203
+
204
+ 响应示例:
205
+
206
+ ```json
207
+ {
208
+ "code": 200,
209
+ "success": true,
210
+ "data": {
211
+ "taskId": "task_123"
212
+ }
213
+ }
214
+ ```
215
+
216
+ 进度结果示例:
217
+
218
+ ```json
219
+ {
220
+ "code": 200,
221
+ "success": true,
222
+ "data": [
223
+ {
224
+ "aiTaskId": "task_123",
225
+ "aiTaskStatus": "done",
226
+ "queuePos": null,
227
+ "taskProgress": 1,
228
+ "aiTaskResult": null,
229
+ "imgInfo": "https://example.com/result.png"
230
+ }
231
+ ]
232
+ }
233
+ ```
@@ -1,4 +1,4 @@
1
- import { l as e, t } from "./client-jorIw6pH.js";
1
+ import { l as e, t } from "./client-CxZI36n6.js";
2
2
  import { N as n, P as r, o as i } from "./constants-CdudjmSn.js";
3
3
  import { LitElement as a, css as o, html as s, nothing as c } from "lit";
4
4
  //#region src/styles/register-theme.ts
@@ -1,4 +1,4 @@
1
- const e=require(`./client-CJ8X0sFi.cjs`),t=require(`./constants-Bdlwi9VJ.cjs`);require(`./react.cjs`);let n=require(`lit`);var r=`light-chain-open-ui-theme`,i=`
1
+ const e=require(`./client-BnY0dpeN.cjs`),t=require(`./constants-Bdlwi9VJ.cjs`);require(`./react.cjs`);let n=require(`lit`);var r=`light-chain-open-ui-theme`,i=`
2
2
  :root {
3
3
  --lc-color-blue-50: #eff6ff;
4
4
  --lc-color-blue-100: #dbeafe;
@@ -1 +1 @@
1
- const e=require(`./constants-Bdlwi9VJ.cjs`);var t={RUNNING:`running`,DONE:`done`},n={DONE:`done`,EXCEPTION:`exception`},r={MAX_SIZE_MB:10,MAX_WIDTH:2048,MAX_HEIGHT:2048,ASPECT_RATIO_MIN:1/3,ASPECT_RATIO_MAX:3},i=[`1:1`,`2:3`,`3:4`,`3:2`,`4:3`,`9:16`,`16:9`];function a(e){let t=[];e.size>r.MAX_SIZE_MB*1024*1024&&t.push(`图片大小不能超过10MB`),(e.width>r.MAX_WIDTH||e.height>r.MAX_HEIGHT)&&t.push(`图片分辨率不能超过2048x2048`);let n=e.width/e.height;return(n<r.ASPECT_RATIO_MIN||n>r.ASPECT_RATIO_MAX)&&t.push(`宽高比必须在1:3到3:1之间`),{valid:t.length===0,errors:t}}function o(e,t){let n=[];return(e.width!==t.width||e.height!==t.height)&&n.push(`蒙版尺寸必须与原图尺寸相同`),{valid:n.length===0,errors:n}}async function s(e){let t=e.size<=r.MAX_SIZE_MB*1024*1024;return new Promise(n=>{let i=new Image,a=URL.createObjectURL(e);i.onload=()=>{URL.revokeObjectURL(a);let e=[];(i.width>r.MAX_WIDTH||i.height>r.MAX_HEIGHT)&&e.push(`图片分辨率不能超过2048x2048`);let o=i.width/i.height;(o<r.ASPECT_RATIO_MIN||o>r.ASPECT_RATIO_MAX)&&e.push(`宽高比必须在1:3到3:1之间`),t||e.push(`图片大小不能超过10MB`),n({valid:e.length===0,errors:e})},i.onerror=()=>{URL.revokeObjectURL(a),n({valid:!1,errors:[`无法加载图片`]})},i.src=a})}var c={GeneratePrinting:{key:`GeneratePrinting`,title:`图案设计`,description:`上传1-2张灵感素材图进行融合发散设计`,fields:[{name:`imgUrlList`,label:`灵感素材图`,type:`images`,required:!0,hint:`上传1-2张灵感素材图`},{name:`prompt`,label:`图案风格`,type:`text`,required:!0,placeholder:`描述想要的图案风格`},{name:`aspectRatio`,label:`比例`,type:`aspectRatio`}]},VirtualFitting:{key:`VirtualFitting`,title:`AI试衣`,description:`上传服装图片生成模特上身效果图`,fields:[{name:`imgUrl`,label:`上装图片`,type:`image`,required:!0,hint:`挂拍图/人台图/平铺图`},{name:`lowerImgUrl`,label:`下装图片`,type:`image`},{name:`prompt`,label:`试衣需求`,type:`text`,placeholder:`描述试衣需求`},{name:`aspectRatio`,label:`比例`,type:`aspectRatio`}]},FixFace:{key:`FixFace`,title:`面部优化`,description:`智能修复模特脸部畸形`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0}]},ChangeFace:{key:`ChangeFace`,title:`面部替换`,description:`上传指定面部图片替换模特面容`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`refImgUrl`,label:`参考面部图`,type:`image`,required:!0}]},MultiPerspective:{key:`MultiPerspective`,title:`多视角`,description:`生成不同角度的展示效果图`,fields:[{name:`imgUrl`,label:`图片`,type:`image`,required:!0},{name:`perspective`,label:`视角`,type:`enum`,required:!0,options:e.b}]},PrintingTiling:{key:`PrintingTiling`,title:`图案印染上身`,description:`将指定图案虚拟印染到款式图上`,fields:[{name:`imgUrl`,label:`款式图`,type:`image`,required:!0},{name:`maskUrl`,label:`蒙版`,type:`mask`},{name:`printingImgUrl`,label:`印花图案`,type:`image`,required:!0},{name:`prompt`,label:`印染需求`,type:`text`,placeholder:`描述印染需求`}]},ChangeDesignPoint:{key:`ChangeDesignPoint`,title:`设计点修改`,description:`通过参考图实现设计点修改或融合`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`蒙版`,type:`mask`},{name:`refImgUrl`,label:`参考图`,type:`image`},{name:`prompt`,label:`修改需求`,type:`text`,placeholder:`描述修改需求`}]},ChangeColor:{key:`ChangeColor`,title:`服装改色`,description:`自定义区域一键换色`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`改色区域蒙版`,type:`mask`,required:!0},{name:`hexCode`,label:`目标颜色`,type:`color`,required:!0}]},ChangeFabric:{key:`ChangeFabric`,title:`面料上身`,description:`将指定面料一键上身到款式图`,fields:[{name:`imgUrl`,label:`款式图/模特图`,type:`image`,required:!0},{name:`maskUrl`,label:`蒙版`,type:`mask`,required:!0},{name:`fabricImgUrl`,label:`面料图`,type:`image`,required:!0}]},Sr:{key:`Sr`,title:`高清放大`,description:`无损高清放大与细节强化`,fields:[{name:`imgUrl`,label:`图片`,type:`image`,required:!0},{name:`scale`,label:`放大倍数`,type:`enum`,required:!0,options:e.T}]},VectorConvert:{key:`VectorConvert`,title:`矢量图转换`,description:`生成可编辑的矢量格式文件`,fields:[{name:`imgUrl`,label:`图片`,type:`image`,required:!0},{name:`patternType`,label:`图案类型`,type:`enum`,required:!0,options:e.y}]},ChangeModel:{key:`ChangeModel`,title:`模特更换`,description:`一键更换模特并支持自定义选择`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`gender`,label:`性别`,type:`enum`,options:e.g},{name:`age`,label:`年龄`,type:`enum`,options:e.u},{name:`race`,label:`人种`,type:`enum`,options:e.S}]},GenerateSketch:{key:`GenerateSketch`,title:`平铺图转线稿`,description:`上传平铺图生成线稿`,fields:[{name:`imgUrl`,label:`平铺图`,type:`image`,required:!0}]},ModelGenerateSketch:{key:`ModelGenerateSketch`,title:`模特图转线稿`,description:`上传模特图生成线稿`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`position`,label:`服装位置`,type:`enum`,options:e.x}]},Eliminate:{key:`Eliminate`,title:`AI消除`,description:`一键消除指定元素`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`消除区域蒙版`,type:`mask`,required:!0}]},ExpandImage:{key:`ExpandImage`,title:`AI扩图`,description:`一键扩充人物或背景`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`扩图区域蒙版`,type:`mask`,required:!0}]},ClothingDesign:{key:`ClothingDesign`,title:`AI创款`,description:`根据灵感图快速创款`,fields:[{name:`imgUrlList`,label:`灵感款式图`,type:`images`,hint:`上传1-3张灵感图`},{name:`fabricImgUrl`,label:`面料图`,type:`image`,hint:`上传面料图进行面料创款`},{name:`words`,label:`创款需求`,type:`text`,placeholder:`描述创款需求`},{name:`aspectRatio`,label:`比例`,type:`aspectRatio`}]},ChangePattern:{key:`ChangePattern`,title:`服装改版`,description:`通过选择部位和版型修改服装版型`,fields:[{name:`imgUrl`,label:`服装图`,type:`image`,required:!0},{name:`detailList`,label:`改版部位`,type:`multiEnum`,required:!0,options:e.m}]},GenerateModel:{key:`GenerateModel`,title:`定制模特`,description:`生成符合需求的虚拟模特`,fields:[{name:`imgUrlList`,label:`参考图片`,type:`images`,required:!0,hint:`上传1-10张带面容的图片`},{name:`gender`,label:`性别`,type:`enum`,required:!0,options:e.g},{name:`race`,label:`人种`,type:`enum`,options:e.S}]},ModifyPrinting:{key:`ModifyPrinting`,title:`图案修改`,description:`上传图案和参考图AI修改`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`refImgUrl`,label:`参考图`,type:`image`},{name:`maskUrl`,label:`蒙版`,type:`mask`},{name:`prompt`,label:`修改需求`,type:`text`,placeholder:`描述修改需求`}]},CutOut:{key:`CutOut`,title:`智能抠图`,description:`一键抠图修边`,fields:[{name:`imgUrl`,label:`图片`,type:`image`,required:!0},{name:`recognitionType`,label:`识别类型`,type:`enum`,required:!0,options:e.C}]},LineArtToReal:{key:`LineArtToReal`,title:`线稿转实物`,description:`线稿图生成实物效果平铺图`,fields:[{name:`imgUrl`,label:`线稿图`,type:`image`,required:!0},{name:`imageType`,label:`图片类型`,type:`enum`,required:!0,options:e._},{name:`prompt`,label:`款式特征`,type:`text`,placeholder:`描述款式特征`}]},FixPartial:{key:`FixPartial`,title:`局部修复`,description:`修复或重新创造指定区域`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`修复区域蒙版`,type:`mask`,required:!0},{name:`prompt`,label:`修复需求`,type:`text`,placeholder:`描述修复需求`}]},DetailCompensation:{key:`DetailCompensation`,title:`细节补偿`,description:`精准还原服装细节`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`蒙版`,type:`mask`},{name:`refImgUrl`,label:`参考图`,type:`image`}]},ChangeClothesByImg:{key:`ChangeClothesByImg`,title:`服装穿搭调整`,description:`上下装搭配调整`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`changeImgUrl`,label:`搭配服装图`,type:`image`,required:!0}]}},l={ChangeAccessoriesByImg:{key:`ChangeAccessoriesByImg`,title:`配饰穿搭调整`,description:`背包鞋子首饰等搭配调整`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`changeImgUrl`,label:`搭配物品图`,type:`image`,required:!0},{name:`accessoryType`,label:`配件类型`,type:`enum`,required:!0,options:e.l}]},VirtualFittingReference:{key:`VirtualFittingReference`,title:`AI试衣参考图模式`,description:`上传模特参考图生成试衣效果`,fields:[{name:`imgUrl`,label:`服装图片`,type:`image`,required:!0},{name:`refImgUrl`,label:`模特参考图`,type:`image`,required:!0}]},VirtualFittingTemplate:{key:`VirtualFittingTemplate`,title:`AI试衣模板模式`,description:`选择试衣场景模板`,fields:[{name:`imgUrl`,label:`服装图片`,type:`image`,required:!0},{name:`templateId`,label:`试衣模板`,type:`enum`,required:!0,options:e.k}]},FixDeformities:{key:`FixDeformities`,title:`畸形修复`,description:`修复手部脚部脸部畸形`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`maskUrl`,label:`修复区域蒙版`,type:`mask`,required:!0}]},IntelligentCropping:{key:`IntelligentCropping`,title:`AI智能裁图`,description:`自定义像素或比例裁图`,fields:[{name:`imgUrl`,label:`图片`,type:`image`,required:!0},{name:`mode`,label:`裁剪模式`,type:`enum`,required:!0,options:e.p},{name:`x`,label:`X坐标`,type:`number`},{name:`y`,label:`Y坐标`,type:`number`},{name:`width`,label:`宽度`,type:`number`},{name:`height`,label:`高度`,type:`number`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},ModelToFlat:{key:`ModelToFlat`,title:`模特转平铺`,description:`模特图生成平铺图效果`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`position`,label:`服装位置`,type:`enum`,required:!0,options:e.x}]},GenerateShortVideo:{key:`GenerateShortVideo`,title:`短视频生成`,description:`上传图片生成短视频`,fields:[{name:`imgUrl`,label:`首帧图片`,type:`image`,required:!0},{name:`tailImgUrl`,label:`尾帧图片`,type:`image`},{name:`prompt`,label:`文本指令`,type:`text`,placeholder:`描述视频内容`},{name:`duration`,label:`时长`,type:`enum`,required:!0,options:e.h}]},OneClickModifyPrinting:{key:`OneClickModifyPrinting`,title:`一键改图案`,description:`通过文本或参考图一键更改图案`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`refImgUrl`,label:`参考图`,type:`image`},{name:`prompt`,label:`文本指令`,type:`text`,placeholder:`描述图案修改需求`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},OrientationDesign:{key:`OrientationDesign`,title:`服装定向设计`,description:`通过设计点对服装进行定向设计`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`蒙版1`,type:`mask`},{name:`refImgUrl`,label:`参考图1`,type:`image`},{name:`prompt`,label:`文本指令1`,type:`text`,placeholder:`描述设计需求`}]},DirectionalIntegration:{key:`DirectionalIntegration`,title:`定向融合`,description:`通过融合设计点对服装进行融合设计`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`蒙版1`,type:`mask`},{name:`refImgUrl`,label:`参考图1`,type:`image`,required:!0}]},OneClickIntegration:{key:`OneClickIntegration`,title:`一键融合`,description:`通过参考图和文本指令一键融合`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`refImgUrl`,label:`参考图`,type:`image`,required:!0},{name:`prompt`,label:`文本指令`,type:`text`,placeholder:`描述融合需求`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},ChangeFabricV2:{key:`ChangeFabricV2`,title:`面料上身2.0`,description:`支持文本指令的面料上身`,fields:[{name:`imgUrl`,label:`款式图`,type:`image`,required:!0},{name:`maskUrl`,label:`蒙版`,type:`mask`,required:!0},{name:`fabricImgUrl`,label:`面料图`,type:`image`,required:!0},{name:`prompt`,label:`文本指令`,type:`text`,placeholder:`描述调整需求`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},VirtualFittingReferenceV2:{key:`VirtualFittingReferenceV2`,title:`AI试衣参考图2.0`,description:`支持姿势和背景的试衣`,fields:[{name:`imgUrl`,label:`服装图片`,type:`image`,required:!0},{name:`refImgUrl`,label:`模特参考图`,type:`image`,required:!0},{name:`poseImgUrl`,label:`姿势图`,type:`image`},{name:`bgImgUrl`,label:`背景图`,type:`image`},{name:`prompt`,label:`文本指令`,type:`text`,placeholder:`描述试衣需求`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FlowerShapedDesign:{key:`FlowerShapedDesign`,title:`花型创款`,description:`将印花上身到指定款式效果图`,fields:[{name:`imgUrl`,label:`印花图案`,type:`image`,required:!0},{name:`prompt`,label:`文本指令`,type:`text`,required:!0,placeholder:`描述上身效果需求`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FlowerShapedVirtualPrinting:{key:`FlowerShapedVirtualPrinting`,title:`花型上身`,description:`将图案上身到款式图指定区域`,fields:[{name:`imgUrl`,label:`印花图案`,type:`image`,required:!0},{name:`bodyImgUrl`,label:`上身图`,type:`image`,required:!0},{name:`bodyMaskImgUrl`,label:`目标区域蒙版`,type:`mask`,required:!0},{name:`removePattern`,label:`是否去除参考图印花`,type:`enum`,options:e.w}]},OneClickChangeColor:{key:`OneClickChangeColor`,title:`一键改色`,description:`整合智能识别与自定义改色`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`hexCode`,label:`目标颜色`,type:`color`},{name:`hexImgUrl`,label:`颜色参考图`,type:`image`},{name:`changeColorArea`,label:`改色区域`,type:`text`,placeholder:`如:上衣`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FittingModelWithLabels:{key:`FittingModelWithLabels`,title:`模特定制标签模式`,description:`通过标签选择生成虚拟模特`,fields:[{name:`gender`,label:`性别`,type:`enum`,required:!0,options:e.g},{name:`age`,label:`年龄`,type:`enum`,options:e.u},{name:`nationality`,label:`国籍`,type:`enum`,options:e.v},{name:`skinColor`,label:`肤色`,type:`enum`,options:e.O},{name:`bodyShape`,label:`身材`,type:`enum`,options:e.f}]},FittingModelCustom:{key:`FittingModelCustom`,title:`模特定制自定义模式`,description:`根据参考图生成虚拟模特`,fields:[{name:`gender`,label:`性别`,type:`enum`,required:!0,options:e.g},{name:`faceRefImgUrl`,label:`脸部参考图`,type:`image`,required:!0},{name:`similarity`,label:`相似度`,type:`enum`,options:e.E},{name:`bodyShapeRefImgUrl`,label:`身材参考图`,type:`image`},{name:`additionalDescription`,label:`附加描述`,type:`text`,placeholder:`附加描述`}]},FittingModelChangeFace:{key:`FittingModelChangeFace`,title:`模特换脸`,description:`对模特图换脸操作`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`refImgUrl`,label:`参考面部图`,type:`image`,required:!0},{name:`similarity`,label:`相似度`,type:`enum`,options:e.E},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FittingModelChangeModel:{key:`FittingModelChangeModel`,title:`模特替换`,description:`随机或指定模特替换`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`gender`,label:`性别`,type:`enum`,options:e.g},{name:`similarity`,label:`相似度`,type:`enum`,options:e.E},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FittingModelChangeBodyShape:{key:`FittingModelChangeBodyShape`,title:`模特身材调整`,description:`通过标签或参考图调整身材`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`bodyShapeRefImgUrl`,label:`身材参考图`,type:`image`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FittingModelChangeClothingSize:{key:`FittingModelChangeClothingSize`,title:`模特尺码调整`,description:`调整模特服装尺码`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`size`,label:`尺码`,type:`enum`,required:!0,options:e.D},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FittingModelChangePosture:{key:`FittingModelChangePosture`,title:`模特姿势调整`,description:`调整模特姿势`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`poseImgUrl`,label:`姿势参考图`,type:`image`,required:!0},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FittingModelChangeBackground:{key:`FittingModelChangeBackground`,title:`模特换背景`,description:`替换模特背景`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`bgImgUrl`,label:`背景参考图`,type:`image`},{name:`prompt`,label:`文本指令`,type:`text`,placeholder:`描述背景需求`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FittingModelChangePerspective:{key:`FittingModelChangePerspective`,title:`模特视角调整`,description:`调整模特视角`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`perspective`,label:`视角`,type:`enum`,required:!0,options:e.b},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},TrainClothingModel:{key:`TrainClothingModel`,title:`服装风格模型训练`,description:`训练自定义服装风格模型`,fields:[{name:`imgUrlList`,label:`训练图片`,type:`images`,required:!0,hint:`建议上传30-50张正面/斜侧面模特图`},{name:`clothingModelName`,label:`模型名称`,type:`text`,required:!0},{name:`enhanceWordList`,label:`加强词`,type:`text`}]}},u={...c,...l};function d(e){return u[e]}function f(){return Object.values(u)}function p(e,t){let n=[];for(let r of t){let t=e[r.name],i=m(r,t);i&&n.push(i)}return{valid:n.length===0,errors:n}}function m(t,n){let r=n==null||n===``;if(t.required&&r)return{field:t.name,label:t.label,message:e.a.FIELD_REQUIRED(t.label)};if(n==null)return null;let i=e=>({field:t.name,label:t.label,message:e(t.label)});switch(t.type){case`image`:case`mask`:if(typeof n!=`string`&&!h(n))return i(e.a.FIELD_STRING);break;case`images`:if(!Array.isArray(n)||n.length===0)return i(e.a.FIELD_ARRAY);if(n.some(e=>(typeof e!=`string`||e===``)&&!h(e)))return i(e.a.FIELD_ARRAY_ELEMENTS);break;case`text`:if(typeof n!=`string`)return i(e.a.FIELD_STRING);if(t.maxLength&&n.length>t.maxLength)return i(n=>e.a.FIELD_MAX_LENGTH(n,t.maxLength));break;case`enum`:if(typeof n!=`string`)return i(e.a.FIELD_STRING);if(t.options&&!t.options.some(e=>e.value===n))return i(e.a.FIELD_ENUM_INVALID);break;case`multiEnum`:if(!Array.isArray(n)||n.length===0)return i(e.a.FIELD_ARRAY);if(n.some(e=>typeof e!=`string`||e===``))return i(e.a.FIELD_ARRAY_ELEMENTS);if(t.options&&n.some(e=>!t.options?.some(t=>t.value===e)))return i(e.a.FIELD_ENUM_INVALID);break;case`color`:if(typeof n!=`string`||!/^#[0-9A-Fa-f]{6}$/.test(n))return i(e.a.FIELD_COLOR_FORMAT);break;case`number`:if(typeof n!=`number`||Number.isNaN(n))return i(e.a.FIELD_NUMBER);break;case`aspectRatio`:case`strength`:break}return null}function h(e){return typeof File<`u`&&e instanceof File}var g=class{constructor(t={}){this.type=``,this.submitEndpoint=`/task/submit`,this.submitEndpointMode=`prefix`,this.pollEndpoint=`/task/progress`,this.pollInterval=1e3,this.maxPollAttempts=120,this.phase=e.P.IDLE,this.taskId=``,this.progress=0,this.result=null,this.error=``,this.activeTasks=new Map,this.pollTimer=null,this.isPollingBatch=!1,this.configure(t)}configure(e){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)}get typeDef(){let e=this.resolvedTaskTypeKey;return e?d(e):void 0}get taskFields(){return this.typeDef?.fields??[]}async submit(t,n){let r=this.createRequestUri(t);if(!r){this.fail(e.a.MISSING_ENDPOINT,e.P.IDLE);return}let i=this.getTaskFields(t);if(i.length>0){let t=p(n,i);if(!t.valid){this.fail(t.errors.map(e=>e.message).join(`; `),e.P.IDLE);return}}this.phase=e.P.SUBMITTING,this.error=``,this.progress=0,this.result=null;try{let e=await this.resolveUploads(n,i),t=(await this.request(r,{method:`POST`,body:JSON.stringify(e),headers:{"Content-Type":`application/json`}})).data.taskId;this.taskId=t;let a={taskId:t,endpoint:r,formData:e};this.onSubmit?.(a),await this.trackTask(t)}catch(t){this.fail(t instanceof Error?t.message:e.a.SUBMIT_FAILED,this.phase)}}reset(){this.phase=e.P.IDLE,this.taskId=``,this.progress=0,this.result=null,this.error=``,this.activeTasks.clear(),this.pollTimer&&=(clearTimeout(this.pollTimer),null)}createRequestUri(e=this.type){return this.submitEndpointMode===`full`?this.submitEndpoint:e?`${this.submitEndpoint}/${e}`:this.submitEndpoint}get resolvedTaskTypeKey(){return _(this.type)}getTaskFields(e){let t=_(e);return t?d(t)?.fields??[]:[]}async resolveUploads(e,t){let n=t.length>0?t.filter(e=>e.type===`image`||e.type===`mask`||e.type===`images`):Object.keys(e).map(e=>({name:e,type:`image`}));if(!n.length)return e;let r={...e};for(let e of n){let t=r[e.name];Array.isArray(t)?r[e.name]=await Promise.all(t.map(t=>this.resolveUploadValue(t,e))):r[e.name]=await this.resolveUploadValue(t,e)}return r}async resolveUploadValue(e,t){if(!v(e))return e;if(!this.customUploadRequest)throw Error(`customUploadRequest is required to upload ${t.name}`);let n=new FormData;return n.append(t.name||`file`,e),y(await this.customUploadRequest({file:e,name:t.name,formData:n,field:t}))}trackTask(t){this.phase=e.P.POLLING;let n=new Promise(e=>{this.activeTasks.set(t,{taskId:t,attempts:0,resolve:e})});return this.ensurePolling(0),n}ensurePolling(e=this.pollInterval){this.pollTimer||this.isPollingBatch||!this.activeTasks.size||(this.pollTimer=setTimeout(()=>{this.pollTimer=null,this.pollActiveTasks()},this.pollInterval))}async pollActiveTasks(){if(!this.activeTasks.size)return;this.isPollingBatch=!0;let t=[...this.activeTasks.keys()];try{let n=`${this.pollEndpoint}?taskIds=${t.map(encodeURIComponent).join(`,`)}`,r=await this.request(n,{method:`GET`}),i=new Map(r.data.map(e=>[e.aiTaskId,e]));t.forEach(t=>{let n=this.activeTasks.get(t);if(!n)return;n.attempts+=1;let r=i.get(t);if(!r){this.failTask(n,e.a.TASK_NOT_FOUND(t));return}this.taskId=t,this.progress=r.taskProgress;let a={taskId:t,progress:r.taskProgress,status:r.aiTaskStatus,queuePos:r.queuePos};if(this.onPoll?.(a),r.aiTaskStatus===`done`){this.result=r;let e={taskId:t,images:r.imgInfo?[{index:0,url:r.imgInfo}]:[],result:r};this.onSuccess?.(e),this.completeTask(n);return}n.attempts>=this.maxPollAttempts&&this.failTask(n,e.a.POLL_TIMEOUT(t))})}catch(t){let n=t instanceof Error?t.message:e.a.POLL_FAILED;[...this.activeTasks.values()].forEach(e=>this.failTask(e,n))}finally{this.isPollingBatch=!1,this.activeTasks.size?(this.phase=e.P.POLLING,this.ensurePolling(this.pollInterval)):this.phase===e.P.POLLING&&(this.phase=this.error?e.P.ERROR:e.P.SUCCESS)}}completeTask(e){this.activeTasks.delete(e.taskId),e.resolve()}failTask(t,n){this.activeTasks.delete(t.taskId),this.fail(n,e.P.POLLING,t.taskId),t.resolve()}async request(e,t){let n=await(this.customRequest??fetch)(e,t);return n&&typeof n.json==`function`?n.json():n}fail(t,n,r){this.phase=e.P.ERROR,this.error=t;let i={message:t,phase:n,taskId:r};this.onError?.(i)}};function _(e){if(!e)return``;if(u[e])return e;let t=e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/[-\s]+/g,`_`).toUpperCase();return u[t]?t:``}function v(e){return typeof File<`u`&&e instanceof File}async function y(e){return e?typeof e==`string`?e:e instanceof Response?y(await e.json()):typeof e.data==`string`?e.data:e.data?e.data.value||e.data.url||``:e.value||e.url||``:``}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return o}});
1
+ const e=require(`./constants-Bdlwi9VJ.cjs`);var t={RUNNING:`running`,DONE:`done`},n={DONE:`done`,EXCEPTION:`exception`},r={MAX_SIZE_MB:10,MAX_WIDTH:2048,MAX_HEIGHT:2048,ASPECT_RATIO_MIN:1/3,ASPECT_RATIO_MAX:3},i=[`1:1`,`2:3`,`3:4`,`3:2`,`4:3`,`9:16`,`16:9`];function a(e){let t=[];e.size>r.MAX_SIZE_MB*1024*1024&&t.push(`图片大小不能超过10MB`),(e.width>r.MAX_WIDTH||e.height>r.MAX_HEIGHT)&&t.push(`图片分辨率不能超过2048x2048`);let n=e.width/e.height;return(n<r.ASPECT_RATIO_MIN||n>r.ASPECT_RATIO_MAX)&&t.push(`宽高比必须在1:3到3:1之间`),{valid:t.length===0,errors:t}}function o(e,t){let n=[];return(e.width!==t.width||e.height!==t.height)&&n.push(`蒙版尺寸必须与原图尺寸相同`),{valid:n.length===0,errors:n}}async function s(e){let t=e.size<=r.MAX_SIZE_MB*1024*1024;return new Promise(n=>{let i=new Image,a=URL.createObjectURL(e);i.onload=()=>{URL.revokeObjectURL(a);let e=[];(i.width>r.MAX_WIDTH||i.height>r.MAX_HEIGHT)&&e.push(`图片分辨率不能超过2048x2048`);let o=i.width/i.height;(o<r.ASPECT_RATIO_MIN||o>r.ASPECT_RATIO_MAX)&&e.push(`宽高比必须在1:3到3:1之间`),t||e.push(`图片大小不能超过10MB`),n({valid:e.length===0,errors:e})},i.onerror=()=>{URL.revokeObjectURL(a),n({valid:!1,errors:[`无法加载图片`]})},i.src=a})}var c={GeneratePrinting:{key:`GeneratePrinting`,title:`图案设计`,description:`上传1-2张灵感素材图进行融合发散设计`,fields:[{name:`imgUrlList`,label:`灵感素材图`,type:`images`,required:!0,hint:`上传1-2张灵感素材图`},{name:`prompt`,label:`图案风格`,type:`text`,required:!0,placeholder:`描述想要的图案风格`},{name:`aspectRatio`,label:`比例`,type:`aspectRatio`}]},VirtualFitting:{key:`VirtualFitting`,title:`AI试衣`,description:`上传服装图片生成模特上身效果图`,fields:[{name:`imgUrl`,label:`上装图片`,type:`image`,required:!0,hint:`挂拍图/人台图/平铺图`},{name:`lowerImgUrl`,label:`下装图片`,type:`image`},{name:`prompt`,label:`试衣需求`,type:`text`,placeholder:`描述试衣需求`},{name:`aspectRatio`,label:`比例`,type:`aspectRatio`}]},FixFace:{key:`FixFace`,title:`面部优化`,description:`智能修复模特脸部畸形`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0}]},ChangeFace:{key:`ChangeFace`,title:`面部替换`,description:`上传指定面部图片替换模特面容`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`refImgUrl`,label:`参考面部图`,type:`image`,required:!0}]},MultiPerspective:{key:`MultiPerspective`,title:`多视角`,description:`生成不同角度的展示效果图`,fields:[{name:`imgUrl`,label:`图片`,type:`image`,required:!0},{name:`perspective`,label:`视角`,type:`enum`,required:!0,options:e.b}]},PrintingTiling:{key:`PrintingTiling`,title:`图案印染上身`,description:`将指定图案虚拟印染到款式图上`,fields:[{name:`imgUrl`,label:`款式图`,type:`image`,required:!0},{name:`maskUrl`,label:`蒙版`,type:`mask`},{name:`printingImgUrl`,label:`印花图案`,type:`image`,required:!0},{name:`prompt`,label:`印染需求`,type:`text`,placeholder:`描述印染需求`}]},ChangeDesignPoint:{key:`ChangeDesignPoint`,title:`设计点修改`,description:`通过参考图实现设计点修改或融合`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`蒙版`,type:`mask`},{name:`refImgUrl`,label:`参考图`,type:`image`},{name:`prompt`,label:`修改需求`,type:`text`,placeholder:`描述修改需求`}]},ChangeColor:{key:`ChangeColor`,title:`服装改色`,description:`自定义区域一键换色`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`改色区域蒙版`,type:`mask`,required:!0},{name:`hexCode`,label:`目标颜色`,type:`color`,required:!0}]},ChangeFabric:{key:`ChangeFabric`,title:`面料上身`,description:`将指定面料一键上身到款式图`,fields:[{name:`imgUrl`,label:`款式图/模特图`,type:`image`,required:!0},{name:`maskUrl`,label:`蒙版`,type:`mask`,required:!0},{name:`fabricImgUrl`,label:`面料图`,type:`image`,required:!0}]},Sr:{key:`Sr`,title:`高清放大`,description:`无损高清放大与细节强化`,fields:[{name:`imgUrl`,label:`图片`,type:`image`,required:!0},{name:`scale`,label:`放大倍数`,type:`enum`,required:!0,options:e.T}]},VectorConvert:{key:`VectorConvert`,title:`矢量图转换`,description:`生成可编辑的矢量格式文件`,fields:[{name:`imgUrl`,label:`图片`,type:`image`,required:!0},{name:`patternType`,label:`图案类型`,type:`enum`,required:!0,options:e.y}]},ChangeModel:{key:`ChangeModel`,title:`模特更换`,description:`一键更换模特并支持自定义选择`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`gender`,label:`性别`,type:`enum`,options:e.g},{name:`age`,label:`年龄`,type:`enum`,options:e.u},{name:`race`,label:`人种`,type:`enum`,options:e.S}]},GenerateSketch:{key:`GenerateSketch`,title:`平铺图转线稿`,description:`上传平铺图生成线稿`,fields:[{name:`imgUrl`,label:`平铺图`,type:`image`,required:!0}]},ModelGenerateSketch:{key:`ModelGenerateSketch`,title:`模特图转线稿`,description:`上传模特图生成线稿`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`position`,label:`服装位置`,type:`enum`,options:e.x}]},Eliminate:{key:`Eliminate`,title:`AI消除`,description:`一键消除指定元素`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`消除区域蒙版`,type:`mask`,required:!0}]},ExpandImage:{key:`ExpandImage`,title:`AI扩图`,description:`一键扩充人物或背景`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`扩图区域蒙版`,type:`mask`,required:!0}]},ClothingDesign:{key:`ClothingDesign`,title:`AI创款`,description:`根据灵感图快速创款`,fields:[{name:`imgUrlList`,label:`灵感款式图`,type:`images`,hint:`上传1-3张灵感图`},{name:`fabricImgUrl`,label:`面料图`,type:`image`,hint:`上传面料图进行面料创款`},{name:`words`,label:`创款需求`,type:`text`,placeholder:`描述创款需求`},{name:`aspectRatio`,label:`比例`,type:`aspectRatio`}]},ChangePattern:{key:`ChangePattern`,title:`服装改版`,description:`通过选择部位和版型修改服装版型`,fields:[{name:`imgUrl`,label:`服装图`,type:`image`,required:!0},{name:`detailList`,label:`改版部位`,type:`multiEnum`,required:!0,options:e.m}]},GenerateModel:{key:`GenerateModel`,title:`定制模特`,description:`生成符合需求的虚拟模特`,fields:[{name:`imgUrlList`,label:`参考图片`,type:`images`,required:!0,hint:`上传1-10张带面容的图片`},{name:`gender`,label:`性别`,type:`enum`,required:!0,options:e.g},{name:`race`,label:`人种`,type:`enum`,options:e.S}]},ModifyPrinting:{key:`ModifyPrinting`,title:`图案修改`,description:`上传图案和参考图AI修改`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`refImgUrl`,label:`参考图`,type:`image`},{name:`maskUrl`,label:`蒙版`,type:`mask`},{name:`prompt`,label:`修改需求`,type:`text`,placeholder:`描述修改需求`}]},CutOut:{key:`CutOut`,title:`智能抠图`,description:`一键抠图修边`,fields:[{name:`imgUrl`,label:`图片`,type:`image`,required:!0},{name:`recognitionType`,label:`识别类型`,type:`enum`,required:!0,options:e.C}]},LineArtToReal:{key:`LineArtToReal`,title:`线稿转实物`,description:`线稿图生成实物效果平铺图`,fields:[{name:`imgUrl`,label:`线稿图`,type:`image`,required:!0},{name:`imageType`,label:`图片类型`,type:`enum`,required:!0,options:e._},{name:`prompt`,label:`款式特征`,type:`text`,placeholder:`描述款式特征`}]},FixPartial:{key:`FixPartial`,title:`局部修复`,description:`修复或重新创造指定区域`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`修复区域蒙版`,type:`mask`,required:!0},{name:`prompt`,label:`修复需求`,type:`text`,placeholder:`描述修复需求`}]},DetailCompensation:{key:`DetailCompensation`,title:`细节补偿`,description:`精准还原服装细节`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`蒙版`,type:`mask`},{name:`refImgUrl`,label:`参考图`,type:`image`}]},ChangeClothesByImg:{key:`ChangeClothesByImg`,title:`服装穿搭调整`,description:`上下装搭配调整`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`changeImgUrl`,label:`搭配服装图`,type:`image`,required:!0}]}},l={ChangeAccessoriesByImg:{key:`ChangeAccessoriesByImg`,title:`配饰穿搭调整`,description:`背包鞋子首饰等搭配调整`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`changeImgUrl`,label:`搭配物品图`,type:`image`,required:!0},{name:`accessoryType`,label:`配件类型`,type:`enum`,required:!0,options:e.l}]},VirtualFittingReference:{key:`VirtualFittingReference`,title:`AI试衣参考图模式`,description:`上传模特参考图生成试衣效果`,fields:[{name:`imgUrl`,label:`服装图片`,type:`image`,required:!0},{name:`refImgUrl`,label:`模特参考图`,type:`image`,required:!0}]},VirtualFittingTemplate:{key:`VirtualFittingTemplate`,title:`AI试衣模板模式`,description:`选择试衣场景模板`,fields:[{name:`imgUrl`,label:`服装图片`,type:`image`,required:!0},{name:`templateId`,label:`试衣模板`,type:`enum`,required:!0,options:e.k}]},FixDeformities:{key:`FixDeformities`,title:`畸形修复`,description:`修复手部脚部脸部畸形`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`maskUrl`,label:`修复区域蒙版`,type:`mask`,required:!0}]},IntelligentCropping:{key:`IntelligentCropping`,title:`AI智能裁图`,description:`自定义像素或比例裁图`,fields:[{name:`imgUrl`,label:`图片`,type:`image`,required:!0},{name:`mode`,label:`裁剪模式`,type:`enum`,required:!0,options:e.p},{name:`x`,label:`X坐标`,type:`number`},{name:`y`,label:`Y坐标`,type:`number`},{name:`width`,label:`宽度`,type:`number`},{name:`height`,label:`高度`,type:`number`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},ModelToFlat:{key:`ModelToFlat`,title:`模特转平铺`,description:`模特图生成平铺图效果`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`position`,label:`服装位置`,type:`enum`,required:!0,options:e.x}]},GenerateShortVideo:{key:`GenerateShortVideo`,title:`短视频生成`,description:`上传图片生成短视频`,fields:[{name:`imgUrl`,label:`首帧图片`,type:`image`,required:!0},{name:`tailImgUrl`,label:`尾帧图片`,type:`image`},{name:`prompt`,label:`文本指令`,type:`text`,placeholder:`描述视频内容`},{name:`duration`,label:`时长`,type:`enum`,required:!0,options:e.h}]},OneClickModifyPrinting:{key:`OneClickModifyPrinting`,title:`一键改图案`,description:`通过文本或参考图一键更改图案`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`refImgUrl`,label:`参考图`,type:`image`},{name:`prompt`,label:`文本指令`,type:`text`,placeholder:`描述图案修改需求`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},OrientationDesign:{key:`OrientationDesign`,title:`服装定向设计`,description:`通过设计点对服装进行定向设计`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`蒙版1`,type:`mask`},{name:`refImgUrl`,label:`参考图1`,type:`image`},{name:`prompt`,label:`文本指令1`,type:`text`,placeholder:`描述设计需求`}]},DirectionalIntegration:{key:`DirectionalIntegration`,title:`定向融合`,description:`通过融合设计点对服装进行融合设计`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`maskUrl`,label:`蒙版1`,type:`mask`},{name:`refImgUrl`,label:`参考图1`,type:`image`,required:!0}]},OneClickIntegration:{key:`OneClickIntegration`,title:`一键融合`,description:`通过参考图和文本指令一键融合`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`refImgUrl`,label:`参考图`,type:`image`,required:!0},{name:`prompt`,label:`文本指令`,type:`text`,placeholder:`描述融合需求`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},ChangeFabricV2:{key:`ChangeFabricV2`,title:`面料上身2.0`,description:`支持文本指令的面料上身`,fields:[{name:`imgUrl`,label:`款式图`,type:`image`,required:!0},{name:`maskUrl`,label:`蒙版`,type:`mask`,required:!0},{name:`fabricImgUrl`,label:`面料图`,type:`image`,required:!0},{name:`prompt`,label:`文本指令`,type:`text`,placeholder:`描述调整需求`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},VirtualFittingReferenceV2:{key:`VirtualFittingReferenceV2`,title:`AI试衣参考图2.0`,description:`支持姿势和背景的试衣`,fields:[{name:`imgUrl`,label:`服装图片`,type:`image`,required:!0},{name:`refImgUrl`,label:`模特参考图`,type:`image`,required:!0},{name:`poseImgUrl`,label:`姿势图`,type:`image`},{name:`bgImgUrl`,label:`背景图`,type:`image`},{name:`prompt`,label:`文本指令`,type:`text`,placeholder:`描述试衣需求`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FlowerShapedDesign:{key:`FlowerShapedDesign`,title:`花型创款`,description:`将印花上身到指定款式效果图`,fields:[{name:`imgUrl`,label:`印花图案`,type:`image`,required:!0},{name:`prompt`,label:`文本指令`,type:`text`,required:!0,placeholder:`描述上身效果需求`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FlowerShapedVirtualPrinting:{key:`FlowerShapedVirtualPrinting`,title:`花型上身`,description:`将图案上身到款式图指定区域`,fields:[{name:`imgUrl`,label:`印花图案`,type:`image`,required:!0},{name:`bodyImgUrl`,label:`上身图`,type:`image`,required:!0},{name:`bodyMaskImgUrl`,label:`目标区域蒙版`,type:`mask`,required:!0},{name:`removePattern`,label:`是否去除参考图印花`,type:`enum`,options:e.w}]},OneClickChangeColor:{key:`OneClickChangeColor`,title:`一键改色`,description:`整合智能识别与自定义改色`,fields:[{name:`imgUrl`,label:`原图`,type:`image`,required:!0},{name:`hexCode`,label:`目标颜色`,type:`color`},{name:`hexImgUrl`,label:`颜色参考图`,type:`image`},{name:`changeColorArea`,label:`改色区域`,type:`text`,placeholder:`如:上衣`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FittingModelWithLabels:{key:`FittingModelWithLabels`,title:`模特定制标签模式`,description:`通过标签选择生成虚拟模特`,fields:[{name:`gender`,label:`性别`,type:`enum`,required:!0,options:e.g},{name:`age`,label:`年龄`,type:`enum`,options:e.u},{name:`nationality`,label:`国籍`,type:`enum`,options:e.v},{name:`skinColor`,label:`肤色`,type:`enum`,options:e.O},{name:`bodyShape`,label:`身材`,type:`enum`,options:e.f}]},FittingModelCustom:{key:`FittingModelCustom`,title:`模特定制自定义模式`,description:`根据参考图生成虚拟模特`,fields:[{name:`gender`,label:`性别`,type:`enum`,required:!0,options:e.g},{name:`faceRefImgUrl`,label:`脸部参考图`,type:`image`,required:!0},{name:`similarity`,label:`相似度`,type:`enum`,options:e.E},{name:`bodyShapeRefImgUrl`,label:`身材参考图`,type:`image`},{name:`additionalDescription`,label:`附加描述`,type:`text`,placeholder:`附加描述`}]},FittingModelChangeFace:{key:`FittingModelChangeFace`,title:`模特换脸`,description:`对模特图换脸操作`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`refImgUrl`,label:`参考面部图`,type:`image`,required:!0},{name:`similarity`,label:`相似度`,type:`enum`,options:e.E},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FittingModelChangeModel:{key:`FittingModelChangeModel`,title:`模特替换`,description:`随机或指定模特替换`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`gender`,label:`性别`,type:`enum`,options:e.g},{name:`similarity`,label:`相似度`,type:`enum`,options:e.E},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FittingModelChangeBodyShape:{key:`FittingModelChangeBodyShape`,title:`模特身材调整`,description:`通过标签或参考图调整身材`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`bodyShapeRefImgUrl`,label:`身材参考图`,type:`image`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FittingModelChangeClothingSize:{key:`FittingModelChangeClothingSize`,title:`模特尺码调整`,description:`调整模特服装尺码`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`size`,label:`尺码`,type:`enum`,required:!0,options:e.D},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FittingModelChangePosture:{key:`FittingModelChangePosture`,title:`模特姿势调整`,description:`调整模特姿势`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`poseImgUrl`,label:`姿势参考图`,type:`image`,required:!0},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FittingModelChangeBackground:{key:`FittingModelChangeBackground`,title:`模特换背景`,description:`替换模特背景`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`bgImgUrl`,label:`背景参考图`,type:`image`},{name:`prompt`,label:`文本指令`,type:`text`,placeholder:`描述背景需求`},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},FittingModelChangePerspective:{key:`FittingModelChangePerspective`,title:`模特视角调整`,description:`调整模特视角`,fields:[{name:`imgUrl`,label:`模特图`,type:`image`,required:!0},{name:`perspective`,label:`视角`,type:`enum`,required:!0,options:e.b},{name:`aspectRatio`,label:`宽高比`,type:`aspectRatio`}]},TrainClothingModel:{key:`TrainClothingModel`,title:`服装风格模型训练`,description:`训练自定义服装风格模型`,fields:[{name:`imgUrlList`,label:`训练图片`,type:`images`,required:!0,hint:`建议上传30-50张正面/斜侧面模特图`},{name:`clothingModelName`,label:`模型名称`,type:`text`,required:!0},{name:`enhanceWordList`,label:`加强词`,type:`text`}]}},u={...c,...l};function d(e){return u[e]}function f(){return Object.values(u)}function p(e,t){let n=[];for(let r of t){let t=e[r.name],i=m(r,t);i&&n.push(i)}return{valid:n.length===0,errors:n}}function m(t,n){let r=n==null||n===``;if(t.required&&r)return{field:t.name,label:t.label,message:e.a.FIELD_REQUIRED(t.label)};if(n==null)return null;let i=e=>({field:t.name,label:t.label,message:e(t.label)});switch(t.type){case`image`:case`mask`:if(typeof n!=`string`&&!h(n))return i(e.a.FIELD_STRING);break;case`images`:if(!Array.isArray(n)||n.length===0)return i(e.a.FIELD_ARRAY);if(n.some(e=>(typeof e!=`string`||e===``)&&!h(e)))return i(e.a.FIELD_ARRAY_ELEMENTS);break;case`text`:if(typeof n!=`string`)return i(e.a.FIELD_STRING);if(t.maxLength&&n.length>t.maxLength)return i(n=>e.a.FIELD_MAX_LENGTH(n,t.maxLength));break;case`enum`:if(typeof n!=`string`)return i(e.a.FIELD_STRING);if(t.options&&!t.options.some(e=>e.value===n))return i(e.a.FIELD_ENUM_INVALID);break;case`multiEnum`:if(!Array.isArray(n)||n.length===0)return i(e.a.FIELD_ARRAY);if(n.some(e=>typeof e!=`string`||e===``))return i(e.a.FIELD_ARRAY_ELEMENTS);if(t.options&&n.some(e=>!t.options?.some(t=>t.value===e)))return i(e.a.FIELD_ENUM_INVALID);break;case`color`:if(typeof n!=`string`||!/^#[0-9A-Fa-f]{6}$/.test(n))return i(e.a.FIELD_COLOR_FORMAT);break;case`number`:if(typeof n!=`number`||Number.isNaN(n))return i(e.a.FIELD_NUMBER);break;case`aspectRatio`:case`strength`:break}return null}function h(e){return typeof File<`u`&&e instanceof File}var g=class{constructor(t={}){this.type=``,this.submitEndpoint=`/task/submit`,this.submitEndpointMode=`prefix`,this.pollEndpoint=`/task/progress`,this.pollInterval=1e3,this.maxPollAttempts=120,this.phase=e.P.IDLE,this.taskId=``,this.progress=0,this.result=null,this.error=``,this.activeTasks=new Map,this.pollTimer=null,this.isPollingBatch=!1,this.configure(t)}configure(e){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)}get typeDef(){let e=this.resolvedTaskTypeKey;return e?d(e):void 0}get taskFields(){return this.typeDef?.fields??[]}async submit(t,n){let r=this.createRequestUri(t);if(!r){this.fail(e.a.MISSING_ENDPOINT,e.P.IDLE);return}let i=this.getTaskFields(t);if(i.length>0){let t=p(n,i);if(!t.valid){this.fail(t.errors.map(e=>e.message).join(`; `),e.P.IDLE);return}}this.phase=e.P.SUBMITTING,this.error=``,this.progress=0,this.result=null;try{let e=await this.resolveUploads(n,i),t=(await this.request(r,e)).data.taskId;this.taskId=t;let a={taskId:t,endpoint:r,formData:e};this.onSubmit?.(a),await this.trackTask(t)}catch(t){this.fail(t instanceof Error?t.message:e.a.SUBMIT_FAILED,this.phase)}}reset(){this.phase=e.P.IDLE,this.taskId=``,this.progress=0,this.result=null,this.error=``,this.activeTasks.clear(),this.pollTimer&&=(clearTimeout(this.pollTimer),null)}createRequestUri(e=this.type){return this.submitEndpointMode===`full`?this.submitEndpoint:e?`${this.submitEndpoint}/${e}`:this.submitEndpoint}get resolvedTaskTypeKey(){return x(this.type)}getTaskFields(e){let t=x(e);return t?d(t)?.fields??[]:[]}async resolveUploads(e,t){let n=t.length>0?t.filter(e=>e.type===`image`||e.type===`mask`||e.type===`images`):Object.keys(e).map(e=>({name:e,type:`image`}));if(!n.length)return e;let r={...e};for(let e of n){let t=r[e.name];Array.isArray(t)?r[e.name]=await Promise.all(t.map(t=>this.resolveUploadValue(t,e))):r[e.name]=await this.resolveUploadValue(t,e)}return r}async resolveUploadValue(e,t){if(!S(e))return e;if(!this.customUploadRequest)throw Error(`customUploadRequest is required to upload ${t.name}`);return C(await this.customUploadRequest(e))}trackTask(t){this.phase=e.P.POLLING;let n=new Promise(e=>{this.activeTasks.set(t,{taskId:t,attempts:0,resolve:e})});return this.ensurePolling(0),n}ensurePolling(e=this.pollInterval){this.pollTimer||this.isPollingBatch||!this.activeTasks.size||(this.pollTimer=setTimeout(()=>{this.pollTimer=null,this.pollActiveTasks()},this.pollInterval))}async pollActiveTasks(){if(!this.activeTasks.size)return;this.isPollingBatch=!0;let t=[...this.activeTasks.keys()];try{let n=`${this.pollEndpoint}?taskIds=${t.map(encodeURIComponent).join(`,`)}`,r=await this.request(n),i=new Map(r.data.map(e=>[e.aiTaskId,e]));t.forEach(t=>{let n=this.activeTasks.get(t);if(!n)return;n.attempts+=1;let r=i.get(t);if(!r){this.failTask(n,e.a.TASK_NOT_FOUND(t));return}this.taskId=t,this.progress=r.taskProgress;let a={taskId:t,progress:r.taskProgress,status:r.aiTaskStatus,queuePos:r.queuePos};if(this.onPoll?.(a),r.aiTaskStatus===`done`){this.result=r;let e={taskId:t,images:r.imgInfo?[{index:0,url:r.imgInfo}]:[],result:r};this.onSuccess?.(e),this.completeTask(n);return}n.attempts>=this.maxPollAttempts&&this.failTask(n,e.a.POLL_TIMEOUT(t))})}catch(t){let n=t instanceof Error?t.message:e.a.POLL_FAILED;[...this.activeTasks.values()].forEach(e=>this.failTask(e,n))}finally{this.isPollingBatch=!1,this.activeTasks.size?(this.phase=e.P.POLLING,this.ensurePolling(this.pollInterval)):this.phase===e.P.POLLING&&(this.phase=this.error?e.P.ERROR:e.P.SUCCESS)}}completeTask(e){this.activeTasks.delete(e.taskId),e.resolve()}failTask(t,n){this.activeTasks.delete(t.taskId),this.fail(n,e.P.POLLING,t.taskId),t.resolve()}async request(e,t){let n=this.customRequest?await this.customRequest(e,t):await fetch(e,t===void 0?{method:`GET`}:{method:`POST`,body:JSON.stringify(t),headers:{"Content-Type":`application/json`}});return n&&typeof n.json==`function`?n.json():_(n)}fail(t,n,r){this.phase=e.P.ERROR,this.error=t;let i={message:t,phase:n,taskId:r};this.onError?.(i)}};function _(e){return b(e)&&y(e.data)?e.data:(v(e),e)}function v(e){return b(e)&&`data`in e}function y(e){return b(e)&&`data`in e&&(`code`in e||`success`in e||`msg`in e)}function b(e){return typeof e==`object`&&!!e}function x(e){if(!e)return``;if(u[e])return e;let t=e.replace(/([a-z0-9])([A-Z])/g,`$1_$2`).replace(/[-\s]+/g,`_`).toUpperCase();return u[t]?t:``}function S(e){return typeof File<`u`&&e instanceof File}async function C(e){return e?typeof e==`string`?e:e instanceof Response?C(await e.json()):typeof e.data==`string`?e.data:e.data?e.data.value||e.data.url||``:e.value||e.url||``:``}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return o}});
@@ -1443,11 +1443,7 @@ var L = class {
1443
1443
  }
1444
1444
  this.phase = i.SUBMITTING, this.error = "", this.progress = 0, this.result = null;
1445
1445
  try {
1446
- let e = await this.resolveUploads(t, r), i = (await this.request(n, {
1447
- method: "POST",
1448
- body: JSON.stringify(e),
1449
- headers: { "Content-Type": "application/json" }
1450
- })).data.taskId;
1446
+ let e = await this.resolveUploads(t, r), i = (await this.request(n, e)).data.taskId;
1451
1447
  this.taskId = i;
1452
1448
  let a = {
1453
1449
  taskId: i,
@@ -1466,10 +1462,10 @@ var L = class {
1466
1462
  return this.submitEndpointMode === "full" ? this.submitEndpoint : e ? `${this.submitEndpoint}/${e}` : this.submitEndpoint;
1467
1463
  }
1468
1464
  get resolvedTaskTypeKey() {
1469
- return R(this.type);
1465
+ return H(this.type);
1470
1466
  }
1471
1467
  getTaskFields(e) {
1472
- let t = R(e);
1468
+ let t = H(e);
1473
1469
  return t ? M(t)?.fields ?? [] : [];
1474
1470
  }
1475
1471
  async resolveUploads(e, t) {
@@ -1486,15 +1482,9 @@ var L = class {
1486
1482
  return r;
1487
1483
  }
1488
1484
  async resolveUploadValue(e, t) {
1489
- if (!z(e)) return e;
1485
+ if (!U(e)) return e;
1490
1486
  if (!this.customUploadRequest) throw Error(`customUploadRequest is required to upload ${t.name}`);
1491
- let n = new FormData();
1492
- return n.append(t.name || "file", e), B(await this.customUploadRequest({
1493
- file: e,
1494
- name: t.name,
1495
- formData: n,
1496
- field: t
1497
- }));
1487
+ return W(await this.customUploadRequest(e));
1498
1488
  }
1499
1489
  trackTask(e) {
1500
1490
  this.phase = i.POLLING;
@@ -1517,7 +1507,7 @@ var L = class {
1517
1507
  this.isPollingBatch = !0;
1518
1508
  let e = [...this.activeTasks.keys()];
1519
1509
  try {
1520
- 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]));
1510
+ let t = `${this.pollEndpoint}?taskIds=${e.map(encodeURIComponent).join(",")}`, n = await this.request(t), r = new Map(n.data.map((e) => [e.aiTaskId, e]));
1521
1511
  e.forEach((e) => {
1522
1512
  let t = this.activeTasks.get(e);
1523
1513
  if (!t) return;
@@ -1563,8 +1553,12 @@ var L = class {
1563
1553
  this.activeTasks.delete(e.taskId), this.fail(t, i.POLLING, e.taskId), e.resolve();
1564
1554
  }
1565
1555
  async request(e, t) {
1566
- let n = await (this.customRequest ?? fetch)(e, t);
1567
- return n && typeof n.json == "function" ? n.json() : n;
1556
+ let n = this.customRequest ? await this.customRequest(e, t) : await fetch(e, t === void 0 ? { method: "GET" } : {
1557
+ method: "POST",
1558
+ body: JSON.stringify(t),
1559
+ headers: { "Content-Type": "application/json" }
1560
+ });
1561
+ return n && typeof n.json == "function" ? n.json() : R(n);
1568
1562
  }
1569
1563
  fail(e, t, n) {
1570
1564
  this.phase = i.ERROR, this.error = e;
@@ -1577,16 +1571,28 @@ var L = class {
1577
1571
  }
1578
1572
  };
1579
1573
  function R(e) {
1574
+ return V(e) && B(e.data) ? e.data : (z(e), e);
1575
+ }
1576
+ function z(e) {
1577
+ return V(e) && "data" in e;
1578
+ }
1579
+ function B(e) {
1580
+ return V(e) && "data" in e && ("code" in e || "success" in e || "msg" in e);
1581
+ }
1582
+ function V(e) {
1583
+ return typeof e == "object" && !!e;
1584
+ }
1585
+ function H(e) {
1580
1586
  if (!e) return "";
1581
1587
  if (j[e]) return e;
1582
1588
  let t = e.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[-\s]+/g, "_").toUpperCase();
1583
1589
  return j[t] ? t : "";
1584
1590
  }
1585
- function z(e) {
1591
+ function U(e) {
1586
1592
  return typeof File < "u" && e instanceof File;
1587
1593
  }
1588
- async function B(e) {
1589
- return e ? typeof e == "string" ? e : e instanceof Response ? B(await e.json()) : typeof e.data == "string" ? e.data : e.data ? e.data.value || e.data.url || "" : e.value || e.url || "" : "";
1594
+ async function W(e) {
1595
+ return e ? typeof e == "string" ? e : e instanceof Response ? W(await e.json()) : typeof e.data == "string" ? e.data : e.data ? e.data.value || e.data.url || "" : e.value || e.url || "" : "";
1590
1596
  }
1591
1597
  //#endregion
1592
1598
  export { M as a, E as c, T as d, C as f, N as i, O as l, S as m, P as n, A as o, w as p, j as r, k as s, L as t, D as u };
package/dist/contants.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./client-CJ8X0sFi.cjs`),t=require(`./constants-Bdlwi9VJ.cjs`);require(`./core-D0DpSeAr.cjs`),exports.ACCEPTED_FILE_TYPES=t.t,exports.API_BASE_URL=t.n,exports.ASPECT_RATIOS=e.d,exports.AUTH_HEADER_KEY=t.r,exports.CallbackStatus=e.f,exports.ERROR_CODES=t.i,exports.ERROR_MESSAGES=t.a,exports.EVENT_NAMES=t.o,exports.FIELD_TYPES=t.s,exports.FILE_SIZE_LIMITS=t.c,exports.IMAGE_LIMITS=e.p,exports.TASK_PROGRESS_PATH=t.A,exports.TASK_SUBMIT_PREFIX=t.j,exports.TASK_TYPES=e.r,exports.TASK_TYPES_PART_A=e.s,exports.TASK_TYPES_PART_B=e.o,exports.TASK_WORKFLOW_TYPES=t.M,exports.TaskStatus=e.m,exports.WORKFLOW_DEFAULTS=t.N,exports.WORKFLOW_PHASES=t.P,exports.getAllTaskTypes=e.i,exports.getTaskTypeDef=e.a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./client-BnY0dpeN.cjs`),t=require(`./constants-Bdlwi9VJ.cjs`);require(`./core-Di13s7Ci.cjs`),exports.ACCEPTED_FILE_TYPES=t.t,exports.API_BASE_URL=t.n,exports.ASPECT_RATIOS=e.d,exports.AUTH_HEADER_KEY=t.r,exports.CallbackStatus=e.f,exports.ERROR_CODES=t.i,exports.ERROR_MESSAGES=t.a,exports.EVENT_NAMES=t.o,exports.FIELD_TYPES=t.s,exports.FILE_SIZE_LIMITS=t.c,exports.IMAGE_LIMITS=e.p,exports.TASK_PROGRESS_PATH=t.A,exports.TASK_SUBMIT_PREFIX=t.j,exports.TASK_TYPES=e.r,exports.TASK_TYPES_PART_A=e.s,exports.TASK_TYPES_PART_B=e.o,exports.TASK_WORKFLOW_TYPES=t.M,exports.TaskStatus=e.m,exports.WORKFLOW_DEFAULTS=t.N,exports.WORKFLOW_PHASES=t.P,exports.getAllTaskTypes=e.i,exports.getTaskTypeDef=e.a;
package/dist/contants.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, d as t, f as n, i as r, m as i, o as a, p as o, r as s, s as c } from "./client-jorIw6pH.js";
1
+ import { a as e, d as t, f as n, i as r, m as i, o as a, p as o, r as s, s as c } from "./client-CxZI36n6.js";
2
2
  import { A as l, M as u, N as d, P as f, a as p, c as m, i as h, j as g, n as _, o as v, r as y, s as b, t as x } from "./constants-CdudjmSn.js";
3
- import "./core-rH2gpxTB.js";
3
+ import "./core-8c7MUnKQ.js";
4
4
  export { x as ACCEPTED_FILE_TYPES, _ as API_BASE_URL, t as ASPECT_RATIOS, y as AUTH_HEADER_KEY, n as CallbackStatus, h as ERROR_CODES, p as ERROR_MESSAGES, v as EVENT_NAMES, b as FIELD_TYPES, m as FILE_SIZE_LIMITS, o as IMAGE_LIMITS, l as TASK_PROGRESS_PATH, g as TASK_SUBMIT_PREFIX, s as TASK_TYPES, c as TASK_TYPES_PART_A, a as TASK_TYPES_PART_B, u as TASK_WORKFLOW_TYPES, i as TaskStatus, d as WORKFLOW_DEFAULTS, f as WORKFLOW_PHASES, r as getAllTaskTypes, e as getTaskTypeDef };
@@ -0,0 +1 @@
1
+ import "./client-CxZI36n6.js";
@@ -0,0 +1 @@
1
+ require(`./client-BnY0dpeN.cjs`);
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./button-hUFCfzUP.cjs`),t=require(`./client-CJ8X0sFi.cjs`),n=require(`./constants-Bdlwi9VJ.cjs`);require(`./core-D0DpSeAr.cjs`),e.f();function r(){}exports.ACCEPTED_FILE_TYPES=n.t,exports.API_BASE_URL=n.n,exports.ASPECT_RATIOS=t.d,exports.AUTH_HEADER_KEY=n.r,exports.CallbackStatus=t.f,exports.ERROR_CODES=n.i,exports.ERROR_MESSAGES=n.a,exports.EVENT_NAMES=n.o,exports.FIELD_TYPES=n.s,exports.FILE_SIZE_LIMITS=n.c,exports.IMAGE_LIMITS=t.p,Object.defineProperty(exports,`LcButton`,{enumerable:!0,get:function(){return e.t}}),Object.defineProperty(exports,`LcColorPicker`,{enumerable:!0,get:function(){return e.s}}),Object.defineProperty(exports,`LcEnumSelector`,{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(exports,`LcImageCompareSlider`,{enumerable:!0,get:function(){return e.r}}),Object.defineProperty(exports,`LcImageUploader`,{enumerable:!0,get:function(){return e.d}}),Object.defineProperty(exports,`LcMaskEditor`,{enumerable:!0,get:function(){return e.u}}),Object.defineProperty(exports,`LcPromptInput`,{enumerable:!0,get:function(){return e.c}}),Object.defineProperty(exports,`LcResultGallery`,{enumerable:!0,get:function(){return e.i}}),Object.defineProperty(exports,`LcStrengthSlider`,{enumerable:!0,get:function(){return e.o}}),Object.defineProperty(exports,`LcTaskProgressCard`,{enumerable:!0,get:function(){return e.a}}),Object.defineProperty(exports,`LcTaskWorkflow`,{enumerable:!0,get:function(){return e.n}}),exports.LightChainClient=t.t,exports.OPTIONS_ACCESSORY_TYPE=n.l,exports.OPTIONS_AGE=n.u,exports.OPTIONS_ASPECT_RATIO=n.d,exports.OPTIONS_BODY_SHAPE=n.f,exports.OPTIONS_CROP_MODE=n.p,exports.OPTIONS_DETAIL_LIST=n.m,exports.OPTIONS_DURATION=n.h,exports.OPTIONS_GENDER=n.g,exports.OPTIONS_IMAGE_TYPE=n._,exports.OPTIONS_NATIONALITY=n.v,exports.OPTIONS_PATTERN_TYPE=n.y,exports.OPTIONS_PERSPECTIVE=n.b,exports.OPTIONS_POSITION=n.x,exports.OPTIONS_RACE=n.S,exports.OPTIONS_RECOGNITION_TYPE=n.C,exports.OPTIONS_REMOVE_PATTERN=n.w,exports.OPTIONS_SCALE=n.T,exports.OPTIONS_SIMILARITY=n.E,exports.OPTIONS_SIZE=n.D,exports.OPTIONS_SKIN_COLOR=n.O,exports.OPTIONS_TEMPLATE_ID=n.k,exports.TASK_PROGRESS_PATH=n.A,exports.TASK_SUBMIT_PREFIX=n.j,exports.TASK_TYPES=t.r,exports.TASK_TYPES_PART_A=t.s,exports.TASK_TYPES_PART_B=t.o,exports.TASK_WORKFLOW_TYPES=n.M,exports.TaskStatus=t.m,exports.WORKFLOW_DEFAULTS=n.N,exports.WORKFLOW_PHASES=n.P,exports.getAllTaskTypes=t.i,exports.getTaskTypeDef=t.a,exports.registerAllComponents=r,exports.validateFormData=t.n,exports.validateImage=t.c,exports.validateImageFile=t.l,exports.validateMask=t.u;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./button-Dl7JV4N-.cjs`),t=require(`./client-BnY0dpeN.cjs`),n=require(`./constants-Bdlwi9VJ.cjs`);require(`./core-Di13s7Ci.cjs`),e.f();function r(){}exports.ACCEPTED_FILE_TYPES=n.t,exports.API_BASE_URL=n.n,exports.ASPECT_RATIOS=t.d,exports.AUTH_HEADER_KEY=n.r,exports.CallbackStatus=t.f,exports.ERROR_CODES=n.i,exports.ERROR_MESSAGES=n.a,exports.EVENT_NAMES=n.o,exports.FIELD_TYPES=n.s,exports.FILE_SIZE_LIMITS=n.c,exports.IMAGE_LIMITS=t.p,Object.defineProperty(exports,`LcButton`,{enumerable:!0,get:function(){return e.t}}),Object.defineProperty(exports,`LcColorPicker`,{enumerable:!0,get:function(){return e.s}}),Object.defineProperty(exports,`LcEnumSelector`,{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(exports,`LcImageCompareSlider`,{enumerable:!0,get:function(){return e.r}}),Object.defineProperty(exports,`LcImageUploader`,{enumerable:!0,get:function(){return e.d}}),Object.defineProperty(exports,`LcMaskEditor`,{enumerable:!0,get:function(){return e.u}}),Object.defineProperty(exports,`LcPromptInput`,{enumerable:!0,get:function(){return e.c}}),Object.defineProperty(exports,`LcResultGallery`,{enumerable:!0,get:function(){return e.i}}),Object.defineProperty(exports,`LcStrengthSlider`,{enumerable:!0,get:function(){return e.o}}),Object.defineProperty(exports,`LcTaskProgressCard`,{enumerable:!0,get:function(){return e.a}}),Object.defineProperty(exports,`LcTaskWorkflow`,{enumerable:!0,get:function(){return e.n}}),exports.LightChainClient=t.t,exports.OPTIONS_ACCESSORY_TYPE=n.l,exports.OPTIONS_AGE=n.u,exports.OPTIONS_ASPECT_RATIO=n.d,exports.OPTIONS_BODY_SHAPE=n.f,exports.OPTIONS_CROP_MODE=n.p,exports.OPTIONS_DETAIL_LIST=n.m,exports.OPTIONS_DURATION=n.h,exports.OPTIONS_GENDER=n.g,exports.OPTIONS_IMAGE_TYPE=n._,exports.OPTIONS_NATIONALITY=n.v,exports.OPTIONS_PATTERN_TYPE=n.y,exports.OPTIONS_PERSPECTIVE=n.b,exports.OPTIONS_POSITION=n.x,exports.OPTIONS_RACE=n.S,exports.OPTIONS_RECOGNITION_TYPE=n.C,exports.OPTIONS_REMOVE_PATTERN=n.w,exports.OPTIONS_SCALE=n.T,exports.OPTIONS_SIMILARITY=n.E,exports.OPTIONS_SIZE=n.D,exports.OPTIONS_SKIN_COLOR=n.O,exports.OPTIONS_TEMPLATE_ID=n.k,exports.TASK_PROGRESS_PATH=n.A,exports.TASK_SUBMIT_PREFIX=n.j,exports.TASK_TYPES=t.r,exports.TASK_TYPES_PART_A=t.s,exports.TASK_TYPES_PART_B=t.o,exports.TASK_WORKFLOW_TYPES=n.M,exports.TaskStatus=t.m,exports.WORKFLOW_DEFAULTS=n.N,exports.WORKFLOW_PHASES=n.P,exports.getAllTaskTypes=t.i,exports.getTaskTypeDef=t.a,exports.registerAllComponents=r,exports.validateFormData=t.n,exports.validateImage=t.c,exports.validateImageFile=t.l,exports.validateMask=t.u;
@@ -1,7 +1,7 @@
1
- import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./button-KoRq6mAW.js";
2
- import { a as f, c as p, d as m, f as h, i as g, l as _, m as v, n as y, o as b, p as x, r as S, s as C, t as w, u as T } from "./client-jorIw6pH.js";
1
+ import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./button-C5RBeUy4.js";
2
+ import { a as f, c as p, d as m, f as h, i as g, l as _, m as v, n as y, o as b, p as x, r as S, s as C, t as w, u as T } from "./client-CxZI36n6.js";
3
3
  import { A as E, C as D, D as O, E as k, M as A, N as j, O as M, P as N, S as P, T as F, _ as I, a as L, b as R, c as z, d as B, f as V, g as H, h as U, i as W, j as G, k as K, l as q, m as J, n as Y, o as X, p as Z, r as Q, s as $, t as ee, u as te, v as ne, w as re, x as ie, y as ae } from "./constants-CdudjmSn.js";
4
- import "./core-rH2gpxTB.js";
4
+ import "./core-8c7MUnKQ.js";
5
5
  //#region src/index.ts
6
6
  r();
7
7
  function oe() {}
package/dist/react.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./button-hUFCfzUP.cjs`),l=require(`./constants-Bdlwi9VJ.cjs`);let u=require(`@lit/react`),d=require(`react`);d=s(d,1);var f=l.o;c.f();var p=(0,u.createComponent)({react:d.default,tagName:`lc-image-uploader`,elementClass:c.d,events:{onChange:f.CHANGE}}),m=(0,u.createComponent)({react:d.default,tagName:`lc-mask-editor`,elementClass:c.u,events:{onChange:f.CHANGE}}),h=(0,u.createComponent)({react:d.default,tagName:`lc-enum-selector`,elementClass:c.l,events:{onChange:f.CHANGE}}),g=(0,u.createComponent)({react:d.default,tagName:`lc-prompt-input`,elementClass:c.c,events:{onChange:f.CHANGE}}),_=(0,u.createComponent)({react:d.default,tagName:`lc-color-picker`,elementClass:c.s,events:{onChange:f.CHANGE}}),v=(0,u.createComponent)({react:d.default,tagName:`lc-strength-slider`,elementClass:c.o,events:{onChange:f.CHANGE}}),y=(0,u.createComponent)({react:d.default,tagName:`lc-task-progress-card`,elementClass:c.a,events:{}}),b=(0,u.createComponent)({react:d.default,tagName:`lc-result-gallery`,elementClass:c.i,events:{onImageClick:f.IMAGE_CLICK,onCompare:f.COMPARE}}),x=(0,u.createComponent)({react:d.default,tagName:`lc-image-compare-slider`,elementClass:c.r,events:{}});function S(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function C(e,t,n){d.default.useLayoutEffect(()=>{let r=e.current;if(!(!r||!n))return r.addEventListener(t,n),()=>r.removeEventListener(t,n)},[t,n,e])}function w(e,t){e.type=t.type??``,t.submitEndpoint!==void 0&&(e.submitEndpoint=t.submitEndpoint),t.pollEndpoint!==void 0&&(e.pollEndpoint=t.pollEndpoint),t.pollInterval!==void 0&&(e.pollInterval=t.pollInterval),t.maxPollAttempts!==void 0&&(e.maxPollAttempts=t.maxPollAttempts),e.client=t.client,e.customRequest=t.customRequest,e.customUploadRequest=t.customUploadRequest}var T=d.default.forwardRef((e,t)=>{let{children:n,className:r,type:i,submitEndpoint:a,pollEndpoint:o,pollInterval:s,maxPollAttempts:c,client:l,customRequest:u,customUploadRequest:p,onSubmit:m,onPoll:h,onPolling:g,onSuccess:_,onError:v,...y}=e,b=d.default.useRef(null),x={type:i,submitEndpoint:a,pollEndpoint:o,pollInterval:s,maxPollAttempts:c,client:l,customRequest:u,customUploadRequest:p},T=d.default.useCallback(e=>{b.current=e,e&&w(e,x),S(t,e)},[t,i,a,o,s,c,l,u,p]);return d.default.useLayoutEffect(()=>{b.current&&w(b.current,x)},[i,a,o,s,c,l,u,p]),C(b,f.SUBMIT,m),C(b,f.POLL,h),C(b,f.POLL,g),C(b,f.SUCCESS,_),C(b,f.ERROR,v),d.default.createElement(`lc-task-workflow`,{...y,class:r,ref:T,suppressHydrationWarning:!0},n)});T.displayName=`LcTaskWorkflowReact`;function E(e,t){e.type=t.type??`button`,e.variant=t.variant??`primary`,e.disabled=!!t.disabled}var D=d.default.forwardRef((e,t)=>{let{children:n,className:r,type:i,variant:a,disabled:o,...s}=e,c=d.default.useRef(null),l={type:i,variant:a,disabled:o},u=d.default.useCallback(e=>{c.current=e,e&&E(e,l),S(t,e)},[t,i,a,o]);return d.default.useLayoutEffect(()=>{c.current&&E(c.current,l)},[i,a,o]),d.default.createElement(`lc-button`,{...s,class:r,ref:u,suppressHydrationWarning:!0},n)});D.displayName=`LcButtonReact`,exports.LcButtonReact=D,exports.LcColorPickerReact=_,exports.LcEnumSelectorReact=h,exports.LcImageCompareSliderReact=x,exports.LcImageUploaderReact=p,exports.LcMaskEditorReact=m,exports.LcPromptInputReact=g,exports.LcResultGalleryReact=b,exports.LcStrengthSliderReact=v,exports.LcTaskProgressCardReact=y,exports.LcTaskWorkflowReact=T,exports.t=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./button-Dl7JV4N-.cjs`),l=require(`./constants-Bdlwi9VJ.cjs`);let u=require(`@lit/react`),d=require(`react`);d=s(d,1);var f=l.o;c.f();var p=(0,u.createComponent)({react:d.default,tagName:`lc-image-uploader`,elementClass:c.d,events:{onChange:f.CHANGE}}),m=(0,u.createComponent)({react:d.default,tagName:`lc-mask-editor`,elementClass:c.u,events:{onChange:f.CHANGE}}),h=(0,u.createComponent)({react:d.default,tagName:`lc-enum-selector`,elementClass:c.l,events:{onChange:f.CHANGE}}),g=(0,u.createComponent)({react:d.default,tagName:`lc-prompt-input`,elementClass:c.c,events:{onChange:f.CHANGE}}),_=(0,u.createComponent)({react:d.default,tagName:`lc-color-picker`,elementClass:c.s,events:{onChange:f.CHANGE}}),v=(0,u.createComponent)({react:d.default,tagName:`lc-strength-slider`,elementClass:c.o,events:{onChange:f.CHANGE}}),y=(0,u.createComponent)({react:d.default,tagName:`lc-task-progress-card`,elementClass:c.a,events:{}}),b=(0,u.createComponent)({react:d.default,tagName:`lc-result-gallery`,elementClass:c.i,events:{onImageClick:f.IMAGE_CLICK,onCompare:f.COMPARE}}),x=(0,u.createComponent)({react:d.default,tagName:`lc-image-compare-slider`,elementClass:c.r,events:{}});function S(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function C(e,t,n){d.default.useLayoutEffect(()=>{let r=e.current;if(!(!r||!n))return r.addEventListener(t,n),()=>r.removeEventListener(t,n)},[t,n,e])}function w(e,t){e.type=t.type??``,t.submitEndpoint!==void 0&&(e.submitEndpoint=t.submitEndpoint),t.pollEndpoint!==void 0&&(e.pollEndpoint=t.pollEndpoint),t.pollInterval!==void 0&&(e.pollInterval=t.pollInterval),t.maxPollAttempts!==void 0&&(e.maxPollAttempts=t.maxPollAttempts),e.client=t.client,e.customRequest=t.customRequest,e.customUploadRequest=t.customUploadRequest}var T=d.default.forwardRef((e,t)=>{let{children:n,className:r,type:i,submitEndpoint:a,pollEndpoint:o,pollInterval:s,maxPollAttempts:c,client:l,customRequest:u,customUploadRequest:p,onSubmit:m,onPoll:h,onPolling:g,onSuccess:_,onError:v,...y}=e,b=d.default.useRef(null),x={type:i,submitEndpoint:a,pollEndpoint:o,pollInterval:s,maxPollAttempts:c,client:l,customRequest:u,customUploadRequest:p},T=d.default.useCallback(e=>{b.current=e,e&&w(e,x),S(t,e)},[t,i,a,o,s,c,l,u,p]);return d.default.useLayoutEffect(()=>{b.current&&w(b.current,x)},[i,a,o,s,c,l,u,p]),C(b,f.SUBMIT,m),C(b,f.POLL,h),C(b,f.POLL,g),C(b,f.SUCCESS,_),C(b,f.ERROR,v),d.default.createElement(`lc-task-workflow`,{...y,class:r,ref:T,suppressHydrationWarning:!0},n)});T.displayName=`LcTaskWorkflowReact`;function E(e,t){e.type=t.type??`button`,e.variant=t.variant??`primary`,e.disabled=!!t.disabled}var D=d.default.forwardRef((e,t)=>{let{children:n,className:r,type:i,variant:a,disabled:o,onClick:s,...c}=e,l=d.default.useRef(null),u={type:i,variant:a,disabled:o},p=i??`button`,m=d.default.useCallback(e=>{l.current=e,e&&E(e,u),S(t,e)},[t,i,a,o]);return d.default.useLayoutEffect(()=>{l.current&&E(l.current,u)},[i,a,o]),C(l,f.REQUEST_SUBMIT,p===`submit`?s:void 0),d.default.createElement(`lc-button`,{...c,...p===`submit`?{}:{onClick:s},class:r,ref:m,suppressHydrationWarning:!0},n)});D.displayName=`LcButtonReact`,exports.LcButtonReact=D,exports.LcColorPickerReact=_,exports.LcEnumSelectorReact=h,exports.LcImageCompareSliderReact=x,exports.LcImageUploaderReact=p,exports.LcMaskEditorReact=m,exports.LcPromptInputReact=g,exports.LcResultGalleryReact=b,exports.LcStrengthSliderReact=v,exports.LcTaskProgressCardReact=y,exports.LcTaskWorkflowReact=T,exports.t=s;
package/dist/react.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, c as t, d as n, f as r, i, l as a, o, r as s, s as c, u as l } from "./button-KoRq6mAW.js";
1
+ import { a as e, c as t, d as n, f as r, i, l as a, o, r as s, s as c, u as l } from "./button-C5RBeUy4.js";
2
2
  import { o as u } from "./constants-CdudjmSn.js";
3
3
  import { createComponent as d } from "@lit/react";
4
4
  import f from "react";
@@ -116,12 +116,12 @@ function D(e, t) {
116
116
  e.type = t.type ?? "button", e.variant = t.variant ?? "primary", e.disabled = !!t.disabled;
117
117
  }
118
118
  var O = f.forwardRef((e, t) => {
119
- let { children: n, className: r, type: i, variant: a, disabled: o, ...s } = e, c = f.useRef(null), l = {
119
+ let { children: n, className: r, type: i, variant: a, disabled: o, onClick: s, ...c } = e, l = f.useRef(null), u = {
120
120
  type: i,
121
121
  variant: a,
122
122
  disabled: o
123
- }, u = f.useCallback((e) => {
124
- c.current = e, e && D(e, l), C(t, e);
123
+ }, d = i ?? "button", m = f.useCallback((e) => {
124
+ l.current = e, e && D(e, u), C(t, e);
125
125
  }, [
126
126
  t,
127
127
  i,
@@ -129,15 +129,16 @@ var O = f.forwardRef((e, t) => {
129
129
  o
130
130
  ]);
131
131
  return f.useLayoutEffect(() => {
132
- c.current && D(c.current, l);
132
+ l.current && D(l.current, u);
133
133
  }, [
134
134
  i,
135
135
  a,
136
136
  o
137
- ]), f.createElement("lc-button", {
138
- ...s,
137
+ ]), w(l, p.REQUEST_SUBMIT, d === "submit" ? s : void 0), f.createElement("lc-button", {
138
+ ...c,
139
+ ...d === "submit" ? {} : { onClick: s },
139
140
  class: r,
140
- ref: u,
141
+ ref: m,
141
142
  suppressHydrationWarning: !0
142
143
  }, n);
143
144
  });
@@ -1,12 +1,6 @@
1
1
  import type { TaskWorkflowType, WorkflowPhase } from './constants.js';
2
2
  import type { TaskFieldDef, TaskTypeDef } from './task-types/index.js';
3
- import type { TaskProgressResult } from './types.js';
4
- export interface LightChainUploadRequestOptions {
5
- file: File;
6
- name: string;
7
- formData: FormData;
8
- field?: Pick<TaskFieldDef, 'name' | 'type'>;
9
- }
3
+ import type { ApiResponse, TaskProgressResult } from './types.js';
10
4
  export type LightChainUploadRequestResult = string | {
11
5
  value?: string;
12
6
  url?: string;
@@ -15,7 +9,7 @@ export type LightChainUploadRequestResult = string | {
15
9
  url?: string;
16
10
  };
17
11
  } | Response | null | undefined;
18
- export type LightChainUploadRequestFn = (options: LightChainUploadRequestOptions) => Promise<LightChainUploadRequestResult> | LightChainUploadRequestResult;
12
+ export type LightChainUploadRequestFn = (file: File) => Promise<LightChainUploadRequestResult> | LightChainUploadRequestResult;
19
13
  export interface LightChainSubmitDetail {
20
14
  taskId: string;
21
15
  endpoint: string;
@@ -40,6 +34,12 @@ export interface LightChainErrorDetail {
40
34
  phase: WorkflowPhase;
41
35
  taskId?: string;
42
36
  }
37
+ export type LightChainRequestResult<T = unknown> = Response | ApiResponse<T> | {
38
+ data: T;
39
+ } | {
40
+ data: ApiResponse<T>;
41
+ };
42
+ export type LightChainRequestFn = (url: string, data?: Record<string, unknown>) => Promise<LightChainRequestResult> | LightChainRequestResult;
43
43
  export interface LightChainClientOptions {
44
44
  type?: TaskWorkflowType | string;
45
45
  submitEndpoint?: string;
@@ -47,7 +47,7 @@ export interface LightChainClientOptions {
47
47
  pollEndpoint?: string;
48
48
  pollInterval?: number;
49
49
  maxPollAttempts?: number;
50
- customRequest?: typeof fetch;
50
+ customRequest?: LightChainRequestFn;
51
51
  customUploadRequest?: LightChainUploadRequestFn;
52
52
  customUploadRequert?: LightChainUploadRequestFn;
53
53
  onSubmit?: (detail: LightChainSubmitDetail) => void;
@@ -62,7 +62,7 @@ export declare class LightChainClient {
62
62
  pollEndpoint: string;
63
63
  pollInterval: number;
64
64
  maxPollAttempts: number;
65
- customRequest?: typeof fetch;
65
+ customRequest?: LightChainRequestFn;
66
66
  customUploadRequest?: LightChainUploadRequestFn;
67
67
  phase: WorkflowPhase;
68
68
  taskId: string;
@@ -22,7 +22,7 @@ export { LcImageCompareSlider } from './components/image-compare-slider/image-co
22
22
  export { LcTaskWorkflow } from './components/task-workflow/task-workflow.js';
23
23
  export { LcButton } from './components/button/button.js';
24
24
  export type { CustomRequestFn, CustomUploadRequestFn } from './components/task-workflow/task-workflow.js';
25
- export type { LightChainUploadRequestFn, LightChainUploadRequestOptions, LightChainUploadRequestResult, } from './core/client.js';
25
+ export type { LightChainRequestFn, LightChainRequestResult, LightChainUploadRequestFn, LightChainUploadRequestResult, } from './core/client.js';
26
26
  export type { WorkflowPhase } from './core/constants.js';
27
27
  /** 娉ㄥ唽鎵€鏈夌粍浠讹紙宸查€氳繃 side-effect import 鑷姩娉ㄥ唽锛?*/
28
28
  export declare function registerAllComponents(): void;
@@ -35,21 +35,22 @@ export declare const LcResultGalleryReact: import("@lit/react").ReactWebComponen
35
35
  }>;
36
36
  export declare const LcImageCompareSliderReact: import("@lit/react").ReactWebComponent<LcImageCompareSlider, {}>;
37
37
  type EventHandler = (event: Event) => void;
38
- export declare const LcTaskWorkflowReact: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<LcTaskWorkflow>, "type" | "onSubmit" | "onError"> & {
39
- type?: LcTaskWorkflow["type"];
40
- submitEndpoint?: LcTaskWorkflow["submitEndpoint"];
41
- pollEndpoint?: LcTaskWorkflow["pollEndpoint"];
42
- pollInterval?: LcTaskWorkflow["pollInterval"];
43
- maxPollAttempts?: LcTaskWorkflow["maxPollAttempts"];
44
- client?: LcTaskWorkflow["client"];
45
- customRequest?: LcTaskWorkflow["customRequest"];
46
- customUploadRequest?: LcTaskWorkflow["customUploadRequest"];
38
+ interface TaskWorkflowReactProps extends Omit<React.HTMLAttributes<LcTaskWorkflow>, 'onError' | 'onSubmit' | 'type'> {
39
+ type?: LcTaskWorkflow['type'];
40
+ submitEndpoint?: LcTaskWorkflow['submitEndpoint'];
41
+ pollEndpoint?: LcTaskWorkflow['pollEndpoint'];
42
+ pollInterval?: LcTaskWorkflow['pollInterval'];
43
+ maxPollAttempts?: LcTaskWorkflow['maxPollAttempts'];
44
+ client?: LcTaskWorkflow['client'];
45
+ customRequest?: LcTaskWorkflow['customRequest'];
46
+ customUploadRequest?: LcTaskWorkflow['customUploadRequest'];
47
47
  onSubmit?: EventHandler;
48
48
  onPoll?: EventHandler;
49
49
  onPolling?: EventHandler;
50
50
  onSuccess?: EventHandler;
51
51
  onError?: EventHandler;
52
- } & React.RefAttributes<LcTaskWorkflow>>;
52
+ }
53
+ export declare const LcTaskWorkflowReact: React.ForwardRefExoticComponent<TaskWorkflowReactProps & React.RefAttributes<LcTaskWorkflow>>;
53
54
  export declare const LcButtonReact: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<LcButton>, "type"> & {
54
55
  type?: LcButtonType;
55
56
  variant?: LcButtonVariant;
@@ -1,4 +1,4 @@
1
- export type { ApiResponse, CallbackImage, CallbackPayload, CallbackStatusValue, LightChainClientOptions, LightChainErrorDetail, LightChainPollDetail, LightChainSubmitDetail, LightChainSuccessDetail, LightChainUploadRequestFn, LightChainUploadRequestOptions, LightChainUploadRequestResult, TaskFieldDef, TaskProgressResult, TaskStatusValue, TaskSubmitResponse, TaskTypeDef, ValidationResult, AspectRatio, } from './core/index.js';
1
+ export type { ApiResponse, CallbackImage, CallbackPayload, CallbackStatusValue, LightChainClientOptions, LightChainErrorDetail, LightChainPollDetail, LightChainSubmitDetail, LightChainSuccessDetail, LightChainRequestFn, LightChainRequestResult, LightChainUploadRequestFn, LightChainUploadRequestResult, TaskFieldDef, TaskProgressResult, TaskStatusValue, TaskSubmitResponse, TaskTypeDef, ValidationResult, AspectRatio, } from './core/index.js';
2
2
  export type { FieldType, TaskWorkflowType, WorkflowPhase, } from './core/constants.js';
3
3
  export type { CustomRequestFn, CustomUploadRequestFn, } from './components/task-workflow/task-workflow.js';
4
4
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "light-chain-open-ui",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/lightchain-ui.cjs",
@@ -1 +0,0 @@
1
- require(`./client-CJ8X0sFi.cjs`);
@@ -1 +0,0 @@
1
- import "./client-jorIw6pH.js";