@yourgoods/ui-smart 0.23.0 → 0.25.0

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.
@@ -1,872 +0,0 @@
1
- import { createElementBlock as b, openBlock as p, createElementVNode as U, defineComponent as ce, reactive as pe, watch as te, ref as D, toRefs as fe, computed as z, createCommentVNode as E, createVNode as S, toDisplayString as G, createBlock as X, createTextVNode as oe, unref as r, isRef as se, withCtx as _, onMounted as Ue, Fragment as je } from "vue";
2
- import { T as ge, c as Oe, a as qe, u as We, P as Be, b as He } from "./useRateLimitToast-CF0qx7i_.js";
3
- import { IconTelegramSm as ye, PInput as de, IconPhoneMd as Ke, IconMailMd as De, PButton as Ae, PDialog as Ge, PTopBar as Je, IconCrossMd as Qe, PTeleportContainer as Xe } from "@profeat/ui-kit";
4
- import { C as K, t as Ie, p as le, g as Le } from "./index-Du1aTQoC.js";
5
- const Ye = {
6
- xmlns: "http://www.w3.org/2000/svg",
7
- width: "12",
8
- height: "16",
9
- fill: "none"
10
- };
11
- function Ze(R, x) {
12
- return p(), b("svg", Ye, x[0] || (x[0] = [
13
- U("path", {
14
- fill: "#1C7EF1",
15
- "fill-rule": "evenodd",
16
- d: "M1 0a1 1 0 0 0-1 1v14a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1V1a1 1 0 0 0-1-1zm1.5 2a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h7a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5zM6 13a1 1 0 1 0 0 2 1 1 0 0 0 0-2",
17
- "clip-rule": "evenodd"
18
- }, null, -1)
19
- ]));
20
- }
21
- const ie = { render: Ze }, _e = { class: "dialogDefaultContainerInsideContent" }, eo = { style: { display: "flex", width: "100%", gap: "4px", "align-items": "center", "justify-content": "center", "text-align": "center" } }, oo = { class: "dialogDefaultContainerTextHint" }, to = { class: "chip" }, no = {
22
- key: 0,
23
- class: "input-wrapper"
24
- }, ao = {
25
- key: 1,
26
- class: "input-wrapper"
27
- }, lo = /* @__PURE__ */ ce({
28
- __name: "OldPhoneContent",
29
- props: {
30
- phone: {},
31
- code: {},
32
- hintText: { default: "Чтобы продолжить, введите код подтверждения из" },
33
- phoneError: { default: "" },
34
- codeError: { default: "" },
35
- rateLimitText: { default: "" },
36
- showPhone: { type: Boolean, default: !0 },
37
- showCode: { type: Boolean, default: !0 },
38
- sendCodeBySmsText: { default: "Получить код из СМС" },
39
- isFinalLimit: { type: Boolean },
40
- isNotMatchCode: { type: Boolean },
41
- loading: { type: Boolean },
42
- isTg: { type: Boolean }
43
- },
44
- emits: ["update:phone", "update:code", "edit", "on-match-code", "on-match-code-error", "on-send-code-again", "on-send-only-sms", "on-clear-code-error"],
45
- setup(R, { emit: x }) {
46
- const k = R, u = x, c = pe({
47
- touched: { phone: !1, code: !1 },
48
- phoneModel: k.phone,
49
- codeModel: k.code
50
- });
51
- te(
52
- () => c.phoneModel,
53
- (d) => u("update:phone", d)
54
- ), te(
55
- () => c.codeModel,
56
- (d) => u("update:code", d)
57
- );
58
- const v = (d) => {
59
- c.touched[d] = !0;
60
- };
61
- let g = D("");
62
- const L = (d) => {
63
- u("on-clear-code-error");
64
- const h = d.target;
65
- let m = ((h == null ? void 0 : h.value) ?? "").replace(/\D/g, "");
66
- m.length > 4 && (m = m.slice(0, 4)), T.value = m, h && h.value !== m && (h.value = m), m.length === 4 && m !== g.value && (g.value = m, u("on-match-code", { phone: e.value, code: m }));
67
- }, J = () => u("on-send-code-again", { phone: c.phoneModel }), Y = () => {
68
- console.debug("onSendCodeViaSms"), u("on-send-only-sms", { phone: c.phoneModel });
69
- }, { phoneModel: e, codeModel: T, touched: C } = fe(c), y = z(() => C.value.phone && !e.value.trim() ? "Введите телефон" : k.phoneError), M = z(() => k.isNotMatchCode ? "Неверный код" : C.value.code ? T.value.trim() ? k.codeError ?? null : "Введите код" : "");
70
- return (d, h) => (p(), b("div", _e, [
71
- U("div", eo, [
72
- U("div", oo, G(d.hintText), 1),
73
- U("div", to, [
74
- d.isTg ? (p(), X(r(ye), { key: 0 })) : (p(), X(r(ie), {
75
- key: 1,
76
- style: { "margin-left": "5px" }
77
- })),
78
- oe(" " + G(d.isTg ? "Telegram" : "СМС"), 1)
79
- ])
80
- ]),
81
- d.showPhone ? (p(), b("div", no, [
82
- S(r(de), {
83
- modelValue: r(e),
84
- "onUpdate:modelValue": h[0] || (h[0] = (m) => se(e) ? e.value = m : null),
85
- size: "large",
86
- "text-size": "medium",
87
- label: "Телефон",
88
- type: "tel",
89
- error: y.value,
90
- disabled: !0,
91
- onBlur: h[1] || (h[1] = (m) => v("phone")),
92
- onInput: h[2] || (h[2] = (m) => v("phone"))
93
- }, null, 8, ["modelValue", "error"]),
94
- S(r(Ke), {
95
- class: "icon-locked",
96
- onClick: h[3] || (h[3] = (m) => d.$emit("edit", "phone"))
97
- })
98
- ])) : E("", !0),
99
- d.showCode ? (p(), b("div", ao, [
100
- S(r(de), {
101
- modelValue: r(T),
102
- "onUpdate:modelValue": h[4] || (h[4] = (m) => se(T) ? T.value = m : null),
103
- size: "large",
104
- "text-size": "medium",
105
- label: "Код",
106
- type: "text",
107
- error: M.value,
108
- onInput: L,
109
- onBlur: h[5] || (h[5] = (m) => v("code"))
110
- }, null, 8, ["modelValue", "error"])
111
- ])) : E("", !0),
112
- S(ge, {
113
- loading: d.loading,
114
- "rate-limit-text": d.rateLimitText,
115
- "is-final-limit": d.isFinalLimit,
116
- "on-send-again": J
117
- }, {
118
- extra: _(() => [
119
- d.isTg ? (p(), b("span", {
120
- key: 0,
121
- class: "dialogDefaultContainerSendCodeBySmsText",
122
- onClick: Y
123
- }, [
124
- oe(G(d.sendCodeBySmsText) + " ", 1),
125
- S(r(ie), { style: { "margin-left": "5px" } })
126
- ])) : E("", !0)
127
- ]),
128
- _: 1
129
- }, 8, ["loading", "rate-limit-text", "is-final-limit"])
130
- ]));
131
- }
132
- }), F = (R) => {
133
- const x = R.replace(/\D/g, "");
134
- if (x.length >= 10 && x.length <= 15) {
135
- if (x.startsWith("8"))
136
- return `+7${x.slice(1)}`;
137
- if (x.startsWith("7"))
138
- return `+${x}`;
139
- }
140
- return R.trim().startsWith("+") ? R.trim() : `+${x}`;
141
- }, so = { class: "dialogDefaultContainerInsideContent" }, io = { style: { display: "flex", width: "100%", gap: "4px", "align-items": "center", "justify-content": "center", "text-align": "center" } }, ro = { class: "dialogDefaultContainerTextHint" }, uo = {
142
- key: 0,
143
- class: "chip"
144
- }, co = {
145
- key: 0,
146
- class: "input-wrapper"
147
- }, po = {
148
- key: 1,
149
- class: "input-wrapper"
150
- }, ho = {
151
- key: 2,
152
- class: "input-wrapper"
153
- }, vo = { key: 3 }, mo = /* @__PURE__ */ ce({
154
- __name: "NewPhoneContent",
155
- props: {
156
- phone: {},
157
- oldPhone: {},
158
- hintText: { default: "" },
159
- phoneError: { default: "" },
160
- codeError: { default: "" },
161
- rateLimitText: { default: "" },
162
- sendCodeBySmsText: { default: "Получить код из СМС" },
163
- showPhone: { type: Boolean, default: !0 },
164
- isFinalLimit: { type: Boolean },
165
- isNotMatchCode: { type: Boolean, default: !1 },
166
- loading: { type: Boolean },
167
- isTg: { type: Boolean }
168
- },
169
- emits: ["update:phone", "update:code", "edit", "on-match-code", "on-match-code-error", "on-send-code", "on-send-code-again", "on-send-only-sms", "on-clear-code-error"],
170
- setup(R, { emit: x }) {
171
- const k = R, u = x, c = D(!1), v = D(""), g = pe({
172
- touched: { phone: !1, code: !1 },
173
- phoneModel: "",
174
- codeModel: ""
175
- });
176
- te(
177
- () => g.phoneModel,
178
- (l) => {
179
- u("update:phone", l), v.value = "";
180
- }
181
- ), te(
182
- () => g.codeModel,
183
- (l) => u("update:code", l)
184
- );
185
- const L = (l) => g.touched[l] = !0, J = z(() => {
186
- const n = g.phoneModel.trim().replace(/[()\-\s]/g, "");
187
- return /^\+?\d{10,15}$/.test(n);
188
- }), Y = async () => {
189
- var l, n;
190
- try {
191
- if (L("phone"), !J.value) {
192
- v.value = "Это не похоже на номер телефона";
193
- return;
194
- }
195
- const {
196
- data: { data: o, success: $, message: B }
197
- } = await Oe(void 0, F(g.phoneModel));
198
- if (!(((l = o == null ? void 0 : o[0]) == null ? void 0 : l.available) ?? !1)) {
199
- v.value = "Такой номер уже используется";
200
- return;
201
- }
202
- v.value = "", u("on-send-code", { phone: g.phoneModel, prevPhone: k.oldPhone, offLoading: !0 }), c.value = !0;
203
- } catch (o) {
204
- console.debug(o);
205
- const $ = (n = o == null ? void 0 : o.response) == null ? void 0 : n.data, B = $ == null ? void 0 : $.message;
206
- if (console.debug("global middle check onSendCode: ", {
207
- errorData: $,
208
- message: B,
209
- phoneTakenError: v
210
- }), B) {
211
- const j = Array.isArray(B) ? B.join(" ") : String(B), ne = j.toLowerCase(), Q = [
212
- "телефон должен быть в формате",
213
- "valid phone number",
214
- "phone must be a valid phone number",
215
- "value must be a valid phone number",
216
- "oldValue must be a valid phone number",
217
- "newValue must be a valid phone number",
218
- "addValue must be a valid phone number",
219
- "addPhone must be a valid phone number"
220
- ], q = Q.some(
221
- (ee) => ne.includes(ee)
222
- );
223
- if (console.debug("global end check onSendCode: ", {
224
- errorMessage: j,
225
- lowerCaseError: ne,
226
- phoneValidationKeywords: Q,
227
- hasPhoneError: q
228
- }), q) {
229
- v.value = "Это не похоже на номер телефона";
230
- return;
231
- }
232
- }
233
- console.error("Неизвестная ошибка при проверке доступности телефона:", o), v.value = "Произошла ошибка сервера. Попробуйте позже";
234
- }
235
- };
236
- let e = D("");
237
- const T = (l) => {
238
- u("on-clear-code-error");
239
- const n = l.target;
240
- let o = ((n == null ? void 0 : n.value) ?? "").replace(/\D/g, "");
241
- o.length > 4 && (o = o.slice(0, 4)), d.value = o, n && n.value !== o && (n.value = o), o.length === 4 && o !== e.value && (e.value = o, u("on-match-code", { phone: M.value, code: o }));
242
- }, C = () => {
243
- u("on-send-code-again", { phone: g.phoneModel });
244
- }, y = () => {
245
- console.debug("onSendCodeViaSms"), u("on-send-only-sms", { phone: g.phoneModel });
246
- }, { phoneModel: M, codeModel: d, touched: h } = fe(g), m = z(() => v.value ? v.value : h.value.phone && !M.value.trim() ? "Это не похоже на номер телефона" : k.phoneError || ""), Z = z(() => k.isNotMatchCode ? "Неверный код" : h.value.code ? d.value.trim() ? k.codeError ?? null : "Введите код" : "");
247
- return (l, n) => (p(), b("div", so, [
248
- U("div", io, [
249
- U("div", ro, G(c.value ? "Чтобы продолжить, введите код подтверждения из" : l.hintText), 1),
250
- c.value ? (p(), b("div", uo, [
251
- l.isTg ? (p(), X(r(ye), { key: 0 })) : (p(), X(r(ie), {
252
- key: 1,
253
- style: { "margin-left": "5px" }
254
- })),
255
- oe(" " + G(l.isTg ? "Telegram" : "СМС"), 1)
256
- ])) : E("", !0)
257
- ]),
258
- l.showPhone ? (p(), b("div", co, [
259
- S(r(de), {
260
- modelValue: r(M),
261
- "onUpdate:modelValue": n[0] || (n[0] = (o) => se(M) ? M.value = o : null),
262
- size: "large",
263
- "text-size": "medium",
264
- label: "Телефон",
265
- type: "tel",
266
- error: m.value,
267
- onBlur: n[1] || (n[1] = (o) => L("phone")),
268
- onInput: n[2] || (n[2] = (o) => L("phone"))
269
- }, null, 8, ["modelValue", "error"]),
270
- S(r(De), {
271
- class: "icon-locked",
272
- onClick: n[3] || (n[3] = (o) => l.$emit("edit", "phone"))
273
- })
274
- ])) : E("", !0),
275
- c.value ? E("", !0) : (p(), b("div", po, [
276
- S(r(Ae), {
277
- style: { width: "100%" },
278
- disabled: !J.value,
279
- onClick: Y
280
- }, {
281
- default: _(() => n[6] || (n[6] = [
282
- oe(" Отправить код ")
283
- ])),
284
- _: 1,
285
- __: [6]
286
- }, 8, ["disabled"])
287
- ])),
288
- c.value ? (p(), b("div", ho, [
289
- S(r(de), {
290
- modelValue: r(d),
291
- "onUpdate:modelValue": n[4] || (n[4] = (o) => se(d) ? d.value = o : null),
292
- size: "large",
293
- "text-size": "medium",
294
- label: "Код",
295
- type: "text",
296
- error: Z.value,
297
- onInput: T,
298
- onBlur: n[5] || (n[5] = (o) => L("code"))
299
- }, null, 8, ["modelValue", "error"])
300
- ])) : E("", !0),
301
- !l.loading && c.value ? (p(), b("div", vo, [
302
- S(ge, {
303
- loading: l.loading,
304
- "rate-limit-text": l.rateLimitText,
305
- "is-final-limit": l.isFinalLimit,
306
- "on-send-again": C
307
- }, {
308
- extra: _(() => [
309
- l.isTg ? (p(), b("span", {
310
- key: 0,
311
- class: "dialogDefaultContainerSendCodeBySmsText",
312
- onClick: y
313
- }, [
314
- oe(G(l.sendCodeBySmsText) + " ", 1),
315
- S(r(ie), { style: { "margin-left": "5px" } })
316
- ])) : E("", !0)
317
- ]),
318
- _: 1
319
- }, 8, ["loading", "rate-limit-text", "is-final-limit"])
320
- ])) : E("", !0)
321
- ]));
322
- }
323
- }), fo = { class: "dialogDefaultContainerInsideContent" }, go = { style: { display: "flex", width: "100%", gap: "4px", "align-items": "center", "justify-content": "center", "text-align": "center" } }, yo = { class: "dialogDefaultContainerTextHint" }, Co = { class: "chip" }, wo = {
324
- key: 0,
325
- class: "input-wrapper"
326
- }, Po = {
327
- key: 1,
328
- class: "input-wrapper"
329
- }, bo = {
330
- key: 2,
331
- class: "input-wrapper"
332
- }, So = { key: 3 }, To = /* @__PURE__ */ ce({
333
- __name: "AddNewPhoneContent",
334
- props: {
335
- phone: {},
336
- oldPhone: {},
337
- hintText: { default: "" },
338
- phoneError: { default: "" },
339
- codeError: { default: "" },
340
- rateLimitText: { default: "" },
341
- sendCodeBySmsText: { default: "Получить код из СМС" },
342
- showPhone: { type: Boolean, default: !0 },
343
- isFinalLimit: { type: Boolean },
344
- isNotMatchCode: { type: Boolean },
345
- loading: { type: Boolean },
346
- isTg: { type: Boolean }
347
- },
348
- emits: ["update:phone", "update:code", "edit", "on-match-code", "on-match-code-error", "on-send-code", "on-send-code-again", "on-send-only-sms", "on-clear-code-error"],
349
- setup(R, { emit: x }) {
350
- const k = R, u = x, c = D(!1), v = D(""), g = pe({
351
- touched: { phone: !1, code: !1 },
352
- phoneModel: "",
353
- codeModel: ""
354
- });
355
- te(
356
- () => g.phoneModel,
357
- (l) => {
358
- u("update:phone", l), v.value = "";
359
- }
360
- ), te(
361
- () => g.codeModel,
362
- (l) => u("update:code", l)
363
- );
364
- const L = (l) => g.touched[l] = !0, J = z(() => {
365
- const n = g.phoneModel.trim().replace(/[()\-\s]/g, "");
366
- return /^\+?\d{10,15}$/.test(n);
367
- }), Y = async () => {
368
- var l, n;
369
- try {
370
- if (L("phone"), !J.value) {
371
- v.value = "Это не похоже на номер телефона";
372
- return;
373
- }
374
- const {
375
- data: { data: o, success: $, message: B }
376
- } = await Oe(void 0, F(g.phoneModel));
377
- if (!(((l = o == null ? void 0 : o[0]) == null ? void 0 : l.available) ?? !1)) {
378
- v.value = "Такой номер уже используется";
379
- return;
380
- }
381
- v.value = "", u("on-send-code", { phone: g.phoneModel, prevPhone: k.oldPhone, offLoading: !0 }), c.value = !0;
382
- } catch (o) {
383
- const $ = (n = o == null ? void 0 : o.response) == null ? void 0 : n.data, B = $ == null ? void 0 : $.message;
384
- if (console.debug("global middle check onSendCode: ", {
385
- errorData: $,
386
- message: B,
387
- phoneTakenError: v
388
- }), B) {
389
- const j = Array.isArray(B) ? B.join(" ") : String(B), ne = j.toLowerCase(), Q = [
390
- "телефон должен быть в формате",
391
- "valid phone number",
392
- "phone must be a valid phone number",
393
- "value must be a valid phone number",
394
- "oldValue must be a valid phone number",
395
- "newValue must be a valid phone number",
396
- "addValue must be a valid phone number",
397
- "addPhone must be a valid phone number"
398
- ], q = Q.some(
399
- (ee) => ne.includes(ee)
400
- );
401
- if (console.debug("global end check onSendCode: ", {
402
- errorMessage: j,
403
- lowerCaseError: ne,
404
- phoneValidationKeywords: Q,
405
- hasPhoneError: q
406
- }), q) {
407
- v.value = "Это не похоже на номер телефона";
408
- return;
409
- }
410
- }
411
- console.error("Неизвестная ошибка при проверке доступности телефона:", o), v.value = "Произошла ошибка сервера. Попробуйте позже";
412
- }
413
- };
414
- let e = "";
415
- const T = (l) => {
416
- u("on-clear-code-error");
417
- const n = l.target;
418
- let o = n.value.replace(/\D/g, "");
419
- o.length > 4 && (o = o.slice(0, 4), n.value = o), g.codeModel = o, o.length === 4 && o !== e && (e = o, u("on-match-code", { phone: g.phoneModel, code: o }));
420
- }, C = () => {
421
- u("on-send-code-again", { phone: g.phoneModel });
422
- }, y = () => {
423
- console.debug("onSendCodeViaSms"), u("on-send-only-sms", { phone: g.phoneModel });
424
- }, { phoneModel: M, codeModel: d, touched: h } = fe(g), m = z(() => v.value ? v.value : h.value.phone && !M.value.trim() ? "Это не похоже на номер телефона" : k.phoneError || ""), Z = z(() => k.isNotMatchCode ? "Неверный код" : g.touched.code ? d.value.trim() ? k.codeError ?? null : "Введите код" : "");
425
- return (l, n) => (p(), b("div", fo, [
426
- U("div", go, [
427
- U("div", yo, G(c.value ? "Чтобы продолжить, введите код подтверждения из" : l.hintText), 1),
428
- U("div", Co, [
429
- l.isTg ? (p(), X(r(ye), { key: 0 })) : (p(), X(r(ie), {
430
- key: 1,
431
- style: { "margin-left": "5px" }
432
- })),
433
- oe(" " + G(l.isTg ? "Telegram" : "СМС"), 1)
434
- ])
435
- ]),
436
- l.showPhone ? (p(), b("div", wo, [
437
- S(r(de), {
438
- modelValue: r(M),
439
- "onUpdate:modelValue": n[0] || (n[0] = (o) => se(M) ? M.value = o : null),
440
- size: "large",
441
- "text-size": "medium",
442
- label: "Телефон",
443
- type: "tel",
444
- error: m.value,
445
- onBlur: n[1] || (n[1] = (o) => L("phone")),
446
- onInput: n[2] || (n[2] = (o) => L("phone"))
447
- }, null, 8, ["modelValue", "error"]),
448
- S(r(De), {
449
- class: "icon-locked",
450
- onClick: n[3] || (n[3] = (o) => l.$emit("edit", "phone"))
451
- })
452
- ])) : E("", !0),
453
- c.value ? E("", !0) : (p(), b("div", Po, [
454
- S(r(Ae), {
455
- style: { width: "100%" },
456
- disabled: !J.value,
457
- onClick: Y
458
- }, {
459
- default: _(() => n[6] || (n[6] = [
460
- oe(" Отправить код ")
461
- ])),
462
- _: 1,
463
- __: [6]
464
- }, 8, ["disabled"])
465
- ])),
466
- c.value ? (p(), b("div", bo, [
467
- S(r(de), {
468
- modelValue: r(d),
469
- "onUpdate:modelValue": n[4] || (n[4] = (o) => se(d) ? d.value = o : null),
470
- size: "large",
471
- "text-size": "medium",
472
- label: "Код",
473
- type: "text",
474
- error: Z.value,
475
- onInput: T,
476
- onBlur: n[5] || (n[5] = (o) => L("code"))
477
- }, null, 8, ["modelValue", "error"])
478
- ])) : E("", !0),
479
- c.value ? (p(), b("div", So, [
480
- S(ge, {
481
- loading: l.loading,
482
- "rate-limit-text": l.rateLimitText,
483
- "is-final-limit": l.isFinalLimit,
484
- "on-send-again": C
485
- }, {
486
- extra: _(() => [
487
- l.isTg ? (p(), b("span", {
488
- key: 0,
489
- class: "dialogDefaultContainerSendCodeBySmsText",
490
- onClick: y
491
- }, [
492
- oe(G(l.sendCodeBySmsText) + " ", 1),
493
- S(r(ie), { style: { "margin-left": "5px" } })
494
- ])) : E("", !0)
495
- ]),
496
- _: 1
497
- }, 8, ["loading", "rate-limit-text", "is-final-limit"])
498
- ])) : E("", !0)
499
- ]));
500
- }
501
- }), Mo = { class: "text-center w-full" }, xo = { class: "dialogTitle" }, Vo = {
502
- key: 0,
503
- class: "dialogDefaultContainer"
504
- }, ko = { key: 3 }, Eo = {
505
- key: 1,
506
- class: "dialogDefaultContainer"
507
- }, re = 3, Oo = /* @__PURE__ */ ce({
508
- __name: "ProfilePhoneDialog",
509
- props: {
510
- modelValue: { type: Boolean },
511
- title: { default: void 0 },
512
- hintText: { default: void 0 },
513
- initialPhone: { default: "" },
514
- language: {},
515
- provider: {},
516
- mode: { default: void 0 }
517
- },
518
- emits: ["update:modelValue", "submit-phone", "edit", "close", "clean-input-errors", "on-update-jwt", "update-phone-field", "on-toast"],
519
- setup(R, { expose: x, emit: k }) {
520
- const u = R, c = k, v = D(u.modelValue);
521
- te(
522
- () => u.modelValue,
523
- (s) => v.value = s
524
- ), te(v, (s) => c("update:modelValue", s));
525
- const g = z(() => u.language ?? "ru"), L = (s) => Ie[g.value] && Ie[g.value][s] || (u.title ?? s), J = z(() => u.title ?? L("Смена номера телефона")), Y = z(() => u.hintText ?? L("Чтобы продолжить, введите новый номер")), e = pe({
526
- oldPhone: u.initialPhone ?? "",
527
- newPhone: "",
528
- code: "",
529
- addPhone: "",
530
- addCode: ""
531
- }), T = D(K.OLD), C = D(null), y = D(!1), M = D(!1), d = D("tg"), h = z(() => d.value === "tg"), m = D(!1), { startTimer: Z, remainingSeconds: l, isAvailableForSendAgain: n, totalRateAttempts: o, currentRateAttempt: $ } = qe(), { showRateLimitToast: B } = He(c), { isEditFlow: j, getFlow: ne } = We(D(u.mode)), Q = z(() => n.value ? "Повторить" : `${l.value}`), q = D(re), ee = z(() => q.value === 0), Ne = (s) => new Promise((a) => setTimeout(a, s));
532
- async function he(s = "email") {
533
- var t;
534
- return (t = (await Le("/users/profile/session/get-edit-session", { params: { field: s } })).data) == null ? void 0 : t.data;
535
- }
536
- async function Ce(s = "phone") {
537
- var V;
538
- const t = (V = (await le("/users/profile/session/create-if-not-exists", {
539
- field: s,
540
- oldValue: F(u.initialPhone)
541
- })).data) == null ? void 0 : V.data;
542
- C.value = (t == null ? void 0 : t.sessionId) ?? null, T.value = (t == null ? void 0 : t.step) ?? K.OLD, e.oldPhone = (t == null ? void 0 : t.oldValue) ?? "", e.newPhone = (t == null ? void 0 : t.newValue) ?? "";
543
- }
544
- async function ze() {
545
- try {
546
- const s = await he("phone");
547
- C.value = s.sessionId, T.value = s.step, e.oldPhone = s.oldValue ?? "", s.sessionId || await Ce("phone");
548
- } catch {
549
- await Ce("phone");
550
- }
551
- }
552
- async function we(s, a = !1) {
553
- var t;
554
- try {
555
- const V = await le(
556
- "/users/profile/check-throttler",
557
- {
558
- method: "sms",
559
- phone: F(s),
560
- isInvite: a
561
- },
562
- {
563
- headers: {
564
- "x-only-sms": m.value ?? !1
565
- }
566
- }
567
- );
568
- await Ne(1e3);
569
- const w = (t = V.data) == null ? void 0 : t.data;
570
- return w ? (w.restTimeSec > 0 ? (Z(w.restTimeSec), n.value = !1, o.value = w.attempts.total, $.value = w.attempts.total - w.attempts.available, q.value = w.attempts.available ?? re) : n.value = !0, w) : null;
571
- } catch {
572
- return null;
573
- }
574
- }
575
- const ve = async ({ phone: s }) => (m.value = !0, await ae({ value: s, isOnlySms: !0 })), ae = async ({ value: s, isOnlySms: a, offLoading: t } = {}) => {
576
- var V, w, A, N, W, I;
577
- y.value = !0;
578
- try {
579
- const f = s ?? e.oldPhone, i = await le(
580
- "/users/profile/phone/contact/send-code",
581
- {
582
- sessionId: C.value,
583
- phone: F(f),
584
- value: F(f),
585
- oldValue: F(e.oldPhone),
586
- provider: u.provider,
587
- isOnlySms: a ?? !1
588
- },
589
- {
590
- headers: {
591
- "x-only-sms": a ?? !1
592
- }
593
- }
594
- );
595
- console.debug("response sendContactCode: ", i);
596
- const P = (w = (V = i == null ? void 0 : i.data) == null ? void 0 : V.data) == null ? void 0 : w.deliveryType;
597
- if ((P === "tg" || P === "sms") && (d.value = P, P === "tg" && (m.value = !1)), console.debug("sendContactCode before обработка 403 tooManyRequests", i), (i == null ? void 0 : i.status) === 403 && ((A = i.data) != null && A.tooManyRequests)) {
598
- console.debug("sendContactCode IN обработка 403 tooManyRequests", i);
599
- const O = (W = (N = i.data) == null ? void 0 : N.tooManyRequests) == null ? void 0 : W.type;
600
- d.value = O;
601
- const H = i.data.tooManyRequests;
602
- return H.restTimeSec > 0 ? (Z(H.restTimeSec), o.value = H.attempts.total, $.value = H.attempts.total - H.attempts.available, q.value = H.attempts.available ?? re) : n.value = !0, i;
603
- }
604
- return console.debug("sendContactCode after обработка 403 tooManyRequests", i), await we(f), i;
605
- } catch (f) {
606
- const i = (I = f == null ? void 0 : f.data) == null ? void 0 : I.tooManyRequests;
607
- if ((f == null ? void 0 : f.status) === 403 && i) {
608
- const { restTimeSec: P, attempts: O } = i;
609
- return P > 0 ? (Z(P), o.value = O.total, $.value = O.total - O.available, q.value = O.available ?? re) : n.value = !0, f;
610
- }
611
- throw f;
612
- } finally {
613
- y.value = !1, t && (y.value = !1);
614
- }
615
- }, Pe = async (s, a) => {
616
- var t, V, w, A, N, W, I, f;
617
- y.value = !0;
618
- try {
619
- const i = await he("phone");
620
- C.value = i.sessionId, T.value = i.step, e.oldPhone = i.oldValue ?? e.oldPhone, e.newPhone = i.newValue ?? e.newPhone;
621
- const P = await le("/users/profile/change/phone/match-code", {
622
- phone: a === K.NEW ? F(e.newPhone) : F(e.oldPhone),
623
- sessionId: C.value,
624
- code: s,
625
- step: a
626
- }), O = ((t = P.data) == null ? void 0 : t.nextStep) ?? ((w = (V = P.data) == null ? void 0 : V.data) == null ? void 0 : w.nextStep), H = ((N = (A = P.data) == null ? void 0 : A.data) == null ? void 0 : N.rateLimit) ?? ((W = P.data) == null ? void 0 : W.rateLimit) ?? null, Re = ((I = P.data) == null ? void 0 : I.data.success) ?? ((f = P.data) == null ? void 0 : f.success);
627
- if (B(H), !Re) {
628
- M.value = !0;
629
- return;
630
- }
631
- if (!O) return P;
632
- if (T.value = O, O === K.NEW) {
633
- const $e = await he("phone");
634
- e.oldPhone = $e.oldValue ?? e.oldPhone, e.newPhone = $e.newValue ?? e.newPhone, e.code = "";
635
- }
636
- return O === K.COMPLETED && (e.code = "", c("update-phone-field", e.addPhone), c("submit-phone", { phone: e.oldPhone, code: s }), c("on-toast", { color: "success", text: "Номер телефона изменён" }), c("on-update-jwt", "phone", "edit", e.newPhone), C.value = null, c("close")), P;
637
- } finally {
638
- y.value = !1;
639
- }
640
- }, be = ({ code: s }) => Pe(s, K.OLD);
641
- function Se(s) {
642
- }
643
- const Te = ({ code: s }) => Pe(s, K.NEW);
644
- function Me(s) {
645
- }
646
- const ue = () => {
647
- c("close"), v.value = !1;
648
- };
649
- async function xe(s = "phone") {
650
- var t;
651
- return (t = (await Le("/users/profile/session/get-bind-session", { params: { field: s } })).data) == null ? void 0 : t.data;
652
- }
653
- async function Ve({
654
- value: s,
655
- field: a = "phone",
656
- offLoading: t = !0
657
- }) {
658
- var V, w, A;
659
- y.value = !0;
660
- try {
661
- if (!C.value) {
662
- const N = await le("/users/profile/session/bind/create", {
663
- field: a,
664
- newValue: F(s || e.addPhone)
665
- });
666
- if (C.value = ((w = (V = N.data) == null ? void 0 : V.data) == null ? void 0 : w.sessionId) ?? ((A = N.data) == null ? void 0 : A.sessionId) ?? null, !C.value)
667
- throw new Error("не удалось создать bind-сессию (sessionId отсутствует)");
668
- }
669
- } finally {
670
- t && (y.value = !1);
671
- }
672
- }
673
- async function Fe() {
674
- try {
675
- const s = await xe("phone");
676
- C.value = s.sessionId, T.value = s.step, e.addPhone = s.newValue ?? "", s.sessionId || await Ve({ field: "phone", value: e.addPhone });
677
- } catch {
678
- await Ve({ field: "phone", value: e.addPhone });
679
- }
680
- }
681
- const me = async ({
682
- value: s,
683
- field: a = "phone",
684
- isOnlySms: t = !1,
685
- offLoading: V = !0
686
- } = {}) => {
687
- var w, A, N;
688
- y.value = !0;
689
- try {
690
- if (!C.value)
691
- throw new Error("bind-сессия не найдена. создайте её через createBindSession.");
692
- const W = s ?? e.addPhone, I = await le(
693
- `/users/profile/bind/contact/send-code/${a}`,
694
- {
695
- sessionId: C.value,
696
- phone: F(W),
697
- provider: u.provider,
698
- isOnlySms: t ?? !1
699
- },
700
- {
701
- headers: {
702
- "x-only-sms": t ?? !1
703
- }
704
- }
705
- ), f = (A = (w = I == null ? void 0 : I.data) == null ? void 0 : w.data) == null ? void 0 : A.deliveryType;
706
- (f === "tg" || f === "sms") && (d.value = f, f === "tg" && (m.value = !1));
707
- const i = (N = I.data) == null ? void 0 : N.tooManyRequests;
708
- if (I.status === 403 && i) {
709
- const O = i == null ? void 0 : i.type;
710
- return d.value = O, i.restTimeSec > 0 ? (Z(i.restTimeSec), o.value = i.attempts.total, $.value = i.attempts.total - i.attempts.available, q.value = i.attempts.available ?? re) : n.value = !0, I;
711
- }
712
- const P = await we(W);
713
- return P && P.restTimeSec > 0 ? (Z(P.restTimeSec), n.value = !1) : n.value = !0, I;
714
- } finally {
715
- V && (y.value = !1);
716
- }
717
- }, ke = async ({ code: s }) => {
718
- var a, t, V, w, A, N, W, I;
719
- y.value = !0;
720
- try {
721
- if (!C.value) {
722
- const H = await xe("phone");
723
- C.value = H.sessionId, e.addPhone = H.newValue ?? e.addPhone;
724
- }
725
- const f = await le("/users/profile/bind/phone/match-code", {
726
- phone: F(e.addPhone),
727
- sessionId: C.value,
728
- code: s
729
- }), i = ((a = f.data) == null ? void 0 : a.nextStep) ?? ((V = (t = f.data) == null ? void 0 : t.data) == null ? void 0 : V.nextStep), P = ((A = (w = f.data) == null ? void 0 : w.data) == null ? void 0 : A.rateLimit) ?? ((N = f.data) == null ? void 0 : N.rateLimit) ?? null, O = ((W = f.data) == null ? void 0 : W.data.success) ?? ((I = f.data) == null ? void 0 : I.success);
730
- if (B(P), !O) {
731
- M.value = !0;
732
- return;
733
- }
734
- return i && i === K.COMPLETED && (e.code = "", c("update-phone-field", e.addPhone), c("submit-phone", { phone: e.addPhone, code: s }), c("on-update-jwt", "phone", "bind", e.addPhone), c("on-toast", { color: "success", text: "Номер телефона успешно привязан к аккаунту" }), C.value = null, c("close")), f;
735
- } finally {
736
- y.value = !1;
737
- }
738
- }, Ee = async () => {
739
- };
740
- return Ue(async () => {
741
- y.value = !0;
742
- const s = await ne("phone");
743
- if (u.mode === "bind" && s === "bind") {
744
- await Fe(), y.value = !1;
745
- return;
746
- }
747
- await ze(), await ae({});
748
- }), x({
749
- localVisible: v,
750
- form: e,
751
- currentStep: T,
752
- loading: y,
753
- rateLimitText: Q,
754
- isAvailable: ee,
755
- title: J,
756
- hintText: Y,
757
- handleClose: ue,
758
- sendContactCode: ae,
759
- sendBindContactCode: me,
760
- handleOldCodeSuccess: be,
761
- handleOldCodeError: Se,
762
- handleNewCodeSuccess: Te,
763
- handleNewCodeError: Me,
764
- matchBindCode: ke,
765
- matchBindCodeError: Ee
766
- }), (s, a) => (p(), b(je, null, [
767
- S(r(Ge), {
768
- modelValue: v.value,
769
- "onUpdate:modelValue": [
770
- a[15] || (a[15] = (t) => v.value = t),
771
- ue
772
- ],
773
- width: "small",
774
- "auto-height": !0,
775
- "close-on-click-outside": !0,
776
- "onClick:outside": ue
777
- }, {
778
- header: _(() => [
779
- U("div", Mo, [
780
- S(r(Je), {
781
- "slot-left": !1,
782
- size: "small",
783
- borded: !0,
784
- "no-padding": !1
785
- }, {
786
- title: _(() => [
787
- U("span", xo, G(r(j) ? J.value : "Добавление номера телефона"), 1)
788
- ]),
789
- "right-button": _(() => [
790
- S(r(Qe), {
791
- class: "cross",
792
- onClick: ue
793
- })
794
- ]),
795
- _: 1
796
- })
797
- ])
798
- ]),
799
- default: _(() => [
800
- r(j) ? (p(), b("div", Vo, [
801
- y.value ? (p(), X(Be, { key: 0 })) : E("", !0),
802
- T.value === r(K).OLD ? (p(), X(lo, {
803
- key: 1,
804
- phone: e.oldPhone,
805
- "onUpdate:phone": a[0] || (a[0] = (t) => e.oldPhone = t),
806
- code: e.code,
807
- "onUpdate:code": a[1] || (a[1] = (t) => e.code = t),
808
- "rate-limit-text": Q.value,
809
- "is-final-limit": ee.value,
810
- "is-not-match-code": M.value,
811
- loading: y.value,
812
- "is-tg": h.value,
813
- onOnSendCode: a[2] || (a[2] = (t) => ae({ value: e.oldPhone })),
814
- onOnSendCodeAgain: a[3] || (a[3] = (t) => ae({ value: e.oldPhone, isOnlySms: !h.value && m.value })),
815
- onOnSendOnlySms: ve,
816
- onOnMatchCode: be,
817
- onOnMatchCodeError: Se
818
- }, null, 8, ["phone", "code", "rate-limit-text", "is-final-limit", "is-not-match-code", "loading", "is-tg"])) : T.value === r(K).NEW ? (p(), X(mo, {
819
- key: 2,
820
- phone: e.newPhone,
821
- "onUpdate:phone": a[4] || (a[4] = (t) => e.newPhone = t),
822
- oldPhone: e.oldPhone,
823
- "onUpdate:oldPhone": a[5] || (a[5] = (t) => e.oldPhone = t),
824
- code: e.code,
825
- "onUpdate:code": a[6] || (a[6] = (t) => e.code = t),
826
- "hint-text": Y.value,
827
- "rate-limit-text": Q.value,
828
- "is-final-limit": ee.value,
829
- "is-not-match-code": M.value,
830
- loading: y.value,
831
- "is-tg": h.value,
832
- onOnSendCode: a[7] || (a[7] = (t) => ae({ value: e.newPhone })),
833
- onOnSendCodeAgain: a[8] || (a[8] = (t) => ae({ value: e.newPhone, isOnlySms: !h.value && m.value })),
834
- onOnSendOnlySms: ve,
835
- onOnMatchCode: Te,
836
- onOnMatchCodeError: Me,
837
- onOnClearCodeError: a[9] || (a[9] = (t) => M.value = !1)
838
- }, null, 8, ["phone", "oldPhone", "code", "hint-text", "rate-limit-text", "is-final-limit", "is-not-match-code", "loading", "is-tg"])) : T.value === r(K).COMPLETED ? (p(), b("div", ko, [
839
- U("p", null, G(L("Телефон успешно изменен")), 1)
840
- ])) : E("", !0)
841
- ])) : (p(), b("div", Eo, [
842
- y.value ? (p(), X(Be, { key: 0 })) : E("", !0),
843
- S(To, {
844
- phone: e.addPhone,
845
- "onUpdate:phone": a[10] || (a[10] = (t) => e.addPhone = t),
846
- oldPhone: e.oldPhone,
847
- "onUpdate:oldPhone": a[11] || (a[11] = (t) => e.oldPhone = t),
848
- code: e.addCode,
849
- "onUpdate:code": a[12] || (a[12] = (t) => e.addCode = t),
850
- "hint-text": r(j) ? Y.value : "Чтобы продолжить, введите новый номер",
851
- "rate-limit-text": Q.value,
852
- "is-final-limit": ee.value,
853
- "is-not-match-code": M.value,
854
- loading: y.value,
855
- "is-tg": h.value,
856
- onOnSendCode: a[13] || (a[13] = (t) => me({ value: e.addPhone, field: "phone" })),
857
- onOnSendCodeAgain: a[14] || (a[14] = (t) => me({ value: e.addPhone, field: "phone", isOnlySms: !h.value && m.value })),
858
- onOnSendOnlySms: ve,
859
- onOnMatchCode: ke,
860
- onOnMatchCodeError: Ee
861
- }, null, 8, ["phone", "oldPhone", "code", "hint-text", "rate-limit-text", "is-final-limit", "is-not-match-code", "loading", "is-tg"])
862
- ]))
863
- ]),
864
- _: 1
865
- }, 8, ["modelValue"]),
866
- S(r(Xe))
867
- ], 64));
868
- }
869
- });
870
- export {
871
- Oo as default
872
- };