@ozdao/prometheus-framework 0.1.39 → 0.1.41
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/ButtonToggleMembership-738720bd.js +1 -0
- package/dist/ButtonToggleMembership-e337e704.mjs +90 -0
- package/dist/CardBlogpost-c7adb0a7.mjs +246 -0
- package/dist/CardBlogpost-f308ff64.js +1 -0
- package/dist/CardOrganization-22beb83d.js +1 -0
- package/dist/CardOrganization-ae384e54.mjs +234 -0
- package/dist/Chips-edf2b573.js +1 -0
- package/dist/Chips-f06ec38f.mjs +213 -0
- package/dist/Community-04b25965.mjs +130 -0
- package/dist/Community-2f6fee0f.js +1 -0
- package/dist/Events-41d71b0e.js +1 -0
- package/dist/Events-af7170ed.mjs +134 -0
- package/dist/Feed-04fe1f7a.mjs +361 -0
- package/dist/Feed-23758089.mjs +124 -0
- package/dist/Feed-36e83be3.mjs +156 -0
- package/dist/Feed-5653cf8b.js +1 -0
- package/dist/Feed-5a359bb7.js +1 -0
- package/dist/Feed-6ca0541a.js +1 -0
- package/dist/Image-39955d9d.mjs +480 -0
- package/dist/Image-c2d190d8.js +9 -0
- package/dist/LeftoverAdd-21311275.js +1 -0
- package/dist/LeftoverAdd-ccf4595f.mjs +228 -0
- package/dist/Members-7251dd52.mjs +109 -0
- package/dist/Members-d35ab7e8.js +1 -0
- package/dist/Organizations-a964d4b6.mjs +72 -0
- package/dist/Organizations-ed6d36d6.js +1 -0
- package/dist/Product-299070ad.mjs +652 -0
- package/dist/Product-aacb05f3.js +7 -0
- package/dist/ProductEdit-70bed802.mjs +296 -0
- package/dist/ProductEdit-e5a2e0f6.js +1 -0
- package/dist/ProductsBackoffice-3c182d6a.mjs +86 -0
- package/dist/ProductsBackoffice-b684913d.js +1 -0
- package/dist/ProfileBlogposts-6bf526fb.js +1 -0
- package/dist/ProfileBlogposts-d4b17535.mjs +77 -0
- package/dist/ProfileEvents-3eeb4320.mjs +68 -0
- package/dist/ProfileEvents-90e09978.js +1 -0
- package/dist/ProfileOrganizations-e838925f.js +1 -0
- package/dist/ProfileOrganizations-edf657ca.mjs +72 -0
- package/dist/Publics-a31d7fe7.js +1 -0
- package/dist/Publics-a8f31413.mjs +45 -0
- package/dist/Wallet-2043b611.mjs +24682 -0
- package/dist/Wallet-8fa7386a.js +55 -0
- package/dist/auth-076a83d0.mjs +625 -0
- package/dist/auth-df5a20c6.js +7 -0
- package/dist/auth.client.cjs +1 -1
- package/dist/auth.client.js +4 -4
- package/dist/auth.validation-80b133df.js +1 -0
- package/dist/auth.validation-fd9ae66f.mjs +24 -0
- package/dist/backoffice.client.cjs +1 -1
- package/dist/backoffice.client.js +11 -11
- package/dist/categories-4327a81c.js +1 -0
- package/dist/categories-52a561a4.mjs +122 -0
- package/dist/community.client.cjs +1 -1
- package/dist/community.client.js +10 -10
- package/dist/events.client.cjs +2 -2
- package/dist/events.client.js +9 -9
- package/dist/legal.client.cjs +1 -1
- package/dist/legal.client.js +1 -1
- package/dist/main.css +1 -1
- package/dist/modules/gallery/components/pages/Gallery.vue.d.ts +2 -0
- package/dist/modules/gallery/components/sections/GalleryWithCategories.vue.d.ts +2 -0
- package/dist/modules/globals/components/sections/Title.vue.d.ts +6 -0
- package/dist/organizations-966e1cd2.mjs +122 -0
- package/dist/organizations-d12c42b6.js +1 -0
- package/dist/organizations.client-8f263e28.js +3 -0
- package/dist/organizations.client-9ffc023f.mjs +2996 -0
- package/dist/organizations.client.cjs +1 -1
- package/dist/organizations.client.js +15 -15
- package/dist/products-7e4253eb.js +1 -0
- package/dist/products-aabe5c02.mjs +108 -0
- package/dist/prometheus-framework.cjs.js +1 -1
- package/dist/prometheus-framework.es.js +2 -2
- package/dist/states.validation-4594b33c.mjs +13 -0
- package/dist/states.validation-69003e66.js +1 -0
- package/dist/style.css +1 -1
- package/dist/users.client.cjs +1 -1
- package/dist/users.client.js +198 -166
- package/package.json +1 -1
- package/src/components/LocationMarker/LocationMarker.vue +1 -1
- package/src/components/LocationSelection/LocationSelection.vue +1 -1
- package/src/components/Navigation/Navigation.vue +12 -1
- package/src/components/Sidebar/Sidebar.vue +8 -10
- package/src/modules/auth/store/auth.js +7 -4
- package/src/modules/backoffice/components/admin/ProductEdit.vue +0 -2
- package/src/modules/files/middlewares/server/md.js +1 -0
- package/src/modules/gallery/components/pages/Gallery.vue +21 -0
- package/src/modules/gallery/components/sections/GalleryWithCategories.vue +408 -0
- package/src/modules/gallery/gallery.client.js +11 -14
- package/src/modules/gallery/router/gallery.router.js +10 -0
- package/src/modules/globals/components/sections/Title.vue +22 -0
- package/src/modules/marketplace/router/marketplace.js +4 -3
- package/src/modules/organizations/components/sections/Feed.vue +2 -2
- package/src/modules/products/components/pages/ProductRecommmendation.vue +5 -3
- package/src/modules/products/components/sections/FilterProducts.vue +2 -0
- package/src/modules/products/components/sections/SectionProduct.vue +17 -5
- package/src/modules/products/components/sections/SortProducts.vue +0 -2
- package/src/modules/products/controllers/products.controller.js +83 -0
- package/src/modules/products/routes/products.routes.js +5 -5
- package/src/modules/products/store/categories.js +9 -9
- package/src/modules/products/store/leftovers.js +9 -6
- package/src/modules/products/store/products.js +0 -2
- package/src/modules/spots/components/layouts/Spots.vue +16 -11
- package/src/modules/spots/components/pages/Map.vue +9 -7
- package/src/modules/users/components/pages/Profile.vue +15 -5
- package/src/modules/users/router/users.js +10 -0
- package/src/modules/wallet/components/pages/Wallet.vue +104 -23
@@ -0,0 +1,625 @@
|
|
1
|
+
import { g as le, a as N } from "./index-a661083c.mjs";
|
2
|
+
import { reactive as V, watch as Z } from "vue";
|
3
|
+
import { s as E } from "./globals-96ba60e4.mjs";
|
4
|
+
var Q = { exports: {} };
|
5
|
+
/*!
|
6
|
+
* JavaScript Cookie v2.2.1
|
7
|
+
* https://github.com/js-cookie/js-cookie
|
8
|
+
*
|
9
|
+
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
10
|
+
* Released under the MIT license
|
11
|
+
*/
|
12
|
+
(function(t, e) {
|
13
|
+
(function(r) {
|
14
|
+
var o;
|
15
|
+
if (t.exports = r(), o = !0, !o) {
|
16
|
+
var n = window.Cookies, s = window.Cookies = r();
|
17
|
+
s.noConflict = function() {
|
18
|
+
return window.Cookies = n, s;
|
19
|
+
};
|
20
|
+
}
|
21
|
+
})(function() {
|
22
|
+
function r() {
|
23
|
+
for (var s = 0, i = {}; s < arguments.length; s++) {
|
24
|
+
var a = arguments[s];
|
25
|
+
for (var d in a)
|
26
|
+
i[d] = a[d];
|
27
|
+
}
|
28
|
+
return i;
|
29
|
+
}
|
30
|
+
function o(s) {
|
31
|
+
return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent);
|
32
|
+
}
|
33
|
+
function n(s) {
|
34
|
+
function i() {
|
35
|
+
}
|
36
|
+
function a(c, p, l) {
|
37
|
+
if (!(typeof document > "u")) {
|
38
|
+
l = r({
|
39
|
+
path: "/"
|
40
|
+
}, i.defaults, l), typeof l.expires == "number" && (l.expires = new Date(/* @__PURE__ */ new Date() * 1 + l.expires * 864e5)), l.expires = l.expires ? l.expires.toUTCString() : "";
|
41
|
+
try {
|
42
|
+
var b = JSON.stringify(p);
|
43
|
+
/^[\{\[]/.test(b) && (p = b);
|
44
|
+
} catch {
|
45
|
+
}
|
46
|
+
p = s.write ? s.write(p, c) : encodeURIComponent(String(p)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent), c = encodeURIComponent(String(c)).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent).replace(/[\(\)]/g, escape);
|
47
|
+
var y = "";
|
48
|
+
for (var C in l)
|
49
|
+
l[C] && (y += "; " + C, l[C] !== !0 && (y += "=" + l[C].split(";")[0]));
|
50
|
+
return document.cookie = c + "=" + p + y;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
function d(c, p) {
|
54
|
+
if (!(typeof document > "u")) {
|
55
|
+
for (var l = {}, b = document.cookie ? document.cookie.split("; ") : [], y = 0; y < b.length; y++) {
|
56
|
+
var C = b[y].split("="), h = C.slice(1).join("=");
|
57
|
+
!p && h.charAt(0) === '"' && (h = h.slice(1, -1));
|
58
|
+
try {
|
59
|
+
var U = o(C[0]);
|
60
|
+
if (h = (s.read || s)(h, U) || o(h), p)
|
61
|
+
try {
|
62
|
+
h = JSON.parse(h);
|
63
|
+
} catch {
|
64
|
+
}
|
65
|
+
if (l[U] = h, c === U)
|
66
|
+
break;
|
67
|
+
} catch {
|
68
|
+
}
|
69
|
+
}
|
70
|
+
return c ? l[c] : l;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
return i.set = a, i.get = function(c) {
|
74
|
+
return d(
|
75
|
+
c,
|
76
|
+
!1
|
77
|
+
/* read as raw */
|
78
|
+
);
|
79
|
+
}, i.getJSON = function(c) {
|
80
|
+
return d(
|
81
|
+
c,
|
82
|
+
!0
|
83
|
+
/* read as json */
|
84
|
+
);
|
85
|
+
}, i.remove = function(c, p) {
|
86
|
+
a(c, "", r(p, {
|
87
|
+
expires: -1
|
88
|
+
}));
|
89
|
+
}, i.defaults = {}, i.withConverter = n, i;
|
90
|
+
}
|
91
|
+
return n(function() {
|
92
|
+
});
|
93
|
+
});
|
94
|
+
})(Q);
|
95
|
+
var de = Q.exports;
|
96
|
+
const D = /* @__PURE__ */ le(de);
|
97
|
+
/*! Capacitor: https://capacitorjs.com/ - MIT License */
|
98
|
+
const ue = (t) => {
|
99
|
+
const e = /* @__PURE__ */ new Map();
|
100
|
+
e.set("web", { name: "web" });
|
101
|
+
const r = t.CapacitorPlatforms || {
|
102
|
+
currentPlatform: { name: "web" },
|
103
|
+
platforms: e
|
104
|
+
}, o = (s, i) => {
|
105
|
+
r.platforms.set(s, i);
|
106
|
+
}, n = (s) => {
|
107
|
+
r.platforms.has(s) && (r.currentPlatform = r.platforms.get(s));
|
108
|
+
};
|
109
|
+
return r.addPlatform = o, r.setPlatform = n, r;
|
110
|
+
}, fe = (t) => t.CapacitorPlatforms = ue(t), X = /* @__PURE__ */ fe(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {});
|
111
|
+
X.addPlatform;
|
112
|
+
X.setPlatform;
|
113
|
+
var _;
|
114
|
+
(function(t) {
|
115
|
+
t.Unimplemented = "UNIMPLEMENTED", t.Unavailable = "UNAVAILABLE";
|
116
|
+
})(_ || (_ = {}));
|
117
|
+
class q extends Error {
|
118
|
+
constructor(e, r, o) {
|
119
|
+
super(e), this.message = e, this.code = r, this.data = o;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
const pe = (t) => {
|
123
|
+
var e, r;
|
124
|
+
return t != null && t.androidBridge ? "android" : !((r = (e = t == null ? void 0 : t.webkit) === null || e === void 0 ? void 0 : e.messageHandlers) === null || r === void 0) && r.bridge ? "ios" : "web";
|
125
|
+
}, ge = (t) => {
|
126
|
+
var e, r, o, n, s;
|
127
|
+
const i = t.CapacitorCustomPlatform || null, a = t.Capacitor || {}, d = a.Plugins = a.Plugins || {}, c = t.CapacitorPlatforms, p = () => i !== null ? i.name : pe(t), l = ((e = c == null ? void 0 : c.currentPlatform) === null || e === void 0 ? void 0 : e.getPlatform) || p, b = () => l() !== "web", y = ((r = c == null ? void 0 : c.currentPlatform) === null || r === void 0 ? void 0 : r.isNativePlatform) || b, C = (u) => {
|
128
|
+
const f = H.get(u);
|
129
|
+
return !!(f != null && f.platforms.has(l()) || R(u));
|
130
|
+
}, h = ((o = c == null ? void 0 : c.currentPlatform) === null || o === void 0 ? void 0 : o.isPluginAvailable) || C, U = (u) => {
|
131
|
+
var f;
|
132
|
+
return (f = a.PluginHeaders) === null || f === void 0 ? void 0 : f.find((x) => x.name === u);
|
133
|
+
}, R = ((n = c == null ? void 0 : c.currentPlatform) === null || n === void 0 ? void 0 : n.getPluginHeader) || U, re = (u) => t.console.error(u), se = (u, f, x) => Promise.reject(`${x} does not have an implementation of "${f}".`), H = /* @__PURE__ */ new Map(), ne = (u, f = {}) => {
|
134
|
+
const x = H.get(u);
|
135
|
+
if (x)
|
136
|
+
return console.warn(`Capacitor plugin "${u}" already registered. Cannot register plugins twice.`), x.proxy;
|
137
|
+
const j = l(), S = R(u);
|
138
|
+
let O;
|
139
|
+
const ae = async () => (!O && j in f ? O = typeof f[j] == "function" ? O = await f[j]() : O = f[j] : i !== null && !O && "web" in f && (O = typeof f.web == "function" ? O = await f.web() : O = f.web), O), ie = (g, w) => {
|
140
|
+
var P, L;
|
141
|
+
if (S) {
|
142
|
+
const k = S == null ? void 0 : S.methods.find((v) => w === v.name);
|
143
|
+
if (k)
|
144
|
+
return k.rtype === "promise" ? (v) => a.nativePromise(u, w.toString(), v) : (v, T) => a.nativeCallback(u, w.toString(), v, T);
|
145
|
+
if (g)
|
146
|
+
return (P = g[w]) === null || P === void 0 ? void 0 : P.bind(g);
|
147
|
+
} else {
|
148
|
+
if (g)
|
149
|
+
return (L = g[w]) === null || L === void 0 ? void 0 : L.bind(g);
|
150
|
+
throw new q(`"${u}" plugin is not implemented on ${j}`, _.Unimplemented);
|
151
|
+
}
|
152
|
+
}, B = (g) => {
|
153
|
+
let w;
|
154
|
+
const P = (...L) => {
|
155
|
+
const k = ae().then((v) => {
|
156
|
+
const T = ie(v, g);
|
157
|
+
if (T) {
|
158
|
+
const I = T(...L);
|
159
|
+
return w = I == null ? void 0 : I.remove, I;
|
160
|
+
} else
|
161
|
+
throw new q(`"${u}.${g}()" is not implemented on ${j}`, _.Unimplemented);
|
162
|
+
});
|
163
|
+
return g === "addListener" && (k.remove = async () => w()), k;
|
164
|
+
};
|
165
|
+
return P.toString = () => `${g.toString()}() { [capacitor code] }`, Object.defineProperty(P, "name", {
|
166
|
+
value: g,
|
167
|
+
writable: !1,
|
168
|
+
configurable: !1
|
169
|
+
}), P;
|
170
|
+
}, J = B("addListener"), G = B("removeListener"), ce = (g, w) => {
|
171
|
+
const P = J({ eventName: g }, w), L = async () => {
|
172
|
+
const v = await P;
|
173
|
+
G({
|
174
|
+
eventName: g,
|
175
|
+
callbackId: v
|
176
|
+
}, w);
|
177
|
+
}, k = new Promise((v) => P.then(() => v({ remove: L })));
|
178
|
+
return k.remove = async () => {
|
179
|
+
console.warn("Using addListener() without 'await' is deprecated."), await L();
|
180
|
+
}, k;
|
181
|
+
}, W = new Proxy({}, {
|
182
|
+
get(g, w) {
|
183
|
+
switch (w) {
|
184
|
+
case "$$typeof":
|
185
|
+
return;
|
186
|
+
case "toJSON":
|
187
|
+
return () => ({});
|
188
|
+
case "addListener":
|
189
|
+
return S ? ce : J;
|
190
|
+
case "removeListener":
|
191
|
+
return G;
|
192
|
+
default:
|
193
|
+
return B(w);
|
194
|
+
}
|
195
|
+
}
|
196
|
+
});
|
197
|
+
return d[u] = W, H.set(u, {
|
198
|
+
name: u,
|
199
|
+
proxy: W,
|
200
|
+
platforms: /* @__PURE__ */ new Set([
|
201
|
+
...Object.keys(f),
|
202
|
+
...S ? [j] : []
|
203
|
+
])
|
204
|
+
}), W;
|
205
|
+
}, oe = ((s = c == null ? void 0 : c.currentPlatform) === null || s === void 0 ? void 0 : s.registerPlugin) || ne;
|
206
|
+
return a.convertFileSrc || (a.convertFileSrc = (u) => u), a.getPlatform = l, a.handleError = re, a.isNativePlatform = y, a.isPluginAvailable = h, a.pluginMethodNoop = se, a.registerPlugin = oe, a.Exception = q, a.DEBUG = !!a.DEBUG, a.isLoggingEnabled = !!a.isLoggingEnabled, a.platform = a.getPlatform(), a.isNative = a.isNativePlatform(), a;
|
207
|
+
}, me = (t) => t.Capacitor = ge(t), M = /* @__PURE__ */ me(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : typeof global < "u" ? global : {}), Y = M.registerPlugin;
|
208
|
+
M.Plugins;
|
209
|
+
class ee {
|
210
|
+
constructor(e) {
|
211
|
+
this.listeners = {}, this.windowListeners = {}, e && (console.warn(`Capacitor WebPlugin "${e.name}" config object was deprecated in v3 and will be removed in v4.`), this.config = e);
|
212
|
+
}
|
213
|
+
addListener(e, r) {
|
214
|
+
this.listeners[e] || (this.listeners[e] = []), this.listeners[e].push(r);
|
215
|
+
const n = this.windowListeners[e];
|
216
|
+
n && !n.registered && this.addWindowListener(n);
|
217
|
+
const s = async () => this.removeListener(e, r), i = Promise.resolve({ remove: s });
|
218
|
+
return Object.defineProperty(i, "remove", {
|
219
|
+
value: async () => {
|
220
|
+
console.warn("Using addListener() without 'await' is deprecated."), await s();
|
221
|
+
}
|
222
|
+
}), i;
|
223
|
+
}
|
224
|
+
async removeAllListeners() {
|
225
|
+
this.listeners = {};
|
226
|
+
for (const e in this.windowListeners)
|
227
|
+
this.removeWindowListener(this.windowListeners[e]);
|
228
|
+
this.windowListeners = {};
|
229
|
+
}
|
230
|
+
notifyListeners(e, r) {
|
231
|
+
const o = this.listeners[e];
|
232
|
+
o && o.forEach((n) => n(r));
|
233
|
+
}
|
234
|
+
hasListeners(e) {
|
235
|
+
return !!this.listeners[e].length;
|
236
|
+
}
|
237
|
+
registerWindowListener(e, r) {
|
238
|
+
this.windowListeners[r] = {
|
239
|
+
registered: !1,
|
240
|
+
windowEventName: e,
|
241
|
+
pluginEventName: r,
|
242
|
+
handler: (o) => {
|
243
|
+
this.notifyListeners(r, o);
|
244
|
+
}
|
245
|
+
};
|
246
|
+
}
|
247
|
+
unimplemented(e = "not implemented") {
|
248
|
+
return new M.Exception(e, _.Unimplemented);
|
249
|
+
}
|
250
|
+
unavailable(e = "not available") {
|
251
|
+
return new M.Exception(e, _.Unavailable);
|
252
|
+
}
|
253
|
+
async removeListener(e, r) {
|
254
|
+
const o = this.listeners[e];
|
255
|
+
if (!o)
|
256
|
+
return;
|
257
|
+
const n = o.indexOf(r);
|
258
|
+
this.listeners[e].splice(n, 1), this.listeners[e].length || this.removeWindowListener(this.windowListeners[e]);
|
259
|
+
}
|
260
|
+
addWindowListener(e) {
|
261
|
+
window.addEventListener(e.windowEventName, e.handler), e.registered = !0;
|
262
|
+
}
|
263
|
+
removeWindowListener(e) {
|
264
|
+
e && (window.removeEventListener(e.windowEventName, e.handler), e.registered = !1);
|
265
|
+
}
|
266
|
+
}
|
267
|
+
const z = (t) => encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape), K = (t) => t.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
268
|
+
class we extends ee {
|
269
|
+
async getCookies() {
|
270
|
+
const e = document.cookie, r = {};
|
271
|
+
return e.split(";").forEach((o) => {
|
272
|
+
if (o.length <= 0)
|
273
|
+
return;
|
274
|
+
let [n, s] = o.replace(/=/, "CAP_COOKIE").split("CAP_COOKIE");
|
275
|
+
n = K(n).trim(), s = K(s).trim(), r[n] = s;
|
276
|
+
}), r;
|
277
|
+
}
|
278
|
+
async setCookie(e) {
|
279
|
+
try {
|
280
|
+
const r = z(e.key), o = z(e.value), n = `; expires=${(e.expires || "").replace("expires=", "")}`, s = (e.path || "/").replace("path=", ""), i = e.url != null && e.url.length > 0 ? `domain=${e.url}` : "";
|
281
|
+
document.cookie = `${r}=${o || ""}${n}; path=${s}; ${i};`;
|
282
|
+
} catch (r) {
|
283
|
+
return Promise.reject(r);
|
284
|
+
}
|
285
|
+
}
|
286
|
+
async deleteCookie(e) {
|
287
|
+
try {
|
288
|
+
document.cookie = `${e.key}=; Max-Age=0`;
|
289
|
+
} catch (r) {
|
290
|
+
return Promise.reject(r);
|
291
|
+
}
|
292
|
+
}
|
293
|
+
async clearCookies() {
|
294
|
+
try {
|
295
|
+
const e = document.cookie.split(";") || [];
|
296
|
+
for (const r of e)
|
297
|
+
document.cookie = r.replace(/^ +/, "").replace(/=.*/, `=;expires=${(/* @__PURE__ */ new Date()).toUTCString()};path=/`);
|
298
|
+
} catch (e) {
|
299
|
+
return Promise.reject(e);
|
300
|
+
}
|
301
|
+
}
|
302
|
+
async clearAllCookies() {
|
303
|
+
try {
|
304
|
+
await this.clearCookies();
|
305
|
+
} catch (e) {
|
306
|
+
return Promise.reject(e);
|
307
|
+
}
|
308
|
+
}
|
309
|
+
}
|
310
|
+
const te = Y("CapacitorCookies", {
|
311
|
+
web: () => new we()
|
312
|
+
}), he = async (t) => new Promise((e, r) => {
|
313
|
+
const o = new FileReader();
|
314
|
+
o.onload = () => {
|
315
|
+
const n = o.result;
|
316
|
+
e(n.indexOf(",") >= 0 ? n.split(",")[1] : n);
|
317
|
+
}, o.onerror = (n) => r(n), o.readAsDataURL(t);
|
318
|
+
}), ve = (t = {}) => {
|
319
|
+
const e = Object.keys(t);
|
320
|
+
return Object.keys(t).map((n) => n.toLocaleLowerCase()).reduce((n, s, i) => (n[s] = t[e[i]], n), {});
|
321
|
+
}, Pe = (t, e = !0) => t ? Object.entries(t).reduce((o, n) => {
|
322
|
+
const [s, i] = n;
|
323
|
+
let a, d;
|
324
|
+
return Array.isArray(i) ? (d = "", i.forEach((c) => {
|
325
|
+
a = e ? encodeURIComponent(c) : c, d += `${s}=${a}&`;
|
326
|
+
}), d.slice(0, -1)) : (a = e ? encodeURIComponent(i) : i, d = `${s}=${a}`), `${o}&${d}`;
|
327
|
+
}, "").substr(1) : null, be = (t, e = {}) => {
|
328
|
+
const r = Object.assign({ method: t.method || "GET", headers: t.headers }, e), n = ve(t.headers)["content-type"] || "";
|
329
|
+
if (typeof t.data == "string")
|
330
|
+
r.body = t.data;
|
331
|
+
else if (n.includes("application/x-www-form-urlencoded")) {
|
332
|
+
const s = new URLSearchParams();
|
333
|
+
for (const [i, a] of Object.entries(t.data || {}))
|
334
|
+
s.set(i, a);
|
335
|
+
r.body = s.toString();
|
336
|
+
} else if (n.includes("multipart/form-data")) {
|
337
|
+
const s = new FormData();
|
338
|
+
if (t.data instanceof FormData)
|
339
|
+
t.data.forEach((a, d) => {
|
340
|
+
s.append(d, a);
|
341
|
+
});
|
342
|
+
else
|
343
|
+
for (const a of Object.keys(t.data))
|
344
|
+
s.append(a, t.data[a]);
|
345
|
+
r.body = s;
|
346
|
+
const i = new Headers(r.headers);
|
347
|
+
i.delete("content-type"), r.headers = i;
|
348
|
+
} else
|
349
|
+
(n.includes("application/json") || typeof t.data == "object") && (r.body = JSON.stringify(t.data));
|
350
|
+
return r;
|
351
|
+
};
|
352
|
+
class ye extends ee {
|
353
|
+
/**
|
354
|
+
* Perform an Http request given a set of options
|
355
|
+
* @param options Options to build the HTTP request
|
356
|
+
*/
|
357
|
+
async request(e) {
|
358
|
+
const r = be(e, e.webFetchExtra), o = Pe(e.params, e.shouldEncodeUrlParams), n = o ? `${e.url}?${o}` : e.url, s = await fetch(n, r), i = s.headers.get("content-type") || "";
|
359
|
+
let { responseType: a = "text" } = s.ok ? e : {};
|
360
|
+
i.includes("application/json") && (a = "json");
|
361
|
+
let d, c;
|
362
|
+
switch (a) {
|
363
|
+
case "arraybuffer":
|
364
|
+
case "blob":
|
365
|
+
c = await s.blob(), d = await he(c);
|
366
|
+
break;
|
367
|
+
case "json":
|
368
|
+
d = await s.json();
|
369
|
+
break;
|
370
|
+
case "document":
|
371
|
+
case "text":
|
372
|
+
default:
|
373
|
+
d = await s.text();
|
374
|
+
}
|
375
|
+
const p = {};
|
376
|
+
return s.headers.forEach((l, b) => {
|
377
|
+
p[b] = l;
|
378
|
+
}), {
|
379
|
+
data: d,
|
380
|
+
headers: p,
|
381
|
+
status: s.status,
|
382
|
+
url: s.url
|
383
|
+
};
|
384
|
+
}
|
385
|
+
/**
|
386
|
+
* Perform an Http GET request given a set of options
|
387
|
+
* @param options Options to build the HTTP request
|
388
|
+
*/
|
389
|
+
async get(e) {
|
390
|
+
return this.request(Object.assign(Object.assign({}, e), { method: "GET" }));
|
391
|
+
}
|
392
|
+
/**
|
393
|
+
* Perform an Http POST request given a set of options
|
394
|
+
* @param options Options to build the HTTP request
|
395
|
+
*/
|
396
|
+
async post(e) {
|
397
|
+
return this.request(Object.assign(Object.assign({}, e), { method: "POST" }));
|
398
|
+
}
|
399
|
+
/**
|
400
|
+
* Perform an Http PUT request given a set of options
|
401
|
+
* @param options Options to build the HTTP request
|
402
|
+
*/
|
403
|
+
async put(e) {
|
404
|
+
return this.request(Object.assign(Object.assign({}, e), { method: "PUT" }));
|
405
|
+
}
|
406
|
+
/**
|
407
|
+
* Perform an Http PATCH request given a set of options
|
408
|
+
* @param options Options to build the HTTP request
|
409
|
+
*/
|
410
|
+
async patch(e) {
|
411
|
+
return this.request(Object.assign(Object.assign({}, e), { method: "PATCH" }));
|
412
|
+
}
|
413
|
+
/**
|
414
|
+
* Perform an Http DELETE request given a set of options
|
415
|
+
* @param options Options to build the HTTP request
|
416
|
+
*/
|
417
|
+
async delete(e) {
|
418
|
+
return this.request(Object.assign(Object.assign({}, e), { method: "DELETE" }));
|
419
|
+
}
|
420
|
+
}
|
421
|
+
Y("CapacitorHttp", {
|
422
|
+
web: () => new ye()
|
423
|
+
});
|
424
|
+
const Ce = N.create({ baseURL: process.env.API_URL, withCredentials: !0 }), $ = V({
|
425
|
+
code: {
|
426
|
+
value: "",
|
427
|
+
type: "",
|
428
|
+
method: "",
|
429
|
+
isSended: !1,
|
430
|
+
isValid: !1
|
431
|
+
}
|
432
|
+
});
|
433
|
+
async function Oe(t, e, r) {
|
434
|
+
return await Ce.post("/api/twofa/sendcode", {
|
435
|
+
phone: t.phone.number,
|
436
|
+
email: t.email,
|
437
|
+
method: e,
|
438
|
+
type: r
|
439
|
+
}).then(
|
440
|
+
(o) => ($.code = o.data, $.code.isSended = !0, Promise.resolve(o.data)),
|
441
|
+
(o) => (console.log(o), E(o), Promise.reject(o))
|
442
|
+
);
|
443
|
+
}
|
444
|
+
Z($, (t, e) => {
|
445
|
+
});
|
446
|
+
const Ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
447
|
+
__proto__: null,
|
448
|
+
sendCode: Oe,
|
449
|
+
state: $
|
450
|
+
}, Symbol.toStringTag, { value: "Module" })), A = N.create({ baseURL: process.env.API_URL, withCredentials: !0 }), m = V({
|
451
|
+
user: {
|
452
|
+
_id: void 0,
|
453
|
+
username: "",
|
454
|
+
email: "",
|
455
|
+
phone: "",
|
456
|
+
password: "",
|
457
|
+
passwordRepeat: ""
|
458
|
+
},
|
459
|
+
access: {
|
460
|
+
roles: null,
|
461
|
+
token: null,
|
462
|
+
status: !1
|
463
|
+
}
|
464
|
+
});
|
465
|
+
async function Le() {
|
466
|
+
const t = await Ee("user");
|
467
|
+
if (t) {
|
468
|
+
const { _id: e, email: r, phone: o, roles: n, accessToken: s } = t;
|
469
|
+
Object.assign(m.user, { _id: e, email: r, phone: o }), Object.assign(m.access, { token: s, roles: n, status: !!s }), A.interceptors.request.use((i) => (s && (i.headers["x-access-token"] = s), i), (i) => Promise.reject(i));
|
470
|
+
}
|
471
|
+
}
|
472
|
+
Le();
|
473
|
+
const ke = {
|
474
|
+
async login(t, e) {
|
475
|
+
try {
|
476
|
+
const r = await A.post("/api/auth/signin", {
|
477
|
+
...t,
|
478
|
+
type: e
|
479
|
+
});
|
480
|
+
return F("user", r.data), Object.assign(m.user, {
|
481
|
+
...r.data
|
482
|
+
}), Object.assign(m.access, {
|
483
|
+
token: r.data.accessToken,
|
484
|
+
status: !0,
|
485
|
+
roles: r.data.roles
|
486
|
+
}), r.data;
|
487
|
+
} catch (r) {
|
488
|
+
return Object.assign(m.access, {
|
489
|
+
token: null,
|
490
|
+
status: !1,
|
491
|
+
roles: null
|
492
|
+
}), E(r), Promise.reject(r);
|
493
|
+
}
|
494
|
+
},
|
495
|
+
async signup(t, e, r) {
|
496
|
+
const { password: o, passwordRepeat: n } = m.user;
|
497
|
+
if (o !== n) {
|
498
|
+
const s = {
|
499
|
+
response: {
|
500
|
+
data: { errorCode: "PASSWORDS_DO_NOT_MATCH" }
|
501
|
+
}
|
502
|
+
};
|
503
|
+
throw E(s), new Error(s.response.status);
|
504
|
+
}
|
505
|
+
try {
|
506
|
+
t.phone = t.phone.number;
|
507
|
+
const s = await A.post("/api/auth/signup", {
|
508
|
+
...t,
|
509
|
+
type: e,
|
510
|
+
inviteCode: r
|
511
|
+
});
|
512
|
+
return s.data.accessToken && F("user", s.data), Object.assign(m.user, {
|
513
|
+
...s.data
|
514
|
+
}), Object.assign(m.access, {
|
515
|
+
token: s.data.accessToken,
|
516
|
+
status: !0,
|
517
|
+
roles: s.data.roles
|
518
|
+
}), s.data;
|
519
|
+
} catch (s) {
|
520
|
+
throw E(s), console.log("Sign up falied"), s;
|
521
|
+
}
|
522
|
+
},
|
523
|
+
logout() {
|
524
|
+
xe("user"), Object.assign(m.user, {
|
525
|
+
email: "",
|
526
|
+
phone: "",
|
527
|
+
password: "",
|
528
|
+
passwordRepeat: ""
|
529
|
+
}), Object.assign(m.access, {
|
530
|
+
token: null,
|
531
|
+
status: !1
|
532
|
+
});
|
533
|
+
},
|
534
|
+
async resetPassword(t, e) {
|
535
|
+
try {
|
536
|
+
const r = await A.post("/api/auth/reset-password", {
|
537
|
+
email: t.email,
|
538
|
+
phone: t.phone.number,
|
539
|
+
type: e
|
540
|
+
});
|
541
|
+
return Object.assign($.code, {
|
542
|
+
...r.data,
|
543
|
+
isSended: !0
|
544
|
+
}), r.data;
|
545
|
+
} catch (r) {
|
546
|
+
return E(r), Promise.reject(r);
|
547
|
+
}
|
548
|
+
},
|
549
|
+
async updatePassword(t, e) {
|
550
|
+
const { password: r, passwordRepeat: o } = m.user;
|
551
|
+
if (r !== o) {
|
552
|
+
const n = {
|
553
|
+
response: {
|
554
|
+
data: { errorCode: "PASSWORDS_DO_NOT_MATCH" }
|
555
|
+
}
|
556
|
+
};
|
557
|
+
throw E(n), new Error(n.response.status);
|
558
|
+
}
|
559
|
+
try {
|
560
|
+
const n = await A.post("/api/auth/update-password", {
|
561
|
+
email: t.email,
|
562
|
+
phone: t.phone.number,
|
563
|
+
password: t.password,
|
564
|
+
passwordRepeat: t.passwordRepeat,
|
565
|
+
type: e
|
566
|
+
});
|
567
|
+
return n.data.accessToken && F("user", n.data), Object.assign(m.user, {
|
568
|
+
...n.data
|
569
|
+
}), Object.assign(m.access, {
|
570
|
+
token: n.data.accessToken,
|
571
|
+
status: !0
|
572
|
+
}), n.data;
|
573
|
+
} catch (n) {
|
574
|
+
return E(n), Promise.reject(n);
|
575
|
+
}
|
576
|
+
}
|
577
|
+
}, je = {
|
578
|
+
development: { secure: !1, expires: 1 },
|
579
|
+
production: { expires: 1, domain: process.env.API_URL, sameSite: "none", secure: !0 }
|
580
|
+
};
|
581
|
+
function Ee(t) {
|
582
|
+
if (process.env.MOBILE_APP) {
|
583
|
+
const e = D.get(t);
|
584
|
+
return e ? JSON.parse(e) : null;
|
585
|
+
} else {
|
586
|
+
const e = D.get(t);
|
587
|
+
return e ? JSON.parse(e) : null;
|
588
|
+
}
|
589
|
+
}
|
590
|
+
function F(t, e, r = process.env.NODE_ENV) {
|
591
|
+
process.env.MOBILE_APP ? te.setCookie({
|
592
|
+
url: process.env.API_URL,
|
593
|
+
// используйте ваш API_URL
|
594
|
+
key: t,
|
595
|
+
value: JSON.stringify(e)
|
596
|
+
}) : D.set(t, JSON.stringify(e), je[r]);
|
597
|
+
}
|
598
|
+
function xe(t, e = process.env.NODE_ENV) {
|
599
|
+
if (process.env.MOBILE_APP)
|
600
|
+
te.deleteCookie({
|
601
|
+
url: process.env.API_URL,
|
602
|
+
// используйте ваш API_URL
|
603
|
+
key: t
|
604
|
+
});
|
605
|
+
else {
|
606
|
+
const r = e === "production" ? { domain: process.env.API_URL } : {};
|
607
|
+
D.remove(t, r);
|
608
|
+
}
|
609
|
+
}
|
610
|
+
Z(m, (t, e) => {
|
611
|
+
});
|
612
|
+
const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
613
|
+
__proto__: null,
|
614
|
+
actions: ke,
|
615
|
+
state: m
|
616
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
617
|
+
export {
|
618
|
+
D as C,
|
619
|
+
ke as a,
|
620
|
+
$ as b,
|
621
|
+
Oe as c,
|
622
|
+
$e as d,
|
623
|
+
m as s,
|
624
|
+
Ae as t
|
625
|
+
};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
"use strict";const G=require("./index-b41aac19.js"),H=require("vue"),j=require("./globals-928eb13c.js");var Z={exports:{}};/*!
|
2
|
+
* JavaScript Cookie v2.2.1
|
3
|
+
* https://github.com/js-cookie/js-cookie
|
4
|
+
*
|
5
|
+
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
6
|
+
* Released under the MIT license
|
7
|
+
*/(function(t,e){(function(r){var o;if(t.exports=r(),o=!0,!o){var n=window.Cookies,s=window.Cookies=r();s.noConflict=function(){return window.Cookies=n,s}}})(function(){function r(){for(var s=0,i={};s<arguments.length;s++){var a=arguments[s];for(var d in a)i[d]=a[d]}return i}function o(s){return s.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}function n(s){function i(){}function a(c,p,l){if(!(typeof document>"u")){l=r({path:"/"},i.defaults,l),typeof l.expires=="number"&&(l.expires=new Date(new Date*1+l.expires*864e5)),l.expires=l.expires?l.expires.toUTCString():"";try{var b=JSON.stringify(p);/^[\{\[]/.test(b)&&(p=b)}catch{}p=s.write?s.write(p,c):encodeURIComponent(String(p)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),c=encodeURIComponent(String(c)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var y="";for(var C in l)l[C]&&(y+="; "+C,l[C]!==!0&&(y+="="+l[C].split(";")[0]));return document.cookie=c+"="+p+y}}function d(c,p){if(!(typeof document>"u")){for(var l={},b=document.cookie?document.cookie.split("; "):[],y=0;y<b.length;y++){var C=b[y].split("="),h=C.slice(1).join("=");!p&&h.charAt(0)==='"'&&(h=h.slice(1,-1));try{var $=o(C[0]);if(h=(s.read||s)(h,$)||o(h),p)try{h=JSON.parse(h)}catch{}if(l[$]=h,c===$)break}catch{}}return c?l[c]:l}}return i.set=a,i.get=function(c){return d(c,!1)},i.getJSON=function(c){return d(c,!0)},i.remove=function(c,p){a(c,"",r(p,{expires:-1}))},i.defaults={},i.withConverter=n,i}return n(function(){})})})(Z);var de=Z.exports;const R=G.getDefaultExportFromCjs(de);/*! Capacitor: https://capacitorjs.com/ - MIT License */const ue=t=>{const e=new Map;e.set("web",{name:"web"});const r=t.CapacitorPlatforms||{currentPlatform:{name:"web"},platforms:e},o=(s,i)=>{r.platforms.set(s,i)},n=s=>{r.platforms.has(s)&&(r.currentPlatform=r.platforms.get(s))};return r.addPlatform=o,r.setPlatform=n,r},fe=t=>t.CapacitorPlatforms=ue(t),Q=fe(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});Q.addPlatform;Q.setPlatform;var _;(function(t){t.Unimplemented="UNIMPLEMENTED",t.Unavailable="UNAVAILABLE"})(_||(_={}));class F extends Error{constructor(e,r,o){super(e),this.message=e,this.code=r,this.data=o}}const pe=t=>{var e,r;return t!=null&&t.androidBridge?"android":!((r=(e=t==null?void 0:t.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||r===void 0)&&r.bridge?"ios":"web"},ge=t=>{var e,r,o,n,s;const i=t.CapacitorCustomPlatform||null,a=t.Capacitor||{},d=a.Plugins=a.Plugins||{},c=t.CapacitorPlatforms,p=()=>i!==null?i.name:pe(t),l=((e=c==null?void 0:c.currentPlatform)===null||e===void 0?void 0:e.getPlatform)||p,b=()=>l()!=="web",y=((r=c==null?void 0:c.currentPlatform)===null||r===void 0?void 0:r.isNativePlatform)||b,C=u=>{const f=B.get(u);return!!(f!=null&&f.platforms.has(l())||T(u))},h=((o=c==null?void 0:c.currentPlatform)===null||o===void 0?void 0:o.isPluginAvailable)||C,$=u=>{var f;return(f=a.PluginHeaders)===null||f===void 0?void 0:f.find(x=>x.name===u)},T=((n=c==null?void 0:c.currentPlatform)===null||n===void 0?void 0:n.getPluginHeader)||$,se=u=>t.console.error(u),ne=(u,f,x)=>Promise.reject(`${x} does not have an implementation of "${f}".`),B=new Map,oe=(u,f={})=>{const x=B.get(u);if(x)return console.warn(`Capacitor plugin "${u}" already registered. Cannot register plugins twice.`),x.proxy;const E=l(),S=T(u);let O;const ie=async()=>(!O&&E in f?O=typeof f[E]=="function"?O=await f[E]():O=f[E]:i!==null&&!O&&"web"in f&&(O=typeof f.web=="function"?O=await f.web():O=f.web),O),ce=(g,w)=>{var P,L;if(S){const k=S==null?void 0:S.methods.find(v=>w===v.name);if(k)return k.rtype==="promise"?v=>a.nativePromise(u,w.toString(),v):(v,I)=>a.nativeCallback(u,w.toString(),v,I);if(g)return(P=g[w])===null||P===void 0?void 0:P.bind(g)}else{if(g)return(L=g[w])===null||L===void 0?void 0:L.bind(g);throw new F(`"${u}" plugin is not implemented on ${E}`,_.Unimplemented)}},q=g=>{let w;const P=(...L)=>{const k=ie().then(v=>{const I=ce(v,g);if(I){const D=I(...L);return w=D==null?void 0:D.remove,D}else throw new F(`"${u}.${g}()" is not implemented on ${E}`,_.Unimplemented)});return g==="addListener"&&(k.remove=async()=>w()),k};return P.toString=()=>`${g.toString()}() { [capacitor code] }`,Object.defineProperty(P,"name",{value:g,writable:!1,configurable:!1}),P},z=q("addListener"),K=q("removeListener"),le=(g,w)=>{const P=z({eventName:g},w),L=async()=>{const v=await P;K({eventName:g,callbackId:v},w)},k=new Promise(v=>P.then(()=>v({remove:L})));return k.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await L()},k},W=new Proxy({},{get(g,w){switch(w){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return S?le:z;case"removeListener":return K;default:return q(w)}}});return d[u]=W,B.set(u,{name:u,proxy:W,platforms:new Set([...Object.keys(f),...S?[E]:[]])}),W},ae=((s=c==null?void 0:c.currentPlatform)===null||s===void 0?void 0:s.registerPlugin)||oe;return a.convertFileSrc||(a.convertFileSrc=u=>u),a.getPlatform=l,a.handleError=se,a.isNativePlatform=y,a.isPluginAvailable=h,a.pluginMethodNoop=ne,a.registerPlugin=ae,a.Exception=F,a.DEBUG=!!a.DEBUG,a.isLoggingEnabled=!!a.isLoggingEnabled,a.platform=a.getPlatform(),a.isNative=a.isNativePlatform(),a},me=t=>t.Capacitor=ge(t),M=me(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),X=M.registerPlugin;M.Plugins;class Y{constructor(e){this.listeners={},this.windowListeners={},e&&(console.warn(`Capacitor WebPlugin "${e.name}" config object was deprecated in v3 and will be removed in v4.`),this.config=e)}addListener(e,r){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(r);const n=this.windowListeners[e];n&&!n.registered&&this.addWindowListener(n);const s=async()=>this.removeListener(e,r),i=Promise.resolve({remove:s});return Object.defineProperty(i,"remove",{value:async()=>{console.warn("Using addListener() without 'await' is deprecated."),await s()}}),i}async removeAllListeners(){this.listeners={};for(const e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,r){const o=this.listeners[e];o&&o.forEach(n=>n(r))}hasListeners(e){return!!this.listeners[e].length}registerWindowListener(e,r){this.windowListeners[r]={registered:!1,windowEventName:e,pluginEventName:r,handler:o=>{this.notifyListeners(r,o)}}}unimplemented(e="not implemented"){return new M.Exception(e,_.Unimplemented)}unavailable(e="not available"){return new M.Exception(e,_.Unavailable)}async removeListener(e,r){const o=this.listeners[e];if(!o)return;const n=o.indexOf(r);this.listeners[e].splice(n,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}}const N=t=>encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),V=t=>t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);class we extends Y{async getCookies(){const e=document.cookie,r={};return e.split(";").forEach(o=>{if(o.length<=0)return;let[n,s]=o.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");n=V(n).trim(),s=V(s).trim(),r[n]=s}),r}async setCookie(e){try{const r=N(e.key),o=N(e.value),n=`; expires=${(e.expires||"").replace("expires=","")}`,s=(e.path||"/").replace("path=",""),i=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${r}=${o||""}${n}; path=${s}; ${i};`}catch(r){return Promise.reject(r)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(r){return Promise.reject(r)}}async clearCookies(){try{const e=document.cookie.split(";")||[];for(const r of e)document.cookie=r.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}}const ee=X("CapacitorCookies",{web:()=>new we}),he=async t=>new Promise((e,r)=>{const o=new FileReader;o.onload=()=>{const n=o.result;e(n.indexOf(",")>=0?n.split(",")[1]:n)},o.onerror=n=>r(n),o.readAsDataURL(t)}),ve=(t={})=>{const e=Object.keys(t);return Object.keys(t).map(n=>n.toLocaleLowerCase()).reduce((n,s,i)=>(n[s]=t[e[i]],n),{})},Pe=(t,e=!0)=>t?Object.entries(t).reduce((o,n)=>{const[s,i]=n;let a,d;return Array.isArray(i)?(d="",i.forEach(c=>{a=e?encodeURIComponent(c):c,d+=`${s}=${a}&`}),d.slice(0,-1)):(a=e?encodeURIComponent(i):i,d=`${s}=${a}`),`${o}&${d}`},"").substr(1):null,be=(t,e={})=>{const r=Object.assign({method:t.method||"GET",headers:t.headers},e),n=ve(t.headers)["content-type"]||"";if(typeof t.data=="string")r.body=t.data;else if(n.includes("application/x-www-form-urlencoded")){const s=new URLSearchParams;for(const[i,a]of Object.entries(t.data||{}))s.set(i,a);r.body=s.toString()}else if(n.includes("multipart/form-data")){const s=new FormData;if(t.data instanceof FormData)t.data.forEach((a,d)=>{s.append(d,a)});else for(const a of Object.keys(t.data))s.append(a,t.data[a]);r.body=s;const i=new Headers(r.headers);i.delete("content-type"),r.headers=i}else(n.includes("application/json")||typeof t.data=="object")&&(r.body=JSON.stringify(t.data));return r};class ye extends Y{async request(e){const r=be(e,e.webFetchExtra),o=Pe(e.params,e.shouldEncodeUrlParams),n=o?`${e.url}?${o}`:e.url,s=await fetch(n,r),i=s.headers.get("content-type")||"";let{responseType:a="text"}=s.ok?e:{};i.includes("application/json")&&(a="json");let d,c;switch(a){case"arraybuffer":case"blob":c=await s.blob(),d=await he(c);break;case"json":d=await s.json();break;case"document":case"text":default:d=await s.text()}const p={};return s.headers.forEach((l,b)=>{p[b]=l}),{data:d,headers:p,status:s.status,url:s.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}}X("CapacitorHttp",{web:()=>new ye});const Ce=G.axios.create({baseURL:process.env.API_URL,withCredentials:!0}),U=H.reactive({code:{value:"",type:"",method:"",isSended:!1,isValid:!1}});async function te(t,e,r){return await Ce.post("/api/twofa/sendcode",{phone:t.phone.number,email:t.email,method:e,type:r}).then(o=>(U.code=o.data,U.code.isSended=!0,Promise.resolve(o.data)),o=>(console.log(o),j.setError(o),Promise.reject(o)))}H.watch(U,(t,e)=>{});const Oe=Object.freeze(Object.defineProperty({__proto__:null,sendCode:te,state:U},Symbol.toStringTag,{value:"Module"})),A=G.axios.create({baseURL:process.env.API_URL,withCredentials:!0}),m=H.reactive({user:{_id:void 0,username:"",email:"",phone:"",password:"",passwordRepeat:""},access:{roles:null,token:null,status:!1}});async function Le(){const t=await Ee("user");if(t){const{_id:e,email:r,phone:o,roles:n,accessToken:s}=t;Object.assign(m.user,{_id:e,email:r,phone:o}),Object.assign(m.access,{token:s,roles:n,status:!!s}),A.interceptors.request.use(i=>(s&&(i.headers["x-access-token"]=s),i),i=>Promise.reject(i))}}Le();const re={async login(t,e){try{const r=await A.post("/api/auth/signin",{...t,type:e});return J("user",r.data),Object.assign(m.user,{...r.data}),Object.assign(m.access,{token:r.data.accessToken,status:!0,roles:r.data.roles}),r.data}catch(r){return Object.assign(m.access,{token:null,status:!1,roles:null}),j.setError(r),Promise.reject(r)}},async signup(t,e,r){const{password:o,passwordRepeat:n}=m.user;if(o!==n){const s={response:{data:{errorCode:"PASSWORDS_DO_NOT_MATCH"}}};throw j.setError(s),new Error(s.response.status)}try{t.phone=t.phone.number;const s=await A.post("/api/auth/signup",{...t,type:e,inviteCode:r});return s.data.accessToken&&J("user",s.data),Object.assign(m.user,{...s.data}),Object.assign(m.access,{token:s.data.accessToken,status:!0,roles:s.data.roles}),s.data}catch(s){throw j.setError(s),console.log("Sign up falied"),s}},logout(){je("user"),Object.assign(m.user,{email:"",phone:"",password:"",passwordRepeat:""}),Object.assign(m.access,{token:null,status:!1})},async resetPassword(t,e){try{const r=await A.post("/api/auth/reset-password",{email:t.email,phone:t.phone.number,type:e});return Object.assign(U.code,{...r.data,isSended:!0}),r.data}catch(r){return j.setError(r),Promise.reject(r)}},async updatePassword(t,e){const{password:r,passwordRepeat:o}=m.user;if(r!==o){const n={response:{data:{errorCode:"PASSWORDS_DO_NOT_MATCH"}}};throw j.setError(n),new Error(n.response.status)}try{const n=await A.post("/api/auth/update-password",{email:t.email,phone:t.phone.number,password:t.password,passwordRepeat:t.passwordRepeat,type:e});return n.data.accessToken&&J("user",n.data),Object.assign(m.user,{...n.data}),Object.assign(m.access,{token:n.data.accessToken,status:!0}),n.data}catch(n){return j.setError(n),Promise.reject(n)}}},ke={development:{secure:!1,expires:1},production:{expires:1,domain:process.env.API_URL,sameSite:"none",secure:!0}};function Ee(t){if(process.env.MOBILE_APP){const e=R.get(t);return e?JSON.parse(e):null}else{const e=R.get(t);return e?JSON.parse(e):null}}function J(t,e,r=process.env.NODE_ENV){process.env.MOBILE_APP?ee.setCookie({url:process.env.API_URL,key:t,value:JSON.stringify(e)}):R.set(t,JSON.stringify(e),ke[r])}function je(t,e=process.env.NODE_ENV){if(process.env.MOBILE_APP)ee.deleteCookie({url:process.env.API_URL,key:t});else{const r=e==="production"?{domain:process.env.API_URL}:{};R.remove(t,r)}}H.watch(m,(t,e)=>{});const xe=Object.freeze(Object.defineProperty({__proto__:null,actions:re,state:m},Symbol.toStringTag,{value:"Module"}));exports.Cookies=R;exports.actions=re;exports.auth=xe;exports.sendCode=te;exports.state=m;exports.state$1=U;exports.twofa=Oe;
|