@fctc/edu-logic-lib 1.0.0

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.
Files changed (51) hide show
  1. package/dist/base-model-type-DvO53Lwi.d.mts +7 -0
  2. package/dist/base-model-type-DvO53Lwi.d.ts +7 -0
  3. package/dist/config.d.mts +15 -0
  4. package/dist/config.d.ts +15 -0
  5. package/dist/config.js +294 -0
  6. package/dist/config.mjs +257 -0
  7. package/dist/constants.d.mts +120 -0
  8. package/dist/constants.d.ts +120 -0
  9. package/dist/constants.js +191 -0
  10. package/dist/constants.mjs +153 -0
  11. package/dist/context-type-D5XefoL-.d.mts +8 -0
  12. package/dist/context-type-D5XefoL-.d.ts +8 -0
  13. package/dist/environment.d.mts +37 -0
  14. package/dist/environment.d.ts +37 -0
  15. package/dist/environment.js +910 -0
  16. package/dist/environment.mjs +870 -0
  17. package/dist/hooks.d.mts +216 -0
  18. package/dist/hooks.d.ts +216 -0
  19. package/dist/hooks.js +5094 -0
  20. package/dist/hooks.mjs +5013 -0
  21. package/dist/index-C_nK1Mii.d.mts +19 -0
  22. package/dist/index-C_nK1Mii.d.ts +19 -0
  23. package/dist/models.d.mts +35 -0
  24. package/dist/models.d.ts +35 -0
  25. package/dist/models.js +3288 -0
  26. package/dist/models.mjs +3249 -0
  27. package/dist/provider.d.mts +16 -0
  28. package/dist/provider.d.ts +16 -0
  29. package/dist/provider.js +3311 -0
  30. package/dist/provider.mjs +3272 -0
  31. package/dist/services.d.mts +160 -0
  32. package/dist/services.d.ts +160 -0
  33. package/dist/services.js +4113 -0
  34. package/dist/services.mjs +4069 -0
  35. package/dist/store.d.mts +505 -0
  36. package/dist/store.d.ts +505 -0
  37. package/dist/store.js +691 -0
  38. package/dist/store.mjs +603 -0
  39. package/dist/types.d.mts +12 -0
  40. package/dist/types.d.ts +12 -0
  41. package/dist/types.js +18 -0
  42. package/dist/types.mjs +0 -0
  43. package/dist/use-get-selection-DFh6sc49.d.mts +26 -0
  44. package/dist/use-get-selection-DFh6sc49.d.ts +26 -0
  45. package/dist/utils.d.mts +52 -0
  46. package/dist/utils.d.ts +52 -0
  47. package/dist/utils.js +2402 -0
  48. package/dist/utils.mjs +2361 -0
  49. package/dist/view-type-BTzRpkT7.d.mts +106 -0
  50. package/dist/view-type-BTzRpkT7.d.ts +106 -0
  51. package/package.json +93 -0
