@fctc/interface-logic 1.7.7 → 1.7.8

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/dist/hooks.mjs CHANGED
@@ -31,626 +31,6 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
31
31
  return UriConstants2;
32
32
  })(UriConstants || {});
33
33
 
34
- // src/store/index.ts
35
- import { useDispatch, useSelector } from "react-redux";
36
-
37
- // src/store/reducers/breadcrums-slice/index.ts
38
- import { createSlice } from "@reduxjs/toolkit";
39
- var initialState = {
40
- breadCrumbs: []
41
- };
42
- var breadcrumbsSlice = createSlice({
43
- name: "breadcrumbs",
44
- initialState,
45
- reducers: {
46
- setBreadCrumbs: (state, action) => {
47
- state.breadCrumbs = [...state.breadCrumbs, action.payload];
48
- }
49
- }
50
- });
51
- var { setBreadCrumbs } = breadcrumbsSlice.actions;
52
- var breadcrums_slice_default = breadcrumbsSlice.reducer;
53
-
54
- // src/store/reducers/env-slice/index.ts
55
- import { createSlice as createSlice2 } from "@reduxjs/toolkit";
56
- var initialState2 = {
57
- baseUrl: "",
58
- companies: [],
59
- user: {},
60
- db: "",
61
- refreshTokenEndpoint: "",
62
- config: {
63
- grantType: "",
64
- clientId: "",
65
- clientSecret: "",
66
- redirectUri: ""
67
- },
68
- envFile: null,
69
- defaultCompany: {
70
- id: null,
71
- logo: "",
72
- secondary_color: "",
73
- primary_color: ""
74
- },
75
- context: {
76
- uid: null,
77
- allowed_company_ids: [],
78
- lang: "vi_VN",
79
- tz: "Asia/Saigon"
80
- }
81
- };
82
- var envSlice = createSlice2({
83
- name: "env",
84
- initialState: initialState2,
85
- reducers: {
86
- setEnv: (state, action) => {
87
- Object.assign(state, action.payload);
88
- },
89
- setUid: (state, action) => {
90
- state.context.uid = action.payload;
91
- },
92
- setAllowCompanies: (state, action) => {
93
- state.context.allowed_company_ids = action.payload;
94
- },
95
- setCompanies: (state, action) => {
96
- state.companies = action.payload;
97
- },
98
- setDefaultCompany: (state, action) => {
99
- state.defaultCompany = action.payload;
100
- },
101
- setLang: (state, action) => {
102
- state.context.lang = action.payload;
103
- },
104
- setUser: (state, action) => {
105
- state.user = action.payload;
106
- },
107
- setConfig: (state, action) => {
108
- state.config = action.payload;
109
- },
110
- setEnvFile: (state, action) => {
111
- state.envFile = action.payload;
112
- }
113
- }
114
- });
115
- var {
116
- setEnv,
117
- setUid,
118
- setLang,
119
- setAllowCompanies,
120
- setCompanies,
121
- setDefaultCompany,
122
- setUser,
123
- setConfig,
124
- setEnvFile
125
- } = envSlice.actions;
126
- var env_slice_default = envSlice.reducer;
127
-
128
- // src/store/reducers/excel-slice/index.ts
129
- import { createSlice as createSlice3 } from "@reduxjs/toolkit";
130
- var initialState3 = {
131
- dataParse: null,
132
- idFile: null,
133
- isFileLoaded: false,
134
- loadingImport: false,
135
- selectedFile: null,
136
- errorData: null
137
- };
138
- var excelSlice = createSlice3({
139
- name: "excel",
140
- initialState: initialState3,
141
- reducers: {
142
- setDataParse: (state, action) => {
143
- state.dataParse = action.payload;
144
- },
145
- setIdFile: (state, action) => {
146
- state.idFile = action.payload;
147
- },
148
- setIsFileLoaded: (state, action) => {
149
- state.isFileLoaded = action.payload;
150
- },
151
- setLoadingImport: (state, action) => {
152
- state.loadingImport = action.payload;
153
- },
154
- setSelectedFile: (state, action) => {
155
- state.selectedFile = action.payload;
156
- },
157
- setErrorData: (state, action) => {
158
- state.errorData = action.payload;
159
- }
160
- }
161
- });
162
- var {
163
- setDataParse,
164
- setIdFile,
165
- setIsFileLoaded,
166
- setLoadingImport,
167
- setSelectedFile,
168
- setErrorData
169
- } = excelSlice.actions;
170
- var excel_slice_default = excelSlice.reducer;
171
-
172
- // src/store/reducers/form-slice/index.ts
173
- import { createSlice as createSlice4 } from "@reduxjs/toolkit";
174
- var initialState4 = {
175
- viewDataStore: {},
176
- isShowingModalDetail: false,
177
- isShowModalTranslate: false,
178
- formSubmitComponent: {},
179
- fieldTranslation: null,
180
- listSubject: {},
181
- dataUser: {}
182
- };
183
- var formSlice = createSlice4({
184
- name: "form",
185
- initialState: initialState4,
186
- reducers: {
187
- setViewDataStore: (state, action) => {
188
- state.viewDataStore = action.payload;
189
- },
190
- setIsShowingModalDetail: (state, action) => {
191
- state.isShowingModalDetail = action.payload;
192
- },
193
- setIsShowModalTranslate: (state, action) => {
194
- state.isShowModalTranslate = action.payload;
195
- },
196
- setFormSubmitComponent: (state, action) => {
197
- state.formSubmitComponent[action.payload.key] = action.payload.component;
198
- },
199
- setFieldTranslate: (state, action) => {
200
- state.fieldTranslation = action.payload;
201
- },
202
- setListSubject: (state, action) => {
203
- state.listSubject = action.payload;
204
- },
205
- setDataUser: (state, action) => {
206
- state.dataUser = action.payload;
207
- }
208
- }
209
- });
210
- var {
211
- setViewDataStore,
212
- setIsShowingModalDetail,
213
- setIsShowModalTranslate,
214
- setFormSubmitComponent,
215
- setFieldTranslate,
216
- setListSubject,
217
- setDataUser
218
- } = formSlice.actions;
219
- var form_slice_default = formSlice.reducer;
220
-
221
- // src/store/reducers/header-slice/index.ts
222
- import { createSlice as createSlice5 } from "@reduxjs/toolkit";
223
- var headerSlice = createSlice5({
224
- name: "header",
225
- initialState: {
226
- value: { allowedCompanyIds: [] }
227
- },
228
- reducers: {
229
- setHeader: (state, action) => {
230
- state.value = { ...state.value, ...action.payload };
231
- },
232
- setAllowedCompanyIds: (state, action) => {
233
- state.value.allowedCompanyIds = action.payload;
234
- }
235
- }
236
- });
237
- var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
238
- var header_slice_default = headerSlice.reducer;
239
-
240
- // src/store/reducers/list-slice/index.ts
241
- import { createSlice as createSlice6 } from "@reduxjs/toolkit";
242
- var initialState5 = {
243
- pageLimit: 10,
244
- fields: {},
245
- order: "",
246
- selectedRowKeys: [],
247
- selectedRadioKey: 0,
248
- indexRowTableModal: -2,
249
- isUpdateTableModal: false,
250
- footerGroupTable: {},
251
- transferDetail: null,
252
- page: 0,
253
- domainTable: []
254
- };
255
- var listSlice = createSlice6({
256
- name: "list",
257
- initialState: initialState5,
258
- reducers: {
259
- setPageLimit: (state, action) => {
260
- state.pageLimit = action.payload;
261
- },
262
- setFields: (state, action) => {
263
- state.fields = action.payload;
264
- },
265
- setOrder: (state, action) => {
266
- state.order = action.payload;
267
- },
268
- setSelectedRowKeys: (state, action) => {
269
- state.selectedRowKeys = action.payload;
270
- },
271
- setSelectedRadioKey: (state, action) => {
272
- state.selectedRadioKey = action.payload;
273
- },
274
- setIndexRowTableModal: (state, action) => {
275
- state.indexRowTableModal = action.payload;
276
- },
277
- setTransferDetail: (state, action) => {
278
- state.transferDetail = action.payload;
279
- },
280
- setIsUpdateTableModal: (state, action) => {
281
- state.isUpdateTableModal = action.payload;
282
- },
283
- setPage: (state, action) => {
284
- state.page = action.payload;
285
- },
286
- setDomainTable: (state, action) => {
287
- state.domainTable = action.payload;
288
- }
289
- }
290
- });
291
- var {
292
- setPageLimit,
293
- setFields,
294
- setOrder,
295
- setSelectedRowKeys,
296
- setIndexRowTableModal,
297
- setIsUpdateTableModal,
298
- setPage,
299
- setSelectedRadioKey,
300
- setTransferDetail,
301
- setDomainTable
302
- } = listSlice.actions;
303
- var list_slice_default = listSlice.reducer;
304
-
305
- // src/store/reducers/login-slice/index.ts
306
- import { createSlice as createSlice7 } from "@reduxjs/toolkit";
307
- var initialState6 = {
308
- db: "",
309
- redirectTo: "/",
310
- forgotPasswordUrl: "/"
311
- };
312
- var loginSlice = createSlice7({
313
- name: "login",
314
- initialState: initialState6,
315
- reducers: {
316
- setDb: (state, action) => {
317
- state.db = action.payload;
318
- },
319
- setRedirectTo: (state, action) => {
320
- state.redirectTo = action.payload;
321
- },
322
- setForgotPasswordUrl: (state, action) => {
323
- state.forgotPasswordUrl = action.payload;
324
- }
325
- }
326
- });
327
- var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
328
- var login_slice_default = loginSlice.reducer;
329
-
330
- // src/store/reducers/navbar-slice/index.ts
331
- import { createSlice as createSlice8 } from "@reduxjs/toolkit";
332
- var initialState7 = {
333
- menuFocus: {},
334
- menuAction: {},
335
- navbarWidth: 250,
336
- menuList: []
337
- };
338
- var navbarSlice = createSlice8({
339
- name: "navbar",
340
- initialState: initialState7,
341
- reducers: {
342
- setMenuFocus: (state, action) => {
343
- state.menuFocus = action.payload;
344
- },
345
- setMenuFocusAction: (state, action) => {
346
- state.menuAction = action.payload;
347
- },
348
- setNavbarWidth: (state, action) => {
349
- state.navbarWidth = action.payload;
350
- },
351
- setMenuList: (state, action) => {
352
- state.menuList = action.payload;
353
- }
354
- }
355
- });
356
- var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
357
- var navbar_slice_default = navbarSlice.reducer;
358
-
359
- // src/store/reducers/profile-slice/index.ts
360
- import { createSlice as createSlice9 } from "@reduxjs/toolkit";
361
- var initialState8 = {
362
- profile: {}
363
- };
364
- var profileSlice = createSlice9({
365
- name: "profile",
366
- initialState: initialState8,
367
- reducers: {
368
- setProfile: (state, action) => {
369
- state.profile = action.payload;
370
- }
371
- }
372
- });
373
- var { setProfile } = profileSlice.actions;
374
- var profile_slice_default = profileSlice.reducer;
375
-
376
- // src/store/reducers/search-slice/index.ts
377
- import { createSlice as createSlice10 } from "@reduxjs/toolkit";
378
- var initialState9 = {
379
- groupByDomain: null,
380
- searchBy: [],
381
- searchString: "",
382
- hoveredIndexSearchList: null,
383
- selectedTags: [],
384
- firstDomain: null,
385
- searchMap: {},
386
- filterBy: [],
387
- groupBy: []
388
- };
389
- var searchSlice = createSlice10({
390
- name: "search",
391
- initialState: initialState9,
392
- reducers: {
393
- setGroupByDomain: (state, action) => {
394
- state.groupByDomain = action.payload;
395
- },
396
- setSearchBy: (state, action) => {
397
- state.searchBy = action.payload;
398
- },
399
- setSearchString: (state, action) => {
400
- state.searchString = action.payload;
401
- },
402
- setHoveredIndexSearchList: (state, action) => {
403
- state.hoveredIndexSearchList = action.payload;
404
- },
405
- setSelectedTags: (state, action) => {
406
- state.selectedTags = action.payload;
407
- },
408
- setFirstDomain: (state, action) => {
409
- state.firstDomain = action.payload;
410
- },
411
- setFilterBy: (state, action) => {
412
- state.filterBy = action.payload;
413
- },
414
- setGroupBy: (state, action) => {
415
- state.groupBy = action.payload;
416
- },
417
- setSearchMap: (state, action) => {
418
- state.searchMap = action.payload;
419
- },
420
- updateSearchMap: (state, action) => {
421
- if (!state.searchMap[action.payload.key]) {
422
- state.searchMap[action.payload.key] = [];
423
- }
424
- state.searchMap[action.payload.key].push(action.payload.value);
425
- },
426
- removeKeyFromSearchMap: (state, action) => {
427
- const { key, item } = action.payload;
428
- const values = state.searchMap[key];
429
- if (!values) return;
430
- if (item) {
431
- const filtered = values.filter((value) => value.name !== item.name);
432
- if (filtered.length > 0) {
433
- state.searchMap[key] = filtered;
434
- } else {
435
- delete state.searchMap[key];
436
- }
437
- } else {
438
- delete state.searchMap[key];
439
- }
440
- },
441
- clearSearchMap: (state) => {
442
- state.searchMap = {};
443
- }
444
- }
445
- });
446
- var {
447
- setGroupByDomain,
448
- setSelectedTags,
449
- setSearchString,
450
- setHoveredIndexSearchList,
451
- setFirstDomain,
452
- setSearchBy,
453
- setFilterBy,
454
- setSearchMap,
455
- updateSearchMap,
456
- removeKeyFromSearchMap,
457
- setGroupBy,
458
- clearSearchMap
459
- } = searchSlice.actions;
460
- var search_slice_default = searchSlice.reducer;
461
-
462
- // src/store/store.ts
463
- import { configureStore } from "@reduxjs/toolkit";
464
-
465
- // node_modules/redux/dist/redux.mjs
466
- function formatProdErrorMessage(code) {
467
- return `Minified Redux error #${code}; visit https://redux.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
468
- }
469
- var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
470
- var ActionTypes = {
471
- INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
472
- REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
473
- PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
474
- };
475
- var actionTypes_default = ActionTypes;
476
- function isPlainObject(obj) {
477
- if (typeof obj !== "object" || obj === null)
478
- return false;
479
- let proto = obj;
480
- while (Object.getPrototypeOf(proto) !== null) {
481
- proto = Object.getPrototypeOf(proto);
482
- }
483
- return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
484
- }
485
- function miniKindOf(val) {
486
- if (val === void 0)
487
- return "undefined";
488
- if (val === null)
489
- return "null";
490
- const type = typeof val;
491
- switch (type) {
492
- case "boolean":
493
- case "string":
494
- case "number":
495
- case "symbol":
496
- case "function": {
497
- return type;
498
- }
499
- }
500
- if (Array.isArray(val))
501
- return "array";
502
- if (isDate(val))
503
- return "date";
504
- if (isError(val))
505
- return "error";
506
- const constructorName = ctorName(val);
507
- switch (constructorName) {
508
- case "Symbol":
509
- case "Promise":
510
- case "WeakMap":
511
- case "WeakSet":
512
- case "Map":
513
- case "Set":
514
- return constructorName;
515
- }
516
- return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
517
- }
518
- function ctorName(val) {
519
- return typeof val.constructor === "function" ? val.constructor.name : null;
520
- }
521
- function isError(val) {
522
- return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
523
- }
524
- function isDate(val) {
525
- if (val instanceof Date)
526
- return true;
527
- return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
528
- }
529
- function kindOf(val) {
530
- let typeOfVal = typeof val;
531
- if (process.env.NODE_ENV !== "production") {
532
- typeOfVal = miniKindOf(val);
533
- }
534
- return typeOfVal;
535
- }
536
- function warning(message) {
537
- if (typeof console !== "undefined" && typeof console.error === "function") {
538
- console.error(message);
539
- }
540
- try {
541
- throw new Error(message);
542
- } catch (e) {
543
- }
544
- }
545
- function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
546
- const reducerKeys = Object.keys(reducers);
547
- const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
548
- if (reducerKeys.length === 0) {
549
- return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
550
- }
551
- if (!isPlainObject(inputState)) {
552
- return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
553
- }
554
- const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
555
- unexpectedKeys.forEach((key) => {
556
- unexpectedKeyCache[key] = true;
557
- });
558
- if (action && action.type === actionTypes_default.REPLACE)
559
- return;
560
- if (unexpectedKeys.length > 0) {
561
- return `Unexpected ${unexpectedKeys.length > 1 ? "keys" : "key"} "${unexpectedKeys.join('", "')}" found in ${argumentName}. Expected to find one of the known reducer keys instead: "${reducerKeys.join('", "')}". Unexpected keys will be ignored.`;
562
- }
563
- }
564
- function assertReducerShape(reducers) {
565
- Object.keys(reducers).forEach((key) => {
566
- const reducer = reducers[key];
567
- const initialState10 = reducer(void 0, {
568
- type: actionTypes_default.INIT
569
- });
570
- if (typeof initialState10 === "undefined") {
571
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : `The slice reducer for key "${key}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);
572
- }
573
- if (typeof reducer(void 0, {
574
- type: actionTypes_default.PROBE_UNKNOWN_ACTION()
575
- }) === "undefined") {
576
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : `The slice reducer for key "${key}" returned undefined when probed with a random type. Don't try to handle '${actionTypes_default.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`);
577
- }
578
- });
579
- }
580
- function combineReducers(reducers) {
581
- const reducerKeys = Object.keys(reducers);
582
- const finalReducers = {};
583
- for (let i = 0; i < reducerKeys.length; i++) {
584
- const key = reducerKeys[i];
585
- if (process.env.NODE_ENV !== "production") {
586
- if (typeof reducers[key] === "undefined") {
587
- warning(`No reducer provided for key "${key}"`);
588
- }
589
- }
590
- if (typeof reducers[key] === "function") {
591
- finalReducers[key] = reducers[key];
592
- }
593
- }
594
- const finalReducerKeys = Object.keys(finalReducers);
595
- let unexpectedKeyCache;
596
- if (process.env.NODE_ENV !== "production") {
597
- unexpectedKeyCache = {};
598
- }
599
- let shapeAssertionError;
600
- try {
601
- assertReducerShape(finalReducers);
602
- } catch (e) {
603
- shapeAssertionError = e;
604
- }
605
- return function combination(state = {}, action) {
606
- if (shapeAssertionError) {
607
- throw shapeAssertionError;
608
- }
609
- if (process.env.NODE_ENV !== "production") {
610
- const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
611
- if (warningMessage) {
612
- warning(warningMessage);
613
- }
614
- }
615
- let hasChanged = false;
616
- const nextState = {};
617
- for (let i = 0; i < finalReducerKeys.length; i++) {
618
- const key = finalReducerKeys[i];
619
- const reducer = finalReducers[key];
620
- const previousStateForKey = state[key];
621
- const nextStateForKey = reducer(previousStateForKey, action);
622
- if (typeof nextStateForKey === "undefined") {
623
- const actionType = action && action.type;
624
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : `When called with an action of type ${actionType ? `"${String(actionType)}"` : "(unknown type)"}, the slice reducer for key "${key}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`);
625
- }
626
- nextState[key] = nextStateForKey;
627
- hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
628
- }
629
- hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
630
- return hasChanged ? nextState : state;
631
- };
632
- }
633
-
634
- // src/store/store.ts
635
- var rootReducer = combineReducers({
636
- env: env_slice_default,
637
- header: header_slice_default,
638
- navbar: navbar_slice_default,
639
- list: list_slice_default,
640
- search: search_slice_default,
641
- form: form_slice_default,
642
- breadcrumbs: breadcrums_slice_default,
643
- login: login_slice_default,
644
- excel: excel_slice_default,
645
- profile: profile_slice_default
646
- });
647
- var envStore = configureStore({
648
- reducer: rootReducer,
649
- middleware: (getDefaultMiddleware) => getDefaultMiddleware({
650
- serializableCheck: false
651
- })
652
- });
653
-
654
34
  // src/configs/axios-client.ts
655
35
  import axios from "axios";
656
36
 
@@ -1514,11 +894,71 @@ var PyDateTime = class _PyDateTime {
1514
894
  s.microsecond
1515
895
  );
1516
896
  }
