@fctc/interface-logic 1.5.1 → 1.5.3

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.
@@ -0,0 +1,3620 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __pow = Math.pow;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
+ var __async = (__this, __arguments, generator) => {
22
+ return new Promise((resolve, reject) => {
23
+ var fulfilled = (value) => {
24
+ try {
25
+ step(generator.next(value));
26
+ } catch (e) {
27
+ reject(e);
28
+ }
29
+ };
30
+ var rejected = (value) => {
31
+ try {
32
+ step(generator.throw(value));
33
+ } catch (e) {
34
+ reject(e);
35
+ }
36
+ };
37
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
38
+ step((generator = generator.apply(__this, __arguments)).next());
39
+ });
40
+ };
41
+
42
+ // src/provider/react-query-provider.tsx
43
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
44
+ import { jsx } from "react/jsx-runtime";
45
+ var ReactQueryProvider = ({ children }) => {
46
+ const queryClient = new QueryClient({
47
+ defaultOptions: {
48
+ queries: {
49
+ // placeholderData: keepPreviousData,
50
+ refetchOnWindowFocus: false,
51
+ refetchOnMount: false,
52
+ refetchOnReconnect: false,
53
+ retry: false
54
+ }
55
+ }
56
+ });
57
+ return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children });
58
+ };
59
+
60
+ // src/provider/redux-provider.tsx
61
+ import { Provider } from "react-redux";
62
+
63
+ // src/store/index.ts
64
+ import { useDispatch, useSelector } from "react-redux";
65
+
66
+ // src/store/reducers/breadcrums-slice/index.ts
67
+ import { createSlice } from "@reduxjs/toolkit";
68
+ var initialState = {
69
+ breadCrumbs: []
70
+ };
71
+ var breadcrumbsSlice = createSlice({
72
+ name: "breadcrumbs",
73
+ initialState,
74
+ reducers: {
75
+ setBreadCrumbs: (state, action) => {
76
+ state.breadCrumbs = [...state.breadCrumbs, action.payload];
77
+ }
78
+ }
79
+ });
80
+ var { setBreadCrumbs } = breadcrumbsSlice.actions;
81
+ var breadcrums_slice_default = breadcrumbsSlice.reducer;
82
+
83
+ // src/store/reducers/env-slice/index.ts
84
+ import { createSlice as createSlice2 } from "@reduxjs/toolkit";
85
+ var initialState2 = {
86
+ baseUrl: "",
87
+ requests: null,
88
+ companies: [],
89
+ user: {},
90
+ config: null,
91
+ envFile: null,
92
+ defaultCompany: {
93
+ id: null,
94
+ logo: "",
95
+ secondary_color: "",
96
+ primary_color: ""
97
+ },
98
+ context: {
99
+ uid: null,
100
+ allowed_company_ids: [],
101
+ lang: "vi_VN",
102
+ tz: "Asia/Saigon"
103
+ }
104
+ };
105
+ var envSlice = createSlice2({
106
+ name: "env",
107
+ initialState: initialState2,
108
+ reducers: {
109
+ setEnv: (state, action) => {
110
+ Object.assign(state, action.payload);
111
+ },
112
+ setUid: (state, action) => {
113
+ state.context.uid = action.payload;
114
+ },
115
+ setAllowCompanies: (state, action) => {
116
+ state.context.allowed_company_ids = action.payload;
117
+ },
118
+ setCompanies: (state, action) => {
119
+ state.companies = action.payload;
120
+ },
121
+ setDefaultCompany: (state, action) => {
122
+ state.defaultCompany = action.payload;
123
+ },
124
+ setLang: (state, action) => {
125
+ state.context.lang = action.payload;
126
+ },
127
+ setUser: (state, action) => {
128
+ state.user = action.payload;
129
+ },
130
+ setConfig: (state, action) => {
131
+ state.config = action.payload;
132
+ },
133
+ setEnvFile: (state, action) => {
134
+ state.envFile = action.payload;
135
+ }
136
+ }
137
+ });
138
+ var {
139
+ setEnv,
140
+ setUid,
141
+ setLang,
142
+ setAllowCompanies,
143
+ setCompanies,
144
+ setDefaultCompany,
145
+ setUser,
146
+ setConfig,
147
+ setEnvFile
148
+ } = envSlice.actions;
149
+ var env_slice_default = envSlice.reducer;
150
+
151
+ // src/store/reducers/excel-slice/index.ts
152
+ import { createSlice as createSlice3 } from "@reduxjs/toolkit";
153
+ var initialState3 = {
154
+ dataParse: null,
155
+ idFile: null,
156
+ isFileLoaded: false,
157
+ loadingImport: false,
158
+ selectedFile: null,
159
+ errorData: null
160
+ };
161
+ var excelSlice = createSlice3({
162
+ name: "excel",
163
+ initialState: initialState3,
164
+ reducers: {
165
+ setDataParse: (state, action) => {
166
+ state.dataParse = action.payload;
167
+ },
168
+ setIdFile: (state, action) => {
169
+ state.idFile = action.payload;
170
+ },
171
+ setIsFileLoaded: (state, action) => {
172
+ state.isFileLoaded = action.payload;
173
+ },
174
+ setLoadingImport: (state, action) => {
175
+ state.loadingImport = action.payload;
176
+ },
177
+ setSelectedFile: (state, action) => {
178
+ state.selectedFile = action.payload;
179
+ },
180
+ setErrorData: (state, action) => {
181
+ state.errorData = action.payload;
182
+ }
183
+ }
184
+ });
185
+ var {
186
+ setDataParse,
187
+ setIdFile,
188
+ setIsFileLoaded,
189
+ setLoadingImport,
190
+ setSelectedFile,
191
+ setErrorData
192
+ } = excelSlice.actions;
193
+ var excel_slice_default = excelSlice.reducer;
194
+
195
+ // src/store/reducers/form-slice/index.ts
196
+ import { createSlice as createSlice4 } from "@reduxjs/toolkit";
197
+ var initialState4 = {
198
+ viewDataStore: {},
199
+ isShowingModalDetail: false,
200
+ isShowModalTranslate: false,
201
+ formSubmitComponent: {},
202
+ fieldTranslation: null,
203
+ listSubject: {},
204
+ dataUser: {}
205
+ };
206
+ var formSlice = createSlice4({
207
+ name: "form",
208
+ initialState: initialState4,
209
+ reducers: {
210
+ setViewDataStore: (state, action) => {
211
+ state.viewDataStore = action.payload;
212
+ },
213
+ setIsShowingModalDetail: (state, action) => {
214
+ state.isShowingModalDetail = action.payload;
215
+ },
216
+ setIsShowModalTranslate: (state, action) => {
217
+ state.isShowModalTranslate = action.payload;
218
+ },
219
+ setFormSubmitComponent: (state, action) => {
220
+ state.formSubmitComponent[action.payload.key] = action.payload.component;
221
+ },
222
+ setFieldTranslate: (state, action) => {
223
+ state.fieldTranslation = action.payload;
224
+ },
225
+ setListSubject: (state, action) => {
226
+ state.listSubject = action.payload;
227
+ },
228
+ setDataUser: (state, action) => {
229
+ state.dataUser = action.payload;
230
+ }
231
+ }
232
+ });
233
+ var {
234
+ setViewDataStore,
235
+ setIsShowingModalDetail,
236
+ setIsShowModalTranslate,
237
+ setFormSubmitComponent,
238
+ setFieldTranslate,
239
+ setListSubject,
240
+ setDataUser
241
+ } = formSlice.actions;
242
+ var form_slice_default = formSlice.reducer;
243
+
244
+ // src/store/reducers/header-slice/index.ts
245
+ import { createSlice as createSlice5 } from "@reduxjs/toolkit";
246
+ var headerSlice = createSlice5({
247
+ name: "header",
248
+ initialState: {
249
+ value: { allowedCompanyIds: [] }
250
+ },
251
+ reducers: {
252
+ setHeader: (state, action) => {
253
+ state.value = __spreadValues(__spreadValues({}, state.value), action.payload);
254
+ },
255
+ setAllowedCompanyIds: (state, action) => {
256
+ state.value.allowedCompanyIds = action.payload;
257
+ }
258
+ }
259
+ });
260
+ var { setAllowedCompanyIds, setHeader } = headerSlice.actions;
261
+ var header_slice_default = headerSlice.reducer;
262
+
263
+ // src/store/reducers/list-slice/index.ts
264
+ import { createSlice as createSlice6 } from "@reduxjs/toolkit";
265
+ var initialState5 = {
266
+ pageLimit: 10,
267
+ fields: {},
268
+ order: "",
269
+ selectedRowKeys: [],
270
+ selectedRadioKey: 0,
271
+ indexRowTableModal: -2,
272
+ isUpdateTableModal: false,
273
+ footerGroupTable: {},
274
+ transferDetail: null,
275
+ page: 0,
276
+ domainTable: []
277
+ };
278
+ var listSlice = createSlice6({
279
+ name: "list",
280
+ initialState: initialState5,
281
+ reducers: {
282
+ setPageLimit: (state, action) => {
283
+ state.pageLimit = action.payload;
284
+ },
285
+ setFields: (state, action) => {
286
+ state.fields = action.payload;
287
+ },
288
+ setOrder: (state, action) => {
289
+ state.order = action.payload;
290
+ },
291
+ setSelectedRowKeys: (state, action) => {
292
+ state.selectedRowKeys = action.payload;
293
+ },
294
+ setSelectedRadioKey: (state, action) => {
295
+ state.selectedRadioKey = action.payload;
296
+ },
297
+ setIndexRowTableModal: (state, action) => {
298
+ state.indexRowTableModal = action.payload;
299
+ },
300
+ setTransferDetail: (state, action) => {
301
+ state.transferDetail = action.payload;
302
+ },
303
+ setIsUpdateTableModal: (state, action) => {
304
+ state.isUpdateTableModal = action.payload;
305
+ },
306
+ setPage: (state, action) => {
307
+ state.page = action.payload;
308
+ },
309
+ setDomainTable: (state, action) => {
310
+ state.domainTable = action.payload;
311
+ }
312
+ }
313
+ });
314
+ var {
315
+ setPageLimit,
316
+ setFields,
317
+ setOrder,
318
+ setSelectedRowKeys,
319
+ setIndexRowTableModal,
320
+ setIsUpdateTableModal,
321
+ setPage,
322
+ setSelectedRadioKey,
323
+ setTransferDetail,
324
+ setDomainTable
325
+ } = listSlice.actions;
326
+ var list_slice_default = listSlice.reducer;
327
+
328
+ // src/store/reducers/login-slice/index.ts
329
+ import { createSlice as createSlice7 } from "@reduxjs/toolkit";
330
+ var initialState6 = {
331
+ db: "",
332
+ redirectTo: "/",
333
+ forgotPasswordUrl: "/"
334
+ };
335
+ var loginSlice = createSlice7({
336
+ name: "login",
337
+ initialState: initialState6,
338
+ reducers: {
339
+ setDb: (state, action) => {
340
+ state.db = action.payload;
341
+ },
342
+ setRedirectTo: (state, action) => {
343
+ state.redirectTo = action.payload;
344
+ },
345
+ setForgotPasswordUrl: (state, action) => {
346
+ state.forgotPasswordUrl = action.payload;
347
+ }
348
+ }
349
+ });
350
+ var { setDb, setRedirectTo, setForgotPasswordUrl } = loginSlice.actions;
351
+ var login_slice_default = loginSlice.reducer;
352
+
353
+ // src/store/reducers/navbar-slice/index.ts
354
+ import { createSlice as createSlice8 } from "@reduxjs/toolkit";
355
+ var initialState7 = {
356
+ menuFocus: {},
357
+ menuAction: {},
358
+ navbarWidth: 250,
359
+ menuList: []
360
+ };
361
+ var navbarSlice = createSlice8({
362
+ name: "navbar",
363
+ initialState: initialState7,
364
+ reducers: {
365
+ setMenuFocus: (state, action) => {
366
+ state.menuFocus = action.payload;
367
+ },
368
+ setMenuFocusAction: (state, action) => {
369
+ state.menuAction = action.payload;
370
+ },
371
+ setNavbarWidth: (state, action) => {
372
+ state.navbarWidth = action.payload;
373
+ },
374
+ setMenuList: (state, action) => {
375
+ state.menuList = action.payload;
376
+ }
377
+ }
378
+ });
379
+ var { setMenuFocus, setMenuFocusAction, setNavbarWidth, setMenuList } = navbarSlice.actions;
380
+ var navbar_slice_default = navbarSlice.reducer;
381
+
382
+ // src/store/reducers/profile-slice/index.ts
383
+ import { createSlice as createSlice9 } from "@reduxjs/toolkit";
384
+ var initialState8 = {
385
+ profile: {}
386
+ };
387
+ var profileSlice = createSlice9({
388
+ name: "profile",
389
+ initialState: initialState8,
390
+ reducers: {
391
+ setProfile: (state, action) => {
392
+ state.profile = action.payload;
393
+ }
394
+ }
395
+ });
396
+ var { setProfile } = profileSlice.actions;
397
+ var profile_slice_default = profileSlice.reducer;
398
+
399
+ // src/store/reducers/search-slice/index.ts
400
+ import { createSlice as createSlice10 } from "@reduxjs/toolkit";
401
+ var initialState9 = {
402
+ groupByDomain: null,
403
+ searchBy: [],
404
+ searchString: "",
405
+ hoveredIndexSearchList: null,
406
+ selectedTags: [],
407
+ firstDomain: null,
408
+ searchMap: {},
409
+ filterBy: [],
410
+ groupBy: []
411
+ };
412
+ var searchSlice = createSlice10({
413
+ name: "search",
414
+ initialState: initialState9,
415
+ reducers: {
416
+ setGroupByDomain: (state, action) => {
417
+ state.groupByDomain = action.payload;
418
+ },
419
+ setSearchBy: (state, action) => {
420
+ state.searchBy = action.payload;
421
+ },
422
+ setSearchString: (state, action) => {
423
+ state.searchString = action.payload;
424
+ },
425
+ setHoveredIndexSearchList: (state, action) => {
426
+ state.hoveredIndexSearchList = action.payload;
427
+ },
428
+ setSelectedTags: (state, action) => {
429
+ state.selectedTags = action.payload;
430
+ },
431
+ setFirstDomain: (state, action) => {
432
+ state.firstDomain = action.payload;
433
+ },
434
+ setFilterBy: (state, action) => {
435
+ state.filterBy = action.payload;
436
+ },
437
+ setGroupBy: (state, action) => {
438
+ state.groupBy = action.payload;
439
+ },
440
+ setSearchMap: (state, action) => {
441
+ state.searchMap = action.payload;
442
+ },
443
+ updateSearchMap: (state, action) => {
444
+ if (!state.searchMap[action.payload.key]) {
445
+ state.searchMap[action.payload.key] = [];
446
+ }
447
+ state.searchMap[action.payload.key].push(action.payload.value);
448
+ },
449
+ removeKeyFromSearchMap: (state, action) => {
450
+ const { key, item } = action.payload;
451
+ const values = state.searchMap[key];
452
+ if (!values) return;
453
+ if (item) {
454
+ const filtered = values.filter((value) => value.name !== item.name);
455
+ if (filtered.length > 0) {
456
+ state.searchMap[key] = filtered;
457
+ } else {
458
+ delete state.searchMap[key];
459
+ }
460
+ } else {
461
+ delete state.searchMap[key];
462
+ }
463
+ },
464
+ clearSearchMap: (state) => {
465
+ state.searchMap = {};
466
+ }
467
+ }
468
+ });
469
+ var {
470
+ setGroupByDomain,
471
+ setSelectedTags,
472
+ setSearchString,
473
+ setHoveredIndexSearchList,
474
+ setFirstDomain,
475
+ setSearchBy,
476
+ setFilterBy,
477
+ setSearchMap,
478
+ updateSearchMap,
479
+ removeKeyFromSearchMap,
480
+ setGroupBy,
481
+ clearSearchMap
482
+ } = searchSlice.actions;
483
+ var search_slice_default = searchSlice.reducer;
484
+
485
+ // src/store/store.ts
486
+ import { configureStore } from "@reduxjs/toolkit";
487
+
488
+ // node_modules/redux/dist/redux.mjs
489
+ function formatProdErrorMessage(code) {
490
+ 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. `;
491
+ }
492
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
493
+ var ActionTypes = {
494
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
495
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
496
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
497
+ };
498
+ var actionTypes_default = ActionTypes;
499
+ function isPlainObject(obj) {
500
+ if (typeof obj !== "object" || obj === null)
501
+ return false;
502
+ let proto = obj;
503
+ while (Object.getPrototypeOf(proto) !== null) {
504
+ proto = Object.getPrototypeOf(proto);
505
+ }
506
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
507
+ }
508
+ function miniKindOf(val) {
509
+ if (val === void 0)
510
+ return "undefined";
511
+ if (val === null)
512
+ return "null";
513
+ const type = typeof val;
514
+ switch (type) {
515
+ case "boolean":
516
+ case "string":
517
+ case "number":
518
+ case "symbol":
519
+ case "function": {
520
+ return type;
521
+ }
522
+ }
523
+ if (Array.isArray(val))
524
+ return "array";
525
+ if (isDate(val))
526
+ return "date";
527
+ if (isError(val))
528
+ return "error";
529
+ const constructorName = ctorName(val);
530
+ switch (constructorName) {
531
+ case "Symbol":
532
+ case "Promise":
533
+ case "WeakMap":
534
+ case "WeakSet":
535
+ case "Map":
536
+ case "Set":
537
+ return constructorName;
538
+ }
539
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
540
+ }
541
+ function ctorName(val) {
542
+ return typeof val.constructor === "function" ? val.constructor.name : null;
543
+ }
544
+ function isError(val) {
545
+ return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
546
+ }
547
+ function isDate(val) {
548
+ if (val instanceof Date)
549
+ return true;
550
+ return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
551
+ }
552
+ function kindOf(val) {
553
+ let typeOfVal = typeof val;
554
+ if (process.env.NODE_ENV !== "production") {
555
+ typeOfVal = miniKindOf(val);
556
+ }
557
+ return typeOfVal;
558
+ }
559
+ function warning(message) {
560
+ if (typeof console !== "undefined" && typeof console.error === "function") {
561
+ console.error(message);
562
+ }
563
+ try {
564
+ throw new Error(message);
565
+ } catch (e) {
566
+ }
567
+ }
568
+ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
569
+ const reducerKeys = Object.keys(reducers);
570
+ const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
571
+ if (reducerKeys.length === 0) {
572
+ return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
573
+ }
574
+ if (!isPlainObject(inputState)) {
575
+ return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
576
+ }
577
+ const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
578
+ unexpectedKeys.forEach((key) => {
579
+ unexpectedKeyCache[key] = true;
580
+ });
581
+ if (action && action.type === actionTypes_default.REPLACE)
582
+ return;
583
+ if (unexpectedKeys.length > 0) {
584
+ 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.`;
585
+ }
586
+ }
587
+ function assertReducerShape(reducers) {
588
+ Object.keys(reducers).forEach((key) => {
589
+ const reducer = reducers[key];
590
+ const initialState10 = reducer(void 0, {
591
+ type: actionTypes_default.INIT
592
+ });
593
+ if (typeof initialState10 === "undefined") {
594
+ 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.`);
595
+ }
596
+ if (typeof reducer(void 0, {
597
+ type: actionTypes_default.PROBE_UNKNOWN_ACTION()
598
+ }) === "undefined") {
599
+ 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.`);
600
+ }
601
+ });
602
+ }
603
+ function combineReducers(reducers) {
604
+ const reducerKeys = Object.keys(reducers);
605
+ const finalReducers = {};
606
+ for (let i = 0; i < reducerKeys.length; i++) {
607
+ const key = reducerKeys[i];
608
+ if (process.env.NODE_ENV !== "production") {
609
+ if (typeof reducers[key] === "undefined") {
610
+ warning(`No reducer provided for key "${key}"`);
611
+ }
612
+ }
613
+ if (typeof reducers[key] === "function") {
614
+ finalReducers[key] = reducers[key];
615
+ }
616
+ }
617
+ const finalReducerKeys = Object.keys(finalReducers);
618
+ let unexpectedKeyCache;
619
+ if (process.env.NODE_ENV !== "production") {
620
+ unexpectedKeyCache = {};
621
+ }
622
+ let shapeAssertionError;
623
+ try {
624
+ assertReducerShape(finalReducers);
625
+ } catch (e) {
626
+ shapeAssertionError = e;
627
+ }
628
+ return function combination(state = {}, action) {
629
+ if (shapeAssertionError) {
630
+ throw shapeAssertionError;
631
+ }
632
+ if (process.env.NODE_ENV !== "production") {
633
+ const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
634
+ if (warningMessage) {
635
+ warning(warningMessage);
636
+ }
637
+ }
638
+ let hasChanged = false;
639
+ const nextState = {};
640
+ for (let i = 0; i < finalReducerKeys.length; i++) {
641
+ const key = finalReducerKeys[i];
642
+ const reducer = finalReducers[key];
643
+ const previousStateForKey = state[key];
644
+ const nextStateForKey = reducer(previousStateForKey, action);
645
+ if (typeof nextStateForKey === "undefined") {
646
+ const actionType = action && action.type;
647
+ 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.`);
648
+ }
649
+ nextState[key] = nextStateForKey;
650
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
651
+ }
652
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
653
+ return hasChanged ? nextState : state;
654
+ };
655
+ }
656
+
657
+ // src/store/store.ts
658
+ var rootReducer = combineReducers({
659
+ env: env_slice_default,
660
+ header: header_slice_default,
661
+ navbar: navbar_slice_default,
662
+ list: list_slice_default,
663
+ search: search_slice_default,
664
+ form: form_slice_default,
665
+ breadcrumbs: breadcrums_slice_default,
666
+ login: login_slice_default,
667
+ excel: excel_slice_default,
668
+ profile: profile_slice_default
669
+ });
670
+ var envStore = configureStore({
671
+ reducer: rootReducer,
672
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
673
+ serializableCheck: false
674
+ })
675
+ });
676
+
677
+ // src/provider/redux-provider.tsx
678
+ import { jsx as jsx2 } from "react/jsx-runtime";
679
+ var ReduxProvider = ({ children }) => {
680
+ return /* @__PURE__ */ jsx2(Provider, { store: envStore, children });
681
+ };
682
+
683
+ // src/provider/main-provider.tsx
684
+ import { jsx as jsx3 } from "react/jsx-runtime";
685
+ var MainProvider = ({ children }) => {
686
+ return /* @__PURE__ */ jsx3(ReduxProvider, { children: /* @__PURE__ */ jsx3(ReactQueryProvider, { children }) });
687
+ };
688
+
689
+ // src/provider/version-gate-provider.tsx
690
+ import { useEffect as useEffect2, useState as useState2 } from "react";
691
+ import { useQueryClient } from "@tanstack/react-query";
692
+
693
+ // src/configs/axios-client.ts
694
+ import axios from "axios";
695
+
696
+ // src/utils/format.ts
697
+ import moment from "moment";
698
+
699
+ // src/utils/domain/py_tokenizer.ts
700
+ var TokenizerError = class extends Error {
701
+ };
702
+ var directMap = {
703
+ "\\": "\\",
704
+ '"': '"',
705
+ "'": "'",
706
+ a: "\x07",
707
+ b: "\b",
708
+ f: "\f",
709
+ n: "\n",
710
+ r: "\r",
711
+ t: " ",
712
+ v: "\v"
713
+ };
714
+ function decodeStringLiteral(str, unicode) {
715
+ const out = [];
716
+ let code;
717
+ for (let i = 0; i < str.length; ++i) {
718
+ if (str[i] !== "\\") {
719
+ out.push(str[i]);
720
+ continue;
721
+ }
722
+ const escape = str[i + 1];
723
+ if (escape in directMap) {
724
+ out.push(directMap[escape]);
725
+ ++i;
726
+ continue;
727
+ }
728
+ switch (escape) {
729
+ case "\n":
730
+ ++i;
731
+ continue;
732
+ case "N":
733
+ if (!unicode) {
734
+ break;
735
+ }
736
+ throw new TokenizerError("SyntaxError: \\N{} escape not implemented");
737
+ case "u":
738
+ if (!unicode) {
739
+ break;
740
+ }
741
+ const uni = str.slice(i + 2, i + 6);
742
+ if (!/[0-9a-f]{4}/i.test(uni)) {
743
+ throw new TokenizerError(
744
+ [
745
+ "SyntaxError: (unicode error) 'unicodeescape' codec",
746
+ " can't decode bytes in position ",
747
+ i,
748
+ "-",
749
+ i + 4,
750
+ ": truncated \\uXXXX escape"
751
+ ].join("")
752
+ );
753
+ }
754
+ code = parseInt(uni, 16);
755
+ out.push(String.fromCharCode(code));
756
+ i += 5;
757
+ continue;
758
+ case "U":
759
+ if (!unicode) {
760
+ break;
761
+ }
762
+ throw new TokenizerError("SyntaxError: \\U escape not implemented");
763
+ case "x":
764
+ const hex = str.slice(i + 2, i + 4);
765
+ if (!/[0-9a-f]{2}/i.test(hex)) {
766
+ if (!unicode) {
767
+ throw new TokenizerError("ValueError: invalid \\x escape");
768
+ }
769
+ throw new TokenizerError(
770
+ [
771
+ "SyntaxError: (unicode error) 'unicodeescape'",
772
+ " codec can't decode bytes in position ",
773
+ i,
774
+ "-",
775
+ i + 2,
776
+ ": truncated \\xXX escape"
777
+ ].join("")
778
+ );
779
+ }
780
+ code = parseInt(hex, 16);
781
+ out.push(String.fromCharCode(code));
782
+ i += 3;
783
+ continue;
784
+ default:
785
+ if (!/[0-8]/.test(escape)) {
786
+ break;
787
+ }
788
+ const r = /[0-8]{1,3}/g;
789
+ r.lastIndex = i + 1;
790
+ const m = r.exec(str);
791
+ if (!m) break;
792
+ const oct = m[0];
793
+ code = parseInt(oct, 8);
794
+ out.push(String.fromCharCode(code));
795
+ i += oct.length;
796
+ continue;
797
+ }
798
+ out.push("\\");
799
+ }
800
+ return out.join("");
801
+ }
802
+ var constants = /* @__PURE__ */ new Set(["None", "False", "True"]);
803
+ var comparators = [
804
+ "in",
805
+ "not",
806
+ "not in",
807
+ "is",
808
+ "is not",
809
+ "<",
810
+ "<=",
811
+ ">",
812
+ ">=",
813
+ "<>",
814
+ "!=",
815
+ "=="
816
+ ];
817
+ var binaryOperators = [
818
+ "or",
819
+ "and",
820
+ "|",
821
+ "^",
822
+ "&",
823
+ "<<",
824
+ ">>",
825
+ "+",
826
+ "-",
827
+ "*",
828
+ "/",
829
+ "//",
830
+ "%",
831
+ "~",
832
+ "**",
833
+ "."
834
+ ];
835
+ var unaryOperators = ["-"];
836
+ var symbols = /* @__PURE__ */ new Set([
837
+ ...["(", ")", "[", "]", "{", "}", ":", ","],
838
+ ...["if", "else", "lambda", "="],
839
+ ...comparators,
840
+ ...binaryOperators,
841
+ ...unaryOperators
842
+ ]);
843
+ function group(...args) {
844
+ return "(" + args.join("|") + ")";
845
+ }
846
+ var Name = "[a-zA-Z_]\\w*";
847
+ var Whitespace = "[ \\f\\t]*";
848
+ var DecNumber = "\\d+(L|l)?";
849
+ var IntNumber = DecNumber;
850
+ var Exponent = "[eE][+-]?\\d+";
851
+ var PointFloat = group(`\\d+\\.\\d*(${Exponent})?`, `\\.\\d+(${Exponent})?`);
852
+ var FloatNumber = group(PointFloat, `\\d+${Exponent}`);
853
+ var Number2 = group(FloatNumber, IntNumber);
854
+ var Operator = group(
855
+ "\\*\\*=?",
856
+ ">>=?",
857
+ "<<=?",
858
+ "<>",
859
+ "!=",
860
+ "//=?",
861
+ "[+\\-*/%&|^=<>]=?",
862
+ "~"
863
+ );
864
+ var Bracket = "[\\[\\]\\(\\)\\{\\}]";
865
+ var Special = "[:;.,`@]";
866
+ var Funny = group(Operator, Bracket, Special);
867
+ var ContStr = group(
868
+ "([uU])?'([^\\n'\\\\]*(?:\\\\.[^\\n'\\\\]*)*)'",
869
+ '([uU])?"([^\\n"\\\\]*(?:\\\\.[^\\n"\\\\]*)*)"'
870
+ );
871
+ var PseudoToken = Whitespace + group(Number2, Funny, ContStr, Name);
872
+ var NumberPattern = new RegExp("^" + Number2 + "$");
873
+ var StringPattern = new RegExp("^" + ContStr + "$");
874
+ var NamePattern = new RegExp("^" + Name + "$");
875
+ var strip = new RegExp("^" + Whitespace);
876
+ function tokenize(str) {
877
+ const tokens = [];
878
+ const max = str.length;
879
+ let start = 0;
880
+ let end = 0;
881
+ const pseudoprog = new RegExp(PseudoToken, "g");
882
+ while (pseudoprog.lastIndex < max) {
883
+ const pseudomatch = pseudoprog.exec(str);
884
+ if (!pseudomatch) {
885
+ if (/^\s+$/.test(str.slice(end))) {
886
+ break;
887
+ }
888
+ throw new TokenizerError(
889
+ "Failed to tokenize <<" + str + ">> at index " + (end || 0) + "; parsed so far: " + tokens
890
+ );
891
+ }
892
+ if (pseudomatch.index > end) {
893
+ if (str.slice(end, pseudomatch.index).trim()) {
894
+ throw new TokenizerError("Invalid expression");
895
+ }
896
+ }
897
+ start = pseudomatch.index;
898
+ end = pseudoprog.lastIndex;
899
+ let token = str.slice(start, end).replace(strip, "");
900
+ if (NumberPattern.test(token)) {
901
+ tokens.push({
902
+ type: 0,
903
+ value: parseFloat(token)
904
+ });
905
+ } else if (StringPattern.test(token)) {
906
+ const m = StringPattern.exec(token);
907
+ if (!m) throw new TokenizerError("Invalid string match");
908
+ tokens.push({
909
+ type: 1,
910
+ value: decodeStringLiteral(
911
+ m[3] !== void 0 ? m[3] : m[5],
912
+ !!(m[2] || m[4])
913
+ )
914
+ });
915
+ } else if (symbols.has(token)) {
916
+ if (token === "in" && tokens.length > 0 && tokens[tokens.length - 1].value === "not") {
917
+ token = "not in";
918
+ tokens.pop();
919
+ } else if (token === "not" && tokens.length > 0 && tokens[tokens.length - 1].value === "is") {
920
+ token = "is not";
921
+ tokens.pop();
922
+ }
923
+ tokens.push({
924
+ type: 2,
925
+ value: token
926
+ });
927
+ } else if (constants.has(token)) {
928
+ tokens.push({
929
+ type: 4,
930
+ value: token
931
+ });
932
+ } else if (NamePattern.test(token)) {
933
+ tokens.push({
934
+ type: 3,
935
+ value: token
936
+ });
937
+ } else {
938
+ throw new TokenizerError("Invalid expression");
939
+ }
940
+ }
941
+ return tokens;
942
+ }
943
+
944
+ // src/utils/domain/py_parser.ts
945
+ var ParserError = class extends Error {
946
+ };
947
+ var chainedOperators = new Set(comparators);
948
+ var infixOperators = /* @__PURE__ */ new Set([...binaryOperators, ...comparators]);
949
+ function bp(symbol) {
950
+ switch (symbol) {
951
+ case "=":
952
+ return 10;
953
+ case "if":
954
+ return 20;
955
+ case "in":
956
+ case "not in":
957
+ case "is":
958
+ case "is not":
959
+ case "<":
960
+ case "<=":
961
+ case ">":
962
+ case ">=":
963
+ case "<>":
964
+ case "==":
965
+ case "!=":
966
+ return 60;
967
+ case "or":
968
+ return 30;
969
+ case "and":
970
+ return 40;
971
+ case "not":
972
+ return 50;
973
+ case "|":
974
+ return 70;
975
+ case "^":
976
+ return 80;
977
+ case "&":
978
+ return 90;
979
+ case "<<":
980
+ case ">>":
981
+ return 100;
982
+ case "+":
983
+ case "-":
984
+ return 110;
985
+ case "*":
986
+ case "/":
987
+ case "//":
988
+ case "%":
989
+ return 120;
990
+ case "**":
991
+ return 140;
992
+ case ".":
993
+ case "(":
994
+ case "[":
995
+ return 150;
996
+ default:
997
+ return 0;
998
+ }
999
+ }
1000
+ function bindingPower(token) {
1001
+ return token.type === 2 ? bp(token.value) : 0;
1002
+ }
1003
+ function isSymbol(token, value) {
1004
+ return token.type === 2 && token.value === value;
1005
+ }
1006
+ function parsePrefix(current, tokens) {
1007
+ switch (current.type) {
1008
+ case 0:
1009
+ return { type: 0, value: current.value };
1010
+ case 1:
1011
+ return { type: 1, value: current.value };
1012
+ case 4:
1013
+ if (current.value === "None") {
1014
+ return {
1015
+ type: 3
1016
+ /* None */
1017
+ };
1018
+ } else {
1019
+ return { type: 2, value: current.value === "True" };
1020
+ }
1021
+ case 3:
1022
+ return { type: 5, value: current.value };
1023
+ case 2:
1024
+ switch (current.value) {
1025
+ case "-":
1026
+ case "+":
1027
+ case "~":
1028
+ return {
1029
+ type: 6,
1030
+ op: current.value,
1031
+ right: _parse(tokens, 130)
1032
+ };
1033
+ case "not":
1034
+ return {
1035
+ type: 6,
1036
+ op: current.value,
1037
+ right: _parse(tokens, 50)
1038
+ };
1039
+ case "(":
1040
+ const content = [];
1041
+ let isTuple = false;
1042
+ while (tokens[0] && !isSymbol(tokens[0], ")")) {
1043
+ content.push(_parse(tokens, 0));
1044
+ if (tokens[0]) {
1045
+ if (tokens[0] && isSymbol(tokens[0], ",")) {
1046
+ isTuple = true;
1047
+ tokens.shift();
1048
+ } else if (!isSymbol(tokens[0], ")")) {
1049
+ throw new ParserError("parsing error");
1050
+ }
1051
+ } else {
1052
+ throw new ParserError("parsing error");
1053
+ }
1054
+ }
1055
+ if (!tokens[0] || !isSymbol(tokens[0], ")")) {
1056
+ throw new ParserError("parsing error");
1057
+ }
1058
+ tokens.shift();
1059
+ isTuple = isTuple || content.length === 0;
1060
+ return isTuple ? { type: 10, value: content } : content[0];
1061
+ case "[":
1062
+ const value = [];
1063
+ while (tokens[0] && !isSymbol(tokens[0], "]")) {
1064
+ value.push(_parse(tokens, 0));
1065
+ if (tokens[0]) {
1066
+ if (isSymbol(tokens[0], ",")) {
1067
+ tokens.shift();
1068
+ } else if (!isSymbol(tokens[0], "]")) {
1069
+ throw new ParserError("parsing error");
1070
+ }
1071
+ }
1072
+ }
1073
+ if (!tokens[0] || !isSymbol(tokens[0], "]")) {
1074
+ throw new ParserError("parsing error");
1075
+ }
1076
+ tokens.shift();
1077
+ return { type: 4, value };
1078
+ case "{":
1079
+ const dict = {};
1080
+ while (tokens[0] && !isSymbol(tokens[0], "}")) {
1081
+ const key = _parse(tokens, 0);
1082
+ if (key.type !== 1 && key.type !== 0 || !tokens[0] || !isSymbol(tokens[0], ":")) {
1083
+ throw new ParserError("parsing error");
1084
+ }
1085
+ tokens.shift();
1086
+ const val = _parse(tokens, 0);
1087
+ dict[key.value] = val;
1088
+ if (isSymbol(tokens[0], ",")) {
1089
+ tokens.shift();
1090
+ }
1091
+ }
1092
+ if (!tokens.shift()) {
1093
+ throw new ParserError("parsing error");
1094
+ }
1095
+ return { type: 11, value: dict };
1096
+ default:
1097
+ throw new ParserError("Token cannot be parsed");
1098
+ }
1099
+ default:
1100
+ throw new ParserError("Token cannot be parsed");
1101
+ }
1102
+ }
1103
+ function parseInfix(left, current, tokens) {
1104
+ switch (current.type) {
1105
+ case 2:
1106
+ if (infixOperators.has(current.value)) {
1107
+ let right = _parse(tokens, bindingPower(current));
1108
+ if (current.value === "and" || current.value === "or") {
1109
+ return {
1110
+ type: 14,
1111
+ op: current.value,
1112
+ left,
1113
+ right
1114
+ };
1115
+ } else if (current.value === ".") {
1116
+ if (right.type === 5) {
1117
+ return {
1118
+ type: 15,
1119
+ obj: left,
1120
+ key: right.value
1121
+ };
1122
+ } else {
1123
+ throw new ParserError("invalid obj lookup");
1124
+ }
1125
+ }
1126
+ let op = {
1127
+ type: 7,
1128
+ op: current.value,
1129
+ left,
1130
+ right
1131
+ };
1132
+ while (chainedOperators.has(current.value) && tokens[0] && tokens[0].type === 2 && chainedOperators.has(tokens[0].value)) {
1133
+ const nextToken = tokens.shift();
1134
+ op = {
1135
+ type: 14,
1136
+ op: "and",
1137
+ left: op,
1138
+ right: {
1139
+ type: 7,
1140
+ op: nextToken.value,
1141
+ left: right,
1142
+ right: _parse(tokens, bindingPower(nextToken))
1143
+ }
1144
+ };
1145
+ right = op.right;
1146
+ }
1147
+ return op;
1148
+ }
1149
+ switch (current.value) {
1150
+ case "(":
1151
+ const args = [];
1152
+ const kwargs = {};
1153
+ while (tokens[0] && !isSymbol(tokens[0], ")")) {
1154
+ const arg = _parse(tokens, 0);
1155
+ if (arg.type === 9) {
1156
+ kwargs[arg.name.value] = arg.value;
1157
+ } else {
1158
+ args.push(arg);
1159
+ }
1160
+ if (tokens[0] && isSymbol(tokens[0], ",")) {
1161
+ tokens.shift();
1162
+ }
1163
+ }
1164
+ if (!tokens[0] || !isSymbol(tokens[0], ")")) {
1165
+ throw new ParserError("parsing error");
1166
+ }
1167
+ tokens.shift();
1168
+ return { type: 8, fn: left, args, kwargs };
1169
+ case "=":
1170
+ if (left.type === 5) {
1171
+ return {
1172
+ type: 9,
1173
+ name: left,
1174
+ value: _parse(tokens, 10)
1175
+ };
1176
+ }
1177
+ break;
1178
+ case "[":
1179
+ const key = _parse(tokens);
1180
+ if (!tokens[0] || !isSymbol(tokens[0], "]")) {
1181
+ throw new ParserError("parsing error");
1182
+ }
1183
+ tokens.shift();
1184
+ return {
1185
+ type: 12,
1186
+ target: left,
1187
+ key
1188
+ };
1189
+ case "if":
1190
+ const condition = _parse(tokens);
1191
+ if (!tokens[0] || !isSymbol(tokens[0], "else")) {
1192
+ throw new ParserError("parsing error");
1193
+ }
1194
+ tokens.shift();
1195
+ const ifFalse = _parse(tokens);
1196
+ return {
1197
+ type: 13,
1198
+ condition,
1199
+ ifTrue: left,
1200
+ ifFalse
1201
+ };
1202
+ default:
1203
+ break;
1204
+ }
1205
+ }
1206
+ throw new ParserError("Token cannot be parsed");
1207
+ }
1208
+ function _parse(tokens, bp2 = 0) {
1209
+ const token = tokens.shift();
1210
+ if (!token) {
1211
+ throw new ParserError("Unexpected end of input");
1212
+ }
1213
+ let expr = parsePrefix(token, tokens);
1214
+ while (tokens[0] && bindingPower(tokens[0]) > bp2) {
1215
+ expr = parseInfix(expr, tokens.shift(), tokens);
1216
+ }
1217
+ return expr;
1218
+ }
1219
+ function parse(tokens) {
1220
+ if (tokens.length) {
1221
+ return _parse(tokens, 0);
1222
+ }
1223
+ throw new ParserError("Missing token");
1224
+ }
1225
+ function parseArgs(args, spec) {
1226
+ const last = args[args.length - 1];
1227
+ const unnamedArgs = typeof last === "object" ? args.slice(0, -1) : args;
1228
+ const kwargs = typeof last === "object" ? last : {};
1229
+ for (const [index, val] of unnamedArgs.entries()) {
1230
+ kwargs[spec[index]] = val;
1231
+ }
1232
+ return kwargs;
1233
+ }
1234
+
1235
+ // src/utils/domain/py_date.ts
1236
+ var AssertionError = class extends Error {
1237
+ };
1238
+ var ValueError = class extends Error {
1239
+ };
1240
+ var NotSupportedError = class extends Error {
1241
+ };
1242
+ function fmt2(n) {
1243
+ return String(n).padStart(2, "0");
1244
+ }
1245
+ function fmt4(n) {
1246
+ return String(n).padStart(4, "0");
1247
+ }
1248
+ function divmod(a, b, fn) {
1249
+ let mod = a % b;
1250
+ if (mod > 0 && b < 0 || mod < 0 && b > 0) {
1251
+ mod += b;
1252
+ }
1253
+ return fn(Math.floor(a / b), mod);
1254
+ }
1255
+ function assert(bool, message = "AssertionError") {
1256
+ if (!bool) {
1257
+ throw new AssertionError(message);
1258
+ }
1259
+ }
1260
+ var DAYS_IN_MONTH = [
1261
+ null,
1262
+ 31,
1263
+ 28,
1264
+ 31,
1265
+ 30,
1266
+ 31,
1267
+ 30,
1268
+ 31,
1269
+ 31,
1270
+ 30,
1271
+ 31,
1272
+ 30,
1273
+ 31
1274
+ ];
1275
+ var DAYS_BEFORE_MONTH = [null];
1276
+ for (let dbm = 0, i = 1; i < DAYS_IN_MONTH.length; ++i) {
1277
+ DAYS_BEFORE_MONTH.push(dbm);
1278
+ dbm += DAYS_IN_MONTH[i];
1279
+ }
1280
+ function daysInMonth(year, month) {
1281
+ if (month === 2 && isLeap(year)) {
1282
+ return 29;
1283
+ }
1284
+ return DAYS_IN_MONTH[month];
1285
+ }
1286
+ function isLeap(year) {
1287
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
1288
+ }
1289
+ function daysBeforeYear(year) {
1290
+ const y = year - 1;
1291
+ return y * 365 + Math.floor(y / 4) - Math.floor(y / 100) + Math.floor(y / 400);
1292
+ }
1293
+ function daysBeforeMonth(year, month) {
1294
+ const postLeapFeb = month > 2 && isLeap(year);
1295
+ return DAYS_BEFORE_MONTH[month] + (postLeapFeb ? 1 : 0);
1296
+ }
1297
+ function ymd2ord(year, month, day) {
1298
+ const dim = daysInMonth(year, month);
1299
+ if (!(1 <= day && day <= dim)) {
1300
+ throw new ValueError(`day must be in 1..${dim}`);
1301
+ }
1302
+ return daysBeforeYear(year) + daysBeforeMonth(year, month) + day;
1303
+ }
1304
+ var DI400Y = daysBeforeYear(401);
1305
+ var DI100Y = daysBeforeYear(101);
1306
+ var DI4Y = daysBeforeYear(5);
1307
+ function ord2ymd(n) {
1308
+ --n;
1309
+ let n400 = 0, n100 = 0, n4 = 0, n1 = 0, n0 = 0;
1310
+ divmod(n, DI400Y, (_n400, n2) => {
1311
+ n400 = _n400;
1312
+ divmod(n2, DI100Y, (_n100, n3) => {
1313
+ n100 = _n100;
1314
+ divmod(n3, DI4Y, (_n4, n5) => {
1315
+ n4 = _n4;
1316
+ divmod(n5, 365, (_n1, n6) => {
1317
+ n1 = _n1;
1318
+ n0 = n6;
1319
+ });
1320
+ });
1321
+ });
1322
+ });
1323
+ n = n0;
1324
+ const year = n400 * 400 + 1 + n100 * 100 + n4 * 4 + n1;
1325
+ if (n1 === 4 || n100 === 100) {
1326
+ assert(n0 === 0);
1327
+ return {
1328
+ year: year - 1,
1329
+ month: 12,
1330
+ day: 31
1331
+ };
1332
+ }
1333
+ const leapyear = n1 === 3 && (n4 !== 24 || n100 === 3);
1334
+ assert(leapyear === isLeap(year));
1335
+ let month = n + 50 >> 5;
1336
+ let preceding = DAYS_BEFORE_MONTH[month] + (month > 2 && leapyear ? 1 : 0);
1337
+ if (preceding > n) {
1338
+ --month;
1339
+ preceding -= DAYS_IN_MONTH[month] + (month === 2 && leapyear ? 1 : 0);
1340
+ }
1341
+ n -= preceding;
1342
+ return {
1343
+ year,
1344
+ month,
1345
+ day: n + 1
1346
+ };
1347
+ }
1348
+ function tmxxx(year, month, day, hour, minute, second, microsecond) {
1349
+ hour = hour || 0;
1350
+ minute = minute || 0;
1351
+ second = second || 0;
1352
+ microsecond = microsecond || 0;
1353
+ if (microsecond < 0 || microsecond > 999999) {
1354
+ divmod(microsecond, 1e6, (carry, ms) => {
1355
+ microsecond = ms;
1356
+ second += carry;
1357
+ });
1358
+ }
1359
+ if (second < 0 || second > 59) {
1360
+ divmod(second, 60, (carry, s) => {
1361
+ second = s;
1362
+ minute += carry;
1363
+ });
1364
+ }
1365
+ if (minute < 0 || minute > 59) {
1366
+ divmod(minute, 60, (carry, m) => {
1367
+ minute = m;
1368
+ hour += carry;
1369
+ });
1370
+ }
1371
+ if (hour < 0 || hour > 23) {
1372
+ divmod(hour, 24, (carry, h) => {
1373
+ hour = h;
1374
+ day += carry;
1375
+ });
1376
+ }
1377
+ if (month < 1 || month > 12) {
1378
+ divmod(month - 1, 12, (carry, m) => {
1379
+ month = m + 1;
1380
+ year += carry;
1381
+ });
1382
+ }
1383
+ const dim = daysInMonth(year, month);
1384
+ if (day < 1 || day > dim) {
1385
+ if (day === 0) {
1386
+ --month;
1387
+ if (month > 0) {
1388
+ day = daysInMonth(year, month);
1389
+ } else {
1390
+ --year;
1391
+ month = 12;
1392
+ day = 31;
1393
+ }
1394
+ } else if (day === dim + 1) {
1395
+ ++month;
1396
+ day = 1;
1397
+ if (month > 12) {
1398
+ month = 1;
1399
+ ++year;
1400
+ }
1401
+ } else {
1402
+ const r = ord2ymd(ymd2ord(year, month, 1) + (day - 1));
1403
+ year = r.year;
1404
+ month = r.month;
1405
+ day = r.day;
1406
+ }
1407
+ }
1408
+ return {
1409
+ year,
1410
+ month,
1411
+ day,
1412
+ hour,
1413
+ minute,
1414
+ second,
1415
+ microsecond
1416
+ };
1417
+ }
1418
+ var PyDate = class _PyDate {
1419
+ constructor(year, month, day) {
1420
+ this.year = year;
1421
+ this.month = month;
1422
+ this.day = day;
1423
+ }
1424
+ static today() {
1425
+ return this.convertDate(/* @__PURE__ */ new Date());
1426
+ }
1427
+ static convertDate(date) {
1428
+ const year = date.getFullYear();
1429
+ const month = date.getMonth() + 1;
1430
+ const day = date.getDate();
1431
+ return new _PyDate(year, month, day);
1432
+ }
1433
+ static create(...args) {
1434
+ const { year, month, day } = parseArgs(args, ["year", "month", "day"]);
1435
+ return new _PyDate(year, month, day);
1436
+ }
1437
+ add(timedelta) {
1438
+ const s = tmxxx(this.year, this.month, this.day + timedelta.days, 0, 0, 0);
1439
+ return new _PyDate(s.year, s.month, s.day);
1440
+ }
1441
+ isEqual(other) {
1442
+ if (!(other instanceof _PyDate)) {
1443
+ return false;
1444
+ }
1445
+ return this.year === other.year && this.month === other.month && this.day === other.day;
1446
+ }
1447
+ strftime(format) {
1448
+ return format.replace(/%([A-Za-z])/g, (m, c) => {
1449
+ switch (c) {
1450
+ case "Y":
1451
+ return fmt4(this.year);
1452
+ case "m":
1453
+ return fmt2(this.month);
1454
+ case "d":
1455
+ return fmt2(this.day);
1456
+ default:
1457
+ throw new ValueError(`No known conversion for ${m}`);
1458
+ }
1459
+ });
1460
+ }
1461
+ substract(other) {
1462
+ if (other instanceof PyTimeDelta) {
1463
+ return this.add(other.negate());
1464
+ }
1465
+ if (other instanceof _PyDate) {
1466
+ return PyTimeDelta.create(this.toordinal() - other.toordinal());
1467
+ }
1468
+ throw new NotSupportedError();
1469
+ }
1470
+ toJSON() {
1471
+ return this.strftime("%Y-%m-%d");
1472
+ }
1473
+ toordinal() {
1474
+ return ymd2ord(this.year, this.month, this.day);
1475
+ }
1476
+ };
1477
+ var PyDateTime = class _PyDateTime {
1478
+ constructor(year, month, day, hour, minute, second, microsecond) {
1479
+ this.year = year;
1480
+ this.month = month;
1481
+ this.day = day;
1482
+ this.hour = hour;
1483
+ this.minute = minute;
1484
+ this.second = second;
1485
+ this.microsecond = microsecond;
1486
+ }
1487
+ static now() {
1488
+ return this.convertDate(/* @__PURE__ */ new Date());
1489
+ }
1490
+ static convertDate(date) {
1491
+ const year = date.getFullYear();
1492
+ const month = date.getMonth() + 1;
1493
+ const day = date.getDate();
1494
+ const hour = date.getHours();
1495
+ const minute = date.getMinutes();
1496
+ const second = date.getSeconds();
1497
+ return new _PyDateTime(year, month, day, hour, minute, second, 0);
1498
+ }
1499
+ static create(...args) {
1500
+ const namedArgs = parseArgs(args, [
1501
+ "year",
1502
+ "month",
1503
+ "day",
1504
+ "hour",
1505
+ "minute",
1506
+ "second",
1507
+ "microsecond"
1508
+ ]);
1509
+ const year = namedArgs.year;
1510
+ const month = namedArgs.month;
1511
+ const day = namedArgs.day;
1512
+ const hour = namedArgs.hour || 0;
1513
+ const minute = namedArgs.minute || 0;
1514
+ const second = namedArgs.second || 0;
1515
+ const ms = namedArgs.microsecond / 1e3 || 0;
1516
+ return new _PyDateTime(year, month, day, hour, minute, second, ms);
1517
+ }
1518
+ static combine(...args) {
1519
+ const { date, time } = parseArgs(args, ["date", "time"]);
1520
+ return _PyDateTime.create(
1521
+ date.year,
1522
+ date.month,
1523
+ date.day,
1524
+ time.hour,
1525
+ time.minute,
1526
+ time.second
1527
+ );
1528
+ }
1529
+ add(timedelta) {
1530
+ const s = tmxxx(
1531
+ this.year,
1532
+ this.month,
1533
+ this.day + timedelta.days,
1534
+ this.hour,
1535
+ this.minute,
1536
+ this.second + timedelta.seconds,
1537
+ this.microsecond + timedelta.microseconds
1538
+ );
1539
+ return new _PyDateTime(
1540
+ s.year,
1541
+ s.month,
1542
+ s.day,
1543
+ s.hour,
1544
+ s.minute,
1545
+ s.second,
1546
+ s.microsecond
1547
+ );
1548
+ }
1549
+ isEqual(other) {
1550
+ if (!(other instanceof _PyDateTime)) {
1551
+ return false;
1552
+ }
1553
+ 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;
1554
+ }
1555
+ strftime(format) {
1556
+ return format.replace(/%([A-Za-z])/g, (m, c) => {
1557
+ switch (c) {
1558
+ case "Y":
1559
+ return fmt4(this.year);
1560
+ case "m":
1561
+ return fmt2(this.month);
1562
+ case "d":
1563
+ return fmt2(this.day);
1564
+ case "H":
1565
+ return fmt2(this.hour);
1566
+ case "M":
1567
+ return fmt2(this.minute);
1568
+ case "S":
1569
+ return fmt2(this.second);
1570
+ default:
1571
+ throw new ValueError(`No known conversion for ${m}`);
1572
+ }
1573
+ });
1574
+ }
1575
+ substract(timedelta) {
1576
+ return this.add(timedelta.negate());
1577
+ }
1578
+ toJSON() {
1579
+ return this.strftime("%Y-%m-%d %H:%M:%S");
1580
+ }
1581
+ to_utc() {
1582
+ const d = new Date(
1583
+ this.year,
1584
+ this.month - 1,
1585
+ this.day,
1586
+ this.hour,
1587
+ this.minute,
1588
+ this.second
1589
+ );
1590
+ const timedelta = PyTimeDelta.create({ minutes: d.getTimezoneOffset() });
1591
+ return this.add(timedelta);
1592
+ }
1593
+ };
1594
+ var PyTime = class _PyTime extends PyDate {
1595
+ constructor(hour, minute, second) {
1596
+ const now = /* @__PURE__ */ new Date();
1597
+ const year = now.getFullYear();
1598
+ const month = now.getMonth() + 1;
1599
+ const day = now.getDate();
1600
+ super(year, month, day);
1601
+ this.hour = hour;
1602
+ this.minute = minute;
1603
+ this.second = second;
1604
+ this.hour = hour;
1605
+ this.minute = minute;
1606
+ this.second = second;
1607
+ }
1608
+ static create(...args) {
1609
+ const namedArgs = parseArgs(args, ["hour", "minute", "second"]);
1610
+ const hour = namedArgs.hour || 0;
1611
+ const minute = namedArgs.minute || 0;
1612
+ const second = namedArgs.second || 0;
1613
+ return new _PyTime(hour, minute, second);
1614
+ }
1615
+ strftime(format) {
1616
+ return format.replace(/%([A-Za-z])/g, (m, c) => {
1617
+ switch (c) {
1618
+ case "Y":
1619
+ return fmt4(this.year);
1620
+ case "m":
1621
+ return fmt2(this.month);
1622
+ case "d":
1623
+ return fmt2(this.day);
1624
+ case "H":
1625
+ return fmt2(this.hour);
1626
+ case "M":
1627
+ return fmt2(this.minute);
1628
+ case "S":
1629
+ return fmt2(this.second);
1630
+ default:
1631
+ throw new ValueError(`No known conversion for ${m}`);
1632
+ }
1633
+ });
1634
+ }
1635
+ toJSON() {
1636
+ return this.strftime("%H:%M:%S");
1637
+ }
1638
+ };
1639
+ var DAYS_IN_YEAR = [
1640
+ 31,
1641
+ 59,
1642
+ 90,
1643
+ 120,
1644
+ 151,
1645
+ 181,
1646
+ 212,
1647
+ 243,
1648
+ 273,
1649
+ 304,
1650
+ 334,
1651
+ 366
1652
+ ];
1653
+ var TIME_PERIODS = ["hour", "minute", "second"];
1654
+ var PERIODS = ["year", "month", "day", ...TIME_PERIODS];
1655
+ var RELATIVE_KEYS = "years months weeks days hours minutes seconds microseconds leapdays".split(
1656
+ " "
1657
+ );
1658
+ var ABSOLUTE_KEYS = "year month day hour minute second microsecond weekday nlyearday yearday".split(
1659
+ " "
1660
+ );
1661
+ var argsSpec = ["dt1", "dt2"];
1662
+ var PyRelativeDelta = class _PyRelativeDelta {
1663
+ static create(...args) {
1664
+ const params = parseArgs(args, argsSpec);
1665
+ if ("dt1" in params) {
1666
+ throw new Error("relativedelta(dt1, dt2) is not supported for now");
1667
+ }
1668
+ for (const period of PERIODS) {
1669
+ if (period in params) {
1670
+ const val = params[period];
1671
+ assert(val >= 0, `${period} ${val} is out of range`);
1672
+ }
1673
+ }
1674
+ for (const key of RELATIVE_KEYS) {
1675
+ params[key] = params[key] || 0;
1676
+ }
1677
+ for (const key of ABSOLUTE_KEYS) {
1678
+ params[key] = key in params ? params[key] : null;
1679
+ }
1680
+ params.days += 7 * params.weeks;
1681
+ let yearDay = 0;
1682
+ if (params.nlyearday) {
1683
+ yearDay = params.nlyearday;
1684
+ } else if (params.yearday) {
1685
+ yearDay = params.yearday;
1686
+ if (yearDay > 59) {
1687
+ params.leapDays = -1;
1688
+ }
1689
+ }
1690
+ if (yearDay) {
1691
+ for (let monthIndex = 0; monthIndex < DAYS_IN_YEAR.length; monthIndex++) {
1692
+ if (yearDay <= DAYS_IN_YEAR[monthIndex]) {
1693
+ params.month = monthIndex + 1;
1694
+ if (monthIndex === 0) {
1695
+ params.day = yearDay;
1696
+ } else {
1697
+ params.day = yearDay - DAYS_IN_YEAR[monthIndex - 1];
1698
+ }
1699
+ break;
1700
+ }
1701
+ }
1702
+ }
1703
+ return new _PyRelativeDelta(params);
1704
+ }
1705
+ static add(date, delta) {
1706
+ if (!(date instanceof PyDate || date instanceof PyDateTime)) {
1707
+ throw new NotSupportedError();
1708
+ }
1709
+ const s = tmxxx(
1710
+ (delta.year || date.year) + delta.years,
1711
+ (delta.month || date.month) + delta.months,
1712
+ delta.day || date.day,
1713
+ delta.hour || (date instanceof PyDateTime ? date.hour : 0),
1714
+ delta.minute || (date instanceof PyDateTime ? date.minute : 0),
1715
+ delta.second || (date instanceof PyDateTime ? date.second : 0),
1716
+ delta.microseconds || (date instanceof PyDateTime ? date.microsecond : 0)
1717
+ );
1718
+ const newDateTime = new PyDateTime(
1719
+ s.year,
1720
+ s.month,
1721
+ s.day,
1722
+ s.hour,
1723
+ s.minute,
1724
+ s.second,
1725
+ s.microsecond
1726
+ );
1727
+ let leapDays = 0;
1728
+ if (delta.leapDays && newDateTime.month > 2 && isLeap(newDateTime.year)) {
1729
+ leapDays = delta.leapDays;
1730
+ }
1731
+ const temp = newDateTime.add(
1732
+ PyTimeDelta.create({
1733
+ days: delta.days + leapDays,
1734
+ hours: delta.hours,
1735
+ minutes: delta.minutes,
1736
+ seconds: delta.seconds,
1737
+ microseconds: delta.microseconds
1738
+ })
1739
+ );
1740
+ const hasTime = Boolean(
1741
+ temp.hour || temp.minute || temp.second || temp.microsecond
1742
+ );
1743
+ const returnDate = !hasTime && date instanceof PyDate ? new PyDate(temp.year, temp.month, temp.day) : temp;
1744
+ if (delta.weekday !== null) {
1745
+ const wantedDow = delta.weekday + 1;
1746
+ const _date = new Date(
1747
+ returnDate.year,
1748
+ returnDate.month - 1,
1749
+ returnDate.day
1750
+ );
1751
+ const days = (7 - _date.getDay() + wantedDow) % 7;
1752
+ return returnDate.add(new PyTimeDelta(days, 0, 0));
1753
+ }
1754
+ return returnDate;
1755
+ }
1756
+ static substract(date, delta) {
1757
+ return _PyRelativeDelta.add(date, delta.negate());
1758
+ }
1759
+ constructor(params = {}, sign = 1) {
1760
+ this.years = sign * params.years;
1761
+ this.months = sign * params.months;
1762
+ this.days = sign * params.days;
1763
+ this.hours = sign * params.hours;
1764
+ this.minutes = sign * params.minutes;
1765
+ this.seconds = sign * params.seconds;
1766
+ this.microseconds = sign * params.microseconds;
1767
+ this.leapDays = params.leapDays;
1768
+ this.year = params.year;
1769
+ this.month = params.month;
1770
+ this.day = params.day;
1771
+ this.hour = params.hour;
1772
+ this.minute = params.minute;
1773
+ this.second = params.second;
1774
+ this.microsecond = params.microsecond;
1775
+ this.weekday = params.weekday;
1776
+ }
1777
+ negate() {
1778
+ return new _PyRelativeDelta(this, -1);
1779
+ }
1780
+ isEqual() {
1781
+ throw new NotSupportedError();
1782
+ }
1783
+ };
1784
+ var TIME_DELTA_KEYS = "weeks days hours minutes seconds milliseconds microseconds".split(" ");
1785
+ function modf(x) {
1786
+ const mod = x % 1;
1787
+ return [mod < 0 ? mod + 1 : mod, Math.floor(x)];
1788
+ }
1789
+ var PyTimeDelta = class _PyTimeDelta {
1790
+ constructor(days, seconds, microseconds) {
1791
+ this.days = days;
1792
+ this.seconds = seconds;
1793
+ this.microseconds = microseconds;
1794
+ }
1795
+ static create(...args) {
1796
+ const namedArgs = parseArgs(args, ["days", "seconds", "microseconds"]);
1797
+ for (const key of TIME_DELTA_KEYS) {
1798
+ namedArgs[key] = namedArgs[key] || 0;
1799
+ }
1800
+ let d = 0;
1801
+ let s = 0;
1802
+ let us = 0;
1803
+ const days = namedArgs.days + namedArgs.weeks * 7;
1804
+ let seconds = namedArgs.seconds + 60 * namedArgs.minutes + 3600 * namedArgs.hours;
1805
+ let microseconds = namedArgs.microseconds + 1e3 * namedArgs.milliseconds;
1806
+ const [dFrac, dInt] = modf(days);
1807
+ d = dInt;
1808
+ let daysecondsfrac = 0;
1809
+ if (dFrac) {
1810
+ const [dsFrac, dsInt] = modf(dFrac * 24 * 3600);
1811
+ s = dsInt;
1812
+ daysecondsfrac = dsFrac;
1813
+ }
1814
+ const [sFrac, sInt] = modf(seconds);
1815
+ seconds = sInt;
1816
+ const secondsfrac = sFrac + daysecondsfrac;
1817
+ divmod(seconds, 24 * 3600, (days2, seconds2) => {
1818
+ d += days2;
1819
+ s += seconds2;
1820
+ });
1821
+ microseconds += secondsfrac * 1e6;
1822
+ divmod(microseconds, 1e6, (seconds2, microseconds2) => {
1823
+ divmod(seconds2, 24 * 3600, (days2, seconds3) => {
1824
+ d += days2;
1825
+ s += seconds3;
1826
+ us += Math.round(microseconds2);
1827
+ });
1828
+ });
1829
+ return new _PyTimeDelta(d, s, us);
1830
+ }
1831
+ add(other) {
1832
+ return _PyTimeDelta.create({
1833
+ days: this.days + other.days,
1834
+ seconds: this.seconds + other.seconds,
1835
+ microseconds: this.microseconds + other.microseconds
1836
+ });
1837
+ }
1838
+ divide(n) {
1839
+ const us = (this.days * 24 * 3600 + this.seconds) * 1e6 + this.microseconds;
1840
+ return _PyTimeDelta.create({ microseconds: Math.floor(us / n) });
1841
+ }
1842
+ isEqual(other) {
1843
+ if (!(other instanceof _PyTimeDelta)) {
1844
+ return false;
1845
+ }
1846
+ return this.days === other.days && this.seconds === other.seconds && this.microseconds === other.microseconds;
1847
+ }
1848
+ isTrue() {
1849
+ return this.days !== 0 || this.seconds !== 0 || this.microseconds !== 0;
1850
+ }
1851
+ multiply(n) {
1852
+ return _PyTimeDelta.create({
1853
+ days: n * this.days,
1854
+ seconds: n * this.seconds,
1855
+ microseconds: n * this.microseconds
1856
+ });
1857
+ }
1858
+ negate() {
1859
+ return _PyTimeDelta.create({
1860
+ days: -this.days,
1861
+ seconds: -this.seconds,
1862
+ microseconds: -this.microseconds
1863
+ });
1864
+ }
1865
+ substract(other) {
1866
+ return _PyTimeDelta.create({
1867
+ days: this.days - other.days,
1868
+ seconds: this.seconds - other.seconds,
1869
+ microseconds: this.microseconds - other.microseconds
1870
+ });
1871
+ }
1872
+ total_seconds() {
1873
+ return this.days * 86400 + this.seconds + this.microseconds / 1e6;
1874
+ }
1875
+ };
1876
+
1877
+ // src/utils/domain/py_builtin.ts
1878
+ var EvaluationError = class extends Error {
1879
+ constructor(message) {
1880
+ super(message);
1881
+ this.name = "EvaluationError";
1882
+ }
1883
+ };
1884
+ function execOnIterable(iterable, func) {
1885
+ if (iterable === null) {
1886
+ throw new EvaluationError("value not iterable");
1887
+ }
1888
+ if (typeof iterable === "object" && !Array.isArray(iterable) && !(iterable instanceof Set)) {
1889
+ iterable = Object.keys(iterable);
1890
+ }
1891
+ if (typeof (iterable == null ? void 0 : iterable[Symbol.iterator]) !== "function") {
1892
+ throw new EvaluationError("value not iterable");
1893
+ }
1894
+ return func(iterable);
1895
+ }
1896
+ var BUILTINS = {
1897
+ /**
1898
+ * @param {any} value
1899
+ * @returns {boolean}
1900
+ */
1901
+ bool(value) {
1902
+ switch (typeof value) {
1903
+ case "number":
1904
+ return value !== 0;
1905
+ case "string":
1906
+ return value !== "";
1907
+ case "boolean":
1908
+ return value;
1909
+ case "object":
1910
+ if (value === null || value === void 0) {
1911
+ return false;
1912
+ }
1913
+ if ("isTrue" in value && typeof value.isTrue === "function") {
1914
+ return value.isTrue();
1915
+ }
1916
+ if (value instanceof Array) {
1917
+ return !!value.length;
1918
+ }
1919
+ if (value instanceof Set) {
1920
+ return !!value.size;
1921
+ }
1922
+ return Object.keys(value).length !== 0;
1923
+ default:
1924
+ return true;
1925
+ }
1926
+ },
1927
+ set(iterable) {
1928
+ if (arguments.length > 2) {
1929
+ throw new EvaluationError(
1930
+ `set expected at most 1 argument, got (${arguments.length - 1})`
1931
+ );
1932
+ }
1933
+ return execOnIterable(
1934
+ iterable,
1935
+ (iterable2) => new Set(iterable2)
1936
+ );
1937
+ },
1938
+ time: {
1939
+ strftime(format) {
1940
+ return PyDateTime.now().strftime(format);
1941
+ }
1942
+ },
1943
+ context_today() {
1944
+ return PyDate.today();
1945
+ },
1946
+ get current_date() {
1947
+ return this.today;
1948
+ },
1949
+ get today() {
1950
+ return PyDate.today().strftime("%Y-%m-%d");
1951
+ },
1952
+ get now() {
1953
+ return PyDateTime.now().strftime("%Y-%m-%d %H:%M:%S");
1954
+ },
1955
+ datetime: {
1956
+ time: PyTime,
1957
+ timedelta: PyTimeDelta,
1958
+ datetime: PyDateTime,
1959
+ date: PyDate
1960
+ },
1961
+ relativedelta: PyRelativeDelta,
1962
+ true: true,
1963
+ false: false
1964
+ };
1965
+
1966
+ // src/utils/domain/py_utils.ts
1967
+ function toPyValue(value) {
1968
+ switch (typeof value) {
1969
+ case "string":
1970
+ return { type: 1, value };
1971
+ case "number":
1972
+ return { type: 0, value };
1973
+ case "boolean":
1974
+ return { type: 2, value };
1975
+ case "object":
1976
+ if (Array.isArray(value)) {
1977
+ return { type: 4, value: value.map(toPyValue) };
1978
+ } else if (value === null) {
1979
+ return {
1980
+ type: 3
1981
+ /* None */
1982
+ };
1983
+ } else if (value instanceof Date) {
1984
+ return {
1985
+ type: 1,
1986
+ value: String(PyDateTime.convertDate(value))
1987
+ };
1988
+ } else if (value instanceof PyDate || value instanceof PyDateTime) {
1989
+ return { type: 1, value };
1990
+ } else {
1991
+ const content = {};
1992
+ for (const key in value) {
1993
+ content[key] = toPyValue(value[key]);
1994
+ }
1995
+ return { type: 11, value: content };
1996
+ }
1997
+ default:
1998
+ throw new Error("Invalid type");
1999
+ }
2000
+ }
2001
+ function formatAST(ast, lbp = 0) {
2002
+ switch (ast.type) {
2003
+ case 3:
2004
+ return "None";
2005
+ case 1:
2006
+ return JSON.stringify(ast.value);
2007
+ case 0:
2008
+ return String(ast.value);
2009
+ case 2:
2010
+ return ast.value ? "True" : "False";
2011
+ case 4:
2012
+ return `[${ast.value.map(formatAST).join(", ")}]`;
2013
+ case 6:
2014
+ if (ast.op === "not") {
2015
+ return `not ${formatAST(ast.right, 50)}`;
2016
+ }
2017
+ return `${ast.op}${formatAST(ast.right, 130)}`;
2018
+ case 7:
2019
+ const abp = bp(ast.op);
2020
+ const binaryStr = `${formatAST(ast.left, abp)} ${ast.op} ${formatAST(ast.right, abp)}`;
2021
+ return abp < lbp ? `(${binaryStr})` : binaryStr;
2022
+ case 11:
2023
+ const pairs = [];
2024
+ for (const k in ast.value) {
2025
+ pairs.push(`"${k}": ${formatAST(ast.value[k])}`);
2026
+ }
2027
+ return `{${pairs.join(", ")}}`;
2028
+ case 10:
2029
+ return `(${ast.value.map(formatAST).join(", ")})`;
2030
+ case 5:
2031
+ return ast.value;
2032
+ case 12:
2033
+ return `${formatAST(ast.target)}[${formatAST(ast.key)}]`;
2034
+ case 13:
2035
+ const { ifTrue, condition, ifFalse } = ast;
2036
+ return `${formatAST(ifTrue)} if ${formatAST(condition)} else ${formatAST(ifFalse)}`;
2037
+ case 14:
2038
+ const boolAbp = bp(ast.op);
2039
+ const boolStr = `${formatAST(ast.left, boolAbp)} ${ast.op} ${formatAST(ast.right, boolAbp)}`;
2040
+ return boolAbp < lbp ? `(${boolStr})` : boolStr;
2041
+ case 15:
2042
+ return `${formatAST(ast.obj, 150)}.${ast.key}`;
2043
+ case 8:
2044
+ const args = ast.args.map(formatAST);
2045
+ const kwargs = [];
2046
+ for (const kwarg in ast.kwargs) {
2047
+ kwargs.push(`${kwarg} = ${formatAST(ast.kwargs[kwarg])}`);
2048
+ }
2049
+ const argStr = args.concat(kwargs).join(", ");
2050
+ return `${formatAST(ast.fn)}(${argStr})`;
2051
+ default:
2052
+ throw new Error("invalid expression: " + JSON.stringify(ast));
2053
+ }
2054
+ }
2055
+ var PY_DICT = /* @__PURE__ */ Object.create(null);
2056
+ function toPyDict(obj) {
2057
+ return new Proxy(obj, {
2058
+ getPrototypeOf() {
2059
+ return PY_DICT;
2060
+ }
2061
+ });
2062
+ }
2063
+
2064
+ // src/utils/domain/py_interpreter.ts
2065
+ var isTrue = BUILTINS.bool;
2066
+ function applyUnaryOp(ast, context) {
2067
+ const value = evaluate(ast.right, context);
2068
+ switch (ast.op) {
2069
+ case "-":
2070
+ if (value instanceof Object && "negate" in value) {
2071
+ return value.negate();
2072
+ }
2073
+ return -value;
2074
+ case "+":
2075
+ return value;
2076
+ case "not":
2077
+ return !isTrue(value);
2078
+ default:
2079
+ throw new EvaluationError(`Unknown unary operator: ${ast.op}`);
2080
+ }
2081
+ }
2082
+ function pytypeIndex(val) {
2083
+ switch (typeof val) {
2084
+ case "object":
2085
+ return val === null ? 1 : Array.isArray(val) ? 5 : 3;
2086
+ case "number":
2087
+ return 2;
2088
+ case "string":
2089
+ return 4;
2090
+ default:
2091
+ throw new EvaluationError(`Unknown type: ${typeof val}`);
2092
+ }
2093
+ }
2094
+ function isLess(left, right) {
2095
+ if (typeof left === "number" && typeof right === "number") {
2096
+ return left < right;
2097
+ }
2098
+ if (typeof left === "boolean") {
2099
+ left = left ? 1 : 0;
2100
+ }
2101
+ if (typeof right === "boolean") {
2102
+ right = right ? 1 : 0;
2103
+ }
2104
+ const leftIndex = pytypeIndex(left);
2105
+ const rightIndex = pytypeIndex(right);
2106
+ if (leftIndex === rightIndex) {
2107
+ return left < right;
2108
+ }
2109
+ return leftIndex < rightIndex;
2110
+ }
2111
+ function isEqual(left, right) {
2112
+ if (typeof left !== typeof right) {
2113
+ if (typeof left === "boolean" && typeof right === "number") {
2114
+ return right === (left ? 1 : 0);
2115
+ }
2116
+ if (typeof left === "number" && typeof right === "boolean") {
2117
+ return left === (right ? 1 : 0);
2118
+ }
2119
+ return false;
2120
+ }
2121
+ if (left instanceof Object && "isEqual" in left) {
2122
+ return left.isEqual(right);
2123
+ }
2124
+ return left === right;
2125
+ }
2126
+ function isIn(left, right) {
2127
+ if (Array.isArray(right)) {
2128
+ return right.includes(left);
2129
+ }
2130
+ if (typeof right === "string" && typeof left === "string") {
2131
+ return right.includes(left);
2132
+ }
2133
+ if (typeof right === "object") {
2134
+ return left in right;
2135
+ }
2136
+ return false;
2137
+ }
2138
+ function applyBinaryOp(ast, context) {
2139
+ const left = evaluate(ast.left, context);
2140
+ const right = evaluate(ast.right, context);
2141
+ switch (ast.op) {
2142
+ case "+": {
2143
+ const relativeDeltaOnLeft = left instanceof PyRelativeDelta;
2144
+ const relativeDeltaOnRight = right instanceof PyRelativeDelta;
2145
+ if (relativeDeltaOnLeft || relativeDeltaOnRight) {
2146
+ const date = relativeDeltaOnLeft ? right : left;
2147
+ const delta = relativeDeltaOnLeft ? left : right;
2148
+ return PyRelativeDelta.add(date, delta);
2149
+ }
2150
+ const timeDeltaOnLeft = left instanceof PyTimeDelta;
2151
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
2152
+ if (timeDeltaOnLeft && timeDeltaOnRight) {
2153
+ return left.add(right);
2154
+ }
2155
+ if (timeDeltaOnLeft) {
2156
+ if (right instanceof PyDate || right instanceof PyDateTime) {
2157
+ return right.add(left);
2158
+ } else {
2159
+ throw new NotSupportedError();
2160
+ }
2161
+ }
2162
+ if (timeDeltaOnRight) {
2163
+ if (left instanceof PyDate || left instanceof PyDateTime) {
2164
+ return left.add(right);
2165
+ } else {
2166
+ throw new NotSupportedError();
2167
+ }
2168
+ }
2169
+ if (left instanceof Array && right instanceof Array) {
2170
+ return [...left, ...right];
2171
+ }
2172
+ return left + right;
2173
+ }
2174
+ case "-": {
2175
+ const isRightDelta = right instanceof PyRelativeDelta;
2176
+ if (isRightDelta) {
2177
+ return PyRelativeDelta.substract(left, right);
2178
+ }
2179
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
2180
+ if (timeDeltaOnRight) {
2181
+ if (left instanceof PyTimeDelta) {
2182
+ return left.substract(right);
2183
+ } else if (left instanceof PyDate || left instanceof PyDateTime) {
2184
+ return left.substract(right);
2185
+ } else {
2186
+ throw new NotSupportedError();
2187
+ }
2188
+ }
2189
+ if (left instanceof PyDate) {
2190
+ return left.substract(right);
2191
+ }
2192
+ return left - right;
2193
+ }
2194
+ case "*": {
2195
+ const timeDeltaOnLeft = left instanceof PyTimeDelta;
2196
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
2197
+ if (timeDeltaOnLeft || timeDeltaOnRight) {
2198
+ const number = timeDeltaOnLeft ? right : left;
2199
+ const delta = timeDeltaOnLeft ? left : right;
2200
+ return delta.multiply(number);
2201
+ }
2202
+ return left * right;
2203
+ }
2204
+ case "/":
2205
+ return left / right;
2206
+ case "%":
2207
+ return left % right;
2208
+ case "//":
2209
+ if (left instanceof PyTimeDelta) {
2210
+ return left.divide(right);
2211
+ }
2212
+ return Math.floor(left / right);
2213
+ case "**":
2214
+ return __pow(left, right);
2215
+ case "==":
2216
+ return isEqual(left, right);
2217
+ case "<>":
2218
+ case "!=":
2219
+ return !isEqual(left, right);
2220
+ case "<":
2221
+ return isLess(left, right);
2222
+ case ">":
2223
+ return isLess(right, left);
2224
+ case ">=":
2225
+ return isEqual(left, right) || isLess(right, left);
2226
+ case "<=":
2227
+ return isEqual(left, right) || isLess(left, right);
2228
+ case "in":
2229
+ return isIn(left, right);
2230
+ case "not in":
2231
+ return !isIn(left, right);
2232
+ default:
2233
+ throw new EvaluationError(`Unknown binary operator: ${ast.op}`);
2234
+ }
2235
+ }
2236
+ var DICT = {
2237
+ get(...args) {
2238
+ const { key, defValue } = parseArgs(args, ["key", "defValue"]);
2239
+ const self = this;
2240
+ if (key in self) {
2241
+ return self[key];
2242
+ } else if (defValue !== void 0) {
2243
+ return defValue;
2244
+ }
2245
+ return null;
2246
+ }
2247
+ };
2248
+ var STRING = {
2249
+ lower() {
2250
+ return this.toLowerCase();
2251
+ },
2252
+ upper() {
2253
+ return this.toUpperCase();
2254
+ }
2255
+ };
2256
+ function applyFunc(key, func, set, ...args) {
2257
+ if (args.length === 1) {
2258
+ return new Set(set);
2259
+ }
2260
+ if (args.length > 2) {
2261
+ throw new EvaluationError(
2262
+ `${key}: py_js supports at most 1 argument, got (${args.length - 1})`
2263
+ );
2264
+ }
2265
+ return execOnIterable(args[0], func);
2266
+ }
2267
+ var SET = {
2268
+ intersection(...args) {
2269
+ return applyFunc(
2270
+ "intersection",
2271
+ (iterable) => {
2272
+ const intersection = /* @__PURE__ */ new Set();
2273
+ for (const i of iterable) {
2274
+ if (this.has(i)) {
2275
+ intersection.add(i);
2276
+ }
2277
+ }
2278
+ return intersection;
2279
+ },
2280
+ this,
2281
+ ...args
2282
+ );
2283
+ },
2284
+ difference(...args) {
2285
+ return applyFunc(
2286
+ "difference",
2287
+ (iterable) => {
2288
+ iterable = new Set(iterable);
2289
+ const difference = /* @__PURE__ */ new Set();
2290
+ for (const e of this) {
2291
+ if (!iterable.has(e)) {
2292
+ difference.add(e);
2293
+ }
2294
+ }
2295
+ return difference;
2296
+ },
2297
+ this,
2298
+ ...args
2299
+ );
2300
+ },
2301
+ union(...args) {
2302
+ return applyFunc(
2303
+ "union",
2304
+ (iterable) => {
2305
+ return /* @__PURE__ */ new Set([...this, ...iterable]);
2306
+ },
2307
+ this,
2308
+ ...args
2309
+ );
2310
+ }
2311
+ };
2312
+ function methods(_class) {
2313
+ return Object.getOwnPropertyNames(_class.prototype).map(
2314
+ (prop) => _class.prototype[prop]
2315
+ );
2316
+ }
2317
+ var allowedFns = /* @__PURE__ */ new Set([
2318
+ BUILTINS.time.strftime,
2319
+ BUILTINS.set,
2320
+ BUILTINS.bool,
2321
+ BUILTINS.context_today,
2322
+ BUILTINS.datetime.datetime.now,
2323
+ BUILTINS.datetime.datetime.combine,
2324
+ BUILTINS.datetime.date.today,
2325
+ ...methods(BUILTINS.relativedelta),
2326
+ ...Object.values(BUILTINS.datetime).flatMap((obj) => methods(obj)),
2327
+ ...Object.values(SET),
2328
+ ...Object.values(DICT),
2329
+ ...Object.values(STRING)
2330
+ ]);
2331
+ var unboundFn = Symbol("unbound function");
2332
+ function evaluate(ast, context = {}) {
2333
+ const dicts = /* @__PURE__ */ new Set();
2334
+ let pyContext;
2335
+ const evalContext = Object.create(context);
2336
+ if (!(evalContext == null ? void 0 : evalContext.context)) {
2337
+ Object.defineProperty(evalContext, "context", {
2338
+ get() {
2339
+ if (!pyContext) {
2340
+ pyContext = toPyDict(context);
2341
+ }
2342
+ return pyContext;
2343
+ }
2344
+ });
2345
+ }
2346
+ function _innerEvaluate(ast2) {
2347
+ var _a, _b, _c;
2348
+ switch (ast2 == null ? void 0 : ast2.type) {
2349
+ case 0:
2350
+ // Number
2351
+ case 1:
2352
+ return ast2.value;
2353
+ case 5:
2354
+ if (ast2.value in evalContext) {
2355
+ if (typeof evalContext[ast2.value] === "object" && ((_a = evalContext[ast2.value]) == null ? void 0 : _a.id)) {
2356
+ return (_b = evalContext[ast2.value]) == null ? void 0 : _b.id;
2357
+ }
2358
+ return (_c = evalContext[ast2.value]) != null ? _c : false;
2359
+ } else if (ast2.value in BUILTINS) {
2360
+ return BUILTINS[ast2.value];
2361
+ } else {
2362
+ return false;
2363
+ }
2364
+ case 3:
2365
+ return null;
2366
+ case 2:
2367
+ return ast2.value;
2368
+ case 6:
2369
+ return applyUnaryOp(ast2, evalContext);
2370
+ case 7:
2371
+ return applyBinaryOp(ast2, evalContext);
2372
+ case 14:
2373
+ const left = _evaluate(ast2.left);
2374
+ if (ast2.op === "and") {
2375
+ return isTrue(left) ? _evaluate(ast2.right) : left;
2376
+ } else {
2377
+ return isTrue(left) ? left : _evaluate(ast2.right);
2378
+ }
2379
+ case 4:
2380
+ // List
2381
+ case 10:
2382
+ return ast2.value.map(_evaluate);
2383
+ case 11:
2384
+ const dict = {};
2385
+ for (const key2 in ast2.value) {
2386
+ dict[key2] = _evaluate(ast2.value[key2]);
2387
+ }
2388
+ dicts.add(dict);
2389
+ return dict;
2390
+ case 8:
2391
+ const fnValue = _evaluate(ast2.fn);
2392
+ const args = ast2.args.map(_evaluate);
2393
+ const kwargs = {};
2394
+ for (const kwarg in ast2.kwargs) {
2395
+ kwargs[kwarg] = _evaluate(ast2 == null ? void 0 : ast2.kwargs[kwarg]);
2396
+ }
2397
+ if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
2398
+ return fnValue.create(...args, kwargs);
2399
+ }
2400
+ return fnValue(...args, kwargs);
2401
+ case 12:
2402
+ const dictVal = _evaluate(ast2.target);
2403
+ const key = _evaluate(ast2.key);
2404
+ return dictVal[key];
2405
+ case 13:
2406
+ if (isTrue(_evaluate(ast2.condition))) {
2407
+ return _evaluate(ast2.ifTrue);
2408
+ } else {
2409
+ return _evaluate(ast2.ifFalse);
2410
+ }
2411
+ case 15:
2412
+ let leftVal = _evaluate(ast2.obj);
2413
+ let result;
2414
+ if (dicts.has(leftVal) || Object.isPrototypeOf.call(PY_DICT, leftVal)) {
2415
+ result = DICT[ast2.key];
2416
+ } else if (typeof leftVal === "string") {
2417
+ result = STRING[ast2.key];
2418
+ } else if (leftVal instanceof Set) {
2419
+ result = SET[ast2.key];
2420
+ } else if (ast2.key === "get" && typeof leftVal === "object") {
2421
+ result = DICT[ast2.key];
2422
+ leftVal = toPyDict(leftVal);
2423
+ } else {
2424
+ result = leftVal[ast2.key];
2425
+ }
2426
+ if (typeof result === "function") {
2427
+ const bound = result.bind(leftVal);
2428
+ bound[unboundFn] = result;
2429
+ return bound;
2430
+ }
2431
+ return result;
2432
+ default:
2433
+ throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
2434
+ }
2435
+ }
2436
+ function _evaluate(ast2) {
2437
+ const val = _innerEvaluate(ast2);
2438
+ if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
2439
+ throw new Error("Invalid Function Call");
2440
+ }
2441
+ return val;
2442
+ }
2443
+ return _evaluate(ast);
2444
+ }
2445
+
2446
+ // src/utils/domain/py.ts
2447
+ function parseExpr(expr) {
2448
+ const tokens = tokenize(expr);
2449
+ return parse(tokens);
2450
+ }
2451
+
2452
+ // src/utils/domain/objects.ts
2453
+ function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
2454
+ if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
2455
+ return obj1 === obj2;
2456
+ }
2457
+ const obj1Keys = Object.keys(obj1);
2458
+ return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
2459
+ }
2460
+
2461
+ // src/utils/domain/arrays.ts
2462
+ var shallowEqual2 = shallowEqual;
2463
+
2464
+ // src/utils/domain/strings.ts
2465
+ var escapeMethod = Symbol("html");
2466
+ function escapeRegExp(str) {
2467
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2468
+ }
2469
+
2470
+ // src/utils/domain/domain.ts
2471
+ var InvalidDomainError = class extends Error {
2472
+ };
2473
+ var Domain = class _Domain {
2474
+ constructor(descr = []) {
2475
+ this.ast = { type: -1, value: null };
2476
+ if (descr instanceof _Domain) {
2477
+ return new _Domain(descr.toString());
2478
+ } else {
2479
+ let rawAST;
2480
+ try {
2481
+ rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
2482
+ } catch (error) {
2483
+ throw new InvalidDomainError(
2484
+ `Invalid domain representation: ${descr}`,
2485
+ {
2486
+ cause: error
2487
+ }
2488
+ );
2489
+ }
2490
+ this.ast = normalizeDomainAST(rawAST);
2491
+ }
2492
+ }
2493
+ static combine(domains, operator) {
2494
+ if (domains.length === 0) {
2495
+ return new _Domain([]);
2496
+ }
2497
+ const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
2498
+ if (domains.length === 1) {
2499
+ return domain1;
2500
+ }
2501
+ const domain2 = _Domain.combine(domains.slice(1), operator);
2502
+ const result = new _Domain([]);
2503
+ const astValues1 = domain1.ast.value;
2504
+ const astValues2 = domain2.ast.value;
2505
+ const op = operator === "AND" ? "&" : "|";
2506
+ const combinedAST = {
2507
+ type: 4,
2508
+ value: astValues1.concat(astValues2)
2509
+ };
2510
+ result.ast = normalizeDomainAST(combinedAST, op);
2511
+ return result;
2512
+ }
2513
+ static and(domains) {
2514
+ return _Domain.combine(domains, "AND");
2515
+ }
2516
+ static or(domains) {
2517
+ return _Domain.combine(domains, "OR");
2518
+ }
2519
+ static not(domain) {
2520
+ const result = new _Domain(domain);
2521
+ result.ast.value.unshift({ type: 1, value: "!" });
2522
+ return result;
2523
+ }
2524
+ static removeDomainLeaves(domain, keysToRemove) {
2525
+ function processLeaf(elements, idx, operatorCtx, newDomain2) {
2526
+ const leaf = elements[idx];
2527
+ if (leaf.type === 10) {
2528
+ if (keysToRemove.includes(leaf.value[0].value)) {
2529
+ if (operatorCtx === "&") {
2530
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
2531
+ } else if (operatorCtx === "|") {
2532
+ newDomain2.ast.value.push(..._Domain.FALSE.ast.value);
2533
+ }
2534
+ } else {
2535
+ newDomain2.ast.value.push(leaf);
2536
+ }
2537
+ return 1;
2538
+ } else if (leaf.type === 1) {
2539
+ 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)) {
2540
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
2541
+ return 3;
2542
+ }
2543
+ newDomain2.ast.value.push(leaf);
2544
+ if (leaf.value === "!") {
2545
+ return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
2546
+ }
2547
+ const firstLeafSkip = processLeaf(
2548
+ elements,
2549
+ idx + 1,
2550
+ leaf.value,
2551
+ newDomain2
2552
+ );
2553
+ const secondLeafSkip = processLeaf(
2554
+ elements,
2555
+ idx + 1 + firstLeafSkip,
2556
+ leaf.value,
2557
+ newDomain2
2558
+ );
2559
+ return 1 + firstLeafSkip + secondLeafSkip;
2560
+ }
2561
+ return 0;
2562
+ }
2563
+ const d = new _Domain(domain);
2564
+ if (d.ast.value.length === 0) {
2565
+ return d;
2566
+ }
2567
+ const newDomain = new _Domain([]);
2568
+ processLeaf(d.ast.value, 0, "&", newDomain);
2569
+ return newDomain;
2570
+ }
2571
+ contains(record) {
2572
+ const expr = evaluate(this.ast, record);
2573
+ return matchDomain(record, expr);
2574
+ }
2575
+ toString() {
2576
+ return formatAST(this.ast);
2577
+ }
2578
+ toList(context) {
2579
+ return evaluate(this.ast, context);
2580
+ }
2581
+ toJson() {
2582
+ try {
2583
+ const evaluatedAsList = this.toList({});
2584
+ const evaluatedDomain = new _Domain(evaluatedAsList);
2585
+ if (evaluatedDomain.toString() === this.toString()) {
2586
+ return evaluatedAsList;
2587
+ }
2588
+ return this.toString();
2589
+ } catch (e) {
2590
+ return this.toString();
2591
+ }
2592
+ }
2593
+ };
2594
+ var TRUE_LEAF = [1, "=", 1];
2595
+ var FALSE_LEAF = [0, "=", 1];
2596
+ var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
2597
+ var FALSE_DOMAIN = new Domain([FALSE_LEAF]);
2598
+ Domain.TRUE = TRUE_DOMAIN;
2599
+ Domain.FALSE = FALSE_DOMAIN;
2600
+ function toAST(domain) {
2601
+ const elems = domain.map((elem) => {
2602
+ switch (elem) {
2603
+ case "!":
2604
+ case "&":
2605
+ case "|":
2606
+ return { type: 1, value: elem };
2607
+ default:
2608
+ return {
2609
+ type: 10,
2610
+ value: elem.map(toPyValue)
2611
+ };
2612
+ }
2613
+ });
2614
+ return { type: 4, value: elems };
2615
+ }
2616
+ function normalizeDomainAST(domain, op = "&") {
2617
+ if (domain.type !== 4) {
2618
+ if (domain.type === 10) {
2619
+ const value = domain.value;
2620
+ if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
2621
+ throw new InvalidDomainError("Invalid domain AST");
2622
+ }
2623
+ } else {
2624
+ throw new InvalidDomainError("Invalid domain AST");
2625
+ }
2626
+ }
2627
+ if (domain.value.length === 0) {
2628
+ return domain;
2629
+ }
2630
+ let expected = 1;
2631
+ for (const child of domain.value) {
2632
+ switch (child.type) {
2633
+ case 1:
2634
+ if (child.value === "&" || child.value === "|") {
2635
+ expected++;
2636
+ } else if (child.value !== "!") {
2637
+ throw new InvalidDomainError("Invalid domain AST");
2638
+ }
2639
+ break;
2640
+ case 4:
2641
+ /* list */
2642
+ case 10:
2643
+ if (child.value.length === 3) {
2644
+ expected--;
2645
+ break;
2646
+ }
2647
+ throw new InvalidDomainError("Invalid domain AST");
2648
+ default:
2649
+ throw new InvalidDomainError("Invalid domain AST");
2650
+ }
2651
+ }
2652
+ const values = domain.value.slice();
2653
+ while (expected < 0) {
2654
+ expected++;
2655
+ values.unshift({ type: 1, value: op });
2656
+ }
2657
+ if (expected > 0) {
2658
+ throw new InvalidDomainError(
2659
+ `invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
2660
+ );
2661
+ }
2662
+ return { type: 4, value: values };
2663
+ }
2664
+ function matchCondition(record, condition) {
2665
+ if (typeof condition === "boolean") {
2666
+ return condition;
2667
+ }
2668
+ const [field, operator, value] = condition;
2669
+ if (typeof field === "string") {
2670
+ const names = field.split(".");
2671
+ if (names.length >= 2) {
2672
+ return matchCondition(record[names[0]], [
2673
+ names.slice(1).join("."),
2674
+ operator,
2675
+ value
2676
+ ]);
2677
+ }
2678
+ }
2679
+ let likeRegexp, ilikeRegexp;
2680
+ if (["like", "not like", "ilike", "not ilike"].includes(operator)) {
2681
+ likeRegexp = new RegExp(
2682
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2683
+ "g"
2684
+ );
2685
+ ilikeRegexp = new RegExp(
2686
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2687
+ "gi"
2688
+ );
2689
+ }
2690
+ const fieldValue = typeof field === "number" ? field : record[field];
2691
+ switch (operator) {
2692
+ case "=?":
2693
+ if ([false, null].includes(value)) {
2694
+ return true;
2695
+ }
2696
+ // eslint-disable-next-line no-fallthrough
2697
+ case "=":
2698
+ case "==":
2699
+ if (Array.isArray(fieldValue) && Array.isArray(value)) {
2700
+ return shallowEqual2(fieldValue, value);
2701
+ }
2702
+ return fieldValue === value;
2703
+ case "!=":
2704
+ case "<>":
2705
+ return !matchCondition(record, [field, "==", value]);
2706
+ case "<":
2707
+ return fieldValue < value;
2708
+ case "<=":
2709
+ return fieldValue <= value;
2710
+ case ">":
2711
+ return fieldValue > value;
2712
+ case ">=":
2713
+ return fieldValue >= value;
2714
+ case "in": {
2715
+ const val = Array.isArray(value) ? value : [value];
2716
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2717
+ return fieldVal.some((fv) => val.includes(fv));
2718
+ }
2719
+ case "not in": {
2720
+ const val = Array.isArray(value) ? value : [value];
2721
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2722
+ return !fieldVal.some((fv) => val.includes(fv));
2723
+ }
2724
+ case "like":
2725
+ if (fieldValue === false) {
2726
+ return false;
2727
+ }
2728
+ return Boolean(fieldValue.match(likeRegexp));
2729
+ case "not like":
2730
+ if (fieldValue === false) {
2731
+ return false;
2732
+ }
2733
+ return Boolean(!fieldValue.match(likeRegexp));
2734
+ case "=like":
2735
+ if (fieldValue === false) {
2736
+ return false;
2737
+ }
2738
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
2739
+ fieldValue
2740
+ );
2741
+ case "ilike":
2742
+ if (fieldValue === false) {
2743
+ return false;
2744
+ }
2745
+ return Boolean(fieldValue.match(ilikeRegexp));
2746
+ case "not ilike":
2747
+ if (fieldValue === false) {
2748
+ return false;
2749
+ }
2750
+ return Boolean(!fieldValue.match(ilikeRegexp));
2751
+ case "=ilike":
2752
+ if (fieldValue === false) {
2753
+ return false;
2754
+ }
2755
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
2756
+ fieldValue
2757
+ );
2758
+ }
2759
+ throw new InvalidDomainError("could not match domain");
2760
+ }
2761
+ function makeOperators(record) {
2762
+ const match = matchCondition.bind(null, record);
2763
+ return {
2764
+ "!": (x) => !match(x),
2765
+ "&": (a, b) => match(a) && match(b),
2766
+ "|": (a, b) => match(a) || match(b)
2767
+ };
2768
+ }
2769
+ function matchDomain(record, domain) {
2770
+ if (domain.length === 0) {
2771
+ return true;
2772
+ }
2773
+ const operators = makeOperators(record);
2774
+ const reversedDomain = Array.from(domain).reverse();
2775
+ const condStack = [];
2776
+ for (const item of reversedDomain) {
2777
+ const operator = typeof item === "string" && operators[item];
2778
+ if (operator) {
2779
+ const operands = condStack.splice(-operator.length);
2780
+ condStack.push(operator(...operands));
2781
+ } else {
2782
+ condStack.push(item);
2783
+ }
2784
+ }
2785
+ return matchCondition(record, condStack.pop());
2786
+ }
2787
+
2788
+ // src/utils/function.ts
2789
+ import { useEffect, useState } from "react";
2790
+ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2791
+ if (!originalRequest.data) return originalRequest.data;
2792
+ if (typeof originalRequest.data === "string") {
2793
+ try {
2794
+ const parsedData = JSON.parse(originalRequest.data);
2795
+ if (parsedData.with_context && typeof parsedData.with_context === "object") {
2796
+ parsedData.with_context.token = newAccessToken;
2797
+ }
2798
+ return JSON.stringify(parsedData);
2799
+ } catch (e) {
2800
+ console.warn("Failed to parse originalRequest.data", e);
2801
+ return originalRequest.data;
2802
+ }
2803
+ }
2804
+ if (typeof originalRequest.data === "object" && originalRequest.data.with_context) {
2805
+ originalRequest.data.with_context.token = newAccessToken;
2806
+ }
2807
+ return originalRequest.data;
2808
+ };
2809
+
2810
+ // src/utils/storage/local-storage.ts
2811
+ var localStorageUtils = () => {
2812
+ const setToken = (access_token) => __async(null, null, function* () {
2813
+ localStorage.setItem("accessToken", access_token);
2814
+ });
2815
+ const setRefreshToken = (refresh_token) => __async(null, null, function* () {
2816
+ localStorage.setItem("refreshToken", refresh_token);
2817
+ });
2818
+ const getAccessToken = () => __async(null, null, function* () {
2819
+ return localStorage.getItem("accessToken");
2820
+ });
2821
+ const getRefreshToken = () => __async(null, null, function* () {
2822
+ return localStorage.getItem("refreshToken");
2823
+ });
2824
+ const clearToken = () => __async(null, null, function* () {
2825
+ localStorage.removeItem("accessToken");
2826
+ localStorage.removeItem("refreshToken");
2827
+ });
2828
+ return {
2829
+ setToken,
2830
+ setRefreshToken,
2831
+ getAccessToken,
2832
+ getRefreshToken,
2833
+ clearToken
2834
+ };
2835
+ };
2836
+
2837
+ // src/utils/storage/session-storage.ts
2838
+ var sessionStorageUtils = () => {
2839
+ const getBrowserSession = () => __async(null, null, function* () {
2840
+ return sessionStorage.getItem("browserSession");
2841
+ });
2842
+ return {
2843
+ getBrowserSession
2844
+ };
2845
+ };
2846
+
2847
+ // src/configs/axios-client.ts
2848
+ var axiosClient = {
2849
+ init(config) {
2850
+ var _a, _b;
2851
+ const localStorage2 = (_a = config.localStorageUtils) != null ? _a : localStorageUtils();
2852
+ const sessionStorage2 = (_b = config.sessionStorageUtils) != null ? _b : sessionStorageUtils();
2853
+ const db = config.db;
2854
+ let isRefreshing = false;
2855
+ let failedQueue = [];
2856
+ const processQueue = (error, token = null) => {
2857
+ failedQueue == null ? void 0 : failedQueue.forEach((prom) => {
2858
+ if (error) {
2859
+ prom.reject(error);
2860
+ } else {
2861
+ prom.resolve(token);
2862
+ }
2863
+ });
2864
+ failedQueue = [];
2865
+ };
2866
+ const instance = axios.create({
2867
+ adapter: axios.defaults.adapter,
2868
+ baseURL: config.baseUrl,
2869
+ timeout: 5e4,
2870
+ paramsSerializer: (params) => new URLSearchParams(params).toString()
2871
+ });
2872
+ instance.interceptors.request.use(
2873
+ (config2) => __async(null, null, function* () {
2874
+ const useRefreshToken = config2.useRefreshToken;
2875
+ const token = useRefreshToken ? yield localStorage2.getRefreshToken() : yield localStorage2.getAccessToken();
2876
+ if (token) {
2877
+ config2.headers["Authorization"] = "Bearer " + token;
2878
+ }
2879
+ return config2;
2880
+ }),
2881
+ (error) => {
2882
+ Promise.reject(error);
2883
+ }
2884
+ );
2885
+ instance.interceptors.response.use(
2886
+ (response) => {
2887
+ return handleResponse(response);
2888
+ },
2889
+ (error) => __async(null, null, function* () {
2890
+ var _a2, _b2, _c;
2891
+ const handleError3 = (error2) => __async(null, null, function* () {
2892
+ var _a3;
2893
+ if (!error2.response) {
2894
+ return error2;
2895
+ }
2896
+ const { data } = error2.response;
2897
+ if (data && data.code === 400 && ["invalid_grant"].includes((_a3 = data.data) == null ? void 0 : _a3.error)) {
2898
+ yield clearAuthToken();
2899
+ }
2900
+ return data;
2901
+ });
2902
+ const originalRequest = error.config;
2903
+ if ((((_a2 = error.response) == null ? void 0 : _a2.status) === 403 || ((_b2 = error.response) == null ? void 0 : _b2.status) === 401 || ((_c = error.response) == null ? void 0 : _c.status) === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401, "ERR_2FA_006"].includes(
2904
+ error.response.data.code
2905
+ )) {
2906
+ if (isRefreshing) {
2907
+ return new Promise(function(resolve, reject) {
2908
+ failedQueue.push({ resolve, reject });
2909
+ }).then((token) => {
2910
+ originalRequest.headers["Authorization"] = "Bearer " + token;
2911
+ originalRequest.data = updateTokenParamInOriginalRequest(
2912
+ originalRequest,
2913
+ token
2914
+ );
2915
+ return instance.request(originalRequest);
2916
+ }).catch((err) => __async(null, null, function* () {
2917
+ var _a3, _b3;
2918
+ if ((((_a3 = err.response) == null ? void 0 : _a3.status) === 400 || ((_b3 = err.response) == null ? void 0 : _b3.status) === 401) && ["invalid_grant"].includes(err.response.data.error)) {
2919
+ yield clearAuthToken();
2920
+ }
2921
+ }));
2922
+ }
2923
+ const browserSession = yield sessionStorage2.getBrowserSession();
2924
+ const refreshToken = yield localStorage2.getRefreshToken();
2925
+ const accessTokenExp = yield localStorage2.getAccessToken();
2926
+ isRefreshing = true;
2927
+ if (!refreshToken && (!browserSession || browserSession == "unActive")) {
2928
+ yield clearAuthToken();
2929
+ } else {
2930
+ const payload = Object.fromEntries(
2931
+ Object.entries({
2932
+ refresh_token: refreshToken,
2933
+ grant_type: "refresh_token",
2934
+ client_id: config.config.clientId,
2935
+ client_secret: config.config.clientSecret
2936
+ }).filter(([_, value]) => !!value)
2937
+ );
2938
+ return new Promise(function(resolve) {
2939
+ var _a3;
2940
+ axios.post(
2941
+ `${config.baseUrl}${(_a3 = config.refreshTokenEndpoint) != null ? _a3 : "/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
2942
+ payload,
2943
+ {
2944
+ headers: {
2945
+ "Content-Type": config.refreshTokenEndpoint ? "application/x-www-form-urlencoded" : "multipart/form-data",
2946
+ Authorization: `Bearer ${accessTokenExp}`
2947
+ }
2948
+ }
2949
+ ).then((res) => __async(null, null, function* () {
2950
+ const data = res.data;
2951
+ yield localStorage2.setToken(data.access_token);
2952
+ yield localStorage2.setRefreshToken(data.refresh_token);
2953
+ axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
2954
+ originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
2955
+ originalRequest.data = updateTokenParamInOriginalRequest(
2956
+ originalRequest,
2957
+ data.access_token
2958
+ );
2959
+ processQueue(null, data.access_token);
2960
+ resolve(instance.request(originalRequest));
2961
+ })).catch((err) => __async(null, null, function* () {
2962
+ var _a4;
2963
+ if (err && ((err == null ? void 0 : err.error_code) === "AUTHEN_FAIL" || (err == null ? void 0 : err.error_code) === "TOKEN_EXPIRED" || (err == null ? void 0 : err.error_code) === "TOKEN_INCORRECT" || (err == null ? void 0 : err.code) === "ERR_BAD_REQUEST") || (err == null ? void 0 : err.error_code) === "ERR_2FA_006") {
2964
+ yield clearAuthToken();
2965
+ }
2966
+ if (err && err.response) {
2967
+ const { error_code } = ((_a4 = err.response) == null ? void 0 : _a4.data) || {};
2968
+ if (error_code === "AUTHEN_FAIL") {
2969
+ yield clearAuthToken();
2970
+ }
2971
+ }
2972
+ processQueue(err, null);
2973
+ })).finally(() => {
2974
+ isRefreshing = false;
2975
+ });
2976
+ });
2977
+ }
2978
+ }
2979
+ return Promise.reject(yield handleError3(error));
2980
+ })
2981
+ );
2982
+ const handleResponse = (res) => {
2983
+ if (res && res.data) {
2984
+ return res.data;
2985
+ }
2986
+ return res;
2987
+ };
2988
+ const handleError2 = (error) => {
2989
+ var _a2, _b2, _c;
2990
+ if (error.isAxiosError && error.code === "ECONNABORTED") {
2991
+ console.error("Request Timeout Error:", error);
2992
+ return "Request Timeout Error";
2993
+ } else if (error.isAxiosError && !error.response) {
2994
+ console.error("Network Error:", error);
2995
+ return "Network Error";
2996
+ } else {
2997
+ console.error("Other Error:", error == null ? void 0 : error.response);
2998
+ const errorMessage = ((_b2 = (_a2 = error == null ? void 0 : error.response) == null ? void 0 : _a2.data) == null ? void 0 : _b2.message) || "An error occurred";
2999
+ return { message: errorMessage, status: (_c = error == null ? void 0 : error.response) == null ? void 0 : _c.status };
3000
+ }
3001
+ };
3002
+ const clearAuthToken = () => __async(null, null, function* () {
3003
+ yield localStorage2.clearToken();
3004
+ if (typeof window !== "undefined") {
3005
+ window.location.href = `/login`;
3006
+ }
3007
+ });
3008
+ function formatUrl(url, db2) {
3009
+ return url + (db2 ? "?db=" + db2 : "");
3010
+ }
3011
+ const responseBody = (response) => response;
3012
+ const requests = {
3013
+ get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
3014
+ post: (url, body, headers) => instance.post(formatUrl(url, db), body, headers).then(responseBody),
3015
+ post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
3016
+ responseType: "arraybuffer",
3017
+ headers: {
3018
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
3019
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
3020
+ }
3021
+ }).then(responseBody),
3022
+ put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
3023
+ patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
3024
+ delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
3025
+ };
3026
+ return requests;
3027
+ }
3028
+ };
3029
+
3030
+ // src/environment/EnvStore.ts
3031
+ var EnvStore = class {
3032
+ constructor(envStore2, localStorageUtils2, sessionStorageUtils2) {
3033
+ this.envStore = envStore2;
3034
+ this.localStorageUtils = localStorageUtils2;
3035
+ this.sessionStorageUtils = sessionStorageUtils2;
3036
+ this.setup();
3037
+ }
3038
+ setup() {
3039
+ const env2 = this.envStore.getState().env;
3040
+ this.baseUrl = env2 == null ? void 0 : env2.baseUrl;
3041
+ this.requests = env2 == null ? void 0 : env2.requests;
3042
+ this.context = env2 == null ? void 0 : env2.context;
3043
+ this.defaultCompany = env2 == null ? void 0 : env2.defaultCompany;
3044
+ this.config = env2 == null ? void 0 : env2.config;
3045
+ this.companies = (env2 == null ? void 0 : env2.companies) || [];
3046
+ this.user = env2 == null ? void 0 : env2.user;
3047
+ this.db = env2 == null ? void 0 : env2.db;
3048
+ this.refreshTokenEndpoint = env2 == null ? void 0 : env2.refreshTokenEndpoint;
3049
+ }
3050
+ setupEnv(envConfig) {
3051
+ const dispatch = this.envStore.dispatch;
3052
+ const env2 = __spreadProps(__spreadValues({}, envConfig), {
3053
+ localStorageUtils: this.localStorageUtils,
3054
+ sessionStorageUtils: this.sessionStorageUtils
3055
+ });
3056
+ const requests = axiosClient.init(env2);
3057
+ dispatch(setEnv(__spreadProps(__spreadValues({}, env2), { requests })));
3058
+ this.setup();
3059
+ }
3060
+ setUid(uid) {
3061
+ const dispatch = this.envStore.dispatch;
3062
+ dispatch(setUid(uid));
3063
+ this.setup();
3064
+ }
3065
+ setLang(lang) {
3066
+ const dispatch = this.envStore.dispatch;
3067
+ dispatch(setLang(lang));
3068
+ this.setup();
3069
+ }
3070
+ setAllowCompanies(allowCompanies) {
3071
+ const dispatch = this.envStore.dispatch;
3072
+ dispatch(setAllowCompanies(allowCompanies));
3073
+ this.setup();
3074
+ }
3075
+ setCompanies(companies) {
3076
+ const dispatch = this.envStore.dispatch;
3077
+ dispatch(setCompanies(companies));
3078
+ this.setup();
3079
+ }
3080
+ setDefaultCompany(company) {
3081
+ const dispatch = this.envStore.dispatch;
3082
+ dispatch(setDefaultCompany(company));
3083
+ this.setup();
3084
+ }
3085
+ setUserInfo(userInfo) {
3086
+ const dispatch = this.envStore.dispatch;
3087
+ dispatch(setUser(userInfo));
3088
+ this.setup();
3089
+ }
3090
+ };
3091
+ var env = null;
3092
+ function getEnv() {
3093
+ if (!env)
3094
+ env = new EnvStore(envStore, localStorageUtils(), sessionStorageUtils());
3095
+ return env;
3096
+ }
3097
+
3098
+ // src/services/view-service/index.ts
3099
+ var ViewService = {
3100
+ getView(_0) {
3101
+ return __async(this, arguments, function* ({
3102
+ model,
3103
+ views,
3104
+ context = {},
3105
+ options = {},
3106
+ aid
3107
+ }) {
3108
+ var _a;
3109
+ const env2 = getEnv();
3110
+ const defaultOptions = {
3111
+ load_filters: true,
3112
+ toolbar: true,
3113
+ action_id: aid
3114
+ };
3115
+ const jsonDataView = {
3116
+ model,
3117
+ method: "get_fields_view_v2" /* GET_FIELD_VIEW */,
3118
+ kwargs: {
3119
+ views,
3120
+ options: __spreadValues(__spreadValues({}, options), defaultOptions)
3121
+ },
3122
+ with_context: context
3123
+ };
3124
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/call" /* CALL_PATH */, jsonDataView, {
3125
+ headers: {
3126
+ "Content-Type": "application/json"
3127
+ }
3128
+ });
3129
+ });
3130
+ },
3131
+ getMenu(context) {
3132
+ return __async(this, null, function* () {
3133
+ var _a;
3134
+ const env2 = getEnv();
3135
+ const jsonData = {
3136
+ model: "ir.ui.menu" /* MENU */,
3137
+ method: "web_search_read" /* WEB_SEARCH_READ */,
3138
+ ids: [],
3139
+ with_context: context,
3140
+ kwargs: {
3141
+ specification: {
3142
+ active: {},
3143
+ name: {},
3144
+ is_display: {},
3145
+ sequence: {},
3146
+ complete_name: {},
3147
+ action: {
3148
+ fields: {
3149
+ display_name: {},
3150
+ type: {},
3151
+ binding_view_types: {}
3152
+ // res_model: {},
3153
+ }
3154
+ },
3155
+ url_icon: {},
3156
+ web_icon: {},
3157
+ web_icon_data: {},
3158
+ groups_id: {
3159
+ fields: {
3160
+ full_name: {}
3161
+ },
3162
+ limit: 40,
3163
+ order: ""
3164
+ },
3165
+ display_name: {},
3166
+ child_id: {
3167
+ fields: {
3168
+ active: {},
3169
+ name: {},
3170
+ is_display: {},
3171
+ sequence: {},
3172
+ complete_name: {},
3173
+ action: {
3174
+ fields: {
3175
+ display_name: {},
3176
+ type: {},
3177
+ binding_view_types: {}
3178
+ // res_model: {},
3179
+ }
3180
+ },
3181
+ url_icon: {},
3182
+ web_icon: {},
3183
+ web_icon_data: {},
3184
+ groups_id: {
3185
+ fields: {
3186
+ full_name: {}
3187
+ },
3188
+ limit: 40,
3189
+ order: ""
3190
+ },
3191
+ display_name: {},
3192
+ child_id: {
3193
+ fields: {
3194
+ active: {},
3195
+ name: {},
3196
+ is_display: {},
3197
+ sequence: {},
3198
+ complete_name: {},
3199
+ action: {
3200
+ fields: {
3201
+ display_name: {},
3202
+ type: {},
3203
+ binding_view_types: {}
3204
+ // res_model: {},
3205
+ }
3206
+ },
3207
+ url_icon: {},
3208
+ web_icon: {},
3209
+ web_icon_data: {},
3210
+ groups_id: {
3211
+ fields: {
3212
+ full_name: {}
3213
+ },
3214
+ limit: 40,
3215
+ order: ""
3216
+ },
3217
+ display_name: {},
3218
+ child_id: {
3219
+ fields: {
3220
+ active: {},
3221
+ name: {},
3222
+ is_display: {},
3223
+ sequence: {},
3224
+ complete_name: {},
3225
+ action: {
3226
+ fields: {
3227
+ display_name: {},
3228
+ type: {},
3229
+ binding_view_types: {}
3230
+ // res_model: {},
3231
+ }
3232
+ },
3233
+ url_icon: {},
3234
+ web_icon: {},
3235
+ web_icon_data: {},
3236
+ groups_id: {
3237
+ fields: {
3238
+ full_name: {}
3239
+ },
3240
+ limit: 40,
3241
+ order: ""
3242
+ },
3243
+ display_name: {},
3244
+ child_id: {
3245
+ fields: {},
3246
+ limit: 40,
3247
+ order: ""
3248
+ }
3249
+ },
3250
+ limit: 40,
3251
+ order: ""
3252
+ }
3253
+ },
3254
+ limit: 40,
3255
+ order: ""
3256
+ }
3257
+ },
3258
+ limit: 40,
3259
+ order: ""
3260
+ }
3261
+ },
3262
+ domain: [
3263
+ "&",
3264
+ ["is_display", "=", true],
3265
+ "&",
3266
+ ["active", "=", true],
3267
+ ["parent_id", "=", false]
3268
+ ]
3269
+ }
3270
+ };
3271
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/call" /* CALL_PATH */, jsonData, {
3272
+ headers: {
3273
+ "Content-Type": "application/json"
3274
+ }
3275
+ });
3276
+ });
3277
+ },
3278
+ getActionDetail(aid, context) {
3279
+ return __async(this, null, function* () {
3280
+ var _a;
3281
+ const env2 = getEnv();
3282
+ const jsonData = {
3283
+ model: "ir.actions.act_window" /* WINDOW_ACTION */,
3284
+ method: "web_read" /* WEB_READ */,
3285
+ ids: [aid],
3286
+ with_context: context,
3287
+ kwargs: {
3288
+ specification: {
3289
+ id: {},
3290
+ name: {},
3291
+ res_model: {},
3292
+ views: {},
3293
+ view_mode: {},
3294
+ mobile_view_mode: {},
3295
+ domain: {},
3296
+ context: {},
3297
+ groups_id: {},
3298
+ search_view_id: {}
3299
+ }
3300
+ }
3301
+ };
3302
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.post("/call" /* CALL_PATH */, jsonData, {
3303
+ headers: {
3304
+ "Content-Type": "application/json"
3305
+ }
3306
+ });
3307
+ });
3308
+ },
3309
+ getResequence(_0) {
3310
+ return __async(this, arguments, function* ({
3311
+ model,
3312
+ ids,
3313
+ context,
3314
+ offset
3315
+ }) {
3316
+ const env2 = getEnv();
3317
+ const jsonData = __spreadValues({
3318
+ model,
3319
+ with_context: context,
3320
+ ids,
3321
+ field: "sequence"
3322
+ }, offset > 0 ? { offset } : {});
3323
+ return env2 == null ? void 0 : env2.requests.post("/web/dataset/resequence", jsonData, {
3324
+ headers: {
3325
+ "Content-Type": "application/json"
3326
+ }
3327
+ });
3328
+ });
3329
+ },
3330
+ getSelectionItem(_0) {
3331
+ return __async(this, arguments, function* ({ data }) {
3332
+ var _a;
3333
+ const env2 = getEnv();
3334
+ const jsonData = {
3335
+ model: data.model,
3336
+ ids: [],
3337
+ method: "get_data_select",
3338
+ with_context: data.context,
3339
+ kwargs: {
3340
+ count_limit: 10001,
3341
+ domain: data.domain ? data.domain : [],
3342
+ offset: 0,
3343
+ order: "",
3344
+ specification: (_a = data == null ? void 0 : data.specification) != null ? _a : {
3345
+ id: {},
3346
+ name: {},
3347
+ display_name: {}
3348
+ }
3349
+ }
3350
+ };
3351
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3352
+ headers: {
3353
+ "Content-Type": "application/json"
3354
+ }
3355
+ });
3356
+ });
3357
+ },
3358
+ loadMessages() {
3359
+ return __async(this, null, function* () {
3360
+ const env2 = getEnv();
3361
+ return env2.requests.post(
3362
+ "/load_message_failures" /* LOAD_MESSAGE */,
3363
+ {},
3364
+ {
3365
+ headers: {
3366
+ "Content-Type": "application/json"
3367
+ }
3368
+ }
3369
+ );
3370
+ });
3371
+ },
3372
+ getVersion() {
3373
+ return __async(this, null, function* () {
3374
+ var _a;
3375
+ const env2 = getEnv();
3376
+ console.log("env?.requests", env2, env2 == null ? void 0 : env2.requests);
3377
+ return (_a = env2 == null ? void 0 : env2.requests) == null ? void 0 : _a.get("", {
3378
+ headers: {
3379
+ "Content-Type": "application/json"
3380
+ }
3381
+ });
3382
+ });
3383
+ },
3384
+ get2FAMethods(_0) {
3385
+ return __async(this, arguments, function* ({
3386
+ method,
3387
+ with_context
3388
+ }) {
3389
+ const env2 = getEnv();
3390
+ const jsonData = {
3391
+ method,
3392
+ with_context
3393
+ };
3394
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3395
+ headers: {
3396
+ "Content-Type": "application/json"
3397
+ }
3398
+ });
3399
+ });
3400
+ },
3401
+ verify2FA(_0) {
3402
+ return __async(this, arguments, function* ({
3403
+ method,
3404
+ with_context,
3405
+ code,
3406
+ device,
3407
+ location
3408
+ }) {
3409
+ const env2 = getEnv();
3410
+ const jsonData = {
3411
+ method,
3412
+ kwargs: {
3413
+ vals: {
3414
+ code,
3415
+ device,
3416
+ location
3417
+ }
3418
+ },
3419
+ with_context
3420
+ };
3421
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3422
+ headers: {
3423
+ "Content-Type": "application/json"
3424
+ },
3425
+ withCredentials: true
3426
+ });
3427
+ });
3428
+ },
3429
+ signInSSO(_0) {
3430
+ return __async(this, arguments, function* ({
3431
+ redirect_uri,
3432
+ state,
3433
+ client_id,
3434
+ response_type,
3435
+ path
3436
+ }) {
3437
+ const env2 = getEnv();
3438
+ const params = new URLSearchParams({
3439
+ response_type,
3440
+ client_id,
3441
+ redirect_uri,
3442
+ state
3443
+ });
3444
+ const url = `${path}?${params.toString()}`;
3445
+ return env2 == null ? void 0 : env2.requests.get(url, {
3446
+ headers: {
3447
+ "Content-Type": "application/json"
3448
+ },
3449
+ withCredentials: true
3450
+ });
3451
+ });
3452
+ },
3453
+ grantAccess(_0) {
3454
+ return __async(this, arguments, function* ({
3455
+ redirect_uri,
3456
+ state,
3457
+ client_id,
3458
+ scopes
3459
+ }) {
3460
+ const env2 = getEnv();
3461
+ const jsonData = {
3462
+ redirect_uri,
3463
+ state,
3464
+ client_id,
3465
+ scopes
3466
+ };
3467
+ return env2 == null ? void 0 : env2.requests.post("/grant-access" /* GRANT_ACCESS */, jsonData, {
3468
+ headers: {
3469
+ "Content-Type": "application/json"
3470
+ },
3471
+ withCredentials: true
3472
+ });
3473
+ });
3474
+ },
3475
+ getFieldsViewSecurity(_0) {
3476
+ return __async(this, arguments, function* ({
3477
+ method,
3478
+ token,
3479
+ views
3480
+ }) {
3481
+ const env2 = getEnv();
3482
+ const jsonData = {
3483
+ method,
3484
+ kwargs: {
3485
+ views
3486
+ },
3487
+ with_context: {
3488
+ token
3489
+ }
3490
+ };
3491
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3492
+ headers: {
3493
+ "Content-Type": "application/json"
3494
+ }
3495
+ });
3496
+ });
3497
+ },
3498
+ settingsWebRead2fa(_0) {
3499
+ return __async(this, arguments, function* ({
3500
+ method,
3501
+ model,
3502
+ kwargs,
3503
+ token
3504
+ }) {
3505
+ const env2 = getEnv();
3506
+ const jsonData = {
3507
+ method,
3508
+ model,
3509
+ kwargs,
3510
+ with_context: {
3511
+ token
3512
+ }
3513
+ };
3514
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3515
+ headers: {
3516
+ "Content-Type": "application/json"
3517
+ }
3518
+ });
3519
+ });
3520
+ },
3521
+ requestSetupTotp(_0) {
3522
+ return __async(this, arguments, function* ({ method, token }) {
3523
+ const env2 = getEnv();
3524
+ const jsonData = {
3525
+ method,
3526
+ with_context: {
3527
+ token
3528
+ }
3529
+ };
3530
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3531
+ headers: {
3532
+ "Content-Type": "application/json"
3533
+ }
3534
+ });
3535
+ });
3536
+ },
3537
+ verifyTotp(_0) {
3538
+ return __async(this, arguments, function* ({
3539
+ method,
3540
+ action_token,
3541
+ code
3542
+ }) {
3543
+ const env2 = getEnv();
3544
+ const jsonData = {
3545
+ method,
3546
+ kwargs: {
3547
+ vals: {
3548
+ code
3549
+ }
3550
+ },
3551
+ with_context: {
3552
+ action_token
3553
+ }
3554
+ };
3555
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3556
+ headers: {
3557
+ "Content-Type": "application/json"
3558
+ }
3559
+ });
3560
+ });
3561
+ },
3562
+ removeTotpSetUp(_0) {
3563
+ return __async(this, arguments, function* ({ method, token }) {
3564
+ const env2 = getEnv();
3565
+ const jsonData = {
3566
+ method,
3567
+ with_context: {
3568
+ token
3569
+ }
3570
+ };
3571
+ return env2 == null ? void 0 : env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3572
+ headers: {
3573
+ "Content-Type": "application/json"
3574
+ }
3575
+ });
3576
+ });
3577
+ }
3578
+ };
3579
+ var view_service_default = ViewService;
3580
+
3581
+ // src/provider/version-gate-provider.tsx
3582
+ import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
3583
+ var VersionGate = ({ children }) => {
3584
+ const queryClient = useQueryClient();
3585
+ const [ready, setReady] = useState2(false);
3586
+ useEffect2(() => {
3587
+ const clearVersion = () => {
3588
+ queryClient.clear();
3589
+ localStorage.removeItem("__api_version__");
3590
+ };
3591
+ const validateVersion = () => __async(null, null, function* () {
3592
+ const serverVersion = yield view_service_default.getVersion();
3593
+ console.log("serverVersion", serverVersion);
3594
+ const cached = localStorage.getItem("__api_version__");
3595
+ if (cached !== (serverVersion == null ? void 0 : serverVersion.api_version)) {
3596
+ clearVersion();
3597
+ localStorage.setItem("__api_version__", serverVersion == null ? void 0 : serverVersion.api_version);
3598
+ } else {
3599
+ console.log("Api version:", serverVersion == null ? void 0 : serverVersion.api_version);
3600
+ }
3601
+ setReady(true);
3602
+ });
3603
+ validateVersion();
3604
+ if (typeof window !== "undefined") {
3605
+ const onKey = (e) => {
3606
+ const key = e.key.toLowerCase();
3607
+ const isHardRefresh = (key === "f5" || key === "r") && e.ctrlKey && (key !== "r" || e.shiftKey) || key === "r" && e.metaKey && e.shiftKey || key === "r" && e.metaKey && e.altKey;
3608
+ if (isHardRefresh) clearVersion();
3609
+ };
3610
+ window.addEventListener("keydown", onKey);
3611
+ return () => window.removeEventListener("keydown", onKey);
3612
+ }
3613
+ }, [queryClient]);
3614
+ return ready ? /* @__PURE__ */ jsx4(Fragment, { children }) : null;
3615
+ };
3616
+ export {
3617
+ MainProvider,
3618
+ ReactQueryProvider,
3619
+ VersionGate
3620
+ };