@overmap-ai/core 1.0.51 → 1.0.53-add-agent-slice.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 (53) hide show
  1. package/README.md +4 -4
  2. package/dist/forms/builder/constants.d.ts +1 -0
  3. package/dist/forms/builder/utils.d.ts +1 -1
  4. package/dist/forms/fields/QrField/QrField.d.ts +21 -0
  5. package/dist/forms/fields/QrField/QrInput.d.ts +10 -0
  6. package/dist/forms/fields/QrField/index.d.ts +2 -0
  7. package/dist/forms/fields/constants.d.ts +8 -0
  8. package/dist/forms/fields/index.d.ts +1 -0
  9. package/dist/forms/renderer/FormSubmissionBrowser/FormSubmissionBrowser.d.ts +5 -5
  10. package/dist/forms/renderer/FormSubmissionViewer/FormSubmissionViewer.d.ts +3 -3
  11. package/dist/forms/typings.d.ts +5 -2
  12. package/dist/overmap-core.js +1472 -485
  13. package/dist/overmap-core.js.map +1 -1
  14. package/dist/overmap-core.umd.cjs +1472 -486
  15. package/dist/overmap-core.umd.cjs.map +1 -1
  16. package/dist/sdk/sdk.d.ts +3 -1
  17. package/dist/sdk/services/AttachmentService.d.ts +2 -2
  18. package/dist/sdk/services/DocumentService.d.ts +5 -5
  19. package/dist/sdk/services/IssueService.d.ts +2 -2
  20. package/dist/sdk/services/IssueTypeService.d.ts +9 -0
  21. package/dist/sdk/services/TeamService.d.ts +12 -0
  22. package/dist/sdk/services/UserFormService.d.ts +10 -2
  23. package/dist/sdk/services/UserFormSubmissionService.d.ts +9 -2
  24. package/dist/sdk/services/index.d.ts +2 -0
  25. package/dist/store/slices/agentSlice.d.ts +14 -0
  26. package/dist/store/slices/categorySlice.d.ts +7 -1
  27. package/dist/store/slices/documentSlice.d.ts +326 -13
  28. package/dist/store/slices/formRevisionSlice.d.ts +68 -0
  29. package/dist/store/slices/formSlice.d.ts +117 -0
  30. package/dist/store/slices/formSubmissionSlice.d.ts +49 -0
  31. package/dist/store/slices/index.d.ts +6 -1
  32. package/dist/store/slices/issueSlice.d.ts +11 -2
  33. package/dist/store/slices/issueTypeSlice.d.ts +20 -0
  34. package/dist/store/slices/projectFileSlice.d.ts +6 -1
  35. package/dist/store/slices/teamSlice.d.ts +19 -0
  36. package/dist/store/slices/utils.d.ts +1 -0
  37. package/dist/store/slices/workspaceSlice.d.ts +6 -1
  38. package/dist/store/store.d.ts +20 -4
  39. package/dist/style.css +5 -0
  40. package/dist/typings/files.d.ts +11 -1
  41. package/dist/typings/models/attachments.d.ts +11 -15
  42. package/dist/typings/models/base.d.ts +14 -0
  43. package/dist/typings/models/documents.d.ts +18 -7
  44. package/dist/typings/models/forms.d.ts +9 -13
  45. package/dist/typings/models/index.d.ts +2 -0
  46. package/dist/typings/models/issueTypes.d.ts +8 -0
  47. package/dist/typings/models/issues.d.ts +7 -7
  48. package/dist/typings/models/organizations.d.ts +2 -3
  49. package/dist/typings/models/teams.d.ts +10 -0
  50. package/dist/utils/file.d.ts +2 -0
  51. package/dist/utils/forms.d.ts +2 -0
  52. package/package.json +153 -152
  53. package/dist/store/slices/userFormSlice.d.ts +0 -145
