@skyservice-developers/vue-dev-kit 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/dist/api-C1dQWVCV.cjs +1 -0
- package/dist/api-DlXvS7Ec.js +309 -0
- package/dist/sdk/api.d.ts +29 -5
- package/dist/sdk.cjs +1 -1
- package/dist/sdk.js +1 -1
- package/dist/vue-dev-kit.cjs +1 -1
- package/dist/vue-dev-kit.js +2 -2
- package/package.json +1 -1
- package/dist/api-BOvdjB3h.js +0 -266
- package/dist/api-D5C6FvTr.cjs +0 -1
package/README.md
CHANGED
|
@@ -74,17 +74,26 @@ navigate('/products/42')
|
|
|
74
74
|
import { SkyserviceAPI, getToken } from '@skyservice-developers/vue-dev-kit/sdk'
|
|
75
75
|
|
|
76
76
|
const token = await getToken()
|
|
77
|
-
const api =
|
|
77
|
+
const api = SkyserviceAPI.create({
|
|
78
78
|
token,
|
|
79
79
|
domain: 'api.skyservice.online',
|
|
80
|
-
|
|
80
|
+
companyId,
|
|
81
|
+
appId,
|
|
82
|
+
// developerId: 'optional',
|
|
81
83
|
})
|
|
82
84
|
|
|
83
85
|
const tradepoints = await api.getTradepoints()
|
|
84
86
|
const categories = await api.getCategoryTree(tradepointId)
|
|
85
87
|
const products = await api.getProducts({ tradepointId })
|
|
88
|
+
|
|
89
|
+
// Активація/деактивація міні-додатку
|
|
90
|
+
await api.setAppActive({ isActive: true, settings: { foo: 'bar' } })
|
|
91
|
+
await api.setAppActive({ isActive: false })
|
|
86
92
|
```
|
|
87
93
|
|
|
94
|
+
> `SkyserviceAPI.create()` — factory; прямий виклик `new SkyserviceAPI(...)` недоступний.
|
|
95
|
+
> `setAppActive` завжди ходить на `api.cabinet.developer.skyservice.online` (хардкод).
|
|
96
|
+
|
|
88
97
|
### Webview detection
|
|
89
98
|
|
|
90
99
|
```ts
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const S=require("ua-parser-js"),v="DASHBOARD",b=5e3;let E=0,f=null;function A(){return`sdk_${Date.now()}_${++E}`}function L(){return"APP_"+Math.random().toString(36).slice(2,10)}function C(t){f=t}function w(){return f||(f=L()),f}function a(t){window.parent.postMessage({...t,sender:w(),target:t.target||v},"*")}function p(t,e,r=b){return y()?new Promise(n=>{const o=A(),i=w(),c=setTimeout(()=>{window.removeEventListener("message",u),n(null)},r);function u(k){const s=k.data;(s==null?void 0:s.type)==="DATA_RESPONSE"&&(s==null?void 0:s.requestId)===o&&(!s.target||s.target===i)&&(clearTimeout(c),window.removeEventListener("message",u),n(s.data??null))}window.addEventListener("message",u),a({type:"DATA_REQUEST",requestId:o,source:t,key:e})}):Promise.resolve(null)}function P(t){a({type:"navigate",path:t})}function m(){a({type:"exit"})}const T=m;function g(t){return p("store",t)}function l(t){return p("localStorage",t)}function _(t){return p("window",t)}function D(){return g("company")}function W(){return g("user")}function R(){return l("token")}function U(){return l("lang")}function $(){return g("productCategories")}function M(t,e){a({type:"setLocalStorage",key:t,value:e})}function O(t){a({type:"setRocketMode",value:t})}function x(t,e){a({type:"trackVisit",name:t,path:e})}function q(t){a({type:"openExternalLink",url:t})}function N(){a({type:"openCrispChat"})}function B(t){a({type:"notification",text:t})}function j(t){a({type:"notification",text:t,variant:"error"})}function G(t){a({type:"notification",text:t,variant:"warn"})}function y(){try{return window.self!==window.top}catch{return!0}}const V=y;function F(t){function e(r){var n;((n=r.data)==null?void 0:n.sender)===v&&t(r.data)}return window.addEventListener("message",e),()=>window.removeEventListener("message",e)}function d(){if(typeof window>"u")return"browser";if(window.webkit!=null&&window.webkit.messageHandlers!==void 0)try{if(S(navigator.userAgent).browser.name==="WebKit")return"ios_webview"}catch(t){console.error(t)}return typeof Android<"u"?"android_webview":typeof window.cefQuery<"u"?"cef_webview":"browser"}function H(){return d()==="ios_webview"}function Q(){return d()==="android_webview"}function z(){return d()==="cef_webview"}function J(){return d()!=="browser"}const K="https://api.cabinet.developer.skyservice.online/index.php";class h{constructor(e){this.token=e.token,this.companyId=e.companyId,this.appId=e.appId,this.developerId=e.developerId;const r=e.domain.replace("dashboard","api");this.baseUrl=r.startsWith("http")?r:`https://${r}`}static create(e){return new h(e)}async get(e){const r=new URLSearchParams({token:this.token,companyId:this.companyId,...e}),n=await fetch(`${this.baseUrl}/?${r}`);if(!n.ok)throw new Error(`Skyservice API error: ${n.status}`);const o=await n.json();if(o.status!=="done")throw new Error(`Skyservice API returned status: ${o.status}`);return o.data}async post(e,r,n){const o=new URLSearchParams({token:this.token,...r}),i=await fetch(`${e}?${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok)throw new Error(`Skyservice API error: ${i.status}`);return i.json()}async getTradepoints(e){const r=await this.get({section:"tradepoints",action:"getTradepoints"});return e!=null&&e.includeDeleted?r.items:r.items.filter(n=>!n.deleted&&!n.frozen)}async getCategoryTree(e){const r=await this.get({section:"productCategory",action:"getCategories",...e?{tradepointId:String(e)}:{}});return I(r,e)}async getProducts(e){const r=await this.get({section:"products",action:"getProducts",pagelimit:"9999",ot:"desc",of:"nomenclatureId",...e!=null&&e.tradepointId?{tradepointId:String(e.tradepointId)}:{}});return Z(r.items,e==null?void 0:e.includeInactive)}async setAppActive({isActive:e,settings:r}){const n=e?"activateApp":"deactivateApp",o={company_id:this.companyId,app_id:this.appId,...this.developerId!==void 0&&{developer_id:this.developerId},...e&&r!==void 0&&{settings:r}};return this.post(K,{section:"integrations",action:n},o)}}function I(t,e){var n,o;const r=[];for(const i of t){if(e!=null&&!((n=i.tradepointShow)==null?void 0:n[String(e)]))continue;const c={id:i.id,pid:i.pid,name:i.name,active:i.active,background:i.background,show:i.show};i.img&&(c.img=i.img),(o=i.children)!=null&&o.length&&(c.children=I(i.children,e)),r.push(c)}return r}const Y=new Set(["product","techcard"]),X="/img/no.png";function Z(t,e){const r=[];for(const n of t)Y.has(n.type)&&(!e&&!n.active||r.push({id:n.id,name:n.nomenclatureName,price:n.price,categoryId:n.categoryId,categoryName:n.categoryTitle||"",active:n.active,type:n.type,unit:n.unit,logo:n.logo&&n.logo!==X?n.logo:""}));return r}exports.SkyserviceAPI=h;exports.exit=m;exports.getBack=T;exports.getCompany=D;exports.getLang=U;exports.getLocalStorageData=l;exports.getProductCategories=$;exports.getSenderId=w;exports.getStoreData=g;exports.getToken=R;exports.getUser=W;exports.getWindowData=_;exports.isAndroidWebview=Q;exports.isCefWebview=z;exports.isInIframe=V;exports.isInsideIframe=y;exports.isIosWebview=H;exports.isWebview=J;exports.navigate=P;exports.notify=B;exports.notifyError=j;exports.notifyWarn=G;exports.onMessage=F;exports.openCrispChat=N;exports.openExternalLink=q;exports.setLocalStorage=M;exports.setRocketMode=O;exports.setSenderId=C;exports.trackVisit=x;exports.webviewCheck=d;
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import b from "ua-parser-js";
|
|
2
|
+
const g = "DASHBOARD", S = 5e3;
|
|
3
|
+
let k = 0, u = null;
|
|
4
|
+
function A() {
|
|
5
|
+
return `sdk_${Date.now()}_${++k}`;
|
|
6
|
+
}
|
|
7
|
+
function E() {
|
|
8
|
+
return "APP_" + Math.random().toString(36).slice(2, 10);
|
|
9
|
+
}
|
|
10
|
+
function R(t) {
|
|
11
|
+
u = t;
|
|
12
|
+
}
|
|
13
|
+
function l() {
|
|
14
|
+
return u || (u = E()), u;
|
|
15
|
+
}
|
|
16
|
+
function o(t) {
|
|
17
|
+
window.parent.postMessage(
|
|
18
|
+
{
|
|
19
|
+
...t,
|
|
20
|
+
sender: l(),
|
|
21
|
+
target: t.target || g
|
|
22
|
+
},
|
|
23
|
+
"*"
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
function p(t, e, r = S) {
|
|
27
|
+
return h() ? new Promise((n) => {
|
|
28
|
+
const a = A(), i = l(), c = setTimeout(() => {
|
|
29
|
+
window.removeEventListener("message", d), n(null);
|
|
30
|
+
}, r);
|
|
31
|
+
function d(I) {
|
|
32
|
+
const s = I.data;
|
|
33
|
+
(s == null ? void 0 : s.type) === "DATA_RESPONSE" && (s == null ? void 0 : s.requestId) === a && (!s.target || s.target === i) && (clearTimeout(c), window.removeEventListener("message", d), n(s.data ?? null));
|
|
34
|
+
}
|
|
35
|
+
window.addEventListener("message", d), o({ type: "DATA_REQUEST", requestId: a, source: t, key: e });
|
|
36
|
+
}) : Promise.resolve(null);
|
|
37
|
+
}
|
|
38
|
+
function U(t) {
|
|
39
|
+
o({ type: "navigate", path: t });
|
|
40
|
+
}
|
|
41
|
+
function L() {
|
|
42
|
+
o({ type: "exit" });
|
|
43
|
+
}
|
|
44
|
+
const $ = L;
|
|
45
|
+
function w(t) {
|
|
46
|
+
return p("store", t);
|
|
47
|
+
}
|
|
48
|
+
function y(t) {
|
|
49
|
+
return p("localStorage", t);
|
|
50
|
+
}
|
|
51
|
+
function O(t) {
|
|
52
|
+
return p("window", t);
|
|
53
|
+
}
|
|
54
|
+
function W() {
|
|
55
|
+
return w("company");
|
|
56
|
+
}
|
|
57
|
+
function x() {
|
|
58
|
+
return w("user");
|
|
59
|
+
}
|
|
60
|
+
function q() {
|
|
61
|
+
return y("token");
|
|
62
|
+
}
|
|
63
|
+
function M() {
|
|
64
|
+
return y("lang");
|
|
65
|
+
}
|
|
66
|
+
function N() {
|
|
67
|
+
return w("productCategories");
|
|
68
|
+
}
|
|
69
|
+
function j(t, e) {
|
|
70
|
+
o({ type: "setLocalStorage", key: t, value: e });
|
|
71
|
+
}
|
|
72
|
+
function B(t) {
|
|
73
|
+
o({ type: "setRocketMode", value: t });
|
|
74
|
+
}
|
|
75
|
+
function G(t, e) {
|
|
76
|
+
o({ type: "trackVisit", name: t, path: e });
|
|
77
|
+
}
|
|
78
|
+
function z(t) {
|
|
79
|
+
o({ type: "openExternalLink", url: t });
|
|
80
|
+
}
|
|
81
|
+
function F() {
|
|
82
|
+
o({ type: "openCrispChat" });
|
|
83
|
+
}
|
|
84
|
+
function H(t) {
|
|
85
|
+
o({ type: "notification", text: t });
|
|
86
|
+
}
|
|
87
|
+
function Q(t) {
|
|
88
|
+
o({ type: "notification", text: t, variant: "error" });
|
|
89
|
+
}
|
|
90
|
+
function V(t) {
|
|
91
|
+
o({ type: "notification", text: t, variant: "warn" });
|
|
92
|
+
}
|
|
93
|
+
function h() {
|
|
94
|
+
try {
|
|
95
|
+
return window.self !== window.top;
|
|
96
|
+
} catch {
|
|
97
|
+
return !0;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const J = h;
|
|
101
|
+
function K(t) {
|
|
102
|
+
function e(r) {
|
|
103
|
+
var n;
|
|
104
|
+
((n = r.data) == null ? void 0 : n.sender) === g && t(r.data);
|
|
105
|
+
}
|
|
106
|
+
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
107
|
+
}
|
|
108
|
+
function f() {
|
|
109
|
+
if (typeof window > "u") return "browser";
|
|
110
|
+
if (window.webkit != null && window.webkit.messageHandlers !== void 0)
|
|
111
|
+
try {
|
|
112
|
+
if (b(navigator.userAgent).browser.name === "WebKit") return "ios_webview";
|
|
113
|
+
} catch (t) {
|
|
114
|
+
console.error(t);
|
|
115
|
+
}
|
|
116
|
+
return typeof Android < "u" ? "android_webview" : typeof window.cefQuery < "u" ? "cef_webview" : "browser";
|
|
117
|
+
}
|
|
118
|
+
function Y() {
|
|
119
|
+
return f() === "ios_webview";
|
|
120
|
+
}
|
|
121
|
+
function X() {
|
|
122
|
+
return f() === "android_webview";
|
|
123
|
+
}
|
|
124
|
+
function Z() {
|
|
125
|
+
return f() === "cef_webview";
|
|
126
|
+
}
|
|
127
|
+
function ee() {
|
|
128
|
+
return f() !== "browser";
|
|
129
|
+
}
|
|
130
|
+
const P = "https://api.cabinet.developer.skyservice.online/index.php";
|
|
131
|
+
class m {
|
|
132
|
+
constructor(e) {
|
|
133
|
+
this.token = e.token, this.companyId = e.companyId, this.appId = e.appId, this.developerId = e.developerId;
|
|
134
|
+
const r = e.domain.replace("dashboard", "api");
|
|
135
|
+
this.baseUrl = r.startsWith("http") ? r : `https://${r}`;
|
|
136
|
+
}
|
|
137
|
+
/** Factory — create a new SkyserviceAPI instance. */
|
|
138
|
+
static create(e) {
|
|
139
|
+
return new m(e);
|
|
140
|
+
}
|
|
141
|
+
// --- Low-level ---
|
|
142
|
+
async get(e) {
|
|
143
|
+
const r = new URLSearchParams({
|
|
144
|
+
token: this.token,
|
|
145
|
+
companyId: this.companyId,
|
|
146
|
+
...e
|
|
147
|
+
}), n = await fetch(`${this.baseUrl}/?${r}`);
|
|
148
|
+
if (!n.ok)
|
|
149
|
+
throw new Error(`Skyservice API error: ${n.status}`);
|
|
150
|
+
const a = await n.json();
|
|
151
|
+
if (a.status !== "done")
|
|
152
|
+
throw new Error(`Skyservice API returned status: ${a.status}`);
|
|
153
|
+
return a.data;
|
|
154
|
+
}
|
|
155
|
+
async post(e, r, n) {
|
|
156
|
+
const a = new URLSearchParams({
|
|
157
|
+
token: this.token,
|
|
158
|
+
...r
|
|
159
|
+
}), i = await fetch(`${e}?${a}`, {
|
|
160
|
+
method: "POST",
|
|
161
|
+
headers: { "Content-Type": "application/json" },
|
|
162
|
+
body: JSON.stringify(n)
|
|
163
|
+
});
|
|
164
|
+
if (!i.ok)
|
|
165
|
+
throw new Error(`Skyservice API error: ${i.status}`);
|
|
166
|
+
return i.json();
|
|
167
|
+
}
|
|
168
|
+
// --- Tradepoints ---
|
|
169
|
+
/**
|
|
170
|
+
* Get all tradepoints for the current company.
|
|
171
|
+
* Filters out deleted and frozen by default.
|
|
172
|
+
*/
|
|
173
|
+
async getTradepoints(e) {
|
|
174
|
+
const r = await this.get({
|
|
175
|
+
section: "tradepoints",
|
|
176
|
+
action: "getTradepoints"
|
|
177
|
+
});
|
|
178
|
+
return e != null && e.includeDeleted ? r.items : r.items.filter((n) => !n.deleted && !n.frozen);
|
|
179
|
+
}
|
|
180
|
+
// --- Categories ---
|
|
181
|
+
/**
|
|
182
|
+
* Get the full category tree, cleaned from POS-specific bloat.
|
|
183
|
+
*
|
|
184
|
+
* Returns only fields relevant for menu building:
|
|
185
|
+
* `id`, `pid`, `name`, `active`, `background`, `show`, `img`, `children`.
|
|
186
|
+
*
|
|
187
|
+
* If `tradepointId` is provided, filters to categories visible for that tradepoint.
|
|
188
|
+
*/
|
|
189
|
+
async getCategoryTree(e) {
|
|
190
|
+
const r = await this.get({
|
|
191
|
+
section: "productCategory",
|
|
192
|
+
action: "getCategories",
|
|
193
|
+
...e ? { tradepointId: String(e) } : {}
|
|
194
|
+
});
|
|
195
|
+
return v(r, e);
|
|
196
|
+
}
|
|
197
|
+
// --- Products ---
|
|
198
|
+
/**
|
|
199
|
+
* Get products, cleaned from POS-specific fields.
|
|
200
|
+
*
|
|
201
|
+
* Filters out ingredients by default — returns only sellable items
|
|
202
|
+
* (type `product` or `techcard`).
|
|
203
|
+
*
|
|
204
|
+
* If `tradepointId` is provided, scopes to that tradepoint.
|
|
205
|
+
*/
|
|
206
|
+
async getProducts(e) {
|
|
207
|
+
const r = await this.get({
|
|
208
|
+
section: "products",
|
|
209
|
+
action: "getProducts",
|
|
210
|
+
pagelimit: "9999",
|
|
211
|
+
ot: "desc",
|
|
212
|
+
of: "nomenclatureId",
|
|
213
|
+
...e != null && e.tradepointId ? { tradepointId: String(e.tradepointId) } : {}
|
|
214
|
+
});
|
|
215
|
+
return C(r.items, e == null ? void 0 : e.includeInactive);
|
|
216
|
+
}
|
|
217
|
+
// --- Integrations ---
|
|
218
|
+
/**
|
|
219
|
+
* Activate or deactivate the mini-app for the current company.
|
|
220
|
+
*
|
|
221
|
+
* Sends POST to `api.cabinet.developer.skyservice.online`:
|
|
222
|
+
* - `isActive: true` → `section=integrations&action=activateApp`
|
|
223
|
+
* - `isActive: false` → `section=integrations&action=deactivateApp`
|
|
224
|
+
*
|
|
225
|
+
* `settings` are sent only when activating.
|
|
226
|
+
*/
|
|
227
|
+
async setAppActive({
|
|
228
|
+
isActive: e,
|
|
229
|
+
settings: r
|
|
230
|
+
}) {
|
|
231
|
+
const n = e ? "activateApp" : "deactivateApp", a = {
|
|
232
|
+
company_id: this.companyId,
|
|
233
|
+
app_id: this.appId,
|
|
234
|
+
...this.developerId !== void 0 && { developer_id: this.developerId },
|
|
235
|
+
...e && r !== void 0 && { settings: r }
|
|
236
|
+
};
|
|
237
|
+
return this.post(P, {
|
|
238
|
+
section: "integrations",
|
|
239
|
+
action: n
|
|
240
|
+
}, a);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function v(t, e) {
|
|
244
|
+
var n, a;
|
|
245
|
+
const r = [];
|
|
246
|
+
for (const i of t) {
|
|
247
|
+
if (e != null && !((n = i.tradepointShow) == null ? void 0 : n[String(e)]))
|
|
248
|
+
continue;
|
|
249
|
+
const c = {
|
|
250
|
+
id: i.id,
|
|
251
|
+
pid: i.pid,
|
|
252
|
+
name: i.name,
|
|
253
|
+
active: i.active,
|
|
254
|
+
background: i.background,
|
|
255
|
+
show: i.show
|
|
256
|
+
};
|
|
257
|
+
i.img && (c.img = i.img), (a = i.children) != null && a.length && (c.children = v(i.children, e)), r.push(c);
|
|
258
|
+
}
|
|
259
|
+
return r;
|
|
260
|
+
}
|
|
261
|
+
const T = /* @__PURE__ */ new Set(["product", "techcard"]), _ = "/img/no.png";
|
|
262
|
+
function C(t, e) {
|
|
263
|
+
const r = [];
|
|
264
|
+
for (const n of t)
|
|
265
|
+
T.has(n.type) && (!e && !n.active || r.push({
|
|
266
|
+
id: n.id,
|
|
267
|
+
name: n.nomenclatureName,
|
|
268
|
+
price: n.price,
|
|
269
|
+
categoryId: n.categoryId,
|
|
270
|
+
categoryName: n.categoryTitle || "",
|
|
271
|
+
active: n.active,
|
|
272
|
+
type: n.type,
|
|
273
|
+
unit: n.unit,
|
|
274
|
+
logo: n.logo && n.logo !== _ ? n.logo : ""
|
|
275
|
+
}));
|
|
276
|
+
return r;
|
|
277
|
+
}
|
|
278
|
+
export {
|
|
279
|
+
R as A,
|
|
280
|
+
G as B,
|
|
281
|
+
f as C,
|
|
282
|
+
m as S,
|
|
283
|
+
W as a,
|
|
284
|
+
M as b,
|
|
285
|
+
y as c,
|
|
286
|
+
N as d,
|
|
287
|
+
L as e,
|
|
288
|
+
l as f,
|
|
289
|
+
$ as g,
|
|
290
|
+
w as h,
|
|
291
|
+
q as i,
|
|
292
|
+
x as j,
|
|
293
|
+
O as k,
|
|
294
|
+
X as l,
|
|
295
|
+
Z as m,
|
|
296
|
+
J as n,
|
|
297
|
+
h as o,
|
|
298
|
+
Y as p,
|
|
299
|
+
ee as q,
|
|
300
|
+
U as r,
|
|
301
|
+
H as s,
|
|
302
|
+
Q as t,
|
|
303
|
+
V as u,
|
|
304
|
+
K as v,
|
|
305
|
+
F as w,
|
|
306
|
+
z as x,
|
|
307
|
+
j as y,
|
|
308
|
+
B as z
|
|
309
|
+
};
|
package/dist/sdk/api.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ import { Tradepoint, Category, Product } from './types';
|
|
|
3
3
|
export interface SkyserviceAPIConfig {
|
|
4
4
|
token: string;
|
|
5
5
|
domain: string;
|
|
6
|
-
companyId
|
|
6
|
+
companyId: string;
|
|
7
|
+
appId: string;
|
|
8
|
+
developerId?: string;
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* HTTP client for Skyservice API.
|
|
@@ -12,17 +14,26 @@ export interface SkyserviceAPIConfig {
|
|
|
12
14
|
*
|
|
13
15
|
* @example
|
|
14
16
|
* ```ts
|
|
15
|
-
* const api =
|
|
17
|
+
* const api = SkyserviceAPI.create({
|
|
18
|
+
* token,
|
|
19
|
+
* domain: 'api.skyservice.online',
|
|
20
|
+
* companyId,
|
|
21
|
+
* appId,
|
|
22
|
+
* });
|
|
16
23
|
* const tradepoints = await api.getTradepoints();
|
|
17
|
-
* const categories = await api.getCategoryTree(tradepointId);
|
|
18
24
|
* ```
|
|
19
25
|
*/
|
|
20
26
|
export declare class SkyserviceAPI {
|
|
21
27
|
private baseUrl;
|
|
22
28
|
private token;
|
|
23
29
|
private companyId;
|
|
24
|
-
|
|
25
|
-
private
|
|
30
|
+
private appId;
|
|
31
|
+
private developerId;
|
|
32
|
+
private constructor();
|
|
33
|
+
/** Factory — create a new SkyserviceAPI instance. */
|
|
34
|
+
static create(config: SkyserviceAPIConfig): SkyserviceAPI;
|
|
35
|
+
private get;
|
|
36
|
+
private post;
|
|
26
37
|
/**
|
|
27
38
|
* Get all tradepoints for the current company.
|
|
28
39
|
* Filters out deleted and frozen by default.
|
|
@@ -51,4 +62,17 @@ export declare class SkyserviceAPI {
|
|
|
51
62
|
tradepointId?: number;
|
|
52
63
|
includeInactive?: boolean;
|
|
53
64
|
}): Promise<Product[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Activate or deactivate the mini-app for the current company.
|
|
67
|
+
*
|
|
68
|
+
* Sends POST to `api.cabinet.developer.skyservice.online`:
|
|
69
|
+
* - `isActive: true` → `section=integrations&action=activateApp`
|
|
70
|
+
* - `isActive: false` → `section=integrations&action=deactivateApp`
|
|
71
|
+
*
|
|
72
|
+
* `settings` are sent only when activating.
|
|
73
|
+
*/
|
|
74
|
+
setAppActive({ isActive, settings, }: {
|
|
75
|
+
isActive: boolean;
|
|
76
|
+
settings?: Record<string, unknown>;
|
|
77
|
+
}): Promise<unknown>;
|
|
54
78
|
}
|
package/dist/sdk.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./api-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./api-C1dQWVCV.cjs");exports.SkyserviceAPI=e.SkyserviceAPI;exports.exit=e.exit;exports.getBack=e.getBack;exports.getCompany=e.getCompany;exports.getLang=e.getLang;exports.getLocalStorageData=e.getLocalStorageData;exports.getProductCategories=e.getProductCategories;exports.getSenderId=e.getSenderId;exports.getStoreData=e.getStoreData;exports.getToken=e.getToken;exports.getUser=e.getUser;exports.getWindowData=e.getWindowData;exports.isAndroidWebview=e.isAndroidWebview;exports.isCefWebview=e.isCefWebview;exports.isInIframe=e.isInIframe;exports.isInsideIframe=e.isInsideIframe;exports.isIosWebview=e.isIosWebview;exports.isWebview=e.isWebview;exports.navigate=e.navigate;exports.notify=e.notify;exports.notifyError=e.notifyError;exports.notifyWarn=e.notifyWarn;exports.onMessage=e.onMessage;exports.openCrispChat=e.openCrispChat;exports.openExternalLink=e.openExternalLink;exports.setLocalStorage=e.setLocalStorage;exports.setRocketMode=e.setRocketMode;exports.setSenderId=e.setSenderId;exports.trackVisit=e.trackVisit;exports.webviewCheck=e.webviewCheck;
|
package/dist/sdk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as s, e as t, g as i, a as o, b as r, c as n, d as g, f as d, h as c, i as f, j as k, k as v, l as w, m as I, n as C, o as S, p as b, q as p, r as y, s as W, t as m, u as l, v as x, w as L, x as h, y as A, z as D, A as u, B, C as E } from "./api-
|
|
1
|
+
import { S as s, e as t, g as i, a as o, b as r, c as n, d as g, f as d, h as c, i as f, j as k, k as v, l as w, m as I, n as C, o as S, p as b, q as p, r as y, s as W, t as m, u as l, v as x, w as L, x as h, y as A, z as D, A as u, B, C as E } from "./api-DlXvS7Ec.js";
|
|
2
2
|
export {
|
|
3
3
|
s as SkyserviceAPI,
|
|
4
4
|
t as exit,
|
package/dist/vue-dev-kit.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),o=require("./api-D5C6FvTr.cjs");require("ua-parser-js");const B=(t,v)=>{const a=t.__vccOpts||t;for(const[c,m]of v)a[c]=m;return a},M={class:"sky-header-container"},z={class:"topmenubox"},P={class:"header-left"},O=["title"],A={width:"15",height:"15",viewBox:"0 0 451.847 451.847",style:{transform:"rotate(90deg)"}},W={class:"notPadding"},R={class:"topmenu-title"},_={key:0,class:"title-dropdown"},U={class:"title-dropdown-header"},X=["onClick"],F={class:"pageName"},K={class:"pageVisit"},j={key:0,class:"topmenu-description"},q={class:"topmenubox-button"},H={__name:"Header",props:{title:{type:String,default:""},subtitle:{type:String,default:""},showBackButton:{type:Boolean,default:!0},backButtonTitle:{type:String,default:"Назад"},backEvent:{type:Function,default:null},dropdownItems:{type:Array,default:()=>[]},dropdownTitle:{type:String,default:"Останні відвідані розділи"},visitLabel:{type:String,default:"Останнє відвідування"},trackPageName:{type:String,default:""},trackPagePath:{type:String,default:""},appId:{type:String,default:""}},emits:["back","navigate"],setup(t,{emit:v}){const a=t;o.setSenderId(a.appId||o.getSenderId());const c=v,m=e.ref(null),i=e.ref(!1),k=e.ref([]),d=e.ref({});o.isInsideIframe()&&a.trackPageName&&o.trackVisit(a.trackPageName,a.trackPagePath||`/${a.trackPageName}`);const r=e.ref(null);o.isInsideIframe()&&o.getLocalStorageData("rocketMode").then(async n=>{r.value=n,await o.getLocalStorageData("fallbackRocketMode")===null&&o.setLocalStorage("fallbackRocketMode",n===!0||n==="true"?"true":"false"),o.setRocketMode(!0)}),e.onUnmounted(()=>{S()}),o.isInsideIframe()&&o.getWindowData("lang").then(n=>{n!=null&&(d.value=n)});function y(n){try{if(!n)return;const u=typeof n=="string"?JSON.parse(n):n;u!=null&&u.pages&&(k.value=Object.values(u.pages))}catch{}}y(localStorage.componentStats),o.isInsideIframe()&&o.getLocalStorageData("componentStats").then(n=>{n!=null&&(localStorage.setItem("componentStats",JSON.stringify(n)),y(n))});const p=e.computed(()=>[...a.dropdownItems.length?a.dropdownItems:k.value].sort((u,E)=>E.lastVisit-u.lastVisit)),g=()=>{p.value.length&&(i.value=!i.value)},h=()=>{i.value=!1},b=n=>{c("navigate",n.path),o.isInsideIframe()&&o.navigate(n.path),h()},w=n=>{if(!n)return"";const u=d.value[n]||n;return u.charAt(0).toUpperCase()+u.slice(1)},s=n=>{const E=Date.now()-n,N=Math.floor(E/1e3),C=Math.floor(N/60),$=Math.floor(C/60),D=Math.floor($/24);return D>0?`${D}д тому`:$>0?`${$}год тому`:C>0?`${C}хв тому`:`${N}с тому`},l=n=>{m.value&&!m.value.contains(n.target)&&h()};e.onMounted(()=>{document.addEventListener("click",l,!0)}),e.onUnmounted(()=>{document.removeEventListener("click",l,!0)});const f=e.computed(()=>a.backEvent||a.showBackButton&&o.isInsideIframe()),S=()=>{if(r.value!==null){const n=r.value===!0||r.value==="true";o.setRocketMode(n)}},V=()=>p.value.find(n=>n.name!==a.trackPageName&&n.path),L=async()=>{if(a.backEvent)return S(),a.backEvent();let n=V();if(!n&&o.isInsideIframe()){const u=await o.getLocalStorageData("componentStats");u&&(y(u),n=V())}S(),n?o.navigate(n.path):o.exit()};return(n,u)=>(e.openBlock(),e.createElementBlock("header",M,[e.createElementVNode("div",z,[e.createElementVNode("div",P,[f.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn-back",onClick:L,title:t.backButtonTitle},[(e.openBlock(),e.createElementBlock("svg",A,[...u[0]||(u[0]=[e.createElementVNode("path",{fill:"currentColor",d:"M225.923,354.706c-8.098,0-16.195-3.092-22.369-9.263L9.27,151.157c-12.359-12.359-12.359-32.397,0-44.751c12.354-12.354,32.388-12.354,44.748,0l171.905,171.915l171.906-171.909c12.359-12.354,32.391-12.354,44.744,0c12.365,12.354,12.365,32.392,0,44.751L248.292,345.449C242.115,351.621,234.018,354.706,225.923,354.706z"},null,-1)])]))],8,O)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"dropdownRef",ref:m,class:"titleAndDesc"},[e.createElementVNode("button",{class:e.normalizeClass(["title-dropdown-toggle",{"title-dropdown-toggle-active":p.value.length}]),onClick:g},[e.renderSlot(n.$slots,"title",{},()=>[e.createElementVNode("h4",W,[e.createElementVNode("span",R,e.toDisplayString(t.title),1),p.value.length?(e.openBlock(),e.createElementBlock("svg",{key:0,class:e.normalizeClass(["arrow",{open:i.value}]),width:"12",height:"12",viewBox:"0 0 451.847 451.847",style:{"flex-shrink":"0"}},[...u[1]||(u[1]=[e.createElementVNode("path",{fill:"currentColor",d:"M225.923,354.706c-8.098,0-16.195-3.092-22.369-9.263L9.27,151.157c-12.359-12.359-12.359-32.397,0-44.751c12.354-12.354,32.388-12.354,44.748,0l171.905,171.915l171.906-171.909c12.359-12.354,32.391-12.354,44.744,0c12.365,12.354,12.365,32.392,0,44.751L248.292,345.449C242.115,351.621,234.018,354.706,225.923,354.706z"},null,-1)])],2)):e.createCommentVNode("",!0)])],!0)],2),i.value&&p.value.length?(e.openBlock(),e.createElementBlock("div",_,[e.createElementVNode("div",U,e.toDisplayString(t.dropdownTitle),1),u[2]||(u[2]=e.createElementVNode("div",{class:"title-dropdown-divider"},null,-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(E,N)=>(e.openBlock(),e.createElementBlock("div",{key:N,class:"title-dropdown-item",onClick:C=>b(E)},[e.createElementVNode("p",F,e.toDisplayString(w(E.name)),1),e.createElementVNode("small",K," ("+e.toDisplayString(t.visitLabel)+" "+e.toDisplayString(s(E.lastVisit))+") ",1)],8,X))),128))])):e.createCommentVNode("",!0),e.renderSlot(n.$slots,"subtitle",{},()=>[t.subtitle?(e.openBlock(),e.createElementBlock("p",j,e.toDisplayString(t.subtitle),1)):e.createCommentVNode("",!0)],!0)],512)]),e.createElementVNode("div",q,[u[3]||(u[3]=e.createElementVNode("div",null,null,-1)),e.renderSlot(n.$slots,"default",{},void 0,!0),u[4]||(u[4]=e.createElementVNode("div",null,null,-1))])])]))}},J=B(H,[["__scopeId","data-v-ad8f398f"]]),G={class:"sky-dialog-overlay"},Q={key:0,class:"sky-dialog-subtitle"},Y=["title"],Z={key:0,class:"sky-dialog-swipe-area"},ee={key:0,class:"sky-dialog-footer"},te={__name:"DialogModal",props:{modelValue:{type:Boolean,default:!1},title:{type:String,default:""},subtitle:{type:String,default:""},zIndex:{type:[Number,String],default:null},closeText:{type:String,default:"Закрити"},closeOnEsc:{type:Boolean,default:!0},hasButtons:{type:Boolean,default:null}},emits:["update:modelValue","close","save"],setup(t,{emit:v}){const a=e.useSlots(),c=t,m=v,i=e.ref(null),k=e.ref(null),d=e.ref(0),r=e.computed(()=>{try{return o.isIosWebview()}catch{return!1}}),y=e.computed(()=>{try{return o.isAndroidWebview()}catch{return!1}}),p=e.computed(()=>c.hasButtons!==null?c.hasButtons:!!a.buttons),g=()=>{m("update:modelValue",!1),m("close")},h=l=>{l.key==="Escape"&&c.closeOnEsc&&c.modelValue&&g(),l.key==="Enter"&&c.modelValue&&m("save")},b=l=>{l.touches[0].clientX<35&&(d.value=l.touches[0].clientX)},w=l=>{d.value>0&&d.value<35&&l.changedTouches[0].clientX-d.value>50&&g(),d.value=0},s=()=>{if(!(!y.value||!i.value))try{if(typeof Android<"u"&&Android.getDisplayCutoutTop){const l=Android.getDisplayCutoutTop();if(l&&window.devicePixelRatio>1){const f=l/window.devicePixelRatio;i.value.style.paddingTop=f+"px"}}}catch{}};return e.watch(()=>c.modelValue,l=>{l?(document.body.style.overflow="hidden",e.nextTick(()=>{s()})):document.body.style.overflow=""}),e.onMounted(()=>{document.addEventListener("keydown",h),window.addEventListener("resize",s)}),e.onUnmounted(()=>{document.removeEventListener("keydown",h),window.removeEventListener("resize",s),document.body.style.overflow=""}),(l,f)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[t.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:"sky-dialogbox sky-dialogbox-classic",style:e.normalizeStyle([t.zIndex?{"z-index":t.zIndex}:null])},[e.createElementVNode("div",G,[e.createElementVNode("div",{ref_key:"dialogContent",ref:i,class:"sky-dialog-content"},[e.createElementVNode("div",{class:e.normalizeClass(["sky-dialog-title",{"sky-dialog-title-with-subtitle":t.subtitle}])},[e.createTextVNode(e.toDisplayString(t.title)+" ",1),t.subtitle?(e.openBlock(),e.createElementBlock("span",Q,e.toDisplayString(t.subtitle),1)):e.createCommentVNode("",!0)],2),e.createElementVNode("button",{class:"sky-dialog-close",title:t.closeText,onClick:g},[...f[0]||(f[0]=[e.createElementVNode("svg",{viewBox:"0 0 16 16",width:"16",height:"16"},[e.createElementVNode("line",{x1:"1",y1:"15",x2:"15",y2:"1",stroke:"currentColor","stroke-width":"2"}),e.createElementVNode("line",{x1:"1",y1:"1",x2:"15",y2:"15",stroke:"currentColor","stroke-width":"2"})],-1)])],8,Y),f[1]||(f[1]=e.createElementVNode("div",{class:"sky-dialog-clearfix"},null,-1)),e.createElementVNode("div",{ref_key:"dialogPaper",ref:k,class:e.normalizeClass(["sky-dialog-paper",{"sky-dialog-paper-no-footer":!p.value}]),onTouchstart:b,onTouchend:w},[r.value?(e.openBlock(),e.createElementBlock("div",Z)):e.createCommentVNode("",!0),e.renderSlot(l.$slots,"default",{},void 0,!0)],34),p.value?(e.openBlock(),e.createElementBlock("div",ee,[e.renderSlot(l.$slots,"buttons",{},void 0,!0)])):e.createCommentVNode("",!0)],512)])],4)):e.createCommentVNode("",!0)]))}},I=B(te,[["__scopeId","data-v-d1a407c7"]]),oe={class:"sky-dialog-overlay"},le={class:"sky-dialog-header"},ne=["title"],ae={width:"15",height:"15",viewBox:"0 0 451.847 451.847",style:{transform:"rotate(90deg)"}},se={key:0,class:"sky-dialog-subtitle"},de={key:0,class:"sky-dialog-swipe-area"},ie={key:0,class:"sky-dialog-footer"},re={__name:"DialogNext",props:{modelValue:{type:Boolean,default:!1},title:{type:String,default:""},subtitle:{type:String,default:""},zIndex:{type:[Number,String],default:null},closeText:{type:String,default:"Назад"},closeOnEsc:{type:Boolean,default:!0},hasButtons:{type:Boolean,default:null}},emits:["update:modelValue","close","save"],setup(t,{emit:v}){const a=e.useSlots(),c=t,m=v,i=e.ref(null),k=e.ref(null),d=e.ref(0),r=e.computed(()=>{try{return o.isIosWebview()}catch{return!1}}),y=e.computed(()=>{try{return o.isAndroidWebview()}catch{return!1}}),p=e.computed(()=>c.hasButtons!==null?c.hasButtons:!!a.buttons),g=()=>{m("update:modelValue",!1),m("close")},h=l=>{l.key==="Escape"&&c.closeOnEsc&&c.modelValue&&g(),l.key==="Enter"&&c.modelValue&&m("save")},b=l=>{l.touches[0].clientX<35&&(d.value=l.touches[0].clientX)},w=l=>{d.value>0&&d.value<35&&l.changedTouches[0].clientX-d.value>50&&g(),d.value=0},s=()=>{if(!(!y.value||!i.value))try{if(typeof Android<"u"&&Android.getDisplayCutoutTop){const l=Android.getDisplayCutoutTop();if(l&&window.devicePixelRatio>1){const f=l/window.devicePixelRatio;i.value.style.paddingTop=f+"px"}}}catch{}};return e.watch(()=>c.modelValue,l=>{l?(document.body.style.overflow="hidden",e.nextTick(()=>{s()})):document.body.style.overflow=""}),e.onMounted(()=>{document.addEventListener("keydown",h),window.addEventListener("resize",s)}),e.onUnmounted(()=>{document.removeEventListener("keydown",h),window.removeEventListener("resize",s),document.body.style.overflow=""}),(l,f)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[t.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:"sky-dialogbox sky-dialogbox-next",style:e.normalizeStyle([t.zIndex?{"z-index":t.zIndex}:null])},[e.createElementVNode("div",oe,[e.createElementVNode("div",{ref_key:"dialogContent",ref:i,class:"sky-dialog-content"},[e.createElementVNode("div",le,[e.createElementVNode("button",{class:"sky-dialog-back",title:t.closeText,onClick:g},[(e.openBlock(),e.createElementBlock("svg",ae,[...f[0]||(f[0]=[e.createElementVNode("path",{fill:"currentColor",d:"M225.923,354.706c-8.098,0-16.195-3.092-22.369-9.263L9.27,151.157c-12.359-12.359-12.359-32.397,0-44.751c12.354-12.354,32.388-12.354,44.748,0l171.905,171.915l171.906-171.909c12.359-12.354,32.391-12.354,44.744,0c12.365,12.354,12.365,32.392,0,44.751L248.292,345.449C242.115,351.621,234.018,354.706,225.923,354.706z"},null,-1)])]))],8,ne),e.createElementVNode("div",{class:e.normalizeClass(["sky-dialog-title",{"sky-dialog-title-with-subtitle":t.subtitle}])},[e.createTextVNode(e.toDisplayString(t.title)+" ",1),t.subtitle?(e.openBlock(),e.createElementBlock("span",se,e.toDisplayString(t.subtitle),1)):e.createCommentVNode("",!0)],2)]),e.createElementVNode("div",{ref_key:"dialogPaper",ref:k,class:e.normalizeClass(["sky-dialog-paper",{"sky-dialog-paper-no-footer":!p.value}]),onTouchstart:b,onTouchend:w},[r.value?(e.openBlock(),e.createElementBlock("div",de)):e.createCommentVNode("",!0),e.renderSlot(l.$slots,"default",{},void 0,!0)],34),p.value?(e.openBlock(),e.createElementBlock("div",ie,[e.renderSlot(l.$slots,"buttons",{},void 0,!0)])):e.createCommentVNode("",!0)],512)])],4)):e.createCommentVNode("",!0)]))}},x=B(re,[["__scopeId","data-v-c2e2d8f9"]]),ce={__name:"Dialog",props:{modelValue:{type:Boolean,default:!1},title:{type:String,default:""},subtitle:{type:String,default:""},zIndex:{type:[Number,String],default:null},closeText:{type:String,default:""},closeOnEsc:{type:Boolean,default:!0},mode:{type:String,default:null,validator:t=>[null,"next","classic"].includes(t)}},emits:["update:modelValue","close","save"],setup(t,{emit:v}){const a=t,c=v,m=e.computed({get:()=>a.modelValue,set:d=>c("update:modelValue",d)}),i=e.ref(!0);e.onMounted(()=>{try{new URLSearchParams(window.location.search).get("rocketMode")==="false"?i.value=!1:i.value=!0}catch{i.value=!0}});const k=e.computed(()=>a.mode==="next"?x:a.mode==="classic"?I:i.value?x:I);return(d,r)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k.value),{modelValue:m.value,"onUpdate:modelValue":r[0]||(r[0]=y=>m.value=y),title:t.title,subtitle:t.subtitle,"z-index":t.zIndex,"close-text":t.closeText,"close-on-esc":t.closeOnEsc,"has-buttons":!!d.$slots.buttons,onClose:r[1]||(r[1]=y=>d.$emit("close")),onSave:r[2]||(r[2]=y=>d.$emit("save"))},e.createSlots({default:e.withCtx(()=>[e.renderSlot(d.$slots,"default")]),_:2},[d.$slots.buttons?{name:"buttons",fn:e.withCtx(()=>[e.renderSlot(d.$slots,"buttons")]),key:"0"}:void 0]),1064,["modelValue","title","subtitle","z-index","close-text","close-on-esc","has-buttons"]))}},ue={props:{to:{type:String,default:"body"}}};function me(t,v,a,c,m,i){return e.openBlock(),e.createBlock(e.Teleport,{to:a.to},[e.renderSlot(t.$slots,"default")],8,["to"])}const T=B(ue,[["render",me]]),fe={class:"sky-modal-header"},ke=["title"],ye={width:"15",height:"15",viewBox:"0 0 451.847 451.847",style:{transform:"rotate(90deg)"}},ve={class:"sky-modal-title-wrapper"},pe={class:"sky-modal-title"},ge={key:0,class:"sky-modal-subtitle"},he={class:"sky-modal-body"},be={key:0,class:"sky-modal-footer"},we={__name:"Modal",props:{modelValue:{type:Boolean,default:!1},title:{type:String,default:""},subtitle:{type:String,default:""},closeTitle:{type:String,default:"Закрити"},closeOnOverlay:{type:Boolean,default:!0},closeOnEsc:{type:Boolean,default:!0},width:{type:String,default:"100%"},height:{type:String,default:"100%"}},emits:["update:modelValue","close"],setup(t,{emit:v}){const a=t,c=v,m=e.computed(()=>({width:a.width,height:a.height})),i=()=>{c("update:modelValue",!1),c("close")},k=()=>{a.closeOnOverlay&&i()},d=r=>{r.key==="Escape"&&a.closeOnEsc&&a.modelValue&&i()};return e.watch(()=>a.modelValue,r=>{r?document.body.style.overflow="hidden":document.body.style.overflow=""}),e.onMounted(()=>{document.addEventListener("keydown",d)}),e.onUnmounted(()=>{document.removeEventListener("keydown",d),document.body.style.overflow=""}),(r,y)=>(e.openBlock(),e.createBlock(T,{to:"body"},{default:e.withCtx(()=>[t.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:"sky-modal-overlay",onMousedown:e.withModifiers(k,["self"])},[e.createElementVNode("div",{class:"sky-modal",style:e.normalizeStyle(m.value)},[e.createElementVNode("div",fe,[e.createElementVNode("button",{class:"sky-modal-back",onClick:i,title:t.closeTitle},[(e.openBlock(),e.createElementBlock("svg",ye,[...y[0]||(y[0]=[e.createElementVNode("path",{fill:"currentColor",d:"M225.923,354.706c-8.098,0-16.195-3.092-22.369-9.263L9.27,151.157c-12.359-12.359-12.359-32.397,0-44.751c12.354-12.354,32.388-12.354,44.748,0l171.905,171.915l171.906-171.909c12.359-12.354,32.391-12.354,44.744,0c12.365,12.354,12.365,32.392,0,44.751L248.292,345.449C242.115,351.621,234.018,354.706,225.923,354.706z"},null,-1)])]))],8,ke),e.createElementVNode("div",ve,[e.createElementVNode("h4",pe,e.toDisplayString(t.title),1),t.subtitle?(e.openBlock(),e.createElementBlock("div",ge,e.toDisplayString(t.subtitle),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",he,[e.renderSlot(r.$slots,"default",{},void 0,!0)]),r.$slots.footer?(e.openBlock(),e.createElementBlock("div",be,[y[1]||(y[1]=e.createElementVNode("div",null,null,-1)),e.renderSlot(r.$slots,"footer",{},void 0,!0),y[2]||(y[2]=e.createElementVNode("div",null,null,-1))])):e.createCommentVNode("",!0)],4)],32)):e.createCommentVNode("",!0)]),_:3}))}},Ee=B(we,[["__scopeId","data-v-e16b0dc3"]]),Be=["disabled"],Se={key:0,class:"sky-btn-spinner"},Ve={__name:"SkyButton",props:{variant:{type:String,default:"primary",validator:t=>["primary","danger","secondary","outline"].includes(t)},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},block:{type:Boolean,default:!1},icon:{type:Boolean,default:!1}},setup(t){return(v,a)=>(e.openBlock(),e.createElementBlock("button",e.mergeProps({class:["sky-btn",[`sky-btn-${t.variant}`,{"sky-btn-block":t.block,"sky-btn-loading":t.loading,"sky-btn-icon":t.icon}]],disabled:t.disabled||t.loading},v.$attrs),[t.loading?(e.openBlock(),e.createElementBlock("span",Se)):e.createCommentVNode("",!0),e.renderSlot(v.$slots,"default",{},void 0,!0)],16,Be))}},Ne=B(Ve,[["__scopeId","data-v-0d61fbfd"]]),Ce=["disabled"],$e={key:0,class:"sky-select-dropdown"},Ie=["onClick","onMouseenter"],xe={key:0,class:"sky-select-check",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},De={__name:"SkySelect",props:{modelValue:{default:null},options:{type:Array,default:()=>[]},placeholder:{type:String,default:""},disabled:{type:Boolean,default:!1},block:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:v}){const a=t,c=v,m=e.ref(null),i=e.ref(!1),k=e.ref(-1),d=e.computed(()=>a.options.map(s=>typeof s=="string"?{label:s,value:s}:s)),r=e.computed(()=>d.value.find(s=>s.value===a.modelValue)??null);function y(){a.disabled||(i.value?g():p())}function p(){i.value=!0,k.value=d.value.findIndex(s=>s.value===a.modelValue),document.addEventListener("mousedown",b)}function g(){i.value=!1,document.removeEventListener("mousedown",b)}function h(s){c("update:modelValue",s.value),g()}function b(s){var l;(l=m.value)!=null&&l.contains(s.target)||g()}function w(s){if(!i.value){(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),p());return}s.key==="Escape"?g():s.key==="ArrowDown"?(s.preventDefault(),k.value=Math.min(k.value+1,d.value.length-1)):s.key==="ArrowUp"?(s.preventDefault(),k.value=Math.max(k.value-1,0)):s.key==="Enter"&&(s.preventDefault(),k.value>=0&&h(d.value[k.value]))}return e.onBeforeUnmount(()=>{document.removeEventListener("mousedown",b)}),(s,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"root",ref:m,class:e.normalizeClass(["sky-select",{"sky-select-block":t.block,"sky-select-open":i.value,"sky-select-disabled":t.disabled}])},[e.createElementVNode("button",{type:"button",class:"sky-select-trigger",disabled:t.disabled,onClick:y,onKeydown:w},[e.createElementVNode("span",{class:e.normalizeClass(["sky-select-value",{"sky-select-placeholder":r.value===null}])},e.toDisplayString(r.value?r.value.label:t.placeholder),3),l[0]||(l[0]=e.createElementVNode("svg",{class:"sky-select-chevron",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M4 6l4 4 4-4",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1))],40,Ce),i.value?(e.openBlock(),e.createElementBlock("div",$e,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(f,S)=>(e.openBlock(),e.createElementBlock("div",{key:f.value,class:e.normalizeClass(["sky-select-option",{"sky-select-option-selected":f.value===t.modelValue,"sky-select-option-focused":S===k.value}]),onClick:V=>h(f),onMouseenter:V=>k.value=S},[e.createElementVNode("span",null,e.toDisplayString(f.label),1),f.value===t.modelValue?(e.openBlock(),e.createElementBlock("svg",xe,[...l[1]||(l[1]=[e.createElementVNode("path",{d:"M3 8l4 4 6-6",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):e.createCommentVNode("",!0)],42,Ie))),128))])):e.createCommentVNode("",!0)],2))}},Te=B(De,[["__scopeId","data-v-5ca23325"]]);exports.SkyserviceAPI=o.SkyserviceAPI;exports.exit=o.exit;exports.getBack=o.getBack;exports.getCompany=o.getCompany;exports.getLang=o.getLang;exports.getLocalStorageData=o.getLocalStorageData;exports.getProductCategories=o.getProductCategories;exports.getSenderId=o.getSenderId;exports.getStoreData=o.getStoreData;exports.getToken=o.getToken;exports.getUser=o.getUser;exports.getWindowData=o.getWindowData;exports.isAndroidWebview=o.isAndroidWebview;exports.isCefWebview=o.isCefWebview;exports.isInIframe=o.isInIframe;exports.isInsideIframe=o.isInsideIframe;exports.isIosWebview=o.isIosWebview;exports.isWebview=o.isWebview;exports.navigate=o.navigate;exports.notify=o.notify;exports.notifyError=o.notifyError;exports.notifyWarn=o.notifyWarn;exports.onMessage=o.onMessage;exports.openCrispChat=o.openCrispChat;exports.openExternalLink=o.openExternalLink;exports.setLocalStorage=o.setLocalStorage;exports.setRocketMode=o.setRocketMode;exports.setSenderId=o.setSenderId;exports.trackVisit=o.trackVisit;exports.webviewCheck=o.webviewCheck;exports.BaseTeleport=T;exports.Dialog=ce;exports.DialogModal=I;exports.DialogNext=x;exports.Header=J;exports.Modal=Ee;exports.SkyButton=Ne;exports.SkySelect=Te;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),o=require("./api-C1dQWVCV.cjs");require("ua-parser-js");const B=(t,v)=>{const a=t.__vccOpts||t;for(const[c,m]of v)a[c]=m;return a},M={class:"sky-header-container"},z={class:"topmenubox"},P={class:"header-left"},O=["title"],A={width:"15",height:"15",viewBox:"0 0 451.847 451.847",style:{transform:"rotate(90deg)"}},W={class:"notPadding"},R={class:"topmenu-title"},_={key:0,class:"title-dropdown"},U={class:"title-dropdown-header"},X=["onClick"],F={class:"pageName"},K={class:"pageVisit"},j={key:0,class:"topmenu-description"},q={class:"topmenubox-button"},H={__name:"Header",props:{title:{type:String,default:""},subtitle:{type:String,default:""},showBackButton:{type:Boolean,default:!0},backButtonTitle:{type:String,default:"Назад"},backEvent:{type:Function,default:null},dropdownItems:{type:Array,default:()=>[]},dropdownTitle:{type:String,default:"Останні відвідані розділи"},visitLabel:{type:String,default:"Останнє відвідування"},trackPageName:{type:String,default:""},trackPagePath:{type:String,default:""},appId:{type:String,default:""}},emits:["back","navigate"],setup(t,{emit:v}){const a=t;o.setSenderId(a.appId||o.getSenderId());const c=v,m=e.ref(null),i=e.ref(!1),k=e.ref([]),d=e.ref({});o.isInsideIframe()&&a.trackPageName&&o.trackVisit(a.trackPageName,a.trackPagePath||`/${a.trackPageName}`);const r=e.ref(null);o.isInsideIframe()&&o.getLocalStorageData("rocketMode").then(async n=>{r.value=n,await o.getLocalStorageData("fallbackRocketMode")===null&&o.setLocalStorage("fallbackRocketMode",n===!0||n==="true"?"true":"false"),o.setRocketMode(!0)}),e.onUnmounted(()=>{S()}),o.isInsideIframe()&&o.getWindowData("lang").then(n=>{n!=null&&(d.value=n)});function y(n){try{if(!n)return;const u=typeof n=="string"?JSON.parse(n):n;u!=null&&u.pages&&(k.value=Object.values(u.pages))}catch{}}y(localStorage.componentStats),o.isInsideIframe()&&o.getLocalStorageData("componentStats").then(n=>{n!=null&&(localStorage.setItem("componentStats",JSON.stringify(n)),y(n))});const p=e.computed(()=>[...a.dropdownItems.length?a.dropdownItems:k.value].sort((u,E)=>E.lastVisit-u.lastVisit)),g=()=>{p.value.length&&(i.value=!i.value)},h=()=>{i.value=!1},b=n=>{c("navigate",n.path),o.isInsideIframe()&&o.navigate(n.path),h()},w=n=>{if(!n)return"";const u=d.value[n]||n;return u.charAt(0).toUpperCase()+u.slice(1)},s=n=>{const E=Date.now()-n,N=Math.floor(E/1e3),C=Math.floor(N/60),$=Math.floor(C/60),D=Math.floor($/24);return D>0?`${D}д тому`:$>0?`${$}год тому`:C>0?`${C}хв тому`:`${N}с тому`},l=n=>{m.value&&!m.value.contains(n.target)&&h()};e.onMounted(()=>{document.addEventListener("click",l,!0)}),e.onUnmounted(()=>{document.removeEventListener("click",l,!0)});const f=e.computed(()=>a.backEvent||a.showBackButton&&o.isInsideIframe()),S=()=>{if(r.value!==null){const n=r.value===!0||r.value==="true";o.setRocketMode(n)}},V=()=>p.value.find(n=>n.name!==a.trackPageName&&n.path),L=async()=>{if(a.backEvent)return S(),a.backEvent();let n=V();if(!n&&o.isInsideIframe()){const u=await o.getLocalStorageData("componentStats");u&&(y(u),n=V())}S(),n?o.navigate(n.path):o.exit()};return(n,u)=>(e.openBlock(),e.createElementBlock("header",M,[e.createElementVNode("div",z,[e.createElementVNode("div",P,[f.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"btn-back",onClick:L,title:t.backButtonTitle},[(e.openBlock(),e.createElementBlock("svg",A,[...u[0]||(u[0]=[e.createElementVNode("path",{fill:"currentColor",d:"M225.923,354.706c-8.098,0-16.195-3.092-22.369-9.263L9.27,151.157c-12.359-12.359-12.359-32.397,0-44.751c12.354-12.354,32.388-12.354,44.748,0l171.905,171.915l171.906-171.909c12.359-12.354,32.391-12.354,44.744,0c12.365,12.354,12.365,32.392,0,44.751L248.292,345.449C242.115,351.621,234.018,354.706,225.923,354.706z"},null,-1)])]))],8,O)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"dropdownRef",ref:m,class:"titleAndDesc"},[e.createElementVNode("button",{class:e.normalizeClass(["title-dropdown-toggle",{"title-dropdown-toggle-active":p.value.length}]),onClick:g},[e.renderSlot(n.$slots,"title",{},()=>[e.createElementVNode("h4",W,[e.createElementVNode("span",R,e.toDisplayString(t.title),1),p.value.length?(e.openBlock(),e.createElementBlock("svg",{key:0,class:e.normalizeClass(["arrow",{open:i.value}]),width:"12",height:"12",viewBox:"0 0 451.847 451.847",style:{"flex-shrink":"0"}},[...u[1]||(u[1]=[e.createElementVNode("path",{fill:"currentColor",d:"M225.923,354.706c-8.098,0-16.195-3.092-22.369-9.263L9.27,151.157c-12.359-12.359-12.359-32.397,0-44.751c12.354-12.354,32.388-12.354,44.748,0l171.905,171.915l171.906-171.909c12.359-12.354,32.391-12.354,44.744,0c12.365,12.354,12.365,32.392,0,44.751L248.292,345.449C242.115,351.621,234.018,354.706,225.923,354.706z"},null,-1)])],2)):e.createCommentVNode("",!0)])],!0)],2),i.value&&p.value.length?(e.openBlock(),e.createElementBlock("div",_,[e.createElementVNode("div",U,e.toDisplayString(t.dropdownTitle),1),u[2]||(u[2]=e.createElementVNode("div",{class:"title-dropdown-divider"},null,-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(E,N)=>(e.openBlock(),e.createElementBlock("div",{key:N,class:"title-dropdown-item",onClick:C=>b(E)},[e.createElementVNode("p",F,e.toDisplayString(w(E.name)),1),e.createElementVNode("small",K," ("+e.toDisplayString(t.visitLabel)+" "+e.toDisplayString(s(E.lastVisit))+") ",1)],8,X))),128))])):e.createCommentVNode("",!0),e.renderSlot(n.$slots,"subtitle",{},()=>[t.subtitle?(e.openBlock(),e.createElementBlock("p",j,e.toDisplayString(t.subtitle),1)):e.createCommentVNode("",!0)],!0)],512)]),e.createElementVNode("div",q,[u[3]||(u[3]=e.createElementVNode("div",null,null,-1)),e.renderSlot(n.$slots,"default",{},void 0,!0),u[4]||(u[4]=e.createElementVNode("div",null,null,-1))])])]))}},J=B(H,[["__scopeId","data-v-ad8f398f"]]),G={class:"sky-dialog-overlay"},Q={key:0,class:"sky-dialog-subtitle"},Y=["title"],Z={key:0,class:"sky-dialog-swipe-area"},ee={key:0,class:"sky-dialog-footer"},te={__name:"DialogModal",props:{modelValue:{type:Boolean,default:!1},title:{type:String,default:""},subtitle:{type:String,default:""},zIndex:{type:[Number,String],default:null},closeText:{type:String,default:"Закрити"},closeOnEsc:{type:Boolean,default:!0},hasButtons:{type:Boolean,default:null}},emits:["update:modelValue","close","save"],setup(t,{emit:v}){const a=e.useSlots(),c=t,m=v,i=e.ref(null),k=e.ref(null),d=e.ref(0),r=e.computed(()=>{try{return o.isIosWebview()}catch{return!1}}),y=e.computed(()=>{try{return o.isAndroidWebview()}catch{return!1}}),p=e.computed(()=>c.hasButtons!==null?c.hasButtons:!!a.buttons),g=()=>{m("update:modelValue",!1),m("close")},h=l=>{l.key==="Escape"&&c.closeOnEsc&&c.modelValue&&g(),l.key==="Enter"&&c.modelValue&&m("save")},b=l=>{l.touches[0].clientX<35&&(d.value=l.touches[0].clientX)},w=l=>{d.value>0&&d.value<35&&l.changedTouches[0].clientX-d.value>50&&g(),d.value=0},s=()=>{if(!(!y.value||!i.value))try{if(typeof Android<"u"&&Android.getDisplayCutoutTop){const l=Android.getDisplayCutoutTop();if(l&&window.devicePixelRatio>1){const f=l/window.devicePixelRatio;i.value.style.paddingTop=f+"px"}}}catch{}};return e.watch(()=>c.modelValue,l=>{l?(document.body.style.overflow="hidden",e.nextTick(()=>{s()})):document.body.style.overflow=""}),e.onMounted(()=>{document.addEventListener("keydown",h),window.addEventListener("resize",s)}),e.onUnmounted(()=>{document.removeEventListener("keydown",h),window.removeEventListener("resize",s),document.body.style.overflow=""}),(l,f)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[t.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:"sky-dialogbox sky-dialogbox-classic",style:e.normalizeStyle([t.zIndex?{"z-index":t.zIndex}:null])},[e.createElementVNode("div",G,[e.createElementVNode("div",{ref_key:"dialogContent",ref:i,class:"sky-dialog-content"},[e.createElementVNode("div",{class:e.normalizeClass(["sky-dialog-title",{"sky-dialog-title-with-subtitle":t.subtitle}])},[e.createTextVNode(e.toDisplayString(t.title)+" ",1),t.subtitle?(e.openBlock(),e.createElementBlock("span",Q,e.toDisplayString(t.subtitle),1)):e.createCommentVNode("",!0)],2),e.createElementVNode("button",{class:"sky-dialog-close",title:t.closeText,onClick:g},[...f[0]||(f[0]=[e.createElementVNode("svg",{viewBox:"0 0 16 16",width:"16",height:"16"},[e.createElementVNode("line",{x1:"1",y1:"15",x2:"15",y2:"1",stroke:"currentColor","stroke-width":"2"}),e.createElementVNode("line",{x1:"1",y1:"1",x2:"15",y2:"15",stroke:"currentColor","stroke-width":"2"})],-1)])],8,Y),f[1]||(f[1]=e.createElementVNode("div",{class:"sky-dialog-clearfix"},null,-1)),e.createElementVNode("div",{ref_key:"dialogPaper",ref:k,class:e.normalizeClass(["sky-dialog-paper",{"sky-dialog-paper-no-footer":!p.value}]),onTouchstart:b,onTouchend:w},[r.value?(e.openBlock(),e.createElementBlock("div",Z)):e.createCommentVNode("",!0),e.renderSlot(l.$slots,"default",{},void 0,!0)],34),p.value?(e.openBlock(),e.createElementBlock("div",ee,[e.renderSlot(l.$slots,"buttons",{},void 0,!0)])):e.createCommentVNode("",!0)],512)])],4)):e.createCommentVNode("",!0)]))}},I=B(te,[["__scopeId","data-v-d1a407c7"]]),oe={class:"sky-dialog-overlay"},le={class:"sky-dialog-header"},ne=["title"],ae={width:"15",height:"15",viewBox:"0 0 451.847 451.847",style:{transform:"rotate(90deg)"}},se={key:0,class:"sky-dialog-subtitle"},de={key:0,class:"sky-dialog-swipe-area"},ie={key:0,class:"sky-dialog-footer"},re={__name:"DialogNext",props:{modelValue:{type:Boolean,default:!1},title:{type:String,default:""},subtitle:{type:String,default:""},zIndex:{type:[Number,String],default:null},closeText:{type:String,default:"Назад"},closeOnEsc:{type:Boolean,default:!0},hasButtons:{type:Boolean,default:null}},emits:["update:modelValue","close","save"],setup(t,{emit:v}){const a=e.useSlots(),c=t,m=v,i=e.ref(null),k=e.ref(null),d=e.ref(0),r=e.computed(()=>{try{return o.isIosWebview()}catch{return!1}}),y=e.computed(()=>{try{return o.isAndroidWebview()}catch{return!1}}),p=e.computed(()=>c.hasButtons!==null?c.hasButtons:!!a.buttons),g=()=>{m("update:modelValue",!1),m("close")},h=l=>{l.key==="Escape"&&c.closeOnEsc&&c.modelValue&&g(),l.key==="Enter"&&c.modelValue&&m("save")},b=l=>{l.touches[0].clientX<35&&(d.value=l.touches[0].clientX)},w=l=>{d.value>0&&d.value<35&&l.changedTouches[0].clientX-d.value>50&&g(),d.value=0},s=()=>{if(!(!y.value||!i.value))try{if(typeof Android<"u"&&Android.getDisplayCutoutTop){const l=Android.getDisplayCutoutTop();if(l&&window.devicePixelRatio>1){const f=l/window.devicePixelRatio;i.value.style.paddingTop=f+"px"}}}catch{}};return e.watch(()=>c.modelValue,l=>{l?(document.body.style.overflow="hidden",e.nextTick(()=>{s()})):document.body.style.overflow=""}),e.onMounted(()=>{document.addEventListener("keydown",h),window.addEventListener("resize",s)}),e.onUnmounted(()=>{document.removeEventListener("keydown",h),window.removeEventListener("resize",s),document.body.style.overflow=""}),(l,f)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[t.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:"sky-dialogbox sky-dialogbox-next",style:e.normalizeStyle([t.zIndex?{"z-index":t.zIndex}:null])},[e.createElementVNode("div",oe,[e.createElementVNode("div",{ref_key:"dialogContent",ref:i,class:"sky-dialog-content"},[e.createElementVNode("div",le,[e.createElementVNode("button",{class:"sky-dialog-back",title:t.closeText,onClick:g},[(e.openBlock(),e.createElementBlock("svg",ae,[...f[0]||(f[0]=[e.createElementVNode("path",{fill:"currentColor",d:"M225.923,354.706c-8.098,0-16.195-3.092-22.369-9.263L9.27,151.157c-12.359-12.359-12.359-32.397,0-44.751c12.354-12.354,32.388-12.354,44.748,0l171.905,171.915l171.906-171.909c12.359-12.354,32.391-12.354,44.744,0c12.365,12.354,12.365,32.392,0,44.751L248.292,345.449C242.115,351.621,234.018,354.706,225.923,354.706z"},null,-1)])]))],8,ne),e.createElementVNode("div",{class:e.normalizeClass(["sky-dialog-title",{"sky-dialog-title-with-subtitle":t.subtitle}])},[e.createTextVNode(e.toDisplayString(t.title)+" ",1),t.subtitle?(e.openBlock(),e.createElementBlock("span",se,e.toDisplayString(t.subtitle),1)):e.createCommentVNode("",!0)],2)]),e.createElementVNode("div",{ref_key:"dialogPaper",ref:k,class:e.normalizeClass(["sky-dialog-paper",{"sky-dialog-paper-no-footer":!p.value}]),onTouchstart:b,onTouchend:w},[r.value?(e.openBlock(),e.createElementBlock("div",de)):e.createCommentVNode("",!0),e.renderSlot(l.$slots,"default",{},void 0,!0)],34),p.value?(e.openBlock(),e.createElementBlock("div",ie,[e.renderSlot(l.$slots,"buttons",{},void 0,!0)])):e.createCommentVNode("",!0)],512)])],4)):e.createCommentVNode("",!0)]))}},x=B(re,[["__scopeId","data-v-c2e2d8f9"]]),ce={__name:"Dialog",props:{modelValue:{type:Boolean,default:!1},title:{type:String,default:""},subtitle:{type:String,default:""},zIndex:{type:[Number,String],default:null},closeText:{type:String,default:""},closeOnEsc:{type:Boolean,default:!0},mode:{type:String,default:null,validator:t=>[null,"next","classic"].includes(t)}},emits:["update:modelValue","close","save"],setup(t,{emit:v}){const a=t,c=v,m=e.computed({get:()=>a.modelValue,set:d=>c("update:modelValue",d)}),i=e.ref(!0);e.onMounted(()=>{try{new URLSearchParams(window.location.search).get("rocketMode")==="false"?i.value=!1:i.value=!0}catch{i.value=!0}});const k=e.computed(()=>a.mode==="next"?x:a.mode==="classic"?I:i.value?x:I);return(d,r)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(k.value),{modelValue:m.value,"onUpdate:modelValue":r[0]||(r[0]=y=>m.value=y),title:t.title,subtitle:t.subtitle,"z-index":t.zIndex,"close-text":t.closeText,"close-on-esc":t.closeOnEsc,"has-buttons":!!d.$slots.buttons,onClose:r[1]||(r[1]=y=>d.$emit("close")),onSave:r[2]||(r[2]=y=>d.$emit("save"))},e.createSlots({default:e.withCtx(()=>[e.renderSlot(d.$slots,"default")]),_:2},[d.$slots.buttons?{name:"buttons",fn:e.withCtx(()=>[e.renderSlot(d.$slots,"buttons")]),key:"0"}:void 0]),1064,["modelValue","title","subtitle","z-index","close-text","close-on-esc","has-buttons"]))}},ue={props:{to:{type:String,default:"body"}}};function me(t,v,a,c,m,i){return e.openBlock(),e.createBlock(e.Teleport,{to:a.to},[e.renderSlot(t.$slots,"default")],8,["to"])}const T=B(ue,[["render",me]]),fe={class:"sky-modal-header"},ke=["title"],ye={width:"15",height:"15",viewBox:"0 0 451.847 451.847",style:{transform:"rotate(90deg)"}},ve={class:"sky-modal-title-wrapper"},pe={class:"sky-modal-title"},ge={key:0,class:"sky-modal-subtitle"},he={class:"sky-modal-body"},be={key:0,class:"sky-modal-footer"},we={__name:"Modal",props:{modelValue:{type:Boolean,default:!1},title:{type:String,default:""},subtitle:{type:String,default:""},closeTitle:{type:String,default:"Закрити"},closeOnOverlay:{type:Boolean,default:!0},closeOnEsc:{type:Boolean,default:!0},width:{type:String,default:"100%"},height:{type:String,default:"100%"}},emits:["update:modelValue","close"],setup(t,{emit:v}){const a=t,c=v,m=e.computed(()=>({width:a.width,height:a.height})),i=()=>{c("update:modelValue",!1),c("close")},k=()=>{a.closeOnOverlay&&i()},d=r=>{r.key==="Escape"&&a.closeOnEsc&&a.modelValue&&i()};return e.watch(()=>a.modelValue,r=>{r?document.body.style.overflow="hidden":document.body.style.overflow=""}),e.onMounted(()=>{document.addEventListener("keydown",d)}),e.onUnmounted(()=>{document.removeEventListener("keydown",d),document.body.style.overflow=""}),(r,y)=>(e.openBlock(),e.createBlock(T,{to:"body"},{default:e.withCtx(()=>[t.modelValue?(e.openBlock(),e.createElementBlock("div",{key:0,class:"sky-modal-overlay",onMousedown:e.withModifiers(k,["self"])},[e.createElementVNode("div",{class:"sky-modal",style:e.normalizeStyle(m.value)},[e.createElementVNode("div",fe,[e.createElementVNode("button",{class:"sky-modal-back",onClick:i,title:t.closeTitle},[(e.openBlock(),e.createElementBlock("svg",ye,[...y[0]||(y[0]=[e.createElementVNode("path",{fill:"currentColor",d:"M225.923,354.706c-8.098,0-16.195-3.092-22.369-9.263L9.27,151.157c-12.359-12.359-12.359-32.397,0-44.751c12.354-12.354,32.388-12.354,44.748,0l171.905,171.915l171.906-171.909c12.359-12.354,32.391-12.354,44.744,0c12.365,12.354,12.365,32.392,0,44.751L248.292,345.449C242.115,351.621,234.018,354.706,225.923,354.706z"},null,-1)])]))],8,ke),e.createElementVNode("div",ve,[e.createElementVNode("h4",pe,e.toDisplayString(t.title),1),t.subtitle?(e.openBlock(),e.createElementBlock("div",ge,e.toDisplayString(t.subtitle),1)):e.createCommentVNode("",!0)])]),e.createElementVNode("div",he,[e.renderSlot(r.$slots,"default",{},void 0,!0)]),r.$slots.footer?(e.openBlock(),e.createElementBlock("div",be,[y[1]||(y[1]=e.createElementVNode("div",null,null,-1)),e.renderSlot(r.$slots,"footer",{},void 0,!0),y[2]||(y[2]=e.createElementVNode("div",null,null,-1))])):e.createCommentVNode("",!0)],4)],32)):e.createCommentVNode("",!0)]),_:3}))}},Ee=B(we,[["__scopeId","data-v-e16b0dc3"]]),Be=["disabled"],Se={key:0,class:"sky-btn-spinner"},Ve={__name:"SkyButton",props:{variant:{type:String,default:"primary",validator:t=>["primary","danger","secondary","outline"].includes(t)},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},block:{type:Boolean,default:!1},icon:{type:Boolean,default:!1}},setup(t){return(v,a)=>(e.openBlock(),e.createElementBlock("button",e.mergeProps({class:["sky-btn",[`sky-btn-${t.variant}`,{"sky-btn-block":t.block,"sky-btn-loading":t.loading,"sky-btn-icon":t.icon}]],disabled:t.disabled||t.loading},v.$attrs),[t.loading?(e.openBlock(),e.createElementBlock("span",Se)):e.createCommentVNode("",!0),e.renderSlot(v.$slots,"default",{},void 0,!0)],16,Be))}},Ne=B(Ve,[["__scopeId","data-v-0d61fbfd"]]),Ce=["disabled"],$e={key:0,class:"sky-select-dropdown"},Ie=["onClick","onMouseenter"],xe={key:0,class:"sky-select-check",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},De={__name:"SkySelect",props:{modelValue:{default:null},options:{type:Array,default:()=>[]},placeholder:{type:String,default:""},disabled:{type:Boolean,default:!1},block:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:v}){const a=t,c=v,m=e.ref(null),i=e.ref(!1),k=e.ref(-1),d=e.computed(()=>a.options.map(s=>typeof s=="string"?{label:s,value:s}:s)),r=e.computed(()=>d.value.find(s=>s.value===a.modelValue)??null);function y(){a.disabled||(i.value?g():p())}function p(){i.value=!0,k.value=d.value.findIndex(s=>s.value===a.modelValue),document.addEventListener("mousedown",b)}function g(){i.value=!1,document.removeEventListener("mousedown",b)}function h(s){c("update:modelValue",s.value),g()}function b(s){var l;(l=m.value)!=null&&l.contains(s.target)||g()}function w(s){if(!i.value){(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),p());return}s.key==="Escape"?g():s.key==="ArrowDown"?(s.preventDefault(),k.value=Math.min(k.value+1,d.value.length-1)):s.key==="ArrowUp"?(s.preventDefault(),k.value=Math.max(k.value-1,0)):s.key==="Enter"&&(s.preventDefault(),k.value>=0&&h(d.value[k.value]))}return e.onBeforeUnmount(()=>{document.removeEventListener("mousedown",b)}),(s,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"root",ref:m,class:e.normalizeClass(["sky-select",{"sky-select-block":t.block,"sky-select-open":i.value,"sky-select-disabled":t.disabled}])},[e.createElementVNode("button",{type:"button",class:"sky-select-trigger",disabled:t.disabled,onClick:y,onKeydown:w},[e.createElementVNode("span",{class:e.normalizeClass(["sky-select-value",{"sky-select-placeholder":r.value===null}])},e.toDisplayString(r.value?r.value.label:t.placeholder),3),l[0]||(l[0]=e.createElementVNode("svg",{class:"sky-select-chevron",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M4 6l4 4 4-4",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1))],40,Ce),i.value?(e.openBlock(),e.createElementBlock("div",$e,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(f,S)=>(e.openBlock(),e.createElementBlock("div",{key:f.value,class:e.normalizeClass(["sky-select-option",{"sky-select-option-selected":f.value===t.modelValue,"sky-select-option-focused":S===k.value}]),onClick:V=>h(f),onMouseenter:V=>k.value=S},[e.createElementVNode("span",null,e.toDisplayString(f.label),1),f.value===t.modelValue?(e.openBlock(),e.createElementBlock("svg",xe,[...l[1]||(l[1]=[e.createElementVNode("path",{d:"M3 8l4 4 6-6",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):e.createCommentVNode("",!0)],42,Ie))),128))])):e.createCommentVNode("",!0)],2))}},Te=B(De,[["__scopeId","data-v-5ca23325"]]);exports.SkyserviceAPI=o.SkyserviceAPI;exports.exit=o.exit;exports.getBack=o.getBack;exports.getCompany=o.getCompany;exports.getLang=o.getLang;exports.getLocalStorageData=o.getLocalStorageData;exports.getProductCategories=o.getProductCategories;exports.getSenderId=o.getSenderId;exports.getStoreData=o.getStoreData;exports.getToken=o.getToken;exports.getUser=o.getUser;exports.getWindowData=o.getWindowData;exports.isAndroidWebview=o.isAndroidWebview;exports.isCefWebview=o.isCefWebview;exports.isInIframe=o.isInIframe;exports.isInsideIframe=o.isInsideIframe;exports.isIosWebview=o.isIosWebview;exports.isWebview=o.isWebview;exports.navigate=o.navigate;exports.notify=o.notify;exports.notifyError=o.notifyError;exports.notifyWarn=o.notifyWarn;exports.onMessage=o.onMessage;exports.openCrispChat=o.openCrispChat;exports.openExternalLink=o.openExternalLink;exports.setLocalStorage=o.setLocalStorage;exports.setRocketMode=o.setRocketMode;exports.setSenderId=o.setSenderId;exports.trackVisit=o.trackVisit;exports.webviewCheck=o.webviewCheck;exports.BaseTeleport=T;exports.Dialog=ce;exports.DialogModal=I;exports.DialogNext=x;exports.Header=J;exports.Modal=Ee;exports.SkyButton=Ne;exports.SkySelect=Te;
|
package/dist/vue-dev-kit.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ref as b, onUnmounted as P, computed as S, onMounted as D, openBlock as i, createElementBlock as r, createElementVNode as t, createCommentVNode as g, normalizeClass as E, renderSlot as x, toDisplayString as $, Fragment as G, renderList as Q, useSlots as Y, watch as F, nextTick as Z, createBlock as z, Teleport as U, normalizeStyle as W, createTextVNode as ee, resolveDynamicComponent as se, createSlots as ne, withCtx as X, withModifiers as ae, mergeProps as ie, onBeforeUnmount as de } from "vue";
|
|
2
|
-
import { A as ue, f as re, o as I, B as ce, c as _, y as fe, z as j, k as ye, r as H, e as ve, p as te, l as oe } from "./api-
|
|
3
|
-
import { S as bt, g as wt, a as $t, b as St, d as xt, h as Bt, i as Ct, j as Et, m as Vt, n as Tt, q as It, s as Lt, t as Mt, u as Pt, v as Dt, w as zt, x as Ot, C as At } from "./api-
|
|
2
|
+
import { A as ue, f as re, o as I, B as ce, c as _, y as fe, z as j, k as ye, r as H, e as ve, p as te, l as oe } from "./api-DlXvS7Ec.js";
|
|
3
|
+
import { S as bt, g as wt, a as $t, b as St, d as xt, h as Bt, i as Ct, j as Et, m as Vt, n as Tt, q as It, s as Lt, t as Mt, u as Pt, v as Dt, w as zt, x as Ot, C as At } from "./api-DlXvS7Ec.js";
|
|
4
4
|
import "ua-parser-js";
|
|
5
5
|
const L = (e, p) => {
|
|
6
6
|
const s = e.__vccOpts || e;
|
package/package.json
CHANGED
package/dist/api-BOvdjB3h.js
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import I from "ua-parser-js";
|
|
2
|
-
const l = "DASHBOARD", b = 5e3;
|
|
3
|
-
let S = 0, d = null;
|
|
4
|
-
function k() {
|
|
5
|
-
return `sdk_${Date.now()}_${++S}`;
|
|
6
|
-
}
|
|
7
|
-
function E() {
|
|
8
|
-
return "APP_" + Math.random().toString(36).slice(2, 10);
|
|
9
|
-
}
|
|
10
|
-
function T(e) {
|
|
11
|
-
d = e;
|
|
12
|
-
}
|
|
13
|
-
function m() {
|
|
14
|
-
return d || (d = E()), d;
|
|
15
|
-
}
|
|
16
|
-
function a(e) {
|
|
17
|
-
window.parent.postMessage(
|
|
18
|
-
{
|
|
19
|
-
...e,
|
|
20
|
-
sender: m(),
|
|
21
|
-
target: e.target || l
|
|
22
|
-
},
|
|
23
|
-
"*"
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
function w(e, t, r = b) {
|
|
27
|
-
return y() ? new Promise((n) => {
|
|
28
|
-
const o = k(), i = m(), c = setTimeout(() => {
|
|
29
|
-
window.removeEventListener("message", u), n(null);
|
|
30
|
-
}, r);
|
|
31
|
-
function u(v) {
|
|
32
|
-
const s = v.data;
|
|
33
|
-
(s == null ? void 0 : s.type) === "DATA_RESPONSE" && (s == null ? void 0 : s.requestId) === o && (!s.target || s.target === i) && (clearTimeout(c), window.removeEventListener("message", u), n(s.data ?? null));
|
|
34
|
-
}
|
|
35
|
-
window.addEventListener("message", u), a({ type: "DATA_REQUEST", requestId: o, source: e, key: t });
|
|
36
|
-
}) : Promise.resolve(null);
|
|
37
|
-
}
|
|
38
|
-
function D(e) {
|
|
39
|
-
a({ type: "navigate", path: e });
|
|
40
|
-
}
|
|
41
|
-
function A() {
|
|
42
|
-
a({ type: "exit" });
|
|
43
|
-
}
|
|
44
|
-
const q = A;
|
|
45
|
-
function g(e) {
|
|
46
|
-
return w("store", e);
|
|
47
|
-
}
|
|
48
|
-
function p(e) {
|
|
49
|
-
return w("localStorage", e);
|
|
50
|
-
}
|
|
51
|
-
function U(e) {
|
|
52
|
-
return w("window", e);
|
|
53
|
-
}
|
|
54
|
-
function R() {
|
|
55
|
-
return g("company");
|
|
56
|
-
}
|
|
57
|
-
function W() {
|
|
58
|
-
return g("user");
|
|
59
|
-
}
|
|
60
|
-
function $() {
|
|
61
|
-
return p("token");
|
|
62
|
-
}
|
|
63
|
-
function x() {
|
|
64
|
-
return p("lang");
|
|
65
|
-
}
|
|
66
|
-
function M() {
|
|
67
|
-
return g("productCategories");
|
|
68
|
-
}
|
|
69
|
-
function B(e, t) {
|
|
70
|
-
a({ type: "setLocalStorage", key: e, value: t });
|
|
71
|
-
}
|
|
72
|
-
function O(e) {
|
|
73
|
-
a({ type: "setRocketMode", value: e });
|
|
74
|
-
}
|
|
75
|
-
function j(e, t) {
|
|
76
|
-
a({ type: "trackVisit", name: e, path: t });
|
|
77
|
-
}
|
|
78
|
-
function N(e) {
|
|
79
|
-
a({ type: "openExternalLink", url: e });
|
|
80
|
-
}
|
|
81
|
-
function z() {
|
|
82
|
-
a({ type: "openCrispChat" });
|
|
83
|
-
}
|
|
84
|
-
function F(e) {
|
|
85
|
-
a({ type: "notification", text: e });
|
|
86
|
-
}
|
|
87
|
-
function G(e) {
|
|
88
|
-
a({ type: "notification", text: e, variant: "error" });
|
|
89
|
-
}
|
|
90
|
-
function H(e) {
|
|
91
|
-
a({ type: "notification", text: e, variant: "warn" });
|
|
92
|
-
}
|
|
93
|
-
function y() {
|
|
94
|
-
try {
|
|
95
|
-
return window.self !== window.top;
|
|
96
|
-
} catch {
|
|
97
|
-
return !0;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const Q = y;
|
|
101
|
-
function V(e) {
|
|
102
|
-
function t(r) {
|
|
103
|
-
var n;
|
|
104
|
-
((n = r.data) == null ? void 0 : n.sender) === l && e(r.data);
|
|
105
|
-
}
|
|
106
|
-
return window.addEventListener("message", t), () => window.removeEventListener("message", t);
|
|
107
|
-
}
|
|
108
|
-
function f() {
|
|
109
|
-
if (typeof window > "u") return "browser";
|
|
110
|
-
if (window.webkit != null && window.webkit.messageHandlers !== void 0)
|
|
111
|
-
try {
|
|
112
|
-
if (I(navigator.userAgent).browser.name === "WebKit") return "ios_webview";
|
|
113
|
-
} catch (e) {
|
|
114
|
-
console.error(e);
|
|
115
|
-
}
|
|
116
|
-
return typeof Android < "u" ? "android_webview" : typeof window.cefQuery < "u" ? "cef_webview" : "browser";
|
|
117
|
-
}
|
|
118
|
-
function K() {
|
|
119
|
-
return f() === "ios_webview";
|
|
120
|
-
}
|
|
121
|
-
function Y() {
|
|
122
|
-
return f() === "android_webview";
|
|
123
|
-
}
|
|
124
|
-
function J() {
|
|
125
|
-
return f() === "cef_webview";
|
|
126
|
-
}
|
|
127
|
-
function X() {
|
|
128
|
-
return f() !== "browser";
|
|
129
|
-
}
|
|
130
|
-
class Z {
|
|
131
|
-
constructor(t) {
|
|
132
|
-
this.token = t.token, this.companyId = t.companyId;
|
|
133
|
-
const r = t.domain.replace("dashboard", "api");
|
|
134
|
-
this.baseUrl = r.startsWith("http") ? r : `https://${r}`;
|
|
135
|
-
}
|
|
136
|
-
// --- Low-level ---
|
|
137
|
-
async request(t) {
|
|
138
|
-
const r = new URLSearchParams({
|
|
139
|
-
token: this.token,
|
|
140
|
-
...this.companyId ? { companyId: this.companyId } : {},
|
|
141
|
-
...t
|
|
142
|
-
}), n = await fetch(`${this.baseUrl}/?${r}`);
|
|
143
|
-
if (!n.ok)
|
|
144
|
-
throw new Error(`Skyservice API error: ${n.status}`);
|
|
145
|
-
const o = await n.json();
|
|
146
|
-
if (o.status !== "done")
|
|
147
|
-
throw new Error(`Skyservice API returned status: ${o.status}`);
|
|
148
|
-
return o.data;
|
|
149
|
-
}
|
|
150
|
-
// --- Tradepoints ---
|
|
151
|
-
/**
|
|
152
|
-
* Get all tradepoints for the current company.
|
|
153
|
-
* Filters out deleted and frozen by default.
|
|
154
|
-
*/
|
|
155
|
-
async getTradepoints(t) {
|
|
156
|
-
const r = await this.request({
|
|
157
|
-
section: "tradepoints",
|
|
158
|
-
action: "getTradepoints"
|
|
159
|
-
});
|
|
160
|
-
return t != null && t.includeDeleted ? r.items : r.items.filter((n) => !n.deleted && !n.frozen);
|
|
161
|
-
}
|
|
162
|
-
// --- Categories ---
|
|
163
|
-
/**
|
|
164
|
-
* Get the full category tree, cleaned from POS-specific bloat.
|
|
165
|
-
*
|
|
166
|
-
* Returns only fields relevant for menu building:
|
|
167
|
-
* `id`, `pid`, `name`, `active`, `background`, `show`, `img`, `children`.
|
|
168
|
-
*
|
|
169
|
-
* If `tradepointId` is provided, filters to categories visible for that tradepoint.
|
|
170
|
-
*/
|
|
171
|
-
async getCategoryTree(t) {
|
|
172
|
-
const r = await this.request({
|
|
173
|
-
section: "productCategory",
|
|
174
|
-
action: "getCategories",
|
|
175
|
-
...t ? { tradepointId: String(t) } : {}
|
|
176
|
-
});
|
|
177
|
-
return h(r, t);
|
|
178
|
-
}
|
|
179
|
-
// --- Products ---
|
|
180
|
-
/**
|
|
181
|
-
* Get products, cleaned from POS-specific fields.
|
|
182
|
-
*
|
|
183
|
-
* Filters out ingredients by default — returns only sellable items
|
|
184
|
-
* (type `product` or `techcard`).
|
|
185
|
-
*
|
|
186
|
-
* If `tradepointId` is provided, scopes to that tradepoint.
|
|
187
|
-
*/
|
|
188
|
-
async getProducts(t) {
|
|
189
|
-
const r = await this.request({
|
|
190
|
-
section: "products",
|
|
191
|
-
action: "getProducts",
|
|
192
|
-
pagelimit: "9999",
|
|
193
|
-
ot: "desc",
|
|
194
|
-
of: "nomenclatureId",
|
|
195
|
-
...t != null && t.tradepointId ? { tradepointId: String(t.tradepointId) } : {}
|
|
196
|
-
});
|
|
197
|
-
return _(r.items, t == null ? void 0 : t.includeInactive);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
function h(e, t) {
|
|
201
|
-
var n, o;
|
|
202
|
-
const r = [];
|
|
203
|
-
for (const i of e) {
|
|
204
|
-
if (t != null && !((n = i.tradepointShow) == null ? void 0 : n[String(t)]))
|
|
205
|
-
continue;
|
|
206
|
-
const c = {
|
|
207
|
-
id: i.id,
|
|
208
|
-
pid: i.pid,
|
|
209
|
-
name: i.name,
|
|
210
|
-
active: i.active,
|
|
211
|
-
background: i.background,
|
|
212
|
-
show: i.show
|
|
213
|
-
};
|
|
214
|
-
i.img && (c.img = i.img), (o = i.children) != null && o.length && (c.children = h(i.children, t)), r.push(c);
|
|
215
|
-
}
|
|
216
|
-
return r;
|
|
217
|
-
}
|
|
218
|
-
const L = /* @__PURE__ */ new Set(["product", "techcard"]), P = "/img/no.png";
|
|
219
|
-
function _(e, t) {
|
|
220
|
-
const r = [];
|
|
221
|
-
for (const n of e)
|
|
222
|
-
L.has(n.type) && (!t && !n.active || r.push({
|
|
223
|
-
id: n.id,
|
|
224
|
-
name: n.nomenclatureName,
|
|
225
|
-
price: n.price,
|
|
226
|
-
categoryId: n.categoryId,
|
|
227
|
-
categoryName: n.categoryTitle || "",
|
|
228
|
-
active: n.active,
|
|
229
|
-
type: n.type,
|
|
230
|
-
unit: n.unit,
|
|
231
|
-
logo: n.logo && n.logo !== P ? n.logo : ""
|
|
232
|
-
}));
|
|
233
|
-
return r;
|
|
234
|
-
}
|
|
235
|
-
export {
|
|
236
|
-
T as A,
|
|
237
|
-
j as B,
|
|
238
|
-
f as C,
|
|
239
|
-
Z as S,
|
|
240
|
-
R as a,
|
|
241
|
-
x as b,
|
|
242
|
-
p as c,
|
|
243
|
-
M as d,
|
|
244
|
-
A as e,
|
|
245
|
-
m as f,
|
|
246
|
-
q as g,
|
|
247
|
-
g as h,
|
|
248
|
-
$ as i,
|
|
249
|
-
W as j,
|
|
250
|
-
U as k,
|
|
251
|
-
Y as l,
|
|
252
|
-
J as m,
|
|
253
|
-
Q as n,
|
|
254
|
-
y as o,
|
|
255
|
-
K as p,
|
|
256
|
-
X as q,
|
|
257
|
-
D as r,
|
|
258
|
-
F as s,
|
|
259
|
-
G as t,
|
|
260
|
-
H as u,
|
|
261
|
-
V as v,
|
|
262
|
-
z as w,
|
|
263
|
-
N as x,
|
|
264
|
-
B as y,
|
|
265
|
-
O as z
|
|
266
|
-
};
|
package/dist/api-D5C6FvTr.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const b=require("ua-parser-js"),m="DASHBOARD",k=5e3;let S=0,f=null;function E(){return`sdk_${Date.now()}_${++S}`}function L(){return"APP_"+Math.random().toString(36).slice(2,10)}function A(e){f=e}function w(){return f||(f=L()),f}function o(e){window.parent.postMessage({...e,sender:w(),target:e.target||m},"*")}function l(e,t,r=k){return p()?new Promise(n=>{const a=E(),i=w(),c=setTimeout(()=>{window.removeEventListener("message",d),n(null)},r);function d(I){const s=I.data;(s==null?void 0:s.type)==="DATA_RESPONSE"&&(s==null?void 0:s.requestId)===a&&(!s.target||s.target===i)&&(clearTimeout(c),window.removeEventListener("message",d),n(s.data??null))}window.addEventListener("message",d),o({type:"DATA_REQUEST",requestId:a,source:e,key:t})}):Promise.resolve(null)}function C(e){o({type:"navigate",path:e})}function v(){o({type:"exit"})}const P=v;function g(e){return l("store",e)}function y(e){return l("localStorage",e)}function D(e){return l("window",e)}function T(){return g("company")}function _(){return g("user")}function W(){return y("token")}function q(){return y("lang")}function U(){return g("productCategories")}function R(e,t){o({type:"setLocalStorage",key:e,value:t})}function M(e){o({type:"setRocketMode",value:e})}function $(e,t){o({type:"trackVisit",name:e,path:t})}function x(e){o({type:"openExternalLink",url:e})}function B(){o({type:"openCrispChat"})}function O(e){o({type:"notification",text:e})}function N(e){o({type:"notification",text:e,variant:"error"})}function V(e){o({type:"notification",text:e,variant:"warn"})}function p(){try{return window.self!==window.top}catch{return!0}}const j=p;function F(e){function t(r){var n;((n=r.data)==null?void 0:n.sender)===m&&e(r.data)}return window.addEventListener("message",t),()=>window.removeEventListener("message",t)}function u(){if(typeof window>"u")return"browser";if(window.webkit!=null&&window.webkit.messageHandlers!==void 0)try{if(b(navigator.userAgent).browser.name==="WebKit")return"ios_webview"}catch(e){console.error(e)}return typeof Android<"u"?"android_webview":typeof window.cefQuery<"u"?"cef_webview":"browser"}function G(){return u()==="ios_webview"}function H(){return u()==="android_webview"}function Q(){return u()==="cef_webview"}function z(){return u()!=="browser"}class K{constructor(t){this.token=t.token,this.companyId=t.companyId;const r=t.domain.replace("dashboard","api");this.baseUrl=r.startsWith("http")?r:`https://${r}`}async request(t){const r=new URLSearchParams({token:this.token,...this.companyId?{companyId:this.companyId}:{},...t}),n=await fetch(`${this.baseUrl}/?${r}`);if(!n.ok)throw new Error(`Skyservice API error: ${n.status}`);const a=await n.json();if(a.status!=="done")throw new Error(`Skyservice API returned status: ${a.status}`);return a.data}async getTradepoints(t){const r=await this.request({section:"tradepoints",action:"getTradepoints"});return t!=null&&t.includeDeleted?r.items:r.items.filter(n=>!n.deleted&&!n.frozen)}async getCategoryTree(t){const r=await this.request({section:"productCategory",action:"getCategories",...t?{tradepointId:String(t)}:{}});return h(r,t)}async getProducts(t){const r=await this.request({section:"products",action:"getProducts",pagelimit:"9999",ot:"desc",of:"nomenclatureId",...t!=null&&t.tradepointId?{tradepointId:String(t.tradepointId)}:{}});return X(r.items,t==null?void 0:t.includeInactive)}}function h(e,t){var n,a;const r=[];for(const i of e){if(t!=null&&!((n=i.tradepointShow)==null?void 0:n[String(t)]))continue;const c={id:i.id,pid:i.pid,name:i.name,active:i.active,background:i.background,show:i.show};i.img&&(c.img=i.img),(a=i.children)!=null&&a.length&&(c.children=h(i.children,t)),r.push(c)}return r}const Y=new Set(["product","techcard"]),J="/img/no.png";function X(e,t){const r=[];for(const n of e)Y.has(n.type)&&(!t&&!n.active||r.push({id:n.id,name:n.nomenclatureName,price:n.price,categoryId:n.categoryId,categoryName:n.categoryTitle||"",active:n.active,type:n.type,unit:n.unit,logo:n.logo&&n.logo!==J?n.logo:""}));return r}exports.SkyserviceAPI=K;exports.exit=v;exports.getBack=P;exports.getCompany=T;exports.getLang=q;exports.getLocalStorageData=y;exports.getProductCategories=U;exports.getSenderId=w;exports.getStoreData=g;exports.getToken=W;exports.getUser=_;exports.getWindowData=D;exports.isAndroidWebview=H;exports.isCefWebview=Q;exports.isInIframe=j;exports.isInsideIframe=p;exports.isIosWebview=G;exports.isWebview=z;exports.navigate=C;exports.notify=O;exports.notifyError=N;exports.notifyWarn=V;exports.onMessage=F;exports.openCrispChat=B;exports.openExternalLink=x;exports.setLocalStorage=R;exports.setRocketMode=M;exports.setSenderId=A;exports.trackVisit=$;exports.webviewCheck=u;
|