package/dist/hooks.mjs ADDED
@@ -0,0 +1,5013 @@
1
+ // src/hooks/auth/use-forgot-password.ts
2
+ import { useMutation } from "@tanstack/react-query";
3
+
4
+ // src/constants/api/uri-constant.ts
5
+ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
6
+ UriConstants2["AUTH_TOKEN_PATH"] = "/authentication/oauth2/token";
7
+ UriConstants2["GENTOKEN_SOCIAL"] = "/token/generate";
8
+ UriConstants2["CALL_PATH"] = "/call";
9
+ UriConstants2["COMPANY_PATH"] = "/company";
10
+ UriConstants2["PROFILE_PATH"] = "/userinfo";
11
+ UriConstants2["RESET_PASSWORD_PATH"] = "/reset_password";
12
+ UriConstants2["CHANGE_PASSWORD_PATH"] = "/change_password";
13
+ UriConstants2["UPDATE_PASSWORD_PATH"] = "/change_password_parent";
14
+ UriConstants2["LOAD_ACTION"] = `/load_action`;
15
+ UriConstants2["REPORT_PATH"] = `/report`;
16
+ UriConstants2["RUN_ACTION_PATH"] = `/run_action`;
17
+ UriConstants2["UPLOAD_FILE_PATH"] = `/upload/file`;
18
+ UriConstants2["GET_MESSAGE"] = `/chatter/thread/messages`;
19
+ UriConstants2["SENT_MESSAGE"] = `/chatter/message/post`;
20
+ UriConstants2["UPLOAD_IMAGE"] = `/mail/attachment/upload`;
21
+ UriConstants2["DELETE_MESSAGE"] = `/chatter/message/update_content`;
22
+ UriConstants2["IMAGE_PATH"] = `/web/image`;
23
+ UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
24
+ UriConstants2["TOKEN"] = `/check_token`;
25
+ UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
26
+ UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
27
+ UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
28
+ return UriConstants2;
29
+ })(UriConstants || {});
30
+
31
+ // src/store/index.ts
32
+ import { useDispatch, useSelector } from "react-redux";
33
+
34
+ // src/store/reducers/env-slice/index.ts
35
+ import { createSlice } from "@reduxjs/toolkit";
36
+ var initialState = {
37
+ baseUrl: "",
38
+ requests: null,
39
+ companies: [],
40
+ user: {},
41
+ envFile: null,
42
+ defaultCompany: {
43
+ id: null,
44
+ logo: "",
45
+ secondary_color: "",
46
+ primary_color: ""
47
+ },
48
+ context: {
49
+ uid: null,
50
+ allowed_company_ids: [],
51
+ lang: "vi_VN",
52
+ tz: "Asia/Saigon"
53
+ }
54
+ };
55
+ var envSlice = createSlice({
56
+ name: "env",
57
+ initialState,
58
+ reducers: {
59
+ setEnv: (state, action) => {
60
+ Object.assign(state, action.payload);
61
+ },
62
+ setUid: (state, action) => {
63
+ state.context.uid = action.payload;
64
+ },
65
+ setAllowCompanies: (state, action) => {
66
+ state.context.allowed_company_ids = action.payload;
67
+ },
68
+ setCompanies: (state, action) => {
69
+ state.companies = action.payload;
70
+ },
71
+ setDefaultCompany: (state, action) => {
72
+ state.defaultCompany = action.payload;
73
+ },
74
+ setLang: (state, action) => {
75
+ state.context.lang = action.payload;
76
+ },
77
+ setUser: (state, action) => {
78
+ state.user = action.payload;
79
+ },
80
+ setEnvFile: (state, action) => {
81
+ state.envFile = action.payload;
82
+ }
83
+ }
84
+ });
85
+ var {
86
+ setEnv,
87
+ setUid,
88
+ setLang,
89
+ setAllowCompanies,
90
+ setCompanies,
91
+ setDefaultCompany,
92
+ setUser,
93
+ setEnvFile
94
+ } = envSlice.actions;
95
+ var env_slice_default = envSlice.reducer;
96
+
97
+ // src/store/reducers/excel-slice/index.ts
98
+ import { createSlice as createSlice2 } from "@reduxjs/toolkit";
99
+ var initialState2 = {
100
+ dataParse: null,
101
+ idFile: null,
102
+ isFileLoaded: false,
103
+ loadingImport: false,
104
+ selectedFile: null,
105
+ errorData: null
106
+ };
107
+ var excelSlice = createSlice2({
108
+ name: "excel",
109
+ initialState: initialState2,
110
+ reducers: {
111
+ setDataParse: (state, action) => {
112
+ state.dataParse = action.payload;
113
+ },
114
+ setIdFile: (state, action) => {
115
+ state.idFile = action.payload;
116
+ },
117
+ setIsFileLoaded: (state, action) => {
118
+ state.isFileLoaded = action.payload;
119
+ },
120
+ setLoadingImport: (state, action) => {
121
+ state.loadingImport = action.payload;
122
+ },
123
+ setSelectedFile: (state, action) => {
124
+ state.selectedFile = action.payload;
125
+ },
126
+ setErrorData: (state, action) => {
127
+ state.errorData = action.payload;
128
+ }
129
+ }
130
+ });
131
+ var {
132
+ setDataParse,
133
+ setIdFile,
134
+ setIsFileLoaded,
135
+ setLoadingImport,
136
+ setSelectedFile,
137
+ setErrorData
138
+ } = excelSlice.actions;
139
+ var excel_slice_default = excelSlice.reducer;
140
+
141
+ // src/store/reducers/form-slice/index.ts
142
+ import { createSlice as createSlice3 } from "@reduxjs/toolkit";
143
+ var initialState3 = {
144
+ viewDataStore: {},
145
+ isShowingModalDetail: false,
146
+ isShowModalTranslate: false,
147
+ formSubmitComponent: {},
148
+ fieldTranslation: null,
149
+ listSubject: {},
150
+ dataUser: {}
151
+ };
152
+ var formSlice = createSlice3({
153
+ name: "form",
154
+ initialState: initialState3,
155
+ reducers: {
156
+ setViewDataStore: (state, action) => {
157
+ state.viewDataStore = action.payload;
158
+ },
159
+ setIsShowingModalDetail: (state, action) => {
160
+ state.isShowingModalDetail = action.payload;
161
+ },
162
+ setIsShowModalTranslate: (state, action) => {
163
+ state.isShowModalTranslate = action.payload;
164
+ },
165
+ setFormSubmitComponent: (state, action) => {
166
+ state.formSubmitComponent[action.payload.key] = action.payload.component;
167
+ },
168
+ setFieldTranslate: (state, action) => {
169
+ state.fieldTranslation = action.payload;
170
+ },
171
+ setListSubject: (state, action) => {
172
+ state.listSubject = action.payload;
173
+ },
174
+ setDataUser: (state, action) => {
175
+ state.dataUser = action.payload;
176
+ }
177
+ }
178
+ });
179
+ var {
180
+ setViewDataStore,
181
+ setIsShowingModalDetail,
182
+ setIsShowModalTranslate,
183
+ setFormSubmitComponent,
184
+ setFieldTranslate,
185
+ setListSubject,
186
+ setDataUser
187
+ } = formSlice.actions;
188
+ var form_slice_default = formSlice.reducer;
189
+
190
+ // src/store/reducers/list-slice/index.ts
191
+ import { createSlice as createSlice4 } from "@reduxjs/toolkit";
192
+ var initialState4 = {
193
+ pageLimit: 10,
194
+ fields: {},
195
+ order: "",
196
+ selectedRowKeys: [],
197
+ indexRowTableModal: -2,
198
+ footerGroupTable: {},
199
+ page: 0,
200
+ domainTable: []
201
+ };
202
+ var listSlice = createSlice4({
203
+ name: "list",
204
+ initialState: initialState4,
205
+ reducers: {
206
+ setPageLimit: (state, action) => {
207
+ state.pageLimit = action.payload;
208
+ },
209
+ setFields: (state, action) => {
210
+ state.fields = action.payload;
211
+ },
212
+ setOrder: (state, action) => {
213
+ state.order = action.payload;
214
+ },
215
+ setSelectedRowKeys: (state, action) => {
216
+ state.selectedRowKeys = action.payload;
217
+ },
218
+ setIndexRowTableModal: (state, action) => {
219
+ state.indexRowTableModal = action.payload;
220
+ },
221
+ setPage: (state, action) => {
222
+ state.page = action.payload;
223
+ },
224
+ setDomainTable: (state, action) => {
225
+ state.domainTable = action.payload;
226
+ }
227
+ }
228
+ });
229
+ var {
230
+ setPageLimit,
231
+ setFields,
232
+ setOrder,
233
+ setSelectedRowKeys,
234
+ setIndexRowTableModal,
235
+ setPage,
236
+ setDomainTable
237
+ } = listSlice.actions;
238
+ var list_slice_default = listSlice.reducer;
239
+
240
+ // src/store/reducers/navbar-slice/index.ts
241
+ import { createSlice as createSlice5 } from "@reduxjs/toolkit";
242
+ var initialState5 = {
243
+ menuList: []
244
+ };
245
+ var navbarSlice = createSlice5({
246
+ name: "navbar",
247
+ initialState: initialState5,
248
+ reducers: {
249
+ setMenuList: (state, action) => {
250
+ state.menuList = action.payload;
251
+ }
252
+ }
253
+ });
254
+ var { setMenuList } = navbarSlice.actions;
255
+ var navbar_slice_default = navbarSlice.reducer;
256
+
257
+ // src/store/reducers/profile-slice/index.ts
258
+ import { createSlice as createSlice6 } from "@reduxjs/toolkit";
259
+ var initialState6 = {
260
+ profile: {}
261
+ };
262
+ var profileSlice = createSlice6({
263
+ name: "profile",
264
+ initialState: initialState6,
265
+ reducers: {
266
+ setProfile: (state, action) => {
267
+ state.profile = action.payload;
268
+ }
269
+ }
270
+ });
271
+ var { setProfile } = profileSlice.actions;
272
+ var profile_slice_default = profileSlice.reducer;
273
+
274
+ // src/store/reducers/search-slice/index.ts
275
+ import { createSlice as createSlice7 } from "@reduxjs/toolkit";
276
+ var initialState7 = {
277
+ groupByDomain: null,
278
+ tableHead: [],
279
+ searchString: "",
280
+ hoveredIndexSearchList: null,
281
+ selectedTags: [],
282
+ firstDomain: null,
283
+ searchMap: {},
284
+ typeFieldsSearch: "",
285
+ modelSearch: "",
286
+ filterBy: [],
287
+ groupBy: []
288
+ };
289
+ var searchSlice = createSlice7({
290
+ name: "search",
291
+ initialState: initialState7,
292
+ reducers: {
293
+ setGroupByDomain: (state, action) => {
294
+ state.groupByDomain = action.payload;
295
+ },
296
+ setTableHead: (state, action) => {
297
+ state.tableHead = action.payload;
298
+ },
299
+ setSearchString: (state, action) => {
300
+ state.searchString = action.payload;
301
+ },
302
+ setHoveredIndexSearchList: (state, action) => {
303
+ state.hoveredIndexSearchList = action.payload;
304
+ },
305
+ setSelectedTags: (state, action) => {
306
+ state.selectedTags = action.payload;
307
+ },
308
+ setFirstDomain: (state, action) => {
309
+ state.firstDomain = action.payload;
310
+ },
311
+ setTypeFieldsSearch: (state, action) => {
312
+ state.typeFieldsSearch = action.payload;
313
+ },
314
+ setModelSearch: (state, action) => {
315
+ state.modelSearch = action.payload;
316
+ },
317
+ setFilterBy: (state, action) => {
318
+ state.filterBy = action.payload;
319
+ },
320
+ setGroupBy: (state, action) => {
321
+ state.groupBy = action.payload;
322
+ },
323
+ setSearchMap: (state, action) => {
324
+ state.searchMap = action.payload;
325
+ },
326
+ updateSearchMap: (state, action) => {
327
+ if (!state.searchMap[action.payload.key]) {
328
+ state.searchMap[action.payload.key] = [];
329
+ }
330
+ state.searchMap[action.payload.key].push(action.payload.value);
331
+ },
332
+ removeKeyFromSearchMap: (state, action) => {
333
+ const { key, item } = action.payload;
334
+ const values = state.searchMap[key];
335
+ if (!values) return;
336
+ if (item) {
337
+ const filtered = values.filter((value) => value.name !== item.name);
338
+ if (filtered.length > 0) {
339
+ state.searchMap[key] = filtered;
340
+ } else {
341
+ delete state.searchMap[key];
342
+ }
343
+ } else {
344
+ delete state.searchMap[key];
345
+ }
346
+ },
347
+ clearSearchMap: (state) => {
348
+ state.searchMap = {};
349
+ }
350
+ }
351
+ });
352
+ var {
353
+ setGroupByDomain,
354
+ setSelectedTags,
355
+ setSearchString,
356
+ setHoveredIndexSearchList,
357
+ setFirstDomain,
358
+ setTableHead,
359
+ setFilterBy,
360
+ setTypeFieldsSearch,
361
+ setModelSearch,
362
+ setSearchMap,
363
+ updateSearchMap,
364
+ removeKeyFromSearchMap,
365
+ setGroupBy,
366
+ clearSearchMap
367
+ } = searchSlice.actions;
368
+ var search_slice_default = searchSlice.reducer;
369
+
370
+ // src/store/store.ts
371
+ import { configureStore } from "@reduxjs/toolkit";
372
+
373
+ // node_modules/redux/dist/redux.mjs
374
+ function formatProdErrorMessage(code) {
375
+ 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. `;
376
+ }
377
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
378
+ var ActionTypes = {
379
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
380
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
381
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
382
+ };
383
+ var actionTypes_default = ActionTypes;
384
+ function isPlainObject(obj) {
385
+ if (typeof obj !== "object" || obj === null)
386
+ return false;
387
+ let proto = obj;
388
+ while (Object.getPrototypeOf(proto) !== null) {
389
+ proto = Object.getPrototypeOf(proto);
390
+ }
391
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
392
+ }
393
+ function miniKindOf(val) {
394
+ if (val === void 0)
395
+ return "undefined";
396
+ if (val === null)
397
+ return "null";
398
+ const type = typeof val;
399
+ switch (type) {
400
+ case "boolean":
401
+ case "string":
402
+ case "number":
403
+ case "symbol":
404
+ case "function": {
405
+ return type;
406
+ }
407
+ }
408
+ if (Array.isArray(val))
409
+ return "array";
410
+ if (isDate(val))
411
+ return "date";
412
+ if (isError(val))
413
+ return "error";
414
+ const constructorName = ctorName(val);
415
+ switch (constructorName) {
416
+ case "Symbol":
417
+ case "Promise":
418
+ case "WeakMap":
419
+ case "WeakSet":
420
+ case "Map":
421
+ case "Set":
422
+ return constructorName;
423
+ }
424
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
425
+ }
426
+ function ctorName(val) {
427
+ return typeof val.constructor === "function" ? val.constructor.name : null;
428
+ }
429
+ function isError(val) {
430
+ return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
431
+ }
432
+ function isDate(val) {
433
+ if (val instanceof Date)
434
+ return true;
435
+ return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
436
+ }
437
+ function kindOf(val) {
438
+ let typeOfVal = typeof val;
439
+ if (process.env.NODE_ENV !== "production") {
440
+ typeOfVal = miniKindOf(val);
441
+ }
442
+ return typeOfVal;
443
+ }
444
+ function warning(message) {
445
+ if (typeof console !== "undefined" && typeof console.error === "function") {
446
+ console.error(message);
447
+ }
448
+ try {
449
+ throw new Error(message);
450
+ } catch (e) {
451
+ }
452
+ }
453
+ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
454
+ const reducerKeys = Object.keys(reducers);
455
+ const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
456
+ if (reducerKeys.length === 0) {
457
+ return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
458
+ }
459
+ if (!isPlainObject(inputState)) {
460
+ return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
461
+ }
462
+ const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
463
+ unexpectedKeys.forEach((key) => {
464
+ unexpectedKeyCache[key] = true;
465
+ });
466
+ if (action && action.type === actionTypes_default.REPLACE)
467
+ return;
468
+ if (unexpectedKeys.length > 0) {
469
+ 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.`;
470
+ }
471
+ }
472
+ function assertReducerShape(reducers) {
473
+ Object.keys(reducers).forEach((key) => {
474
+ const reducer = reducers[key];
475
+ const initialState8 = reducer(void 0, {
476
+ type: actionTypes_default.INIT
477
+ });
478
+ if (typeof initialState8 === "undefined") {
479
+ 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.`);
480
+ }
481
+ if (typeof reducer(void 0, {
482
+ type: actionTypes_default.PROBE_UNKNOWN_ACTION()
483
+ }) === "undefined") {
484
+ 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.`);
485
+ }
486
+ });
487
+ }
488
+ function combineReducers(reducers) {
489
+ const reducerKeys = Object.keys(reducers);
490
+ const finalReducers = {};
491
+ for (let i = 0; i < reducerKeys.length; i++) {
492
+ const key = reducerKeys[i];
493
+ if (process.env.NODE_ENV !== "production") {
494
+ if (typeof reducers[key] === "undefined") {
495
+ warning(`No reducer provided for key "${key}"`);
496
+ }
497
+ }
498
+ if (typeof reducers[key] === "function") {
499
+ finalReducers[key] = reducers[key];
500
+ }
501
+ }
502
+ const finalReducerKeys = Object.keys(finalReducers);
503
+ let unexpectedKeyCache;
504
+ if (process.env.NODE_ENV !== "production") {
505
+ unexpectedKeyCache = {};
506
+ }
507
+ let shapeAssertionError;
508
+ try {
509
+ assertReducerShape(finalReducers);
510
+ } catch (e) {
511
+ shapeAssertionError = e;
512
+ }
513
+ return function combination(state = {}, action) {
514
+ if (shapeAssertionError) {
515
+ throw shapeAssertionError;
516
+ }
517
+ if (process.env.NODE_ENV !== "production") {
518
+ const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
519
+ if (warningMessage) {
520
+ warning(warningMessage);
521
+ }
522
+ }
523
+ let hasChanged = false;
524
+ const nextState = {};
525
+ for (let i = 0; i < finalReducerKeys.length; i++) {
526
+ const key = finalReducerKeys[i];
527
+ const reducer = finalReducers[key];
528
+ const previousStateForKey = state[key];
529
+ const nextStateForKey = reducer(previousStateForKey, action);
530
+ if (typeof nextStateForKey === "undefined") {
531
+ const actionType = action && action.type;
532
+ 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.`);
533
+ }
534
+ nextState[key] = nextStateForKey;
535
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
536
+ }
537
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
538
+ return hasChanged ? nextState : state;
539
+ };
540
+ }
541
+
542
+ // src/store/store.ts
543
+ var rootReducer = combineReducers({
544
+ env: env_slice_default,
545
+ navbar: navbar_slice_default,
546
+ list: list_slice_default,
547
+ search: search_slice_default,
548
+ form: form_slice_default,
549
+ excel: excel_slice_default,
550
+ profile: profile_slice_default
551
+ });
552
+ var envStore = configureStore({
553
+ reducer: rootReducer,
554
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
555
+ serializableCheck: false
556
+ })
557
+ });
558
+
559
+ // src/config/axios-client.ts
560
+ import axios from "axios";
561
+ var MAINT_KEY = "MAINTENANCE_ACTIVE";
562
+ var MAINT_AT = "MAINTENANCE_AT";
563
+ var MAINT_LAST_PATH = "MAINTENANCE_LAST_PATH";
564
+ var hasRedirectedToMaintenance = false;
565
+ function setMaintenanceFlags() {
566
+ if (typeof window === "undefined") return;
567
+ const { pathname, search } = window.location;
568
+ const lastPath = pathname + (search || "");
569
+ if (pathname !== "/maintenance" && !window.localStorage.getItem(MAINT_LAST_PATH)) {
570
+ window.localStorage.setItem(MAINT_LAST_PATH, lastPath);
571
+ }
572
+ window.localStorage.setItem(MAINT_KEY, "true");
573
+ window.localStorage.setItem(MAINT_AT, String(Date.now()));
574
+ }
575
+ async function clearMaintenanceAndExit(getToken, opts) {
576
+ if (typeof window === "undefined") return;
577
+ const forceLogin = opts?.forceLogin === true;
578
+ const clearTokenOnForce = opts?.clearTokenOnForce !== false;
579
+ window.localStorage.removeItem(MAINT_KEY);
580
+ window.localStorage.removeItem(MAINT_AT);
581
+ const lastPath = window.localStorage.getItem(MAINT_LAST_PATH);
582
+ window.localStorage.removeItem(MAINT_LAST_PATH);
583
+ try {
584
+ if (forceLogin) {
585
+ if (clearTokenOnForce) {
586
+ try {
587
+ await opts?.clearToken?.();
588
+ } catch {
589
+ }
590
+ }
591
+ window.location.replace("/login");
592
+ return;
593
+ }
594
+ const token = await getToken();
595
+ if (token) {
596
+ const target = lastPath && lastPath !== "/maintenance" ? lastPath : "/";
597
+ window.location.replace(target);
598
+ } else {
599
+ window.location.replace("/login");
600
+ }
601
+ } catch {
602
+ window.location.replace("/login");
603
+ }
604
+ }
605
+ var axiosClient = {
606
+ init(config) {
607
+ const localStorage = config.localStorageUtils;
608
+ const sessionStorage = config.sessionStorageUtils;
609
+ const db = config.db;
610
+ let isRefreshing = false;
611
+ let failedQueue = [];
612
+ const processQueue = (error, token = null) => {
613
+ failedQueue?.forEach((prom) => {
614
+ if (error) {
615
+ prom.reject(error);
616
+ } else {
617
+ prom.resolve(token);
618
+ }
619
+ });
620
+ failedQueue = [];
621
+ };
622
+ const instance = axios.create({
623
+ adapter: axios.defaults.adapter,
624
+ baseURL: config.baseUrl,
625
+ timeout: 5e4,
626
+ paramsSerializer: (params) => new URLSearchParams(params).toString()
627
+ });
628
+ if (typeof window !== "undefined") {
629
+ const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
630
+ const onMaintenancePage = window.location.pathname === "/maintenance";
631
+ if (isMaint && !onMaintenancePage) {
632
+ hasRedirectedToMaintenance = true;
633
+ window.location.replace("/maintenance");
634
+ }
635
+ if (isMaint && onMaintenancePage) {
636
+ const healthUrl = config.healthUrl || `${(config.baseUrl || "").replace(/\/+$/, "")}/health`;
637
+ (async () => {
638
+ try {
639
+ await axios.get(healthUrl, { timeout: 8e3 });
640
+ await clearMaintenanceAndExit(() => localStorage.getAccessToken(), {
641
+ forceLogin: true,
642
+ clearTokenOnForce: true,
643
+ clearToken: () => localStorage.clearToken()
644
+ });
645
+ } catch {
646
+ }
647
+ })();
648
+ }
649
+ }
650
+ instance.interceptors.request.use(
651
+ async (configReq) => {
652
+ const token = await localStorage.getAccessToken();
653
+ if (token) {
654
+ configReq.headers["Authorization"] = "Bearer " + token;
655
+ }
656
+ return configReq;
657
+ },
658
+ (error) => Promise.reject(error)
659
+ );
660
+ instance.interceptors.response.use(
661
+ (response) => {
662
+ if (typeof window !== "undefined") {
663
+ const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
664
+ const onMaintenancePage = window.location.pathname === "/maintenance";
665
+ if (isMaint && onMaintenancePage) {
666
+ ;
667
+ (async () => {
668
+ await clearMaintenanceAndExit(
669
+ () => localStorage.getAccessToken(),
670
+ {
671
+ forceLogin: true,
672
+ clearTokenOnForce: true,
673
+ clearToken: () => localStorage.clearToken()
674
+ }
675
+ );
676
+ })();
677
+ } else if (isMaint) {
678
+ window.localStorage.removeItem(MAINT_KEY);
679
+ window.localStorage.removeItem(MAINT_AT);
680
+ window.localStorage.removeItem(MAINT_LAST_PATH);
681
+ }
682
+ }
683
+ return handleResponse(response);
684
+ },
685
+ async (error) => {
686
+ const status = error?.response?.status;
687
+ if (status === 503) {
688
+ if (typeof window !== "undefined") {
689
+ setMaintenanceFlags();
690
+ if (!hasRedirectedToMaintenance && window.location.pathname !== "/maintenance") {
691
+ hasRedirectedToMaintenance = true;
692
+ window.location.replace("/maintenance");
693
+ }
694
+ }
695
+ return Promise.reject({
696
+ code: 503,
697
+ message: "SERVICE_UNAVAILABLE",
698
+ original: error?.response?.data
699
+ });
700
+ }
701
+ const handleError = async (err) => {
702
+ if (!err.response) {
703
+ return err;
704
+ }
705
+ const { data } = err.response;
706
+ if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
707
+ await clearAuthToken();
708
+ }
709
+ return data;
710
+ };
711
+ const originalRequest = error.config;
712
+ if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
713
+ error.response.data.code
714
+ )) {
715
+ if (isRefreshing) {
716
+ return new Promise(function(resolve, reject) {
717
+ failedQueue.push({ resolve, reject });
718
+ }).then((token) => {
719
+ originalRequest.headers["Authorization"] = "Bearer " + token;
720
+ return instance.request(originalRequest);
721
+ }).catch(async (err) => {
722
+ if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
723
+ await clearAuthToken();
724
+ }
725
+ });
726
+ }
727
+ const browserSession = await sessionStorage.getBrowserSession();
728
+ const refreshToken = await localStorage.getRefreshToken();
729
+ const accessTokenExp = await localStorage.getAccessToken();
730
+ isRefreshing = true;
731
+ if (!refreshToken && (!browserSession || browserSession == "unActive")) {
732
+ await clearAuthToken();
733
+ } else {
734
+ const payload = Object.fromEntries(
735
+ Object.entries({
736
+ refresh_token: refreshToken,
737
+ grant_type: "refresh_token",
738
+ client_id: config.config.clientId,
739
+ client_secret: config.config.clientSecret
740
+ }).filter(([_, value]) => !!value)
741
+ );
742
+ return new Promise(function(resolve) {
743
+ axios.post(
744
+ `${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
745
+ payload,
746
+ {
747
+ headers: {
748
+ "Content-Type": "multipart/form-data",
749
+ Authorization: `Bearer ${accessTokenExp}`
750
+ }
751
+ }
752
+ ).then(async (res) => {
753
+ const data = res.data;
754
+ await localStorage.setToken(data.access_token);
755
+ await localStorage.setRefreshToken(data.refresh_token);
756
+ axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
757
+ originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
758
+ processQueue(null, data.access_token);
759
+ resolve(instance.request(originalRequest));
760
+ }).catch(async (err) => {
761
+ if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
762
+ await clearAuthToken();
763
+ }
764
+ if (err && err.response) {
765
+ const { error_code } = err.response?.data || {};
766
+ if (error_code === "AUTHEN_FAIL") {
767
+ await clearAuthToken();
768
+ }
769
+ }
770
+ processQueue(err, null);
771
+ }).finally(() => {
772
+ isRefreshing = false;
773
+ });
774
+ });
775
+ }
776
+ }
777
+ return Promise.reject(await handleError(error));
778
+ }
779
+ );
780
+ const handleResponse = (res) => {
781
+ if (res && res.data) {
782
+ return res.data;
783
+ }
784
+ return res;
785
+ };
786
+ const clearAuthToken = async () => {
787
+ await localStorage.clearToken();
788
+ if (typeof window !== "undefined") {
789
+ window.location.href = `/login`;
790
+ }
791
+ };
792
+ function formatUrl(url, db2) {
793
+ return url + (db2 ? "?db=" + db2 : "");
794
+ }
795
+ const responseBody = (response) => response;
796
+ const requests = {
797
+ get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
798
+ post: (url, body, headers) => instance.post(formatUrl(url, db), body, { headers }).then(responseBody),
799
+ post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
800
+ responseType: "arraybuffer",
801
+ headers: {
802
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
803
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
804
+ }
805
+ }).then(responseBody),
806
+ put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
807
+ patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
808
+ delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
809
+ };
810
+ return requests;
811
+ }
812
+ };
813
+
814
+ // src/environment/EnvStore.ts
815
+ var EnvStore = class {
816
+ envStore;
817
+ baseUrl;
818
+ requests;
819
+ context;
820
+ defaultCompany;
821
+ config;
822
+ companies;
823
+ user;
824
+ db;
825
+ localStorageUtils;
826
+ sessionStorageUtils;
827
+ constructor(envStore2, localStorageUtils, sessionStorageUtils) {
828
+ this.envStore = envStore2;
829
+ this.localStorageUtils = localStorageUtils;
830
+ this.sessionStorageUtils = sessionStorageUtils;
831
+ this.setup();
832
+ }
833
+ setup() {
834
+ const env2 = this.envStore.getState().env;
835
+ this.baseUrl = env2?.baseUrl;
836
+ this.requests = env2?.requests;
837
+ this.context = env2?.context;
838
+ this.defaultCompany = env2?.defaultCompany;
839
+ this.config = env2?.config;
840
+ this.companies = env2?.companies || [];
841
+ this.user = env2?.user;
842
+ this.db = env2?.db;
843
+ }
844
+ setupEnv(envConfig) {
845
+ const dispatch = this.envStore.dispatch;
846
+ const env2 = {
847
+ ...envConfig,
848
+ localStorageUtils: this.localStorageUtils,
849
+ sessionStorageUtils: this.sessionStorageUtils
850
+ };
851
+ const requests = axiosClient.init(env2);
852
+ dispatch(setEnv({ ...env2, requests }));
853
+ this.setup();
854
+ }
855
+ setUid(uid) {
856
+ const dispatch = this.envStore.dispatch;
857
+ dispatch(setUid(uid));
858
+ this.setup();
859
+ }
860
+ setLang(lang) {
861
+ const dispatch = this.envStore.dispatch;
862
+ dispatch(setLang(lang));
863
+ this.setup();
864
+ }
865
+ setAllowCompanies(allowCompanies) {
866
+ const dispatch = this.envStore.dispatch;
867
+ dispatch(setAllowCompanies(allowCompanies));
868
+ this.setup();
869
+ }
870
+ setCompanies(companies) {
871
+ const dispatch = this.envStore.dispatch;
872
+ dispatch(setCompanies(companies));
873
+ this.setup();
874
+ }
875
+ setDefaultCompany(company) {
876
+ const dispatch = this.envStore.dispatch;
877
+ dispatch(setDefaultCompany(company));
878
+ this.setup();
879
+ }
880
+ setUserInfo(userInfo) {
881
+ const dispatch = this.envStore.dispatch;
882
+ dispatch(setUser(userInfo));
883
+ this.setup();
884
+ }
885
+ };
886
+ var env = null;
887
+ function getEnv() {
888
+ if (!env) env = new EnvStore(envStore);
889
+ return env;
890
+ }
891
+
892
+ // src/utils/domain/py_tokenizer.ts
893
+ var TokenizerError = class extends Error {
894
+ };
895
+ var directMap = {
896
+ "\\": "\\",
897
+ '"': '"',
898
+ "'": "'",
899
+ a: "\x07",
900
+ b: "\b",
901
+ f: "\f",
902
+ n: "\n",
903
+ r: "\r",
904
+ t: " ",
905
+ v: "\v"
906
+ };
907
+ function decodeStringLiteral(str, unicode) {
908
+ const out = [];
909
+ let code;
910
+ for (let i = 0; i < str.length; ++i) {
911
+ if (str[i] !== "\\") {
912
+ out.push(str[i]);
913
+ continue;
914
+ }
915
+ const escape = str[i + 1];
916
+ if (escape in directMap) {
917
+ out.push(directMap[escape]);
918
+ ++i;
919
+ continue;
920
+ }
921
+ switch (escape) {
922
+ case "\n":
923
+ ++i;
924
+ continue;
925
+ case "N":
926
+ if (!unicode) {
927
+ break;
928
+ }
929
+ throw new TokenizerError("SyntaxError: \\N{} escape not implemented");
930
+ case "u":
931
+ if (!unicode) {
932
+ break;
933
+ }
934
+ const uni = str.slice(i + 2, i + 6);
935
+ if (!/[0-9a-f]{4}/i.test(uni)) {
936
+ throw new TokenizerError(
937
+ [
938
+ "SyntaxError: (unicode error) 'unicodeescape' codec",
939
+ " can't decode bytes in position ",
940
+ i,
941
+ "-",
942
+ i + 4,
943
+ ": truncated \\uXXXX escape"
944
+ ].join("")
945
+ );
946
+ }
947
+ code = parseInt(uni, 16);
948
+ out.push(String.fromCharCode(code));
949
+ i += 5;
950
+ continue;
951
+ case "U":
952
+ if (!unicode) {
953
+ break;
954
+ }
955
+ throw new TokenizerError("SyntaxError: \\U escape not implemented");
956
+ case "x":
957
+ const hex = str.slice(i + 2, i + 4);
958
+ if (!/[0-9a-f]{2}/i.test(hex)) {
959
+ if (!unicode) {
960
+ throw new TokenizerError("ValueError: invalid \\x escape");
961
+ }
962
+ throw new TokenizerError(
963
+ [
964
+ "SyntaxError: (unicode error) 'unicodeescape'",
965
+ " codec can't decode bytes in position ",
966
+ i,
967
+ "-",
968
+ i + 2,
969
+ ": truncated \\xXX escape"
970
+ ].join("")
971
+ );
972
+ }
973
+ code = parseInt(hex, 16);
974
+ out.push(String.fromCharCode(code));
975
+ i += 3;
976
+ continue;
977
+ default:
978
+ if (!/[0-8]/.test(escape)) {
979
+ break;
980
+ }
981
+ const r = /[0-8]{1,3}/g;
982
+ r.lastIndex = i + 1;
983
+ const m = r.exec(str);
984
+ if (!m) break;
985
+ const oct = m[0];
986
+ code = parseInt(oct, 8);
987
+ out.push(String.fromCharCode(code));
988
+ i += oct.length;
989
+ continue;
990
+ }
991
+ out.push("\\");
992
+ }
993
+ return out.join("");
994
+ }
995
+ var constants = /* @__PURE__ */ new Set(["None", "False", "True"]);
996
+ var comparators = [
997
+ "in",
998
+ "not",
999
+ "not in",
1000
+ "is",
1001
+ "is not",
1002
+ "<",
1003
+ "<=",
1004
+ ">",
1005
+ ">=",
1006
+ "<>",
1007
+ "!=",
1008
+ "=="
1009
+ ];
1010
+ var binaryOperators = [
1011
+ "or",
1012
+ "and",
1013
+ "|",
1014
+ "^",
1015
+ "&",
1016
+ "<<",
1017
+ ">>",
1018
+ "+",
1019
+ "-",
1020
+ "*",
1021
+ "/",
1022
+ "//",
1023
+ "%",
1024
+ "~",
1025
+ "**",
1026
+ "."
1027
+ ];
1028
+ var unaryOperators = ["-"];
1029
+ var symbols = /* @__PURE__ */ new Set([
1030
+ ...["(", ")", "[", "]", "{", "}", ":", ","],
1031
+ ...["if", "else", "lambda", "="],
1032
+ ...comparators,
1033
+ ...binaryOperators,
1034
+ ...unaryOperators
1035
+ ]);
1036
+ function group(...args) {
1037
+ return "(" + args.join("|") + ")";
1038
+ }
1039
+ var Name = "[a-zA-Z_]\\w*";
1040
+ var Whitespace = "[ \\f\\t]*";
1041
+ var DecNumber = "\\d+(L|l)?";
1042
+ var IntNumber = DecNumber;
1043
+ var Exponent = "[eE][+-]?\\d+";
1044
+ var PointFloat = group(`\\d+\\.\\d*(${Exponent})?`, `\\.\\d+(${Exponent})?`);
1045
+ var FloatNumber = group(PointFloat, `\\d+${Exponent}`);
1046
+ var Number2 = group(FloatNumber, IntNumber);
1047
+ var Operator = group(
1048
+ "\\*\\*=?",
1049
+ ">>=?",
1050
+ "<<=?",
1051
+ "<>",
1052
+ "!=",
1053
+ "//=?",
1054
+ "[+\\-*/%&|^=<>]=?",
1055
+ "~"
1056
+ );
1057
+ var Bracket = "[\\[\\]\\(\\)\\{\\}]";
1058
+ var Special = "[:;.,`@]";
1059
+ var Funny = group(Operator, Bracket, Special);
1060
+ var ContStr = group(
1061
+ "([uU])?'([^\\n'\\\\]*(?:\\\\.[^\\n'\\\\]*)*)'",
1062
+ '([uU])?"([^\\n"\\\\]*(?:\\\\.[^\\n"\\\\]*)*)"'
1063
+ );
1064
+ var PseudoToken = Whitespace + group(Number2, Funny, ContStr, Name);
1065
+ var NumberPattern = new RegExp("^" + Number2 + "$");
1066
+ var StringPattern = new RegExp("^" + ContStr + "$");
1067
+ var NamePattern = new RegExp("^" + Name + "$");
1068
+ var strip = new RegExp("^" + Whitespace);
1069
+ function tokenize(str) {
1070
+ const tokens = [];
1071
+ const max = str.length;
1072
+ let start = 0;
1073
+ let end = 0;
1074
+ const pseudoprog = new RegExp(PseudoToken, "g");
1075
+ while (pseudoprog.lastIndex < max) {
1076
+ const pseudomatch = pseudoprog.exec(str);
1077
+ if (!pseudomatch) {
1078
+ if (/^\s+$/.test(str.slice(end))) {
1079
+ break;
1080
+ }
1081
+ throw new TokenizerError(
1082
+ "Failed to tokenize <<" + str + ">> at index " + (end || 0) + "; parsed so far: " + tokens
1083
+ );
1084
+ }
1085
+ if (pseudomatch.index > end) {
1086
+ if (str.slice(end, pseudomatch.index).trim()) {
1087
+ throw new TokenizerError("Invalid expression");
1088
+ }
1089
+ }
1090
+ start = pseudomatch.index;
1091
+ end = pseudoprog.lastIndex;
1092
+ let token = str.slice(start, end).replace(strip, "");
1093
+ if (NumberPattern.test(token)) {
1094
+ tokens.push({
1095
+ type: 0,
1096
+ value: parseFloat(token)
1097
+ });
1098
+ } else if (StringPattern.test(token)) {
1099
+ const m = StringPattern.exec(token);
1100
+ if (!m) throw new TokenizerError("Invalid string match");
1101
+ tokens.push({
1102
+ type: 1,
1103
+ value: decodeStringLiteral(
1104
+ m[3] !== void 0 ? m[3] : m[5],
1105
+ !!(m[2] || m[4])
1106
+ )
1107
+ });
1108
+ } else if (symbols.has(token)) {
1109
+ if (token === "in" && tokens.length > 0 && tokens[tokens.length - 1].value === "not") {
1110
+ token = "not in";
1111
+ tokens.pop();
1112
+ } else if (token === "not" && tokens.length > 0 && tokens[tokens.length - 1].value === "is") {
1113
+ token = "is not";
1114
+ tokens.pop();
1115
+ }
1116
+ tokens.push({
1117
+ type: 2,
1118
+ value: token
1119
+ });
1120
+ } else if (constants.has(token)) {
1121
+ tokens.push({
1122
+ type: 4,
1123
+ value: token
1124
+ });
1125
+ } else if (NamePattern.test(token)) {
1126
+ tokens.push({
1127
+ type: 3,
1128
+ value: token
1129
+ });
1130
+ } else {
1131
+ throw new TokenizerError("Invalid expression");
1132
+ }
1133
+ }
1134
+ return tokens;
1135
+ }
1136
+
1137
+ // src/utils/domain/py_parser.ts
1138
+ var ParserError = class extends Error {
1139
+ };
1140
+ var chainedOperators = new Set(comparators);
1141
+ var infixOperators = /* @__PURE__ */ new Set([...binaryOperators, ...comparators]);
1142
+ function bp(symbol) {
1143
+ switch (symbol) {
1144
+ case "=":
1145
+ return 10;
1146
+ case "if":
1147
+ return 20;
1148
+ case "in":
1149
+ case "not in":
1150
+ case "is":
1151
+ case "is not":
1152
+ case "<":
1153
+ case "<=":
1154
+ case ">":
1155
+ case ">=":
1156
+ case "<>":
1157
+ case "==":
1158
+ case "!=":
1159
+ return 60;
1160
+ case "or":
1161
+ return 30;
1162
+ case "and":
1163
+ return 40;
1164
+ case "not":
1165
+ return 50;
1166
+ case "|":
1167
+ return 70;
1168
+ case "^":
1169
+ return 80;
1170
+ case "&":
1171
+ return 90;
1172
+ case "<<":
1173
+ case ">>":
1174
+ return 100;
1175
+ case "+":
1176
+ case "-":
1177
+ return 110;
1178
+ case "*":
1179
+ case "/":
1180
+ case "//":
1181
+ case "%":
1182
+ return 120;
1183
+ case "**":
1184
+ return 140;
1185
+ case ".":
1186
+ case "(":
1187
+ case "[":
1188
+ return 150;
1189
+ default:
1190
+ return 0;
1191
+ }
1192
+ }
1193
+ function bindingPower(token) {
1194
+ return token.type === 2 ? bp(token.value) : 0;
1195
+ }
1196
+ function isSymbol(token, value) {
1197
+ return token.type === 2 && token.value === value;
1198
+ }
1199
+ function parsePrefix(current, tokens) {
1200
+ switch (current.type) {
1201
+ case 0:
1202
+ return { type: 0, value: current.value };
1203
+ case 1:
1204
+ return { type: 1, value: current.value };
1205
+ case 4:
1206
+ if (current.value === "None") {
1207
+ return {
1208
+ type: 3
1209
+ /* None */
1210
+ };
1211
+ } else {
1212
+ return { type: 2, value: current.value === "True" };
1213
+ }
1214
+ case 3:
1215
+ return { type: 5, value: current.value };
1216
+ case 2:
1217
+ switch (current.value) {
1218
+ case "-":
1219
+ case "+":
1220
+ case "~":
1221
+ return {
1222
+ type: 6,
1223
+ op: current.value,
1224
+ right: _parse(tokens, 130)
1225
+ };
1226
+ case "not":
1227
+ return {
1228
+ type: 6,
1229
+ op: current.value,
1230
+ right: _parse(tokens, 50)
1231
+ };
1232
+ case "(":
1233
+ const content = [];
1234
+ let isTuple = false;
1235
+ while (tokens[0] && !isSymbol(tokens[0], ")")) {
1236
+ content.push(_parse(tokens, 0));
1237
+ if (tokens[0]) {
1238
+ if (tokens[0] && isSymbol(tokens[0], ",")) {
1239
+ isTuple = true;
1240
+ tokens.shift();
1241
+ } else if (!isSymbol(tokens[0], ")")) {
1242
+ throw new ParserError("parsing error");
1243
+ }
1244
+ } else {
1245
+ throw new ParserError("parsing error");
1246
+ }
1247
+ }
1248
+ if (!tokens[0] || !isSymbol(tokens[0], ")")) {
1249
+ throw new ParserError("parsing error");
1250
+ }
1251
+ tokens.shift();
1252
+ isTuple = isTuple || content.length === 0;
1253
+ return isTuple ? { type: 10, value: content } : content[0];
1254
+ case "[":
1255
+ const value = [];
1256
+ while (tokens[0] && !isSymbol(tokens[0], "]")) {
1257
+ value.push(_parse(tokens, 0));
1258
+ if (tokens[0]) {
1259
+ if (isSymbol(tokens[0], ",")) {
1260
+ tokens.shift();
1261
+ } else if (!isSymbol(tokens[0], "]")) {
1262
+ throw new ParserError("parsing error");
1263
+ }
1264
+ }
1265
+ }
1266
+ if (!tokens[0] || !isSymbol(tokens[0], "]")) {
1267
+ throw new ParserError("parsing error");
1268
+ }
1269
+ tokens.shift();
1270
+ return { type: 4, value };
1271
+ case "{":
1272
+ const dict = {};
1273
+ while (tokens[0] && !isSymbol(tokens[0], "}")) {
1274
+ const key = _parse(tokens, 0);
1275
+ if (key.type !== 1 && key.type !== 0 || !tokens[0] || !isSymbol(tokens[0], ":")) {
1276
+ throw new ParserError("parsing error");
1277
+ }
1278
+ tokens.shift();
1279
+ const val = _parse(tokens, 0);
1280
+ dict[key.value] = val;
1281
+ if (isSymbol(tokens[0], ",")) {
1282
+ tokens.shift();
1283
+ }
1284
+ }
1285
+ if (!tokens.shift()) {
1286
+ throw new ParserError("parsing error");
1287
+ }
1288
+ return { type: 11, value: dict };
1289
+ default:
1290
+ throw new ParserError("Token cannot be parsed");
1291
+ }
1292
+ default:
1293
+ throw new ParserError("Token cannot be parsed");
1294
+ }
1295
+ }
1296
+ function parseInfix(left, current, tokens) {
1297
+ switch (current.type) {
1298
+ case 2:
1299
+ if (infixOperators.has(current.value)) {
1300
+ let right = _parse(tokens, bindingPower(current));
1301
+ if (current.value === "and" || current.value === "or") {
1302
+ return {
1303
+ type: 14,
1304
+ op: current.value,
1305
+ left,
1306
+ right
1307
+ };
1308
+ } else if (current.value === ".") {
1309
+ if (right.type === 5) {
1310
+ return {
1311
+ type: 15,
1312
+ obj: left,
1313
+ key: right.value
1314
+ };
1315
+ } else {
1316
+ throw new ParserError("invalid obj lookup");
1317
+ }
1318
+ }
1319
+ let op = {
1320
+ type: 7,
1321
+ op: current.value,
1322
+ left,
1323
+ right
1324
+ };
1325
+ while (chainedOperators.has(current.value) && tokens[0] && tokens[0].type === 2 && chainedOperators.has(tokens[0].value)) {
1326
+ const nextToken = tokens.shift();
1327
+ op = {
1328
+ type: 14,
1329
+ op: "and",
1330
+ left: op,
1331
+ right: {
1332
+ type: 7,
1333
+ op: nextToken.value,
1334
+ left: right,
1335
+ right: _parse(tokens, bindingPower(nextToken))
1336
+ }
1337
+ };
1338
+ right = op.right;
1339
+ }
1340
+ return op;
1341
+ }
1342
+ switch (current.value) {
1343
+ case "(":
1344
+ const args = [];
1345
+ const kwargs = {};
1346
+ while (tokens[0] && !isSymbol(tokens[0], ")")) {
1347
+ const arg = _parse(tokens, 0);
1348
+ if (arg.type === 9) {
1349
+ kwargs[arg.name.value] = arg.value;
1350
+ } else {
1351
+ args.push(arg);
1352
+ }
1353
+ if (tokens[0] && isSymbol(tokens[0], ",")) {
1354
+ tokens.shift();
1355
+ }
1356
+ }
1357
+ if (!tokens[0] || !isSymbol(tokens[0], ")")) {
1358
+ throw new ParserError("parsing error");
1359
+ }
1360
+ tokens.shift();
1361
+ return { type: 8, fn: left, args, kwargs };
1362
+ case "=":
1363
+ if (left.type === 5) {
1364
+ return {
1365
+ type: 9,
1366
+ name: left,
1367
+ value: _parse(tokens, 10)
1368
+ };
1369
+ }
1370
+ break;
1371
+ case "[":
1372
+ const key = _parse(tokens);
1373
+ if (!tokens[0] || !isSymbol(tokens[0], "]")) {
1374
+ throw new ParserError("parsing error");
1375
+ }
1376
+ tokens.shift();
1377
+ return {
1378
+ type: 12,
1379
+ target: left,
1380
+ key
1381
+ };
1382
+ case "if":
1383
+ const condition = _parse(tokens);
1384
+ if (!tokens[0] || !isSymbol(tokens[0], "else")) {
1385
+ throw new ParserError("parsing error");
1386
+ }
1387
+ tokens.shift();
1388
+ const ifFalse = _parse(tokens);
1389
+ return {
1390
+ type: 13,
1391
+ condition,
1392
+ ifTrue: left,
1393
+ ifFalse
1394
+ };
1395
+ default:
1396
+ break;
1397
+ }
1398
+ }
1399
+ throw new ParserError("Token cannot be parsed");
1400
+ }
1401
+ function _parse(tokens, bp2 = 0) {
1402
+ const token = tokens.shift();
1403
+ if (!token) {
1404
+ throw new ParserError("Unexpected end of input");
1405
+ }
1406
+ let expr = parsePrefix(token, tokens);
1407
+ while (tokens[0] && bindingPower(tokens[0]) > bp2) {
1408
+ expr = parseInfix(expr, tokens.shift(), tokens);
1409
+ }
1410
+ return expr;
1411
+ }
1412
+ function parse(tokens) {
1413
+ if (tokens.length) {
1414
+ return _parse(tokens, 0);
1415
+ }
1416
+ throw new ParserError("Missing token");
1417
+ }
1418
+ function parseArgs(args, spec) {
1419
+ const last = args[args.length - 1];
1420
+ const unnamedArgs = typeof last === "object" ? args.slice(0, -1) : args;
1421
+ const kwargs = typeof last === "object" ? last : {};
1422
+ for (const [index, val] of unnamedArgs.entries()) {
1423
+ kwargs[spec[index]] = val;
1424
+ }
1425
+ return kwargs;
1426
+ }
1427
+
1428
+ // src/utils/domain/py_date.ts
1429
+ var AssertionError = class extends Error {
1430
+ };
1431
+ var ValueError = class extends Error {
1432
+ };
1433
+ var NotSupportedError = class extends Error {
1434
+ };
1435
+ function fmt2(n) {
1436
+ return String(n).padStart(2, "0");
1437
+ }
1438
+ function fmt4(n) {
1439
+ return String(n).padStart(4, "0");
1440
+ }
1441
+ function divmod(a, b, fn) {
1442
+ let mod = a % b;
1443
+ if (mod > 0 && b < 0 || mod < 0 && b > 0) {
1444
+ mod += b;
1445
+ }
1446
+ return fn(Math.floor(a / b), mod);
1447
+ }
1448
+ function assert(bool, message = "AssertionError") {
1449
+ if (!bool) {
1450
+ throw new AssertionError(message);
1451
+ }
1452
+ }
1453
+ var DAYS_IN_MONTH = [
1454
+ null,
1455
+ 31,
1456
+ 28,
1457
+ 31,
1458
+ 30,
1459
+ 31,
1460
+ 30,
1461
+ 31,
1462
+ 31,
1463
+ 30,
1464
+ 31,
1465
+ 30,
1466
+ 31
1467
+ ];
1468
+ var DAYS_BEFORE_MONTH = [null];
1469
+ for (let dbm = 0, i = 1; i < DAYS_IN_MONTH.length; ++i) {
1470
+ DAYS_BEFORE_MONTH.push(dbm);
1471
+ dbm += DAYS_IN_MONTH[i];
1472
+ }
1473
+ function daysInMonth(year, month) {
1474
+ if (month === 2 && isLeap(year)) {
1475
+ return 29;
1476
+ }
1477
+ return DAYS_IN_MONTH[month];
1478
+ }
1479
+ function isLeap(year) {
1480
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
1481
+ }
1482
+ function daysBeforeYear(year) {
1483
+ const y = year - 1;
1484
+ return y * 365 + Math.floor(y / 4) - Math.floor(y / 100) + Math.floor(y / 400);
1485
+ }
1486
+ function daysBeforeMonth(year, month) {
1487
+ const postLeapFeb = month > 2 && isLeap(year);
1488
+ return DAYS_BEFORE_MONTH[month] + (postLeapFeb ? 1 : 0);
1489
+ }
1490
+ function ymd2ord(year, month, day) {
1491
+ const dim = daysInMonth(year, month);
1492
+ if (!(1 <= day && day <= dim)) {
1493
+ throw new ValueError(`day must be in 1..${dim}`);
1494
+ }
1495
+ return daysBeforeYear(year) + daysBeforeMonth(year, month) + day;
1496
+ }
1497
+ var DI400Y = daysBeforeYear(401);
1498
+ var DI100Y = daysBeforeYear(101);
1499
+ var DI4Y = daysBeforeYear(5);
1500
+ function ord2ymd(n) {
1501
+ --n;
1502
+ let n400 = 0, n100 = 0, n4 = 0, n1 = 0, n0 = 0;
1503
+ divmod(n, DI400Y, (_n400, n2) => {
1504
+ n400 = _n400;
1505
+ divmod(n2, DI100Y, (_n100, n3) => {
1506
+ n100 = _n100;
1507
+ divmod(n3, DI4Y, (_n4, n5) => {
1508
+ n4 = _n4;
1509
+ divmod(n5, 365, (_n1, n6) => {
1510
+ n1 = _n1;
1511
+ n0 = n6;
1512
+ });
1513
+ });
1514
+ });
1515
+ });
1516
+ n = n0;
1517
+ const year = n400 * 400 + 1 + n100 * 100 + n4 * 4 + n1;
1518
+ if (n1 === 4 || n100 === 100) {
1519
+ assert(n0 === 0);
1520
+ return {
1521
+ year: year - 1,
1522
+ month: 12,
1523
+ day: 31
1524
+ };
1525
+ }
1526
+ const leapyear = n1 === 3 && (n4 !== 24 || n100 === 3);
1527
+ assert(leapyear === isLeap(year));
1528
+ let month = n + 50 >> 5;
1529
+ let preceding = DAYS_BEFORE_MONTH[month] + (month > 2 && leapyear ? 1 : 0);
1530
+ if (preceding > n) {
1531
+ --month;
1532
+ preceding -= DAYS_IN_MONTH[month] + (month === 2 && leapyear ? 1 : 0);
1533
+ }
1534
+ n -= preceding;
1535
+ return {
1536
+ year,
1537
+ month,
1538
+ day: n + 1
1539
+ };
1540
+ }
1541
+ function tmxxx(year, month, day, hour, minute, second, microsecond) {
1542
+ hour = hour || 0;
1543
+ minute = minute || 0;
1544
+ second = second || 0;
1545
+ microsecond = microsecond || 0;
1546
+ if (microsecond < 0 || microsecond > 999999) {
1547
+ divmod(microsecond, 1e6, (carry, ms) => {
1548
+ microsecond = ms;
1549
+ second += carry;
1550
+ });
1551
+ }
1552
+ if (second < 0 || second > 59) {
1553
+ divmod(second, 60, (carry, s) => {
1554
+ second = s;
1555
+ minute += carry;
1556
+ });
1557
+ }
1558
+ if (minute < 0 || minute > 59) {
1559
+ divmod(minute, 60, (carry, m) => {
1560
+ minute = m;
1561
+ hour += carry;
1562
+ });
1563
+ }
1564
+ if (hour < 0 || hour > 23) {
1565
+ divmod(hour, 24, (carry, h) => {
1566
+ hour = h;
1567
+ day += carry;
1568
+ });
1569
+ }
1570
+ if (month < 1 || month > 12) {
1571
+ divmod(month - 1, 12, (carry, m) => {
1572
+ month = m + 1;
1573
+ year += carry;
1574
+ });
1575
+ }
1576
+ const dim = daysInMonth(year, month);
1577
+ if (day < 1 || day > dim) {
1578
+ if (day === 0) {
1579
+ --month;
1580
+ if (month > 0) {
1581
+ day = daysInMonth(year, month);
1582
+ } else {
1583
+ --year;
1584
+ month = 12;
1585
+ day = 31;
1586
+ }
1587
+ } else if (day === dim + 1) {
1588
+ ++month;
1589
+ day = 1;
1590
+ if (month > 12) {
1591
+ month = 1;
1592
+ ++year;
1593
+ }
1594
+ } else {
1595
+ const r = ord2ymd(ymd2ord(year, month, 1) + (day - 1));
1596
+ year = r.year;
1597
+ month = r.month;
1598
+ day = r.day;
1599
+ }
1600
+ }
1601
+ return {
1602
+ year,
1603
+ month,
1604
+ day,
1605
+ hour,
1606
+ minute,
1607
+ second,
1608
+ microsecond
1609
+ };
1610
+ }
1611
+ var PyDate = class _PyDate {
1612
+ constructor(year, month, day) {
1613
+ this.year = year;
1614
+ this.month = month;
1615
+ this.day = day;
1616
+ }
1617
+ static today() {
1618
+ return this.convertDate(/* @__PURE__ */ new Date());
1619
+ }
1620
+ static convertDate(date) {
1621
+ const year = date.getFullYear();
1622
+ const month = date.getMonth() + 1;
1623
+ const day = date.getDate();
1624
+ return new _PyDate(year, month, day);
1625
+ }
1626
+ static create(...args) {
1627
+ const { year, month, day } = parseArgs(args, ["year", "month", "day"]);
1628
+ return new _PyDate(year, month, day);
1629
+ }
1630
+ add(timedelta) {
1631
+ const s = tmxxx(this.year, this.month, this.day + timedelta.days, 0, 0, 0);
1632
+ return new _PyDate(s.year, s.month, s.day);
1633
+ }
1634
+ isEqual(other) {
1635
+ if (!(other instanceof _PyDate)) {
1636
+ return false;
1637
+ }
1638
+ return this.year === other.year && this.month === other.month && this.day === other.day;
1639
+ }
1640
+ strftime(format) {
1641
+ return format.replace(/%([A-Za-z])/g, (m, c) => {
1642
+ switch (c) {
1643
+ case "Y":
1644
+ return fmt4(this.year);
1645
+ case "m":
1646
+ return fmt2(this.month);
1647
+ case "d":
1648
+ return fmt2(this.day);
1649
+ default:
1650
+ throw new ValueError(`No known conversion for ${m}`);
1651
+ }
1652
+ });
1653
+ }
1654
+ substract(other) {
1655
+ if (other instanceof PyTimeDelta) {
1656
+ return this.add(other.negate());
1657
+ }
1658
+ if (other instanceof _PyDate) {
1659
+ return PyTimeDelta.create(this.toordinal() - other.toordinal());
1660
+ }
1661
+ throw new NotSupportedError();
1662
+ }
1663
+ toJSON() {
1664
+ return this.strftime("%Y-%m-%d");
1665
+ }
1666
+ toordinal() {
1667
+ return ymd2ord(this.year, this.month, this.day);
1668
+ }
1669
+ };
1670
+ var PyDateTime = class _PyDateTime {
1671
+ constructor(year, month, day, hour, minute, second, microsecond) {
1672
+ this.year = year;
1673
+ this.month = month;
1674
+ this.day = day;
1675
+ this.hour = hour;
1676
+ this.minute = minute;
1677
+ this.second = second;
1678
+ this.microsecond = microsecond;
1679
+ }
1680
+ static now() {
1681
+ return this.convertDate(/* @__PURE__ */ new Date());
1682
+ }
1683
+ static convertDate(date) {
1684
+ const year = date.getFullYear();
1685
+ const month = date.getMonth() + 1;
1686
+ const day = date.getDate();
1687
+ const hour = date.getHours();
1688
+ const minute = date.getMinutes();
1689
+ const second = date.getSeconds();
1690
+ return new _PyDateTime(year, month, day, hour, minute, second, 0);
1691
+ }
1692
+ static create(...args) {
1693
+ const namedArgs = parseArgs(args, [
1694
+ "year",
1695
+ "month",
1696
+ "day",
1697
+ "hour",
1698
+ "minute",
1699
+ "second",
1700
+ "microsecond"
1701
+ ]);
1702
+ const year = namedArgs.year;
1703
+ const month = namedArgs.month;
1704
+ const day = namedArgs.day;
1705
+ const hour = namedArgs.hour || 0;
1706
+ const minute = namedArgs.minute || 0;
1707
+ const second = namedArgs.second || 0;
1708
+ const ms = namedArgs.microsecond / 1e3 || 0;
1709
+ return new _PyDateTime(year, month, day, hour, minute, second, ms);
1710
+ }
1711
+ static combine(...args) {
1712
+ const { date, time } = parseArgs(args, ["date", "time"]);
1713
+ return _PyDateTime.create(
1714
+ date.year,
1715
+ date.month,
1716
+ date.day,
1717
+ time.hour,
1718
+ time.minute,
1719
+ time.second
1720
+ );
1721
+ }
1722
+ add(timedelta) {
1723
+ const s = tmxxx(
1724
+ this.year,
1725
+ this.month,
1726
+ this.day + timedelta.days,
1727
+ this.hour,
1728
+ this.minute,
1729
+ this.second + timedelta.seconds,
1730
+ this.microsecond + timedelta.microseconds
1731
+ );
1732
+ return new _PyDateTime(
1733
+ s.year,
1734
+ s.month,
1735
+ s.day,
1736
+ s.hour,
1737
+ s.minute,
1738
+ s.second,
1739
+ s.microsecond
1740
+ );
1741
+ }
1742
+ isEqual(other) {
1743
+ if (!(other instanceof _PyDateTime)) {
1744
+ return false;
1745
+ }
1746
+ 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;
1747
+ }
1748
+ strftime(format) {
1749
+ return format.replace(/%([A-Za-z])/g, (m, c) => {
1750
+ switch (c) {
1751
+ case "Y":
1752
+ return fmt4(this.year);
1753
+ case "m":
1754
+ return fmt2(this.month);
1755
+ case "d":
1756
+ return fmt2(this.day);
1757
+ case "H":
1758
+ return fmt2(this.hour);
1759
+ case "M":
1760
+ return fmt2(this.minute);
1761
+ case "S":
1762
+ return fmt2(this.second);
1763
+ default:
1764
+ throw new ValueError(`No known conversion for ${m}`);
1765
+ }
1766
+ });
1767
+ }
1768
+ substract(timedelta) {
1769
+ return this.add(timedelta.negate());
1770
+ }
1771
+ toJSON() {
1772
+ return this.strftime("%Y-%m-%d %H:%M:%S");
1773
+ }
1774
+ to_utc() {
1775
+ const d = new Date(
1776
+ this.year,
1777
+ this.month - 1,
1778
+ this.day,
1779
+ this.hour,
1780
+ this.minute,
1781
+ this.second
1782
+ );
1783
+ const timedelta = PyTimeDelta.create({ minutes: d.getTimezoneOffset() });
1784
+ return this.add(timedelta);
1785
+ }
1786
+ };
1787
+ var PyTime = class _PyTime extends PyDate {
1788
+ constructor(hour, minute, second) {
1789
+ const now = /* @__PURE__ */ new Date();
1790
+ const year = now.getFullYear();
1791
+ const month = now.getMonth() + 1;
1792
+ const day = now.getDate();
1793
+ super(year, month, day);
1794
+ this.hour = hour;
1795
+ this.minute = minute;
1796
+ this.second = second;
1797
+ this.hour = hour;
1798
+ this.minute = minute;
1799
+ this.second = second;
1800
+ }
1801
+ static create(...args) {
1802
+ const namedArgs = parseArgs(args, ["hour", "minute", "second"]);
1803
+ const hour = namedArgs.hour || 0;
1804
+ const minute = namedArgs.minute || 0;
1805
+ const second = namedArgs.second || 0;
1806
+ return new _PyTime(hour, minute, second);
1807
+ }
1808
+ strftime(format) {
1809
+ return format.replace(/%([A-Za-z])/g, (m, c) => {
1810
+ switch (c) {
1811
+ case "Y":
1812
+ return fmt4(this.year);
1813
+ case "m":
1814
+ return fmt2(this.month);
1815
+ case "d":
1816
+ return fmt2(this.day);
1817
+ case "H":
1818
+ return fmt2(this.hour);
1819
+ case "M":
1820
+ return fmt2(this.minute);
1821
+ case "S":
1822
+ return fmt2(this.second);
1823
+ default:
1824
+ throw new ValueError(`No known conversion for ${m}`);
1825
+ }
1826
+ });
1827
+ }
1828
+ toJSON() {
1829
+ return this.strftime("%H:%M:%S");
1830
+ }
1831
+ };
1832
+ var DAYS_IN_YEAR = [
1833
+ 31,
1834
+ 59,
1835
+ 90,
1836
+ 120,
1837
+ 151,
1838
+ 181,
1839
+ 212,
1840
+ 243,
1841
+ 273,
1842
+ 304,
1843
+ 334,
1844
+ 366
1845
+ ];
1846
+ var TIME_PERIODS = ["hour", "minute", "second"];
1847
+ var PERIODS = ["year", "month", "day", ...TIME_PERIODS];
1848
+ var RELATIVE_KEYS = "years months weeks days hours minutes seconds microseconds leapdays".split(
1849
+ " "
1850
+ );
1851
+ var ABSOLUTE_KEYS = "year month day hour minute second microsecond weekday nlyearday yearday".split(
1852
+ " "
1853
+ );
1854
+ var argsSpec = ["dt1", "dt2"];
1855
+ var PyRelativeDelta = class _PyRelativeDelta {
1856
+ static create(...args) {
1857
+ const params = parseArgs(args, argsSpec);
1858
+ if ("dt1" in params) {
1859
+ throw new Error("relativedelta(dt1, dt2) is not supported for now");
1860
+ }
1861
+ for (const period of PERIODS) {
1862
+ if (period in params) {
1863
+ const val = params[period];
1864
+ assert(val >= 0, `${period} ${val} is out of range`);
1865
+ }
1866
+ }
1867
+ for (const key of RELATIVE_KEYS) {
1868
+ params[key] = params[key] || 0;
1869
+ }
1870
+ for (const key of ABSOLUTE_KEYS) {
1871
+ params[key] = key in params ? params[key] : null;
1872
+ }
1873
+ params.days += 7 * params.weeks;
1874
+ let yearDay = 0;
1875
+ if (params.nlyearday) {
1876
+ yearDay = params.nlyearday;
1877
+ } else if (params.yearday) {
1878
+ yearDay = params.yearday;
1879
+ if (yearDay > 59) {
1880
+ params.leapDays = -1;
1881
+ }
1882
+ }
1883
+ if (yearDay) {
1884
+ for (let monthIndex = 0; monthIndex < DAYS_IN_YEAR.length; monthIndex++) {
1885
+ if (yearDay <= DAYS_IN_YEAR[monthIndex]) {
1886
+ params.month = monthIndex + 1;
1887
+ if (monthIndex === 0) {
1888
+ params.day = yearDay;
1889
+ } else {
1890
+ params.day = yearDay - DAYS_IN_YEAR[monthIndex - 1];
1891
+ }
1892
+ break;
1893
+ }
1894
+ }
1895
+ }
1896
+ return new _PyRelativeDelta(params);
1897
+ }
1898
+ static add(date, delta) {
1899
+ if (!(date instanceof PyDate || date instanceof PyDateTime)) {
1900
+ throw new NotSupportedError();
1901
+ }
1902
+ const s = tmxxx(
1903
+ (delta.year || date.year) + delta.years,
1904
+ (delta.month || date.month) + delta.months,
1905
+ delta.day || date.day,
1906
+ delta.hour || (date instanceof PyDateTime ? date.hour : 0),
1907
+ delta.minute || (date instanceof PyDateTime ? date.minute : 0),
1908
+ delta.second || (date instanceof PyDateTime ? date.second : 0),
1909
+ delta.microseconds || (date instanceof PyDateTime ? date.microsecond : 0)
1910
+ );
1911
+ const newDateTime = new PyDateTime(
1912
+ s.year,
1913
+ s.month,
1914
+ s.day,
1915
+ s.hour,
1916
+ s.minute,
1917
+ s.second,
1918
+ s.microsecond
1919
+ );
1920
+ let leapDays = 0;
1921
+ if (delta.leapDays && newDateTime.month > 2 && isLeap(newDateTime.year)) {
1922
+ leapDays = delta.leapDays;
1923
+ }
1924
+ const temp = newDateTime.add(
1925
+ PyTimeDelta.create({
1926
+ days: delta.days + leapDays,
1927
+ hours: delta.hours,
1928
+ minutes: delta.minutes,
1929
+ seconds: delta.seconds,
1930
+ microseconds: delta.microseconds
1931
+ })
1932
+ );
1933
+ const hasTime = Boolean(
1934
+ temp.hour || temp.minute || temp.second || temp.microsecond
1935
+ );
1936
+ const returnDate = !hasTime && date instanceof PyDate ? new PyDate(temp.year, temp.month, temp.day) : temp;
1937
+ if (delta.weekday !== null) {
1938
+ const wantedDow = delta.weekday + 1;
1939
+ const _date = new Date(
1940
+ returnDate.year,
1941
+ returnDate.month - 1,
1942
+ returnDate.day
1943
+ );
1944
+ const days = (7 - _date.getDay() + wantedDow) % 7;
1945
+ return returnDate.add(new PyTimeDelta(days, 0, 0));
1946
+ }
1947
+ return returnDate;
1948
+ }
1949
+ static substract(date, delta) {
1950
+ return _PyRelativeDelta.add(date, delta.negate());
1951
+ }
1952
+ constructor(params = {}, sign = 1) {
1953
+ this.years = sign * params.years;
1954
+ this.months = sign * params.months;
1955
+ this.days = sign * params.days;
1956
+ this.hours = sign * params.hours;
1957
+ this.minutes = sign * params.minutes;
1958
+ this.seconds = sign * params.seconds;
1959
+ this.microseconds = sign * params.microseconds;
1960
+ this.leapDays = params.leapDays;
1961
+ this.year = params.year;
1962
+ this.month = params.month;
1963
+ this.day = params.day;
1964
+ this.hour = params.hour;
1965
+ this.minute = params.minute;
1966
+ this.second = params.second;
1967
+ this.microsecond = params.microsecond;
1968
+ this.weekday = params.weekday;
1969
+ }
1970
+ years;
1971
+ months;
1972
+ days;
1973
+ hours;
1974
+ minutes;
1975
+ seconds;
1976
+ microseconds;
1977
+ leapDays;
1978
+ year;
1979
+ month;
1980
+ day;
1981
+ hour;
1982
+ minute;
1983
+ second;
1984
+ microsecond;
1985
+ weekday;
1986
+ negate() {
1987
+ return new _PyRelativeDelta(this, -1);
1988
+ }
1989
+ isEqual() {
1990
+ throw new NotSupportedError();
1991
+ }
1992
+ };
1993
+ var TIME_DELTA_KEYS = "weeks days hours minutes seconds milliseconds microseconds".split(" ");
1994
+ function modf(x) {
1995
+ const mod = x % 1;
1996
+ return [mod < 0 ? mod + 1 : mod, Math.floor(x)];
1997
+ }
1998
+ var PyTimeDelta = class _PyTimeDelta {
1999
+ constructor(days, seconds, microseconds) {
2000
+ this.days = days;
2001
+ this.seconds = seconds;
2002
+ this.microseconds = microseconds;
2003
+ }
2004
+ static create(...args) {
2005
+ const namedArgs = parseArgs(args, ["days", "seconds", "microseconds"]);
2006
+ for (const key of TIME_DELTA_KEYS) {
2007
+ namedArgs[key] = namedArgs[key] || 0;
2008
+ }
2009
+ let d = 0;
2010
+ let s = 0;
2011
+ let us = 0;
2012
+ const days = namedArgs.days + namedArgs.weeks * 7;
2013
+ let seconds = namedArgs.seconds + 60 * namedArgs.minutes + 3600 * namedArgs.hours;
2014
+ let microseconds = namedArgs.microseconds + 1e3 * namedArgs.milliseconds;
2015
+ const [dFrac, dInt] = modf(days);
2016
+ d = dInt;
2017
+ let daysecondsfrac = 0;
2018
+ if (dFrac) {
2019
+ const [dsFrac, dsInt] = modf(dFrac * 24 * 3600);
2020
+ s = dsInt;
2021
+ daysecondsfrac = dsFrac;
2022
+ }
2023
+ const [sFrac, sInt] = modf(seconds);
2024
+ seconds = sInt;
2025
+ const secondsfrac = sFrac + daysecondsfrac;
2026
+ divmod(seconds, 24 * 3600, (days2, seconds2) => {
2027
+ d += days2;
2028
+ s += seconds2;
2029
+ });
2030
+ microseconds += secondsfrac * 1e6;
2031
+ divmod(microseconds, 1e6, (seconds2, microseconds2) => {
2032
+ divmod(seconds2, 24 * 3600, (days2, seconds3) => {
2033
+ d += days2;
2034
+ s += seconds3;
2035
+ us += Math.round(microseconds2);
2036
+ });
2037
+ });
2038
+ return new _PyTimeDelta(d, s, us);
2039
+ }
2040
+ add(other) {
2041
+ return _PyTimeDelta.create({
2042
+ days: this.days + other.days,
2043
+ seconds: this.seconds + other.seconds,
2044
+ microseconds: this.microseconds + other.microseconds
2045
+ });
2046
+ }
2047
+ divide(n) {
2048
+ const us = (this.days * 24 * 3600 + this.seconds) * 1e6 + this.microseconds;
2049
+ return _PyTimeDelta.create({ microseconds: Math.floor(us / n) });
2050
+ }
2051
+ isEqual(other) {
2052
+ if (!(other instanceof _PyTimeDelta)) {
2053
+ return false;
2054
+ }
2055
+ return this.days === other.days && this.seconds === other.seconds && this.microseconds === other.microseconds;
2056
+ }
2057
+ isTrue() {
2058
+ return this.days !== 0 || this.seconds !== 0 || this.microseconds !== 0;
2059
+ }
2060
+ multiply(n) {
2061
+ return _PyTimeDelta.create({
2062
+ days: n * this.days,
2063
+ seconds: n * this.seconds,
2064
+ microseconds: n * this.microseconds
2065
+ });
2066
+ }
2067
+ negate() {
2068
+ return _PyTimeDelta.create({
2069
+ days: -this.days,
2070
+ seconds: -this.seconds,
2071
+ microseconds: -this.microseconds
2072
+ });
2073
+ }
2074
+ substract(other) {
2075
+ return _PyTimeDelta.create({
2076
+ days: this.days - other.days,
2077
+ seconds: this.seconds - other.seconds,
2078
+ microseconds: this.microseconds - other.microseconds
2079
+ });
2080
+ }
2081
+ total_seconds() {
2082
+ return this.days * 86400 + this.seconds + this.microseconds / 1e6;
2083
+ }
2084
+ };
2085
+
2086
+ // src/utils/domain/py_builtin.ts
2087
+ var EvaluationError = class extends Error {
2088
+ constructor(message) {
2089
+ super(message);
2090
+ this.name = "EvaluationError";
2091
+ }
2092
+ };
2093
+ function execOnIterable(iterable, func) {
2094
+ if (iterable === null) {
2095
+ throw new EvaluationError("value not iterable");
2096
+ }
2097
+ if (typeof iterable === "object" && !Array.isArray(iterable) && !(iterable instanceof Set)) {
2098
+ iterable = Object.keys(iterable);
2099
+ }
2100
+ if (typeof iterable?.[Symbol.iterator] !== "function") {
2101
+ throw new EvaluationError("value not iterable");
2102
+ }
2103
+ return func(iterable);
2104
+ }
2105
+ var BUILTINS = {
2106
+ /**
2107
+ * @param {any} value
2108
+ * @returns {boolean}
2109
+ */
2110
+ bool(value) {
2111
+ switch (typeof value) {
2112
+ case "number":
2113
+ return value !== 0;
2114
+ case "string":
2115
+ return value !== "";
2116
+ case "boolean":
2117
+ return value;
2118
+ case "object":
2119
+ if (value === null || value === void 0) {
2120
+ return false;
2121
+ }
2122
+ if ("isTrue" in value && typeof value.isTrue === "function") {
2123
+ return value.isTrue();
2124
+ }
2125
+ if (value instanceof Array) {
2126
+ return !!value.length;
2127
+ }
2128
+ if (value instanceof Set) {
2129
+ return !!value.size;
2130
+ }
2131
+ return Object.keys(value).length !== 0;
2132
+ default:
2133
+ return true;
2134
+ }
2135
+ },
2136
+ set(iterable) {
2137
+ if (arguments.length > 2) {
2138
+ throw new EvaluationError(
2139
+ `set expected at most 1 argument, got (${arguments.length - 1})`
2140
+ );
2141
+ }
2142
+ return execOnIterable(
2143
+ iterable,
2144
+ (iterable2) => new Set(iterable2)
2145
+ );
2146
+ },
2147
+ time: {
2148
+ strftime(format) {
2149
+ return PyDateTime.now().strftime(format);
2150
+ }
2151
+ },
2152
+ context_today() {
2153
+ return PyDate.today();
2154
+ },
2155
+ get current_date() {
2156
+ return this.today;
2157
+ },
2158
+ get today() {
2159
+ return PyDate.today().strftime("%Y-%m-%d");
2160
+ },
2161
+ get now() {
2162
+ return PyDateTime.now().strftime("%Y-%m-%d %H:%M:%S");
2163
+ },
2164
+ datetime: {
2165
+ time: PyTime,
2166
+ timedelta: PyTimeDelta,
2167
+ datetime: PyDateTime,
2168
+ date: PyDate
2169
+ },
2170
+ relativedelta: PyRelativeDelta,
2171
+ true: true,
2172
+ false: false
2173
+ };
2174
+
2175
+ // src/utils/domain/py_utils.ts
2176
+ function toPyValue(value) {
2177
+ switch (typeof value) {
2178
+ case "string":
2179
+ return { type: 1, value };
2180
+ case "number":
2181
+ return { type: 0, value };
2182
+ case "boolean":
2183
+ return { type: 2, value };
2184
+ case "object":
2185
+ if (Array.isArray(value)) {
2186
+ return { type: 4, value: value.map(toPyValue) };
2187
+ } else if (value === null) {
2188
+ return {
2189
+ type: 3
2190
+ /* None */
2191
+ };
2192
+ } else if (value instanceof Date) {
2193
+ return {
2194
+ type: 1,
2195
+ value: String(PyDateTime.convertDate(value))
2196
+ };
2197
+ } else if (value instanceof PyDate || value instanceof PyDateTime) {
2198
+ return { type: 1, value };
2199
+ } else {
2200
+ const content = {};
2201
+ for (const key in value) {
2202
+ content[key] = toPyValue(value[key]);
2203
+ }
2204
+ return { type: 11, value: content };
2205
+ }
2206
+ default:
2207
+ throw new Error("Invalid type");
2208
+ }
2209
+ }
2210
+ function formatAST(ast, lbp = 0) {
2211
+ switch (ast.type) {
2212
+ case 3:
2213
+ return "None";
2214
+ case 1:
2215
+ return JSON.stringify(ast.value);
2216
+ case 0:
2217
+ return String(ast.value);
2218
+ case 2:
2219
+ return ast.value ? "True" : "False";
2220
+ case 4:
2221
+ return `[${ast.value.map(formatAST).join(", ")}]`;
2222
+ case 6:
2223
+ if (ast.op === "not") {
2224
+ return `not ${formatAST(ast.right, 50)}`;
2225
+ }
2226
+ return `${ast.op}${formatAST(ast.right, 130)}`;
2227
+ case 7:
2228
+ const abp = bp(ast.op);
2229
+ const binaryStr = `${formatAST(ast.left, abp)} ${ast.op} ${formatAST(ast.right, abp)}`;
2230
+ return abp < lbp ? `(${binaryStr})` : binaryStr;
2231
+ case 11:
2232
+ const pairs = [];
2233
+ for (const k in ast.value) {
2234
+ pairs.push(`"${k}": ${formatAST(ast.value[k])}`);
2235
+ }
2236
+ return `{${pairs.join(", ")}}`;
2237
+ case 10:
2238
+ return `(${ast.value.map(formatAST).join(", ")})`;
2239
+ case 5:
2240
+ return ast.value;
2241
+ case 12:
2242
+ return `${formatAST(ast.target)}[${formatAST(ast.key)}]`;
2243
+ case 13:
2244
+ const { ifTrue, condition, ifFalse } = ast;
2245
+ return `${formatAST(ifTrue)} if ${formatAST(condition)} else ${formatAST(ifFalse)}`;
2246
+ case 14:
2247
+ const boolAbp = bp(ast.op);
2248
+ const boolStr = `${formatAST(ast.left, boolAbp)} ${ast.op} ${formatAST(ast.right, boolAbp)}`;
2249
+ return boolAbp < lbp ? `(${boolStr})` : boolStr;
2250
+ case 15:
2251
+ return `${formatAST(ast.obj, 150)}.${ast.key}`;
2252
+ case 8:
2253
+ const args = ast.args.map(formatAST);
2254
+ const kwargs = [];
2255
+ for (const kwarg in ast.kwargs) {
2256
+ kwargs.push(`${kwarg} = ${formatAST(ast.kwargs[kwarg])}`);
2257
+ }
2258
+ const argStr = args.concat(kwargs).join(", ");
2259
+ return `${formatAST(ast.fn)}(${argStr})`;
2260
+ default:
2261
+ throw new Error("invalid expression: " + JSON.stringify(ast));
2262
+ }
2263
+ }
2264
+ var PY_DICT = /* @__PURE__ */ Object.create(null);
2265
+ function toPyDict(obj) {
2266
+ return new Proxy(obj, {
2267
+ getPrototypeOf() {
2268
+ return PY_DICT;
2269
+ }
2270
+ });
2271
+ }
2272
+
2273
+ // src/utils/domain/py_interpreter.ts
2274
+ var isTrue = BUILTINS.bool;
2275
+ function applyUnaryOp(ast, context) {
2276
+ const value = evaluate(ast.right, context);
2277
+ switch (ast.op) {
2278
+ case "-":
2279
+ if (value instanceof Object && "negate" in value) {
2280
+ return value.negate();
2281
+ }
2282
+ return -value;
2283
+ case "+":
2284
+ return value;
2285
+ case "not":
2286
+ return !isTrue(value);
2287
+ default:
2288
+ throw new EvaluationError(`Unknown unary operator: ${ast.op}`);
2289
+ }
2290
+ }
2291
+ function pytypeIndex(val) {
2292
+ switch (typeof val) {
2293
+ case "object":
2294
+ return val === null ? 1 : Array.isArray(val) ? 5 : 3;
2295
+ case "number":
2296
+ return 2;
2297
+ case "string":
2298
+ return 4;
2299
+ default:
2300
+ throw new EvaluationError(`Unknown type: ${typeof val}`);
2301
+ }
2302
+ }
2303
+ function isLess(left, right) {
2304
+ if (typeof left === "number" && typeof right === "number") {
2305
+ return left < right;
2306
+ }
2307
+ if (typeof left === "boolean") {
2308
+ left = left ? 1 : 0;
2309
+ }
2310
+ if (typeof right === "boolean") {
2311
+ right = right ? 1 : 0;
2312
+ }
2313
+ const leftIndex = pytypeIndex(left);
2314
+ const rightIndex = pytypeIndex(right);
2315
+ if (leftIndex === rightIndex) {
2316
+ return left < right;
2317
+ }
2318
+ return leftIndex < rightIndex;
2319
+ }
2320
+ function isEqual(left, right) {
2321
+ if (typeof left !== typeof right) {
2322
+ if (typeof left === "boolean" && typeof right === "number") {
2323
+ return right === (left ? 1 : 0);
2324
+ }
2325
+ if (typeof left === "number" && typeof right === "boolean") {
2326
+ return left === (right ? 1 : 0);
2327
+ }
2328
+ return false;
2329
+ }
2330
+ if (left instanceof Object && "isEqual" in left) {
2331
+ return left.isEqual(right);
2332
+ }
2333
+ return left === right;
2334
+ }
2335
+ function isIn(left, right) {
2336
+ if (Array.isArray(right)) {
2337
+ return right.includes(left);
2338
+ }
2339
+ if (typeof right === "string" && typeof left === "string") {
2340
+ return right.includes(left);
2341
+ }
2342
+ if (typeof right === "object") {
2343
+ return left in right;
2344
+ }
2345
+ return false;
2346
+ }
2347
+ function applyBinaryOp(ast, context) {
2348
+ const left = evaluate(ast.left, context);
2349
+ const right = evaluate(ast.right, context);
2350
+ switch (ast.op) {
2351
+ case "+": {
2352
+ const relativeDeltaOnLeft = left instanceof PyRelativeDelta;
2353
+ const relativeDeltaOnRight = right instanceof PyRelativeDelta;
2354
+ if (relativeDeltaOnLeft || relativeDeltaOnRight) {
2355
+ const date = relativeDeltaOnLeft ? right : left;
2356
+ const delta = relativeDeltaOnLeft ? left : right;
2357
+ return PyRelativeDelta.add(date, delta);
2358
+ }
2359
+ const timeDeltaOnLeft = left instanceof PyTimeDelta;
2360
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
2361
+ if (timeDeltaOnLeft && timeDeltaOnRight) {
2362
+ return left.add(right);
2363
+ }
2364
+ if (timeDeltaOnLeft) {
2365
+ if (right instanceof PyDate || right instanceof PyDateTime) {
2366
+ return right.add(left);
2367
+ } else {
2368
+ throw new NotSupportedError();
2369
+ }
2370
+ }
2371
+ if (timeDeltaOnRight) {
2372
+ if (left instanceof PyDate || left instanceof PyDateTime) {
2373
+ return left.add(right);
2374
+ } else {
2375
+ throw new NotSupportedError();
2376
+ }
2377
+ }
2378
+ if (left instanceof Array && right instanceof Array) {
2379
+ return [...left, ...right];
2380
+ }
2381
+ return left + right;
2382
+ }
2383
+ case "-": {
2384
+ const isRightDelta = right instanceof PyRelativeDelta;
2385
+ if (isRightDelta) {
2386
+ return PyRelativeDelta.substract(left, right);
2387
+ }
2388
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
2389
+ if (timeDeltaOnRight) {
2390
+ if (left instanceof PyTimeDelta) {
2391
+ return left.substract(right);
2392
+ } else if (left instanceof PyDate || left instanceof PyDateTime) {
2393
+ return left.substract(right);
2394
+ } else {
2395
+ throw new NotSupportedError();
2396
+ }
2397
+ }
2398
+ if (left instanceof PyDate) {
2399
+ return left.substract(right);
2400
+ }
2401
+ return left - right;
2402
+ }
2403
+ case "*": {
2404
+ const timeDeltaOnLeft = left instanceof PyTimeDelta;
2405
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
2406
+ if (timeDeltaOnLeft || timeDeltaOnRight) {
2407
+ const number = timeDeltaOnLeft ? right : left;
2408
+ const delta = timeDeltaOnLeft ? left : right;
2409
+ return delta.multiply(number);
2410
+ }
2411
+ return left * right;
2412
+ }
2413
+ case "/":
2414
+ return left / right;
2415
+ case "%":
2416
+ return left % right;
2417
+ case "//":
2418
+ if (left instanceof PyTimeDelta) {
2419
+ return left.divide(right);
2420
+ }
2421
+ return Math.floor(left / right);
2422
+ case "**":
2423
+ return left ** right;
2424
+ case "==":
2425
+ return isEqual(left, right);
2426
+ case "<>":
2427
+ case "!=":
2428
+ return !isEqual(left, right);
2429
+ case "<":
2430
+ return isLess(left, right);
2431
+ case ">":
2432
+ return isLess(right, left);
2433
+ case ">=":
2434
+ return isEqual(left, right) || isLess(right, left);
2435
+ case "<=":
2436
+ return isEqual(left, right) || isLess(left, right);
2437
+ case "in":
2438
+ return isIn(left, right);
2439
+ case "not in":
2440
+ return !isIn(left, right);
2441
+ default:
2442
+ throw new EvaluationError(`Unknown binary operator: ${ast.op}`);
2443
+ }
2444
+ }
2445
+ var DICT = {
2446
+ get(...args) {
2447
+ const { key, defValue } = parseArgs(args, ["key", "defValue"]);
2448
+ const self = this;
2449
+ if (key in self) {
2450
+ return self[key];
2451
+ } else if (defValue !== void 0) {
2452
+ return defValue;
2453
+ }
2454
+ return null;
2455
+ }
2456
+ };
2457
+ var STRING = {
2458
+ lower() {
2459
+ return this.toLowerCase();
2460
+ },
2461
+ upper() {
2462
+ return this.toUpperCase();
2463
+ }
2464
+ };
2465
+ function applyFunc(key, func, set, ...args) {
2466
+ if (args.length === 1) {
2467
+ return new Set(set);
2468
+ }
2469
+ if (args.length > 2) {
2470
+ throw new EvaluationError(
2471
+ `${key}: py_js supports at most 1 argument, got (${args.length - 1})`
2472
+ );
2473
+ }
2474
+ return execOnIterable(args[0], func);
2475
+ }
2476
+ var SET = {
2477
+ intersection(...args) {
2478
+ return applyFunc(
2479
+ "intersection",
2480
+ (iterable) => {
2481
+ const intersection = /* @__PURE__ */ new Set();
2482
+ for (const i of iterable) {
2483
+ if (this.has(i)) {
2484
+ intersection.add(i);
2485
+ }
2486
+ }
2487
+ return intersection;
2488
+ },
2489
+ this,
2490
+ ...args
2491
+ );
2492
+ },
2493
+ difference(...args) {
2494
+ return applyFunc(
2495
+ "difference",
2496
+ (iterable) => {
2497
+ iterable = new Set(iterable);
2498
+ const difference = /* @__PURE__ */ new Set();
2499
+ for (const e of this) {
2500
+ if (!iterable.has(e)) {
2501
+ difference.add(e);
2502
+ }
2503
+ }
2504
+ return difference;
2505
+ },
2506
+ this,
2507
+ ...args
2508
+ );
2509
+ },
2510
+ union(...args) {
2511
+ return applyFunc(
2512
+ "union",
2513
+ (iterable) => {
2514
+ return /* @__PURE__ */ new Set([...this, ...iterable]);
2515
+ },
2516
+ this,
2517
+ ...args
2518
+ );
2519
+ }
2520
+ };
2521
+ function methods(_class) {
2522
+ return Object.getOwnPropertyNames(_class.prototype).map(
2523
+ (prop) => _class.prototype[prop]
2524
+ );
2525
+ }
2526
+ var allowedFns = /* @__PURE__ */ new Set([
2527
+ BUILTINS.time.strftime,
2528
+ BUILTINS.set,
2529
+ BUILTINS.bool,
2530
+ BUILTINS.context_today,
2531
+ BUILTINS.datetime.datetime.now,
2532
+ BUILTINS.datetime.datetime.combine,
2533
+ BUILTINS.datetime.date.today,
2534
+ ...methods(BUILTINS.relativedelta),
2535
+ ...Object.values(BUILTINS.datetime).flatMap((obj) => methods(obj)),
2536
+ ...Object.values(SET),
2537
+ ...Object.values(DICT),
2538
+ ...Object.values(STRING)
2539
+ ]);
2540
+ var unboundFn = /* @__PURE__ */ Symbol("unbound function");
2541
+ function evaluate(ast, context = {}) {
2542
+ const dicts = /* @__PURE__ */ new Set();
2543
+ let pyContext;
2544
+ const evalContext = Object.create(context);
2545
+ if (!evalContext?.context) {
2546
+ Object.defineProperty(evalContext, "context", {
2547
+ get() {
2548
+ if (!pyContext) {
2549
+ pyContext = toPyDict(context);
2550
+ }
2551
+ return pyContext;
2552
+ }
2553
+ });
2554
+ }
2555
+ function _innerEvaluate(ast2) {
2556
+ switch (ast2?.type) {
2557
+ case 0:
2558
+ // Number
2559
+ case 1:
2560
+ return ast2.value;
2561
+ case 5:
2562
+ if (ast2.value in evalContext) {
2563
+ if (typeof evalContext[ast2.value] === "object" && evalContext[ast2.value]?.id && ast2?.value !== "parent") {
2564
+ return evalContext[ast2.value]?.id;
2565
+ }
2566
+ return evalContext[ast2.value] ?? false;
2567
+ } else if (ast2.value in BUILTINS) {
2568
+ return BUILTINS[ast2.value];
2569
+ } else {
2570
+ return false;
2571
+ }
2572
+ case 3:
2573
+ return null;
2574
+ case 2:
2575
+ return ast2.value;
2576
+ case 6:
2577
+ return applyUnaryOp(ast2, evalContext);
2578
+ case 7:
2579
+ return applyBinaryOp(ast2, evalContext);
2580
+ case 14:
2581
+ const left = _evaluate(ast2.left);
2582
+ if (ast2.op === "and") {
2583
+ return isTrue(left) ? _evaluate(ast2.right) : left;
2584
+ } else {
2585
+ return isTrue(left) ? left : _evaluate(ast2.right);
2586
+ }
2587
+ case 4:
2588
+ // List
2589
+ case 10:
2590
+ return ast2.value.map(_evaluate);
2591
+ case 11:
2592
+ const dict = {};
2593
+ for (const key2 in ast2.value) {
2594
+ dict[key2] = _evaluate(ast2.value[key2]);
2595
+ }
2596
+ dicts.add(dict);
2597
+ return dict;
2598
+ case 8:
2599
+ const fnValue = _evaluate(ast2.fn);
2600
+ const args = ast2.args.map(_evaluate);
2601
+ const kwargs = {};
2602
+ for (const kwarg in ast2.kwargs) {
2603
+ kwargs[kwarg] = _evaluate(ast2?.kwargs[kwarg]);
2604
+ }
2605
+ if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
2606
+ return fnValue.create(...args, kwargs);
2607
+ }
2608
+ return fnValue(...args, kwargs);
2609
+ case 12:
2610
+ const dictVal = _evaluate(ast2.target);
2611
+ const key = _evaluate(ast2.key);
2612
+ return dictVal[key];
2613
+ case 13:
2614
+ if (isTrue(_evaluate(ast2.condition))) {
2615
+ return _evaluate(ast2.ifTrue);
2616
+ } else {
2617
+ return _evaluate(ast2.ifFalse);
2618
+ }
2619
+ case 15:
2620
+ let leftVal = _evaluate(ast2.obj);
2621
+ let result;
2622
+ if (dicts.has(leftVal) || Object.isPrototypeOf.call(PY_DICT, leftVal)) {
2623
+ result = DICT[ast2.key];
2624
+ } else if (typeof leftVal === "string") {
2625
+ result = STRING[ast2.key];
2626
+ } else if (leftVal instanceof Set) {
2627
+ result = SET[ast2.key];
2628
+ } else if (ast2.key === "get" && typeof leftVal === "object") {
2629
+ result = DICT[ast2.key];
2630
+ leftVal = toPyDict(leftVal);
2631
+ } else if (typeof leftVal === "number") {
2632
+ result = leftVal;
2633
+ } else if (Array.isArray(leftVal[ast2.key])) {
2634
+ result = leftVal[ast2.key]?.map(
2635
+ (value) => value?.id ?? value
2636
+ );
2637
+ } else {
2638
+ result = leftVal[ast2.key]?.id ?? leftVal[ast2.key] ?? false;
2639
+ }
2640
+ if (typeof result === "function") {
2641
+ const bound = result.bind(leftVal);
2642
+ bound[unboundFn] = result;
2643
+ return bound;
2644
+ }
2645
+ return result;
2646
+ default:
2647
+ throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
2648
+ }
2649
+ }
2650
+ function _evaluate(ast2) {
2651
+ const val = _innerEvaluate(ast2);
2652
+ if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
2653
+ throw new Error("Invalid Function Call");
2654
+ }
2655
+ return val;
2656
+ }
2657
+ return _evaluate(ast);
2658
+ }
2659
+
2660
+ // src/utils/domain/py.ts
2661
+ function parseExpr(expr) {
2662
+ const tokens = tokenize(expr);
2663
+ return parse(tokens);
2664
+ }
2665
+ function evaluateExpr(expr, context = {}) {
2666
+ let ast;
2667
+ try {
2668
+ ast = parseExpr(expr);
2669
+ } catch (error) {
2670
+ throw new EvalError(
2671
+ `Can not parse python expression: (${expr})
2672
+ Error: ${error.message}`
2673
+ );
2674
+ }
2675
+ try {
2676
+ return evaluate(ast, context);
2677
+ } catch (error) {
2678
+ throw new EvalError(
2679
+ `Can not evaluate python expression: (${expr})
2680
+ Error: ${error.message}`
2681
+ );
2682
+ }
2683
+ }
2684
+ function evaluateBooleanExpr(expr, context = {}) {
2685
+ if (!expr || expr === "False" || expr === "0") {
2686
+ return false;
2687
+ }
2688
+ if (expr === "True" || expr === "1") {
2689
+ return true;
2690
+ }
2691
+ return evaluateExpr(`bool(${expr})`, context);
2692
+ }
2693
+
2694
+ // src/utils/domain/objects.ts
2695
+ function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
2696
+ if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
2697
+ return obj1 === obj2;
2698
+ }
2699
+ const obj1Keys = Object.keys(obj1);
2700
+ return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
2701
+ }
2702
+
2703
+ // src/utils/domain/arrays.ts
2704
+ var shallowEqual2 = shallowEqual;
2705
+
2706
+ // src/utils/domain/strings.ts
2707
+ function escapeRegExp(str) {
2708
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2709
+ }
2710
+
2711
+ // src/utils/domain/domain.ts
2712
+ var InvalidDomainError = class extends Error {
2713
+ };
2714
+ var Domain = class _Domain {
2715
+ ast = { type: -1, value: null };
2716
+ static TRUE;
2717
+ static FALSE;
2718
+ static combine(domains, operator) {
2719
+ if (domains.length === 0) {
2720
+ return new _Domain([]);
2721
+ }
2722
+ const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
2723
+ if (domains.length === 1) {
2724
+ return domain1;
2725
+ }
2726
+ const domain2 = _Domain.combine(domains.slice(1), operator);
2727
+ const result = new _Domain([]);
2728
+ const astValues1 = domain1.ast.value;
2729
+ const astValues2 = domain2.ast.value;
2730
+ const op = operator === "AND" ? "&" : "|";
2731
+ const combinedAST = {
2732
+ type: 4,
2733
+ value: astValues1.concat(astValues2)
2734
+ };
2735
+ result.ast = normalizeDomainAST(combinedAST, op);
2736
+ return result;
2737
+ }
2738
+ static and(domains) {
2739
+ return _Domain.combine(domains, "AND");
2740
+ }
2741
+ static or(domains) {
2742
+ return _Domain.combine(domains, "OR");
2743
+ }
2744
+ static not(domain) {
2745
+ const result = new _Domain(domain);
2746
+ result.ast.value.unshift({ type: 1, value: "!" });
2747
+ return result;
2748
+ }
2749
+ static removeDomainLeaves(domain, keysToRemove) {
2750
+ function processLeaf(elements, idx, operatorCtx, newDomain2) {
2751
+ const leaf = elements[idx];
2752
+ if (leaf.type === 10) {
2753
+ if (keysToRemove.includes(leaf.value[0].value)) {
2754
+ if (operatorCtx === "&") {
2755
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
2756
+ } else if (operatorCtx === "|") {
2757
+ newDomain2.ast.value.push(..._Domain.FALSE.ast.value);
2758
+ }
2759
+ } else {
2760
+ newDomain2.ast.value.push(leaf);
2761
+ }
2762
+ return 1;
2763
+ } else if (leaf.type === 1) {
2764
+ 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)) {
2765
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
2766
+ return 3;
2767
+ }
2768
+ newDomain2.ast.value.push(leaf);
2769
+ if (leaf.value === "!") {
2770
+ return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
2771
+ }
2772
+ const firstLeafSkip = processLeaf(
2773
+ elements,
2774
+ idx + 1,
2775
+ leaf.value,
2776
+ newDomain2
2777
+ );
2778
+ const secondLeafSkip = processLeaf(
2779
+ elements,
2780
+ idx + 1 + firstLeafSkip,
2781
+ leaf.value,
2782
+ newDomain2
2783
+ );
2784
+ return 1 + firstLeafSkip + secondLeafSkip;
2785
+ }
2786
+ return 0;
2787
+ }
2788
+ const d = new _Domain(domain);
2789
+ if (d.ast.value.length === 0) {
2790
+ return d;
2791
+ }
2792
+ const newDomain = new _Domain([]);
2793
+ processLeaf(d.ast.value, 0, "&", newDomain);
2794
+ return newDomain;
2795
+ }
2796
+ constructor(descr = []) {
2797
+ if (descr instanceof _Domain) {
2798
+ return new _Domain(descr.toString());
2799
+ } else {
2800
+ let rawAST;
2801
+ try {
2802
+ rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
2803
+ } catch (error) {
2804
+ throw new InvalidDomainError(
2805
+ `Invalid domain representation: ${descr}`,
2806
+ {
2807
+ cause: error
2808
+ }
2809
+ );
2810
+ }
2811
+ this.ast = normalizeDomainAST(rawAST);
2812
+ }
2813
+ }
2814
+ contains(record) {
2815
+ const expr = evaluate(this.ast, record);
2816
+ return matchDomain(record, expr);
2817
+ }
2818
+ toString() {
2819
+ return formatAST(this.ast);
2820
+ }
2821
+ toList(context) {
2822
+ return evaluate(this.ast, context);
2823
+ }
2824
+ toJson() {
2825
+ try {
2826
+ const evaluatedAsList = this.toList({});
2827
+ const evaluatedDomain = new _Domain(evaluatedAsList);
2828
+ if (evaluatedDomain.toString() === this.toString()) {
2829
+ return evaluatedAsList;
2830
+ }
2831
+ return this.toString();
2832
+ } catch {
2833
+ return this.toString();
2834
+ }
2835
+ }
2836
+ };
2837
+ var TRUE_LEAF = [1, "=", 1];
2838
+ var FALSE_LEAF = [0, "=", 1];
2839
+ var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
2840
+ var FALSE_DOMAIN = new Domain([FALSE_LEAF]);
2841
+ Domain.TRUE = TRUE_DOMAIN;
2842
+ Domain.FALSE = FALSE_DOMAIN;
2843
+ function toAST(domain) {
2844
+ const elems = domain.map((elem) => {
2845
+ switch (elem) {
2846
+ case "!":
2847
+ case "&":
2848
+ case "|":
2849
+ return { type: 1, value: elem };
2850
+ default:
2851
+ return {
2852
+ type: 10,
2853
+ value: elem.map(toPyValue)
2854
+ };
2855
+ }
2856
+ });
2857
+ return { type: 4, value: elems };
2858
+ }
2859
+ function normalizeDomainAST(domain, op = "&") {
2860
+ if (domain.type !== 4) {
2861
+ if (domain.type === 10) {
2862
+ const value = domain.value;
2863
+ if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
2864
+ throw new InvalidDomainError("Invalid domain AST");
2865
+ }
2866
+ } else {
2867
+ throw new InvalidDomainError("Invalid domain AST");
2868
+ }
2869
+ }
2870
+ if (domain.value.length === 0) {
2871
+ return domain;
2872
+ }
2873
+ let expected = 1;
2874
+ for (const child of domain.value) {
2875
+ switch (child.type) {
2876
+ case 1:
2877
+ if (child.value === "&" || child.value === "|") {
2878
+ expected++;
2879
+ } else if (child.value !== "!") {
2880
+ throw new InvalidDomainError("Invalid domain AST");
2881
+ }
2882
+ break;
2883
+ case 4:
2884
+ /* list */
2885
+ case 10:
2886
+ if (child.value.length === 3) {
2887
+ expected--;
2888
+ break;
2889
+ }
2890
+ throw new InvalidDomainError("Invalid domain AST");
2891
+ default:
2892
+ throw new InvalidDomainError("Invalid domain AST");
2893
+ }
2894
+ }
2895
+ const values = domain.value.slice();
2896
+ while (expected < 0) {
2897
+ expected++;
2898
+ values.unshift({ type: 1, value: op });
2899
+ }
2900
+ if (expected > 0) {
2901
+ throw new InvalidDomainError(
2902
+ `invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
2903
+ );
2904
+ }
2905
+ return { type: 4, value: values };
2906
+ }
2907
+ function matchCondition(record, condition) {
2908
+ if (typeof condition === "boolean") {
2909
+ return condition;
2910
+ }
2911
+ const [field, operator, value] = condition;
2912
+ if (typeof field === "string") {
2913
+ const names = field.split(".");
2914
+ if (names.length >= 2) {
2915
+ return matchCondition(record[names[0]], [
2916
+ names.slice(1).join("."),
2917
+ operator,
2918
+ value
2919
+ ]);
2920
+ }
2921
+ }
2922
+ let likeRegexp, ilikeRegexp;
2923
+ if (["like", "not like", "ilike", "not ilike"].includes(operator)) {
2924
+ likeRegexp = new RegExp(
2925
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2926
+ "g"
2927
+ );
2928
+ ilikeRegexp = new RegExp(
2929
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
2930
+ "gi"
2931
+ );
2932
+ }
2933
+ const fieldValue = typeof field === "number" ? field : record[field];
2934
+ switch (operator) {
2935
+ case "=?":
2936
+ if ([false, null].includes(value)) {
2937
+ return true;
2938
+ }
2939
+ // eslint-disable-next-line no-fallthrough
2940
+ case "=":
2941
+ case "==":
2942
+ if (Array.isArray(fieldValue) && Array.isArray(value)) {
2943
+ return shallowEqual2(fieldValue, value);
2944
+ }
2945
+ return fieldValue === value;
2946
+ case "!=":
2947
+ case "<>":
2948
+ return !matchCondition(record, [field, "==", value]);
2949
+ case "<":
2950
+ return fieldValue < value;
2951
+ case "<=":
2952
+ return fieldValue <= value;
2953
+ case ">":
2954
+ return fieldValue > value;
2955
+ case ">=":
2956
+ return fieldValue >= value;
2957
+ case "in": {
2958
+ const val = Array.isArray(value) ? value : [value];
2959
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2960
+ return fieldVal.some((fv) => val.includes(fv));
2961
+ }
2962
+ case "not in": {
2963
+ const val = Array.isArray(value) ? value : [value];
2964
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
2965
+ return !fieldVal.some((fv) => val.includes(fv));
2966
+ }
2967
+ case "like":
2968
+ if (fieldValue === false) {
2969
+ return false;
2970
+ }
2971
+ return Boolean(fieldValue.match(likeRegexp));
2972
+ case "not like":
2973
+ if (fieldValue === false) {
2974
+ return false;
2975
+ }
2976
+ return Boolean(!fieldValue.match(likeRegexp));
2977
+ case "=like":
2978
+ if (fieldValue === false) {
2979
+ return false;
2980
+ }
2981
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
2982
+ fieldValue
2983
+ );
2984
+ case "ilike":
2985
+ if (fieldValue === false) {
2986
+ return false;
2987
+ }
2988
+ return Boolean(fieldValue.match(ilikeRegexp));
2989
+ case "not ilike":
2990
+ if (fieldValue === false) {
2991
+ return false;
2992
+ }
2993
+ return Boolean(!fieldValue.match(ilikeRegexp));
2994
+ case "=ilike":
2995
+ if (fieldValue === false) {
2996
+ return false;
2997
+ }
2998
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
2999
+ fieldValue
3000
+ );
3001
+ }
3002
+ throw new InvalidDomainError("could not match domain");
3003
+ }
3004
+ function makeOperators(record) {
3005
+ const match = matchCondition.bind(null, record);
3006
+ return {
3007
+ "!": (x) => !match(x),
3008
+ "&": (a, b) => match(a) && match(b),
3009
+ "|": (a, b) => match(a) || match(b)
3010
+ };
3011
+ }
3012
+ function matchDomain(record, domain) {
3013
+ if (domain.length === 0) {
3014
+ return true;
3015
+ }
3016
+ const operators = makeOperators(record);
3017
+ const reversedDomain = Array.from(domain).reverse();
3018
+ const condStack = [];
3019
+ for (const item of reversedDomain) {
3020
+ const operator = typeof item === "string" && operators[item];
3021
+ if (operator) {
3022
+ const operands = condStack.splice(-operator.length);
3023
+ condStack.push(operator(...operands));
3024
+ } else {
3025
+ condStack.push(item);
3026
+ }
3027
+ }
3028
+ return matchCondition(record, condStack.pop());
3029
+ }
3030
+ var checkDomain = (context, domain) => {
3031
+ try {
3032
+ if (domain === void 0 || domain === "0" || domain === "False" || domain === false) {
3033
+ return false;
3034
+ } else if (domain === "1" || domain === "True" || domain === true) {
3035
+ return true;
3036
+ }
3037
+ try {
3038
+ if (context && domain) {
3039
+ const d = new Domain(domain);
3040
+ return d.contains(context);
3041
+ }
3042
+ } catch (error) {
3043
+ if (context && domain) {
3044
+ const domainEval = evaluateBooleanExpr(domain, context);
3045
+ return domainEval;
3046
+ }
3047
+ return false;
3048
+ }
3049
+ return false;
3050
+ } catch (e) {
3051
+ return false;
3052
+ }
3053
+ };
3054
+ var matchDomains = (context, domains) => {
3055
+ if (Array.isArray(domains)) {
3056
+ if (domains?.length > 0) {
3057
+ return domains && domains.some((domain) => checkDomain(context, domain));
3058
+ }
3059
+ } else return checkDomain(context, domains);
3060
+ return false;
3061
+ };
3062
+
3063
+ // src/utils/function.ts
3064
+ var toQueryString = (params) => {
3065
+ return Object.keys(params).map(
3066
+ (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
3067
+ ).join("&");
3068
+ };
3069
+ var isBase64File = (str) => {
3070
+ try {
3071
+ const dataUriPattern = /^data:([a-zA-Z]+\/[a-zA-Z0-9-.+]+)?;base64,/;
3072
+ if (dataUriPattern.test(str)) {
3073
+ return true;
3074
+ }
3075
+ const base64Pattern = (
3076
+ // eslint-disable-next-line no-useless-escape
3077
+ /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)?$/
3078
+ );
3079
+ return base64Pattern.test(str);
3080
+ } catch (e) {
3081
+ return false;
3082
+ }
3083
+ };
3084
+
3085
+ // src/services/action-service/index.ts
3086
+ var ActionService = {
3087
+ async loadAction({
3088
+ idAction,
3089
+ context
3090
+ }) {
3091
+ const env2 = getEnv();
3092
+ const jsonData = {
3093
+ action_id: idAction,
3094
+ with_context: {
3095
+ ...context
3096
+ }
3097
+ };
3098
+ return env2.requests.post(`${"/load_action" /* LOAD_ACTION */}`, jsonData, {
3099
+ headers: {
3100
+ "Content-Type": "application/json"
3101
+ }
3102
+ });
3103
+ },
3104
+ async callButton({
3105
+ model,
3106
+ ids = [],
3107
+ context,
3108
+ method
3109
+ }) {
3110
+ try {
3111
+ const env2 = getEnv();
3112
+ const jsonData = {
3113
+ model,
3114
+ method,
3115
+ ids,
3116
+ with_context: context
3117
+ };
3118
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3119
+ headers: {
3120
+ "Content-Type": "application/json"
3121
+ }
3122
+ });
3123
+ } catch (error) {
3124
+ console.error("Error when calling button action:", error);
3125
+ throw error;
3126
+ }
3127
+ },
3128
+ async removeRows({
3129
+ model,
3130
+ ids,
3131
+ context
3132
+ }) {
3133
+ const env2 = getEnv();
3134
+ const jsonData = {
3135
+ model,
3136
+ method: "unlink",
3137
+ ids,
3138
+ with_context: context
3139
+ };
3140
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3141
+ headers: {
3142
+ "Content-Type": "application/json"
3143
+ }
3144
+ });
3145
+ },
3146
+ async duplicateRecord({
3147
+ model,
3148
+ id,
3149
+ context
3150
+ }) {
3151
+ const env2 = getEnv();
3152
+ const jsonData = {
3153
+ model,
3154
+ method: "copy",
3155
+ ids: id,
3156
+ with_context: context
3157
+ };
3158
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3159
+ headers: {
3160
+ "Content-Type": "application/json"
3161
+ }
3162
+ });
3163
+ },
3164
+ async print({ id, report, db }) {
3165
+ const env2 = getEnv();
3166
+ const jsonData = {
3167
+ report,
3168
+ id,
3169
+ type: "pdf",
3170
+ file_response: true,
3171
+ db
3172
+ };
3173
+ const queryString = toQueryString(jsonData);
3174
+ const urlWithParams = `${"/report" /* REPORT_PATH */}?${queryString}`;
3175
+ return env2.requests.get(urlWithParams, {
3176
+ headers: {
3177
+ "Content-Type": "application/json"
3178
+ },
3179
+ responseType: "arraybuffer"
3180
+ });
3181
+ },
3182
+ async runAction({
3183
+ idAction,
3184
+ context
3185
+ }) {
3186
+ const env2 = getEnv();
3187
+ const jsonData = {
3188
+ action_id: idAction,
3189
+ with_context: {
3190
+ ...context
3191
+ }
3192
+ };
3193
+ return env2.requests.post(`${"/run_action" /* RUN_ACTION_PATH */}`, jsonData, {
3194
+ headers: {
3195
+ "Content-Type": "application/json"
3196
+ }
3197
+ });
3198
+ }
3199
+ };
3200
+ var action_service_default = ActionService;
3201
+
3202
+ // src/services/auth-service/index.ts
3203
+ var AuthService = {
3204
+ async login(body) {
3205
+ const env2 = getEnv();
3206
+ const payload = Object.fromEntries(
3207
+ Object.entries({
3208
+ username: body.email,
3209
+ password: body.password,
3210
+ grant_type: env2?.config?.grantType || "",
3211
+ client_id: env2?.config?.clientId || "",
3212
+ client_secret: env2?.config?.clientSecret || ""
3213
+ }).filter(([_, value]) => !!value)
3214
+ );
3215
+ const encodedData = new URLSearchParams(payload).toString();
3216
+ return env2?.requests?.post(body.path, encodedData, {
3217
+ headers: {
3218
+ "Content-Type": "application/x-www-form-urlencoded"
3219
+ }
3220
+ });
3221
+ },
3222
+ async forgotPassword(email) {
3223
+ const env2 = getEnv();
3224
+ const bodyData = {
3225
+ login: email,
3226
+ url: `${window.location.origin}/reset-password`
3227
+ };
3228
+ return env2?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3229
+ headers: {
3230
+ "Content-Type": "application/json"
3231
+ }
3232
+ });
3233
+ },
3234
+ async resetPassword(data, token) {
3235
+ const env2 = getEnv();
3236
+ const bodyData = {
3237
+ token,
3238
+ password: data.password,
3239
+ new_password: data.confirmPassword
3240
+ };
3241
+ return env2?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
3242
+ headers: {
3243
+ "Content-Type": "application/json"
3244
+ }
3245
+ });
3246
+ },
3247
+ async updatePassword(data, token) {
3248
+ const env2 = getEnv();
3249
+ const bodyData = {
3250
+ token,
3251
+ old_password: data.oldPassword,
3252
+ new_password: data.newPassword
3253
+ };
3254
+ return env2?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
3255
+ headers: {
3256
+ "Content-Type": "application/json"
3257
+ }
3258
+ });
3259
+ },
3260
+ async isValidToken(token) {
3261
+ const env2 = getEnv();
3262
+ const bodyData = {
3263
+ token
3264
+ };
3265
+ return env2?.requests?.post("/check_token" /* TOKEN */, bodyData, {
3266
+ headers: {
3267
+ "Content-Type": "application/json"
3268
+ }
3269
+ });
3270
+ },
3271
+ async loginSocial({
3272
+ state,
3273
+ access_token
3274
+ }) {
3275
+ const env2 = getEnv();
3276
+ return env2?.requests?.post(
3277
+ "/token/generate" /* GENTOKEN_SOCIAL */,
3278
+ { state, access_token },
3279
+ {
3280
+ headers: {
3281
+ "Content-Type": "application/json"
3282
+ }
3283
+ }
3284
+ );
3285
+ },
3286
+ async getProviders(db) {
3287
+ const env2 = getEnv();
3288
+ return env2?.requests?.get("/oauth/providers", { params: { db } });
3289
+ }
3290
+ };
3291
+ var auth_service_default = AuthService;
3292
+
3293
+ // src/constants/widget/widget-avatar-constant.ts
3294
+ var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
3295
+ WIDGETAVATAR2["many2one_avatar_user"] = "many2one_avatar_user";
3296
+ WIDGETAVATAR2["many2many_avatar_user"] = "many2many_avatar_user";
3297
+ return WIDGETAVATAR2;
3298
+ })(WIDGETAVATAR || {});
3299
+
3300
+ // src/services/company-service/index.ts
3301
+ var CompanyService = {
3302
+ async getCurrentCompany() {
3303
+ const env2 = getEnv();
3304
+ return await env2.requests.get("/company" /* COMPANY_PATH */, {
3305
+ headers: {
3306
+ "Content-Type": "application/json"
3307
+ }
3308
+ });
3309
+ },
3310
+ async getInfoCompany(id) {
3311
+ const env2 = getEnv();
3312
+ const jsonData = {
3313
+ ids: [id],
3314
+ model: "res.company" /* COMPANY */,
3315
+ method: "web_read" /* WEB_READ */,
3316
+ kwargs: {
3317
+ specification: {
3318
+ primary_color: {},
3319
+ secondary_color: {},
3320
+ logo: {},
3321
+ display_name: {},
3322
+ secondary_logo: {}
3323
+ }
3324
+ }
3325
+ };
3326
+ return await env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3327
+ headers: {
3328
+ "Content-Type": "application/json"
3329
+ }
3330
+ });
3331
+ }
3332
+ };
3333
+ var company_service_default = CompanyService;
3334
+
3335
+ // src/services/excel-service/index.ts
3336
+ var ExcelService = {
3337
+ async uploadFile({ formData }) {
3338
+ const env2 = getEnv();
3339
+ return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3340
+ headers: {
3341
+ "Content-Type": "multipart/form-data"
3342
+ }
3343
+ });
3344
+ },
3345
+ async uploadIdFile({ formData }) {
3346
+ const env2 = getEnv();
3347
+ return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3348
+ headers: {
3349
+ "Content-Type": "multipart/form-data"
3350
+ }
3351
+ });
3352
+ },
3353
+ async parsePreview({
3354
+ id,
3355
+ selectedSheet,
3356
+ isHeader,
3357
+ context
3358
+ }) {
3359
+ const env2 = getEnv();
3360
+ const jsonData = {
3361
+ model: "base_import.import" /* BASE_IMPORT */,
3362
+ method: "parse_preview",
3363
+ ids: [id],
3364
+ kwargs: {
3365
+ options: {
3366
+ import_skip_records: [],
3367
+ import_set_empty_fields: [],
3368
+ fallback_values: {},
3369
+ name_create_enabled_fields: {},
3370
+ encoding: "",
3371
+ separator: "",
3372
+ quoting: '"',
3373
+ date_format: "",
3374
+ datetime_format: "",
3375
+ float_thousand_separator: ",",
3376
+ float_decimal_separator: ".",
3377
+ advanced: true,
3378
+ has_headers: isHeader,
3379
+ keep_matches: false,
3380
+ limit: 2e3,
3381
+ sheets: [],
3382
+ sheet: selectedSheet,
3383
+ skip: 0,
3384
+ tracking_disable: true
3385
+ }
3386
+ },
3387
+ with_context: context
3388
+ };
3389
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3390
+ headers: {
3391
+ "Content-Type": "multipart/form-data"
3392
+ }
3393
+ });
3394
+ },
3395
+ async executeImport({
3396
+ columns,
3397
+ fields,
3398
+ idFile,
3399
+ options,
3400
+ dryrun,
3401
+ context
3402
+ }) {
3403
+ const env2 = getEnv();
3404
+ const jsonData = {
3405
+ model: "base_import.import" /* BASE_IMPORT */,
3406
+ method: "execute_import",
3407
+ ids: [idFile],
3408
+ kwargs: {
3409
+ fields,
3410
+ columns,
3411
+ options,
3412
+ dryrun
3413
+ },
3414
+ with_context: context
3415
+ };
3416
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3417
+ headers: {
3418
+ "Content-Type": "multipart/form-data"
3419
+ }
3420
+ });
3421
+ },
3422
+ async getFileExcel({ model, context }) {
3423
+ const env2 = getEnv();
3424
+ const jsonData = {
3425
+ model,
3426
+ method: "get_import_templates" /* GET_IMPORT */,
3427
+ args: [],
3428
+ with_context: context
3429
+ };
3430
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData);
3431
+ },
3432
+ async getFieldExport({
3433
+ ids,
3434
+ model,
3435
+ isShow,
3436
+ parentField,
3437
+ fieldType,
3438
+ parentName,
3439
+ prefix,
3440
+ name,
3441
+ context,
3442
+ importCompat
3443
+ }) {
3444
+ const env2 = getEnv();
3445
+ const jsonData = {
3446
+ model,
3447
+ import_compat: importCompat,
3448
+ domain: [["id", "in", ids]],
3449
+ with_context: context
3450
+ };
3451
+ if (isShow) {
3452
+ jsonData.parent_field = parentField;
3453
+ jsonData.parent_field_type = fieldType;
3454
+ jsonData.parent_name = parentName;
3455
+ jsonData.name = name;
3456
+ jsonData.prefix = prefix;
3457
+ jsonData.exclude = [null];
3458
+ }
3459
+ return env2.requests.post("/export/get_fields", jsonData);
3460
+ },
3461
+ async exportExcel({
3462
+ model,
3463
+ domain,
3464
+ ids,
3465
+ fields,
3466
+ type,
3467
+ importCompat,
3468
+ context,
3469
+ groupby
3470
+ }) {
3471
+ const env2 = getEnv();
3472
+ const jsonData = {
3473
+ model,
3474
+ domain,
3475
+ ids,
3476
+ import_compat: importCompat,
3477
+ fields,
3478
+ with_context: context,
3479
+ groupby: groupby ?? []
3480
+ };
3481
+ return env2.requests.post_excel(`/export/${type}`, jsonData);
3482
+ }
3483
+ };
3484
+ var excel_service_default = ExcelService;
3485
+
3486
+ // src/services/form-service/index.ts
3487
+ var FormService = {
3488
+ async getComment({ data }) {
3489
+ try {
3490
+ const env2 = getEnv();
3491
+ const jsonData = {
3492
+ thread_id: data.thread_id,
3493
+ thread_model: data.thread_model,
3494
+ limit: 100,
3495
+ with_context: {
3496
+ lang: data.lang
3497
+ }
3498
+ };
3499
+ return env2.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
3500
+ headers: {
3501
+ "Content-Type": "application/json"
3502
+ }
3503
+ });
3504
+ } catch (error) {
3505
+ console.error("Error when sending message:", error);
3506
+ throw error;
3507
+ }
3508
+ },
3509
+ async sentComment({ data }) {
3510
+ try {
3511
+ const env2 = getEnv();
3512
+ const jsonData = {
3513
+ context: {
3514
+ tz: "Asia/Saigon",
3515
+ uid: 2,
3516
+ allowed_company_ids: [1],
3517
+ mail_post_autofollow: false,
3518
+ temporary_id: 142183.01
3519
+ },
3520
+ post_data: {
3521
+ body: data.message,
3522
+ message_type: "comment",
3523
+ attachment_ids: data.attachment_ids,
3524
+ attachment_tokens: [],
3525
+ subtype_xmlid: data.subtype
3526
+ },
3527
+ thread_id: Number(data.thread_id),
3528
+ thread_model: data.thread_model
3529
+ };
3530
+ return env2.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
3531
+ headers: {
3532
+ "Content-Type": "application/json"
3533
+ }
3534
+ });
3535
+ } catch (error) {
3536
+ console.error("Error when sent message:", error);
3537
+ throw error;
3538
+ }
3539
+ },
3540
+ async deleteComment({ data }) {
3541
+ try {
3542
+ const env2 = getEnv();
3543
+ const jsonData = {
3544
+ attachment_ids: [],
3545
+ attachment_tokens: [],
3546
+ body: "",
3547
+ message_id: data.message_id
3548
+ };
3549
+ return env2.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
3550
+ headers: {
3551
+ "Content-Type": "application/json"
3552
+ }
3553
+ });
3554
+ } catch (error) {
3555
+ console.error("Error when sent message:", error);
3556
+ throw error;
3557
+ }
3558
+ },
3559
+ async getImage({ data }) {
3560
+ try {
3561
+ const env2 = getEnv();
3562
+ return env2.requests.get(
3563
+ `${"/web/image" /* IMAGE_PATH */}?filename=${data.filename}&unique=${data.checksum}&width=1920&height=300`,
3564
+ {
3565
+ headers: {
3566
+ "Content-Type": "application/json"
3567
+ }
3568
+ }
3569
+ );
3570
+ } catch (error) {
3571
+ console.error("Error when sent message:", error);
3572
+ throw error;
3573
+ }
3574
+ },
3575
+ async uploadImage({ data }) {
3576
+ try {
3577
+ const env2 = getEnv();
3578
+ return env2.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
3579
+ headers: {
3580
+ "Content-Type": "multipart/form-data"
3581
+ }
3582
+ });
3583
+ } catch (error) {
3584
+ console.error("Error when sent message:", error);
3585
+ throw error;
3586
+ }
3587
+ },
3588
+ async getFormView({ data }) {
3589
+ try {
3590
+ const env2 = getEnv();
3591
+ const jsonData = {
3592
+ model: data.model,
3593
+ method: "get_formview_action",
3594
+ ids: data.id ? [data.id] : [],
3595
+ with_context: data.context
3596
+ };
3597
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3598
+ headers: {
3599
+ "Content-Type": "application/json"
3600
+ }
3601
+ });
3602
+ } catch (error) {
3603
+ console.error("Error when fetching form view:", error);
3604
+ throw error;
3605
+ }
3606
+ },
3607
+ async changeStatus({ data }) {
3608
+ const env2 = getEnv();
3609
+ const vals = {
3610
+ [data.name]: data.stage_id
3611
+ };
3612
+ const jsonData = {
3613
+ model: data.model,
3614
+ method: "web_save",
3615
+ with_context: {
3616
+ lang: data.lang,
3617
+ allowed_company_ids: [1],
3618
+ uid: 2,
3619
+ search_default_my_ticket: true,
3620
+ search_default_is_open: true
3621
+ },
3622
+ ids: [data.id],
3623
+ kwargs: {
3624
+ vals,
3625
+ specification: {}
3626
+ }
3627
+ };
3628
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3629
+ headers: {
3630
+ "Content-Type": "application/json"
3631
+ }
3632
+ });
3633
+ }
3634
+ };
3635
+ var form_service_default = FormService;
3636
+
3637
+ // src/services/model-service/index.ts
3638
+ var OBJECT_POSITION = 2;
3639
+ var ModelService = {
3640
+ async getAll({ data }) {
3641
+ const env2 = getEnv();
3642
+ const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3643
+ fields: data.fields,
3644
+ groupby: data.groupby
3645
+ } : {
3646
+ count_limit: 10001,
3647
+ order: data.sort,
3648
+ specification: data.specification
3649
+ };
3650
+ const jsonData = {
3651
+ model: String(data.model),
3652
+ method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
3653
+ ids: data.ids,
3654
+ with_context: data.context,
3655
+ kwargs: {
3656
+ domain: data.domain,
3657
+ limit: data.limit,
3658
+ offset: data.offset,
3659
+ ...jsonReadGroup
3660
+ }
3661
+ };
3662
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3663
+ headers: {
3664
+ "Content-Type": "application/json"
3665
+ }
3666
+ });
3667
+ },
3668
+ async getList({
3669
+ model,
3670
+ ids = [],
3671
+ specification = {},
3672
+ domain = [],
3673
+ offset,
3674
+ order,
3675
+ context = {},
3676
+ limit = 10
3677
+ }) {
3678
+ const env2 = getEnv();
3679
+ const jsonData = {
3680
+ model,
3681
+ method: "web_search_read" /* WEB_SEARCH_READ */,
3682
+ ids,
3683
+ with_context: context,
3684
+ kwargs: {
3685
+ specification,
3686
+ domain,
3687
+ limit,
3688
+ offset,
3689
+ order
3690
+ }
3691
+ };
3692
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3693
+ headers: {
3694
+ "Content-Type": "application/json"
3695
+ }
3696
+ });
3697
+ },
3698
+ async getDetail({
3699
+ ids = [],
3700
+ model,
3701
+ specification,
3702
+ context
3703
+ }) {
3704
+ const env2 = getEnv();
3705
+ const jsonData = {
3706
+ model,
3707
+ method: "web_read" /* WEB_READ */,
3708
+ ids,
3709
+ with_context: context,
3710
+ kwargs: {
3711
+ specification
3712
+ }
3713
+ };
3714
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3715
+ headers: {
3716
+ "Content-Type": "application/json"
3717
+ }
3718
+ });
3719
+ },
3720
+ async save({
3721
+ model,
3722
+ ids = [],
3723
+ data = {},
3724
+ specification = {},
3725
+ context = {}
3726
+ }) {
3727
+ const env2 = getEnv();
3728
+ const jsonData = {
3729
+ model,
3730
+ method: "web_save" /* WEB_SAVE */,
3731
+ with_context: context,
3732
+ ids,
3733
+ kwargs: {
3734
+ vals: data,
3735
+ specification
3736
+ }
3737
+ };
3738
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3739
+ headers: {
3740
+ "Content-Type": "application/json"
3741
+ }
3742
+ });
3743
+ },
3744
+ async delete({ ids = [], model }) {
3745
+ const env2 = getEnv();
3746
+ const jsonData = {
3747
+ model,
3748
+ method: "unlink" /* UNLINK */,
3749
+ ids
3750
+ };
3751
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3752
+ headers: {
3753
+ "Content-Type": "application/json"
3754
+ }
3755
+ });
3756
+ },
3757
+ async onChange({
3758
+ ids = [],
3759
+ model,
3760
+ object,
3761
+ specification,
3762
+ context,
3763
+ fieldChange
3764
+ }) {
3765
+ const env2 = getEnv();
3766
+ const jsonData = {
3767
+ model,
3768
+ method: "onchange" /* ONCHANGE */,
3769
+ ids,
3770
+ with_context: context,
3771
+ args: [
3772
+ object ? object : {},
3773
+ fieldChange ? fieldChange : [],
3774
+ specification
3775
+ ]
3776
+ };
3777
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3778
+ headers: {
3779
+ "Content-Type": "application/json"
3780
+ }
3781
+ });
3782
+ },
3783
+ async getListFieldsOnchange({ model }) {
3784
+ const env2 = getEnv();
3785
+ const jsonData = {
3786
+ model,
3787
+ method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
3788
+ };
3789
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3790
+ headers: {
3791
+ "Content-Type": "application/json"
3792
+ }
3793
+ });
3794
+ },
3795
+ parseORMOdoo(data) {
3796
+ for (const key in data) {
3797
+ if (key === "display_name") {
3798
+ delete data[key];
3799
+ }
3800
+ if (!data[key] && data[key] !== 0) {
3801
+ data[key] = false;
3802
+ } else if (data[key] === "Draft") {
3803
+ data[key] = "/";
3804
+ }
3805
+ }
3806
+ return { ...data };
3807
+ },
3808
+ toDataJS(data, viewData, model) {
3809
+ for (const key in data) {
3810
+ if (data[key] === false) {
3811
+ if (viewData && model) {
3812
+ if (viewData?.models?.[model]?.[key]?.type !== "boolean" /* BOOLEAN */) {
3813
+ data[key] = null;
3814
+ }
3815
+ } else {
3816
+ data[key] = null;
3817
+ }
3818
+ } else if (data[key] === "/") {
3819
+ data[key] = "Draft";
3820
+ } else if (data[key] !== false) {
3821
+ if (model !== void 0) {
3822
+ if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */ || viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
3823
+ data[key] = (data[key] ??= [])?.map((item, index) => {
3824
+ const relation = viewData?.models?.[model]?.[key]?.relation;
3825
+ if (relation !== void 0) {
3826
+ if (viewData?.models?.[relation]) {
3827
+ if (item?.length >= 3) {
3828
+ if (item[0] === 2 /* DELETE */) {
3829
+ delete data[key][index];
3830
+ return;
3831
+ }
3832
+ return ModelService.toDataJS(
3833
+ { ...item[OBJECT_POSITION], id: `virtual_${index}` },
3834
+ viewData,
3835
+ relation
3836
+ );
3837
+ } else {
3838
+ return ModelService.toDataJS(item, viewData, relation);
3839
+ }
3840
+ } else {
3841
+ if (item?.length >= 3) {
3842
+ if (!item[OBJECT_POSITION] || item[0] === 2 /* DELETE */) {
3843
+ delete data[key][index];
3844
+ return;
3845
+ }
3846
+ return item[OBJECT_POSITION];
3847
+ } else {
3848
+ return item;
3849
+ }
3850
+ }
3851
+ }
3852
+ });
3853
+ }
3854
+ }
3855
+ }
3856
+ }
3857
+ return { ...data };
3858
+ }
3859
+ };
3860
+ var model_service_default = ModelService;
3861
+
3862
+ // src/services/user-service/index.ts
3863
+ var UserService = {
3864
+ async getProfile() {
3865
+ const env2 = getEnv();
3866
+ return env2.requests.get("/userinfo" /* PROFILE_PATH */, {
3867
+ headers: {
3868
+ "Content-Type": "application/x-www-form-urlencoded"
3869
+ }
3870
+ });
3871
+ },
3872
+ async getUser({ context, id }) {
3873
+ const env2 = getEnv();
3874
+ const jsonData = {
3875
+ model: "res.users",
3876
+ method: "web_read",
3877
+ ids: [id],
3878
+ with_context: context,
3879
+ kwargs: {
3880
+ specification: {
3881
+ display_name: {},
3882
+ image_1920: {},
3883
+ name: {},
3884
+ login: {},
3885
+ email: {},
3886
+ password: {},
3887
+ visible_group_id: {
3888
+ fields: {
3889
+ id: {},
3890
+ display_name: {}
3891
+ }
3892
+ },
3893
+ company_id: {
3894
+ fields: {
3895
+ id: {},
3896
+ display_name: {}
3897
+ }
3898
+ }
3899
+ }
3900
+ }
3901
+ };
3902
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3903
+ headers: {
3904
+ "Content-Type": "application/json"
3905
+ }
3906
+ });
3907
+ },
3908
+ switchUserLocale: async ({ id, values }) => {
3909
+ const env2 = getEnv();
3910
+ const jsonData = {
3911
+ model: "res.users",
3912
+ domain: [["id", "=", id]],
3913
+ values
3914
+ };
3915
+ return env2?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
3916
+ headers: {
3917
+ "Content-Type": "application/json"
3918
+ }
3919
+ });
3920
+ }
3921
+ };
3922
+ var user_service_default = UserService;
3923
+
3924
+ // src/services/view-service/index.ts
3925
+ var ViewService = {
3926
+ async getView({
3927
+ model,
3928
+ views,
3929
+ context = {},
3930
+ options = {},
3931
+ aid
3932
+ }) {
3933
+ const env2 = getEnv();
3934
+ const defaultOptions = {
3935
+ load_filters: true,
3936
+ toolbar: true,
3937
+ action_id: aid
3938
+ };
3939
+ const jsonDataView = {
3940
+ model,
3941
+ method: "get_fields_view_v2" /* GET_FIELD_VIEW */,
3942
+ kwargs: {
3943
+ views,
3944
+ options: { ...options, ...defaultOptions }
3945
+ },
3946
+ with_context: context
3947
+ };
3948
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
3949
+ headers: {
3950
+ "Content-Type": "application/json"
3951
+ }
3952
+ });
3953
+ },
3954
+ async getMenu(context) {
3955
+ const env2 = getEnv();
3956
+ const jsonData = {
3957
+ model: "ir.ui.menu" /* MENU */,
3958
+ method: "web_search_read" /* WEB_SEARCH_READ */,
3959
+ ids: [],
3960
+ with_context: context,
3961
+ kwargs: {
3962
+ specification: {
3963
+ active: {},
3964
+ name: {},
3965
+ is_display: {},
3966
+ sequence: {},
3967
+ complete_name: {},
3968
+ action: {
3969
+ fields: {
3970
+ display_name: {},
3971
+ type: {},
3972
+ binding_view_types: {}
3973
+ // res_model: {},
3974
+ }
3975
+ },
3976
+ url_icon: {},
3977
+ web_icon: {},
3978
+ web_icon_data: {},
3979
+ groups_id: {
3980
+ fields: {
3981
+ full_name: {}
3982
+ },
3983
+ limit: 40,
3984
+ order: ""
3985
+ },
3986
+ display_name: {},
3987
+ child_id: {
3988
+ fields: {
3989
+ active: {},
3990
+ name: {},
3991
+ is_display: {},
3992
+ sequence: {},
3993
+ complete_name: {},
3994
+ action: {
3995
+ fields: {
3996
+ display_name: {},
3997
+ type: {},
3998
+ binding_view_types: {}
3999
+ // res_model: {},
4000
+ }
4001
+ },
4002
+ url_icon: {},
4003
+ web_icon: {},
4004
+ web_icon_data: {},
4005
+ groups_id: {
4006
+ fields: {
4007
+ full_name: {}
4008
+ },
4009
+ limit: 40,
4010
+ order: ""
4011
+ },
4012
+ display_name: {},
4013
+ child_id: {
4014
+ fields: {
4015
+ active: {},
4016
+ name: {},
4017
+ is_display: {},
4018
+ sequence: {},
4019
+ complete_name: {},
4020
+ action: {
4021
+ fields: {
4022
+ display_name: {},
4023
+ type: {},
4024
+ binding_view_types: {}
4025
+ // res_model: {},
4026
+ }
4027
+ },
4028
+ url_icon: {},
4029
+ web_icon: {},
4030
+ web_icon_data: {},
4031
+ groups_id: {
4032
+ fields: {
4033
+ full_name: {}
4034
+ },
4035
+ limit: 40,
4036
+ order: ""
4037
+ },
4038
+ display_name: {},
4039
+ child_id: {
4040
+ fields: {
4041
+ active: {},
4042
+ name: {},
4043
+ is_display: {},
4044
+ sequence: {},
4045
+ complete_name: {},
4046
+ action: {
4047
+ fields: {
4048
+ display_name: {},
4049
+ type: {},
4050
+ binding_view_types: {}
4051
+ // res_model: {},
4052
+ }
4053
+ },
4054
+ url_icon: {},
4055
+ web_icon: {},
4056
+ web_icon_data: {},
4057
+ groups_id: {
4058
+ fields: {
4059
+ full_name: {}
4060
+ },
4061
+ limit: 40,
4062
+ order: ""
4063
+ },
4064
+ display_name: {},
4065
+ child_id: {
4066
+ fields: {},
4067
+ limit: 40,
4068
+ order: ""
4069
+ }
4070
+ },
4071
+ limit: 40,
4072
+ order: ""
4073
+ }
4074
+ },
4075
+ limit: 40,
4076
+ order: ""
4077
+ }
4078
+ },
4079
+ limit: 40,
4080
+ order: ""
4081
+ }
4082
+ },
4083
+ domain: [
4084
+ "&",
4085
+ ["is_display", "=", true],
4086
+ "&",
4087
+ ["active", "=", true],
4088
+ ["parent_id", "=", false]
4089
+ ]
4090
+ }
4091
+ };
4092
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4093
+ headers: {
4094
+ "Content-Type": "application/json"
4095
+ }
4096
+ });
4097
+ },
4098
+ async getSelectionItem({ data }) {
4099
+ const env2 = getEnv();
4100
+ const jsonData = {
4101
+ model: data.model,
4102
+ ids: [],
4103
+ method: "get_data_select",
4104
+ with_context: data.context,
4105
+ kwargs: {
4106
+ count_limit: 10001,
4107
+ domain: data.domain ? data.domain : [],
4108
+ offset: 0,
4109
+ order: "",
4110
+ specification: data?.specification ?? {
4111
+ id: {},
4112
+ name: {},
4113
+ display_name: {}
4114
+ }
4115
+ }
4116
+ };
4117
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4118
+ headers: {
4119
+ "Content-Type": "application/json"
4120
+ }
4121
+ });
4122
+ },
4123
+ async loadMessages() {
4124
+ const env2 = getEnv();
4125
+ return env2.requests.post(
4126
+ "/load_message_failures" /* LOAD_MESSAGE */,
4127
+ {},
4128
+ {
4129
+ headers: {
4130
+ "Content-Type": "application/json"
4131
+ }
4132
+ }
4133
+ );
4134
+ },
4135
+ async getVersion() {
4136
+ const env2 = getEnv();
4137
+ return env2?.requests.get("", {
4138
+ headers: {
4139
+ "Content-Type": "application/json"
4140
+ }
4141
+ });
4142
+ }
4143
+ };
4144
+ var view_service_default = ViewService;
4145
+
4146
+ // src/hooks/auth/use-forgot-password.ts
4147
+ var useForgotPassword = () => {
4148
+ return useMutation({
4149
+ mutationFn: (email) => {
4150
+ return auth_service_default.forgotPassword(email);
4151
+ }
4152
+ });
4153
+ };
4154
+ var use_forgot_password_default = useForgotPassword;
4155
+
4156
+ // src/hooks/auth/use-get-provider.ts
4157
+ import { useMutation as useMutation2 } from "@tanstack/react-query";
4158
+ var useGetProvider = () => {
4159
+ return useMutation2({
4160
+ mutationFn: (data) => {
4161
+ return auth_service_default.getProviders(data?.db);
4162
+ }
4163
+ });
4164
+ };
4165
+ var use_get_provider_default = useGetProvider;
4166
+
4167
+ // src/hooks/auth/use-isvalid-token.ts
4168
+ import { useMutation as useMutation3 } from "@tanstack/react-query";
4169
+ var useIsValidToken = () => {
4170
+ return useMutation3({
4171
+ mutationFn: (token) => {
4172
+ return auth_service_default.isValidToken(token);
4173
+ }
4174
+ });
4175
+ };
4176
+ var use_isvalid_token_default = useIsValidToken;
4177
+
4178
+ // src/hooks/auth/use-login-credential.ts
4179
+ import { useMutation as useMutation4 } from "@tanstack/react-query";
4180
+ var useLoginCredential = () => {
4181
+ return useMutation4({
4182
+ mutationFn: (data) => {
4183
+ return auth_service_default.login(data);
4184
+ }
4185
+ });
4186
+ };
4187
+ var use_login_credential_default = useLoginCredential;
4188
+
4189
+ // src/hooks/auth/use-login-socical.ts
4190
+ import { useMutation as useMutation5 } from "@tanstack/react-query";
4191
+ var useLoginSocial = () => {
4192
+ return useMutation5({
4193
+ mutationFn: (data) => {
4194
+ return auth_service_default.loginSocial(data);
4195
+ }
4196
+ });
4197
+ };
4198
+ var use_login_socical_default = useLoginSocial;
4199
+
4200
+ // src/hooks/auth/use-reset-password.ts
4201
+ import { useMutation as useMutation6 } from "@tanstack/react-query";
4202
+ var useResetPassword = () => {
4203
+ return useMutation6({
4204
+ mutationFn: (request) => {
4205
+ return auth_service_default.resetPassword(request.data, request.token);
4206
+ }
4207
+ });
4208
+ };
4209
+ var use_reset_password_default = useResetPassword;
4210
+
4211
+ // src/hooks/auth/use-update-password.ts
4212
+ import { useMutation as useMutation7 } from "@tanstack/react-query";
4213
+ var useUpdatePassword = () => {
4214
+ return useMutation7({
4215
+ mutationFn: (request) => {
4216
+ return auth_service_default.updatePassword(request.data, request.token);
4217
+ }
4218
+ });
4219
+ };
4220
+ var use_update_password_default = useUpdatePassword;
4221
+
4222
+ // src/hooks/common/use-field.ts
4223
+ import React, { useEffect } from "react";
4224
+ var useField = (props) => {
4225
+ const [invisible, setInvisible] = React.useState(true);
4226
+ const [required, setRequired] = React.useState(false);
4227
+ const [readonly, setReadOnly] = React.useState(false);
4228
+ const {
4229
+ invisible: inv,
4230
+ required: req,
4231
+ readonly: rea,
4232
+ onchangeData,
4233
+ rootField,
4234
+ index,
4235
+ name
4236
+ } = props;
4237
+ const nameField = rootField ? `${rootField?.name}.${index}.${name}` : null;
4238
+ useEffect(() => {
4239
+ if (onchangeData && Object.keys(onchangeData).length > 0) {
4240
+ setRequired(
4241
+ typeof req === "object" ? matchDomains(onchangeData, req) : checkDomain(onchangeData, req)
4242
+ );
4243
+ setInvisible(matchDomains(onchangeData, inv));
4244
+ setReadOnly(
4245
+ typeof req === "object" ? matchDomains(onchangeData, rea) : checkDomain(onchangeData, rea)
4246
+ );
4247
+ }
4248
+ }, [onchangeData]);
4249
+ return {
4250
+ invisible,
4251
+ required,
4252
+ readonly,
4253
+ nameField
4254
+ };
4255
+ };
4256
+ var use_field_default = useField;
4257
+
4258
+ // src/hooks/company/use-get-company-info.ts
4259
+ import { useMutation as useMutation8 } from "@tanstack/react-query";
4260
+ var useGetCompanyInfo = () => {
4261
+ return useMutation8({
4262
+ mutationFn: (id) => company_service_default.getInfoCompany(id)
4263
+ });
4264
+ };
4265
+ var use_get_company_info_default = useGetCompanyInfo;
4266
+
4267
+ // src/hooks/company/use-get-current-company.ts
4268
+ import { useMutation as useMutation9 } from "@tanstack/react-query";
4269
+ var useGetCurrentCompany = () => {
4270
+ return useMutation9({
4271
+ mutationFn: () => company_service_default.getCurrentCompany()
4272
+ });
4273
+ };
4274
+ var use_get_current_company_default = useGetCurrentCompany;
4275
+
4276
+ // src/hooks/form/use-change-status.ts
4277
+ import { useMutation as useMutation10 } from "@tanstack/react-query";
4278
+ var useChangeStatus = () => {
4279
+ return useMutation10({
4280
+ mutationFn: ({ data }) => {
4281
+ return form_service_default.changeStatus({
4282
+ data
4283
+ });
4284
+ }
4285
+ });
4286
+ };
4287
+ var use_change_status_default = useChangeStatus;
4288
+
4289
+ // src/hooks/form/use-delete-comment.ts
4290
+ import { useMutation as useMutation11 } from "@tanstack/react-query";
4291
+ var useDeleteComment = () => {
4292
+ return useMutation11({
4293
+ mutationFn: ({ data }) => form_service_default.deleteComment({
4294
+ data
4295
+ })
4296
+ });
4297
+ };
4298
+ var use_delete_comment_default = useDeleteComment;
4299
+
4300
+ // src/hooks/form/use-get-comment.ts
4301
+ import { useQuery } from "@tanstack/react-query";
4302
+ var useGetComment = ({ data, queryKey }) => {
4303
+ return useQuery({
4304
+ queryKey,
4305
+ queryFn: () => form_service_default.getComment({ data }).then((res) => {
4306
+ if (res) {
4307
+ return res;
4308
+ }
4309
+ }),
4310
+ enabled: !!data.thread_id && !isNaN(data.thread_id),
4311
+ refetchOnWindowFocus: false
4312
+ });
4313
+ };
4314
+ var use_get_comment_default = useGetComment;
4315
+
4316
+ // src/hooks/form/use-get-form-view.ts
4317
+ import { useQuery as useQuery2 } from "@tanstack/react-query";
4318
+ var useGetFormView = ({
4319
+ data,
4320
+ queryKey,
4321
+ enabled
4322
+ }) => {
4323
+ return useQuery2({
4324
+ queryKey,
4325
+ queryFn: () => form_service_default.getFormView({ data }).then((res) => {
4326
+ if (res) {
4327
+ return res;
4328
+ }
4329
+ }),
4330
+ enabled,
4331
+ refetchOnWindowFocus: false
4332
+ });
4333
+ };
4334
+ var use_get_form_view_default = useGetFormView;
4335
+
4336
+ // src/hooks/form/use-get-image.ts
4337
+ import { useQuery as useQuery3 } from "@tanstack/react-query";
4338
+ var useGetImage = ({
4339
+ data,
4340
+ queryKey,
4341
+ src
4342
+ }) => {
4343
+ return useQuery3({
4344
+ queryKey,
4345
+ queryFn: () => form_service_default.getImage({ data }).then((res) => {
4346
+ if (res) {
4347
+ return res;
4348
+ }
4349
+ }),
4350
+ enabled: !src && !isBase64File(src),
4351
+ refetchOnWindowFocus: false
4352
+ });
4353
+ };
4354
+ var use_get_image_default = useGetImage;
4355
+
4356
+ // src/hooks/form/use-send-comment.ts
4357
+ import { useMutation as useMutation12 } from "@tanstack/react-query";
4358
+ var useSendComment = () => {
4359
+ return useMutation12({
4360
+ mutationFn: ({ data }) => form_service_default.sentComment({
4361
+ data
4362
+ })
4363
+ });
4364
+ };
4365
+ var use_send_comment_default = useSendComment;
4366
+
4367
+ // src/hooks/form/use-upload-image.ts
4368
+ import { useMutation as useMutation13 } from "@tanstack/react-query";
4369
+ var useUploadImage = () => {
4370
+ return useMutation13({
4371
+ mutationFn: ({ data }) => form_service_default.uploadImage({
4372
+ data
4373
+ })
4374
+ });
4375
+ };
4376
+ var use_upload_image_default = useUploadImage;
4377
+
4378
+ // src/hooks/excel/use-export-excel.ts
4379
+ import { useMutation as useMutation14 } from "@tanstack/react-query";
4380
+ var useExportExcel = () => {
4381
+ return useMutation14({
4382
+ mutationFn: ({
4383
+ model,
4384
+ domain,
4385
+ ids,
4386
+ fields,
4387
+ type,
4388
+ importCompat,
4389
+ context,
4390
+ groupby
4391
+ }) => excel_service_default.exportExcel({
4392
+ model,
4393
+ domain,
4394
+ ids,
4395
+ fields,
4396
+ type,
4397
+ importCompat,
4398
+ context,
4399
+ groupby
4400
+ })
4401
+ });
4402
+ };
4403
+ var use_export_excel_default = useExportExcel;
4404
+
4405
+ // src/hooks/excel/use-get-field-export.ts
4406
+ import { useMutation as useMutation15 } from "@tanstack/react-query";
4407
+ var useGetFieldExport = () => {
4408
+ return useMutation15({
4409
+ mutationFn: ({
4410
+ ids,
4411
+ model,
4412
+ isShow,
4413
+ parentField,
4414
+ fieldType,
4415
+ parentName,
4416
+ prefix,
4417
+ name,
4418
+ context,
4419
+ importCompat
4420
+ }) => excel_service_default.getFieldExport({
4421
+ ids,
4422
+ model,
4423
+ isShow,
4424
+ parentField,
4425
+ fieldType,
4426
+ parentName,
4427
+ prefix,
4428
+ name,
4429
+ context,
4430
+ importCompat
4431
+ })
4432
+ });
4433
+ };
4434
+ var use_get_field_export_default = useGetFieldExport;
4435
+
4436
+ // src/hooks/excel/use-get-file-excel.ts
4437
+ import { useQuery as useQuery4 } from "@tanstack/react-query";
4438
+ var useGetFileExcel = ({
4439
+ model,
4440
+ context
4441
+ }) => {
4442
+ return useQuery4({
4443
+ queryKey: [],
4444
+ queryFn: () => excel_service_default.getFileExcel({
4445
+ model,
4446
+ context
4447
+ }).then((res) => {
4448
+ if (res) {
4449
+ return res;
4450
+ }
4451
+ return [];
4452
+ }),
4453
+ refetchOnWindowFocus: false
4454
+ });
4455
+ };
4456
+ var use_get_file_excel_default = useGetFileExcel;
4457
+
4458
+ // src/hooks/excel/use-parse-preview.ts
4459
+ import { useMutation as useMutation16 } from "@tanstack/react-query";
4460
+ var useParsePreview = () => {
4461
+ return useMutation16({
4462
+ mutationFn: ({
4463
+ id,
4464
+ selectedSheet,
4465
+ isHeader,
4466
+ context
4467
+ }) => excel_service_default.parsePreview({
4468
+ id,
4469
+ selectedSheet,
4470
+ isHeader,
4471
+ context
4472
+ })
4473
+ });
4474
+ };
4475
+ var use_parse_preview_default = useParsePreview;
4476
+
4477
+ // src/hooks/excel/use-upload-file.ts
4478
+ import { useMutation as useMutation17 } from "@tanstack/react-query";
4479
+ var useUploadFile = () => {
4480
+ return useMutation17({
4481
+ mutationFn: ({ formData }) => excel_service_default.uploadFile({
4482
+ formData
4483
+ })
4484
+ });
4485
+ };
4486
+ var use_upload_file_default = useUploadFile;
4487
+
4488
+ // src/hooks/excel/use-upload-id-file.ts
4489
+ import { useMutation as useMutation18 } from "@tanstack/react-query";
4490
+ var useUploadIdFile = () => {
4491
+ return useMutation18({
4492
+ mutationFn: ({ formData }) => excel_service_default.uploadIdFile({
4493
+ formData
4494
+ })
4495
+ });
4496
+ };
4497
+ var use_upload_id_file_default = useUploadIdFile;
4498
+
4499
+ // src/hooks/excel/uss-execute-import.ts
4500
+ import { useMutation as useMutation19 } from "@tanstack/react-query";
4501
+ var useExecuteImport = () => {
4502
+ return useMutation19({
4503
+ mutationFn: ({
4504
+ fields,
4505
+ columns,
4506
+ idFile,
4507
+ options,
4508
+ dryrun,
4509
+ context
4510
+ }) => excel_service_default.executeImport({
4511
+ fields,
4512
+ columns,
4513
+ idFile,
4514
+ options,
4515
+ dryrun,
4516
+ context
4517
+ })
4518
+ });
4519
+ };
4520
+ var uss_execute_import_default = useExecuteImport;
4521
+
4522
+ // src/hooks/model/use-delete.ts
4523
+ import { useMutation as useMutation20 } from "@tanstack/react-query";
4524
+ var useDelete = () => {
4525
+ return useMutation20({
4526
+ mutationFn: ({ ids, model }) => model_service_default.delete({ ids, model })
4527
+ });
4528
+ };
4529
+ var use_delete_default = useDelete;
4530
+
4531
+ // src/hooks/model/use-get-all.ts
4532
+ import { useQuery as useQuery5 } from "@tanstack/react-query";
4533
+ var useGetAll = ({ data, queryKey, viewResponse }) => {
4534
+ return useQuery5({
4535
+ queryKey,
4536
+ queryFn: () => model_service_default.getAll({ data }).then((res) => {
4537
+ if (res) {
4538
+ return res;
4539
+ }
4540
+ }),
4541
+ enabled: !!data.specification && !!data.model && !!data.domain && !!viewResponse,
4542
+ refetchOnWindowFocus: false
4543
+ // placeholderData: keepPreviousData,
4544
+ });
4545
+ };
4546
+ var use_get_all_default = useGetAll;
4547
+
4548
+ // src/hooks/model/use-get-detail.ts
4549
+ import { useMutation as useMutation21 } from "@tanstack/react-query";
4550
+ var useGetDetail = () => {
4551
+ return useMutation21({
4552
+ mutationFn: ({
4553
+ model,
4554
+ ids,
4555
+ specification,
4556
+ context
4557
+ }) => model_service_default.getDetail({
4558
+ model,
4559
+ ids,
4560
+ specification,
4561
+ context
4562
+ })
4563
+ });
4564
+ };
4565
+ var use_get_detail_default = useGetDetail;
4566
+
4567
+ // src/hooks/model/use-get-field-onchange.ts
4568
+ import { useQuery as useQuery6 } from "@tanstack/react-query";
4569
+ var useGetFieldOnChange = ({ model }) => {
4570
+ return useQuery6({
4571
+ queryKey: [`field-onchange-${model}`, model],
4572
+ queryFn: () => model_service_default.getListFieldsOnchange({
4573
+ model
4574
+ }).then((res) => {
4575
+ if (res) {
4576
+ return res;
4577
+ }
4578
+ }),
4579
+ refetchOnWindowFocus: false,
4580
+ staleTime: Infinity
4581
+ });
4582
+ };
4583
+ var use_get_field_onchange_default = useGetFieldOnChange;
4584
+
4585
+ // src/models/base-model/index.ts
4586
+ var BaseModel = class {
4587
+ name;
4588
+ view;
4589
+ actContext;
4590
+ fields;
4591
+ constructor(init) {
4592
+ this.name = init.name;
4593
+ this.view = init.view;
4594
+ this.actContext = init.actContext;
4595
+ this.fields = init.fields;
4596
+ }
4597
+ getSpecificationByFields({
4598
+ fields = [],
4599
+ specification = {},
4600
+ modelsData,
4601
+ model,
4602
+ modelRoot
4603
+ }) {
4604
+ if (Array.isArray(fields)) {
4605
+ let spec = { ...specification };
4606
+ fields.forEach((field) => {
4607
+ if (!field?.type_co || field?.name && field?.type_co === "field" /* FIELD */) {
4608
+ if (modelsData?.[model]?.[field?.name]) {
4609
+ if (modelsData?.[model]?.[field?.name]?.type === "one2many" /* ONE2MANY */ || modelsData?.[model]?.[field?.name]?.type === "many2many" /* MANY2MANY */) {
4610
+ const relation = modelsData?.[model]?.[field?.name]?.relation;
4611
+ const modelRelation = modelsData?.[relation];
4612
+ if (modelRelation) {
4613
+ spec[field?.name] = {
4614
+ fields: {}
4615
+ };
4616
+ if (modelRoot && modelRoot === relation) {
4617
+ spec[field?.name].fields = { id: {} };
4618
+ } else {
4619
+ spec[field?.name].fields = this.getSpecificationByFields({
4620
+ fields: Object.values(modelRelation),
4621
+ specification: {},
4622
+ modelsData,
4623
+ model: relation,
4624
+ modelRoot: model
4625
+ });
4626
+ }
4627
+ } else {
4628
+ spec[field?.name] = {
4629
+ fields: {
4630
+ id: {},
4631
+ display_name: {}
4632
+ }
4633
+ };
4634
+ }
4635
+ } else if (modelsData?.[model]?.[field?.name]?.type === "many2one" /* MANY2ONE */) {
4636
+ spec[field?.name] = {
4637
+ fields: {
4638
+ id: {},
4639
+ display_name: {},
4640
+ ...WIDGETAVATAR[field?.widget] ? { image_256: {} } : {},
4641
+ ...field?.name === "currency_id" && fields?.find((item) => item?.widget === "monetary") ? { symbol: {} } : {},
4642
+ ...field?.widget === "many2many_binary" ? { mimetype: {} } : {}
4643
+ }
4644
+ };
4645
+ } else {
4646
+ spec[field?.name] = {};
4647
+ }
4648
+ }
4649
+ } else if (field?.type_co === "group" /* GROUP */ || field?.type_co === "div" /* DIV */ || field?.type_co === "span" /* SPAN */) {
4650
+ const specGroup = this.getSpecificationByFields({
4651
+ fields: field?.fields,
4652
+ specification: spec,
4653
+ modelsData,
4654
+ model
4655
+ });
4656
+ spec = { ...spec, ...specGroup };
4657
+ } else if (field?.type_co === "tree" /* TREE */ || field?.type_co === "list" /* LIST */) {
4658
+ const relation = modelsData?.[model]?.[field?.name]?.relation;
4659
+ const specTreee = this.getSpecificationByFields({
4660
+ fields: field?.fields,
4661
+ specification: {},
4662
+ modelsData,
4663
+ model: relation,
4664
+ modelRoot: model
4665
+ });
4666
+ spec = {
4667
+ ...spec,
4668
+ [field?.name]: {
4669
+ fields: { ...spec?.[field?.name]?.fields, ...specTreee }
4670
+ }
4671
+ };
4672
+ }
4673
+ });
4674
+ return spec;
4675
+ } else {
4676
+ console.warn("fields is not array");
4677
+ }
4678
+ }
4679
+ getTreeProps() {
4680
+ const props = this.view?.views?.list || {};
4681
+ return props;
4682
+ }
4683
+ getTreeFields() {
4684
+ const fields = this.view?.views?.list?.fields || [];
4685
+ return fields;
4686
+ }
4687
+ getSpecification() {
4688
+ const specInit = {};
4689
+ const modelData = this.view?.models || {};
4690
+ const specification = this.getSpecificationByFields({
4691
+ fields: this.fields,
4692
+ specification: specInit,
4693
+ modelsData: modelData,
4694
+ model: this.name,
4695
+ modelRoot: ""
4696
+ });
4697
+ return specification;
4698
+ }
4699
+ };
4700
+ var base_model_default = BaseModel;
4701
+
4702
+ // src/hooks/model/use-model.ts
4703
+ var useModel = () => {
4704
+ const initModel = (modelData) => {
4705
+ switch (modelData?.name) {
4706
+ default:
4707
+ return new base_model_default(modelData);
4708
+ }
4709
+ };
4710
+ return {
4711
+ initModel
4712
+ };
4713
+ };
4714
+ var use_model_default = useModel;
4715
+
4716
+ // src/hooks/model/use-odoo-data-transform.ts
4717
+ var useOdooDataTransform = () => {
4718
+ return {
4719
+ toDataJS: model_service_default.toDataJS,
4720
+ parseORM: model_service_default.parseORMOdoo
4721
+ };
4722
+ };
4723
+ var use_odoo_data_transform_default = useOdooDataTransform;
4724
+
4725
+ // src/hooks/model/use-onchange-form.ts
4726
+ import { useMutation as useMutation22 } from "@tanstack/react-query";
4727
+ var useOnChangeForm = () => {
4728
+ return useMutation22({
4729
+ mutationFn: ({
4730
+ ids,
4731
+ model,
4732
+ specification,
4733
+ context,
4734
+ object,
4735
+ fieldChange
4736
+ }) => model_service_default.onChange({
4737
+ ids,
4738
+ model,
4739
+ specification,
4740
+ context,
4741
+ object,
4742
+ fieldChange
4743
+ })
4744
+ });
4745
+ };
4746
+ var use_onchange_form_default = useOnChangeForm;
4747
+
4748
+ // src/hooks/model/use-save.ts
4749
+ import { useMutation as useMutation23 } from "@tanstack/react-query";
4750
+ var useSave = () => {
4751
+ return useMutation23({
4752
+ mutationFn: ({
4753
+ ids,
4754
+ model,
4755
+ data,
4756
+ specification,
4757
+ context
4758
+ }) => model_service_default.save({ ids, model, data, specification, context })
4759
+ });
4760
+ };
4761
+ var use_save_default = useSave;
4762
+
4763
+ // src/hooks/user/use-get-profile.ts
4764
+ import { useMutation as useMutation24 } from "@tanstack/react-query";
4765
+ var useGetProfile = () => {
4766
+ return useMutation24({
4767
+ mutationFn: () => user_service_default.getProfile()
4768
+ });
4769
+ };
4770
+ var use_get_profile_default = useGetProfile;
4771
+
4772
+ // src/hooks/user/use-get-user.ts
4773
+ import { useMutation as useMutation25 } from "@tanstack/react-query";
4774
+ var useGetUser = () => {
4775
+ return useMutation25({
4776
+ mutationFn: ({ id, context }) => user_service_default.getUser({
4777
+ id,
4778
+ context
4779
+ })
4780
+ });
4781
+ };
4782
+ var use_get_user_default = useGetUser;
4783
+
4784
+ // src/hooks/user/use-switch-locale.ts
4785
+ import { useMutation as useMutation26 } from "@tanstack/react-query";
4786
+ var useSwitchLocale = () => {
4787
+ return useMutation26({
4788
+ mutationFn: ({ data }) => {
4789
+ return user_service_default.switchUserLocale({
4790
+ id: data.id,
4791
+ values: data.values
4792
+ });
4793
+ }
4794
+ });
4795
+ };
4796
+ var use_switch_locale_default = useSwitchLocale;
4797
+
4798
+ // src/hooks/view/use-button.ts
4799
+ import { useMutation as useMutation27 } from "@tanstack/react-query";
4800
+ var useButton = () => {
4801
+ return useMutation27({
4802
+ mutationFn: ({
4803
+ model,
4804
+ ids,
4805
+ context,
4806
+ method
4807
+ }) => action_service_default.callButton({
4808
+ model,
4809
+ ids,
4810
+ context,
4811
+ method
4812
+ }),
4813
+ onSuccess: (response) => {
4814
+ return response;
4815
+ }
4816
+ });
4817
+ };
4818
+ var use_button_default = useButton;
4819
+
4820
+ // src/hooks/view/use-duplicate-record.ts
4821
+ import { useMutation as useMutation28 } from "@tanstack/react-query";
4822
+ var useDuplicateRecord = () => {
4823
+ return useMutation28({
4824
+ mutationFn: ({
4825
+ id,
4826
+ model,
4827
+ context
4828
+ }) => action_service_default.duplicateRecord({
4829
+ id,
4830
+ model,
4831
+ context
4832
+ })
4833
+ });
4834
+ };
4835
+ var use_duplicate_record_default = useDuplicateRecord;
4836
+
4837
+ // src/hooks/view/use-get-list-data.ts
4838
+ import { useQuery as useQuery7 } from "@tanstack/react-query";
4839
+ var useGetListData = (listDataProps, queryKey, enabled) => {
4840
+ return useQuery7({
4841
+ queryKey,
4842
+ queryFn: () => model_service_default.getAll({ data: listDataProps }).then((res) => {
4843
+ if (res) {
4844
+ return res;
4845
+ }
4846
+ return [];
4847
+ }),
4848
+ enabled,
4849
+ refetchOnWindowFocus: false,
4850
+ staleTime: 0
4851
+ });
4852
+ };
4853
+ var use_get_list_data_default = useGetListData;
4854
+
4855
+ // src/hooks/view/use-get-menu.ts
4856
+ import { useQuery as useQuery8 } from "@tanstack/react-query";
4857
+ var useGetMenu = ({ context, enabled, queryKey }) => {
4858
+ return useQuery8({
4859
+ queryKey,
4860
+ queryFn: async () => {
4861
+ const res = await view_service_default.getMenu(context);
4862
+ if (res?.records && Array.isArray(res.records) && res.records.length > 0) {
4863
+ return res.records;
4864
+ }
4865
+ return [];
4866
+ },
4867
+ refetchOnWindowFocus: false,
4868
+ staleTime: Infinity,
4869
+ enabled
4870
+ });
4871
+ };
4872
+ var use_get_menu_default = useGetMenu;
4873
+
4874
+ // src/hooks/view/use-get-selection.ts
4875
+ import { useQuery as useQuery9 } from "@tanstack/react-query";
4876
+ var useGetSelection = ({
4877
+ data,
4878
+ queryKey,
4879
+ enabled
4880
+ }) => {
4881
+ return useQuery9({
4882
+ queryKey,
4883
+ queryFn: () => view_service_default.getSelectionItem({ data }),
4884
+ enabled,
4885
+ refetchOnWindowFocus: false
4886
+ });
4887
+ };
4888
+ var use_get_selection_default = useGetSelection;
4889
+
4890
+ // src/hooks/view/use-get-view.ts
4891
+ import { useQuery as useQuery10 } from "@tanstack/react-query";
4892
+ var useGetView = (viewParams, actData) => {
4893
+ return useQuery10({
4894
+ queryKey: ["get_view_by_action" /* GET_VIEW_BY_ACTION */, viewParams],
4895
+ queryFn: () => view_service_default.getView(viewParams),
4896
+ enabled: !!actData,
4897
+ refetchOnWindowFocus: false,
4898
+ staleTime: Infinity
4899
+ });
4900
+ };
4901
+ var use_get_view_default = useGetView;
4902
+
4903
+ // src/hooks/view/use-load-action.ts
4904
+ import { useQuery as useQuery11 } from "@tanstack/react-query";
4905
+ var useLoadAction = ({
4906
+ idAction,
4907
+ context
4908
+ }) => {
4909
+ return useQuery11({
4910
+ queryKey: ["load_action", idAction],
4911
+ queryFn: () => action_service_default.loadAction({
4912
+ idAction,
4913
+ context
4914
+ }),
4915
+ enabled: false,
4916
+ staleTime: Infinity,
4917
+ gcTime: Infinity
4918
+ });
4919
+ };
4920
+ var use_load_action_default = useLoadAction;
4921
+
4922
+ // src/hooks/view/use-print.ts
4923
+ import { useMutation as useMutation29 } from "@tanstack/react-query";
4924
+ var usePrint = () => {
4925
+ return useMutation29({
4926
+ mutationFn: ({ id, report, db }) => action_service_default.print({
4927
+ id,
4928
+ report,
4929
+ db
4930
+ })
4931
+ });
4932
+ };
4933
+ var use_print_default = usePrint;
4934
+
4935
+ // src/hooks/view/use-remove-row.ts
4936
+ import { useMutation as useMutation30 } from "@tanstack/react-query";
4937
+ var useRemoveRow = () => {
4938
+ return useMutation30({
4939
+ mutationFn: ({
4940
+ model,
4941
+ ids,
4942
+ context
4943
+ }) => action_service_default.removeRows({
4944
+ model,
4945
+ ids,
4946
+ context
4947
+ })
4948
+ });
4949
+ };
4950
+ var use_remove_row_default = useRemoveRow;
4951
+
4952
+ // src/hooks/view/use-run-action.ts
4953
+ import { useQuery as useQuery12 } from "@tanstack/react-query";
4954
+ var useRunAction = ({ idAction, context }) => {
4955
+ return useQuery12({
4956
+ queryKey: ["run_action", idAction],
4957
+ queryFn: () => action_service_default.runAction({
4958
+ idAction,
4959
+ context
4960
+ }),
4961
+ enabled: false,
4962
+ staleTime: Infinity,
4963
+ gcTime: Infinity
4964
+ });
4965
+ };
4966
+ var use_run_action_default = useRunAction;
4967
+ export {
4968
+ use_button_default as useButton,
4969
+ use_change_status_default as useChangeStatus,
4970
+ use_delete_default as useDelete,
4971
+ use_delete_comment_default as useDeleteComment,
4972
+ use_duplicate_record_default as useDuplicateRecord,
4973
+ uss_execute_import_default as useExecuteImport,
4974
+ use_export_excel_default as useExportExcel,
4975
+ use_field_default as useField,
4976
+ use_forgot_password_default as useForgotPassword,
4977
+ use_get_all_default as useGetAll,
4978
+ use_get_comment_default as useGetComment,
4979
+ use_get_company_info_default as useGetCompanyInfo,
4980
+ use_get_current_company_default as useGetCurrentCompany,
4981
+ use_get_detail_default as useGetDetail,
4982
+ use_get_field_export_default as useGetFieldExport,
4983
+ use_get_field_onchange_default as useGetFieldOnChange,
4984
+ use_get_file_excel_default as useGetFileExcel,
4985
+ use_get_form_view_default as useGetFormView,
4986
+ use_get_image_default as useGetImage,
4987
+ use_get_list_data_default as useGetListData,
4988
+ use_get_menu_default as useGetMenu,
4989
+ use_get_profile_default as useGetProfile,
4990
+ use_get_provider_default as useGetProvider,
4991
+ use_get_selection_default as useGetSelection,
4992
+ use_get_user_default as useGetUser,
4993
+ use_get_view_default as useGetView,
4994
+ use_isvalid_token_default as useIsValidToken,
4995
+ use_load_action_default as useLoadAction,
4996
+ use_login_credential_default as useLoginCredential,
4997
+ use_login_socical_default as useLoginSocial,
4998
+ use_model_default as useModel,
4999
+ use_odoo_data_transform_default as useOdooDataTransform,
5000
+ use_onchange_form_default as useOnChangeForm,
5001
+ use_parse_preview_default as useParsePreview,
5002
+ use_print_default as usePrint,
5003
+ use_remove_row_default as useRemoveRow,
5004
+ use_reset_password_default as useResetPassword,
5005
+ use_run_action_default as useRunAction,
5006
+ use_save_default as useSave,
5007
+ use_send_comment_default as useSendComment,
5008
+ use_switch_locale_default as useSwitchLocale,
5009
+ use_update_password_default as useUpdatePassword,
5010
+ use_upload_file_default as useUploadFile,
5011
+ use_upload_id_file_default as useUploadIdFile,
5012
+ use_upload_image_default as useUploadImage
5013
+ };