light-chain-open-ui 1.0.0 → 1.0.2

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.
@@ -0,0 +1,1101 @@
1
+ const e=require(`./client-Dt9_oZey.cjs`),t=require(`./constants-BTXokn3H.cjs`);require(`./react.cjs`);let n=require(`lit`);var r=e=>(t,n)=>{n===void 0?customElements.define(e,t):n.addInitializer(()=>{customElements.define(e,t)})},i=globalThis,a=i.ShadowRoot&&(i.ShadyCSS===void 0||i.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,o=Symbol(),s=new WeakMap,c=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==o)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(a&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=s.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&s.set(t,e))}return e}toString(){return this.cssText}},l=e=>new c(typeof e==`string`?e:e+``,void 0,o),u=(e,t)=>{if(a)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let n of t){let t=document.createElement(`style`),r=i.litNonce;r!==void 0&&t.setAttribute(`nonce`,r),t.textContent=n.cssText,e.appendChild(t)}},d=a?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return l(t)})(e):e,{is:ee,defineProperty:te,getOwnPropertyDescriptor:ne,getOwnPropertyNames:re,getOwnPropertySymbols:ie,getPrototypeOf:ae}=Object,f=globalThis,oe=f.trustedTypes,se=oe?oe.emptyScript:``,ce=f.reactiveElementPolyfillSupport,p=(e,t)=>e,m={toAttribute(e,t){switch(t){case Boolean:e=e?se:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},le=(e,t)=>!ee(e,t),ue={attribute:!0,type:String,converter:m,reflect:!1,useDefault:!1,hasChanged:le};Symbol.metadata??=Symbol(`metadata`),f.litPropertyMetadata??=new WeakMap;var h=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=ue){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){let n=Symbol(),r=this.getPropertyDescriptor(e,n,t);r!==void 0&&te(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){let{get:r,set:i}=ne(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:r,set(t){let a=r?.call(this);i?.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??ue}static _$Ei(){if(this.hasOwnProperty(p(`elementProperties`)))return;let e=ae(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(p(`finalized`)))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(p(`properties`))){let e=this.properties,t=[...re(e),...ie(e)];for(let n of t)this.createProperty(n,e[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let n=this._$Eu(e,t);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let e of n)t.unshift(d(e))}else e!==void 0&&t.push(d(e));return t}static _$Eu(e,t){let n=t.attribute;return!1===n?void 0:typeof n==`string`?n:typeof e==`string`?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return u(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){let n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&!0===n.reflect){let i=(n.converter?.toAttribute===void 0?m:n.converter).toAttribute(t,n.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,t){let n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let e=n.getPropertyOptions(r),i=typeof e.converter==`function`?{fromAttribute:e.converter}:e.converter?.fromAttribute===void 0?m:e.converter;this._$Em=r;let a=i.fromAttribute(t,e.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,n,r=!1,i){if(e!==void 0){let a=this.constructor;if(!1===r&&(i=this[e]),n??=a.getPropertyOptions(e),!((n.hasChanged??le)(i,t)||n.useDefault&&n.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:r,wrapped:i},a){n&&!(this._$Ej??=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??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}let e=this.constructor.elementProperties;if(e.size>0)for(let[t,n]of e){let{wrapped:e}=n,r=this[t];!0!==e||this._$AL.has(t)||r===void 0||this.C(t,void 0,n,r)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};h.elementStyles=[],h.shadowRootOptions={mode:`open`},h[p(`elementProperties`)]=new Map,h[p(`finalized`)]=new Map,ce?.({ReactiveElement:h}),(f.reactiveElementVersions??=[]).push(`2.1.2`);var de={attribute:!0,type:String,converter:m,reflect:!1,hasChanged:le},fe=(e=de,t,n)=>{let{kind:r,metadata:i}=n,a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),r===`setter`&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),r===`accessor`){let{name:r}=n;return{set(n){let i=t.get.call(this);t.set.call(this,n),this.requestUpdate(r,i,e,!0,n)},init(t){return t!==void 0&&this.C(r,void 0,e,t),t}}}if(r===`setter`){let{name:r}=n;return function(n){let i=this[r];t.call(this,n),this.requestUpdate(r,i,e,!0,n)}}throw Error(`Unsupported decorator location: `+r)};function g(e){return(t,n)=>typeof n==`object`?fe(e,t,n):((e,t,n)=>{let r=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),r?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function _(e){return g({...e,state:!0,attribute:!1})}var pe=(e,t,n)=>(n.configurable=!0,n.enumerable=!0,Reflect.decorate&&typeof t!=`object`&&Object.defineProperty(e,t,n),n);function me(e,t){return(n,r,i)=>{let a=t=>t.renderRoot?.querySelector(e)??null;if(t){let{get:e,set:t}=typeof r==`object`?n:i??(()=>{let e=Symbol();return{get(){return this[e]},set(t){this[e]=t}}})();return pe(n,r,{get(){let n=e.call(this);return n===void 0&&(n=a(this),(n!==null||this.hasUpdated)&&t.call(this,n)),n}})}return pe(n,r,{get(){return a(this)}})}}function v(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);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);return i>3&&a&&Object.defineProperty(t,n,a),a}var y=class extends n.LitElement{constructor(...e){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}static{this.styles=n.css`
2
+ :host {
3
+ display: block;
4
+ --lc-uploader-border-color: var(--lc-color-border);
5
+ --lc-uploader-border-style: dashed;
6
+ --lc-uploader-border-width: 2px;
7
+ --lc-uploader-border-radius: var(--lc-radius-component);
8
+ --lc-uploader-bg: var(--lc-color-bg);
9
+ --lc-uploader-bg-hover: var(--lc-color-primary-light);
10
+ --lc-uploader-padding: var(--lc-spacing-6);
11
+ --lc-uploader-icon-size: 48px;
12
+ --lc-uploader-icon-color: var(--lc-color-text-secondary);
13
+ --lc-uploader-placeholder-color: var(--lc-color-text-placeholder);
14
+ --lc-uploader-error-color: var(--lc-color-error);
15
+ }
16
+
17
+ :host([disabled]) {
18
+ opacity: 0.5;
19
+ pointer-events: none;
20
+ }
21
+
22
+ .container {
23
+ display: flex;
24
+ flex-direction: column;
25
+ gap: var(--lc-spacing-2);
26
+ }
27
+
28
+ .label {
29
+ color: var(--lc-color-text);
30
+ font-size: var(--lc-font-size-sm);
31
+ font-weight: 500;
32
+ }
33
+
34
+ .dropzone {
35
+ display: flex;
36
+ flex-direction: column;
37
+ align-items: center;
38
+ justify-content: center;
39
+ gap: var(--lc-spacing-2);
40
+ border: var(--lc-uploader-border-width) var(--lc-uploader-border-style)
41
+ var(--lc-uploader-border-color);
42
+ border-radius: var(--lc-uploader-border-radius);
43
+ background: var(--lc-uploader-bg);
44
+ padding: var(--lc-uploader-padding);
45
+ cursor: pointer;
46
+ transition: background var(--lc-transition-fast),
47
+ border-color var(--lc-transition-fast);
48
+ min-height: 160px;
49
+ }
50
+
51
+ .dropzone:hover {
52
+ background: var(--lc-uploader-bg-hover);
53
+ border-color: var(--lc-color-primary);
54
+ }
55
+
56
+ .dropzone.dragover {
57
+ background: var(--lc-uploader-bg-hover);
58
+ border-color: var(--lc-color-primary);
59
+ }
60
+
61
+ .dropzone-icon {
62
+ width: var(--lc-uploader-icon-size);
63
+ height: var(--lc-uploader-icon-size);
64
+ color: var(--lc-uploader-icon-color);
65
+ }
66
+
67
+ .dropzone-text {
68
+ font-size: var(--lc-font-size-sm);
69
+ color: var(--lc-uploader-placeholder-color);
70
+ }
71
+
72
+ .hidden-input {
73
+ display: none;
74
+ }
75
+
76
+ .preview {
77
+ position: relative;
78
+ border-radius: var(--lc-uploader-border-radius);
79
+ overflow: hidden;
80
+ border: var(--lc-uploader-border-width) solid var(--lc-color-border);
81
+ }
82
+
83
+ .preview img {
84
+ display: block;
85
+ max-width: 100%;
86
+ max-height: 300px;
87
+ object-fit: contain;
88
+ }
89
+
90
+ .preview-remove {
91
+ position: absolute;
92
+ top: var(--lc-spacing-1);
93
+ right: var(--lc-spacing-1);
94
+ width: 28px;
95
+ height: 28px;
96
+ border: none;
97
+ border-radius: var(--lc-radius-full);
98
+ background: rgba(0, 0, 0, 0.5);
99
+ color: #fff;
100
+ font-size: var(--lc-font-size-base);
101
+ line-height: 1;
102
+ cursor: pointer;
103
+ display: flex;
104
+ align-items: center;
105
+ justify-content: center;
106
+ transition: background var(--lc-transition-fast);
107
+ }
108
+
109
+ .preview-remove:hover {
110
+ background: rgba(0, 0, 0, 0.7);
111
+ }
112
+
113
+ .hint {
114
+ font-size: var(--lc-font-size-xs);
115
+ color: var(--lc-color-text-secondary);
116
+ }
117
+
118
+ .error {
119
+ font-size: var(--lc-font-size-xs);
120
+ color: var(--lc-uploader-error-color);
121
+ }
122
+
123
+ .mask-hint {
124
+ font-size: var(--lc-font-size-xs);
125
+ color: var(--lc-color-text-secondary);
126
+ margin-top: var(--lc-spacing-1);
127
+ }
128
+ `}disconnectedCallback(){super.disconnectedCallback(),this._cleanupPreview()}_cleanupPreview(){this._previewUrl&&URL.revokeObjectURL(this._previewUrl)}_handleClick(){this._fileInput?.click()}_handleDragOver(e){e.preventDefault(),this._isDragOver=!0}_handleDragLeave(){this._isDragOver=!1}_handleDrop(e){e.preventDefault(),this._isDragOver=!1;let t=e.dataTransfer?.files[0];t&&this._processFile(t)}_handleFileChange(e){let t=e.target,n=t.files?.[0];n&&this._processFile(n),t.value=``}async _processFile(t){this._errorMessage=``;let n=await e.l(t);if(!n.valid){this._errorMessage=n.errors.join(`; `),this.value=``,this.file=null,this._dispatchChange(null);return}let r=URL.createObjectURL(t);this._cleanupPreview(),this._previewUrl=r,this.file=t,this.value=r,this._dispatchChange(t)}_handleRemove(e){e.stopPropagation(),this._cleanupPreview(),this._previewUrl=``,this.value=``,this.file=null,this._errorMessage=``,this._dispatchChange(null)}_dispatchChange(e){this.dispatchEvent(new CustomEvent(t.o.CHANGE,{detail:{value:this.value,file:e},bubbles:!0,composed:!0}))}render(){let e=this._previewUrl||this.value;return n.html`
129
+ <div class="container" part="container">
130
+ ${this.label?n.html`<label class="label" part="label">${this.label}</label>`:n.nothing}
131
+ ${e?this._renderPreview():this._renderDropzone()}
132
+ ${this._errorMessage?n.html`<div class="error">${this._errorMessage}</div>`:n.nothing}
133
+ ${this.hint&&!this.showMaskHint?n.html`<div class="hint" part="hint">${this.hint}</div>`:n.nothing}
134
+ ${this.showMaskHint?this._renderMaskHint():n.nothing}
135
+ </div>
136
+ `}_renderDropzone(){return n.html`
137
+ <div
138
+ class="${this._isDragOver?`dropzone dragover`:`dropzone`}"
139
+ part="dropzone"
140
+ @click=${this._handleClick}
141
+ @dragover=${this._handleDragOver}
142
+ @dragleave=${this._handleDragLeave}
143
+ @drop=${this._handleDrop}
144
+ >
145
+ <svg
146
+ class="dropzone-icon"
147
+ viewBox="0 0 48 48"
148
+ fill="none"
149
+ xmlns="http://www.w3.org/2000/svg"
150
+ >
151
+ <path
152
+ d="M24 6v24M24 6l-7 7M24 6l7 7"
153
+ stroke="currentColor"
154
+ stroke-width="3"
155
+ stroke-linecap="round"
156
+ stroke-linejoin="round"
157
+ />
158
+ <path
159
+ d="M8 30v8a4 4 0 004 4h24a4 4 0 004-4v-8"
160
+ stroke="currentColor"
161
+ stroke-width="3"
162
+ stroke-linecap="round"
163
+ stroke-linejoin="round"
164
+ />
165
+ </svg>
166
+ <span class="dropzone-text">点击或拖拽图片到此处</span>
167
+ <input
168
+ class="hidden-input"
169
+ type="file"
170
+ accept="image/*"
171
+ ?disabled=${this.disabled}
172
+ @change=${this._handleFileChange}
173
+ />
174
+ </div>
175
+ `}_renderPreview(){return n.html`
176
+ <div class="preview" part="preview">
177
+ <img src="${this._previewUrl||this.value}" alt="预览" />
178
+ <button
179
+ class="preview-remove"
180
+ @click=${this._handleRemove}
181
+ aria-label="删除图片"
182
+ >
183
+ &times;
184
+ </button>
185
+ </div>
186
+ `}_renderMaskHint(){return n.html`<div class="mask-hint" part="hint">${this.hint||`Mask hint: white keeps the area, black removes the area`}</div>`}};v([g({type:String})],y.prototype,`name`,void 0),v([g({type:String})],y.prototype,`label`,void 0),v([g({type:String})],y.prototype,`hint`,void 0),v([g({type:String})],y.prototype,`value`,void 0),v([g({attribute:!1})],y.prototype,`file`,void 0),v([g({type:Boolean})],y.prototype,`disabled`,void 0),v([g({type:Boolean})],y.prototype,`showMaskHint`,void 0),v([_()],y.prototype,`_previewUrl`,void 0),v([_()],y.prototype,`_errorMessage`,void 0),v([_()],y.prototype,`_isDragOver`,void 0),v([me(`input[type="file"]`)],y.prototype,`_fileInput`,void 0),y=v([r(`lc-image-uploader`)],y);var b=class extends n.LitElement{constructor(...e){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}static{this.styles=n.css`
187
+ :host {
188
+ display: block;
189
+ --lc-mask-border-color: var(--lc-color-border);
190
+ --lc-mask-border-radius: var(--lc-radius-component);
191
+ --lc-mask-bg: var(--lc-color-bg);
192
+ --lc-mask-bg-muted: var(--lc-color-bg-secondary, #f5f5f5);
193
+ --lc-mask-padding: var(--lc-spacing-4);
194
+ --lc-mask-error-color: var(--lc-color-error);
195
+ }
196
+
197
+ :host([disabled]) {
198
+ opacity: 0.5;
199
+ pointer-events: none;
200
+ }
201
+
202
+ .container {
203
+ display: flex;
204
+ flex-direction: column;
205
+ gap: var(--lc-spacing-2);
206
+ }
207
+
208
+ .label {
209
+ font-size: var(--lc-font-size-sm);
210
+ color: var(--lc-color-text);
211
+ font-weight: 500;
212
+ }
213
+
214
+ .required {
215
+ color: var(--lc-color-error);
216
+ margin-left: 2px;
217
+ }
218
+
219
+ .empty {
220
+ min-height: 160px;
221
+ display: flex;
222
+ align-items: center;
223
+ justify-content: center;
224
+ padding: var(--lc-mask-padding);
225
+ border: 1px dashed var(--lc-mask-border-color);
226
+ border-radius: var(--lc-mask-border-radius);
227
+ background: var(--lc-mask-bg-muted);
228
+ color: var(--lc-color-text-secondary);
229
+ font-size: var(--lc-font-size-sm);
230
+ text-align: center;
231
+ }
232
+
233
+ .editor {
234
+ border: 1px solid var(--lc-mask-border-color);
235
+ border-radius: var(--lc-mask-border-radius);
236
+ overflow: hidden;
237
+ background: var(--lc-mask-bg);
238
+ }
239
+
240
+ .stage {
241
+ position: relative;
242
+ width: 100%;
243
+ aspect-ratio: var(--lc-mask-aspect-ratio, 1 / 1);
244
+ max-height: 420px;
245
+ background: var(--lc-mask-bg-muted);
246
+ touch-action: none;
247
+ overflow: hidden;
248
+ }
249
+
250
+ .stage img,
251
+ .stage canvas {
252
+ position: absolute;
253
+ inset: 0;
254
+ width: 100%;
255
+ height: 100%;
256
+ display: block;
257
+ transform: translate(var(--lc-mask-pan-x, 0px), var(--lc-mask-pan-y, 0px)) scale(var(--lc-mask-zoom, 1));
258
+ transform-origin: 0 0;
259
+ }
260
+
261
+ .stage:focus {
262
+ outline: none;
263
+ }
264
+
265
+ .stage img {
266
+ object-fit: contain;
267
+ user-select: none;
268
+ pointer-events: none;
269
+ }
270
+
271
+ canvas {
272
+ cursor: crosshair;
273
+ }
274
+
275
+ canvas.panning {
276
+ cursor: grab;
277
+ }
278
+
279
+ canvas.dragging {
280
+ cursor: grabbing;
281
+ }
282
+
283
+ .toolbar {
284
+ display: flex;
285
+ align-items: center;
286
+ gap: var(--lc-spacing-2);
287
+ padding: var(--lc-spacing-2);
288
+ border-top: 1px solid var(--lc-mask-border-color);
289
+ background: var(--lc-mask-bg);
290
+ }
291
+
292
+ .toolbar button {
293
+ min-height: 30px;
294
+ padding: 0 var(--lc-spacing-3);
295
+ border: 1px solid var(--lc-color-border);
296
+ border-radius: var(--lc-radius-sm);
297
+ background: var(--lc-color-bg);
298
+ color: var(--lc-color-text);
299
+ cursor: pointer;
300
+ }
301
+
302
+ .toolbar button.active {
303
+ border-color: var(--lc-color-primary);
304
+ color: var(--lc-color-primary);
305
+ background: var(--lc-color-primary-light);
306
+ }
307
+
308
+ .toolbar button:disabled {
309
+ opacity: 0.45;
310
+ cursor: not-allowed;
311
+ }
312
+
313
+ .toolbar input {
314
+ width: 96px;
315
+ }
316
+
317
+ .zoom-value {
318
+ min-width: 44px;
319
+ font-size: var(--lc-font-size-xs);
320
+ color: var(--lc-color-text-secondary);
321
+ text-align: right;
322
+ }
323
+
324
+ .hint,
325
+ .mask-hint {
326
+ font-size: var(--lc-font-size-xs);
327
+ color: var(--lc-color-text-secondary);
328
+ }
329
+
330
+ .error {
331
+ font-size: var(--lc-font-size-xs);
332
+ color: var(--lc-mask-error-color);
333
+ }
334
+ `}firstUpdated(){this._setupCanvas()}updated(e){e.has(`source`)&&this._loadSource()}disconnectedCallback(){this._resizeObserver?.disconnect(),super.disconnectedCallback()}_setupCanvas(){if(this._ctx=this._canvas?.getContext(`2d`)??void 0,typeof ResizeObserver<`u`){this._resizeObserver=new ResizeObserver(()=>this._resizeCanvas());let e=this.renderRoot.querySelector(`.stage`);e&&this._resizeObserver.observe(e)}this._resizeCanvas()}async _loadSource(){if(this._errorMessage=``,this.value=``,await this.updateComplete,this._setupCanvas(),!this.source){this._clearCanvas(!1),this._resetHistory();return}let e=new Image;e.onload=()=>{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()},e.onerror=()=>{this._errorMessage=`无法加载原图,请重新上传图片`},e.src=this.source}_resizeCanvas(){let e=this._canvas;if(!e)return;let t=e.getBoundingClientRect(),n=Math.max(1,Math.round(t.width)),r=Math.max(1,Math.round(t.height));if(e.width===n&&e.height===r)return;let i=e.width&&e.height?e.toDataURL(`image/png`):``;if(e.width=n,e.height=r,this._ctx=e.getContext(`2d`)??void 0,i){let e=new Image;e.onload=()=>{this._ctx?.drawImage(e,0,0,n,r),this._syncValue()},e.src=i}}_clearCanvas(e=!0){let t=this._canvas;!t||!this._ctx||(this._ctx.clearRect(0,0,t.width,t.height),this._syncValue(),e&&this._commitHistory())}_handlePointerDown(e){if(!this.source||this.disabled)return;if(this._focusStage(e),this._isSpacePressed){this._isPanning=!0,this._lastPanPoint={x:e.clientX,y:e.clientY},this._canvas?.setPointerCapture(e.pointerId);return}this._isDrawing=!0,this._canvas?.setPointerCapture(e.pointerId);let t=this._getCanvasPoint(e);if(!this._isPointInCanvas(t)){this._isDrawing=!1,this._lastPoint=null;return}this._lastPoint=t,this._drawPoint(t)}_handleWheel(e){if(!this.source||this.disabled)return;e.preventDefault();let t=e.deltaY<0?1.12:.88;this._setZoomAt(this._zoom*t,e)}_handlePointerMove(e){if(this._isPanning){this._pan(e);return}this._isDrawing&&(typeof e.getCoalescedEvents==`function`?e.getCoalescedEvents():[e]).forEach(e=>{let t=this._getCanvasPoint(e);if(!this._isPointInCanvas(t)){this._lastPoint=null;return}this._drawLineTo(t)})}_handlePointerUp(e){if(this._isPanning){this._isPanning=!1,this._lastPanPoint=null,this._canvas?.releasePointerCapture(e.pointerId);return}if(!this._isDrawing)return;let t=this._getCanvasPoint(e);this._isPointInCanvas(t)&&this._drawLineTo(t),this._isDrawing=!1,this._lastPoint=null,this._canvas?.releasePointerCapture(e.pointerId),this._syncValue(),this._commitHistory()}_focusStage(e){(e.currentTarget?.closest(`.stage`))?.focus({preventScroll:!0})}_handleKeyDown(e){e.code===`Space`&&(e.preventDefault(),this._isSpacePressed=!0)}_handleKeyUp(e){e.code===`Space`&&(e.preventDefault(),this._isSpacePressed=!1,this._isPanning=!1,this._lastPanPoint=null)}_handleBlur(){this._isSpacePressed=!1,this._isPanning=!1,this._lastPanPoint=null}_pan(e){if(!this._lastPanPoint){this._lastPanPoint={x:e.clientX,y:e.clientY};return}let t=e.clientX-this._lastPanPoint.x,n=e.clientY-this._lastPanPoint.y;this._lastPanPoint={x:e.clientX,y:e.clientY},this._setPan(this._panX+t,this._panY+n)}_getCanvasPoint(e){let t=this._canvas;if(!t)return{x:0,y:0};let n=t.getBoundingClientRect(),r=n.width?t.width/n.width:1,i=n.height?t.height/n.height:1;return{x:(e.clientX-n.left)*r,y:(e.clientY-n.top)*i}}_getStagePoint(e){let t=this.renderRoot.querySelector(`.stage`);if(!t)return{x:0,y:0};let n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}_isPointInCanvas(e){let t=this._getImageCanvasRect();if(t)return e.x>=t.x&&e.x<=t.x+t.width&&e.y>=t.y&&e.y<=t.y+t.height;let n=this._canvas;return n?e.x>=0&&e.x<=n.width&&e.y>=0&&e.y<=n.height:!1}_getImageCanvasRect(){let e=this._canvas;if(!e||!this._sourceWidth||!this._sourceHeight)return null;let t=this._sourceWidth/this._sourceHeight,n=e.width/e.height,r=e.width,i=e.height,a=0,o=0;return n>t?(r=i*t,a=(e.width-r)/2):n<t&&(i=r/t,o=(e.height-i)/2),{x:a,y:o,width:r,height:i}}_drawPoint(e){let t=this._ctx;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())}_drawLineTo(e){let t=this._ctx;if(t){if(!this._isPointInCanvas(e)){this._lastPoint=null;return}if(!this._lastPoint){this._lastPoint=e,this._drawPoint(e);return}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}}_clipToImage(e){let t=this._getImageCanvasRect();t&&(e.beginPath(),e.rect(t.x,t.y,t.width,t.height),e.clip())}_syncValue(){let e=this._canvas;this.value=this.source&&e?e.toDataURL(`image/png`):``,this.dispatchEvent(new CustomEvent(t.o.CHANGE,{detail:{value:this.value},bubbles:!0,composed:!0}))}_setZoom(e){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)}_setZoomAt(e,t){let n=this._zoom,r=Math.min(5,Math.max(1,Number(e.toFixed(2))));if(r===n)return;let i=this._getStagePoint(t),a={x:(i.x-this._panX)/n,y:(i.y-this._panY)/n};if(this._zoom=r,this.style.setProperty(`--lc-mask-zoom`,String(this._zoom)),this._zoom===1){this._setPan(0,0);return}this._setPan(i.x-a.x*this._zoom,i.y-a.y*this._zoom)}_setPan(e,t){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`)}_resetView(){this._setZoom(1),this._setPan(0,0)}_resetHistory(){this._history=[this.value],this._historyIndex=0,this._updateHistoryState()}_commitHistory(){if(!this.source)return;let e=this.value;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())}_updateHistoryState(){this._canUndo=this._historyIndex>0,this._canRedo=this._historyIndex>=0&&this._historyIndex<this._history.length-1}_undo(){this._canUndo&&(--this._historyIndex,this._restoreHistory())}_redo(){this._canRedo&&(this._historyIndex+=1,this._restoreHistory())}_restoreHistory(){let e=this._history[this._historyIndex]??``;this._restoreSnapshot(e),this._updateHistoryState()}_restoreSnapshot(e){let t=this._canvas,n=this._ctx;if(!t||!n)return;if(n.clearRect(0,0,t.width,t.height),!e){this._syncValue();return}let r=new Image;r.onload=()=>{n.clearRect(0,0,t.width,t.height),n.drawImage(r,0,0,t.width,t.height),this._syncValue()},r.src=e}render(){return n.html`
335
+ <div class="container" part="container">
336
+ ${this._renderLabel()}
337
+ ${this.source?this._renderEditor():this._renderEmpty()}
338
+ ${this._errorMessage?n.html`<div class="error">${this._errorMessage}</div>`:n.nothing}
339
+ ${this.hint?n.html`<div class="hint" part="hint">${this.hint}</div>`:n.nothing}
340
+ <div class="mask-hint">先上传原图,再在图片上涂抹需要处理的区域。</div>
341
+ </div>
342
+ `}_renderLabel(){return n.html`
343
+ <label class="label" part="label">
344
+ ${this.label}${this.required?n.html`<span class="required">*</span>`:n.nothing}
345
+ </label>
346
+ `}_renderEmpty(){return n.html`
347
+ <div class="empty" part="editor">
348
+ 请先上传原图,随后在这里涂抹生成蒙版
349
+ </div>
350
+ `}_renderEditor(){return n.html`
351
+ <div class="editor" part="editor">
352
+ <div
353
+ class="stage"
354
+ tabindex="0"
355
+ @wheel=${this._handleWheel}
356
+ @keydown=${this._handleKeyDown}
357
+ @keyup=${this._handleKeyUp}
358
+ @blur=${this._handleBlur}
359
+ @pointerenter=${this._focusStage}
360
+ >
361
+ <img src=${this.source} alt="原图" />
362
+ <canvas
363
+ class=${this._isPanning?`dragging`:this._isSpacePressed?`panning`:``}
364
+ part="canvas"
365
+ @pointerdown=${this._handlePointerDown}
366
+ @pointermove=${this._handlePointerMove}
367
+ @pointerup=${this._handlePointerUp}
368
+ @pointercancel=${this._handlePointerUp}
369
+ ></canvas>
370
+ </div>
371
+ <div class="toolbar">
372
+ <button
373
+ type="button"
374
+ class=${this._mode===`paint`?`active`:``}
375
+ @click=${()=>{this._mode=`paint`}}
376
+ >涂抹</button>
377
+ <button
378
+ type="button"
379
+ class=${this._mode===`erase`?`active`:``}
380
+ @click=${()=>{this._mode=`erase`}}
381
+ >擦除</button>
382
+ <button type="button" ?disabled=${!this._canUndo} @click=${this._undo}>撤销</button>
383
+ <button type="button" ?disabled=${!this._canRedo} @click=${this._redo}>重做</button>
384
+ <input
385
+ type="range"
386
+ min="8"
387
+ max="80"
388
+ .value=${String(this.brushSize)}
389
+ @input=${e=>{this.brushSize=Number(e.target.value)}}
390
+ />
391
+ <span class="zoom-value">${Math.round(this._zoom*100)}%</span>
392
+ <button type="button" @click=${()=>this._resetView()}>重置视图</button>
393
+ <button type="button" @click=${()=>this._clearCanvas()}>清空</button>
394
+ </div>
395
+ </div>
396
+ `}};v([g({type:String})],b.prototype,`label`,void 0),v([g({type:String})],b.prototype,`name`,void 0),v([g({type:String})],b.prototype,`hint`,void 0),v([g({type:Boolean})],b.prototype,`required`,void 0),v([g({type:String})],b.prototype,`value`,void 0),v([g({type:String})],b.prototype,`source`,void 0),v([g({type:Boolean})],b.prototype,`disabled`,void 0),v([g({type:Number})],b.prototype,`brushSize`,void 0),v([_()],b.prototype,`_mode`,void 0),v([_()],b.prototype,`_isDrawing`,void 0),v([_()],b.prototype,`_errorMessage`,void 0),v([_()],b.prototype,`_aspectRatio`,void 0),v([_()],b.prototype,`_canUndo`,void 0),v([_()],b.prototype,`_canRedo`,void 0),v([_()],b.prototype,`_zoom`,void 0),v([_()],b.prototype,`_isSpacePressed`,void 0),v([_()],b.prototype,`_isPanning`,void 0),v([_()],b.prototype,`_panX`,void 0),v([_()],b.prototype,`_panY`,void 0),v([me(`canvas`)],b.prototype,`_canvas`,void 0),b=v([r(`lc-mask-editor`)],b);var x=class extends n.LitElement{constructor(...e){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=`[]`}static{this.styles=n.css`
397
+ :host {
398
+ display: block;
399
+ font-family: var(--lc-font-family);
400
+ }
401
+
402
+ .label {
403
+ display: block;
404
+ font-size: var(--lc-font-size-sm);
405
+ color: var(--lc-color-text);
406
+ margin-bottom: var(--lc-spacing-2);
407
+ }
408
+
409
+ .label .required {
410
+ color: var(--lc-color-error);
411
+ margin-left: 2px;
412
+ }
413
+
414
+ .button-group {
415
+ display: flex;
416
+ flex-wrap: wrap;
417
+ gap: var(--lc-spacing-2);
418
+ }
419
+
420
+ .button-group.with-icon {
421
+ gap: var(--lc-spacing-3);
422
+ }
423
+
424
+ .btn {
425
+ display: inline-flex;
426
+ align-items: center;
427
+ justify-content: center;
428
+ gap: var(--lc-spacing-1);
429
+ padding: var(--lc-spacing-1) var(--lc-spacing-3);
430
+ border: 1px solid var(--lc-color-border);
431
+ border-radius: var(--lc-radius-sm);
432
+ background: var(--lc-color-bg);
433
+ color: var(--lc-color-text);
434
+ cursor: pointer;
435
+ font-size: var(--lc-font-size-sm);
436
+ font-family: var(--lc-font-family);
437
+ transition: all var(--lc-transition-fast);
438
+ }
439
+
440
+ .btn.with-icon {
441
+ min-width: 64px;
442
+ min-height: 64px;
443
+ flex-direction: column;
444
+ padding: var(--lc-spacing-2);
445
+ }
446
+
447
+ .btn:hover:not(.active):not(:disabled) {
448
+ border-color: var(--lc-color-primary);
449
+ }
450
+
451
+ .btn.active {
452
+ background: var(--lc-color-primary);
453
+ color: white;
454
+ border-color: var(--lc-color-primary);
455
+ }
456
+
457
+ .btn:disabled {
458
+ opacity: 0.5;
459
+ cursor: not-allowed;
460
+ }
461
+
462
+ .radio-group {
463
+ display: flex;
464
+ flex-direction: column;
465
+ gap: var(--lc-spacing-2);
466
+ }
467
+
468
+ .radio-item {
469
+ display: flex;
470
+ align-items: center;
471
+ gap: var(--lc-spacing-2);
472
+ cursor: pointer;
473
+ font-size: var(--lc-font-size-sm);
474
+ color: var(--lc-color-text);
475
+ }
476
+
477
+ .radio-item input {
478
+ accent-color: var(--lc-color-primary);
479
+ }
480
+
481
+ .radio-item.disabled {
482
+ opacity: 0.5;
483
+ cursor: not-allowed;
484
+ }
485
+
486
+ .option-icon {
487
+ display: inline-flex;
488
+ align-items: center;
489
+ justify-content: center;
490
+ color: var(--lc-color-text-secondary);
491
+ line-height: 1;
492
+ }
493
+
494
+ .btn.active .option-icon {
495
+ color: white;
496
+ }
497
+
498
+ .ratio-box {
499
+ border: 2px solid currentColor;
500
+ border-radius: 2px;
501
+ background: var(--lc-color-bg-secondary);
502
+ box-sizing: border-box;
503
+ }
504
+
505
+ .select-input {
506
+ width: 100%;
507
+ padding: var(--lc-spacing-1) var(--lc-spacing-2);
508
+ border: 1px solid var(--lc-color-border);
509
+ border-radius: var(--lc-radius-sm);
510
+ font-size: var(--lc-font-size-sm);
511
+ font-family: var(--lc-font-family);
512
+ color: var(--lc-color-text);
513
+ background: var(--lc-color-bg);
514
+ }
515
+
516
+ .select-input:focus {
517
+ outline: none;
518
+ border-color: var(--lc-color-primary);
519
+ }
520
+ `}get parsedOptions(){try{return JSON.parse(this.options)}catch{return[]}}get selectedValues(){if(Array.isArray(this.value))return this.value;if(this.multiple&&typeof this.value==`string`&&this.value)try{let e=JSON.parse(this.value);if(Array.isArray(e))return e.map(String)}catch{return this.value.split(`,`).map(e=>e.trim()).filter(Boolean)}return typeof this.value==`string`&&this.value?[this.value]:[]}isSelected(e){return this.selectedValues.includes(e)}emitChange(e){this.dispatchEvent(new CustomEvent(t.o.CHANGE,{detail:{value:e},bubbles:!0,composed:!0}))}getRatioBoxDimensions(e){let[t,n]=e.split(`:`).map(Number),r=32/Math.max(t,n);return{width:Math.round(t*r),height:Math.round(n*r)}}isRatioValue(e){return/^\d+(?:\.\d+)?:\d+(?:\.\d+)?$/.test(e)}renderOptionIcon(e){if(!this.showIcon)return n.nothing;if(e.icon)return n.html`<span class="option-icon" aria-hidden="true">${e.icon}</span>`;if(this.isRatioValue(e.value)){let t=this.getRatioBoxDimensions(e.value);return n.html`
521
+ <span class="option-icon" aria-hidden="true">
522
+ <span class="ratio-box" style="width: ${t.width}px; height: ${t.height}px;"></span>
523
+ </span>
524
+ `}return n.nothing}handleSelect(e){let t=e.target;this.value=this.multiple?Array.from(t.selectedOptions).map(e=>e.value):t.value,this.emitChange(this.value)}handleRadioChange(e){let t=e.target;this.value=t.value,this.emitChange(this.value)}handleCheckboxChange(e){let t=e.target,n=new Set(this.selectedValues);t.checked?n.add(t.value):n.delete(t.value),this.value=Array.from(n),this.emitChange(this.value)}handleButtonClick(e){if(!this.multiple){this.value=e,this.emitChange(e);return}let t=new Set(this.selectedValues);t.has(e)?t.delete(e):t.add(e),this.value=Array.from(t),this.emitChange(this.value)}render(){let e=this.parsedOptions;return n.html`
525
+ ${this.label?n.html`<label class="label">
526
+ ${this.label}${this.required?n.html`<span class="required">*</span>`:n.nothing}
527
+ </label>`:n.nothing}
528
+ ${this.mode===`button`?this.renderButtonGroup(e):this.mode===`radio`?this.renderRadioGroup(e):this.renderSelect(e)}
529
+ `}renderButtonGroup(e){return n.html`
530
+ <div class="button-group ${this.showIcon?`with-icon`:``}">
531
+ ${e.map(e=>n.html`
532
+ <button
533
+ type="button"
534
+ class="btn ${this.showIcon?`with-icon`:``} ${this.isSelected(e.value)?`active`:``}"
535
+ ?disabled=${this.disabled}
536
+ aria-pressed=${this.isSelected(e.value)}
537
+ @click=${()=>this.handleButtonClick(e.value)}
538
+ >
539
+ ${this.renderOptionIcon(e)}
540
+ ${e.label}
541
+ </button>
542
+ `)}
543
+ </div>
544
+ `}renderRadioGroup(e){return n.html`
545
+ <div class="radio-group">
546
+ ${e.map(e=>n.html`
547
+ <label class="radio-item ${this.disabled?`disabled`:``}">
548
+ <input
549
+ type=${this.multiple?`checkbox`:`radio`}
550
+ name="enum-radio"
551
+ .value=${e.value}
552
+ .checked=${this.isSelected(e.value)}
553
+ ?disabled=${this.disabled}
554
+ @change=${e=>{this.multiple?this.handleCheckboxChange(e):this.handleRadioChange(e)}}
555
+ />
556
+ ${this.renderOptionIcon(e)}
557
+ ${e.label}
558
+ </label>
559
+ `)}
560
+ </div>
561
+ `}renderSelect(e){return n.html`
562
+ <select
563
+ class="select-input"
564
+ .value=${this.multiple?``:String(this.value)}
565
+ ?multiple=${this.multiple}
566
+ ?disabled=${this.disabled}
567
+ @change=${this.handleSelect}
568
+ >
569
+ ${e.map(e=>n.html`<option value=${e.value} ?selected=${this.isSelected(e.value)}>
570
+ ${e.label}
571
+ </option>`)}
572
+ </select>
573
+ `}};v([g({type:String})],x.prototype,`label`,void 0),v([g({type:String})],x.prototype,`name`,void 0),v([g()],x.prototype,`value`,void 0),v([g({type:String})],x.prototype,`mode`,void 0),v([g({type:Boolean})],x.prototype,`multiple`,void 0),v([g({type:Boolean})],x.prototype,`required`,void 0),v([g({type:Boolean})],x.prototype,`disabled`,void 0),v([g({type:Boolean,attribute:`show-icon`})],x.prototype,`showIcon`,void 0),v([g({type:String})],x.prototype,`options`,void 0),x=v([r(`lc-enum-selector`)],x);var S=class extends n.LitElement{constructor(...e){super(...e),this.value=``,this.name=``,this.label=``,this.placeholder=``,this.maxLength=500,this.required=!1,this.disabled=!1}static{this.styles=n.css`
574
+ :host {
575
+ display: block;
576
+ font-family: var(--lc-font-family);
577
+ }
578
+
579
+ .label {
580
+ display: block;
581
+ font-size: var(--lc-font-size-sm);
582
+ color: var(--lc-color-text);
583
+ margin-bottom: var(--lc-spacing-2);
584
+ }
585
+
586
+ .label .required {
587
+ color: var(--lc-color-error);
588
+ margin-left: 2px;
589
+ }
590
+
591
+ .wrapper {
592
+ position: relative;
593
+ }
594
+
595
+ textarea {
596
+ width: 100%;
597
+ min-height: 80px;
598
+ padding: var(--lc-spacing-3);
599
+ border: 1px solid var(--lc-color-border);
600
+ border-radius: var(--lc-radius-component);
601
+ font-family: var(--lc-font-family);
602
+ font-size: var(--lc-font-size-sm);
603
+ color: var(--lc-color-text);
604
+ resize: vertical;
605
+ outline: none;
606
+ transition: border-color var(--lc-transition-fast);
607
+ box-sizing: border-box;
608
+ }
609
+
610
+ textarea:focus {
611
+ border-color: var(--lc-color-primary);
612
+ }
613
+
614
+ textarea::placeholder {
615
+ color: var(--lc-color-text-placeholder);
616
+ }
617
+
618
+ textarea:disabled {
619
+ opacity: 0.5;
620
+ cursor: not-allowed;
621
+ }
622
+
623
+ .counter {
624
+ text-align: right;
625
+ font-size: var(--lc-font-size-xs);
626
+ color: var(--lc-color-text-secondary);
627
+ margin-top: var(--lc-spacing-1);
628
+ }
629
+
630
+ .counter.over {
631
+ color: var(--lc-color-error);
632
+ }
633
+ `}emitChange(e){this.dispatchEvent(new CustomEvent(t.o.CHANGE,{detail:{value:e},bubbles:!0,composed:!0}))}handleInput(e){let t=e.target;this.value=t.value,this.emitChange(this.value)}render(){let e=this.value.length>this.maxLength;return n.html`
634
+ ${this.label?n.html`<label class="label">
635
+ ${this.label}${this.required?n.html`<span class="required">*</span>`:n.nothing}
636
+ </label>`:n.nothing}
637
+ <div class="wrapper">
638
+ <textarea
639
+ .value=${this.value}
640
+ .placeholder=${this.placeholder}
641
+ ?disabled=${this.disabled}
642
+ .maxLength=${this.maxLength}
643
+ @input=${this.handleInput}
644
+ ></textarea>
645
+ </div>
646
+ <div class="counter ${e?`over`:``}">
647
+ ${this.value.length}/${this.maxLength}
648
+ </div>
649
+ `}};v([g({type:String})],S.prototype,`value`,void 0),v([g({type:String})],S.prototype,`name`,void 0),v([g({type:String})],S.prototype,`label`,void 0),v([g({type:String})],S.prototype,`placeholder`,void 0),v([g({type:Number})],S.prototype,`maxLength`,void 0),v([g({type:Boolean})],S.prototype,`required`,void 0),v([g({type:Boolean})],S.prototype,`disabled`,void 0),S=v([r(`lc-prompt-input`)],S);var C=globalThis,he=e=>e,w=C.trustedTypes,ge=w?w.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,T=`$lit$`,E=`lit$${Math.random().toFixed(9).slice(2)}$`,D=`?`+E,_e=`<${D}>`,O=document,k=()=>O.createComment(``),A=e=>e===null||typeof e!=`object`&&typeof e!=`function`,j=Array.isArray,ve=e=>j(e)||typeof e?.[Symbol.iterator]==`function`,M=`[
650
+ \f\r]`,N=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ye=/-->/g,be=/>/g,P=RegExp(`>|${M}(?:([^\\s"'>=/]+)(${M}*=${M}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),xe=/'/g,Se=/"/g,Ce=/^(?:script|style|textarea|title)$/i,F=Symbol.for(`lit-noChange`),I=Symbol.for(`lit-nothing`),we=new WeakMap,L=O.createTreeWalker(O,129);function Te(e,t){if(!j(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return ge===void 0?t:ge.createHTML(t)}var Ee=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=N;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===N?c[1]===`!--`?o=ye:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=P):(Ce.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=P):o=be:o===P?c[0]===`>`?(o=i??N,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?P:c[3]===`"`?Se:xe):o===Se||o===xe?o=P:o===ye||o===be?o=N:(o=P,i=void 0);let d=o===P&&e[t+1].startsWith(`/>`)?` `:``;a+=o===N?n+_e:l>=0?(r.push(s),n.slice(0,l)+T+n.slice(l)+E+d):n+E+(l===-2?t:d)}return[Te(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},R=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=Ee(t,n);if(this.el=e.createElement(l,r),L.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=L.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(T)){let t=u[o++],n=i.getAttribute(e).split(E),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?Oe:r[1]===`?`?ke:r[1]===`@`?Ae:V}),i.removeAttribute(e)}else e.startsWith(E)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(Ce.test(i.tagName)){let e=i.textContent.split(E),t=e.length-1;if(t>0){i.textContent=w?w.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],k()),L.nextNode(),c.push({type:2,index:++a});i.append(e[t],k())}}}else if(i.nodeType===8)if(i.data===D)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(E,e+1))!==-1;)c.push({type:7,index:a}),e+=E.length-1}a++}}static createElement(e,t){let n=O.createElement(`template`);return n.innerHTML=e,n}};function z(e,t,n=e,r){if(t===F)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=A(t)?void 0:t._$litDirective$;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=z(e,i._$AS(e,t.values),i,r)),t}var De=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??O).importNode(t,!0);L.currentNode=r;let i=L.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new B(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new je(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=L.nextNode(),a++)}return L.currentNode=O,r}p(e){let t=0;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++}},B=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=I,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=z(this,e,t),A(e)?e===I||e==null||e===``?(this._$AH!==I&&this._$AR(),this._$AH=I):e!==this._$AH&&e!==F&&this._(e):e._$litType$===void 0?e.nodeType===void 0?ve(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==I&&A(this._$AH)?this._$AA.nextSibling.data=e:this.T(O.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=R.createElement(Te(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new De(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=we.get(e.strings);return t===void 0&&we.set(e.strings,t=new R(e)),t}k(t){j(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(k()),this.O(k()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=he(e).nextSibling;he(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},V=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=I,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(new String),this.strings=n):this._$AH=I}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=z(this,e,t,0),a=!A(e)||e!==this._$AH&&e!==F,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=z(this,r[n+o],t,o),s===F&&(s=this._$AH[o]),a||=!A(s)||s!==this._$AH[o],s===I?e=I:e!==I&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===I?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},Oe=class extends V{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===I?void 0:e}},ke=class extends V{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==I)}},Ae=class extends V{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=z(this,e,t,0)??I)===F)return;let n=this._$AH,r=e===I&&n!==I||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==I&&(n===I||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},je=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){z(this,e)}},Me={M:T,P:E,A:D,C:1,L:Ee,R:De,D:ve,V:z,I:B,H:V,N:ke,U:Ae,B:Oe,F:je},Ne=C.litHtmlPolyfillSupport;Ne?.(R,B),(C.litHtmlVersions??=[]).push(`3.3.3`);var{I:Pe}=Me,Fe=e=>e.strings===void 0,Ie={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Le=e=>(...t)=>({_$litDirective$:e,values:t}),Re=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}},H=(e,t)=>{let n=e._$AN;if(n===void 0)return!1;for(let e of n)e._$AO?.(t,!1),H(e,t);return!0},U=e=>{let t,n;do{if((t=e._$AM)===void 0)break;n=t._$AN,n.delete(e),e=t}while(n?.size===0)},ze=e=>{for(let t;t=e._$AM;e=t){let n=t._$AN;if(n===void 0)t._$AN=n=new Set;else if(n.has(e))break;n.add(e),He(t)}};function Be(e){this._$AN===void 0?this._$AM=e:(U(this),this._$AM=e,ze(this))}function Ve(e,t=!1,n=0){let r=this._$AH,i=this._$AN;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]);else r!=null&&(H(r,!1),U(r));else H(this,e)}var He=e=>{e.type==Ie.CHILD&&(e._$AP??=Ve,e._$AQ??=Be)},Ue=class extends Re{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,n){super._$AT(e,t,n),ze(this),this.isConnected=e._$AU}_$AO(e,t=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),t&&(H(this,e),U(this))}setValue(e){if(Fe(this._$Ct))this._$Ct._$AI(e,this);else{let t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}},We=()=>new Ge,Ge=class{},W=new WeakMap,Ke=Le(class extends Ue{render(e){return I}update(e,[t]){let n=t!==this.G;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)),I}rt(e){if(this.G!==void 0)if(this.isConnected||(e=void 0),typeof this.G==`function`){let t=this.ht??globalThis,n=W.get(t);n===void 0&&(n=new WeakMap,W.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)}else this.G.value=e}get lt(){return typeof this.G==`function`?W.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}}),G=class extends n.LitElement{constructor(...e){super(...e),this.value=``,this.name=``,this.label=``,this.disabled=!1,this.colorInputRef=We()}static{this.styles=n.css`
651
+ :host {
652
+ display: block;
653
+ font-family: var(--lc-font-family);
654
+ }
655
+
656
+ .label {
657
+ display: block;
658
+ font-size: var(--lc-font-size-sm);
659
+ color: var(--lc-color-text);
660
+ margin-bottom: var(--lc-spacing-2);
661
+ }
662
+
663
+ .container {
664
+ display: flex;
665
+ align-items: center;
666
+ gap: var(--lc-spacing-3);
667
+ }
668
+
669
+ .preview {
670
+ width: 40px;
671
+ height: 40px;
672
+ border-radius: var(--lc-radius-sm);
673
+ border: 1px solid var(--lc-color-border);
674
+ cursor: pointer;
675
+ flex-shrink: 0;
676
+ transition: border-color var(--lc-transition-fast);
677
+ }
678
+
679
+ .preview:hover {
680
+ border-color: var(--lc-color-primary);
681
+ }
682
+
683
+ .preview.disabled {
684
+ opacity: 0.5;
685
+ cursor: not-allowed;
686
+ }
687
+
688
+ .hex-input {
689
+ padding: var(--lc-spacing-1) var(--lc-spacing-2);
690
+ border: 1px solid var(--lc-color-border);
691
+ border-radius: var(--lc-radius-sm);
692
+ font-size: var(--lc-font-size-sm);
693
+ font-family: var(--lc-font-family);
694
+ width: 100px;
695
+ color: var(--lc-color-text);
696
+ outline: none;
697
+ transition: border-color var(--lc-transition-fast);
698
+ }
699
+
700
+ .hex-input:focus {
701
+ border-color: var(--lc-color-primary);
702
+ }
703
+
704
+ .hex-input:disabled {
705
+ opacity: 0.5;
706
+ cursor: not-allowed;
707
+ }
708
+
709
+ .hidden {
710
+ position: absolute;
711
+ opacity: 0;
712
+ width: 0;
713
+ height: 0;
714
+ pointer-events: none;
715
+ }
716
+ `}emitChange(e){this.dispatchEvent(new CustomEvent(t.o.CHANGE,{detail:{value:e},bubbles:!0,composed:!0}))}handleHexInput(e){let t=e.target.value.trim();t&&!t.startsWith(`#`)&&(t=`#`+t),this.value=t,this.emitChange(this.value)}handleColorInput(e){let t=e.target;this.value=t.value,this.emitChange(this.value)}openPicker(){!this.disabled&&this.colorInputRef.value&&this.colorInputRef.value.click()}render(){let e=this.value||`#000000`;return n.html`
717
+ ${this.label?n.html`<label class="label">${this.label}</label>`:n.nothing}
718
+ <div class="container">
719
+ <input
720
+ class="hidden"
721
+ type="color"
722
+ .value=${e}
723
+ ?disabled=${this.disabled}
724
+ @input=${this.handleColorInput}
725
+ ${Ke(this.colorInputRef)}
726
+ />
727
+ <div
728
+ class="preview ${this.disabled?`disabled`:``}"
729
+ style="background-color: ${e};"
730
+ @click=${this.openPicker}
731
+ ></div>
732
+ <input
733
+ class="hex-input"
734
+ type="text"
735
+ .value=${this.value}
736
+ ?disabled=${this.disabled}
737
+ placeholder="#000000"
738
+ @input=${this.handleHexInput}
739
+ />
740
+ </div>
741
+ `}};v([g({type:String})],G.prototype,`value`,void 0),v([g({type:String})],G.prototype,`name`,void 0),v([g({type:String})],G.prototype,`label`,void 0),v([g({type:Boolean})],G.prototype,`disabled`,void 0),G=v([r(`lc-color-picker`)],G);var K=class extends n.LitElement{constructor(...e){super(...e),this.value=.5,this.min=0,this.max=1,this.step=.1,this.name=``,this.label=``,this.disabled=!1}static{this.styles=n.css`
742
+ :host {
743
+ display: block;
744
+ font-family: var(--lc-font-family);
745
+ }
746
+
747
+ .label {
748
+ display: block;
749
+ font-size: var(--lc-font-size-sm);
750
+ color: var(--lc-color-text);
751
+ margin-bottom: var(--lc-spacing-2);
752
+ }
753
+
754
+ .container {
755
+ display: flex;
756
+ align-items: center;
757
+ gap: var(--lc-spacing-3);
758
+ }
759
+
760
+ input[type='range'] {
761
+ flex: 1;
762
+ accent-color: var(--lc-color-primary);
763
+ }
764
+
765
+ input[type='range']:disabled {
766
+ opacity: 0.5;
767
+ }
768
+
769
+ .value-display {
770
+ min-width: 32px;
771
+ text-align: center;
772
+ font-size: var(--lc-font-size-sm);
773
+ color: var(--lc-color-text);
774
+ }
775
+ `}emitChange(e){this.dispatchEvent(new CustomEvent(t.o.CHANGE,{detail:{value:e},bubbles:!0,composed:!0}))}handleInput(e){let t=e.target;this.value=parseFloat(t.value),this.emitChange(this.value)}render(){return n.html`
776
+ ${this.label?n.html`<label class="label">${this.label}</label>`:n.nothing}
777
+ <div class="container">
778
+ <input
779
+ type="range"
780
+ .min=${String(this.min)}
781
+ .max=${String(this.max)}
782
+ .step=${String(this.step)}
783
+ .value=${String(this.value)}
784
+ ?disabled=${this.disabled}
785
+ @input=${this.handleInput}
786
+ />
787
+ <span class="value-display">${this.value}</span>
788
+ </div>
789
+ `}};v([g({type:Number})],K.prototype,`value`,void 0),v([g({type:Number})],K.prototype,`min`,void 0),v([g({type:Number})],K.prototype,`max`,void 0),v([g({type:Number})],K.prototype,`step`,void 0),v([g({type:String})],K.prototype,`name`,void 0),v([g({type:String})],K.prototype,`label`,void 0),v([g({type:Boolean})],K.prototype,`disabled`,void 0),K=v([r(`lc-strength-slider`)],K);var qe={pending:`等待中`,running:`运行中`,done:`已完成`,exception:`异常`},q=class extends n.LitElement{constructor(...e){super(...e),this.taskId=``,this.status=`pending`,this.progress=0,this.queuePos=-1,this.errorMessage=``,this.submittedAt=0}static{this.styles=n.css`
790
+ :host {
791
+ display: block;
792
+ --lc-progress-height: 8px;
793
+ --lc-progress-bg: var(--lc-color-gray-100);
794
+ --lc-progress-fill: var(--lc-color-primary);
795
+ --lc-progress-radius: var(--lc-radius-full);
796
+ --lc-card-padding: var(--lc-spacing-4);
797
+ --lc-card-bg: var(--lc-color-bg);
798
+ --lc-card-border: 1px solid var(--lc-color-border);
799
+ --lc-card-radius: var(--lc-radius-lg);
800
+ }
801
+
802
+ .card {
803
+ padding: var(--lc-card-padding);
804
+ background: var(--lc-card-bg);
805
+ border: var(--lc-card-border);
806
+ border-radius: var(--lc-card-radius);
807
+ font-family: var(--lc-font-family);
808
+ }
809
+
810
+ .title {
811
+ font-size: var(--lc-font-size-sm);
812
+ font-weight: 500;
813
+ color: var(--lc-color-text);
814
+ margin-bottom: var(--lc-spacing-3);
815
+ }
816
+
817
+ .progress-track {
818
+ height: var(--lc-progress-height);
819
+ background: var(--lc-progress-bg);
820
+ border-radius: var(--lc-progress-radius);
821
+ overflow: hidden;
822
+ margin-bottom: var(--lc-spacing-3);
823
+ }
824
+
825
+ .progress-fill {
826
+ height: 100%;
827
+ background: var(--lc-progress-fill);
828
+ border-radius: var(--lc-progress-radius);
829
+ transition: width var(--lc-transition-normal);
830
+ }
831
+
832
+ .progress-text {
833
+ font-size: var(--lc-font-size-xs);
834
+ color: var(--lc-color-text-secondary);
835
+ margin-bottom: var(--lc-spacing-2);
836
+ text-align: right;
837
+ }
838
+
839
+ .meta {
840
+ display: flex;
841
+ align-items: center;
842
+ gap: var(--lc-spacing-2);
843
+ font-size: var(--lc-font-size-xs);
844
+ color: var(--lc-color-text-secondary);
845
+ }
846
+
847
+ .status-dot {
848
+ display: inline-block;
849
+ width: 8px;
850
+ height: 8px;
851
+ border-radius: 50%;
852
+ }
853
+
854
+ .separator {
855
+ color: var(--lc-color-gray-300);
856
+ }
857
+
858
+ .error-message {
859
+ margin-top: var(--lc-spacing-2);
860
+ font-size: var(--lc-font-size-xs);
861
+ color: var(--lc-color-error);
862
+ }
863
+ `}getStatusColor(){switch(this.status){case`pending`:return`var(--lc-color-gray-300)`;case`running`:return`var(--lc-color-primary)`;case`done`:return`var(--lc-color-success)`;case`exception`:return`var(--lc-color-error)`}}formatTime(e){return e?new Date(e).toLocaleString(`zh-CN`):``}render(){let e=Math.max(0,Math.min(1,this.progress)),t=`width: ${e*100}%`,r=`background: ${this.getStatusColor()}`;return n.html`
864
+ <div class="card" part="card">
865
+ <div class="title">任务 #${this.taskId}</div>
866
+ <div class="progress-text">${Math.round(e*100)}%</div>
867
+ <div class="progress-track" part="progress-bar">
868
+ <div class="progress-fill" style=${t} part="progress-fill"></div>
869
+ </div>
870
+ <div class="meta">
871
+ <span class="status-dot" style=${r}></span>
872
+ <span part="status">${qe[this.status]}</span>
873
+ ${this.queuePos>=0?n.html`<span class="separator">·</span><span>队列位置: ${this.queuePos}</span>`:null}
874
+ </div>
875
+ ${this.submittedAt?n.html`<div class="meta" style="margin-top: var(--lc-spacing-1)">
876
+ 提交时间: ${this.formatTime(this.submittedAt)}
877
+ </div>`:null}
878
+ ${this.status===`exception`&&this.errorMessage?n.html`<div class="error-message">${this.errorMessage}</div>`:null}
879
+ </div>
880
+ `}};v([g({type:String})],q.prototype,`taskId`,void 0),v([g({type:String})],q.prototype,`status`,void 0),v([g({type:Number})],q.prototype,`progress`,void 0),v([g({type:Number})],q.prototype,`queuePos`,void 0),v([g({type:String})],q.prototype,`errorMessage`,void 0),v([g({type:Number})],q.prototype,`submittedAt`,void 0),q=v([r(`lc-task-progress-card`)],q);var J=class extends n.LitElement{constructor(...e){super(...e),this.images=`[]`,this.originalUrl=``,this.showDownload=!0}static{this.styles=n.css`
881
+ :host {
882
+ display: block;
883
+ --lc-gallery-gap: var(--lc-spacing-3);
884
+ --lc-gallery-item-radius: var(--lc-radius-md);
885
+ --lc-gallery-overlay-bg: rgba(0, 0, 0, 0.6);
886
+ }
887
+
888
+ .gallery {
889
+ display: grid;
890
+ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
891
+ gap: var(--lc-gallery-gap);
892
+ }
893
+
894
+ .image-item {
895
+ position: relative;
896
+ border-radius: var(--lc-gallery-item-radius);
897
+ overflow: hidden;
898
+ cursor: pointer;
899
+ }
900
+
901
+ .image-item img {
902
+ display: block;
903
+ width: 100%;
904
+ height: auto;
905
+ border-radius: var(--lc-gallery-item-radius);
906
+ }
907
+
908
+ .overlay {
909
+ position: absolute;
910
+ inset: 0;
911
+ display: flex;
912
+ align-items: center;
913
+ justify-content: center;
914
+ gap: var(--lc-spacing-2);
915
+ background: var(--lc-gallery-overlay-bg);
916
+ opacity: 0;
917
+ transition: opacity var(--lc-transition-fast);
918
+ }
919
+
920
+ .image-item:hover .overlay {
921
+ opacity: 1;
922
+ }
923
+
924
+ .action-btn {
925
+ display: flex;
926
+ align-items: center;
927
+ justify-content: center;
928
+ width: 36px;
929
+ height: 36px;
930
+ border-radius: var(--lc-radius-sm);
931
+ background: rgba(255, 255, 255, 0.9);
932
+ color: var(--lc-color-gray-900);
933
+ font-size: var(--lc-font-size-base);
934
+ text-decoration: none;
935
+ border: none;
936
+ cursor: pointer;
937
+ }
938
+
939
+ .action-btn:hover {
940
+ background: white;
941
+ }
942
+ `}getParsedImages(){try{let e=JSON.parse(this.images);return Array.isArray(e)?e:[]}catch{return[]}}_onImageClick(e){this.dispatchEvent(new CustomEvent(t.o.IMAGE_CLICK,{detail:{index:e.index,url:e.url},bubbles:!0,composed:!0}))}_onCompare(e){this.dispatchEvent(new CustomEvent(t.o.COMPARE,{detail:{originalUrl:this.originalUrl,resultUrl:e},bubbles:!0,composed:!0}))}renderImageItem(e){return n.html`
943
+ <div class="image-item" @click=${()=>this._onImageClick(e)}>
944
+ <img src="${e.url}" alt="结果 ${e.index+1}">
945
+ <div class="overlay">
946
+ ${this.showDownload?n.html`<a class="action-btn" href="${e.url}" download title="下载">&#11015;</a>`:n.nothing}
947
+ ${this.originalUrl?n.html`<button class="action-btn" @click=${t=>{t.stopPropagation(),this._onCompare(e.url)}} title="对比">&#8801;</button>`:n.nothing}
948
+ </div>
949
+ </div>
950
+ `}render(){return n.html`
951
+ <div class="gallery">
952
+ ${this.getParsedImages().map(e=>this.renderImageItem(e))}
953
+ </div>
954
+ `}};v([g({type:String})],J.prototype,`images`,void 0),v([g({type:String})],J.prototype,`originalUrl`,void 0),v([g({type:Boolean})],J.prototype,`showDownload`,void 0),J=v([r(`lc-result-gallery`)],J);var Y=class extends n.LitElement{constructor(...e){super(...e),this.beforeSrc=``,this.afterSrc=``,this.beforeLabel=`原图`,this.afterLabel=`结果`,this._position=50}static{this.styles=n.css`
955
+ :host {
956
+ display: block;
957
+ --lc-compare-width: 100%;
958
+ --lc-compare-max-height: 500px;
959
+ --lc-slider-width: 2px;
960
+ --lc-slider-color: white;
961
+ --lc-handle-size: 40px;
962
+ --lc-handle-color: white;
963
+ --lc-handle-shadow: var(--lc-shadow-md);
964
+ }
965
+
966
+ .compare-container {
967
+ position: relative;
968
+ width: var(--lc-compare-width);
969
+ max-height: var(--lc-compare-max-height);
970
+ overflow: hidden;
971
+ user-select: none;
972
+ }
973
+
974
+ .compare-container img {
975
+ display: block;
976
+ width: 100%;
977
+ height: auto;
978
+ }
979
+
980
+ .after-wrapper {
981
+ position: relative;
982
+ }
983
+
984
+ .before-image {
985
+ position: absolute;
986
+ top: 0;
987
+ left: 0;
988
+ width: 100%;
989
+ height: 100%;
990
+ object-fit: cover;
991
+ }
992
+
993
+ .slider-handle {
994
+ position: absolute;
995
+ top: 0;
996
+ bottom: 0;
997
+ width: var(--lc-slider-width);
998
+ background: var(--lc-slider-color);
999
+ cursor: ew-resize;
1000
+ z-index: 2;
1001
+ transform: translateX(-50%);
1002
+ }
1003
+
1004
+ .slider-handle::after {
1005
+ content: '\\27F7';
1006
+ position: absolute;
1007
+ top: 50%;
1008
+ left: 50%;
1009
+ transform: translate(-50%, -50%);
1010
+ width: var(--lc-handle-size);
1011
+ height: var(--lc-handle-size);
1012
+ border-radius: 50%;
1013
+ background: var(--lc-handle-color);
1014
+ box-shadow: var(--lc-handle-shadow);
1015
+ display: flex;
1016
+ align-items: center;
1017
+ justify-content: center;
1018
+ font-size: 14px;
1019
+ }
1020
+
1021
+ .label {
1022
+ position: absolute;
1023
+ bottom: 8px;
1024
+ padding: 2px 8px;
1025
+ border-radius: var(--lc-radius-sm);
1026
+ background: rgba(0, 0, 0, 0.5);
1027
+ color: white;
1028
+ font-size: var(--lc-font-size-xs);
1029
+ z-index: 3;
1030
+ }
1031
+
1032
+ .label-before { left: 8px; }
1033
+ .label-after { right: 8px; }
1034
+ `}_onPointerDown(e){e.currentTarget.setPointerCapture(e.pointerId)}_onPointerMove(e){let t=this.shadowRoot?.querySelector(`.compare-container`);if(!t)return;let n=t.getBoundingClientRect(),r=e.clientX-n.left;this._position=Math.max(0,Math.min(100,r/n.width*100))}render(){let e=`clip-path: inset(0 0 0 ${this._position}%)`,t=`left: ${this._position}%`;return n.html`
1035
+ <div class="compare-container" part="container">
1036
+ <div class="after-wrapper">
1037
+ <img src="${this.afterSrc}" alt="${this.afterLabel}">
1038
+ </div>
1039
+ <img class="before-image" src="${this.beforeSrc}" alt="${this.beforeLabel}" style=${e}>
1040
+ <div
1041
+ class="slider-handle"
1042
+ part="slider"
1043
+ style=${t}
1044
+ @pointerdown=${this._onPointerDown}
1045
+ @pointermove=${this._onPointerMove}
1046
+ ></div>
1047
+ <span class="label label-before">${this.beforeLabel}</span>
1048
+ <span class="label label-after">${this.afterLabel}</span>
1049
+ </div>
1050
+ `}};v([g({type:String})],Y.prototype,`beforeSrc`,void 0),v([g({type:String})],Y.prototype,`afterSrc`,void 0),v([g({type:String})],Y.prototype,`beforeLabel`,void 0),v([g({type:String})],Y.prototype,`afterLabel`,void 0),v([_()],Y.prototype,`_position`,void 0),Y=v([r(`lc-image-compare-slider`)],Y);var X=t.P,Z=t.o,Q=class extends n.LitElement{constructor(...n){super(...n),this.type=``,this.submitEndpoint=``,this.pollEndpoint=t.N.POLL_ENDPOINT,this.pollInterval=t.N.POLL_INTERVAL,this.maxPollAttempts=t.N.MAX_POLL_ATTEMPTS,this.phase=X.IDLE,this.taskId=``,this.progress=0,this.result=null,this.error=``,this._defaultClient=new e.t}get typeDef(){return this._syncClientConfig(),this._activeClient.typeDef}get taskFields(){return this.typeDef?.fields??[]}async submit(e){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())}reset(){this._activeClient.reset(),this._syncStateFromClient()}async _handleFormSubmit(e){e.preventDefault(),await this.submit(this.collectFormData())}_handleClick(e){e.composedPath().find(e=>e instanceof HTMLElement?(e.type||e.getAttribute(`type`))===`submit`:!1)&&(e.preventDefault(),this.submit(this.collectFormData()))}_handleChildChange(e){let t=e.target;if(!(t instanceof HTMLElement))return;let n=Je(t);if(!n)return;let r=Ze(e)??Ye(t);r!==void 0&&(t.value=r,this._syncMaskSources(n,r))}_syncMaskSources(e,t){this.taskFields.find(t=>t.name===e)?.type===`image`&&(typeof t!=`string`||!t||this.querySelectorAll(`lc-mask-editor`).forEach(e=>{let n=e;n.source||=t}))}collectFormData(){let e={},t=this.querySelectorAll(`*`),n=new Map(this.taskFields.map(e=>[e.name,e]));return t.forEach(t=>{let r=Je(t);if(!r)return;let i=Xe(t);n.get(r)?.type===`images`&&typeof i==`string`&&i&&(i=[i]),n.get(r)?.type===`multiEnum`&&typeof i==`string`&&i&&(i=Qe(i)),i!==void 0&&(e[r]=i)}),e}get _activeClient(){return this.client??this._defaultClient}_syncClientConfig(){let e={customRequest:this.customRequest,customUploadRequest:this.customUploadRequest,onSubmit:e=>{this._syncStateFromClient(),this.dispatchEvent(new CustomEvent(Z.SUBMIT,{detail:e,bubbles:!0,composed:!0}))},onPoll:e=>{this._syncStateFromClient(),this.dispatchEvent(new CustomEvent(Z.POLL,{detail:e,bubbles:!0,composed:!0}))},onSuccess:e=>{this._syncStateFromClient(),this.dispatchEvent(new CustomEvent(Z.SUCCESS,{detail:e,bubbles:!0,composed:!0}))},onError:e=>this._fail(e.message,e.phase)};this.client?(this.type&&(e.type=this.type),this.submitEndpoint&&(e.submitEndpoint=this.submitEndpoint),this.pollEndpoint!==t.N.POLL_ENDPOINT&&(e.pollEndpoint=this.pollEndpoint),this.pollInterval!==t.N.POLL_INTERVAL&&(e.pollInterval=this.pollInterval),this.maxPollAttempts!==t.N.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)}_syncStateFromClient(){let e=this._activeClient;this.phase=e.phase,this.taskId=e.taskId,this.progress=e.progress,this.result=e.result,this.error=e.error}_fail(e,t){this.phase=X.ERROR,this.error=e,this.dispatchEvent(new CustomEvent(Z.ERROR,{detail:{message:e,phase:t},bubbles:!0,composed:!0}))}render(){return n.html`
1051
+ <form @submit=${this._handleFormSubmit} @click=${this._handleClick} @change=${this._handleChildChange}>
1052
+ <slot></slot>
1053
+ </form>
1054
+ `}};v([g({type:String})],Q.prototype,`type`,void 0),v([g({type:String,attribute:`submit-endpoint`})],Q.prototype,`submitEndpoint`,void 0),v([g({type:String,attribute:`poll-endpoint`})],Q.prototype,`pollEndpoint`,void 0),v([g({type:Number})],Q.prototype,`pollInterval`,void 0),v([g({type:Number})],Q.prototype,`maxPollAttempts`,void 0),v([g({attribute:!1})],Q.prototype,`client`,void 0),v([g({attribute:!1})],Q.prototype,`customRequest`,void 0),v([g({attribute:!1})],Q.prototype,`customUploadRequest`,void 0),v([_()],Q.prototype,`phase`,void 0),v([_()],Q.prototype,`taskId`,void 0),v([_()],Q.prototype,`progress`,void 0),v([_()],Q.prototype,`result`,void 0),v([_()],Q.prototype,`error`,void 0),Q=v([r(`lc-task-workflow`)],Q);function Je(e){return e.name||e.getAttribute(`name`)||``}function Ye(e){let t=e.value;if(t!==void 0)return t;if(e.hasAttribute(`value`))return e.getAttribute(`value`)??``}function Xe(e){return e.file||Ye(e)}function Ze(e){let t=e.detail;if(t){if(`value`in t)return t.value;if(`file`in t)return t.file}}function Qe(e){try{let t=JSON.parse(e);if(Array.isArray(t))return t.map(String)}catch{}return e.split(`,`).map(e=>e.trim()).filter(Boolean)}var $=class extends n.LitElement{constructor(...e){super(...e),this.type=`button`,this.variant=`primary`,this.disabled=!1}static{this.styles=n.css`
1055
+ :host {
1056
+ display: inline-block;
1057
+ --lc-button-bg: var(--lc-color-primary);
1058
+ --lc-button-bg-hover: var(--lc-color-primary-hover);
1059
+ --lc-button-color: #fff;
1060
+ --lc-button-border: 1px solid var(--lc-color-primary);
1061
+ --lc-button-radius: var(--lc-radius-component);
1062
+ --lc-button-padding: var(--lc-spacing-2) var(--lc-spacing-4);
1063
+ }
1064
+
1065
+ button {
1066
+ display: inline-flex;
1067
+ align-items: center;
1068
+ justify-content: center;
1069
+ gap: var(--lc-spacing-2);
1070
+ min-height: 36px;
1071
+ padding: var(--lc-button-padding);
1072
+ border: var(--lc-button-border);
1073
+ border-radius: var(--lc-button-radius);
1074
+ background: var(--lc-button-bg);
1075
+ color: var(--lc-button-color);
1076
+ font: inherit;
1077
+ font-family: var(--lc-font-family);
1078
+ cursor: pointer;
1079
+ transition: background var(--lc-transition-fast), border-color var(--lc-transition-fast), opacity var(--lc-transition-fast);
1080
+ }
1081
+
1082
+ button:hover:not(:disabled) {
1083
+ background: var(--lc-button-bg-hover);
1084
+ }
1085
+
1086
+ button:disabled {
1087
+ opacity: 0.5;
1088
+ cursor: not-allowed;
1089
+ }
1090
+
1091
+ :host([variant='secondary']) {
1092
+ --lc-button-bg: var(--lc-color-bg);
1093
+ --lc-button-bg-hover: var(--lc-color-bg-secondary);
1094
+ --lc-button-color: var(--lc-color-text);
1095
+ --lc-button-border: 1px solid var(--lc-color-border);
1096
+ }
1097
+ `}handleClick(e){e.stopPropagation(),!this.disabled&&this.dispatchEvent(new MouseEvent(`click`,{bubbles:!0,composed:!0,cancelable:!0}))}render(){return n.html`
1098
+ <button type=${this.type} ?disabled=${this.disabled} part="button" @click=${this.handleClick}>
1099
+ <slot></slot>
1100
+ </button>
1101
+ `}};v([g({type:String})],$.prototype,`type`,void 0),v([g({type:String,reflect:!0})],$.prototype,`variant`,void 0),v([g({type:Boolean})],$.prototype,`disabled`,void 0),$=v([r(`lc-button`)],$),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return q}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Y}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return b}});