1517
- isEqual(other) {
1518
- if (!(other instanceof _PyDateTime)) {
1519
- return false;
1520
- }
1521
- return this.year === other.year && this.month === other.month && this.day === other.day && this.hour === other.hour && this.minute === other.minute && this.second === other.second && this.microsecond === other.microsecond;
897
+ isEqual(other) {
898
+ if (!(other instanceof _PyDateTime)) {
899
+ return false;
900
+ }
901
+ return this.year === other.year && this.month === other.month && this.day === other.day && this.hour === other.hour && this.minute === other.minute && this.second === other.second && this.microsecond === other.microsecond;
902
+ }
903
+ strftime(format) {
904
+ return format.replace(/%([A-Za-z])/g, (m, c) => {
905
+ switch (c) {
906
+ case "Y":
907
+ return fmt4(this.year);
908
+ case "m":
909
+ return fmt2(this.month);
910
+ case "d":
911
+ return fmt2(this.day);
912
+ case "H":
913
+ return fmt2(this.hour);
914
+ case "M":
915
+ return fmt2(this.minute);
916
+ case "S":
917
+ return fmt2(this.second);
918
+ default:
919
+ throw new ValueError(`No known conversion for ${m}`);
920
+ }
921
+ });
922
+ }
923
+ substract(timedelta) {
924
+ return this.add(timedelta.negate());
925
+ }
926
+ toJSON() {
927
+ return this.strftime("%Y-%m-%d %H:%M:%S");
928
+ }
929
+ to_utc() {
930
+ const d = new Date(
931
+ this.year,
932
+ this.month - 1,
933
+ this.day,
934
+ this.hour,
935
+ this.minute,
936
+ this.second
937
+ );
938
+ const timedelta = PyTimeDelta.create({ minutes: d.getTimezoneOffset() });
939
+ return this.add(timedelta);
940
+ }
941
+ };
942
+ var PyTime = class _PyTime extends PyDate {
943
+ constructor(hour, minute, second) {
944
+ const now = /* @__PURE__ */ new Date();
945
+ const year = now.getFullYear();
946
+ const month = now.getMonth() + 1;
947
+ const day = now.getDate();
948
+ super(year, month, day);
949
+ this.hour = hour;
950
+ this.minute = minute;
951
+ this.second = second;
952
+ this.hour = hour;
953
+ this.minute = minute;
954
+ this.second = second;
955
+ }
956
+ static create(...args) {
957
+ const namedArgs = parseArgs(args, ["hour", "minute", "second"]);
958
+ const hour = namedArgs.hour || 0;
959
+ const minute = namedArgs.minute || 0;
960
+ const second = namedArgs.second || 0;
961
+ return new _PyTime(hour, minute, second);
1522
962
  }
1523
963
  strftime(format) {
1524
964
  return format.replace(/%([A-Za-z])/g, (m, c) => {
@@ -1540,1271 +980,2121 @@ var PyDateTime = class _PyDateTime {
1540
980
  }
1541
981
  });
1542
982
  }
1543
- substract(timedelta) {
1544
- return this.add(timedelta.negate());
983
+ toJSON() {
984
+ return this.strftime("%H:%M:%S");
985
+ }
986
+ };
987
+ var DAYS_IN_YEAR = [
988
+ 31,
989
+ 59,
990
+ 90,
991
+ 120,
992
+ 151,
993
+ 181,
994
+ 212,
995
+ 243,
996
+ 273,
997
+ 304,
998
+ 334,
999
+ 366
1000
+ ];
1001
+ var TIME_PERIODS = ["hour", "minute", "second"];
1002
+ var PERIODS = ["year", "month", "day", ...TIME_PERIODS];
1003
+ var RELATIVE_KEYS = "years months weeks days hours minutes seconds microseconds leapdays".split(
1004
+ " "
1005
+ );
1006
+ var ABSOLUTE_KEYS = "year month day hour minute second microsecond weekday nlyearday yearday".split(
1007
+ " "
1008
+ );
1009
+ var argsSpec = ["dt1", "dt2"];
1010
+ var PyRelativeDelta = class _PyRelativeDelta {
1011
+ static create(...args) {
1012
+ const params = parseArgs(args, argsSpec);
1013
+ if ("dt1" in params) {
1014
+ throw new Error("relativedelta(dt1, dt2) is not supported for now");
1015
+ }
1016
+ for (const period of PERIODS) {
1017
+ if (period in params) {
1018
+ const val = params[period];
1019
+ assert(val >= 0, `${period} ${val} is out of range`);
1020
+ }
1021
+ }
1022
+ for (const key of RELATIVE_KEYS) {
1023
+ params[key] = params[key] || 0;
1024
+ }
1025
+ for (const key of ABSOLUTE_KEYS) {
1026
+ params[key] = key in params ? params[key] : null;
1027
+ }
1028
+ params.days += 7 * params.weeks;
1029
+ let yearDay = 0;
1030
+ if (params.nlyearday) {
1031
+ yearDay = params.nlyearday;
1032
+ } else if (params.yearday) {
1033
+ yearDay = params.yearday;
1034
+ if (yearDay > 59) {
1035
+ params.leapDays = -1;
1036
+ }
1037
+ }
1038
+ if (yearDay) {
1039
+ for (let monthIndex = 0; monthIndex < DAYS_IN_YEAR.length; monthIndex++) {
1040
+ if (yearDay <= DAYS_IN_YEAR[monthIndex]) {
1041
+ params.month = monthIndex + 1;
1042
+ if (monthIndex === 0) {
1043
+ params.day = yearDay;
1044
+ } else {
1045
+ params.day = yearDay - DAYS_IN_YEAR[monthIndex - 1];
1046
+ }
1047
+ break;
1048
+ }
1049
+ }
1050
+ }
1051
+ return new _PyRelativeDelta(params);
1052
+ }
1053
+ static add(date, delta) {
1054
+ if (!(date instanceof PyDate || date instanceof PyDateTime)) {
1055
+ throw new NotSupportedError();
1056
+ }
1057
+ const s = tmxxx(
1058
+ (delta.year || date.year) + delta.years,
1059
+ (delta.month || date.month) + delta.months,
1060
+ delta.day || date.day,
1061
+ delta.hour || (date instanceof PyDateTime ? date.hour : 0),
1062
+ delta.minute || (date instanceof PyDateTime ? date.minute : 0),
1063
+ delta.second || (date instanceof PyDateTime ? date.second : 0),
1064
+ delta.microseconds || (date instanceof PyDateTime ? date.microsecond : 0)
1065
+ );
1066
+ const newDateTime = new PyDateTime(
1067
+ s.year,
1068
+ s.month,
1069
+ s.day,
1070
+ s.hour,
1071
+ s.minute,
1072
+ s.second,
1073
+ s.microsecond
1074
+ );
1075
+ let leapDays = 0;
1076
+ if (delta.leapDays && newDateTime.month > 2 && isLeap(newDateTime.year)) {
1077
+ leapDays = delta.leapDays;
1078
+ }
1079
+ const temp = newDateTime.add(
1080
+ PyTimeDelta.create({
1081
+ days: delta.days + leapDays,
1082
+ hours: delta.hours,
1083
+ minutes: delta.minutes,
1084
+ seconds: delta.seconds,
1085
+ microseconds: delta.microseconds
1086
+ })
1087
+ );
1088
+ const hasTime = Boolean(
1089
+ temp.hour || temp.minute || temp.second || temp.microsecond
1090
+ );
1091
+ const returnDate = !hasTime && date instanceof PyDate ? new PyDate(temp.year, temp.month, temp.day) : temp;
1092
+ if (delta.weekday !== null) {
1093
+ const wantedDow = delta.weekday + 1;
1094
+ const _date = new Date(
1095
+ returnDate.year,
1096
+ returnDate.month - 1,
1097
+ returnDate.day
1098
+ );
1099
+ const days = (7 - _date.getDay() + wantedDow) % 7;
1100
+ return returnDate.add(new PyTimeDelta(days, 0, 0));
1101
+ }
1102
+ return returnDate;
1103
+ }
1104
+ static substract(date, delta) {
1105
+ return _PyRelativeDelta.add(date, delta.negate());
1106
+ }
1107
+ constructor(params = {}, sign = 1) {
1108
+ this.years = sign * params.years;
1109
+ this.months = sign * params.months;
1110
+ this.days = sign * params.days;
1111
+ this.hours = sign * params.hours;
1112
+ this.minutes = sign * params.minutes;
1113
+ this.seconds = sign * params.seconds;
1114
+ this.microseconds = sign * params.microseconds;
1115
+ this.leapDays = params.leapDays;
1116
+ this.year = params.year;
1117
+ this.month = params.month;
1118
+ this.day = params.day;
1119
+ this.hour = params.hour;
1120
+ this.minute = params.minute;
1121
+ this.second = params.second;
1122
+ this.microsecond = params.microsecond;
1123
+ this.weekday = params.weekday;
1124
+ }
1125
+ years;
1126
+ months;
1127
+ days;
1128
+ hours;
1129
+ minutes;
1130
+ seconds;
1131
+ microseconds;
1132
+ leapDays;
1133
+ year;
1134
+ month;
1135
+ day;
1136
+ hour;
1137
+ minute;
1138
+ second;
1139
+ microsecond;
1140
+ weekday;
1141
+ negate() {
1142
+ return new _PyRelativeDelta(this, -1);
1143
+ }
1144
+ isEqual() {
1145
+ throw new NotSupportedError();
1146
+ }
1147
+ };
1148
+ var TIME_DELTA_KEYS = "weeks days hours minutes seconds milliseconds microseconds".split(" ");
1149
+ function modf(x) {
1150
+ const mod = x % 1;
1151
+ return [mod < 0 ? mod + 1 : mod, Math.floor(x)];
1152
+ }
1153
+ var PyTimeDelta = class _PyTimeDelta {
1154
+ constructor(days, seconds, microseconds) {
1155
+ this.days = days;
1156
+ this.seconds = seconds;
1157
+ this.microseconds = microseconds;
1158
+ }
1159
+ static create(...args) {
1160
+ const namedArgs = parseArgs(args, ["days", "seconds", "microseconds"]);
1161
+ for (const key of TIME_DELTA_KEYS) {
1162
+ namedArgs[key] = namedArgs[key] || 0;
1163
+ }
1164
+ let d = 0;
1165
+ let s = 0;
1166
+ let us = 0;
1167
+ const days = namedArgs.days + namedArgs.weeks * 7;
1168
+ let seconds = namedArgs.seconds + 60 * namedArgs.minutes + 3600 * namedArgs.hours;
1169
+ let microseconds = namedArgs.microseconds + 1e3 * namedArgs.milliseconds;
1170
+ const [dFrac, dInt] = modf(days);
1171
+ d = dInt;
1172
+ let daysecondsfrac = 0;
1173
+ if (dFrac) {
1174
+ const [dsFrac, dsInt] = modf(dFrac * 24 * 3600);
1175
+ s = dsInt;
1176
+ daysecondsfrac = dsFrac;
1177
+ }
1178
+ const [sFrac, sInt] = modf(seconds);
1179
+ seconds = sInt;
1180
+ const secondsfrac = sFrac + daysecondsfrac;
1181
+ divmod(seconds, 24 * 3600, (days2, seconds2) => {
1182
+ d += days2;
1183
+ s += seconds2;
1184
+ });
1185
+ microseconds += secondsfrac * 1e6;
1186
+ divmod(microseconds, 1e6, (seconds2, microseconds2) => {
1187
+ divmod(seconds2, 24 * 3600, (days2, seconds3) => {
1188
+ d += days2;
1189
+ s += seconds3;
1190
+ us += Math.round(microseconds2);
1191
+ });
1192
+ });
1193
+ return new _PyTimeDelta(d, s, us);
1194
+ }
1195
+ add(other) {
1196
+ return _PyTimeDelta.create({
1197
+ days: this.days + other.days,
1198
+ seconds: this.seconds + other.seconds,
1199
+ microseconds: this.microseconds + other.microseconds
1200
+ });
1201
+ }
1202
+ divide(n) {
1203
+ const us = (this.days * 24 * 3600 + this.seconds) * 1e6 + this.microseconds;
1204
+ return _PyTimeDelta.create({ microseconds: Math.floor(us / n) });
1545
1205
  }
1546
- toJSON() {
1547
- return this.strftime("%Y-%m-%d %H:%M:%S");
1206
+ isEqual(other) {
1207
+ if (!(other instanceof _PyTimeDelta)) {
1208
+ return false;
1209
+ }
1210
+ return this.days === other.days && this.seconds === other.seconds && this.microseconds === other.microseconds;
1548
1211
  }
1549
- to_utc() {
1550
- const d = new Date(
1551
- this.year,
1552
- this.month - 1,
1553
- this.day,
1554
- this.hour,
1555
- this.minute,
1556
- this.second
1557
- );
1558
- const timedelta = PyTimeDelta.create({ minutes: d.getTimezoneOffset() });
1559
- return this.add(timedelta);
1212
+ isTrue() {
1213
+ return this.days !== 0 || this.seconds !== 0 || this.microseconds !== 0;
1560
1214
  }
1561
- };
1562
- var PyTime = class _PyTime extends PyDate {
1563
- constructor(hour, minute, second) {
1564
- const now = /* @__PURE__ */ new Date();
1565
- const year = now.getFullYear();
1566
- const month = now.getMonth() + 1;
1567
- const day = now.getDate();
1568
- super(year, month, day);
1569
- this.hour = hour;
1570
- this.minute = minute;
1571
- this.second = second;
1572
- this.hour = hour;
1573
- this.minute = minute;
1574
- this.second = second;
1215
+ multiply(n) {
1216
+ return _PyTimeDelta.create({
1217
+ days: n * this.days,
1218
+ seconds: n * this.seconds,
1219
+ microseconds: n * this.microseconds
1220
+ });
1575
1221
  }
1576
- static create(...args) {
1577
- const namedArgs = parseArgs(args, ["hour", "minute", "second"]);
1578
- const hour = namedArgs.hour || 0;
1579
- const minute = namedArgs.minute || 0;
1580
- const second = namedArgs.second || 0;
1581
- return new _PyTime(hour, minute, second);
1222
+ negate() {
1223
+ return _PyTimeDelta.create({
1224
+ days: -this.days,
1225
+ seconds: -this.seconds,
1226
+ microseconds: -this.microseconds
1227
+ });
1582
1228
  }
1583
- strftime(format) {
1584
- return format.replace(/%([A-Za-z])/g, (m, c) => {
1585
- switch (c) {
1586
- case "Y":
1587
- return fmt4(this.year);
1588
- case "m":
1589
- return fmt2(this.month);
1590
- case "d":
1591
- return fmt2(this.day);
1592
- case "H":
1593
- return fmt2(this.hour);
1594
- case "M":
1595
- return fmt2(this.minute);
1596
- case "S":
1597
- return fmt2(this.second);
1598
- default:
1599
- throw new ValueError(`No known conversion for ${m}`);
1600
- }
1229
+ substract(other) {
1230
+ return _PyTimeDelta.create({
1231
+ days: this.days - other.days,
1232
+ seconds: this.seconds - other.seconds,
1233
+ microseconds: this.microseconds - other.microseconds
1601
1234
  });
1602
1235
  }
1603
- toJSON() {
1604
- return this.strftime("%H:%M:%S");
1236
+ total_seconds() {
1237
+ return this.days * 86400 + this.seconds + this.microseconds / 1e6;
1605
1238
  }
1606
1239
  };
1607
- var DAYS_IN_YEAR = [
1608
- 31,
1609
- 59,
1610
- 90,
1611
- 120,
1612
- 151,
1613
- 181,
1614
- 212,
1615
- 243,
1616
- 273,
1617
- 304,
1618
- 334,
1619
- 366
1620
- ];
1621
- var TIME_PERIODS = ["hour", "minute", "second"];
1622
- var PERIODS = ["year", "month", "day", ...TIME_PERIODS];
1623
- var RELATIVE_KEYS = "years months weeks days hours minutes seconds microseconds leapdays".split(
1624
- " "
1625
- );
1626
- var ABSOLUTE_KEYS = "year month day hour minute second microsecond weekday nlyearday yearday".split(
1627
- " "
1628
- );
1629
- var argsSpec = ["dt1", "dt2"];
1630
- var PyRelativeDelta = class _PyRelativeDelta {
1631
- static create(...args) {
1632
- const params = parseArgs(args, argsSpec);
1633
- if ("dt1" in params) {
1634
- throw new Error("relativedelta(dt1, dt2) is not supported for now");
1635
- }
1636
- for (const period of PERIODS) {
1637
- if (period in params) {
1638
- const val = params[period];
1639
- assert(val >= 0, `${period} ${val} is out of range`);
1640
- }
1641
- }
1642
- for (const key of RELATIVE_KEYS) {
1643
- params[key] = params[key] || 0;
1240
+
1241
+ // src/utils/domain/py_builtin.ts
1242
+ var EvaluationError = class extends Error {
1243
+ constructor(message) {
1244
+ super(message);
1245
+ this.name = "EvaluationError";
1246
+ }
1247
+ };
1248
+ function execOnIterable(iterable, func) {
1249
+ if (iterable === null) {
1250
+ throw new EvaluationError("value not iterable");
1251
+ }
1252
+ if (typeof iterable === "object" && !Array.isArray(iterable) && !(iterable instanceof Set)) {
1253
+ iterable = Object.keys(iterable);
1254
+ }
1255
+ if (typeof iterable?.[Symbol.iterator] !== "function") {
1256
+ throw new EvaluationError("value not iterable");
1257
+ }
1258
+ return func(iterable);
1259
+ }
1260
+ var BUILTINS = {
1261
+ /**
1262
+ * @param {any} value
1263
+ * @returns {boolean}
1264
+ */
1265
+ bool(value) {
1266
+ switch (typeof value) {
1267
+ case "number":
1268
+ return value !== 0;
1269
+ case "string":
1270
+ return value !== "";
1271
+ case "boolean":
1272
+ return value;
1273
+ case "object":
1274
+ if (value === null || value === void 0) {
1275
+ return false;
1276
+ }
1277
+ if ("isTrue" in value && typeof value.isTrue === "function") {
1278
+ return value.isTrue();
1279
+ }
1280
+ if (value instanceof Array) {
1281
+ return !!value.length;
1282
+ }
1283
+ if (value instanceof Set) {
1284
+ return !!value.size;
1285
+ }
1286
+ return Object.keys(value).length !== 0;
1287
+ default:
1288
+ return true;
1644
1289
  }
1645
- for (const key of ABSOLUTE_KEYS) {
1646
- params[key] = key in params ? params[key] : null;
1290
+ },
1291
+ set(iterable) {
1292
+ if (arguments.length > 2) {
1293
+ throw new EvaluationError(
1294
+ `set expected at most 1 argument, got (${arguments.length - 1})`
1295
+ );
1647
1296
  }
1648
- params.days += 7 * params.weeks;
1649
- let yearDay = 0;
1650
- if (params.nlyearday) {
1651
- yearDay = params.nlyearday;
1652
- } else if (params.yearday) {
1653
- yearDay = params.yearday;
1654
- if (yearDay > 59) {
1655
- params.leapDays = -1;
1656
- }
1297
+ return execOnIterable(
1298
+ iterable,
1299
+ (iterable2) => new Set(iterable2)
1300
+ );
1301
+ },
1302
+ time: {
1303
+ strftime(format) {
1304
+ return PyDateTime.now().strftime(format);
1657
1305
  }
1658
- if (yearDay) {
1659
- for (let monthIndex = 0; monthIndex < DAYS_IN_YEAR.length; monthIndex++) {
1660
- if (yearDay <= DAYS_IN_YEAR[monthIndex]) {
1661
- params.month = monthIndex + 1;
1662
- if (monthIndex === 0) {
1663
- params.day = yearDay;
1664
- } else {
1665
- params.day = yearDay - DAYS_IN_YEAR[monthIndex - 1];
1666
- }
1667
- break;
1306
+ },
1307
+ context_today() {
1308
+ return PyDate.today();
1309
+ },
1310
+ get current_date() {
1311
+ return this.today;
1312
+ },
1313
+ get today() {
1314
+ return PyDate.today().strftime("%Y-%m-%d");
1315
+ },
1316
+ get now() {
1317
+ return PyDateTime.now().strftime("%Y-%m-%d %H:%M:%S");
1318
+ },
1319
+ datetime: {
1320
+ time: PyTime,
1321
+ timedelta: PyTimeDelta,
1322
+ datetime: PyDateTime,
1323
+ date: PyDate
1324
+ },
1325
+ relativedelta: PyRelativeDelta,
1326
+ true: true,
1327
+ false: false
1328
+ };
1329
+
1330
+ // src/utils/domain/py_utils.ts
1331
+ function toPyValue(value) {
1332
+ switch (typeof value) {
1333
+ case "string":
1334
+ return { type: 1, value };
1335
+ case "number":
1336
+ return { type: 0, value };
1337
+ case "boolean":
1338
+ return { type: 2, value };
1339
+ case "object":
1340
+ if (Array.isArray(value)) {
1341
+ return { type: 4, value: value.map(toPyValue) };
1342
+ } else if (value === null) {
1343
+ return {
1344
+ type: 3
1345
+ /* None */
1346
+ };
1347
+ } else if (value instanceof Date) {
1348
+ return {
1349
+ type: 1,
1350
+ value: String(PyDateTime.convertDate(value))
1351
+ };
1352
+ } else if (value instanceof PyDate || value instanceof PyDateTime) {
1353
+ return { type: 1, value };
1354
+ } else {
1355
+ const content = {};
1356
+ for (const key in value) {
1357
+ content[key] = toPyValue(value[key]);
1668
1358
  }
1359
+ return { type: 11, value: content };
1669
1360
  }
1670
- }
1671
- return new _PyRelativeDelta(params);
1672
- }
1673
- static add(date, delta) {
1674
- if (!(date instanceof PyDate || date instanceof PyDateTime)) {
1675
- throw new NotSupportedError();
1676
- }
1677
- const s = tmxxx(
1678
- (delta.year || date.year) + delta.years,
1679
- (delta.month || date.month) + delta.months,
1680
- delta.day || date.day,
1681
- delta.hour || (date instanceof PyDateTime ? date.hour : 0),
1682
- delta.minute || (date instanceof PyDateTime ? date.minute : 0),
1683
- delta.second || (date instanceof PyDateTime ? date.second : 0),
1684
- delta.microseconds || (date instanceof PyDateTime ? date.microsecond : 0)
1685
- );
1686
- const newDateTime = new PyDateTime(
1687
- s.year,
1688
- s.month,
1689
- s.day,
1690
- s.hour,
1691
- s.minute,
1692
- s.second,
1693
- s.microsecond
1694
- );
1695
- let leapDays = 0;
1696
- if (delta.leapDays && newDateTime.month > 2 && isLeap(newDateTime.year)) {
1697
- leapDays = delta.leapDays;
1698
- }
1699
- const temp = newDateTime.add(
1700
- PyTimeDelta.create({
1701
- days: delta.days + leapDays,
1702
- hours: delta.hours,
1703
- minutes: delta.minutes,
1704
- seconds: delta.seconds,
1705
- microseconds: delta.microseconds
1706
- })
1707
- );
1708
- const hasTime = Boolean(
1709
- temp.hour || temp.minute || temp.second || temp.microsecond
1710
- );
1711
- const returnDate = !hasTime && date instanceof PyDate ? new PyDate(temp.year, temp.month, temp.day) : temp;
1712
- if (delta.weekday !== null) {
1713
- const wantedDow = delta.weekday + 1;
1714
- const _date = new Date(
1715
- returnDate.year,
1716
- returnDate.month - 1,
1717
- returnDate.day
1718
- );
1719
- const days = (7 - _date.getDay() + wantedDow) % 7;
1720
- return returnDate.add(new PyTimeDelta(days, 0, 0));
1721
- }
1722
- return returnDate;
1723
- }
1724
- static substract(date, delta) {
1725
- return _PyRelativeDelta.add(date, delta.negate());
1726
- }
1727
- constructor(params = {}, sign = 1) {
1728
- this.years = sign * params.years;
1729
- this.months = sign * params.months;
1730
- this.days = sign * params.days;
1731
- this.hours = sign * params.hours;
1732
- this.minutes = sign * params.minutes;
1733
- this.seconds = sign * params.seconds;
1734
- this.microseconds = sign * params.microseconds;
1735
- this.leapDays = params.leapDays;
1736
- this.year = params.year;
1737
- this.month = params.month;
1738
- this.day = params.day;
1739
- this.hour = params.hour;
1740
- this.minute = params.minute;
1741
- this.second = params.second;
1742
- this.microsecond = params.microsecond;
1743
- this.weekday = params.weekday;
1361
+ default:
1362
+ throw new Error("Invalid type");
1744
1363
  }
1745
- years;
1746
- months;
1747
- days;
1748
- hours;
1749
- minutes;
1750
- seconds;
1751
- microseconds;
1752
- leapDays;
1753
- year;
1754
- month;
1755
- day;
1756
- hour;
1757
- minute;
1758
- second;
1759
- microsecond;
1760
- weekday;
1761
- negate() {
1762
- return new _PyRelativeDelta(this, -1);
1364
+ }
1365
+ function formatAST(ast, lbp = 0) {
1366
+ switch (ast.type) {
1367
+ case 3:
1368
+ return "None";
1369
+ case 1:
1370
+ return JSON.stringify(ast.value);
1371
+ case 0:
1372
+ return String(ast.value);
1373
+ case 2:
1374
+ return ast.value ? "True" : "False";
1375
+ case 4:
1376
+ return `[${ast.value.map(formatAST).join(", ")}]`;
1377
+ case 6:
1378
+ if (ast.op === "not") {
1379
+ return `not ${formatAST(ast.right, 50)}`;
1380
+ }
1381
+ return `${ast.op}${formatAST(ast.right, 130)}`;
1382
+ case 7:
1383
+ const abp = bp(ast.op);
1384
+ const binaryStr = `${formatAST(ast.left, abp)} ${ast.op} ${formatAST(ast.right, abp)}`;
1385
+ return abp < lbp ? `(${binaryStr})` : binaryStr;
1386
+ case 11:
1387
+ const pairs = [];
1388
+ for (const k in ast.value) {
1389
+ pairs.push(`"${k}": ${formatAST(ast.value[k])}`);
1390
+ }
1391
+ return `{${pairs.join(", ")}}`;
1392
+ case 10:
1393
+ return `(${ast.value.map(formatAST).join(", ")})`;
1394
+ case 5:
1395
+ return ast.value;
1396
+ case 12:
1397
+ return `${formatAST(ast.target)}[${formatAST(ast.key)}]`;
1398
+ case 13:
1399
+ const { ifTrue, condition, ifFalse } = ast;
1400
+ return `${formatAST(ifTrue)} if ${formatAST(condition)} else ${formatAST(ifFalse)}`;
1401
+ case 14:
1402
+ const boolAbp = bp(ast.op);
1403
+ const boolStr = `${formatAST(ast.left, boolAbp)} ${ast.op} ${formatAST(ast.right, boolAbp)}`;
1404
+ return boolAbp < lbp ? `(${boolStr})` : boolStr;
1405
+ case 15:
1406
+ return `${formatAST(ast.obj, 150)}.${ast.key}`;
1407
+ case 8:
1408
+ const args = ast.args.map(formatAST);
1409
+ const kwargs = [];
1410
+ for (const kwarg in ast.kwargs) {
1411
+ kwargs.push(`${kwarg} = ${formatAST(ast.kwargs[kwarg])}`);
1412
+ }
1413
+ const argStr = args.concat(kwargs).join(", ");
1414
+ return `${formatAST(ast.fn)}(${argStr})`;
1415
+ default:
1416
+ throw new Error("invalid expression: " + JSON.stringify(ast));
1763
1417
  }
1764
- isEqual() {
1765
- throw new NotSupportedError();
1418
+ }
1419
+ var PY_DICT = /* @__PURE__ */ Object.create(null);
1420
+ function toPyDict(obj) {
1421
+ return new Proxy(obj, {
1422
+ getPrototypeOf() {
1423
+ return PY_DICT;
1424
+ }
1425
+ });
1426
+ }
1427
+
1428
+ // src/utils/domain/py_interpreter.ts
1429
+ var isTrue = BUILTINS.bool;
1430
+ function applyUnaryOp(ast, context) {
1431
+ const value = evaluate(ast.right, context);
1432
+ switch (ast.op) {
1433
+ case "-":
1434
+ if (value instanceof Object && "negate" in value) {
1435
+ return value.negate();
1436
+ }
1437
+ return -value;
1438
+ case "+":
1439
+ return value;
1440
+ case "not":
1441
+ return !isTrue(value);
1442
+ default:
1443
+ throw new EvaluationError(`Unknown unary operator: ${ast.op}`);
1766
1444
  }
1767
- };
1768
- var TIME_DELTA_KEYS = "weeks days hours minutes seconds milliseconds microseconds".split(" ");
1769
- function modf(x) {
1770
- const mod = x % 1;
1771
- return [mod < 0 ? mod + 1 : mod, Math.floor(x)];
1772
1445
  }
1773
- var PyTimeDelta = class _PyTimeDelta {
1774
- constructor(days, seconds, microseconds) {
1775
- this.days = days;
1776
- this.seconds = seconds;
1777
- this.microseconds = microseconds;
1446
+ function pytypeIndex(val) {
1447
+ switch (typeof val) {
1448
+ case "object":
1449
+ return val === null ? 1 : Array.isArray(val) ? 5 : 3;
1450
+ case "number":
1451
+ return 2;
1452
+ case "string":
1453
+ return 4;
1454
+ default:
1455
+ throw new EvaluationError(`Unknown type: ${typeof val}`);
1778
1456
  }
1779
- static create(...args) {
1780
- const namedArgs = parseArgs(args, ["days", "seconds", "microseconds"]);
1781
- for (const key of TIME_DELTA_KEYS) {
1782
- namedArgs[key] = namedArgs[key] || 0;
1783
- }
1784
- let d = 0;
1785
- let s = 0;
1786
- let us = 0;
1787
- const days = namedArgs.days + namedArgs.weeks * 7;
1788
- let seconds = namedArgs.seconds + 60 * namedArgs.minutes + 3600 * namedArgs.hours;
1789
- let microseconds = namedArgs.microseconds + 1e3 * namedArgs.milliseconds;
1790
- const [dFrac, dInt] = modf(days);
1791
- d = dInt;
1792
- let daysecondsfrac = 0;
1793
- if (dFrac) {
1794
- const [dsFrac, dsInt] = modf(dFrac * 24 * 3600);
1795
- s = dsInt;
1796
- daysecondsfrac = dsFrac;
1797
- }
1798
- const [sFrac, sInt] = modf(seconds);
1799
- seconds = sInt;
1800
- const secondsfrac = sFrac + daysecondsfrac;
1801
- divmod(seconds, 24 * 3600, (days2, seconds2) => {
1802
- d += days2;
1803
- s += seconds2;
1804
- });
1805
- microseconds += secondsfrac * 1e6;
1806
- divmod(microseconds, 1e6, (seconds2, microseconds2) => {
1807
- divmod(seconds2, 24 * 3600, (days2, seconds3) => {
1808
- d += days2;
1809
- s += seconds3;
1810
- us += Math.round(microseconds2);
1811
- });
1812
- });
1813
- return new _PyTimeDelta(d, s, us);
1457
+ }
1458
+ function isLess(left, right) {
1459
+ if (typeof left === "number" && typeof right === "number") {
1460
+ return left < right;
1814
1461
  }
1815
- add(other) {
1816
- return _PyTimeDelta.create({
1817
- days: this.days + other.days,
1818
- seconds: this.seconds + other.seconds,
1819
- microseconds: this.microseconds + other.microseconds
1820
- });
1462
+ if (typeof left === "boolean") {
1463
+ left = left ? 1 : 0;
1821
1464
  }
1822
- divide(n) {
1823
- const us = (this.days * 24 * 3600 + this.seconds) * 1e6 + this.microseconds;
1824
- return _PyTimeDelta.create({ microseconds: Math.floor(us / n) });
1465
+ if (typeof right === "boolean") {
1466
+ right = right ? 1 : 0;
1825
1467
  }
1826
- isEqual(other) {
1827
- if (!(other instanceof _PyTimeDelta)) {
1828
- return false;
1468
+ const leftIndex = pytypeIndex(left);
1469
+ const rightIndex = pytypeIndex(right);
1470
+ if (leftIndex === rightIndex) {
1471
+ return left < right;
1472
+ }
1473
+ return leftIndex < rightIndex;
1474
+ }
1475
+ function isEqual(left, right) {
1476
+ if (typeof left !== typeof right) {
1477
+ if (typeof left === "boolean" && typeof right === "number") {
1478
+ return right === (left ? 1 : 0);
1829
1479
  }
1830
- return this.days === other.days && this.seconds === other.seconds && this.microseconds === other.microseconds;
1480
+ if (typeof left === "number" && typeof right === "boolean") {
1481
+ return left === (right ? 1 : 0);
1482
+ }
1483
+ return false;
1831
1484
  }
1832
- isTrue() {
1833
- return this.days !== 0 || this.seconds !== 0 || this.microseconds !== 0;
1485
+ if (left instanceof Object && "isEqual" in left) {
1486
+ return left.isEqual(right);
1834
1487
  }
1835
- multiply(n) {
1836
- return _PyTimeDelta.create({
1837
- days: n * this.days,
1838
- seconds: n * this.seconds,
1839
- microseconds: n * this.microseconds
1840
- });
1488
+ return left === right;
1489
+ }
1490
+ function isIn(left, right) {
1491
+ if (Array.isArray(right)) {
1492
+ return right.includes(left);
1841
1493
  }
1842
- negate() {
1843
- return _PyTimeDelta.create({
1844
- days: -this.days,
1845
- seconds: -this.seconds,
1846
- microseconds: -this.microseconds
1847
- });
1494
+ if (typeof right === "string" && typeof left === "string") {
1495
+ return right.includes(left);
1848
1496
  }
1849
- substract(other) {
1850
- return _PyTimeDelta.create({
1851
- days: this.days - other.days,
1852
- seconds: this.seconds - other.seconds,
1853
- microseconds: this.microseconds - other.microseconds
1854
- });
1497
+ if (typeof right === "object") {
1498
+ return left in right;
1855
1499
  }
1856
- total_seconds() {
1857
- return this.days * 86400 + this.seconds + this.microseconds / 1e6;
1500
+ return false;
1501
+ }
1502
+ function applyBinaryOp(ast, context) {
1503
+ const left = evaluate(ast.left, context);
1504
+ const right = evaluate(ast.right, context);
1505
+ switch (ast.op) {
1506
+ case "+": {
1507
+ const relativeDeltaOnLeft = left instanceof PyRelativeDelta;
1508
+ const relativeDeltaOnRight = right instanceof PyRelativeDelta;
1509
+ if (relativeDeltaOnLeft || relativeDeltaOnRight) {
1510
+ const date = relativeDeltaOnLeft ? right : left;
1511
+ const delta = relativeDeltaOnLeft ? left : right;
1512
+ return PyRelativeDelta.add(date, delta);
1513
+ }
1514
+ const timeDeltaOnLeft = left instanceof PyTimeDelta;
1515
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
1516
+ if (timeDeltaOnLeft && timeDeltaOnRight) {
1517
+ return left.add(right);
1518
+ }
1519
+ if (timeDeltaOnLeft) {
1520
+ if (right instanceof PyDate || right instanceof PyDateTime) {
1521
+ return right.add(left);
1522
+ } else {
1523
+ throw new NotSupportedError();
1524
+ }
1525
+ }
1526
+ if (timeDeltaOnRight) {
1527
+ if (left instanceof PyDate || left instanceof PyDateTime) {
1528
+ return left.add(right);
1529
+ } else {
1530
+ throw new NotSupportedError();
1531
+ }
1532
+ }
1533
+ if (left instanceof Array && right instanceof Array) {
1534
+ return [...left, ...right];
1535
+ }
1536
+ return left + right;
1537
+ }
1538
+ case "-": {
1539
+ const isRightDelta = right instanceof PyRelativeDelta;
1540
+ if (isRightDelta) {
1541
+ return PyRelativeDelta.substract(left, right);
1542
+ }
1543
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
1544
+ if (timeDeltaOnRight) {
1545
+ if (left instanceof PyTimeDelta) {
1546
+ return left.substract(right);
1547
+ } else if (left instanceof PyDate || left instanceof PyDateTime) {
1548
+ return left.substract(right);
1549
+ } else {
1550
+ throw new NotSupportedError();
1551
+ }
1552
+ }
1553
+ if (left instanceof PyDate) {
1554
+ return left.substract(right);
1555
+ }
1556
+ return left - right;
1557
+ }
1558
+ case "*": {
1559
+ const timeDeltaOnLeft = left instanceof PyTimeDelta;
1560
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
1561
+ if (timeDeltaOnLeft || timeDeltaOnRight) {
1562
+ const number = timeDeltaOnLeft ? right : left;
1563
+ const delta = timeDeltaOnLeft ? left : right;
1564
+ return delta.multiply(number);
1565
+ }
1566
+ return left * right;
1567
+ }
1568
+ case "/":
1569
+ return left / right;
1570
+ case "%":
1571
+ return left % right;
1572
+ case "//":
1573
+ if (left instanceof PyTimeDelta) {
1574
+ return left.divide(right);
1575
+ }
1576
+ return Math.floor(left / right);
1577
+ case "**":
1578
+ return left ** right;
1579
+ case "==":
1580
+ return isEqual(left, right);
1581
+ case "<>":
1582
+ case "!=":
1583
+ return !isEqual(left, right);
1584
+ case "<":
1585
+ return isLess(left, right);
1586
+ case ">":
1587
+ return isLess(right, left);
1588
+ case ">=":
1589
+ return isEqual(left, right) || isLess(right, left);
1590
+ case "<=":
1591
+ return isEqual(left, right) || isLess(left, right);
1592
+ case "in":
1593
+ return isIn(left, right);
1594
+ case "not in":
1595
+ return !isIn(left, right);
1596
+ default:
1597
+ throw new EvaluationError(`Unknown binary operator: ${ast.op}`);
1598
+ }
1599
+ }
1600
+ var DICT = {
1601
+ get(...args) {
1602
+ const { key, defValue } = parseArgs(args, ["key", "defValue"]);
1603
+ const self = this;
1604
+ if (key in self) {
1605
+ return self[key];
1606
+ } else if (defValue !== void 0) {
1607
+ return defValue;
1608
+ }
1609
+ return null;
1858
1610
  }
1859
1611
  };
1860
-
1861
- // src/utils/domain/py_builtin.ts
1862
- var EvaluationError = class extends Error {
1863
- constructor(message) {
1864
- super(message);
1865
- this.name = "EvaluationError";
1612
+ var STRING = {
1613
+ lower() {
1614
+ return this.toLowerCase();
1615
+ },
1616
+ upper() {
1617
+ return this.toUpperCase();
1866
1618
  }
1867
1619
  };
1868
- function execOnIterable(iterable, func) {
1869
- if (iterable === null) {
1870
- throw new EvaluationError("value not iterable");
1620
+ function applyFunc(key, func, set, ...args) {
1621
+ if (args.length === 1) {
1622
+ return new Set(set);
1871
1623
  }
1872
- if (typeof iterable === "object" && !Array.isArray(iterable) && !(iterable instanceof Set)) {
1873
- iterable = Object.keys(iterable);
1624
+ if (args.length > 2) {
1625
+ throw new EvaluationError(
1626
+ `${key}: py_js supports at most 1 argument, got (${args.length - 1})`
1627
+ );
1874
1628
  }
1875
- if (typeof iterable?.[Symbol.iterator] !== "function") {
1876
- throw new EvaluationError("value not iterable");
1629
+ return execOnIterable(args[0], func);
1630
+ }
1631
+ var SET = {
1632
+ intersection(...args) {
1633
+ return applyFunc(
1634
+ "intersection",
1635
+ (iterable) => {
1636
+ const intersection = /* @__PURE__ */ new Set();
1637
+ for (const i of iterable) {
1638
+ if (this.has(i)) {
1639
+ intersection.add(i);
1640
+ }
1641
+ }
1642
+ return intersection;
1643
+ },
1644
+ this,
1645
+ ...args
1646
+ );
1647
+ },
1648
+ difference(...args) {
1649
+ return applyFunc(
1650
+ "difference",
1651
+ (iterable) => {
1652
+ iterable = new Set(iterable);
1653
+ const difference = /* @__PURE__ */ new Set();
1654
+ for (const e of this) {
1655
+ if (!iterable.has(e)) {
1656
+ difference.add(e);
1657
+ }
1658
+ }
1659
+ return difference;
1660
+ },
1661
+ this,
1662
+ ...args
1663
+ );
1664
+ },
1665
+ union(...args) {
1666
+ return applyFunc(
1667
+ "union",
1668
+ (iterable) => {
1669
+ return /* @__PURE__ */ new Set([...this, ...iterable]);
1670
+ },
1671
+ this,
1672
+ ...args
1673
+ );
1674
+ }
1675
+ };
1676
+ function methods(_class) {
1677
+ return Object.getOwnPropertyNames(_class.prototype).map(
1678
+ (prop) => _class.prototype[prop]
1679
+ );
1680
+ }
1681
+ var allowedFns = /* @__PURE__ */ new Set([
1682
+ BUILTINS.time.strftime,
1683
+ BUILTINS.set,
1684
+ BUILTINS.bool,
1685
+ BUILTINS.context_today,
1686
+ BUILTINS.datetime.datetime.now,
1687
+ BUILTINS.datetime.datetime.combine,
1688
+ BUILTINS.datetime.date.today,
1689
+ ...methods(BUILTINS.relativedelta),
1690
+ ...Object.values(BUILTINS.datetime).flatMap((obj) => methods(obj)),
1691
+ ...Object.values(SET),
1692
+ ...Object.values(DICT),
1693
+ ...Object.values(STRING)
1694
+ ]);
1695
+ var unboundFn = Symbol("unbound function");
1696
+ function evaluate(ast, context = {}) {
1697
+ const dicts = /* @__PURE__ */ new Set();
1698
+ let pyContext;
1699
+ const evalContext = Object.create(context);
1700
+ if (!evalContext?.context) {
1701
+ Object.defineProperty(evalContext, "context", {
1702
+ get() {
1703
+ if (!pyContext) {
1704
+ pyContext = toPyDict(context);
1705
+ }
1706
+ return pyContext;
1707
+ }
1708
+ });
1877
1709
  }
1878
- return func(iterable);
1879
- }
1880
- var BUILTINS = {
1881
- /**
1882
- * @param {any} value
1883
- * @returns {boolean}
1884
- */
1885
- bool(value) {
1886
- switch (typeof value) {
1887
- case "number":
1888
- return value !== 0;
1889
- case "string":
1890
- return value !== "";
1891
- case "boolean":
1892
- return value;
1893
- case "object":
1894
- if (value === null || value === void 0) {
1710
+ function _innerEvaluate(ast2) {
1711
+ switch (ast2?.type) {
1712
+ case 0:
1713
+ // Number
1714
+ case 1:
1715
+ return ast2.value;
1716
+ case 5:
1717
+ if (ast2.value in evalContext) {
1718
+ if (typeof evalContext[ast2.value] === "object" && evalContext[ast2.value]?.id) {
1719
+ return evalContext[ast2.value]?.id;
1720
+ }
1721
+ return evalContext[ast2.value] ?? false;
1722
+ } else if (ast2.value in BUILTINS) {
1723
+ return BUILTINS[ast2.value];
1724
+ } else {
1895
1725
  return false;
1896
1726
  }
1897
- if ("isTrue" in value && typeof value.isTrue === "function") {
1898
- return value.isTrue();
1727
+ case 3:
1728
+ return null;
1729
+ case 2:
1730
+ return ast2.value;
1731
+ case 6:
1732
+ return applyUnaryOp(ast2, evalContext);
1733
+ case 7:
1734
+ return applyBinaryOp(ast2, evalContext);
1735
+ case 14:
1736
+ const left = _evaluate(ast2.left);
1737
+ if (ast2.op === "and") {
1738
+ return isTrue(left) ? _evaluate(ast2.right) : left;
1739
+ } else {
1740
+ return isTrue(left) ? left : _evaluate(ast2.right);
1899
1741
  }
1900
- if (value instanceof Array) {
1901
- return !!value.length;
1742
+ case 4:
1743
+ // List
1744
+ case 10:
1745
+ return ast2.value.map(_evaluate);
1746
+ case 11:
1747
+ const dict = {};
1748
+ for (const key2 in ast2.value) {
1749
+ dict[key2] = _evaluate(ast2.value[key2]);
1902
1750
  }
1903
- if (value instanceof Set) {
1904
- return !!value.size;
1751
+ dicts.add(dict);
1752
+ return dict;
1753
+ case 8:
1754
+ const fnValue = _evaluate(ast2.fn);
1755
+ const args = ast2.args.map(_evaluate);
1756
+ const kwargs = {};
1757
+ for (const kwarg in ast2.kwargs) {
1758
+ kwargs[kwarg] = _evaluate(ast2?.kwargs[kwarg]);
1905
1759
  }
1906
- return Object.keys(value).length !== 0;
1760
+ if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
1761
+ return fnValue.create(...args, kwargs);
1762
+ }
1763
+ return fnValue(...args, kwargs);
1764
+ case 12:
1765
+ const dictVal = _evaluate(ast2.target);
1766
+ const key = _evaluate(ast2.key);
1767
+ return dictVal[key];
1768
+ case 13:
1769
+ if (isTrue(_evaluate(ast2.condition))) {
1770
+ return _evaluate(ast2.ifTrue);
1771
+ } else {
1772
+ return _evaluate(ast2.ifFalse);
1773
+ }
1774
+ case 15:
1775
+ let leftVal = _evaluate(ast2.obj);
1776
+ let result;
1777
+ if (dicts.has(leftVal) || Object.isPrototypeOf.call(PY_DICT, leftVal)) {
1778
+ result = DICT[ast2.key];
1779
+ } else if (typeof leftVal === "string") {
1780
+ result = STRING[ast2.key];
1781
+ } else if (leftVal instanceof Set) {
1782
+ result = SET[ast2.key];
1783
+ } else if (ast2.key === "get" && typeof leftVal === "object") {
1784
+ result = DICT[ast2.key];
1785
+ leftVal = toPyDict(leftVal);
1786
+ } else {
1787
+ result = leftVal[ast2.key];
1788
+ }
1789
+ if (typeof result === "function") {
1790
+ const bound = result.bind(leftVal);
1791
+ bound[unboundFn] = result;
1792
+ return bound;
1793
+ }
1794
+ return result;
1907
1795
  default:
1908
- return true;
1909
- }
1910
- },
1911
- set(iterable) {
1912
- if (arguments.length > 2) {
1913
- throw new EvaluationError(
1914
- `set expected at most 1 argument, got (${arguments.length - 1})`
1915
- );
1916
- }
1917
- return execOnIterable(
1918
- iterable,
1919
- (iterable2) => new Set(iterable2)
1920
- );
1921
- },
1922
- time: {
1923
- strftime(format) {
1924
- return PyDateTime.now().strftime(format);
1796
+ throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
1925
1797
  }
1926
- },
1927
- context_today() {
1928
- return PyDate.today();
1929
- },
1930
- get current_date() {
1931
- return this.today;
1932
- },
1933
- get today() {
1934
- return PyDate.today().strftime("%Y-%m-%d");
1935
- },
1936
- get now() {
1937
- return PyDateTime.now().strftime("%Y-%m-%d %H:%M:%S");
1938
- },
1939
- datetime: {
1940
- time: PyTime,
1941
- timedelta: PyTimeDelta,
1942
- datetime: PyDateTime,
1943
- date: PyDate
1944
- },
1945
- relativedelta: PyRelativeDelta,
1946
- true: true,
1947
- false: false
1948
- };
1949
-
1950
- // src/utils/domain/py_utils.ts
1951
- function toPyValue(value) {
1952
- switch (typeof value) {
1953
- case "string":
1954
- return { type: 1, value };
1955
- case "number":
1956
- return { type: 0, value };
1957
- case "boolean":
1958
- return { type: 2, value };
1959
- case "object":
1960
- if (Array.isArray(value)) {
1961
- return { type: 4, value: value.map(toPyValue) };
1962
- } else if (value === null) {
1963
- return {
1964
- type: 3
1965
- /* None */
1966
- };
1967
- } else if (value instanceof Date) {
1968
- return {
1969
- type: 1,
1970
- value: String(PyDateTime.convertDate(value))
1971
- };
1972
- } else if (value instanceof PyDate || value instanceof PyDateTime) {
1973
- return { type: 1, value };
1974
- } else {
1975
- const content = {};
1976
- for (const key in value) {
1977
- content[key] = toPyValue(value[key]);
1978
- }
1979
- return { type: 11, value: content };
1980
- }
1981
- default:
1982
- throw new Error("Invalid type");
1983
1798
  }
1984
- }
1985
- function formatAST(ast, lbp = 0) {
1986
- switch (ast.type) {
1987
- case 3:
1988
- return "None";
1989
- case 1:
1990
- return JSON.stringify(ast.value);
1991
- case 0:
1992
- return String(ast.value);
1993
- case 2:
1994
- return ast.value ? "True" : "False";
1995
- case 4:
1996
- return `[${ast.value.map(formatAST).join(", ")}]`;
1997
- case 6:
1998
- if (ast.op === "not") {
1999
- return `not ${formatAST(ast.right, 50)}`;
2000
- }
2001
- return `${ast.op}${formatAST(ast.right, 130)}`;
2002
- case 7:
2003
- const abp = bp(ast.op);
2004
- const binaryStr = `${formatAST(ast.left, abp)} ${ast.op} ${formatAST(ast.right, abp)}`;
2005
- return abp < lbp ? `(${binaryStr})` : binaryStr;
2006
- case 11:
2007
- const pairs = [];
2008
- for (const k in ast.value) {
2009
- pairs.push(`"${k}": ${formatAST(ast.value[k])}`);
2010
- }
2011
- return `{${pairs.join(", ")}}`;
2012
- case 10:
2013
- return `(${ast.value.map(formatAST).join(", ")})`;
2014
- case 5:
2015
- return ast.value;
2016
- case 12:
2017
- return `${formatAST(ast.target)}[${formatAST(ast.key)}]`;
2018
- case 13:
2019
- const { ifTrue, condition, ifFalse } = ast;
2020
- return `${formatAST(ifTrue)} if ${formatAST(condition)} else ${formatAST(ifFalse)}`;
2021
- case 14:
2022
- const boolAbp = bp(ast.op);
2023
- const boolStr = `${formatAST(ast.left, boolAbp)} ${ast.op} ${formatAST(ast.right, boolAbp)}`;
2024
- return boolAbp < lbp ? `(${boolStr})` : boolStr;
2025
- case 15:
2026
- return `${formatAST(ast.obj, 150)}.${ast.key}`;
2027
- case 8:
2028
- const args = ast.args.map(formatAST);
2029
- const kwargs = [];
2030
- for (const kwarg in ast.kwargs) {
2031
- kwargs.push(`${kwarg} = ${formatAST(ast.kwargs[kwarg])}`);
2032
- }
2033
- const argStr = args.concat(kwargs).join(", ");
2034
- return `${formatAST(ast.fn)}(${argStr})`;
2035
- default:
2036
- throw new Error("invalid expression: " + JSON.stringify(ast));
1799
+ function _evaluate(ast2) {
1800
+ const val = _innerEvaluate(ast2);
1801
+ if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
1802
+ throw new Error("Invalid Function Call");
1803
+ }
1804
+ return val;
2037
1805
  }
1806
+ return _evaluate(ast);
2038
1807
  }
2039
- var PY_DICT = /* @__PURE__ */ Object.create(null);
2040
- function toPyDict(obj) {
2041
- return new Proxy(obj, {
2042
- getPrototypeOf() {
2043
- return PY_DICT;
2044
- }
2045
- });
1808
+
1809
+ // src/utils/domain/py.ts
1810
+ function parseExpr(expr) {
1811
+ const tokens = tokenize(expr);
1812
+ return parse(tokens);
2046
1813
  }
2047
1814
 
2048
- // src/utils/domain/py_interpreter.ts
2049
- var isTrue = BUILTINS.bool;
2050
- function applyUnaryOp(ast, context) {
2051
- const value = evaluate(ast.right, context);
2052
- switch (ast.op) {
2053
- case "-":
2054
- if (value instanceof Object && "negate" in value) {
2055
- return value.negate();
2056
- }
2057
- return -value;
2058
- case "+":
2059
- return value;
2060
- case "not":
2061
- return !isTrue(value);
2062
- default:
2063
- throw new EvaluationError(`Unknown unary operator: ${ast.op}`);
1815
+ // src/utils/domain/objects.ts
1816
+ function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
1817
+ if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
1818
+ return obj1 === obj2;
2064
1819
  }
1820
+ const obj1Keys = Object.keys(obj1);
1821
+ return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
2065
1822
  }
2066
- function pytypeIndex(val) {
2067
- switch (typeof val) {
2068
- case "object":
2069
- return val === null ? 1 : Array.isArray(val) ? 5 : 3;
2070
- case "number":
2071
- return 2;
2072
- case "string":
2073
- return 4;
2074
- default:
2075
- throw new EvaluationError(`Unknown type: ${typeof val}`);
2076
- }
1823
+
1824
+ // src/utils/domain/arrays.ts
1825
+ var shallowEqual2 = shallowEqual;
1826
+
1827
+ // src/utils/domain/strings.ts
1828
+ var escapeMethod = Symbol("html");
1829
+ function escapeRegExp(str) {
1830
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2077
1831
  }
2078
- function isLess(left, right) {
2079
- if (typeof left === "number" && typeof right === "number") {
2080
- return left < right;
1832
+
1833
+ // src/utils/domain/domain.ts
1834
+ var InvalidDomainError = class extends Error {
1835
+ };
1836
+ var Domain = class _Domain {
1837
+ ast = { type: -1, value: null };
1838
+ static TRUE;
1839
+ static FALSE;
1840
+ static combine(domains, operator) {
1841
+ if (domains.length === 0) {
1842
+ return new _Domain([]);
1843
+ }
1844
+ const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
1845
+ if (domains.length === 1) {
1846
+ return domain1;
1847
+ }
1848
+ const domain2 = _Domain.combine(domains.slice(1), operator);
1849
+ const result = new _Domain([]);
1850
+ const astValues1 = domain1.ast.value;
1851
+ const astValues2 = domain2.ast.value;
1852
+ const op = operator === "AND" ? "&" : "|";
1853
+ const combinedAST = {
1854
+ type: 4,
1855
+ value: astValues1.concat(astValues2)
1856
+ };
1857
+ result.ast = normalizeDomainAST(combinedAST, op);
1858
+ return result;
2081
1859
  }
2082
- if (typeof left === "boolean") {
2083
- left = left ? 1 : 0;
1860
+ static and(domains) {
1861
+ return _Domain.combine(domains, "AND");
2084
1862
  }
2085
- if (typeof right === "boolean") {
2086
- right = right ? 1 : 0;
1863
+ static or(domains) {
1864
+ return _Domain.combine(domains, "OR");
2087
1865
  }
2088
- const leftIndex = pytypeIndex(left);
2089
- const rightIndex = pytypeIndex(right);
2090
- if (leftIndex === rightIndex) {
2091
- return left < right;
1866
+ static not(domain) {
1867
+ const result = new _Domain(domain);
1868
+ result.ast.value.unshift({ type: 1, value: "!" });
1869
+ return result;
2092
1870
  }
2093
- return leftIndex < rightIndex;
2094
- }
2095
- function isEqual(left, right) {
2096
- if (typeof left !== typeof right) {
2097
- if (typeof left === "boolean" && typeof right === "number") {
2098
- return right === (left ? 1 : 0);
1871
+ static removeDomainLeaves(domain, keysToRemove) {
1872
+ function processLeaf(elements, idx, operatorCtx, newDomain2) {
1873
+ const leaf = elements[idx];
1874
+ if (leaf.type === 10) {
1875
+ if (keysToRemove.includes(leaf.value[0].value)) {
1876
+ if (operatorCtx === "&") {
1877
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
1878
+ } else if (operatorCtx === "|") {
1879
+ newDomain2.ast.value.push(..._Domain.FALSE.ast.value);
1880
+ }
1881
+ } else {
1882
+ newDomain2.ast.value.push(leaf);
1883
+ }
1884
+ return 1;
1885
+ } else if (leaf.type === 1) {
1886
+ if (leaf.value === "|" && elements[idx + 1].type === 10 && elements[idx + 2].type === 10 && keysToRemove.includes(elements[idx + 1].value[0].value) && keysToRemove.includes(elements[idx + 2].value[0].value)) {
1887
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
1888
+ return 3;
1889
+ }
1890
+ newDomain2.ast.value.push(leaf);
1891
+ if (leaf.value === "!") {
1892
+ return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
1893
+ }
1894
+ const firstLeafSkip = processLeaf(
1895
+ elements,
1896
+ idx + 1,
1897
+ leaf.value,
1898
+ newDomain2
1899
+ );
1900
+ const secondLeafSkip = processLeaf(
1901
+ elements,
1902
+ idx + 1 + firstLeafSkip,
1903
+ leaf.value,
1904
+ newDomain2
1905
+ );
1906
+ return 1 + firstLeafSkip + secondLeafSkip;
1907
+ }
1908
+ return 0;
2099
1909
  }
2100
- if (typeof left === "number" && typeof right === "boolean") {
2101
- return left === (right ? 1 : 0);
1910
+ const d = new _Domain(domain);
1911
+ if (d.ast.value.length === 0) {
1912
+ return d;
2102
1913
  }
2103
- return false;
1914
+ const newDomain = new _Domain([]);
1915
+ processLeaf(d.ast.value, 0, "&", newDomain);
1916
+ return newDomain;
2104
1917
  }
2105
- if (left instanceof Object && "isEqual" in left) {
2106
- return left.isEqual(right);
1918
+ constructor(descr = []) {
1919
+ if (descr instanceof _Domain) {
1920
+ return new _Domain(descr.toString());
1921
+ } else {
1922
+ let rawAST;
1923
+ try {
1924
+ rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
1925
+ } catch (error) {
1926
+ throw new InvalidDomainError(
1927
+ `Invalid domain representation: ${descr}`,
1928
+ {
1929
+ cause: error
1930
+ }
1931
+ );
1932
+ }
1933
+ this.ast = normalizeDomainAST(rawAST);
1934
+ }
2107
1935
  }
2108
- return left === right;
2109
- }
2110
- function isIn(left, right) {
2111
- if (Array.isArray(right)) {
2112
- return right.includes(left);
1936
+ contains(record) {
1937
+ const expr = evaluate(this.ast, record);
1938
+ return matchDomain(record, expr);
2113
1939
  }
2114
- if (typeof right === "string" && typeof left === "string") {
2115
- return right.includes(left);
1940
+ toString() {
1941
+ return formatAST(this.ast);
2116
1942
  }
2117
- if (typeof right === "object") {
2118
- return left in right;
1943
+ toList(context) {
1944
+ return evaluate(this.ast, context);
2119
1945
  }
2120
- return false;
2121
- }
2122
- function applyBinaryOp(ast, context) {
2123
- const left = evaluate(ast.left, context);
2124
- const right = evaluate(ast.right, context);
2125
- switch (ast.op) {
2126
- case "+": {
2127
- const relativeDeltaOnLeft = left instanceof PyRelativeDelta;
2128
- const relativeDeltaOnRight = right instanceof PyRelativeDelta;
2129
- if (relativeDeltaOnLeft || relativeDeltaOnRight) {
2130
- const date = relativeDeltaOnLeft ? right : left;
2131
- const delta = relativeDeltaOnLeft ? left : right;
2132
- return PyRelativeDelta.add(date, delta);
2133
- }
2134
- const timeDeltaOnLeft = left instanceof PyTimeDelta;
2135
- const timeDeltaOnRight = right instanceof PyTimeDelta;
2136
- if (timeDeltaOnLeft && timeDeltaOnRight) {
2137
- return left.add(right);
1946
+ toJson() {
1947
+ try {
1948
+ const evaluatedAsList = this.toList({});
1949
+ const evaluatedDomain = new _Domain(evaluatedAsList);
1950
+ if (evaluatedDomain.toString() === this.toString()) {
1951
+ return evaluatedAsList;
2138
1952
  }
2139
- if (timeDeltaOnLeft) {
2140
- if (right instanceof PyDate || right instanceof PyDateTime) {
2141
- return right.add(left);
2142
- } else {
2143
- throw new NotSupportedError();
2144
- }
1953
+ return this.toString();
1954
+ } catch {
1955
+ return this.toString();
1956
+ }
1957
+ }
1958
+ };
1959
+ var TRUE_LEAF = [1, "=", 1];
1960
+ var FALSE_LEAF = [0, "=", 1];
1961
+ var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
1962
+ var FALSE_DOMAIN = new Domain([FALSE_LEAF]);
1963
+ Domain.TRUE = TRUE_DOMAIN;
1964
+ Domain.FALSE = FALSE_DOMAIN;
1965
+ function toAST(domain) {
1966
+ const elems = domain.map((elem) => {
1967
+ switch (elem) {
1968
+ case "!":
1969
+ case "&":
1970
+ case "|":
1971
+ return { type: 1, value: elem };
1972
+ default:
1973
+ return {
1974
+ type: 10,
1975
+ value: elem.map(toPyValue)
1976
+ };
1977
+ }
1978
+ });
1979
+ return { type: 4, value: elems };
1980
+ }
1981
+ function normalizeDomainAST(domain, op = "&") {
1982
+ if (domain.type !== 4) {
1983
+ if (domain.type === 10) {
1984
+ const value = domain.value;
1985
+ if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
1986
+ throw new InvalidDomainError("Invalid domain AST");
2145
1987
  }
2146
- if (timeDeltaOnRight) {
2147
- if (left instanceof PyDate || left instanceof PyDateTime) {
2148
- return left.add(right);
2149
- } else {
2150
- throw new NotSupportedError();
1988
+ } else {
1989
+ throw new InvalidDomainError("Invalid domain AST");
1990
+ }
1991
+ }
1992
+ if (domain.value.length === 0) {
1993
+ return domain;
1994
+ }
1995
+ let expected = 1;
1996
+ for (const child of domain.value) {
1997
+ switch (child.type) {
1998
+ case 1:
1999
+ if (child.value === "&" || child.value === "|") {
2000
+ expected++;
2001
+ } else if (child.value !== "!") {
2002
+ throw new InvalidDomainError("Invalid domain AST");
2151
2003
  }
2152
- }
2153
- if (left instanceof Array && right instanceof Array) {
2154
- return [...left, ...right];
2155
- }
2156
- return left + right;
2157
- }
2158
- case "-": {
2159
- const isRightDelta = right instanceof PyRelativeDelta;
2160
- if (isRightDelta) {
2161
- return PyRelativeDelta.substract(left, right);
2162
- }
2163
- const timeDeltaOnRight = right instanceof PyTimeDelta;
2164
- if (timeDeltaOnRight) {
2165
- if (left instanceof PyTimeDelta) {
2166
- return left.substract(right);
2167
- } else if (left instanceof PyDate || left instanceof PyDateTime) {
2168
- return left.substract(right);
2169
- } else {
2170
- throw new NotSupportedError();
2004
+ break;
2005
+ case 4:
2006
+ /* list */
2007
+ case 10:
2008
+ if (child.value.length === 3) {
2009
+ expected--;
2010
+ break;
2171
2011
  }
2172
- }
2173
- if (left instanceof PyDate) {
2174
- return left.substract(right);
2175
- }
2176
- return left - right;
2012
+ throw new InvalidDomainError("Invalid domain AST");
2013
+ default:
2014
+ throw new InvalidDomainError("Invalid domain AST");
2177
2015
  }
2178
- case "*": {
2179
- const timeDeltaOnLeft = left instanceof PyTimeDelta;
2180
- const timeDeltaOnRight = right instanceof PyTimeDelta;
2181
- if (timeDeltaOnLeft || timeDeltaOnRight) {
2182
- const number = timeDeltaOnLeft ? right : left;
2183
- const delta = timeDeltaOnLeft ? left : right;
2184
- return delta.multiply(number);
2185
- }
2186
- return left * right;
2016
+ }
2017
+ const values = domain.value.slice();
2018
+ while (expected < 0) {
2019
+ expected++;
2020
+ values.unshift({ type: 1, value: op });
2021
+ }
2022
+ if (expected > 0) {
2023
+ throw new InvalidDomainError(
2024
+ `invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
2025
+ );
2026
+ }
2027
+ return { type: 4, value: values };
2028
+ }
2029
+ function matchCondition(record, condition) {
2030
+ if (typeof condition === "boolean") {
2031
+ return condition;
2032
+ }
2033
+ const [field, operator, value] = condition;
2034
+ if (typeof field === "string") {
2035
+ const names = field.split(".");
2036
+ if (names.length >= 2) {
2037
+ return matchCondition(record[names[0]], [
2038
+ names.slice(1).join("."),
2039
+ operator,
2040
+ value
2041
+ ]);
2187
2042
  }
2188
- case "/":
2189
- return left / right;
2190
- case "%":
2191
- return left % right;
2192
- case "//":
2193
- if (left instanceof PyTimeDelta) {
2194
- return left.divide(right);
2043
+ }
2044
+ let likeRegexp, ilikeRegexp;
2045
+ if (["like", "not like", "ilike", "not ilike"].includes(operator)) {
2046
+ likeRegexp = new RegExp(
2047
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2048
+ "g"
2049
+ );
2050
+ ilikeRegexp = new RegExp(
2051
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2052
+ "gi"
2053
+ );
2054
+ }
2055
+ const fieldValue = typeof field === "number" ? field : record[field];
2056
+ switch (operator) {
2057
+ case "=?":
2058
+ if ([false, null].includes(value)) {
2059
+ return true;
2195
2060
  }
2196
- return Math.floor(left / right);
2197
- case "**":
2198
- return left ** right;
2061
+ // eslint-disable-next-line no-fallthrough
2062
+ case "=":
2199
2063
  case "==":
2200
- return isEqual(left, right);
2201
- case "<>":
2064
+ if (Array.isArray(fieldValue) && Array.isArray(value)) {
2065
+ return shallowEqual2(fieldValue, value);
2066
+ }
2067
+ return fieldValue === value;
2202
2068
  case "!=":
2203
- return !isEqual(left, right);
2069
+ case "<>":
2070
+ return !matchCondition(record, [field, "==", value]);
2204
2071
  case "<":
2205
- return isLess(left, right);
2072
+ return fieldValue < value;
2073
+ case "<=":
2074
+ return fieldValue <= value;
2206
2075
  case ">":
2207
- return isLess(right, left);
2076
+ return fieldValue > value;
2208
2077
  case ">=":
2209
- return isEqual(left, right) || isLess(right, left);
2210
- case "<=":
2211
- return isEqual(left, right) || isLess(left, right);
2212
- case "in":
2213
- return isIn(left, right);
2214
- case "not in":
2215
- return !isIn(left, right);
2216
- default:
2217
- throw new EvaluationError(`Unknown binary operator: ${ast.op}`);
2078
+ return fieldValue >= value;
2079
+ case "in": {
2080
+ const val = Array.isArray(value) ? value : [value];
2081
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2082
+ return fieldVal.some((fv) => val.includes(fv));
2083
+ }
2084
+ case "not in": {
2085
+ const val = Array.isArray(value) ? value : [value];
2086
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2087
+ return !fieldVal.some((fv) => val.includes(fv));
2088
+ }
2089
+ case "like":
2090
+ if (fieldValue === false) {
2091
+ return false;
2092
+ }
2093
+ return Boolean(fieldValue.match(likeRegexp));
2094
+ case "not like":
2095
+ if (fieldValue === false) {
2096
+ return false;
2097
+ }
2098
+ return Boolean(!fieldValue.match(likeRegexp));
2099
+ case "=like":
2100
+ if (fieldValue === false) {
2101
+ return false;
2102
+ }
2103
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
2104
+ fieldValue
2105
+ );
2106
+ case "ilike":
2107
+ if (fieldValue === false) {
2108
+ return false;
2109
+ }
2110
+ return Boolean(fieldValue.match(ilikeRegexp));
2111
+ case "not ilike":
2112
+ if (fieldValue === false) {
2113
+ return false;
2114
+ }
2115
+ return Boolean(!fieldValue.match(ilikeRegexp));
2116
+ case "=ilike":
2117
+ if (fieldValue === false) {
2118
+ return false;
2119
+ }
2120
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
2121
+ fieldValue
2122
+ );
2218
2123
  }
2124
+ throw new InvalidDomainError("could not match domain");
2219
2125
  }
2220
- var DICT = {
2221
- get(...args) {
2222
- const { key, defValue } = parseArgs(args, ["key", "defValue"]);
2223
- const self = this;
2224
- if (key in self) {
2225
- return self[key];
2226
- } else if (defValue !== void 0) {
2227
- return defValue;
2126
+ function makeOperators(record) {
2127
+ const match = matchCondition.bind(null, record);
2128
+ return {
2129
+ "!": (x) => !match(x),
2130
+ "&": (a, b) => match(a) && match(b),
2131
+ "|": (a, b) => match(a) || match(b)
2132
+ };
2133
+ }
2134
+ function matchDomain(record, domain) {
2135
+ if (domain.length === 0) {
2136
+ return true;
2137
+ }
2138
+ const operators = makeOperators(record);
2139
+ const reversedDomain = Array.from(domain).reverse();
2140
+ const condStack = [];
2141
+ for (const item of reversedDomain) {
2142
+ const operator = typeof item === "string" && operators[item];
2143
+ if (operator) {
2144
+ const operands = condStack.splice(-operator.length);
2145
+ condStack.push(operator(...operands));
2146
+ } else {
2147
+ condStack.push(item);
2228
2148
  }
2229
- return null;
2230
2149
  }
2150
+ return matchCondition(record, condStack.pop());
2151
+ }
2152
+
2153
+ // src/utils/function.ts
2154
+ import { useEffect, useState } from "react";
2155
+ var toQueryString = (params) => {
2156
+ return Object.keys(params).map(
2157
+ (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
2158
+ ).join("&");
2231
2159
  };
2232
- var STRING = {
2233
- lower() {
2234
- return this.toLowerCase();
2235
- },
2236
- upper() {
2237
- return this.toUpperCase();
2160
+ var isBase64File = (str) => {
2161
+ try {
2162
+ const dataUriPattern = /^data:([a-zA-Z]+\/[a-zA-Z0-9-.+]+)?;base64,/;
2163
+ if (dataUriPattern.test(str)) {
2164
+ return true;
2165
+ }
2166
+ const base64Pattern = (
2167
+ // eslint-disable-next-line no-useless-escape
2168
+ /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)?$/
2169
+ );
2170
+ return base64Pattern.test(str);
2171
+ } catch (e) {
2172
+ return false;
2238
2173
  }
2239
2174
  };
2240
- function applyFunc(key, func, set, ...args) {
2241
- if (args.length === 1) {
2242
- return new Set(set);
2175
+ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2176
+ if (!originalRequest.data) return originalRequest.data;
2177
+ if (typeof originalRequest.data === "string") {
2178
+ try {
2179
+ const parsedData = JSON.parse(originalRequest.data);
2180
+ if (parsedData.with_context && typeof parsedData.with_context === "object") {
2181
+ parsedData.with_context.token = newAccessToken;
2182
+ }
2183
+ return JSON.stringify(parsedData);
2184
+ } catch (e) {
2185
+ console.warn("Failed to parse originalRequest.data", e);
2186
+ return originalRequest.data;
2187
+ }
2243
2188
  }
2244
- if (args.length > 2) {
2245
- throw new EvaluationError(
2246
- `${key}: py_js supports at most 1 argument, got (${args.length - 1})`
2247
- );
2189
+ if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
2190
+ originalRequest.data.with_context.token = newAccessToken;
2248
2191
  }
2249
- return execOnIterable(args[0], func);
2250
- }
2251
- var SET = {
2252
- intersection(...args) {
2253
- return applyFunc(
2254
- "intersection",
2255
- (iterable) => {
2256
- const intersection = /* @__PURE__ */ new Set();
2257
- for (const i of iterable) {
2258
- if (this.has(i)) {
2259
- intersection.add(i);
2260
- }
2192
+ return originalRequest.data;
2193
+ };
2194
+
2195
+ // src/utils/storage/local-storage.ts
2196
+ var localStorageUtils = () => {
2197
+ const setToken = async (access_token) => {
2198
+ localStorage.setItem("accessToken", access_token);
2199
+ };
2200
+ const setRefreshToken = async (refresh_token) => {
2201
+ localStorage.setItem("refreshToken", refresh_token);
2202
+ };
2203
+ const getAccessToken = async () => {
2204
+ return localStorage.getItem("accessToken");
2205
+ };
2206
+ const getRefreshToken = async () => {
2207
+ return localStorage.getItem("refreshToken");
2208
+ };
2209
+ const clearToken = async () => {
2210
+ localStorage.removeItem("accessToken");
2211
+ localStorage.removeItem("refreshToken");
2212
+ };
2213
+ return {
2214
+ setToken,
2215
+ setRefreshToken,
2216
+ getAccessToken,
2217
+ getRefreshToken,
2218
+ clearToken
2219
+ };
2220
+ };
2221
+
2222
+ // src/utils/storage/session-storage.ts
2223
+ var sessionStorageUtils = () => {
2224
+ const getBrowserSession = async () => {
2225
+ return sessionStorage.getItem("browserSession");
2226
+ };
2227
+ return {
2228
+ getBrowserSession
2229
+ };
2230
+ };
2231
+
2232
+ // src/configs/axios-client.ts
2233
+ var axiosClient = {
2234
+ init(config) {
2235
+ const localStorage2 = config?.localStorageUtils ?? localStorageUtils();
2236
+ const sessionStorage2 = config?.sessionStorageUtils ?? sessionStorageUtils();
2237
+ const db = config?.db;
2238
+ let isRefreshing = false;
2239
+ let failedQueue = [];
2240
+ const processQueue = (error, token = null) => {
2241
+ failedQueue?.forEach((prom) => {
2242
+ if (error) {
2243
+ prom.reject(error);
2244
+ } else {
2245
+ prom.resolve(token);
2261
2246
  }
2262
- return intersection;
2247
+ });
2248
+ failedQueue = [];
2249
+ };
2250
+ const instance = axios.create({
2251
+ adapter: axios.defaults.adapter,
2252
+ baseURL: config.baseUrl,
2253
+ timeout: 5e4,
2254
+ paramsSerializer: (params) => new URLSearchParams(params).toString()
2255
+ });
2256
+ instance.interceptors.request.use(
2257
+ async (config2) => {
2258
+ const useRefreshToken = config2.useRefreshToken;
2259
+ const token = useRefreshToken ? await localStorage2.getRefreshToken() : await localStorage2.getAccessToken();
2260
+ if (token) {
2261
+ config2.headers["Authorization"] = "Bearer " + token;
2262
+ }
2263
+ return config2;
2263
2264
  },
2264
- this,
2265
- ...args
2265
+ (error) => {
2266
+ Promise.reject(error);
2267
+ }
2266
2268
  );
2267
- },
2268
- difference(...args) {
2269
- return applyFunc(
2270
- "difference",
2271
- (iterable) => {
2272
- iterable = new Set(iterable);
2273
- const difference = /* @__PURE__ */ new Set();
2274
- for (const e of this) {
2275
- if (!iterable.has(e)) {
2276
- difference.add(e);
2269
+ instance.interceptors.response.use(
2270
+ (response) => {
2271
+ return handleResponse(response);
2272
+ },
2273
+ async (error) => {
2274
+ const handleError3 = async (error2) => {
2275
+ if (!error2.response) {
2276
+ return error2;
2277
+ }
2278
+ const { data } = error2.response;
2279
+ if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
2280
+ await clearAuthToken();
2281
+ }
2282
+ return data;
2283
+ };
2284
+ const originalRequest = error.config;
2285
+ if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
2286
+ error.response.data.code
2287
+ )) {
2288
+ if (isRefreshing) {
2289
+ return new Promise(function(resolve, reject) {
2290
+ failedQueue.push({ resolve, reject });
2291
+ }).then((token) => {
2292
+ originalRequest.headers["Authorization"] = "Bearer " + token;
2293
+ originalRequest.data = updateTokenParamInOriginalRequest(
2294
+ originalRequest,
2295
+ token
2296
+ );
2297
+ return instance.request(originalRequest);
2298
+ }).catch(async (err) => {
2299
+ if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
2300
+ await clearAuthToken();
2301
+ }
2302
+ });
2303
+ }
2304
+ const browserSession = await sessionStorage2.getBrowserSession();
2305
+ const refreshToken = await localStorage2.getRefreshToken();
2306
+ const accessTokenExp = await localStorage2.getAccessToken();
2307
+ isRefreshing = true;
2308
+ if (!refreshToken && (!browserSession || browserSession == "unActive")) {
2309
+ await clearAuthToken();
2310
+ } else {
2311
+ const payload = Object.fromEntries(
2312
+ Object.entries({
2313
+ refresh_token: refreshToken,
2314
+ grant_type: "refresh_token",
2315
+ client_id: config.config.clientId,
2316
+ client_secret: config.config.clientSecret
2317
+ }).filter(([_, value]) => !!value)
2318
+ );
2319
+ return new Promise(function(resolve) {
2320
+ axios.post(
2321
+ `${config.baseUrl}${config.refreshTokenEndpoint ?? "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2322
+ payload,
2323
+ {
2324
+ headers: {
2325
+ "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
2326
+ Authorization: `Bearer ${accessTokenExp}`
2327
+ }
2328
+ }
2329
+ ).then(async (res) => {
2330
+ const data = res.data;
2331
+ await localStorage2.setToken(data.access_token);
2332
+ await localStorage2.setRefreshToken(data.refresh_token);
2333
+ axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
2334
+ originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
2335
+ originalRequest.data = updateTokenParamInOriginalRequest(
2336
+ originalRequest,
2337
+ data.access_token
2338
+ );
2339
+ processQueue(null, data.access_token);
2340
+ resolve(instance.request(originalRequest));
2341
+ }).catch(async (err) => {
2342
+ if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST") || err?.error_code === "ERR_2FA_006") {
2343
+ await clearAuthToken();
2344
+ }
2345
+ if (err && err.response) {
2346
+ const { error_code } = err.response?.data || {};
2347
+ if (error_code === "AUTHEN_FAIL") {
2348
+ await clearAuthToken();
2349
+ }
2350
+ }
2351
+ processQueue(err, null);
2352
+ }).finally(() => {
2353
+ isRefreshing = false;
2354
+ });
2355
+ });
2277
2356
  }
2278
2357
  }
2279
- return difference;
2280
- },
2281
- this,
2282
- ...args
2358
+ return Promise.reject(await handleError3(error));
2359
+ }
2283
2360
  );
2361
+ const handleResponse = (res) => {
2362
+ if (res && res.data) {
2363
+ return res.data;
2364
+ }
2365
+ return res;
2366
+ };
2367
+ const handleError2 = (error) => {
2368
+ if (error.isAxiosError && error.code === "ECONNABORTED") {
2369
+ console.error("Request Timeout Error:", error);
2370
+ return "Request Timeout Error";
2371
+ } else if (error.isAxiosError && !error.response) {
2372
+ console.error("Network Error:", error);
2373
+ return "Network Error";
2374
+ } else {
2375
+ console.error("Other Error:", error?.response);
2376
+ const errorMessage = error?.response?.data?.message || "An error occurred";
2377
+ return { message: errorMessage, status: error?.response?.status };
2378
+ }
2379
+ };
2380
+ const clearAuthToken = async () => {
2381
+ await localStorage2.clearToken();
2382
+ if (typeof window !== "undefined") {
2383
+ window.location.href = `/login`;
2384
+ }
2385
+ };
2386
+ function formatUrl(url, db2) {
2387
+ return url + (db2 ? "?db=" + db2 : "");
2388
+ }
2389
+ const responseBody = (response) => response;
2390
+ const requests = {
2391
+ get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
2392
+ post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
2393
+ post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
2394
+ responseType: "arraybuffer",
2395
+ headers: {
2396
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
2397
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
2398
+ }
2399
+ }).then(responseBody),
2400
+ put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
2401
+ patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
2402
+ delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
2403
+ };
2404
+ return requests;
2405
+ }
2406
+ };
2407
+
2408
+ // src/store/index.ts
2409
+ import { useDispatch, useSelector } from "react-redux";
2410
+
2411
+ // src/store/reducers/breadcrums-slice/index.ts
2412
+ import { createSlice } from "@reduxjs/toolkit";
2413
+ var initialState = {
2414
+ breadCrumbs: []
2415
+ };
2416
+ var breadcrumbsSlice = createSlice({
2417
+ name: "breadcrumbs",
2418
+ initialState,
2419
+ reducers: {
2420
+ setBreadCrumbs: (state, action) => {
2421
+ state.breadCrumbs = [...state.breadCrumbs, action.payload];
2422
+ }
2423
+ }
2424
+ });
2425
+ var { setBreadCrumbs } = breadcrumbsSlice.actions;
2426
+ var breadcrums_slice_default = breadcrumbsSlice.reducer;
2427
+
2428
+ // src/store/reducers/env-slice/index.ts
2429
+ import { createSlice as createSlice2 } from "@reduxjs/toolkit";
2430
+ var initialState2 = {
2431
+ baseUrl: "",
2432
+ requests: null,
2433
+ companies: [],
2434
+ user: {},
2435
+ config: null,
2436
+ envFile: null,
2437
+ defaultCompany: {
2438
+ id: null,
2439
+ logo: "",
2440
+ secondary_color: "",
2441
+ primary_color: ""
2284
2442
  },
2285
- union(...args) {
2286
- return applyFunc(
2287
- "union",
2288
- (iterable) => {
2289
- return /* @__PURE__ */ new Set([...this, ...iterable]);
2290
- },
2291
- this,
2292
- ...args
2293
- );
2443
+ context: {
2444
+ uid: null,
2445
+ allowed_company_ids: [],
2446
+ lang: "vi_VN",
2447
+ tz: "Asia/Saigon"
2294
2448
  }
2295
2449
  };
2296
- function methods(_class) {
2297
- return Object.getOwnPropertyNames(_class.prototype).map(
2298
- (prop) => _class.prototype[prop]
2299
- );
2300
- }
2301
- var allowedFns = /* @__PURE__ */ new Set([
2302
- BUILTINS.time.strftime,
2303
- BUILTINS.set,
2304
- BUILTINS.bool,
2305
- BUILTINS.context_today,
2306
- BUILTINS.datetime.datetime.now,
2307
- BUILTINS.datetime.datetime.combine,
2308
- BUILTINS.datetime.date.today,
2309
- ...methods(BUILTINS.relativedelta),
2310
- ...Object.values(BUILTINS.datetime).flatMap((obj) => methods(obj)),
2311
- ...Object.values(SET),
2312
- ...Object.values(DICT),
2313
- ...Object.values(STRING)
2314
- ]);
2315
- var unboundFn = Symbol("unbound function");
2316
- function evaluate(ast, context = {}) {
2317
- const dicts = /* @__PURE__ */ new Set();
2318
- let pyContext;
2319
- const evalContext = Object.create(context);
2320
- if (!evalContext?.context) {
2321
- Object.defineProperty(evalContext, "context", {
2322
- get() {
2323
- if (!pyContext) {
2324
- pyContext = toPyDict(context);
2325
- }
2326
- return pyContext;
2327
- }
2328
- });
2450
+ var envSlice = createSlice2({
2451
+ name: "env",
2452
+ initialState: initialState2,
2453
+ reducers: {
2454
+ setEnv: (state, action) => {
2455
+ Object.assign(state, action.payload);
2456
+ },
2457
+ setUid: (state, action) => {
2458
+ state.context.uid = action.payload;
2459
+ },
2460
+ setAllowCompanies: (state, action) => {
2461
+ state.context.allowed_company_ids = action.payload;
2462
+ },
2463
+ setCompanies: (state, action) => {
2464
+ state.companies = action.payload;
2465
+ },
2466
+ setDefaultCompany: (state, action) => {
2467
+ state.defaultCompany = action.payload;
2468
+ },
2469
+ setLang: (state, action) => {
2470
+ state.context.lang = action.payload;
2471
+ },
2472
+ setUser: (state, action) => {
2473
+ state.user = action.payload;
2474
+ },
2475
+ setConfig: (state, action) => {
2476
+ state.config = action.payload;
2477
+ },
2478
+ setEnvFile: (state, action) => {
2479
+ state.envFile = action.payload;
2480
+ }
2481
+ }
2482
+ });
2483
+ var {
2484
+ setEnv,
2485
+ setUid,
2486
+ setLang,
2487
+ setAllowCompanies,
2488
+ setCompanies,
2489
+ setDefaultCompany,
2490
+ setUser,
2491
+ setConfig,
2492
+ setEnvFile
2493
+ } = envSlice.actions;
2494
+ var env_slice_default = envSlice.reducer;
2495
+
2496
+ // src/store/reducers/excel-slice/index.ts
2497
+ import { createSlice as createSlice3 } from "@reduxjs/toolkit";
2498
+ var initialState3 = {
2499
+ dataParse: null,
2500
+ idFile: null,
2501
+ isFileLoaded: false,
2502
+ loadingImport: false,
2503
+ selectedFile: null,
2504
+ errorData: null
2505
+ };
2506
+ var excelSlice = createSlice3({
2507
+ name: "excel",
2508
+ initialState: initialState3,
2509
+ reducers: {
2510
+ setDataParse: (state, action) => {
2511
+ state.dataParse = action.payload;
2512
+ },
2513
+ setIdFile: (state, action) => {
2514
+ state.idFile = action.payload;
2515
+ },
2516
+ setIsFileLoaded: (state, action) => {
2517
+ state.isFileLoaded = action.payload;
2518
+ },
2519
+ setLoadingImport: (state, action) => {
2520
+ state.loadingImport = action.payload;
2521
+ },
2522
+ setSelectedFile: (state, action) => {
2523
+ state.selectedFile = action.payload;
2524
+ },
2525
+ setErrorData: (state, action) => {
2526
+ state.errorData = action.payload;
2527
+ }
2528
+ }
2529
+ });
2530
+ var {
2531
+ setDataParse,
2532
+ setIdFile,
2533
+ setIsFileLoaded,
2534
+ setLoadingImport,
2535
+ setSelectedFile,
2536
+ setErrorData
2537
+ } = excelSlice.actions;
2538
+ var excel_slice_default = excelSlice.reducer;
2539
+
2540
+ // src/store/reducers/form-slice/index.ts
2541
+ import { createSlice as createSlice4 } from "@reduxjs/toolkit";
2542
+ var initialState4 = {
2543
+ viewDataStore: {},
2544
+ isShowingModalDetail: false,
2545
+ isShowModalTranslate: false,
2546
+ formSubmitComponent: {},
2547
+ fieldTranslation: null,
2548
+ listSubject: {},
2549
+ dataUser: {}
2550
+ };
2551
+ var formSlice = createSlice4({
2552
+ name: "form",
2553
+ initialState: initialState4,
2554
+ reducers: {
2555
+ setViewDataStore: (state, action) => {
2556
+ state.viewDataStore = action.payload;
2557
+ },
2558
+ setIsShowingModalDetail: (state, action) => {
2559
+ state.isShowingModalDetail = action.payload;
2560
+ },
2561
+ setIsShowModalTranslate: (state, action) => {
2562
+ state.isShowModalTranslate = action.payload;
2563
+ },
2564
+ setFormSubmitComponent: (state, action) => {
2565
+ state.formSubmitComponent[action.payload.key] = action.payload.component;
2566
+ },
2567
+ setFieldTranslate: (state, action) => {
2568
+ state.fieldTranslation = action.payload;
2569
+ },
2570
+ setListSubject: (state, action) => {
2571
+ state.listSubject = action.payload;
2572
+ },
2573
+ setDataUser: (state, action) => {
2574
+ state.dataUser = action.payload;
2575
+ }
2329
2576
  }
2330
- function _innerEvaluate(ast2) {
2331
- switch (ast2?.type) {
2332
- case 0:
2333
- // Number
2334
- case 1:
2335
- return ast2.value;
2336
- case 5:
2337
- if (ast2.value in evalContext) {
2338
- if (typeof evalContext[ast2.value] === "object" && evalContext[ast2.value]?.id) {
2339
- return evalContext[ast2.value]?.id;
2340
- }
2341
- return evalContext[ast2.value] ?? false;
2342
- } else if (ast2.value in BUILTINS) {
2343
- return BUILTINS[ast2.value];
2344
- } else {
2345
- return false;
2346
- }
2347
- case 3:
2348
- return null;
2349
- case 2:
2350
- return ast2.value;
2351
- case 6:
2352
- return applyUnaryOp(ast2, evalContext);
2353
- case 7:
2354
- return applyBinaryOp(ast2, evalContext);
2355
- case 14:
2356
- const left = _evaluate(ast2.left);
2357
- if (ast2.op === "and") {
2358
- return isTrue(left) ? _evaluate(ast2.right) : left;
2359
- } else {
2360
- return isTrue(left) ? left : _evaluate(ast2.right);
2361
- }
2362
- case 4:
2363
- // List
2364
- case 10:
2365
- return ast2.value.map(_evaluate);
2366
- case 11:
2367
- const dict = {};
2368
- for (const key2 in ast2.value) {
2369
- dict[key2] = _evaluate(ast2.value[key2]);
2370
- }
2371
- dicts.add(dict);
2372
- return dict;
2373
- case 8:
2374
- const fnValue = _evaluate(ast2.fn);
2375
- const args = ast2.args.map(_evaluate);
2376
- const kwargs = {};
2377
- for (const kwarg in ast2.kwargs) {
2378
- kwargs[kwarg] = _evaluate(ast2?.kwargs[kwarg]);
2379
- }
2380
- if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
2381
- return fnValue.create(...args, kwargs);
2382
- }
2383
- return fnValue(...args, kwargs);
2384
- case 12:
2385
- const dictVal = _evaluate(ast2.target);
2386
- const key = _evaluate(ast2.key);
2387
- return dictVal[key];
2388
- case 13:
2389
- if (isTrue(_evaluate(ast2.condition))) {
2390
- return _evaluate(ast2.ifTrue);
2391
- } else {
2392
- return _evaluate(ast2.ifFalse);
2393
- }
2394
- case 15:
2395
- let leftVal = _evaluate(ast2.obj);
2396
- let result;
2397
- if (dicts.has(leftVal) || Object.isPrototypeOf.call(PY_DICT, leftVal)) {
2398
- result = DICT[ast2.key];
2399
- } else if (typeof leftVal === "string") {
2400
- result = STRING[ast2.key];
2401
- } else if (leftVal instanceof Set) {
2402
- result = SET[ast2.key];
2403
- } else if (ast2.key === "get" && typeof leftVal === "object") {
2404
- result = DICT[ast2.key];
2405
- leftVal = toPyDict(leftVal);
2406
- } else {
2407
- result = leftVal[ast2.key];
2408
- }
2409
- if (typeof result === "function") {
2410
- const bound = result.bind(leftVal);
2411
- bound[unboundFn] = result;
2412
- return bound;
2413
- }
2414
- return result;
2415
- default:
2416
- throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
2577
+ });
2578
+ var {
2579
+ setViewDataStore,
2580
+ setIsShowingModalDetail,
2581
+ setIsShowModalTranslate,
2582
+ setFormSubmitComponent,
2583
+ setFieldTranslate,
2584
+ setListSubject,
2585
+ setDataUser
2586
+ } = formSlice.actions;
2587
+ var form_slice_default = formSlice.reducer;
2588
+
2589
+ // src/store/reducers/header-slice/index.ts
2590
+ import { createSlice as createSlice5 } from "@reduxjs/toolkit";
2591
+ var headerSlice = createSlice5({
2592
+ name: "header",
2593
+ initialState: {
2594
+ value: { allowedCompanyIds: [] }
2595
+ },
2596
+ reducers: {
2597
+ setHeader: (state, action) => {
2598
+ state.value = { ...state.value, ...action.payload };
2599
+ },
2600
+ setAllowedCompanyIds: (state, action) => {
2601
+ state.value.allowedCompanyIds = action.payload;
2417
2602
  }
2418
2603
  }
2419
- function _evaluate(ast2) {
2420
- const val = _innerEvaluate(ast2);
2421
- if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
2422
- throw new Error("Invalid Function Call");
2604
+ });
2605
+ var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
2606
+ var header_slice_default = headerSlice.reducer;
2607
+
2608
+ // src/store/reducers/list-slice/index.ts
2609
+ import { createSlice as createSlice6 } from "@reduxjs/toolkit";
2610
+ var initialState5 = {
2611
+ pageLimit: 10,
2612
+ fields: {},
2613
+ order: "",
2614
+ selectedRowKeys: [],
2615
+ selectedRadioKey: 0,
2616
+ indexRowTableModal: -2,
2617
+ isUpdateTableModal: false,
2618
+ footerGroupTable: {},
2619
+ transferDetail: null,
2620
+ page: 0,
2621
+ domainTable: []
2622
+ };
2623
+ var listSlice = createSlice6({
2624
+ name: "list",
2625
+ initialState: initialState5,
2626
+ reducers: {
2627
+ setPageLimit: (state, action) => {
2628
+ state.pageLimit = action.payload;
2629
+ },
2630
+ setFields: (state, action) => {
2631
+ state.fields = action.payload;
2632
+ },
2633
+ setOrder: (state, action) => {
2634
+ state.order = action.payload;
2635
+ },
2636
+ setSelectedRowKeys: (state, action) => {
2637
+ state.selectedRowKeys = action.payload;
2638
+ },
2639
+ setSelectedRadioKey: (state, action) => {
2640
+ state.selectedRadioKey = action.payload;
2641
+ },
2642
+ setIndexRowTableModal: (state, action) => {
2643
+ state.indexRowTableModal = action.payload;
2644
+ },
2645
+ setTransferDetail: (state, action) => {
2646
+ state.transferDetail = action.payload;
2647
+ },
2648
+ setIsUpdateTableModal: (state, action) => {
2649
+ state.isUpdateTableModal = action.payload;
2650
+ },
2651
+ setPage: (state, action) => {
2652
+ state.page = action.payload;
2653
+ },
2654
+ setDomainTable: (state, action) => {
2655
+ state.domainTable = action.payload;
2423
2656
  }
2424
- return val;
2425
2657
  }
2426
- return _evaluate(ast);
2427
- }
2658
+ });
2659
+ var {
2660
+ setPageLimit,
2661
+ setFields,
2662
+ setOrder,
2663
+ setSelectedRowKeys,
2664
+ setIndexRowTableModal,
2665
+ setIsUpdateTableModal,
2666
+ setPage,
2667
+ setSelectedRadioKey,
2668
+ setTransferDetail,
2669
+ setDomainTable
2670
+ } = listSlice.actions;
2671
+ var list_slice_default = listSlice.reducer;
2428
2672
 
2429
- // src/utils/domain/py.ts
2430
- function parseExpr(expr) {
2431
- const tokens = tokenize(expr);
2432
- return parse(tokens);
2433
- }
2673
+ // src/store/reducers/login-slice/index.ts
2674
+ import { createSlice as createSlice7 } from "@reduxjs/toolkit";
2675
+ var initialState6 = {
2676
+ db: "",
2677
+ redirectTo: "/",
2678
+ forgotPasswordUrl: "/"
2679
+ };
2680
+ var loginSlice = createSlice7({
2681
+ name: "login",
2682
+ initialState: initialState6,
2683
+ reducers: {
2684
+ setDb: (state, action) => {
2685
+ state.db = action.payload;
2686
+ },
2687
+ setRedirectTo: (state, action) => {
2688
+ state.redirectTo = action.payload;
2689
+ },
2690
+ setForgotPasswordUrl: (state, action) => {
2691
+ state.forgotPasswordUrl = action.payload;
2692
+ }
2693
+ }
2694
+ });
2695
+ var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
2696
+ var login_slice_default = loginSlice.reducer;
2434
2697
 
2435
- // src/utils/domain/objects.ts
2436
- function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
2437
- if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
2438
- return obj1 === obj2;
2698
+ // src/store/reducers/navbar-slice/index.ts
2699
+ import { createSlice as createSlice8 } from "@reduxjs/toolkit";
2700
+ var initialState7 = {
2701
+ menuFocus: {},
2702
+ menuAction: {},
2703
+ navbarWidth: 250,
2704
+ menuList: []
2705
+ };
2706
+ var navbarSlice = createSlice8({
2707
+ name: "navbar",
2708
+ initialState: initialState7,
2709
+ reducers: {
2710
+ setMenuFocus: (state, action) => {
2711
+ state.menuFocus = action.payload;
2712
+ },
2713
+ setMenuFocusAction: (state, action) => {
2714
+ state.menuAction = action.payload;
2715
+ },
2716
+ setNavbarWidth: (state, action) => {
2717
+ state.navbarWidth = action.payload;
2718
+ },
2719
+ setMenuList: (state, action) => {
2720
+ state.menuList = action.payload;
2721
+ }
2439
2722
  }
2440
- const obj1Keys = Object.keys(obj1);
2441
- return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
2442
- }
2443
-
2444
- // src/utils/domain/arrays.ts
2445
- var shallowEqual2 = shallowEqual;
2446
-
2447
- // src/utils/domain/strings.ts
2448
- var escapeMethod = Symbol("html");
2449
- function escapeRegExp(str) {
2450
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2451
- }
2723
+ });
2724
+ var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
2725
+ var navbar_slice_default = navbarSlice.reducer;
2452
2726
 
2453
- // src/utils/domain/domain.ts
2454
- var InvalidDomainError = class extends Error {
2727
+ // src/store/reducers/profile-slice/index.ts
2728
+ import { createSlice as createSlice9 } from "@reduxjs/toolkit";
2729
+ var initialState8 = {
2730
+ profile: {}
2455
2731
  };
2456
- var Domain = class _Domain {
2457
- ast = { type: -1, value: null };
2458
- static TRUE;
2459
- static FALSE;
2460
- static combine(domains, operator) {
2461
- if (domains.length === 0) {
2462
- return new _Domain([]);
2463
- }
2464
- const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
2465
- if (domains.length === 1) {
2466
- return domain1;
2732
+ var profileSlice = createSlice9({
2733
+ name: "profile",
2734
+ initialState: initialState8,
2735
+ reducers: {
2736
+ setProfile: (state, action) => {
2737
+ state.profile = action.payload;
2467
2738
  }
2468
- const domain2 = _Domain.combine(domains.slice(1), operator);
2469
- const result = new _Domain([]);
2470
- const astValues1 = domain1.ast.value;
2471
- const astValues2 = domain2.ast.value;
2472
- const op = operator === "AND" ? "&" : "|";
2473
- const combinedAST = {
2474
- type: 4,
2475
- value: astValues1.concat(astValues2)
2476
- };
2477
- result.ast = normalizeDomainAST(combinedAST, op);
2478
- return result;
2479
- }
2480
- static and(domains) {
2481
- return _Domain.combine(domains, "AND");
2482
- }
2483
- static or(domains) {
2484
- return _Domain.combine(domains, "OR");
2485
- }
2486
- static not(domain) {
2487
- const result = new _Domain(domain);
2488
- result.ast.value.unshift({ type: 1, value: "!" });
2489
- return result;
2490
2739
  }
2491
- static removeDomainLeaves(domain, keysToRemove) {
2492
- function processLeaf(elements, idx, operatorCtx, newDomain2) {
2493
- const leaf = elements[idx];
2494
- if (leaf.type === 10) {
2495
- if (keysToRemove.includes(leaf.value[0].value)) {
2496
- if (operatorCtx === "&") {
2497
- newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
2498
- } else if (operatorCtx === "|") {
2499
- newDomain2.ast.value.push(..._Domain.FALSE.ast.value);
2500
- }
2740
+ });
2741
+ var { setProfile } = profileSlice.actions;
2742
+ var profile_slice_default = profileSlice.reducer;
2743
+
2744
+ // src/store/reducers/search-slice/index.ts
2745
+ import { createSlice as createSlice10 } from "@reduxjs/toolkit";
2746
+ var initialState9 = {
2747
+ groupByDomain: null,
2748
+ searchBy: [],
2749
+ searchString: "",
2750
+ hoveredIndexSearchList: null,
2751
+ selectedTags: [],
2752
+ firstDomain: null,
2753
+ searchMap: {},
2754
+ filterBy: [],
2755
+ groupBy: []
2756
+ };
2757
+ var searchSlice = createSlice10({
2758
+ name: "search",
2759
+ initialState: initialState9,
2760
+ reducers: {
2761
+ setGroupByDomain: (state, action) => {
2762
+ state.groupByDomain = action.payload;
2763
+ },
2764
+ setSearchBy: (state, action) => {
2765
+ state.searchBy = action.payload;
2766
+ },
2767
+ setSearchString: (state, action) => {
2768
+ state.searchString = action.payload;
2769
+ },
2770
+ setHoveredIndexSearchList: (state, action) => {
2771
+ state.hoveredIndexSearchList = action.payload;
2772
+ },
2773
+ setSelectedTags: (state, action) => {
2774
+ state.selectedTags = action.payload;
2775
+ },
2776
+ setFirstDomain: (state, action) => {
2777
+ state.firstDomain = action.payload;
2778
+ },
2779
+ setFilterBy: (state, action) => {
2780
+ state.filterBy = action.payload;
2781
+ },
2782
+ setGroupBy: (state, action) => {
2783
+ state.groupBy = action.payload;
2784
+ },
2785
+ setSearchMap: (state, action) => {
2786
+ state.searchMap = action.payload;
2787
+ },
2788
+ updateSearchMap: (state, action) => {
2789
+ if (!state.searchMap[action.payload.key]) {
2790
+ state.searchMap[action.payload.key] = [];
2791
+ }
2792
+ state.searchMap[action.payload.key].push(action.payload.value);
2793
+ },
2794
+ removeKeyFromSearchMap: (state, action) => {
2795
+ const { key, item } = action.payload;
2796
+ const values = state.searchMap[key];
2797
+ if (!values) return;
2798
+ if (item) {
2799
+ const filtered = values.filter((value) => value.name !== item.name);
2800
+ if (filtered.length > 0) {
2801
+ state.searchMap[key] = filtered;
2501
2802
  } else {
2502
- newDomain2.ast.value.push(leaf);
2503
- }
2504
- return 1;
2505
- } else if (leaf.type === 1) {
2506
- if (leaf.value === "|" && elements[idx + 1].type === 10 && elements[idx + 2].type === 10 && keysToRemove.includes(elements[idx + 1].value[0].value) && keysToRemove.includes(elements[idx + 2].value[0].value)) {
2507
- newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
2508
- return 3;
2509
- }
2510
- newDomain2.ast.value.push(leaf);
2511
- if (leaf.value === "!") {
2512
- return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
2803
+ delete state.searchMap[key];
2513
2804
  }
2514
- const firstLeafSkip = processLeaf(
2515
- elements,
2516
- idx + 1,
2517
- leaf.value,
2518
- newDomain2
2519
- );
2520
- const secondLeafSkip = processLeaf(
2521
- elements,
2522
- idx + 1 + firstLeafSkip,
2523
- leaf.value,
2524
- newDomain2
2525
- );
2526
- return 1 + firstLeafSkip + secondLeafSkip;
2527
- }
2528
- return 0;
2529
- }
2530
- const d = new _Domain(domain);
2531
- if (d.ast.value.length === 0) {
2532
- return d;
2533
- }
2534
- const newDomain = new _Domain([]);
2535
- processLeaf(d.ast.value, 0, "&", newDomain);
2536
- return newDomain;
2537
- }
2538
- constructor(descr = []) {
2539
- if (descr instanceof _Domain) {
2540
- return new _Domain(descr.toString());
2541
- } else {
2542
- let rawAST;
2543
- try {
2544
- rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
2545
- } catch (error) {
2546
- throw new InvalidDomainError(
2547
- `Invalid domain representation: ${descr}`,
2548
- {
2549
- cause: error
2550
- }
2551
- );
2552
- }
2553
- this.ast = normalizeDomainAST(rawAST);
2554
- }
2555
- }
2556
- contains(record) {
2557
- const expr = evaluate(this.ast, record);
2558
- return matchDomain(record, expr);
2559
- }
2560
- toString() {
2561
- return formatAST(this.ast);
2562
- }
2563
- toList(context) {
2564
- return evaluate(this.ast, context);
2565
- }
2566
- toJson() {
2567
- try {
2568
- const evaluatedAsList = this.toList({});
2569
- const evaluatedDomain = new _Domain(evaluatedAsList);
2570
- if (evaluatedDomain.toString() === this.toString()) {
2571
- return evaluatedAsList;
2805
+ } else {
2806
+ delete state.searchMap[key];
2572
2807
  }
2573
- return this.toString();
2574
- } catch {
2575
- return this.toString();
2808
+ },
2809
+ clearSearchMap: (state) => {
2810
+ state.searchMap = {};
2576
2811
  }
2577
2812
  }
2578
- };
2579
- var TRUE_LEAF = [1, "=", 1];
2580
- var FALSE_LEAF = [0, "=", 1];
2581
- var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
2582
- var FALSE_DOMAIN = new Domain([FALSE_LEAF]);
2583
- Domain.TRUE = TRUE_DOMAIN;
2584
- Domain.FALSE = FALSE_DOMAIN;
2585
- function toAST(domain) {
2586
- const elems = domain.map((elem) => {
2587
- switch (elem) {
2588
- case "!":
2589
- case "&":
2590
- case "|":
2591
- return { type: 1, value: elem };
2592
- default:
2593
- return {
2594
- type: 10,
2595
- value: elem.map(toPyValue)
2596
- };
2597
- }
2598
- });
2599
- return { type: 4, value: elems };
2813
+ });
2814
+ var {
2815
+ setGroupByDomain,
2816
+ setSelectedTags,
2817
+ setSearchString,
2818
+ setHoveredIndexSearchList,
2819
+ setFirstDomain,
2820
+ setSearchBy,
2821
+ setFilterBy,
2822
+ setSearchMap,
2823
+ updateSearchMap,
2824
+ removeKeyFromSearchMap,
2825
+ setGroupBy,
2826
+ clearSearchMap
2827
+ } = searchSlice.actions;
2828
+ var search_slice_default = searchSlice.reducer;
2829
+
2830
+ // src/store/store.ts
2831
+ import { configureStore } from "@reduxjs/toolkit";
2832
+
2833
+ // node_modules/redux/dist/redux.mjs
2834
+ function formatProdErrorMessage(code) {
2835
+ return `Minified Redux error #${code}; visit https://redux.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
2836
+ }
2837
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
2838
+ var ActionTypes = {
2839
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
2840
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
2841
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
2842
+ };
2843
+ var actionTypes_default = ActionTypes;
2844
+ function isPlainObject(obj) {
2845
+ if (typeof obj !== "object" || obj === null)
2846
+ return false;
2847
+ let proto = obj;
2848
+ while (Object.getPrototypeOf(proto) !== null) {
2849
+ proto = Object.getPrototypeOf(proto);
2850
+ }
2851
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
2600
2852
  }
2601
- function normalizeDomainAST(domain, op = "&") {
2602
- if (domain.type !== 4) {
2603
- if (domain.type === 10) {
2604
- const value = domain.value;
2605
- if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
2606
- throw new InvalidDomainError("Invalid domain AST");
2607
- }
2608
- } else {
2609
- throw new InvalidDomainError("Invalid domain AST");
2853
+ function miniKindOf(val) {
2854
+ if (val === void 0)
2855
+ return "undefined";
2856
+ if (val === null)
2857
+ return "null";
2858
+ const type = typeof val;
2859
+ switch (type) {
2860
+ case "boolean":
2861
+ case "string":
2862
+ case "number":
2863
+ case "symbol":
2864
+ case "function": {
2865
+ return type;
2610
2866
  }
2611
2867
  }
2612
- if (domain.value.length === 0) {
2613
- return domain;
2868
+ if (Array.isArray(val))
2869
+ return "array";
2870
+ if (isDate(val))
2871
+ return "date";
2872
+ if (isError(val))
2873
+ return "error";
2874
+ const constructorName = ctorName(val);
2875
+ switch (constructorName) {
2876
+ case "Symbol":
2877
+ case "Promise":
2878
+ case "WeakMap":
2879
+ case "WeakSet":
2880
+ case "Map":
2881
+ case "Set":
2882
+ return constructorName;
2614
2883
  }
2615
- let expected = 1;
2616
- for (const child of domain.value) {
2617
- switch (child.type) {
2618
- case 1:
2619
- if (child.value === "&" || child.value === "|") {
2620
- expected++;
2621
- } else if (child.value !== "!") {
2622
- throw new InvalidDomainError("Invalid domain AST");
2623
- }
2624
- break;
2625
- case 4:
2626
- /* list */
2627
- case 10:
2628
- if (child.value.length === 3) {
2629
- expected--;
2630
- break;
2631
- }
2632
- throw new InvalidDomainError("Invalid domain AST");
2633
- default:
2634
- throw new InvalidDomainError("Invalid domain AST");
2635
- }
2884
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
2885
+ }
2886
+ function ctorName(val) {
2887
+ return typeof val.constructor === "function" ? val.constructor.name : null;
2888
+ }
2889
+ function isError(val) {
2890
+ return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
2891
+ }
2892
+ function isDate(val) {
2893
+ if (val instanceof Date)
2894
+ return true;
2895
+ return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
2896
+ }
2897
+ function kindOf(val) {
2898
+ let typeOfVal = typeof val;
2899
+ if (process.env.NODE_ENV !== "production") {
2900
+ typeOfVal = miniKindOf(val);
2636
2901
  }
2637
- const values = domain.value.slice();
2638
- while (expected < 0) {
2639
- expected++;
2640
- values.unshift({ type: 1, value: op });
2902
+ return typeOfVal;
2903
+ }
2904
+ function warning(message) {
2905
+ if (typeof console !== "undefined" && typeof console.error === "function") {
2906
+ console.error(message);
2641
2907
  }
2642
- if (expected > 0) {
2643
- throw new InvalidDomainError(
2644
- `invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
2645
- );
2908
+ try {
2909
+ throw new Error(message);
2910
+ } catch (e) {
2646
2911
  }
2647
- return { type: 4, value: values };
2648
2912
  }
2649
- function matchCondition(record, condition) {
2650
- if (typeof condition === "boolean") {
2651
- return condition;
2913
+ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
2914
+ const reducerKeys = Object.keys(reducers);
2915
+ const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
2916
+ if (reducerKeys.length === 0) {
2917
+ return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
2652
2918
  }
2653
- const [field, operator, value] = condition;
2654
- if (typeof field === "string") {
2655
- const names = field.split(".");
2656
- if (names.length >= 2) {
2657
- return matchCondition(record[names[0]], [
2658
- names.slice(1).join("."),
2659
- operator,
2660
- value
2661
- ]);
2662
- }
2919
+ if (!isPlainObject(inputState)) {
2920
+ return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
2663
2921
  }
2664
- let likeRegexp, ilikeRegexp;
2665
- if (["like", "not like", "ilike", "not ilike"].includes(operator)) {
2666
- likeRegexp = new RegExp(
2667
- `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2668
- "g"
2669
- );
2670
- ilikeRegexp = new RegExp(
2671
- `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2672
- "gi"
2673
- );
2922
+ const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
2923
+ unexpectedKeys.forEach((key) => {
2924
+ unexpectedKeyCache[key] = true;
2925
+ });
2926
+ if (action && action.type === actionTypes_default.REPLACE)
2927
+ return;
2928
+ if (unexpectedKeys.length > 0) {
2929
+ return `Unexpected ${unexpectedKeys.length > 1 ? "keys" : "key"} "${unexpectedKeys.join('", "')}" found in ${argumentName}. Expected to find one of the known reducer keys instead: "${reducerKeys.join('", "')}". Unexpected keys will be ignored.`;
2674
2930
  }
2675
- const fieldValue = typeof field === "number" ? field : record[field];
2676
- switch (operator) {
2677
- case "=?":
2678
- if ([false, null].includes(value)) {
2679
- return true;
2680
- }
2681
- // eslint-disable-next-line no-fallthrough
2682
- case "=":
2683
- case "==":
2684
- if (Array.isArray(fieldValue) && Array.isArray(value)) {
2685
- return shallowEqual2(fieldValue, value);
2686
- }
2687
- return fieldValue === value;
2688
- case "!=":
2689
- case "<>":
2690
- return !matchCondition(record, [field, "==", value]);
2691
- case "<":
2692
- return fieldValue < value;
2693
- case "<=":
2694
- return fieldValue <= value;
2695
- case ">":
2696
- return fieldValue > value;
2697
- case ">=":
2698
- return fieldValue >= value;
2699
- case "in": {
2700
- const val = Array.isArray(value) ? value : [value];
2701
- const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2702
- return fieldVal.some((fv) => val.includes(fv));
2931
+ }
2932
+ function assertReducerShape(reducers) {
2933
+ Object.keys(reducers).forEach((key) => {
2934
+ const reducer = reducers[key];
2935
+ const initialState10 = reducer(void 0, {
2936
+ type: actionTypes_default.INIT
2937
+ });
2938
+ if (typeof initialState10 === "undefined") {
2939
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : `The slice reducer for key "${key}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);
2703
2940
  }
2704
- case "not in": {
2705
- const val = Array.isArray(value) ? value : [value];
2706
- const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2707
- return !fieldVal.some((fv) => val.includes(fv));
2941
+ if (typeof reducer(void 0, {
2942
+ type: actionTypes_default.PROBE_UNKNOWN_ACTION()
2943
+ }) === "undefined") {
2944
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : `The slice reducer for key "${key}" returned undefined when probed with a random type. Don't try to handle '${actionTypes_default.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`);
2708
2945
  }
2709
- case "like":
2710
- if (fieldValue === false) {
2711
- return false;
2712
- }
2713
- return Boolean(fieldValue.match(likeRegexp));
2714
- case "not like":
2715
- if (fieldValue === false) {
2716
- return false;
2717
- }
2718
- return Boolean(!fieldValue.match(likeRegexp));
2719
- case "=like":
2720
- if (fieldValue === false) {
2721
- return false;
2722
- }
2723
- return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
2724
- fieldValue
2725
- );
2726
- case "ilike":
2727
- if (fieldValue === false) {
2728
- return false;
2729
- }
2730
- return Boolean(fieldValue.match(ilikeRegexp));
2731
- case "not ilike":
2732
- if (fieldValue === false) {
2733
- return false;
2734
- }
2735
- return Boolean(!fieldValue.match(ilikeRegexp));
2736
- case "=ilike":
2737
- if (fieldValue === false) {
2738
- return false;
2739
- }
2740
- return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
2741
- fieldValue
2742
- );
2743
- }
2744
- throw new InvalidDomainError("could not match domain");
2745
- }
2746
- function makeOperators(record) {
2747
- const match = matchCondition.bind(null, record);
2748
- return {
2749
- "!": (x) => !match(x),
2750
- "&": (a, b) => match(a) && match(b),
2751
- "|": (a, b) => match(a) || match(b)
2752
- };
2946
+ });
2753
2947
  }
2754
- function matchDomain(record, domain) {
2755
- if (domain.length === 0) {
2756
- return true;
2757
- }
2758
- const operators = makeOperators(record);
2759
- const reversedDomain = Array.from(domain).reverse();
2760
- const condStack = [];
2761
- for (const item of reversedDomain) {
2762
- const operator = typeof item === "string" && operators[item];
2763
- if (operator) {
2764
- const operands = condStack.splice(-operator.length);
2765
- condStack.push(operator(...operands));
2766
- } else {
2767
- condStack.push(item);
2948
+ function combineReducers(reducers) {
2949
+ const reducerKeys = Object.keys(reducers);
2950
+ const finalReducers = {};
2951
+ for (let i = 0; i < reducerKeys.length; i++) {
2952
+ const key = reducerKeys[i];
2953
+ if (process.env.NODE_ENV !== "production") {
2954
+ if (typeof reducers[key] === "undefined") {
2955
+ warning(`No reducer provided for key "${key}"`);
2956
+ }
2957
+ }
2958
+ if (typeof reducers[key] === "function") {
2959
+ finalReducers[key] = reducers[key];
2768
2960
  }
2769
2961
  }
2770
- return matchCondition(record, condStack.pop());
2771
- }
2772
-
2773
- // src/utils/function.ts
2774
- import { useEffect, useState } from "react";
2775
- var toQueryString = (params) => {
2776
- return Object.keys(params).map(
2777
- (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
2778
- ).join("&");
2779
- };
2780
- var isBase64File = (str) => {
2962
+ const finalReducerKeys = Object.keys(finalReducers);
2963
+ let unexpectedKeyCache;
2964
+ if (process.env.NODE_ENV !== "production") {
2965
+ unexpectedKeyCache = {};
2966
+ }
2967
+ let shapeAssertionError;
2781
2968
  try {
2782
- const dataUriPattern = /^data:([a-zA-Z]+\/[a-zA-Z0-9-.+]+)?;base64,/;
2783
- if (dataUriPattern.test(str)) {
2784
- return true;
2785
- }
2786
- const base64Pattern = (
2787
- // eslint-disable-next-line no-useless-escape
2788
- /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)?$/
2789
- );
2790
- return base64Pattern.test(str);
2969
+ assertReducerShape(finalReducers);
2791
2970
  } catch (e) {
2792
- return false;
2971
+ shapeAssertionError = e;
2793
2972
  }
2794
- };
2973
+ return function combination(state = {}, action) {
2974
+ if (shapeAssertionError) {
2975
+ throw shapeAssertionError;
2976
+ }
2977
+ if (process.env.NODE_ENV !== "production") {
2978
+ const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
2979
+ if (warningMessage) {
2980
+ warning(warningMessage);
2981
+ }
2982
+ }
2983
+ let hasChanged = false;
2984
+ const nextState = {};
2985
+ for (let i = 0; i < finalReducerKeys.length; i++) {
2986
+ const key = finalReducerKeys[i];
2987
+ const reducer = finalReducers[key];
2988
+ const previousStateForKey = state[key];
2989
+ const nextStateForKey = reducer(previousStateForKey, action);
2990
+ if (typeof nextStateForKey === "undefined") {
2991
+ const actionType = action && action.type;
2992
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : `When called with an action of type ${actionType ? `"${String(actionType)}"` : "(unknown type)"}, the slice reducer for key "${key}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`);
2993
+ }
2994
+ nextState[key] = nextStateForKey;
2995
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
2996
+ }
2997
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
2998
+ return hasChanged ? nextState : state;
2999
+ };
3000
+ }
3001
+
3002
+ // src/store/store.ts
3003
+ var rootReducer = combineReducers({
3004
+ env: env_slice_default,
3005
+ header: header_slice_default,
3006
+ navbar: navbar_slice_default,
3007
+ list: list_slice_default,
3008
+ search: search_slice_default,
3009
+ form: form_slice_default,
3010
+ breadcrumbs: breadcrums_slice_default,
3011
+ login: login_slice_default,
3012
+ excel: excel_slice_default,
3013
+ profile: profile_slice_default
3014
+ });
3015
+ var envStore = configureStore({
3016
+ reducer: rootReducer,
3017
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
3018
+ serializableCheck: false
3019
+ })
3020
+ });
2795
3021
 
2796
3022
  // src/environment/EnvStore.ts
2797
- var requests = {
2798
- get: async (url, headers) => ({}),
2799
- post: async (url, body, headers) => ({}),
2800
- post_excel: async (url, body, headers) => ({}),
2801
- put: async (url, body, headers) => ({}),
2802
- patch: async (url, body) => ({}),
2803
- delete: async (url, body) => ({})
3023
+ var EnvStore = class _EnvStore {
3024
+ static instance = null;
3025
+ static localStorageUtils;
3026
+ static sessionStorageUtils;
3027
+ constructor() {
3028
+ }
3029
+ static getInstance(localStorageUtils2, sessionStorageUtils2) {
3030
+ if (!_EnvStore.instance) {
3031
+ console.log("Creating new EnvStore instance");
3032
+ _EnvStore.instance = new _EnvStore();
3033
+ _EnvStore.localStorageUtils = localStorageUtils2;
3034
+ _EnvStore.sessionStorageUtils = sessionStorageUtils2;
3035
+ } else {
3036
+ console.log("Returning existing EnvStore instance");
3037
+ }
3038
+ return _EnvStore.instance;
3039
+ }
3040
+ static getState() {
3041
+ const state = envStore.getState().env;
3042
+ console.log("Redux env state:", state);
3043
+ return {
3044
+ baseUrl: state?.baseUrl,
3045
+ requests: state?.requests,
3046
+ context: state?.context,
3047
+ defaultCompany: state?.defaultCompany,
3048
+ config: state?.config,
3049
+ companies: state?.companies || [],
3050
+ user: state?.user,
3051
+ db: state?.db,
3052
+ refreshTokenEndpoint: state?.refreshTokenEndpoint,
3053
+ uid: state?.uid,
3054
+ lang: state?.lang,
3055
+ allowCompanies: state?.allowCompanies
3056
+ };
3057
+ }
3058
+ static setupEnv(envConfig) {
3059
+ const dispatch = envStore.dispatch;
3060
+ const env = {
3061
+ ..._EnvStore.getState(),
3062
+ ...envConfig,
3063
+ localStorageUtils: _EnvStore.localStorageUtils,
3064
+ sessionStorageUtils: _EnvStore.sessionStorageUtils
3065
+ };
3066
+ console.log("Setting up env with config:", envConfig);
3067
+ const requests = axiosClient.init(env);
3068
+ console.log("axiosClient.init result:", requests);
3069
+ dispatch(setEnv({ ...env, requests }));
3070
+ }
3071
+ static setUid(uid) {
3072
+ const dispatch = envStore.dispatch;
3073
+ dispatch(setUid(uid));
3074
+ }
3075
+ static setLang(lang) {
3076
+ const dispatch = envStore.dispatch;
3077
+ dispatch(setLang(lang));
3078
+ }
3079
+ static setAllowCompanies(allowCompanies) {
3080
+ const dispatch = envStore.dispatch;
3081
+ dispatch(setAllowCompanies(allowCompanies));
3082
+ }
3083
+ static setCompanies(companies) {
3084
+ const dispatch = envStore.dispatch;
3085
+ dispatch(setCompanies(companies));
3086
+ }
3087
+ static setDefaultCompany(company) {
3088
+ const dispatch = envStore.dispatch;
3089
+ dispatch(setDefaultCompany(company));
3090
+ }
3091
+ static setUserInfo(userInfo) {
3092
+ const dispatch = envStore.dispatch;
3093
+ dispatch(setUser(userInfo));
3094
+ }
2804
3095
  };
2805
3096
  function getEnv() {
2806
- const env = envStore.getState().env;
2807
- return { ...env, requests };
3097
+ return EnvStore.getState();
2808
3098
  }
2809
3099
 
2810
3100
  // src/services/action-service/index.ts
@@ -2972,7 +3262,7 @@ var AuthService = {
2972
3262
  }).filter(([_, value]) => !!value)
2973
3263
  );
2974
3264
  const encodedData = new URLSearchParams(payload).toString();
2975
- return env?.requests?.post(body?.path ?? "", encodedData, {
3265
+ return env?.requests?.post(body.path, encodedData, {
2976
3266
  headers: {
2977
3267
  "Content-Type": "application/x-www-form-urlencoded"
2978
3268
  }
@@ -3069,20 +3359,6 @@ var AuthService = {
3069
3359
  }
3070
3360
  });
3071
3361
  },
3072
- async isValidActionToken(actionToken, path) {
3073
- const env = getEnv();
3074
- return env?.requests?.post(
3075
- path,
3076
- {},
3077
- {
3078
- headers: {
3079
- "Content-Type": "application/json"
3080
- },
3081
- useActionToken: true,
3082
- actionToken
3083
- }
3084
- );
3085
- },
3086
3362
  async loginSocial({
3087
3363
  db,
3088
3364
  state,
@@ -3847,7 +4123,7 @@ var model_service_default = ModelService;
3847
4123
  var UserService = {
3848
4124
  async getProfile(path) {
3849
4125
  const env = getEnv();
3850
- return env?.requests?.get(path ?? "/userinfo" /* PROFILE_PATH */, {
4126
+ return env.requests.get(path ?? "/userinfo" /* PROFILE_PATH */, {
3851
4127
  headers: {
3852
4128
  "Content-Type": "application/x-www-form-urlencoded"
3853
4129
  }
@@ -4166,7 +4442,8 @@ var ViewService = {
4166
4442
  },
4167
4443
  async getVersion() {
4168
4444
  const env = getEnv();
4169
- return env?.requests.get("", {
4445
+ console.log("env?.requests", env, env?.requests);
4446
+ return env?.requests?.get("", {
4170
4447
  headers: {
4171
4448
  "Content-Type": "application/json"
4172
4449
  }
@@ -4483,33 +4760,19 @@ var useGetAccessByCode = () => {
4483
4760
  };
4484
4761
  var use_get_access_by_code_default = useGetAccessByCode;
4485
4762
 
4486
- // src/hooks/auth/use-validate-action-token.ts
4487
- import { useMutation as useMutation12 } from "@tanstack/react-query";
4488
- var useValidateActionToken = () => {
4489
- return useMutation12({
4490
- mutationFn: ({
4491
- actionToken,
4492
- path
4493
- }) => {
4494
- return auth_service_default.isValidActionToken(actionToken, path);
4495
- }
4496
- });
4497
- };
4498
- var use_validate_action_token_default = useValidateActionToken;
4499
-
4500
4763
  // src/hooks/company/use-get-company-info.ts
4501
- import { useMutation as useMutation13 } from "@tanstack/react-query";
4764
+ import { useMutation as useMutation12 } from "@tanstack/react-query";
4502
4765
  var useGetCompanyInfo = () => {
4503
- return useMutation13({
4766
+ return useMutation12({
4504
4767
  mutationFn: (id) => company_service_default.getInfoCompany(id)
4505
4768
  });
4506
4769
  };
4507
4770
  var use_get_company_info_default = useGetCompanyInfo;
4508
4771
 
4509
4772
  // src/hooks/company/use-get-current-company.ts
4510
- import { useMutation as useMutation14 } from "@tanstack/react-query";
4773
+ import { useMutation as useMutation13 } from "@tanstack/react-query";
4511
4774
  var useGetCurrentCompany = () => {
4512
- return useMutation14({
4775
+ return useMutation13({
4513
4776
  mutationFn: () => company_service_default.getCurrentCompany()
4514
4777
  });
4515
4778
  };
@@ -4536,9 +4799,9 @@ var useGetListCompany = (companyIDs = []) => {
4536
4799
  var use_get_list_company_default = useGetListCompany;
4537
4800
 
4538
4801
  // src/hooks/excel/use-export-excel.ts
4539
- import { useMutation as useMutation15 } from "@tanstack/react-query";
4802
+ import { useMutation as useMutation14 } from "@tanstack/react-query";
4540
4803
  var useExportExcel = () => {
4541
- return useMutation15({
4804
+ return useMutation14({
4542
4805
  mutationFn: ({
4543
4806
  model,
4544
4807
  domain,
@@ -4563,9 +4826,9 @@ var useExportExcel = () => {
4563
4826
  var use_export_excel_default = useExportExcel;
4564
4827
 
4565
4828
  // src/hooks/excel/use-get-field-export.ts
4566
- import { useMutation as useMutation16 } from "@tanstack/react-query";
4829
+ import { useMutation as useMutation15 } from "@tanstack/react-query";
4567
4830
  var useGetFieldExport = () => {
4568
- return useMutation16({
4831
+ return useMutation15({
4569
4832
  mutationFn: ({
4570
4833
  ids,
4571
4834
  model,
@@ -4612,9 +4875,9 @@ var useGetFileExcel = ({ model }) => {
4612
4875
  var use_get_file_excel_default = useGetFileExcel;
4613
4876
 
4614
4877
  // src/hooks/excel/use-parse-preview.ts
4615
- import { useMutation as useMutation17 } from "@tanstack/react-query";
4878
+ import { useMutation as useMutation16 } from "@tanstack/react-query";
4616
4879
  var useParsePreview = () => {
4617
- return useMutation17({
4880
+ return useMutation16({
4618
4881
  mutationFn: ({
4619
4882
  id,
4620
4883
  selectedSheet,
@@ -4631,9 +4894,9 @@ var useParsePreview = () => {
4631
4894
  var use_parse_preview_default = useParsePreview;
4632
4895
 
4633
4896
  // src/hooks/excel/use-upload-file.ts
4634
- import { useMutation as useMutation18 } from "@tanstack/react-query";
4897
+ import { useMutation as useMutation17 } from "@tanstack/react-query";
4635
4898
  var useUploadFile = () => {
4636
- return useMutation18({
4899
+ return useMutation17({
4637
4900
  mutationFn: ({ formData }) => excel_service_default.uploadFile({
4638
4901
  formData
4639
4902
  })
@@ -4642,9 +4905,9 @@ var useUploadFile = () => {
4642
4905
  var use_upload_file_default = useUploadFile;
4643
4906
 
4644
4907
  // src/hooks/excel/use-upload-id-file.ts
4645
- import { useMutation as useMutation19 } from "@tanstack/react-query";
4908
+ import { useMutation as useMutation18 } from "@tanstack/react-query";
4646
4909
  var useUploadIdFile = () => {
4647
- return useMutation19({
4910
+ return useMutation18({
4648
4911
  mutationFn: ({ formData }) => excel_service_default.uploadIdFile({
4649
4912
  formData
4650
4913
  })
@@ -4653,9 +4916,9 @@ var useUploadIdFile = () => {
4653
4916
  var use_upload_id_file_default = useUploadIdFile;
4654
4917
 
4655
4918
  // src/hooks/excel/uss-execute-import.ts
4656
- import { useMutation as useMutation20 } from "@tanstack/react-query";
4919
+ import { useMutation as useMutation19 } from "@tanstack/react-query";
4657
4920
  var useExecuteImport = () => {
4658
- return useMutation20({
4921
+ return useMutation19({
4659
4922
  mutationFn: ({
4660
4923
  fields,
4661
4924
  columns,
@@ -4676,9 +4939,9 @@ var useExecuteImport = () => {
4676
4939
  var uss_execute_import_default = useExecuteImport;
4677
4940
 
4678
4941
  // src/hooks/form/use-change-status.ts
4679
- import { useMutation as useMutation21 } from "@tanstack/react-query";
4942
+ import { useMutation as useMutation20 } from "@tanstack/react-query";
4680
4943
  var useChangeStatus = () => {
4681
- return useMutation21({
4944
+ return useMutation20({
4682
4945
  mutationFn: ({ data }) => {
4683
4946
  return form_service_default.changeStatus({
4684
4947
  data
@@ -4689,9 +4952,9 @@ var useChangeStatus = () => {
4689
4952
  var use_change_status_default = useChangeStatus;
4690
4953
 
4691
4954
  // src/hooks/form/use-delete-comment.ts
4692
- import { useMutation as useMutation22 } from "@tanstack/react-query";
4955
+ import { useMutation as useMutation21 } from "@tanstack/react-query";
4693
4956
  var useDeleteComment = () => {
4694
- return useMutation22({
4957
+ return useMutation21({
4695
4958
  mutationFn: ({ data }) => form_service_default.deleteComment({
4696
4959
  data
4697
4960
  })
@@ -4756,9 +5019,9 @@ var useGetImage = ({
4756
5019
  var use_get_image_default = useGetImage;
4757
5020
 
4758
5021
  // src/hooks/form/use-send-comment.ts
4759
- import { useMutation as useMutation23 } from "@tanstack/react-query";
5022
+ import { useMutation as useMutation22 } from "@tanstack/react-query";
4760
5023
  var useSendComment = () => {
4761
- return useMutation23({
5024
+ return useMutation22({
4762
5025
  mutationFn: ({ data }) => form_service_default.sentComment({
4763
5026
  data
4764
5027
  })
@@ -4767,9 +5030,9 @@ var useSendComment = () => {
4767
5030
  var use_send_comment_default = useSendComment;
4768
5031
 
4769
5032
  // src/hooks/form/use-upload-image.ts
4770
- import { useMutation as useMutation24 } from "@tanstack/react-query";
5033
+ import { useMutation as useMutation23 } from "@tanstack/react-query";
4771
5034
  var useUploadImage = () => {
4772
- return useMutation24({
5035
+ return useMutation23({
4773
5036
  mutationFn: ({ data }) => form_service_default.uploadImage({
4774
5037
  data
4775
5038
  })
@@ -4778,9 +5041,9 @@ var useUploadImage = () => {
4778
5041
  var use_upload_image_default = useUploadImage;
4779
5042
 
4780
5043
  // src/hooks/model/use-delete.ts
4781
- import { useMutation as useMutation25 } from "@tanstack/react-query";
5044
+ import { useMutation as useMutation24 } from "@tanstack/react-query";
4782
5045
  var useDelete = () => {
4783
- return useMutation25({
5046
+ return useMutation24({
4784
5047
  mutationFn: ({ ids, model }) => model_service_default.delete({ ids, model })
4785
5048
  });
4786
5049
  };
@@ -4834,9 +5097,9 @@ var useGetCurrency = () => {
4834
5097
  var use_get_currency_default = useGetCurrency;
4835
5098
 
4836
5099
  // src/hooks/model/use-get-detail.ts
4837
- import { useMutation as useMutation26 } from "@tanstack/react-query";
5100
+ import { useMutation as useMutation25 } from "@tanstack/react-query";
4838
5101
  var useGetDetail = () => {
4839
- return useMutation26({
5102
+ return useMutation25({
4840
5103
  mutationFn: ({
4841
5104
  model,
4842
5105
  ids,
@@ -5029,9 +5292,9 @@ var useOdooDataTransform = () => {
5029
5292
  var use_odoo_data_transform_default = useOdooDataTransform;
5030
5293
 
5031
5294
  // src/hooks/model/use-onchange-form.ts
5032
- import { useMutation as useMutation27 } from "@tanstack/react-query";
5295
+ import { useMutation as useMutation26 } from "@tanstack/react-query";
5033
5296
  var useOnChangeForm = () => {
5034
- return useMutation27({
5297
+ return useMutation26({
5035
5298
  mutationFn: ({
5036
5299
  ids,
5037
5300
  model,
@@ -5052,9 +5315,9 @@ var useOnChangeForm = () => {
5052
5315
  var use_onchange_form_default = useOnChangeForm;
5053
5316
 
5054
5317
  // src/hooks/model/use-save.ts
5055
- import { useMutation as useMutation28 } from "@tanstack/react-query";
5318
+ import { useMutation as useMutation27 } from "@tanstack/react-query";
5056
5319
  var useSave = () => {
5057
- return useMutation28({
5320
+ return useMutation27({
5058
5321
  mutationFn: ({
5059
5322
  ids,
5060
5323
  model,
@@ -5068,18 +5331,18 @@ var useSave = () => {
5068
5331
  var use_save_default = useSave;
5069
5332
 
5070
5333
  // src/hooks/user/use-get-profile.ts
5071
- import { useMutation as useMutation29 } from "@tanstack/react-query";
5334
+ import { useMutation as useMutation28 } from "@tanstack/react-query";
5072
5335
  var useGetProfile = (path) => {
5073
- return useMutation29({
5336
+ return useMutation28({
5074
5337
  mutationFn: () => user_service_default.getProfile(path)
5075
5338
  });
5076
5339
  };
5077
5340
  var use_get_profile_default = useGetProfile;
5078
5341
 
5079
5342
  // src/hooks/user/use-get-user.ts
5080
- import { useMutation as useMutation30 } from "@tanstack/react-query";
5343
+ import { useMutation as useMutation29 } from "@tanstack/react-query";
5081
5344
  var useGetUser = () => {
5082
- return useMutation30({
5345
+ return useMutation29({
5083
5346
  mutationFn: ({ id, context }) => user_service_default.getUser({
5084
5347
  id,
5085
5348
  context
@@ -5089,9 +5352,9 @@ var useGetUser = () => {
5089
5352
  var use_get_user_default = useGetUser;
5090
5353
 
5091
5354
  // src/hooks/user/use-switch-locale.ts
5092
- import { useMutation as useMutation31 } from "@tanstack/react-query";
5355
+ import { useMutation as useMutation30 } from "@tanstack/react-query";
5093
5356
  var useSwitchLocale = () => {
5094
- return useMutation31({
5357
+ return useMutation30({
5095
5358
  mutationFn: ({ data }) => {
5096
5359
  return user_service_default.switchUserLocale({
5097
5360
  id: data.id,
@@ -5103,9 +5366,9 @@ var useSwitchLocale = () => {
5103
5366
  var use_switch_locale_default = useSwitchLocale;
5104
5367
 
5105
5368
  // src/hooks/view/use-button.ts
5106
- import { useMutation as useMutation32 } from "@tanstack/react-query";
5369
+ import { useMutation as useMutation31 } from "@tanstack/react-query";
5107
5370
  var useButton = () => {
5108
- return useMutation32({
5371
+ return useMutation31({
5109
5372
  mutationFn: ({
5110
5373
  model,
5111
5374
  ids,
@@ -5125,9 +5388,9 @@ var useButton = () => {
5125
5388
  var use_button_default = useButton;
5126
5389
 
5127
5390
  // src/hooks/view/use-duplicate-record.ts
5128
- import { useMutation as useMutation33 } from "@tanstack/react-query";
5391
+ import { useMutation as useMutation32 } from "@tanstack/react-query";
5129
5392
  var useDuplicateRecord = () => {
5130
- return useMutation33({
5393
+ return useMutation32({
5131
5394
  mutationFn: ({
5132
5395
  id,
5133
5396
  model,
@@ -5253,9 +5516,9 @@ var useGetMenu = (context, enabled) => {
5253
5516
  var use_get_menu_default = useGetMenu;
5254
5517
 
5255
5518
  // src/hooks/view/use-get-print-report.ts
5256
- import { useMutation as useMutation34 } from "@tanstack/react-query";
5519
+ import { useMutation as useMutation33 } from "@tanstack/react-query";
5257
5520
  var useGetPrintReport = () => {
5258
- return useMutation34({
5521
+ return useMutation33({
5259
5522
  mutationFn: ({ id }) => action_service_default.getPrintReportName({
5260
5523
  id
5261
5524
  })
@@ -5319,9 +5582,9 @@ var useGetView = (viewParams, actData) => {
5319
5582
  var use_get_view_default = useGetView;
5320
5583
 
5321
5584
  // src/hooks/view/use-load-action.ts
5322
- import { useMutation as useMutation35 } from "@tanstack/react-query";
5585
+ import { useMutation as useMutation34 } from "@tanstack/react-query";
5323
5586
  var useLoadAction = () => {
5324
- return useMutation35({
5587
+ return useMutation34({
5325
5588
  mutationFn: ({
5326
5589
  idAction,
5327
5590
  context
@@ -5347,9 +5610,9 @@ var useLoadMessage = () => {
5347
5610
  var use_load_message_default = useLoadMessage;
5348
5611
 
5349
5612
  // src/hooks/view/use-print.ts
5350
- import { useMutation as useMutation36 } from "@tanstack/react-query";
5613
+ import { useMutation as useMutation35 } from "@tanstack/react-query";
5351
5614
  var usePrint = () => {
5352
- return useMutation36({
5615
+ return useMutation35({
5353
5616
  mutationFn: ({ id, report, db }) => action_service_default.print({
5354
5617
  id,
5355
5618
  report,
@@ -5360,9 +5623,9 @@ var usePrint = () => {
5360
5623
  var use_print_default = usePrint;
5361
5624
 
5362
5625
  // src/hooks/view/use-remove-row.ts
5363
- import { useMutation as useMutation37 } from "@tanstack/react-query";
5626
+ import { useMutation as useMutation36 } from "@tanstack/react-query";
5364
5627
  var useRemoveRow = () => {
5365
- return useMutation37({
5628
+ return useMutation36({
5366
5629
  mutationFn: ({
5367
5630
  model,
5368
5631
  ids,
@@ -5394,9 +5657,9 @@ var useGetResequence = (model, resIds, context, offset) => {
5394
5657
  var use_resequence_default = useGetResequence;
5395
5658
 
5396
5659
  // src/hooks/view/use-run-action.ts
5397
- import { useMutation as useMutation38 } from "@tanstack/react-query";
5660
+ import { useMutation as useMutation37 } from "@tanstack/react-query";
5398
5661
  var useRunAction = () => {
5399
- return useMutation38({
5662
+ return useMutation37({
5400
5663
  mutationFn: ({
5401
5664
  idAction,
5402
5665
  context
@@ -5409,9 +5672,9 @@ var useRunAction = () => {
5409
5672
  var use_run_action_default = useRunAction;
5410
5673
 
5411
5674
  // src/hooks/view/use-signin-sso.ts
5412
- import { useMutation as useMutation39 } from "@tanstack/react-query";
5675
+ import { useMutation as useMutation38 } from "@tanstack/react-query";
5413
5676
  var useSignInSSO = () => {
5414
- return useMutation39({
5677
+ return useMutation38({
5415
5678
  mutationFn: ({
5416
5679
  redirect_uri,
5417
5680
  state,
@@ -5432,9 +5695,9 @@ var useSignInSSO = () => {
5432
5695
  var use_signin_sso_default = useSignInSSO;
5433
5696
 
5434
5697
  // src/hooks/view/use-verify-2FA.ts
5435
- import { useMutation as useMutation40 } from "@tanstack/react-query";
5698
+ import { useMutation as useMutation39 } from "@tanstack/react-query";
5436
5699
  var useVerify2FA = () => {
5437
- return useMutation40({
5700
+ return useMutation39({
5438
5701
  mutationFn: ({
5439
5702
  method,
5440
5703
  with_context,
@@ -5455,9 +5718,9 @@ var useVerify2FA = () => {
5455
5718
  var use_verify_2FA_default = useVerify2FA;
5456
5719
 
5457
5720
  // src/hooks/view/uset-get-2FA-method.ts
5458
- import { useMutation as useMutation41 } from "@tanstack/react-query";
5721
+ import { useMutation as useMutation40 } from "@tanstack/react-query";
5459
5722
  var useGet2FAMethods = () => {
5460
- return useMutation41({
5723
+ return useMutation40({
5461
5724
  mutationFn: ({
5462
5725
  method,
5463
5726
  with_context
@@ -5472,9 +5735,9 @@ var useGet2FAMethods = () => {
5472
5735
  var uset_get_2FA_method_default = useGet2FAMethods;
5473
5736
 
5474
5737
  // src/hooks/view/use-get-fields-view-security.ts
5475
- import { useMutation as useMutation42 } from "@tanstack/react-query";
5738
+ import { useMutation as useMutation41 } from "@tanstack/react-query";
5476
5739
  var useGetFieldsViewSecurity = () => {
5477
- return useMutation42({
5740
+ return useMutation41({
5478
5741
  mutationFn: ({
5479
5742
  method,
5480
5743
  token,
@@ -5491,9 +5754,9 @@ var useGetFieldsViewSecurity = () => {
5491
5754
  var use_get_fields_view_security_default = useGetFieldsViewSecurity;
5492
5755
 
5493
5756
  // src/hooks/view/use-grant-access.ts
5494
- import { useMutation as useMutation43 } from "@tanstack/react-query";
5757
+ import { useMutation as useMutation42 } from "@tanstack/react-query";
5495
5758
  var useGrantAccess = () => {
5496
- return useMutation43({
5759
+ return useMutation42({
5497
5760
  mutationFn: ({
5498
5761
  redirect_uri,
5499
5762
  state,
@@ -5512,9 +5775,9 @@ var useGrantAccess = () => {
5512
5775
  var use_grant_access_default = useGrantAccess;
5513
5776
 
5514
5777
  // src/hooks/view/use-remove-totp-setup.ts
5515
- import { useMutation as useMutation44 } from "@tanstack/react-query";
5778
+ import { useMutation as useMutation43 } from "@tanstack/react-query";
5516
5779
  var useRemoveTotpSetup = () => {
5517
- return useMutation44({
5780
+ return useMutation43({
5518
5781
  mutationFn: ({ method, token }) => {
5519
5782
  return view_service_default.removeTotpSetUp({
5520
5783
  method,
@@ -5526,9 +5789,9 @@ var useRemoveTotpSetup = () => {
5526
5789
  var use_remove_totp_setup_default = useRemoveTotpSetup;
5527
5790
 
5528
5791
  // src/hooks/view/use-request-setup-totp.ts
5529
- import { useMutation as useMutation45 } from "@tanstack/react-query";
5792
+ import { useMutation as useMutation44 } from "@tanstack/react-query";
5530
5793
  var useRequestSetupTotp = () => {
5531
- return useMutation45({
5794
+ return useMutation44({
5532
5795
  mutationFn: ({ method, token }) => {
5533
5796
  return view_service_default.requestSetupTotp({
5534
5797
  method,
@@ -5540,9 +5803,9 @@ var useRequestSetupTotp = () => {
5540
5803
  var use_request_setup_totp_default = useRequestSetupTotp;
5541
5804
 
5542
5805
  // src/hooks/view/use-settings-web-read-2fa.ts
5543
- import { useMutation as useMutation46 } from "@tanstack/react-query";
5806
+ import { useMutation as useMutation45 } from "@tanstack/react-query";
5544
5807
  var useSettingsWebRead2fa = () => {
5545
- return useMutation46({
5808
+ return useMutation45({
5546
5809
  mutationFn: ({
5547
5810
  method,
5548
5811
  token,
@@ -5561,9 +5824,9 @@ var useSettingsWebRead2fa = () => {
5561
5824
  var use_settings_web_read_2fa_default = useSettingsWebRead2fa;
5562
5825
 
5563
5826
  // src/hooks/view/use-verify-totp.ts
5564
- import { useMutation as useMutation47 } from "@tanstack/react-query";
5827
+ import { useMutation as useMutation46 } from "@tanstack/react-query";
5565
5828
  var useVerifyTotp = () => {
5566
- return useMutation47({
5829
+ return useMutation46({
5567
5830
  mutationFn: ({
5568
5831
  method,
5569
5832
  action_token,
@@ -5645,7 +5908,6 @@ export {
5645
5908
  use_upload_file_default as useUploadFile,
5646
5909
  use_upload_id_file_default as useUploadIdFile,
5647
5910
  use_upload_image_default as useUploadImage,
5648
- use_validate_action_token_default as useValidateActionToken,
5649
5911
  use_verify_2FA_default as useVerify2FA,
5650
5912
  use_verify_totp_default as useVerifyTotp
5651
5913
  };