@fewangsit/wangsvue-fats 1.0.1-alpha.62 → 1.0.1-alpha.64

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.
@@ -36,6 +36,10 @@ export interface TreeNode {
36
36
  * Mandatory unique key of the node.
37
37
  */
38
38
  key: string | number;
39
+ /**
40
+ * The API response might give id instead of key, in which case it needs to be assigned to the key
41
+ */
42
+ _id?: string | number;
39
43
  /**
40
44
  * Label of the node.
41
45
  */
@@ -300,9 +304,9 @@ export interface TreeContext {
300
304
  * Defines valid properties in Tree component.
301
305
  */
302
306
  export interface BaseTreeProps {
303
- disableKeys?: number[];
307
+ disableKeys?: string[] | number[];
304
308
  disableNodeAll?: boolean;
305
- exactDisableKeys?: number[];
309
+ exactDisableKeys?: string[] | number[];
306
310
  level?: number;
307
311
  /**
308
312
  * List of labels that has no menu option
@@ -135,7 +135,7 @@ const Y = ["id"], Z = ["aria-label", "aria-labelledby"], te = /* @__PURE__ */ V(
135
135
  class: [...(k = (K = l.pt ?? u(c)) == null ? void 0 : K.node) == null ? void 0 : k.class],
136
136
  "disable-keys": e.disableKeys,
137
137
  "disable-node-all": l.disableNodeAll,
138
- disabled: (M = e.disableKeys) == null ? void 0 : M.includes(+r.key),
138
+ disabled: (M = e.disableKeys) == null ? void 0 : M.includes(r.key),
139
139
  "exact-disable-keys": e.exactDisableKeys,
140
140
  "expanded-keys": d.value,
141
141
  index: T,
@@ -1,62 +1,62 @@
1
- import { AxiosError as ye } from "axios";
2
- import { ref as re, defineComponent as Re, onBeforeUnmount as _e, shallowRef as v, computed as E, createElementBlock as D, openBlock as u, Fragment as F, createVNode as b, createBlock as M, createCommentVNode as U, mergeProps as De, withCtx as ke, createElementVNode as C, normalizeClass as ee, createTextVNode as se, toDisplayString as j, Teleport as Ne } from "vue";
3
- import { ChangelogServices as he } from "@tagsamurai/fats-api-services";
1
+ import { AxiosError as Re } from "axios";
2
+ import { ref as ce, defineComponent as _e, onBeforeUnmount as De, shallowRef as m, computed as E, createElementBlock as D, openBlock as d, Fragment as F, createVNode as b, createBlock as U, createCommentVNode as V, mergeProps as Ne, withCtx as ke, createElementVNode as O, normalizeClass as se, createTextVNode as ne, toDisplayString as A, Teleport as he } from "vue";
3
+ import { ChangelogServices as Ce } from "@tagsamurai/fats-api-services";
4
4
  import { u as Ie } from "../utils/baseToast.util.es.js";
5
- import { _ as ne } from "../button/index.es.js";
5
+ import { _ as oe } from "../button/index.es.js";
6
6
  import { _ as Ee } from "../dialogconfirm/index.es.js";
7
- import { _ as Ce } from "../hardwaresync/index.es.js";
8
- import { _ as A } from "../icon/index.es.js";
7
+ import { _ as Oe } from "../hardwaresync/index.es.js";
8
+ import { _ as J } from "../icon/index.es.js";
9
9
  import { _ as z } from "../toast/index.es.js";
10
- import { v as J } from "../vendor/uuid/dist/esm-browser/v4.es.js";
11
- const Oe = (a) => {
12
- if (a instanceof ye)
13
- return a.response ? "DEVICE_NOT_CONNECTED" : "DRIVER_NOT_FOUND";
14
- if (a instanceof Error && ["NOT_SUPPORTED_SYSTEM", "HARDWARE_NOT_SYNCHRONIZED"].includes(
15
- a.message
10
+ import { v as G } from "../vendor/uuid/dist/esm-browser/v4.es.js";
11
+ const Te = (t) => {
12
+ if (t instanceof Re)
13
+ return t.response ? "DEVICE_NOT_CONNECTED" : "DRIVER_NOT_FOUND";
14
+ if (t instanceof Error && ["NOT_SUPPORTED_SYSTEM", "HARDWARE_NOT_SYNCHRONIZED"].includes(
15
+ t.message
16
16
  ))
17
- return a.message;
18
- }, ce = `(function(){"use strict";let n=null,t=null,a;self.onmessage=s=>{const e=s.data;switch(e.command){case"sync":u(e);break;case"connect":l(e);break;case"scan":m(e);break;case"stopscan":d(e);break}};const r=s=>{let e="established";n&&n.readyState===WebSocket.OPEN?(e="reused",s.onopen(n,e),i(s.timeout)):n=new WebSocket("wss://dev-api.tagsamurai.com/rfid-reader-go/"),n.onopen=()=>{e="established",n&&s.onopen(n,e),i(s.timeout)},n.onmessage=o=>{s.onmessage(o),i(s.timeout)},n.onerror=o=>{console.error("🚀 ~ Scanner Worker: openConnection ~ error:",o),s.onerror(o),n==null||n.close(),n=null,t&&clearTimeout(t)}},p=()=>{d({userId:a}),a=void 0,n&&n.close(),n=null,t&&clearTimeout(t),console.info("Socket connection has been closed!")},i=(s=0)=>{s&&(t&&clearTimeout(t),t=setTimeout(p,s))},u=({userId:s})=>{a=s,r({onopen:e=>{e.send(JSON.stringify({data:{command:"connect",userId:s,source:"app"},event:"reader"}))},onmessage:e=>{postMessage({status:"synced",...JSON.parse(e.data)})},onerror:e=>{postMessage({status:"sync_error",error:e})}})},l=({userId:s})=>{a=s,r({onopen:(e,o)=>{o==="established"?e.send(JSON.stringify({data:{command:"connect",userId:s,source:"app"},event:"reader"})):postMessage({status:"connection_reused"})},onmessage:e=>{postMessage({status:"connection_established",...JSON.parse(e.data)})},onerror:e=>{postMessage({status:"error_connecting",error:e})}})},m=({scanCommand:s,userId:e,serialNumber:o,jenisDevice:g})=>{a=e,r({onopen:c=>{c.send(JSON.stringify({data:{command:s,userId:e,source:"app",serialNumber:o,jenisDevice:g},event:"reader"})),postMessage({status:"scan_started"})},onmessage:c=>{postMessage({status:"scanned",...JSON.parse(c.data)})},onerror:c=>{postMessage({status:"scan_error",error:c})}})},d=({userId:s})=>{n&&n.readyState===WebSocket.OPEN&&(n.send(JSON.stringify({data:{command:"stopscan",userId:s,source:"app"},event:"reader"})),postMessage({status:"scan_stopped"}),console.info("Scan Process Stopped!"))}})();
19
- `, te = typeof self < "u" && self.Blob && new Blob([ce], { type: "text/javascript;charset=utf-8" });
20
- function Te(a) {
21
- let l;
17
+ return t.message;
18
+ }, ie = `(function(){"use strict";let n=null,t=null,a,c,r="";self.onmessage=s=>{const e=s.data;switch(c=e.companyCode,e.command){case"sync":l(e);break;case"connect":g(e);break;case"scan":S(e);break;case"stopscan":p(e);break}};const d=s=>{let e="established";n&&n.readyState===WebSocket.OPEN?(e="reused",s.onopen(n,e),m(s.timeout)):n=new WebSocket("wss://dev-api.tagsamurai.com/rfid-reader-go/"),n.onopen=()=>{r=Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15),e="established",n&&s.onopen(n,e),m(s.timeout)},n.onmessage=o=>{s.onmessage(o),m(s.timeout)},n.onerror=o=>{console.error("🚀 ~ Scanner Worker: openConnection ~ error:",o),s.onerror(o),n==null||n.close(),n=null,t&&clearTimeout(t)}},u=()=>{p({userId:a}),a=void 0,n&&n.close(),n=null,t&&clearTimeout(t),console.info("Socket connection has been closed!")},m=(s=0)=>{s&&(t&&clearTimeout(t),t=setTimeout(u,s))},l=({userId:s})=>{a=s,d({onopen:e=>{e.send(JSON.stringify({data:{command:"connect",userId:s,sessionId:r,companyCode:c,source:"app"},event:"reader"}))},onmessage:e=>{postMessage({status:"synced",...JSON.parse(e.data)})},onerror:e=>{postMessage({status:"sync_error",error:e})}})},g=({userId:s})=>{a=s,d({onopen:(e,o)=>{o==="established"?e.send(JSON.stringify({data:{command:"connect",userId:s,source:"app",sessionId:r,companyCode:c},event:"reader"})):postMessage({status:"connection_reused"})},onmessage:e=>{postMessage({status:"connection_established",...JSON.parse(e.data)})},onerror:e=>{postMessage({status:"error_connecting",error:e})}})},S=({scanCommand:s,userId:e,serialNumber:o,jenisDevice:f})=>{a=e,d({onopen:i=>{i.send(JSON.stringify({data:{command:s,userId:e,sessionId:r,companyCode:c,source:"app",serialNumber:o,jenisDevice:f},event:"reader"})),postMessage({status:"scan_started"})},onmessage:i=>{postMessage({status:"scanned",...JSON.parse(i.data)})},onerror:i=>{postMessage({status:"scan_error",error:i})}})},p=({userId:s})=>{n&&n.readyState===WebSocket.OPEN&&(n.send(JSON.stringify({data:{command:"stopscan",userId:s,source:"app",sessionId:r,companyCode:c},event:"reader"})),postMessage({status:"scan_stopped"}),console.info("Scan Process Stopped!"))}})();
19
+ `, ae = typeof self < "u" && self.Blob && new Blob([ie], { type: "text/javascript;charset=utf-8" });
20
+ function xe(t) {
21
+ let u;
22
22
  try {
23
- if (l = te && (self.URL || self.webkitURL).createObjectURL(te), !l) throw "";
24
- const m = new Worker(l, {
25
- name: a == null ? void 0 : a.name
23
+ if (u = ae && (self.URL || self.webkitURL).createObjectURL(ae), !u) throw "";
24
+ const p = new Worker(u, {
25
+ name: t == null ? void 0 : t.name
26
26
  });
27
- return m.addEventListener("error", () => {
28
- (self.URL || self.webkitURL).revokeObjectURL(l);
29
- }), m;
27
+ return p.addEventListener("error", () => {
28
+ (self.URL || self.webkitURL).revokeObjectURL(u);
29
+ }), p;
30
30
  } catch {
31
31
  return new Worker(
32
- "data:text/javascript;charset=utf-8," + encodeURIComponent(ce),
32
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(ie),
33
33
  {
34
- name: a == null ? void 0 : a.name
34
+ name: t == null ? void 0 : t.name
35
35
  }
36
36
  );
37
37
  } finally {
38
- l && (self.URL || self.webkitURL).revokeObjectURL(l);
38
+ u && (self.URL || self.webkitURL).revokeObjectURL(u);
39
39
  }
40
40
  }
41
- const ie = () => window.devices ?? [], xe = () => window.device ?? { RFID: null, QR: null }, oe = re(ie()), ae = re(xe()), Be = () => {
42
- const a = (s) => {
43
- window.devices = s, m();
44
- }, l = (s) => {
45
- window.device = s, ae.value = s;
46
- }, m = () => {
47
- oe.value = ie();
41
+ const le = () => window.devices ?? [], Be = () => window.device ?? { RFID: null, QR: null }, te = ce(le()), re = ce(Be()), Le = () => {
42
+ const t = (s) => {
43
+ window.devices = s, p();
44
+ }, u = (s) => {
45
+ window.device = s, re.value = s;
46
+ }, p = () => {
47
+ te.value = le();
48
48
  };
49
49
  return {
50
- devices: oe,
51
- device: ae,
52
- saveDevices: a,
53
- setDevice: l,
54
- loadDevices: m
50
+ devices: te,
51
+ device: re,
52
+ saveDevices: t,
53
+ setDevice: u,
54
+ loadDevices: p
55
55
  };
56
- }, Le = { class: "flex gap-2 items-center" }, We = { class: "flex gap-0.5 items-center leading-4" }, Fe = { class: "flex gap-5 items-center" }, Me = {
56
+ }, Me = { class: "flex gap-2 items-center" }, We = { class: "flex gap-0.5 items-center leading-4" }, Fe = { class: "flex gap-5 items-center" }, Ue = {
57
57
  key: 1,
58
58
  class: "text-xs font-medium leading-[16.39px] tracking-[0.02em]"
59
- }, He = /* @__PURE__ */ Re({
59
+ }, qe = /* @__PURE__ */ _e({
60
60
  __name: "ButtonScan",
61
61
  props: {
62
62
  label: {},
@@ -91,218 +91,221 @@ const ie = () => window.devices ?? [], xe = () => window.device ?? { RFID: null,
91
91
  plain: { type: Boolean }
92
92
  },
93
93
  emits: ["update:modelValue", "connect", "connected", "scan", "stop", "error", "beforeStartScan"],
94
- setup(a, { expose: l, emit: m }) {
95
- const s = a, r = m;
96
- _e(() => {
97
- X();
94
+ setup(t, { expose: u, emit: p }) {
95
+ const s = t, c = p;
96
+ De(() => {
97
+ ee();
98
98
  });
99
- const c = Ie(), { devices: le, device: S, saveDevices: ue, setDevice: G } = Be(), w = v(!1), O = v(!1), k = v(!1), N = v(!1), y = v(!1), V = v(!1), f = v(), H = v(0), o = v(s.type ?? "RFID"), P = [], T = E(
100
- () => o.value === "RFID" ? "RFID_Scanning" : "QR_Scanning"
101
- ), g = E(
102
- () => o.value === "RFID" ? "RFID_Connecting" : "QR_Connecting"
99
+ const i = Ie(), { devices: ue, device: y, saveDevices: de, setDevice: H } = Le(), w = m(!1), T = m(!1), N = m(!1), k = m(!1), R = m(!1), P = m(!1), g = m(), q = m(0), a = m(s.type ?? "RFID"), Q = [], x = E(
100
+ () => a.value === "RFID" ? "RFID_Scanning" : "QR_Scanning"
101
+ ), S = E(
102
+ () => a.value === "RFID" ? "RFID_Connecting" : "QR_Connecting"
103
103
  );
104
- E(() => `The scanner could not identify the ${o.value} code. It may be damaged or improperly positioned. Please check the code and try again.`);
105
- const de = () => {
106
- window.scannerWorker ?? (window.scannerWorker = new Te());
107
- }, x = () => {
108
- const { serialNumber: e = "" } = S.value[o.value] ?? {};
104
+ E(() => `The scanner could not identify the ${a.value} code. It may be damaged or improperly positioned. Please check the code and try again.`);
105
+ const ve = () => {
106
+ window.scannerWorker ?? (window.scannerWorker = new xe());
107
+ }, B = () => {
108
+ const { serialNumber: e = "" } = y.value[a.value] ?? {};
109
109
  return e;
110
- }, q = async () => {
110
+ }, Y = async () => {
111
111
  try {
112
- de(), await ve(), w.value = !0;
112
+ ve(), await me(), w.value = !0;
113
113
  } catch (e) {
114
114
  console.error(e), w.value = !1;
115
115
  }
116
- }, ve = async () => {
117
- var e;
116
+ }, me = async () => {
117
+ var e, o;
118
118
  try {
119
- if (!ge())
119
+ if (!Se())
120
120
  throw new Error("NOT_SUPPORTED_SYSTEM");
121
- if (r("connect"), !le.value.length || !S.value[o.value])
121
+ if (c("connect"), !ue.value.length || !y.value[a.value])
122
122
  throw new Error("HARDWARE_NOT_SYNCHRONIZED");
123
- c.add({
123
+ i.add({
124
124
  customMessage: !0,
125
- message: o.value === "QR" ? "Connecting QR Scanner..." : "Connecting RFID Scanner...",
125
+ message: a.value === "QR" ? "Connecting QR Scanner..." : "Connecting RFID Scanner...",
126
126
  severity: "info",
127
127
  life: 0,
128
- group: g.value
129
- }), k.value = !0;
130
- const t = () => {
131
- r("connected", S.value[o.value]), setTimeout(() => {
132
- Q();
128
+ group: S.value
129
+ }), N.value = !0;
130
+ const n = () => {
131
+ c("connected", y.value[a.value]), setTimeout(() => {
132
+ $();
133
133
  }, 0);
134
134
  };
135
- window.scannerWorker.onmessage = ({ data: n }) => {
136
- var R;
137
- if (n.status === "connection_established")
135
+ window.scannerWorker.onmessage = ({ data: r }) => {
136
+ var I;
137
+ if (r.status === "connection_established")
138
138
  try {
139
- const { error: p } = (n == null ? void 0 : n.data) ?? {}, i = ((R = n == null ? void 0 : n.data) == null ? void 0 : R.deviceList) ?? [], _ = S.value[s.type], d = i.some(
139
+ const { error: f } = (r == null ? void 0 : r.data) ?? {}, l = ((I = r == null ? void 0 : r.data) == null ? void 0 : I.deviceList) ?? [], _ = y.value[s.type], v = l.some(
140
140
  (W) => W.serialNumber === (_ == null ? void 0 : _.serialNumber)
141
141
  );
142
- if (i.length && d)
143
- t();
142
+ if (l.length && v)
143
+ n();
144
144
  else {
145
- if (p === "Driver not connected to server")
145
+ if (f === "Driver not connected to server")
146
146
  throw new Error("DRIVER_NOT_FOUND");
147
- if (!i.length)
147
+ if (!l.length)
148
148
  throw new Error("DEVICE_NOT_CONNECTED");
149
149
  }
150
- c.removeGroup(g.value);
151
- } catch (p) {
152
- Y(p);
150
+ i.removeGroup(S.value);
151
+ } catch (f) {
152
+ Z(f);
153
153
  }
154
- else n.status === "connection_reused" ? t() : n.status === "error_connecting" && (c.removeGroup(g.value), c.add({
154
+ else r.status === "connection_reused" ? n() : r.status === "error_connecting" && (i.removeGroup(S.value), i.add({
155
155
  customMessage: !0,
156
156
  message: "Scanner connection failed",
157
157
  severity: "error"
158
158
  }));
159
159
  }, window.scannerWorker.postMessage({
160
160
  command: "connect",
161
- userId: (e = JSON.parse(localStorage.getItem("user") ?? "{}")) == null ? void 0 : e._id
161
+ userId: (e = JSON.parse(localStorage.getItem("user") ?? "{}")) == null ? void 0 : e._id,
162
+ companyCode: (o = JSON.parse(localStorage.getItem("user") ?? "{}")) == null ? void 0 : o.companyCode
162
163
  });
163
- } catch (t) {
164
- Y(t);
164
+ } catch (n) {
165
+ Z(n);
165
166
  }
166
- }, Q = (e = !1, t = !1) => {
167
- var R;
168
- V.value = !1, c.removeGroup(g.value), localStorage.devmode || (window.addEventListener("blur", L), window.addEventListener("beforeunload", L));
169
- const n = S.value[o.value];
167
+ }, $ = (e = !1, o = !1) => {
168
+ var r, I;
169
+ P.value = !1, i.removeGroup(S.value), localStorage.devmode || (window.addEventListener("blur", M), window.addEventListener("beforeunload", M));
170
+ const n = y.value[a.value];
170
171
  if (n) {
171
- let p = "";
172
- s.bulk ? p = `bulkscan-${o.value.toLowerCase()}` : p = `scan-${o.value.toLowerCase()}`, window.scannerWorker.onmessage = async ({ data: i }) => {
172
+ let f = "";
173
+ s.bulk ? f = `bulkscan-${a.value.toLowerCase()}` : f = `scan-${a.value.toLowerCase()}`, window.scannerWorker.onmessage = async ({ data: l }) => {
173
174
  var _;
174
- if (i.status === "scan_started")
175
- t || (H.value++, setTimeout(() => {
176
- c.add({
175
+ if (l.status === "scan_started")
176
+ o || (q.value++, setTimeout(() => {
177
+ i.add({
177
178
  customMessage: !0,
178
179
  message: "scanning",
179
180
  severity: "info",
180
181
  life: 0,
181
- group: T.value
182
+ group: x.value
182
183
  });
183
184
  }, 0));
184
- else if (i.status === "scanned") {
185
- const { code: d, error: W, deviceList: we } = (i == null ? void 0 : i.data) ?? {};
186
- if (W) return me(W, we);
187
- if (d) {
188
- if (["scan-rfid", "scan-qr"].includes(p)) {
189
- y.value = !!s.scanValidation;
190
- const $ = await ((_ = s.scanValidation) == null ? void 0 : _.call(
185
+ else if (l.status === "scanned") {
186
+ const { code: v, error: W, deviceList: we } = (l == null ? void 0 : l.data) ?? {};
187
+ if (W) return pe(W, we);
188
+ if (v) {
189
+ if (["scan-rfid", "scan-qr"].includes(f)) {
190
+ R.value = !!s.scanValidation;
191
+ const j = await ((_ = s.scanValidation) == null ? void 0 : _.call(
191
192
  s,
192
- o.value,
193
- d,
194
- x()
193
+ a.value,
194
+ v,
195
+ B()
195
196
  )) ?? !0;
196
- if (y.value = !1, $)
197
- s.autoSwitch ? (K(), fe()) : h(!0);
197
+ if (R.value = !1, j)
198
+ s.autoSwitch ? (X(), ge()) : h(!0);
198
199
  else {
199
- V.value || Q(!1, !0);
200
+ P.value || $(!1, !0);
200
201
  return;
201
202
  }
202
203
  }
203
- if (!P.includes(d)) {
204
+ if (!Q.includes(v)) {
204
205
  try {
205
- he.postScanLog({
206
- tag: d,
207
- serialNumber: x()
206
+ Ce.postScanLog({
207
+ tag: v,
208
+ serialNumber: B()
208
209
  });
209
- } catch ($) {
210
- console.error($);
210
+ } catch (j) {
211
+ console.error(j);
211
212
  }
212
- r("update:modelValue", d), r("scan", d, x()), s.bulk && P.push(d);
213
+ c("update:modelValue", v), c("scan", v, B()), s.bulk && Q.push(v);
213
214
  }
214
215
  }
215
- } else i.status === "scan_stopped" ? h(!0) : i.status === "scan_error" && Z(i.error);
216
- }, window.scannerWorker.onerror = Z, window.scannerWorker.postMessage({
216
+ } else l.status === "scan_stopped" ? h(!0) : l.status === "scan_error" && K(l.error);
217
+ }, window.scannerWorker.onerror = K, window.scannerWorker.postMessage({
217
218
  command: "scan",
218
- scanCommand: p,
219
- userId: (R = JSON.parse(localStorage.getItem("user") ?? "{}")) == null ? void 0 : R._id,
219
+ scanCommand: f,
220
+ userId: (r = JSON.parse(localStorage.getItem("user") ?? "{}")) == null ? void 0 : r._id,
221
+ companyCode: (I = JSON.parse(localStorage.getItem("user") ?? "{}")) == null ? void 0 : I.companyCode,
220
222
  source: "app",
221
223
  jenisDevice: n.jenisDevice,
222
224
  serialNumber: n.serialNumber,
223
225
  newConnection: e
224
226
  });
225
227
  }
226
- }, Y = (e) => {
227
- G({ RFID: void 0, QR: void 0 }), N.value = !0, f.value = e instanceof Error ? e.message : Oe(e), k.value = !1, r("error", e), c.removeGroup(g.value);
228
- }, me = (e, t = []) => {
228
+ }, Z = (e) => {
229
+ H({ RFID: void 0, QR: void 0 }), k.value = !0, g.value = e instanceof Error ? e.message : Te(e), N.value = !1, c("error", e), i.removeGroup(S.value);
230
+ }, pe = (e, o = []) => {
229
231
  let n = "";
230
- f.value = void 0, I(!0), e === "Time out" ? n = "The scanning process has timed out. Please try again." : e === "Driver not connected to server" ? f.value = "DRIVER_NOT_FOUND" : e === "Device disconnected" && (f.value = "DEVICE_DISCONNECTED", ue(t), G({ RFID: void 0, QR: void 0 })), r("error", e), N.value = !!f.value, n && c.add({
232
+ g.value = void 0, C(!0), e === "Time out" ? n = "The scanning process has timed out. Please try again." : e === "Driver not connected to server" ? g.value = "DRIVER_NOT_FOUND" : e === "Device disconnected" && (g.value = "DEVICE_DISCONNECTED", de(o), H({ RFID: void 0, QR: void 0 })), c("error", e), k.value = !!g.value, n && i.add({
231
233
  customMessage: !0,
232
234
  message: n,
233
235
  error: e,
234
236
  life: 6e3,
235
- group: T.value
237
+ group: x.value
236
238
  });
237
- }, Z = (e) => {
238
- I(!0), r("error", e), c.add({
239
+ }, K = (e) => {
240
+ C(!0), c("error", e), i.add({
239
241
  customMessage: !0,
240
242
  message: "An unexpected error occurred during scanning. Please try again, and if the issue persists, contact your administrator for assistance.",
241
243
  error: e,
242
244
  life: 6e3,
243
- group: T.value
245
+ group: x.value
244
246
  });
245
- }, B = () => {
246
- window.Cypress ? pe() : q();
247
- }, pe = () => {
248
- c.add({
247
+ }, L = () => {
248
+ window.Cypress ? fe() : Y();
249
+ }, fe = () => {
250
+ i.add({
249
251
  customMessage: !0,
250
252
  message: "Connecting device...",
251
253
  severity: "info",
252
254
  life: 3e3,
253
- group: g.value
255
+ group: S.value
254
256
  }), setTimeout(async () => {
255
257
  var e;
256
- if (r("connect"), r("connected", {
258
+ if (c("connect"), c("connected", {
257
259
  jenisDevice: "Handheld",
258
- serialNumber: J(),
260
+ serialNumber: G(),
259
261
  API: "v2",
260
262
  rfidScan: !0,
261
263
  qrScan: !0,
262
264
  name: "Device Test"
263
265
  }), s.bulk)
264
- r("scan", J(), "serialNumber");
266
+ c("scan", G(), "serialNumber");
265
267
  else {
266
- const t = J();
267
- y.value = !!s.scanValidation;
268
+ const o = G();
269
+ R.value = !!s.scanValidation;
268
270
  const n = await ((e = s.scanValidation) == null ? void 0 : e.call(
269
271
  s,
270
- o.value,
271
- t,
272
- x()
272
+ a.value,
273
+ o,
274
+ B()
273
275
  )) ?? !0;
274
- y.value = !1, n && (r("scan", t, "serialNumber"), h());
276
+ R.value = !1, n && (c("scan", o, "serialNumber"), h());
275
277
  }
276
278
  }, 100);
277
- }, K = () => {
278
- c.removeGroup("RFID_Scanning"), c.removeGroup("QR_Scanning");
279
+ }, X = () => {
280
+ i.removeGroup("RFID_Scanning"), i.removeGroup("QR_Scanning");
279
281
  }, h = (e = !1) => {
280
- K(), k.value = !1, X(), e && r("stop"), P.splice(0);
281
- }, I = (e = !1) => {
282
- var t;
282
+ X(), N.value = !1, ee(), e && c("stop"), Q.splice(0);
283
+ }, C = (e = !1) => {
284
+ var o, n;
283
285
  window.scannerWorker.onmessage = null, window.scannerWorker.postMessage({
284
286
  command: "stopscan",
285
- userId: (t = JSON.parse(localStorage.getItem("user") ?? "{}")) == null ? void 0 : t._id
286
- }), h(e), V.value = !0, w.value = !1;
287
- }, fe = () => {
288
- s.bulk || (S.value[o.value] ? (o.value = o.value === "QR" ? "RFID" : "QR", Q()) : (h(), N.value = !0, f.value = "HARDWARE_NOT_SYNCHRONIZED", k.value = !1));
289
- }, L = (e) => {
290
- O.value = !0, I(!0), e.preventDefault();
291
- }, X = () => {
292
- window.removeEventListener("blur", L), window.removeEventListener("beforeunload", L);
287
+ userId: (o = JSON.parse(localStorage.getItem("user") ?? "{}")) == null ? void 0 : o._id,
288
+ companyCode: (n = JSON.parse(localStorage.getItem("user") ?? "{}")) == null ? void 0 : n.companyCode
289
+ }), h(e), P.value = !0, w.value = !1;
293
290
  }, ge = () => {
291
+ s.bulk || (y.value[a.value] ? (a.value = a.value === "QR" ? "RFID" : "QR", $()) : (h(), k.value = !0, g.value = "HARDWARE_NOT_SYNCHRONIZED", N.value = !1));
292
+ }, M = (e) => {
293
+ T.value = !0, C(!0), e.preventDefault();
294
+ }, ee = () => {
295
+ window.removeEventListener("blur", M), window.removeEventListener("beforeunload", M);
296
+ }, Se = () => {
294
297
  const { userAgent: e } = navigator;
295
298
  return e.includes("Windows");
296
299
  }, be = E(() => {
297
300
  if (!s.labelOnly)
298
- return s.icon ? s.icon : s.autoSwitch ? "qr-scan" : o.value === "QR" ? "qr" : "rfid";
299
- }), Se = E(() => s.label ? s.label : s.autoSwitch ? "SCAN TAG" : o.value === "QR" ? "Scan QR" : "Scan RFID");
300
- return l({
301
- onBeforeStartScan: B,
302
- startScan: q,
303
- stopScan: I
304
- }), (e, t) => (u(), D(F, null, [
305
- b(ne, De(e.$attrs, {
301
+ return s.icon ? s.icon : s.autoSwitch ? "qr-scan" : a.value === "QR" ? "qr" : "rfid";
302
+ }), ye = E(() => s.label ? s.label : s.autoSwitch ? "SCAN TAG" : a.value === "QR" ? "Scan QR" : "Scan RFID");
303
+ return u({
304
+ onBeforeStartScan: L,
305
+ startScan: Y,
306
+ stopScan: C
307
+ }), (e, o) => (d(), D(F, null, [
308
+ b(oe, Ne(e.$attrs, {
306
309
  class: [
307
310
  {
308
311
  "[&_i]:w-2 [&_i]:h-2": e.type === "QR",
@@ -313,105 +316,105 @@ const ie = () => window.devices ?? [], xe = () => window.device ?? { RFID: null,
313
316
  ],
314
317
  disabled: s.disabled,
315
318
  icon: be.value,
316
- label: Se.value,
319
+ label: ye.value,
317
320
  outlined: s.outlined,
318
321
  severity: s.severity,
319
322
  size: s.size,
320
- onClick: B
323
+ onClick: L
321
324
  }), null, 16, ["class", "disabled", "icon", "label", "outlined", "severity", "size"]),
322
- b(Ce, {
323
- visible: N.value,
324
- "onUpdate:visible": t[0] || (t[0] = (n) => N.value = n),
325
+ b(Oe, {
326
+ visible: k.value,
327
+ "onUpdate:visible": o[0] || (o[0] = (n) => k.value = n),
325
328
  bulk: e.bulk,
326
- "error-code": f.value,
327
- "search-by": o.value,
328
- onScan: B
329
+ "error-code": g.value,
330
+ "search-by": a.value,
331
+ onScan: L
329
332
  }, null, 8, ["visible", "bulk", "error-code", "search-by"]),
330
- w.value ? (u(), M(z, {
333
+ w.value ? (d(), U(z, {
331
334
  key: 0,
332
335
  "base-z-index": 9983,
333
- group: g.value,
336
+ group: S.value,
334
337
  icon: "info"
335
- }, null, 8, ["group"])) : U("", !0),
336
- w.value ? (u(), M(z, {
338
+ }, null, 8, ["group"])) : V("", !0),
339
+ w.value ? (d(), U(z, {
337
340
  key: 1,
338
341
  "base-z-index": 9997,
339
342
  class: "!absolute !bottom-[80px] !h-max",
340
343
  group: "scan-error-validation"
341
- })) : U("", !0),
342
- w.value ? (u(), M(z, {
343
- key: H.value,
344
+ })) : V("", !0),
345
+ w.value ? (d(), U(z, {
346
+ key: q.value,
344
347
  "base-z-index": 9984,
345
- group: T.value,
348
+ group: x.value,
346
349
  class: "[&_[data-pc-section=buttoncontainer]]"
347
350
  }, {
348
351
  message: ke(({ message: n }) => [
349
- C("div", {
350
- class: ee(
352
+ O("div", {
353
+ class: se(
351
354
  n.detail == "scanning" ? "w-full -mr-8 z-10 flex gap-2 justify-between items-center text-general-800 text-xs font-normal" : "w-full"
352
355
  )
353
356
  }, [
354
- n.detail === "scanning" ? (u(), D(F, { key: 0 }, [
355
- C("section", Le, [
356
- b(A, {
357
+ n.detail === "scanning" ? (d(), D(F, { key: 0 }, [
358
+ O("section", Me, [
359
+ b(J, {
357
360
  class: "animate-spin text-base",
358
361
  icon: "loader-4"
359
362
  }),
360
- C("span", We, [
361
- o.value === "RFID" ? (u(), D(F, { key: 0 }, [
362
- b(A, {
363
+ O("span", We, [
364
+ a.value === "RFID" ? (d(), D(F, { key: 0 }, [
365
+ b(J, {
363
366
  class: "text-base !w-4 !h-4",
364
367
  icon: "rfid"
365
368
  }),
366
- se(" " + j(y.value ? "Validating RFID..." : "RFID Scanning..."), 1)
367
- ], 64)) : (u(), D(F, { key: 1 }, [
368
- b(A, {
369
+ ne(" " + A(R.value ? "Validating RFID..." : "RFID Scanning..."), 1)
370
+ ], 64)) : (d(), D(F, { key: 1 }, [
371
+ b(J, {
369
372
  class: "text-sm",
370
373
  icon: "qr"
371
374
  }),
372
- se(" " + j(y.value ? "Validating QR..." : "QR Scanning..."), 1)
375
+ ne(" " + A(R.value ? "Validating QR..." : "QR Scanning..."), 1)
373
376
  ], 64))
374
377
  ])
375
378
  ]),
376
- C("section", Fe, [
377
- t[4] || (t[4] = C("span", null, "do not leave this page", -1)),
378
- b(ne, {
379
- onClick: t[1] || (t[1] = (R) => I(!0)),
379
+ O("section", Fe, [
380
+ o[4] || (o[4] = O("span", null, "do not leave this page", -1)),
381
+ b(oe, {
382
+ onClick: o[1] || (o[1] = (r) => C(!0)),
380
383
  label: "Stop Scan",
381
384
  severity: "danger"
382
385
  })
383
386
  ])
384
- ], 64)) : (u(), D("span", Me, j(n.detail), 1))
387
+ ], 64)) : (d(), D("span", Ue, A(n.detail), 1))
385
388
  ], 2)
386
389
  ]),
387
390
  _: 1
388
- }, 8, ["group"])) : U("", !0),
391
+ }, 8, ["group"])) : V("", !0),
389
392
  b(Ee, {
390
- visible: O.value,
391
- "onUpdate:visible": t[2] || (t[2] = (n) => O.value = n),
392
- header: `${o.value} SCAN STOPPED`,
393
- onConfirm: t[3] || (t[3] = (n) => (O.value = !1, B())),
393
+ visible: T.value,
394
+ "onUpdate:visible": o[2] || (o[2] = (n) => T.value = n),
395
+ header: `${a.value} SCAN STOPPED`,
396
+ onConfirm: o[3] || (o[3] = (n) => (T.value = !1, L())),
394
397
  "confirm-label": "Continue",
395
398
  message: "The scan process was interrupted because you want to leave this window.",
396
399
  severity: "danger"
397
400
  }, null, 8, ["visible", "header"]),
398
- (u(), M(Ne, { to: "body" }, [
399
- k.value ? (u(), D("div", {
401
+ (d(), U(he, { to: "body" }, [
402
+ N.value ? (d(), D("div", {
400
403
  key: 0,
401
- class: ee([
404
+ class: se([
402
405
  e.$preset.dialog.mask({ props: { modal: !0 } }).class,
403
406
  "w-screen h-screen fixed top-0 left-0",
404
407
  "!z-[9982]"
405
408
  ]),
406
409
  "data-ts-section": "toast-mask"
407
- }, null, 2)) : U("", !0)
410
+ }, null, 2)) : V("", !0)
408
411
  ]))
409
412
  ], 64));
410
413
  }
411
414
  });
412
415
  export {
413
- Te as W,
414
- He as _,
415
- Oe as g,
416
- Be as u
416
+ xe as W,
417
+ qe as _,
418
+ Te as g,
419
+ Le as u
417
420
  };