@kc-one/smart-fill-sdk 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
- var nn = Object.defineProperty;
2
- var rn = (e, t, n) => t in e ? nn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var d = (e, t, n) => rn(e, typeof t != "symbol" ? t + "" : t, n);
4
- const Vo = {
1
+ var Yt = Object.defineProperty;
2
+ var Wt = (e, t, n) => t in e ? Yt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var d = (e, t, n) => Wt(e, typeof t != "symbol" ? t + "" : t, n);
4
+ const Ao = {
5
5
  name: "native",
6
6
  /** 匹配 input / textarea / select 原生控件 */
7
7
  match: (e) => e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement,
@@ -14,7 +14,7 @@ const Vo = {
14
14
  const n = e.element;
15
15
  n instanceof HTMLInputElement && n.type === "checkbox" ? n.checked = !!t : (n instanceof HTMLInputElement || n instanceof HTMLTextAreaElement || n instanceof HTMLSelectElement) && (n.value = String(t ?? "")), n == null || n.dispatchEvent(new Event("input", { bubbles: !0 })), n == null || n.dispatchEvent(new Event("change", { bubbles: !0 }));
16
16
  }
17
- }, yt = [
17
+ }, ct = [
18
18
  // Element Plus / Element UI
19
19
  { framework: "element", selectors: ".el-select,.el-select-v2", type: "select", kind: "input" },
20
20
  { framework: "element", selectors: ".el-cascader", type: "cascader", kind: "input" },
@@ -59,7 +59,7 @@ const Vo = {
59
59
  { framework: "vant", selectors: ".van-checkbox-group", type: "checkbox", kind: "checkboxGroup", optionSelector: '.van-checkbox,[role="checkbox"],input[type="checkbox"]' },
60
60
  // 通用 ARIA 下拉(无框架 class 或作为内层触发器)
61
61
  { framework: "generic", selectors: '[role="combobox"]', type: "select", kind: "input" }
62
- ], on = [
62
+ ], Xt = [
63
63
  "is-disabled",
64
64
  "ant-select-disabled",
65
65
  "n-select--disabled",
@@ -68,7 +68,7 @@ const Vo = {
68
68
  "van-switch--disabled",
69
69
  "van-stepper--disabled",
70
70
  "van-dropdown-menu--disabled"
71
- ], bt = yt.map((e) => e.selectors).join(", "), sn = [
71
+ ], lt = ct.map((e) => e.selectors).join(", "), Zt = [
72
72
  ".form-item",
73
73
  ".ant-form-item",
74
74
  ".el-form-item",
@@ -78,7 +78,7 @@ const Vo = {
78
78
  ".van-field",
79
79
  ".field",
80
80
  ".form-row"
81
- ].join(", "), an = [
81
+ ].join(", "), Jt = [
82
82
  "label",
83
83
  ".ant-form-item-label",
84
84
  ".el-form-item__label",
@@ -86,7 +86,7 @@ const Vo = {
86
86
  ".arco-form-item-label",
87
87
  ".van-field__label",
88
88
  ".label"
89
- ].join(", "), Xe = [
89
+ ].join(", "), ze = [
90
90
  "dialog[open]",
91
91
  "[role='dialog']",
92
92
  "[aria-modal='true']",
@@ -105,7 +105,7 @@ const Vo = {
105
105
  ".van-action-sheet",
106
106
  ".popup",
107
107
  ".drawer"
108
- ].join(", "), cn = [
108
+ ].join(", "), Qt = [
109
109
  "is-checked",
110
110
  "ant-switch-checked",
111
111
  "n-switch--active",
@@ -114,20 +114,20 @@ const Vo = {
114
114
  "van-radio--checked",
115
115
  "van-checkbox--checked"
116
116
  ];
117
- function N(e) {
118
- return yt.find((t) => e.matches(t.selectors)) || null;
117
+ function F(e) {
118
+ return ct.find((t) => e.matches(t.selectors)) || null;
119
119
  }
120
- function mt(e) {
121
- return !!N(e);
120
+ function ut(e) {
121
+ return !!F(e);
122
122
  }
123
- function Re(e) {
123
+ function Te(e) {
124
124
  for (let t = e; t; t = t.parentElement)
125
- if (mt(t)) return t;
125
+ if (ut(t)) return t;
126
126
  return null;
127
127
  }
128
- function he(e) {
128
+ function ce(e) {
129
129
  var n;
130
- const t = N(e);
130
+ const t = F(e);
131
131
  if (!t) return null;
132
132
  if (e.matches(".van-field")) {
133
133
  if (e.querySelector("textarea")) return "textarea";
@@ -139,36 +139,36 @@ function he(e) {
139
139
  if (!o || /选择|select/i.test(o)) return "select";
140
140
  }
141
141
  if (e.classList.contains("van-field--clickable")) {
142
- const o = f(((n = e.querySelector(".van-field__control")) == null ? void 0 : n.textContent) || "");
142
+ const o = p(((n = e.querySelector(".van-field__control")) == null ? void 0 : n.textContent) || "");
143
143
  if (!e.querySelector("textarea") && (o === "请选择" || o === ""))
144
144
  return "select";
145
145
  }
146
146
  }
147
147
  return t.type;
148
148
  }
149
- function vt(e) {
150
- const t = N(e);
149
+ function dt(e) {
150
+ const t = F(e);
151
151
  if (t != null && t.optionSelector)
152
- return Array.from(e.querySelectorAll(t.optionSelector)).map((n) => ln(n)).filter((n) => !!(n.label || n.value));
152
+ return Array.from(e.querySelectorAll(t.optionSelector)).map((n) => en(n)).filter((n) => !!(n.label || n.value));
153
153
  }
154
- function ln(e) {
155
- const t = e instanceof HTMLInputElement ? e : e.querySelector('input[type="radio"],input[type="checkbox"]'), n = f(e.textContent || e.getAttribute("aria-label") || e.getAttribute("title") || ""), r = e.getAttribute("value") || (t == null ? void 0 : t.value) || n;
154
+ function en(e) {
155
+ const t = e instanceof HTMLInputElement ? e : e.querySelector('input[type="radio"],input[type="checkbox"]'), n = p(e.textContent || e.getAttribute("aria-label") || e.getAttribute("title") || ""), r = e.getAttribute("value") || (t == null ? void 0 : t.value) || n;
156
156
  return { label: n, value: r };
157
157
  }
158
- function X(e) {
159
- return cn.some((t) => e.classList.contains(t)) || e.getAttribute("aria-checked") === "true" || !!e.querySelector("input:checked");
158
+ function U(e) {
159
+ return Qt.some((t) => e.classList.contains(t)) || e.getAttribute("aria-checked") === "true" || !!e.querySelector("input:checked");
160
160
  }
161
- function q(e) {
161
+ function O(e) {
162
162
  return e.querySelector('input:not([type="hidden"]), textarea');
163
163
  }
164
- function wt(e) {
164
+ function pt(e) {
165
165
  var t, n, r;
166
- return e.getAttribute("name") || ((t = q(e)) == null ? void 0 : t.getAttribute("name")) || e.getAttribute("data-smart-fill-key") || ((n = q(e)) == null ? void 0 : n.getAttribute("data-smart-fill-key")) || ((r = e.querySelector("[data-smart-fill-key]")) == null ? void 0 : r.getAttribute("data-smart-fill-key"));
166
+ return e.getAttribute("name") || ((t = O(e)) == null ? void 0 : t.getAttribute("name")) || e.getAttribute("data-smart-fill-key") || ((n = O(e)) == null ? void 0 : n.getAttribute("data-smart-fill-key")) || ((r = e.querySelector("[data-smart-fill-key]")) == null ? void 0 : r.getAttribute("data-smart-fill-key"));
167
167
  }
168
- function f(e) {
168
+ function p(e) {
169
169
  return e.replace(/[*::]/g, "").replace(/\s+/g, " ").trim();
170
170
  }
171
- const Fe = "data-smart-fill-hide-dropdown-mode", Ze = "smart-fill-hide-dropdown-style", St = [
171
+ const Le = "data-smart-fill-hide-dropdown-mode", Be = "smart-fill-hide-dropdown-style", ft = [
172
172
  "[role='combobox']",
173
173
  "[aria-haspopup='listbox']",
174
174
  ".el-cascader",
@@ -191,7 +191,7 @@ const Fe = "data-smart-fill-hide-dropdown-mode", Ze = "smart-fill-hide-dropdown-
191
191
  ".van-dropdown-menu__bar",
192
192
  ".van-field--picker",
193
193
  ".van-field--clickable"
194
- ].join(", "), un = [
194
+ ].join(", "), tn = [
195
195
  ".ant-select-selection-item",
196
196
  ".el-select__selected-item",
197
197
  ".el-select-v2__selected-item",
@@ -207,7 +207,7 @@ const Fe = "data-smart-fill-hide-dropdown-mode", Ze = "smart-fill-hide-dropdown-
207
207
  ".select-value",
208
208
  ".selection-item",
209
209
  ".van-field__control"
210
- ].join(", "), Oe = [
210
+ ].join(", "), Ie = [
211
211
  "[role='option']",
212
212
  ".ant-select-item-option",
213
213
  ".el-select-dropdown__item",
@@ -219,8 +219,8 @@ const Fe = "data-smart-fill-hide-dropdown-mode", Ze = "smart-fill-hide-dropdown-
219
219
  ".t-select-option",
220
220
  ".van-picker-column__item",
221
221
  ".van-action-sheet__item"
222
- ].join(", "), ge = [
223
- Oe,
222
+ ].join(", "), le = [
223
+ Ie,
224
224
  ".van-action-sheet__name",
225
225
  ".van-cascader__option",
226
226
  ".van-dropdown-item__option",
@@ -229,7 +229,7 @@ const Fe = "data-smart-fill-hide-dropdown-mode", Ze = "smart-fill-hide-dropdown-
229
229
  ".ant-cascader-menu-item",
230
230
  ".n-cascader-node",
231
231
  ".arco-cascader-option"
232
- ].join(", "), De = [
232
+ ].join(", "), Me = [
233
233
  ".el-select-dropdown",
234
234
  ".el-cascader__dropdown",
235
235
  ".el-cascader-panel",
@@ -253,7 +253,7 @@ const Fe = "data-smart-fill-hide-dropdown-mode", Ze = "smart-fill-hide-dropdown-
253
253
  ".van-dropdown-item",
254
254
  ".van-picker",
255
255
  "[role='listbox']"
256
- ].join(", "), Et = [
256
+ ].join(", "), ht = [
257
257
  ".el-select-dropdown",
258
258
  ".el-select__popper",
259
259
  ".el-select-v2__popper",
@@ -270,7 +270,7 @@ const Fe = "data-smart-fill-hide-dropdown-mode", Ze = "smart-fill-hide-dropdown-
270
270
  ".van-dropdown-item",
271
271
  ".van-picker",
272
272
  "[role='listbox']"
273
- ].join(", "), xt = [
273
+ ].join(", "), gt = [
274
274
  ".el-cascader__dropdown",
275
275
  ".el-cascader-panel",
276
276
  ".el-popper.el-cascader__dropdown",
@@ -279,11 +279,11 @@ const Fe = "data-smart-fill-hide-dropdown-mode", Ze = "smart-fill-hide-dropdown-
279
279
  ".arco-cascader-panel",
280
280
  ".van-cascader",
281
281
  ".van-cascader__options"
282
- ].join(", "), dn = /(?:省|市|自治区|特别行政区|自治州|地区|盟|县|区)$/, fn = /地址|省|市|区|县|地区|籍贯|户籍|居住地|所在地|区域/, pn = /* @__PURE__ */ new Set(["select", "cascader", "date"]);
282
+ ].join(", "), nn = /(?:省|市|自治区|特别行政区|自治州|地区|盟|县|区)$/, rn = /地址|省|市|区|县|地区|籍贯|户籍|居住地|所在地|区域/, on = /* @__PURE__ */ new Set(["select", "cascader", "date"]);
283
283
  function C(e) {
284
- return !Ft(e) || At(e) ? !1 : !!e.closest(".el-cascader, .ant-cascader, .van-cascader, .n-cascader, .arco-cascader");
284
+ return !_t(e) || mt(e) ? !1 : !!e.closest(".el-cascader, .ant-cascader, .van-cascader, .n-cascader, .arco-cascader");
285
285
  }
286
- function O(e) {
286
+ function E(e) {
287
287
  var n;
288
288
  if (!e.matches(".van-field")) return !1;
289
289
  if (e.classList.contains("van-field--picker") || e.querySelector(".van-dropdown-menu"))
@@ -294,16 +294,16 @@ function O(e) {
294
294
  if (!r || /选择|select/i.test(r)) return !0;
295
295
  }
296
296
  if (e.classList.contains("van-field--clickable")) {
297
- const r = f(((n = e.querySelector(".van-field__control")) == null ? void 0 : n.textContent) || "");
297
+ const r = p(((n = e.querySelector(".van-field__control")) == null ? void 0 : n.textContent) || "");
298
298
  if (!e.querySelector("textarea") && (r === "请选择" || r === ""))
299
299
  return !0;
300
300
  }
301
301
  return !1;
302
302
  }
303
- function Z(e) {
304
- return !Ft(e) || At(e) || e instanceof HTMLSelectElement || e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement ? !1 : e.matches(St) || e.getAttribute("role") === "combobox" || e.getAttribute("aria-haspopup") === "listbox" || e.classList.contains("el-select__wrapper") || e.classList.contains("el-select-v2__wrapper") || O(e);
303
+ function j(e) {
304
+ return !_t(e) || mt(e) || e instanceof HTMLSelectElement || e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement ? !1 : e.matches(ft) || e.getAttribute("role") === "combobox" || e.getAttribute("aria-haspopup") === "listbox" || e.classList.contains("el-select__wrapper") || e.classList.contains("el-select-v2__wrapper") || E(e);
305
305
  }
306
- function Ee(e) {
306
+ function G(e) {
307
307
  const t = e.closest(".el-cascader, .ant-cascader, .van-cascader, .n-cascader, .arco-cascader");
308
308
  if (t instanceof HTMLElement) return t;
309
309
  const n = e.closest([
@@ -333,77 +333,82 @@ function Ee(e) {
333
333
  ".el-select__wrapper",
334
334
  ".el-select-v2__wrapper"
335
335
  ].join(", "));
336
- return n instanceof HTMLElement ? n.matches(".van-field") && !O(n) ? null : n : Z(e) ? e : null;
336
+ return n instanceof HTMLElement ? n.matches(".van-field") && !E(n) ? null : n : j(e) ? e : null;
337
337
  }
338
- function Pe(e) {
338
+ function Re(e) {
339
339
  if (e instanceof HTMLSelectElement) return e;
340
340
  if (C(e))
341
341
  return e.closest(".el-cascader, .ant-cascader, .van-cascader, .n-cascader, .arco-cascader") || e;
342
- const t = Ee(e);
343
- return t || (e.matches(".van-field") && O(e) ? e : null);
342
+ const t = G(e);
343
+ return t || (e.matches(".van-field") && E(e) ? e : null);
344
344
  }
345
- function Ke(e) {
345
+ function yt(e) {
346
346
  if (C(e)) return "cascader";
347
- if (Z(e) || O(e)) return "select";
348
- const t = he(e);
347
+ if (j(e) || E(e)) return "select";
348
+ const t = ce(e);
349
349
  return t || (e instanceof HTMLSelectElement ? "select" : null);
350
350
  }
351
- function Y(e, t) {
352
- const n = t || Ke(e);
353
- return n != null && pn.has(n);
354
- }
355
- function hn(e) {
356
- return Y(e, Ke(e) || void 0);
357
- }
358
- function kt(e) {
359
- const t = e.querySelector(un);
360
- if (t instanceof HTMLInputElement)
361
- return f(t.value);
362
- const n = f((t == null ? void 0 : t.textContent) || "");
363
- if (n && n !== "请选择") return n;
364
- const r = e.querySelector('input:not([type="hidden"])');
365
- return r != null && r.value ? f(r.value) : n;
366
- }
367
- function _t(e) {
368
- const t = Sn(e);
351
+ function Oe(e, t) {
352
+ const n = t || yt(e);
353
+ return n != null && on.has(n);
354
+ }
355
+ function sn(e) {
356
+ const t = e.matches(".van-field") ? e : e.closest(".van-field");
357
+ if (t instanceof HTMLElement && E(t)) {
358
+ const i = t.querySelector(".van-field__control");
359
+ if (i instanceof HTMLInputElement)
360
+ return p(i.value);
361
+ const s = p((i == null ? void 0 : i.textContent) || "");
362
+ return s && s !== "请选择" ? s : "";
363
+ }
364
+ const n = e.querySelector(tn);
365
+ if (n instanceof HTMLInputElement)
366
+ return p(n.value);
367
+ const r = p((n == null ? void 0 : n.textContent) || "");
368
+ if (r && r !== "请选择") return r;
369
+ const o = e.querySelector('input:not([type="hidden"])');
370
+ return o != null && o.value ? p(o.value) : r;
371
+ }
372
+ function bt(e) {
373
+ const t = fn(e);
369
374
  if (!t.length) return;
370
- const n = En(t);
375
+ const n = hn(t);
371
376
  return n.length ? n : void 0;
372
377
  }
373
- function se(e) {
378
+ function ne(e) {
374
379
  var t;
375
- return !((t = e.options) != null && t.length) || e.type === "cascader" || fn.test(e.label || "") ? !1 : Tn(e.options);
380
+ return !((t = e.options) != null && t.length) || e.type === "cascader" || rn.test(e.label || "") ? !1 : vn(e.options);
376
381
  }
377
- async function gn(e) {
382
+ async function an(e) {
378
383
  if (e instanceof HTMLSelectElement)
379
- return Array.from(e.options).map((s) => ({ value: s.value, label: f(s.textContent || s.label) })).filter((s) => s.label || s.value);
380
- const t = _t(e);
384
+ return Array.from(e.options).map((s) => ({ value: s.value, label: p(s.textContent || s.label) })).filter((s) => s.label || s.value);
385
+ const t = bt(e);
381
386
  if (t != null && t.length) return t;
382
- const n = Ee(e) || e;
383
- if (!Z(n) && !C(n) && !O(n))
387
+ const n = G(e) || e;
388
+ if (!j(n) && !C(n) && !E(n))
384
389
  return;
385
- const r = Rn(), o = Ln(), i = new Set(o.getTrackedDropdowns());
390
+ const r = kn(), o = Sn(), i = new Set(o.getTrackedDropdowns());
386
391
  try {
387
- if (!(C(n) ? await bn(n, o, i) : await yn(n, o, i))) return;
388
- const a = await vn(o, i, n);
392
+ if (!(C(n) ? await ln(n, o, i) : await cn(n, o, i))) return;
393
+ const a = await dn(o, i, n);
389
394
  if (!a.length) return;
390
- const c = mn(a);
395
+ const c = un(a);
391
396
  return c.length ? c : void 0;
392
397
  } finally {
393
- await Mn(n, o), await R(60), o.restore(), r();
398
+ await xn(n, o), await M(60), o.restore(), r();
394
399
  }
395
400
  }
396
- function At(e) {
401
+ function mt(e) {
397
402
  return e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true";
398
403
  }
399
- async function yn(e, t, n) {
400
- const r = J(e);
404
+ async function cn(e, t, n) {
405
+ const r = Y(e);
401
406
  if (!r.length) return !1;
402
407
  for (const o of r)
403
- if (Mt(o), It(o), await R(160), Je(e, t, n) || (Rt(o), await R(180), Je(e, t, n))) return !0;
408
+ if (xt(o), Et(o), await M(160), Ue(e, t, n) || (kt(o), await M(180), Ue(e, t, n))) return !0;
404
409
  return !1;
405
410
  }
406
- async function bn(e, t, n) {
411
+ async function ln(e, t, n) {
407
412
  const r = [
408
413
  e,
409
414
  e.querySelector(".el-input__wrapper"),
@@ -412,18 +417,18 @@ async function bn(e, t, n) {
412
417
  e.querySelector("input")
413
418
  ].filter((o) => o instanceof HTMLElement);
414
419
  for (const o of r)
415
- if (Mt(o), It(o), await R(180), ye(t, n, e).length || (Rt(o), await R(180), ye(t, n, e).length)) return !0;
420
+ if (xt(o), Et(o), await M(180), ue(t, n, e).length || (kt(o), await M(180), ue(t, n, e).length)) return !0;
416
421
  return !1;
417
422
  }
418
- function mn(e) {
423
+ function un(e) {
419
424
  var r;
420
425
  const t = /* @__PURE__ */ new Set(), n = [];
421
426
  for (const o of e) {
422
- const i = o.matches(ge) ? [o] : Array.from(o.querySelectorAll(ge));
427
+ const i = o.matches(le) ? [o] : Array.from(o.querySelectorAll(le));
423
428
  for (const s of i) {
424
429
  if (s.classList.contains("is-disabled") || s.classList.contains("ant-select-item-option-disabled") || s.getAttribute("aria-disabled") === "true")
425
430
  continue;
426
- const a = f(
431
+ const a = p(
427
432
  ((r = s.querySelector(".el-cascader-node__label, .ant-cascader-menu-item-content")) == null ? void 0 : r.textContent) || s.textContent || ""
428
433
  ), c = s.getAttribute("data-value") || s.getAttribute("value") || a;
429
434
  if (!a && !c) continue;
@@ -433,56 +438,56 @@ function mn(e) {
433
438
  }
434
439
  return n;
435
440
  }
436
- async function vn(e, t, n) {
441
+ async function dn(e, t, n) {
437
442
  for (let r = 0; r < 8; r += 1) {
438
- const o = ye(e, t, n);
443
+ const o = ue(e, t, n);
439
444
  if (o.length) return o;
440
- await R(r === 0 ? 120 : 80);
445
+ await M(r === 0 ? 120 : 80);
441
446
  }
442
447
  return [];
443
448
  }
444
- function Je(e, t, n) {
445
- return ye(t, n, e).length > 0 ? !0 : J(e).some((r) => r.getAttribute("aria-expanded") === "true" || r.classList.contains("is-focus") || r.classList.contains("is-focused"));
449
+ function Ue(e, t, n) {
450
+ return ue(t, n, e).length > 0 ? !0 : Y(e).some((r) => r.getAttribute("aria-expanded") === "true" || r.classList.contains("is-focus") || r.classList.contains("is-focused"));
446
451
  }
447
- function wn(e, t, n) {
448
- const r = t.filter((c) => qe(e, c)), o = r.filter((c) => xn(e, c)), i = o.filter((c) => !n.has(c));
452
+ function pn(e, t, n) {
453
+ const r = t.filter((c) => Fe(e, c)), o = r.filter((c) => gn(e, c)), i = o.filter((c) => !n.has(c));
449
454
  if (i.length)
450
- return i.sort((c, l) => P(l, e) - P(c, e));
451
- const s = Ct(e);
455
+ return i.sort((c, l) => R(l, e) - R(c, e));
456
+ const s = wt(e);
452
457
  if (s.size) {
453
458
  const c = o.filter((l) => l.id && s.has(l.id));
454
459
  if (c.length) return c;
455
460
  }
456
461
  if (o.length)
457
- return o.sort((c, l) => P(l, e) - P(c, e)).slice(0, 1);
458
- const a = r.filter((c) => Cn(c) && Tt(e)).sort((c, l) => P(l, e) - P(c, e)).slice(0, 1);
462
+ return o.sort((c, l) => R(l, e) - R(c, e)).slice(0, 1);
463
+ const a = r.filter((c) => wn(c) && vt(e)).sort((c, l) => R(l, e) - R(c, e)).slice(0, 1);
459
464
  return a.length ? a : [];
460
465
  }
461
- function ye(e, t, n) {
462
- return wn(n, e.getTrackedDropdowns(), t);
466
+ function ue(e, t, n) {
467
+ return pn(n, e.getTrackedDropdowns(), t);
463
468
  }
464
- function P(e, t) {
469
+ function R(e, t) {
465
470
  const n = e.getBoundingClientRect(), r = Number.parseInt(window.getComputedStyle(e).zIndex || "0", 10);
466
471
  let o = (Number.isNaN(r) ? 0 : r) * 10 + n.width * n.height;
467
- return t && (o += Lt(t, e)), o;
472
+ return t && (o += St(t, e)), o;
468
473
  }
469
- function Sn(e) {
470
- const t = C(e) ? xt : Et, n = /* @__PURE__ */ new Set();
474
+ function fn(e) {
475
+ const t = C(e) ? gt : ht, n = /* @__PURE__ */ new Set();
471
476
  e.matches(t) && n.add(e);
472
477
  for (const r of e.querySelectorAll(t))
473
- qe(e, r) && n.add(r);
478
+ Fe(e, r) && n.add(r);
474
479
  for (const r of e.querySelectorAll("[role='listbox']"))
475
- e.contains(r) && qe(e, r) && n.add(r);
480
+ e.contains(r) && Fe(e, r) && n.add(r);
476
481
  return [...n];
477
482
  }
478
- function En(e) {
483
+ function hn(e) {
479
484
  const t = /* @__PURE__ */ new Set(), n = [];
480
485
  for (const r of e) {
481
- const o = r.matches(Oe) ? [r] : Array.from(r.querySelectorAll(Oe));
486
+ const o = r.matches(Ie) ? [r] : Array.from(r.querySelectorAll(Ie));
482
487
  for (const i of o) {
483
488
  if (i.classList.contains("is-disabled") || i.classList.contains("ant-select-item-option-disabled") || i.getAttribute("aria-disabled") === "true")
484
489
  continue;
485
- const s = f(i.textContent || ""), a = i.getAttribute("data-value") || i.getAttribute("value") || s;
490
+ const s = p(i.textContent || ""), a = i.getAttribute("data-value") || i.getAttribute("value") || s;
486
491
  if (!s && !a) continue;
487
492
  const c = `${s}::${String(a)}`;
488
493
  t.has(c) || (t.add(c), n.push({ label: s, value: a }));
@@ -490,35 +495,35 @@ function En(e) {
490
495
  }
491
496
  return n;
492
497
  }
493
- function Ct(e) {
498
+ function wt(e) {
494
499
  return new Set(
495
- J(e).flatMap((t) => [t.getAttribute("aria-controls"), t.getAttribute("aria-owns")]).filter((t) => !!t)
500
+ Y(e).flatMap((t) => [t.getAttribute("aria-controls"), t.getAttribute("aria-owns")]).filter((t) => !!t)
496
501
  );
497
502
  }
498
- function xn(e, t) {
499
- const n = Ct(e);
500
- return n.size && t.id && n.has(t.id) || e.contains(t) ? !0 : An(t) ? Tt(e) : n.size > 0 || J(e).some((o) => o.getAttribute("aria-controls") || o.getAttribute("aria-owns")) ? !1 : Lt(e, t) > 0;
503
+ function gn(e, t) {
504
+ const n = wt(e);
505
+ return n.size && t.id && n.has(t.id) || e.contains(t) ? !0 : mn(t) ? vt(e) : n.size > 0 || Y(e).some((o) => o.getAttribute("aria-controls") || o.getAttribute("aria-owns")) ? !1 : St(e, t) > 0;
501
506
  }
502
- function qe(e, t) {
503
- const n = C(e), r = kn(t);
504
- return n ? r : r ? !1 : _n(t);
507
+ function Fe(e, t) {
508
+ const n = C(e), r = yn(t);
509
+ return n ? r : r ? !1 : bn(t);
505
510
  }
506
- function kn(e) {
507
- return e.matches(xt) || !!e.querySelector(".el-cascader-node, .ant-cascader-menu-item, .van-cascader__option, .n-cascader-node, .arco-cascader-option");
511
+ function yn(e) {
512
+ return e.matches(gt) || !!e.querySelector(".el-cascader-node, .ant-cascader-menu-item, .van-cascader__option, .n-cascader-node, .arco-cascader-option");
508
513
  }
509
- function _n(e) {
510
- return e.matches(Et) || !!e.querySelector('.el-select-dropdown__item, .ant-select-item-option, .van-picker-column__item, .van-action-sheet__item, .van-dropdown-item__option, [role="option"]');
514
+ function bn(e) {
515
+ return e.matches(ht) || !!e.querySelector('.el-select-dropdown__item, .ant-select-item-option, .van-picker-column__item, .van-action-sheet__item, .van-dropdown-item__option, [role="option"]');
511
516
  }
512
- function An(e) {
517
+ function mn(e) {
513
518
  return e.matches(".van-popup, .van-action-sheet, .van-picker, .van-dropdown-item__content, .van-dropdown-item");
514
519
  }
515
- function Tt(e) {
516
- return J(e).some((t) => t.getAttribute("aria-expanded") === "true" || t.classList.contains("is-focus") || t.classList.contains("is-focused") || e.contains(document.activeElement));
520
+ function vt(e) {
521
+ return Y(e).some((t) => t.getAttribute("aria-expanded") === "true" || t.classList.contains("is-focus") || t.classList.contains("is-focused") || e.contains(document.activeElement));
517
522
  }
518
- function Cn(e) {
519
- return e.matches(ge) || !!e.querySelector(ge);
523
+ function wn(e) {
524
+ return e.matches(le) || !!e.querySelector(le);
520
525
  }
521
- function Lt(e, t) {
526
+ function St(e, t) {
522
527
  const n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
523
528
  if (!n.width || !n.height || !r.width || !r.height)
524
529
  return 0;
@@ -527,11 +532,11 @@ function Lt(e, t) {
527
532
  const i = r.top >= n.bottom ? r.top - n.bottom : n.top - r.bottom;
528
533
  return i > 320 ? 0 : Math.max(0, 400 - i) + o;
529
534
  }
530
- function Tn(e) {
531
- const t = e.slice(0, 8).map((r) => f(String(r.label || r.value || ""))).filter(Boolean);
532
- return t.length < 4 ? !1 : t.filter((r) => dn.test(r)).length / t.length >= 0.75;
535
+ function vn(e) {
536
+ const t = e.slice(0, 8).map((r) => p(String(r.label || r.value || ""))).filter(Boolean);
537
+ return t.length < 4 ? !1 : t.filter((r) => nn.test(r)).length / t.length >= 0.75;
533
538
  }
534
- function J(e) {
539
+ function Y(e) {
535
540
  return [
536
541
  e,
537
542
  e.querySelector(".van-field__control"),
@@ -556,11 +561,11 @@ function J(e) {
556
561
  e.querySelector(".select__wrapper")
557
562
  ].filter((n) => n instanceof HTMLElement).filter((n, r, o) => o.indexOf(n) === r);
558
563
  }
559
- function Ln() {
564
+ function Sn() {
560
565
  const e = /* @__PURE__ */ new Map();
561
- In(), document.documentElement.setAttribute(Fe, "true");
566
+ En(), document.documentElement.setAttribute(Le, "true");
562
567
  const t = () => {
563
- for (const r of document.querySelectorAll(De))
568
+ for (const r of document.querySelectorAll(Me))
564
569
  e.has(r) || e.set(r, {
565
570
  display: r.style.display,
566
571
  opacity: r.style.opacity,
@@ -576,19 +581,19 @@ function Ln() {
576
581
  attributes: !0,
577
582
  attributeFilter: ["class", "style", "aria-hidden"]
578
583
  }), {
579
- getTrackedDropdowns: () => Array.from(document.querySelectorAll(De)),
584
+ getTrackedDropdowns: () => Array.from(document.querySelectorAll(Me)),
580
585
  restore: () => {
581
- n.disconnect(), document.documentElement.removeAttribute(Fe);
586
+ n.disconnect(), document.documentElement.removeAttribute(Le);
582
587
  for (const [r, o] of e)
583
588
  r.style.display = o.display, r.style.opacity = o.opacity, r.style.visibility = o.visibility, r.style.pointerEvents = o.pointerEvents;
584
589
  }
585
590
  };
586
591
  }
587
- function In() {
588
- if (document.getElementById(Ze)) return;
592
+ function En() {
593
+ if (document.getElementById(Be)) return;
589
594
  const e = document.createElement("style");
590
- e.id = Ze, e.textContent = `
591
- ${De.split(",").map((t) => `html[${Fe}="true"] ${t.trim()}`).join(`,
595
+ e.id = Be, e.textContent = `
596
+ ${Me.split(",").map((t) => `html[${Le}="true"] ${t.trim()}`).join(`,
592
597
  `)} {
593
598
  opacity: 0 !important;
594
599
  visibility: hidden !important;
@@ -598,27 +603,27 @@ function In() {
598
603
  }
599
604
  `, document.head.appendChild(e);
600
605
  }
601
- async function Mn(e, t) {
602
- e.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.activeElement instanceof HTMLElement && document.activeElement.blur(), document.body.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("click", { bubbles: !0, cancelable: !0, view: window })), await R(120);
606
+ async function xn(e, t) {
607
+ e.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.activeElement instanceof HTMLElement && document.activeElement.blur(), document.body.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("click", { bubbles: !0, cancelable: !0, view: window })), await M(120);
603
608
  for (const n of t.getTrackedDropdowns())
604
609
  n.isConnected && (n.style.display = "none", n.setAttribute("aria-hidden", "true"));
605
610
  }
606
- function It(e) {
611
+ function Et(e) {
607
612
  window.PointerEvent && (e.dispatchEvent(new PointerEvent("pointerdown", { bubbles: !0, composed: !0, button: 0 })), e.dispatchEvent(new PointerEvent("pointerup", { bubbles: !0, composed: !0, button: 0 }))), e.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, composed: !0, button: 0 })), e.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, composed: !0, button: 0 })), e.click();
608
613
  }
609
- function Mt(e) {
614
+ function xt(e) {
610
615
  e.focus({ preventScroll: !0 });
611
616
  const t = e instanceof HTMLInputElement ? e : e.querySelector("input");
612
617
  t instanceof HTMLElement && t.focus({ preventScroll: !0 });
613
618
  }
614
- function Rt(e) {
619
+ function kt(e) {
615
620
  for (const t of [{ key: "ArrowDown", code: "ArrowDown" }, { key: "Enter", code: "Enter" }, { key: " ", code: "Space" }])
616
621
  e.dispatchEvent(new KeyboardEvent("keydown", { ...t, bubbles: !0, composed: !0 })), e.dispatchEvent(new KeyboardEvent("keyup", { ...t, bubbles: !0, composed: !0 }));
617
622
  }
618
- function R(e) {
623
+ function M(e) {
619
624
  return new Promise((t) => window.setTimeout(t, e));
620
625
  }
621
- function Rn() {
626
+ function kn() {
622
627
  const e = /* @__PURE__ */ new Map();
623
628
  e.set(window, { left: window.scrollX, top: window.scrollY });
624
629
  for (const t of document.querySelectorAll("*"))
@@ -628,250 +633,43 @@ function Rn() {
628
633
  t === window ? window.scrollTo(n.left, n.top) : t instanceof HTMLElement && (t.scrollLeft = n.left, t.scrollTop = n.top);
629
634
  };
630
635
  }
631
- function Ft(e) {
636
+ function _t(e) {
632
637
  const t = window.getComputedStyle(e);
633
638
  if (t.display === "none" || t.visibility === "hidden" || Number(t.opacity) === 0)
634
639
  return !1;
635
640
  const n = e.getBoundingClientRect();
636
641
  return n.width > 0 && n.height > 0;
637
642
  }
638
- const Fn = /(维吾尔自治区|壮族自治区|回族自治区|特别行政区|自治区直辖县级行政区划|自治区|自治州|地区|盟|林区|街道|苏木|社区|省|市|区|县|旗|镇|乡)$/g, On = /* @__PURE__ */ new Set(["市辖区", "县", "自治区直辖县级行政区划"]);
639
- let ae = null;
640
- function m(e) {
641
- return String(e ?? "").replace(/\s+/g, "").replace(/[,,。.、/\\\-]/g, "").trim().toLowerCase();
642
- }
643
- function T(e) {
644
- return m(e).replace(Fn, "");
645
- }
646
- function Ve(e) {
647
- if (e == null) return "";
648
- if (typeof e == "string" || typeof e == "number")
649
- return String(e).trim();
650
- if (Array.isArray(e))
651
- return e.map((t) => Ve(t)).filter(Boolean).join("");
652
- if (typeof e == "object") {
653
- const t = [], n = /* @__PURE__ */ new Set(), r = (o) => {
654
- const i = f(String(o ?? ""));
655
- !i || n.has(i) || (n.add(i), t.push(i));
656
- };
657
- for (const o of [
658
- "province",
659
- "provinceName",
660
- "prov",
661
- "city",
662
- "cityName",
663
- "district",
664
- "districtName",
665
- "area",
666
- "areaName",
667
- "county",
668
- "countyName",
669
- "region",
670
- "regionName",
671
- "address",
672
- "detail",
673
- "detailAddress",
674
- "fullAddress",
675
- "label",
676
- "text",
677
- "value",
678
- "name",
679
- "answer"
680
- ])
681
- r(e[o]);
682
- return t.join("");
683
- }
684
- return f(String(e));
685
- }
686
- function xe(e) {
687
- const t = [], n = [], r = (s) => {
688
- const a = f(String(s ?? ""));
689
- a && t.push(a);
690
- }, o = (s) => {
691
- const a = m(s);
692
- a && (n.push(a), r(s));
693
- };
694
- if (Array.isArray(e))
695
- for (const s of e) o(s);
696
- else if (typeof e == "object" && e) {
697
- for (const s of [
698
- "province",
699
- "provinceName",
700
- "prov",
701
- "city",
702
- "cityName",
703
- "district",
704
- "districtName",
705
- "area",
706
- "areaName",
707
- "county",
708
- "countyName",
709
- "region",
710
- "regionName"
711
- ])
712
- o(e[s]);
713
- for (const s of ["address", "detail", "detailAddress", "fullAddress", "label", "value", "text", "name", "answer"])
714
- r(e[s]);
715
- } else
716
- r(e);
717
- const i = m(t.join(""));
718
- return {
719
- fullText: i,
720
- looseFullText: T(i),
721
- structuredParts: n
722
- };
723
- }
724
- function _e(e, t) {
725
- const n = m(e), r = m(t);
726
- if (!n || !r) return !1;
727
- if (n === r || n.includes(r) || r.includes(n))
728
- return !0;
729
- const o = T(n), i = T(r);
730
- return !o || !i ? !1 : o === i || o.includes(i) || i.includes(o);
731
- }
732
- function Be(e, t = xe(e)) {
733
- const n = zn();
734
- if (!n.length) return [];
735
- let r = null, o = 0;
736
- for (const i of n) {
737
- const s = Nn(i, t);
738
- s > o && (o = s, r = i);
739
- }
740
- return o >= 120 ? (r == null ? void 0 : r.labels) || [] : [];
741
- }
742
- function Dn(e, t, n, r) {
743
- let o = null, i = 0;
744
- const s = Pn(t, n, r);
745
- for (const a of e) {
746
- const c = a.querySelector(".el-cascader-node__label, .ant-cascader-menu-item-content, .n-cascader-node__label, .arco-cascader-option-label"), l = f((c == null ? void 0 : c.textContent) || a.textContent || ""), u = m(l);
747
- if (!u) continue;
748
- const p = T(u);
749
- let g = qn(u, p, s);
750
- !g && t.fullText && (t.fullText.includes(u) ? g = 100 + u.length : u.includes(t.fullText) ? g = 70 + t.fullText.length : t.looseFullText.includes(p) && (g = 80 + p.length)), g > i && (i = g, o = a);
751
- }
752
- return i >= 75 ? o : null;
753
- }
754
- function Pn(e, t, n) {
755
- const r = [], o = /* @__PURE__ */ new Set(), i = (s, a) => {
756
- const c = m(s);
757
- !c || o.has(c) || (o.add(c), r.push({
758
- normalized: c,
759
- stripped: T(c),
760
- score: a
761
- }));
762
- };
763
- if (t.length) {
764
- t[n] && i(t[n], 260);
765
- for (let s = n + 1; s < t.length; s += 1)
766
- i(t[s], 215 - (s - n) * 15);
767
- }
768
- e.structuredParts[n] && i(e.structuredParts[n], 235);
769
- for (let s = 0; s < e.structuredParts.length; s += 1)
770
- s !== n && i(e.structuredParts[s], 180 - Math.abs(s - n) * 20);
771
- return e.fullText && i(e.fullText, 130), r;
772
- }
773
- function qn(e, t, n) {
774
- let r = 0;
775
- for (const o of n) {
776
- let i = 0;
777
- o.normalized === e ? i = o.score + 80 : o.stripped && o.stripped === t ? i = o.score + 68 : o.normalized.includes(e) ? i = o.score + 40 + e.length : e.includes(o.normalized) ? i = o.score + 28 + o.normalized.length : o.stripped && t && o.stripped.includes(t) ? i = o.score + 24 + t.length : o.stripped && t && t.includes(o.stripped) && (i = o.score + 20 + o.stripped.length), i > r && (r = i);
778
- }
779
- return r;
780
- }
781
- function Nn(e, t) {
782
- let n = 0, r = 0;
783
- for (let o = 0; o < e.aliasesByLevel.length; o += 1) {
784
- const i = $n(
785
- e.aliasesByLevel[o],
786
- t.structuredParts[o] || "",
787
- t.fullText,
788
- t.looseFullText,
789
- o
790
- );
791
- i > 0 ? (r += 1, n += i) : t.structuredParts[o] && (n -= 30);
792
- }
793
- return n += r * 18 + e.labels.length * 4, t.structuredParts.length > e.labels.length && (n -= (t.structuredParts.length - e.labels.length) * 10), n;
794
- }
795
- function $n(e, t, n, r, o) {
796
- const i = [60, 95, 135, 160][o] || 160;
797
- let s = 0;
798
- for (const a of e) {
799
- let c = 0;
800
- const l = T(a);
801
- t && (t === a ? c = Math.max(c, i + 130 + a.length) : t.includes(a) || a.includes(t) ? c = Math.max(c, i + 95 + Math.min(a.length, t.length)) : l && T(t) === l && (c = Math.max(c, i + 80 + l.length))), n && (n.includes(a) ? c = Math.max(c, i + 50 + a.length) : l && r.includes(l) && (c = Math.max(c, i + 35 + l.length))), c > s && (s = c);
802
- }
803
- return s;
804
- }
805
- function Hn(e) {
806
- const t = f(e), n = m(t);
807
- if (!n) return [];
808
- const r = /* @__PURE__ */ new Set([n]), o = T(n);
809
- o && !On.has(t) && r.add(o);
810
- const i = {
811
- 内蒙古自治区: "内蒙古",
812
- 广西壮族自治区: "广西",
813
- 西藏自治区: "西藏",
814
- 宁夏回族自治区: "宁夏",
815
- 新疆维吾尔自治区: "新疆",
816
- 香港特别行政区: "香港",
817
- 澳门特别行政区: "澳门"
818
- };
819
- return i[t] && r.add(i[t]), Array.from(r).filter(Boolean);
820
- }
821
- function zn() {
822
- if (ae) return ae;
823
- const e = globalThis.__SMART_FILL_ADDRESS_MAP__, t = e == null ? void 0 : e.data, n = Array.isArray(t) ? t : Array.isArray(t == null ? void 0 : t.data) ? t.data : [];
824
- return ae = Kn(n), ae;
825
- }
826
- function Kn(e) {
827
- const t = [], n = /* @__PURE__ */ new Set(), r = (o) => {
828
- const i = o.map((a) => f(a)).filter(Boolean);
829
- if (!i.length) return;
830
- const s = i.join(">");
831
- n.has(s) || (n.add(s), t.push({
832
- labels: i,
833
- aliasesByLevel: i.map((a) => Hn(a))
834
- }));
835
- };
836
- for (const o of e)
837
- if (o != null && o.label && (r([o.label]), !(!Array.isArray(o.children) || !o.children.length))) {
838
- for (const i of o.children)
839
- if (i != null && i.label && (r([o.label, i.label]), !(!Array.isArray(i.children) || !i.children.length)))
840
- for (const s of i.children)
841
- s != null && s.label && r([o.label, i.label, s.label]);
842
- }
843
- return t;
844
- }
845
- function Q(e, t) {
846
- const n = Ue(t);
643
+ function be(e, t) {
644
+ const n = me(t);
847
645
  if (!n.length) return null;
848
646
  let r = null, o = 0;
849
647
  for (const i of e) {
850
- const s = L(i.value), a = L(i.label);
648
+ const s = w(i.value), a = w(i.label);
851
649
  for (const c of n) {
852
650
  let l = 0;
853
- c === s || c === a ? l = 120 : s && c.includes(s) || a && c.includes(a) ? l = 100 : s && s.includes(c) || a && a.includes(c) ? l = 90 : (s && ce(s) === ce(c) || a && ce(a) === ce(c)) && (l = 80), l > o && (o = l, r = i);
651
+ c === s || c === a ? l = 120 : s && c.includes(s) || a && c.includes(a) ? l = 100 : s && s.includes(c) || a && a.includes(c) ? l = 90 : (s && re(s) === re(c) || a && re(a) === re(c)) && (l = 80), l > o && (o = l, r = i);
854
652
  }
855
653
  }
856
654
  return o >= 80 ? r : null;
857
655
  }
858
- function Ue(e) {
656
+ function me(e) {
859
657
  if (Array.isArray(e))
860
- return e.flatMap((n) => Ue(n));
658
+ return e.flatMap((n) => me(n));
861
659
  if (typeof e == "object" && e) {
862
660
  const n = e;
863
- return [n.label, n.value, n.text, n.answer, n.name].filter((r) => r != null).map((r) => L(r)).filter(Boolean);
661
+ return [n.label, n.value, n.text, n.answer, n.name].filter((r) => r != null).map((r) => w(r)).filter(Boolean);
864
662
  }
865
- const t = L(e);
663
+ const t = w(e);
866
664
  return t ? [t] : [];
867
665
  }
868
- function L(e) {
666
+ function w(e) {
869
667
  return String(e ?? "").replace(/\s+/g, "").replace(/[::,,。.、()()\-_/]/g, "").trim().toLowerCase();
870
668
  }
871
- function ce(e) {
872
- return L(e).replace(/(请选择|选择|状态|情况|类型|方式|所属|是否)$/g, "");
669
+ function re(e) {
670
+ return w(e).replace(/(请选择|选择|状态|情况|类型|方式|所属|是否)$/g, "");
873
671
  }
874
- const be = [
672
+ const de = [
875
673
  ".ant-select-item-option",
876
674
  ".el-select-dropdown__item",
877
675
  ".el-select-v2__option",
@@ -888,121 +686,114 @@ const be = [
888
686
  ".van-dropdown-item__option",
889
687
  ".van-radio",
890
688
  "[role='option']"
891
- ].join(", "), Vn = [
689
+ ].join(", "), _n = [
892
690
  ".el-cascader-panel .el-cascader-menu",
893
691
  ".ant-cascader-menu",
894
692
  ".van-cascader__options",
895
693
  ".n-cascader-menu",
896
694
  ".arco-cascader-list"
897
- ].join(", "), Bn = [
695
+ ].join(", "), Cn = [
898
696
  ".el-cascader-node",
899
697
  ".ant-cascader-menu-item",
900
698
  ".van-cascader__option",
901
699
  ".n-cascader-node",
902
700
  ".arco-cascader-option"
903
- ].join(", "), Un = ".van-picker__confirm, .van-picker__toolbar .van-picker__confirm", jn = [
904
- ".el-input__clear",
905
- ".el-cascader__tags .el-tag__close",
906
- ".el-tag__close",
907
- ".ant-select-clear",
908
- ".ant-cascader-picker-clear",
909
- ".n-base-clear",
910
- ".n-base-close",
911
- ".arco-icon-close",
912
- ".van-icon-clear",
913
- ".van-field__clear"
914
- ].join(", ");
915
- async function Gn(e, t, n, r) {
916
- const o = Xn(t, r);
917
- return e instanceof HTMLSelectElement ? Yn(e, o) : C(e) || n === "cascader" ? Wn(e, o) : (Z(e) || O(e) || n === "select" || n === "date", Qe(e, o));
701
+ ].join(", "), An = ".van-picker__confirm, .van-picker__toolbar .van-picker__confirm";
702
+ async function Tn(e, t, n, r) {
703
+ const o = Ct(t, r);
704
+ return e instanceof HTMLSelectElement ? Ln(e, o) : C(e) || n === "cascader" ? In(e, o) : (j(e) || E(e) || n === "select" || n === "date", je(e, o));
918
705
  }
919
- function Ot(e) {
706
+ function $e(e) {
920
707
  if (e instanceof HTMLSelectElement) {
921
708
  const n = e.options[e.selectedIndex];
922
- return f((n == null ? void 0 : n.textContent) || e.value);
709
+ return p((n == null ? void 0 : n.textContent) || e.value);
923
710
  }
924
- if (C(e))
925
- return je(e);
926
- if (Z(e) || O(e))
927
- return kt(e);
711
+ if (C(e)) {
712
+ const n = e.querySelector("input");
713
+ if (n != null && n.value) return p(n.value);
714
+ const r = e.querySelector(".el-cascader__tags-text, .el-cascader__label");
715
+ return p((r == null ? void 0 : r.textContent) || "");
716
+ }
717
+ if (j(e) || E(e))
718
+ return sn(e);
928
719
  const t = e.querySelector("input, textarea");
929
- return f((t == null ? void 0 : t.value) || e.textContent || "");
720
+ return p((t == null ? void 0 : t.value) || e.textContent || "");
930
721
  }
931
- async function Yn(e, t) {
722
+ async function Ln(e, t) {
932
723
  const n = Array.from(e.options).map((o) => ({
933
724
  source: o,
934
725
  value: o.value,
935
726
  label: o.textContent
936
- })), r = Q(n, t.searchValue);
727
+ })), r = be(n, t.searchValue);
937
728
  if ((r == null ? void 0 : r.source) instanceof HTMLOptionElement) {
938
- ve(e, r.source.value), A(e);
729
+ he(e, r.source.value), _(e);
939
730
  return;
940
731
  }
941
- if (!U(e, t.fillValue))
732
+ if (!V(e, t))
942
733
  throw new Error("原生下拉框中没有匹配到对应选项");
943
734
  }
944
- async function Qe(e, t) {
945
- const n = Ee(e) || e, r = kt(n);
946
- if (r && Q([{ value: r, label: r }], t.searchValue))
947
- return;
948
- const o = new Set(ee());
735
+ async function je(e, t) {
736
+ const n = G(e) || e;
737
+ if (Se(n, t.searchValue)) return;
738
+ const r = new Set(W());
949
739
  try {
950
- if (!await Zn(n)) {
951
- if (U(n, t.fillValue)) return;
740
+ if (!await Mn(n)) {
741
+ if (V(n, t)) return;
952
742
  throw new Error("自定义下拉框未能成功展开");
953
743
  }
954
- const s = await rr(n, o), a = await Qn(t.searchValue, s, !0);
955
- if (!(a != null && a.source)) {
956
- if (await me(n), U(n, t.fillValue)) return;
744
+ const i = await Vn(n, r), s = await On(t.searchValue, i, !0);
745
+ if (!(s != null && s.source)) {
746
+ if (await fe(n), V(n, t)) return;
957
747
  throw new Error("自定义下拉框展开后未找到匹配选项");
958
748
  }
959
- if (H(a.source), await y(120), ir(), A(n), await y(120), tt(n, t.searchValue) || U(n, t.fillValue) && tt(n, t.searchValue))
749
+ if (X(s.source), await y(120), zn(), _(n), await y(120), Se(n, t.searchValue) || V(n, t) && Se(n, t.searchValue))
960
750
  return;
961
751
  throw new Error("自定义下拉框点击选项后未成功回填");
962
752
  } finally {
963
- await me(n), await y(80);
753
+ await fe(n), await y(80);
964
754
  }
965
755
  }
966
- async function Wn(e, t) {
756
+ async function In(e, t) {
967
757
  const n = e.closest(".el-cascader, .ant-cascader, .van-cascader, .n-cascader, .arco-cascader") || e;
968
- if (!le(n, t.searchValue) && !(z(n) && (await nr(n), await y(120), le(n, t.searchValue)))) {
758
+ if (!ve(n, t.searchValue)) {
969
759
  try {
970
- if (await Jn(n)) {
971
- const o = await er(t.searchValue);
972
- if (await y(180), await me(n), await y(120), o && le(n, t.searchValue)) {
973
- A(n);
760
+ if (await Rn(n)) {
761
+ const o = await Dn(t.searchValue);
762
+ if (await y(180), await fe(n), await y(120), o && ve(n, t.searchValue)) {
763
+ _(n);
974
764
  return;
975
765
  }
976
766
  }
977
- if (tr(n, t.fillValue) && le(n, t.searchValue))
767
+ if (Pn(n, t.fillValue) && ve(n, t.searchValue))
978
768
  return;
979
769
  } finally {
980
- await me(n), await y(80);
770
+ await fe(n), await y(80);
981
771
  }
982
772
  throw new Error("级联选择框匹配失败");
983
773
  }
984
774
  }
985
- function Xn(e, t) {
986
- var o;
987
- const n = (o = t == null ? void 0 : t.options) != null && o.length ? Q(
988
- t.options.map((i) => ({
989
- value: String(i.value),
990
- label: i.label
775
+ function Ct(e, t) {
776
+ var s;
777
+ const n = (s = t == null ? void 0 : t.options) != null && s.length ? be(
778
+ t.options.map((a) => ({
779
+ value: String(a.value),
780
+ label: a.label
991
781
  })),
992
782
  e
993
- ) : null, r = (n == null ? void 0 : n.value) ?? (n == null ? void 0 : n.label) ?? e;
783
+ ) : null, r = A(e), o = p(String((n == null ? void 0 : n.label) ?? r ?? "")), i = p(String((n == null ? void 0 : n.value) ?? (n == null ? void 0 : n.label) ?? r ?? ""));
994
784
  return {
995
785
  searchValue: n ? [e, n.label, n.value] : e,
996
- fillValue: r
786
+ fillValue: i,
787
+ displayValue: o
997
788
  };
998
789
  }
999
- async function Zn(e) {
1000
- const t = Ge(e);
790
+ async function Mn(e) {
791
+ const t = Ne(e);
1001
792
  for (const n of t)
1002
- if (Pt(n), H(n), await y(160), et(e) || (qt(n), await y(180), et(e))) return !0;
793
+ if (Tt(n), X(n), await y(160), Ge(e) || (Lt(n), await y(180), Ge(e))) return !0;
1003
794
  return !1;
1004
795
  }
1005
- async function Jn(e) {
796
+ async function Rn(e) {
1006
797
  const t = [
1007
798
  e,
1008
799
  e.querySelector(".el-input__wrapper"),
@@ -1011,16 +802,16 @@ async function Jn(e) {
1011
802
  e.querySelector("input")
1012
803
  ].filter((n) => n instanceof HTMLElement);
1013
804
  for (const n of t)
1014
- if (Pt(n), H(n), await y(180), j().length || (qt(n), await y(180), j().length)) return !0;
805
+ if (Tt(n), X(n), await y(180), pe().length || (Lt(n), await y(180), pe().length)) return !0;
1015
806
  return !1;
1016
807
  }
1017
- async function Qn(e, t, n = !1) {
808
+ async function On(e, t, n = !1) {
1018
809
  for (let r = 0; r < 12; r += 1) {
1019
- const o = Q(
1020
- Dt(t, n).map((i) => ({
810
+ const o = be(
811
+ At(t, n).map((i) => ({
1021
812
  source: i,
1022
- value: i.getAttribute("data-value") || i.getAttribute("value") || i.textContent || "",
1023
- label: i.textContent || ""
813
+ value: Fn(i),
814
+ label: qn(i)
1024
815
  })),
1025
816
  e
1026
817
  );
@@ -1029,101 +820,105 @@ async function Qn(e, t, n = !1) {
1029
820
  }
1030
821
  return null;
1031
822
  }
1032
- async function er(e) {
1033
- const t = xe(e), n = ar(e, t);
1034
- if (!t.fullText && !t.structuredParts.length && !n.length) return !1;
1035
- const r = Be(e, t), o = Math.max(r.length, n.length, t.structuredParts.length, 1);
1036
- for (let i = 0; i < o; i += 1) {
1037
- const s = j();
1038
- if (!s.length) return i > 0;
1039
- const a = s[Math.min(i, s.length - 1)], c = Array.from(a.querySelectorAll(Bn)).filter((u) => !u.classList.contains("is-disabled") && u.getAttribute("aria-disabled") !== "true");
1040
- if (!c.length) return !1;
1041
- let l = null;
1042
- if ((t.fullText || t.structuredParts.length) && (l = Dn(c, t, r, i)), !l) {
1043
- const u = r[i] ?? n[i];
1044
- if (!u) return !1;
1045
- const p = Q(
1046
- c.map((g) => {
1047
- var x;
1048
- return {
1049
- source: g,
1050
- value: g.getAttribute("data-value") || g.textContent,
1051
- label: ((x = g.querySelector(".el-cascader-node__label, .ant-cascader-menu-item-content, .n-cascader-node__label, .arco-cascader-option-label")) == null ? void 0 : x.textContent) || g.textContent
1052
- };
1053
- }),
1054
- u
1055
- );
1056
- l = (p == null ? void 0 : p.source) ?? null;
1057
- }
1058
- if (!l) return !1;
1059
- if (H(l), await y(220), !j().length) return !0;
823
+ function Fn(e) {
824
+ return e.getAttribute("data-value") || e.getAttribute("data-name") || e.getAttribute("value") || e.getAttribute("name") || e.textContent || "";
825
+ }
826
+ function qn(e) {
827
+ var t;
828
+ return p(
829
+ ((t = e.querySelector(".van-action-sheet__name, .el-cascader-node__label, .ant-cascader-menu-item-content, .n-cascader-node__label, .arco-cascader-option-label")) == null ? void 0 : t.textContent) || e.textContent || ""
830
+ );
831
+ }
832
+ async function Dn(e) {
833
+ const t = Un(e);
834
+ if (!t.length) return !1;
835
+ for (let n = 0; n < t.length; n += 1) {
836
+ const r = pe();
837
+ if (!r.length) return n > 0;
838
+ const o = r[r.length - 1], i = Array.from(o.querySelectorAll(Cn)).filter((a) => !a.classList.contains("is-disabled") && a.getAttribute("aria-disabled") !== "true"), s = be(
839
+ i.map((a) => {
840
+ var c;
841
+ return {
842
+ source: a,
843
+ value: a.getAttribute("data-value") || a.textContent,
844
+ label: ((c = a.querySelector(".el-cascader-node__label")) == null ? void 0 : c.textContent) || a.textContent
845
+ };
846
+ }),
847
+ t[n]
848
+ );
849
+ if (!(s != null && s.source)) return !1;
850
+ X(s.source), await y(220);
1060
851
  }
1061
- return !j().length;
852
+ return !pe().length || !0;
1062
853
  }
1063
- function U(e, t) {
1064
- const n = F(t);
1065
- if (!n) return !1;
854
+ function V(e, t) {
855
+ const n = Nn(t) ? t : Ct(t), r = n.displayValue || A(t), o = n.fillValue || r;
856
+ if (!r && !o) return !1;
857
+ const i = G(e) || e;
858
+ if (E(i))
859
+ return Hn(i, r, o);
1066
860
  if (e instanceof HTMLSelectElement) {
1067
- let s = Array.from(e.options).find((a) => a.dataset.smartFillFallbackOption === "true");
1068
- return s || (s = document.createElement("option"), s.dataset.smartFillFallbackOption = "true", e.appendChild(s)), s.value = n, s.textContent = n, s.selected = !0, ve(e, n), A(e), !0;
861
+ let l = Array.from(e.options).find((u) => u.dataset.smartFillFallbackOption === "true");
862
+ return l || (l = document.createElement("option"), l.dataset.smartFillFallbackOption = "true", e.appendChild(l)), l.value = o, l.textContent = r || o, l.selected = !0, he(e, o), _(e), !0;
1069
863
  }
1070
- const r = e.querySelector('input:not([type="hidden"])');
1071
- if (!(r instanceof HTMLInputElement) || r.disabled) return !1;
1072
- const o = r.readOnly, i = r.hasAttribute("readonly");
864
+ const s = e.querySelector('input:not([type="hidden"])');
865
+ if (!(s instanceof HTMLInputElement) || s.disabled) return !1;
866
+ const a = s.readOnly, c = s.hasAttribute("readonly");
1073
867
  try {
1074
- return o && (r.readOnly = !1, r.removeAttribute("readonly")), r.focus(), ve(r, n), r.dispatchEvent(new InputEvent("input", {
868
+ return a && (s.readOnly = !1, s.removeAttribute("readonly")), s.focus(), he(s, r), s.dispatchEvent(new InputEvent("input", {
1075
869
  bubbles: !0,
1076
870
  composed: !0,
1077
- data: n,
871
+ data: r,
1078
872
  inputType: "insertReplacementText"
1079
- })), r.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), A(r), A(e), r.blur(), !0;
873
+ })), s.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), _(s), _(e), s.blur(), !0;
1080
874
  } catch {
1081
875
  return !1;
1082
876
  } finally {
1083
- o && (r.readOnly = !0, i && r.setAttribute("readonly", ""));
877
+ a && (s.readOnly = !0, c && s.setAttribute("readonly", ""));
1084
878
  }
1085
879
  }
1086
- function tr(e, t) {
1087
- const n = e.querySelector("input"), r = Ve(t) || F(t);
1088
- return !(n instanceof HTMLInputElement) || !r || n.disabled ? !1 : U(e, r);
1089
- }
1090
- function je(e) {
1091
- const t = e.querySelector("input");
1092
- if (t instanceof HTMLInputElement && t.value)
1093
- return f(t.value);
1094
- const n = e.querySelector(
1095
- ".el-cascader__tags-text, .el-cascader__label, .ant-cascader-picker-label, .n-base-selection-label, .arco-cascader-view-value"
1096
- );
1097
- return f((n == null ? void 0 : n.textContent) || "");
880
+ function Pn(e, t) {
881
+ const n = e.querySelector("input"), r = A(t);
882
+ return !(n instanceof HTMLInputElement) || !r || n.disabled ? !1 : V(e, {
883
+ searchValue: t,
884
+ fillValue: r,
885
+ displayValue: r
886
+ });
1098
887
  }
1099
- function z(e) {
1100
- const t = je(e);
1101
- return !!(m(t) || L(t));
1102
- }
1103
- async function nr(e) {
1104
- if (!z(e)) return !0;
1105
- const t = e.querySelector(".el-input__wrapper, .el-input, .ant-select-selector, .ant-cascader-picker") ?? e;
1106
- t instanceof HTMLElement && (t.dispatchEvent(new MouseEvent("mouseenter", { bubbles: !0 })), await y(80));
1107
- const n = e.querySelector(jn);
1108
- if (n && D(n) && (H(n), await y(120), !z(e)))
1109
- return !0;
1110
- const r = e.querySelector('input:not([type="hidden"])');
1111
- if (r instanceof HTMLInputElement && !r.disabled) {
1112
- const o = r.readOnly, i = r.hasAttribute("readonly");
1113
- try {
1114
- if (o && (r.readOnly = !1, r.removeAttribute("readonly")), r.focus(), ve(r, ""), r.dispatchEvent(new InputEvent("input", {
1115
- bubbles: !0,
1116
- composed: !0,
1117
- data: "",
1118
- inputType: "deleteContentBackward"
1119
- })), r.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), A(r), A(e), r.blur(), await y(80), !z(e)) return !0;
1120
- } finally {
1121
- o && (r.readOnly = !0, i && r.setAttribute("readonly", ""));
1122
- }
888
+ function Hn(e, t, n) {
889
+ $n(e);
890
+ const r = e.querySelector(".van-field__control"), o = Array.from(e.querySelectorAll('input[type="hidden"]')), i = Array.from(e.querySelectorAll('input:not([type="hidden"])'));
891
+ r instanceof HTMLInputElement ? K(r, t || n) : r instanceof HTMLElement && (r.textContent = t || n);
892
+ for (const s of o)
893
+ K(s, n);
894
+ for (const s of i)
895
+ r !== s && K(s, t || n);
896
+ return _(e), !0;
897
+ }
898
+ function $n(e) {
899
+ const t = e.querySelector(".van-field__control");
900
+ t instanceof HTMLInputElement ? K(t, "") : t instanceof HTMLElement && (t.textContent = "");
901
+ for (const n of e.querySelectorAll("input"))
902
+ K(n, "");
903
+ }
904
+ function K(e, t) {
905
+ if (e.disabled) return;
906
+ const n = e.readOnly, r = e.hasAttribute("readonly");
907
+ try {
908
+ n && (e.readOnly = !1, e.removeAttribute("readonly")), he(e, t), e.dispatchEvent(new InputEvent("input", {
909
+ bubbles: !0,
910
+ composed: !0,
911
+ data: t,
912
+ inputType: t ? "insertReplacementText" : "deleteContentBackward"
913
+ })), e.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), _(e);
914
+ } finally {
915
+ n && (e.readOnly = !0, r && e.setAttribute("readonly", ""));
1123
916
  }
1124
- return !z(e);
1125
917
  }
1126
- function Ge(e) {
918
+ function Nn(e) {
919
+ return typeof e == "object" && e != null && "searchValue" in e && "fillValue" in e && "displayValue" in e;
920
+ }
921
+ function Ne(e) {
1127
922
  return [
1128
923
  e,
1129
924
  e.querySelector(".van-field__control"),
@@ -1143,65 +938,68 @@ function Ge(e) {
1143
938
  e.querySelector(".select__wrapper")
1144
939
  ].filter((n) => n instanceof HTMLElement).filter((n, r, o) => o.indexOf(n) === r);
1145
940
  }
1146
- function Dt(e, t) {
1147
- return (e.length ? e : ee()).flatMap((o) => o.matches(be) ? [o] : Array.from(o.querySelectorAll(be))).filter((o, i, s) => s.indexOf(o) === i).filter((o) => t ? !o.classList.contains("is-disabled") && !o.classList.contains("ant-select-item-option-disabled") && o.getAttribute("aria-disabled") !== "true" : D(o) && !o.classList.contains("is-disabled") && !o.classList.contains("ant-select-item-option-disabled") && o.getAttribute("aria-disabled") !== "true");
941
+ function At(e, t) {
942
+ return (e.length ? e : W()).flatMap((o) => o.matches(de) ? [o] : Array.from(o.querySelectorAll(de))).filter((o, i, s) => s.indexOf(o) === i).filter((o) => t ? !o.classList.contains("is-disabled") && !o.classList.contains("ant-select-item-option-disabled") && o.getAttribute("aria-disabled") !== "true" : D(o) && !o.classList.contains("is-disabled") && !o.classList.contains("ant-select-item-option-disabled") && o.getAttribute("aria-disabled") !== "true");
1148
943
  }
1149
- function j() {
1150
- return Array.from(document.querySelectorAll(Vn)).filter(D);
944
+ function pe() {
945
+ return Array.from(document.querySelectorAll(_n)).filter(D);
1151
946
  }
1152
- async function rr(e, t) {
947
+ async function Vn(e, t) {
1153
948
  for (let n = 0; n < 10; n += 1) {
1154
- const r = or(e, t);
949
+ const r = Kn(e, t);
1155
950
  if (r.length) return r;
1156
951
  await y(80);
1157
952
  }
1158
- return ee().filter(D);
953
+ return W().filter(D);
1159
954
  }
1160
- function or(e, t) {
1161
- const n = ee(), r = n.filter((i) => !t.has(i));
955
+ function Kn(e, t) {
956
+ const n = W(), r = n.filter((i) => !t.has(i));
1162
957
  if (r.length)
1163
- return r.sort((i, s) => ue(s) - ue(i));
958
+ return r.sort((i, s) => oe(s) - oe(i));
1164
959
  const o = new Set(
1165
- Ge(e).flatMap((i) => [i.getAttribute("aria-controls"), i.getAttribute("aria-owns")]).filter((i) => !!i)
960
+ Ne(e).flatMap((i) => [i.getAttribute("aria-controls"), i.getAttribute("aria-owns")]).filter((i) => !!i)
1166
961
  );
1167
962
  if (o.size) {
1168
963
  const i = n.filter((s) => o.has(s.id));
1169
964
  if (i.length) return i;
1170
965
  }
1171
- return n.filter((i) => D(i) && (i.querySelector(be) || i.matches(be))).sort((i, s) => ue(s) - ue(i)).slice(0, 1);
1172
- }
1173
- function et(e) {
1174
- return Dt(ee().filter(D), !1).length > 0 ? !0 : Ge(e).some((t) => t.getAttribute("aria-expanded") === "true" || t.classList.contains("is-focus") || t.classList.contains("is-focused"));
966
+ return n.filter((i) => D(i) && (i.querySelector(de) || i.matches(de))).sort((i, s) => oe(s) - oe(i)).slice(0, 1);
1175
967
  }
1176
- function le(e, t) {
1177
- const n = je(e), r = m(n);
1178
- if (!r) return !1;
1179
- const o = Ve(t) || F(t), i = m(o);
1180
- if (_e(r, i)) return !0;
1181
- const s = xe(t), a = Be(t, s);
1182
- if (_e(r, m(a.join("")))) return !0;
1183
- const c = m(s.structuredParts.join(""));
1184
- return _e(r, c);
968
+ function Ge(e) {
969
+ return At(W().filter(D), !1).length > 0 ? !0 : Ne(e).some((t) => t.getAttribute("aria-expanded") === "true" || t.classList.contains("is-focus") || t.classList.contains("is-focused"));
1185
970
  }
1186
- function tt(e, t) {
1187
- const n = L(Ot(e)), r = L(F(t));
971
+ function ve(e, t) {
972
+ const n = w($e(e)), r = w(A(t));
1188
973
  return !n || !r ? !1 : n === r || n.includes(r) || r.includes(n);
1189
974
  }
1190
- function ir() {
1191
- const e = document.querySelector(Un);
1192
- e && D(e) && H(e);
975
+ function Se(e, t) {
976
+ const n = w($e(e));
977
+ if (!n) return !1;
978
+ const r = me(t);
979
+ if (!r.length) {
980
+ const o = w(A(t));
981
+ return o ? n === o || n.includes(o) || o.includes(n) : !1;
982
+ }
983
+ return r.some((o) => {
984
+ const i = w(o);
985
+ return !!i && (n === i || n.includes(i) || i.includes(n));
986
+ });
1193
987
  }
1194
- async function me(e) {
988
+ function zn() {
989
+ const e = document.querySelector(An);
990
+ e && D(e) && X(e);
991
+ }
992
+ async function fe(e) {
1195
993
  e == null || e.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", code: "Escape", bubbles: !0 })), document.activeElement instanceof HTMLElement && document.activeElement.blur(), document.body.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, cancelable: !0, view: window })), document.body.dispatchEvent(new MouseEvent("click", { bubbles: !0, cancelable: !0, view: window })), await y(120);
1196
994
  }
1197
- function ee() {
1198
- return Array.from(document.querySelectorAll(sr()));
995
+ function W() {
996
+ return Array.from(document.querySelectorAll(Bn()));
1199
997
  }
1200
- function ue(e) {
998
+ function oe(e) {
1201
999
  const t = e.getBoundingClientRect(), n = Number.parseInt(window.getComputedStyle(e).zIndex || "0", 10);
1202
1000
  return (Number.isNaN(n) ? 0 : n) * 10 + t.width * t.height;
1203
1001
  }
1204
- function sr() {
1002
+ function Bn() {
1205
1003
  return [
1206
1004
  ".el-select-dropdown",
1207
1005
  ".el-cascader__dropdown",
@@ -1227,50 +1025,46 @@ function sr() {
1227
1025
  "[role='listbox']"
1228
1026
  ].join(", ");
1229
1027
  }
1230
- function F(e) {
1028
+ function A(e) {
1231
1029
  if (e == null) return "";
1232
1030
  if (typeof e == "string" || typeof e == "number" || typeof e == "boolean")
1233
- return f(String(e));
1031
+ return p(String(e));
1234
1032
  if (Array.isArray(e))
1235
- return e.map((t) => F(t)).filter(Boolean).join(" ");
1033
+ return e.map((t) => A(t)).filter(Boolean).join(" ");
1236
1034
  if (typeof e == "object") {
1237
1035
  const t = e;
1238
1036
  for (const n of ["label", "text", "value", "answer", "name"]) {
1239
- const r = F(t[n]);
1037
+ const r = A(t[n]);
1240
1038
  if (r) return r;
1241
1039
  }
1242
1040
  }
1243
- return f(String(e));
1041
+ return p(String(e));
1244
1042
  }
1245
- function ar(e, t = xe(e)) {
1246
- if (t.structuredParts.length)
1247
- return t.structuredParts.map((i) => f(i));
1248
- const n = Be(e, t);
1249
- if (n.length) return n;
1250
- const r = F(e);
1251
- if (!r) return [];
1252
- if (r.includes("/") || r.includes("、"))
1253
- return r.split(/[//、]/).map((i) => i.trim()).filter(Boolean);
1254
- const o = Ue(e);
1255
- return o.length ? [f(o[0])] : [r];
1043
+ function Un(e) {
1044
+ const t = A(e);
1045
+ if (!t) return [];
1046
+ if (t.includes("/") || t.includes("、"))
1047
+ return t.split(/[//、]/).map((r) => r.trim()).filter(Boolean);
1048
+ const n = me(e);
1049
+ return n.length ? [p(n[0])] : [t];
1256
1050
  }
1257
- function ve(e, t) {
1051
+ function he(e, t) {
1258
1052
  var o;
1259
1053
  const n = Object.getPrototypeOf(e), r = Object.getOwnPropertyDescriptor(n, "value");
1260
1054
  (o = r == null ? void 0 : r.set) == null || o.call(e, t);
1261
1055
  }
1262
- function A(e) {
1056
+ function _(e) {
1263
1057
  e.dispatchEvent(new Event("focus", { bubbles: !0 })), e.dispatchEvent(new InputEvent("input", { bubbles: !0, composed: !0, data: null, inputType: "insertText" })), e.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), e.dispatchEvent(new Event("blur", { bubbles: !0 }));
1264
1058
  }
1265
- function H(e) {
1059
+ function X(e) {
1266
1060
  window.PointerEvent && (e.dispatchEvent(new PointerEvent("pointerdown", { bubbles: !0, composed: !0, button: 0 })), e.dispatchEvent(new PointerEvent("pointerup", { bubbles: !0, composed: !0, button: 0 }))), e.dispatchEvent(new MouseEvent("mousedown", { bubbles: !0, composed: !0, button: 0 })), e.dispatchEvent(new MouseEvent("mouseup", { bubbles: !0, composed: !0, button: 0 })), e.click();
1267
1061
  }
1268
- function Pt(e) {
1062
+ function Tt(e) {
1269
1063
  e.focus({ preventScroll: !0 });
1270
1064
  const t = e instanceof HTMLInputElement ? e : e.querySelector("input");
1271
1065
  t instanceof HTMLElement && t.focus({ preventScroll: !0 });
1272
1066
  }
1273
- function qt(e) {
1067
+ function Lt(e) {
1274
1068
  for (const t of [{ key: "ArrowDown", code: "ArrowDown" }, { key: "Enter", code: "Enter" }, { key: " ", code: "Space" }])
1275
1069
  e.dispatchEvent(new KeyboardEvent("keydown", { ...t, bubbles: !0, composed: !0 })), e.dispatchEvent(new KeyboardEvent("keyup", { ...t, bubbles: !0, composed: !0 }));
1276
1070
  }
@@ -1283,110 +1077,110 @@ function D(e) {
1283
1077
  function y(e) {
1284
1078
  return new Promise((t) => window.setTimeout(t, e));
1285
1079
  }
1286
- const nt = /* @__PURE__ */ new Set(["select", "cascader", "date"]), Nt = {
1080
+ const Ye = /* @__PURE__ */ new Set(["select", "cascader", "date"]), It = {
1287
1081
  name: "ui-framework",
1288
- match: (e) => e.matches(bt) || mt(e) || !cr(e) && Y(e),
1082
+ match: (e) => e.matches(lt) || ut(e) || !jn(e) && Oe(e),
1289
1083
  getValue: (e) => {
1290
1084
  var o, i;
1291
1085
  const t = e.element;
1292
1086
  if (!t) return;
1293
- const n = N(t);
1294
- if ((n == null ? void 0 : n.kind) === "switch") return X(t);
1295
- if ((n == null ? void 0 : n.kind) === "radioGroup") return fr(t);
1296
- if ((n == null ? void 0 : n.kind) === "checkboxGroup") return pr(t);
1297
- const r = e.type || he(t) || (n == null ? void 0 : n.type);
1298
- return r && nt.has(r) ? Ot(t) : n ? ((i = q(t)) == null ? void 0 : i.value) || t.textContent || void 0 : (o = q(t)) == null ? void 0 : o.value;
1087
+ const n = F(t);
1088
+ if ((n == null ? void 0 : n.kind) === "switch") return U(t);
1089
+ if ((n == null ? void 0 : n.kind) === "radioGroup") return Xn(t);
1090
+ if ((n == null ? void 0 : n.kind) === "checkboxGroup") return Zn(t);
1091
+ const r = e.type || ce(t) || (n == null ? void 0 : n.type);
1092
+ return r && Ye.has(r) ? $e(t) : n ? ((i = O(t)) == null ? void 0 : i.value) || t.textContent || void 0 : (o = O(t)) == null ? void 0 : o.value;
1299
1093
  },
1300
1094
  setValue: async (e, t) => {
1301
1095
  const n = e.element;
1302
1096
  if (!n) return;
1303
- const r = N(n);
1097
+ const r = F(n);
1304
1098
  if ((r == null ? void 0 : r.kind) === "switch") {
1305
- lr(n, t);
1099
+ Gn(n, t);
1306
1100
  return;
1307
1101
  }
1308
1102
  if ((r == null ? void 0 : r.kind) === "radioGroup") {
1309
- dr(n, t);
1103
+ Wn(n, t);
1310
1104
  return;
1311
1105
  }
1312
1106
  if ((r == null ? void 0 : r.kind) === "checkboxGroup") {
1313
- ur(n, t);
1107
+ Yn(n, t);
1314
1108
  return;
1315
1109
  }
1316
- const o = e.type || he(n) || (r == null ? void 0 : r.type);
1317
- if (o && nt.has(o) || Y(n, o || void 0)) {
1318
- await Gn(n, t, o || "select", e);
1110
+ const o = e.type || ce(n) || (r == null ? void 0 : r.type);
1111
+ if (o && Ye.has(o) || Oe(n, o || void 0)) {
1112
+ await Tn(n, t, o || "select", e);
1319
1113
  return;
1320
1114
  }
1321
- const i = q(n);
1115
+ const i = O(n);
1322
1116
  if (i) {
1323
- hr(i, t);
1117
+ Jn(i, t);
1324
1118
  return;
1325
1119
  }
1326
1120
  n.dispatchEvent(new Event("change", { bubbles: !0 }));
1327
1121
  }
1328
- }, Bo = Nt;
1329
- function cr(e) {
1122
+ }, To = It;
1123
+ function jn(e) {
1330
1124
  return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement;
1331
1125
  }
1332
- function lr(e, t) {
1333
- X(e) !== gr(t) && we(e);
1126
+ function Gn(e, t) {
1127
+ U(e) !== Qn(t) && ge(e);
1334
1128
  }
1335
- function ur(e, t) {
1129
+ function Yn(e, t) {
1336
1130
  var o;
1337
- const n = new Set(yr(t).map(_)), r = vt(e) || [];
1338
- for (const i of W(e)) {
1339
- const s = te(i.textContent || ""), a = i.getAttribute("value") || ((o = i.querySelector("input")) == null ? void 0 : o.value) || s, c = X(i), l = n.has(_(String(a))) || n.has(_(s));
1340
- c !== l && we(i);
1131
+ const n = new Set(er(t).map(k)), r = dt(e) || [];
1132
+ for (const i of B(e)) {
1133
+ const s = Z(i.textContent || ""), a = i.getAttribute("value") || ((o = i.querySelector("input")) == null ? void 0 : o.value) || s, c = U(i), l = n.has(k(String(a))) || n.has(k(s));
1134
+ c !== l && ge(i);
1341
1135
  }
1342
- if (!W(e).length && r.length)
1136
+ if (!B(e).length && r.length)
1343
1137
  for (const i of r)
1344
- (n.has(_(String(i.value))) || n.has(_(i.label))) && we(e);
1138
+ (n.has(k(String(i.value))) || n.has(k(i.label))) && ge(e);
1345
1139
  }
1346
- function dr(e, t) {
1347
- const n = _(String(t ?? "")), r = W(e).find((o) => {
1140
+ function Wn(e, t) {
1141
+ const n = k(String(t ?? "")), r = B(e).find((o) => {
1348
1142
  var a;
1349
- const i = te(o.textContent || ""), s = o.getAttribute("value") || ((a = o.querySelector("input")) == null ? void 0 : a.value) || i;
1350
- return _(String(s)) === n || _(i) === n;
1143
+ const i = Z(o.textContent || ""), s = o.getAttribute("value") || ((a = o.querySelector("input")) == null ? void 0 : a.value) || i;
1144
+ return k(String(s)) === n || k(i) === n;
1351
1145
  });
1352
- r && we(r);
1146
+ r && ge(r);
1353
1147
  }
1354
- function fr(e) {
1148
+ function Xn(e) {
1355
1149
  var n;
1356
- const t = W(e).find((r) => X(r));
1150
+ const t = B(e).find((r) => U(r));
1357
1151
  if (t)
1358
- return t.getAttribute("value") || ((n = t.querySelector("input")) == null ? void 0 : n.value) || te(t.textContent || "");
1152
+ return t.getAttribute("value") || ((n = t.querySelector("input")) == null ? void 0 : n.value) || Z(t.textContent || "");
1359
1153
  }
1360
- function pr(e) {
1361
- return W(e).filter((t) => X(t)).map((t) => {
1154
+ function Zn(e) {
1155
+ return B(e).filter((t) => U(t)).map((t) => {
1362
1156
  var n;
1363
- return t.getAttribute("value") || ((n = t.querySelector("input")) == null ? void 0 : n.value) || te(t.textContent || "");
1157
+ return t.getAttribute("value") || ((n = t.querySelector("input")) == null ? void 0 : n.value) || Z(t.textContent || "");
1364
1158
  });
1365
1159
  }
1366
- function W(e) {
1367
- const t = N(e);
1160
+ function B(e) {
1161
+ const t = F(e);
1368
1162
  return t != null && t.optionSelector ? Array.from(e.querySelectorAll(t.optionSelector)) : [];
1369
1163
  }
1370
- function hr(e, t) {
1164
+ function Jn(e, t) {
1371
1165
  e.value = String(t ?? ""), e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 })), e.dispatchEvent(new Event("blur", { bubbles: !0 }));
1372
1166
  }
1373
- function we(e) {
1167
+ function ge(e) {
1374
1168
  e.dispatchEvent(new MouseEvent("click", { bubbles: !0, cancelable: !0, view: window }));
1375
1169
  }
1376
- function gr(e) {
1170
+ function Qn(e) {
1377
1171
  return typeof e == "boolean" ? e : ["true", "1", "是", "开启", "启用", "yes", "y"].includes(String(e ?? "").trim().toLowerCase());
1378
1172
  }
1379
- function yr(e) {
1173
+ function er(e) {
1380
1174
  return Array.isArray(e) ? e.map(String) : String(e ?? "").split(/[,,;;、]/).map((t) => t.trim()).filter(Boolean);
1381
1175
  }
1382
- function _(e) {
1383
- return te(e).toLowerCase();
1176
+ function k(e) {
1177
+ return Z(e).toLowerCase();
1384
1178
  }
1385
- function te(e) {
1179
+ function Z(e) {
1386
1180
  return e.replace(/\s+/g, " ").trim();
1387
1181
  }
1388
- const br = "https://uat.kingdeefin.com";
1389
- class $t extends Error {
1182
+ const tr = "https://uat.kingdeefin.com";
1183
+ class Mt extends Error {
1390
1184
  constructor(n) {
1391
1185
  super(n.message);
1392
1186
  /** 结构化错误信息,含 code / stage / retryable */
@@ -1394,26 +1188,26 @@ class $t extends Error {
1394
1188
  this.name = "SmartFillException", this.smartFillError = n;
1395
1189
  }
1396
1190
  }
1397
- function v(e, t, n, r = {}) {
1398
- return new $t({ code: e, message: t, stage: n, ...r });
1191
+ function b(e, t, n, r = {}) {
1192
+ return new Mt({ code: e, message: t, stage: n, ...r });
1399
1193
  }
1400
- function rt(e, t, n = "RECOGNIZE_FAILED") {
1401
- return e instanceof $t ? e.smartFillError : {
1194
+ function We(e, t, n = "RECOGNIZE_FAILED") {
1195
+ return e instanceof Mt ? e.smartFillError : {
1402
1196
  code: n,
1403
1197
  message: e instanceof Error ? e.message : String(e || "智能录入异常"),
1404
1198
  stage: t,
1405
1199
  retryable: t === "recognize"
1406
1200
  };
1407
1201
  }
1408
- function Se(e = "sf") {
1202
+ function ye(e = "sf") {
1409
1203
  return `${e}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
1410
1204
  }
1411
- class mr {
1205
+ class nr {
1412
1206
  constructor(t) {
1413
1207
  /** 会话 accessToken,写入请求头 seToken */
1414
1208
  d(this, "seToken", "");
1415
1209
  /** 网关根地址,见 config/defaults.ts */
1416
- d(this, "baseURL", br);
1210
+ d(this, "baseURL", tr);
1417
1211
  this.config = t;
1418
1212
  }
1419
1213
  /** 设置会话 token,后续 request 自动携带 seToken 请求头 */
@@ -1426,7 +1220,7 @@ class mr {
1426
1220
  */
1427
1221
  async createSession() {
1428
1222
  if (!/^seKey-[A-Za-z0-9_-]{6,}$/.test(this.config.apiKey))
1429
- throw v("API_KEY_INVALID", "apiKey 格式不正确,应以 seKey- 开头。", "setup");
1223
+ throw b("API_KEY_INVALID", "apiKey 格式不正确,应以 seKey- 开头。", "setup");
1430
1224
  return {
1431
1225
  apiKey: this.config.apiKey,
1432
1226
  rulesVersion: "0.0.1"
@@ -1471,17 +1265,17 @@ class mr {
1471
1265
  // scanToken: payload.scanToken,
1472
1266
  formCode: t.formCode || "",
1473
1267
  configVersion: t.configVersion || "",
1474
- formMsg: t.fields.map(({ fingerprint: c, element: l, localRuleMode: u, scanToken: p, source: g, ...x }) => x),
1268
+ formMsg: t.fields.map(({ fingerprint: c, element: l, localRuleMode: u, scanToken: h, source: T, ...P }) => P),
1475
1269
  // 将字段描述符转换为后端需要的格式
1476
1270
  userInputMsg: r || ""
1477
1271
  })
1478
1272
  }
1479
- ), i = wr(o, t.fields, t.scanToken);
1273
+ ), i = or(o, t.fields, t.scanToken);
1480
1274
  return console.log("suggestions", i), {
1481
1275
  scanToken: t.scanToken,
1482
1276
  suggestions: i,
1483
1277
  trace: o.trace || {
1484
- traceId: Se("trace"),
1278
+ traceId: ye("trace"),
1485
1279
  usedOcr: !!t.usedOcr,
1486
1280
  usedAi: !0,
1487
1281
  durationMs: Math.round(performance.now() - n)
@@ -1500,15 +1294,15 @@ class mr {
1500
1294
  method: "POST",
1501
1295
  body: n
1502
1296
  }
1503
- ), o = Er(r);
1297
+ ), o = sr(r);
1504
1298
  if (!o)
1505
- throw v("RECOGNIZE_FAILED", "图片识别未提取到文本内容。", "recognize");
1299
+ throw b("RECOGNIZE_FAILED", "图片识别未提取到文本内容。", "recognize");
1506
1300
  return o;
1507
1301
  }
1508
1302
  /** 通用 fetch 封装:超时控制、trace 头、HTTP 错误映射为 SmartFillException */
1509
1303
  async request(t, n) {
1510
1304
  const r = new AbortController(), o = window.setTimeout(() => r.abort(), this.config.requestTimeoutMs ?? 3e4), i = new Headers(n.headers);
1511
- n.body && !(n.body instanceof FormData) && !i.has("Content-Type") && i.set("Content-Type", "application/json"), i.set("x-trace-id", Se("trace")), this.seToken && i.set("seToken", `${this.seToken}`);
1305
+ n.body && !(n.body instanceof FormData) && !i.has("Content-Type") && i.set("Content-Type", "application/json"), i.set("x-trace-id", ye("trace")), this.seToken && i.set("seToken", `${this.seToken}`);
1512
1306
  try {
1513
1307
  const s = await fetch(`${this.baseURL}${t}`, {
1514
1308
  ...n,
@@ -1516,19 +1310,19 @@ class mr {
1516
1310
  signal: r.signal
1517
1311
  });
1518
1312
  if (!s.ok)
1519
- throw v(xr(s.status), await s.text(), t.includes("session") ? "setup" : "recognize", {
1313
+ throw b(ar(s.status), await s.text(), t.includes("session") ? "setup" : "recognize", {
1520
1314
  retryable: s.status >= 500 || s.status === 429
1521
1315
  });
1522
1316
  return s.json();
1523
1317
  } catch (s) {
1524
- throw s instanceof DOMException && s.name === "AbortError" ? v("RECOGNIZE_TIMEOUT", "识别请求超时,请稍后重试。", "recognize", { retryable: !0 }) : s;
1318
+ throw s instanceof DOMException && s.name === "AbortError" ? b("RECOGNIZE_TIMEOUT", "识别请求超时,请稍后重试。", "recognize", { retryable: !0 }) : s;
1525
1319
  } finally {
1526
1320
  window.clearTimeout(o);
1527
1321
  }
1528
1322
  }
1529
1323
  }
1530
- const vr = 0.95;
1531
- function wr(e, t, n) {
1324
+ const rr = 0.95;
1325
+ function or(e, t, n) {
1532
1326
  var i;
1533
1327
  const r = new Map(t.map((s) => [s.fieldId, s]));
1534
1328
  return (((i = e.data) == null ? void 0 : i.fieldValues) || []).filter((s) => !!(s != null && s.fieldId)).map((s) => {
@@ -1539,24 +1333,24 @@ function wr(e, t, n) {
1539
1333
  label: s.label || (a == null ? void 0 : a.label) || s.fieldId,
1540
1334
  value: s.value,
1541
1335
  displayValue: s.value == null ? "" : String(s.value),
1542
- confidence: Sr(s.confidence),
1336
+ confidence: ir(s.confidence),
1543
1337
  source: s.source || "ai",
1544
1338
  warnings: s.warnings
1545
1339
  };
1546
1340
  });
1547
1341
  }
1548
- function Sr(e) {
1549
- return typeof e != "number" || Number.isNaN(e) ? vr : e < 0 ? 0 : e > 1 ? 1 : e;
1342
+ function ir(e) {
1343
+ return typeof e != "number" || Number.isNaN(e) ? rr : e < 0 ? 0 : e > 1 ? 1 : e;
1550
1344
  }
1551
- function Er(e) {
1345
+ function sr(e) {
1552
1346
  var n;
1553
1347
  const t = typeof e.data == "string" ? e.data : ((n = e.data) == null ? void 0 : n.text) || e.text || "";
1554
1348
  return String(t || "").trim();
1555
1349
  }
1556
- function xr(e) {
1350
+ function ar(e) {
1557
1351
  return e === 401 ? "TOKEN_EXPIRED" : e === 403 ? "API_KEY_FORBIDDEN" : e === 404 ? "FORM_CONFIG_NOT_FOUND" : "RECOGNIZE_FAILED";
1558
1352
  }
1559
- class Ht {
1353
+ class Rt {
1560
1354
  constructor() {
1561
1355
  d(this, "handlers", /* @__PURE__ */ new Map());
1562
1356
  }
@@ -1577,7 +1371,7 @@ class Ht {
1577
1371
  this.handlers.clear();
1578
1372
  }
1579
1373
  }
1580
- class kr {
1374
+ class cr {
1581
1375
  constructor() {
1582
1376
  /** 当前页面所有存活实例 */
1583
1377
  d(this, "instances", /* @__PURE__ */ new Set());
@@ -1601,24 +1395,24 @@ class kr {
1601
1395
  this.instances.forEach((t) => t.destroy()), this.instances.clear(), this.active = null;
1602
1396
  }
1603
1397
  }
1604
- const _r = [
1398
+ const lr = [
1605
1399
  /^(el|rc|ant|radix|headlessui|mui|chakra)-/i,
1606
1400
  /[0-9a-f]{8,}/i,
1607
1401
  /\d{6,}/
1608
1402
  ];
1609
- function E(e) {
1403
+ function S(e) {
1610
1404
  const t = String(e || "").trim();
1611
- return !t || _r.some((n) => n.test(t)) ? "" : t;
1405
+ return !t || lr.some((n) => n.test(t)) ? "" : t;
1612
1406
  }
1613
- function G(e) {
1407
+ function z(e) {
1614
1408
  const t = (e.options || []).slice(0, 20).map((n) => `${n.label}:${String(n.value)}`).join("|");
1615
- return $(
1409
+ return q(
1616
1410
  [
1617
1411
  e.fieldId,
1618
1412
  e.tagName,
1619
1413
  e.type,
1620
- E(e.name),
1621
- E(e.id),
1414
+ S(e.name),
1415
+ S(e.id),
1622
1416
  e.label,
1623
1417
  e.placeholder,
1624
1418
  e.section,
@@ -1626,10 +1420,10 @@ function G(e) {
1626
1420
  ].join("::")
1627
1421
  );
1628
1422
  }
1629
- function $(e) {
1423
+ function q(e) {
1630
1424
  return String(e ?? "").replace(/\s+/g, " ").trim().toLowerCase();
1631
1425
  }
1632
- const Ae = /* @__PURE__ */ new WeakMap(), Ar = [
1426
+ const Ee = /* @__PURE__ */ new WeakMap(), ur = [
1633
1427
  'input:not([type="hidden"])',
1634
1428
  "textarea",
1635
1429
  "select",
@@ -1650,7 +1444,7 @@ const Ae = /* @__PURE__ */ new WeakMap(), Ar = [
1650
1444
  ".van-field__body",
1651
1445
  "[role='combobox']"
1652
1446
  ].join(", ");
1653
- class ot {
1447
+ class Xe {
1654
1448
  constructor(t, n, r = []) {
1655
1449
  this.fields = t, this.schemas = n, this.adapters = r;
1656
1450
  }
@@ -1664,23 +1458,23 @@ class ot {
1664
1458
  for (const o of t.values) {
1665
1459
  const i = this.fields.find((l) => l.fieldId === o.fieldId);
1666
1460
  if (!i) {
1667
- r.push(fe(o.fieldId, "", o.value, "字段不在当前扫描结果中", "FIELD_NOT_FOUND"));
1461
+ r.push(se(o.fieldId, "", o.value, "字段不在当前扫描结果中", "FIELD_NOT_FOUND"));
1668
1462
  continue;
1669
1463
  }
1670
1464
  if (i.scanToken !== t.scanToken) {
1671
- r.push(fe(i.fieldId, i.label, o.value, "页面扫描已过期,请重新扫描", "SCAN_TOKEN_EXPIRED"));
1465
+ r.push(se(i.fieldId, i.label, o.value, "页面扫描已过期,请重新扫描", "SCAN_TOKEN_EXPIRED"));
1672
1466
  continue;
1673
1467
  }
1674
- const s = Rr(this.schemas, o.fieldId), a = s != null && s.transform ? s.transform(o.value) : o.value, c = await this.getValue(i, s);
1468
+ const s = yr(this.schemas, o.fieldId), a = s != null && s.transform ? s.transform(o.value) : o.value, c = await this.getValue(i, s);
1675
1469
  try {
1676
1470
  const l = s != null && s.validate ? await s.validate(a) : !0;
1677
1471
  if (l !== !0) {
1678
- r.push(fe(i.fieldId, i.label, a, typeof l == "string" ? l : "字段校验未通过", "VALIDATE_FAILED"));
1472
+ r.push(se(i.fieldId, i.label, a, typeof l == "string" ? l : "字段校验未通过", "VALIDATE_FAILED"));
1679
1473
  continue;
1680
1474
  }
1681
1475
  await this.setValue(i, a, s), n.push({ fieldId: i.fieldId, label: i.label, value: a, previousValue: c });
1682
1476
  } catch (l) {
1683
- r.push(fe(i.fieldId, i.label, a, l instanceof Error ? l.message : "字段回填失败", "SET_VALUE_FAILED"));
1477
+ r.push(se(i.fieldId, i.label, a, l instanceof Error ? l.message : "字段回填失败", "SET_VALUE_FAILED"));
1684
1478
  }
1685
1479
  }
1686
1480
  return {
@@ -1694,7 +1488,7 @@ class ot {
1694
1488
  if (n != null && n.getValue) return n.getValue();
1695
1489
  const r = this.matchAdapter(t, n);
1696
1490
  if (r != null && r.getValue) return r.getValue(t);
1697
- const o = de(t, n);
1491
+ const o = ie(t, n);
1698
1492
  if (o)
1699
1493
  return o instanceof HTMLInputElement && o.type === "checkbox" ? o.checked : o instanceof HTMLInputElement && o.type === "radio" ? o.checked ? o.value : void 0 : o instanceof HTMLInputElement || o instanceof HTMLTextAreaElement || o instanceof HTMLSelectElement ? o.value : o.textContent;
1700
1494
  }
@@ -1705,38 +1499,38 @@ class ot {
1705
1499
  async setValue(t, n, r) {
1706
1500
  if (r != null && r.setValue) {
1707
1501
  await r.setValue(n);
1708
- const a = de(t, r);
1709
- a && Ce(a, t);
1502
+ const s = ie(t, r);
1503
+ s && xe(s, t);
1710
1504
  return;
1711
1505
  }
1712
- const o = de(t, r);
1506
+ const o = ie(t, r);
1713
1507
  if (!o) throw new Error("页面中未找到对应字段");
1714
- if (t.fingerprint && t.fingerprint !== G({ ...t, tagName: o.tagName.toLowerCase() }))
1508
+ if (t.fingerprint && t.fingerprint !== z({ ...t, tagName: o.tagName.toLowerCase() }))
1715
1509
  throw new Error("字段结构已变化,请重新扫描");
1716
- const i = this.matchAdapter(t, r), s = Y(o, t.type);
1510
+ const i = this.matchAdapter(t, r);
1717
1511
  if (t.disabled || o.hasAttribute("disabled") || o.getAttribute("aria-disabled") === "true")
1718
1512
  throw new Error("字段不可编辑");
1719
- if (!s && !i && (t.readonly || o.hasAttribute("readonly")))
1513
+ if (t.readonly || o.hasAttribute("readonly"))
1720
1514
  throw new Error("字段不可编辑");
1721
1515
  if (i) {
1722
- await i.setValue(t, n), Ce(o, t);
1516
+ await i.setValue(t, n), xe(o, t);
1723
1517
  return;
1724
1518
  }
1725
- Tr(o, n), Ce(o, t);
1519
+ pr(o, n), xe(o, t);
1726
1520
  }
1727
1521
  /** 匹配第一个适用的组件库适配器 */
1728
1522
  matchAdapter(t, n) {
1729
- const r = de(t, n);
1523
+ const r = ie(t, n);
1730
1524
  return r ? this.adapters.find((o) => o.match(r, t)) : void 0;
1731
1525
  }
1732
1526
  }
1733
- function de(e, t) {
1527
+ function ie(e, t) {
1734
1528
  var r;
1735
1529
  if ((r = e.element) != null && r.isConnected) return e.element;
1736
- const n = Cr(t == null ? void 0 : t.element);
1737
- return n || document.querySelector(`[data-smart-fill-id="${Ne(e.fieldId)}"]`);
1530
+ const n = dr(t == null ? void 0 : t.element);
1531
+ return n || document.querySelector(`[data-smart-fill-id="${qe(e.fieldId)}"]`);
1738
1532
  }
1739
- function Cr(e) {
1533
+ function dr(e) {
1740
1534
  if (e instanceof HTMLElement)
1741
1535
  return e.isConnected ? e : null;
1742
1536
  if (typeof e == "string")
@@ -1748,69 +1542,69 @@ function Cr(e) {
1748
1542
  }
1749
1543
  return null;
1750
1544
  }
1751
- function Tr(e, t) {
1545
+ function pr(e, t) {
1752
1546
  if (e instanceof HTMLInputElement && e.type === "checkbox")
1753
1547
  e.checked = !!t;
1754
1548
  else if (e instanceof HTMLInputElement && e.type === "radio") {
1755
- const n = document.querySelector(`input[type="radio"][name="${Ne(e.name)}"][value="${Ne(String(t))}"]`);
1549
+ const n = document.querySelector(`input[type="radio"][name="${qe(e.name)}"][value="${qe(String(t))}"]`);
1756
1550
  (n || e).checked = !0;
1757
1551
  } else e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? e.value = String(t ?? "") : e.isContentEditable && (e.textContent = String(t ?? ""));
1758
1552
  e.dispatchEvent(new Event("input", { bubbles: !0 })), e.dispatchEvent(new Event("change", { bubbles: !0 }));
1759
1553
  }
1760
- function Ce(e, t) {
1761
- for (const n of Lr(e, t))
1762
- Ir(n);
1554
+ function xe(e, t) {
1555
+ for (const n of fr(e, t))
1556
+ hr(n);
1763
1557
  }
1764
- function Lr(e, t) {
1558
+ function fr(e, t) {
1765
1559
  if (e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement)
1766
1560
  return [e];
1767
- const n = Y(e, t == null ? void 0 : t.type) && Ee(e) || e, r = Mr(
1768
- Array.from(n.querySelectorAll(Ar)).filter(it)
1561
+ const n = Oe(e, t == null ? void 0 : t.type) && G(e) || e, r = gr(
1562
+ Array.from(n.querySelectorAll(ur)).filter(Ze)
1769
1563
  );
1770
1564
  if (r.length)
1771
1565
  return r;
1772
- const o = q(n);
1773
- return o && it(o) ? [o] : [n];
1566
+ const o = O(n);
1567
+ return o && Ze(o) ? [o] : [n];
1774
1568
  }
1775
- function Ir(e) {
1569
+ function hr(e) {
1776
1570
  var r;
1777
- e.setAttribute("data-smart-fill-highlighted", "true"), (r = Ae.get(e)) == null || r.abort();
1571
+ e.setAttribute("data-smart-fill-highlighted", "true"), (r = Ee.get(e)) == null || r.abort();
1778
1572
  const t = new AbortController(), n = (o) => {
1779
- o && "isTrusted" in o && !o.isTrusted || (e.removeAttribute("data-smart-fill-highlighted"), t.abort(), Ae.delete(e));
1573
+ o && "isTrusted" in o && !o.isTrusted || (e.removeAttribute("data-smart-fill-highlighted"), t.abort(), Ee.delete(e));
1780
1574
  };
1781
- Ae.set(e, t), e.addEventListener("focus", n, { signal: t.signal }), e.addEventListener("pointerdown", n, { signal: t.signal }), e.addEventListener("keydown", n, { signal: t.signal }), e.addEventListener("input", n, { signal: t.signal }), e.addEventListener("change", n, { signal: t.signal });
1575
+ Ee.set(e, t), e.addEventListener("focus", n, { signal: t.signal }), e.addEventListener("pointerdown", n, { signal: t.signal }), e.addEventListener("keydown", n, { signal: t.signal }), e.addEventListener("input", n, { signal: t.signal }), e.addEventListener("change", n, { signal: t.signal });
1782
1576
  }
1783
- function Mr(e) {
1577
+ function gr(e) {
1784
1578
  return e.filter((t) => !e.some((n) => n !== t && n.contains(t)));
1785
1579
  }
1786
- function it(e) {
1580
+ function Ze(e) {
1787
1581
  const t = window.getComputedStyle(e);
1788
1582
  if (t.display === "none" || t.visibility === "hidden" || Number(t.opacity) === 0)
1789
1583
  return !1;
1790
1584
  const n = e.getBoundingClientRect();
1791
1585
  return n.width > 0 && n.height > 0;
1792
1586
  }
1793
- function fe(e, t, n, r, o) {
1587
+ function se(e, t, n, r, o) {
1794
1588
  return { fieldId: e, label: t, attemptedValue: n, reason: r, reasonCode: o };
1795
1589
  }
1796
- function Ne(e) {
1590
+ function qe(e) {
1797
1591
  return typeof CSS < "u" && CSS.escape ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
1798
1592
  }
1799
- function Rr(e, t) {
1593
+ function yr(e, t) {
1800
1594
  const n = e.find((o) => o.fieldId === t);
1801
1595
  if (n) return n;
1802
1596
  const r = t.includes(":") ? t.slice(t.lastIndexOf(":") + 1) : "";
1803
1597
  if (r)
1804
1598
  return e.find((o) => o.rowKey != null && String(o.rowKey) === r && `${o.fieldId}:${o.rowKey}` === t);
1805
1599
  }
1806
- const Fr = [
1600
+ const br = [
1807
1601
  { key: "mobile", pattern: new RegExp("(?<!\\d)1[3-9]\\d{9}(?!\\d)", "g"), confidence: 0.98, reason: "手机号正则命中" },
1808
1602
  { key: "idCard", pattern: new RegExp("(?<!\\d)\\d{17}[\\dXx](?!\\d)", "g"), confidence: 0.96, reason: "身份证号正则命中" },
1809
1603
  { key: "email", pattern: /[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g, confidence: 0.95, reason: "邮箱正则命中" },
1810
1604
  { key: "bankCard", pattern: new RegExp("(?<!\\d)\\d{16,19}(?!\\d)", "g"), confidence: 0.9, reason: "银行卡号正则命中" },
1811
1605
  { key: "amount", pattern: /(?:金额|价格|费用|合计|总计)[::\s]*([0-9]+(?:\.[0-9]{1,2})?)/g, confidence: 0.88, reason: "金额关键词命中" },
1812
1606
  { key: "date", pattern: /\d{4}[-/.年]\d{1,2}[-/.月]\d{1,2}日?/g, confidence: 0.86, reason: "日期格式命中" }
1813
- ], M = {
1607
+ ], I = {
1814
1608
  mobile: [
1815
1609
  "手机",
1816
1610
  "手机号",
@@ -1862,7 +1656,7 @@ const Fr = [
1862
1656
  "申请额度"
1863
1657
  ],
1864
1658
  date: ["日期", "时间", "有效期", "date", "申请日期", "申请时间", "受理日期", "进件日期"]
1865
- }, zt = {
1659
+ }, Ot = {
1866
1660
  mobile: "mobile",
1867
1661
  idCard: "idCard",
1868
1662
  email: "email",
@@ -1870,20 +1664,20 @@ const Fr = [
1870
1664
  amount: "amount",
1871
1665
  date: "date"
1872
1666
  };
1873
- class Or {
1667
+ class mr {
1874
1668
  /**
1875
1669
  * 从文本中提取事实并匹配到 scan 字段。
1876
1670
  * 按 confidence 降序分配,每个 fieldId 仅匹配一次(usedFieldIds 去重)。
1877
1671
  */
1878
1672
  recognize(t, n, r) {
1879
- const o = Vr([...Dr(t), ...Pr(t)]), i = /* @__PURE__ */ new Set(), s = [];
1673
+ const o = Ar([...wr(t), ...vr(t)]), i = /* @__PURE__ */ new Set(), s = [];
1880
1674
  for (const a of o.sort((c, l) => l.confidence - c.confidence)) {
1881
- const c = Nr(a, n, i);
1675
+ const c = Er(a, n, i);
1882
1676
  c && (s.push({
1883
1677
  fieldId: c.fieldId,
1884
1678
  scanToken: r,
1885
1679
  label: c.label,
1886
- value: Hr(a.value, c),
1680
+ value: kr(a.value, c),
1887
1681
  displayValue: a.value,
1888
1682
  confidence: a.confidence,
1889
1683
  source: "local_rule",
@@ -1893,76 +1687,76 @@ class Or {
1893
1687
  return s;
1894
1688
  }
1895
1689
  }
1896
- function Dr(e) {
1690
+ function wr(e) {
1897
1691
  const t = [];
1898
- for (const n of Fr)
1692
+ for (const n of br)
1899
1693
  for (const r of e.matchAll(n.pattern)) {
1900
- const o = Kt(r[1] || r[0]);
1694
+ const o = Ft(r[1] || r[0]);
1901
1695
  t.push({
1902
1696
  key: n.key,
1903
1697
  value: o,
1904
1698
  confidence: n.confidence,
1905
1699
  reason: n.reason,
1906
- baseKey: zt[n.key]
1700
+ baseKey: Ot[n.key]
1907
1701
  });
1908
1702
  }
1909
1703
  return t;
1910
1704
  }
1911
- function Pr(e) {
1705
+ function vr(e) {
1912
1706
  const t = [], n = e.split(/\r?\n|[;,;]/).map((r) => r.trim()).filter(Boolean);
1913
1707
  for (const r of n) {
1914
1708
  const o = r.match(/^[“"'`]?([^::=]{2,30})[”"'`]?[::=]\s*(.+)$/);
1915
1709
  if (!o) continue;
1916
- const i = Kr(o[1]), s = Kt(o[2]);
1710
+ const i = Cr(o[1]), s = Ft(o[2]);
1917
1711
  if (!(!i || !s))
1918
- for (const a of qr(i, s))
1712
+ for (const a of Sr(i, s))
1919
1713
  t.push(a);
1920
1714
  }
1921
1715
  return t;
1922
1716
  }
1923
- function qr(e, t) {
1924
- const n = $(e), r = zr(t), o = [];
1925
- return (k(n, M.mobile) || r === "mobile") && o.push("mobile"), (k(n, M.idCard) || r === "idCard") && o.push("idCard"), (k(n, M.email) || r === "email") && o.push("email"), (k(n, M.bankCard) || r === "bankCard") && o.push("bankCard"), (k(n, M.amount) || r === "amount") && o.push("amount"), (k(n, M.date) || r === "date") && o.push("date"), Br(o).map((i, s) => ({
1717
+ function Sr(e, t) {
1718
+ const n = q(e), r = _r(t), o = [];
1719
+ return (x(n, I.mobile) || r === "mobile") && o.push("mobile"), (x(n, I.idCard) || r === "idCard") && o.push("idCard"), (x(n, I.email) || r === "email") && o.push("email"), (x(n, I.bankCard) || r === "bankCard") && o.push("bankCard"), (x(n, I.amount) || r === "amount") && o.push("amount"), (x(n, I.date) || r === "date") && o.push("date"), Tr(o).map((i, s) => ({
1926
1720
  key: i,
1927
1721
  value: t,
1928
1722
  confidence: Math.max(0.84, 0.96 - s * 0.04),
1929
1723
  reason: `键值对文本命中(${e})`,
1930
- baseKey: zt[i]
1724
+ baseKey: Ot[i]
1931
1725
  }));
1932
1726
  }
1933
- function Nr(e, t, n) {
1727
+ function Er(e, t, n) {
1934
1728
  let r = null;
1935
1729
  for (const o of t) {
1936
1730
  if (n.has(o.fieldId)) continue;
1937
- const i = $r(e, o);
1731
+ const i = xr(e, o);
1938
1732
  i > ((r == null ? void 0 : r.score) ?? 0) && (r = { field: o, score: i });
1939
1733
  }
1940
1734
  return r && r.score >= 0.45 ? r.field : null;
1941
1735
  }
1942
- function $r(e, t) {
1943
- const n = $([t.fieldId, t.label, t.placeholder, t.name, t.id, t.section].join(" ")), r = M[e.key] || [e.key];
1736
+ function xr(e, t) {
1737
+ const n = q([t.fieldId, t.label, t.placeholder, t.name, t.id, t.section].join(" ")), r = I[e.key] || [e.key];
1944
1738
  let o = 0;
1945
- return k(n, r) ? o += 0.95 : k(n, [e.key]) && (o += 0.82), n.includes($(e.key)) && (o += 0.22), t.required && (o += 0.05), e.baseKey === "amount" && (t.type === "amount" || t.type === "number") && (o += 0.18), e.baseKey === "date" && t.type === "date" && (o += 0.18), ["email", "mobile", "idCard", "bankCard"].includes(e.baseKey) && t.type === "text" && (o += 0.08), Math.min(o, 1);
1739
+ return x(n, r) ? o += 0.95 : x(n, [e.key]) && (o += 0.82), n.includes(q(e.key)) && (o += 0.22), t.required && (o += 0.05), e.baseKey === "amount" && (t.type === "amount" || t.type === "number") && (o += 0.18), e.baseKey === "date" && t.type === "date" && (o += 0.18), ["email", "mobile", "idCard", "bankCard"].includes(e.baseKey) && t.type === "text" && (o += 0.08), Math.min(o, 1);
1946
1740
  }
1947
- function Hr(e, t) {
1741
+ function kr(e, t) {
1948
1742
  var n;
1949
1743
  return t.type === "date" ? e.replace(/[年月/.]/g, "-").replace(/日/g, "").replace(/--/g, "-") : t.type === "number" || t.type === "amount" ? ((n = e.match(/[0-9]+(?:\.[0-9]+)?/)) == null ? void 0 : n[0]) ?? e : t.name && /mobile|phone|idcard|bankcard/i.test(t.name) || t.id && /mobile|phone|idcard|bankcard/i.test(t.id) || /mobile|phone|idcard|bankcard/i.test(t.fieldId) ? e.replace(/\s+/g, "") : e;
1950
1744
  }
1951
- function zr(e) {
1745
+ function _r(e) {
1952
1746
  const t = e.replace(/\s+/g, "");
1953
1747
  return /^1[3-9]\d{9}$/.test(t) ? "mobile" : /^\d{17}[\dXx]$/.test(t) ? "idCard" : /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/.test(e) ? "email" : /^\d{16,19}$/.test(t) ? "bankCard" : /^\d{4}[-/.年]\d{1,2}[-/.月]\d{1,2}日?$/.test(e) ? "date" : /^[0-9]+(?:\.[0-9]{1,2})?$/.test(t) ? "amount" : "unknown";
1954
1748
  }
1955
- function Kr(e) {
1749
+ function Cr(e) {
1956
1750
  return e.replace(/[“”"'`]/g, "").replace(/\s+/g, " ").trim();
1957
1751
  }
1958
- function Kt(e) {
1752
+ function Ft(e) {
1959
1753
  return e.replace(/[,。;;]+$/g, "").replace(/^[“”"'`\s]+|[“”"'`\s]+$/g, "").trim();
1960
1754
  }
1961
- function k(e, t) {
1962
- const n = $(e);
1963
- return t.some((r) => n.includes($(r)));
1755
+ function x(e, t) {
1756
+ const n = q(e);
1757
+ return t.some((r) => n.includes(q(r)));
1964
1758
  }
1965
- function Vr(e) {
1759
+ function Ar(e) {
1966
1760
  const t = /* @__PURE__ */ new Map();
1967
1761
  for (const n of e) {
1968
1762
  const r = `${n.key}::${n.value}`, o = t.get(r);
@@ -1970,16 +1764,16 @@ function Vr(e) {
1970
1764
  }
1971
1765
  return [...t.values()];
1972
1766
  }
1973
- function Br(e) {
1767
+ function Tr(e) {
1974
1768
  return [...new Set(e)];
1975
1769
  }
1976
- const st = [
1770
+ const Je = [
1977
1771
  "input",
1978
1772
  "textarea",
1979
1773
  "select",
1980
1774
  "[contenteditable]:not([contenteditable='false'])"
1981
- ].join(", "), Ur = /* @__PURE__ */ new Set(["hidden", "submit", "button", "image", "reset", "file", "password"]);
1982
- class jr {
1775
+ ].join(", "), Lr = /* @__PURE__ */ new Set(["hidden", "submit", "button", "image", "reset", "file", "password"]);
1776
+ class Ir {
1983
1777
  constructor(t = document) {
1984
1778
  this.root = t;
1985
1779
  }
@@ -1990,7 +1784,7 @@ class jr {
1990
1784
  */
1991
1785
  scan(t = {}) {
1992
1786
  var l;
1993
- const n = Se("scan");
1787
+ const n = ye("scan");
1994
1788
  if ((l = t.registered) != null && l.length)
1995
1789
  return {
1996
1790
  scanToken: n,
@@ -1999,7 +1793,7 @@ class jr {
1999
1793
  const r = this.resolveRoot(t.scanContainer), o = this.collectVisibleFields(r), i = this.detectTopLayerContainer(o), s = o.filter((u) => i.contains(u)), a = (s.length ? s : o).slice(0, t.maxFields ?? 200), c = s.length ? i : r;
2000
1794
  return {
2001
1795
  scanToken: n,
2002
- fields: a.map((u, p) => this.fromElement(u, p, n, c))
1796
+ fields: a.map((u, h) => this.fromElement(u, h, n, c))
2003
1797
  };
2004
1798
  }
2005
1799
  /** 在基础扫描后,按需展开下拉并补充动态选项 */
@@ -2010,18 +1804,18 @@ class jr {
2010
1804
  return n;
2011
1805
  const r = [];
2012
1806
  for (const s of n.fields) {
2013
- const a = !!((i = s.options) != null && i.length) && !se(s);
1807
+ const a = !!((i = s.options) != null && i.length) && !ne(s);
2014
1808
  if (!s.element || a || s.type !== "select" && s.type !== "cascader") {
2015
1809
  r.push(s);
2016
1810
  continue;
2017
1811
  }
2018
- const c = await gn(s.element), l = c != null && c.length && !se({ ...s, options: c }) ? c : void 0;
1812
+ const c = await an(s.element), l = c != null && c.length && !ne({ ...s, options: c }) ? c : void 0;
2019
1813
  if (!(l != null && l.length)) {
2020
- r.push({ ...s, options: se(s) ? void 0 : s.options });
1814
+ r.push({ ...s, options: ne(s) ? void 0 : s.options });
2021
1815
  continue;
2022
1816
  }
2023
1817
  const u = { ...s, options: l };
2024
- u.fingerprint = G({
1818
+ u.fingerprint = z({
2025
1819
  ...u,
2026
1820
  tagName: s.element.tagName.toLowerCase()
2027
1821
  }), r.push(u);
@@ -2030,7 +1824,7 @@ class jr {
2030
1824
  }
2031
1825
  /** FieldSchema → FieldDescriptor,解析 element 并生成 fingerprint */
2032
1826
  fromSchema(t, n) {
2033
- const r = no(t.element, this.root), o = r ? Pe(r) || Re(r) || r : null, i = {
1827
+ const r = Nr(t.element, this.root), o = r ? Re(r) || Te(r) || r : null, i = {
2034
1828
  fieldId: t.rowKey == null ? t.fieldId : `${t.fieldId}:${t.rowKey}`,
2035
1829
  label: t.label,
2036
1830
  type: t.type,
@@ -2044,32 +1838,32 @@ class jr {
2044
1838
  element: o || void 0,
2045
1839
  fingerprint: ""
2046
1840
  };
2047
- return i.fingerprint = G({
1841
+ return i.fingerprint = z({
2048
1842
  ...i,
2049
1843
  tagName: o == null ? void 0 : o.tagName.toLowerCase()
2050
1844
  }), i;
2051
1845
  }
2052
1846
  /** DOM 元素 → FieldDescriptor,自动推断 label/type 并写入 data-smart-fill-id */
2053
1847
  fromElement(t, n, r, o = this.root) {
2054
- const i = Gr(t, n), s = Xr(t, o), a = {
1848
+ const i = Mr(t, n), s = Fr(t, o), a = {
2055
1849
  fieldId: i,
2056
1850
  fingerprint: "",
2057
1851
  scanToken: r,
2058
- type: Yr(t),
1852
+ type: Rr(t),
2059
1853
  localRuleMode: "inherit",
2060
- label: Vt(t),
2061
- placeholder: Ut(t),
2062
- name: E(wt(t)) || void 0,
2063
- id: E(t.id) || void 0,
2064
- section: Wr(t),
1854
+ label: qt(t),
1855
+ placeholder: Pt(t),
1856
+ name: S(pt(t)) || void 0,
1857
+ id: S(t.id) || void 0,
1858
+ section: Or(t),
2065
1859
  options: s,
2066
- required: Qr(t),
2067
- readonly: Jr(t) && !hn(t),
2068
- disabled: Te(t),
1860
+ required: Pr(t),
1861
+ readonly: Dr(t),
1862
+ disabled: ke(t),
2069
1863
  source: "form_scan",
2070
1864
  element: t
2071
1865
  };
2072
- return se(a) && (a.options = void 0), a.fingerprint = G({
1866
+ return ne(a) && (a.options = void 0), a.fingerprint = z({
2073
1867
  ...a,
2074
1868
  tagName: t.tagName.toLowerCase()
2075
1869
  }), a;
@@ -2077,7 +1871,7 @@ class jr {
2077
1871
  /** 解析扫描根节点,scanContainer 为 CSS 选择器 */
2078
1872
  resolveRoot(t) {
2079
1873
  if (t) {
2080
- const n = jt(this.root, t);
1874
+ const n = Ht(this.root, t);
2081
1875
  if (n)
2082
1876
  return n;
2083
1877
  }
@@ -2085,38 +1879,38 @@ class jr {
2085
1879
  }
2086
1880
  /** 收集 root 下可见且可编辑的表单控件 */
2087
1881
  collectVisibleFields(t) {
2088
- const n = /* @__PURE__ */ new Set(), r = [st, St, bt, ".van-field"].join(", ");
1882
+ const n = /* @__PURE__ */ new Set(), r = [Je, ft, lt, ".van-field"].join(", ");
2089
1883
  for (const s of t.querySelectorAll(r)) {
2090
1884
  if (!(s instanceof HTMLElement)) continue;
2091
- const a = Pe(s) || Re(s);
2092
- !a || !$e(a) || Te(a) || n.add(a);
1885
+ const a = Re(s) || Te(s);
1886
+ !a || !De(a) || ke(a) || n.add(a);
2093
1887
  }
2094
- const o = [...n], i = Array.from(t.querySelectorAll(st)).filter((s) => !(s instanceof HTMLElement) || !$e(s) || eo(s) || s instanceof HTMLInputElement && Ur.has((s.type || "").toLowerCase()) ? !1 : !Te(s) && !s.hasAttribute("readonly"));
2095
- return to([...i, ...o]);
1888
+ const o = [...n], i = Array.from(t.querySelectorAll(Je)).filter((s) => !(s instanceof HTMLElement) || !De(s) || Hr(s) || s instanceof HTMLInputElement && Lr.has((s.type || "").toLowerCase()) ? !1 : !ke(s) && !s.hasAttribute("readonly"));
1889
+ return $r([...i, ...o]);
2096
1890
  }
2097
1891
  /**
2098
1892
  * 检测最应优先扫描的容器。
2099
1893
  * 优先 activeElement 所在弹窗,否则取包含最多字段的弹窗容器。
2100
1894
  */
2101
1895
  detectTopLayerContainer(t) {
2102
- const n = document.activeElement instanceof HTMLElement ? document.activeElement : null, r = n == null ? void 0 : n.closest(Xe);
1896
+ const n = document.activeElement instanceof HTMLElement ? document.activeElement : null, r = n == null ? void 0 : n.closest(ze);
2103
1897
  if (r instanceof HTMLElement && t.some((i) => r.contains(i)))
2104
1898
  return r;
2105
- const o = t.map((i) => i.closest(Xe)).filter((i) => i instanceof HTMLElement);
1899
+ const o = t.map((i) => i.closest(ze)).filter((i) => i instanceof HTMLElement);
2106
1900
  return o.length ? o.sort((i, s) => t.filter((a) => s.contains(a)).length - t.filter((a) => i.contains(a)).length)[0] : document.body;
2107
1901
  }
2108
1902
  }
2109
- function Gr(e, t) {
1903
+ function Mr(e, t) {
2110
1904
  const n = e.getAttribute("data-smart-fill-id");
2111
1905
  if (n)
2112
1906
  return n;
2113
- const o = E(e.getAttribute("name")) || E(e.getAttribute("data-smart-fill-key")) || E(wt(e)) || E(e.id) || E(Vt(e)) || `smart-fill-${Date.now()}-${t}`;
1907
+ const o = S(e.getAttribute("name")) || S(e.getAttribute("data-smart-fill-key")) || S(pt(e)) || S(e.id) || S(qt(e)) || `smart-fill-${Date.now()}-${t}`;
2114
1908
  return e.setAttribute("data-smart-fill-id", o), o;
2115
1909
  }
2116
- function Yr(e) {
2117
- const t = Ke(e);
1910
+ function Rr(e) {
1911
+ const t = yt(e);
2118
1912
  if (t) return t;
2119
- const n = he(e);
1913
+ const n = ce(e);
2120
1914
  if (n) return n;
2121
1915
  if (e instanceof HTMLTextAreaElement) return "textarea";
2122
1916
  if (e instanceof HTMLSelectElement) return "select";
@@ -2129,92 +1923,92 @@ function Yr(e) {
2129
1923
  }
2130
1924
  return "text";
2131
1925
  }
2132
- function Vt(e) {
1926
+ function qt(e) {
2133
1927
  const t = e.getAttribute("aria-label");
2134
1928
  if (t) return t.trim();
2135
1929
  if (e.id) {
2136
- const i = document.querySelector(`label[for="${Ye(e.id)}"]`);
2137
- if (i != null && i.textContent) return f(i.textContent);
1930
+ const i = document.querySelector(`label[for="${Ve(e.id)}"]`);
1931
+ if (i != null && i.textContent) return p(i.textContent);
2138
1932
  }
2139
- const n = e.closest(sn), r = n == null ? void 0 : n.querySelector(an);
2140
- if (r != null && r.textContent) return f(r.textContent);
1933
+ const n = e.closest(Zt), r = n == null ? void 0 : n.querySelector(Jt);
1934
+ if (r != null && r.textContent) return p(r.textContent);
2141
1935
  const o = e.closest("label");
2142
1936
  if (o) {
2143
- const i = Bt(o, e);
1937
+ const i = Dt(o, e);
2144
1938
  if (i) return i;
2145
1939
  }
2146
- return Ut(e) || e.getAttribute("name") || e.id || "未命名字段";
1940
+ return Pt(e) || e.getAttribute("name") || e.id || "未命名字段";
2147
1941
  }
2148
- function Bt(e, t) {
1942
+ function Dt(e, t) {
2149
1943
  const n = e.cloneNode(!0);
2150
1944
  for (const o of n.querySelectorAll('input, textarea, select, button, [role="combobox"], [role="listbox"]'))
2151
1945
  o.remove();
2152
- const r = f(n.textContent || "");
1946
+ const r = p(n.textContent || "");
2153
1947
  if (r)
2154
- return t instanceof HTMLInputElement && t.value && r.includes(t.value) ? f(r.replace(t.value, "")) || void 0 : r;
1948
+ return t instanceof HTMLInputElement && t.value && r.includes(t.value) ? p(r.replace(t.value, "")) || void 0 : r;
2155
1949
  }
2156
- function Ut(e) {
1950
+ function Pt(e) {
2157
1951
  var t;
2158
1952
  return e.getAttribute("placeholder") || e.getAttribute("aria-placeholder") || ((t = e.querySelector("[placeholder]")) == null ? void 0 : t.getAttribute("placeholder")) || void 0;
2159
1953
  }
2160
- function Wr(e) {
1954
+ function Or(e) {
2161
1955
  const t = e.closest("fieldset, section, .panel, .card, .form-section"), n = t == null ? void 0 : t.querySelector("legend, h1, h2, h3, .title, .section-title");
2162
- return n != null && n.textContent ? f(n.textContent) : void 0;
1956
+ return n != null && n.textContent ? p(n.textContent) : void 0;
2163
1957
  }
2164
- function Xr(e, t = document) {
2165
- const n = _t(e);
1958
+ function Fr(e, t = document) {
1959
+ const n = bt(e);
2166
1960
  if (n != null && n.length) return n;
2167
- const r = vt(e);
1961
+ const r = dt(e);
2168
1962
  if (r != null && r.length) return r;
2169
1963
  if (e instanceof HTMLSelectElement)
2170
1964
  return Array.from(e.options).map((o) => ({
2171
- label: f(o.textContent || o.label),
1965
+ label: p(o.textContent || o.label),
2172
1966
  value: o.value
2173
1967
  }));
2174
1968
  if (e instanceof HTMLInputElement && (e.type === "radio" || e.type === "checkbox") && e.name)
2175
- return Array.from(t.querySelectorAll(`input[name="${Ye(e.name)}"]`)).filter((o) => o.type === e.type && $e(o)).map((o) => ({
2176
- label: Zr(o),
1969
+ return Array.from(t.querySelectorAll(`input[name="${Ve(e.name)}"]`)).filter((o) => o.type === e.type && De(o)).map((o) => ({
1970
+ label: qr(o),
2177
1971
  value: o.value || !0
2178
1972
  }));
2179
1973
  }
2180
- function Zr(e) {
1974
+ function qr(e) {
2181
1975
  if (e.id) {
2182
- const n = document.querySelector(`label[for="${Ye(e.id)}"]`);
2183
- if (n != null && n.textContent) return f(n.textContent);
1976
+ const n = document.querySelector(`label[for="${Ve(e.id)}"]`);
1977
+ if (n != null && n.textContent) return p(n.textContent);
2184
1978
  }
2185
1979
  const t = e.closest("label");
2186
1980
  if (t) {
2187
- const n = Bt(t, e);
1981
+ const n = Dt(t, e);
2188
1982
  if (n) return n;
2189
1983
  }
2190
- return f(e.getAttribute("aria-label") || e.value || "");
1984
+ return p(e.getAttribute("aria-label") || e.value || "");
2191
1985
  }
2192
- function $e(e) {
1986
+ function De(e) {
2193
1987
  const t = window.getComputedStyle(e);
2194
1988
  return t.display === "none" || t.visibility === "hidden" || Number(t.opacity) === 0 ? !1 : !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
2195
1989
  }
2196
- function Te(e) {
2197
- return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof HTMLButtonElement ? e.disabled || e.getAttribute("aria-disabled") === "true" : e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true" || on.some((t) => e.classList.contains(t));
1990
+ function ke(e) {
1991
+ return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement || e instanceof HTMLButtonElement ? e.disabled || e.getAttribute("aria-disabled") === "true" : e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true" || Xt.some((t) => e.classList.contains(t));
2198
1992
  }
2199
- function Jr(e) {
1993
+ function Dr(e) {
2200
1994
  return e.hasAttribute("readonly") || !!e.querySelector("[readonly]");
2201
1995
  }
2202
- function Qr(e) {
1996
+ function Pr(e) {
2203
1997
  return e.hasAttribute("required") || e.getAttribute("aria-required") === "true" || !!e.querySelector('[required], [aria-required="true"]');
2204
1998
  }
2205
- function eo(e) {
2206
- return Pe(e) != null || Re(e) != null;
1999
+ function Hr(e) {
2000
+ return Re(e) != null || Te(e) != null;
2207
2001
  }
2208
- function to(e) {
2002
+ function $r(e) {
2209
2003
  const t = [];
2210
2004
  for (const n of e)
2211
2005
  t.some((r) => r === n || r.contains(n) || n.contains(r)) || t.push(n);
2212
2006
  return t;
2213
2007
  }
2214
- function no(e, t) {
2215
- return e instanceof HTMLElement ? e : typeof e == "string" ? jt(t, e) : null;
2008
+ function Nr(e, t) {
2009
+ return e instanceof HTMLElement ? e : typeof e == "string" ? Ht(t, e) : null;
2216
2010
  }
2217
- function jt(e, t) {
2011
+ function Ht(e, t) {
2218
2012
  try {
2219
2013
  const n = e.querySelector(t);
2220
2014
  return n instanceof HTMLElement ? n : null;
@@ -2222,11 +2016,11 @@ function jt(e, t) {
2222
2016
  return null;
2223
2017
  }
2224
2018
  }
2225
- function Ye(e) {
2019
+ function Ve(e) {
2226
2020
  return typeof CSS < "u" && CSS.escape ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
2227
2021
  }
2228
- const Le = 5, ro = 10 * 1024 * 1024, oo = 50 * 1024 * 1024;
2229
- class io {
2022
+ const _e = 5, Vr = 10 * 1024 * 1024, Kr = 50 * 1024 * 1024;
2023
+ class zr {
2230
2024
  constructor(t) {
2231
2025
  /** 面板宿主元素,挂载到 container 下 */
2232
2026
  d(this, "host", null);
@@ -2252,7 +2046,7 @@ class io {
2252
2046
  if (!this.dragState || !this.host || t.pointerId !== this.dragState.pointerId) return;
2253
2047
  const n = t.clientX - this.dragState.startX, r = t.clientY - this.dragState.startY;
2254
2048
  (Math.abs(n) > 3 || Math.abs(r) > 3) && (this.dragState.moved = !0);
2255
- const o = this.host.getBoundingClientRect(), i = Math.max(8, window.innerWidth - o.width - 8), s = Math.max(8, window.innerHeight - o.height - 8), a = pe(this.dragState.startLeft + n, 8, i), c = pe(this.dragState.startTop + r, 8, s);
2049
+ const o = this.host.getBoundingClientRect(), i = Math.max(8, window.innerWidth - o.width - 8), s = Math.max(8, window.innerHeight - o.height - 8), a = ae(this.dragState.startLeft + n, 8, i), c = ae(this.dragState.startTop + r, 8, s);
2256
2050
  this.host.style.left = `${a}px`, this.host.style.top = `${c}px`;
2257
2051
  });
2258
2052
  d(this, "handleDragEnd", (t) => {
@@ -2262,7 +2056,7 @@ class io {
2262
2056
  });
2263
2057
  /** 面板聚焦或鼠标悬浮在图片区时接管全局粘贴图片 */
2264
2058
  d(this, "handleDocumentPaste", (t) => {
2265
- const n = ao(t);
2059
+ const n = Ur(t);
2266
2060
  if (!n.length || !this.isOpen || !this.host)
2267
2061
  return;
2268
2062
  const r = document.activeElement, o = this.root instanceof ShadowRoot ? this.root.activeElement : null;
@@ -2315,7 +2109,7 @@ class io {
2315
2109
  }
2316
2110
  render(t) {
2317
2111
  this.root && (this.root.innerHTML = `
2318
- <style>${co}</style>
2112
+ <style>${jr}</style>
2319
2113
  ${this.options.mode === "floating" ? `<button class="sf-float" type="button" data-role="open">${this.t("entry", "智能录入")}</button>` : ""}
2320
2114
  <section class="sf-panel ${t ? "is-open" : ""} ${this.options.mode === "inline" ? "is-inline" : "is-floating"}" aria-label="智能录入面板">
2321
2115
  <header class="sf-header" data-role="close" >
@@ -2332,7 +2126,7 @@ class io {
2332
2126
  </label>
2333
2127
  <div class="sf-entry-grid">
2334
2128
  <div class="sf-textarea-wrap">
2335
- <textarea class="sf-textarea" data-role="text" placeholder="${this.t("placeholder", "粘贴文本,如:姓名:张三 手机号:13800000000")}">${so(this.inputText)}</textarea>
2129
+ <textarea class="sf-textarea" data-role="text" placeholder="${this.t("placeholder", "粘贴文本,如:姓名:张三 手机号:13800000000")}">${Br(this.inputText)}</textarea>
2336
2130
  <div class="sf-textarea-actions">
2337
2131
  <button class="sf-btn sf-btn-secondary" type="button" data-role="clear">${this.t("clear", "清空")}</button>
2338
2132
  <button class="sf-btn sf-btn-primary" type="button" data-role="recognize">${this.t("recognize", "智能识别")}</button>
@@ -2349,7 +2143,7 @@ class io {
2349
2143
  <circle cx="10" cy="10.5" r="1" fill="currentColor"/>
2350
2144
  </svg>
2351
2145
  </span>
2352
- <span class="sf-upload-hint">${this.t("uploadHint", `点击、拖拽、Ctrl + V 粘贴图片至此(最多 ${Le} 张)`)}</span>
2146
+ <span class="sf-upload-hint">${this.t("uploadHint", `点击、拖拽、Ctrl + V 粘贴图片至此(最多 ${_e} 张)`)}</span>
2353
2147
  </span>
2354
2148
  <span class="sf-upload-btn" data-role="file-label">图片识别</span>
2355
2149
  </label>
@@ -2373,8 +2167,8 @@ class io {
2373
2167
  }
2374
2168
  this.options.onClose();
2375
2169
  }), (i = this.query('[data-role="file"]')) == null || i.addEventListener("change", (u) => {
2376
- const p = u.target;
2377
- this.handleImages(Array.from(p.files || []));
2170
+ const h = u.target;
2171
+ this.handleImages(Array.from(h.files || []));
2378
2172
  });
2379
2173
  const n = this.query('[data-role="upload"]');
2380
2174
  n == null || n.addEventListener("pointerenter", () => {
@@ -2388,22 +2182,22 @@ class io {
2388
2182
  }), n == null || n.addEventListener("dragleave", (u) => {
2389
2183
  u.currentTarget.contains(u.relatedTarget) || (this.isUploadHovering = !1, n.removeAttribute("data-dragover"));
2390
2184
  }), n == null || n.addEventListener("drop", (u) => {
2391
- var p;
2392
- u.preventDefault(), this.isUploadHovering = !1, n.removeAttribute("data-dragover"), this.handleImages(Array.from(((p = u.dataTransfer) == null ? void 0 : p.files) || []));
2185
+ var h;
2186
+ u.preventDefault(), this.isUploadHovering = !1, n.removeAttribute("data-dragover"), this.handleImages(Array.from(((h = u.dataTransfer) == null ? void 0 : h.files) || []));
2393
2187
  }), (s = this.query('[data-role="text"]')) == null || s.addEventListener("input", (u) => {
2394
2188
  this.inputText = u.target.value;
2395
2189
  }), (a = this.query('[data-role="local-priority-toggle"]')) == null || a.addEventListener("change", (u) => {
2396
- var p, g;
2397
- this.localPriorityEnabled = u.target.checked, (g = (p = this.options).onLocalPriorityChange) == null || g.call(p, this.localPriorityEnabled);
2190
+ var h, T;
2191
+ this.localPriorityEnabled = u.target.checked, (T = (h = this.options).onLocalPriorityChange) == null || T.call(h, this.localPriorityEnabled);
2398
2192
  }), (c = this.query('[data-role="clear"]')) == null || c.addEventListener("click", () => {
2399
2193
  this.clearFormState();
2400
2194
  }), (l = this.query('[data-role="recognize"]')) == null || l.addEventListener("click", () => {
2401
- const u = this.query('[data-role="text"]'), p = u == null ? void 0 : u.value.trim();
2402
- if (this.inputText = (u == null ? void 0 : u.value) || this.inputText, !p) {
2195
+ const u = this.query('[data-role="text"]'), h = u == null ? void 0 : u.value.trim();
2196
+ if (this.inputText = (u == null ? void 0 : u.value) || this.inputText, !h) {
2403
2197
  this.setError(this.t("emptyInput", "请输入文本内容。"));
2404
2198
  return;
2405
2199
  }
2406
- this.options.onRecognize({ text: p });
2200
+ this.options.onRecognize({ text: h });
2407
2201
  });
2408
2202
  }
2409
2203
  clearFormState() {
@@ -2423,15 +2217,15 @@ class io {
2423
2217
  this.resetSelectedFiles(), this.setError(this.t("invalidImageError", "请选择图片文件。"));
2424
2218
  return;
2425
2219
  }
2426
- if (n.length > Le) {
2427
- this.resetSelectedFiles(), this.setError(this.t("maxFilesError", `最多上传 ${Le} 张图片。`));
2220
+ if (n.length > _e) {
2221
+ this.resetSelectedFiles(), this.setError(this.t("maxFilesError", `最多上传 ${_e} 张图片。`));
2428
2222
  return;
2429
2223
  }
2430
- if (n.find((i) => i.size > ro)) {
2224
+ if (n.find((i) => i.size > Vr)) {
2431
2225
  this.resetSelectedFiles(), this.setError(this.t("maxSingleFileSizeError", "单张图片不能超过 10MB。"));
2432
2226
  return;
2433
2227
  }
2434
- if (n.reduce((i, s) => i + s.size, 0) > oo) {
2228
+ if (n.reduce((i, s) => i + s.size, 0) > Kr) {
2435
2229
  this.resetSelectedFiles(), this.setError(this.t("maxTotalFileSizeError", "上传图片总大小不能超过 50MB。"));
2436
2230
  return;
2437
2231
  }
@@ -2457,7 +2251,7 @@ class io {
2457
2251
  keepHostInViewport() {
2458
2252
  this.options.mode !== "floating" || !this.host || !this.host.style.left || !this.host.style.top || window.requestAnimationFrame(() => {
2459
2253
  if (!this.host) return;
2460
- const t = this.host.getBoundingClientRect(), n = pe(t.left, 8, Math.max(8, window.innerWidth - t.width - 8)), r = pe(t.top, 8, Math.max(8, window.innerHeight - t.height - 8));
2254
+ const t = this.host.getBoundingClientRect(), n = ae(t.left, 8, Math.max(8, window.innerWidth - t.width - 8)), r = ae(t.top, 8, Math.max(8, window.innerHeight - t.height - 8));
2461
2255
  this.host.style.left = `${n}px`, this.host.style.top = `${r}px`;
2462
2256
  });
2463
2257
  }
@@ -2470,7 +2264,7 @@ class io {
2470
2264
  return ((r = this.options.messages) == null ? void 0 : r[t]) || n;
2471
2265
  }
2472
2266
  }
2473
- function so(e) {
2267
+ function Br(e) {
2474
2268
  return e.replace(/[&<>"']/g, (t) => ({
2475
2269
  "&": "&amp;",
2476
2270
  "<": "&lt;",
@@ -2479,14 +2273,14 @@ function so(e) {
2479
2273
  "'": "&#39;"
2480
2274
  })[t] || t);
2481
2275
  }
2482
- function pe(e, t, n) {
2276
+ function ae(e, t, n) {
2483
2277
  return Math.min(Math.max(e, t), n);
2484
2278
  }
2485
- function ao(e) {
2279
+ function Ur(e) {
2486
2280
  var n;
2487
2281
  return Array.from(((n = e.clipboardData) == null ? void 0 : n.items) || []).filter((r) => r.kind === "file" && r.type.startsWith("image/")).map((r) => r.getAsFile()).filter((r) => !!r);
2488
2282
  }
2489
- const co = `
2283
+ const jr = `
2490
2284
  :host, .sf-panel { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
2491
2285
  :host(.sf-sdk-host-floating), .sf-sdk-host-floating { position: fixed; top: 30px; right: 30px; z-index: 2147483647; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; width: min(450px, calc(100vw - 32px)); pointer-events: none; }
2492
2286
  .sf-float { font-size: 15px; align-self: flex-end; border: 0; border-radius: 999px; padding: 10px 30px; color: #fff; background: linear-gradient(to right, #FF7E49, #FFA34E); box-shadow: 0 10px 24px rgba(37,99,235,.3); cursor: move; user-select: none; touch-action: none; pointer-events: auto; }
@@ -2550,24 +2344,29 @@ const co = `
2550
2344
  .sf-toggle-title{
2551
2345
  min-width: 60px;
2552
2346
  }
2347
+ :host(.sf-sdk-host-floating), .sf-sdk-host-floating{
2348
+ top: 8px;
2349
+ right: 16px;
2350
+ width: min(450px, calc(100vw - 32px))
2351
+ }
2553
2352
  }
2554
- `, lo = 0.75, uo = 1800, K = /* @__PURE__ */ new Map();
2555
- let V = 0;
2556
- const He = "smart-fill:routechange", Gt = "smart-fill:session-scan:";
2557
- let at = !1;
2558
- const ct = /* @__PURE__ */ new WeakMap();
2559
- let fo = 0;
2560
- function Yt() {
2561
- K.clear(), en(), V += 1;
2353
+ `, Gr = 0.75, Yr = 1800, H = /* @__PURE__ */ new Map();
2354
+ let $ = 0;
2355
+ const Pe = "smart-fill:routechange", $t = "smart-fill:session-scan:";
2356
+ let Qe = !1;
2357
+ const et = /* @__PURE__ */ new WeakMap();
2358
+ let Wr = 0;
2359
+ function Nt() {
2360
+ H.clear(), jt(), $ += 1;
2562
2361
  }
2563
- class po {
2362
+ class Xr {
2564
2363
  constructor(t, n) {
2565
2364
  /** 实例级事件总线,对应 instance.on(...) */
2566
- d(this, "events", new Ht());
2365
+ d(this, "events", new Rt());
2567
2366
  /** 页面字段扫描器,root 来自 SmartFill.create({ root }) */
2568
2367
  d(this, "scanner");
2569
2368
  /** 浏览器端本地规则引擎,用于文本正则/键值对提取 */
2570
- d(this, "ruleEngine", new Or());
2369
+ d(this, "ruleEngine", new mr());
2571
2370
  /** Shadow DOM 面板,mount / mountFloatingButton 后可用(指向最后挂载的面板,用于状态展示) */
2572
2371
  d(this, "panel", null);
2573
2372
  /** 已挂载的全部面板(inline / floating 可同时存在),用于本地优先开关广播与销毁 */
@@ -2577,7 +2376,7 @@ class po {
2577
2376
  /** 业务方 registerFields 注册的字段;非空时 rescan 仅扫描这些字段 */
2578
2377
  d(this, "registeredFields", []);
2579
2378
  /** 组件库回填适配器链,如 AntD / Element 自定义控件 */
2580
- d(this, "adapters", [Nt]);
2379
+ d(this, "adapters", [It]);
2581
2380
  /** 最近一次 rescan 结果;scanToken 用于识别/回填防过期校验 */
2582
2381
  d(this, "scanResult", null);
2583
2382
  /** recognize 完成后生成的自动回填候选,供面板展示与 applyAutoItems 使用 */
@@ -2589,14 +2388,14 @@ class po {
2589
2388
  /** 实例是否已 destroy,销毁后所有公开方法抛 INSTANCE_DESTROYED */
2590
2389
  d(this, "destroyed", !1);
2591
2390
  /** 页面扫描缓存代际快照;变化时说明缓存已被全局清空 */
2592
- d(this, "scanCacheVersion", V);
2391
+ d(this, "scanCacheVersion", $);
2593
2392
  /** 悬浮挂载时记录当前路由快照,路由切换后自动销毁实例 */
2594
2393
  d(this, "floatingRouteSnapshot", null);
2595
2394
  /** 悬浮挂载生命周期清理函数:移除路由监听和容器 observer */
2596
2395
  d(this, "floatingLifecycleCleanup", null);
2597
2396
  /** mount 后预扫描定时器 */
2598
2397
  d(this, "preScanTimer", null);
2599
- this.config = t, this.context = n, this.scanner = new jr(t.root || document), this.localPriorityEnabled = qo(), this.context.manager.add(this);
2398
+ this.config = t, this.context = n, this.scanner = new Ir(t.root || document), this.localPriorityEnabled = So(), this.context.manager.add(this);
2600
2399
  }
2601
2400
  /** 订阅实例事件,返回取消订阅函数 */
2602
2401
  on(t, n) {
@@ -2617,7 +2416,7 @@ class po {
2617
2416
  for (const r of t) {
2618
2417
  const o = r.rowKey == null ? r.fieldId : `${r.fieldId}:${r.rowKey}`;
2619
2418
  if (n.has(o))
2620
- throw v("UNSUPPORTED_PAGE", `字段 ${o} 重复注册。`, "scan");
2419
+ throw b("UNSUPPORTED_PAGE", `字段 ${o} 重复注册。`, "scan");
2621
2420
  n.add(o);
2622
2421
  }
2623
2422
  return this.registeredFields = t, this.scanResult = null, this.schedulePreScan(), this;
@@ -2631,14 +2430,14 @@ class po {
2631
2430
  this.assertAlive();
2632
2431
  const n = typeof t == "string" ? document.querySelector(t) : t;
2633
2432
  if (!n)
2634
- throw v("UNSUPPORTED_PAGE", "未找到智能录入挂载点。", "ui");
2635
- const r = ft("inline", Po(t, n)), o = pt(r, !0);
2433
+ throw b("UNSUPPORTED_PAGE", "未找到智能录入挂载点。", "ui");
2434
+ const r = ot("inline", vo(t, n)), o = it(r, !0);
2636
2435
  return this.createPanel("inline", r, o).mount(n), this.schedulePreScan(), this;
2637
2436
  }
2638
2437
  /** 挂载右下角悬浮按钮 + 弹框(floating 模式),优先挂到当前子路由页面顶层容器 */
2639
2438
  mountFloatingButton() {
2640
2439
  this.assertAlive();
2641
- const t = Ao(this.config), n = ft("floating"), r = pt(n, !1);
2440
+ const t = lo(this.config), n = ot("floating"), r = it(n, !1);
2642
2441
  return this.createPanel("floating", n, r).mount(t), this.bindFloatingLifecycle(t), this.schedulePreScan(), this;
2643
2442
  }
2644
2443
  /**
@@ -2647,7 +2446,7 @@ class po {
2647
2446
  */
2648
2447
  createPanel(t, n, r) {
2649
2448
  let o;
2650
- return o = new io({
2449
+ return o = new zr({
2651
2450
  mode: t,
2652
2451
  initialOpen: r,
2653
2452
  messages: this.config.messages,
@@ -2660,17 +2459,17 @@ class po {
2660
2459
  }
2661
2460
  /** 同步本地优先开关:更新内存态、写入 localStorage,并广播到其他已挂载面板 */
2662
2461
  handleLocalPriorityChange(t, n) {
2663
- this.localPriorityEnabled = t, No(t);
2462
+ this.localPriorityEnabled = t, Eo(t);
2664
2463
  for (const r of this.panels)
2665
2464
  r !== n && r.setLocalPriorityEnabled(t);
2666
2465
  }
2667
2466
  /** 打开面板并触发 rescan,同时激活当前实例(关闭其他实例面板) */
2668
2467
  async open(t = this.panel) {
2669
- this.assertAlive(), this.syncScanCacheVersion(), t && (this.context.manager.activate(this), this.panel = t, t.setOpen(!0), ht(this.panelStorageKeys.get(t), !0), this.scanResult || await this.rescan());
2468
+ this.assertAlive(), this.syncScanCacheVersion(), t && (this.context.manager.activate(this), this.panel = t, t.setOpen(!0), st(this.panelStorageKeys.get(t), !0), this.scanResult || await this.rescan());
2670
2469
  }
2671
2470
  /** 关闭面板(不销毁实例) */
2672
2471
  close(t = this.panel) {
2673
- t && (this.panel = t, t.setOpen(!1), ht(this.panelStorageKeys.get(t), !1));
2472
+ t && (this.panel = t, t.setOpen(!1), st(this.panelStorageKeys.get(t), !1));
2674
2473
  }
2675
2474
  /**
2676
2475
  * 扫描页面可回填字段。
@@ -2696,7 +2495,7 @@ class po {
2696
2495
  maxFields: this.config.maxFields
2697
2496
  }));
2698
2497
  if (this.scanResult = i, this.cachePageScanResult(i, t.dynamicOptions), !this.scanResult.fields.length)
2699
- throw v("NO_FIELDS_FOUND", "当前页面未找到可回填字段。", "scan");
2498
+ throw b("NO_FIELDS_FOUND", "当前页面未找到可回填字段。", "scan");
2700
2499
  return t.emitStatus && (this.events.emit("scanCompleted", {
2701
2500
  scanToken: this.scanResult.scanToken,
2702
2501
  fieldCount: this.scanResult.fields.length
@@ -2710,7 +2509,7 @@ class po {
2710
2509
  this.destroyed || !this.panels.length || (this.preScanTimer != null && window.clearTimeout(this.preScanTimer), this.preScanTimer = window.setTimeout(() => {
2711
2510
  this.preScanTimer = null, !(this.destroyed || this.scanResult) && this.preScan().catch(() => {
2712
2511
  });
2713
- }, uo));
2512
+ }, Yr));
2714
2513
  }
2715
2514
  cancelPreScan() {
2716
2515
  this.preScanTimer != null && (window.clearTimeout(this.preScanTimer), this.preScanTimer = null);
@@ -2728,74 +2527,74 @@ class po {
2728
2527
  async recognize(t) {
2729
2528
  var i, s, a, c, l, u;
2730
2529
  this.assertAlive(), this.syncScanCacheVersion(), (i = this.panel) == null || i.setBusy(!0, "扫描中..."), (s = this.panel) == null || s.setStatus("扫描中...");
2731
- const n = await this.rescan(), r = Se("trace"), o = performance.now();
2530
+ const n = await this.rescan(), r = ye("trace"), o = performance.now();
2732
2531
  this.events.emit("recognizing", { scanToken: n.scanToken, traceId: r }), (a = this.panel) == null || a.setBusy(!0, "识别中...");
2733
2532
  try {
2734
- const p = n.fields.filter((b) => mo(b.localRuleMode, this.localPriorityEnabled)), g = n.fields.filter((b) => b.localRuleMode !== "only"), { text: x, usedOcr: ne } = await this.context.client.resolveInputText({
2533
+ const h = n.fields.filter((g) => to(g.localRuleMode, this.localPriorityEnabled)), T = n.fields.filter((g) => g.localRuleMode !== "only"), { text: P, usedOcr: J } = await this.context.client.resolveInputText({
2735
2534
  text: t.text,
2736
2535
  images: t.images,
2737
- onStatusChange: (b) => {
2738
- var oe, I, ie;
2739
- if (b === "image_uploading") {
2740
- (oe = this.panel) == null || oe.setStatus("图片上传中...");
2536
+ onStatusChange: (g) => {
2537
+ var ee, L, te;
2538
+ if (g === "image_uploading") {
2539
+ (ee = this.panel) == null || ee.setStatus("图片上传中...");
2741
2540
  return;
2742
2541
  }
2743
- if (b === "image_recognizing") {
2744
- (I = this.panel) == null || I.setStatus("图片识别中...");
2542
+ if (g === "image_recognizing") {
2543
+ (L = this.panel) == null || L.setStatus("图片识别中...");
2745
2544
  return;
2746
2545
  }
2747
- (ie = this.panel) == null || ie.setStatus("识别中...");
2546
+ (te = this.panel) == null || te.setStatus("识别中...");
2748
2547
  }
2749
- }), re = x ? this.ruleEngine.recognize(x, p, n.scanToken) : [];
2750
- let S;
2751
- if (!g.length)
2752
- S = lt(n.scanToken, r, re, o, void 0, ne);
2548
+ }), Q = P ? this.ruleEngine.recognize(P, h, n.scanToken) : [];
2549
+ let v;
2550
+ if (!T.length)
2551
+ v = tt(n.scanToken, r, Q, o, void 0, J);
2753
2552
  else
2754
2553
  try {
2755
- const b = await this.context.client.recognize({
2554
+ const g = await this.context.client.recognize({
2756
2555
  scanToken: n.scanToken,
2757
2556
  formCode: this.config.formCode,
2758
2557
  configVersion: this.formConfigVersion,
2759
- text: x,
2760
- usedOcr: ne,
2761
- fields: g,
2558
+ text: P,
2559
+ usedOcr: J,
2560
+ fields: T,
2762
2561
  onStatusChange: () => {
2763
- var I;
2764
- (I = this.panel) == null || I.setStatus("识别中...");
2562
+ var L;
2563
+ (L = this.panel) == null || L.setStatus("识别中...");
2765
2564
  }
2766
2565
  });
2767
- b.trace.durationMs = b.trace.durationMs || Math.round(performance.now() - o);
2768
- const oe = bo(
2769
- re,
2770
- b.suggestions.filter((I) => g.some((ie) => ie.fieldId === I.fieldId))
2566
+ g.trace.durationMs = g.trace.durationMs || Math.round(performance.now() - o);
2567
+ const ee = eo(
2568
+ Q,
2569
+ g.suggestions.filter((L) => T.some((te) => te.fieldId === L.fieldId))
2771
2570
  );
2772
- S = { ...b, suggestions: oe };
2773
- } catch (b) {
2774
- if (!re.length)
2775
- throw b;
2776
- S = lt(
2571
+ v = { ...g, suggestions: ee };
2572
+ } catch (g) {
2573
+ if (!Q.length)
2574
+ throw g;
2575
+ v = tt(
2777
2576
  n.scanToken,
2778
2577
  r,
2779
- re,
2578
+ Q,
2780
2579
  o,
2781
- [ne ? "后端识别失败,已使用 OCR 文本触发本地识别继续回填。" : "后端识别失败,已启用本地识别继续回填。"],
2782
- ne
2580
+ [J ? "后端识别失败,已使用 OCR 文本触发本地识别继续回填。" : "后端识别失败,已启用本地识别继续回填。"],
2581
+ J
2783
2582
  );
2784
2583
  }
2785
- if (this.autoApplyState = go(
2786
- S.scanToken,
2787
- S.trace.traceId,
2788
- S.suggestions,
2584
+ if (this.autoApplyState = Jr(
2585
+ v.scanToken,
2586
+ v.trace.traceId,
2587
+ v.suggestions,
2789
2588
  n,
2790
2589
  this.registeredFields
2791
- ), this.events.emit("recognized", S), (c = this.panel) == null || c.setAutoApplyState(this.autoApplyState), this.config.apiEnable) {
2792
- const b = ho(S, this.autoApplyState, n);
2793
- this.config.apiCallback && await Promise.resolve(this.config.apiCallback(b)), (l = this.panel) == null || l.setStatus(`识别完成,已返回 ${b.fields.length} 个字段。`);
2590
+ ), this.events.emit("recognized", v), (c = this.panel) == null || c.setAutoApplyState(this.autoApplyState), this.config.apiEnable) {
2591
+ const g = Zr(v, this.autoApplyState, n);
2592
+ this.config.apiCallback && await Promise.resolve(this.config.apiCallback(g)), (l = this.panel) == null || l.setStatus(`识别完成,已返回 ${g.fields.length} 个字段。`);
2794
2593
  } else
2795
2594
  await this.applyAutoItems(this.autoApplyState);
2796
- return S;
2797
- } catch (p) {
2798
- throw this.clearScanStateOnTokenExpired(p), this.emitError(p, "recognize"), p;
2595
+ return v;
2596
+ } catch (h) {
2597
+ throw this.clearScanStateOnTokenExpired(h), this.emitError(h, "recognize"), h;
2799
2598
  } finally {
2800
2599
  (u = this.panel) == null || u.setBusy(!1);
2801
2600
  }
@@ -2808,9 +2607,9 @@ class po {
2808
2607
  async apply(t) {
2809
2608
  var o;
2810
2609
  if (this.assertAlive(), this.syncScanCacheVersion(), !this.scanResult)
2811
- throw v("SCAN_TOKEN_EXPIRED", "请先扫描字段后再回填。", "apply");
2610
+ throw b("SCAN_TOKEN_EXPIRED", "请先扫描字段后再回填。", "apply");
2812
2611
  this.events.emit("applying", { scanToken: t.scanToken, count: t.values.length });
2813
- const r = await new ot(this.scanResult.fields, this.registeredFields, this.adapters).apply(t);
2612
+ const r = await new Xe(this.scanResult.fields, this.registeredFields, this.adapters).apply(t);
2814
2613
  return this.events.emit("applied", r), (o = this.panel) == null || o.setApplyResult(r), r;
2815
2614
  }
2816
2615
  /**
@@ -2820,10 +2619,10 @@ class po {
2820
2619
  async applyAutoItems(t) {
2821
2620
  var a, c;
2822
2621
  if (!this.scanResult)
2823
- throw v("SCAN_TOKEN_EXPIRED", "请先扫描字段后再回填。", "apply");
2824
- const n = yo(t), r = t.items.filter((l) => Wt(l)).map((l) => ({ fieldId: l.fieldId, value: l.value, source: l.source }));
2622
+ throw b("SCAN_TOKEN_EXPIRED", "请先扫描字段后再回填。", "apply");
2623
+ const n = Qr(t), r = t.items.filter((l) => Vt(l)).map((l) => ({ fieldId: l.fieldId, value: l.value, source: l.source }));
2825
2624
  this.events.emit("applying", { scanToken: t.scanToken, count: r.length }), (a = this.panel) == null || a.setStatus("识别完成,正在自动回填...");
2826
- const i = await new ot(this.scanResult.fields, this.registeredFields, this.adapters).apply({ scanToken: t.scanToken, values: r }), s = {
2625
+ const i = await new Xe(this.scanResult.fields, this.registeredFields, this.adapters).apply({ scanToken: t.scanToken, values: r }), s = {
2827
2626
  ...i,
2828
2627
  skipped: [...n, ...i.skipped],
2829
2628
  warnings: [
@@ -2843,21 +2642,21 @@ class po {
2843
2642
  }
2844
2643
  assertAlive() {
2845
2644
  if (this.destroyed)
2846
- throw v("INSTANCE_DESTROYED", "实例已销毁。", "ui");
2645
+ throw b("INSTANCE_DESTROYED", "实例已销毁。", "ui");
2847
2646
  }
2848
2647
  emitError(t, n) {
2849
2648
  var o;
2850
- const r = rt(t, n);
2649
+ const r = We(t, n);
2851
2650
  this.events.emit("error", r), (o = this.panel) == null || o.setError(r.message);
2852
2651
  }
2853
2652
  getCachedPageScanResult(t) {
2854
2653
  const n = this.getPageScanCacheKey();
2855
2654
  if (!n) return null;
2856
- const r = K.get(n);
2655
+ const r = H.get(n);
2857
2656
  if (r && (!t || r.dynamicOptionsReady)) {
2858
- const i = wo(r.scanResult);
2657
+ const i = ro(r.scanResult);
2859
2658
  if (!i)
2860
- K.delete(n);
2659
+ H.delete(n);
2861
2660
  else
2862
2661
  return i;
2863
2662
  }
@@ -2867,54 +2666,54 @@ class po {
2867
2666
  cachePageScanResult(t, n) {
2868
2667
  const r = this.getPageScanCacheKey();
2869
2668
  if (!r || !t.fields.length) return;
2870
- const o = K.get(r);
2871
- o != null && o.dynamicOptionsReady && !n || (K.set(r, {
2669
+ const o = H.get(r);
2670
+ o != null && o.dynamicOptionsReady && !n || (H.set(r, {
2872
2671
  scanResult: t,
2873
2672
  dynamicOptionsReady: (o == null ? void 0 : o.dynamicOptionsReady) || n
2874
2673
  }), this.persistPageScanResult(t, (o == null ? void 0 : o.dynamicOptionsReady) || n));
2875
2674
  }
2876
2675
  getPageScanCacheKey() {
2877
- return this.registeredFields.length ? null : xo(this.config);
2676
+ return this.registeredFields.length ? null : so(this.config);
2878
2677
  }
2879
2678
  getSessionPageScanCacheKey() {
2880
- return this.registeredFields.length || !this.config.formCode ? null : ko(this.config);
2679
+ return this.registeredFields.length || !this.config.formCode ? null : ao(this.config);
2881
2680
  }
2882
2681
  clearScanStateOnTokenExpired(t) {
2883
- rt(t, "recognize").code === "TOKEN_EXPIRED" && (Yt(), this.scanCacheVersion = V, this.scanResult = null, this.autoApplyState = null);
2682
+ We(t, "recognize").code === "TOKEN_EXPIRED" && (Nt(), this.scanCacheVersion = $, this.scanResult = null, this.autoApplyState = null);
2884
2683
  }
2885
2684
  syncScanCacheVersion() {
2886
- this.scanCacheVersion !== V && (this.scanCacheVersion = V, this.scanResult = null, this.autoApplyState = null);
2685
+ this.scanCacheVersion !== $ && (this.scanCacheVersion = $, this.scanResult = null, this.autoApplyState = null);
2887
2686
  }
2888
2687
  getPersistedPageScanResult(t) {
2889
2688
  const n = this.getSessionPageScanCacheKey();
2890
2689
  if (!n) return null;
2891
- const r = Oo(n);
2690
+ const r = mo(n);
2892
2691
  if (!r || t && !r.dynamicOptionsReady) return null;
2893
- const o = this.scanner.scan({ maxFields: this.config.maxFields }), i = So(r, o);
2692
+ const o = this.scanner.scan({ maxFields: this.config.maxFields }), i = oo(r, o);
2894
2693
  return i ? {
2895
2694
  scanResult: i,
2896
2695
  dynamicOptionsReady: r.dynamicOptionsReady
2897
- } : (en(n), null);
2696
+ } : (jt(n), null);
2898
2697
  }
2899
2698
  persistPageScanResult(t, n) {
2900
2699
  const r = this.getSessionPageScanCacheKey();
2901
- !r || !t.fields.length || Do(r, {
2700
+ !r || !t.fields.length || wo(r, {
2902
2701
  version: 1,
2903
2702
  dynamicOptionsReady: n,
2904
2703
  fields: t.fields.map(({ element: o, scanToken: i, ...s }) => s)
2905
2704
  });
2906
2705
  }
2907
2706
  bindFloatingLifecycle(t) {
2908
- this.clearFloatingLifecycle(), this.floatingRouteSnapshot = dt(), _o();
2707
+ this.clearFloatingLifecycle(), this.floatingRouteSnapshot = rt(), co();
2909
2708
  const n = () => {
2910
- this.destroyed || dt() !== this.floatingRouteSnapshot && this.destroy();
2709
+ this.destroyed || rt() !== this.floatingRouteSnapshot && this.destroy();
2911
2710
  };
2912
- window.addEventListener(He, n);
2711
+ window.addEventListener(Pe, n);
2913
2712
  const r = new MutationObserver(() => {
2914
2713
  this.destroyed || t !== document.body && !t.isConnected && this.destroy();
2915
2714
  });
2916
2715
  r.observe(document.body, { childList: !0, subtree: !0 }), this.floatingLifecycleCleanup = () => {
2917
- window.removeEventListener(He, n), r.disconnect(), this.floatingRouteSnapshot = null, this.floatingLifecycleCleanup = null;
2716
+ window.removeEventListener(Pe, n), r.disconnect(), this.floatingRouteSnapshot = null, this.floatingLifecycleCleanup = null;
2918
2717
  };
2919
2718
  }
2920
2719
  clearFloatingLifecycle() {
@@ -2922,7 +2721,7 @@ class po {
2922
2721
  (t = this.floatingLifecycleCleanup) == null || t.call(this);
2923
2722
  }
2924
2723
  }
2925
- function ho(e, t, n) {
2724
+ function Zr(e, t, n) {
2926
2725
  return {
2927
2726
  scanToken: e.scanToken,
2928
2727
  trace: e.trace,
@@ -2943,12 +2742,12 @@ function ho(e, t, n) {
2943
2742
  })
2944
2743
  };
2945
2744
  }
2946
- function go(e, t, n, r, o) {
2745
+ function Jr(e, t, n, r, o) {
2947
2746
  return {
2948
2747
  scanToken: e,
2949
2748
  traceId: t,
2950
2749
  items: n.map((i) => {
2951
- const s = r.fields.find((l) => l.fieldId === i.fieldId), a = o.find((l) => l.fieldId === i.fieldId), c = a != null && a.getValue ? a.getValue() : vo(s == null ? void 0 : s.element);
2750
+ const s = r.fields.find((l) => l.fieldId === i.fieldId), a = o.find((l) => l.fieldId === i.fieldId), c = a != null && a.getValue ? a.getValue() : no(s == null ? void 0 : s.element);
2952
2751
  return {
2953
2752
  applyItemId: `${i.fieldId}_${Math.random().toString(36).slice(2, 8)}`,
2954
2753
  fieldId: i.fieldId,
@@ -2966,12 +2765,12 @@ function go(e, t, n, r, o) {
2966
2765
  })
2967
2766
  };
2968
2767
  }
2969
- function Wt(e) {
2768
+ function Vt(e) {
2970
2769
  var t;
2971
- return e.confidence >= lo && !((t = e.warnings) != null && t.length);
2770
+ return e.confidence >= Gr && !((t = e.warnings) != null && t.length);
2972
2771
  }
2973
- function yo(e) {
2974
- return e.items.filter((t) => !Wt(t)).map((t) => {
2772
+ function Qr(e) {
2773
+ return e.items.filter((t) => !Vt(t)).map((t) => {
2975
2774
  var n, r;
2976
2775
  return {
2977
2776
  fieldId: t.fieldId,
@@ -2982,7 +2781,7 @@ function yo(e) {
2982
2781
  };
2983
2782
  });
2984
2783
  }
2985
- function bo(e, t) {
2784
+ function eo(e, t) {
2986
2785
  const n = /* @__PURE__ */ new Map();
2987
2786
  for (const r of t)
2988
2787
  n.set(r.fieldId, r);
@@ -2990,10 +2789,10 @@ function bo(e, t) {
2990
2789
  n.has(r.fieldId) || n.set(r.fieldId, r);
2991
2790
  return [...n.values()];
2992
2791
  }
2993
- function mo(e, t) {
2792
+ function to(e, t) {
2994
2793
  return e === "only" ? !0 : e === "off" ? !1 : t;
2995
2794
  }
2996
- function lt(e, t, n, r, o, i = !1) {
2795
+ function tt(e, t, n, r, o, i = !1) {
2997
2796
  return {
2998
2797
  scanToken: e,
2999
2798
  suggestions: n,
@@ -3006,15 +2805,15 @@ function lt(e, t, n, r, o, i = !1) {
3006
2805
  }
3007
2806
  };
3008
2807
  }
3009
- function vo(e) {
2808
+ function no(e) {
3010
2809
  if (e)
3011
2810
  return e instanceof HTMLInputElement && e.type === "checkbox" ? e.checked : e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement ? e.value : e.textContent;
3012
2811
  }
3013
- function wo(e) {
2812
+ function ro(e) {
3014
2813
  const t = e.fields.map((n) => {
3015
2814
  if (n.source === "registered")
3016
2815
  return n;
3017
- const r = Eo(n);
2816
+ const r = io(n);
3018
2817
  return r ? { ...n, element: r } : null;
3019
2818
  });
3020
2819
  return t.some((n) => !n) ? null : {
@@ -3022,7 +2821,7 @@ function wo(e) {
3022
2821
  fields: t
3023
2822
  };
3024
2823
  }
3025
- function So(e, t) {
2824
+ function oo(e, t) {
3026
2825
  var s, a;
3027
2826
  const n = new Map(t.fields.map((c) => [c.fieldId, c])), r = [], o = /* @__PURE__ */ new Set();
3028
2827
  for (const c of e.fields) {
@@ -3041,7 +2840,7 @@ function So(e, t) {
3041
2840
  readonly: c.readonly ?? l.readonly,
3042
2841
  disabled: c.disabled ?? l.disabled
3043
2842
  };
3044
- u.fingerprint = G({
2843
+ u.fingerprint = z({
3045
2844
  ...u,
3046
2845
  tagName: (a = u.element) == null ? void 0 : a.tagName.toLowerCase()
3047
2846
  }), r.push(u);
@@ -3054,77 +2853,77 @@ function So(e, t) {
3054
2853
  fields: [...r, ...i]
3055
2854
  };
3056
2855
  }
3057
- function Eo(e) {
2856
+ function io(e) {
3058
2857
  var t;
3059
2858
  if ((t = e.element) != null && t.isConnected) return e.element;
3060
2859
  try {
3061
- return document.querySelector(`[data-smart-fill-id="${$o(e.fieldId)}"]`);
2860
+ return document.querySelector(`[data-smart-fill-id="${xo(e.fieldId)}"]`);
3062
2861
  } catch {
3063
2862
  return null;
3064
2863
  }
3065
2864
  }
3066
- function xo(e) {
3067
- const t = typeof location < "u" ? `${location.origin}${location.pathname}${location.search}` : "unknown-page", n = Xt(e.root || document);
2865
+ function so(e) {
2866
+ const t = typeof location < "u" ? `${location.origin}${location.pathname}${location.search}` : "unknown-page", n = Kt(e.root || document);
3068
2867
  return `smart-fill:${t}:${e.formCode || "default-form"}:${n}:${e.maxFields ?? 200}:scan`;
3069
2868
  }
3070
- function ko(e) {
3071
- const t = Xt(e.root || document);
3072
- return `${Gt}${e.formCode || "default-form"}:${t}:${e.maxFields ?? 200}`;
2869
+ function ao(e) {
2870
+ const t = Kt(e.root || document);
2871
+ return `${$t}${e.formCode || "default-form"}:${t}:${e.maxFields ?? 200}`;
3073
2872
  }
3074
- function Xt(e) {
2873
+ function Kt(e) {
3075
2874
  if (e === document) return "document";
3076
- const t = ct.get(e);
2875
+ const t = et.get(e);
3077
2876
  if (t) return t;
3078
- const n = e instanceof HTMLElement && e.id ? `el:${e.id}` : `root:${++fo}`;
3079
- return ct.set(e, n), n;
2877
+ const n = e instanceof HTMLElement && e.id ? `el:${e.id}` : `root:${++Wr}`;
2878
+ return et.set(e, n), n;
3080
2879
  }
3081
- function _o() {
3082
- if (at || typeof window > "u") return;
3083
- at = !0;
2880
+ function co() {
2881
+ if (Qe || typeof window > "u") return;
2882
+ Qe = !0;
3084
2883
  const e = () => {
3085
- window.dispatchEvent(new Event(He));
2884
+ window.dispatchEvent(new Event(Pe));
3086
2885
  };
3087
- window.addEventListener("popstate", e), window.addEventListener("hashchange", e), ut("pushState", e), ut("replaceState", e);
2886
+ window.addEventListener("popstate", e), window.addEventListener("hashchange", e), nt("pushState", e), nt("replaceState", e);
3088
2887
  }
3089
- function ut(e, t) {
2888
+ function nt(e, t) {
3090
2889
  const n = window.history[e];
3091
2890
  window.history[e] = function(...o) {
3092
2891
  const i = n.apply(this, o);
3093
2892
  return t(), i;
3094
2893
  };
3095
2894
  }
3096
- function dt() {
2895
+ function rt() {
3097
2896
  return typeof location > "u" ? "unknown-route" : `${location.pathname}${location.search}${location.hash}`;
3098
2897
  }
3099
- function Ao(e) {
3100
- const t = Co(e.floatingContainer);
2898
+ function lo(e) {
2899
+ const t = uo(e.floatingContainer);
3101
2900
  if (t)
3102
2901
  return t;
3103
- const n = To(e.routeContainerSelector);
3104
- return n || Lo() || document.body;
2902
+ const n = po(e.routeContainerSelector);
2903
+ return n || fo() || document.body;
3105
2904
  }
3106
- function Co(e) {
3107
- return e ? e instanceof HTMLElement ? e : ze(e) : null;
2905
+ function uo(e) {
2906
+ return e ? e instanceof HTMLElement ? e : He(e) : null;
3108
2907
  }
3109
- function To(e) {
2908
+ function po(e) {
3110
2909
  if (!e) return null;
3111
- const t = Zt(), n = t ? ze(e, t) : null;
3112
- return n || ze(e);
2910
+ const t = zt(), n = t ? He(e, t) : null;
2911
+ return n || He(e);
3113
2912
  }
3114
- function Lo() {
3115
- const e = Zt();
2913
+ function fo() {
2914
+ const e = zt();
3116
2915
  if (!e)
3117
2916
  return null;
3118
- const t = Io(e);
2917
+ const t = ho(e);
3119
2918
  if (t)
3120
2919
  return t;
3121
- const n = Mo(e);
2920
+ const n = go(e);
3122
2921
  if (n)
3123
2922
  return n;
3124
- const r = Ro(e);
2923
+ const r = yo(e);
3125
2924
  return r !== e ? r : null;
3126
2925
  }
3127
- function Zt() {
2926
+ function zt() {
3128
2927
  const e = [
3129
2928
  "#app",
3130
2929
  "#root",
@@ -3138,16 +2937,16 @@ function Zt() {
3138
2937
  ];
3139
2938
  for (const t of e) {
3140
2939
  const n = document.querySelector(t);
3141
- if (n && ke(n))
2940
+ if (n && we(n))
3142
2941
  return n;
3143
2942
  }
3144
2943
  return null;
3145
2944
  }
3146
- function Io(e) {
3147
- const t = w(e), n = Jt(e).filter((o) => !We(o)).filter((o) => w(o) >= Math.max(t * 0.2, 48e3)), r = n.filter((o) => Fo(o));
3148
- return r.length ? r.sort((o, i) => w(i) - w(o))[0] : n.length === 1 ? n[0] : null;
2945
+ function ho(e) {
2946
+ const t = m(e), n = Bt(e).filter((o) => !Ke(o)).filter((o) => m(o) >= Math.max(t * 0.2, 48e3)), r = n.filter((o) => bo(o));
2947
+ return r.length ? r.sort((o, i) => m(i) - m(o))[0] : n.length === 1 ? n[0] : null;
3149
2948
  }
3150
- function Mo(e) {
2949
+ function go(e) {
3151
2950
  const t = [
3152
2951
  "[data-route-root]",
3153
2952
  "[data-router-view]",
@@ -3163,63 +2962,63 @@ function Mo(e) {
3163
2962
  ".app-content",
3164
2963
  "main",
3165
2964
  '[role="main"]'
3166
- ], n = Qt(e), r = w(e);
3167
- return t.flatMap((i) => Array.from(e.querySelectorAll(i))).filter((i) => ke(i) && !We(i)).filter((i) => Ie(i, n) <= 3).filter((i) => w(i) >= Math.max(r * 0.2, 48e3)).sort((i, s) => Ie(i, n) - Ie(s, n) || w(s) - w(i))[0] || null;
2965
+ ], n = Ut(e), r = m(e);
2966
+ return t.flatMap((i) => Array.from(e.querySelectorAll(i))).filter((i) => we(i) && !Ke(i)).filter((i) => Ce(i, n) <= 3).filter((i) => m(i) >= Math.max(r * 0.2, 48e3)).sort((i, s) => Ce(i, n) - Ce(s, n) || m(s) - m(i))[0] || null;
3168
2967
  }
3169
- function Ro(e) {
2968
+ function yo(e) {
3170
2969
  let t = e;
3171
2970
  for (; ; ) {
3172
- const n = Jt(t).filter((o) => !We(o));
2971
+ const n = Bt(t).filter((o) => !Ke(o));
3173
2972
  if (n.length !== 1)
3174
2973
  return t;
3175
2974
  const [r] = n;
3176
- if (w(r) < Math.max(w(t) * 0.25, 48e3))
2975
+ if (m(r) < Math.max(m(t) * 0.25, 48e3))
3177
2976
  return t;
3178
2977
  t = r;
3179
2978
  }
3180
2979
  }
3181
- function Jt(e) {
3182
- return Array.from(e.children).filter((t) => t instanceof HTMLElement).filter((t) => ke(t));
2980
+ function Bt(e) {
2981
+ return Array.from(e.children).filter((t) => t instanceof HTMLElement).filter((t) => we(t));
3183
2982
  }
3184
- function ze(e, t = document) {
2983
+ function He(e, t = document) {
3185
2984
  try {
3186
2985
  const n = t.querySelector(e);
3187
- return n && ke(n) ? n : null;
2986
+ return n && we(n) ? n : null;
3188
2987
  } catch {
3189
2988
  return null;
3190
2989
  }
3191
2990
  }
3192
- function ke(e) {
2991
+ function we(e) {
3193
2992
  const t = window.getComputedStyle(e);
3194
2993
  if (t.display === "none" || t.visibility === "hidden" || Number(t.opacity) === 0)
3195
2994
  return !1;
3196
2995
  const n = e.getBoundingClientRect();
3197
2996
  return n.width > 0 && n.height > 0;
3198
2997
  }
3199
- function We(e) {
2998
+ function Ke(e) {
3200
2999
  const t = window.getComputedStyle(e);
3201
- return t.position === "fixed" || t.position === "sticky" ? !0 : w(e) < 24e3;
3000
+ return t.position === "fixed" || t.position === "sticky" ? !0 : m(e) < 24e3;
3202
3001
  }
3203
- function Fo(e) {
3002
+ function bo(e) {
3204
3003
  if (e.tagName.toLowerCase() === "main" || e.getAttribute("role") === "main")
3205
3004
  return !0;
3206
3005
  const t = e.id || "", n = typeof e.className == "string" ? e.className : "", r = `${t} ${n}`.toLowerCase();
3207
3006
  return /(page|layout|content|container|main|router|route|view)/.test(r);
3208
3007
  }
3209
- function w(e) {
3008
+ function m(e) {
3210
3009
  const t = e.getBoundingClientRect();
3211
3010
  return Math.max(0, t.width) * Math.max(0, t.height);
3212
3011
  }
3213
- function Qt(e) {
3012
+ function Ut(e) {
3214
3013
  let t = 0, n = e;
3215
3014
  for (; n && n !== document.body; )
3216
3015
  t += 1, n = n.parentElement;
3217
3016
  return t;
3218
3017
  }
3219
- function Ie(e, t) {
3220
- return Math.max(0, Qt(e) - t);
3018
+ function Ce(e, t) {
3019
+ return Math.max(0, Ut(e) - t);
3221
3020
  }
3222
- function Oo(e) {
3021
+ function mo(e) {
3223
3022
  try {
3224
3023
  const t = window.sessionStorage.getItem(e);
3225
3024
  if (!t) return null;
@@ -3229,13 +3028,13 @@ function Oo(e) {
3229
3028
  return null;
3230
3029
  }
3231
3030
  }
3232
- function Do(e, t) {
3031
+ function wo(e, t) {
3233
3032
  try {
3234
3033
  window.sessionStorage.setItem(e, JSON.stringify(t));
3235
3034
  } catch {
3236
3035
  }
3237
3036
  }
3238
- function en(e) {
3037
+ function jt(e) {
3239
3038
  try {
3240
3039
  if (e) {
3241
3040
  window.sessionStorage.removeItem(e);
@@ -3244,24 +3043,24 @@ function en(e) {
3244
3043
  const t = [];
3245
3044
  for (let n = 0; n < window.sessionStorage.length; n += 1) {
3246
3045
  const r = window.sessionStorage.key(n);
3247
- r != null && r.startsWith(Gt) && t.push(r);
3046
+ r != null && r.startsWith($t) && t.push(r);
3248
3047
  }
3249
3048
  for (const n of t)
3250
3049
  window.sessionStorage.removeItem(n);
3251
3050
  } catch {
3252
3051
  }
3253
3052
  }
3254
- function ft(e, t = "default") {
3053
+ function ot(e, t = "default") {
3255
3054
  const n = typeof location < "u" ? location.pathname : "unknown-page", r = t.replace(/[^\w-]/g, "_") || "default";
3256
3055
  return `smart-fill:${e}:${n}:${r}:open`;
3257
3056
  }
3258
- function Po(e, t) {
3057
+ function vo(e, t) {
3259
3058
  if (typeof e == "string") return e;
3260
3059
  if (t.id) return `#${t.id}`;
3261
3060
  const n = typeof t.className == "string" ? t.className.trim().split(/\s+/).filter(Boolean)[0] : "";
3262
3061
  return n ? `.${n}` : t.tagName.toLowerCase();
3263
3062
  }
3264
- function pt(e, t) {
3063
+ function it(e, t) {
3265
3064
  try {
3266
3065
  const n = window.localStorage.getItem(e);
3267
3066
  return n == null ? t : n === "1";
@@ -3269,63 +3068,63 @@ function pt(e, t) {
3269
3068
  return t;
3270
3069
  }
3271
3070
  }
3272
- function ht(e, t) {
3071
+ function st(e, t) {
3273
3072
  if (e)
3274
3073
  try {
3275
3074
  window.localStorage.setItem(e, t ? "1" : "0");
3276
3075
  } catch {
3277
3076
  }
3278
3077
  }
3279
- function tn() {
3078
+ function Gt() {
3280
3079
  return `smart-fill:${typeof location < "u" ? location.pathname : "unknown-page"}:local-priority`;
3281
3080
  }
3282
- function qo() {
3081
+ function So() {
3283
3082
  try {
3284
- return window.localStorage.getItem(tn()) === "1";
3083
+ return window.localStorage.getItem(Gt()) === "1";
3285
3084
  } catch {
3286
3085
  return !1;
3287
3086
  }
3288
3087
  }
3289
- function No(e) {
3088
+ function Eo(e) {
3290
3089
  try {
3291
- window.localStorage.setItem(tn(), e ? "1" : "0");
3090
+ window.localStorage.setItem(Gt(), e ? "1" : "0");
3292
3091
  } catch {
3293
3092
  }
3294
3093
  }
3295
- function $o(e) {
3094
+ function xo(e) {
3296
3095
  return typeof CSS < "u" && CSS.escape ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
3297
3096
  }
3298
- const h = { status: "idle" }, Me = new Ht(), gt = new kr();
3299
- class Ho {
3097
+ const f = { status: "idle" }, Ae = new Rt(), at = new cr();
3098
+ class ko {
3300
3099
  /** 初始化 SDK:校验 apiKey、创建会话、获取 accessToken */
3301
3100
  static async setup(t) {
3302
3101
  if (typeof window > "u")
3303
- return h.status = "ready", zo();
3304
- if (h.status === "ready" && h.apiKey === t.apiKey && h.session)
3305
- return h.session;
3306
- if (h.status === "loading" && h.apiKey === t.apiKey && h.promise)
3307
- return h.promise;
3308
- h.apiKey && h.apiKey !== t.apiKey && (Yt(), gt.destroyAll());
3309
- const n = new mr(t);
3310
- return h.status = "loading", h.apiKey = t.apiKey, h.client = n, h.promise = n.createSession().then((r) => (console.log("SmartFill session created:", r), n.setAccessToken(r.apiKey), h.status = "ready", h.session = r, Me.emit("ready", { apiKey: t.apiKey }), r)).catch((r) => {
3311
- throw h.status = "error", r;
3312
- }), h.promise;
3102
+ return f.status = "ready", _o();
3103
+ if (f.status === "ready" && f.apiKey === t.apiKey && f.session)
3104
+ return f.session;
3105
+ if (f.status === "loading" && f.apiKey === t.apiKey && f.promise)
3106
+ return f.promise;
3107
+ f.apiKey && f.apiKey !== t.apiKey && (Nt(), at.destroyAll());
3108
+ const n = new nr(t);
3109
+ return f.status = "loading", f.apiKey = t.apiKey, f.client = n, f.promise = n.createSession().then((r) => (console.log("SmartFill session created:", r), n.setAccessToken(r.apiKey), f.status = "ready", f.session = r, Ae.emit("ready", { apiKey: t.apiKey }), r)).catch((r) => {
3110
+ throw f.status = "error", r;
3111
+ }), f.promise;
3313
3112
  }
3314
3113
  /** 创建页面实例,必须在 setup ready 后调用 */
3315
3114
  static create(t = {}) {
3316
3115
  if (typeof window > "u")
3317
- return B();
3318
- if (h.status !== "ready" || !h.client)
3319
- throw v("SDK_NOT_READY", "请先 await SmartFill.setup({ apiKey })。", "setup");
3320
- return new po(t, {
3321
- client: h.client,
3322
- manager: gt
3116
+ return N();
3117
+ if (f.status !== "ready" || !f.client)
3118
+ throw b("SDK_NOT_READY", "请先 await SmartFill.setup({ apiKey })。", "setup");
3119
+ return new Xr(t, {
3120
+ client: f.client,
3121
+ manager: at
3323
3122
  });
3324
3123
  }
3325
3124
  }
3326
3125
  /** 订阅全局事件(目前仅 ready) */
3327
- d(Ho, "on", Me.on.bind(Me));
3328
- function zo() {
3126
+ d(ko, "on", Ae.on.bind(Ae));
3127
+ function _o() {
3329
3128
  return {
3330
3129
  apiKey: "server-mock",
3331
3130
  accessToken: "server-mock",
@@ -3335,16 +3134,16 @@ function zo() {
3335
3134
  rulesVersion: "server"
3336
3135
  };
3337
3136
  }
3338
- function B(e) {
3137
+ function N(e) {
3339
3138
  const t = () => {
3340
3139
  };
3341
3140
  return {
3342
3141
  on: t,
3343
- useAdapter: () => B(),
3344
- registerFields: () => B(),
3142
+ useAdapter: () => N(),
3143
+ registerFields: () => N(),
3345
3144
  unregisterFields: t,
3346
- mount: () => B(),
3347
- mountFloatingButton: () => B(),
3145
+ mount: () => N(),
3146
+ mountFloatingButton: () => N(),
3348
3147
  open: async () => {
3349
3148
  },
3350
3149
  close: t,
@@ -3362,14 +3161,14 @@ function B(e) {
3362
3161
  };
3363
3162
  }
3364
3163
  export {
3365
- br as DEFAULT_BASE_URL,
3366
- ot as DomFiller,
3367
- jr as DomScanner,
3368
- Bo as ElementAdapter,
3369
- Ht as EventBus,
3370
- Or as LocalRuleEngine,
3371
- Vo as NativeAdapter,
3372
- Ho as SmartFill,
3373
- po as SmartFillInstance,
3374
- Nt as UiFrameworkAdapter
3164
+ tr as DEFAULT_BASE_URL,
3165
+ Xe as DomFiller,
3166
+ Ir as DomScanner,
3167
+ To as ElementAdapter,
3168
+ Rt as EventBus,
3169
+ mr as LocalRuleEngine,
3170
+ Ao as NativeAdapter,
3171
+ ko as SmartFill,
3172
+ Xr as SmartFillInstance,
3173
+ It as UiFrameworkAdapter
3375
3174
  };