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