@kc-one/smart-fill-sdk 0.0.11 → 0.0.12
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 +51 -51
- package/dist/index.umd.cjs +1 -1
- package/dist/src/config/defaults.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -14,7 +14,7 @@ const ti = {
|
|
|
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
|
+
}, wt = [
|
|
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" },
|
|
@@ -68,7 +68,7 @@ const ti = {
|
|
|
68
68
|
"van-switch--disabled",
|
|
69
69
|
"van-stepper--disabled",
|
|
70
70
|
"van-dropdown-menu--disabled"
|
|
71
|
-
],
|
|
71
|
+
], vt = wt.map((e) => e.selectors).join(", "), yn = [
|
|
72
72
|
".form-item",
|
|
73
73
|
".ant-form-item",
|
|
74
74
|
".el-form-item",
|
|
@@ -115,7 +115,7 @@ const ti = {
|
|
|
115
115
|
"van-checkbox--checked"
|
|
116
116
|
];
|
|
117
117
|
function K(e) {
|
|
118
|
-
return
|
|
118
|
+
return wt.find((t) => e.matches(t.selectors)) || null;
|
|
119
119
|
}
|
|
120
120
|
function St(e) {
|
|
121
121
|
return !!K(e);
|
|
@@ -149,9 +149,9 @@ function me(e) {
|
|
|
149
149
|
function Et(e) {
|
|
150
150
|
const t = K(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) => wn(n)).filter((n) => !!(n.label || n.value));
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function wn(e) {
|
|
155
155
|
const t = e instanceof HTMLInputElement ? e : e.querySelector('input[type="radio"],input[type="checkbox"]'), n = f(e.textContent || e.getAttribute("aria-label") || e.getAttribute("title") || ""), r = e.getAttribute("value") || (t == null ? void 0 : t.value) || n;
|
|
156
156
|
return { label: n, value: r };
|
|
157
157
|
}
|
|
@@ -191,7 +191,7 @@ const qe = "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(", "), vn = [
|
|
195
195
|
".ant-select-selection-item",
|
|
196
196
|
".el-select__selected-item",
|
|
197
197
|
".el-select-v2__selected-item",
|
|
@@ -219,7 +219,7 @@ const qe = "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(", "),
|
|
222
|
+
].join(", "), we = [
|
|
223
223
|
De,
|
|
224
224
|
".van-action-sheet__name",
|
|
225
225
|
".van-cascader__option",
|
|
@@ -361,7 +361,7 @@ function kn(e) {
|
|
|
361
361
|
const s = f((i == null ? void 0 : i.textContent) || "");
|
|
362
362
|
return s && s !== "请选择" ? s : "";
|
|
363
363
|
}
|
|
364
|
-
const n = e.querySelector(
|
|
364
|
+
const n = e.querySelector(vn);
|
|
365
365
|
if (n instanceof HTMLInputElement)
|
|
366
366
|
return f(n.value);
|
|
367
367
|
const r = f((n == null ? void 0 : n.textContent) || "");
|
|
@@ -417,14 +417,14 @@ async function Cn(e, t, n) {
|
|
|
417
417
|
e.querySelector("input")
|
|
418
418
|
].filter((o) => o instanceof HTMLElement);
|
|
419
419
|
for (const o of r)
|
|
420
|
-
if (Ft(o), Ot(o), await D(180),
|
|
420
|
+
if (Ft(o), Ot(o), await D(180), ve(t, n, e).length || (qt(o), await D(180), ve(t, n, e).length)) return !0;
|
|
421
421
|
return !1;
|
|
422
422
|
}
|
|
423
423
|
function Tn(e) {
|
|
424
424
|
var r;
|
|
425
425
|
const t = /* @__PURE__ */ new Set(), n = [];
|
|
426
426
|
for (const o of e) {
|
|
427
|
-
const i = o.matches(
|
|
427
|
+
const i = o.matches(we) ? [o] : Array.from(o.querySelectorAll(we));
|
|
428
428
|
for (const s of i) {
|
|
429
429
|
if (s.classList.contains("is-disabled") || s.classList.contains("ant-select-item-option-disabled") || s.getAttribute("aria-disabled") === "true")
|
|
430
430
|
continue;
|
|
@@ -440,14 +440,14 @@ function Tn(e) {
|
|
|
440
440
|
}
|
|
441
441
|
async function Ln(e, t, n) {
|
|
442
442
|
for (let r = 0; r < 8; r += 1) {
|
|
443
|
-
const o =
|
|
443
|
+
const o = ve(e, t, n);
|
|
444
444
|
if (o.length) return o;
|
|
445
445
|
await D(r === 0 ? 120 : 80);
|
|
446
446
|
}
|
|
447
447
|
return [];
|
|
448
448
|
}
|
|
449
449
|
function Je(e, t, n) {
|
|
450
|
-
return
|
|
450
|
+
return ve(t, n, e).length > 0 ? !0 : ne(e).some((r) => r.getAttribute("aria-expanded") === "true" || r.classList.contains("is-focus") || r.classList.contains("is-focused"));
|
|
451
451
|
}
|
|
452
452
|
function In(e, t, n) {
|
|
453
453
|
const r = t.filter((c) => $e(e, c)), o = r.filter((c) => On(e, c)), i = o.filter((c) => !n.has(c));
|
|
@@ -463,7 +463,7 @@ function In(e, t, n) {
|
|
|
463
463
|
const a = r.filter((c) => Pn(c) && Mt(e)).sort((c, l) => N(l, e) - N(c, e)).slice(0, 1);
|
|
464
464
|
return a.length ? a : [];
|
|
465
465
|
}
|
|
466
|
-
function
|
|
466
|
+
function ve(e, t, n) {
|
|
467
467
|
return In(n, e.getTrackedDropdowns(), t);
|
|
468
468
|
}
|
|
469
469
|
function N(e, t) {
|
|
@@ -521,7 +521,7 @@ function Mt(e) {
|
|
|
521
521
|
return ne(e).some((t) => t.getAttribute("aria-expanded") === "true" || t.classList.contains("is-focus") || t.classList.contains("is-focused") || e.contains(document.activeElement));
|
|
522
522
|
}
|
|
523
523
|
function Pn(e) {
|
|
524
|
-
return e.matches(
|
|
524
|
+
return e.matches(we) || !!e.querySelector(we);
|
|
525
525
|
}
|
|
526
526
|
function Rt(e, t) {
|
|
527
527
|
const n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
@@ -642,11 +642,11 @@ function Dt(e) {
|
|
|
642
642
|
}
|
|
643
643
|
const Vn = /(维吾尔自治区|壮族自治区|回族自治区|特别行政区|自治区直辖县级行政区划|自治区|自治州|地区|盟|林区|街道|苏木|社区|省|市|区|县|旗|镇|乡)$/g, Bn = /* @__PURE__ */ new Set(["市辖区", "县", "自治区直辖县级行政区划"]);
|
|
644
644
|
let le = null;
|
|
645
|
-
function
|
|
645
|
+
function w(e) {
|
|
646
646
|
return String(e ?? "").replace(/\s+/g, "").replace(/[,,。.、/\\\-]/g, "").trim().toLowerCase();
|
|
647
647
|
}
|
|
648
648
|
function M(e) {
|
|
649
|
-
return
|
|
649
|
+
return w(e).replace(Vn, "");
|
|
650
650
|
}
|
|
651
651
|
function Ue(e) {
|
|
652
652
|
if (e == null) return "";
|
|
@@ -693,7 +693,7 @@ function ke(e) {
|
|
|
693
693
|
const a = f(String(s ?? ""));
|
|
694
694
|
a && t.push(a);
|
|
695
695
|
}, o = (s) => {
|
|
696
|
-
const a =
|
|
696
|
+
const a = w(s);
|
|
697
697
|
a && (n.push(a), r(s));
|
|
698
698
|
};
|
|
699
699
|
if (Array.isArray(e))
|
|
@@ -719,7 +719,7 @@ function ke(e) {
|
|
|
719
719
|
r(e[s]);
|
|
720
720
|
} else
|
|
721
721
|
r(e);
|
|
722
|
-
const i =
|
|
722
|
+
const i = w(t.join(""));
|
|
723
723
|
return {
|
|
724
724
|
fullText: i,
|
|
725
725
|
looseFullText: M(i),
|
|
@@ -727,7 +727,7 @@ function ke(e) {
|
|
|
727
727
|
};
|
|
728
728
|
}
|
|
729
729
|
function ue(e, t) {
|
|
730
|
-
const n =
|
|
730
|
+
const n = w(e), r = w(t);
|
|
731
731
|
if (!n || !r) return !1;
|
|
732
732
|
if (n === r || n.includes(r) || r.includes(n))
|
|
733
733
|
return !0;
|
|
@@ -748,7 +748,7 @@ function Qe(e, t, n, r) {
|
|
|
748
748
|
let o = null, i = 0;
|
|
749
749
|
const s = Un(t, n, r);
|
|
750
750
|
for (const a of e) {
|
|
751
|
-
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 =
|
|
751
|
+
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 = w(l);
|
|
752
752
|
if (!u) continue;
|
|
753
753
|
const p = M(u);
|
|
754
754
|
let h = jn(u, p, s);
|
|
@@ -758,7 +758,7 @@ function Qe(e, t, n, r) {
|
|
|
758
758
|
}
|
|
759
759
|
function Un(e, t, n) {
|
|
760
760
|
const r = [], o = /* @__PURE__ */ new Set(), i = (s, a) => {
|
|
761
|
-
const c =
|
|
761
|
+
const c = w(s);
|
|
762
762
|
!c || o.has(c) || (o.add(c), r.push({
|
|
763
763
|
normalized: c,
|
|
764
764
|
stripped: M(c),
|
|
@@ -808,7 +808,7 @@ function Yn(e, t, n, r, o) {
|
|
|
808
808
|
return s;
|
|
809
809
|
}
|
|
810
810
|
function Wn(e) {
|
|
811
|
-
const t = f(e), n =
|
|
811
|
+
const t = f(e), n = w(t);
|
|
812
812
|
if (!n) return [];
|
|
813
813
|
const r = /* @__PURE__ */ new Set([n]), o = M(n);
|
|
814
814
|
o && !Bn.has(t) && r.add(o);
|
|
@@ -1141,7 +1141,7 @@ function zt(e) {
|
|
|
1141
1141
|
return f((n == null ? void 0 : n.textContent) || "");
|
|
1142
1142
|
}
|
|
1143
1143
|
function be(e) {
|
|
1144
|
-
return !!
|
|
1144
|
+
return !!w(zt(e));
|
|
1145
1145
|
}
|
|
1146
1146
|
async function tt(e) {
|
|
1147
1147
|
if (!be(e)) return;
|
|
@@ -1278,15 +1278,15 @@ function nt(e) {
|
|
|
1278
1278
|
return Bt(re().filter(H), !1).length > 0 ? !0 : Ge(e).some((t) => t.getAttribute("aria-expanded") === "true" || t.classList.contains("is-focus") || t.classList.contains("is-focused"));
|
|
1279
1279
|
}
|
|
1280
1280
|
function rt(e, t) {
|
|
1281
|
-
const n = zt(e), r =
|
|
1281
|
+
const n = zt(e), r = w(n);
|
|
1282
1282
|
if (!r) return !1;
|
|
1283
|
-
const o = Ue(t), i =
|
|
1283
|
+
const o = Ue(t), i = w(o);
|
|
1284
1284
|
if (ue(r, i)) return !0;
|
|
1285
|
-
const s = ke(t), a = je(t, s), c =
|
|
1285
|
+
const s = ke(t), a = je(t, s), c = w(a.join(""));
|
|
1286
1286
|
if (ue(r, c)) return !0;
|
|
1287
|
-
const l =
|
|
1287
|
+
const l = w(ur(t));
|
|
1288
1288
|
if (ue(r, l)) return !0;
|
|
1289
|
-
const u =
|
|
1289
|
+
const u = w(s.structuredParts.join(""));
|
|
1290
1290
|
return ue(r, u);
|
|
1291
1291
|
}
|
|
1292
1292
|
function Ce(e, t) {
|
|
@@ -1399,7 +1399,7 @@ function b(e) {
|
|
|
1399
1399
|
}
|
|
1400
1400
|
const ot = /* @__PURE__ */ new Set(["select", "cascader", "date"]), Yt = {
|
|
1401
1401
|
name: "ui-framework",
|
|
1402
|
-
match: (e) => e.matches(
|
|
1402
|
+
match: (e) => e.matches(vt) || St(e) || !mr(e) && Ne(e),
|
|
1403
1403
|
getValue: (e) => {
|
|
1404
1404
|
var o, i;
|
|
1405
1405
|
const t = e.element;
|
|
@@ -1416,7 +1416,7 @@ const ot = /* @__PURE__ */ new Set(["select", "cascader", "date"]), Yt = {
|
|
|
1416
1416
|
if (!n) return;
|
|
1417
1417
|
const r = K(n);
|
|
1418
1418
|
if ((r == null ? void 0 : r.kind) === "switch") {
|
|
1419
|
-
|
|
1419
|
+
wr(n, t);
|
|
1420
1420
|
return;
|
|
1421
1421
|
}
|
|
1422
1422
|
if ((r == null ? void 0 : r.kind) === "radioGroup") {
|
|
@@ -1424,7 +1424,7 @@ const ot = /* @__PURE__ */ new Set(["select", "cascader", "date"]), Yt = {
|
|
|
1424
1424
|
return;
|
|
1425
1425
|
}
|
|
1426
1426
|
if ((r == null ? void 0 : r.kind) === "checkboxGroup") {
|
|
1427
|
-
|
|
1427
|
+
vr(n, t);
|
|
1428
1428
|
return;
|
|
1429
1429
|
}
|
|
1430
1430
|
const o = e.type || me(n) || (r == null ? void 0 : r.type);
|
|
@@ -1443,10 +1443,10 @@ const ot = /* @__PURE__ */ new Set(["select", "cascader", "date"]), Yt = {
|
|
|
1443
1443
|
function mr(e) {
|
|
1444
1444
|
return e instanceof HTMLInputElement || e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement;
|
|
1445
1445
|
}
|
|
1446
|
-
function
|
|
1446
|
+
function wr(e, t) {
|
|
1447
1447
|
Q(e) !== _r(t) && Ee(e);
|
|
1448
1448
|
}
|
|
1449
|
-
function
|
|
1449
|
+
function vr(e, t) {
|
|
1450
1450
|
var o;
|
|
1451
1451
|
const n = new Set(Ar(t).map(T)), r = Et(e) || [];
|
|
1452
1452
|
for (const i of J(e)) {
|
|
@@ -1499,7 +1499,7 @@ function T(e) {
|
|
|
1499
1499
|
function oe(e) {
|
|
1500
1500
|
return e.replace(/\s+/g, " ").trim();
|
|
1501
1501
|
}
|
|
1502
|
-
const Cr = "https://
|
|
1502
|
+
const Cr = "https://www.kingdeefin.com";
|
|
1503
1503
|
class Wt extends Error {
|
|
1504
1504
|
constructor(n) {
|
|
1505
1505
|
super(n.message);
|
|
@@ -1508,7 +1508,7 @@ class Wt extends Error {
|
|
|
1508
1508
|
this.name = "SmartFillException", this.smartFillError = n;
|
|
1509
1509
|
}
|
|
1510
1510
|
}
|
|
1511
|
-
function
|
|
1511
|
+
function v(e, t, n, r = {}) {
|
|
1512
1512
|
return new Wt({ code: e, message: t, stage: n, ...r });
|
|
1513
1513
|
}
|
|
1514
1514
|
function it(e, t, n = "RECOGNIZE_FAILED") {
|
|
@@ -1540,7 +1540,7 @@ class Tr {
|
|
|
1540
1540
|
*/
|
|
1541
1541
|
async createSession() {
|
|
1542
1542
|
if (!/^seKey-[A-Za-z0-9_-]{6,}$/.test(this.config.apiKey))
|
|
1543
|
-
throw
|
|
1543
|
+
throw v("API_KEY_INVALID", "apiKey 格式不正确,应以 seKey- 开头。", "setup");
|
|
1544
1544
|
return {
|
|
1545
1545
|
apiKey: this.config.apiKey,
|
|
1546
1546
|
rulesVersion: "0.0.1"
|
|
@@ -1616,7 +1616,7 @@ class Tr {
|
|
|
1616
1616
|
}
|
|
1617
1617
|
), o = Rr(r);
|
|
1618
1618
|
if (!o)
|
|
1619
|
-
throw
|
|
1619
|
+
throw v("RECOGNIZE_FAILED", "图片识别未提取到文本内容。", "recognize");
|
|
1620
1620
|
return o;
|
|
1621
1621
|
}
|
|
1622
1622
|
/** 通用 fetch 封装:超时控制、trace 头、HTTP 错误映射为 SmartFillException */
|
|
@@ -1630,12 +1630,12 @@ class Tr {
|
|
|
1630
1630
|
signal: r.signal
|
|
1631
1631
|
});
|
|
1632
1632
|
if (!s.ok)
|
|
1633
|
-
throw
|
|
1633
|
+
throw v(Or(s.status), await s.text(), t.includes("session") ? "setup" : "recognize", {
|
|
1634
1634
|
retryable: s.status >= 500 || s.status === 429
|
|
1635
1635
|
});
|
|
1636
1636
|
return s.json();
|
|
1637
1637
|
} catch (s) {
|
|
1638
|
-
throw s instanceof DOMException && s.name === "AbortError" ?
|
|
1638
|
+
throw s instanceof DOMException && s.name === "AbortError" ? v("RECOGNIZE_TIMEOUT", "识别请求超时,请稍后重试。", "recognize", { retryable: !0 }) : s;
|
|
1639
1639
|
} finally {
|
|
1640
1640
|
window.clearTimeout(o);
|
|
1641
1641
|
}
|
|
@@ -2237,7 +2237,7 @@ class oo {
|
|
|
2237
2237
|
}
|
|
2238
2238
|
/** 收集 root 下可见且可编辑的表单控件 */
|
|
2239
2239
|
collectVisibleFields(t) {
|
|
2240
|
-
const n = /* @__PURE__ */ new Set(), r = [lt, kt,
|
|
2240
|
+
const n = /* @__PURE__ */ new Set(), r = [lt, kt, vt, ".van-field"].join(", ");
|
|
2241
2241
|
for (const s of t.querySelectorAll(r)) {
|
|
2242
2242
|
if (!(s instanceof HTMLElement)) continue;
|
|
2243
2243
|
const a = He(s) || Fe(s);
|
|
@@ -2414,7 +2414,7 @@ class mo {
|
|
|
2414
2414
|
});
|
|
2415
2415
|
/** 面板聚焦或鼠标悬浮在图片区时接管全局粘贴图片 */
|
|
2416
2416
|
d(this, "handleDocumentPaste", (t) => {
|
|
2417
|
-
const n =
|
|
2417
|
+
const n = vo(t);
|
|
2418
2418
|
if (!n.length || !this.isOpen || !this.host)
|
|
2419
2419
|
return;
|
|
2420
2420
|
const r = document.activeElement, o = this.root instanceof ShadowRoot ? this.root.activeElement : null;
|
|
@@ -2477,7 +2477,7 @@ class mo {
|
|
|
2477
2477
|
<div class="sf-body ${t ? "is-open" : ""}">
|
|
2478
2478
|
<div class="sf-entry-grid">
|
|
2479
2479
|
<div class="sf-textarea-wrap">
|
|
2480
|
-
<textarea class="sf-textarea" data-role="text" placeholder="${this.t("placeholder", "粘贴文本,如:姓名:张三 手机号:13800000000")}">${
|
|
2480
|
+
<textarea class="sf-textarea" data-role="text" placeholder="${this.t("placeholder", "粘贴文本,如:姓名:张三 手机号:13800000000")}">${wo(this.inputText)}</textarea>
|
|
2481
2481
|
<div class="sf-textarea-actions">
|
|
2482
2482
|
<button class="sf-btn sf-btn-secondary" type="button" data-role="clear">${this.t("clear", "清空")}</button>
|
|
2483
2483
|
<button class="sf-btn sf-btn-primary" type="button" data-role="recognize">${this.t("recognize", "智能识别")}</button>
|
|
@@ -2615,7 +2615,7 @@ class mo {
|
|
|
2615
2615
|
return ((r = this.options.messages) == null ? void 0 : r[t]) || n;
|
|
2616
2616
|
}
|
|
2617
2617
|
}
|
|
2618
|
-
function
|
|
2618
|
+
function wo(e) {
|
|
2619
2619
|
return e.replace(/[&<>"']/g, (t) => ({
|
|
2620
2620
|
"&": "&",
|
|
2621
2621
|
"<": "<",
|
|
@@ -2627,7 +2627,7 @@ function vo(e) {
|
|
|
2627
2627
|
function ge(e, t, n) {
|
|
2628
2628
|
return Math.min(Math.max(e, t), n);
|
|
2629
2629
|
}
|
|
2630
|
-
function
|
|
2630
|
+
function vo(e) {
|
|
2631
2631
|
var n;
|
|
2632
2632
|
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);
|
|
2633
2633
|
}
|
|
@@ -2768,7 +2768,7 @@ class _o {
|
|
|
2768
2768
|
for (const r of t) {
|
|
2769
2769
|
const o = r.rowKey == null ? r.fieldId : `${r.fieldId}:${r.rowKey}`;
|
|
2770
2770
|
if (n.has(o))
|
|
2771
|
-
throw
|
|
2771
|
+
throw v("UNSUPPORTED_PAGE", `字段 ${o} 重复注册。`, "scan");
|
|
2772
2772
|
n.add(o);
|
|
2773
2773
|
}
|
|
2774
2774
|
return this.registeredFields = t, this.scanResult = null, this.schedulePreScan(), this;
|
|
@@ -2782,7 +2782,7 @@ class _o {
|
|
|
2782
2782
|
this.assertAlive();
|
|
2783
2783
|
const n = typeof t == "string" ? document.querySelector(t) : t;
|
|
2784
2784
|
if (!n)
|
|
2785
|
-
throw
|
|
2785
|
+
throw v("UNSUPPORTED_PAGE", "未找到智能录入挂载点。", "ui");
|
|
2786
2786
|
const r = gt("inline", Yo(t, n)), o = yt(r, !0);
|
|
2787
2787
|
return this.createPanel("inline", r, o).mount(n), this.schedulePreScan(), this;
|
|
2788
2788
|
}
|
|
@@ -2847,7 +2847,7 @@ class _o {
|
|
|
2847
2847
|
maxFields: this.config.maxFields
|
|
2848
2848
|
}));
|
|
2849
2849
|
if (this.scanResult = i, this.cachePageScanResult(i, t.dynamicOptions), !this.scanResult.fields.length)
|
|
2850
|
-
throw
|
|
2850
|
+
throw v("NO_FIELDS_FOUND", "当前页面未找到可回填字段。", "scan");
|
|
2851
2851
|
return t.emitStatus && (this.events.emit("scanCompleted", {
|
|
2852
2852
|
scanToken: this.scanResult.scanToken,
|
|
2853
2853
|
fieldCount: this.scanResult.fields.length
|
|
@@ -2959,7 +2959,7 @@ class _o {
|
|
|
2959
2959
|
async apply(t) {
|
|
2960
2960
|
var o;
|
|
2961
2961
|
if (this.assertAlive(), this.syncScanCacheVersion(), !this.scanResult)
|
|
2962
|
-
throw
|
|
2962
|
+
throw v("SCAN_TOKEN_EXPIRED", "请先扫描字段后再回填。", "apply");
|
|
2963
2963
|
this.events.emit("applying", { scanToken: t.scanToken, count: t.values.length });
|
|
2964
2964
|
const r = await new at(this.scanResult.fields, this.registeredFields, this.adapters).apply(t);
|
|
2965
2965
|
return this.events.emit("applied", r), (o = this.panel) == null || o.setApplyResult(r), r;
|
|
@@ -2971,7 +2971,7 @@ class _o {
|
|
|
2971
2971
|
async applyAutoItems(t) {
|
|
2972
2972
|
var a, c;
|
|
2973
2973
|
if (!this.scanResult)
|
|
2974
|
-
throw
|
|
2974
|
+
throw v("SCAN_TOKEN_EXPIRED", "请先扫描字段后再回填。", "apply");
|
|
2975
2975
|
const n = To(t), r = t.items.filter((l) => sn(l)).map((l) => ({ fieldId: l.fieldId, value: l.value, source: l.source }));
|
|
2976
2976
|
this.events.emit("applying", { scanToken: t.scanToken, count: r.length }), (a = this.panel) == null || a.setStatus("识别完成,正在自动回填...");
|
|
2977
2977
|
const i = await new at(this.scanResult.fields, this.registeredFields, this.adapters).apply({ scanToken: t.scanToken, values: r }), s = {
|
|
@@ -2994,7 +2994,7 @@ class _o {
|
|
|
2994
2994
|
}
|
|
2995
2995
|
assertAlive() {
|
|
2996
2996
|
if (this.destroyed)
|
|
2997
|
-
throw
|
|
2997
|
+
throw v("INSTANCE_DESTROYED", "实例已销毁。", "ui");
|
|
2998
2998
|
}
|
|
2999
2999
|
emitError(t, n) {
|
|
3000
3000
|
var o;
|
|
@@ -3467,7 +3467,7 @@ class Jo {
|
|
|
3467
3467
|
if (typeof window > "u")
|
|
3468
3468
|
return G();
|
|
3469
3469
|
if (g.status !== "ready" || !g.client)
|
|
3470
|
-
throw
|
|
3470
|
+
throw v("SDK_NOT_READY", "请先 await SmartFill.setup({ apiKey })。", "setup");
|
|
3471
3471
|
return new _o(t, {
|
|
3472
3472
|
client: g.client,
|
|
3473
3473
|
manager: mt
|
package/dist/index.umd.cjs
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
transition: none !important;
|
|
8
8
|
animation: none !important;
|
|
9
9
|
}
|
|
10
|
-
`,document.head.appendChild(e)}async function jn(e,t){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 D(120);for(const n of t.getTrackedDropdowns())n.isConnected&&(n.style.display="none",n.setAttribute("aria-hidden","true"))}function mt(e){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()}function vt(e){e.focus({preventScroll:!0});const t=e instanceof HTMLInputElement?e:e.querySelector("input");t instanceof HTMLElement&&t.focus({preventScroll:!0})}function wt(e){for(const t of[{key:"ArrowDown",code:"ArrowDown"},{key:"Enter",code:"Enter"},{key:" ",code:"Space"}])e.dispatchEvent(new KeyboardEvent("keydown",{...t,bubbles:!0,composed:!0})),e.dispatchEvent(new KeyboardEvent("keyup",{...t,bubbles:!0,composed:!0}))}function D(e){return new Promise(t=>window.setTimeout(t,e))}function Gn(){const e=new Map;e.set(window,{left:window.scrollX,top:window.scrollY});for(const t of document.querySelectorAll("*"))(t.scrollTop||t.scrollLeft)&&e.set(t,{left:t.scrollLeft,top:t.scrollTop});return()=>{for(const[t,n]of e)t===window?window.scrollTo(n.left,n.top):t instanceof HTMLElement&&(t.scrollLeft=n.left,t.scrollTop=n.top)}}function St(e){const t=window.getComputedStyle(e);if(t.display==="none"||t.visibility==="hidden"||Number(t.opacity)===0)return!1;const n=e.getBoundingClientRect();return n.width>0&&n.height>0}const Yn=/(维吾尔自治区|壮族自治区|回族自治区|特别行政区|自治区直辖县级行政区划|自治区|自治州|地区|盟|林区|街道|苏木|社区|省|市|区|县|旗|镇|乡)$/g,Wn=new Set(["市辖区","县","自治区直辖县级行政区划"]);let fe=null;function w(e){return String(e??"").replace(/\s+/g,"").replace(/[,,。.、/\\\-]/g,"").trim().toLowerCase()}function I(e){return w(e).replace(Yn,"")}function Pe(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number")return String(e).trim();if(Array.isArray(e))return e.map(t=>Pe(t)).filter(Boolean).join("");if(typeof e=="object"){const t=[],n=new Set,r=i=>{const o=d(String(i??""));!o||n.has(o)||(n.add(o),t.push(o))};for(const i of["province","provinceName","prov","city","cityName","district","districtName","area","areaName","county","countyName","region","regionName","address","detail","detailAddress","fullAddress","label","text","value","name","answer"])r(e[i]);return t.join("")}return d(String(e))}function pe(e){const t=[],n=[],r=s=>{const a=d(String(s??""));a&&t.push(a)},i=s=>{const a=w(s);a&&(n.push(a),r(s))};if(Array.isArray(e))for(const s of e)i(s);else if(typeof e=="object"&&e){for(const s of["province","provinceName","prov","city","cityName","district","districtName","area","areaName","county","countyName","region","regionName"])i(e[s]);for(const s of["address","detail","detailAddress","fullAddress","label","value","text","name","answer"])r(e[s])}else r(e);const o=w(t.join(""));return{fullText:o,looseFullText:I(o),structuredParts:n}}function he(e,t){const n=w(e),r=w(t);if(!n||!r)return!1;if(n===r||n.includes(r)||r.includes(n))return!0;const i=I(n),o=I(r);return!i||!o?!1:i===o||i.includes(o)||o.includes(i)}function Ne(e,t=pe(e)){const n=tr();if(!n.length)return[];let r=null,i=0;for(const o of n){const s=Jn(o,t);s>i&&(i=s,r=o)}return i>=120?(r==null?void 0:r.labels)||[]:[]}function Et(e,t,n,r){let i=null,o=0;const s=Xn(t,n,r);for(const a of e){const c=a.querySelector(".el-cascader-node__label, .ant-cascader-menu-item-content, .n-cascader-node__label, .arco-cascader-option-label"),l=d((c==null?void 0:c.textContent)||a.textContent||""),u=w(l);if(!u)continue;const p=I(u);let h=Zn(u,p,s);!h&&t.fullText&&(t.fullText.includes(u)?h=100+u.length:u.includes(t.fullText)?h=70+t.fullText.length:t.looseFullText.includes(p)&&(h=80+p.length)),h>o&&(o=h,i=a)}return o>=75?i:null}function Xn(e,t,n){const r=[],i=new Set,o=(s,a)=>{const c=w(s);!c||i.has(c)||(i.add(c),r.push({normalized:c,stripped:I(c),score:a}))};if(t.length){t[n]&&o(t[n],260);for(let s=n+1;s<t.length;s+=1)o(t[s],215-(s-n)*15)}e.structuredParts[n]&&o(e.structuredParts[n],235);for(let s=0;s<e.structuredParts.length;s+=1)s!==n&&o(e.structuredParts[s],180-Math.abs(s-n)*20);return e.fullText&&o(e.fullText,130),r}function Zn(e,t,n){let r=0;for(const i of n){let o=0;i.normalized===e?o=i.score+80:i.stripped&&i.stripped===t?o=i.score+68:i.normalized.includes(e)?o=i.score+40+e.length:e.includes(i.normalized)?o=i.score+28+i.normalized.length:i.stripped&&t&&i.stripped.includes(t)?o=i.score+24+t.length:i.stripped&&t&&t.includes(i.stripped)&&(o=i.score+20+i.stripped.length),o>r&&(r=o)}return r}function Jn(e,t){let n=0,r=0;for(let i=0;i<e.aliasesByLevel.length;i+=1){const o=Qn(e.aliasesByLevel[i],t.structuredParts[i]||"",t.fullText,t.looseFullText,i);o>0?(r+=1,n+=o):t.structuredParts[i]&&(n-=30)}return n+=r*18+e.labels.length*4,t.structuredParts.length>e.labels.length&&(n-=(t.structuredParts.length-e.labels.length)*10),n}function Qn(e,t,n,r,i){const o=[60,95,135,160][i]||160;let s=0;for(const a of e){let c=0;const l=I(a);t&&(t===a?c=Math.max(c,o+130+a.length):t.includes(a)||a.includes(t)?c=Math.max(c,o+95+Math.min(a.length,t.length)):l&&I(t)===l&&(c=Math.max(c,o+80+l.length))),n&&(n.includes(a)?c=Math.max(c,o+50+a.length):l&&r.includes(l)&&(c=Math.max(c,o+35+l.length))),c>s&&(s=c)}return s}function er(e){const t=d(e),n=w(t);if(!n)return[];const r=new Set([n]),i=I(n);i&&!Wn.has(t)&&r.add(i);const o={内蒙古自治区:"内蒙古",广西壮族自治区:"广西",西藏自治区:"西藏",宁夏回族自治区:"宁夏",新疆维吾尔自治区:"新疆",香港特别行政区:"香港",澳门特别行政区:"澳门"};return o[t]&&r.add(o[t]),Array.from(r).filter(Boolean)}function tr(){if(fe)return fe;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:[];return fe=nr(n),fe}function nr(e){const t=[],n=new Set,r=i=>{const o=i.map(a=>d(a)).filter(Boolean);if(!o.length)return;const s=o.join(">");n.has(s)||(n.add(s),t.push({labels:o,aliasesByLevel:o.map(a=>er(a))}))};for(const i of e)if(i!=null&&i.label&&(r([i.label]),!(!Array.isArray(i.children)||!i.children.length))){for(const o of i.children)if(o!=null&&o.label&&(r([i.label,o.label]),!(!Array.isArray(o.children)||!o.children.length)))for(const s of o.children)s!=null&&s.label&&r([i.label,o.label,s.label])}return t}function J(e,t){const n=ge(t);if(!n.length)return null;let r=null,i=0;for(const o of e){const s=M(o.value),a=M(o.label);for(const c of n){let l=0;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&&ye(s)===ye(c)||a&&ye(a)===ye(c))&&(l=80),l>i&&(i=l,r=o)}}return i>=80?r:null}function ge(e){if(Array.isArray(e))return e.flatMap(n=>ge(n));if(typeof e=="object"&&e){const n=e;return[n.label,n.value,n.text,n.answer,n.name].filter(r=>r!=null).map(r=>M(r)).filter(Boolean)}const t=M(e);return t?[t]:[]}function M(e){return String(e??"").replace(/\s+/g,"").replace(/[::,,。.、()()\-_/]/g,"").trim().toLowerCase()}function ye(e){return M(e).replace(/(请选择|选择|状态|情况|类型|方式|所属|是否)$/g,"")}const be=[".ant-select-item-option",".el-select-dropdown__item",".el-select-v2__option",".el-select-v2__option-item",".n-base-select-option",".ivu-select-item",".arco-select-option",".semi-select-option",".t-select-option",".van-picker-column__item",".van-action-sheet__item",".van-action-sheet__name",".van-cascader__option",".van-dropdown-item__option",".van-radio","[role='option']"].join(", "),rr=[".el-cascader-panel .el-cascader-menu",".ant-cascader-menu",".van-cascader__options",".n-cascader-menu",".arco-cascader-list"].join(", "),ir=[".el-cascader-node",".ant-cascader-menu-item",".van-cascader__option",".n-cascader-node",".arco-cascader-option"].join(", "),or=".van-picker__confirm, .van-picker__toolbar .van-picker__confirm";async function sr(e,t,n,r){const i=_t(t,r);return e instanceof HTMLSelectElement?ar(e,i):L(e)||n==="cascader"?cr(e,i):(W(e)||_(e)||n==="select"||n==="date",kt(e,i))}function xt(e){if(e instanceof HTMLSelectElement){const n=e.options[e.selectedIndex];return d((n==null?void 0:n.textContent)||e.value)}if(L(e)){const n=e.querySelector("input");if(n!=null&&n.value)return d(n.value);const r=e.querySelector(".el-cascader__tags-text, .el-cascader__label");return d((r==null?void 0:r.textContent)||"")}if(W(e)||_(e))return Ln(e);const t=e.querySelector("input, textarea");return d((t==null?void 0:t.value)||e.textContent||"")}async function ar(e,t){const n=Array.from(e.options).map(i=>({source:i,value:i.value,label:i.textContent})),r=J(n,t.searchValue);if((r==null?void 0:r.source)instanceof HTMLOptionElement){if(r.source.disabled)throw It(e),new Error("下拉目标选项已禁用");N(e,r.source.value),E(e);return}if(!me(e,t))throw new Error("原生下拉框中没有匹配到对应选项")}async function kt(e,t){const n=X(e)||e;if($e(n,t.searchValue))return;const r=new Set(te());try{if(!await lr(n)){if(me(n,t))return;throw new Error("自定义下拉框未能成功展开")}const o=await vr(n,r),s=await At(t.searchValue,o,!0,!0);if(s!=null&&s.source&&U(s.source))throw await ee(n),await yr(n),new Error("下拉目标选项已禁用");const a=await dr(t.searchValue,o,!0);if(!(a!=null&&a.source)){if(await ee(n),me(n,t))return;throw new Error("自定义下拉框展开后未找到匹配选项")}if(R(a.source),await b(120),Sr(),E(n),await b(120),$e(n,t.searchValue)||me(n,t)&&$e(n,t.searchValue))return;throw new Error("自定义下拉框点击选项后未成功回填")}finally{await ee(n),await b(80)}}async function cr(e,t){const n=e.closest(".el-cascader, .ant-cascader, .van-cascader, .n-cascader, .arco-cascader")||e;if(Ot(n,t.searchValue))return;ve(n)&&(await Lt(n),await b(120));let r="级联选择框匹配失败";try{if(await ur(n)){const o=await hr(t.searchValue);if(await b(180),await ee(n),await b(120),o&&Ot(n,t.searchValue)){E(n);return}}}catch(i){i instanceof Error&&i.message&&(r=i.message)}finally{await ee(n),await b(80)}throw await Lt(n),new Error(r)}function _t(e,t){var s;const n=(s=t==null?void 0:t.options)!=null&&s.length?J(t.options.map(a=>({value:String(a.value),label:a.label})),e):null,r=j(e),i=d(String((n==null?void 0:n.label)??r??"")),o=d(String((n==null?void 0:n.value)??(n==null?void 0:n.label)??r??""));return{searchValue:n?[e,n.label,n.value]:e,fillValue:o,displayValue:i}}async function lr(e){const t=He(e);for(const n of t)if(Dt(n),R(n),await b(160),Ft(e)||(Pt(n),await b(180),Ft(e)))return!0;return!1}async function ur(e){const t=[e,e.querySelector(".el-input__wrapper"),e.querySelector(".el-input"),e.querySelector(".van-field__control"),e.querySelector("input")].filter(n=>n instanceof HTMLElement);for(const n of t)if(n.scrollIntoView({block:"nearest",inline:"nearest"}),Dt(n),R(n),await b(180),Q().length||(Pt(n),await b(180),Q().length))return!0;return!1}async function dr(e,t,n=!1){return At(e,t,n,!1)}async function At(e,t,n=!1,r=!1){for(let i=0;i<12;i+=1){const o=J(Rt(t,n,r).map(s=>({source:s,value:fr(s),label:pr(s)})),e);if(o)return o;await b(100)}return null}function fr(e){return e.getAttribute("data-value")||e.getAttribute("data-name")||e.getAttribute("value")||e.getAttribute("name")||e.textContent||""}function pr(e){var t;return d(((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||"")}async function hr(e){const t=pe(e),n=Ne(e,t),r=qt(e),i=Math.max(n.length,r.length,1);if(!t.fullText&&!t.structuredParts.length&&!r.length)return!1;for(let o=0;o<i;o+=1){const s=Q();if(!s.length)return o>0;const a=s[Math.min(o,s.length-1)],c=Array.from(a.querySelectorAll(ir)),l=c.filter(h=>!U(h));let u=null;if(n.length||t.structuredParts.length){const h=c.filter(m=>U(m));h.length&&(u=Et(h,t,n,o))}if(!l.length){if(u)throw new Error("级联目标选项已禁用");return!1}let p=null;if((n.length||t.structuredParts.length)&&(p=Et(l,t,n,o)),!p&&!u&&r[o]){const h=J(c.filter(m=>U(m)).map(m=>{var A;return{source:m,value:m.getAttribute("data-value")||m.textContent,label:((A=m.querySelector(".el-cascader-node__label"))==null?void 0:A.textContent)||m.textContent}}),r[o]);u=(h==null?void 0:h.source)instanceof HTMLElement?h.source:null}if(!p&&u)throw new Error("级联目标选项已禁用");if(!p&&r[o]){const h=J(l.map(m=>{var A;return{source:m,value:m.getAttribute("data-value")||m.textContent,label:((A=m.querySelector(".el-cascader-node__label"))==null?void 0:A.textContent)||m.textContent}}),r[o]);p=(h==null?void 0:h.source)instanceof HTMLElement?h.source:null}if(!p)return!1;if(R(p),await b(220),!Q().length)return!0}return!Q().length||!0}function me(e,t){const n=mr(t)?t:_t(t),r=n.displayValue||j(t),i=n.fillValue||r;if(!r&&!i)return!1;const o=X(e)||e;if(_(o))return br(o,r,i);if(e instanceof HTMLSelectElement){let l=Array.from(e.options).find(u=>u.dataset.smartFillFallbackOption==="true");return l||(l=document.createElement("option"),l.dataset.smartFillFallbackOption="true",e.appendChild(l)),l.value=i,l.textContent=r||i,l.selected=!0,N(e,i),E(e),!0}const s=e.querySelector('input:not([type="hidden"])');if(!(s instanceof HTMLInputElement)||s.disabled)return!1;const a=s.readOnly,c=s.hasAttribute("readonly");try{return a&&(s.readOnly=!1,s.removeAttribute("readonly")),s.focus(),N(s,r),s.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0,data:r,inputType:"insertReplacementText"})),s.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),E(s),E(e),s.blur(),!0}catch{return!1}finally{a&&(s.readOnly=!0,c&&s.setAttribute("readonly",""))}}function gr(e){const t=pe(e),n=Ne(e,t);if(n.length)return n.join(" / ");const r=qt(e);return r.length?r.join(" / "):Pe(e)}function Ct(e){const t=e.querySelector("input");return t instanceof HTMLInputElement?t:null}function Tt(e){const t=Ct(e);if(t!=null&&t.value)return d(t.value);const n=e.querySelector(".el-cascader__tags-text, .el-cascader__label");return d((n==null?void 0:n.textContent)||"")}function ve(e){return!!w(Tt(e))}async function Lt(e){if(!ve(e))return;const t=e.querySelector(".el-input__wrapper, .el-input, .ant-select-selector");t&&(t.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0})),t.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0})),await b(80));const n=e.querySelector(".el-input__clear, .el-icon-circle-close, .ant-select-clear, .ant-cascader-picker-clear, .van-icon-clear");if(n&&(R(n),await b(180),!ve(e)))return;const r=Ct(e);if(r&&!r.disabled){const o=r.readOnly,s=r.hasAttribute("readonly");try{o&&(r.readOnly=!1,r.removeAttribute("readonly")),N(r,""),r.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0,inputType:"deleteContentBackward"})),r.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),E(r)}finally{o&&(r.readOnly=!0,s&&r.setAttribute("readonly",""))}await b(120)}const i=e.querySelector(".el-tag__close, .el-cascader__tags .el-icon-close");i&&ve(e)&&(R(i),await b(120))}async function yr(e){if(e instanceof HTMLSelectElement){It(e);return}if(_(e)){Mt(e);return}const t=e.querySelector(".el-input__wrapper, .el-input, .ant-select-selector, .ant-picker, .n-base-selection, .arco-select-view, .semi-select-selection");t&&(t.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0})),t.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0})),await b(80));const n=e.querySelector(".el-input__clear, .el-icon-circle-close, .ant-select-clear, .ant-picker-clear, .ant-cascader-picker-clear, .n-base-clear, .van-icon-clear");n&&(R(n),await b(180));const r=e.querySelector('input:not([type="hidden"])');r&&!r.disabled&&P(r,"");for(const i of e.querySelectorAll('input[type="hidden"]'))P(i,"");E(e)}function It(e){const t=Array.from(e.options).find(n=>n.value==="");t?N(e,t.value):(e.selectedIndex=-1,N(e,"")),E(e)}function br(e,t,n){Mt(e);const r=e.querySelector(".van-field__control"),i=Array.from(e.querySelectorAll('input[type="hidden"]')),o=Array.from(e.querySelectorAll('input:not([type="hidden"])'));r instanceof HTMLInputElement?P(r,t||n):r instanceof HTMLElement&&(r.textContent=t||n);for(const s of i)P(s,n);for(const s of o)r!==s&&P(s,t||n);return E(e),!0}function Mt(e){const t=e.querySelector(".van-field__control");t instanceof HTMLInputElement?P(t,""):t instanceof HTMLElement&&(t.textContent="");for(const n of e.querySelectorAll("input"))P(n,"")}function P(e,t){if(e.disabled)return;const n=e.readOnly,r=e.hasAttribute("readonly");try{n&&(e.readOnly=!1,e.removeAttribute("readonly")),N(e,t),e.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0,data:t,inputType:t?"insertReplacementText":"deleteContentBackward"})),e.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),E(e)}finally{n&&(e.readOnly=!0,r&&e.setAttribute("readonly",""))}}function mr(e){return typeof e=="object"&&e!=null&&"searchValue"in e&&"fillValue"in e&&"displayValue"in e}function He(e){return[e,e.querySelector(".van-field__control"),e.querySelector(".van-field__body"),e.querySelector(".el-select__wrapper"),e.querySelector(".el-select-v2__wrapper"),e.querySelector(".el-select__selection"),e.querySelector(".el-input__wrapper"),e.querySelector(".el-input"),e.querySelector("input"),e.querySelector("[role='combobox']"),e.querySelector("[aria-haspopup='listbox']"),e.querySelector(".ant-select-selector"),e.querySelector(".n-base-selection"),e.querySelector(".arco-select-view"),e.querySelector(".select-trigger"),e.querySelector(".select__wrapper")].filter(n=>n instanceof HTMLElement).filter((n,r,i)=>i.indexOf(n)===r)}function Rt(e,t,n=!1){return(e.length?e:te()).flatMap(o=>o.matches(be)?[o]:Array.from(o.querySelectorAll(be))).filter((o,s,a)=>a.indexOf(o)===s).filter(o=>n?t?!0:H(o):(t||H(o))&&!U(o))}function Q(){return Array.from(document.querySelectorAll(rr)).filter(H)}async function vr(e,t){for(let n=0;n<10;n+=1){const r=wr(e,t);if(r.length)return r;await b(80)}return te().filter(H)}function wr(e,t){const n=te(),r=n.filter(o=>!t.has(o));if(r.length)return r.sort((o,s)=>we(s)-we(o));const i=new Set(He(e).flatMap(o=>[o.getAttribute("aria-controls"),o.getAttribute("aria-owns")]).filter(o=>!!o));if(i.size){const o=n.filter(s=>i.has(s.id));if(o.length)return o}return n.filter(o=>H(o)&&(o.querySelector(be)||o.matches(be))).sort((o,s)=>we(s)-we(o)).slice(0,1)}function Ft(e){return Rt(te().filter(H),!1).length>0?!0:He(e).some(t=>t.getAttribute("aria-expanded")==="true"||t.classList.contains("is-focus")||t.classList.contains("is-focused"))}function Ot(e,t){const n=Tt(e),r=w(n);if(!r)return!1;const i=Pe(t),o=w(i);if(he(r,o))return!0;const s=pe(t),a=Ne(t,s),c=w(a.join(""));if(he(r,c))return!0;const l=w(gr(t));if(he(r,l))return!0;const u=w(s.structuredParts.join(""));return he(r,u)}function $e(e,t){const n=M(xt(e));if(!n)return!1;const r=ge(t);if(!r.length){const i=M(j(t));return i?n===i||n.includes(i)||i.includes(n):!1}return r.some(i=>{const o=M(i);return!!o&&(n===o||n.includes(o)||o.includes(n))})}function U(e){return e instanceof HTMLOptionElement?e.disabled:e.classList.contains("is-disabled")||e.classList.contains("ant-select-item-option-disabled")||e.classList.contains("van-cascader__option--disabled")||e.classList.contains("n-cascader-node--disabled")||e.classList.contains("arco-cascader-option-disabled")||e.classList.contains("arco-select-option-disabled")||e.getAttribute("aria-disabled")==="true"}function Sr(){const e=document.querySelector(or);e&&H(e)&&R(e)}async function ee(e){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 b(120)}function te(){return Array.from(document.querySelectorAll(Er()))}function we(e){const t=e.getBoundingClientRect(),n=Number.parseInt(window.getComputedStyle(e).zIndex||"0",10);return(Number.isNaN(n)?0:n)*10+t.width*t.height}function Er(){return[".el-select-dropdown",".el-cascader__dropdown",".el-cascader-panel",".el-select__popper",".el-select-v2__popper",".el-popper.el-cascader__dropdown",".el-popper.el-select__popper",".el-popper.el-select-v2__popper",".el-popper",".ant-select-dropdown",".ant-cascader-menus",".n-base-select-menu",".n-cascader-menu",".arco-select-dropdown",".arco-cascader-panel",".semi-select-dropdown",".t-select__dropdown",".van-popup",".van-action-sheet",".van-dropdown-item__content",".van-picker","[role='listbox']"].join(", ")}function j(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return d(String(e));if(Array.isArray(e))return e.map(t=>j(t)).filter(Boolean).join(" ");if(typeof e=="object"){const t=e;for(const n of["label","text","value","answer","name"]){const r=j(t[n]);if(r)return r}}return d(String(e))}function qt(e){const t=j(e);if(!t)return[];if(t.includes("/")||t.includes("、"))return t.split(/[//、]/).map(r=>r.trim()).filter(Boolean);const n=ge(e);return n.length?[d(n[0])]:[t]}function N(e,t){var i;const n=Object.getPrototypeOf(e),r=Object.getOwnPropertyDescriptor(n,"value");(i=r==null?void 0:r.set)==null||i.call(e,t)}function E(e){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}))}function R(e){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()}function Dt(e){e.focus({preventScroll:!0});const t=e instanceof HTMLInputElement?e:e.querySelector("input");t instanceof HTMLElement&&t.focus({preventScroll:!0})}function Pt(e){for(const t of[{key:"ArrowDown",code:"ArrowDown"},{key:"Enter",code:"Enter"},{key:" ",code:"Space"}])e.dispatchEvent(new KeyboardEvent("keydown",{...t,bubbles:!0,composed:!0})),e.dispatchEvent(new KeyboardEvent("keyup",{...t,bubbles:!0,composed:!0}))}function H(e){const t=window.getComputedStyle(e);if(t.display==="none"||t.visibility==="hidden"||Number(t.opacity)===0)return!1;const n=e.getBoundingClientRect();return n.width>0&&n.height>0}function b(e){return new Promise(t=>window.setTimeout(t,e))}const Nt=new Set(["select","cascader","date"]),ze={name:"ui-framework",match:e=>e.matches(nt)||it(e)||!kr(e)&&qe(e),getValue:e=>{var i,o;const t=e.element;if(!t)return;const n=K(t);if((n==null?void 0:n.kind)==="switch")return Y(t);if((n==null?void 0:n.kind)==="radioGroup")return Tr(t);if((n==null?void 0:n.kind)==="checkboxGroup")return Lr(t);const r=e.type||ce(t)||(n==null?void 0:n.type);return r&&Nt.has(r)?xt(t):n?((o=V(t))==null?void 0:o.value)||t.textContent||void 0:(i=V(t))==null?void 0:i.value},setValue:async(e,t)=>{const n=e.element;if(!n)return;const r=K(n);if((r==null?void 0:r.kind)==="switch"){_r(n,t);return}if((r==null?void 0:r.kind)==="radioGroup"){Cr(n,t);return}if((r==null?void 0:r.kind)==="checkboxGroup"){Ar(n,t);return}const i=e.type||ce(n)||(r==null?void 0:r.type);if(i&&Nt.has(i)||qe(n,i||void 0)){await sr(n,t,i||"select",e);return}const o=V(n);if(o){Ir(o,t);return}n.dispatchEvent(new Event("change",{bubbles:!0}))}},xr=ze;function kr(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement}function _r(e,t){Y(e)!==Mr(t)&&Se(e)}function Ar(e,t){var i;const n=new Set(Rr(t).map(F)),r=ot(e)||[];for(const o of ne(e)){const s=re(o.textContent||""),a=o.getAttribute("value")||((i=o.querySelector("input"))==null?void 0:i.value)||s,c=Y(o),l=n.has(F(String(a)))||n.has(F(s));c!==l&&Se(o)}if(!ne(e).length&&r.length)for(const o of r)(n.has(F(String(o.value)))||n.has(F(o.label)))&&Se(e)}function Cr(e,t){const n=F(String(t??"")),r=ne(e).find(i=>{var a;const o=re(i.textContent||""),s=i.getAttribute("value")||((a=i.querySelector("input"))==null?void 0:a.value)||o;return F(String(s))===n||F(o)===n});r&&Se(r)}function Tr(e){var n;const t=ne(e).find(r=>Y(r));if(t)return t.getAttribute("value")||((n=t.querySelector("input"))==null?void 0:n.value)||re(t.textContent||"")}function Lr(e){return ne(e).filter(t=>Y(t)).map(t=>{var n;return t.getAttribute("value")||((n=t.querySelector("input"))==null?void 0:n.value)||re(t.textContent||"")})}function ne(e){const t=K(e);return t!=null&&t.optionSelector?Array.from(e.querySelectorAll(t.optionSelector)):[]}function Ir(e,t){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}))}function Se(e){e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window}))}function Mr(e){return typeof e=="boolean"?e:["true","1","是","开启","启用","yes","y"].includes(String(e??"").trim().toLowerCase())}function Rr(e){return Array.isArray(e)?e.map(String):String(e??"").split(/[,,;;、]/).map(t=>t.trim()).filter(Boolean)}function F(e){return re(e).toLowerCase()}function re(e){return e.replace(/\s+/g," ").trim()}const Ht="https://uat.kingdeefin.com";class $t extends Error{constructor(n){super(n.message);f(this,"smartFillError");this.name="SmartFillException",this.smartFillError=n}}function x(e,t,n,r={}){return new $t({code:e,message:t,stage:n,...r})}function zt(e,t,n="RECOGNIZE_FAILED"){return e instanceof $t?e.smartFillError:{code:n,message:e instanceof Error?e.message:String(e||"智能录入异常"),stage:t,retryable:t==="recognize"}}function Ee(e="sf"){return`${e}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}class Fr{constructor(t){f(this,"seToken","");f(this,"baseURL",Ht);this.config=t}setAccessToken(t){this.seToken=t}async createSession(){if(!/^seKey-[A-Za-z0-9_-]{6,}$/.test(this.config.apiKey))throw x("API_KEY_INVALID","apiKey 格式不正确,应以 seKey- 开头。","setup");return{apiKey:this.config.apiKey,rulesVersion:"0.0.1"}}async getFormConfig(t){return t?this.request(`/sdk/forms/${encodeURIComponent(t)}`,{method:"GET"}):null}async resolveInputText(t){var o,s,a,c;const n=(o=t.images)!=null&&o.length?t.images:[],r=((s=t.text)==null?void 0:s.trim())||"";if(!n.length)return{text:r,usedOcr:!1};(a=t.onStatusChange)==null||a.call(t,"image_uploading");const i=await this.recognizeImages(n);return(c=t.onStatusChange)==null||c.call(t,"image_recognizing"),{text:i,usedOcr:!0}}async recognize(t){var s,a;const n=performance.now(),r=(s=t.text)==null?void 0:s.trim();(a=t.onStatusChange)==null||a.call(t,"recognizing");const i=await this.request("/fcloud/flow-product/agentChat/smartEntry",{method:"POST",body:JSON.stringify({formCode:t.formCode||"",configVersion:t.configVersion||"",formMsg:t.fields.map(({fingerprint:c,element:l,localRuleMode:u,scanToken:p,source:h,...m})=>m),userInputMsg:r||""})}),o=qr(i,t.fields,t.scanToken);return console.log("suggestions",o),{scanToken:t.scanToken,suggestions:o,trace:i.trace||{traceId:Ee("trace"),usedOcr:!!t.usedOcr,usedAi:!0,durationMs:Math.round(performance.now()-n)}}}async recognizeImages(t){const n=new FormData;t.forEach(o=>{n.append("image",o,o.name)});const r=await this.request("/fcloud/flow-product/agentChat/smartEntry/ocr",{method:"POST",body:n}),i=Pr(r);if(!i)throw x("RECOGNIZE_FAILED","图片识别未提取到文本内容。","recognize");return i}async request(t,n){const r=new AbortController,i=window.setTimeout(()=>r.abort(),this.config.requestTimeoutMs??3e4),o=new Headers(n.headers);n.body&&!(n.body instanceof FormData)&&!o.has("Content-Type")&&o.set("Content-Type","application/json"),o.set("x-trace-id",Ee("trace")),this.seToken&&o.set("seToken",`${this.seToken}`);try{const s=await fetch(`${this.baseURL}${t}`,{...n,headers:o,signal:r.signal});if(!s.ok)throw x(Nr(s.status),await s.text(),t.includes("session")?"setup":"recognize",{retryable:s.status>=500||s.status===429});return s.json()}catch(s){throw s instanceof DOMException&&s.name==="AbortError"?x("RECOGNIZE_TIMEOUT","识别请求超时,请稍后重试。","recognize",{retryable:!0}):s}finally{window.clearTimeout(i)}}}const Or=.95;function qr(e,t,n){var o;const r=new Map(t.map(s=>[s.fieldId,s]));return(((o=e.data)==null?void 0:o.fieldValues)||[]).filter(s=>!!(s!=null&&s.fieldId)).map(s=>{const a=r.get(s.fieldId);return{fieldId:s.fieldId,scanToken:n,label:s.label||(a==null?void 0:a.label)||s.fieldId,value:s.value,displayValue:s.value==null?"":String(s.value),confidence:Dr(s.confidence),source:s.source||"ai",warnings:s.warnings}})}function Dr(e){return typeof e!="number"||Number.isNaN(e)?Or:e<0?0:e>1?1:e}function Pr(e){var n;const t=typeof e.data=="string"?e.data:((n=e.data)==null?void 0:n.text)||e.text||"";return String(t||"").trim()}function Nr(e){return e===401?"TOKEN_EXPIRED":e===403?"API_KEY_FORBIDDEN":e===404?"FORM_CONFIG_NOT_FOUND":"RECOGNIZE_FAILED"}class Ke{constructor(){f(this,"handlers",new Map)}on(t,n){const r=this.handlers.get(t)??new Set;return r.add(n),this.handlers.set(t,r),()=>this.off(t,n)}off(t,n){var r;(r=this.handlers.get(t))==null||r.delete(n)}emit(t,n){var r;(r=this.handlers.get(t))==null||r.forEach(i=>i(n))}clear(){this.handlers.clear()}}class Hr{constructor(){f(this,"instances",new Set);f(this,"active",null)}add(t){this.instances.add(t)}activate(t){this.active&&this.active!==t&&this.active.close(),this.active=t}remove(t){this.instances.delete(t),this.active===t&&(this.active=null)}destroyAll(){this.instances.forEach(t=>t.destroy()),this.instances.clear(),this.active=null}}const $r=[/^(el|rc|ant|radix|headlessui|mui|chakra)-/i,/[0-9a-f]{8,}/i,/\d{6,}/];function C(e){const t=String(e||"").trim();return!t||$r.some(n=>n.test(t))?"":t}function ie(e){const t=(e.options||[]).slice(0,20).map(n=>`${n.label}:${String(n.value)}`).join("|");return G([e.fieldId,e.tagName,e.type,C(e.name),C(e.id),e.label,e.placeholder,e.section,t].join("::"))}function G(e){return String(e??"").replace(/\s+/g," ").trim().toLowerCase()}const Kt="smart-fill-highlight-style",zr=`
|
|
10
|
+
`,document.head.appendChild(e)}async function jn(e,t){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 D(120);for(const n of t.getTrackedDropdowns())n.isConnected&&(n.style.display="none",n.setAttribute("aria-hidden","true"))}function mt(e){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()}function vt(e){e.focus({preventScroll:!0});const t=e instanceof HTMLInputElement?e:e.querySelector("input");t instanceof HTMLElement&&t.focus({preventScroll:!0})}function wt(e){for(const t of[{key:"ArrowDown",code:"ArrowDown"},{key:"Enter",code:"Enter"},{key:" ",code:"Space"}])e.dispatchEvent(new KeyboardEvent("keydown",{...t,bubbles:!0,composed:!0})),e.dispatchEvent(new KeyboardEvent("keyup",{...t,bubbles:!0,composed:!0}))}function D(e){return new Promise(t=>window.setTimeout(t,e))}function Gn(){const e=new Map;e.set(window,{left:window.scrollX,top:window.scrollY});for(const t of document.querySelectorAll("*"))(t.scrollTop||t.scrollLeft)&&e.set(t,{left:t.scrollLeft,top:t.scrollTop});return()=>{for(const[t,n]of e)t===window?window.scrollTo(n.left,n.top):t instanceof HTMLElement&&(t.scrollLeft=n.left,t.scrollTop=n.top)}}function St(e){const t=window.getComputedStyle(e);if(t.display==="none"||t.visibility==="hidden"||Number(t.opacity)===0)return!1;const n=e.getBoundingClientRect();return n.width>0&&n.height>0}const Yn=/(维吾尔自治区|壮族自治区|回族自治区|特别行政区|自治区直辖县级行政区划|自治区|自治州|地区|盟|林区|街道|苏木|社区|省|市|区|县|旗|镇|乡)$/g,Wn=new Set(["市辖区","县","自治区直辖县级行政区划"]);let fe=null;function w(e){return String(e??"").replace(/\s+/g,"").replace(/[,,。.、/\\\-]/g,"").trim().toLowerCase()}function I(e){return w(e).replace(Yn,"")}function Pe(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number")return String(e).trim();if(Array.isArray(e))return e.map(t=>Pe(t)).filter(Boolean).join("");if(typeof e=="object"){const t=[],n=new Set,r=i=>{const o=d(String(i??""));!o||n.has(o)||(n.add(o),t.push(o))};for(const i of["province","provinceName","prov","city","cityName","district","districtName","area","areaName","county","countyName","region","regionName","address","detail","detailAddress","fullAddress","label","text","value","name","answer"])r(e[i]);return t.join("")}return d(String(e))}function pe(e){const t=[],n=[],r=s=>{const a=d(String(s??""));a&&t.push(a)},i=s=>{const a=w(s);a&&(n.push(a),r(s))};if(Array.isArray(e))for(const s of e)i(s);else if(typeof e=="object"&&e){for(const s of["province","provinceName","prov","city","cityName","district","districtName","area","areaName","county","countyName","region","regionName"])i(e[s]);for(const s of["address","detail","detailAddress","fullAddress","label","value","text","name","answer"])r(e[s])}else r(e);const o=w(t.join(""));return{fullText:o,looseFullText:I(o),structuredParts:n}}function he(e,t){const n=w(e),r=w(t);if(!n||!r)return!1;if(n===r||n.includes(r)||r.includes(n))return!0;const i=I(n),o=I(r);return!i||!o?!1:i===o||i.includes(o)||o.includes(i)}function Ne(e,t=pe(e)){const n=tr();if(!n.length)return[];let r=null,i=0;for(const o of n){const s=Jn(o,t);s>i&&(i=s,r=o)}return i>=120?(r==null?void 0:r.labels)||[]:[]}function Et(e,t,n,r){let i=null,o=0;const s=Xn(t,n,r);for(const a of e){const c=a.querySelector(".el-cascader-node__label, .ant-cascader-menu-item-content, .n-cascader-node__label, .arco-cascader-option-label"),l=d((c==null?void 0:c.textContent)||a.textContent||""),u=w(l);if(!u)continue;const p=I(u);let h=Zn(u,p,s);!h&&t.fullText&&(t.fullText.includes(u)?h=100+u.length:u.includes(t.fullText)?h=70+t.fullText.length:t.looseFullText.includes(p)&&(h=80+p.length)),h>o&&(o=h,i=a)}return o>=75?i:null}function Xn(e,t,n){const r=[],i=new Set,o=(s,a)=>{const c=w(s);!c||i.has(c)||(i.add(c),r.push({normalized:c,stripped:I(c),score:a}))};if(t.length){t[n]&&o(t[n],260);for(let s=n+1;s<t.length;s+=1)o(t[s],215-(s-n)*15)}e.structuredParts[n]&&o(e.structuredParts[n],235);for(let s=0;s<e.structuredParts.length;s+=1)s!==n&&o(e.structuredParts[s],180-Math.abs(s-n)*20);return e.fullText&&o(e.fullText,130),r}function Zn(e,t,n){let r=0;for(const i of n){let o=0;i.normalized===e?o=i.score+80:i.stripped&&i.stripped===t?o=i.score+68:i.normalized.includes(e)?o=i.score+40+e.length:e.includes(i.normalized)?o=i.score+28+i.normalized.length:i.stripped&&t&&i.stripped.includes(t)?o=i.score+24+t.length:i.stripped&&t&&t.includes(i.stripped)&&(o=i.score+20+i.stripped.length),o>r&&(r=o)}return r}function Jn(e,t){let n=0,r=0;for(let i=0;i<e.aliasesByLevel.length;i+=1){const o=Qn(e.aliasesByLevel[i],t.structuredParts[i]||"",t.fullText,t.looseFullText,i);o>0?(r+=1,n+=o):t.structuredParts[i]&&(n-=30)}return n+=r*18+e.labels.length*4,t.structuredParts.length>e.labels.length&&(n-=(t.structuredParts.length-e.labels.length)*10),n}function Qn(e,t,n,r,i){const o=[60,95,135,160][i]||160;let s=0;for(const a of e){let c=0;const l=I(a);t&&(t===a?c=Math.max(c,o+130+a.length):t.includes(a)||a.includes(t)?c=Math.max(c,o+95+Math.min(a.length,t.length)):l&&I(t)===l&&(c=Math.max(c,o+80+l.length))),n&&(n.includes(a)?c=Math.max(c,o+50+a.length):l&&r.includes(l)&&(c=Math.max(c,o+35+l.length))),c>s&&(s=c)}return s}function er(e){const t=d(e),n=w(t);if(!n)return[];const r=new Set([n]),i=I(n);i&&!Wn.has(t)&&r.add(i);const o={内蒙古自治区:"内蒙古",广西壮族自治区:"广西",西藏自治区:"西藏",宁夏回族自治区:"宁夏",新疆维吾尔自治区:"新疆",香港特别行政区:"香港",澳门特别行政区:"澳门"};return o[t]&&r.add(o[t]),Array.from(r).filter(Boolean)}function tr(){if(fe)return fe;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:[];return fe=nr(n),fe}function nr(e){const t=[],n=new Set,r=i=>{const o=i.map(a=>d(a)).filter(Boolean);if(!o.length)return;const s=o.join(">");n.has(s)||(n.add(s),t.push({labels:o,aliasesByLevel:o.map(a=>er(a))}))};for(const i of e)if(i!=null&&i.label&&(r([i.label]),!(!Array.isArray(i.children)||!i.children.length))){for(const o of i.children)if(o!=null&&o.label&&(r([i.label,o.label]),!(!Array.isArray(o.children)||!o.children.length)))for(const s of o.children)s!=null&&s.label&&r([i.label,o.label,s.label])}return t}function J(e,t){const n=ge(t);if(!n.length)return null;let r=null,i=0;for(const o of e){const s=M(o.value),a=M(o.label);for(const c of n){let l=0;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&&ye(s)===ye(c)||a&&ye(a)===ye(c))&&(l=80),l>i&&(i=l,r=o)}}return i>=80?r:null}function ge(e){if(Array.isArray(e))return e.flatMap(n=>ge(n));if(typeof e=="object"&&e){const n=e;return[n.label,n.value,n.text,n.answer,n.name].filter(r=>r!=null).map(r=>M(r)).filter(Boolean)}const t=M(e);return t?[t]:[]}function M(e){return String(e??"").replace(/\s+/g,"").replace(/[::,,。.、()()\-_/]/g,"").trim().toLowerCase()}function ye(e){return M(e).replace(/(请选择|选择|状态|情况|类型|方式|所属|是否)$/g,"")}const be=[".ant-select-item-option",".el-select-dropdown__item",".el-select-v2__option",".el-select-v2__option-item",".n-base-select-option",".ivu-select-item",".arco-select-option",".semi-select-option",".t-select-option",".van-picker-column__item",".van-action-sheet__item",".van-action-sheet__name",".van-cascader__option",".van-dropdown-item__option",".van-radio","[role='option']"].join(", "),rr=[".el-cascader-panel .el-cascader-menu",".ant-cascader-menu",".van-cascader__options",".n-cascader-menu",".arco-cascader-list"].join(", "),ir=[".el-cascader-node",".ant-cascader-menu-item",".van-cascader__option",".n-cascader-node",".arco-cascader-option"].join(", "),or=".van-picker__confirm, .van-picker__toolbar .van-picker__confirm";async function sr(e,t,n,r){const i=_t(t,r);return e instanceof HTMLSelectElement?ar(e,i):L(e)||n==="cascader"?cr(e,i):(W(e)||_(e)||n==="select"||n==="date",kt(e,i))}function xt(e){if(e instanceof HTMLSelectElement){const n=e.options[e.selectedIndex];return d((n==null?void 0:n.textContent)||e.value)}if(L(e)){const n=e.querySelector("input");if(n!=null&&n.value)return d(n.value);const r=e.querySelector(".el-cascader__tags-text, .el-cascader__label");return d((r==null?void 0:r.textContent)||"")}if(W(e)||_(e))return Ln(e);const t=e.querySelector("input, textarea");return d((t==null?void 0:t.value)||e.textContent||"")}async function ar(e,t){const n=Array.from(e.options).map(i=>({source:i,value:i.value,label:i.textContent})),r=J(n,t.searchValue);if((r==null?void 0:r.source)instanceof HTMLOptionElement){if(r.source.disabled)throw It(e),new Error("下拉目标选项已禁用");N(e,r.source.value),E(e);return}if(!me(e,t))throw new Error("原生下拉框中没有匹配到对应选项")}async function kt(e,t){const n=X(e)||e;if($e(n,t.searchValue))return;const r=new Set(te());try{if(!await lr(n)){if(me(n,t))return;throw new Error("自定义下拉框未能成功展开")}const o=await vr(n,r),s=await At(t.searchValue,o,!0,!0);if(s!=null&&s.source&&U(s.source))throw await ee(n),await yr(n),new Error("下拉目标选项已禁用");const a=await dr(t.searchValue,o,!0);if(!(a!=null&&a.source)){if(await ee(n),me(n,t))return;throw new Error("自定义下拉框展开后未找到匹配选项")}if(R(a.source),await b(120),Sr(),E(n),await b(120),$e(n,t.searchValue)||me(n,t)&&$e(n,t.searchValue))return;throw new Error("自定义下拉框点击选项后未成功回填")}finally{await ee(n),await b(80)}}async function cr(e,t){const n=e.closest(".el-cascader, .ant-cascader, .van-cascader, .n-cascader, .arco-cascader")||e;if(Ot(n,t.searchValue))return;ve(n)&&(await Lt(n),await b(120));let r="级联选择框匹配失败";try{if(await ur(n)){const o=await hr(t.searchValue);if(await b(180),await ee(n),await b(120),o&&Ot(n,t.searchValue)){E(n);return}}}catch(i){i instanceof Error&&i.message&&(r=i.message)}finally{await ee(n),await b(80)}throw await Lt(n),new Error(r)}function _t(e,t){var s;const n=(s=t==null?void 0:t.options)!=null&&s.length?J(t.options.map(a=>({value:String(a.value),label:a.label})),e):null,r=j(e),i=d(String((n==null?void 0:n.label)??r??"")),o=d(String((n==null?void 0:n.value)??(n==null?void 0:n.label)??r??""));return{searchValue:n?[e,n.label,n.value]:e,fillValue:o,displayValue:i}}async function lr(e){const t=He(e);for(const n of t)if(Dt(n),R(n),await b(160),Ft(e)||(Pt(n),await b(180),Ft(e)))return!0;return!1}async function ur(e){const t=[e,e.querySelector(".el-input__wrapper"),e.querySelector(".el-input"),e.querySelector(".van-field__control"),e.querySelector("input")].filter(n=>n instanceof HTMLElement);for(const n of t)if(n.scrollIntoView({block:"nearest",inline:"nearest"}),Dt(n),R(n),await b(180),Q().length||(Pt(n),await b(180),Q().length))return!0;return!1}async function dr(e,t,n=!1){return At(e,t,n,!1)}async function At(e,t,n=!1,r=!1){for(let i=0;i<12;i+=1){const o=J(Rt(t,n,r).map(s=>({source:s,value:fr(s),label:pr(s)})),e);if(o)return o;await b(100)}return null}function fr(e){return e.getAttribute("data-value")||e.getAttribute("data-name")||e.getAttribute("value")||e.getAttribute("name")||e.textContent||""}function pr(e){var t;return d(((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||"")}async function hr(e){const t=pe(e),n=Ne(e,t),r=qt(e),i=Math.max(n.length,r.length,1);if(!t.fullText&&!t.structuredParts.length&&!r.length)return!1;for(let o=0;o<i;o+=1){const s=Q();if(!s.length)return o>0;const a=s[Math.min(o,s.length-1)],c=Array.from(a.querySelectorAll(ir)),l=c.filter(h=>!U(h));let u=null;if(n.length||t.structuredParts.length){const h=c.filter(m=>U(m));h.length&&(u=Et(h,t,n,o))}if(!l.length){if(u)throw new Error("级联目标选项已禁用");return!1}let p=null;if((n.length||t.structuredParts.length)&&(p=Et(l,t,n,o)),!p&&!u&&r[o]){const h=J(c.filter(m=>U(m)).map(m=>{var A;return{source:m,value:m.getAttribute("data-value")||m.textContent,label:((A=m.querySelector(".el-cascader-node__label"))==null?void 0:A.textContent)||m.textContent}}),r[o]);u=(h==null?void 0:h.source)instanceof HTMLElement?h.source:null}if(!p&&u)throw new Error("级联目标选项已禁用");if(!p&&r[o]){const h=J(l.map(m=>{var A;return{source:m,value:m.getAttribute("data-value")||m.textContent,label:((A=m.querySelector(".el-cascader-node__label"))==null?void 0:A.textContent)||m.textContent}}),r[o]);p=(h==null?void 0:h.source)instanceof HTMLElement?h.source:null}if(!p)return!1;if(R(p),await b(220),!Q().length)return!0}return!Q().length||!0}function me(e,t){const n=mr(t)?t:_t(t),r=n.displayValue||j(t),i=n.fillValue||r;if(!r&&!i)return!1;const o=X(e)||e;if(_(o))return br(o,r,i);if(e instanceof HTMLSelectElement){let l=Array.from(e.options).find(u=>u.dataset.smartFillFallbackOption==="true");return l||(l=document.createElement("option"),l.dataset.smartFillFallbackOption="true",e.appendChild(l)),l.value=i,l.textContent=r||i,l.selected=!0,N(e,i),E(e),!0}const s=e.querySelector('input:not([type="hidden"])');if(!(s instanceof HTMLInputElement)||s.disabled)return!1;const a=s.readOnly,c=s.hasAttribute("readonly");try{return a&&(s.readOnly=!1,s.removeAttribute("readonly")),s.focus(),N(s,r),s.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0,data:r,inputType:"insertReplacementText"})),s.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),E(s),E(e),s.blur(),!0}catch{return!1}finally{a&&(s.readOnly=!0,c&&s.setAttribute("readonly",""))}}function gr(e){const t=pe(e),n=Ne(e,t);if(n.length)return n.join(" / ");const r=qt(e);return r.length?r.join(" / "):Pe(e)}function Ct(e){const t=e.querySelector("input");return t instanceof HTMLInputElement?t:null}function Tt(e){const t=Ct(e);if(t!=null&&t.value)return d(t.value);const n=e.querySelector(".el-cascader__tags-text, .el-cascader__label");return d((n==null?void 0:n.textContent)||"")}function ve(e){return!!w(Tt(e))}async function Lt(e){if(!ve(e))return;const t=e.querySelector(".el-input__wrapper, .el-input, .ant-select-selector");t&&(t.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0})),t.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0})),await b(80));const n=e.querySelector(".el-input__clear, .el-icon-circle-close, .ant-select-clear, .ant-cascader-picker-clear, .van-icon-clear");if(n&&(R(n),await b(180),!ve(e)))return;const r=Ct(e);if(r&&!r.disabled){const o=r.readOnly,s=r.hasAttribute("readonly");try{o&&(r.readOnly=!1,r.removeAttribute("readonly")),N(r,""),r.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0,inputType:"deleteContentBackward"})),r.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),E(r)}finally{o&&(r.readOnly=!0,s&&r.setAttribute("readonly",""))}await b(120)}const i=e.querySelector(".el-tag__close, .el-cascader__tags .el-icon-close");i&&ve(e)&&(R(i),await b(120))}async function yr(e){if(e instanceof HTMLSelectElement){It(e);return}if(_(e)){Mt(e);return}const t=e.querySelector(".el-input__wrapper, .el-input, .ant-select-selector, .ant-picker, .n-base-selection, .arco-select-view, .semi-select-selection");t&&(t.dispatchEvent(new MouseEvent("mouseenter",{bubbles:!0})),t.dispatchEvent(new MouseEvent("mouseover",{bubbles:!0})),await b(80));const n=e.querySelector(".el-input__clear, .el-icon-circle-close, .ant-select-clear, .ant-picker-clear, .ant-cascader-picker-clear, .n-base-clear, .van-icon-clear");n&&(R(n),await b(180));const r=e.querySelector('input:not([type="hidden"])');r&&!r.disabled&&P(r,"");for(const i of e.querySelectorAll('input[type="hidden"]'))P(i,"");E(e)}function It(e){const t=Array.from(e.options).find(n=>n.value==="");t?N(e,t.value):(e.selectedIndex=-1,N(e,"")),E(e)}function br(e,t,n){Mt(e);const r=e.querySelector(".van-field__control"),i=Array.from(e.querySelectorAll('input[type="hidden"]')),o=Array.from(e.querySelectorAll('input:not([type="hidden"])'));r instanceof HTMLInputElement?P(r,t||n):r instanceof HTMLElement&&(r.textContent=t||n);for(const s of i)P(s,n);for(const s of o)r!==s&&P(s,t||n);return E(e),!0}function Mt(e){const t=e.querySelector(".van-field__control");t instanceof HTMLInputElement?P(t,""):t instanceof HTMLElement&&(t.textContent="");for(const n of e.querySelectorAll("input"))P(n,"")}function P(e,t){if(e.disabled)return;const n=e.readOnly,r=e.hasAttribute("readonly");try{n&&(e.readOnly=!1,e.removeAttribute("readonly")),N(e,t),e.dispatchEvent(new InputEvent("input",{bubbles:!0,composed:!0,data:t,inputType:t?"insertReplacementText":"deleteContentBackward"})),e.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),E(e)}finally{n&&(e.readOnly=!0,r&&e.setAttribute("readonly",""))}}function mr(e){return typeof e=="object"&&e!=null&&"searchValue"in e&&"fillValue"in e&&"displayValue"in e}function He(e){return[e,e.querySelector(".van-field__control"),e.querySelector(".van-field__body"),e.querySelector(".el-select__wrapper"),e.querySelector(".el-select-v2__wrapper"),e.querySelector(".el-select__selection"),e.querySelector(".el-input__wrapper"),e.querySelector(".el-input"),e.querySelector("input"),e.querySelector("[role='combobox']"),e.querySelector("[aria-haspopup='listbox']"),e.querySelector(".ant-select-selector"),e.querySelector(".n-base-selection"),e.querySelector(".arco-select-view"),e.querySelector(".select-trigger"),e.querySelector(".select__wrapper")].filter(n=>n instanceof HTMLElement).filter((n,r,i)=>i.indexOf(n)===r)}function Rt(e,t,n=!1){return(e.length?e:te()).flatMap(o=>o.matches(be)?[o]:Array.from(o.querySelectorAll(be))).filter((o,s,a)=>a.indexOf(o)===s).filter(o=>n?t?!0:H(o):(t||H(o))&&!U(o))}function Q(){return Array.from(document.querySelectorAll(rr)).filter(H)}async function vr(e,t){for(let n=0;n<10;n+=1){const r=wr(e,t);if(r.length)return r;await b(80)}return te().filter(H)}function wr(e,t){const n=te(),r=n.filter(o=>!t.has(o));if(r.length)return r.sort((o,s)=>we(s)-we(o));const i=new Set(He(e).flatMap(o=>[o.getAttribute("aria-controls"),o.getAttribute("aria-owns")]).filter(o=>!!o));if(i.size){const o=n.filter(s=>i.has(s.id));if(o.length)return o}return n.filter(o=>H(o)&&(o.querySelector(be)||o.matches(be))).sort((o,s)=>we(s)-we(o)).slice(0,1)}function Ft(e){return Rt(te().filter(H),!1).length>0?!0:He(e).some(t=>t.getAttribute("aria-expanded")==="true"||t.classList.contains("is-focus")||t.classList.contains("is-focused"))}function Ot(e,t){const n=Tt(e),r=w(n);if(!r)return!1;const i=Pe(t),o=w(i);if(he(r,o))return!0;const s=pe(t),a=Ne(t,s),c=w(a.join(""));if(he(r,c))return!0;const l=w(gr(t));if(he(r,l))return!0;const u=w(s.structuredParts.join(""));return he(r,u)}function $e(e,t){const n=M(xt(e));if(!n)return!1;const r=ge(t);if(!r.length){const i=M(j(t));return i?n===i||n.includes(i)||i.includes(n):!1}return r.some(i=>{const o=M(i);return!!o&&(n===o||n.includes(o)||o.includes(n))})}function U(e){return e instanceof HTMLOptionElement?e.disabled:e.classList.contains("is-disabled")||e.classList.contains("ant-select-item-option-disabled")||e.classList.contains("van-cascader__option--disabled")||e.classList.contains("n-cascader-node--disabled")||e.classList.contains("arco-cascader-option-disabled")||e.classList.contains("arco-select-option-disabled")||e.getAttribute("aria-disabled")==="true"}function Sr(){const e=document.querySelector(or);e&&H(e)&&R(e)}async function ee(e){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 b(120)}function te(){return Array.from(document.querySelectorAll(Er()))}function we(e){const t=e.getBoundingClientRect(),n=Number.parseInt(window.getComputedStyle(e).zIndex||"0",10);return(Number.isNaN(n)?0:n)*10+t.width*t.height}function Er(){return[".el-select-dropdown",".el-cascader__dropdown",".el-cascader-panel",".el-select__popper",".el-select-v2__popper",".el-popper.el-cascader__dropdown",".el-popper.el-select__popper",".el-popper.el-select-v2__popper",".el-popper",".ant-select-dropdown",".ant-cascader-menus",".n-base-select-menu",".n-cascader-menu",".arco-select-dropdown",".arco-cascader-panel",".semi-select-dropdown",".t-select__dropdown",".van-popup",".van-action-sheet",".van-dropdown-item__content",".van-picker","[role='listbox']"].join(", ")}function j(e){if(e==null)return"";if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return d(String(e));if(Array.isArray(e))return e.map(t=>j(t)).filter(Boolean).join(" ");if(typeof e=="object"){const t=e;for(const n of["label","text","value","answer","name"]){const r=j(t[n]);if(r)return r}}return d(String(e))}function qt(e){const t=j(e);if(!t)return[];if(t.includes("/")||t.includes("、"))return t.split(/[//、]/).map(r=>r.trim()).filter(Boolean);const n=ge(e);return n.length?[d(n[0])]:[t]}function N(e,t){var i;const n=Object.getPrototypeOf(e),r=Object.getOwnPropertyDescriptor(n,"value");(i=r==null?void 0:r.set)==null||i.call(e,t)}function E(e){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}))}function R(e){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()}function Dt(e){e.focus({preventScroll:!0});const t=e instanceof HTMLInputElement?e:e.querySelector("input");t instanceof HTMLElement&&t.focus({preventScroll:!0})}function Pt(e){for(const t of[{key:"ArrowDown",code:"ArrowDown"},{key:"Enter",code:"Enter"},{key:" ",code:"Space"}])e.dispatchEvent(new KeyboardEvent("keydown",{...t,bubbles:!0,composed:!0})),e.dispatchEvent(new KeyboardEvent("keyup",{...t,bubbles:!0,composed:!0}))}function H(e){const t=window.getComputedStyle(e);if(t.display==="none"||t.visibility==="hidden"||Number(t.opacity)===0)return!1;const n=e.getBoundingClientRect();return n.width>0&&n.height>0}function b(e){return new Promise(t=>window.setTimeout(t,e))}const Nt=new Set(["select","cascader","date"]),ze={name:"ui-framework",match:e=>e.matches(nt)||it(e)||!kr(e)&&qe(e),getValue:e=>{var i,o;const t=e.element;if(!t)return;const n=K(t);if((n==null?void 0:n.kind)==="switch")return Y(t);if((n==null?void 0:n.kind)==="radioGroup")return Tr(t);if((n==null?void 0:n.kind)==="checkboxGroup")return Lr(t);const r=e.type||ce(t)||(n==null?void 0:n.type);return r&&Nt.has(r)?xt(t):n?((o=V(t))==null?void 0:o.value)||t.textContent||void 0:(i=V(t))==null?void 0:i.value},setValue:async(e,t)=>{const n=e.element;if(!n)return;const r=K(n);if((r==null?void 0:r.kind)==="switch"){_r(n,t);return}if((r==null?void 0:r.kind)==="radioGroup"){Cr(n,t);return}if((r==null?void 0:r.kind)==="checkboxGroup"){Ar(n,t);return}const i=e.type||ce(n)||(r==null?void 0:r.type);if(i&&Nt.has(i)||qe(n,i||void 0)){await sr(n,t,i||"select",e);return}const o=V(n);if(o){Ir(o,t);return}n.dispatchEvent(new Event("change",{bubbles:!0}))}},xr=ze;function kr(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement}function _r(e,t){Y(e)!==Mr(t)&&Se(e)}function Ar(e,t){var i;const n=new Set(Rr(t).map(F)),r=ot(e)||[];for(const o of ne(e)){const s=re(o.textContent||""),a=o.getAttribute("value")||((i=o.querySelector("input"))==null?void 0:i.value)||s,c=Y(o),l=n.has(F(String(a)))||n.has(F(s));c!==l&&Se(o)}if(!ne(e).length&&r.length)for(const o of r)(n.has(F(String(o.value)))||n.has(F(o.label)))&&Se(e)}function Cr(e,t){const n=F(String(t??"")),r=ne(e).find(i=>{var a;const o=re(i.textContent||""),s=i.getAttribute("value")||((a=i.querySelector("input"))==null?void 0:a.value)||o;return F(String(s))===n||F(o)===n});r&&Se(r)}function Tr(e){var n;const t=ne(e).find(r=>Y(r));if(t)return t.getAttribute("value")||((n=t.querySelector("input"))==null?void 0:n.value)||re(t.textContent||"")}function Lr(e){return ne(e).filter(t=>Y(t)).map(t=>{var n;return t.getAttribute("value")||((n=t.querySelector("input"))==null?void 0:n.value)||re(t.textContent||"")})}function ne(e){const t=K(e);return t!=null&&t.optionSelector?Array.from(e.querySelectorAll(t.optionSelector)):[]}function Ir(e,t){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}))}function Se(e){e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window}))}function Mr(e){return typeof e=="boolean"?e:["true","1","是","开启","启用","yes","y"].includes(String(e??"").trim().toLowerCase())}function Rr(e){return Array.isArray(e)?e.map(String):String(e??"").split(/[,,;;、]/).map(t=>t.trim()).filter(Boolean)}function F(e){return re(e).toLowerCase()}function re(e){return e.replace(/\s+/g," ").trim()}const Ht="https://www.kingdeefin.com";class $t extends Error{constructor(n){super(n.message);f(this,"smartFillError");this.name="SmartFillException",this.smartFillError=n}}function x(e,t,n,r={}){return new $t({code:e,message:t,stage:n,...r})}function zt(e,t,n="RECOGNIZE_FAILED"){return e instanceof $t?e.smartFillError:{code:n,message:e instanceof Error?e.message:String(e||"智能录入异常"),stage:t,retryable:t==="recognize"}}function Ee(e="sf"){return`${e}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}class Fr{constructor(t){f(this,"seToken","");f(this,"baseURL",Ht);this.config=t}setAccessToken(t){this.seToken=t}async createSession(){if(!/^seKey-[A-Za-z0-9_-]{6,}$/.test(this.config.apiKey))throw x("API_KEY_INVALID","apiKey 格式不正确,应以 seKey- 开头。","setup");return{apiKey:this.config.apiKey,rulesVersion:"0.0.1"}}async getFormConfig(t){return t?this.request(`/sdk/forms/${encodeURIComponent(t)}`,{method:"GET"}):null}async resolveInputText(t){var o,s,a,c;const n=(o=t.images)!=null&&o.length?t.images:[],r=((s=t.text)==null?void 0:s.trim())||"";if(!n.length)return{text:r,usedOcr:!1};(a=t.onStatusChange)==null||a.call(t,"image_uploading");const i=await this.recognizeImages(n);return(c=t.onStatusChange)==null||c.call(t,"image_recognizing"),{text:i,usedOcr:!0}}async recognize(t){var s,a;const n=performance.now(),r=(s=t.text)==null?void 0:s.trim();(a=t.onStatusChange)==null||a.call(t,"recognizing");const i=await this.request("/fcloud/flow-product/agentChat/smartEntry",{method:"POST",body:JSON.stringify({formCode:t.formCode||"",configVersion:t.configVersion||"",formMsg:t.fields.map(({fingerprint:c,element:l,localRuleMode:u,scanToken:p,source:h,...m})=>m),userInputMsg:r||""})}),o=qr(i,t.fields,t.scanToken);return console.log("suggestions",o),{scanToken:t.scanToken,suggestions:o,trace:i.trace||{traceId:Ee("trace"),usedOcr:!!t.usedOcr,usedAi:!0,durationMs:Math.round(performance.now()-n)}}}async recognizeImages(t){const n=new FormData;t.forEach(o=>{n.append("image",o,o.name)});const r=await this.request("/fcloud/flow-product/agentChat/smartEntry/ocr",{method:"POST",body:n}),i=Pr(r);if(!i)throw x("RECOGNIZE_FAILED","图片识别未提取到文本内容。","recognize");return i}async request(t,n){const r=new AbortController,i=window.setTimeout(()=>r.abort(),this.config.requestTimeoutMs??3e4),o=new Headers(n.headers);n.body&&!(n.body instanceof FormData)&&!o.has("Content-Type")&&o.set("Content-Type","application/json"),o.set("x-trace-id",Ee("trace")),this.seToken&&o.set("seToken",`${this.seToken}`);try{const s=await fetch(`${this.baseURL}${t}`,{...n,headers:o,signal:r.signal});if(!s.ok)throw x(Nr(s.status),await s.text(),t.includes("session")?"setup":"recognize",{retryable:s.status>=500||s.status===429});return s.json()}catch(s){throw s instanceof DOMException&&s.name==="AbortError"?x("RECOGNIZE_TIMEOUT","识别请求超时,请稍后重试。","recognize",{retryable:!0}):s}finally{window.clearTimeout(i)}}}const Or=.95;function qr(e,t,n){var o;const r=new Map(t.map(s=>[s.fieldId,s]));return(((o=e.data)==null?void 0:o.fieldValues)||[]).filter(s=>!!(s!=null&&s.fieldId)).map(s=>{const a=r.get(s.fieldId);return{fieldId:s.fieldId,scanToken:n,label:s.label||(a==null?void 0:a.label)||s.fieldId,value:s.value,displayValue:s.value==null?"":String(s.value),confidence:Dr(s.confidence),source:s.source||"ai",warnings:s.warnings}})}function Dr(e){return typeof e!="number"||Number.isNaN(e)?Or:e<0?0:e>1?1:e}function Pr(e){var n;const t=typeof e.data=="string"?e.data:((n=e.data)==null?void 0:n.text)||e.text||"";return String(t||"").trim()}function Nr(e){return e===401?"TOKEN_EXPIRED":e===403?"API_KEY_FORBIDDEN":e===404?"FORM_CONFIG_NOT_FOUND":"RECOGNIZE_FAILED"}class Ke{constructor(){f(this,"handlers",new Map)}on(t,n){const r=this.handlers.get(t)??new Set;return r.add(n),this.handlers.set(t,r),()=>this.off(t,n)}off(t,n){var r;(r=this.handlers.get(t))==null||r.delete(n)}emit(t,n){var r;(r=this.handlers.get(t))==null||r.forEach(i=>i(n))}clear(){this.handlers.clear()}}class Hr{constructor(){f(this,"instances",new Set);f(this,"active",null)}add(t){this.instances.add(t)}activate(t){this.active&&this.active!==t&&this.active.close(),this.active=t}remove(t){this.instances.delete(t),this.active===t&&(this.active=null)}destroyAll(){this.instances.forEach(t=>t.destroy()),this.instances.clear(),this.active=null}}const $r=[/^(el|rc|ant|radix|headlessui|mui|chakra)-/i,/[0-9a-f]{8,}/i,/\d{6,}/];function C(e){const t=String(e||"").trim();return!t||$r.some(n=>n.test(t))?"":t}function ie(e){const t=(e.options||[]).slice(0,20).map(n=>`${n.label}:${String(n.value)}`).join("|");return G([e.fieldId,e.tagName,e.type,C(e.name),C(e.id),e.label,e.placeholder,e.section,t].join("::"))}function G(e){return String(e??"").replace(/\s+/g," ").trim().toLowerCase()}const Kt="smart-fill-highlight-style",zr=`
|
|
11
11
|
[data-smart-fill-highlighted="true"] {
|
|
12
12
|
background: #eaf3ff !important;
|
|
13
13
|
box-shadow: 0 0 0 1px #91caff inset !important;
|