@@ -5,8 +5,8 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  (function(global2, factory) {
8
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("react/jsx-runtime"), require("@overmap-ai/blocks"), require("dependency-graph"), require("@redux-offline/redux-offline"), require("@redux-offline/redux-offline/lib/defaults"), require("localforage"), require("redux-persist-migrate"), require("@reduxjs/toolkit"), require("superagent"), require("react-redux"), require("file-saver"), require("uuid"), require("color"), require("jwt-decode"), require("@redux-offline/redux-offline/lib/constants"), require("idb"), require("formik"), require("lodash.get"), require("linkify-react"), require("@hello-pangea/dnd"), require("xlsx"), require("react-pdf"), require("react-pdf/dist/Page/AnnotationLayer.css"), require("react-pdf/dist/Page/TextLayer.css"), require("react-dom"), require("react-sketch-canvas"), require("lodash.set"), require("lodash.clonedeep")) : typeof define === "function" && define.amd ? define(["exports", "react", "react/jsx-runtime", "@overmap-ai/blocks", "dependency-graph", "@redux-offline/redux-offline", "@redux-offline/redux-offline/lib/defaults", "localforage", "redux-persist-migrate", "@reduxjs/toolkit", "superagent", "react-redux", "file-saver", "uuid", "color", "jwt-decode", "@redux-offline/redux-offline/lib/constants", "idb", "formik", "lodash.get", "linkify-react", "@hello-pangea/dnd", "xlsx", "react-pdf", "react-pdf/dist/Page/AnnotationLayer.css", "react-pdf/dist/Page/TextLayer.css", "react-dom", "react-sketch-canvas", "lodash.set", "lodash.clonedeep"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["overmap-core"] = {}, global2.React, global2.jsxRuntime, global2.blocks, global2.dependencyGraph, global2.reduxOffline, global2.offlineConfig, global2.localforage, global2.createMigration, global2.toolkit, global2.request, global2.reactRedux, global2.saveAs, global2.uuid, global2.ColorCls, global2.jwtDecode, global2.constants, global2.idb, global2.formik, global2.get, global2.Linkify, global2.dnd, global2.xlsx, global2.reactPdf, null, null, global2.ReactDOM, global2.reactSketchCanvas, global2.set, global2.cloneDeep));
9
- })(this, function(exports2, React, jsxRuntime, blocks, dependencyGraph, reduxOffline, offlineConfig, localforage, createMigration, toolkit, request, reactRedux, saveAs, uuid, ColorCls, jwtDecode, constants, idb, formik, get, Linkify, dnd, xlsx, reactPdf, AnnotationLayer_css, TextLayer_css, ReactDOM, reactSketchCanvas, set, cloneDeep) {
8
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("react/jsx-runtime"), require("@overmap-ai/blocks"), require("dependency-graph"), require("@redux-offline/redux-offline"), require("@redux-offline/redux-offline/lib/defaults"), require("localforage"), require("redux-persist-migrate"), require("@reduxjs/toolkit"), require("superagent"), require("react-redux"), require("file-saver"), require("uuid"), require("color"), require("jwt-decode"), require("@redux-offline/redux-offline/lib/constants"), require("idb"), require("formik"), require("lodash.get"), require("linkify-react"), require("@hello-pangea/dnd"), require("qr-scanner"), require("xlsx"), require("react-pdf"), require("react-pdf/dist/Page/AnnotationLayer.css"), require("react-pdf/dist/Page/TextLayer.css"), require("react-dom"), require("react-sketch-canvas"), require("lodash.set"), require("lodash.clonedeep")) : typeof define === "function" && define.amd ? define(["exports", "react", "react/jsx-runtime", "@overmap-ai/blocks", "dependency-graph", "@redux-offline/redux-offline", "@redux-offline/redux-offline/lib/defaults", "localforage", "redux-persist-migrate", "@reduxjs/toolkit", "superagent", "react-redux", "file-saver", "uuid", "color", "jwt-decode", "@redux-offline/redux-offline/lib/constants", "idb", "formik", "lodash.get", "linkify-react", "@hello-pangea/dnd", "qr-scanner", "xlsx", "react-pdf", "react-pdf/dist/Page/AnnotationLayer.css", "react-pdf/dist/Page/TextLayer.css", "react-dom", "react-sketch-canvas", "lodash.set", "lodash.clonedeep"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2["overmap-core"] = {}, global2.React, global2.jsxRuntime, global2.blocks, global2.dependencyGraph, global2.reduxOffline, global2.offlineConfig, global2.localforage, global2.createMigration, global2.toolkit, global2.request, global2.reactRedux, global2.saveAs, global2.uuid, global2.ColorCls, global2.jwtDecode, global2.constants, global2.idb, global2.formik, global2.get, global2.Linkify, global2.dnd, global2.QrScannerAPI, global2.xlsx, global2.reactPdf, null, null, global2.ReactDOM, global2.reactSketchCanvas, global2.set, global2.cloneDeep));
9
+ })(this, function(exports2, React, jsxRuntime, blocks, dependencyGraph, reduxOffline, offlineConfig, localforage, createMigration, toolkit, request, reactRedux, saveAs, uuid, ColorCls, jwtDecode, constants, idb, formik, get, Linkify, dnd, QrScannerAPI, xlsx, reactPdf, AnnotationLayer_css, TextLayer_css, ReactDOM, reactSketchCanvas, set, cloneDeep) {
10
10
  var _a;
11
11
  "use strict";
12
12
  function _interopNamespaceDefault(e) {
@@ -668,15 +668,15 @@ var __publicField = (obj, key, value) => {
668
668
  };
669
669
  const migrations = [initialVersioning, signOut, signOut, createOutboxState];
670
670
  const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
671
- const initialState$n = {
671
+ const initialState$s = {
672
672
  accessToken: "",
673
673
  refreshToken: "",
674
674
  isLoggedIn: false
675
675
  };
676
676
  const authSlice = toolkit.createSlice({
677
677
  name: "auth",
678
- initialState: initialState$n,
679
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
678
+ initialState: initialState$s,
679
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$s)),
680
680
  reducers: {
681
681
  setTokens: (state, action) => {
682
682
  state.accessToken = action.payload.accessToken;
@@ -841,6 +841,19 @@ var __publicField = (obj, key, value) => {
841
841
  element.click();
842
842
  document.body.removeChild(element);
843
843
  }
844
+ const constructUploadedFilePayloads = async (files) => {
845
+ const filePayloads = {};
846
+ for (const file of files) {
847
+ const sha1 = await hashFile(file);
848
+ filePayloads[sha1] = {
849
+ sha1,
850
+ extension: file.name.split(".").pop() || "",
851
+ file_type: file.type,
852
+ size: file.size
853
+ };
854
+ }
855
+ return Object.values(filePayloads);
856
+ };
844
857
  const fileToBlob = async (dataUrl) => {
845
858
  return (await fetch(dataUrl)).blob();
846
859
  };
@@ -1407,7 +1420,7 @@ var __publicField = (obj, key, value) => {
1407
1420
  return getLocalDateString(date);
1408
1421
  return relative.format(days, "days");
1409
1422
  });
1410
- const initialState$m = {
1423
+ const initialState$r = {
1411
1424
  categories: {},
1412
1425
  usedCategoryColors: [],
1413
1426
  categoryVisibility: {
@@ -1417,8 +1430,8 @@ var __publicField = (obj, key, value) => {
1417
1430
  };
1418
1431
  const categorySlice = toolkit.createSlice({
1419
1432
  name: "categories",
1420
- initialState: initialState$m,
1421
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
1433
+ initialState: initialState$r,
1434
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
1422
1435
  reducers: {
1423
1436
  setCategories: (state, action) => {
1424
1437
  if (!Array.isArray(action.payload))
@@ -1550,6 +1563,9 @@ var __publicField = (obj, key, value) => {
1550
1563
  hiddenCategoryCount++;
1551
1564
  return hiddenCategoryCount;
1552
1565
  };
1566
+ const selectIssueCountOfCategory = (categoryId) => (state) => {
1567
+ return Object.values(state.issueReducer.issues).filter((issue) => issue.category === categoryId).length;
1568
+ };
1553
1569
  const categoryReducer = categorySlice.reducer;
1554
1570
  function setAttachments(state, action) {
1555
1571
  state.attachments = {};
@@ -1587,14 +1603,14 @@ var __publicField = (obj, key, value) => {
1587
1603
  delete state.attachments[attachmentId];
1588
1604
  }
1589
1605
  }
1590
- const initialState$l = {
1606
+ const initialState$q = {
1591
1607
  components: {},
1592
1608
  attachments: {}
1593
1609
  };
1594
1610
  const componentSlice = toolkit.createSlice({
1595
1611
  name: "components",
1596
- initialState: initialState$l,
1597
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
1612
+ initialState: initialState$q,
1613
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
1598
1614
  reducers: {
1599
1615
  addComponent: (state, action) => {
1600
1616
  state.components[action.payload.offline_id] = action.payload;
@@ -1750,13 +1766,13 @@ var __publicField = (obj, key, value) => {
1750
1766
  removeAllComponentsOfType
1751
1767
  } = componentSlice.actions;
1752
1768
  const componentReducer = componentSlice.reducer;
1753
- const initialState$k = {
1769
+ const initialState$p = {
1754
1770
  completionsByComponentId: {}
1755
1771
  };
1756
1772
  const componentStageCompletionSlice = toolkit.createSlice({
1757
1773
  name: "componentStageCompletions",
1758
- initialState: initialState$k,
1759
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
1774
+ initialState: initialState$p,
1775
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$p)),
1760
1776
  reducers: {
1761
1777
  addStageCompletion: (state, action) => {
1762
1778
  let stageToCompletionDateMapping = state.completionsByComponentId[action.payload.component];
@@ -1807,13 +1823,13 @@ var __publicField = (obj, key, value) => {
1807
1823
  return Object.keys(state.componentStageCompletionReducer.completionsByComponentId[component.offline_id] ?? {});
1808
1824
  };
1809
1825
  const componentStageCompletionReducer = componentStageCompletionSlice.reducer;
1810
- const initialState$j = {
1826
+ const initialState$o = {
1811
1827
  stages: {}
1812
1828
  };
1813
1829
  const componentStageSlice = toolkit.createSlice({
1814
1830
  name: "componentStages",
1815
- initialState: initialState$j,
1816
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
1831
+ initialState: initialState$o,
1832
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
1817
1833
  reducers: {
1818
1834
  addStages: (state, action) => {
1819
1835
  Object.assign(state.stages, toOfflineIdRecord(action.payload));
@@ -1923,15 +1939,15 @@ var __publicField = (obj, key, value) => {
1923
1939
  );
1924
1940
  const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
1925
1941
  const componentStageReducer = componentStageSlice.reducer;
1926
- const initialState$i = {
1942
+ const initialState$n = {
1927
1943
  componentTypes: {},
1928
1944
  hiddenComponentTypeIds: {},
1929
1945
  attachments: {}
1930
1946
  };
1931
1947
  const componentTypeSlice = toolkit.createSlice({
1932
1948
  name: "componentTypes",
1933
- initialState: initialState$i,
1934
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
1949
+ initialState: initialState$n,
1950
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
1935
1951
  reducers: {
1936
1952
  addComponentType: (state, action) => {
1937
1953
  state.componentTypes[action.payload.offline_id] = action.payload;
@@ -2042,13 +2058,13 @@ var __publicField = (obj, key, value) => {
2042
2058
  deleteComponentType
2043
2059
  } = componentTypeSlice.actions;
2044
2060
  const componentTypeReducer = componentTypeSlice.reducer;
2045
- const initialState$h = {
2061
+ const initialState$m = {
2046
2062
  workspaces: {},
2047
2063
  activeWorkspaceId: null
2048
2064
  };
2049
2065
  const workspaceSlice = toolkit.createSlice({
2050
2066
  name: "workspace",
2051
- initialState: initialState$h,
2067
+ initialState: initialState$m,
2052
2068
  // The `reducers` field lets us define reducers and generate associated actions
2053
2069
  reducers: {
2054
2070
  setWorkspaces: (state, action) => {
@@ -2105,7 +2121,7 @@ var __publicField = (obj, key, value) => {
2105
2121
  );
2106
2122
  const workspaceReducer = workspaceSlice.reducer;
2107
2123
  const maxRecentIssues = 10;
2108
- const initialState$g = {
2124
+ const initialState$l = {
2109
2125
  issues: {},
2110
2126
  attachments: {},
2111
2127
  comments: {},
@@ -2117,9 +2133,9 @@ var __publicField = (obj, key, value) => {
2117
2133
  };
2118
2134
  const issueSlice = toolkit.createSlice({
2119
2135
  name: "issues",
2120
- initialState: initialState$g,
2136
+ initialState: initialState$l,
2121
2137
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
2122
- Object.assign(state, initialState$g);
2138
+ Object.assign(state, initialState$l);
2123
2139
  }),
2124
2140
  reducers: {
2125
2141
  setIssues: (state, action) => {
@@ -2150,6 +2166,16 @@ var __publicField = (obj, key, value) => {
2150
2166
  }
2151
2167
  state.issues[action.payload.offline_id] = action.payload;
2152
2168
  },
2169
+ addIssues: (state, action) => {
2170
+ for (const issue of action.payload) {
2171
+ if (issue.offline_id in state.issues) {
2172
+ throw new Error(`Tried to add duplicate issue with ID: ${issue.offline_id}`);
2173
+ }
2174
+ }
2175
+ for (const issue of action.payload) {
2176
+ state.issues[issue.offline_id] = issue;
2177
+ }
2178
+ },
2153
2179
  addIssueAttachment: addAttachment,
2154
2180
  addIssueAttachments: addAttachments,
2155
2181
  addIssueUpdate: (state, action) => {
@@ -2181,6 +2207,11 @@ var __publicField = (obj, key, value) => {
2181
2207
  throw new Error(`Failed to remove issue because ID doesn't exist: ${action.payload}`);
2182
2208
  }
2183
2209
  },
2210
+ removeIssues: (state, action) => {
2211
+ for (const issueId of action.payload) {
2212
+ delete state.issues[issueId];
2213
+ }
2214
+ },
2184
2215
  removeIssueAttachment: removeAttachment,
2185
2216
  removeIssueUpdate: (state, action) => {
2186
2217
  if (action.payload in state.updates) {
@@ -2285,6 +2316,7 @@ var __publicField = (obj, key, value) => {
2285
2316
  addIssueAttachment,
2286
2317
  addIssueAttachments,
2287
2318
  addIssue,
2319
+ addIssues,
2288
2320
  addIssueUpdate,
2289
2321
  addIssueUpdates,
2290
2322
  addOrReplaceIssueComment,
@@ -2293,6 +2325,7 @@ var __publicField = (obj, key, value) => {
2293
2325
  removeIssueAttachment,
2294
2326
  removeAttachmentsOfIssue,
2295
2327
  removeIssue,
2328
+ removeIssues,
2296
2329
  removeIssueUpdate,
2297
2330
  removeIssueUpdates,
2298
2331
  removeRecentIssue,
@@ -2527,15 +2560,89 @@ var __publicField = (obj, key, value) => {
2527
2560
  }
2528
2561
  );
2529
2562
  const issueReducer = issueSlice.reducer;
2530
- const initialState$f = {
2563
+ const initialState$k = {
2564
+ issueTypes: {}
2565
+ };
2566
+ const issueTypeSlice = toolkit.createSlice({
2567
+ name: "issueTypes",
2568
+ initialState: initialState$k,
2569
+ extraReducers: (builder) => builder.addCase("RESET", (state) => {
2570
+ Object.assign(state, initialState$k);
2571
+ }),
2572
+ reducers: {
2573
+ setIssueTypes: (state, action) => {
2574
+ for (const issueType of action.payload) {
2575
+ state.issueTypes[issueType.offline_id] = issueType;
2576
+ }
2577
+ },
2578
+ setIssueType: (state, action) => {
2579
+ state.issueTypes[action.payload.offline_id] = action.payload;
2580
+ },
2581
+ addIssueType: (state, action) => {
2582
+ if (action.payload.offline_id in state.issueTypes) {
2583
+ throw new Error(`IssueType with offline_id ${action.payload.offline_id} already exists in the store.`);
2584
+ }
2585
+ state.issueTypes[action.payload.offline_id] = action.payload;
2586
+ },
2587
+ updateIssueType: (state, action) => {
2588
+ if (!(action.payload.offline_id in state.issueTypes)) {
2589
+ throw new Error(`IssueType with offline_id ${action.payload.offline_id} does not exist in the store.`);
2590
+ }
2591
+ state.issueTypes[action.payload.offline_id] = action.payload;
2592
+ },
2593
+ removeIssueType: (state, action) => {
2594
+ if (!(action.payload in state.issueTypes)) {
2595
+ throw new Error(`IssueType with offline_id ${action.payload} does not exist in the store.`);
2596
+ }
2597
+ delete state.issueTypes[action.payload];
2598
+ }
2599
+ }
2600
+ });
2601
+ const { setIssueTypes, setIssueType, addIssueType, updateIssueType, removeIssueType } = issueTypeSlice.actions;
2602
+ const selectIssueTypeMapping = (state) => {
2603
+ return state.issueTypeReducer.issueTypes;
2604
+ };
2605
+ const selectIssueTypes = toolkit.createSelector(selectIssueTypeMapping, (issueTypes) => {
2606
+ return Object.values(issueTypes);
2607
+ });
2608
+ const selectIssueType = restructureCreateSelectorWithArgs(
2609
+ toolkit.createSelector(
2610
+ [selectIssueTypeMapping, (_, issueTypeId) => issueTypeId],
2611
+ (issueTypesMapping, issueTypeId) => {
2612
+ return issueTypesMapping[issueTypeId];
2613
+ }
2614
+ )
2615
+ );
2616
+ const selectIssueTypesOfOrganization = restructureCreateSelectorWithArgs(
2617
+ toolkit.createSelector(
2618
+ [selectIssueTypes, (_, organizationId) => organizationId],
2619
+ (issueTypes, organizationId) => {
2620
+ return issueTypes.filter((issueType) => issueType.organization === organizationId);
2621
+ }
2622
+ )
2623
+ );
2624
+ const selectIssuesOfIssueType = restructureCreateSelectorWithArgs(
2625
+ toolkit.createSelector(
2626
+ [(state) => state.issueReducer.issues, (_, issueTypeId) => issueTypeId],
2627
+ (issuesMapping, issueTypeId) => {
2628
+ return Object.values(issuesMapping).filter((issue) => issue.issue_type === issueTypeId);
2629
+ }
2630
+ )
2631
+ );
2632
+ const selectIssuesOfIssueTypeCount = (issueTypeId) => (state) => {
2633
+ var _a2;
2634
+ return ((_a2 = selectIssuesOfIssueType(issueTypeId)(state)) == null ? void 0 : _a2.length) ?? 0;
2635
+ };
2636
+ const issueTypeReducer = issueTypeSlice.reducer;
2637
+ const initialState$j = {
2531
2638
  s3Urls: {}
2532
2639
  };
2533
2640
  const msPerHour = 1e3 * 60 * 60;
2534
2641
  const msPerWeek = msPerHour * 24 * 7;
2535
2642
  const fileSlice = toolkit.createSlice({
2536
2643
  name: "file",
2537
- initialState: initialState$f,
2538
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2644
+ initialState: initialState$j,
2645
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$j)),
2539
2646
  reducers: {
2540
2647
  setUploadUrl: (state, action) => {
2541
2648
  const { url, fields, sha1 } = action.payload;
@@ -2562,7 +2669,7 @@ var __publicField = (obj, key, value) => {
2562
2669
  return url;
2563
2670
  };
2564
2671
  const fileReducer = fileSlice.reducer;
2565
- const initialState$e = {
2672
+ const initialState$i = {
2566
2673
  // TODO: Change first MapStyle.SATELLITE to MaptStyle.None when project creation map is fixed
2567
2674
  mapStyle: MapStyle.SATELLITE,
2568
2675
  showTooltips: false,
@@ -2570,8 +2677,8 @@ var __publicField = (obj, key, value) => {
2570
2677
  };
2571
2678
  const mapSlice = toolkit.createSlice({
2572
2679
  name: "map",
2573
- initialState: initialState$e,
2574
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2680
+ initialState: initialState$i,
2681
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$i)),
2575
2682
  reducers: {
2576
2683
  setMapStyle: (state, action) => {
2577
2684
  state.mapStyle = action.payload;
@@ -2640,7 +2747,7 @@ var __publicField = (obj, key, value) => {
2640
2747
  LicenseStatus2[LicenseStatus2["PAST_DUE"] = 8] = "PAST_DUE";
2641
2748
  return LicenseStatus2;
2642
2749
  })(LicenseStatus || {});
2643
- const initialState$d = {
2750
+ const initialState$h = {
2644
2751
  users: {},
2645
2752
  currentUser: {
2646
2753
  id: 0,
@@ -2651,8 +2758,8 @@ var __publicField = (obj, key, value) => {
2651
2758
  };
2652
2759
  const userSlice = toolkit.createSlice({
2653
2760
  name: "users",
2654
- initialState: initialState$d,
2655
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
2761
+ initialState: initialState$h,
2762
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$h)),
2656
2763
  reducers: {
2657
2764
  setUsers: (state, action) => {
2658
2765
  const usersMapping = {};
@@ -2714,13 +2821,13 @@ var __publicField = (obj, key, value) => {
2714
2821
  const selectUsersAsMapping = (state) => state.userReducer.users;
2715
2822
  const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
2716
2823
  const userReducer = userSlice.reducer;
2717
- const initialState$c = {
2824
+ const initialState$g = {
2718
2825
  organizationAccesses: {}
2719
2826
  };
2720
2827
  const organizationAccessSlice = toolkit.createSlice({
2721
2828
  name: "organizationAccess",
2722
- initialState: initialState$c,
2723
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
2829
+ initialState: initialState$g,
2830
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
2724
2831
  reducers: {
2725
2832
  setOrganizationAccesses: (state, action) => {
2726
2833
  if (!Array.isArray(action.payload))
@@ -2783,13 +2890,13 @@ var __publicField = (obj, key, value) => {
2783
2890
  return organizationAccesses;
2784
2891
  };
2785
2892
  const organizationAccessReducer = organizationAccessSlice.reducer;
2786
- const initialState$b = {
2893
+ const initialState$f = {
2787
2894
  licenses: {}
2788
2895
  };
2789
2896
  const licenseSlice = toolkit.createSlice({
2790
2897
  name: "license",
2791
- initialState: initialState$b,
2792
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
2898
+ initialState: initialState$f,
2899
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
2793
2900
  reducers: {
2794
2901
  setLicenses: (state, action) => {
2795
2902
  if (!Array.isArray(action.payload))
@@ -2834,13 +2941,13 @@ var __publicField = (obj, key, value) => {
2834
2941
  (licenses) => Object.values(licenses).filter((license) => license.project).reduce((accum, license) => ({ ...accum, [license.project]: license }), {})
2835
2942
  );
2836
2943
  const licenseReducer = licenseSlice.reducer;
2837
- const initialState$a = {
2944
+ const initialState$e = {
2838
2945
  projectAccesses: {}
2839
2946
  };
2840
2947
  const projectAccessSlice = toolkit.createSlice({
2841
2948
  name: "projectAccess",
2842
- initialState: initialState$a,
2843
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
2949
+ initialState: initialState$e,
2950
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
2844
2951
  reducers: {
2845
2952
  setProjectAccesses: (state, action) => {
2846
2953
  if (!Array.isArray(action.payload))
@@ -2908,7 +3015,7 @@ var __publicField = (obj, key, value) => {
2908
3015
  return projectAccesses;
2909
3016
  };
2910
3017
  const projectAccessReducer = projectAccessSlice.reducer;
2911
- const initialState$9 = {
3018
+ const initialState$d = {
2912
3019
  projects: {},
2913
3020
  activeProjectId: null,
2914
3021
  recentProjectIds: [],
@@ -2918,7 +3025,7 @@ var __publicField = (obj, key, value) => {
2918
3025
  };
2919
3026
  const projectSlice = toolkit.createSlice({
2920
3027
  name: "projects",
2921
- initialState: initialState$9,
3028
+ initialState: initialState$d,
2922
3029
  reducers: {
2923
3030
  setProjects: (state, action) => {
2924
3031
  const projectsMap = {};
@@ -3105,14 +3212,14 @@ var __publicField = (obj, key, value) => {
3105
3212
  }
3106
3213
  )
3107
3214
  );
3108
- const initialState$8 = {
3215
+ const initialState$c = {
3109
3216
  organizations: {},
3110
3217
  activeOrganizationId: null
3111
3218
  };
3112
3219
  const organizationSlice = toolkit.createSlice({
3113
3220
  name: "organizations",
3114
- initialState: initialState$8,
3115
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3221
+ initialState: initialState$c,
3222
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
3116
3223
  reducers: {
3117
3224
  setOrganizations: (state, action) => {
3118
3225
  for (const org of action.payload) {
@@ -3231,14 +3338,14 @@ var __publicField = (obj, key, value) => {
3231
3338
  }
3232
3339
  };
3233
3340
  };
3234
- const initialState$7 = {
3341
+ const initialState$b = {
3235
3342
  deletedRequests: [],
3236
3343
  latestRetryTime: 0
3237
3344
  };
3238
3345
  const outboxSlice = toolkit.createSlice({
3239
3346
  name: "outbox",
3240
- initialState: initialState$7,
3241
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
3347
+ initialState: initialState$b,
3348
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
3242
3349
  reducers: {
3243
3350
  // enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
3244
3351
  // Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
@@ -3270,7 +3377,7 @@ var __publicField = (obj, key, value) => {
3270
3377
  const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
3271
3378
  const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
3272
3379
  const outboxReducer = outboxSlice.reducer;
3273
- const initialState$6 = {
3380
+ const initialState$a = {
3274
3381
  projectFiles: {},
3275
3382
  activeProjectFileId: null,
3276
3383
  isImportingProjectFile: false,
@@ -3278,8 +3385,8 @@ var __publicField = (obj, key, value) => {
3278
3385
  };
3279
3386
  const projectFileSlice = toolkit.createSlice({
3280
3387
  name: "projectFiles",
3281
- initialState: initialState$6,
3282
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3388
+ initialState: initialState$a,
3389
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$a)),
3283
3390
  reducers: {
3284
3391
  addOrReplaceProjectFiles: (state, action) => {
3285
3392
  for (let fileObj of action.payload) {
@@ -3380,12 +3487,12 @@ var __publicField = (obj, key, value) => {
3380
3487
  const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProjectFileId;
3381
3488
  const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
3382
3489
  const projectFileReducer = projectFileSlice.reducer;
3383
- const initialState$5 = {
3490
+ const initialState$9 = {
3384
3491
  isRehydrated: false
3385
3492
  };
3386
3493
  const rehydratedSlice = toolkit.createSlice({
3387
3494
  name: "rehydrated",
3388
- initialState: initialState$5,
3495
+ initialState: initialState$9,
3389
3496
  // The `reducers` field lets us define reducers and generate associated actions
3390
3497
  reducers: {
3391
3498
  setRehydrated: (state, action) => {
@@ -3395,7 +3502,7 @@ var __publicField = (obj, key, value) => {
3395
3502
  });
3396
3503
  const selectRehydrated = (state) => state.rehydratedReducer.isRehydrated;
3397
3504
  const rehydratedReducer = rehydratedSlice.reducer;
3398
- const initialState$4 = {
3505
+ const initialState$8 = {
3399
3506
  useIssueTemplate: false,
3400
3507
  placementMode: false,
3401
3508
  enableClustering: false,
@@ -3412,8 +3519,8 @@ var __publicField = (obj, key, value) => {
3412
3519
  };
3413
3520
  const settingSlice = toolkit.createSlice({
3414
3521
  name: "settings",
3415
- initialState: initialState$4,
3416
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
3522
+ initialState: initialState$8,
3523
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
3417
3524
  reducers: {
3418
3525
  setEnableDuplicateIssues: (state, action) => {
3419
3526
  state.useIssueTemplate = action.payload;
@@ -3459,146 +3566,231 @@ var __publicField = (obj, key, value) => {
3459
3566
  const settingReducer = settingSlice.reducer;
3460
3567
  const selectIsFetchingInitialData = (state) => state.settingReducer.isFetchingInitialData;
3461
3568
  const selectIsLoading = (state) => state.settingReducer.isLoading;
3462
- const LATEST_REVISION_CACHE = {};
3463
- function considerCachingRevision(revision, formId2, preferPending = false) {
3464
- var _a2;
3465
- if (!revision) {
3466
- if (!formId2) {
3467
- throw new Error("If revision is null, formId is required.");
3468
- }
3469
- const currentLatestRevision = getLatestRevisionFromCache(formId2);
3470
- if (currentLatestRevision)
3471
- return;
3472
- LATEST_REVISION_CACHE[formId2] = null;
3473
- return;
3474
- }
3475
- if (revision.revision === "Pending") {
3476
- if (preferPending) {
3477
- LATEST_REVISION_CACHE[revision.form] = revision;
3478
- }
3479
- return;
3480
- }
3481
- const cachedRevision = (_a2 = LATEST_REVISION_CACHE[revision.form]) == null ? void 0 : _a2.revision;
3482
- if (revision.revision > (typeof cachedRevision === "number" ? cachedRevision : -1)) {
3483
- LATEST_REVISION_CACHE[revision.form] = revision;
3569
+ const formRevisionSortFn = (formRevisionA, formRevisionB) => {
3570
+ const revisionA = formRevisionA.revision;
3571
+ const revisionB = formRevisionB.revision;
3572
+ if (revisionA === "Pending" && revisionB === "Pending") {
3573
+ return formRevisionA.submitted_at < formRevisionB.submitted_at ? -1 : 1;
3574
+ } else if (revisionA === "Pending") {
3575
+ return 1;
3576
+ } else if (revisionB === "Pending") {
3577
+ return -1;
3578
+ } else {
3579
+ return revisionA < revisionB ? -1 : 1;
3484
3580
  }
3485
- }
3486
- function getLatestRevisionFromCache(formId2) {
3487
- return LATEST_REVISION_CACHE[formId2];
3488
- }
3489
- const initialState$3 = {
3490
- userForms: {},
3491
- revisions: {},
3492
- submissions: {},
3493
- submissionAttachments: {},
3494
- revisionAttachments: {}
3495
- };
3496
- const userFormSlice = toolkit.createSlice({
3497
- name: "userForms",
3498
- initialState: initialState$3,
3499
- extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
3581
+ };
3582
+ const initialState$7 = {
3583
+ formRevisions: {},
3584
+ attachments: {}
3585
+ };
3586
+ const formRevisionsSlice = toolkit.createSlice({
3587
+ name: "formRevisions",
3588
+ initialState: initialState$7,
3589
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
3500
3590
  reducers: {
3501
- setUserForms: (state, action) => {
3502
- state.userForms = {};
3503
- action.payload.forEach((userForm) => {
3504
- state.userForms[userForm.offline_id] = userForm;
3505
- });
3591
+ // revision related actions
3592
+ setFormRevision: (state, action) => {
3593
+ state.formRevisions[action.payload.offline_id] = action.payload;
3506
3594
  },
3507
- addUserForm: (state, action) => {
3508
- state.userForms[action.payload.offline_id] = action.payload;
3509
- },
3510
- addUserForms: (state, action) => {
3511
- action.payload.forEach((userForm) => {
3512
- state.userForms[userForm.offline_id] = userForm;
3513
- });
3514
- },
3515
- addUserFormRevisions: (state, action) => {
3516
- action.payload.forEach((userFormRevision) => {
3517
- state.revisions[userFormRevision.offline_id] = userFormRevision;
3518
- considerCachingRevision(userFormRevision);
3519
- });
3520
- },
3521
- addUserFormRevision: (state, action) => {
3522
- state.revisions[action.payload.offline_id] = action.payload;
3523
- considerCachingRevision(action.payload);
3595
+ setFormRevisions: (state, action) => {
3596
+ state.formRevisions = {};
3597
+ for (const revision of action.payload) {
3598
+ state.formRevisions[revision.offline_id] = revision;
3599
+ }
3524
3600
  },
3525
- deleteUserFormRevision: (state, action) => {
3526
- delete state.revisions[action.payload];
3527
- delete LATEST_REVISION_CACHE[action.payload];
3601
+ addFormRevision: (state, action) => {
3602
+ if (state.formRevisions[action.payload.offline_id] !== void 0) {
3603
+ throw new Error(`Revision with offline_id ${action.payload.offline_id} already exists`);
3604
+ }
3605
+ state.formRevisions[action.payload.offline_id] = action.payload;
3528
3606
  },
3529
- deleteUserFormRevisions: (state, action) => {
3607
+ addFormRevisions: (state, action) => {
3530
3608
  for (const userFormRevision of action.payload) {
3531
- delete state.revisions[userFormRevision.offline_id];
3532
- delete LATEST_REVISION_CACHE[userFormRevision.offline_id];
3609
+ if (state.formRevisions[userFormRevision.offline_id] !== void 0) {
3610
+ throw new Error(`Revision with offline_id ${userFormRevision.offline_id} already exists`);
3611
+ }
3533
3612
  }
3534
- },
3535
- updateOrCreateUserFormSubmission: (state, action) => {
3536
- state.submissions[action.payload.offline_id] = action.payload;
3537
- },
3538
- addUserFormSubmissionAttachment: (state, action) => {
3539
- const submissionId = action.payload.submission;
3540
- const submissionAttachments = state.submissionAttachments[submissionId];
3541
- if (submissionAttachments) {
3542
- submissionAttachments.push(action.payload);
3543
- } else {
3544
- state.submissionAttachments[submissionId] = [action.payload];
3613
+ for (const userFormRevision of action.payload) {
3614
+ state.formRevisions[userFormRevision.offline_id] = userFormRevision;
3545
3615
  }
3546
3616
  },
3547
- addUserFormRevisionAttachment: (state, action) => {
3548
- const revisionId = action.payload.revision;
3549
- const revisionAttachments = state.revisionAttachments[revisionId];
3550
- if (revisionAttachments) {
3551
- revisionAttachments.push(action.payload);
3552
- } else {
3553
- state.revisionAttachments[revisionId] = [action.payload];
3617
+ // UserFormRevisions do not get updated
3618
+ deleteFormRevision: (state, action) => {
3619
+ if (state.formRevisions[action.payload] === void 0) {
3620
+ throw new Error(`Revision with offline_id ${action.payload} does not exist`);
3554
3621
  }
3622
+ delete state.formRevisions[action.payload];
3555
3623
  },
3556
- setUserFormSubmissionAttachments: (state, action) => {
3557
- state.submissionAttachments = {};
3558
- for (const attachment of action.payload) {
3559
- const submissionId = attachment.submission;
3560
- const submissionAttachments = state.submissionAttachments[submissionId];
3561
- if (submissionAttachments) {
3562
- submissionAttachments.push(attachment);
3563
- } else {
3564
- state.submissionAttachments[submissionId] = [attachment];
3624
+ deleteFormRevisions: (state, action) => {
3625
+ for (const offlineId of action.payload) {
3626
+ if (state.formRevisions[offlineId] === void 0) {
3627
+ throw new Error(`Revision with offline_id ${offlineId} does not exist`);
3565
3628
  }
3566
3629
  }
3630
+ for (const offlineId of action.payload) {
3631
+ delete state.formRevisions[offlineId];
3632
+ }
3567
3633
  },
3568
- setUserFormRevisionAttachments: (state, action) => {
3569
- state.revisionAttachments = {};
3634
+ // attachment related actions
3635
+ setFormRevisionAttachments: (state, action) => {
3636
+ state.attachments = {};
3570
3637
  for (const attachment of action.payload) {
3571
- const revisionId = attachment.revision;
3572
- const revisionAttachments = state.revisionAttachments[revisionId];
3573
- if (revisionAttachments) {
3574
- revisionAttachments.push(attachment);
3575
- } else {
3576
- state.revisionAttachments[revisionId] = [attachment];
3577
- }
3638
+ state.attachments[attachment.offline_id] = attachment;
3578
3639
  }
3579
3640
  },
3580
- deleteUserFormSubmission: (state, action) => {
3581
- delete state.submissions[action.payload];
3641
+ addFormRevisionAttachment: (state, action) => {
3642
+ if (state.attachments[action.payload.offline_id] !== void 0) {
3643
+ throw new Error(`Attachment with offline_id ${action.payload.offline_id} already exists`);
3644
+ }
3645
+ state.attachments[action.payload.offline_id] = action.payload;
3582
3646
  },
3583
- deleteUserFormSubmissions: (state, action) => {
3584
- for (const userFormSubmission of action.payload) {
3585
- delete state.submissions[userFormSubmission.offline_id];
3647
+ addFormRevisionAttachments: (state, action) => {
3648
+ for (const attachment of action.payload) {
3649
+ if (state.attachments[attachment.offline_id] !== void 0) {
3650
+ throw new Error(`Attachment with offline_id ${attachment.offline_id} already exists`);
3651
+ }
3652
+ }
3653
+ for (const attachment of action.payload) {
3654
+ state.attachments[attachment.offline_id] = attachment;
3586
3655
  }
3587
3656
  },
3588
- addUserFormSubmissions: (state, action) => {
3589
- for (const submission of action.payload) {
3590
- state.submissions[submission.offline_id] = submission;
3657
+ deleteFormRevisionAttachment: (state, action) => {
3658
+ if (state.attachments[action.payload] === void 0) {
3659
+ throw new Error(`Attachment with offline_id ${action.payload} does not exist`);
3591
3660
  }
3661
+ delete state.attachments[action.payload];
3592
3662
  },
3593
- setUserFormSubmissions: (state, action) => {
3594
- state.submissions = {};
3595
- action.payload.forEach((submission) => {
3596
- state.submissions[submission.offline_id] = submission;
3663
+ deleteFormRevisionAttachments: (state, action) => {
3664
+ for (const offlineId of action.payload) {
3665
+ if (state.attachments[offlineId] === void 0) {
3666
+ throw new Error(`Attachment with offline_id ${offlineId} does not exist`);
3667
+ }
3668
+ }
3669
+ for (const offlineId of action.payload) {
3670
+ delete state.attachments[offlineId];
3671
+ }
3672
+ }
3673
+ }
3674
+ });
3675
+ const {
3676
+ setFormRevision,
3677
+ setFormRevisions,
3678
+ addFormRevision,
3679
+ addFormRevisions,
3680
+ deleteFormRevision,
3681
+ deleteFormRevisions,
3682
+ setFormRevisionAttachments,
3683
+ addFormRevisionAttachment,
3684
+ addFormRevisionAttachments,
3685
+ deleteFormRevisionAttachment,
3686
+ deleteFormRevisionAttachments
3687
+ } = formRevisionsSlice.actions;
3688
+ const selectFormRevisionMapping = (state) => state.formRevisionReducer.formRevisions;
3689
+ const selectFormRevisions = toolkit.createSelector(
3690
+ [selectFormRevisionMapping],
3691
+ (formRevisions) => Object.values(formRevisions)
3692
+ );
3693
+ const selectFormRevision = (formRevisionId) => (state) => {
3694
+ return state.formRevisionReducer.formRevisions[formRevisionId];
3695
+ };
3696
+ const _selectLatestFormRevision = (formRevisions, formId2) => {
3697
+ let ret = null;
3698
+ for (const candidate of Object.values(formRevisions)) {
3699
+ if (candidate.form === formId2 && (!ret || ret.revision < candidate.revision)) {
3700
+ ret = candidate;
3701
+ }
3702
+ }
3703
+ if (!ret) {
3704
+ throw new Error("No form revision found for form " + formId2);
3705
+ }
3706
+ return ret;
3707
+ };
3708
+ const selectLatestFormRevisionOfForm = restructureCreateSelectorWithArgs(
3709
+ toolkit.createSelector([selectFormRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
3710
+ return revisions.filter((revision) => revision.form === formId2).sort(formRevisionSortFn).pop();
3711
+ })
3712
+ );
3713
+ const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
3714
+ toolkit.createSelector([selectFormRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
3715
+ return revisions.filter((revision) => {
3716
+ return revision.form === formId2;
3717
+ });
3718
+ })
3719
+ );
3720
+ const selectLatestFormRevisionsOfComponentTypes = restructureCreateSelectorWithArgs(
3721
+ toolkit.createSelector(
3722
+ [
3723
+ (state) => state.formReducer.forms,
3724
+ selectFormRevisionMapping,
3725
+ (_state, componentTypeIds) => componentTypeIds
3726
+ ],
3727
+ (userForms, revisions, componentTypeIds) => {
3728
+ const componentTypeIdsSet = new Set(componentTypeIds);
3729
+ const formsOfComponentTypes = {};
3730
+ const ret = {};
3731
+ for (const form of Object.values(userForms)) {
3732
+ if (form.component_type && componentTypeIdsSet.has(form.component_type)) {
3733
+ formsOfComponentTypes[form.offline_id] = form;
3734
+ }
3735
+ }
3736
+ for (const revision of Object.values(revisions)) {
3737
+ const form = formsOfComponentTypes[revision.form];
3738
+ if (!form || !form.component_type || ret[form.component_type] && formRevisionSortFn(ret[form.component_type], revision) > 0)
3739
+ continue;
3740
+ ret[form.component_type] = revision;
3741
+ }
3742
+ return ret;
3743
+ }
3744
+ )
3745
+ );
3746
+ const selectLatestFormRevisionByForm = toolkit.createSelector([selectFormRevisionMapping], (revisions) => {
3747
+ const latestRevisions = {};
3748
+ for (const revision of Object.values(revisions)) {
3749
+ const formId2 = revision.form;
3750
+ const currentLatestRevision = latestRevisions[formId2];
3751
+ if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
3752
+ latestRevisions[formId2] = revision;
3753
+ }
3754
+ }
3755
+ return latestRevisions;
3756
+ });
3757
+ const selectUserFormRevisionAttachmentsMapping = (state) => {
3758
+ return state.formRevisionReducer.attachments;
3759
+ };
3760
+ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
3761
+ toolkit.createSelector(
3762
+ [selectUserFormRevisionAttachmentsMapping, (_state, revisionId) => revisionId],
3763
+ (attachments, revisionId) => {
3764
+ return Object.values(attachments).filter((attachment) => attachment.revision === revisionId);
3765
+ }
3766
+ )
3767
+ );
3768
+ const formRevisionReducer = formRevisionsSlice.reducer;
3769
+ const initialState$6 = {
3770
+ forms: {}
3771
+ };
3772
+ const formSlice = toolkit.createSlice({
3773
+ name: "forms",
3774
+ initialState: initialState$6,
3775
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
3776
+ reducers: {
3777
+ setForms: (state, action) => {
3778
+ state.forms = {};
3779
+ action.payload.forEach((userForm) => {
3780
+ state.forms[userForm.offline_id] = userForm;
3597
3781
  });
3598
3782
  },
3783
+ addForm: (state, action) => {
3784
+ state.forms[action.payload.offline_id] = action.payload;
3785
+ },
3786
+ addForms: (state, action) => {
3787
+ for (const userForm of action.payload) {
3788
+ state.forms[userForm.offline_id] = userForm;
3789
+ }
3790
+ },
3599
3791
  favoriteForm: (state, action) => {
3600
3792
  const { formId: formId2 } = action.payload;
3601
- const form = state.userForms[formId2];
3793
+ const form = state.forms[formId2];
3602
3794
  if (!form) {
3603
3795
  throw new Error("No form exists with the id " + formId2);
3604
3796
  }
@@ -3606,48 +3798,23 @@ var __publicField = (obj, key, value) => {
3606
3798
  },
3607
3799
  unfavoriteForm: (state, action) => {
3608
3800
  const { formId: formId2 } = action.payload;
3609
- const form = state.userForms[formId2];
3801
+ const form = state.forms[formId2];
3610
3802
  if (!form) {
3611
3803
  throw new Error("No form exists with the id " + formId2);
3612
3804
  }
3613
3805
  form.favorite = false;
3614
3806
  },
3615
- deleteUserForm: (state, action) => {
3616
- delete state.userForms[action.payload];
3807
+ deleteForm: (state, action) => {
3808
+ delete state.forms[action.payload];
3617
3809
  }
3618
3810
  }
3619
3811
  });
3620
- const {
3621
- addUserForm,
3622
- addUserForms,
3623
- addUserFormRevisions,
3624
- updateOrCreateUserFormSubmission,
3625
- addUserFormSubmissions,
3626
- deleteUserFormSubmission,
3627
- deleteUserFormSubmissions,
3628
- favoriteForm,
3629
- unfavoriteForm,
3630
- deleteUserForm,
3631
- deleteUserFormRevision,
3632
- deleteUserFormRevisions,
3633
- setUserFormSubmissions,
3634
- addUserFormRevision,
3635
- addUserFormSubmissionAttachment,
3636
- addUserFormRevisionAttachment,
3637
- setUserFormSubmissionAttachments,
3638
- setUserFormRevisionAttachments
3639
- } = userFormSlice.actions;
3640
- const selectSubmissionAttachments = (submissionId) => (state) => {
3641
- return state.userFormReducer.submissionAttachments[submissionId] || [];
3642
- };
3643
- const selectRevisionAttachments = (revisionId) => (state) => {
3644
- return state.userFormReducer.revisionAttachments[revisionId] || [];
3645
- };
3646
- const selectFilteredUserForms = restructureCreateSelectorWithArgs(
3812
+ const { setForms, addForm, addForms, favoriteForm, unfavoriteForm, deleteForm } = formSlice.actions;
3813
+ const selectFilteredForms = restructureCreateSelectorWithArgs(
3647
3814
  toolkit.createSelector(
3648
3815
  [
3649
- (state) => state.userFormReducer.userForms,
3650
- (state) => state.userFormReducer.revisions,
3816
+ (state) => state.formReducer.forms,
3817
+ (state) => state.formRevisionReducer.formRevisions,
3651
3818
  (_state, search) => search
3652
3819
  ],
3653
3820
  (userForms, revisions, search) => {
@@ -3681,63 +3848,233 @@ var __publicField = (obj, key, value) => {
3681
3848
  { memoizeOptions: { equalityCheck: reactRedux.shallowEqual } }
3682
3849
  )
3683
3850
  );
3684
- const selectFormRevision = (revisionId) => (state) => {
3685
- return state.userFormReducer.revisions[revisionId];
3851
+ const selectForm = (formId2) => (state) => {
3852
+ return state.formReducer.forms[formId2];
3686
3853
  };
3687
- const _selectLatestFormRevision = (revisions, formId2) => {
3688
- let ret = null;
3689
- for (const candidate of Object.values(revisions)) {
3690
- if (candidate.form === formId2 && (!ret || ret.revision < candidate.revision)) {
3691
- ret = candidate;
3692
- }
3693
- }
3694
- if (!ret) {
3695
- throw new Error("No revision found for form " + formId2);
3696
- }
3697
- return ret;
3854
+ const selectFormMapping = (state) => {
3855
+ return state.formReducer.forms;
3698
3856
  };
3699
- const selectLatestFormRevision = restructureCreateSelectorWithArgs(
3857
+ const selectFormOfComponentType = restructureCreateSelectorWithArgs(
3700
3858
  toolkit.createSelector(
3701
- [(state) => state.userFormReducer.revisions, (_state, formId2) => formId2],
3702
- (revisions, formId2) => {
3703
- if (!formId2) {
3704
- throw new Error("formId is required");
3705
- }
3706
- return _selectLatestFormRevision(revisions, formId2);
3859
+ [selectFormMapping, (_state, componentTypeId) => componentTypeId],
3860
+ (userForms, componentTypeId) => {
3861
+ return Object.values(userForms).find((userForm) => userForm.component_type === componentTypeId);
3707
3862
  }
3708
3863
  )
3709
3864
  );
3710
- const selectUserForm = (formId2) => (state) => {
3711
- return state.userFormReducer.userForms[formId2];
3712
- };
3713
- const selectSubmissionMapping = (state) => state.userFormReducer.submissions;
3714
- const selectUserFormSubmission = (submissionId) => (state) => {
3715
- return state.userFormReducer.submissions[submissionId];
3716
- };
3717
- const selectSubmissions = toolkit.createSelector([selectSubmissionMapping], (submissions) => Object.values(submissions));
3718
- const selectRevisionMapping = (state) => state.userFormReducer.revisions;
3719
- const selectRevisions = toolkit.createSelector([selectRevisionMapping], (revisions) => Object.values(revisions));
3720
- const selectRevisionsForForm = restructureCreateSelectorWithArgs(
3721
- toolkit.createSelector([selectRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
3722
- return revisions.filter((revision) => {
3723
- return revision.form === formId2;
3724
- });
3725
- })
3865
+ const selectFormOfIssueType = restructureCreateSelectorWithArgs(
3866
+ toolkit.createSelector(
3867
+ [selectFormMapping, (_state, issueTypeId) => issueTypeId],
3868
+ (userForms, issueTypeId) => {
3869
+ return Object.values(userForms).find((userForm) => userForm.issue_type === issueTypeId);
3870
+ }
3871
+ )
3872
+ );
3873
+ const selectFormsCount = toolkit.createSelector([selectFormMapping], (userForms) => {
3874
+ return Object.keys(userForms).length;
3875
+ });
3876
+ const selectGeneralFormCount = toolkit.createSelector([selectFormMapping], (userForms) => {
3877
+ return Object.values(userForms).filter((form) => !form.component_type).length;
3878
+ });
3879
+ const formReducer = formSlice.reducer;
3880
+ const initialState$5 = {
3881
+ formSubmissions: {},
3882
+ attachments: {}
3883
+ };
3884
+ const formSubmissionSlice = toolkit.createSlice({
3885
+ name: "formSubmissions",
3886
+ initialState: initialState$5,
3887
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
3888
+ reducers: {
3889
+ setFormSubmission: (state, action) => {
3890
+ state.formSubmissions[action.payload.offline_id] = action.payload;
3891
+ },
3892
+ setFormSubmissions: (state, action) => {
3893
+ state.formSubmissions = {};
3894
+ for (const submission of action.payload) {
3895
+ state.formSubmissions[submission.offline_id] = submission;
3896
+ }
3897
+ },
3898
+ addFormSubmission: (state, action) => {
3899
+ if (action.payload.offline_id in state.formSubmissions) {
3900
+ throw new Error(`Submission with offline_id ${action.payload.offline_id} already exists`);
3901
+ }
3902
+ state.formSubmissions[action.payload.offline_id] = action.payload;
3903
+ },
3904
+ addFormSubmissions: (state, action) => {
3905
+ for (const submission of action.payload) {
3906
+ if (state.formSubmissions[submission.offline_id] !== void 0) {
3907
+ throw new Error(`Submission with offline_id ${submission.offline_id} already exists`);
3908
+ }
3909
+ }
3910
+ for (const submission of action.payload) {
3911
+ state.formSubmissions[submission.offline_id] = submission;
3912
+ }
3913
+ },
3914
+ updateFormSubmission: (state, action) => {
3915
+ if (state.formSubmissions[action.payload.offline_id] === void 0) {
3916
+ throw new Error(`Submission with offline_id ${action.payload.offline_id} does not exist`);
3917
+ }
3918
+ state.formSubmissions[action.payload.offline_id] = action.payload;
3919
+ },
3920
+ updateFormSubmissions: (state, action) => {
3921
+ for (const submission of action.payload) {
3922
+ if (state.formSubmissions[submission.offline_id] === void 0) {
3923
+ throw new Error(`Submission with offline_id ${submission.offline_id} does not exist`);
3924
+ }
3925
+ }
3926
+ for (const submission of action.payload) {
3927
+ state.formSubmissions[submission.offline_id] = submission;
3928
+ }
3929
+ },
3930
+ deleteFormSubmission: (state, action) => {
3931
+ if (state.formSubmissions[action.payload] === void 0) {
3932
+ throw new Error(`Submission with offline_id ${action.payload} does not exist`);
3933
+ }
3934
+ delete state.formSubmissions[action.payload];
3935
+ },
3936
+ deleteFormSubmissions: (state, action) => {
3937
+ for (const offlineId of action.payload) {
3938
+ if (state.formSubmissions[offlineId] === void 0) {
3939
+ throw new Error(`Submission with offline_id ${offlineId} does not exist`);
3940
+ }
3941
+ delete state.formSubmissions[offlineId];
3942
+ }
3943
+ for (const offlineId of action.payload) {
3944
+ delete state.formSubmissions[offlineId];
3945
+ }
3946
+ },
3947
+ // Attachments
3948
+ addFormSubmissionAttachment: (state, action) => {
3949
+ if (state.attachments[action.payload.offline_id] !== void 0) {
3950
+ throw new Error(`Attachment with offline_id ${action.payload.offline_id} already exists`);
3951
+ }
3952
+ state.attachments[action.payload.offline_id] = action.payload;
3953
+ },
3954
+ addFormSubmissionAttachments: (state, action) => {
3955
+ for (const attachment of action.payload) {
3956
+ if (state.attachments[attachment.offline_id] !== void 0) {
3957
+ throw new Error(`Attachment with offline_id ${attachment.offline_id} already exists`);
3958
+ }
3959
+ }
3960
+ for (const attachment of action.payload) {
3961
+ state.attachments[attachment.offline_id] = attachment;
3962
+ }
3963
+ },
3964
+ // We only need a multi set for attachments because they are not updated, only added and deleted
3965
+ setFormSubmissionAttachments: (state, action) => {
3966
+ state.attachments = {};
3967
+ for (const attachment of action.payload) {
3968
+ state.attachments[attachment.offline_id] = attachment;
3969
+ }
3970
+ },
3971
+ updateFormSubmissionAttachments: (state, action) => {
3972
+ for (const attachment of action.payload) {
3973
+ if (state.attachments[attachment.offline_id] === void 0) {
3974
+ throw new Error(`Attachment with offline_id ${attachment.offline_id} does not exist`);
3975
+ }
3976
+ }
3977
+ for (const attachment of action.payload) {
3978
+ state.attachments[attachment.offline_id] = attachment;
3979
+ }
3980
+ },
3981
+ // The delete actions for UserFormSubmissionAttachments are not used in the app, but are included for completeness
3982
+ // Could be used if editing a submission is ever supported, will be applicable for supporting tip tap content in submissions
3983
+ deleteFormSubmissionAttachment: (state, action) => {
3984
+ if (state.attachments[action.payload] === void 0) {
3985
+ throw new Error(`Attachment with offline_id ${action.payload} does not exist`);
3986
+ }
3987
+ delete state.attachments[action.payload];
3988
+ },
3989
+ deleteFormSubmissionAttachments: (state, action) => {
3990
+ for (const offlineId of action.payload) {
3991
+ if (state.attachments[offlineId] === void 0) {
3992
+ throw new Error(`Attachment with offline_id ${offlineId} does not exist`);
3993
+ }
3994
+ delete state.attachments[offlineId];
3995
+ }
3996
+ }
3997
+ }
3998
+ });
3999
+ const {
4000
+ setFormSubmission,
4001
+ setFormSubmissions,
4002
+ addFormSubmission,
4003
+ addFormSubmissions,
4004
+ updateFormSubmission,
4005
+ updateFormSubmissions,
4006
+ deleteFormSubmission,
4007
+ deleteFormSubmissions,
4008
+ addFormSubmissionAttachment,
4009
+ addFormSubmissionAttachments,
4010
+ setFormSubmissionAttachments,
4011
+ updateFormSubmissionAttachments,
4012
+ deleteFormSubmissionAttachment,
4013
+ deleteFormSubmissionAttachments
4014
+ } = formSubmissionSlice.actions;
4015
+ const selectFormSubmissionsMapping = (state) => {
4016
+ return state.formSubmissionReducer.formSubmissions;
4017
+ };
4018
+ const selectFormSubmissions = toolkit.createSelector(
4019
+ [selectFormSubmissionsMapping],
4020
+ (submissions) => {
4021
+ return Object.values(submissions);
4022
+ }
3726
4023
  );
3727
- const selectSubmissionsForForm = restructureCreateSelectorWithArgs(
4024
+ const selectFormSubmission = (submissionId) => (state) => {
4025
+ return state.formSubmissionReducer.formSubmissions[submissionId];
4026
+ };
4027
+ const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
3728
4028
  toolkit.createSelector(
3729
- [selectSubmissions, selectRevisionMapping, (_state, formId2) => formId2],
4029
+ [selectFormSubmissions, selectFormRevisionMapping, (_state, formId2) => formId2],
3730
4030
  (submissions, revisionMapping, formId2) => {
3731
- return Object.values(submissions).filter((submission) => {
4031
+ return submissions.filter((submission) => {
3732
4032
  const revision = revisionMapping[submission.form_revision];
3733
4033
  return (revision == null ? void 0 : revision.form) === formId2;
3734
4034
  });
3735
4035
  }
3736
4036
  )
3737
4037
  );
3738
- const selectSubmissionsForIssue = restructureCreateSelectorWithArgs(
4038
+ const selectFormSubmissionsByFormRevisions = toolkit.createSelector([selectFormRevisionMapping, selectFormSubmissions], (revisions, submissions) => {
4039
+ var _a2;
4040
+ const submissionMapping = {};
4041
+ for (const revisionId in revisions) {
4042
+ submissionMapping[revisionId] = [];
4043
+ }
4044
+ for (const submission of submissions) {
4045
+ (_a2 = submissionMapping[submission.form_revision]) == null ? void 0 : _a2.push(submission);
4046
+ }
4047
+ return submissionMapping;
4048
+ });
4049
+ const selectSortedFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
4050
+ toolkit.createSelector(
4051
+ [
4052
+ selectFormRevisionMapping,
4053
+ selectFormSubmissionsByFormRevisions,
4054
+ (_state, formId2) => formId2
4055
+ ],
4056
+ (revisionsMapping, submissionsByRevision, formId2) => {
4057
+ const submissionsByFormRevisions = {};
4058
+ for (const revisionId in revisionsMapping) {
4059
+ const revision = revisionsMapping[revisionId];
4060
+ const submissionsOfRevision = submissionsByRevision[revisionId];
4061
+ if (revision && submissionsOfRevision && revision.form === formId2) {
4062
+ submissionsByFormRevisions[revisionId] = submissionsOfRevision.sort(
4063
+ (a, b) => a.submitted_at < b.submitted_at ? -1 : 1
4064
+ );
4065
+ }
4066
+ }
4067
+ return Object.entries(submissionsByFormRevisions).sort((a, b) => {
4068
+ const aRevision = revisionsMapping[a[0]];
4069
+ const bRevision = revisionsMapping[b[0]];
4070
+ return formRevisionSortFn(aRevision, bRevision);
4071
+ }).map(([_revisionId, submissions]) => submissions).flat();
4072
+ }
4073
+ )
4074
+ );
4075
+ const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
3739
4076
  toolkit.createSelector(
3740
- [(state) => state.userFormReducer.submissions, (_state, issueId) => issueId],
4077
+ [selectFormSubmissions, (_state, issueId) => issueId],
3741
4078
  (submissions, issueId) => {
3742
4079
  return Object.values(submissions).filter((submission) => {
3743
4080
  return submission.issue === issueId;
@@ -3745,9 +4082,9 @@ var __publicField = (obj, key, value) => {
3745
4082
  }
3746
4083
  )
3747
4084
  );
3748
- const selectSubmissionsForComponent = restructureCreateSelectorWithArgs(
4085
+ const selectFormSubmissionsOfComponent = restructureCreateSelectorWithArgs(
3749
4086
  toolkit.createSelector(
3750
- [selectSubmissions, (_state, componentId) => componentId],
4087
+ [selectFormSubmissions, (_state, componentId) => componentId],
3751
4088
  (submissions, componentId) => {
3752
4089
  return submissions.filter((submission) => {
3753
4090
  return submission.component === componentId;
@@ -3755,8 +4092,8 @@ var __publicField = (obj, key, value) => {
3755
4092
  }
3756
4093
  )
3757
4094
  );
3758
- const selectComponentSubmissionMapping = toolkit.createSelector(
3759
- [selectSubmissionMapping, selectComponentsMapping],
4095
+ const selectFormSubmissionsByComponents = toolkit.createSelector(
4096
+ [selectFormSubmissionsMapping, selectComponentsMapping],
3760
4097
  (submissions, components) => {
3761
4098
  var _a2;
3762
4099
  const componentSubmissionMapping = {};
@@ -3772,60 +4109,24 @@ var __publicField = (obj, key, value) => {
3772
4109
  return componentSubmissionMapping;
3773
4110
  }
3774
4111
  );
3775
- const selectUserFormMapping = (state) => {
3776
- return state.userFormReducer.userForms;
4112
+ const selectFormSubmissionAttachmentsMapping = (state) => {
4113
+ return state.formSubmissionReducer.attachments;
3777
4114
  };
3778
- const selectComponentTypeForm = restructureCreateSelectorWithArgs(
4115
+ const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
3779
4116
  toolkit.createSelector(
3780
- [selectUserFormMapping, (_state, componentTypeId) => componentTypeId],
3781
- (userForms, componentTypeId) => {
3782
- return Object.values(userForms).find((userForm) => userForm.component_type === componentTypeId);
4117
+ [selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
4118
+ (attachmentsMapping, submissionId) => {
4119
+ return Object.values(attachmentsMapping).filter((attachment) => attachment.submission === submissionId);
3783
4120
  }
3784
4121
  )
3785
4122
  );
3786
- const selectLatestRevisionsFromComponentTypeIds = restructureCreateSelectorWithArgs(
3787
- toolkit.createSelector(
3788
- [
3789
- selectUserFormMapping,
3790
- selectRevisionMapping,
3791
- (_state, componentTypeIds) => componentTypeIds
3792
- ],
3793
- (userForms, revisions, componentTypeIds) => {
3794
- const componentTypeIdsSet = new Set(componentTypeIds);
3795
- const ret = {};
3796
- for (const form of Object.values(userForms)) {
3797
- if (form.component_type && componentTypeIdsSet.has(form.component_type)) {
3798
- ret[form.component_type] = _selectLatestFormRevision(revisions, form.offline_id);
3799
- }
3800
- }
3801
- return ret;
3802
- }
3803
- )
3804
- );
3805
- const selectLatestRevisionByFormId = toolkit.createSelector([selectRevisionMapping], (revisions) => {
3806
- const latestRevisions = {};
3807
- for (const revision of Object.values(revisions)) {
3808
- const formId2 = revision.form;
3809
- const currentLatestRevision = latestRevisions[formId2];
3810
- if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
3811
- latestRevisions[formId2] = revision;
3812
- }
3813
- }
3814
- return latestRevisions;
3815
- });
3816
- const selectNumberOfUserForms = toolkit.createSelector([selectUserFormMapping], (userForms) => {
3817
- return Object.keys(userForms).length;
3818
- });
3819
- const selectNumberOfGeneralUserForms = toolkit.createSelector([selectUserFormMapping], (userForms) => {
3820
- return Object.values(userForms).filter((form) => !form.component_type).length;
3821
- });
3822
- const userFormReducer = userFormSlice.reducer;
3823
- const initialState$2 = {
4123
+ const formSubmissionReducer = formSubmissionSlice.reducer;
4124
+ const initialState$4 = {
3824
4125
  emailDomains: {}
3825
4126
  };
3826
4127
  const emailDomainsSlice = toolkit.createSlice({
3827
4128
  name: "emailDomains",
3828
- initialState: initialState$2,
4129
+ initialState: initialState$4,
3829
4130
  reducers: {
3830
4131
  setEmailDomains: (state, action) => {
3831
4132
  const emailDomains = {};
@@ -3852,15 +4153,15 @@ var __publicField = (obj, key, value) => {
3852
4153
  (ed1, ed2) => ed1.domain.localeCompare(ed2.domain)
3853
4154
  );
3854
4155
  const emailDomainsReducer = emailDomainsSlice.reducer;
3855
- const initialState$1 = {
4156
+ const initialState$3 = {
3856
4157
  documents: {},
3857
4158
  attachments: {}
3858
4159
  };
3859
4160
  const documentSlice = toolkit.createSlice({
3860
4161
  name: "documents",
3861
- initialState: initialState$1,
4162
+ initialState: initialState$3,
3862
4163
  extraReducers: (builder) => builder.addCase("RESET", (state) => {
3863
- Object.assign(state, initialState$1);
4164
+ Object.assign(state, initialState$3);
3864
4165
  }),
3865
4166
  reducers: {
3866
4167
  setDocuments: (state, action) => {
@@ -3897,9 +4198,18 @@ var __publicField = (obj, key, value) => {
3897
4198
  }
3898
4199
  }
3899
4200
  for (const document2 of action.payload) {
4201
+ const existingDocument = state.documents[document2.offline_id];
4202
+ if (document2.organization !== void 0 && document2.organization !== existingDocument.organization) {
4203
+ throw new Error("organization cannot be updated");
4204
+ }
4205
+ if (document2.project !== void 0 && document2.project !== existingDocument.project) {
4206
+ throw new Error("project cannot be updated");
4207
+ }
3900
4208
  state.documents[document2.offline_id] = {
3901
- ...state.documents[document2.offline_id],
4209
+ ...existingDocument,
3902
4210
  ...document2
4211
+ // Without the cast, TypeScript doesn't realize that we have guaranteed that the document doesn't
4212
+ // have both a project and an organization.
3903
4213
  };
3904
4214
  }
3905
4215
  },
@@ -4076,6 +4386,78 @@ var __publicField = (obj, key, value) => {
4076
4386
  )
4077
4387
  );
4078
4388
  const documentsReducer = documentSlice.reducer;
4389
+ const initialState$2 = {
4390
+ teams: {}
4391
+ };
4392
+ const teamSlice = toolkit.createSlice({
4393
+ name: "teams",
4394
+ initialState: initialState$2,
4395
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
4396
+ reducers: {
4397
+ setTeam: (state, action) => {
4398
+ state.teams[action.payload.offline_id] = action.payload;
4399
+ },
4400
+ setTeams: (state, action) => {
4401
+ state.teams = {};
4402
+ for (const team of action.payload) {
4403
+ state.teams[team.offline_id] = team;
4404
+ }
4405
+ },
4406
+ addTeam: (state, action) => {
4407
+ if (state.teams[action.payload.offline_id]) {
4408
+ throw new Error(`Team with offline_id ${action.payload.offline_id} already exists`);
4409
+ }
4410
+ state.teams[action.payload.offline_id] = action.payload;
4411
+ },
4412
+ updateTeam: (state, action) => {
4413
+ if (!state.teams[action.payload.offline_id]) {
4414
+ throw new Error(`Team with offline_id ${action.payload.offline_id} does not exist`);
4415
+ }
4416
+ state.teams[action.payload.offline_id] = action.payload;
4417
+ },
4418
+ deleteTeam: (state, action) => {
4419
+ delete state.teams[action.payload];
4420
+ }
4421
+ }
4422
+ });
4423
+ const { setTeam, setTeams, addTeam, updateTeam, deleteTeam } = teamSlice.actions;
4424
+ const selectTeamsMapping = (state) => state.teamReducer.teams;
4425
+ const selectTeams = toolkit.createSelector([selectTeamsMapping], (teams) => {
4426
+ return Object.values(teams);
4427
+ });
4428
+ const selectTeam = (teamId) => (state) => {
4429
+ return state.teamReducer.teams[teamId];
4430
+ };
4431
+ const selectTeamsOfOrganization = restructureCreateSelectorWithArgs(
4432
+ toolkit.createSelector(
4433
+ [selectTeams, (_state, organizationId) => organizationId],
4434
+ (teams, organizationId) => {
4435
+ return teams.filter((team) => team.organization === organizationId);
4436
+ }
4437
+ )
4438
+ );
4439
+ const selectTeamsOfUser = restructureCreateSelectorWithArgs(
4440
+ toolkit.createSelector([selectTeams, (_state, userId) => userId], (teams, userId) => {
4441
+ return teams.filter((team) => team.members.includes(userId));
4442
+ })
4443
+ );
4444
+ const teamReducer = teamSlice.reducer;
4445
+ const initialState$1 = {
4446
+ conversationId: void 0
4447
+ };
4448
+ const agentSlice = toolkit.createSlice({
4449
+ name: "agents",
4450
+ initialState: initialState$1,
4451
+ extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$1)),
4452
+ reducers: {
4453
+ setConversationId: (state, action) => {
4454
+ state.conversationId = action.payload;
4455
+ }
4456
+ }
4457
+ });
4458
+ const { setConversationId } = agentSlice.actions;
4459
+ const selectConversationId = (state) => state.agentReducer.conversationId;
4460
+ const agentReducer = agentSlice.reducer;
4079
4461
  const initialState = {
4080
4462
  version: 0
4081
4463
  };
@@ -4108,6 +4490,7 @@ var __publicField = (obj, key, value) => {
4108
4490
  componentStageReducer,
4109
4491
  componentTypeReducer,
4110
4492
  issueReducer,
4493
+ issueTypeReducer,
4111
4494
  mapReducer,
4112
4495
  organizationReducer,
4113
4496
  outboxReducer,
@@ -4117,12 +4500,16 @@ var __publicField = (obj, key, value) => {
4117
4500
  projectFileReducer,
4118
4501
  rehydratedReducer,
4119
4502
  settingReducer,
4120
- userFormReducer,
4503
+ formReducer,
4504
+ formRevisionReducer,
4505
+ formSubmissionReducer,
4121
4506
  userReducer,
4122
4507
  workspaceReducer,
4123
4508
  emailDomainsReducer,
4124
4509
  licenseReducer,
4125
- documentsReducer
4510
+ documentsReducer,
4511
+ teamReducer,
4512
+ agentReducer
4126
4513
  };
4127
4514
  const overmapReducer = toolkit.combineReducers(overmapReducers);
4128
4515
  const resetStore = "RESET";
@@ -4170,9 +4557,7 @@ var __publicField = (obj, key, value) => {
4170
4557
  throw new Error(`Failed to update index_workspace of issue ${issue.offline_id} to main workspace`);
4171
4558
  }
4172
4559
  }
4173
- const indexedForms = Object.values(draft.userFormReducer.userForms).filter(
4174
- (form) => form.index_workspace === workspaceId
4175
- );
4560
+ const indexedForms = Object.values(draft.formReducer.forms).filter((form) => form.index_workspace === workspaceId);
4176
4561
  for (const form of indexedForms) {
4177
4562
  form.index_workspace = mainWorkspace.offline_id;
4178
4563
  }
@@ -6051,7 +6436,7 @@ var __publicField = (obj, key, value) => {
6051
6436
  // Basic CRUD functions
6052
6437
  // TODO: Once all models are represented in `Created<TModel>`, use `Created` in `OptimisticModelResult`, so we don't
6053
6438
  // have to repeat it for all optimistic model results (all optimistic results are created).
6054
- add(issue) {
6439
+ add(issue, issue_type = null) {
6055
6440
  const { store } = this.client;
6056
6441
  const dateWithoutMilliseconds = /* @__PURE__ */ new Date();
6057
6442
  const state = store.getState();
@@ -6077,7 +6462,8 @@ var __publicField = (obj, key, value) => {
6077
6462
  method: HttpMethod.POST,
6078
6463
  url: "/issues/",
6079
6464
  queryParams: {
6080
- workspace_id: workspaceId
6465
+ workspace_id: workspaceId,
6466
+ ...issue_type ? { issue_type } : {}
6081
6467
  },
6082
6468
  payload: issuePayload,
6083
6469
  blockers: [
@@ -6250,16 +6636,113 @@ var __publicField = (obj, key, value) => {
6250
6636
  throw e;
6251
6637
  }
6252
6638
  }
6253
- // Special functions
6639
+ // Special functions
6640
+ async refreshStore() {
6641
+ const { store } = this.client;
6642
+ const projectId = store.getState().projectReducer.activeProjectId;
6643
+ if (!projectId) {
6644
+ throw new Error("No active project");
6645
+ }
6646
+ const [_offlineIssues, promise] = this.fetchAll(projectId);
6647
+ const result = await promise;
6648
+ store.dispatch(setIssues(result));
6649
+ }
6650
+ }
6651
+ class IssueTypeService extends BaseApiService {
6652
+ add(payload) {
6653
+ const { store } = this.client;
6654
+ const activeOrganizationId = store.getState().organizationReducer.activeOrganizationId;
6655
+ if (!activeOrganizationId) {
6656
+ throw new Error(`No active organization, got ${activeOrganizationId} for activeOrganizationId.`);
6657
+ }
6658
+ const offlineIssueType = offline({
6659
+ ...payload,
6660
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
6661
+ created_by: store.getState().userReducer.currentUser.id,
6662
+ organization: activeOrganizationId
6663
+ });
6664
+ store.dispatch(addIssueType(offlineIssueType));
6665
+ const promise = this.enqueueRequest({
6666
+ method: HttpMethod.POST,
6667
+ url: `/organizations/${activeOrganizationId}/issue-types/`,
6668
+ // Sending only whats needed here
6669
+ payload: {
6670
+ offline_id: offlineIssueType.offline_id,
6671
+ submitted_at: offlineIssueType.submitted_at,
6672
+ icon: offlineIssueType.icon,
6673
+ icon_color: offlineIssueType.icon_color,
6674
+ name: offlineIssueType.name,
6675
+ description: offlineIssueType.description
6676
+ },
6677
+ blockers: [],
6678
+ blocks: [offlineIssueType.offline_id]
6679
+ });
6680
+ promise.then((createdIssueType) => {
6681
+ store.dispatch(setIssueType(createdIssueType));
6682
+ }).catch(() => {
6683
+ store.dispatch(removeIssueType(offlineIssueType.offline_id));
6684
+ });
6685
+ return [offlineIssueType, promise];
6686
+ }
6687
+ update(issueTypeFields) {
6688
+ const { store } = this.client;
6689
+ const issueTypeToBeUpdated = store.getState().issueTypeReducer.issueTypes[issueTypeFields.offline_id];
6690
+ if (!issueTypeToBeUpdated) {
6691
+ throw new Error(`IssueType with offline_id ${issueTypeFields.offline_id} does not exist in the store.`);
6692
+ }
6693
+ const offlineUpdatedIssueType = {
6694
+ ...issueTypeToBeUpdated,
6695
+ ...issueTypeFields
6696
+ };
6697
+ store.dispatch(updateIssueType(offlineUpdatedIssueType));
6698
+ const promise = this.enqueueRequest({
6699
+ method: HttpMethod.PATCH,
6700
+ url: `/issues/types/${issueTypeFields.offline_id}/`,
6701
+ payload: issueTypeFields,
6702
+ blockers: [issueTypeFields.offline_id],
6703
+ blocks: [issueTypeFields.offline_id]
6704
+ });
6705
+ promise.then((updatedIssueType) => {
6706
+ store.dispatch(setIssueType(updatedIssueType));
6707
+ }).catch(() => {
6708
+ store.dispatch(setIssueType(issueTypeToBeUpdated));
6709
+ });
6710
+ return [offlineUpdatedIssueType, promise];
6711
+ }
6712
+ delete(issueTypeId) {
6713
+ const { store } = this.client;
6714
+ const issueTypeToDelete = store.getState().issueTypeReducer.issueTypes[issueTypeId];
6715
+ if (!issueTypeToDelete) {
6716
+ throw new Error(`IssueType with offline_id ${issueTypeId} does not exist in the store.`);
6717
+ }
6718
+ const issuesOfIssueType = selectIssuesOfIssueType(issueTypeId)(store.getState()) ?? [];
6719
+ store.dispatch(removeIssueType(issueTypeId));
6720
+ store.dispatch(removeIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
6721
+ const promise = this.enqueueRequest({
6722
+ method: HttpMethod.DELETE,
6723
+ url: `/issues/types/${issueTypeId}/`,
6724
+ blockers: [issueTypeId],
6725
+ blocks: []
6726
+ });
6727
+ promise.catch(() => {
6728
+ store.dispatch(setIssueType(issueTypeToDelete));
6729
+ store.dispatch(addIssues(issuesOfIssueType));
6730
+ });
6731
+ return promise;
6732
+ }
6254
6733
  async refreshStore() {
6255
6734
  const { store } = this.client;
6256
- const projectId = store.getState().projectReducer.activeProjectId;
6257
- if (!projectId) {
6258
- throw new Error("No active project");
6735
+ const activeOrganizationId = store.getState().organizationReducer.activeOrganizationId;
6736
+ if (!activeOrganizationId) {
6737
+ throw new Error(`No active organization, got ${activeOrganizationId} for activeOrganizationId.`);
6259
6738
  }
6260
- const [_offlineIssues, promise] = this.fetchAll(projectId);
6261
- const result = await promise;
6262
- store.dispatch(setIssues(result));
6739
+ const result = await this.enqueueRequest({
6740
+ method: HttpMethod.GET,
6741
+ url: `/organizations/${activeOrganizationId}/issue-types/`,
6742
+ blockers: [],
6743
+ blocks: []
6744
+ });
6745
+ store.dispatch(setIssueTypes(result));
6263
6746
  }
6264
6747
  }
6265
6748
  class MainService extends BaseApiService {
@@ -6363,6 +6846,7 @@ var __publicField = (obj, key, value) => {
6363
6846
  }
6364
6847
  if (currentOrgId) {
6365
6848
  await this.client.organizations.fetchInitialOrganizationData(currentOrgId, false);
6849
+ void this.client.teams.refreshStore();
6366
6850
  }
6367
6851
  if (!isProjectIdValid) {
6368
6852
  if (validProjects.length !== 0) {
@@ -6436,6 +6920,7 @@ var __publicField = (obj, key, value) => {
6436
6920
  });
6437
6921
  void this.client.documents.refreshStore();
6438
6922
  void this.client.issueUpdates.refreshStore();
6923
+ void this.client.issueTypes.refreshStore();
6439
6924
  }
6440
6925
  store.dispatch(setIsFetchingInitialData(false));
6441
6926
  if (overwrite) {
@@ -6800,12 +7285,12 @@ var __publicField = (obj, key, value) => {
6800
7285
  ...revisionAttachmentPayload,
6801
7286
  file: URL.createObjectURL(image)
6802
7287
  };
6803
- store.dispatch(addUserFormRevisionAttachment(offlinePayload));
7288
+ store.dispatch(addFormRevisionAttachment(offlinePayload));
6804
7289
  return attach;
6805
7290
  });
6806
7291
  });
6807
7292
  }
6808
- async add(state, initialRevision, url, ownerUser, ownerOrganization, componentTypeId) {
7293
+ async add(state, initialRevision, url, ownerUser, ownerOrganization, componentTypeId, issueTypeId) {
6809
7294
  if (!!ownerUser === !!ownerOrganization) {
6810
7295
  throw new Error("Exactly one of ownerUser and ownerOrganization must be defined.");
6811
7296
  }
@@ -6815,15 +7300,17 @@ var __publicField = (obj, key, value) => {
6815
7300
  };
6816
7301
  const currentUser = state.userReducer.currentUser;
6817
7302
  const activeWorkspaceId = state.workspaceReducer.activeWorkspaceId;
7303
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
6818
7304
  const offlineFormPayload = offline({});
6819
- const offlineRevisionPayload = offline(initialRevision);
7305
+ const offlineRevisionPayload = offline({ ...initialRevision, submitted_at: submittedAt });
6820
7306
  const retForm = {
6821
7307
  ...offlineFormPayload,
6822
7308
  index_workspace: activeWorkspaceId,
6823
7309
  favorite: true,
6824
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
7310
+ submitted_at: submittedAt,
6825
7311
  created_by: currentUser.id,
6826
7312
  ...componentTypeId && { component_type: componentTypeId },
7313
+ ...issueTypeId && { issue_type: issueTypeId },
6827
7314
  ...ownerAttrs
6828
7315
  };
6829
7316
  const { payloadWithoutImage, images } = await separateImageFromFields(offlineRevisionPayload);
@@ -6831,11 +7318,12 @@ var __publicField = (obj, key, value) => {
6831
7318
  ...payloadWithoutImage,
6832
7319
  created_by: currentUser.id,
6833
7320
  form: retForm.offline_id,
6834
- revision: 0
7321
+ revision: 0,
7322
+ submitted_at: submittedAt
6835
7323
  };
6836
7324
  const { store } = this.client;
6837
- store.dispatch(addUserForm(retForm));
6838
- store.dispatch(addUserFormRevision(retRevision));
7325
+ store.dispatch(addForm(retForm));
7326
+ store.dispatch(addFormRevision(retRevision));
6839
7327
  const formPromise = this.enqueueRequest({
6840
7328
  description: "Create form",
6841
7329
  method: HttpMethod.POST,
@@ -6846,21 +7334,22 @@ var __publicField = (obj, key, value) => {
6846
7334
  payload: {
6847
7335
  ...offlineFormPayload,
6848
7336
  ...componentTypeId && { component_type: componentTypeId },
7337
+ ...issueTypeId && { issue_type: issueTypeId },
6849
7338
  initial_revision: payloadWithoutImage
6850
7339
  },
6851
- blockers: componentTypeId ? [componentTypeId] : [],
7340
+ blockers: componentTypeId ? [componentTypeId] : issueTypeId ? [issueTypeId] : [],
6852
7341
  blocks: [offlineFormPayload.offline_id, payloadWithoutImage.offline_id]
6853
7342
  });
6854
7343
  const attachImagesPromises = this.getAttachImagePromises(images, offlineRevisionPayload.offline_id);
6855
7344
  void formPromise.catch((e) => {
6856
- store.dispatch(deleteUserForm(retForm.offline_id));
6857
- store.dispatch(deleteUserFormRevision(retRevision.offline_id));
7345
+ store.dispatch(deleteForm(retForm.offline_id));
7346
+ store.dispatch(deleteFormRevision(retRevision.offline_id));
6858
7347
  throw e;
6859
7348
  });
6860
7349
  const settledPromise = Promise.all([formPromise, ...attachImagesPromises]).then(() => formPromise);
6861
7350
  return [retForm, retRevision, formPromise, settledPromise];
6862
7351
  }
6863
- async addForOrganization(initialRevision, componentTypeId) {
7352
+ async addForOrganization(initialRevision, attachedTo) {
6864
7353
  const state = this.client.store.getState();
6865
7354
  const activeOrganizationId = state.organizationReducer.activeOrganizationId;
6866
7355
  if (!activeOrganizationId) {
@@ -6872,13 +7361,22 @@ var __publicField = (obj, key, value) => {
6872
7361
  `/forms/in-organization/${activeOrganizationId}/`,
6873
7362
  void 0,
6874
7363
  activeOrganizationId,
6875
- componentTypeId
7364
+ attachedTo && "componentTypeId" in attachedTo ? attachedTo.componentTypeId : void 0,
7365
+ attachedTo && "issueTypeId" in attachedTo ? attachedTo.issueTypeId : void 0
6876
7366
  );
6877
7367
  }
6878
- async addForCurrentUser(initialRevision, componentTypeId) {
7368
+ async addForCurrentUser(initialRevision, attachedTo) {
6879
7369
  const state = this.client.store.getState();
6880
7370
  const currentUser = state.userReducer.currentUser;
6881
- return await this.add(state, initialRevision, "/forms/my-forms/", currentUser.id, void 0, componentTypeId);
7371
+ return await this.add(
7372
+ state,
7373
+ initialRevision,
7374
+ "/forms/my-forms/",
7375
+ currentUser.id,
7376
+ void 0,
7377
+ attachedTo && "componentTypeId" in attachedTo ? attachedTo.componentTypeId : void 0,
7378
+ attachedTo && "issueTypeId" in attachedTo ? attachedTo.issueTypeId : void 0
7379
+ );
6882
7380
  }
6883
7381
  async createRevision(formId2, revision) {
6884
7382
  const offlineRevision = offline(revision);
@@ -6894,9 +7392,10 @@ var __publicField = (obj, key, value) => {
6894
7392
  ...payloadWithoutImage,
6895
7393
  created_by: currentUserId,
6896
7394
  revision: "Pending",
6897
- form: formId2
7395
+ form: formId2,
7396
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
6898
7397
  };
6899
- store.dispatch(addUserFormRevision(fullRevision));
7398
+ store.dispatch(addFormRevision(fullRevision));
6900
7399
  const promise = this.enqueueRequest({
6901
7400
  description: "Create form revision",
6902
7401
  method: HttpMethod.PATCH,
@@ -6910,9 +7409,9 @@ var __publicField = (obj, key, value) => {
6910
7409
  });
6911
7410
  const attachImagesPromises = this.getAttachImagePromises(images, offlineRevision.offline_id);
6912
7411
  void promise.then((result) => {
6913
- store.dispatch(addUserFormRevision(result));
7412
+ store.dispatch(setFormRevision(result));
6914
7413
  }).catch(() => {
6915
- store.dispatch(deleteUserFormRevision(fullRevision.offline_id));
7414
+ store.dispatch(deleteFormRevision(fullRevision.offline_id));
6916
7415
  });
6917
7416
  const settledPromise = Promise.all([promise, ...attachImagesPromises]).then(() => promise);
6918
7417
  return [fullRevision, settledPromise];
@@ -6954,19 +7453,19 @@ var __publicField = (obj, key, value) => {
6954
7453
  async delete(formId2) {
6955
7454
  const { store } = this.client;
6956
7455
  const state = store.getState();
6957
- const userForm = selectUserForm(formId2)(state);
7456
+ const userForm = selectForm(formId2)(state);
6958
7457
  if (!userForm) {
6959
7458
  throw new Error("Expected userForm to exist");
6960
7459
  }
6961
- const userFormSubmissions = selectSubmissionsForForm(formId2)(state);
7460
+ const userFormSubmissions = selectFormSubmissionsOfForm(formId2)(state);
6962
7461
  if (userFormSubmissions && userFormSubmissions.length > 0) {
6963
- store.dispatch(deleteUserFormSubmissions(userFormSubmissions));
7462
+ store.dispatch(deleteFormSubmissions(userFormSubmissions.map(({ offline_id }) => offline_id)));
6964
7463
  }
6965
- const userFormRevisions = selectRevisionsForForm(formId2)(state);
7464
+ const userFormRevisions = selectFormRevisionsOfForm(formId2)(state);
6966
7465
  if (userFormRevisions && userFormRevisions.length > 0) {
6967
- store.dispatch(deleteUserFormRevisions(userFormRevisions));
7466
+ store.dispatch(deleteFormRevisions(userFormRevisions.map(({ offline_id }) => offline_id)));
6968
7467
  }
6969
- store.dispatch(deleteUserForm(formId2));
7468
+ store.dispatch(deleteForm(formId2));
6970
7469
  try {
6971
7470
  return await this.enqueueRequest({
6972
7471
  description: "Delete form",
@@ -6976,12 +7475,12 @@ var __publicField = (obj, key, value) => {
6976
7475
  blocks: []
6977
7476
  });
6978
7477
  } catch (e) {
6979
- store.dispatch(addUserForm(userForm));
7478
+ store.dispatch(addForm(userForm));
6980
7479
  if (userFormRevisions && userFormRevisions.length > 0) {
6981
- store.dispatch(addUserFormRevisions(userFormRevisions));
7480
+ store.dispatch(addFormRevisions(userFormRevisions));
6982
7481
  }
6983
7482
  if (userFormSubmissions && userFormSubmissions.length > 0) {
6984
- store.dispatch(addUserFormSubmissions(userFormSubmissions));
7483
+ store.dispatch(addFormSubmissions(userFormSubmissions));
6985
7484
  }
6986
7485
  throw e;
6987
7486
  }
@@ -6995,16 +7494,15 @@ var __publicField = (obj, key, value) => {
6995
7494
  blockers: [],
6996
7495
  blocks: []
6997
7496
  });
6998
- store.dispatch(addUserForms(Object.values(result.forms)));
6999
- store.dispatch(addUserFormRevisions(Object.values(result.revisions)));
7000
- store.dispatch(setUserFormRevisionAttachments(Object.values(result.attachments)));
7497
+ store.dispatch(setForms(Object.values(result.forms)));
7498
+ store.dispatch(setFormRevisions(Object.values(result.revisions)));
7499
+ store.dispatch(setFormRevisionAttachments(Object.values(result.attachments)));
7001
7500
  }
7002
7501
  }
7003
7502
  const isArrayOfFiles = (value) => {
7004
7503
  return Array.isArray(value) && value[0] instanceof File;
7005
7504
  };
7006
- const separateFilesFromValues = (payload) => {
7007
- const { values } = payload;
7505
+ const separateFilesFromValues = (values) => {
7008
7506
  const files = {};
7009
7507
  const newValues = {};
7010
7508
  for (const key in values) {
@@ -7019,17 +7517,13 @@ var __publicField = (obj, key, value) => {
7019
7517
  newValues[key] = value;
7020
7518
  }
7021
7519
  }
7022
- const payloadWithoutFiles = {
7023
- ...payload,
7024
- values: newValues
7025
- };
7026
- return { payloadWithoutFiles, files };
7520
+ return { values: newValues, files };
7027
7521
  };
7028
7522
  class UserFormSubmissionService extends BaseApiService {
7029
7523
  constructor() {
7030
7524
  super(...arguments);
7031
7525
  // Attach files to submission, after uploading them to S3
7032
- __publicField(this, "getAttachFilesPromises", (files, payload) => {
7526
+ __publicField(this, "getAttachFilesPromises", (files, submission) => {
7033
7527
  const { store } = this.client;
7034
7528
  return Object.entries(files).map(async ([key, fileArray]) => {
7035
7529
  const attachResults = [];
@@ -7039,24 +7533,27 @@ var __publicField = (obj, key, value) => {
7039
7533
  const [fileProps] = await this.client.files.uploadFileToS3(sha1);
7040
7534
  const submissionAttachmentPayload = offline({
7041
7535
  ...fileProps,
7042
- submission: payload.offline_id,
7536
+ submission: submission.offline_id,
7043
7537
  field_identifier: key
7044
7538
  });
7045
7539
  const attach = await this.enqueueRequest({
7046
7540
  description: "Attach file to form submission",
7047
7541
  method: HttpMethod.POST,
7048
- url: `/forms/submission/${payload.offline_id}/attachments/`,
7542
+ url: `/forms/submission/${submission.offline_id}/attachments/`,
7049
7543
  payload: submissionAttachmentPayload,
7050
- blockers: [payload.component, payload.component_stage, payload.issue, payload.form_revision].filter(
7051
- (x) => x !== void 0
7052
- ),
7544
+ blockers: [
7545
+ submission.component,
7546
+ submission.component_stage,
7547
+ submission.issue,
7548
+ submission.form_revision
7549
+ ].filter((x) => x !== void 0),
7053
7550
  blocks: [submissionAttachmentPayload.offline_id]
7054
7551
  });
7055
7552
  const offlinePayload = {
7056
7553
  ...submissionAttachmentPayload,
7057
7554
  file: URL.createObjectURL(file)
7058
7555
  };
7059
- store.dispatch(addUserFormSubmissionAttachment(offlinePayload));
7556
+ store.dispatch(addFormSubmissionAttachment(offlinePayload));
7060
7557
  attachResults.push(attach);
7061
7558
  }
7062
7559
  return attachResults;
@@ -7070,71 +7567,168 @@ var __publicField = (obj, key, value) => {
7070
7567
  if (!activeProjectId) {
7071
7568
  throw new Error("Expected an active project");
7072
7569
  }
7073
- const { payloadWithoutFiles, files } = separateFilesFromValues(payload);
7570
+ const { values, files } = separateFilesFromValues(payload.values);
7571
+ const offlineSubmission = {
7572
+ ...payload,
7573
+ values,
7574
+ created_by: state.userReducer.currentUser.id,
7575
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
7576
+ };
7074
7577
  const promise = this.enqueueRequest({
7075
7578
  description: "Respond to form",
7076
7579
  method: HttpMethod.POST,
7077
7580
  url: `/forms/revisions/${payload.form_revision}/respond/`,
7078
- payload: { ...payloadWithoutFiles, project: activeProjectId },
7581
+ payload: { ...offlineSubmission, project: activeProjectId },
7079
7582
  blockers: [payload.issue, payload.component, payload.component_stage, "add-form-entry"].filter(
7080
7583
  (x) => x !== void 0
7081
7584
  ),
7082
7585
  blocks: [payload.offline_id]
7083
7586
  });
7084
- const attachFilesPromises = this.getAttachFilesPromises(files, payload);
7085
- const now = (/* @__PURE__ */ new Date()).toISOString();
7086
- const fullOfflineResult = {
7087
- ...payload,
7088
- created_by: state.userReducer.currentUser.id,
7089
- created_at: now,
7090
- updated_at: now
7091
- };
7092
- const offlineResultWithoutFiles = {
7093
- ...fullOfflineResult,
7094
- ...payloadWithoutFiles
7095
- };
7096
- store.dispatch(updateOrCreateUserFormSubmission(offlineResultWithoutFiles));
7587
+ const attachFilesPromises = this.getAttachFilesPromises(files, offlineSubmission);
7588
+ store.dispatch(addFormSubmission(offlineSubmission));
7097
7589
  void promise.then((result) => {
7098
7590
  store.dispatch(addActiveProjectFormSubmissionsCount(1));
7099
- store.dispatch(updateOrCreateUserFormSubmission(result));
7591
+ store.dispatch(setFormSubmission(result));
7100
7592
  return result;
7101
7593
  }).catch(() => {
7102
- store.dispatch(deleteUserFormSubmission(payload.offline_id));
7594
+ store.dispatch(deleteFormSubmission(payload.offline_id));
7103
7595
  store.dispatch(addActiveProjectFormSubmissionsCount(-1));
7104
7596
  });
7105
7597
  const settledPromise = Promise.all([promise, ...attachFilesPromises]).then(() => promise);
7106
- return [fullOfflineResult, settledPromise];
7598
+ return [offlineSubmission, settledPromise];
7107
7599
  }
7108
- update(submission) {
7600
+ // Note currently the bulkAdd method is specific to form submissions for components
7601
+ // TODO: adapt the support bulk adding to any model type
7602
+ async bulkAdd(args) {
7603
+ const { formRevision, values: argsValues, componentOfflineIds } = args;
7109
7604
  const { store } = this.client;
7110
- const { payloadWithoutFiles, files } = separateFilesFromValues(submission);
7111
- if (!("created_by" in payloadWithoutFiles) || !("created_at" in payloadWithoutFiles)) {
7112
- throw new Error("Expected payloadWithoutFiles to have created_by and created_at fields.");
7605
+ const offlineSubmissions = [];
7606
+ const offlineAttachments = [];
7607
+ const submissionOfflineIds = [];
7608
+ const submissionsPayload = [];
7609
+ const attachmentsPayload = [];
7610
+ const { values, files } = separateFilesFromValues(argsValues);
7611
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
7612
+ const createdBy = store.getState().userReducer.currentUser.id;
7613
+ for (const component_id of componentOfflineIds) {
7614
+ const submission = offline({
7615
+ form_revision: formRevision,
7616
+ values,
7617
+ created_by: createdBy,
7618
+ submitted_at: submittedAt,
7619
+ component: component_id
7620
+ });
7621
+ submissionOfflineIds.push(submission.offline_id);
7622
+ submissionsPayload.push({ offline_id: submission.offline_id, component_id });
7623
+ offlineSubmissions.push(submission);
7624
+ for (const [fieldIdentifier, fileArray] of Object.entries(files)) {
7625
+ for (const file of fileArray) {
7626
+ const sha1 = await hashFile(file);
7627
+ await this.client.files.addCache(file, sha1);
7628
+ const offlineAttachment = offline({
7629
+ file_name: file.name,
7630
+ file_sha1: sha1,
7631
+ file: URL.createObjectURL(file),
7632
+ submission: submission.offline_id,
7633
+ field_identifier: fieldIdentifier
7634
+ });
7635
+ offlineAttachments.push(offlineAttachment);
7636
+ attachmentsPayload.push({
7637
+ offline_id: offlineAttachment.offline_id,
7638
+ submission_id: submission.offline_id,
7639
+ sha1,
7640
+ name: file.name,
7641
+ field_identifier: fieldIdentifier
7642
+ });
7643
+ }
7644
+ }
7113
7645
  }
7646
+ const filesRecord = {};
7647
+ for (const file of Object.values(files).flat()) {
7648
+ const sha1 = await hashFile(file);
7649
+ filesRecord[sha1] = {
7650
+ sha1,
7651
+ extension: file.name.split(".").pop() || "",
7652
+ file_type: file.type,
7653
+ size: file.size
7654
+ };
7655
+ }
7656
+ store.dispatch(addFormSubmissions(offlineSubmissions));
7657
+ store.dispatch(addFormSubmissionAttachments(offlineAttachments));
7658
+ const promise = this.enqueueRequest({
7659
+ description: "Bulk add form submissions",
7660
+ method: HttpMethod.POST,
7661
+ url: `/forms/revisions/${formRevision}/bulk-respond/`,
7662
+ payload: {
7663
+ form_data: values,
7664
+ submitted_at: submittedAt,
7665
+ submissions: submissionsPayload,
7666
+ attachments: attachmentsPayload,
7667
+ files: Object.values(filesRecord)
7668
+ },
7669
+ blockers: componentOfflineIds,
7670
+ blocks: submissionOfflineIds
7671
+ });
7672
+ promise.then(({ submissions, attachments, presigned_urls }) => {
7673
+ store.dispatch(updateFormSubmissions(submissions));
7674
+ store.dispatch(updateFormSubmissionAttachments(attachments));
7675
+ for (const [sha1, presigned_url] of Object.entries(presigned_urls)) {
7676
+ const file = filesRecord[sha1];
7677
+ if (!file)
7678
+ continue;
7679
+ void this.enqueueRequest({
7680
+ url: presigned_url.url,
7681
+ description: "Upload file",
7682
+ method: HttpMethod.POST,
7683
+ isExternalUrl: true,
7684
+ isAuthNeeded: false,
7685
+ attachmentHash: sha1,
7686
+ blockers: [`s3-${file.sha1}.${file.extension}`],
7687
+ blocks: [sha1],
7688
+ s3url: presigned_url
7689
+ });
7690
+ }
7691
+ }).catch(() => {
7692
+ store.dispatch(deleteFormSubmissions(submissionOfflineIds));
7693
+ store.dispatch(deleteFormSubmissionAttachments(offlineAttachments.map((x) => x.offline_id)));
7694
+ });
7695
+ return [offlineSubmissions, promise.then(({ submissions }) => submissions)];
7696
+ }
7697
+ update(submission) {
7698
+ const { store } = this.client;
7699
+ const { values, files } = separateFilesFromValues(submission.values);
7114
7700
  const attachFilesPromises = this.getAttachFilesPromises(files, submission);
7115
- const fullResult = {
7116
- ...payloadWithoutFiles,
7117
- updated_at: (/* @__PURE__ */ new Date()).toISOString()
7701
+ const offlineSubmission = {
7702
+ ...submission,
7703
+ values
7118
7704
  };
7119
- store.dispatch(updateOrCreateUserFormSubmission(fullResult));
7705
+ const submissionToBeUpdated = store.getState().formSubmissionReducer.formSubmissions[submission.offline_id];
7706
+ store.dispatch(updateFormSubmission(offlineSubmission));
7120
7707
  const promise = this.enqueueRequest({
7121
7708
  description: "Patch form submission",
7122
7709
  method: HttpMethod.PATCH,
7123
7710
  url: `/forms/submissions/${submission.offline_id}/`,
7124
- payload: fullResult,
7125
- blockers: [fullResult.issue, fullResult.component, fullResult.component_stage].filter(
7711
+ payload: offlineSubmission,
7712
+ blockers: [offlineSubmission.issue, offlineSubmission.component, offlineSubmission.component_stage].filter(
7126
7713
  (x) => x !== void 0
7127
7714
  ),
7128
- blocks: [fullResult.offline_id]
7715
+ blocks: [offlineSubmission.offline_id]
7129
7716
  });
7130
- return Promise.all([promise, ...attachFilesPromises]).then(() => promise);
7717
+ promise.then((createdSubmission) => {
7718
+ store.dispatch(setFormSubmission(createdSubmission));
7719
+ }).catch(() => {
7720
+ store.dispatch(setFormSubmission(submissionToBeUpdated));
7721
+ });
7722
+ return [offlineSubmission, Promise.all([promise, ...attachFilesPromises]).then(() => promise)];
7131
7723
  }
7132
7724
  async delete(submissionId) {
7133
7725
  const { store } = this.client;
7134
7726
  const state = store.getState();
7135
- const submission = state.userFormReducer.submissions[submissionId];
7136
- store.dispatch(deleteUserFormSubmission(submissionId));
7727
+ const submission = state.formSubmissionReducer.formSubmissions[submissionId];
7728
+ const submissionAttachments = selectAttachmentsOfFormSubmission(submissionId)(state);
7729
+ store.dispatch(deleteFormSubmission(submissionId));
7137
7730
  store.dispatch(addActiveProjectFormSubmissionsCount(-1));
7731
+ store.dispatch(deleteFormSubmissionAttachments(submissionAttachments.map((x) => x.offline_id)));
7138
7732
  try {
7139
7733
  return await this.enqueueRequest({
7140
7734
  description: "Delete user form submissions",
@@ -7144,10 +7738,9 @@ var __publicField = (obj, key, value) => {
7144
7738
  blocks: []
7145
7739
  });
7146
7740
  } catch (e) {
7147
- if (submission) {
7148
- store.dispatch(addActiveProjectFormSubmissionsCount(1));
7149
- store.dispatch(updateOrCreateUserFormSubmission(submission));
7150
- }
7741
+ store.dispatch(addActiveProjectFormSubmissionsCount(1));
7742
+ store.dispatch(addFormSubmission(submission));
7743
+ store.dispatch(addFormSubmissionAttachments(submissionAttachments));
7151
7744
  throw e;
7152
7745
  }
7153
7746
  }
@@ -7161,7 +7754,7 @@ var __publicField = (obj, key, value) => {
7161
7754
  blockers: [],
7162
7755
  blocks: []
7163
7756
  });
7164
- store.dispatch(setUserFormSubmissions(submissions));
7757
+ store.dispatch(setFormSubmissions(submissions));
7165
7758
  const attachments = await this.enqueueRequest({
7166
7759
  description: "Fetch form attachments",
7167
7760
  method: HttpMethod.GET,
@@ -7169,7 +7762,7 @@ var __publicField = (obj, key, value) => {
7169
7762
  blockers: [],
7170
7763
  blocks: []
7171
7764
  });
7172
- store.dispatch(setUserFormSubmissionAttachments(attachments));
7765
+ store.dispatch(setFormSubmissionAttachments(attachments));
7173
7766
  }
7174
7767
  }
7175
7768
  class WorkspaceService extends BaseApiService {
@@ -7729,17 +8322,28 @@ var __publicField = (obj, key, value) => {
7729
8322
  }
7730
8323
  }
7731
8324
  class DocumentService extends BaseApiService {
8325
+ // TODO: Support adding for project or organization
7732
8326
  add(document2) {
7733
8327
  const { store } = this.client;
7734
8328
  const currentUserId = store.getState().userReducer.currentUser.id;
7735
8329
  const activeProjectId = store.getState().projectReducer.activeProjectId;
7736
- const offlineDocument = offline({ ...document2, created_by: currentUserId });
7737
- store.dispatch(addDocuments([offlineDocument]));
8330
+ if (!activeProjectId) {
8331
+ throw new Error("No active project ID while creating document.");
8332
+ }
8333
+ const offlineDocument = offline(document2);
8334
+ const submittedDocument = {
8335
+ ...offlineDocument,
8336
+ created_by: currentUserId,
8337
+ project: activeProjectId,
8338
+ organization: null,
8339
+ children_documents: []
8340
+ };
8341
+ store.dispatch(addDocuments([submittedDocument]));
7738
8342
  const promise = this.enqueueRequest({
7739
8343
  description: "Create Document",
7740
8344
  method: HttpMethod.POST,
7741
- url: `/projects/${activeProjectId}/create-document/`,
7742
- payload: { ...offlineDocument },
8345
+ url: `/projects/${activeProjectId}/documents/`,
8346
+ payload: offlineDocument,
7743
8347
  queryParams: {
7744
8348
  parent_document: offlineDocument.parent_document ?? void 0
7745
8349
  },
@@ -7750,7 +8354,7 @@ var __publicField = (obj, key, value) => {
7750
8354
  promise.catch(() => {
7751
8355
  store.dispatch(removeDocuments([offlineDocument.offline_id]));
7752
8356
  });
7753
- return [offlineDocument, promise];
8357
+ return [submittedDocument, promise];
7754
8358
  }
7755
8359
  update(document2) {
7756
8360
  const { store } = this.client;
@@ -7850,15 +8454,25 @@ var __publicField = (obj, key, value) => {
7850
8454
  }
7851
8455
  async refreshStore() {
7852
8456
  const { store } = this.client;
7853
- const activeProjectId = store.getState().projectReducer.activeProjectId;
7854
- const result = await this.enqueueRequest({
8457
+ const state = store.getState();
8458
+ const activeProjectId = state.projectReducer.activeProjectId;
8459
+ const projectDocumentsPromise = this.enqueueRequest({
7855
8460
  description: "Get project documents",
7856
8461
  method: HttpMethod.GET,
7857
- url: `/documents/projects/${activeProjectId}/`,
8462
+ url: `/projects/${activeProjectId}/documents/`,
8463
+ blockers: [],
8464
+ blocks: []
8465
+ });
8466
+ const activeOrganizationId = state.organizationReducer.activeOrganizationId;
8467
+ const organizationDocumentsPromise = this.enqueueRequest({
8468
+ description: "Get organization documents",
8469
+ method: HttpMethod.GET,
8470
+ url: `/organizations/${activeOrganizationId}/documents/`,
7858
8471
  blockers: [],
7859
8472
  blocks: []
7860
8473
  });
7861
- store.dispatch(setDocuments(result));
8474
+ store.dispatch(setDocuments(await projectDocumentsPromise));
8475
+ store.dispatch(addDocuments(await organizationDocumentsPromise));
7862
8476
  }
7863
8477
  }
7864
8478
  class AgentService extends BaseApiService {
@@ -7893,6 +8507,142 @@ var __publicField = (obj, key, value) => {
7893
8507
  });
7894
8508
  }
7895
8509
  }
8510
+ class TeamService extends BaseApiService {
8511
+ add(teamPayload) {
8512
+ const { store } = this.client;
8513
+ const state = store.getState();
8514
+ const activeOrganizationId = state.organizationReducer.activeOrganizationId;
8515
+ if (!activeOrganizationId) {
8516
+ throw new Error(`Expected active organization to be set, got ${activeOrganizationId}`);
8517
+ }
8518
+ const offlineTeam = offline({
8519
+ ...teamPayload,
8520
+ organization: activeOrganizationId,
8521
+ submitted_at: (/* @__PURE__ */ new Date()).toISOString()
8522
+ // TODO: uncomment once supported
8523
+ // created_by: state.userReducer.currentUser.id,
8524
+ });
8525
+ store.dispatch(addTeam(offlineTeam));
8526
+ const promise = this.enqueueRequest({
8527
+ description: "Create team",
8528
+ method: HttpMethod.POST,
8529
+ url: `/organizations/${activeOrganizationId}/teams/`,
8530
+ payload: offlineTeam,
8531
+ // No blocks since users and organizations are not offline
8532
+ blockers: [],
8533
+ blocks: [offlineTeam.offline_id]
8534
+ });
8535
+ promise.then((createdTeam) => {
8536
+ store.dispatch(setTeam(createdTeam));
8537
+ }).catch(() => {
8538
+ store.dispatch(deleteTeam(offlineTeam.offline_id));
8539
+ });
8540
+ return [offlineTeam, promise];
8541
+ }
8542
+ // TODO: @Audiopolis / Magnus - should we pass a offline_id as one arg and a UpdatedTeamProps as a second arg instead of this set up?
8543
+ update(team) {
8544
+ const { store } = this.client;
8545
+ const teamToBeUpdated = store.getState().teamReducer.teams[team.offline_id];
8546
+ const offlineUpdatedTeam = {
8547
+ ...teamToBeUpdated,
8548
+ ...team
8549
+ };
8550
+ store.dispatch(updateTeam(offlineUpdatedTeam));
8551
+ const promise = this.enqueueRequest({
8552
+ description: "Update team",
8553
+ method: HttpMethod.PATCH,
8554
+ url: `/organizations/teams/${team.offline_id}/`,
8555
+ payload: offlineUpdatedTeam,
8556
+ blockers: [team.offline_id],
8557
+ blocks: [team.offline_id]
8558
+ });
8559
+ promise.then((updatedTeam) => {
8560
+ store.dispatch(setTeam(updatedTeam));
8561
+ }).catch(() => {
8562
+ store.dispatch(setTeam(teamToBeUpdated));
8563
+ });
8564
+ return [offlineUpdatedTeam, promise];
8565
+ }
8566
+ async delete(teamId) {
8567
+ const { store } = this.client;
8568
+ const state = store.getState();
8569
+ const team = state.teamReducer.teams[teamId];
8570
+ if (!team) {
8571
+ throw new Error(`Expected team with id ${teamId} to exist`);
8572
+ }
8573
+ store.dispatch(deleteTeam(teamId));
8574
+ try {
8575
+ return await this.enqueueRequest({
8576
+ description: "Delete team",
8577
+ method: HttpMethod.DELETE,
8578
+ url: `/organizations/teams/${teamId}/`,
8579
+ blockers: [teamId],
8580
+ blocks: [teamId]
8581
+ });
8582
+ } catch (e) {
8583
+ store.dispatch(setTeam(team));
8584
+ throw e;
8585
+ }
8586
+ }
8587
+ async setMembers(teamId, members) {
8588
+ const { store } = this.client;
8589
+ const team = store.getState().teamReducer.teams[teamId];
8590
+ if (!team) {
8591
+ throw new Error(`Expected team with id ${teamId} to exist`);
8592
+ }
8593
+ if (members.length !== new Set(members).size) {
8594
+ throw new Error("Duplicate members found in the list");
8595
+ }
8596
+ store.dispatch(updateTeam({ ...team, members }));
8597
+ const promise = this.enqueueRequest({
8598
+ description: "Set team members",
8599
+ method: HttpMethod.PUT,
8600
+ url: `/organizations/teams/${teamId}/set-members/`,
8601
+ payload: {
8602
+ users: members
8603
+ },
8604
+ blockers: [teamId],
8605
+ blocks: [teamId]
8606
+ });
8607
+ promise.catch(() => {
8608
+ store.dispatch(setTeam(team));
8609
+ });
8610
+ return promise;
8611
+ }
8612
+ async addMembers(teamId, members) {
8613
+ const { store } = this.client;
8614
+ const team = store.getState().teamReducer.teams[teamId];
8615
+ if (!team) {
8616
+ throw new Error(`Expected team with id ${teamId} to exist`);
8617
+ }
8618
+ const newMembers = [...team.members, ...members];
8619
+ return this.setMembers(teamId, newMembers);
8620
+ }
8621
+ async removeMembers(teamId, members) {
8622
+ const { store } = this.client;
8623
+ const team = store.getState().teamReducer.teams[teamId];
8624
+ if (!team) {
8625
+ throw new Error(`Expected team with id ${teamId} to exist`);
8626
+ }
8627
+ const newMembers = team.members.filter((member) => !members.includes(member));
8628
+ return this.setMembers(teamId, newMembers);
8629
+ }
8630
+ async refreshStore() {
8631
+ const { store } = this.client;
8632
+ const activeOrganizationId = store.getState().organizationReducer.activeOrganizationId;
8633
+ if (!activeOrganizationId) {
8634
+ throw new Error(`Expected active organization to be set, got ${activeOrganizationId}`);
8635
+ }
8636
+ const result = await this.enqueueRequest({
8637
+ description: "Fetch teams",
8638
+ method: HttpMethod.GET,
8639
+ url: `/organizations/${activeOrganizationId}/teams/`,
8640
+ blockers: [],
8641
+ blocks: []
8642
+ });
8643
+ store.dispatch(setTeams(result));
8644
+ }
8645
+ }
7896
8646
  class OvermapSDK {
7897
8647
  constructor(apiUrl, store) {
7898
8648
  __publicField(this, "API_URL");
@@ -7906,6 +8656,7 @@ var __publicField = (obj, key, value) => {
7906
8656
  __publicField(this, "organizations", new OrganizationService(this));
7907
8657
  __publicField(this, "organizationAccess", new OrganizationAccessService(this));
7908
8658
  __publicField(this, "issues", new IssueService(this));
8659
+ __publicField(this, "issueTypes", new IssueTypeService(this));
7909
8660
  __publicField(this, "issueComments", new IssueCommentService(this));
7910
8661
  __publicField(this, "issueUpdates", new IssueUpdateService(this));
7911
8662
  __publicField(this, "workspaces", new WorkspaceService(this));
@@ -7922,6 +8673,7 @@ var __publicField = (obj, key, value) => {
7922
8673
  __publicField(this, "emailDomains", new EmailDomainsService(this));
7923
8674
  __publicField(this, "licenses", new LicenseService(this));
7924
8675
  __publicField(this, "documents", new DocumentService(this));
8676
+ __publicField(this, "teams", new TeamService(this));
7925
8677
  this.API_URL = apiUrl;
7926
8678
  this.store = store;
7927
8679
  }
@@ -7963,7 +8715,7 @@ var __publicField = (obj, key, value) => {
7963
8715
  const patchfieldBorder = "_patchfieldBorder_1w0fq_73";
7964
8716
  const title = "_title_1w0fq_73";
7965
8717
  const error = "_error_1w0fq_89";
7966
- const styles$c = {
8718
+ const styles$d = {
7967
8719
  description: description$2,
7968
8720
  floatingButtonContainer: floatingButtonContainer$2,
7969
8721
  FullScreenImageContainer: FullScreenImageContainer$2,
@@ -8084,7 +8836,7 @@ var __publicField = (obj, key, value) => {
8084
8836
  const longIconButton$1 = "_longIconButton_10o76_36";
8085
8837
  const previewImage$1 = "_previewImage_10o76_42";
8086
8838
  const FullScreenImage$1 = "_FullScreenImage_10o76_12";
8087
- const styles$b = {
8839
+ const styles$c = {
8088
8840
  description: description$1,
8089
8841
  floatingButtonContainer: floatingButtonContainer$1,
8090
8842
  FullScreenImageContainer: FullScreenImageContainer$1,
@@ -8108,7 +8860,7 @@ var __publicField = (obj, key, value) => {
8108
8860
  /* @__PURE__ */ jsxRuntime.jsx(
8109
8861
  "button",
8110
8862
  {
8111
- className: styles$b.FullScreenImageContainer,
8863
+ className: styles$c.FullScreenImageContainer,
8112
8864
  type: "button",
8113
8865
  onClick: () => {
8114
8866
  setShowPreview(false);
@@ -8116,7 +8868,7 @@ var __publicField = (obj, key, value) => {
8116
8868
  children: /* @__PURE__ */ jsxRuntime.jsx(
8117
8869
  "img",
8118
8870
  {
8119
- className: styles$b.FullScreenImage,
8871
+ className: styles$c.FullScreenImage,
8120
8872
  src: url,
8121
8873
  alt: name,
8122
8874
  onClick: (e) => {
@@ -8126,11 +8878,11 @@ var __publicField = (obj, key, value) => {
8126
8878
  )
8127
8879
  }
8128
8880
  ),
8129
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$b.TopBarContainer, align: "center", children: [
8881
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$c.TopBarContainer, align: "center", children: [
8130
8882
  /* @__PURE__ */ jsxRuntime.jsx(
8131
8883
  blocks.IconButton,
8132
8884
  {
8133
- className: styles$b.longIconButton,
8885
+ className: styles$c.longIconButton,
8134
8886
  variant: "soft",
8135
8887
  "aria-label": "Exit preview",
8136
8888
  onClick: () => {
@@ -8139,11 +8891,11 @@ var __publicField = (obj, key, value) => {
8139
8891
  children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiArrowLeftLine" })
8140
8892
  }
8141
8893
  ),
8142
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$b.fileName, children: name }),
8894
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$c.fileName, children: name }),
8143
8895
  /* @__PURE__ */ jsxRuntime.jsx(
8144
8896
  blocks.IconButton,
8145
8897
  {
8146
- className: styles$b.longIconButton,
8898
+ className: styles$c.longIconButton,
8147
8899
  variant: "soft",
8148
8900
  "aria-label": `Download ${name}`,
8149
8901
  onClick: handleDownload,
@@ -8171,7 +8923,7 @@ var __publicField = (obj, key, value) => {
8171
8923
  /* @__PURE__ */ jsxRuntime.jsx(
8172
8924
  "img",
8173
8925
  {
8174
- className: styles$b.previewImage,
8926
+ className: styles$c.previewImage,
8175
8927
  src: resolvedImageURL,
8176
8928
  alt: resolvedImage.name,
8177
8929
  onClick: () => {
@@ -8199,7 +8951,7 @@ var __publicField = (obj, key, value) => {
8199
8951
  const { helpText, children, severity } = props;
8200
8952
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "1", children: [
8201
8953
  children,
8202
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity, className: styles$b.description, children: helpText }) })
8954
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity, className: styles$c.description, children: helpText }) })
8203
8955
  ] });
8204
8956
  };
8205
8957
  const InputWithLabelAndHelpText = (props) => {
@@ -8433,6 +9185,9 @@ var __publicField = (obj, key, value) => {
8433
9185
  function RiCalendarLine(props) {
8434
9186
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M9 1V3H15V1H17V3H21C21.5523 3 22 3.44772 22 4V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V4C2 3.44772 2.44772 3 3 3H7V1H9ZM20 11H4V19H20V11ZM7 5H4V9H20V5H17V7H15V5H9V7H7V5Z" }, "child": [] }] })(props);
8435
9187
  }
9188
+ function RiQrCodeLine(props) {
9189
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M16 17V16H13V13H16V15H18V17H17V19H15V21H13V18H15V17H16ZM21 21H17V19H19V17H21V21ZM3 3H11V11H3V3ZM5 5V9H9V5H5ZM13 3H21V11H13V3ZM15 5V9H19V5H15ZM3 13H11V21H3V13ZM5 15V19H9V15H5ZM18 13H21V15H18V13ZM6 6H8V8H6V6ZM6 16H8V18H6V16ZM16 6H18V8H16V6Z" }, "child": [] }] })(props);
9190
+ }
8436
9191
  function RiFileCopyLine(props) {
8437
9192
  return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M6.9998 6V3C6.9998 2.44772 7.44752 2 7.9998 2H19.9998C20.5521 2 20.9998 2.44772 20.9998 3V17C20.9998 17.5523 20.5521 18 19.9998 18H16.9998V20.9991C16.9998 21.5519 16.5499 22 15.993 22H4.00666C3.45059 22 3 21.5554 3 20.9991L3.0026 7.00087C3.0027 6.44811 3.45264 6 4.00942 6H6.9998ZM5.00242 8L5.00019 20H14.9998V8H5.00242ZM8.9998 6H16.9998V16H18.9998V4H8.9998V6Z" }, "child": [] }] })(props);
8438
9193
  }
@@ -9336,9 +10091,9 @@ var __publicField = (obj, key, value) => {
9336
10091
  return React__namespace.createElement("div", { ...insetProps, ref: forwardedRef, className: classNames("rt-Inset", className, withBreakpoints(side, "rt-r-side"), withBreakpoints(clip, "rt-r-clip"), withBreakpoints(p, "rt-r-p"), withBreakpoints(px, "rt-r-px"), withBreakpoints(py, "rt-r-py"), withBreakpoints(pt, "rt-r-pt"), withBreakpoints(pr, "rt-r-pr"), withBreakpoints(pb, "rt-r-pb"), withBreakpoints(pl, "rt-r-pl"), withMarginProps(marginProps)) });
9337
10092
  });
9338
10093
  Inset.displayName = "Inset";
9339
- const sizes$7 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
10094
+ const sizes$8 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9340
10095
  const headingPropDefs = {
9341
- size: { type: "enum", values: sizes$7, default: "6", responsive: true },
10096
+ size: { type: "enum", values: sizes$8, default: "6", responsive: true },
9342
10097
  weight: { ...weightProp, default: "bold" },
9343
10098
  align: alignProp,
9344
10099
  trim: trimProp,
@@ -9351,9 +10106,9 @@ var __publicField = (obj, key, value) => {
9351
10106
  return React__namespace.createElement($5e63c961fc1ce211$export$8c6ed5c666ac1360, { "data-accent-color": color, ...headingProps, ref: forwardedRef, className: classNames("rt-Heading", className, withBreakpoints(size, "rt-r-size"), withBreakpoints(weight, "rt-r-weight"), withBreakpoints(align, "rt-r-ta"), withBreakpoints(trim, "rt-r-lt"), { "rt-high-contrast": highContrast }, withMarginProps(marginProps)) }, asChild ? children : React__namespace.createElement(Tag, null, children));
9352
10107
  });
9353
10108
  Heading.displayName = "Heading";
9354
- const sizes$6 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
10109
+ const sizes$7 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9355
10110
  const textPropDefs = {
9356
- size: { type: "enum", values: sizes$6, default: void 0, responsive: true },
10111
+ size: { type: "enum", values: sizes$7, default: void 0, responsive: true },
9357
10112
  weight: weightProp,
9358
10113
  align: alignProp,
9359
10114
  trim: trimProp,
@@ -9366,6 +10121,21 @@ var __publicField = (obj, key, value) => {
9366
10121
  return React__namespace.createElement($5e63c961fc1ce211$export$8c6ed5c666ac1360, { "data-accent-color": color, ...textProps, ref: forwardedRef, className: classNames("rt-Text", className, withBreakpoints(size, "rt-r-size"), withBreakpoints(weight, "rt-r-weight"), withBreakpoints(align, "rt-r-ta"), withBreakpoints(trim, "rt-r-lt"), { "rt-high-contrast": highContrast }, withMarginProps(marginProps)) }, asChild ? children : React__namespace.createElement(Tag, null, children));
9367
10122
  });
9368
10123
  Text.displayName = "Text";
10124
+ const sizes$6 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
10125
+ const variants$4 = ["solid", "soft", "outline", "ghost"];
10126
+ const codePropDefs = {
10127
+ size: { type: "enum", values: sizes$6, default: void 0, responsive: true },
10128
+ variant: { type: "enum", values: variants$4, default: "soft" },
10129
+ weight: weightProp,
10130
+ color: colorProp,
10131
+ highContrast: highContrastProp
10132
+ };
10133
+ const Code = React__namespace.forwardRef((props, forwardedRef) => {
10134
+ const { rest: marginRest, ...marginProps } = extractMarginProps(props);
10135
+ const { className, size = codePropDefs.size.default, variant = codePropDefs.variant.default, weight = codePropDefs.weight.default, color = codePropDefs.color.default, highContrast = codePropDefs.highContrast.default, ...codeProps } = marginRest;
10136
+ return React__namespace.createElement("code", { "data-accent-color": color, ...codeProps, ref: forwardedRef, className: classNames("rt-Code", className, withBreakpoints(size, "rt-r-size"), `rt-variant-${variant}`, withBreakpoints(weight, "rt-r-weight"), { "rt-high-contrast": highContrast }, withMarginProps(marginProps)) });
10137
+ });
10138
+ Code.displayName = "Code";
9369
10139
  const Em = React__namespace.forwardRef((props, forwardedRef) => React__namespace.createElement("em", { ...props, ref: forwardedRef, className: classNames("rt-Em", props.className) }));
9370
10140
  Em.displayName = "Em";
9371
10141
  const Strong = React__namespace.forwardRef((props, forwardedRef) => React__namespace.createElement("strong", { ...props, ref: forwardedRef, className: classNames("rt-Strong", props.className) }));
@@ -11756,7 +12526,7 @@ var __publicField = (obj, key, value) => {
11756
12526
  });
11757
12527
  const clickableLinkContainer = "_clickableLinkContainer_1ace7_1";
11758
12528
  const TextFieldInputCopy = "_TextFieldInputCopy_1ace7_5";
11759
- const styles$a = {
12529
+ const styles$b = {
11760
12530
  clickableLinkContainer,
11761
12531
  TextFieldInputCopy
11762
12532
  };
@@ -11785,13 +12555,13 @@ var __publicField = (obj, key, value) => {
11785
12555
  placeholder: field.placeholder,
11786
12556
  color
11787
12557
  }
11788
- ) : /* @__PURE__ */ jsxRuntime.jsxs(TextField$1.Root, { className: styles$a.clickableLinkContainer, children: [
12558
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(TextField$1.Root, { className: styles$b.clickableLinkContainer, children: [
11789
12559
  /* @__PURE__ */ jsxRuntime.jsx(
11790
12560
  "div",
11791
12561
  {
11792
12562
  className: classNames$1(
11793
12563
  "rt-TextFieldInput rt-r-size-2 rt-variant-surface",
11794
- styles$a.TextFieldInputCopy
12564
+ styles$b.TextFieldInputCopy
11795
12565
  ),
11796
12566
  children: /* @__PURE__ */ jsxRuntime.jsx(
11797
12567
  Linkify,
@@ -12363,8 +13133,7 @@ var __publicField = (obj, key, value) => {
12363
13133
  description: "List possible options for the user to select from.",
12364
13134
  required: true,
12365
13135
  identifier: `${path}options`,
12366
- minimum_length: 2,
12367
- maximum_length: 20
13136
+ minimum_length: 2
12368
13137
  }),
12369
13138
  showDirectly: true
12370
13139
  }
@@ -12483,6 +13252,158 @@ var __publicField = (obj, key, value) => {
12483
13252
  __publicField(_MultiSelectField, "fieldTypeDescription", "Allows the user to select a multiple options from a list of options.");
12484
13253
  __publicField(_MultiSelectField, "Icon", RiCheckboxLine);
12485
13254
  let MultiSelectField = _MultiSelectField;
13255
+ const QrScannerWrapper = "_QrScannerWrapper_1puz3_1";
13256
+ const styles$a = {
13257
+ QrScannerWrapper
13258
+ };
13259
+ const QrInput = React.memo((props) => {
13260
+ const [{ inputId, labelId, label, helpText, size, severity, showInputOnly, field, fieldProps }, rest] = useFormikInput(props);
13261
+ const [showQrScanner, setShowQrScanner] = React.useState(false);
13262
+ const value = fieldProps.value;
13263
+ const handleQrScan = React.useCallback(
13264
+ (data) => {
13265
+ fieldProps.onChange({ target: { value: data } });
13266
+ setShowQrScanner(false);
13267
+ },
13268
+ [fieldProps]
13269
+ );
13270
+ const handleClearScanResult = React.useCallback(() => {
13271
+ fieldProps.onChange({ target: { value: "" } });
13272
+ }, [fieldProps]);
13273
+ const handleScanButtonClicked = React.useCallback(() => {
13274
+ setShowQrScanner(true);
13275
+ }, []);
13276
+ const handleQrScannerClose = React.useCallback(() => {
13277
+ setShowQrScanner(false);
13278
+ }, []);
13279
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsxs(
13280
+ InputWithLabel,
13281
+ {
13282
+ size,
13283
+ severity,
13284
+ inputId,
13285
+ labelId,
13286
+ label: showInputOnly ? label : "",
13287
+ image: showInputOnly ? void 0 : field.image,
13288
+ flexProps: { direction: "column", justify: "start", align: "start", gap: "1" },
13289
+ children: [
13290
+ /* @__PURE__ */ jsxRuntime.jsx(
13291
+ blocks.Overlay,
13292
+ {
13293
+ open: showQrScanner,
13294
+ content: () => /* @__PURE__ */ jsxRuntime.jsx(QrScanner, { onQrScan: handleQrScan, onClose: handleQrScannerClose }),
13295
+ onOpenChange: setShowQrScanner
13296
+ }
13297
+ ),
13298
+ /* @__PURE__ */ jsxRuntime.jsxs(Flex, { width: "max-content", gap: "1", align: "center", children: [
13299
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Button, { ...rest, variant: "soft", onClick: handleScanButtonClicked, children: [
13300
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiQrCodeLine" }),
13301
+ "Scan"
13302
+ ] }),
13303
+ value && /* @__PURE__ */ jsxRuntime.jsx(Text, { color: "jade", size: "1", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiCheckLine", style: { verticalAlign: "bottom" } }) })
13304
+ ] }),
13305
+ value && /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { width: "max-content", gap: "2", align: "center", children: [
13306
+ /* @__PURE__ */ jsxRuntime.jsx(Code, { color: "gray", highContrast: true, children: value }),
13307
+ /* @__PURE__ */ jsxRuntime.jsx(
13308
+ blocks.IconButton,
13309
+ {
13310
+ severity: "info",
13311
+ variant: "ghost",
13312
+ "aria-label": "delete",
13313
+ size: "small",
13314
+ onClick: handleClearScanResult,
13315
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiCloseLine" })
13316
+ }
13317
+ )
13318
+ ] }) })
13319
+ ]
13320
+ }
13321
+ ) });
13322
+ });
13323
+ QrInput.displayName = "QrInput";
13324
+ const QrScanner = React.memo((props) => {
13325
+ const { onQrScan, onClose } = props;
13326
+ const videoRef = React.useRef(null);
13327
+ const [isScannerLoading, setIsScannerLoading] = React.useState(false);
13328
+ React.useEffect(() => {
13329
+ if (!videoRef.current)
13330
+ return;
13331
+ const qrScanner = new QrScannerAPI(
13332
+ videoRef.current,
13333
+ (result) => {
13334
+ const data = result.data;
13335
+ onQrScan(data);
13336
+ qrScanner.destroy();
13337
+ },
13338
+ {
13339
+ highlightCodeOutline: true,
13340
+ highlightScanRegion: true,
13341
+ maxScansPerSecond: 1
13342
+ }
13343
+ );
13344
+ setIsScannerLoading(true);
13345
+ qrScanner.start().then(() => {
13346
+ setIsScannerLoading(false);
13347
+ }).catch(() => {
13348
+ setIsScannerLoading(false);
13349
+ });
13350
+ }, [onQrScan]);
13351
+ return /* @__PURE__ */ jsxRuntime.jsxs(
13352
+ Flex,
13353
+ {
13354
+ className: styles$a.QrScannerWrapper,
13355
+ width: "100%",
13356
+ height: "100%",
13357
+ direction: "column",
13358
+ gap: "2",
13359
+ justify: "center",
13360
+ position: "relative",
13361
+ children: [
13362
+ /* @__PURE__ */ jsxRuntime.jsx(Flex, { width: "100%", position: "absolute", top: "0", p: "2", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.IconButton, { "aria-label": "close", variant: "soft", severity: "info", highContrast: true, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiCloseLine" }) }) }),
13363
+ /* @__PURE__ */ jsxRuntime.jsxs(Box, { style: { maxWidth: "100%", maxHeight: "100%" }, position: "relative", children: [
13364
+ /* @__PURE__ */ jsxRuntime.jsx("video", { ref: videoRef, style: { width: "100%", height: "100%" } }),
13365
+ isScannerLoading && /* @__PURE__ */ jsxRuntime.jsx(
13366
+ Flex,
13367
+ {
13368
+ position: "absolute",
13369
+ inset: "0",
13370
+ style: { background: "var(--color-background)" },
13371
+ justify: "center",
13372
+ align: "center",
13373
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Spinner, {})
13374
+ }
13375
+ )
13376
+ ] })
13377
+ ]
13378
+ }
13379
+ );
13380
+ });
13381
+ QrScanner.displayName = "QrScanner";
13382
+ const emptyQrField = {
13383
+ ...emptyBaseField,
13384
+ type: "qr"
13385
+ };
13386
+ const _QrField = class _QrField extends BaseField {
13387
+ constructor(options) {
13388
+ super({ ...options, type: "qr" });
13389
+ __publicField(this, "onlyValidateAfterTouched", false);
13390
+ }
13391
+ serialize() {
13392
+ return super._serialize();
13393
+ }
13394
+ static deserialize(data) {
13395
+ if (data.type !== "qr")
13396
+ throw new Error("Type mismatch.");
13397
+ return new _QrField(data);
13398
+ }
13399
+ getInput(props) {
13400
+ return /* @__PURE__ */ jsxRuntime.jsx(QrInput, { ...props, field: this });
13401
+ }
13402
+ };
13403
+ __publicField(_QrField, "fieldTypeName", "QR");
13404
+ __publicField(_QrField, "fieldTypeDescription", "Used for scanning/reading QR codes.");
13405
+ __publicField(_QrField, "Icon", RiQrCodeLine);
13406
+ let QrField = _QrField;
12486
13407
  const FieldInputCloner = React.memo((props) => {
12487
13408
  const { field, ...rest } = props;
12488
13409
  const [{ value: identifier }] = formik.useField(field.options.clonedFieldIdentifier);
@@ -13740,6 +14661,7 @@ var __publicField = (obj, key, value) => {
13740
14661
  text: TextField,
13741
14662
  custom: CustomField,
13742
14663
  upload: UploadField,
14664
+ qr: QrField,
13743
14665
  // TODO: Underscore
13744
14666
  "multi-string": MultiStringField,
13745
14667
  "multi-select": MultiSelectField
@@ -13753,6 +14675,7 @@ var __publicField = (obj, key, value) => {
13753
14675
  text: emptyTextField,
13754
14676
  custom: emptyCustomField,
13755
14677
  upload: emptyUploadField,
14678
+ qr: emptyQrField,
13756
14679
  // TODO: Underscore
13757
14680
  "multi-string": emptyMultiStringField,
13758
14681
  "multi-select": emptyMultiSelectField
@@ -13840,7 +14763,7 @@ var __publicField = (obj, key, value) => {
13840
14763
  return /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "3", children: [
13841
14764
  /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", children: [
13842
14765
  /* @__PURE__ */ jsxRuntime.jsx(Heading, { as: "h3", size: "3", children: label }),
13843
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$b.description, children: description2 })
14766
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$c.description, children: description2 })
13844
14767
  ] }),
13845
14768
  inputs
13846
14769
  ] }) });
@@ -14027,7 +14950,7 @@ var __publicField = (obj, key, value) => {
14027
14950
  };
14028
14951
  const useAttachImagesToFormRevisionFields = (revision) => {
14029
14952
  const { sdk } = useSDK();
14030
- const attachments = useAppSelector(selectRevisionAttachments((revision == null ? void 0 : revision.offline_id) ?? ""));
14953
+ const attachments = useAppSelector(selectAttachmentsOfFormRevision((revision == null ? void 0 : revision.offline_id) ?? ""));
14031
14954
  return React.useMemo(() => {
14032
14955
  if (!revision || !attachments)
14033
14956
  return revision;
@@ -14083,7 +15006,7 @@ var __publicField = (obj, key, value) => {
14083
15006
  [schema.title]
14084
15007
  );
14085
15008
  const Description = React.useMemo(
14086
- () => typeof schema.description === "string" ? /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$b.description, children: schema.description }) : schema.description,
15009
+ () => typeof schema.description === "string" ? /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$c.description, children: schema.description }) : schema.description,
14087
15010
  [schema.description]
14088
15011
  );
14089
15012
  const inputs = useFieldInputs(schema.fields, { formId: formId2, disabled: readonly });
@@ -14099,7 +15022,7 @@ var __publicField = (obj, key, value) => {
14099
15022
  !hideDescription && Description
14100
15023
  ] }) }),
14101
15024
  inputs,
14102
- !readonly && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$b.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
15025
+ !readonly && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$c.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
14103
15026
  cancelText && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { severity: "info", ...buttonProps, type: "button", onClick: onCancel, children: cancelText }),
14104
15027
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { ...buttonProps, type: "submit", disabled: !formik$1.isValid, children: submitText })
14105
15028
  ] })
@@ -14124,7 +15047,7 @@ var __publicField = (obj, key, value) => {
14124
15047
  return formRevisionToSchema(revisionWithImages, { readonly: true });
14125
15048
  }, [revisionWithImages]);
14126
15049
  const submissionValuesWithAttachments = React.useMemo(() => {
14127
- const attachments = selectSubmissionAttachments(submission.offline_id)(sdk.store.getState()) ?? [];
15050
+ const attachments = selectAttachmentsOfFormSubmission(submission.offline_id)(sdk.store.getState()) ?? [];
14128
15051
  const downloadedAttachments = {};
14129
15052
  for (const attachment of attachments) {
14130
15053
  const promise = sdk.files.fetchFileFromUrl(attachment.file, attachment.file_sha1, attachment.file_name);
@@ -14174,9 +15097,9 @@ var __publicField = (obj, key, value) => {
14174
15097
  }
14175
15098
  return ret;
14176
15099
  }, [filter, maxResults, ownerFilter]);
14177
- const userForms = useAppSelector(selectFilteredUserForms(ownerFilterOptions)) ?? [];
14178
- const userFormMapping = useAppSelector(selectUserFormMapping);
14179
- const attachableUserForms = userForms.filter((form) => !form.component_type);
15100
+ const userForms = useAppSelector(selectFilteredForms(ownerFilterOptions)) ?? [];
15101
+ const userFormMapping = useAppSelector(selectFormMapping);
15102
+ const attachableUserForms = userForms.filter((form) => !form.component_type && !form.issue_type);
14180
15103
  const attachableUserFormMapping = Object.values(userFormMapping).filter(
14181
15104
  (form) => !form.component_type
14182
15105
  );
@@ -14208,7 +15131,7 @@ var __publicField = (obj, key, value) => {
14208
15131
  const handleChange = React.useCallback((e) => {
14209
15132
  setFilter(e.currentTarget.value);
14210
15133
  }, []);
14211
- const numberOfForms = useAppSelector(selectNumberOfGeneralUserForms) || 0;
15134
+ const numberOfForms = useAppSelector(selectGeneralFormCount) || 0;
14212
15135
  const numberOfHiddenForms = numberOfForms - attachableUserForms.length;
14213
15136
  const overflowMessage = attachableUserForms.length == maxResults && numberOfHiddenForms > 0 ? `Only the first ${maxResults} results are shown (${numberOfHiddenForms} hidden)` : numberOfHiddenForms > 0 && `${numberOfHiddenForms} hidden forms`;
14214
15137
  return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { ref, direction: "column", gap: "2", children: [
@@ -14302,16 +15225,13 @@ var __publicField = (obj, key, value) => {
14302
15225
  const { submission, onSubmissionClick, compact, labelType, rowDecorator } = props;
14303
15226
  const currentUser = useAppSelector(selectCurrentUser);
14304
15227
  const createdBy = useAppSelector(selectUser("created_by" in submission ? submission.created_by : currentUser.id));
14305
- const dateToUse = getCreatedAtOrSubmittedAtDate(submission);
14306
- const formattedDateTime = isToday(dateToUse) ? dateToUse.toLocaleTimeString([], {
14307
- hour: "2-digit",
14308
- minute: "2-digit"
14309
- }) : getLocalDateString(dateToUse);
15228
+ const dateToUse = submission.submitted_at;
15229
+ const formattedDateTime = getLocalDateString(dateToUse);
14310
15230
  const revision = useAppSelector(selectFormRevision(submission.form_revision));
14311
15231
  if (!revision) {
14312
15232
  throw new Error(`Could not find revision ${submission.form_revision} for submission ${submission.offline_id}.`);
14313
15233
  }
14314
- const latestRevisionNumber = (_a2 = useAppSelector(selectLatestFormRevision(revision.form))) == null ? void 0 : _a2.revision;
15234
+ const latestRevisionNumber = (_a2 = useAppSelector(selectLatestFormRevisionOfForm(revision.form))) == null ? void 0 : _a2.revision;
14315
15235
  const creatorProfileSrc = useFileSrc({
14316
15236
  file: (createdBy == null ? void 0 : createdBy.profile.file) ?? null,
14317
15237
  fileSha1: (createdBy == null ? void 0 : createdBy.profile.file_sha1) ?? null
@@ -14342,10 +15262,6 @@ var __publicField = (obj, key, value) => {
14342
15262
  return row;
14343
15263
  });
14344
15264
  FormSubmissionBrowserEntry.displayName = "FormSubmissionBrowserEntry";
14345
- const getCreatedAtOrSubmittedAtDate = (submission) => {
14346
- const date = "created_at" in submission ? submission.created_at : submission.submitted_at;
14347
- return new Date(date);
14348
- };
14349
15265
  const FormSubmissionBrowser = React.memo((props) => {
14350
15266
  const {
14351
15267
  formId: formId2,
@@ -14359,10 +15275,10 @@ var __publicField = (obj, key, value) => {
14359
15275
  if (!!formId2 === !!propSubmissions) {
14360
15276
  throw new Error("Either formId or submissions must be provided, but not both.");
14361
15277
  }
14362
- const submissions = useAppSelector(propSubmissions ? () => propSubmissions : selectSubmissionsForForm(formId2));
15278
+ const submissions = useAppSelector(propSubmissions ? () => propSubmissions : selectFormSubmissionsOfForm(formId2));
14363
15279
  const sortedSubmissions = React.useMemo(
14364
15280
  () => submissions == null ? void 0 : submissions.sort((a, b) => {
14365
- return getCreatedAtOrSubmittedAtDate(b).getTime() - getCreatedAtOrSubmittedAtDate(a).getTime();
15281
+ return a.submitted_at.localeCompare(b.submitted_at);
14366
15282
  }),
14367
15283
  [submissions]
14368
15284
  );
@@ -15454,12 +16370,12 @@ var __publicField = (obj, key, value) => {
15454
16370
  });
15455
16371
  const previewSchema = React.useMemo(() => formRevisionToSchema(formik$1.values), [formik$1.values]);
15456
16372
  return /* @__PURE__ */ jsxRuntime.jsx(Tabs.Root, { ref, defaultValue: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
15457
- showTabs && /* @__PURE__ */ jsxRuntime.jsxs(Tabs.List, { className: classNames$1(styles$c.tabsList, tabsListClassName), children: [
15458
- /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { className: styles$c.tabTrigger, value: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
16373
+ showTabs && /* @__PURE__ */ jsxRuntime.jsxs(Tabs.List, { className: classNames$1(styles$d.tabsList, tabsListClassName), children: [
16374
+ /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { className: styles$d.tabTrigger, value: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
15459
16375
  /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiPencilLine" }),
15460
16376
  "Edit"
15461
16377
  ] }) }),
15462
- /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { className: styles$c.tabTrigger, value: "preview", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
16378
+ /* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { className: styles$d.tabTrigger, value: "preview", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
15463
16379
  /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiEyeLine" }),
15464
16380
  "Preview"
15465
16381
  ] }) })
@@ -15483,8 +16399,8 @@ var __publicField = (obj, key, value) => {
15483
16399
  render: ({ setValue, value, meta }) => /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { severity: "danger", helpText: meta.error ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(
15484
16400
  blocks.Input,
15485
16401
  {
15486
- className: classNames$1(styles$c.title, {
15487
- [styles$c.error]: meta.error
16402
+ className: classNames$1(styles$d.title, {
16403
+ [styles$d.error]: meta.error
15488
16404
  }),
15489
16405
  placeholder: "Form title",
15490
16406
  value,
@@ -15506,7 +16422,7 @@ var __publicField = (obj, key, value) => {
15506
16422
  render: ({ setValue, value }) => /* @__PURE__ */ jsxRuntime.jsx(
15507
16423
  blocks.TextArea,
15508
16424
  {
15509
- className: styles$c.description,
16425
+ className: styles$d.description,
15510
16426
  placeholder: "Explain the purpose of this form",
15511
16427
  value,
15512
16428
  onChange: (event) => {
@@ -15524,7 +16440,7 @@ var __publicField = (obj, key, value) => {
15524
16440
  /* @__PURE__ */ jsxRuntime.jsx(FieldsEditor, { fieldsOnly }),
15525
16441
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { severity: "danger", size: "1", children: typeof formik$1.errors.fields === "string" && formik$1.errors.fields })
15526
16442
  ] }),
15527
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$c.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
16443
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$d.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
15528
16444
  onCancel && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "solid", severity: "info", onClick: onCancel, children: "Cancel" }),
15529
16445
  /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "submit", children: "Save form" })
15530
16446
  ] })
@@ -15559,6 +16475,9 @@ var __publicField = (obj, key, value) => {
15559
16475
  NumberInput,
15560
16476
  PatchField,
15561
16477
  PatchFormProvider,
16478
+ QrField,
16479
+ QrInput,
16480
+ QrScanner,
15562
16481
  SelectField,
15563
16482
  SelectInput,
15564
16483
  StringField,
@@ -15573,6 +16492,7 @@ var __publicField = (obj, key, value) => {
15573
16492
  emptyMultiSelectField,
15574
16493
  emptyMultiStringField,
15575
16494
  emptyNumberField,
16495
+ emptyQrField,
15576
16496
  emptySelectField,
15577
16497
  emptyStringField,
15578
16498
  emptyTextField,
@@ -15632,6 +16552,7 @@ var __publicField = (obj, key, value) => {
15632
16552
  exports2.IssuePriority = IssuePriority;
15633
16553
  exports2.IssueService = IssueService;
15634
16554
  exports2.IssueStatus = IssueStatus;
16555
+ exports2.IssueTypeService = IssueTypeService;
15635
16556
  exports2.IssueUpdateChange = IssueUpdateChange;
15636
16557
  exports2.IssueUpdateService = IssueUpdateService;
15637
16558
  exports2.LicenseLevel = LicenseLevel;
@@ -15662,6 +16583,9 @@ var __publicField = (obj, key, value) => {
15662
16583
  exports2.ProjectFileService = ProjectFileService;
15663
16584
  exports2.ProjectService = ProjectService;
15664
16585
  exports2.ProjectType = ProjectType;
16586
+ exports2.QrField = QrField;
16587
+ exports2.QrInput = QrInput;
16588
+ exports2.QrScanner = QrScanner;
15665
16589
  exports2.SDKContext = SDKContext;
15666
16590
  exports2.SDKProvider = SDKProvider;
15667
16591
  exports2.SUPPORTED_IMAGE_FILE_TYPES = SUPPORTED_IMAGE_FILE_TYPES;
@@ -15672,6 +16596,7 @@ var __publicField = (obj, key, value) => {
15672
16596
  exports2.SpreadsheetViewer = SpreadsheetViewer;
15673
16597
  exports2.StringField = StringField;
15674
16598
  exports2.StringInput = StringInput;
16599
+ exports2.TeamService = TeamService;
15675
16600
  exports2.TextField = TextField;
15676
16601
  exports2.TextInput = TextInput;
15677
16602
  exports2.UserFormService = UserFormService;
@@ -15679,6 +16604,7 @@ var __publicField = (obj, key, value) => {
15679
16604
  exports2.VerificationCodeType = VerificationCodeType;
15680
16605
  exports2.WorkspaceService = WorkspaceService;
15681
16606
  exports2.YELLOW = YELLOW;
16607
+ exports2._selectLatestFormRevision = _selectLatestFormRevision;
15682
16608
  exports2._setLatestRetryTime = _setLatestRetryTime;
15683
16609
  exports2.acceptProjectInvite = acceptProjectInvite;
15684
16610
  exports2.addActiveProjectFormSubmissionsCount = addActiveProjectFormSubmissionsCount;
@@ -15696,13 +16622,25 @@ var __publicField = (obj, key, value) => {
15696
16622
  exports2.addDocuments = addDocuments;
15697
16623
  exports2.addEmailDomain = addEmailDomain;
15698
16624
  exports2.addFavouriteProjectId = addFavouriteProjectId;
16625
+ exports2.addForm = addForm;
16626
+ exports2.addFormRevision = addFormRevision;
16627
+ exports2.addFormRevisionAttachment = addFormRevisionAttachment;
16628
+ exports2.addFormRevisionAttachments = addFormRevisionAttachments;
16629
+ exports2.addFormRevisions = addFormRevisions;
16630
+ exports2.addFormSubmission = addFormSubmission;
16631
+ exports2.addFormSubmissionAttachment = addFormSubmissionAttachment;
16632
+ exports2.addFormSubmissionAttachments = addFormSubmissionAttachments;
16633
+ exports2.addFormSubmissions = addFormSubmissions;
16634
+ exports2.addForms = addForms;
15699
16635
  exports2.addIssue = addIssue;
15700
16636
  exports2.addIssueAttachment = addIssueAttachment;
15701
16637
  exports2.addIssueAttachments = addIssueAttachments;
15702
16638
  exports2.addIssueComment = addIssueComment;
15703
16639
  exports2.addIssueComments = addIssueComments;
16640
+ exports2.addIssueType = addIssueType;
15704
16641
  exports2.addIssueUpdate = addIssueUpdate;
15705
16642
  exports2.addIssueUpdates = addIssueUpdates;
16643
+ exports2.addIssues = addIssues;
15706
16644
  exports2.addLicenses = addLicenses;
15707
16645
  exports2.addOrReplaceCategories = addOrReplaceCategories;
15708
16646
  exports2.addOrReplaceIssueComment = addOrReplaceIssueComment;
@@ -15715,16 +16653,12 @@ var __publicField = (obj, key, value) => {
15715
16653
  exports2.addStageCompletion = addStageCompletion;
15716
16654
  exports2.addStageCompletions = addStageCompletions;
15717
16655
  exports2.addStages = addStages;
16656
+ exports2.addTeam = addTeam;
15718
16657
  exports2.addToRecentIssues = addToRecentIssues;
15719
- exports2.addUserForm = addUserForm;
15720
- exports2.addUserFormRevision = addUserFormRevision;
15721
- exports2.addUserFormRevisionAttachment = addUserFormRevisionAttachment;
15722
- exports2.addUserFormRevisions = addUserFormRevisions;
15723
- exports2.addUserFormSubmissionAttachment = addUserFormSubmissionAttachment;
15724
- exports2.addUserFormSubmissions = addUserFormSubmissions;
15725
- exports2.addUserForms = addUserForms;
15726
16658
  exports2.addUsers = addUsers;
15727
16659
  exports2.addWorkspace = addWorkspace;
16660
+ exports2.agentReducer = agentReducer;
16661
+ exports2.agentSlice = agentSlice;
15728
16662
  exports2.areArraysEqual = areArraysEqual;
15729
16663
  exports2.authReducer = authReducer;
15730
16664
  exports2.authSlice = authSlice;
@@ -15743,6 +16677,7 @@ var __publicField = (obj, key, value) => {
15743
16677
  exports2.componentStageSlice = componentStageSlice;
15744
16678
  exports2.componentTypeReducer = componentTypeReducer;
15745
16679
  exports2.componentTypeSlice = componentTypeSlice;
16680
+ exports2.constructUploadedFilePayloads = constructUploadedFilePayloads;
15746
16681
  exports2.coordinatesAreEqual = coordinatesAreEqual;
15747
16682
  exports2.coordinatesToLiteral = coordinatesToLiteral;
15748
16683
  exports2.coordinatesToPointGeometry = coordinatesToPointGeometry;
@@ -15753,12 +16688,17 @@ var __publicField = (obj, key, value) => {
15753
16688
  exports2.defaultBadgeColor = defaultBadgeColor;
15754
16689
  exports2.defaultStore = defaultStore;
15755
16690
  exports2.deleteComponentType = deleteComponentType;
16691
+ exports2.deleteForm = deleteForm;
16692
+ exports2.deleteFormRevision = deleteFormRevision;
16693
+ exports2.deleteFormRevisionAttachment = deleteFormRevisionAttachment;
16694
+ exports2.deleteFormRevisionAttachments = deleteFormRevisionAttachments;
16695
+ exports2.deleteFormRevisions = deleteFormRevisions;
16696
+ exports2.deleteFormSubmission = deleteFormSubmission;
16697
+ exports2.deleteFormSubmissionAttachment = deleteFormSubmissionAttachment;
16698
+ exports2.deleteFormSubmissionAttachments = deleteFormSubmissionAttachments;
16699
+ exports2.deleteFormSubmissions = deleteFormSubmissions;
15756
16700
  exports2.deleteProject = deleteProject;
15757
- exports2.deleteUserForm = deleteUserForm;
15758
- exports2.deleteUserFormRevision = deleteUserFormRevision;
15759
- exports2.deleteUserFormRevisions = deleteUserFormRevisions;
15760
- exports2.deleteUserFormSubmission = deleteUserFormSubmission;
15761
- exports2.deleteUserFormSubmissions = deleteUserFormSubmissions;
16701
+ exports2.deleteTeam = deleteTeam;
15762
16702
  exports2.dequeue = dequeue;
15763
16703
  exports2.deserialize = deserialize;
15764
16704
  exports2.deserializeField = deserializeField;
@@ -15776,6 +16716,7 @@ var __publicField = (obj, key, value) => {
15776
16716
  exports2.emptyMultiSelectField = emptyMultiSelectField;
15777
16717
  exports2.emptyMultiStringField = emptyMultiStringField;
15778
16718
  exports2.emptyNumberField = emptyNumberField;
16719
+ exports2.emptyQrField = emptyQrField;
15779
16720
  exports2.emptySelectField = emptySelectField;
15780
16721
  exports2.emptyStringField = emptyStringField;
15781
16722
  exports2.emptyTextField = emptyTextField;
@@ -15787,7 +16728,13 @@ var __publicField = (obj, key, value) => {
15787
16728
  exports2.fileSlice = fileSlice;
15788
16729
  exports2.fileToBlob = fileToBlob;
15789
16730
  exports2.flipCoordinates = flipCoordinates;
16731
+ exports2.formReducer = formReducer;
16732
+ exports2.formRevisionReducer = formRevisionReducer;
15790
16733
  exports2.formRevisionToSchema = formRevisionToSchema;
16734
+ exports2.formRevisionsSlice = formRevisionsSlice;
16735
+ exports2.formSlice = formSlice;
16736
+ exports2.formSubmissionReducer = formSubmissionReducer;
16737
+ exports2.formSubmissionSlice = formSubmissionSlice;
15791
16738
  exports2.forms = index;
15792
16739
  exports2.fullComponentMarkerSize = fullComponentMarkerSize;
15793
16740
  exports2.generateBadgeColors = generateBadgeColors;
@@ -15807,6 +16754,8 @@ var __publicField = (obj, key, value) => {
15807
16754
  exports2.issueReducer = issueReducer;
15808
16755
  exports2.issueSlice = issueSlice;
15809
16756
  exports2.issueToSearchResult = issueToSearchResult;
16757
+ exports2.issueTypeReducer = issueTypeReducer;
16758
+ exports2.issueTypeSlice = issueTypeSlice;
15810
16759
  exports2.licenseReducer = licenseReducer;
15811
16760
  exports2.licenseSlice = licenseSlice;
15812
16761
  exports2.linkStageToForm = linkStageToForm;
@@ -15865,8 +16814,10 @@ var __publicField = (obj, key, value) => {
15865
16814
  exports2.removeIssueAttachment = removeIssueAttachment;
15866
16815
  exports2.removeIssueComment = removeIssueComment;
15867
16816
  exports2.removeIssueComments = removeIssueComments;
16817
+ exports2.removeIssueType = removeIssueType;
15868
16818
  exports2.removeIssueUpdate = removeIssueUpdate;
15869
16819
  exports2.removeIssueUpdates = removeIssueUpdates;
16820
+ exports2.removeIssues = removeIssues;
15870
16821
  exports2.removeOrganizationAccess = removeOrganizationAccess;
15871
16822
  exports2.removeProjectAccess = removeProjectAccess;
15872
16823
  exports2.removeProjectAccessesOfProject = removeProjectAccessesOfProject;
@@ -15915,6 +16866,8 @@ var __publicField = (obj, key, value) => {
15915
16866
  exports2.selectAttachmentsOfComponentTypeByType = selectAttachmentsOfComponentTypeByType;
15916
16867
  exports2.selectAttachmentsOfDocument = selectAttachmentsOfDocument;
15917
16868
  exports2.selectAttachmentsOfDocumentByType = selectAttachmentsOfDocumentByType;
16869
+ exports2.selectAttachmentsOfFormRevision = selectAttachmentsOfFormRevision;
16870
+ exports2.selectAttachmentsOfFormSubmission = selectAttachmentsOfFormSubmission;
15918
16871
  exports2.selectAttachmentsOfIssue = selectAttachmentsOfIssue;
15919
16872
  exports2.selectAttachmentsOfIssueByType = selectAttachmentsOfIssueByType;
15920
16873
  exports2.selectAttachmentsOfProject = selectAttachmentsOfProject;
@@ -15932,11 +16885,9 @@ var __publicField = (obj, key, value) => {
15932
16885
  exports2.selectComponent = selectComponent;
15933
16886
  exports2.selectComponentAttachment = selectComponentAttachment;
15934
16887
  exports2.selectComponentAttachmentMapping = selectComponentAttachmentMapping;
15935
- exports2.selectComponentSubmissionMapping = selectComponentSubmissionMapping;
15936
16888
  exports2.selectComponentType = selectComponentType;
15937
16889
  exports2.selectComponentTypeAttachment = selectComponentTypeAttachment;
15938
16890
  exports2.selectComponentTypeAttachmentMapping = selectComponentTypeAttachmentMapping;
15939
- exports2.selectComponentTypeForm = selectComponentTypeForm;
15940
16891
  exports2.selectComponentTypeFromComponent = selectComponentTypeFromComponent;
15941
16892
  exports2.selectComponentTypeFromComponents = selectComponentTypeFromComponents;
15942
16893
  exports2.selectComponentTypeStagesMapping = selectComponentTypeStagesMapping;
@@ -15948,6 +16899,7 @@ var __publicField = (obj, key, value) => {
15948
16899
  exports2.selectComponentsByType = selectComponentsByType;
15949
16900
  exports2.selectComponentsFromComponentType = selectComponentsFromComponentType;
15950
16901
  exports2.selectComponentsMapping = selectComponentsMapping;
16902
+ exports2.selectConversationId = selectConversationId;
15951
16903
  exports2.selectCreateProjectType = selectCreateProjectType;
15952
16904
  exports2.selectCurrentUser = selectCurrentUser;
15953
16905
  exports2.selectDeletedRequests = selectDeletedRequests;
@@ -15966,8 +16918,26 @@ var __publicField = (obj, key, value) => {
15966
16918
  exports2.selectExpandedSections = selectExpandedSections;
15967
16919
  exports2.selectFavouriteProjects = selectFavouriteProjects;
15968
16920
  exports2.selectFileAttachmentsOfIssue = selectFileAttachmentsOfIssue;
15969
- exports2.selectFilteredUserForms = selectFilteredUserForms;
16921
+ exports2.selectFilteredForms = selectFilteredForms;
16922
+ exports2.selectForm = selectForm;
16923
+ exports2.selectFormMapping = selectFormMapping;
16924
+ exports2.selectFormOfComponentType = selectFormOfComponentType;
16925
+ exports2.selectFormOfIssueType = selectFormOfIssueType;
15970
16926
  exports2.selectFormRevision = selectFormRevision;
16927
+ exports2.selectFormRevisionMapping = selectFormRevisionMapping;
16928
+ exports2.selectFormRevisions = selectFormRevisions;
16929
+ exports2.selectFormRevisionsOfForm = selectFormRevisionsOfForm;
16930
+ exports2.selectFormSubmission = selectFormSubmission;
16931
+ exports2.selectFormSubmissionAttachmentsMapping = selectFormSubmissionAttachmentsMapping;
16932
+ exports2.selectFormSubmissions = selectFormSubmissions;
16933
+ exports2.selectFormSubmissionsByComponents = selectFormSubmissionsByComponents;
16934
+ exports2.selectFormSubmissionsByFormRevisions = selectFormSubmissionsByFormRevisions;
16935
+ exports2.selectFormSubmissionsMapping = selectFormSubmissionsMapping;
16936
+ exports2.selectFormSubmissionsOfComponent = selectFormSubmissionsOfComponent;
16937
+ exports2.selectFormSubmissionsOfForm = selectFormSubmissionsOfForm;
16938
+ exports2.selectFormSubmissionsOfIssue = selectFormSubmissionsOfIssue;
16939
+ exports2.selectFormsCount = selectFormsCount;
16940
+ exports2.selectGeneralFormCount = selectGeneralFormCount;
15971
16941
  exports2.selectHiddenCategoryCount = selectHiddenCategoryCount;
15972
16942
  exports2.selectHiddenComponentTypeIds = selectHiddenComponentTypeIds;
15973
16943
  exports2.selectIsFetchingInitialData = selectIsFetchingInitialData;
@@ -15978,14 +16948,21 @@ var __publicField = (obj, key, value) => {
15978
16948
  exports2.selectIssueAttachment = selectIssueAttachment;
15979
16949
  exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
15980
16950
  exports2.selectIssueAttachments = selectIssueAttachments;
16951
+ exports2.selectIssueCountOfCategory = selectIssueCountOfCategory;
15981
16952
  exports2.selectIssueMapping = selectIssueMapping;
16953
+ exports2.selectIssueType = selectIssueType;
16954
+ exports2.selectIssueTypeMapping = selectIssueTypeMapping;
16955
+ exports2.selectIssueTypes = selectIssueTypes;
16956
+ exports2.selectIssueTypesOfOrganization = selectIssueTypesOfOrganization;
15982
16957
  exports2.selectIssueUpdateMapping = selectIssueUpdateMapping;
15983
16958
  exports2.selectIssueUpdatesOfIssue = selectIssueUpdatesOfIssue;
15984
16959
  exports2.selectIssues = selectIssues;
15985
- exports2.selectLatestFormRevision = selectLatestFormRevision;
16960
+ exports2.selectIssuesOfIssueType = selectIssuesOfIssueType;
16961
+ exports2.selectIssuesOfIssueTypeCount = selectIssuesOfIssueTypeCount;
16962
+ exports2.selectLatestFormRevisionByForm = selectLatestFormRevisionByForm;
16963
+ exports2.selectLatestFormRevisionOfForm = selectLatestFormRevisionOfForm;
16964
+ exports2.selectLatestFormRevisionsOfComponentTypes = selectLatestFormRevisionsOfComponentTypes;
15986
16965
  exports2.selectLatestRetryTime = selectLatestRetryTime;
15987
- exports2.selectLatestRevisionByFormId = selectLatestRevisionByFormId;
15988
- exports2.selectLatestRevisionsFromComponentTypeIds = selectLatestRevisionsFromComponentTypeIds;
15989
16966
  exports2.selectLicense = selectLicense;
15990
16967
  exports2.selectLicenseForProject = selectLicenseForProject;
15991
16968
  exports2.selectLicenses = selectLicenses;
@@ -15994,8 +16971,6 @@ var __publicField = (obj, key, value) => {
15994
16971
  exports2.selectMapStyle = selectMapStyle;
15995
16972
  exports2.selectNumberOfComponentTypesMatchingCaseInsensitiveName = selectNumberOfComponentTypesMatchingCaseInsensitiveName;
15996
16973
  exports2.selectNumberOfComponentsOfComponentType = selectNumberOfComponentsOfComponentType;
15997
- exports2.selectNumberOfGeneralUserForms = selectNumberOfGeneralUserForms;
15998
- exports2.selectNumberOfUserForms = selectNumberOfUserForms;
15999
16974
  exports2.selectOrganization = selectOrganization;
16000
16975
  exports2.selectOrganizationAccess = selectOrganizationAccess;
16001
16976
  exports2.selectOrganizationAccessForUser = selectOrganizationAccessForUser;
@@ -16023,11 +16998,10 @@ var __publicField = (obj, key, value) => {
16023
16998
  exports2.selectRecentIssuesAsSearchResults = selectRecentIssuesAsSearchResults;
16024
16999
  exports2.selectRecentProjects = selectRecentProjects;
16025
17000
  exports2.selectRehydrated = selectRehydrated;
16026
- exports2.selectRevisionAttachments = selectRevisionAttachments;
16027
- exports2.selectRevisionsForForm = selectRevisionsForForm;
16028
17001
  exports2.selectRootDocuments = selectRootDocuments;
16029
17002
  exports2.selectShowTooltips = selectShowTooltips;
16030
17003
  exports2.selectSortedEmailDomains = selectSortedEmailDomains;
17004
+ exports2.selectSortedFormSubmissionsOfForm = selectSortedFormSubmissionsOfForm;
16031
17005
  exports2.selectSortedOrganizationLicenses = selectSortedOrganizationLicenses;
16032
17006
  exports2.selectSortedOrganizationUsers = selectSortedOrganizationUsers;
16033
17007
  exports2.selectSortedProjectUsers = selectSortedProjectUsers;
@@ -16039,16 +17013,15 @@ var __publicField = (obj, key, value) => {
16039
17013
  exports2.selectStagesFromComponentType = selectStagesFromComponentType;
16040
17014
  exports2.selectStagesFromComponentTypeIds = selectStagesFromComponentTypeIds;
16041
17015
  exports2.selectStagesFromStageIds = selectStagesFromStageIds;
16042
- exports2.selectSubmissionAttachments = selectSubmissionAttachments;
16043
- exports2.selectSubmissionsForComponent = selectSubmissionsForComponent;
16044
- exports2.selectSubmissionsForForm = selectSubmissionsForForm;
16045
- exports2.selectSubmissionsForIssue = selectSubmissionsForIssue;
17016
+ exports2.selectTeam = selectTeam;
17017
+ exports2.selectTeams = selectTeams;
17018
+ exports2.selectTeamsMapping = selectTeamsMapping;
17019
+ exports2.selectTeamsOfOrganization = selectTeamsOfOrganization;
17020
+ exports2.selectTeamsOfUser = selectTeamsOfUser;
16046
17021
  exports2.selectUploadUrl = selectUploadUrl;
16047
17022
  exports2.selectUsedColors = selectUsedColors;
16048
17023
  exports2.selectUser = selectUser;
16049
- exports2.selectUserForm = selectUserForm;
16050
- exports2.selectUserFormMapping = selectUserFormMapping;
16051
- exports2.selectUserFormSubmission = selectUserFormSubmission;
17024
+ exports2.selectUserFormRevisionAttachmentsMapping = selectUserFormRevisionAttachmentsMapping;
16052
17025
  exports2.selectUsersAsMapping = selectUsersAsMapping;
16053
17026
  exports2.selectVisibleStatuses = selectVisibleStatuses;
16054
17027
  exports2.selectVisibleUserIds = selectVisibleUserIds;
@@ -16067,6 +17040,7 @@ var __publicField = (obj, key, value) => {
16067
17040
  exports2.setComponentTypeAttachments = setComponentTypeAttachments;
16068
17041
  exports2.setComponentTypes = setComponentTypes;
16069
17042
  exports2.setComponents = setComponents;
17043
+ exports2.setConversationId = setConversationId;
16070
17044
  exports2.setCreateProjectType = setCreateProjectType;
16071
17045
  exports2.setCurrentUser = setCurrentUser;
16072
17046
  exports2.setDocumentAttachments = setDocumentAttachments;
@@ -16075,12 +17049,21 @@ var __publicField = (obj, key, value) => {
16075
17049
  exports2.setEnableClustering = setEnableClustering;
16076
17050
  exports2.setEnableDuplicateIssues = setEnableDuplicateIssues;
16077
17051
  exports2.setEnablePlacementMode = setEnablePlacementMode;
17052
+ exports2.setFormRevision = setFormRevision;
17053
+ exports2.setFormRevisionAttachments = setFormRevisionAttachments;
17054
+ exports2.setFormRevisions = setFormRevisions;
17055
+ exports2.setFormSubmission = setFormSubmission;
17056
+ exports2.setFormSubmissionAttachments = setFormSubmissionAttachments;
17057
+ exports2.setFormSubmissions = setFormSubmissions;
17058
+ exports2.setForms = setForms;
16078
17059
  exports2.setIsFetchingInitialData = setIsFetchingInitialData;
16079
17060
  exports2.setIsImportingProjectFile = setIsImportingProjectFile;
16080
17061
  exports2.setIsLoading = setIsLoading;
16081
17062
  exports2.setIssueAttachments = setIssueAttachments;
16082
17063
  exports2.setIssueComment = setIssueComment;
16083
17064
  exports2.setIssueComments = setIssueComments;
17065
+ exports2.setIssueType = setIssueType;
17066
+ exports2.setIssueTypes = setIssueTypes;
16084
17067
  exports2.setIssueUpdates = setIssueUpdates;
16085
17068
  exports2.setIssues = setIssues;
16086
17069
  exports2.setLicenses = setLicenses;
@@ -16096,12 +17079,11 @@ var __publicField = (obj, key, value) => {
16096
17079
  exports2.setSectionExpanded = setSectionExpanded;
16097
17080
  exports2.setShowTooltips = setShowTooltips;
16098
17081
  exports2.setStageCompletions = setStageCompletions;
17082
+ exports2.setTeam = setTeam;
17083
+ exports2.setTeams = setTeams;
16099
17084
  exports2.setTokens = setTokens;
16100
17085
  exports2.setTourStep = setTourStep;
16101
17086
  exports2.setUploadUrl = setUploadUrl;
16102
- exports2.setUserFormRevisionAttachments = setUserFormRevisionAttachments;
16103
- exports2.setUserFormSubmissionAttachments = setUserFormSubmissionAttachments;
16104
- exports2.setUserFormSubmissions = setUserFormSubmissions;
16105
17087
  exports2.setUsers = setUsers;
16106
17088
  exports2.setVisibleStatuses = setVisibleStatuses;
16107
17089
  exports2.setVisibleUserIds = setVisibleUserIds;
@@ -16112,6 +17094,8 @@ var __publicField = (obj, key, value) => {
16112
17094
  exports2.slugify = slugify;
16113
17095
  exports2.spacesToDashesLower = spacesToDashesLower;
16114
17096
  exports2.successColor = successColor;
17097
+ exports2.teamReducer = teamReducer;
17098
+ exports2.teamSlice = teamSlice;
16115
17099
  exports2.toFileNameSafeString = toFileNameSafeString;
16116
17100
  exports2.toOfflineIdRecord = toOfflineIdRecord;
16117
17101
  exports2.toggleComponentTypeVisibility = toggleComponentTypeVisibility;
@@ -16126,15 +17110,19 @@ var __publicField = (obj, key, value) => {
16126
17110
  exports2.updateComponentTypeAttachment = updateComponentTypeAttachment;
16127
17111
  exports2.updateDocumentAttachment = updateDocumentAttachment;
16128
17112
  exports2.updateDocuments = updateDocuments;
17113
+ exports2.updateFormSubmission = updateFormSubmission;
17114
+ exports2.updateFormSubmissionAttachments = updateFormSubmissionAttachments;
17115
+ exports2.updateFormSubmissions = updateFormSubmissions;
16129
17116
  exports2.updateIssue = updateIssue;
16130
17117
  exports2.updateIssueAttachment = updateIssueAttachment;
17118
+ exports2.updateIssueType = updateIssueType;
16131
17119
  exports2.updateLicense = updateLicense;
16132
17120
  exports2.updateOrCreateProject = updateOrCreateProject;
16133
- exports2.updateOrCreateUserFormSubmission = updateOrCreateUserFormSubmission;
16134
17121
  exports2.updateOrganizationAccess = updateOrganizationAccess;
16135
17122
  exports2.updateProjectAccess = updateProjectAccess;
16136
17123
  exports2.updateProjectAttachment = updateProjectAttachment;
16137
17124
  exports2.updateStages = updateStages;
17125
+ exports2.updateTeam = updateTeam;
16138
17126
  exports2.useAppDispatch = useAppDispatch;
16139
17127
  exports2.useAppSelector = useAppSelector;
16140
17128
  exports2.useFieldInput = useFieldInput;
@@ -16144,8 +17132,6 @@ var __publicField = (obj, key, value) => {
16144
17132
  exports2.useFormikInput = useFormikInput;
16145
17133
  exports2.useMemoCompare = useMemoCompare;
16146
17134
  exports2.useSDK = useSDK;
16147
- exports2.userFormReducer = userFormReducer;
16148
- exports2.userFormSlice = userFormSlice;
16149
17135
  exports2.userReducer = userReducer;
16150
17136
  exports2.userSlice = userSlice;
16151
17137
  exports2.valueIsFile = valueIsFile;