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