@kevisual/kv-login 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kv-login.es.js +1587 -1164
- package/dist/kv-login.umd.js +25 -25
- package/index.html +1 -1
- package/package.json +7 -4
- package/readme.md +5 -0
- package/src/modules/login-handle.ts +5 -3
- package/src/modules/mitt.ts +134 -0
- package/src/pages/kv-login.ts +6 -2
- package/types/index.d.ts +127 -0
package/dist/kv-login.es.js
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
const
|
|
2
|
-
\f\r]`,
|
|
3
|
-
\f\r"'\`<>=]|("|')|))|$)`, "g"),
|
|
4
|
-
function
|
|
5
|
-
if (!
|
|
6
|
-
return
|
|
7
|
-
}
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
let o, s = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", i =
|
|
11
|
-
for (let c = 0; c <
|
|
12
|
-
const a =
|
|
1
|
+
const Je = globalThis, ue = Je.trustedTypes, tt = ue ? ue.createPolicy("lit-html", { createHTML: (n) => n }) : void 0, Vt = "$lit$", j = `lit$${Math.random().toFixed(9).slice(2)}$`, Ot = "?" + j, pn = `<${Ot}>`, W = document, re = () => W.createComment(""), oe = (n) => n === null || typeof n != "object" && typeof n != "function", Qe = Array.isArray, wn = (n) => Qe(n) || typeof n?.[Symbol.iterator] == "function", ve = `[
|
|
2
|
+
\f\r]`, te = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, nt = /-->/g, rt = />/g, V = RegExp(`>|${ve}(?:([^\\s"'>=/]+)(${ve}*=${ve}*(?:[^
|
|
3
|
+
\f\r"'\`<>=]|("|')|))|$)`, "g"), ot = /'/g, st = /"/g, Wt = /^(?:script|style|textarea|title)$/i, yn = (n) => (e, ...t) => ({ _$litType$: n, strings: e, values: t }), I = yn(1), X = Symbol.for("lit-noChange"), B = Symbol.for("lit-nothing"), it = /* @__PURE__ */ new WeakMap(), O = W.createTreeWalker(W, 129);
|
|
4
|
+
function Kt(n, e) {
|
|
5
|
+
if (!Qe(n) || !n.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
6
|
+
return tt !== void 0 ? tt.createHTML(e) : e;
|
|
7
|
+
}
|
|
8
|
+
const vn = (n, e) => {
|
|
9
|
+
const t = n.length - 1, r = [];
|
|
10
|
+
let o, s = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", i = te;
|
|
11
|
+
for (let c = 0; c < t; c++) {
|
|
12
|
+
const a = n[c];
|
|
13
13
|
let l, u, h = -1, f = 0;
|
|
14
|
-
for (; f < a.length && (i.lastIndex = f, u = i.exec(a), u !== null); ) f = i.lastIndex, i ===
|
|
15
|
-
const d = i ===
|
|
16
|
-
s += i ===
|
|
14
|
+
for (; f < a.length && (i.lastIndex = f, u = i.exec(a), u !== null); ) f = i.lastIndex, i === te ? u[1] === "!--" ? i = nt : u[1] !== void 0 ? i = rt : u[2] !== void 0 ? (Wt.test(u[2]) && (o = RegExp("</" + u[2], "g")), i = V) : u[3] !== void 0 && (i = V) : i === V ? u[0] === ">" ? (i = o ?? te, h = -1) : u[1] === void 0 ? h = -2 : (h = i.lastIndex - u[2].length, l = u[1], i = u[3] === void 0 ? V : u[3] === '"' ? st : ot) : i === st || i === ot ? i = V : i === nt || i === rt ? i = te : (i = V, o = void 0);
|
|
15
|
+
const d = i === V && n[c + 1].startsWith("/>") ? " " : "";
|
|
16
|
+
s += i === te ? a + pn : h >= 0 ? (r.push(l), a.slice(0, h) + Vt + a.slice(h) + j + d) : a + j + (h === -2 ? c : d);
|
|
17
17
|
}
|
|
18
|
-
return [
|
|
18
|
+
return [Kt(n, s + (n[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), r];
|
|
19
19
|
};
|
|
20
|
-
class
|
|
21
|
-
constructor({ strings: e, _$litType$:
|
|
20
|
+
class se {
|
|
21
|
+
constructor({ strings: e, _$litType$: t }, r) {
|
|
22
22
|
let o;
|
|
23
23
|
this.parts = [];
|
|
24
24
|
let s = 0, i = 0;
|
|
25
|
-
const c = e.length - 1, a = this.parts, [l, u] =
|
|
26
|
-
if (this.el =
|
|
25
|
+
const c = e.length - 1, a = this.parts, [l, u] = vn(e, t);
|
|
26
|
+
if (this.el = se.createElement(l, r), O.currentNode = this.el.content, t === 2 || t === 3) {
|
|
27
27
|
const h = this.el.content.firstChild;
|
|
28
28
|
h.replaceWith(...h.childNodes);
|
|
29
29
|
}
|
|
30
|
-
for (; (o =
|
|
30
|
+
for (; (o = O.nextNode()) !== null && a.length < c; ) {
|
|
31
31
|
if (o.nodeType === 1) {
|
|
32
|
-
if (o.hasAttributes()) for (const h of o.getAttributeNames()) if (h.endsWith(
|
|
33
|
-
const f = u[i++], d = o.getAttribute(h).split(
|
|
34
|
-
a.push({ type: 1, index: s, name:
|
|
35
|
-
} else h.startsWith(
|
|
36
|
-
if (
|
|
37
|
-
const h = o.textContent.split(
|
|
32
|
+
if (o.hasAttributes()) for (const h of o.getAttributeNames()) if (h.endsWith(Vt)) {
|
|
33
|
+
const f = u[i++], d = o.getAttribute(h).split(j), g = /([.?@])?(.*)/.exec(f);
|
|
34
|
+
a.push({ type: 1, index: s, name: g[2], strings: d, ctor: g[1] === "." ? Cn : g[1] === "?" ? An : g[1] === "@" ? Tn : ge }), o.removeAttribute(h);
|
|
35
|
+
} else h.startsWith(j) && (a.push({ type: 6, index: s }), o.removeAttribute(h));
|
|
36
|
+
if (Wt.test(o.tagName)) {
|
|
37
|
+
const h = o.textContent.split(j), f = h.length - 1;
|
|
38
38
|
if (f > 0) {
|
|
39
|
-
o.textContent =
|
|
40
|
-
for (let d = 0; d < f; d++) o.append(h[d],
|
|
41
|
-
o.append(h[f],
|
|
39
|
+
o.textContent = ue ? ue.emptyScript : "";
|
|
40
|
+
for (let d = 0; d < f; d++) o.append(h[d], re()), O.nextNode(), a.push({ type: 2, index: ++s });
|
|
41
|
+
o.append(h[f], re());
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
} else if (o.nodeType === 8) if (o.data ===
|
|
44
|
+
} else if (o.nodeType === 8) if (o.data === Ot) a.push({ type: 2, index: s });
|
|
45
45
|
else {
|
|
46
46
|
let h = -1;
|
|
47
|
-
for (; (h = o.data.indexOf(
|
|
47
|
+
for (; (h = o.data.indexOf(j, h + 1)) !== -1; ) a.push({ type: 7, index: s }), h += j.length - 1;
|
|
48
48
|
}
|
|
49
49
|
s++;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
static createElement(e,
|
|
53
|
-
const
|
|
54
|
-
return
|
|
52
|
+
static createElement(e, t) {
|
|
53
|
+
const r = W.createElement("template");
|
|
54
|
+
return r.innerHTML = e, r;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
if (e ===
|
|
59
|
-
let o =
|
|
60
|
-
const s =
|
|
61
|
-
return o?.constructor !== s && (o?._$AO?.(!1), s === void 0 ? o = void 0 : (o = new s(
|
|
57
|
+
function Z(n, e, t = n, r) {
|
|
58
|
+
if (e === X) return e;
|
|
59
|
+
let o = r !== void 0 ? t._$Co?.[r] : t._$Cl;
|
|
60
|
+
const s = oe(e) ? void 0 : e._$litDirective$;
|
|
61
|
+
return o?.constructor !== s && (o?._$AO?.(!1), s === void 0 ? o = void 0 : (o = new s(n), o._$AT(n, t, r)), r !== void 0 ? (t._$Co ??= [])[r] = o : t._$Cl = o), o !== void 0 && (e = Z(n, o._$AS(n, e.values), o, r)), e;
|
|
62
62
|
}
|
|
63
|
-
class
|
|
64
|
-
constructor(e,
|
|
65
|
-
this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM =
|
|
63
|
+
class bn {
|
|
64
|
+
constructor(e, t) {
|
|
65
|
+
this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t;
|
|
66
66
|
}
|
|
67
67
|
get parentNode() {
|
|
68
68
|
return this._$AM.parentNode;
|
|
@@ -71,34 +71,34 @@ class cn {
|
|
|
71
71
|
return this._$AM._$AU;
|
|
72
72
|
}
|
|
73
73
|
u(e) {
|
|
74
|
-
const { el: { content:
|
|
75
|
-
|
|
76
|
-
let s =
|
|
74
|
+
const { el: { content: t }, parts: r } = this._$AD, o = (e?.creationScope ?? W).importNode(t, !0);
|
|
75
|
+
O.currentNode = o;
|
|
76
|
+
let s = O.nextNode(), i = 0, c = 0, a = r[0];
|
|
77
77
|
for (; a !== void 0; ) {
|
|
78
78
|
if (i === a.index) {
|
|
79
79
|
let l;
|
|
80
|
-
a.type === 2 ? l = new
|
|
80
|
+
a.type === 2 ? l = new ae(s, s.nextSibling, this, e) : a.type === 1 ? l = new a.ctor(s, a.name, a.strings, this, e) : a.type === 6 && (l = new En(s, this, e)), this._$AV.push(l), a = r[++c];
|
|
81
81
|
}
|
|
82
|
-
i !== a?.index && (s =
|
|
82
|
+
i !== a?.index && (s = O.nextNode(), i++);
|
|
83
83
|
}
|
|
84
|
-
return
|
|
84
|
+
return O.currentNode = W, o;
|
|
85
85
|
}
|
|
86
86
|
p(e) {
|
|
87
|
-
let
|
|
88
|
-
for (const
|
|
87
|
+
let t = 0;
|
|
88
|
+
for (const r of this._$AV) r !== void 0 && (r.strings !== void 0 ? (r._$AI(e, r, t), t += r.strings.length - 2) : r._$AI(e[t])), t++;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
class
|
|
91
|
+
class ae {
|
|
92
92
|
get _$AU() {
|
|
93
93
|
return this._$AM?._$AU ?? this._$Cv;
|
|
94
94
|
}
|
|
95
|
-
constructor(e,
|
|
96
|
-
this.type = 2, this._$AH =
|
|
95
|
+
constructor(e, t, r, o) {
|
|
96
|
+
this.type = 2, this._$AH = B, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = r, this.options = o, this._$Cv = o?.isConnected ?? !0;
|
|
97
97
|
}
|
|
98
98
|
get parentNode() {
|
|
99
99
|
let e = this._$AA.parentNode;
|
|
100
|
-
const
|
|
101
|
-
return
|
|
100
|
+
const t = this._$AM;
|
|
101
|
+
return t !== void 0 && e?.nodeType === 11 && (e = t.parentNode), e;
|
|
102
102
|
}
|
|
103
103
|
get startNode() {
|
|
104
104
|
return this._$AA;
|
|
@@ -106,8 +106,8 @@ class ie {
|
|
|
106
106
|
get endNode() {
|
|
107
107
|
return this._$AB;
|
|
108
108
|
}
|
|
109
|
-
_$AI(e,
|
|
110
|
-
e =
|
|
109
|
+
_$AI(e, t = this) {
|
|
110
|
+
e = Z(this, e, t), oe(e) ? e === B || e == null || e === "" ? (this._$AH !== B && this._$AR(), this._$AH = B) : e !== this._$AH && e !== X && this._(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) : wn(e) ? this.k(e) : this._(e);
|
|
111
111
|
}
|
|
112
112
|
O(e) {
|
|
113
113
|
return this._$AA.parentNode.insertBefore(e, this._$AB);
|
|
@@ -116,162 +116,162 @@ class ie {
|
|
|
116
116
|
this._$AH !== e && (this._$AR(), this._$AH = this.O(e));
|
|
117
117
|
}
|
|
118
118
|
_(e) {
|
|
119
|
-
this._$AH !==
|
|
119
|
+
this._$AH !== B && oe(this._$AH) ? this._$AA.nextSibling.data = e : this.T(W.createTextNode(e)), this._$AH = e;
|
|
120
120
|
}
|
|
121
121
|
$(e) {
|
|
122
|
-
const { values:
|
|
123
|
-
if (this._$AH?._$AD === o) this._$AH.p(
|
|
122
|
+
const { values: t, _$litType$: r } = e, o = typeof r == "number" ? this._$AC(e) : (r.el === void 0 && (r.el = se.createElement(Kt(r.h, r.h[0]), this.options)), r);
|
|
123
|
+
if (this._$AH?._$AD === o) this._$AH.p(t);
|
|
124
124
|
else {
|
|
125
|
-
const s = new
|
|
126
|
-
s.p(
|
|
125
|
+
const s = new bn(o, this), i = s.u(this.options);
|
|
126
|
+
s.p(t), this.T(i), this._$AH = s;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
_$AC(e) {
|
|
130
|
-
let
|
|
131
|
-
return
|
|
130
|
+
let t = it.get(e.strings);
|
|
131
|
+
return t === void 0 && it.set(e.strings, t = new se(e)), t;
|
|
132
132
|
}
|
|
133
133
|
k(e) {
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
let
|
|
137
|
-
for (const s of e) o ===
|
|
138
|
-
o <
|
|
139
|
-
}
|
|
140
|
-
_$AR(e = this._$AA.nextSibling,
|
|
141
|
-
for (this._$AP?.(!1, !0,
|
|
142
|
-
const
|
|
143
|
-
e.remove(), e =
|
|
134
|
+
Qe(this._$AH) || (this._$AH = [], this._$AR());
|
|
135
|
+
const t = this._$AH;
|
|
136
|
+
let r, o = 0;
|
|
137
|
+
for (const s of e) o === t.length ? t.push(r = new ae(this.O(re()), this.O(re()), this, this.options)) : r = t[o], r._$AI(s), o++;
|
|
138
|
+
o < t.length && (this._$AR(r && r._$AB.nextSibling, o), t.length = o);
|
|
139
|
+
}
|
|
140
|
+
_$AR(e = this._$AA.nextSibling, t) {
|
|
141
|
+
for (this._$AP?.(!1, !0, t); e !== this._$AB; ) {
|
|
142
|
+
const r = e.nextSibling;
|
|
143
|
+
e.remove(), e = r;
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
setConnected(e) {
|
|
147
147
|
this._$AM === void 0 && (this._$Cv = e, this._$AP?.(e));
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
class
|
|
150
|
+
class ge {
|
|
151
151
|
get tagName() {
|
|
152
152
|
return this.element.tagName;
|
|
153
153
|
}
|
|
154
154
|
get _$AU() {
|
|
155
155
|
return this._$AM._$AU;
|
|
156
156
|
}
|
|
157
|
-
constructor(e,
|
|
158
|
-
this.type = 1, this._$AH =
|
|
157
|
+
constructor(e, t, r, o, s) {
|
|
158
|
+
this.type = 1, this._$AH = B, this._$AN = void 0, this.element = e, this.name = t, this._$AM = o, this.options = s, r.length > 2 || r[0] !== "" || r[1] !== "" ? (this._$AH = Array(r.length - 1).fill(new String()), this.strings = r) : this._$AH = B;
|
|
159
159
|
}
|
|
160
|
-
_$AI(e,
|
|
160
|
+
_$AI(e, t = this, r, o) {
|
|
161
161
|
const s = this.strings;
|
|
162
162
|
let i = !1;
|
|
163
|
-
if (s === void 0) e =
|
|
163
|
+
if (s === void 0) e = Z(this, e, t, 0), i = !oe(e) || e !== this._$AH && e !== X, i && (this._$AH = e);
|
|
164
164
|
else {
|
|
165
165
|
const c = e;
|
|
166
166
|
let a, l;
|
|
167
|
-
for (e = s[0], a = 0; a < s.length - 1; a++) l =
|
|
167
|
+
for (e = s[0], a = 0; a < s.length - 1; a++) l = Z(this, c[r + a], t, a), l === X && (l = this._$AH[a]), i ||= !oe(l) || l !== this._$AH[a], l === B ? e = B : e !== B && (e += (l ?? "") + s[a + 1]), this._$AH[a] = l;
|
|
168
168
|
}
|
|
169
169
|
i && !o && this.j(e);
|
|
170
170
|
}
|
|
171
171
|
j(e) {
|
|
172
|
-
e ===
|
|
172
|
+
e === B ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
|
-
class
|
|
175
|
+
class Cn extends ge {
|
|
176
176
|
constructor() {
|
|
177
177
|
super(...arguments), this.type = 3;
|
|
178
178
|
}
|
|
179
179
|
j(e) {
|
|
180
|
-
this.element[this.name] = e ===
|
|
180
|
+
this.element[this.name] = e === B ? void 0 : e;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
class
|
|
183
|
+
class An extends ge {
|
|
184
184
|
constructor() {
|
|
185
185
|
super(...arguments), this.type = 4;
|
|
186
186
|
}
|
|
187
187
|
j(e) {
|
|
188
|
-
this.element.toggleAttribute(this.name, !!e && e !==
|
|
188
|
+
this.element.toggleAttribute(this.name, !!e && e !== B);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
-
class
|
|
192
|
-
constructor(e,
|
|
193
|
-
super(e,
|
|
191
|
+
class Tn extends ge {
|
|
192
|
+
constructor(e, t, r, o, s) {
|
|
193
|
+
super(e, t, r, o, s), this.type = 5;
|
|
194
194
|
}
|
|
195
|
-
_$AI(e,
|
|
196
|
-
if ((e =
|
|
197
|
-
const
|
|
198
|
-
o && this.element.removeEventListener(this.name, this,
|
|
195
|
+
_$AI(e, t = this) {
|
|
196
|
+
if ((e = Z(this, e, t, 0) ?? B) === X) return;
|
|
197
|
+
const r = this._$AH, o = e === B && r !== B || e.capture !== r.capture || e.once !== r.once || e.passive !== r.passive, s = e !== B && (r === B || o);
|
|
198
|
+
o && this.element.removeEventListener(this.name, this, r), s && this.element.addEventListener(this.name, this, e), this._$AH = e;
|
|
199
199
|
}
|
|
200
200
|
handleEvent(e) {
|
|
201
201
|
typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, e) : this._$AH.handleEvent(e);
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
class
|
|
205
|
-
constructor(e,
|
|
206
|
-
this.element = e, this.type = 6, this._$AN = void 0, this._$AM =
|
|
204
|
+
class En {
|
|
205
|
+
constructor(e, t, r) {
|
|
206
|
+
this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = r;
|
|
207
207
|
}
|
|
208
208
|
get _$AU() {
|
|
209
209
|
return this._$AM._$AU;
|
|
210
210
|
}
|
|
211
211
|
_$AI(e) {
|
|
212
|
-
|
|
212
|
+
Z(this, e);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
const
|
|
218
|
-
const
|
|
219
|
-
let o =
|
|
220
|
-
return o === void 0 && (
|
|
215
|
+
const _n = Je.litHtmlPolyfillSupport;
|
|
216
|
+
_n?.(se, ae), (Je.litHtmlVersions ??= []).push("3.3.1");
|
|
217
|
+
const Jt = (n, e, t) => {
|
|
218
|
+
const r = e;
|
|
219
|
+
let o = r._$litPart$;
|
|
220
|
+
return o === void 0 && (r._$litPart$ = o = new ae(e.insertBefore(re(), null), null, void 0, {})), o._$AI(n), o;
|
|
221
221
|
};
|
|
222
|
-
const
|
|
223
|
-
class
|
|
222
|
+
const kn = { CHILD: 2 }, xn = (n) => (...e) => ({ _$litDirective$: n, values: e });
|
|
223
|
+
class Rn {
|
|
224
224
|
constructor(e) {
|
|
225
225
|
}
|
|
226
226
|
get _$AU() {
|
|
227
227
|
return this._$AM._$AU;
|
|
228
228
|
}
|
|
229
|
-
_$AT(e,
|
|
230
|
-
this._$Ct = e, this._$AM =
|
|
229
|
+
_$AT(e, t, r) {
|
|
230
|
+
this._$Ct = e, this._$AM = t, this._$Ci = r;
|
|
231
231
|
}
|
|
232
|
-
_$AS(e,
|
|
233
|
-
return this.update(e,
|
|
232
|
+
_$AS(e, t) {
|
|
233
|
+
return this.update(e, t);
|
|
234
234
|
}
|
|
235
|
-
update(e,
|
|
236
|
-
return this.render(...
|
|
235
|
+
update(e, t) {
|
|
236
|
+
return this.render(...t);
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
-
class
|
|
239
|
+
class Ke extends Rn {
|
|
240
240
|
constructor(e) {
|
|
241
|
-
if (super(e), this.it =
|
|
241
|
+
if (super(e), this.it = B, e.type !== kn.CHILD) throw Error(this.constructor.directiveName + "() can only be used in child bindings");
|
|
242
242
|
}
|
|
243
243
|
render(e) {
|
|
244
|
-
if (e ===
|
|
245
|
-
if (e ===
|
|
244
|
+
if (e === B || e == null) return this._t = void 0, this.it = e;
|
|
245
|
+
if (e === X) return e;
|
|
246
246
|
if (typeof e != "string") throw Error(this.constructor.directiveName + "() called with a non-string value");
|
|
247
247
|
if (e === this.it) return this._t;
|
|
248
248
|
this.it = e;
|
|
249
|
-
const
|
|
250
|
-
return
|
|
249
|
+
const t = [e];
|
|
250
|
+
return t.raw = t, this._t = { _$litType$: this.constructor.resultType, strings: t, values: [] };
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
-
|
|
254
|
-
const
|
|
255
|
-
const
|
|
256
|
-
|
|
253
|
+
Ke.directiveName = "unsafeHTML", Ke.resultType = 1;
|
|
254
|
+
const at = xn(Ke), Sn = (n) => n ? ["text/", "xml", "html", "javascript", "css", "csv", "plain", "x-www-form-urlencoded"].some((t) => n.includes(t)) : !1, ct = async (n = {}, e) => {
|
|
255
|
+
const t = new AbortController(), r = t.signal, o = n.isBlob || !1, s = n.isText || !1, i = n.isPostFile || !1, c = n.timeout || 6e4 * 3, a = setTimeout(() => {
|
|
256
|
+
t.abort();
|
|
257
257
|
}, c);
|
|
258
|
-
let l = e?.method ||
|
|
259
|
-
|
|
258
|
+
let l = e?.method || n?.method || "POST", u = { ...n?.headers, ...e?.headers }, h = "", f;
|
|
259
|
+
n?.url?.startsWith("http") ? f = new URL(n.url) : (h = window?.location?.origin || "http://localhost:51015", f = new URL(n.url, h));
|
|
260
260
|
const d = l === "GET";
|
|
261
|
-
d && (f.search = new URLSearchParams(
|
|
262
|
-
let
|
|
263
|
-
return d ?
|
|
261
|
+
d && (f.search = new URLSearchParams(n.body).toString());
|
|
262
|
+
let g;
|
|
263
|
+
return d ? g = void 0 : i ? g = n.body : (u = {
|
|
264
264
|
"Content-Type": "application/json",
|
|
265
265
|
...u
|
|
266
|
-
},
|
|
266
|
+
}, g = JSON.stringify(n.body)), fetch(f, {
|
|
267
267
|
method: l.toUpperCase(),
|
|
268
|
-
signal:
|
|
269
|
-
body:
|
|
268
|
+
signal: r,
|
|
269
|
+
body: g,
|
|
270
270
|
...e,
|
|
271
271
|
headers: u
|
|
272
272
|
}).then(async (p) => {
|
|
273
|
-
const
|
|
274
|
-
return o ? await p.blob() :
|
|
273
|
+
const m = p.headers.get("Content-Type");
|
|
274
|
+
return o ? await p.blob() : m && m.includes("application/json") && !s ? await p.json() : Sn(m) ? {
|
|
275
275
|
code: 200,
|
|
276
276
|
status: p.status,
|
|
277
277
|
data: await p.text()
|
|
@@ -282,17 +282,17 @@ const nt = pn(He), wn = (t) => t ? ["text/", "xml", "html", "javascript", "css",
|
|
|
282
282
|
})).finally(() => {
|
|
283
283
|
clearTimeout(a);
|
|
284
284
|
});
|
|
285
|
-
},
|
|
286
|
-
!
|
|
287
|
-
},
|
|
288
|
-
code:
|
|
285
|
+
}, lt = (n) => (n.success = n.code === 200, n.showError = (e) => {
|
|
286
|
+
!n.success && !n.noMsg && e?.();
|
|
287
|
+
}, n), be = ({ code: n, message: e }) => ({
|
|
288
|
+
code: n || 500,
|
|
289
289
|
success: !1,
|
|
290
290
|
message: e || "api request error",
|
|
291
|
-
showError: (
|
|
291
|
+
showError: (r) => {
|
|
292
292
|
},
|
|
293
293
|
noMsg: !0
|
|
294
294
|
});
|
|
295
|
-
class
|
|
295
|
+
class Qt {
|
|
296
296
|
adapter;
|
|
297
297
|
url;
|
|
298
298
|
beforeRequest;
|
|
@@ -306,7 +306,7 @@ class Ft {
|
|
|
306
306
|
// 默认不使用ws
|
|
307
307
|
qws;
|
|
308
308
|
constructor(e) {
|
|
309
|
-
this.adapter = e?.adapter ||
|
|
309
|
+
this.adapter = e?.adapter || ct, this.url = e?.url || "/api/router", this.headers = e?.headers || {
|
|
310
310
|
"Content-Type": "application/json"
|
|
311
311
|
}, this.timeout = e?.timeout || 6e4 * 3;
|
|
312
312
|
}
|
|
@@ -327,8 +327,8 @@ class Ft {
|
|
|
327
327
|
* @param options 请求配置
|
|
328
328
|
* @returns 请求结果
|
|
329
329
|
*/
|
|
330
|
-
async get(e,
|
|
331
|
-
return this.post(e,
|
|
330
|
+
async get(e, t) {
|
|
331
|
+
return this.post(e, t);
|
|
332
332
|
}
|
|
333
333
|
/**
|
|
334
334
|
* 发送 post 请求
|
|
@@ -338,46 +338,46 @@ class Ft {
|
|
|
338
338
|
* @param options 请求配置
|
|
339
339
|
* @returns 请求结果
|
|
340
340
|
*/
|
|
341
|
-
async post(e,
|
|
342
|
-
const
|
|
343
|
-
url:
|
|
341
|
+
async post(e, t) {
|
|
342
|
+
const r = t?.url || this.url, { headers: o, adapter: s, beforeRequest: i, afterResponse: c, timeout: a, ...l } = t || {}, u = { ...this.headers, ...o }, h = s || this.adapter, f = i || this.beforeRequest, d = c || this.afterResponse, g = a || this.timeout, p = {
|
|
343
|
+
url: r,
|
|
344
344
|
headers: u,
|
|
345
345
|
body: e,
|
|
346
|
-
timeout:
|
|
346
|
+
timeout: g,
|
|
347
347
|
...l
|
|
348
348
|
};
|
|
349
349
|
try {
|
|
350
350
|
if (f && await f(p) === !1)
|
|
351
|
-
return
|
|
351
|
+
return be({
|
|
352
352
|
code: 500,
|
|
353
353
|
message: "request is cancel",
|
|
354
354
|
// @ts-ignore
|
|
355
355
|
req: p
|
|
356
356
|
});
|
|
357
|
-
} catch (
|
|
358
|
-
return console.error("request beforeFn error",
|
|
357
|
+
} catch (m) {
|
|
358
|
+
return console.error("request beforeFn error", m, p), be({
|
|
359
359
|
code: 500,
|
|
360
360
|
message: "api request beforeFn error"
|
|
361
361
|
});
|
|
362
362
|
}
|
|
363
|
-
if (this.stop && !
|
|
364
|
-
const
|
|
365
|
-
await new Promise((
|
|
366
|
-
let
|
|
367
|
-
const
|
|
368
|
-
|
|
363
|
+
if (this.stop && !t?.noStop) {
|
|
364
|
+
const m = this;
|
|
365
|
+
await new Promise((y) => {
|
|
366
|
+
let E = 0;
|
|
367
|
+
const w = setInterval(() => {
|
|
368
|
+
m.stop || (clearInterval(w), y(!0)), E++, E > 30 && console.error("request stop: timeout", p.url, E);
|
|
369
369
|
}, 1e3);
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
|
-
return h(p).then(async (
|
|
372
|
+
return h(p).then(async (m) => {
|
|
373
373
|
try {
|
|
374
|
-
return
|
|
374
|
+
return lt(m), d ? await d(m, {
|
|
375
375
|
req: p,
|
|
376
|
-
res:
|
|
376
|
+
res: m,
|
|
377
377
|
fetch: s
|
|
378
|
-
}) :
|
|
379
|
-
} catch (
|
|
380
|
-
return console.error("request afterFn error",
|
|
378
|
+
}) : m;
|
|
379
|
+
} catch (y) {
|
|
380
|
+
return console.error("request afterFn error", y, p), be({
|
|
381
381
|
code: 500,
|
|
382
382
|
message: "api request afterFn error"
|
|
383
383
|
});
|
|
@@ -398,21 +398,21 @@ class Ft {
|
|
|
398
398
|
after(e) {
|
|
399
399
|
this.afterResponse = e;
|
|
400
400
|
}
|
|
401
|
-
async fetchText(e,
|
|
402
|
-
let
|
|
403
|
-
typeof e == "string" && !
|
|
404
|
-
const o = await
|
|
401
|
+
async fetchText(e, t) {
|
|
402
|
+
let r = { ...t };
|
|
403
|
+
typeof e == "string" && !r.url && (r.url = e), typeof e == "object" && (r = { ...e, ...r });
|
|
404
|
+
const o = await ct({
|
|
405
405
|
method: "GET",
|
|
406
|
-
...
|
|
406
|
+
...r,
|
|
407
407
|
headers: {
|
|
408
408
|
...this.headers,
|
|
409
|
-
...
|
|
409
|
+
...r?.headers || {}
|
|
410
410
|
}
|
|
411
411
|
});
|
|
412
|
-
return
|
|
412
|
+
return lt(o);
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
|
-
class
|
|
415
|
+
class Mn {
|
|
416
416
|
query;
|
|
417
417
|
queryDefine;
|
|
418
418
|
constructor(e) {
|
|
@@ -421,52 +421,52 @@ class yn {
|
|
|
421
421
|
get chain() {
|
|
422
422
|
return this.queryDefine.queryChain;
|
|
423
423
|
}
|
|
424
|
-
post(e,
|
|
425
|
-
return this.query.post(e,
|
|
424
|
+
post(e, t) {
|
|
425
|
+
return this.query.post(e, t);
|
|
426
426
|
}
|
|
427
|
-
get(e,
|
|
428
|
-
return this.query.get(e,
|
|
427
|
+
get(e, t) {
|
|
428
|
+
return this.query.get(e, t);
|
|
429
429
|
}
|
|
430
430
|
}
|
|
431
|
-
const
|
|
432
|
-
!
|
|
433
|
-
},
|
|
434
|
-
function
|
|
435
|
-
return new Promise((e,
|
|
436
|
-
|
|
431
|
+
const ut = (n) => (n.success = n.code === 200, n.showError = (e) => {
|
|
432
|
+
!n.success && !n.noMsg && e?.();
|
|
433
|
+
}, n);
|
|
434
|
+
function L(n) {
|
|
435
|
+
return new Promise((e, t) => {
|
|
436
|
+
n.oncomplete = n.onsuccess = () => e(n.result), n.onabort = n.onerror = () => t(n.error);
|
|
437
437
|
});
|
|
438
438
|
}
|
|
439
|
-
function
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
const
|
|
443
|
-
return (o, s) =>
|
|
439
|
+
function Gt(n, e) {
|
|
440
|
+
const t = indexedDB.open(n);
|
|
441
|
+
t.onupgradeneeded = () => t.result.createObjectStore(e);
|
|
442
|
+
const r = L(t);
|
|
443
|
+
return (o, s) => r.then((i) => s(i.transaction(e, o).objectStore(e)));
|
|
444
444
|
}
|
|
445
|
-
let
|
|
446
|
-
function
|
|
447
|
-
return
|
|
445
|
+
let Ce;
|
|
446
|
+
function $() {
|
|
447
|
+
return Ce || (Ce = Gt("keyval-store", "keyval")), Ce;
|
|
448
448
|
}
|
|
449
|
-
function
|
|
450
|
-
return e("readonly", (
|
|
449
|
+
function Yt(n, e = $()) {
|
|
450
|
+
return e("readonly", (t) => L(t.get(n)));
|
|
451
451
|
}
|
|
452
|
-
function
|
|
453
|
-
return
|
|
452
|
+
function Xt(n, e, t = $()) {
|
|
453
|
+
return t("readwrite", (r) => (r.put(e, n), L(r.transaction)));
|
|
454
454
|
}
|
|
455
|
-
function
|
|
456
|
-
return e("readwrite", (
|
|
455
|
+
function Bn(n, e = $()) {
|
|
456
|
+
return e("readwrite", (t) => (n.forEach((r) => t.put(r[1], r[0])), L(t.transaction)));
|
|
457
457
|
}
|
|
458
|
-
function
|
|
459
|
-
return e("readonly", (
|
|
458
|
+
function Ln(n, e = $()) {
|
|
459
|
+
return e("readonly", (t) => Promise.all(n.map((r) => L(t.get(r)))));
|
|
460
460
|
}
|
|
461
|
-
function
|
|
462
|
-
return
|
|
461
|
+
function In(n, e, t = $()) {
|
|
462
|
+
return t("readwrite", (r) => (
|
|
463
463
|
// Need to create the promise manually.
|
|
464
464
|
// If I try to chain promises, the transaction closes in browsers
|
|
465
465
|
// that use a promise polyfill (IE10/11).
|
|
466
466
|
new Promise((o, s) => {
|
|
467
|
-
|
|
467
|
+
r.get(n).onsuccess = function() {
|
|
468
468
|
try {
|
|
469
|
-
|
|
469
|
+
r.put(e(this.result), n), o(L(r.transaction));
|
|
470
470
|
} catch (i) {
|
|
471
471
|
s(i);
|
|
472
472
|
}
|
|
@@ -474,87 +474,87 @@ function An(t, e, r = I()) {
|
|
|
474
474
|
})
|
|
475
475
|
));
|
|
476
476
|
}
|
|
477
|
-
function
|
|
478
|
-
return e("readwrite", (
|
|
477
|
+
function Zt(n, e = $()) {
|
|
478
|
+
return e("readwrite", (t) => (t.delete(n), L(t.transaction)));
|
|
479
479
|
}
|
|
480
|
-
function
|
|
481
|
-
return e("readwrite", (
|
|
480
|
+
function $n(n, e = $()) {
|
|
481
|
+
return e("readwrite", (t) => (n.forEach((r) => t.delete(r)), L(t.transaction)));
|
|
482
482
|
}
|
|
483
|
-
function
|
|
484
|
-
return
|
|
483
|
+
function en(n = $()) {
|
|
484
|
+
return n("readwrite", (e) => (e.clear(), L(e.transaction)));
|
|
485
485
|
}
|
|
486
|
-
function
|
|
487
|
-
return
|
|
486
|
+
function Ge(n, e) {
|
|
487
|
+
return n.openCursor().onsuccess = function() {
|
|
488
488
|
this.result && (e(this.result), this.result.continue());
|
|
489
|
-
},
|
|
489
|
+
}, L(n.transaction);
|
|
490
490
|
}
|
|
491
|
-
function
|
|
492
|
-
return
|
|
491
|
+
function Pn(n = $()) {
|
|
492
|
+
return n("readonly", (e) => {
|
|
493
493
|
if (e.getAllKeys)
|
|
494
|
-
return
|
|
495
|
-
const
|
|
496
|
-
return
|
|
494
|
+
return L(e.getAllKeys());
|
|
495
|
+
const t = [];
|
|
496
|
+
return Ge(e, (r) => t.push(r.key)).then(() => t);
|
|
497
497
|
});
|
|
498
498
|
}
|
|
499
|
-
function
|
|
500
|
-
return
|
|
499
|
+
function qn(n = $()) {
|
|
500
|
+
return n("readonly", (e) => {
|
|
501
501
|
if (e.getAll)
|
|
502
|
-
return
|
|
503
|
-
const
|
|
504
|
-
return
|
|
502
|
+
return L(e.getAll());
|
|
503
|
+
const t = [];
|
|
504
|
+
return Ge(e, (r) => t.push(r.value)).then(() => t);
|
|
505
505
|
});
|
|
506
506
|
}
|
|
507
|
-
function
|
|
508
|
-
return
|
|
507
|
+
function Nn(n = $()) {
|
|
508
|
+
return n("readonly", (e) => {
|
|
509
509
|
if (e.getAll && e.getAllKeys)
|
|
510
510
|
return Promise.all([
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
]).then(([
|
|
514
|
-
const
|
|
515
|
-
return
|
|
511
|
+
L(e.getAllKeys()),
|
|
512
|
+
L(e.getAll())
|
|
513
|
+
]).then(([r, o]) => r.map((s, i) => [s, o[i]]));
|
|
514
|
+
const t = [];
|
|
515
|
+
return n("readonly", (r) => Ge(r, (o) => t.push([o.key, o.value])).then(() => t));
|
|
516
516
|
});
|
|
517
517
|
}
|
|
518
|
-
var
|
|
518
|
+
var Dn = /* @__PURE__ */ Object.freeze({
|
|
519
519
|
__proto__: null,
|
|
520
|
-
clear:
|
|
521
|
-
createStore:
|
|
522
|
-
del:
|
|
523
|
-
delMany:
|
|
524
|
-
entries:
|
|
525
|
-
get:
|
|
526
|
-
getMany:
|
|
527
|
-
keys:
|
|
528
|
-
promisifyRequest:
|
|
529
|
-
set:
|
|
530
|
-
setMany:
|
|
531
|
-
update:
|
|
532
|
-
values:
|
|
520
|
+
clear: en,
|
|
521
|
+
createStore: Gt,
|
|
522
|
+
del: Zt,
|
|
523
|
+
delMany: $n,
|
|
524
|
+
entries: Nn,
|
|
525
|
+
get: Yt,
|
|
526
|
+
getMany: Ln,
|
|
527
|
+
keys: Pn,
|
|
528
|
+
promisifyRequest: L,
|
|
529
|
+
set: Xt,
|
|
530
|
+
setMany: Bn,
|
|
531
|
+
update: In,
|
|
532
|
+
values: qn
|
|
533
533
|
});
|
|
534
|
-
class
|
|
534
|
+
class Un {
|
|
535
535
|
storage;
|
|
536
536
|
data = null;
|
|
537
537
|
constructor() {
|
|
538
|
-
this.storage =
|
|
538
|
+
this.storage = Dn;
|
|
539
539
|
}
|
|
540
540
|
async get(e) {
|
|
541
|
-
const
|
|
542
|
-
return this.data =
|
|
541
|
+
const t = await Yt(e);
|
|
542
|
+
return this.data = t, t;
|
|
543
543
|
}
|
|
544
|
-
async set(e,
|
|
545
|
-
this.data =
|
|
544
|
+
async set(e, t) {
|
|
545
|
+
this.data = t, await Xt(e, t);
|
|
546
546
|
}
|
|
547
547
|
async del(e) {
|
|
548
|
-
this.data = null, await
|
|
548
|
+
this.data = null, await Zt(e);
|
|
549
549
|
}
|
|
550
550
|
/**
|
|
551
551
|
* Clear all values in the store.
|
|
552
552
|
*/
|
|
553
553
|
async clear() {
|
|
554
|
-
await
|
|
554
|
+
await en();
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
|
-
class
|
|
557
|
+
class Fn extends Un {
|
|
558
558
|
name;
|
|
559
559
|
updatedAt;
|
|
560
560
|
constructor(e) {
|
|
@@ -569,10 +569,10 @@ class Sn extends Rn {
|
|
|
569
569
|
* @param data
|
|
570
570
|
* @param opts
|
|
571
571
|
*/
|
|
572
|
-
async setData(e,
|
|
573
|
-
const o = Date.now() + (
|
|
572
|
+
async setData(e, t) {
|
|
573
|
+
const o = Date.now() + (t?.expireTime || 1e3 * 60 * 60 * 24 * 10), s = {
|
|
574
574
|
data: e,
|
|
575
|
-
updatedAt:
|
|
575
|
+
updatedAt: t?.updatedAt || Date.now(),
|
|
576
576
|
expireTime: o
|
|
577
577
|
};
|
|
578
578
|
await super.set(this.name, s), this.updatedAt = s.updatedAt;
|
|
@@ -581,20 +581,20 @@ class Sn extends Rn {
|
|
|
581
581
|
await super.del(this.name);
|
|
582
582
|
}
|
|
583
583
|
}
|
|
584
|
-
var
|
|
584
|
+
var zn = class {
|
|
585
585
|
cache;
|
|
586
586
|
name;
|
|
587
587
|
cacheData;
|
|
588
|
-
constructor(
|
|
589
|
-
if (!
|
|
588
|
+
constructor(n) {
|
|
589
|
+
if (!n.cache)
|
|
590
590
|
throw new Error("cache is required");
|
|
591
|
-
this.cache =
|
|
591
|
+
this.cache = n.cache, this.cacheData = {
|
|
592
592
|
loginUsers: [],
|
|
593
593
|
user: void 0,
|
|
594
594
|
id: void 0,
|
|
595
595
|
accessToken: void 0,
|
|
596
596
|
refreshToken: void 0
|
|
597
|
-
}, this.name =
|
|
597
|
+
}, this.name = n.name;
|
|
598
598
|
}
|
|
599
599
|
/**
|
|
600
600
|
* 设置缓存
|
|
@@ -602,8 +602,8 @@ var Bn = class {
|
|
|
602
602
|
* @param value
|
|
603
603
|
* @returns
|
|
604
604
|
*/
|
|
605
|
-
async setValue(
|
|
606
|
-
return await this.cache.set(this.name,
|
|
605
|
+
async setValue(n) {
|
|
606
|
+
return await this.cache.set(this.name, n), this.cacheData = n, n;
|
|
607
607
|
}
|
|
608
608
|
/**
|
|
609
609
|
* 删除缓存
|
|
@@ -618,7 +618,7 @@ var Bn = class {
|
|
|
618
618
|
* 初始化,设置默认值
|
|
619
619
|
*/
|
|
620
620
|
async init() {
|
|
621
|
-
const
|
|
621
|
+
const n = {
|
|
622
622
|
loginUsers: [],
|
|
623
623
|
user: null,
|
|
624
624
|
id: null,
|
|
@@ -628,43 +628,43 @@ var Bn = class {
|
|
|
628
628
|
if (this.cache.init)
|
|
629
629
|
try {
|
|
630
630
|
const e = await this.cache.init();
|
|
631
|
-
this.cacheData = e ||
|
|
631
|
+
this.cacheData = e || n;
|
|
632
632
|
} catch (e) {
|
|
633
633
|
console.log("cacheInit error", e);
|
|
634
634
|
}
|
|
635
635
|
else
|
|
636
|
-
this.cacheData = await this.getValue() ||
|
|
636
|
+
this.cacheData = await this.getValue() || n;
|
|
637
637
|
}
|
|
638
638
|
/**
|
|
639
639
|
* 设置当前用户
|
|
640
640
|
* @param user
|
|
641
641
|
*/
|
|
642
|
-
async setLoginUser(
|
|
643
|
-
this.cacheData.loginUsers.find((
|
|
642
|
+
async setLoginUser(n) {
|
|
643
|
+
this.cacheData.loginUsers.find((t) => t.id === n.id) && (this.cacheData.loginUsers = this.cacheData?.loginUsers?.filter((t) => t?.id && t.id !== n.id)), this.cacheData.loginUsers.push(n), this.cacheData.user = n.user, this.cacheData.id = n.id, this.cacheData.accessToken = n.accessToken, this.cacheData.refreshToken = n.refreshToken, await this.setValue(this.cacheData);
|
|
644
644
|
}
|
|
645
645
|
getCurrentUser() {
|
|
646
|
-
const
|
|
647
|
-
return Promise.resolve(
|
|
646
|
+
const n = this.cacheData;
|
|
647
|
+
return Promise.resolve(n.user);
|
|
648
648
|
}
|
|
649
649
|
getCurrentUserList() {
|
|
650
|
-
return Promise.resolve(this.cacheData.loginUsers.filter((
|
|
650
|
+
return Promise.resolve(this.cacheData.loginUsers.filter((n) => n?.id));
|
|
651
651
|
}
|
|
652
652
|
getRefreshToken() {
|
|
653
|
-
const
|
|
654
|
-
return Promise.resolve(
|
|
653
|
+
const n = this.cacheData;
|
|
654
|
+
return Promise.resolve(n.refreshToken || "");
|
|
655
655
|
}
|
|
656
656
|
getAccessToken() {
|
|
657
|
-
const
|
|
658
|
-
return Promise.resolve(
|
|
657
|
+
const n = this.cacheData;
|
|
658
|
+
return Promise.resolve(n.accessToken || "");
|
|
659
659
|
}
|
|
660
660
|
async clearCurrentUser() {
|
|
661
|
-
const
|
|
662
|
-
this.cacheData.loginUsers.find((
|
|
661
|
+
const n = await this.getCurrentUser();
|
|
662
|
+
this.cacheData.loginUsers.find((t) => t.id === n.id) && (this.cacheData.loginUsers = this.cacheData?.loginUsers?.filter((t) => t?.id && t.id !== n.id)), this.cacheData.user = void 0, this.cacheData.id = void 0, this.cacheData.accessToken = void 0, this.cacheData.refreshToken = void 0, await this.setValue(this.cacheData);
|
|
663
663
|
}
|
|
664
664
|
async clearAll() {
|
|
665
665
|
this.cacheData.loginUsers = [], this.cacheData.user = void 0, this.cacheData.id = void 0, this.cacheData.accessToken = void 0, this.cacheData.refreshToken = void 0, await this.setValue(this.cacheData);
|
|
666
666
|
}
|
|
667
|
-
},
|
|
667
|
+
}, Hn = class extends Mn {
|
|
668
668
|
/**
|
|
669
669
|
* query login cache, 非实际操作, 一个cache的包裹模块
|
|
670
670
|
*/
|
|
@@ -673,22 +673,22 @@ var Bn = class {
|
|
|
673
673
|
load;
|
|
674
674
|
storage;
|
|
675
675
|
onLoad;
|
|
676
|
-
constructor(
|
|
676
|
+
constructor(n) {
|
|
677
677
|
super({
|
|
678
|
-
query:
|
|
679
|
-
}), this.cacheStore = new
|
|
678
|
+
query: n?.query || new Qt()
|
|
679
|
+
}), this.cacheStore = new zn({ name: "login", cache: n.cache }), this.isBrowser = n?.isBrowser ?? !0, this.init(), this.onLoad = n?.onLoad, this.storage = n?.storage || localStorage;
|
|
680
680
|
}
|
|
681
|
-
setQuery(
|
|
682
|
-
this.query =
|
|
681
|
+
setQuery(n) {
|
|
682
|
+
this.query = n;
|
|
683
683
|
}
|
|
684
684
|
async init() {
|
|
685
685
|
await this.cacheStore.init(), this.load = !0, this.onLoad?.();
|
|
686
686
|
}
|
|
687
|
-
async post(
|
|
687
|
+
async post(n, e) {
|
|
688
688
|
try {
|
|
689
|
-
return this.query.post({ path: "user", ...
|
|
690
|
-
} catch (
|
|
691
|
-
return console.log("error",
|
|
689
|
+
return this.query.post({ path: "user", ...n }, e);
|
|
690
|
+
} catch (t) {
|
|
691
|
+
return console.log("error", t), {
|
|
692
692
|
code: 400
|
|
693
693
|
};
|
|
694
694
|
}
|
|
@@ -698,11 +698,11 @@ var Bn = class {
|
|
|
698
698
|
* @param data
|
|
699
699
|
* @returns
|
|
700
700
|
*/
|
|
701
|
-
async login(
|
|
702
|
-
const e = await this.post({ key: "login", ...
|
|
701
|
+
async login(n) {
|
|
702
|
+
const e = await this.post({ key: "login", ...n });
|
|
703
703
|
if (e.code === 200) {
|
|
704
|
-
const { accessToken:
|
|
705
|
-
this.storage.setItem("token",
|
|
704
|
+
const { accessToken: t, refreshToken: r } = e?.data || {};
|
|
705
|
+
this.storage.setItem("token", t || ""), await this.beforeSetLoginUser({ accessToken: t, refreshToken: r });
|
|
706
706
|
}
|
|
707
707
|
return e;
|
|
708
708
|
}
|
|
@@ -711,11 +711,11 @@ var Bn = class {
|
|
|
711
711
|
* @param data
|
|
712
712
|
* @returns
|
|
713
713
|
*/
|
|
714
|
-
async loginByCode(
|
|
715
|
-
const e = await this.post({ path: "sms", key: "login", data:
|
|
714
|
+
async loginByCode(n) {
|
|
715
|
+
const e = await this.post({ path: "sms", key: "login", data: n });
|
|
716
716
|
if (e.code === 200) {
|
|
717
|
-
const { accessToken:
|
|
718
|
-
this.storage.setItem("token",
|
|
717
|
+
const { accessToken: t, refreshToken: r } = e?.data || {};
|
|
718
|
+
this.storage.setItem("token", t || ""), await this.beforeSetLoginUser({ accessToken: t, refreshToken: r });
|
|
719
719
|
}
|
|
720
720
|
return e;
|
|
721
721
|
}
|
|
@@ -723,15 +723,15 @@ var Bn = class {
|
|
|
723
723
|
* 设置token
|
|
724
724
|
* @param token
|
|
725
725
|
*/
|
|
726
|
-
async setLoginToken(
|
|
727
|
-
const { accessToken: e, refreshToken:
|
|
728
|
-
this.storage.setItem("token", e || ""), await this.beforeSetLoginUser({ accessToken: e, refreshToken:
|
|
726
|
+
async setLoginToken(n) {
|
|
727
|
+
const { accessToken: e, refreshToken: t } = n;
|
|
728
|
+
this.storage.setItem("token", e || ""), await this.beforeSetLoginUser({ accessToken: e, refreshToken: t });
|
|
729
729
|
}
|
|
730
|
-
async loginByWechat(
|
|
731
|
-
const e = await this.post({ path: "wx", key: "open-login", code:
|
|
730
|
+
async loginByWechat(n) {
|
|
731
|
+
const e = await this.post({ path: "wx", key: "open-login", code: n.code });
|
|
732
732
|
if (e.code === 200) {
|
|
733
|
-
const { accessToken:
|
|
734
|
-
this.storage.setItem("token",
|
|
733
|
+
const { accessToken: t, refreshToken: r } = e?.data || {};
|
|
734
|
+
this.storage.setItem("token", t || ""), await this.beforeSetLoginUser({ accessToken: t, refreshToken: r });
|
|
735
735
|
}
|
|
736
736
|
return e;
|
|
737
737
|
}
|
|
@@ -739,26 +739,26 @@ var Bn = class {
|
|
|
739
739
|
* 检测微信登录,登陆成功后,调用onSuccess,否则调用onError
|
|
740
740
|
* @param param0
|
|
741
741
|
*/
|
|
742
|
-
async checkWechat({ onSuccess:
|
|
743
|
-
const
|
|
744
|
-
if (
|
|
745
|
-
const s = await this.loginByWechat({ code:
|
|
746
|
-
s.code === 200 ?
|
|
742
|
+
async checkWechat({ onSuccess: n, onError: e }) {
|
|
743
|
+
const t = new URL(window.location.href), r = t.searchParams.get("code"), o = t.searchParams.get("state");
|
|
744
|
+
if (r && o) {
|
|
745
|
+
const s = await this.loginByWechat({ code: r });
|
|
746
|
+
s.code === 200 ? n?.(s.data) : e?.(s);
|
|
747
747
|
}
|
|
748
748
|
}
|
|
749
749
|
/**
|
|
750
750
|
* 登陆成功,需要获取用户信息进行缓存
|
|
751
751
|
* @param param0
|
|
752
752
|
*/
|
|
753
|
-
async beforeSetLoginUser({ accessToken:
|
|
754
|
-
if (
|
|
755
|
-
const
|
|
756
|
-
if (
|
|
757
|
-
const o =
|
|
753
|
+
async beforeSetLoginUser({ accessToken: n, refreshToken: e, check401: t }) {
|
|
754
|
+
if (n && e) {
|
|
755
|
+
const r = await this.getMe(n, t);
|
|
756
|
+
if (r.code === 200) {
|
|
757
|
+
const o = r.data;
|
|
758
758
|
o ? this.cacheStore.setLoginUser({
|
|
759
759
|
user: o,
|
|
760
760
|
id: o.id,
|
|
761
|
-
accessToken:
|
|
761
|
+
accessToken: n,
|
|
762
762
|
refreshToken: e
|
|
763
763
|
}) : console.error("登录失败");
|
|
764
764
|
}
|
|
@@ -769,13 +769,13 @@ var Bn = class {
|
|
|
769
769
|
* @param refreshToken
|
|
770
770
|
* @returns
|
|
771
771
|
*/
|
|
772
|
-
async queryRefreshToken(
|
|
773
|
-
const e =
|
|
774
|
-
let
|
|
772
|
+
async queryRefreshToken(n) {
|
|
773
|
+
const e = n || this.cacheStore.getRefreshToken();
|
|
774
|
+
let t = { refreshToken: e };
|
|
775
775
|
return e ? this.post(
|
|
776
|
-
{ key: "refreshToken", data:
|
|
776
|
+
{ key: "refreshToken", data: t },
|
|
777
777
|
{
|
|
778
|
-
afterResponse: async (
|
|
778
|
+
afterResponse: async (r, o) => (ut(r), r)
|
|
779
779
|
}
|
|
780
780
|
) : (await this.cacheStore.clearCurrentUser(), {
|
|
781
781
|
code: 401,
|
|
@@ -791,29 +791,29 @@ var Bn = class {
|
|
|
791
791
|
* @param refetch
|
|
792
792
|
* @returns
|
|
793
793
|
*/
|
|
794
|
-
async afterCheck401ToRefreshToken(
|
|
795
|
-
const
|
|
796
|
-
if (
|
|
797
|
-
const o = await
|
|
794
|
+
async afterCheck401ToRefreshToken(n, e, t) {
|
|
795
|
+
const r = this;
|
|
796
|
+
if (n?.code === 401) {
|
|
797
|
+
const o = await r.cacheStore.getRefreshToken();
|
|
798
798
|
if (o) {
|
|
799
|
-
const s = await
|
|
799
|
+
const s = await r.queryRefreshToken(o);
|
|
800
800
|
if (s.code === 200) {
|
|
801
801
|
const { accessToken: i, refreshToken: c } = s?.data || {};
|
|
802
|
-
if (
|
|
802
|
+
if (r.storage.setItem("token", i || ""), await r.beforeSetLoginUser({ accessToken: i, refreshToken: c, check401: !1 }), t && e && e.req && e.req.url && e.fetch) {
|
|
803
803
|
await new Promise((f) => setTimeout(f, 1500));
|
|
804
804
|
const a = e.req?.url, l = e.req?.body, u = e.req?.headers, h = await e.fetch(a, {
|
|
805
805
|
method: "POST",
|
|
806
806
|
body: l,
|
|
807
807
|
headers: { ...u, Authorization: `Bearer ${i}` }
|
|
808
808
|
});
|
|
809
|
-
return
|
|
809
|
+
return ut(h), h;
|
|
810
810
|
}
|
|
811
811
|
} else
|
|
812
|
-
|
|
812
|
+
r.storage.removeItem("token"), await r.cacheStore.clearCurrentUser();
|
|
813
813
|
return s;
|
|
814
814
|
}
|
|
815
815
|
}
|
|
816
|
-
return
|
|
816
|
+
return n;
|
|
817
817
|
}
|
|
818
818
|
/**
|
|
819
819
|
* 一个简单的401处理, 如果401,则刷新token, 如果refreshToken不存在,则返回401
|
|
@@ -824,29 +824,29 @@ var Bn = class {
|
|
|
824
824
|
* @param opts
|
|
825
825
|
* @returns
|
|
826
826
|
*/
|
|
827
|
-
async run401Action(
|
|
828
|
-
const
|
|
829
|
-
if (
|
|
830
|
-
if (
|
|
827
|
+
async run401Action(n, e, t) {
|
|
828
|
+
const r = this, o = t?.refetch ?? !1;
|
|
829
|
+
if (n?.code === 401) {
|
|
830
|
+
if (r.query.stop === !0)
|
|
831
831
|
return { code: 500, success: !1, message: "refresh token loading..." };
|
|
832
|
-
|
|
833
|
-
const s = await
|
|
834
|
-
return
|
|
832
|
+
r.query.stop = !0;
|
|
833
|
+
const s = await r.afterCheck401ToRefreshToken(n, e, o);
|
|
834
|
+
return r.query.stop = !1, t?.afterCheck?.(s), s.code === 401 && t?.afterAlso401?.(s), s;
|
|
835
835
|
} else
|
|
836
|
-
return
|
|
836
|
+
return n;
|
|
837
837
|
}
|
|
838
838
|
/**
|
|
839
839
|
* 获取用户信息
|
|
840
840
|
* @param token
|
|
841
841
|
* @returns
|
|
842
842
|
*/
|
|
843
|
-
async getMe(
|
|
844
|
-
const
|
|
845
|
-
return
|
|
843
|
+
async getMe(n, e = !0) {
|
|
844
|
+
const t = n || this.storage.getItem("token"), r = this;
|
|
845
|
+
return r.post(
|
|
846
846
|
{ key: "me" },
|
|
847
847
|
{
|
|
848
|
-
beforeRequest: async (o) => (o.headers && (o.headers.Authorization = `Bearer ${
|
|
849
|
-
afterResponse: async (o, s) => o?.code === 401 && e && !
|
|
848
|
+
beforeRequest: async (o) => (o.headers && (o.headers.Authorization = `Bearer ${t}`), o),
|
|
849
|
+
afterResponse: async (o, s) => o?.code === 401 && e && !n ? await r.afterCheck401ToRefreshToken(o, s) : o
|
|
850
850
|
}
|
|
851
851
|
);
|
|
852
852
|
}
|
|
@@ -855,8 +855,8 @@ var Bn = class {
|
|
|
855
855
|
* @returns
|
|
856
856
|
*/
|
|
857
857
|
async checkLocalUser() {
|
|
858
|
-
const
|
|
859
|
-
return
|
|
858
|
+
const n = await this.cacheStore.getCurrentUser();
|
|
859
|
+
return n || null;
|
|
860
860
|
}
|
|
861
861
|
/**
|
|
862
862
|
* 检查本地token是否存在,简单的判断是否已经属于登陆状态
|
|
@@ -870,32 +870,32 @@ var Bn = class {
|
|
|
870
870
|
* @param username
|
|
871
871
|
* @returns
|
|
872
872
|
*/
|
|
873
|
-
async postSwitchUser(
|
|
874
|
-
return this.post({ key: "switchCheck", data: { username:
|
|
873
|
+
async postSwitchUser(n) {
|
|
874
|
+
return this.post({ key: "switchCheck", data: { username: n } });
|
|
875
875
|
}
|
|
876
876
|
/**
|
|
877
877
|
* 切换用户
|
|
878
878
|
* @param username
|
|
879
879
|
* @returns
|
|
880
880
|
*/
|
|
881
|
-
async switchUser(
|
|
882
|
-
const
|
|
883
|
-
if (
|
|
884
|
-
return this.storage.setItem("token",
|
|
881
|
+
async switchUser(n) {
|
|
882
|
+
const t = (await this.cacheStore.getCurrentUserList()).find((o) => o.user.username === n);
|
|
883
|
+
if (t)
|
|
884
|
+
return this.storage.setItem("token", t.accessToken || ""), await this.beforeSetLoginUser({ accessToken: t.accessToken, refreshToken: t.refreshToken }), {
|
|
885
885
|
code: 200,
|
|
886
886
|
data: {
|
|
887
|
-
accessToken:
|
|
888
|
-
refreshToken:
|
|
887
|
+
accessToken: t.accessToken,
|
|
888
|
+
refreshToken: t.refreshToken
|
|
889
889
|
},
|
|
890
890
|
success: !0,
|
|
891
891
|
message: "切换用户成功"
|
|
892
892
|
};
|
|
893
|
-
const
|
|
894
|
-
if (
|
|
895
|
-
const { accessToken: o, refreshToken: s } =
|
|
893
|
+
const r = await this.postSwitchUser(n);
|
|
894
|
+
if (r.code === 200) {
|
|
895
|
+
const { accessToken: o, refreshToken: s } = r?.data || {};
|
|
896
896
|
this.storage.setItem("token", o || ""), await this.beforeSetLoginUser({ accessToken: o, refreshToken: s });
|
|
897
897
|
}
|
|
898
|
-
return
|
|
898
|
+
return r;
|
|
899
899
|
}
|
|
900
900
|
/**
|
|
901
901
|
* 退出登陆,去掉token, 并删除缓存
|
|
@@ -903,7 +903,7 @@ var Bn = class {
|
|
|
903
903
|
*/
|
|
904
904
|
async logout() {
|
|
905
905
|
this.storage.removeItem("token");
|
|
906
|
-
const e = (await this.cacheStore.getCurrentUserList()).map((
|
|
906
|
+
const e = (await this.cacheStore.getCurrentUserList()).map((t) => t?.accessToken).filter(Boolean);
|
|
907
907
|
return this.cacheStore.delValue(), this.post({ key: "logout", data: { tokens: e } });
|
|
908
908
|
}
|
|
909
909
|
/**
|
|
@@ -911,18 +911,18 @@ var Bn = class {
|
|
|
911
911
|
* @param username
|
|
912
912
|
* @returns
|
|
913
913
|
*/
|
|
914
|
-
async hasUser(
|
|
914
|
+
async hasUser(n) {
|
|
915
915
|
const e = this;
|
|
916
916
|
return this.post(
|
|
917
917
|
{
|
|
918
918
|
path: "org",
|
|
919
919
|
key: "hasUser",
|
|
920
920
|
data: {
|
|
921
|
-
username:
|
|
921
|
+
username: n
|
|
922
922
|
}
|
|
923
923
|
},
|
|
924
924
|
{
|
|
925
|
-
afterResponse: async (
|
|
925
|
+
afterResponse: async (t, r) => t?.code === 401 ? await e.afterCheck401ToRefreshToken(t, r, !0) : t
|
|
926
926
|
}
|
|
927
927
|
);
|
|
928
928
|
}
|
|
@@ -931,41 +931,41 @@ var Bn = class {
|
|
|
931
931
|
* @param token
|
|
932
932
|
* @returns
|
|
933
933
|
*/
|
|
934
|
-
async checkLoginStatus(
|
|
934
|
+
async checkLoginStatus(n) {
|
|
935
935
|
const e = await this.post({
|
|
936
936
|
path: "user",
|
|
937
937
|
key: "checkLoginStatus",
|
|
938
|
-
loginToken:
|
|
938
|
+
loginToken: n
|
|
939
939
|
});
|
|
940
940
|
if (e.code === 200) {
|
|
941
|
-
const
|
|
942
|
-
return this.storage.setItem("token",
|
|
941
|
+
const t = e.data?.accessToken;
|
|
942
|
+
return this.storage.setItem("token", t || ""), await this.beforeSetLoginUser({ accessToken: t, refreshToken: e.data?.refreshToken }), e;
|
|
943
943
|
}
|
|
944
944
|
return !1;
|
|
945
945
|
}
|
|
946
946
|
/**
|
|
947
947
|
* 使用web登录,创建url地址, 需要MD5和jsonwebtoken
|
|
948
948
|
*/
|
|
949
|
-
loginWithWeb(
|
|
950
|
-
const
|
|
949
|
+
loginWithWeb(n, { MD5: e, jsonwebtoken: t }) {
|
|
950
|
+
const r = Math.random().toString(36).substring(2, 15), o = Date.now(), s = "xiao" + r, i = e(`${s}${o}`).toString(), c = t.sign({ randomId: r, timestamp: o, sign: i }, s, {
|
|
951
951
|
// 10分钟过期
|
|
952
952
|
expiresIn: 600
|
|
953
953
|
// 10分钟
|
|
954
954
|
});
|
|
955
|
-
return { url: `${
|
|
955
|
+
return { url: `${n}/api/router?path=user&key=webLogin&p&loginToken=${c}&sign=${i}&randomId=${r}`, token: c, tokenSecret: s };
|
|
956
956
|
}
|
|
957
|
-
},
|
|
958
|
-
constructor(
|
|
957
|
+
}, jn = class extends Hn {
|
|
958
|
+
constructor(n) {
|
|
959
959
|
super({
|
|
960
|
-
...
|
|
961
|
-
cache: new
|
|
960
|
+
...n,
|
|
961
|
+
cache: new Fn("login")
|
|
962
962
|
});
|
|
963
963
|
}
|
|
964
964
|
};
|
|
965
|
-
const
|
|
966
|
-
query:
|
|
965
|
+
const Vn = new Qt(), U = new jn({
|
|
966
|
+
query: Vn
|
|
967
967
|
});
|
|
968
|
-
class
|
|
968
|
+
class On extends HTMLElement {
|
|
969
969
|
options;
|
|
970
970
|
timer = null;
|
|
971
971
|
constructor() {
|
|
@@ -983,7 +983,7 @@ class Ln extends HTMLElement {
|
|
|
983
983
|
this.options = { ...this.options, ...e }, this.render();
|
|
984
984
|
}
|
|
985
985
|
render() {
|
|
986
|
-
const { type: e, message:
|
|
986
|
+
const { type: e, message: t, closable: r } = this.options, s = I`
|
|
987
987
|
<style>
|
|
988
988
|
:host {
|
|
989
989
|
display: block;
|
|
@@ -1117,19 +1117,19 @@ class Ln extends HTMLElement {
|
|
|
1117
1117
|
case "error":
|
|
1118
1118
|
return "✕";
|
|
1119
1119
|
case "loading":
|
|
1120
|
-
return
|
|
1120
|
+
return I`<div class="loading-spinner"></div>`;
|
|
1121
1121
|
default:
|
|
1122
1122
|
return "";
|
|
1123
1123
|
}
|
|
1124
1124
|
})()}
|
|
1125
1125
|
</div>
|
|
1126
|
-
<div class="message-content">${
|
|
1127
|
-
${
|
|
1126
|
+
<div class="message-content">${t}</div>
|
|
1127
|
+
${r ? I`
|
|
1128
1128
|
<button class="message-close" @click=${() => this.remove()}>×</button>
|
|
1129
1129
|
` : ""}
|
|
1130
1130
|
</div>
|
|
1131
1131
|
`;
|
|
1132
|
-
|
|
1132
|
+
Jt(s, this), e !== "loading" && this.options.duration && this.options.duration > 0 && this.setTimer();
|
|
1133
1133
|
}
|
|
1134
1134
|
setTimer() {
|
|
1135
1135
|
this.timer && clearTimeout(this.timer), this.timer = window.setTimeout(() => {
|
|
@@ -1145,20 +1145,20 @@ class Ln extends HTMLElement {
|
|
|
1145
1145
|
this.timer && (clearTimeout(this.timer), this.timer = null);
|
|
1146
1146
|
}
|
|
1147
1147
|
}
|
|
1148
|
-
customElements.define("kv-message",
|
|
1149
|
-
class
|
|
1148
|
+
customElements.define("kv-message", On);
|
|
1149
|
+
class Y {
|
|
1150
1150
|
static instance;
|
|
1151
1151
|
container = null;
|
|
1152
1152
|
defaultPosition = "center";
|
|
1153
1153
|
static getInstance() {
|
|
1154
|
-
return
|
|
1154
|
+
return Y.instance || (Y.instance = new Y()), Y.instance;
|
|
1155
1155
|
}
|
|
1156
1156
|
setDefaultPosition(e) {
|
|
1157
1157
|
this.defaultPosition = e;
|
|
1158
1158
|
}
|
|
1159
1159
|
getContainer(e) {
|
|
1160
|
-
const
|
|
1161
|
-
return this.container || (this.container = document.getElementById("messages"), this.container || (this.container = document.createElement("div"), this.container.id = "messages",
|
|
1160
|
+
const t = e || this.defaultPosition;
|
|
1161
|
+
return this.container || (this.container = document.getElementById("messages"), this.container || (this.container = document.createElement("div"), this.container.id = "messages", t === "center" ? this.container.style.cssText = `
|
|
1162
1162
|
position: fixed;
|
|
1163
1163
|
top: 20px;
|
|
1164
1164
|
left: 50%;
|
|
@@ -1182,173 +1182,255 @@ class G {
|
|
|
1182
1182
|
`, document.body.appendChild(this.container))), this.container;
|
|
1183
1183
|
}
|
|
1184
1184
|
show(e) {
|
|
1185
|
-
const
|
|
1186
|
-
return
|
|
1185
|
+
const t = this.getContainer(e.position), r = document.createElement("kv-message");
|
|
1186
|
+
return r.setOptions(e), r.style.cssText = "pointer-events: auto;", t.appendChild(r), r;
|
|
1187
1187
|
}
|
|
1188
|
-
success(e,
|
|
1188
|
+
success(e, t) {
|
|
1189
1189
|
return this.show({
|
|
1190
1190
|
type: "success",
|
|
1191
1191
|
message: e,
|
|
1192
|
-
duration:
|
|
1193
|
-
position:
|
|
1194
|
-
closable:
|
|
1192
|
+
duration: t?.duration || 2e3,
|
|
1193
|
+
position: t?.position,
|
|
1194
|
+
closable: t?.closable
|
|
1195
1195
|
});
|
|
1196
1196
|
}
|
|
1197
|
-
error(e,
|
|
1197
|
+
error(e, t) {
|
|
1198
1198
|
return this.show({
|
|
1199
1199
|
type: "error",
|
|
1200
1200
|
message: e,
|
|
1201
|
-
duration:
|
|
1202
|
-
position:
|
|
1203
|
-
closable:
|
|
1201
|
+
duration: t?.duration || 3e3,
|
|
1202
|
+
position: t?.position,
|
|
1203
|
+
closable: t?.closable
|
|
1204
1204
|
});
|
|
1205
1205
|
}
|
|
1206
|
-
loading(e,
|
|
1206
|
+
loading(e, t) {
|
|
1207
1207
|
return this.show({
|
|
1208
1208
|
type: "loading",
|
|
1209
1209
|
message: e,
|
|
1210
1210
|
duration: 0,
|
|
1211
|
-
position:
|
|
1212
|
-
closable:
|
|
1211
|
+
position: t?.position,
|
|
1212
|
+
closable: t?.closable
|
|
1213
1213
|
});
|
|
1214
1214
|
}
|
|
1215
1215
|
remove(e) {
|
|
1216
1216
|
e.remove();
|
|
1217
1217
|
}
|
|
1218
1218
|
clear() {
|
|
1219
|
-
this.getContainer().querySelectorAll("kv-message").forEach((
|
|
1220
|
-
|
|
1219
|
+
this.getContainer().querySelectorAll("kv-message").forEach((r) => {
|
|
1220
|
+
r.remove();
|
|
1221
1221
|
});
|
|
1222
1222
|
}
|
|
1223
1223
|
}
|
|
1224
|
-
const
|
|
1225
|
-
window.createMessage =
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1224
|
+
const tn = () => Y.getInstance();
|
|
1225
|
+
window.createMessage = tn;
|
|
1226
|
+
let Wn = class {
|
|
1227
|
+
events = /* @__PURE__ */ new Map();
|
|
1228
|
+
/**
|
|
1229
|
+
* 监听事件
|
|
1230
|
+
* @param type 事件类型
|
|
1231
|
+
* @param handler 事件处理函数
|
|
1232
|
+
*/
|
|
1233
|
+
on(e, t) {
|
|
1234
|
+
this.events.has(e) || this.events.set(e, /* @__PURE__ */ new Set()), this.events.get(e).add(t);
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* 移除事件监听器
|
|
1238
|
+
* @param type 事件类型
|
|
1239
|
+
* @param handler 事件处理函数 (可选,如果不提供则移除该类型的所有监听器)
|
|
1240
|
+
*/
|
|
1241
|
+
off(e, t) {
|
|
1242
|
+
this.events.has(e) && (t ? (this.events.get(e).delete(t), this.events.get(e).size === 0 && this.events.delete(e)) : this.events.delete(e));
|
|
1243
|
+
}
|
|
1244
|
+
/**
|
|
1245
|
+
* 触发事件
|
|
1246
|
+
* @param event 事件对象,包含 type 和 data
|
|
1247
|
+
*/
|
|
1248
|
+
emit(e) {
|
|
1249
|
+
const { type: t } = e;
|
|
1250
|
+
if (!this.events.has(t))
|
|
1251
|
+
return;
|
|
1252
|
+
this.events.get(t).forEach((o) => {
|
|
1253
|
+
try {
|
|
1254
|
+
o(e);
|
|
1255
|
+
} catch (s) {
|
|
1256
|
+
console.error(`Error in event handler for type "${t}":`, s);
|
|
1257
|
+
}
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* 触发事件(简化版本,直接传递type和data)
|
|
1262
|
+
* @param type 事件类型
|
|
1263
|
+
* @param data 事件数据
|
|
1264
|
+
*/
|
|
1265
|
+
emitSimple(e, t) {
|
|
1266
|
+
this.emit({ type: e, data: t });
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* 清空所有事件监听器
|
|
1270
|
+
*/
|
|
1271
|
+
clear() {
|
|
1272
|
+
this.events.clear();
|
|
1273
|
+
}
|
|
1274
|
+
/**
|
|
1275
|
+
* 获取指定类型的监听器数量
|
|
1276
|
+
* @param type 事件类型
|
|
1277
|
+
* @returns 监听器数量
|
|
1278
|
+
*/
|
|
1279
|
+
listenerCount(e) {
|
|
1280
|
+
return this.events.get(e)?.size || 0;
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* 获取所有事件类型
|
|
1284
|
+
* @returns 事件类型数组
|
|
1285
|
+
*/
|
|
1286
|
+
eventNames() {
|
|
1287
|
+
return Array.from(this.events.keys());
|
|
1288
|
+
}
|
|
1289
|
+
/**
|
|
1290
|
+
* 检查是否有指定类型的监听器
|
|
1291
|
+
* @param type 事件类型
|
|
1292
|
+
* @returns 是否有监听器
|
|
1293
|
+
*/
|
|
1294
|
+
hasListeners(e) {
|
|
1295
|
+
return this.events.has(e) && this.events.get(e).size > 0;
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* 只监听一次事件
|
|
1299
|
+
* @param type 事件类型
|
|
1300
|
+
* @param handler 事件处理函数
|
|
1301
|
+
*/
|
|
1302
|
+
once(e, t) {
|
|
1303
|
+
const r = (o) => {
|
|
1304
|
+
t(o), this.off(e, r);
|
|
1305
|
+
};
|
|
1306
|
+
this.on(e, r);
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
const nn = new Wn(), Kn = (n) => nn.emit(n), F = tn(), ie = () => {
|
|
1310
|
+
const n = window.location.href, t = new URL(n).searchParams.get("redirect");
|
|
1311
|
+
if (t) {
|
|
1312
|
+
const r = decodeURIComponent(t);
|
|
1313
|
+
window.open(r, "_self");
|
|
1314
|
+
}
|
|
1315
|
+
Kn({ type: "login-success", data: {} });
|
|
1316
|
+
}, Jn = async (n) => {
|
|
1317
|
+
const { loginMethod: e, data: t } = n;
|
|
1236
1318
|
switch (e) {
|
|
1237
1319
|
case "password":
|
|
1238
|
-
await
|
|
1320
|
+
await Qn(t);
|
|
1239
1321
|
break;
|
|
1240
1322
|
case "phone":
|
|
1241
|
-
await
|
|
1323
|
+
await Gn(t);
|
|
1242
1324
|
break;
|
|
1243
1325
|
case "wechat-mp":
|
|
1244
|
-
await
|
|
1326
|
+
await Xn(t);
|
|
1245
1327
|
break;
|
|
1246
1328
|
case "wechat":
|
|
1247
|
-
await
|
|
1329
|
+
await Yn(t);
|
|
1248
1330
|
break;
|
|
1249
1331
|
default:
|
|
1250
1332
|
console.warn("未知的登录方式:", e);
|
|
1251
1333
|
}
|
|
1252
|
-
},
|
|
1253
|
-
console.log("使用用户名密码登录:",
|
|
1334
|
+
}, Qn = async (n) => {
|
|
1335
|
+
console.log("使用用户名密码登录:", n);
|
|
1254
1336
|
let e = !0;
|
|
1255
|
-
if (await
|
|
1256
|
-
|
|
1337
|
+
if (await U.checkLocalToken() && (await U.checkLocalUser())?.username === n?.username && (await U.getMe()).code === 200 && (e = !1, console.log("已登录,跳过登录步骤"), F.success("已登录")), !e) {
|
|
1338
|
+
ie();
|
|
1257
1339
|
return;
|
|
1258
1340
|
}
|
|
1259
|
-
const
|
|
1260
|
-
username:
|
|
1261
|
-
password:
|
|
1341
|
+
const r = await U.login({
|
|
1342
|
+
username: n.username,
|
|
1343
|
+
password: n.password
|
|
1262
1344
|
});
|
|
1263
|
-
|
|
1264
|
-
},
|
|
1265
|
-
console.log("使用手机号登录:",
|
|
1266
|
-
},
|
|
1267
|
-
console.log("使用微信登录:",
|
|
1268
|
-
},
|
|
1269
|
-
console.log("使用微信公众号登录:",
|
|
1270
|
-
},
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1273
|
-
},
|
|
1274
|
-
const
|
|
1275
|
-
if (
|
|
1345
|
+
r.code === 200 ? (console.log("登录成功"), F.success("登录成功"), ie()) : F.error(`登录失败: ${r.message}`);
|
|
1346
|
+
}, Gn = async (n) => {
|
|
1347
|
+
console.log("使用手机号登录:", n);
|
|
1348
|
+
}, Yn = async (n) => {
|
|
1349
|
+
console.log("使用微信登录:", n);
|
|
1350
|
+
}, Xn = async (n) => {
|
|
1351
|
+
console.log("使用微信公众号登录:", n);
|
|
1352
|
+
}, Zn = () => {
|
|
1353
|
+
const n = new URL(window.location.href);
|
|
1354
|
+
n.searchParams.delete("code"), n.searchParams.delete("state"), window.history.replaceState({}, document.title, n.toString());
|
|
1355
|
+
}, er = async () => {
|
|
1356
|
+
const n = new URL(window.location.href), e = n.searchParams.get("code");
|
|
1357
|
+
if (n.searchParams.get("state")?.includes?.("-") || !e)
|
|
1276
1358
|
return;
|
|
1277
|
-
const
|
|
1278
|
-
|
|
1279
|
-
},
|
|
1280
|
-
const
|
|
1281
|
-
if (console.log("检查微信公众号登录流程:",
|
|
1282
|
-
|
|
1283
|
-
else if (
|
|
1284
|
-
const o =
|
|
1359
|
+
const r = await U.loginByWechat({ code: e });
|
|
1360
|
+
r.code === 200 ? (F.success("登录成功"), ie()) : (F.error(r.message || "登录失败"), Zn());
|
|
1361
|
+
}, tr = async () => {
|
|
1362
|
+
const n = new URL(window.location.href), e = n.searchParams.get("state"), [t, r] = e ? e.split("-") : [null, null];
|
|
1363
|
+
if (console.log("检查微信公众号登录流程:", t, r, e), t === "1")
|
|
1364
|
+
rr();
|
|
1365
|
+
else if (t === "2") {
|
|
1366
|
+
const o = n.searchParams.get("code"), s = await U.post({
|
|
1285
1367
|
path: "wx",
|
|
1286
1368
|
key: "mplogin",
|
|
1287
|
-
state:
|
|
1369
|
+
state: r,
|
|
1288
1370
|
code: o
|
|
1289
1371
|
});
|
|
1290
|
-
s.code === 200 ?
|
|
1372
|
+
s.code === 200 ? F.success("登录成功") : F.error(s.message || "登录失败"), rn();
|
|
1291
1373
|
}
|
|
1292
|
-
},
|
|
1293
|
-
const
|
|
1294
|
-
return /micromessenger/i.test(
|
|
1295
|
-
},
|
|
1296
|
-
if (!
|
|
1374
|
+
}, nr = () => {
|
|
1375
|
+
const n = navigator.userAgent.toLowerCase();
|
|
1376
|
+
return /micromessenger/i.test(n);
|
|
1377
|
+
}, rn = (n = 2e3) => {
|
|
1378
|
+
if (!nr()) {
|
|
1297
1379
|
setTimeout(() => {
|
|
1298
1380
|
window.close();
|
|
1299
|
-
},
|
|
1381
|
+
}, n);
|
|
1300
1382
|
return;
|
|
1301
1383
|
}
|
|
1302
1384
|
window.WeixinJSBridge ? setTimeout(() => {
|
|
1303
1385
|
window.WeixinJSBridge.call("closeWindow");
|
|
1304
|
-
},
|
|
1386
|
+
}, n) : setTimeout(() => {
|
|
1305
1387
|
window.close();
|
|
1306
|
-
},
|
|
1307
|
-
},
|
|
1308
|
-
const
|
|
1309
|
-
let [o, s] =
|
|
1310
|
-
const i = new URL(
|
|
1388
|
+
}, n);
|
|
1389
|
+
}, rr = async () => {
|
|
1390
|
+
const n = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect", e = dn, t = new URL(window.location.href), r = t.searchParams.get("state");
|
|
1391
|
+
let [o, s] = r ? r.split("-") : [null, null];
|
|
1392
|
+
const i = new URL(t.pathname, t.origin);
|
|
1311
1393
|
s = "2-" + s;
|
|
1312
1394
|
const c = encodeURIComponent(i.toString());
|
|
1313
1395
|
document.body.innerHTML = "<p>正在准备跳转到微信公众号授权页面...</p>";
|
|
1314
1396
|
const a = "snsapi_userinfo";
|
|
1315
1397
|
if (!s) {
|
|
1316
|
-
alert("Invalid state. Please try again later."),
|
|
1398
|
+
alert("Invalid state. Please try again later."), rn();
|
|
1317
1399
|
return;
|
|
1318
1400
|
}
|
|
1319
|
-
const l =
|
|
1401
|
+
const l = n.replace("APPID", e).replace("REDIRECT_URI", c).replace("SCOPE", a).replace("STATE", s);
|
|
1320
1402
|
setTimeout(() => {
|
|
1321
1403
|
window.location.href = l;
|
|
1322
1404
|
}, 100);
|
|
1323
1405
|
};
|
|
1324
1406
|
setTimeout(() => {
|
|
1325
|
-
|
|
1407
|
+
tr();
|
|
1326
1408
|
}, 100);
|
|
1327
|
-
const
|
|
1328
|
-
const
|
|
1409
|
+
const or = async () => {
|
|
1410
|
+
const n = await U.post({
|
|
1329
1411
|
path: "wx",
|
|
1330
1412
|
key: "get-qrcode-ticket"
|
|
1331
1413
|
});
|
|
1332
|
-
return
|
|
1333
|
-
},
|
|
1414
|
+
return n.code !== 200 ? (F.error("获取二维码失败"), null) : n?.data;
|
|
1415
|
+
}, sr = (n) => {
|
|
1334
1416
|
let e = !0;
|
|
1335
|
-
const
|
|
1336
|
-
const s = await
|
|
1417
|
+
const t = async () => {
|
|
1418
|
+
const s = await U.post({
|
|
1337
1419
|
path: "wx",
|
|
1338
1420
|
key: "check-qrcode-login",
|
|
1339
|
-
payload: { ticket:
|
|
1421
|
+
payload: { ticket: n }
|
|
1340
1422
|
});
|
|
1341
|
-
s.code === 200 ? (
|
|
1342
|
-
},
|
|
1423
|
+
s.code === 200 ? (F.success("登录成功"), clearTimeout(r), ie()) : (s.code === 401 ? console.log("等待扫码登录...") : console.log("扫码登录状态:", s), e && setTimeout(t, 2e3));
|
|
1424
|
+
}, r = setTimeout(t, 2e3);
|
|
1343
1425
|
return () => {
|
|
1344
|
-
console.log("停止检测扫码登录状态"), clearTimeout(
|
|
1426
|
+
console.log("停止检测扫码登录状态"), clearTimeout(r), e = !1;
|
|
1345
1427
|
};
|
|
1346
|
-
},
|
|
1347
|
-
let e =
|
|
1348
|
-
const { appid:
|
|
1428
|
+
}, ht = async (n) => {
|
|
1429
|
+
let e = n?.redirect_uri;
|
|
1430
|
+
const { appid: t } = n || {};
|
|
1349
1431
|
e || (e = window.location.href);
|
|
1350
|
-
const
|
|
1351
|
-
if (
|
|
1432
|
+
const r = new URL(e);
|
|
1433
|
+
if (r.searchParams.delete("code"), r.searchParams.delete("state"), e = r.toString(), console.log("redirect_uri", e), !t) {
|
|
1352
1434
|
console.error("appid is not cant be empty");
|
|
1353
1435
|
return;
|
|
1354
1436
|
}
|
|
@@ -1356,7 +1438,7 @@ const Vn = async () => {
|
|
|
1356
1438
|
self_redirect: !1,
|
|
1357
1439
|
id: "weixinLogin",
|
|
1358
1440
|
// 需要显示的容器id
|
|
1359
|
-
appid:
|
|
1441
|
+
appid: t,
|
|
1360
1442
|
// 微信开放平台appid wx*******
|
|
1361
1443
|
scope: "snsapi_login",
|
|
1362
1444
|
// 网页默认即可 snsapi_userinfo
|
|
@@ -1375,31 +1457,31 @@ const Vn = async () => {
|
|
|
1375
1457
|
}
|
|
1376
1458
|
return o;
|
|
1377
1459
|
};
|
|
1378
|
-
function
|
|
1460
|
+
function ir(n) {
|
|
1379
1461
|
const e = document.createElement("script");
|
|
1380
1462
|
if (e.type = "text/javascript", e.src = "//res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js", e.id = "weixinLogin-js", document.getElementById("weixinLogin-js")) {
|
|
1381
|
-
|
|
1463
|
+
ht(n);
|
|
1382
1464
|
return;
|
|
1383
1465
|
}
|
|
1384
|
-
const
|
|
1385
|
-
|
|
1386
|
-
|
|
1466
|
+
const t = document.body.appendChild(e);
|
|
1467
|
+
t.onload = function() {
|
|
1468
|
+
ht(n);
|
|
1387
1469
|
};
|
|
1388
1470
|
}
|
|
1389
|
-
function
|
|
1390
|
-
return
|
|
1471
|
+
function ar(n) {
|
|
1472
|
+
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
1391
1473
|
}
|
|
1392
|
-
var
|
|
1393
|
-
function
|
|
1394
|
-
return
|
|
1474
|
+
var G = {}, Ae, dt;
|
|
1475
|
+
function cr() {
|
|
1476
|
+
return dt || (dt = 1, Ae = function() {
|
|
1395
1477
|
return typeof Promise == "function" && Promise.prototype && Promise.prototype.then;
|
|
1396
|
-
}),
|
|
1478
|
+
}), Ae;
|
|
1397
1479
|
}
|
|
1398
|
-
var
|
|
1399
|
-
function
|
|
1400
|
-
if (
|
|
1401
|
-
|
|
1402
|
-
let
|
|
1480
|
+
var Te = {}, H = {}, ft;
|
|
1481
|
+
function K() {
|
|
1482
|
+
if (ft) return H;
|
|
1483
|
+
ft = 1;
|
|
1484
|
+
let n;
|
|
1403
1485
|
const e = [
|
|
1404
1486
|
0,
|
|
1405
1487
|
// Not used
|
|
@@ -1444,121 +1526,121 @@ function O() {
|
|
|
1444
1526
|
3532,
|
|
1445
1527
|
3706
|
|
1446
1528
|
];
|
|
1447
|
-
return
|
|
1448
|
-
if (!
|
|
1449
|
-
if (
|
|
1450
|
-
return
|
|
1451
|
-
},
|
|
1452
|
-
return e[
|
|
1453
|
-
},
|
|
1454
|
-
let
|
|
1455
|
-
for (;
|
|
1456
|
-
|
|
1457
|
-
return
|
|
1458
|
-
},
|
|
1459
|
-
if (typeof
|
|
1529
|
+
return H.getSymbolSize = function(r) {
|
|
1530
|
+
if (!r) throw new Error('"version" cannot be null or undefined');
|
|
1531
|
+
if (r < 1 || r > 40) throw new Error('"version" should be in range from 1 to 40');
|
|
1532
|
+
return r * 4 + 17;
|
|
1533
|
+
}, H.getSymbolTotalCodewords = function(r) {
|
|
1534
|
+
return e[r];
|
|
1535
|
+
}, H.getBCHDigit = function(t) {
|
|
1536
|
+
let r = 0;
|
|
1537
|
+
for (; t !== 0; )
|
|
1538
|
+
r++, t >>>= 1;
|
|
1539
|
+
return r;
|
|
1540
|
+
}, H.setToSJISFunction = function(r) {
|
|
1541
|
+
if (typeof r != "function")
|
|
1460
1542
|
throw new Error('"toSJISFunc" is not a valid function.');
|
|
1461
|
-
|
|
1462
|
-
},
|
|
1463
|
-
return typeof
|
|
1464
|
-
},
|
|
1465
|
-
return
|
|
1466
|
-
},
|
|
1467
|
-
}
|
|
1468
|
-
var
|
|
1469
|
-
function
|
|
1470
|
-
return
|
|
1471
|
-
|
|
1472
|
-
function e(
|
|
1473
|
-
if (typeof
|
|
1543
|
+
n = r;
|
|
1544
|
+
}, H.isKanjiModeEnabled = function() {
|
|
1545
|
+
return typeof n < "u";
|
|
1546
|
+
}, H.toSJIS = function(r) {
|
|
1547
|
+
return n(r);
|
|
1548
|
+
}, H;
|
|
1549
|
+
}
|
|
1550
|
+
var Ee = {}, gt;
|
|
1551
|
+
function Ye() {
|
|
1552
|
+
return gt || (gt = 1, (function(n) {
|
|
1553
|
+
n.L = { bit: 1 }, n.M = { bit: 0 }, n.Q = { bit: 3 }, n.H = { bit: 2 };
|
|
1554
|
+
function e(t) {
|
|
1555
|
+
if (typeof t != "string")
|
|
1474
1556
|
throw new Error("Param is not a string");
|
|
1475
|
-
switch (
|
|
1557
|
+
switch (t.toLowerCase()) {
|
|
1476
1558
|
case "l":
|
|
1477
1559
|
case "low":
|
|
1478
|
-
return
|
|
1560
|
+
return n.L;
|
|
1479
1561
|
case "m":
|
|
1480
1562
|
case "medium":
|
|
1481
|
-
return
|
|
1563
|
+
return n.M;
|
|
1482
1564
|
case "q":
|
|
1483
1565
|
case "quartile":
|
|
1484
|
-
return
|
|
1566
|
+
return n.Q;
|
|
1485
1567
|
case "h":
|
|
1486
1568
|
case "high":
|
|
1487
|
-
return
|
|
1569
|
+
return n.H;
|
|
1488
1570
|
default:
|
|
1489
|
-
throw new Error("Unknown EC Level: " +
|
|
1571
|
+
throw new Error("Unknown EC Level: " + t);
|
|
1490
1572
|
}
|
|
1491
1573
|
}
|
|
1492
|
-
|
|
1493
|
-
return
|
|
1494
|
-
},
|
|
1495
|
-
if (
|
|
1496
|
-
return
|
|
1574
|
+
n.isValid = function(r) {
|
|
1575
|
+
return r && typeof r.bit < "u" && r.bit >= 0 && r.bit < 4;
|
|
1576
|
+
}, n.from = function(r, o) {
|
|
1577
|
+
if (n.isValid(r))
|
|
1578
|
+
return r;
|
|
1497
1579
|
try {
|
|
1498
|
-
return e(
|
|
1580
|
+
return e(r);
|
|
1499
1581
|
} catch {
|
|
1500
1582
|
return o;
|
|
1501
1583
|
}
|
|
1502
1584
|
};
|
|
1503
|
-
})(
|
|
1585
|
+
})(Ee)), Ee;
|
|
1504
1586
|
}
|
|
1505
|
-
var
|
|
1506
|
-
function
|
|
1507
|
-
if (
|
|
1508
|
-
|
|
1509
|
-
function
|
|
1587
|
+
var _e, mt;
|
|
1588
|
+
function lr() {
|
|
1589
|
+
if (mt) return _e;
|
|
1590
|
+
mt = 1;
|
|
1591
|
+
function n() {
|
|
1510
1592
|
this.buffer = [], this.length = 0;
|
|
1511
1593
|
}
|
|
1512
|
-
return
|
|
1594
|
+
return n.prototype = {
|
|
1513
1595
|
get: function(e) {
|
|
1514
|
-
const
|
|
1515
|
-
return (this.buffer[
|
|
1596
|
+
const t = Math.floor(e / 8);
|
|
1597
|
+
return (this.buffer[t] >>> 7 - e % 8 & 1) === 1;
|
|
1516
1598
|
},
|
|
1517
|
-
put: function(e,
|
|
1518
|
-
for (let
|
|
1519
|
-
this.putBit((e >>>
|
|
1599
|
+
put: function(e, t) {
|
|
1600
|
+
for (let r = 0; r < t; r++)
|
|
1601
|
+
this.putBit((e >>> t - r - 1 & 1) === 1);
|
|
1520
1602
|
},
|
|
1521
1603
|
getLengthInBits: function() {
|
|
1522
1604
|
return this.length;
|
|
1523
1605
|
},
|
|
1524
1606
|
putBit: function(e) {
|
|
1525
|
-
const
|
|
1526
|
-
this.buffer.length <=
|
|
1607
|
+
const t = Math.floor(this.length / 8);
|
|
1608
|
+
this.buffer.length <= t && this.buffer.push(0), e && (this.buffer[t] |= 128 >>> this.length % 8), this.length++;
|
|
1527
1609
|
}
|
|
1528
|
-
},
|
|
1610
|
+
}, _e = n, _e;
|
|
1529
1611
|
}
|
|
1530
|
-
var
|
|
1531
|
-
function
|
|
1532
|
-
if (
|
|
1533
|
-
|
|
1534
|
-
function
|
|
1612
|
+
var ke, pt;
|
|
1613
|
+
function ur() {
|
|
1614
|
+
if (pt) return ke;
|
|
1615
|
+
pt = 1;
|
|
1616
|
+
function n(e) {
|
|
1535
1617
|
if (!e || e < 1)
|
|
1536
1618
|
throw new Error("BitMatrix size must be defined and greater than 0");
|
|
1537
1619
|
this.size = e, this.data = new Uint8Array(e * e), this.reservedBit = new Uint8Array(e * e);
|
|
1538
1620
|
}
|
|
1539
|
-
return
|
|
1540
|
-
const s = e * this.size +
|
|
1541
|
-
this.data[s] =
|
|
1542
|
-
},
|
|
1543
|
-
return this.data[e * this.size +
|
|
1544
|
-
},
|
|
1545
|
-
this.data[e * this.size +
|
|
1546
|
-
},
|
|
1547
|
-
return this.reservedBit[e * this.size +
|
|
1548
|
-
},
|
|
1549
|
-
}
|
|
1550
|
-
var
|
|
1551
|
-
function
|
|
1552
|
-
return
|
|
1553
|
-
const e =
|
|
1554
|
-
|
|
1555
|
-
if (
|
|
1556
|
-
const o = Math.floor(
|
|
1621
|
+
return n.prototype.set = function(e, t, r, o) {
|
|
1622
|
+
const s = e * this.size + t;
|
|
1623
|
+
this.data[s] = r, o && (this.reservedBit[s] = !0);
|
|
1624
|
+
}, n.prototype.get = function(e, t) {
|
|
1625
|
+
return this.data[e * this.size + t];
|
|
1626
|
+
}, n.prototype.xor = function(e, t, r) {
|
|
1627
|
+
this.data[e * this.size + t] ^= r;
|
|
1628
|
+
}, n.prototype.isReserved = function(e, t) {
|
|
1629
|
+
return this.reservedBit[e * this.size + t];
|
|
1630
|
+
}, ke = n, ke;
|
|
1631
|
+
}
|
|
1632
|
+
var xe = {}, wt;
|
|
1633
|
+
function hr() {
|
|
1634
|
+
return wt || (wt = 1, (function(n) {
|
|
1635
|
+
const e = K().getSymbolSize;
|
|
1636
|
+
n.getRowColCoords = function(r) {
|
|
1637
|
+
if (r === 1) return [];
|
|
1638
|
+
const o = Math.floor(r / 7) + 2, s = e(r), i = s === 145 ? 26 : Math.ceil((s - 13) / (2 * o - 2)) * 2, c = [s - 7];
|
|
1557
1639
|
for (let a = 1; a < o - 1; a++)
|
|
1558
1640
|
c[a] = c[a - 1] - i;
|
|
1559
1641
|
return c.push(6), c.reverse();
|
|
1560
|
-
},
|
|
1561
|
-
const o = [], s =
|
|
1642
|
+
}, n.getPositions = function(r) {
|
|
1643
|
+
const o = [], s = n.getRowColCoords(r), i = s.length;
|
|
1562
1644
|
for (let c = 0; c < i; c++)
|
|
1563
1645
|
for (let a = 0; a < i; a++)
|
|
1564
1646
|
c === 0 && a === 0 || // top-left
|
|
@@ -1566,15 +1648,15 @@ function Yn() {
|
|
|
1566
1648
|
c === i - 1 && a === 0 || o.push([s[c], s[a]]);
|
|
1567
1649
|
return o;
|
|
1568
1650
|
};
|
|
1569
|
-
})(
|
|
1651
|
+
})(xe)), xe;
|
|
1570
1652
|
}
|
|
1571
|
-
var
|
|
1572
|
-
function
|
|
1573
|
-
if (
|
|
1574
|
-
|
|
1575
|
-
const
|
|
1576
|
-
return
|
|
1577
|
-
const o =
|
|
1653
|
+
var Re = {}, yt;
|
|
1654
|
+
function dr() {
|
|
1655
|
+
if (yt) return Re;
|
|
1656
|
+
yt = 1;
|
|
1657
|
+
const n = K().getSymbolSize, e = 7;
|
|
1658
|
+
return Re.getPositions = function(r) {
|
|
1659
|
+
const o = n(r);
|
|
1578
1660
|
return [
|
|
1579
1661
|
// top-left
|
|
1580
1662
|
[0, 0],
|
|
@@ -1583,12 +1665,12 @@ function Xn() {
|
|
|
1583
1665
|
// bottom-left
|
|
1584
1666
|
[0, o - e]
|
|
1585
1667
|
];
|
|
1586
|
-
},
|
|
1668
|
+
}, Re;
|
|
1587
1669
|
}
|
|
1588
|
-
var
|
|
1589
|
-
function
|
|
1590
|
-
return
|
|
1591
|
-
|
|
1670
|
+
var Se = {}, vt;
|
|
1671
|
+
function fr() {
|
|
1672
|
+
return vt || (vt = 1, (function(n) {
|
|
1673
|
+
n.Patterns = {
|
|
1592
1674
|
PATTERN000: 0,
|
|
1593
1675
|
PATTERN001: 1,
|
|
1594
1676
|
PATTERN010: 2,
|
|
@@ -1604,11 +1686,11 @@ function Zn() {
|
|
|
1604
1686
|
N3: 40,
|
|
1605
1687
|
N4: 10
|
|
1606
1688
|
};
|
|
1607
|
-
|
|
1689
|
+
n.isValid = function(o) {
|
|
1608
1690
|
return o != null && o !== "" && !isNaN(o) && o >= 0 && o <= 7;
|
|
1609
|
-
},
|
|
1610
|
-
return
|
|
1611
|
-
},
|
|
1691
|
+
}, n.from = function(o) {
|
|
1692
|
+
return n.isValid(o) ? parseInt(o, 10) : void 0;
|
|
1693
|
+
}, n.getPenaltyN1 = function(o) {
|
|
1612
1694
|
const s = o.size;
|
|
1613
1695
|
let i = 0, c = 0, a = 0, l = null, u = null;
|
|
1614
1696
|
for (let h = 0; h < s; h++) {
|
|
@@ -1620,7 +1702,7 @@ function Zn() {
|
|
|
1620
1702
|
c >= 5 && (i += e.N1 + (c - 5)), a >= 5 && (i += e.N1 + (a - 5));
|
|
1621
1703
|
}
|
|
1622
1704
|
return i;
|
|
1623
|
-
},
|
|
1705
|
+
}, n.getPenaltyN2 = function(o) {
|
|
1624
1706
|
const s = o.size;
|
|
1625
1707
|
let i = 0;
|
|
1626
1708
|
for (let c = 0; c < s - 1; c++)
|
|
@@ -1629,7 +1711,7 @@ function Zn() {
|
|
|
1629
1711
|
(l === 4 || l === 0) && i++;
|
|
1630
1712
|
}
|
|
1631
1713
|
return i * e.N2;
|
|
1632
|
-
},
|
|
1714
|
+
}, n.getPenaltyN3 = function(o) {
|
|
1633
1715
|
const s = o.size;
|
|
1634
1716
|
let i = 0, c = 0, a = 0;
|
|
1635
1717
|
for (let l = 0; l < s; l++) {
|
|
@@ -1638,56 +1720,56 @@ function Zn() {
|
|
|
1638
1720
|
c = c << 1 & 2047 | o.get(l, u), u >= 10 && (c === 1488 || c === 93) && i++, a = a << 1 & 2047 | o.get(u, l), u >= 10 && (a === 1488 || a === 93) && i++;
|
|
1639
1721
|
}
|
|
1640
1722
|
return i * e.N3;
|
|
1641
|
-
},
|
|
1723
|
+
}, n.getPenaltyN4 = function(o) {
|
|
1642
1724
|
let s = 0;
|
|
1643
1725
|
const i = o.data.length;
|
|
1644
1726
|
for (let a = 0; a < i; a++) s += o.data[a];
|
|
1645
1727
|
return Math.abs(Math.ceil(s * 100 / i / 5) - 10) * e.N4;
|
|
1646
1728
|
};
|
|
1647
|
-
function r
|
|
1648
|
-
switch (
|
|
1649
|
-
case
|
|
1729
|
+
function t(r, o, s) {
|
|
1730
|
+
switch (r) {
|
|
1731
|
+
case n.Patterns.PATTERN000:
|
|
1650
1732
|
return (o + s) % 2 === 0;
|
|
1651
|
-
case
|
|
1733
|
+
case n.Patterns.PATTERN001:
|
|
1652
1734
|
return o % 2 === 0;
|
|
1653
|
-
case
|
|
1735
|
+
case n.Patterns.PATTERN010:
|
|
1654
1736
|
return s % 3 === 0;
|
|
1655
|
-
case
|
|
1737
|
+
case n.Patterns.PATTERN011:
|
|
1656
1738
|
return (o + s) % 3 === 0;
|
|
1657
|
-
case
|
|
1739
|
+
case n.Patterns.PATTERN100:
|
|
1658
1740
|
return (Math.floor(o / 2) + Math.floor(s / 3)) % 2 === 0;
|
|
1659
|
-
case
|
|
1741
|
+
case n.Patterns.PATTERN101:
|
|
1660
1742
|
return o * s % 2 + o * s % 3 === 0;
|
|
1661
|
-
case
|
|
1743
|
+
case n.Patterns.PATTERN110:
|
|
1662
1744
|
return (o * s % 2 + o * s % 3) % 2 === 0;
|
|
1663
|
-
case
|
|
1745
|
+
case n.Patterns.PATTERN111:
|
|
1664
1746
|
return (o * s % 3 + (o + s) % 2) % 2 === 0;
|
|
1665
1747
|
default:
|
|
1666
|
-
throw new Error("bad maskPattern:" +
|
|
1748
|
+
throw new Error("bad maskPattern:" + r);
|
|
1667
1749
|
}
|
|
1668
1750
|
}
|
|
1669
|
-
|
|
1751
|
+
n.applyMask = function(o, s) {
|
|
1670
1752
|
const i = s.size;
|
|
1671
1753
|
for (let c = 0; c < i; c++)
|
|
1672
1754
|
for (let a = 0; a < i; a++)
|
|
1673
|
-
s.isReserved(a, c) || s.xor(a, c,
|
|
1674
|
-
},
|
|
1675
|
-
const i = Object.keys(
|
|
1755
|
+
s.isReserved(a, c) || s.xor(a, c, t(o, a, c));
|
|
1756
|
+
}, n.getBestMask = function(o, s) {
|
|
1757
|
+
const i = Object.keys(n.Patterns).length;
|
|
1676
1758
|
let c = 0, a = 1 / 0;
|
|
1677
1759
|
for (let l = 0; l < i; l++) {
|
|
1678
|
-
s(l),
|
|
1679
|
-
const u =
|
|
1680
|
-
|
|
1760
|
+
s(l), n.applyMask(l, o);
|
|
1761
|
+
const u = n.getPenaltyN1(o) + n.getPenaltyN2(o) + n.getPenaltyN3(o) + n.getPenaltyN4(o);
|
|
1762
|
+
n.applyMask(l, o), u < a && (a = u, c = l);
|
|
1681
1763
|
}
|
|
1682
1764
|
return c;
|
|
1683
1765
|
};
|
|
1684
|
-
})(
|
|
1766
|
+
})(Se)), Se;
|
|
1685
1767
|
}
|
|
1686
|
-
var
|
|
1687
|
-
function
|
|
1688
|
-
if (
|
|
1689
|
-
|
|
1690
|
-
const
|
|
1768
|
+
var le = {}, bt;
|
|
1769
|
+
function on() {
|
|
1770
|
+
if (bt) return le;
|
|
1771
|
+
bt = 1;
|
|
1772
|
+
const n = Ye(), e = [
|
|
1691
1773
|
// L M Q H
|
|
1692
1774
|
1,
|
|
1693
1775
|
1,
|
|
@@ -1849,7 +1931,7 @@ function Kt() {
|
|
|
1849
1931
|
49,
|
|
1850
1932
|
68,
|
|
1851
1933
|
81
|
|
1852
|
-
],
|
|
1934
|
+
], t = [
|
|
1853
1935
|
// L M Q H
|
|
1854
1936
|
7,
|
|
1855
1937
|
10,
|
|
@@ -2012,66 +2094,66 @@ function Kt() {
|
|
|
2012
2094
|
2040,
|
|
2013
2095
|
2430
|
|
2014
2096
|
];
|
|
2015
|
-
return
|
|
2097
|
+
return le.getBlocksCount = function(o, s) {
|
|
2016
2098
|
switch (s) {
|
|
2017
|
-
case
|
|
2099
|
+
case n.L:
|
|
2018
2100
|
return e[(o - 1) * 4 + 0];
|
|
2019
|
-
case
|
|
2101
|
+
case n.M:
|
|
2020
2102
|
return e[(o - 1) * 4 + 1];
|
|
2021
|
-
case
|
|
2103
|
+
case n.Q:
|
|
2022
2104
|
return e[(o - 1) * 4 + 2];
|
|
2023
|
-
case
|
|
2105
|
+
case n.H:
|
|
2024
2106
|
return e[(o - 1) * 4 + 3];
|
|
2025
2107
|
default:
|
|
2026
2108
|
return;
|
|
2027
2109
|
}
|
|
2028
|
-
},
|
|
2110
|
+
}, le.getTotalCodewordsCount = function(o, s) {
|
|
2029
2111
|
switch (s) {
|
|
2030
|
-
case
|
|
2031
|
-
return
|
|
2032
|
-
case
|
|
2033
|
-
return
|
|
2034
|
-
case
|
|
2035
|
-
return
|
|
2036
|
-
case
|
|
2037
|
-
return
|
|
2112
|
+
case n.L:
|
|
2113
|
+
return t[(o - 1) * 4 + 0];
|
|
2114
|
+
case n.M:
|
|
2115
|
+
return t[(o - 1) * 4 + 1];
|
|
2116
|
+
case n.Q:
|
|
2117
|
+
return t[(o - 1) * 4 + 2];
|
|
2118
|
+
case n.H:
|
|
2119
|
+
return t[(o - 1) * 4 + 3];
|
|
2038
2120
|
default:
|
|
2039
2121
|
return;
|
|
2040
2122
|
}
|
|
2041
|
-
},
|
|
2123
|
+
}, le;
|
|
2042
2124
|
}
|
|
2043
|
-
var
|
|
2044
|
-
function
|
|
2045
|
-
if (
|
|
2046
|
-
|
|
2047
|
-
const
|
|
2125
|
+
var Me = {}, ne = {}, Ct;
|
|
2126
|
+
function gr() {
|
|
2127
|
+
if (Ct) return ne;
|
|
2128
|
+
Ct = 1;
|
|
2129
|
+
const n = new Uint8Array(512), e = new Uint8Array(256);
|
|
2048
2130
|
return (function() {
|
|
2049
|
-
let
|
|
2131
|
+
let r = 1;
|
|
2050
2132
|
for (let o = 0; o < 255; o++)
|
|
2051
|
-
|
|
2133
|
+
n[o] = r, e[r] = o, r <<= 1, r & 256 && (r ^= 285);
|
|
2052
2134
|
for (let o = 255; o < 512; o++)
|
|
2053
|
-
|
|
2054
|
-
})(),
|
|
2055
|
-
if (
|
|
2056
|
-
return e[
|
|
2057
|
-
},
|
|
2058
|
-
return
|
|
2059
|
-
},
|
|
2060
|
-
return
|
|
2061
|
-
},
|
|
2062
|
-
}
|
|
2063
|
-
var
|
|
2064
|
-
function
|
|
2065
|
-
return
|
|
2066
|
-
const e =
|
|
2067
|
-
|
|
2068
|
-
const s = new Uint8Array(
|
|
2069
|
-
for (let i = 0; i <
|
|
2135
|
+
n[o] = n[o - 255];
|
|
2136
|
+
})(), ne.log = function(r) {
|
|
2137
|
+
if (r < 1) throw new Error("log(" + r + ")");
|
|
2138
|
+
return e[r];
|
|
2139
|
+
}, ne.exp = function(r) {
|
|
2140
|
+
return n[r];
|
|
2141
|
+
}, ne.mul = function(r, o) {
|
|
2142
|
+
return r === 0 || o === 0 ? 0 : n[e[r] + e[o]];
|
|
2143
|
+
}, ne;
|
|
2144
|
+
}
|
|
2145
|
+
var At;
|
|
2146
|
+
function mr() {
|
|
2147
|
+
return At || (At = 1, (function(n) {
|
|
2148
|
+
const e = gr();
|
|
2149
|
+
n.mul = function(r, o) {
|
|
2150
|
+
const s = new Uint8Array(r.length + o.length - 1);
|
|
2151
|
+
for (let i = 0; i < r.length; i++)
|
|
2070
2152
|
for (let c = 0; c < o.length; c++)
|
|
2071
|
-
s[i + c] ^= e.mul(
|
|
2153
|
+
s[i + c] ^= e.mul(r[i], o[c]);
|
|
2072
2154
|
return s;
|
|
2073
|
-
},
|
|
2074
|
-
let s = new Uint8Array(
|
|
2155
|
+
}, n.mod = function(r, o) {
|
|
2156
|
+
let s = new Uint8Array(r);
|
|
2075
2157
|
for (; s.length - o.length >= 0; ) {
|
|
2076
2158
|
const i = s[0];
|
|
2077
2159
|
for (let a = 0; a < o.length; a++)
|
|
@@ -2081,54 +2163,54 @@ function tr() {
|
|
|
2081
2163
|
s = s.slice(c);
|
|
2082
2164
|
}
|
|
2083
2165
|
return s;
|
|
2084
|
-
},
|
|
2166
|
+
}, n.generateECPolynomial = function(r) {
|
|
2085
2167
|
let o = new Uint8Array([1]);
|
|
2086
|
-
for (let s = 0; s <
|
|
2087
|
-
o =
|
|
2168
|
+
for (let s = 0; s < r; s++)
|
|
2169
|
+
o = n.mul(o, new Uint8Array([1, e.exp(s)]));
|
|
2088
2170
|
return o;
|
|
2089
2171
|
};
|
|
2090
|
-
})(
|
|
2172
|
+
})(Me)), Me;
|
|
2091
2173
|
}
|
|
2092
|
-
var
|
|
2093
|
-
function
|
|
2094
|
-
if (
|
|
2095
|
-
|
|
2096
|
-
const
|
|
2097
|
-
function e(
|
|
2098
|
-
this.genPoly = void 0, this.degree =
|
|
2174
|
+
var Be, Tt;
|
|
2175
|
+
function pr() {
|
|
2176
|
+
if (Tt) return Be;
|
|
2177
|
+
Tt = 1;
|
|
2178
|
+
const n = mr();
|
|
2179
|
+
function e(t) {
|
|
2180
|
+
this.genPoly = void 0, this.degree = t, this.degree && this.initialize(this.degree);
|
|
2099
2181
|
}
|
|
2100
|
-
return e.prototype.initialize = function(
|
|
2101
|
-
this.degree =
|
|
2102
|
-
}, e.prototype.encode = function(
|
|
2182
|
+
return e.prototype.initialize = function(r) {
|
|
2183
|
+
this.degree = r, this.genPoly = n.generateECPolynomial(this.degree);
|
|
2184
|
+
}, e.prototype.encode = function(r) {
|
|
2103
2185
|
if (!this.genPoly)
|
|
2104
2186
|
throw new Error("Encoder not initialized");
|
|
2105
|
-
const o = new Uint8Array(
|
|
2106
|
-
o.set(
|
|
2107
|
-
const s =
|
|
2187
|
+
const o = new Uint8Array(r.length + this.degree);
|
|
2188
|
+
o.set(r);
|
|
2189
|
+
const s = n.mod(o, this.genPoly), i = this.degree - s.length;
|
|
2108
2190
|
if (i > 0) {
|
|
2109
2191
|
const c = new Uint8Array(this.degree);
|
|
2110
2192
|
return c.set(s, i), c;
|
|
2111
2193
|
}
|
|
2112
2194
|
return s;
|
|
2113
|
-
},
|
|
2195
|
+
}, Be = e, Be;
|
|
2114
2196
|
}
|
|
2115
|
-
var
|
|
2116
|
-
function
|
|
2117
|
-
return
|
|
2197
|
+
var Le = {}, Ie = {}, $e = {}, Et;
|
|
2198
|
+
function sn() {
|
|
2199
|
+
return Et || (Et = 1, $e.isValid = function(e) {
|
|
2118
2200
|
return !isNaN(e) && e >= 1 && e <= 40;
|
|
2119
|
-
}),
|
|
2120
|
-
}
|
|
2121
|
-
var P = {},
|
|
2122
|
-
function
|
|
2123
|
-
if (
|
|
2124
|
-
|
|
2125
|
-
const
|
|
2126
|
-
let
|
|
2127
|
-
|
|
2128
|
-
const
|
|
2201
|
+
}), $e;
|
|
2202
|
+
}
|
|
2203
|
+
var P = {}, _t;
|
|
2204
|
+
function an() {
|
|
2205
|
+
if (_t) return P;
|
|
2206
|
+
_t = 1;
|
|
2207
|
+
const n = "[0-9]+", e = "[A-Z $%*+\\-./:]+";
|
|
2208
|
+
let t = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
2209
|
+
t = t.replace(/u/g, "\\u");
|
|
2210
|
+
const r = "(?:(?![A-Z0-9 $%*+\\-./:]|" + t + `)(?:.|[\r
|
|
2129
2211
|
]))+`;
|
|
2130
|
-
P.KANJI = new RegExp(
|
|
2131
|
-
const o = new RegExp("^" +
|
|
2212
|
+
P.KANJI = new RegExp(t, "g"), P.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g"), P.BYTE = new RegExp(r, "g"), P.NUMERIC = new RegExp(n, "g"), P.ALPHANUMERIC = new RegExp(e, "g");
|
|
2213
|
+
const o = new RegExp("^" + t + "$"), s = new RegExp("^" + n + "$"), i = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
2132
2214
|
return P.testKanji = function(a) {
|
|
2133
2215
|
return o.test(a);
|
|
2134
2216
|
}, P.testNumeric = function(a) {
|
|
@@ -2137,174 +2219,174 @@ function Gt() {
|
|
|
2137
2219
|
return i.test(a);
|
|
2138
2220
|
}, P;
|
|
2139
2221
|
}
|
|
2140
|
-
var
|
|
2222
|
+
var kt;
|
|
2141
2223
|
function J() {
|
|
2142
|
-
return
|
|
2143
|
-
const e =
|
|
2144
|
-
|
|
2224
|
+
return kt || (kt = 1, (function(n) {
|
|
2225
|
+
const e = sn(), t = an();
|
|
2226
|
+
n.NUMERIC = {
|
|
2145
2227
|
id: "Numeric",
|
|
2146
2228
|
bit: 1,
|
|
2147
2229
|
ccBits: [10, 12, 14]
|
|
2148
|
-
},
|
|
2230
|
+
}, n.ALPHANUMERIC = {
|
|
2149
2231
|
id: "Alphanumeric",
|
|
2150
2232
|
bit: 2,
|
|
2151
2233
|
ccBits: [9, 11, 13]
|
|
2152
|
-
},
|
|
2234
|
+
}, n.BYTE = {
|
|
2153
2235
|
id: "Byte",
|
|
2154
2236
|
bit: 4,
|
|
2155
2237
|
ccBits: [8, 16, 16]
|
|
2156
|
-
},
|
|
2238
|
+
}, n.KANJI = {
|
|
2157
2239
|
id: "Kanji",
|
|
2158
2240
|
bit: 8,
|
|
2159
2241
|
ccBits: [8, 10, 12]
|
|
2160
|
-
},
|
|
2242
|
+
}, n.MIXED = {
|
|
2161
2243
|
bit: -1
|
|
2162
|
-
},
|
|
2244
|
+
}, n.getCharCountIndicator = function(s, i) {
|
|
2163
2245
|
if (!s.ccBits) throw new Error("Invalid mode: " + s);
|
|
2164
2246
|
if (!e.isValid(i))
|
|
2165
2247
|
throw new Error("Invalid version: " + i);
|
|
2166
2248
|
return i >= 1 && i < 10 ? s.ccBits[0] : i < 27 ? s.ccBits[1] : s.ccBits[2];
|
|
2167
|
-
},
|
|
2168
|
-
return
|
|
2169
|
-
},
|
|
2249
|
+
}, n.getBestModeForData = function(s) {
|
|
2250
|
+
return t.testNumeric(s) ? n.NUMERIC : t.testAlphanumeric(s) ? n.ALPHANUMERIC : t.testKanji(s) ? n.KANJI : n.BYTE;
|
|
2251
|
+
}, n.toString = function(s) {
|
|
2170
2252
|
if (s && s.id) return s.id;
|
|
2171
2253
|
throw new Error("Invalid mode");
|
|
2172
|
-
},
|
|
2254
|
+
}, n.isValid = function(s) {
|
|
2173
2255
|
return s && s.bit && s.ccBits;
|
|
2174
2256
|
};
|
|
2175
|
-
function
|
|
2257
|
+
function r(o) {
|
|
2176
2258
|
if (typeof o != "string")
|
|
2177
2259
|
throw new Error("Param is not a string");
|
|
2178
2260
|
switch (o.toLowerCase()) {
|
|
2179
2261
|
case "numeric":
|
|
2180
|
-
return
|
|
2262
|
+
return n.NUMERIC;
|
|
2181
2263
|
case "alphanumeric":
|
|
2182
|
-
return
|
|
2264
|
+
return n.ALPHANUMERIC;
|
|
2183
2265
|
case "kanji":
|
|
2184
|
-
return
|
|
2266
|
+
return n.KANJI;
|
|
2185
2267
|
case "byte":
|
|
2186
|
-
return
|
|
2268
|
+
return n.BYTE;
|
|
2187
2269
|
default:
|
|
2188
2270
|
throw new Error("Unknown mode: " + o);
|
|
2189
2271
|
}
|
|
2190
2272
|
}
|
|
2191
|
-
|
|
2192
|
-
if (
|
|
2273
|
+
n.from = function(s, i) {
|
|
2274
|
+
if (n.isValid(s))
|
|
2193
2275
|
return s;
|
|
2194
2276
|
try {
|
|
2195
|
-
return
|
|
2277
|
+
return r(s);
|
|
2196
2278
|
} catch {
|
|
2197
2279
|
return i;
|
|
2198
2280
|
}
|
|
2199
2281
|
};
|
|
2200
|
-
})(
|
|
2282
|
+
})(Ie)), Ie;
|
|
2201
2283
|
}
|
|
2202
|
-
var
|
|
2203
|
-
function
|
|
2204
|
-
return
|
|
2205
|
-
const e =
|
|
2206
|
-
function a(f, d,
|
|
2284
|
+
var xt;
|
|
2285
|
+
function wr() {
|
|
2286
|
+
return xt || (xt = 1, (function(n) {
|
|
2287
|
+
const e = K(), t = on(), r = Ye(), o = J(), s = sn(), i = 7973, c = e.getBCHDigit(i);
|
|
2288
|
+
function a(f, d, g) {
|
|
2207
2289
|
for (let p = 1; p <= 40; p++)
|
|
2208
|
-
if (d <=
|
|
2290
|
+
if (d <= n.getCapacity(p, g, f))
|
|
2209
2291
|
return p;
|
|
2210
2292
|
}
|
|
2211
2293
|
function l(f, d) {
|
|
2212
2294
|
return o.getCharCountIndicator(f, d) + 4;
|
|
2213
2295
|
}
|
|
2214
2296
|
function u(f, d) {
|
|
2215
|
-
let
|
|
2297
|
+
let g = 0;
|
|
2216
2298
|
return f.forEach(function(p) {
|
|
2217
|
-
const
|
|
2218
|
-
|
|
2219
|
-
}),
|
|
2299
|
+
const m = l(p.mode, d);
|
|
2300
|
+
g += m + p.getBitsLength();
|
|
2301
|
+
}), g;
|
|
2220
2302
|
}
|
|
2221
2303
|
function h(f, d) {
|
|
2222
|
-
for (let
|
|
2223
|
-
if (u(f,
|
|
2224
|
-
return
|
|
2304
|
+
for (let g = 1; g <= 40; g++)
|
|
2305
|
+
if (u(f, g) <= n.getCapacity(g, d, o.MIXED))
|
|
2306
|
+
return g;
|
|
2225
2307
|
}
|
|
2226
|
-
|
|
2227
|
-
return s.isValid(d) ? parseInt(d, 10) :
|
|
2228
|
-
},
|
|
2308
|
+
n.from = function(d, g) {
|
|
2309
|
+
return s.isValid(d) ? parseInt(d, 10) : g;
|
|
2310
|
+
}, n.getCapacity = function(d, g, p) {
|
|
2229
2311
|
if (!s.isValid(d))
|
|
2230
2312
|
throw new Error("Invalid QR Code version");
|
|
2231
2313
|
typeof p > "u" && (p = o.BYTE);
|
|
2232
|
-
const
|
|
2233
|
-
if (p === o.MIXED) return
|
|
2234
|
-
const
|
|
2314
|
+
const m = e.getSymbolTotalCodewords(d), y = t.getTotalCodewordsCount(d, g), E = (m - y) * 8;
|
|
2315
|
+
if (p === o.MIXED) return E;
|
|
2316
|
+
const w = E - l(p, d);
|
|
2235
2317
|
switch (p) {
|
|
2236
2318
|
case o.NUMERIC:
|
|
2237
|
-
return Math.floor(
|
|
2319
|
+
return Math.floor(w / 10 * 3);
|
|
2238
2320
|
case o.ALPHANUMERIC:
|
|
2239
|
-
return Math.floor(
|
|
2321
|
+
return Math.floor(w / 11 * 2);
|
|
2240
2322
|
case o.KANJI:
|
|
2241
|
-
return Math.floor(
|
|
2323
|
+
return Math.floor(w / 13);
|
|
2242
2324
|
case o.BYTE:
|
|
2243
2325
|
default:
|
|
2244
|
-
return Math.floor(
|
|
2326
|
+
return Math.floor(w / 8);
|
|
2245
2327
|
}
|
|
2246
|
-
},
|
|
2328
|
+
}, n.getBestVersionForData = function(d, g) {
|
|
2247
2329
|
let p;
|
|
2248
|
-
const
|
|
2330
|
+
const m = r.from(g, r.M);
|
|
2249
2331
|
if (Array.isArray(d)) {
|
|
2250
2332
|
if (d.length > 1)
|
|
2251
|
-
return h(d,
|
|
2333
|
+
return h(d, m);
|
|
2252
2334
|
if (d.length === 0)
|
|
2253
2335
|
return 1;
|
|
2254
2336
|
p = d[0];
|
|
2255
2337
|
} else
|
|
2256
2338
|
p = d;
|
|
2257
|
-
return a(p.mode, p.getLength(),
|
|
2258
|
-
},
|
|
2339
|
+
return a(p.mode, p.getLength(), m);
|
|
2340
|
+
}, n.getEncodedBits = function(d) {
|
|
2259
2341
|
if (!s.isValid(d) || d < 7)
|
|
2260
2342
|
throw new Error("Invalid QR Code version");
|
|
2261
|
-
let
|
|
2262
|
-
for (; e.getBCHDigit(
|
|
2263
|
-
|
|
2264
|
-
return d << 12 |
|
|
2343
|
+
let g = d << 12;
|
|
2344
|
+
for (; e.getBCHDigit(g) - c >= 0; )
|
|
2345
|
+
g ^= i << e.getBCHDigit(g) - c;
|
|
2346
|
+
return d << 12 | g;
|
|
2265
2347
|
};
|
|
2266
|
-
})(
|
|
2348
|
+
})(Le)), Le;
|
|
2267
2349
|
}
|
|
2268
|
-
var
|
|
2269
|
-
function
|
|
2270
|
-
if (
|
|
2271
|
-
|
|
2272
|
-
const
|
|
2273
|
-
return
|
|
2350
|
+
var Pe = {}, Rt;
|
|
2351
|
+
function yr() {
|
|
2352
|
+
if (Rt) return Pe;
|
|
2353
|
+
Rt = 1;
|
|
2354
|
+
const n = K(), e = 1335, t = 21522, r = n.getBCHDigit(e);
|
|
2355
|
+
return Pe.getEncodedBits = function(s, i) {
|
|
2274
2356
|
const c = s.bit << 3 | i;
|
|
2275
2357
|
let a = c << 10;
|
|
2276
|
-
for (;
|
|
2277
|
-
a ^= e <<
|
|
2278
|
-
return (c << 10 | a) ^
|
|
2279
|
-
},
|
|
2280
|
-
}
|
|
2281
|
-
var
|
|
2282
|
-
function
|
|
2283
|
-
if (
|
|
2284
|
-
|
|
2285
|
-
const
|
|
2286
|
-
function e(
|
|
2287
|
-
this.mode =
|
|
2288
|
-
}
|
|
2289
|
-
return e.getBitsLength = function(
|
|
2290
|
-
return 10 * Math.floor(
|
|
2358
|
+
for (; n.getBCHDigit(a) - r >= 0; )
|
|
2359
|
+
a ^= e << n.getBCHDigit(a) - r;
|
|
2360
|
+
return (c << 10 | a) ^ t;
|
|
2361
|
+
}, Pe;
|
|
2362
|
+
}
|
|
2363
|
+
var qe = {}, Ne, St;
|
|
2364
|
+
function vr() {
|
|
2365
|
+
if (St) return Ne;
|
|
2366
|
+
St = 1;
|
|
2367
|
+
const n = J();
|
|
2368
|
+
function e(t) {
|
|
2369
|
+
this.mode = n.NUMERIC, this.data = t.toString();
|
|
2370
|
+
}
|
|
2371
|
+
return e.getBitsLength = function(r) {
|
|
2372
|
+
return 10 * Math.floor(r / 3) + (r % 3 ? r % 3 * 3 + 1 : 0);
|
|
2291
2373
|
}, e.prototype.getLength = function() {
|
|
2292
2374
|
return this.data.length;
|
|
2293
2375
|
}, e.prototype.getBitsLength = function() {
|
|
2294
2376
|
return e.getBitsLength(this.data.length);
|
|
2295
|
-
}, e.prototype.write = function(
|
|
2377
|
+
}, e.prototype.write = function(r) {
|
|
2296
2378
|
let o, s, i;
|
|
2297
2379
|
for (o = 0; o + 3 <= this.data.length; o += 3)
|
|
2298
|
-
s = this.data.substr(o, 3), i = parseInt(s, 10),
|
|
2380
|
+
s = this.data.substr(o, 3), i = parseInt(s, 10), r.put(i, 10);
|
|
2299
2381
|
const c = this.data.length - o;
|
|
2300
|
-
c > 0 && (s = this.data.substr(o), i = parseInt(s, 10),
|
|
2301
|
-
},
|
|
2302
|
-
}
|
|
2303
|
-
var
|
|
2304
|
-
function
|
|
2305
|
-
if (
|
|
2306
|
-
|
|
2307
|
-
const
|
|
2382
|
+
c > 0 && (s = this.data.substr(o), i = parseInt(s, 10), r.put(i, c * 3 + 1));
|
|
2383
|
+
}, Ne = e, Ne;
|
|
2384
|
+
}
|
|
2385
|
+
var De, Mt;
|
|
2386
|
+
function br() {
|
|
2387
|
+
if (Mt) return De;
|
|
2388
|
+
Mt = 1;
|
|
2389
|
+
const n = J(), e = [
|
|
2308
2390
|
"0",
|
|
2309
2391
|
"1",
|
|
2310
2392
|
"2",
|
|
@@ -2351,58 +2433,58 @@ function ir() {
|
|
|
2351
2433
|
"/",
|
|
2352
2434
|
":"
|
|
2353
2435
|
];
|
|
2354
|
-
function r
|
|
2355
|
-
this.mode =
|
|
2436
|
+
function t(r) {
|
|
2437
|
+
this.mode = n.ALPHANUMERIC, this.data = r;
|
|
2356
2438
|
}
|
|
2357
|
-
return
|
|
2439
|
+
return t.getBitsLength = function(o) {
|
|
2358
2440
|
return 11 * Math.floor(o / 2) + 6 * (o % 2);
|
|
2359
|
-
},
|
|
2441
|
+
}, t.prototype.getLength = function() {
|
|
2360
2442
|
return this.data.length;
|
|
2361
|
-
},
|
|
2362
|
-
return
|
|
2363
|
-
},
|
|
2443
|
+
}, t.prototype.getBitsLength = function() {
|
|
2444
|
+
return t.getBitsLength(this.data.length);
|
|
2445
|
+
}, t.prototype.write = function(o) {
|
|
2364
2446
|
let s;
|
|
2365
2447
|
for (s = 0; s + 2 <= this.data.length; s += 2) {
|
|
2366
2448
|
let i = e.indexOf(this.data[s]) * 45;
|
|
2367
2449
|
i += e.indexOf(this.data[s + 1]), o.put(i, 11);
|
|
2368
2450
|
}
|
|
2369
2451
|
this.data.length % 2 && o.put(e.indexOf(this.data[s]), 6);
|
|
2370
|
-
},
|
|
2371
|
-
}
|
|
2372
|
-
var
|
|
2373
|
-
function
|
|
2374
|
-
if (
|
|
2375
|
-
|
|
2376
|
-
const
|
|
2377
|
-
function e(
|
|
2378
|
-
this.mode =
|
|
2379
|
-
}
|
|
2380
|
-
return e.getBitsLength = function(
|
|
2381
|
-
return
|
|
2452
|
+
}, De = t, De;
|
|
2453
|
+
}
|
|
2454
|
+
var Ue, Bt;
|
|
2455
|
+
function Cr() {
|
|
2456
|
+
if (Bt) return Ue;
|
|
2457
|
+
Bt = 1;
|
|
2458
|
+
const n = J();
|
|
2459
|
+
function e(t) {
|
|
2460
|
+
this.mode = n.BYTE, typeof t == "string" ? this.data = new TextEncoder().encode(t) : this.data = new Uint8Array(t);
|
|
2461
|
+
}
|
|
2462
|
+
return e.getBitsLength = function(r) {
|
|
2463
|
+
return r * 8;
|
|
2382
2464
|
}, e.prototype.getLength = function() {
|
|
2383
2465
|
return this.data.length;
|
|
2384
2466
|
}, e.prototype.getBitsLength = function() {
|
|
2385
2467
|
return e.getBitsLength(this.data.length);
|
|
2386
|
-
}, e.prototype.write = function(
|
|
2387
|
-
for (let
|
|
2388
|
-
|
|
2389
|
-
},
|
|
2468
|
+
}, e.prototype.write = function(t) {
|
|
2469
|
+
for (let r = 0, o = this.data.length; r < o; r++)
|
|
2470
|
+
t.put(this.data[r], 8);
|
|
2471
|
+
}, Ue = e, Ue;
|
|
2390
2472
|
}
|
|
2391
|
-
var
|
|
2392
|
-
function
|
|
2393
|
-
if (
|
|
2394
|
-
|
|
2395
|
-
const
|
|
2396
|
-
function r
|
|
2397
|
-
this.mode =
|
|
2473
|
+
var Fe, Lt;
|
|
2474
|
+
function Ar() {
|
|
2475
|
+
if (Lt) return Fe;
|
|
2476
|
+
Lt = 1;
|
|
2477
|
+
const n = J(), e = K();
|
|
2478
|
+
function t(r) {
|
|
2479
|
+
this.mode = n.KANJI, this.data = r;
|
|
2398
2480
|
}
|
|
2399
|
-
return
|
|
2481
|
+
return t.getBitsLength = function(o) {
|
|
2400
2482
|
return o * 13;
|
|
2401
|
-
},
|
|
2483
|
+
}, t.prototype.getLength = function() {
|
|
2402
2484
|
return this.data.length;
|
|
2403
|
-
},
|
|
2404
|
-
return
|
|
2405
|
-
},
|
|
2485
|
+
}, t.prototype.getBitsLength = function() {
|
|
2486
|
+
return t.getBitsLength(this.data.length);
|
|
2487
|
+
}, t.prototype.write = function(r) {
|
|
2406
2488
|
let o;
|
|
2407
2489
|
for (o = 0; o < this.data.length; o++) {
|
|
2408
2490
|
let s = e.toSJIS(this.data[o]);
|
|
@@ -2415,37 +2497,37 @@ function cr() {
|
|
|
2415
2497
|
"Invalid SJIS character: " + this.data[o] + `
|
|
2416
2498
|
Make sure your charset is UTF-8`
|
|
2417
2499
|
);
|
|
2418
|
-
s = (s >>> 8 & 255) * 192 + (s & 255),
|
|
2500
|
+
s = (s >>> 8 & 255) * 192 + (s & 255), r.put(s, 13);
|
|
2419
2501
|
}
|
|
2420
|
-
},
|
|
2502
|
+
}, Fe = t, Fe;
|
|
2421
2503
|
}
|
|
2422
|
-
var
|
|
2423
|
-
function
|
|
2424
|
-
return
|
|
2504
|
+
var ze = { exports: {} }, It;
|
|
2505
|
+
function Tr() {
|
|
2506
|
+
return It || (It = 1, (function(n) {
|
|
2425
2507
|
var e = {
|
|
2426
|
-
single_source_shortest_paths: function(
|
|
2508
|
+
single_source_shortest_paths: function(t, r, o) {
|
|
2427
2509
|
var s = {}, i = {};
|
|
2428
|
-
i[
|
|
2510
|
+
i[r] = 0;
|
|
2429
2511
|
var c = e.PriorityQueue.make();
|
|
2430
|
-
c.push(
|
|
2431
|
-
for (var a, l, u, h, f, d,
|
|
2432
|
-
a = c.pop(), l = a.value, h = a.cost, f =
|
|
2512
|
+
c.push(r, 0);
|
|
2513
|
+
for (var a, l, u, h, f, d, g, p, m; !c.empty(); ) {
|
|
2514
|
+
a = c.pop(), l = a.value, h = a.cost, f = t[l] || {};
|
|
2433
2515
|
for (u in f)
|
|
2434
|
-
f.hasOwnProperty(u) && (d = f[u],
|
|
2516
|
+
f.hasOwnProperty(u) && (d = f[u], g = h + d, p = i[u], m = typeof i[u] > "u", (m || p > g) && (i[u] = g, c.push(u, g), s[u] = l));
|
|
2435
2517
|
}
|
|
2436
2518
|
if (typeof o < "u" && typeof i[o] > "u") {
|
|
2437
|
-
var
|
|
2438
|
-
throw new Error(
|
|
2519
|
+
var y = ["Could not find a path from ", r, " to ", o, "."].join("");
|
|
2520
|
+
throw new Error(y);
|
|
2439
2521
|
}
|
|
2440
2522
|
return s;
|
|
2441
2523
|
},
|
|
2442
|
-
extract_shortest_path_from_predecessor_list: function(
|
|
2443
|
-
for (var o = [], s =
|
|
2444
|
-
o.push(s),
|
|
2524
|
+
extract_shortest_path_from_predecessor_list: function(t, r) {
|
|
2525
|
+
for (var o = [], s = r; s; )
|
|
2526
|
+
o.push(s), t[s], s = t[s];
|
|
2445
2527
|
return o.reverse(), o;
|
|
2446
2528
|
},
|
|
2447
|
-
find_path: function(
|
|
2448
|
-
var s = e.single_source_shortest_paths(
|
|
2529
|
+
find_path: function(t, r, o) {
|
|
2530
|
+
var s = e.single_source_shortest_paths(t, r, o);
|
|
2449
2531
|
return e.extract_shortest_path_from_predecessor_list(
|
|
2450
2532
|
s,
|
|
2451
2533
|
o
|
|
@@ -2455,22 +2537,22 @@ function lr() {
|
|
|
2455
2537
|
* A very naive priority queue implementation.
|
|
2456
2538
|
*/
|
|
2457
2539
|
PriorityQueue: {
|
|
2458
|
-
make: function(
|
|
2459
|
-
var
|
|
2460
|
-
|
|
2461
|
-
for (s in
|
|
2462
|
-
|
|
2463
|
-
return o.queue = [], o.sorter =
|
|
2540
|
+
make: function(t) {
|
|
2541
|
+
var r = e.PriorityQueue, o = {}, s;
|
|
2542
|
+
t = t || {};
|
|
2543
|
+
for (s in r)
|
|
2544
|
+
r.hasOwnProperty(s) && (o[s] = r[s]);
|
|
2545
|
+
return o.queue = [], o.sorter = t.sorter || r.default_sorter, o;
|
|
2464
2546
|
},
|
|
2465
|
-
default_sorter: function(
|
|
2466
|
-
return
|
|
2547
|
+
default_sorter: function(t, r) {
|
|
2548
|
+
return t.cost - r.cost;
|
|
2467
2549
|
},
|
|
2468
2550
|
/**
|
|
2469
2551
|
* Add a new item to the queue and ensure the highest priority element
|
|
2470
2552
|
* is at the front of the queue.
|
|
2471
2553
|
*/
|
|
2472
|
-
push: function(
|
|
2473
|
-
var o = { value:
|
|
2554
|
+
push: function(t, r) {
|
|
2555
|
+
var o = { value: t, cost: r };
|
|
2474
2556
|
this.queue.push(o), this.queue.sort(this.sorter);
|
|
2475
2557
|
},
|
|
2476
2558
|
/**
|
|
@@ -2484,396 +2566,396 @@ function lr() {
|
|
|
2484
2566
|
}
|
|
2485
2567
|
}
|
|
2486
2568
|
};
|
|
2487
|
-
|
|
2488
|
-
})(
|
|
2569
|
+
n.exports = e;
|
|
2570
|
+
})(ze)), ze.exports;
|
|
2489
2571
|
}
|
|
2490
|
-
var
|
|
2491
|
-
function
|
|
2492
|
-
return
|
|
2493
|
-
const e = J(),
|
|
2494
|
-
function l(
|
|
2495
|
-
return unescape(encodeURIComponent(
|
|
2572
|
+
var $t;
|
|
2573
|
+
function Er() {
|
|
2574
|
+
return $t || ($t = 1, (function(n) {
|
|
2575
|
+
const e = J(), t = vr(), r = br(), o = Cr(), s = Ar(), i = an(), c = K(), a = Tr();
|
|
2576
|
+
function l(y) {
|
|
2577
|
+
return unescape(encodeURIComponent(y)).length;
|
|
2496
2578
|
}
|
|
2497
|
-
function u(
|
|
2498
|
-
const
|
|
2499
|
-
let
|
|
2500
|
-
for (; (
|
|
2501
|
-
|
|
2502
|
-
data:
|
|
2503
|
-
index:
|
|
2504
|
-
mode:
|
|
2505
|
-
length:
|
|
2579
|
+
function u(y, E, w) {
|
|
2580
|
+
const x = [];
|
|
2581
|
+
let M;
|
|
2582
|
+
for (; (M = y.exec(w)) !== null; )
|
|
2583
|
+
x.push({
|
|
2584
|
+
data: M[0],
|
|
2585
|
+
index: M.index,
|
|
2586
|
+
mode: E,
|
|
2587
|
+
length: M[0].length
|
|
2506
2588
|
});
|
|
2507
|
-
return
|
|
2589
|
+
return x;
|
|
2508
2590
|
}
|
|
2509
|
-
function h(
|
|
2510
|
-
const
|
|
2511
|
-
let
|
|
2512
|
-
return c.isKanjiModeEnabled() ? (
|
|
2513
|
-
return
|
|
2514
|
-
}).map(function(
|
|
2591
|
+
function h(y) {
|
|
2592
|
+
const E = u(i.NUMERIC, e.NUMERIC, y), w = u(i.ALPHANUMERIC, e.ALPHANUMERIC, y);
|
|
2593
|
+
let x, M;
|
|
2594
|
+
return c.isKanjiModeEnabled() ? (x = u(i.BYTE, e.BYTE, y), M = u(i.KANJI, e.KANJI, y)) : (x = u(i.BYTE_KANJI, e.BYTE, y), M = []), E.concat(w, x, M).sort(function(_, T) {
|
|
2595
|
+
return _.index - T.index;
|
|
2596
|
+
}).map(function(_) {
|
|
2515
2597
|
return {
|
|
2516
|
-
data:
|
|
2517
|
-
mode:
|
|
2518
|
-
length:
|
|
2598
|
+
data: _.data,
|
|
2599
|
+
mode: _.mode,
|
|
2600
|
+
length: _.length
|
|
2519
2601
|
};
|
|
2520
2602
|
});
|
|
2521
2603
|
}
|
|
2522
|
-
function f(
|
|
2523
|
-
switch (
|
|
2604
|
+
function f(y, E) {
|
|
2605
|
+
switch (E) {
|
|
2524
2606
|
case e.NUMERIC:
|
|
2525
|
-
return
|
|
2607
|
+
return t.getBitsLength(y);
|
|
2526
2608
|
case e.ALPHANUMERIC:
|
|
2527
|
-
return
|
|
2609
|
+
return r.getBitsLength(y);
|
|
2528
2610
|
case e.KANJI:
|
|
2529
|
-
return s.getBitsLength(
|
|
2611
|
+
return s.getBitsLength(y);
|
|
2530
2612
|
case e.BYTE:
|
|
2531
|
-
return o.getBitsLength(
|
|
2613
|
+
return o.getBitsLength(y);
|
|
2532
2614
|
}
|
|
2533
2615
|
}
|
|
2534
|
-
function d(
|
|
2535
|
-
return
|
|
2536
|
-
const
|
|
2537
|
-
return
|
|
2616
|
+
function d(y) {
|
|
2617
|
+
return y.reduce(function(E, w) {
|
|
2618
|
+
const x = E.length - 1 >= 0 ? E[E.length - 1] : null;
|
|
2619
|
+
return x && x.mode === w.mode ? (E[E.length - 1].data += w.data, E) : (E.push(w), E);
|
|
2538
2620
|
}, []);
|
|
2539
2621
|
}
|
|
2540
|
-
function
|
|
2541
|
-
const
|
|
2542
|
-
for (let
|
|
2543
|
-
const
|
|
2544
|
-
switch (
|
|
2622
|
+
function g(y) {
|
|
2623
|
+
const E = [];
|
|
2624
|
+
for (let w = 0; w < y.length; w++) {
|
|
2625
|
+
const x = y[w];
|
|
2626
|
+
switch (x.mode) {
|
|
2545
2627
|
case e.NUMERIC:
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
{ data:
|
|
2549
|
-
{ data:
|
|
2628
|
+
E.push([
|
|
2629
|
+
x,
|
|
2630
|
+
{ data: x.data, mode: e.ALPHANUMERIC, length: x.length },
|
|
2631
|
+
{ data: x.data, mode: e.BYTE, length: x.length }
|
|
2550
2632
|
]);
|
|
2551
2633
|
break;
|
|
2552
2634
|
case e.ALPHANUMERIC:
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
{ data:
|
|
2635
|
+
E.push([
|
|
2636
|
+
x,
|
|
2637
|
+
{ data: x.data, mode: e.BYTE, length: x.length }
|
|
2556
2638
|
]);
|
|
2557
2639
|
break;
|
|
2558
2640
|
case e.KANJI:
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
{ data:
|
|
2641
|
+
E.push([
|
|
2642
|
+
x,
|
|
2643
|
+
{ data: x.data, mode: e.BYTE, length: l(x.data) }
|
|
2562
2644
|
]);
|
|
2563
2645
|
break;
|
|
2564
2646
|
case e.BYTE:
|
|
2565
|
-
|
|
2566
|
-
{ data:
|
|
2647
|
+
E.push([
|
|
2648
|
+
{ data: x.data, mode: e.BYTE, length: l(x.data) }
|
|
2567
2649
|
]);
|
|
2568
2650
|
}
|
|
2569
2651
|
}
|
|
2570
|
-
return
|
|
2652
|
+
return E;
|
|
2571
2653
|
}
|
|
2572
|
-
function p(
|
|
2573
|
-
const
|
|
2574
|
-
let
|
|
2575
|
-
for (let
|
|
2576
|
-
const
|
|
2577
|
-
for (let
|
|
2578
|
-
const
|
|
2579
|
-
|
|
2580
|
-
for (let
|
|
2581
|
-
const
|
|
2582
|
-
|
|
2654
|
+
function p(y, E) {
|
|
2655
|
+
const w = {}, x = { start: {} };
|
|
2656
|
+
let M = ["start"];
|
|
2657
|
+
for (let b = 0; b < y.length; b++) {
|
|
2658
|
+
const _ = y[b], T = [];
|
|
2659
|
+
for (let v = 0; v < _.length; v++) {
|
|
2660
|
+
const R = _[v], C = "" + b + v;
|
|
2661
|
+
T.push(C), w[C] = { node: R, lastCount: 0 }, x[C] = {};
|
|
2662
|
+
for (let k = 0; k < M.length; k++) {
|
|
2663
|
+
const A = M[k];
|
|
2664
|
+
w[A] && w[A].node.mode === R.mode ? (x[A][C] = f(w[A].lastCount + R.length, R.mode) - f(w[A].lastCount, R.mode), w[A].lastCount += R.length) : (w[A] && (w[A].lastCount = R.length), x[A][C] = f(R.length, R.mode) + 4 + e.getCharCountIndicator(R.mode, E));
|
|
2583
2665
|
}
|
|
2584
2666
|
}
|
|
2585
|
-
|
|
2667
|
+
M = T;
|
|
2586
2668
|
}
|
|
2587
|
-
for (let
|
|
2588
|
-
|
|
2589
|
-
return { map:
|
|
2669
|
+
for (let b = 0; b < M.length; b++)
|
|
2670
|
+
x[M[b]].end = 0;
|
|
2671
|
+
return { map: x, table: w };
|
|
2590
2672
|
}
|
|
2591
|
-
function
|
|
2592
|
-
let
|
|
2593
|
-
const
|
|
2594
|
-
if (
|
|
2595
|
-
throw new Error('"' +
|
|
2596
|
-
Suggested mode is: ` + e.toString(
|
|
2597
|
-
switch (
|
|
2673
|
+
function m(y, E) {
|
|
2674
|
+
let w;
|
|
2675
|
+
const x = e.getBestModeForData(y);
|
|
2676
|
+
if (w = e.from(E, x), w !== e.BYTE && w.bit < x.bit)
|
|
2677
|
+
throw new Error('"' + y + '" cannot be encoded with mode ' + e.toString(w) + `.
|
|
2678
|
+
Suggested mode is: ` + e.toString(x));
|
|
2679
|
+
switch (w === e.KANJI && !c.isKanjiModeEnabled() && (w = e.BYTE), w) {
|
|
2598
2680
|
case e.NUMERIC:
|
|
2599
|
-
return new
|
|
2681
|
+
return new t(y);
|
|
2600
2682
|
case e.ALPHANUMERIC:
|
|
2601
|
-
return new
|
|
2683
|
+
return new r(y);
|
|
2602
2684
|
case e.KANJI:
|
|
2603
|
-
return new s(
|
|
2685
|
+
return new s(y);
|
|
2604
2686
|
case e.BYTE:
|
|
2605
|
-
return new o(
|
|
2687
|
+
return new o(y);
|
|
2606
2688
|
}
|
|
2607
2689
|
}
|
|
2608
|
-
|
|
2609
|
-
return
|
|
2610
|
-
return typeof
|
|
2690
|
+
n.fromArray = function(E) {
|
|
2691
|
+
return E.reduce(function(w, x) {
|
|
2692
|
+
return typeof x == "string" ? w.push(m(x, null)) : x.data && w.push(m(x.data, x.mode)), w;
|
|
2611
2693
|
}, []);
|
|
2612
|
-
},
|
|
2613
|
-
const
|
|
2614
|
-
for (let
|
|
2615
|
-
|
|
2616
|
-
return
|
|
2617
|
-
},
|
|
2618
|
-
return
|
|
2619
|
-
h(
|
|
2694
|
+
}, n.fromString = function(E, w) {
|
|
2695
|
+
const x = h(E, c.isKanjiModeEnabled()), M = g(x), b = p(M, w), _ = a.find_path(b.map, "start", "end"), T = [];
|
|
2696
|
+
for (let v = 1; v < _.length - 1; v++)
|
|
2697
|
+
T.push(b.table[_[v]].node);
|
|
2698
|
+
return n.fromArray(d(T));
|
|
2699
|
+
}, n.rawSplit = function(E) {
|
|
2700
|
+
return n.fromArray(
|
|
2701
|
+
h(E, c.isKanjiModeEnabled())
|
|
2620
2702
|
);
|
|
2621
2703
|
};
|
|
2622
|
-
})(
|
|
2623
|
-
}
|
|
2624
|
-
var
|
|
2625
|
-
function
|
|
2626
|
-
if (
|
|
2627
|
-
|
|
2628
|
-
const
|
|
2629
|
-
function d(
|
|
2630
|
-
const
|
|
2631
|
-
for (let
|
|
2632
|
-
const
|
|
2633
|
-
for (let
|
|
2634
|
-
if (!(
|
|
2635
|
-
for (let
|
|
2636
|
-
|
|
2704
|
+
})(qe)), qe;
|
|
2705
|
+
}
|
|
2706
|
+
var Pt;
|
|
2707
|
+
function _r() {
|
|
2708
|
+
if (Pt) return Te;
|
|
2709
|
+
Pt = 1;
|
|
2710
|
+
const n = K(), e = Ye(), t = lr(), r = ur(), o = hr(), s = dr(), i = fr(), c = on(), a = pr(), l = wr(), u = yr(), h = J(), f = Er();
|
|
2711
|
+
function d(b, _) {
|
|
2712
|
+
const T = b.size, v = s.getPositions(_);
|
|
2713
|
+
for (let R = 0; R < v.length; R++) {
|
|
2714
|
+
const C = v[R][0], k = v[R][1];
|
|
2715
|
+
for (let A = -1; A <= 7; A++)
|
|
2716
|
+
if (!(C + A <= -1 || T <= C + A))
|
|
2717
|
+
for (let S = -1; S <= 7; S++)
|
|
2718
|
+
k + S <= -1 || T <= k + S || (A >= 0 && A <= 6 && (S === 0 || S === 6) || S >= 0 && S <= 6 && (A === 0 || A === 6) || A >= 2 && A <= 4 && S >= 2 && S <= 4 ? b.set(C + A, k + S, !0, !0) : b.set(C + A, k + S, !1, !0));
|
|
2637
2719
|
}
|
|
2638
2720
|
}
|
|
2639
|
-
function
|
|
2640
|
-
const
|
|
2641
|
-
for (let
|
|
2642
|
-
const
|
|
2643
|
-
|
|
2721
|
+
function g(b) {
|
|
2722
|
+
const _ = b.size;
|
|
2723
|
+
for (let T = 8; T < _ - 8; T++) {
|
|
2724
|
+
const v = T % 2 === 0;
|
|
2725
|
+
b.set(T, 6, v, !0), b.set(6, T, v, !0);
|
|
2644
2726
|
}
|
|
2645
2727
|
}
|
|
2646
|
-
function p(
|
|
2647
|
-
const
|
|
2648
|
-
for (let
|
|
2649
|
-
const
|
|
2650
|
-
for (let
|
|
2651
|
-
for (let
|
|
2652
|
-
|
|
2728
|
+
function p(b, _) {
|
|
2729
|
+
const T = o.getPositions(_);
|
|
2730
|
+
for (let v = 0; v < T.length; v++) {
|
|
2731
|
+
const R = T[v][0], C = T[v][1];
|
|
2732
|
+
for (let k = -2; k <= 2; k++)
|
|
2733
|
+
for (let A = -2; A <= 2; A++)
|
|
2734
|
+
k === -2 || k === 2 || A === -2 || A === 2 || k === 0 && A === 0 ? b.set(R + k, C + A, !0, !0) : b.set(R + k, C + A, !1, !0);
|
|
2653
2735
|
}
|
|
2654
2736
|
}
|
|
2655
|
-
function
|
|
2656
|
-
const
|
|
2657
|
-
let
|
|
2658
|
-
for (let
|
|
2659
|
-
|
|
2660
|
-
}
|
|
2661
|
-
function
|
|
2662
|
-
const
|
|
2663
|
-
let
|
|
2664
|
-
for (
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
}
|
|
2668
|
-
function
|
|
2669
|
-
const
|
|
2670
|
-
let
|
|
2671
|
-
for (let
|
|
2672
|
-
for (
|
|
2673
|
-
for (let
|
|
2674
|
-
if (!
|
|
2675
|
-
let
|
|
2676
|
-
|
|
2737
|
+
function m(b, _) {
|
|
2738
|
+
const T = b.size, v = l.getEncodedBits(_);
|
|
2739
|
+
let R, C, k;
|
|
2740
|
+
for (let A = 0; A < 18; A++)
|
|
2741
|
+
R = Math.floor(A / 3), C = A % 3 + T - 8 - 3, k = (v >> A & 1) === 1, b.set(R, C, k, !0), b.set(C, R, k, !0);
|
|
2742
|
+
}
|
|
2743
|
+
function y(b, _, T) {
|
|
2744
|
+
const v = b.size, R = u.getEncodedBits(_, T);
|
|
2745
|
+
let C, k;
|
|
2746
|
+
for (C = 0; C < 15; C++)
|
|
2747
|
+
k = (R >> C & 1) === 1, C < 6 ? b.set(C, 8, k, !0) : C < 8 ? b.set(C + 1, 8, k, !0) : b.set(v - 15 + C, 8, k, !0), C < 8 ? b.set(8, v - C - 1, k, !0) : C < 9 ? b.set(8, 15 - C - 1 + 1, k, !0) : b.set(8, 15 - C - 1, k, !0);
|
|
2748
|
+
b.set(v - 8, 8, 1, !0);
|
|
2749
|
+
}
|
|
2750
|
+
function E(b, _) {
|
|
2751
|
+
const T = b.size;
|
|
2752
|
+
let v = -1, R = T - 1, C = 7, k = 0;
|
|
2753
|
+
for (let A = T - 1; A > 0; A -= 2)
|
|
2754
|
+
for (A === 6 && A--; ; ) {
|
|
2755
|
+
for (let S = 0; S < 2; S++)
|
|
2756
|
+
if (!b.isReserved(R, A - S)) {
|
|
2757
|
+
let z = !1;
|
|
2758
|
+
k < _.length && (z = (_[k] >>> C & 1) === 1), b.set(R, A - S, z), C--, C === -1 && (k++, C = 7);
|
|
2677
2759
|
}
|
|
2678
|
-
if (
|
|
2679
|
-
|
|
2760
|
+
if (R += v, R < 0 || T <= R) {
|
|
2761
|
+
R -= v, v = -v;
|
|
2680
2762
|
break;
|
|
2681
2763
|
}
|
|
2682
2764
|
}
|
|
2683
2765
|
}
|
|
2684
|
-
function
|
|
2685
|
-
const
|
|
2686
|
-
|
|
2687
|
-
|
|
2766
|
+
function w(b, _, T) {
|
|
2767
|
+
const v = new t();
|
|
2768
|
+
T.forEach(function(S) {
|
|
2769
|
+
v.put(S.mode.bit, 4), v.put(S.getLength(), h.getCharCountIndicator(S.mode, b)), S.write(v);
|
|
2688
2770
|
});
|
|
2689
|
-
const
|
|
2690
|
-
for (
|
|
2691
|
-
|
|
2692
|
-
const
|
|
2693
|
-
for (let
|
|
2694
|
-
|
|
2695
|
-
return
|
|
2696
|
-
}
|
|
2697
|
-
function
|
|
2698
|
-
const
|
|
2699
|
-
let
|
|
2700
|
-
const
|
|
2701
|
-
let
|
|
2702
|
-
const
|
|
2703
|
-
for (let
|
|
2704
|
-
const
|
|
2705
|
-
|
|
2771
|
+
const R = n.getSymbolTotalCodewords(b), C = c.getTotalCodewordsCount(b, _), k = (R - C) * 8;
|
|
2772
|
+
for (v.getLengthInBits() + 4 <= k && v.put(0, 4); v.getLengthInBits() % 8 !== 0; )
|
|
2773
|
+
v.putBit(0);
|
|
2774
|
+
const A = (k - v.getLengthInBits()) / 8;
|
|
2775
|
+
for (let S = 0; S < A; S++)
|
|
2776
|
+
v.put(S % 2 ? 17 : 236, 8);
|
|
2777
|
+
return x(v, b, _);
|
|
2778
|
+
}
|
|
2779
|
+
function x(b, _, T) {
|
|
2780
|
+
const v = n.getSymbolTotalCodewords(_), R = c.getTotalCodewordsCount(_, T), C = v - R, k = c.getBlocksCount(_, T), A = v % k, S = k - A, z = Math.floor(v / k), ee = Math.floor(C / k), fn = ee + 1, Xe = z - ee, gn = new a(Xe);
|
|
2781
|
+
let me = 0;
|
|
2782
|
+
const ce = new Array(k), Ze = new Array(k);
|
|
2783
|
+
let pe = 0;
|
|
2784
|
+
const mn = new Uint8Array(b.buffer);
|
|
2785
|
+
for (let Q = 0; Q < k; Q++) {
|
|
2786
|
+
const ye = Q < S ? ee : fn;
|
|
2787
|
+
ce[Q] = mn.slice(me, me + ye), Ze[Q] = gn.encode(ce[Q]), me += ye, pe = Math.max(pe, ye);
|
|
2706
2788
|
}
|
|
2707
|
-
const
|
|
2708
|
-
let
|
|
2709
|
-
for (q = 0; q <
|
|
2710
|
-
for (
|
|
2711
|
-
q <
|
|
2712
|
-
for (q = 0; q <
|
|
2713
|
-
for (
|
|
2714
|
-
|
|
2715
|
-
return
|
|
2716
|
-
}
|
|
2717
|
-
function
|
|
2718
|
-
let
|
|
2719
|
-
if (Array.isArray(
|
|
2720
|
-
|
|
2721
|
-
else if (typeof
|
|
2722
|
-
let
|
|
2723
|
-
if (!
|
|
2724
|
-
const
|
|
2725
|
-
|
|
2789
|
+
const we = new Uint8Array(v);
|
|
2790
|
+
let et = 0, q, N;
|
|
2791
|
+
for (q = 0; q < pe; q++)
|
|
2792
|
+
for (N = 0; N < k; N++)
|
|
2793
|
+
q < ce[N].length && (we[et++] = ce[N][q]);
|
|
2794
|
+
for (q = 0; q < Xe; q++)
|
|
2795
|
+
for (N = 0; N < k; N++)
|
|
2796
|
+
we[et++] = Ze[N][q];
|
|
2797
|
+
return we;
|
|
2798
|
+
}
|
|
2799
|
+
function M(b, _, T, v) {
|
|
2800
|
+
let R;
|
|
2801
|
+
if (Array.isArray(b))
|
|
2802
|
+
R = f.fromArray(b);
|
|
2803
|
+
else if (typeof b == "string") {
|
|
2804
|
+
let z = _;
|
|
2805
|
+
if (!z) {
|
|
2806
|
+
const ee = f.rawSplit(b);
|
|
2807
|
+
z = l.getBestVersionForData(ee, T);
|
|
2726
2808
|
}
|
|
2727
|
-
|
|
2809
|
+
R = f.fromString(b, z || 40);
|
|
2728
2810
|
} else
|
|
2729
2811
|
throw new Error("Invalid data");
|
|
2730
|
-
const
|
|
2731
|
-
if (!y)
|
|
2732
|
-
throw new Error("The amount of data is too big to be stored in a QR Code");
|
|
2812
|
+
const C = l.getBestVersionForData(R, T);
|
|
2733
2813
|
if (!C)
|
|
2734
|
-
|
|
2735
|
-
|
|
2814
|
+
throw new Error("The amount of data is too big to be stored in a QR Code");
|
|
2815
|
+
if (!_)
|
|
2816
|
+
_ = C;
|
|
2817
|
+
else if (_ < C)
|
|
2736
2818
|
throw new Error(
|
|
2737
2819
|
`
|
|
2738
2820
|
The chosen QR Code version cannot contain this amount of data.
|
|
2739
|
-
Minimum version required to store current data is: ` +
|
|
2821
|
+
Minimum version required to store current data is: ` + C + `.
|
|
2740
2822
|
`
|
|
2741
2823
|
);
|
|
2742
|
-
const
|
|
2743
|
-
return d(
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
)), i.applyMask(
|
|
2747
|
-
modules:
|
|
2748
|
-
version:
|
|
2749
|
-
errorCorrectionLevel:
|
|
2750
|
-
maskPattern:
|
|
2751
|
-
segments:
|
|
2824
|
+
const k = w(_, T, R), A = n.getSymbolSize(_), S = new r(A);
|
|
2825
|
+
return d(S, _), g(S), p(S, _), y(S, T, 0), _ >= 7 && m(S, _), E(S, k), isNaN(v) && (v = i.getBestMask(
|
|
2826
|
+
S,
|
|
2827
|
+
y.bind(null, S, T)
|
|
2828
|
+
)), i.applyMask(v, S), y(S, T, v), {
|
|
2829
|
+
modules: S,
|
|
2830
|
+
version: _,
|
|
2831
|
+
errorCorrectionLevel: T,
|
|
2832
|
+
maskPattern: v,
|
|
2833
|
+
segments: R
|
|
2752
2834
|
};
|
|
2753
2835
|
}
|
|
2754
|
-
return
|
|
2755
|
-
if (typeof
|
|
2836
|
+
return Te.create = function(_, T) {
|
|
2837
|
+
if (typeof _ > "u" || _ === "")
|
|
2756
2838
|
throw new Error("No input text");
|
|
2757
|
-
let
|
|
2758
|
-
return typeof
|
|
2759
|
-
},
|
|
2760
|
-
}
|
|
2761
|
-
var
|
|
2762
|
-
function
|
|
2763
|
-
return
|
|
2764
|
-
function e(
|
|
2765
|
-
if (typeof
|
|
2839
|
+
let v = e.M, R, C;
|
|
2840
|
+
return typeof T < "u" && (v = e.from(T.errorCorrectionLevel, e.M), R = l.from(T.version), C = i.from(T.maskPattern), T.toSJISFunc && n.setToSJISFunction(T.toSJISFunc)), M(_, R, v, C);
|
|
2841
|
+
}, Te;
|
|
2842
|
+
}
|
|
2843
|
+
var He = {}, je = {}, qt;
|
|
2844
|
+
function cn() {
|
|
2845
|
+
return qt || (qt = 1, (function(n) {
|
|
2846
|
+
function e(t) {
|
|
2847
|
+
if (typeof t == "number" && (t = t.toString()), typeof t != "string")
|
|
2766
2848
|
throw new Error("Color should be defined as hex string");
|
|
2767
|
-
let
|
|
2768
|
-
if (
|
|
2769
|
-
throw new Error("Invalid hex color: " +
|
|
2770
|
-
(
|
|
2849
|
+
let r = t.slice().replace("#", "").split("");
|
|
2850
|
+
if (r.length < 3 || r.length === 5 || r.length > 8)
|
|
2851
|
+
throw new Error("Invalid hex color: " + t);
|
|
2852
|
+
(r.length === 3 || r.length === 4) && (r = Array.prototype.concat.apply([], r.map(function(s) {
|
|
2771
2853
|
return [s, s];
|
|
2772
|
-
}))),
|
|
2773
|
-
const o = parseInt(
|
|
2854
|
+
}))), r.length === 6 && r.push("F", "F");
|
|
2855
|
+
const o = parseInt(r.join(""), 16);
|
|
2774
2856
|
return {
|
|
2775
2857
|
r: o >> 24 & 255,
|
|
2776
2858
|
g: o >> 16 & 255,
|
|
2777
2859
|
b: o >> 8 & 255,
|
|
2778
2860
|
a: o & 255,
|
|
2779
|
-
hex: "#" +
|
|
2861
|
+
hex: "#" + r.slice(0, 6).join("")
|
|
2780
2862
|
};
|
|
2781
2863
|
}
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
const o = typeof
|
|
2864
|
+
n.getOptions = function(r) {
|
|
2865
|
+
r || (r = {}), r.color || (r.color = {});
|
|
2866
|
+
const o = typeof r.margin > "u" || r.margin === null || r.margin < 0 ? 4 : r.margin, s = r.width && r.width >= 21 ? r.width : void 0, i = r.scale || 4;
|
|
2785
2867
|
return {
|
|
2786
2868
|
width: s,
|
|
2787
2869
|
scale: s ? 4 : i,
|
|
2788
2870
|
margin: o,
|
|
2789
2871
|
color: {
|
|
2790
|
-
dark: e(
|
|
2791
|
-
light: e(
|
|
2872
|
+
dark: e(r.color.dark || "#000000ff"),
|
|
2873
|
+
light: e(r.color.light || "#ffffffff")
|
|
2792
2874
|
},
|
|
2793
|
-
type:
|
|
2794
|
-
rendererOpts:
|
|
2875
|
+
type: r.type,
|
|
2876
|
+
rendererOpts: r.rendererOpts || {}
|
|
2795
2877
|
};
|
|
2796
|
-
},
|
|
2797
|
-
return o.width && o.width >=
|
|
2798
|
-
},
|
|
2799
|
-
const s =
|
|
2800
|
-
return Math.floor((
|
|
2801
|
-
},
|
|
2802
|
-
const i = o.modules.size, c = o.modules.data, a =
|
|
2878
|
+
}, n.getScale = function(r, o) {
|
|
2879
|
+
return o.width && o.width >= r + o.margin * 2 ? o.width / (r + o.margin * 2) : o.scale;
|
|
2880
|
+
}, n.getImageWidth = function(r, o) {
|
|
2881
|
+
const s = n.getScale(r, o);
|
|
2882
|
+
return Math.floor((r + o.margin * 2) * s);
|
|
2883
|
+
}, n.qrToImageData = function(r, o, s) {
|
|
2884
|
+
const i = o.modules.size, c = o.modules.data, a = n.getScale(i, s), l = Math.floor((i + s.margin * 2) * a), u = s.margin * a, h = [s.color.light, s.color.dark];
|
|
2803
2885
|
for (let f = 0; f < l; f++)
|
|
2804
2886
|
for (let d = 0; d < l; d++) {
|
|
2805
|
-
let
|
|
2887
|
+
let g = (f * l + d) * 4, p = s.color.light;
|
|
2806
2888
|
if (f >= u && d >= u && f < l - u && d < l - u) {
|
|
2807
|
-
const
|
|
2808
|
-
p = h[c[
|
|
2889
|
+
const m = Math.floor((f - u) / a), y = Math.floor((d - u) / a);
|
|
2890
|
+
p = h[c[m * i + y] ? 1 : 0];
|
|
2809
2891
|
}
|
|
2810
|
-
|
|
2892
|
+
r[g++] = p.r, r[g++] = p.g, r[g++] = p.b, r[g] = p.a;
|
|
2811
2893
|
}
|
|
2812
2894
|
};
|
|
2813
|
-
})(
|
|
2895
|
+
})(je)), je;
|
|
2814
2896
|
}
|
|
2815
|
-
var
|
|
2816
|
-
function
|
|
2817
|
-
return
|
|
2818
|
-
const e =
|
|
2819
|
-
function
|
|
2897
|
+
var Nt;
|
|
2898
|
+
function kr() {
|
|
2899
|
+
return Nt || (Nt = 1, (function(n) {
|
|
2900
|
+
const e = cn();
|
|
2901
|
+
function t(o, s, i) {
|
|
2820
2902
|
o.clearRect(0, 0, s.width, s.height), s.style || (s.style = {}), s.height = i, s.width = i, s.style.height = i + "px", s.style.width = i + "px";
|
|
2821
2903
|
}
|
|
2822
|
-
function
|
|
2904
|
+
function r() {
|
|
2823
2905
|
try {
|
|
2824
2906
|
return document.createElement("canvas");
|
|
2825
2907
|
} catch {
|
|
2826
2908
|
throw new Error("You need to specify a canvas element");
|
|
2827
2909
|
}
|
|
2828
2910
|
}
|
|
2829
|
-
|
|
2911
|
+
n.render = function(s, i, c) {
|
|
2830
2912
|
let a = c, l = i;
|
|
2831
|
-
typeof a > "u" && (!i || !i.getContext) && (a = i, i = void 0), i || (l =
|
|
2913
|
+
typeof a > "u" && (!i || !i.getContext) && (a = i, i = void 0), i || (l = r()), a = e.getOptions(a);
|
|
2832
2914
|
const u = e.getImageWidth(s.modules.size, a), h = l.getContext("2d"), f = h.createImageData(u, u);
|
|
2833
|
-
return e.qrToImageData(f.data, s, a),
|
|
2834
|
-
},
|
|
2915
|
+
return e.qrToImageData(f.data, s, a), t(h, l, u), h.putImageData(f, 0, 0), l;
|
|
2916
|
+
}, n.renderToDataURL = function(s, i, c) {
|
|
2835
2917
|
let a = c;
|
|
2836
2918
|
typeof a > "u" && (!i || !i.getContext) && (a = i, i = void 0), a || (a = {});
|
|
2837
|
-
const l =
|
|
2919
|
+
const l = n.render(s, i, a), u = a.type || "image/png", h = a.rendererOpts || {};
|
|
2838
2920
|
return l.toDataURL(u, h.quality);
|
|
2839
2921
|
};
|
|
2840
|
-
})(
|
|
2922
|
+
})(He)), He;
|
|
2841
2923
|
}
|
|
2842
|
-
var
|
|
2843
|
-
function
|
|
2844
|
-
if (
|
|
2845
|
-
|
|
2846
|
-
const
|
|
2924
|
+
var Ve = {}, Dt;
|
|
2925
|
+
function xr() {
|
|
2926
|
+
if (Dt) return Ve;
|
|
2927
|
+
Dt = 1;
|
|
2928
|
+
const n = cn();
|
|
2847
2929
|
function e(o, s) {
|
|
2848
2930
|
const i = o.a / 255, c = s + '="' + o.hex + '"';
|
|
2849
2931
|
return i < 1 ? c + " " + s + '-opacity="' + i.toFixed(2).slice(1) + '"' : c;
|
|
2850
2932
|
}
|
|
2851
|
-
function
|
|
2933
|
+
function t(o, s, i) {
|
|
2852
2934
|
let c = o + s;
|
|
2853
2935
|
return typeof i < "u" && (c += " " + i), c;
|
|
2854
2936
|
}
|
|
2855
|
-
function
|
|
2937
|
+
function r(o, s, i) {
|
|
2856
2938
|
let c = "", a = 0, l = !1, u = 0;
|
|
2857
2939
|
for (let h = 0; h < o.length; h++) {
|
|
2858
2940
|
const f = Math.floor(h % s), d = Math.floor(h / s);
|
|
2859
|
-
!f && !l && (l = !0), o[h] ? (u++, h > 0 && f > 0 && o[h - 1] || (c += l ?
|
|
2941
|
+
!f && !l && (l = !0), o[h] ? (u++, h > 0 && f > 0 && o[h - 1] || (c += l ? t("M", f + i, 0.5 + d + i) : t("m", a, 0), a = 0, l = !1), f + 1 < s && o[h + 1] || (c += t("h", u), u = 0)) : a++;
|
|
2860
2942
|
}
|
|
2861
2943
|
return c;
|
|
2862
2944
|
}
|
|
2863
|
-
return
|
|
2864
|
-
const a =
|
|
2945
|
+
return Ve.render = function(s, i, c) {
|
|
2946
|
+
const a = n.getOptions(i), l = s.modules.size, u = s.modules.data, h = l + a.margin * 2, f = a.color.light.a ? "<path " + e(a.color.light, "fill") + ' d="M0 0h' + h + "v" + h + 'H0z"/>' : "", d = "<path " + e(a.color.dark, "stroke") + ' d="' + r(u, l, a.margin) + '"/>', g = 'viewBox="0 0 ' + h + " " + h + '"', m = '<svg xmlns="http://www.w3.org/2000/svg" ' + (a.width ? 'width="' + a.width + '" height="' + a.width + '" ' : "") + g + ' shape-rendering="crispEdges">' + f + d + `</svg>
|
|
2865
2947
|
`;
|
|
2866
|
-
return typeof c == "function" && c(null,
|
|
2867
|
-
},
|
|
2868
|
-
}
|
|
2869
|
-
var
|
|
2870
|
-
function
|
|
2871
|
-
if (
|
|
2872
|
-
|
|
2873
|
-
const
|
|
2948
|
+
return typeof c == "function" && c(null, m), m;
|
|
2949
|
+
}, Ve;
|
|
2950
|
+
}
|
|
2951
|
+
var Ut;
|
|
2952
|
+
function Rr() {
|
|
2953
|
+
if (Ut) return G;
|
|
2954
|
+
Ut = 1;
|
|
2955
|
+
const n = cr(), e = _r(), t = kr(), r = xr();
|
|
2874
2956
|
function o(s, i, c, a, l) {
|
|
2875
2957
|
const u = [].slice.call(arguments, 1), h = u.length, f = typeof u[h - 1] == "function";
|
|
2876
|
-
if (!f && !
|
|
2958
|
+
if (!f && !n())
|
|
2877
2959
|
throw new Error("Callback required as last argument");
|
|
2878
2960
|
if (f) {
|
|
2879
2961
|
if (h < 2)
|
|
@@ -2882,12 +2964,12 @@ function gr() {
|
|
|
2882
2964
|
} else {
|
|
2883
2965
|
if (h < 1)
|
|
2884
2966
|
throw new Error("Too few arguments provided");
|
|
2885
|
-
return h === 1 ? (c = i, i = a = void 0) : h === 2 && !i.getContext && (a = c, c = i, i = void 0), new Promise(function(d,
|
|
2967
|
+
return h === 1 ? (c = i, i = a = void 0) : h === 2 && !i.getContext && (a = c, c = i, i = void 0), new Promise(function(d, g) {
|
|
2886
2968
|
try {
|
|
2887
2969
|
const p = e.create(c, a);
|
|
2888
2970
|
d(s(p, i, a));
|
|
2889
2971
|
} catch (p) {
|
|
2890
|
-
|
|
2972
|
+
g(p);
|
|
2891
2973
|
}
|
|
2892
2974
|
});
|
|
2893
2975
|
}
|
|
@@ -2898,60 +2980,400 @@ function gr() {
|
|
|
2898
2980
|
l(d);
|
|
2899
2981
|
}
|
|
2900
2982
|
}
|
|
2901
|
-
return
|
|
2902
|
-
return
|
|
2903
|
-
}),
|
|
2983
|
+
return G.create = e.create, G.toCanvas = o.bind(null, t.render), G.toDataURL = o.bind(null, t.renderToDataURL), G.toString = o.bind(null, function(s, i, c) {
|
|
2984
|
+
return r.render(s, c);
|
|
2985
|
+
}), G;
|
|
2904
2986
|
}
|
|
2905
|
-
var
|
|
2906
|
-
const
|
|
2987
|
+
var Sr = Rr();
|
|
2988
|
+
const Mr = /* @__PURE__ */ ar(Sr), Br = (n) => {
|
|
2907
2989
|
var e = {
|
|
2908
2990
|
errorCorrectionLevel: "H",
|
|
2909
2991
|
type: "image/jpeg",
|
|
2910
2992
|
margin: 1,
|
|
2911
2993
|
width: 300
|
|
2912
2994
|
};
|
|
2913
|
-
let
|
|
2914
|
-
const
|
|
2995
|
+
let t = null;
|
|
2996
|
+
const r = async (a) => {
|
|
2915
2997
|
const l = new URL(window.location.href), u = new URL(l.pathname, l.origin);
|
|
2916
2998
|
u.searchParams.set("state", "1-" + a), console.log("生成登录二维码链接:", u.toString());
|
|
2917
|
-
var h =
|
|
2918
|
-
await
|
|
2999
|
+
var h = n || document.getElementById("qrcode");
|
|
3000
|
+
await Mr.toDataURL(h, u.toString(), e);
|
|
2919
3001
|
}, o = async (a) => {
|
|
2920
3002
|
const l = await fetch(`/api/router?path=wx&key=checkLogin&state=${a}`).then((u) => u.json());
|
|
2921
3003
|
if (l.code === 200) {
|
|
2922
3004
|
console.log(l);
|
|
2923
3005
|
const u = l.data;
|
|
2924
|
-
u && (localStorage.setItem("token", u.accessToken), await
|
|
2925
|
-
|
|
3006
|
+
u && (localStorage.setItem("token", u.accessToken), await U.setLoginToken(u)), c(), setTimeout(() => {
|
|
3007
|
+
ie();
|
|
2926
3008
|
}, 1e3);
|
|
2927
3009
|
} else
|
|
2928
|
-
|
|
3010
|
+
t = setTimeout(() => {
|
|
2929
3011
|
o(a), console.log("继续检测登录状态");
|
|
2930
3012
|
}, 2e3);
|
|
2931
3013
|
}, s = Math.random().toString(36).substring(2, 15);
|
|
2932
|
-
|
|
3014
|
+
r(s), o(s);
|
|
2933
3015
|
const i = setInterval(() => {
|
|
2934
3016
|
const a = Math.random().toString(36).substring(2, 15);
|
|
2935
|
-
clearTimeout(
|
|
3017
|
+
clearTimeout(t), r(a), o(a), console.log("更新二维码");
|
|
2936
3018
|
}, 9e4), c = () => {
|
|
2937
|
-
clearTimeout(
|
|
3019
|
+
clearTimeout(t), clearInterval(i), console.log("停止检测登录状态");
|
|
2938
3020
|
};
|
|
2939
|
-
return { createQrcode:
|
|
2940
|
-
}
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
3021
|
+
return { createQrcode: r, clear: c };
|
|
3022
|
+
};
|
|
3023
|
+
function Lr(n) {
|
|
3024
|
+
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
3025
|
+
}
|
|
3026
|
+
var Oe = { exports: {} }, Ft;
|
|
3027
|
+
function Ir() {
|
|
3028
|
+
return Ft || (Ft = 1, (function(n) {
|
|
3029
|
+
var e = Object.prototype.hasOwnProperty, t = "~";
|
|
3030
|
+
function r() {
|
|
3031
|
+
}
|
|
3032
|
+
Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (t = !1));
|
|
3033
|
+
function o(a, l, u) {
|
|
3034
|
+
this.fn = a, this.context = l, this.once = u || !1;
|
|
3035
|
+
}
|
|
3036
|
+
function s(a, l, u, h, f) {
|
|
3037
|
+
if (typeof u != "function")
|
|
3038
|
+
throw new TypeError("The listener must be a function");
|
|
3039
|
+
var d = new o(u, h || a, f), g = t ? t + l : l;
|
|
3040
|
+
return a._events[g] ? a._events[g].fn ? a._events[g] = [a._events[g], d] : a._events[g].push(d) : (a._events[g] = d, a._eventsCount++), a;
|
|
3041
|
+
}
|
|
3042
|
+
function i(a, l) {
|
|
3043
|
+
--a._eventsCount === 0 ? a._events = new r() : delete a._events[l];
|
|
3044
|
+
}
|
|
3045
|
+
function c() {
|
|
3046
|
+
this._events = new r(), this._eventsCount = 0;
|
|
3047
|
+
}
|
|
3048
|
+
c.prototype.eventNames = function() {
|
|
3049
|
+
var l = [], u, h;
|
|
3050
|
+
if (this._eventsCount === 0)
|
|
3051
|
+
return l;
|
|
3052
|
+
for (h in u = this._events)
|
|
3053
|
+
e.call(u, h) && l.push(t ? h.slice(1) : h);
|
|
3054
|
+
return Object.getOwnPropertySymbols ? l.concat(Object.getOwnPropertySymbols(u)) : l;
|
|
3055
|
+
}, c.prototype.listeners = function(l) {
|
|
3056
|
+
var u = t ? t + l : l, h = this._events[u];
|
|
3057
|
+
if (!h)
|
|
3058
|
+
return [];
|
|
3059
|
+
if (h.fn)
|
|
3060
|
+
return [h.fn];
|
|
3061
|
+
for (var f = 0, d = h.length, g = new Array(d); f < d; f++)
|
|
3062
|
+
g[f] = h[f].fn;
|
|
3063
|
+
return g;
|
|
3064
|
+
}, c.prototype.listenerCount = function(l) {
|
|
3065
|
+
var u = t ? t + l : l, h = this._events[u];
|
|
3066
|
+
return h ? h.fn ? 1 : h.length : 0;
|
|
3067
|
+
}, c.prototype.emit = function(l, u, h, f, d, g) {
|
|
3068
|
+
var p = t ? t + l : l;
|
|
3069
|
+
if (!this._events[p])
|
|
3070
|
+
return !1;
|
|
3071
|
+
var m = this._events[p], y = arguments.length, E, w;
|
|
3072
|
+
if (m.fn) {
|
|
3073
|
+
switch (m.once && this.removeListener(l, m.fn, void 0, !0), y) {
|
|
3074
|
+
case 1:
|
|
3075
|
+
return m.fn.call(m.context), !0;
|
|
3076
|
+
case 2:
|
|
3077
|
+
return m.fn.call(m.context, u), !0;
|
|
3078
|
+
case 3:
|
|
3079
|
+
return m.fn.call(m.context, u, h), !0;
|
|
3080
|
+
case 4:
|
|
3081
|
+
return m.fn.call(m.context, u, h, f), !0;
|
|
3082
|
+
case 5:
|
|
3083
|
+
return m.fn.call(m.context, u, h, f, d), !0;
|
|
3084
|
+
case 6:
|
|
3085
|
+
return m.fn.call(m.context, u, h, f, d, g), !0;
|
|
3086
|
+
}
|
|
3087
|
+
for (w = 1, E = new Array(y - 1); w < y; w++)
|
|
3088
|
+
E[w - 1] = arguments[w];
|
|
3089
|
+
m.fn.apply(m.context, E);
|
|
3090
|
+
} else {
|
|
3091
|
+
var x = m.length, M;
|
|
3092
|
+
for (w = 0; w < x; w++)
|
|
3093
|
+
switch (m[w].once && this.removeListener(l, m[w].fn, void 0, !0), y) {
|
|
3094
|
+
case 1:
|
|
3095
|
+
m[w].fn.call(m[w].context);
|
|
3096
|
+
break;
|
|
3097
|
+
case 2:
|
|
3098
|
+
m[w].fn.call(m[w].context, u);
|
|
3099
|
+
break;
|
|
3100
|
+
case 3:
|
|
3101
|
+
m[w].fn.call(m[w].context, u, h);
|
|
3102
|
+
break;
|
|
3103
|
+
case 4:
|
|
3104
|
+
m[w].fn.call(m[w].context, u, h, f);
|
|
3105
|
+
break;
|
|
3106
|
+
default:
|
|
3107
|
+
if (!E)
|
|
3108
|
+
for (M = 1, E = new Array(y - 1); M < y; M++)
|
|
3109
|
+
E[M - 1] = arguments[M];
|
|
3110
|
+
m[w].fn.apply(m[w].context, E);
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
return !0;
|
|
3114
|
+
}, c.prototype.on = function(l, u, h) {
|
|
3115
|
+
return s(this, l, u, h, !1);
|
|
3116
|
+
}, c.prototype.once = function(l, u, h) {
|
|
3117
|
+
return s(this, l, u, h, !0);
|
|
3118
|
+
}, c.prototype.removeListener = function(l, u, h, f) {
|
|
3119
|
+
var d = t ? t + l : l;
|
|
3120
|
+
if (!this._events[d])
|
|
3121
|
+
return this;
|
|
3122
|
+
if (!u)
|
|
3123
|
+
return i(this, d), this;
|
|
3124
|
+
var g = this._events[d];
|
|
3125
|
+
if (g.fn)
|
|
3126
|
+
g.fn === u && (!f || g.once) && (!h || g.context === h) && i(this, d);
|
|
3127
|
+
else {
|
|
3128
|
+
for (var p = 0, m = [], y = g.length; p < y; p++)
|
|
3129
|
+
(g[p].fn !== u || f && !g[p].once || h && g[p].context !== h) && m.push(g[p]);
|
|
3130
|
+
m.length ? this._events[d] = m.length === 1 ? m[0] : m : i(this, d);
|
|
3131
|
+
}
|
|
3132
|
+
return this;
|
|
3133
|
+
}, c.prototype.removeAllListeners = function(l) {
|
|
3134
|
+
var u;
|
|
3135
|
+
return l ? (u = t ? t + l : l, this._events[u] && i(this, u)) : (this._events = new r(), this._eventsCount = 0), this;
|
|
3136
|
+
}, c.prototype.off = c.prototype.removeListener, c.prototype.addListener = c.prototype.on, c.prefixed = t, c.EventEmitter = c, n.exports = c;
|
|
3137
|
+
})(Oe)), Oe.exports;
|
|
3138
|
+
}
|
|
3139
|
+
var $r = Ir(), Pr = /* @__PURE__ */ Lr($r), zt = (n) => {
|
|
3140
|
+
const e = n.timeout || 3e5, t = n.interval || 1e3, r = n?.checkSuccess || (() => !0), o = n.signal;
|
|
3141
|
+
return new Promise(async (s, i) => {
|
|
3142
|
+
let c, a = setTimeout(() => {
|
|
3143
|
+
clearTimeout(c), s({
|
|
3144
|
+
code: 500,
|
|
3145
|
+
message: "timeout"
|
|
3146
|
+
});
|
|
3147
|
+
}, e);
|
|
3148
|
+
const l = n.fn || (() => !0), u = async () => {
|
|
3149
|
+
if (o?.aborted)
|
|
3150
|
+
return clearInterval(c), clearTimeout(a), s({
|
|
3151
|
+
code: 499,
|
|
3152
|
+
message: "operation cancelled"
|
|
3153
|
+
});
|
|
3154
|
+
const h = await l();
|
|
3155
|
+
r(h) ? (clearInterval(c), clearTimeout(a), s({
|
|
3156
|
+
code: 200,
|
|
3157
|
+
data: h
|
|
3158
|
+
})) : setTimeout(() => {
|
|
3159
|
+
u();
|
|
3160
|
+
}, t);
|
|
3161
|
+
};
|
|
3162
|
+
o && o.addEventListener("abort", () => {
|
|
3163
|
+
clearInterval(c), clearTimeout(a), s({
|
|
3164
|
+
code: 499,
|
|
3165
|
+
message: "operation cancelled"
|
|
3166
|
+
});
|
|
3167
|
+
}), u();
|
|
3168
|
+
});
|
|
3169
|
+
};
|
|
3170
|
+
class ln {
|
|
3171
|
+
modules = /* @__PURE__ */ new Map();
|
|
3172
|
+
event;
|
|
3173
|
+
loading;
|
|
3174
|
+
static reRunFn = zt;
|
|
3175
|
+
timeout = 300 * 1e3;
|
|
3176
|
+
constructor() {
|
|
3177
|
+
this.event = new Pr(), this.loading = !1;
|
|
3178
|
+
}
|
|
3179
|
+
listenKey(e, t) {
|
|
3180
|
+
const r = t?.timeout ?? this.timeout;
|
|
3181
|
+
return new Promise((o) => {
|
|
3182
|
+
const s = setTimeout(() => {
|
|
3183
|
+
this.event.removeListener(e, i), o({
|
|
3184
|
+
code: 500,
|
|
3185
|
+
message: "timeout"
|
|
3186
|
+
});
|
|
3187
|
+
}, r), i = (c) => {
|
|
3188
|
+
if (clearTimeout(s), c)
|
|
3189
|
+
return o({
|
|
3190
|
+
code: 500,
|
|
3191
|
+
message: c
|
|
3192
|
+
});
|
|
3193
|
+
const a = this.modules.get(e);
|
|
3194
|
+
a?.loadSuccessClear && this.remove(e), o({
|
|
3195
|
+
code: 200,
|
|
3196
|
+
data: a?.modules
|
|
3197
|
+
});
|
|
3198
|
+
};
|
|
3199
|
+
this.event.once(e, i);
|
|
3200
|
+
});
|
|
3201
|
+
}
|
|
3202
|
+
async hasLoaded(e, t) {
|
|
3203
|
+
if (!e)
|
|
3204
|
+
return {
|
|
3205
|
+
code: 404,
|
|
3206
|
+
message: "key is required"
|
|
3207
|
+
};
|
|
3208
|
+
if (!this.modules.has(e)) {
|
|
3209
|
+
const s = t?.isExist ?? !0, i = t?.timeout ?? this.timeout;
|
|
3210
|
+
return s ? await this.listenKey(e, { timeout: i }) : {
|
|
3211
|
+
code: 404
|
|
3212
|
+
};
|
|
3213
|
+
}
|
|
3214
|
+
const o = this.modules.get(e);
|
|
3215
|
+
return o?.status === "loaded" ? {
|
|
3216
|
+
code: 200,
|
|
3217
|
+
data: o.modules
|
|
3218
|
+
} : o?.status === "loading" ? await this.listenKey(e, { timeout: t?.timeout ?? this.timeout }) : o?.status === "error" ? {
|
|
3219
|
+
code: 500,
|
|
3220
|
+
message: "load error"
|
|
3221
|
+
} : o?.status === "cancel" ? {
|
|
3222
|
+
code: 499,
|
|
3223
|
+
message: "operation cancelled"
|
|
3224
|
+
} : {
|
|
3225
|
+
code: 404
|
|
3226
|
+
};
|
|
3227
|
+
}
|
|
3228
|
+
async loadFn(e, t) {
|
|
3229
|
+
const r = t.key;
|
|
3230
|
+
if (!r)
|
|
3231
|
+
return {
|
|
3232
|
+
code: 404,
|
|
3233
|
+
message: "key is required"
|
|
3234
|
+
};
|
|
3235
|
+
const o = {
|
|
3236
|
+
key: t.key,
|
|
3237
|
+
status: "loading",
|
|
3238
|
+
loading: !0,
|
|
3239
|
+
loadSuccessClear: t.loadSuccessClear ?? !0
|
|
3240
|
+
};
|
|
3241
|
+
let s = "";
|
|
3242
|
+
try {
|
|
3243
|
+
const i = t.isReRun ?? !1;
|
|
3244
|
+
let c;
|
|
3245
|
+
if (!i)
|
|
3246
|
+
this.modules.set(r, o), c = await e();
|
|
3247
|
+
else {
|
|
3248
|
+
o.controller = new AbortController();
|
|
3249
|
+
const a = o.controller.signal;
|
|
3250
|
+
this.modules.set(r, o);
|
|
3251
|
+
const l = await zt({
|
|
3252
|
+
timeout: t.timeout,
|
|
3253
|
+
interval: t.interval,
|
|
3254
|
+
checkSuccess: t.checkSuccess,
|
|
3255
|
+
fn: e,
|
|
3256
|
+
signal: a
|
|
3257
|
+
});
|
|
3258
|
+
if (o.controller = null, l.code === 499)
|
|
3259
|
+
return o.status = "cancel", {
|
|
3260
|
+
code: 499,
|
|
3261
|
+
message: "operation cancelled"
|
|
3262
|
+
};
|
|
3263
|
+
if (l.code !== 200)
|
|
3264
|
+
throw new Error(l.message);
|
|
3265
|
+
c = l.data;
|
|
3266
|
+
}
|
|
3267
|
+
return o.modules = c, o.status = "loaded", {
|
|
3268
|
+
code: 200,
|
|
3269
|
+
data: c
|
|
3270
|
+
};
|
|
3271
|
+
} catch (i) {
|
|
3272
|
+
return s = i.message, o.status = "error", {
|
|
3273
|
+
code: 500,
|
|
3274
|
+
message: i
|
|
3275
|
+
};
|
|
3276
|
+
} finally {
|
|
3277
|
+
o.loading = !1, this.modules.set(t.key, o), s ? this.event.emit(t.key, s) : this.event.emit(t.key);
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
async load(e, t) {
|
|
3281
|
+
this.loading = !0;
|
|
3282
|
+
const r = t.key;
|
|
3283
|
+
if (!r)
|
|
3284
|
+
return {
|
|
3285
|
+
code: 404,
|
|
3286
|
+
message: "key is required"
|
|
3287
|
+
};
|
|
3288
|
+
if (t?.force && this.remove(r), this.modules.has(r))
|
|
3289
|
+
return await this.hasLoaded(r);
|
|
3290
|
+
if (typeof e == "function")
|
|
3291
|
+
return this.loadFn(e, t);
|
|
3292
|
+
console.error("loadContent is not a function and not has loaded");
|
|
3293
|
+
}
|
|
3294
|
+
remove(e) {
|
|
3295
|
+
this.modules.has(e) && (this.checkRemoveController(e), this.modules.delete(e));
|
|
3296
|
+
}
|
|
3297
|
+
emitLoaded(e) {
|
|
3298
|
+
this.checkRemoveController(e), this.event.emit(e);
|
|
3299
|
+
}
|
|
3300
|
+
setModule(e, t, r) {
|
|
3301
|
+
const o = {
|
|
3302
|
+
key: e,
|
|
3303
|
+
status: "loaded",
|
|
3304
|
+
loading: !1,
|
|
3305
|
+
modules: t || {},
|
|
3306
|
+
...r
|
|
3307
|
+
};
|
|
3308
|
+
return this.modules.set(e, o), this.emitLoaded(e), o;
|
|
3309
|
+
}
|
|
3310
|
+
cancel(e) {
|
|
3311
|
+
this.checkRemoveController(e);
|
|
3312
|
+
}
|
|
3313
|
+
checkRemoveController(e) {
|
|
3314
|
+
const t = this.modules.get(e);
|
|
3315
|
+
t?.controller && (t.controller?.abort?.(), delete t.controller, this.modules.set(e, t));
|
|
3316
|
+
}
|
|
3317
|
+
}
|
|
3318
|
+
var D = globalThis || window || self, un = (n, e = "config", t) => {
|
|
3319
|
+
const r = D[e], o = r || n;
|
|
3320
|
+
return r || (o ? D[e] = o : D[e] = {}), D[e];
|
|
3321
|
+
}, he = (n, e, t = "config") => {
|
|
3322
|
+
const r = un({}, t);
|
|
3323
|
+
if (n && typeof r[n] < "u")
|
|
3324
|
+
return r[n];
|
|
3325
|
+
if (n && e) {
|
|
3326
|
+
if (typeof e != "function" && (r[n] = e), typeof e == "function") {
|
|
3327
|
+
const o = e();
|
|
3328
|
+
if (o instanceof Promise)
|
|
3329
|
+
return o.then((s) => (r[n] = s, s));
|
|
3330
|
+
r[n] = o;
|
|
3331
|
+
}
|
|
3332
|
+
return r[n];
|
|
3333
|
+
}
|
|
3334
|
+
if (n) {
|
|
3335
|
+
const o = new ln(), s = async () => r[n];
|
|
3336
|
+
return (async () => (await o.load(s, {
|
|
3337
|
+
key: n,
|
|
3338
|
+
isReRun: !0,
|
|
3339
|
+
checkSuccess: () => r[n],
|
|
3340
|
+
timeout: 3e5,
|
|
3341
|
+
interval: 1e3
|
|
3342
|
+
})).code !== 200 ? (console.error("load key error"), null) : r[n])();
|
|
3343
|
+
}
|
|
3344
|
+
return console.error("key is empty "), null;
|
|
3345
|
+
}, hn = (n, e = "config", t) => {
|
|
3346
|
+
const r = un({}, e);
|
|
3347
|
+
if (n && delete r[n], t?.getNew && t.init)
|
|
3348
|
+
return he(n, t.init, e);
|
|
3349
|
+
if (t?.getNew)
|
|
3350
|
+
return he(n, null, e);
|
|
3351
|
+
}, de = (n, e, t) => t ? hn(n, "context", { getNew: !0, init: e }) : he(n, e, "context"), Ht = de, jt = (n, e, t) => t ? hn(n, "config", { getNew: !0, init: e }) : he(n, e, "config");
|
|
3352
|
+
class fe {
|
|
3353
|
+
static isInit = !1;
|
|
3354
|
+
static init(e) {
|
|
3355
|
+
if (fe.isInit)
|
|
3356
|
+
return;
|
|
3357
|
+
const { load: t = !0, page: r = !1 } = e || {};
|
|
3358
|
+
fe.isInit = !0, D.useConfigKey = jt, D.useContextKey = de, D.use = Ht, D.webEnv = { useConfigKey: jt, useContextKey: de, use: Ht }, t && (D.Load = ln);
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
fe.init();
|
|
3362
|
+
const qr = de("login-emitter", nn), dn = "wxff97d569b1db16b6", Nr = '<svg t="1764510467010" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1958" width="32" height="32"><path d="M615.904 388.48c8.8 0 17.536 0.64 26.176 1.6-23.52-109.536-140.608-190.912-274.272-190.912C218.4 199.2 96 301.056 96 430.4c0 74.656 40.736 135.936 108.768 183.488l-27.2 81.792 95.04-47.648c33.984 6.72 61.28 13.632 95.2 13.632 8.544 0 16.992-0.416 25.376-1.088a202.496 202.496 0 0 1-8.384-56.96c0-118.752 101.984-215.136 231.104-215.136zM469.76 314.784c20.48 0 34.016 13.472 34.016 33.92 0 20.352-13.536 34.016-34.016 34.016-20.384 0-40.832-13.664-40.832-34.016 0-20.448 20.448-33.92 40.832-33.92zM279.52 382.72c-20.384 0-40.928-13.664-40.928-34.016 0-20.448 20.544-33.92 40.928-33.92 20.352 0 33.92 13.472 33.92 33.92 0 20.384-13.568 34.016-33.92 34.016z" fill="" p-id="1959"></path><path d="M864 600.352c0-108.672-108.736-197.28-230.88-197.28-129.344 0-231.2 88.576-231.2 197.28 0 108.864 101.856 197.248 231.2 197.248 27.072 0 54.368-6.816 81.568-13.632l74.56 40.8-20.448-67.904C823.328 715.936 864 661.664 864 600.352z m-305.856-34.016c-13.536 0-27.2-13.44-27.2-27.2 0-13.568 13.664-27.2 27.2-27.2 20.576 0 34.016 13.632 34.016 27.2 0 13.76-13.44 27.2-34.016 27.2z m149.536 0c-13.44 0-27.008-13.44-27.008-27.2 0-13.568 13.568-27.2 27.008-27.2 20.352 0 34.016 13.632 34.016 27.2 0 13.76-13.664 27.2-34.016 27.2z" fill="" p-id="1960"></path></svg>', Dr = '<svg t="1764511395617" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3882" width="32" height="32"><path d="M256 259.584c-29.184 0-51.2 14.848-51.2 44.032s29.184 44.032 51.2 44.032c29.184 0 44.032-14.848 44.032-44.032s-22.016-44.032-44.032-44.032zM541.184 303.616c0-29.184-14.848-44.032-44.032-44.032-29.184 0-51.2 14.848-51.2 44.032s29.184 44.032 51.2 44.032c29.696 0 44.032-22.016 44.032-44.032zM614.4 508.416c-14.848 0-36.352 14.848-36.352 36.352 0 14.848 14.848 36.352 36.352 36.352 29.184 0 44.032-14.848 44.032-36.352 0-14.336-14.848-36.352-44.032-36.352z" p-id="3883"></path><path d="M1024 625.152c0-138.752-124.416-256-285.184-270.848-29.184-153.6-189.952-263.168-373.248-263.168C160.768 91.648 0 230.4 0 406.016c0 95.232 44.032 175.616 138.752 241.152L109.568 742.4c0 7.168 0 14.848 7.168 22.016h14.848l117.248-58.368h14.848c36.352 7.168 66.048 14.848 109.568 14.848 14.848 0 44.032-7.168 44.032-7.168C460.8 822.784 578.048 896 716.8 896c36.352 0 73.216-7.168 102.4-14.848l87.552 51.2h14.848c7.168-7.168 7.168-7.168 7.168-14.848l-22.016-87.552c80.896-58.368 117.248-131.584 117.248-204.8z m-621.568 51.2h-36.352c-36.352 0-66.048-7.168-95.232-14.848l-22.016-7.168h-7.168L153.6 698.368l22.016-66.048c0-7.168 0-14.848-7.168-14.848C80.384 559.616 36.352 486.4 36.352 398.848 36.352 245.248 182.784 128 358.4 128c160.768 0 300.032 95.232 329.216 226.816-168.448 0-300.032 117.248-300.032 263.168 7.168 22.016 14.848 44.032 14.848 58.368z m467.968 132.096c-7.168 7.168-7.168 7.168-7.168 14.848l14.848 51.2L819.2 844.8h-14.848c-29.184 7.168-66.048 14.848-95.232 14.848-146.432 0-270.848-102.4-270.848-226.816 0-131.584 124.416-233.984 270.848-233.984s270.848 102.4 270.848 226.816c0 65.536-36.352 123.904-109.568 182.784z" p-id="3884"></path><path d="M804.352 508.416c-14.848 0-36.352 14.848-36.352 36.352 0 14.848 14.848 36.352 36.352 36.352 29.184 0 44.032-14.848 44.032-36.352 0-14.336-14.336-36.352-44.032-36.352z" p-id="3885"></path></svg>', Ur = '<svg t="1764511425462" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5097" width="32" height="32"><path d="M820.409449 797.228346q0 25.19685-10.07874 46.866142t-27.716535 38.299213-41.322835 26.204724-50.897638 9.574803l-357.795276 0q-27.212598 0-50.897638-9.574803t-41.322835-26.204724-27.716535-38.299213-10.07874-46.866142l0-675.275591q0-25.19685 10.07874-47.370079t27.716535-38.80315 41.322835-26.204724 50.897638-9.574803l357.795276 0q27.212598 0 50.897638 9.574803t41.322835 26.204724 27.716535 38.80315 10.07874 47.370079l0 675.275591zM738.771654 170.330709l-455.559055 0 0 577.511811 455.559055 0 0-577.511811zM510.992126 776.062992q-21.165354 0-36.787402 15.11811t-15.622047 37.291339q0 21.165354 15.622047 36.787402t36.787402 15.622047q22.173228 0 37.291339-15.622047t15.11811-36.787402q0-22.173228-15.11811-37.291339t-37.291339-15.11811zM591.622047 84.661417q0-8.062992-5.03937-12.598425t-11.086614-4.535433l-128 0q-5.03937 0-10.582677 4.535433t-5.543307 12.598425 5.03937 12.598425 11.086614 4.535433l128 0q6.047244 0 11.086614-4.535433t5.03937-12.598425z" p-id="5098"></path></svg>', Fr = '<svg t="1764511500570" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10511" width="32" height="32"><path d="M768.9216 422.72768 372.06016 422.72768C378.88 365.21984 329.37984 131.42016 512.2048 125.72672c173.83424-6.59456 146.78016 213.34016 146.78016 213.34016l85.13536 0.57344c0 0 24.73984-294.4-231.91552-295.8336C232.09984 58.01984 297.82016 377.18016 289.28 422.72768c1.98656 0 4.56704 0 7.29088 0-55.88992 0-101.21216 45.34272-101.21216 101.21216l0 337.38752c0 55.88992 45.34272 101.21216 101.21216 101.21216l472.35072 0c55.88992 0 101.21216-45.34272 101.21216-101.21216L870.13376 523.93984C870.13376 468.0704 824.79104 422.72768 768.9216 422.72768zM566.4768 717.02528l0 76.84096c0 18.57536-15.1552 33.73056-33.73056 33.73056-18.57536 0-33.73056-15.1552-33.73056-33.73056l0-76.84096c-20.09088-11.69408-33.73056-33.21856-33.73056-58.12224 0-37.2736 30.208-67.4816 67.4816-67.4816 37.2736 0 67.4816 30.208 67.4816 67.4816C600.22784 683.80672 586.58816 705.3312 566.4768 717.02528z" fill="#272636" p-id="10512"></path></svg>', We = {
|
|
3363
|
+
pwd: Fr,
|
|
3364
|
+
phone: Ur,
|
|
3365
|
+
wxmpSvg: Nr,
|
|
3366
|
+
wxOpenSvg: Dr
|
|
3367
|
+
}, zr = [
|
|
2946
3368
|
{ id: "password", name: "密码登录", icon: "pwd" },
|
|
2947
3369
|
{ id: "wechat", name: "微信登录", icon: "wxmpSvg", appid: "wx9378885c8390e09b" },
|
|
2948
|
-
{ id: "wechat-mp", name: "微信公众号", icon: "wxOpenSvg", appid:
|
|
3370
|
+
{ id: "wechat-mp", name: "微信公众号", icon: "wxOpenSvg", appid: dn },
|
|
2949
3371
|
{ id: "wechat-mp-ticket", name: "微信公众号", icon: "wxOpenSvg" },
|
|
2950
3372
|
{ id: "phone", name: "手机号登录", icon: "phone" }
|
|
2951
|
-
],
|
|
2952
|
-
const
|
|
3373
|
+
], Hr = () => {
|
|
3374
|
+
const n = window.location.hostname;
|
|
2953
3375
|
let e = [];
|
|
2954
|
-
switch (
|
|
3376
|
+
switch (n) {
|
|
2955
3377
|
case "kevisual.xiongxiao.me":
|
|
2956
3378
|
e = ["password", "wechat-mp"];
|
|
2957
3379
|
break;
|
|
@@ -2962,12 +3384,11 @@ const mr = /* @__PURE__ */ Jn(pr), wr = (t) => {
|
|
|
2962
3384
|
e = ["password", "phone", "wechat", "wechat-mp", "wechat-mp-ticket"];
|
|
2963
3385
|
break;
|
|
2964
3386
|
}
|
|
2965
|
-
return
|
|
3387
|
+
return zr.filter((t) => e.includes(t.id));
|
|
2966
3388
|
};
|
|
2967
|
-
|
|
2968
|
-
class Tr extends HTMLElement {
|
|
3389
|
+
class jr extends HTMLElement {
|
|
2969
3390
|
selectedMethod = "password";
|
|
2970
|
-
loginMethods =
|
|
3391
|
+
loginMethods = Hr();
|
|
2971
3392
|
setLoginMethods(e) {
|
|
2972
3393
|
this.loginMethods = e, this.render();
|
|
2973
3394
|
}
|
|
@@ -2975,30 +3396,32 @@ class Tr extends HTMLElement {
|
|
|
2975
3396
|
super();
|
|
2976
3397
|
}
|
|
2977
3398
|
connectedCallback() {
|
|
2978
|
-
this.attachShadow({ mode: "open" }), this.render(), this.bindEvents(),
|
|
3399
|
+
this.attachShadow({ mode: "open" }), this.render(), this.bindEvents(), er();
|
|
2979
3400
|
}
|
|
2980
3401
|
#e = null;
|
|
2981
3402
|
selectLoginMethod(e) {
|
|
2982
3403
|
this.selectedMethod = e, this.render(), this.#e && (this.#e(), this.#e = null);
|
|
2983
3404
|
}
|
|
2984
3405
|
getMethodData(e) {
|
|
2985
|
-
return this.loginMethods.find((
|
|
3406
|
+
return this.loginMethods.find((t) => t.id === e);
|
|
2986
3407
|
}
|
|
2987
3408
|
bindEvents() {
|
|
2988
3409
|
this.shadowRoot && (this.shadowRoot.addEventListener("click", (e) => {
|
|
2989
|
-
const
|
|
2990
|
-
if (
|
|
2991
|
-
const o =
|
|
3410
|
+
const r = e.target.closest(".login-method");
|
|
3411
|
+
if (r) {
|
|
3412
|
+
const o = r.getAttribute("data-method");
|
|
2992
3413
|
o && this.selectLoginMethod(o);
|
|
2993
3414
|
}
|
|
2994
3415
|
}), this.shadowRoot.addEventListener("submit", (e) => {
|
|
2995
|
-
const
|
|
2996
|
-
|
|
3416
|
+
const t = e.target;
|
|
3417
|
+
t && t.id === "loginForm" && (e.preventDefault(), this.handleLogin());
|
|
3418
|
+
}), qr.on("login-success", () => {
|
|
3419
|
+
console.log("收到登录成功事件,处理后续逻辑");
|
|
2997
3420
|
}));
|
|
2998
3421
|
}
|
|
2999
3422
|
handleLogin() {
|
|
3000
3423
|
const e = this.getFormData();
|
|
3001
|
-
|
|
3424
|
+
Jn({
|
|
3002
3425
|
loginMethod: this.selectedMethod,
|
|
3003
3426
|
data: e
|
|
3004
3427
|
}), this.dispatchEvent(new CustomEvent("login", {
|
|
@@ -3013,15 +3436,15 @@ class Tr extends HTMLElement {
|
|
|
3013
3436
|
if (!this.shadowRoot) return {};
|
|
3014
3437
|
switch (this.selectedMethod) {
|
|
3015
3438
|
case "password":
|
|
3016
|
-
const e = this.shadowRoot.querySelector("#username"),
|
|
3439
|
+
const e = this.shadowRoot.querySelector("#username"), t = this.shadowRoot.querySelector("#password");
|
|
3017
3440
|
return {
|
|
3018
3441
|
username: e?.value || "",
|
|
3019
|
-
password:
|
|
3442
|
+
password: t?.value || ""
|
|
3020
3443
|
};
|
|
3021
3444
|
case "phone":
|
|
3022
|
-
const
|
|
3445
|
+
const r = this.shadowRoot.querySelector("#phone"), o = this.shadowRoot.querySelector("#code");
|
|
3023
3446
|
return {
|
|
3024
|
-
phone:
|
|
3447
|
+
phone: r?.value || "",
|
|
3025
3448
|
code: o?.value || ""
|
|
3026
3449
|
};
|
|
3027
3450
|
case "wechat":
|
|
@@ -3037,7 +3460,7 @@ class Tr extends HTMLElement {
|
|
|
3037
3460
|
}
|
|
3038
3461
|
}
|
|
3039
3462
|
renderPasswordForm() {
|
|
3040
|
-
return
|
|
3463
|
+
return I`
|
|
3041
3464
|
<form id="loginForm" class="login-form">
|
|
3042
3465
|
<div class="form-group">
|
|
3043
3466
|
<input
|
|
@@ -3064,7 +3487,7 @@ class Tr extends HTMLElement {
|
|
|
3064
3487
|
`;
|
|
3065
3488
|
}
|
|
3066
3489
|
renderPhoneForm() {
|
|
3067
|
-
return
|
|
3490
|
+
return I`
|
|
3068
3491
|
<form id="loginForm" class="login-form">
|
|
3069
3492
|
<div class="form-group">
|
|
3070
3493
|
<input
|
|
@@ -3093,7 +3516,7 @@ class Tr extends HTMLElement {
|
|
|
3093
3516
|
`;
|
|
3094
3517
|
}
|
|
3095
3518
|
renderWechatForm() {
|
|
3096
|
-
return
|
|
3519
|
+
return I`
|
|
3097
3520
|
<div class="wechat-login">
|
|
3098
3521
|
<slot></slot>
|
|
3099
3522
|
</div>
|
|
@@ -3102,9 +3525,9 @@ class Tr extends HTMLElement {
|
|
|
3102
3525
|
renderWechatMpForm() {
|
|
3103
3526
|
const e = this;
|
|
3104
3527
|
return setTimeout(() => {
|
|
3105
|
-
const
|
|
3106
|
-
e.#e =
|
|
3107
|
-
}, 0),
|
|
3528
|
+
const t = e.shadowRoot.querySelector("#qrcode"), { clear: r } = Br(t);
|
|
3529
|
+
e.#e = r;
|
|
3530
|
+
}, 0), I`
|
|
3108
3531
|
<div class="wechat-login">
|
|
3109
3532
|
<div class="qr-container">
|
|
3110
3533
|
<div class="qr-placeholder">
|
|
@@ -3118,15 +3541,15 @@ class Tr extends HTMLElement {
|
|
|
3118
3541
|
renderWechatMpTicketForm() {
|
|
3119
3542
|
const e = this;
|
|
3120
3543
|
return setTimeout(async () => {
|
|
3121
|
-
const
|
|
3122
|
-
if (!
|
|
3123
|
-
const
|
|
3124
|
-
if (
|
|
3125
|
-
|
|
3126
|
-
const o =
|
|
3544
|
+
const t = await or();
|
|
3545
|
+
if (!t) return;
|
|
3546
|
+
const r = e.shadowRoot.querySelector(".qrcode");
|
|
3547
|
+
if (t.url) {
|
|
3548
|
+
r.src = t.url;
|
|
3549
|
+
const o = sr(t.ticket);
|
|
3127
3550
|
e.#e = o;
|
|
3128
3551
|
}
|
|
3129
|
-
}, 0),
|
|
3552
|
+
}, 0), I`
|
|
3130
3553
|
<div class="wechat-login">
|
|
3131
3554
|
<div class="qr-container">
|
|
3132
3555
|
<div class="qr-placeholder">
|
|
@@ -3151,7 +3574,7 @@ class Tr extends HTMLElement {
|
|
|
3151
3574
|
case "phone":
|
|
3152
3575
|
return this.renderPhoneForm();
|
|
3153
3576
|
case "wechat":
|
|
3154
|
-
return
|
|
3577
|
+
return ir({ appid: e?.appid || "" }), this.renderWechatForm();
|
|
3155
3578
|
case "wechat-mp":
|
|
3156
3579
|
return this.renderWechatMpForm();
|
|
3157
3580
|
case "wechat-mp-ticket":
|
|
@@ -3162,7 +3585,7 @@ class Tr extends HTMLElement {
|
|
|
3162
3585
|
}
|
|
3163
3586
|
render() {
|
|
3164
3587
|
if (!this.shadowRoot) return;
|
|
3165
|
-
const e = (
|
|
3588
|
+
const e = (r) => typeof r == "string" && !We[r] ? I`<span class="method-icon-emoji">${r}</span>` : typeof r == "string" && We[r] ? I`<span class="method-icon-svg">${at(We[r])}</span>` : typeof r == "string" && (r.includes("<svg") || r.includes("<?xml")) ? I`<span class="method-icon-svg">${at(r)}</span>` : I`<span class="method-icon-emoji">${r}</span>`, t = I`
|
|
3166
3589
|
<style>
|
|
3167
3590
|
:host {
|
|
3168
3591
|
display: block;
|
|
@@ -3374,13 +3797,13 @@ class Tr extends HTMLElement {
|
|
|
3374
3797
|
|
|
3375
3798
|
<div class="login-sidebar">
|
|
3376
3799
|
<div class="login-methods">
|
|
3377
|
-
${this.loginMethods.map((
|
|
3800
|
+
${this.loginMethods.map((r) => I`
|
|
3378
3801
|
<button
|
|
3379
|
-
class="login-method ${this.selectedMethod ===
|
|
3380
|
-
data-method="${
|
|
3802
|
+
class="login-method ${this.selectedMethod === r.id ? "active" : ""}"
|
|
3803
|
+
data-method="${r.id}"
|
|
3381
3804
|
>
|
|
3382
|
-
${e(
|
|
3383
|
-
<span class="method-name">${
|
|
3805
|
+
${e(r.icon)}
|
|
3806
|
+
<span class="method-name">${r.name}</span>
|
|
3384
3807
|
</button>
|
|
3385
3808
|
`)}
|
|
3386
3809
|
</div>
|
|
@@ -3390,7 +3813,7 @@ class Tr extends HTMLElement {
|
|
|
3390
3813
|
</div>
|
|
3391
3814
|
</div>
|
|
3392
3815
|
`;
|
|
3393
|
-
|
|
3816
|
+
Jt(t, this.shadowRoot);
|
|
3394
3817
|
}
|
|
3395
3818
|
}
|
|
3396
|
-
customElements.define("kv-login",
|
|
3819
|
+
customElements.define("kv-login", jr);
|