@overmap-ai/core 1.0.53-add-agent-conversations.9 → 1.0.53-add-agent-conversations.11

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.
@@ -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("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) {
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("react-dom"), 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-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", "react-dom", "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-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.ReactDOM, global2.get, global2.Linkify, global2.dnd, global2.QrScannerAPI, global2.xlsx, global2.reactPdf, null, null, 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, ReactDOM, get, Linkify, dnd, QrScannerAPI, xlsx, reactPdf, AnnotationLayer_css, TextLayer_css, reactSketchCanvas, set, cloneDeep) {
10
10
  var _a;
11
11
  "use strict";
12
12
  function _interopNamespaceDefault(e) {
@@ -1568,6 +1568,9 @@ var __publicField = (obj, key, value) => {
1568
1568
  return Object.values(state.issueReducer.issues).filter((issue) => issue.category === categoryId).length;
1569
1569
  };
1570
1570
  const categoryReducer = categorySlice.reducer;
1571
+ function setAttachment(state, action) {
1572
+ state.attachments[action.payload.offline_id] = action.payload;
1573
+ }
1571
1574
  function setAttachments(state, action) {
1572
1575
  state.attachments = {};
1573
1576
  for (const attachment of action.payload) {
@@ -1592,6 +1595,15 @@ var __publicField = (obj, key, value) => {
1592
1595
  throw new Error(`Attachment ${action.payload.offline_id} does not exist.`);
1593
1596
  }
1594
1597
  }
1598
+ function updateAttachments(state, action) {
1599
+ for (const attachment of action.payload) {
1600
+ if (attachment.offline_id in state.attachments) {
1601
+ state.attachments[attachment.offline_id] = attachment;
1602
+ } else {
1603
+ throw new Error(`Attachment ${attachment.offline_id} does not exist.`);
1604
+ }
1605
+ }
1606
+ }
1595
1607
  function removeAttachment(state, action) {
1596
1608
  if (action.payload in state.attachments) {
1597
1609
  delete state.attachments[action.payload];
@@ -1625,12 +1637,6 @@ var __publicField = (obj, key, value) => {
1625
1637
  state.components = toOfflineIdRecord(action.payload);
1626
1638
  prevComponents = null;
1627
1639
  },
1628
- setComponentAttachments: setAttachments,
1629
- addComponentAttachment: addAttachment,
1630
- addComponentAttachments: addAttachments,
1631
- updateComponentAttachment: updateAttachment,
1632
- removeComponentAttachment: removeAttachment,
1633
- removeComponentAttachments: removeAttachments,
1634
1640
  updateComponent: (state, action) => {
1635
1641
  if (action.payload.offline_id in state.components) {
1636
1642
  state.components[action.payload.offline_id] = action.payload;
@@ -1655,9 +1661,35 @@ var __publicField = (obj, key, value) => {
1655
1661
  }
1656
1662
  }
1657
1663
  prevComponents = null;
1658
- }
1664
+ },
1665
+ // Attachments
1666
+ setComponentAttachment: setAttachment,
1667
+ setComponentAttachments: setAttachments,
1668
+ addComponentAttachment: addAttachment,
1669
+ addComponentAttachments: addAttachments,
1670
+ updateComponentAttachment: updateAttachment,
1671
+ updateComponentAttachments: updateAttachments,
1672
+ removeComponentAttachment: removeAttachment,
1673
+ removeComponentAttachments: removeAttachments
1659
1674
  }
1660
1675
  });
1676
+ const {
1677
+ addComponent,
1678
+ updateComponent,
1679
+ removeComponent,
1680
+ addComponentsInBatches,
1681
+ setComponents,
1682
+ removeAllComponentsOfType,
1683
+ // Attachments
1684
+ setComponentAttachment,
1685
+ setComponentAttachments,
1686
+ addComponentAttachment,
1687
+ addComponentAttachments,
1688
+ updateComponentAttachment,
1689
+ updateComponentAttachments,
1690
+ removeComponentAttachment,
1691
+ removeComponentAttachments
1692
+ } = componentSlice.actions;
1661
1693
  let prevComponents = null;
1662
1694
  const selectComponents = (state) => {
1663
1695
  if (!prevComponents) {
@@ -1752,20 +1784,6 @@ var __publicField = (obj, key, value) => {
1752
1784
  }
1753
1785
  )
1754
1786
  );
1755
- const {
1756
- addComponent,
1757
- updateComponent,
1758
- removeComponent,
1759
- addComponentsInBatches,
1760
- setComponents,
1761
- setComponentAttachments,
1762
- addComponentAttachment,
1763
- addComponentAttachments,
1764
- updateComponentAttachment,
1765
- removeComponentAttachment,
1766
- removeComponentAttachments,
1767
- removeAllComponentsOfType
1768
- } = componentSlice.actions;
1769
1787
  const componentReducer = componentSlice.reducer;
1770
1788
  const initialState$p = {
1771
1789
  completionsByComponentId: {}
@@ -1956,20 +1974,38 @@ var __publicField = (obj, key, value) => {
1956
1974
  setComponentTypes: (state, action) => {
1957
1975
  state.componentTypes = toOfflineIdRecord(action.payload);
1958
1976
  },
1959
- setComponentTypeAttachments: setAttachments,
1960
- addComponentTypeAttachment: addAttachment,
1961
- addComponentTypeAttachments: addAttachments,
1962
- updateComponentTypeAttachment: updateAttachment,
1963
- removeComponentTypeAttachment: removeAttachment,
1964
- removeComponentTypeAttachments: removeAttachments,
1965
1977
  toggleComponentTypeVisibility: (state, action) => {
1966
1978
  state.hiddenComponentTypeIds[action.payload] = !state.hiddenComponentTypeIds[action.payload];
1967
1979
  },
1968
1980
  deleteComponentType: (state, action) => {
1969
1981
  delete state.componentTypes[action.payload];
1970
- }
1982
+ },
1983
+ // Attachments
1984
+ setComponentTypeAttachment: setAttachment,
1985
+ setComponentTypeAttachments: setAttachments,
1986
+ addComponentTypeAttachment: addAttachment,
1987
+ addComponentTypeAttachments: addAttachments,
1988
+ updateComponentTypeAttachment: updateAttachment,
1989
+ updateComponentTypeAttachments: updateAttachments,
1990
+ removeComponentTypeAttachment: removeAttachment,
1991
+ removeComponentTypeAttachments: removeAttachments
1971
1992
  }
1972
1993
  });
1994
+ const {
1995
+ addComponentType,
1996
+ setComponentTypes,
1997
+ toggleComponentTypeVisibility,
1998
+ deleteComponentType,
1999
+ // Attachmet
2000
+ setComponentTypeAttachment,
2001
+ setComponentTypeAttachments,
2002
+ addComponentTypeAttachment,
2003
+ addComponentTypeAttachments,
2004
+ updateComponentTypeAttachment,
2005
+ updateComponentTypeAttachments,
2006
+ removeComponentTypeAttachment,
2007
+ removeComponentTypeAttachments
2008
+ } = componentTypeSlice.actions;
1973
2009
  const selectComponentTypesMapping = (state) => state.componentTypeReducer.componentTypes;
1974
2010
  const selectComponentTypes = toolkit.createSelector(
1975
2011
  [selectComponentTypesMapping],
@@ -2046,18 +2082,6 @@ var __publicField = (obj, key, value) => {
2046
2082
  }
2047
2083
  )
2048
2084
  );
2049
- const {
2050
- addComponentType,
2051
- setComponentTypes,
2052
- setComponentTypeAttachments,
2053
- addComponentTypeAttachment,
2054
- addComponentTypeAttachments,
2055
- updateComponentTypeAttachment,
2056
- removeComponentTypeAttachment,
2057
- removeComponentTypeAttachments,
2058
- toggleComponentTypeVisibility,
2059
- deleteComponentType
2060
- } = componentTypeSlice.actions;
2061
2085
  const componentTypeReducer = componentTypeSlice.reducer;
2062
2086
  const initialState$m = {
2063
2087
  workspaces: {},
@@ -2147,7 +2171,6 @@ var __publicField = (obj, key, value) => {
2147
2171
  state.issues[issue.offline_id] = issue;
2148
2172
  });
2149
2173
  },
2150
- setIssueAttachments: setAttachments,
2151
2174
  setIssueUpdates: (state, action) => {
2152
2175
  if (action.payload.filter(onlyUniqueOfflineIds).length !== action.payload.length) {
2153
2176
  throw new Error("Tried to use setIssues reducer with duplicate ID's");
@@ -2177,8 +2200,6 @@ var __publicField = (obj, key, value) => {
2177
2200
  state.issues[issue.offline_id] = issue;
2178
2201
  }
2179
2202
  },
2180
- addIssueAttachment: addAttachment,
2181
- addIssueAttachments: addAttachments,
2182
2203
  addIssueUpdate: (state, action) => {
2183
2204
  if (action.payload.offline_id in state.updates) {
2184
2205
  throw new Error(`Tried to add duplicate issue update with offline_id: ${action.payload.offline_id}`);
@@ -2200,7 +2221,6 @@ var __publicField = (obj, key, value) => {
2200
2221
  throw new Error(`Tried to update issue with ID that doesn't exist: ${action.payload.offline_id}`);
2201
2222
  }
2202
2223
  },
2203
- updateIssueAttachment: updateAttachment,
2204
2224
  removeIssue: (state, action) => {
2205
2225
  if (action.payload in state.issues) {
2206
2226
  delete state.issues[action.payload];
@@ -2213,7 +2233,6 @@ var __publicField = (obj, key, value) => {
2213
2233
  delete state.issues[issueId];
2214
2234
  }
2215
2235
  },
2216
- removeIssueAttachment: removeAttachment,
2217
2236
  removeIssueUpdate: (state, action) => {
2218
2237
  if (action.payload in state.updates) {
2219
2238
  delete state.updates[action.payload];
@@ -2310,12 +2329,19 @@ var __publicField = (obj, key, value) => {
2310
2329
  if (indexToRemove !== -1) {
2311
2330
  state.recentIssueIds.splice(indexToRemove, 1);
2312
2331
  }
2313
- }
2332
+ },
2333
+ // Attachments
2334
+ setIssueAttachment: setAttachment,
2335
+ setIssueAttachments: setAttachments,
2336
+ addIssueAttachment: addAttachment,
2337
+ addIssueAttachments: addAttachments,
2338
+ updateIssueAttachment: updateAttachment,
2339
+ updateIssueAttachments: updateAttachments,
2340
+ removeIssueAttachment: removeAttachment,
2341
+ removeIssueAttachments: removeAttachments
2314
2342
  }
2315
2343
  });
2316
2344
  const {
2317
- addIssueAttachment,
2318
- addIssueAttachments,
2319
2345
  addIssue,
2320
2346
  addIssues,
2321
2347
  addIssueUpdate,
@@ -2323,7 +2349,6 @@ var __publicField = (obj, key, value) => {
2323
2349
  addOrReplaceIssueComment,
2324
2350
  addToRecentIssues,
2325
2351
  cleanRecentIssues,
2326
- removeIssueAttachment,
2327
2352
  removeAttachmentsOfIssue,
2328
2353
  removeIssue,
2329
2354
  removeIssues,
@@ -2332,13 +2357,20 @@ var __publicField = (obj, key, value) => {
2332
2357
  removeRecentIssue,
2333
2358
  resetRecentIssues,
2334
2359
  setActiveIssueId,
2335
- setIssueAttachments,
2336
2360
  setIssueUpdates,
2337
2361
  setIssues,
2338
2362
  setVisibleStatuses,
2339
2363
  setVisibleUserIds,
2340
- updateIssueAttachment,
2341
2364
  updateIssue,
2365
+ // Attachments
2366
+ setIssueAttachment,
2367
+ setIssueAttachments,
2368
+ addIssueAttachment,
2369
+ addIssueAttachments,
2370
+ updateIssueAttachment,
2371
+ updateIssueAttachments,
2372
+ removeIssueAttachment,
2373
+ removeIssueAttachments,
2342
2374
  // Commments
2343
2375
  addIssueComment,
2344
2376
  addIssueComments,
@@ -2707,6 +2739,14 @@ var __publicField = (obj, key, value) => {
2707
2739
  OrganizationAccessLevel2[OrganizationAccessLevel2["ADMIN"] = 2] = "ADMIN";
2708
2740
  return OrganizationAccessLevel2;
2709
2741
  })(OrganizationAccessLevel || {});
2742
+ var AttachmentModel = /* @__PURE__ */ ((AttachmentModel2) => {
2743
+ AttachmentModel2["Issue"] = "issue";
2744
+ AttachmentModel2["Component"] = "component";
2745
+ AttachmentModel2["ComponentType"] = "component_type";
2746
+ AttachmentModel2["Project"] = "project";
2747
+ AttachmentModel2["Document"] = "document";
2748
+ return AttachmentModel2;
2749
+ })(AttachmentModel || {});
2710
2750
  var IssueUpdateChange = /* @__PURE__ */ ((IssueUpdateChange2) => {
2711
2751
  IssueUpdateChange2["STATUS"] = "status";
2712
2752
  IssueUpdateChange2["PRIORITY"] = "priority";
@@ -3094,11 +3134,13 @@ var __publicField = (obj, key, value) => {
3094
3134
  throw new Error("Update form submissions count: no active project");
3095
3135
  }
3096
3136
  },
3097
- // Attachment related
3137
+ // Attachments
3138
+ setProjectAttachment: setAttachment,
3098
3139
  setProjectAttachments: setAttachments,
3099
3140
  addProjectAttachment: addAttachment,
3100
3141
  addProjectAttachments: addAttachments,
3101
3142
  updateProjectAttachment: updateAttachment,
3143
+ updateProjectAttachments: updateAttachments,
3102
3144
  removeProjectAttachment: removeAttachment,
3103
3145
  removeProjectAttachments: removeAttachments
3104
3146
  }
@@ -3113,11 +3155,13 @@ var __publicField = (obj, key, value) => {
3113
3155
  acceptProjectInvite,
3114
3156
  addActiveProjectIssuesCount,
3115
3157
  addActiveProjectFormSubmissionsCount,
3116
- // Attachment related
3158
+ // Attachments
3159
+ setProjectAttachment,
3117
3160
  setProjectAttachments,
3118
3161
  addProjectAttachment,
3119
3162
  addProjectAttachments,
3120
3163
  updateProjectAttachment,
3164
+ updateProjectAttachments,
3121
3165
  removeProjectAttachment,
3122
3166
  removeProjectAttachments
3123
3167
  } = projectSlice.actions;
@@ -3188,6 +3232,9 @@ var __publicField = (obj, key, value) => {
3188
3232
  [selectProjectAttachmentMapping],
3189
3233
  (mapping) => Object.values(mapping)
3190
3234
  );
3235
+ const selectProjectAttachment = (attachmentId) => (state) => {
3236
+ return state.projectReducer.attachments[attachmentId];
3237
+ };
3191
3238
  const selectAttachmentsOfProject = restructureCreateSelectorWithArgs(
3192
3239
  toolkit.createSelector(
3193
3240
  [selectAllProjectAttachments, (_state, projectId) => projectId],
@@ -4303,10 +4350,13 @@ var __publicField = (obj, key, value) => {
4303
4350
  delete state.documents[documentId];
4304
4351
  }
4305
4352
  },
4353
+ // Attachments
4354
+ setDocumentAttachment: setAttachment,
4306
4355
  setDocumentAttachments: setAttachments,
4307
4356
  addDocumentAttachment: addAttachment,
4308
4357
  addDocumentAttachments: addAttachments,
4309
4358
  updateDocumentAttachment: updateAttachment,
4359
+ updateDocumentAttachments: updateAttachments,
4310
4360
  removeDocumentAttachment: removeAttachment,
4311
4361
  removeDocumentAttachments: removeAttachments
4312
4362
  }
@@ -4317,10 +4367,13 @@ var __publicField = (obj, key, value) => {
4317
4367
  updateDocuments,
4318
4368
  moveDocument,
4319
4369
  removeDocuments,
4370
+ // Attachments
4371
+ setDocumentAttachment,
4320
4372
  setDocumentAttachments,
4321
4373
  addDocumentAttachment,
4322
4374
  addDocumentAttachments,
4323
4375
  updateDocumentAttachment,
4376
+ updateDocumentAttachments,
4324
4377
  removeDocumentAttachment,
4325
4378
  removeDocumentAttachments
4326
4379
  } = documentSlice.actions;
@@ -5059,642 +5112,95 @@ var __publicField = (obj, key, value) => {
5059
5112
  return promise;
5060
5113
  }
5061
5114
  }
5062
- class AttachmentService extends BaseApiService {
5063
- fetchAll(projectId) {
5064
- const promise = this.enqueueRequest({
5065
- description: "Fetch attachments",
5066
- method: HttpMethod.GET,
5067
- url: `/attachments/${projectId}/`,
5068
- blocks: [],
5069
- blockers: []
5070
- });
5071
- const state = this.client.store.getState();
5072
- const allAttachments = {
5073
- issue_attachments: Object.values(state.issueReducer.attachments),
5074
- component_attachments: Object.values(state.componentReducer.attachments),
5075
- component_type_attachments: Object.values(state.componentTypeReducer.attachments),
5076
- project_attachments: Object.values(state.projectReducer.attachments),
5077
- document_attachments: Object.values(state.documentsReducer.attachments)
5078
- };
5079
- return [allAttachments, promise];
5080
- }
5081
- // Attachments aren't models, so we use the OptimisticGenericResult type instead
5082
- async addIssueAttachment(attachmentPayload) {
5083
- const { issue, file_sha1, offline_id } = attachmentPayload;
5084
- if (!attachmentPayload.file.objectURL) {
5085
- throw new Error("Expected attachmentPayload.file.objectURL to be defined.");
5086
- }
5087
- const offlineAttachment = {
5088
- ...attachmentPayload,
5089
- file: attachmentPayload.file.objectURL,
5090
- file_name: attachmentPayload.file.name,
5091
- file_type: attachmentPayload.file.type,
5092
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5093
- created_by: this.client.store.getState().userReducer.currentUser.id
5094
- };
5095
- await this.client.files.addCache(attachmentPayload.file, file_sha1);
5096
- this.client.store.dispatch(addIssueAttachment(offlineAttachment));
5097
- const [fileProps] = await this.client.files.uploadFileToS3(file_sha1);
5098
- const promise = this.enqueueRequest({
5099
- description: "Create attachment",
5100
- method: HttpMethod.POST,
5101
- url: `/issues/${issue}/attach/`,
5102
- blocks: [offline_id, issue],
5103
- blockers: [file_sha1],
5104
- payload: {
5105
- ...offlineAttachment,
5106
- ...fileProps
5107
- }
5108
- });
5109
- promise.catch((error2) => {
5110
- this.client.store.dispatch(removeIssueAttachment(offlineAttachment.offline_id));
5111
- throw error2;
5112
- });
5113
- return [offlineAttachment, promise];
5114
- }
5115
- async addComponentAttachment(attachmentPayload) {
5116
- const { component, file_sha1, offline_id } = attachmentPayload;
5117
- if (!attachmentPayload.file.objectURL) {
5118
- throw new Error("Expected attachmentPayload.file.objectURL to be defined.");
5119
- }
5120
- const offlineAttachment = {
5121
- ...attachmentPayload,
5122
- file: attachmentPayload.file.objectURL,
5123
- file_name: attachmentPayload.file.name,
5124
- file_type: attachmentPayload.file.type,
5125
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5126
- created_by: this.client.store.getState().userReducer.currentUser.id
5127
- };
5128
- await this.client.files.addCache(attachmentPayload.file, file_sha1);
5129
- this.client.store.dispatch(addComponentAttachment(offlineAttachment));
5130
- const [fileProps] = await this.client.files.uploadFileToS3(file_sha1);
5131
- const promise = this.enqueueRequest({
5132
- description: "Create attachment",
5133
- method: HttpMethod.POST,
5134
- url: `/components/${component}/attach/`,
5135
- blocks: [offline_id, component],
5136
- blockers: [file_sha1],
5137
- payload: {
5138
- ...offlineAttachment,
5139
- ...fileProps
5140
- }
5141
- });
5142
- promise.catch((error2) => {
5143
- this.client.store.dispatch(removeComponentAttachment(offlineAttachment.offline_id));
5144
- throw error2;
5145
- });
5146
- return [offlineAttachment, promise];
5147
- }
5148
- async addComponentTypeAttachment(attachmentPayload) {
5149
- const { component_type, file_sha1, offline_id } = attachmentPayload;
5150
- if (!attachmentPayload.file.objectURL) {
5151
- throw new Error("Expected attachmentPayload.file.objectURL to be defined.");
5152
- }
5153
- const offlineAttachment = {
5154
- ...attachmentPayload,
5155
- file: attachmentPayload.file.objectURL,
5156
- file_name: attachmentPayload.file.name,
5157
- file_type: attachmentPayload.file.type,
5158
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5159
- created_by: this.client.store.getState().userReducer.currentUser.id
5160
- };
5161
- await this.client.files.addCache(attachmentPayload.file, file_sha1);
5162
- this.client.store.dispatch(addComponentTypeAttachment(offlineAttachment));
5163
- const [fileProps] = await this.client.files.uploadFileToS3(file_sha1);
5164
- const promise = this.enqueueRequest({
5165
- description: "Create attachment",
5166
- method: HttpMethod.POST,
5167
- url: `/components/types/${component_type}/attach/`,
5168
- blocks: [offline_id, component_type],
5169
- blockers: [file_sha1],
5170
- payload: {
5171
- ...offlineAttachment,
5172
- ...fileProps
5173
- }
5174
- });
5175
- promise.catch((error2) => {
5176
- this.client.store.dispatch(removeComponentTypeAttachment(offlineAttachment.offline_id));
5177
- throw error2;
5178
- });
5179
- return [offlineAttachment, promise];
5180
- }
5181
- async addDocumentAttachment(attachmentPayload) {
5182
- const { description: description2, document: document2, file_sha1, offline_id } = attachmentPayload;
5183
- if (!attachmentPayload.file.objectURL) {
5184
- throw new Error("Expected attachmentPayload.file.objectURL to be defined.");
5185
- }
5186
- const offlineAttachment = {
5187
- ...attachmentPayload,
5188
- file: attachmentPayload.file.objectURL,
5189
- file_name: attachmentPayload.file.name,
5190
- file_type: attachmentPayload.file.type,
5191
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5192
- created_by: this.client.store.getState().userReducer.currentUser.id
5193
- };
5194
- await this.client.files.addCache(attachmentPayload.file, file_sha1);
5195
- this.client.store.dispatch(addDocumentAttachment(offlineAttachment));
5196
- const [fileProps] = await this.client.files.uploadFileToS3(file_sha1);
5197
- const promise = this.enqueueRequest({
5198
- description: "Create attachment",
5199
- method: HttpMethod.POST,
5200
- url: `/documents/${document2}/attach/`,
5201
- blocks: [offline_id, document2],
5202
- blockers: [file_sha1],
5203
- payload: {
5204
- offline_id,
5205
- document: document2,
5206
- description: description2 ?? "",
5207
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5208
- ...fileProps
5209
- }
5210
- });
5211
- promise.catch((error2) => {
5212
- this.client.store.dispatch(removeDocumentAttachment(offlineAttachment.offline_id));
5213
- throw error2;
5214
- });
5215
- return [offlineAttachment, promise];
5216
- }
5217
- /** the outer Promise is needed to await the hashing of each file, which is required before offline use. If wanting to
5218
- * attach promise handlers to the request to add the attachment in the backend, apply it on the promise returned from the
5219
- * OptimisticModelResult. */
5220
- attachFilesToIssue(filesToSubmit, issueId) {
5221
- return filesToSubmit.map((file) => {
5222
- if (!(file instanceof File)) {
5223
- throw new Error("Expected a File instance.");
5224
- }
5225
- const photoAttachmentPromise = async (file2) => {
5226
- const hash = await hashFile(file2);
5227
- const attachment = offline({
5228
- file: file2,
5229
- file_name: file2.name,
5230
- file_type: file2.type,
5231
- issue: issueId,
5232
- file_sha1: hash,
5233
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5234
- created_by: this.client.store.getState().userReducer.currentUser.id
5235
- });
5236
- return this.addIssueAttachment(attachment);
5237
- };
5238
- return photoAttachmentPromise(file);
5239
- });
5240
- }
5241
- attachFilesToComponent(filesToSubmit, componentId) {
5242
- return filesToSubmit.map((file) => {
5243
- if (!(file instanceof File)) {
5244
- throw new Error("Expected a File instance.");
5245
- }
5246
- const photoAttachmentPromise = async (file2) => {
5247
- const hash = await hashFile(file2);
5248
- const attachment = offline({
5249
- file: file2,
5250
- file_name: file2.name,
5251
- file_type: file2.type,
5252
- component: componentId,
5253
- file_sha1: hash,
5254
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5255
- created_by: this.client.store.getState().userReducer.currentUser.id
5256
- });
5257
- return this.addComponentAttachment(attachment);
5258
- };
5259
- return photoAttachmentPromise(file);
5260
- });
5261
- }
5262
- attachFilesToComponentType(filesToSubmit, componentTypeId) {
5263
- return filesToSubmit.map((file) => {
5264
- if (!(file instanceof File)) {
5265
- throw new Error("Expected a File instance.");
5266
- }
5267
- const photoAttachmentPromise = async (file2) => {
5268
- const hash = await hashFile(file2);
5269
- const attachment = offline({
5270
- file: file2,
5271
- file_name: file2.name,
5272
- file_type: file2.type,
5273
- component_type: componentTypeId,
5274
- file_sha1: hash,
5275
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5276
- created_by: this.client.store.getState().userReducer.currentUser.id
5277
- });
5278
- return this.addComponentTypeAttachment(attachment);
5279
- };
5280
- return photoAttachmentPromise(file);
5281
- });
5282
- }
5283
- attachFilesToDocument(filesToSubmit, documentId) {
5284
- return filesToSubmit.map((file) => {
5285
- if (!(file instanceof File)) {
5286
- throw new Error("Expected a File instance.");
5287
- }
5288
- const photoAttachmentPromise = async (file2) => {
5289
- const hash = await hashFile(file2);
5290
- const attachment = offline({
5291
- file: file2,
5292
- file_name: file2.name,
5293
- file_type: file2.type,
5294
- document: documentId,
5295
- file_sha1: hash,
5296
- submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5297
- created_by: this.client.store.getState().userReducer.currentUser.id
5298
- });
5299
- return this.addDocumentAttachment(attachment);
5300
- };
5301
- return photoAttachmentPromise(file);
5302
- });
5303
- }
5304
- async replaceIssueAttachmentFile(attachmentId, newFile) {
5305
- const { store } = this.client;
5306
- const attachment = store.getState().issueReducer.attachments[attachmentId];
5307
- if (!attachment)
5308
- throw new Error(`Attachment ${attachmentId} not found`);
5309
- let oldFile = void 0;
5310
- const newSha1 = await hashFile(newFile);
5311
- const performRequest2 = async () => {
5312
- oldFile = await this.client.files.fetchCache(attachment.file_sha1);
5313
- if (!oldFile) {
5314
- console.error(`Failed to fetch old file from cache for sha1 ${attachment.file_sha1}.`);
5315
- }
5316
- if (!newFile.objectURL) {
5317
- throw new Error(`newFile["objectURL"] is unexpectedly ${newFile.objectURL}`);
5318
- }
5319
- store.dispatch(
5320
- updateIssueAttachment({ ...attachment, file_sha1: newSha1, file: URL.createObjectURL(newFile) })
5321
- );
5322
- await this.client.files.addCache(newFile, newSha1);
5323
- const [fileProps] = await this.client.files.uploadFileToS3(newSha1).catch((e) => {
5324
- store.dispatch(updateIssueAttachment(attachment));
5115
+ const EXPIRING_SOON_THRESHOLD = 1800;
5116
+ function parseTokens(response) {
5117
+ if (!response.access)
5118
+ throw new Error("Missing access token");
5119
+ if (!response.refresh)
5120
+ throw new Error("Missing refresh token");
5121
+ return { accessToken: response.access, refreshToken: response.refresh };
5122
+ }
5123
+ class AuthService extends BaseApiService {
5124
+ constructor() {
5125
+ super(...arguments);
5126
+ __publicField(this, "_getAccessToken", () => this.client.store.getState().authReducer.accessToken);
5127
+ __publicField(this, "_getRefreshToken", () => this.client.store.getState().authReducer.refreshToken);
5128
+ // _getTokenPair and _getRenewedTokens don't need to use enqueueRequest from the BaseApiService because
5129
+ // they are very simple. However, if we need robust error handling or want these operations to queue in the Outbox,
5130
+ // we will use enqueueRequest.
5131
+ /**
5132
+ * Takes credentials and gets a token pair
5133
+ * @async
5134
+ * @param credentials The username and password for obtaining a token pair
5135
+ * @param logoutOnFailure Whether to log out if the request fails
5136
+ * @returns An array containing two elements: 1) a Promise for the access and refresh tokens, and 2) the UUID of the
5137
+ * request, so the request can be cancelled if necessary.
5138
+ */
5139
+ __publicField(this, "_getTokenPair", (credentials, logoutOnFailure = true) => {
5140
+ const uuid$1 = uuid.v4();
5141
+ const responsePromise = this.enqueueRequest({
5142
+ uuid: uuid$1,
5143
+ description: "Get token pair",
5144
+ method: HttpMethod.POST,
5145
+ url: "/api/token/",
5146
+ payload: credentials,
5147
+ isAuthNeeded: false,
5148
+ checkAuth: false,
5149
+ blockers: [],
5150
+ blocks: []
5151
+ }).then(parseTokens).catch((e) => {
5152
+ if (logoutOnFailure) {
5153
+ void this.logout().then();
5154
+ }
5325
5155
  throw e;
5326
5156
  });
5327
- const promise2 = this.enqueueRequest({
5328
- description: "Edit attachment",
5329
- method: HttpMethod.PATCH,
5330
- url: `/attachments/issues/${attachment.offline_id}/`,
5331
- isResponseBlob: false,
5332
- payload: fileProps,
5333
- blockers: [attachmentId, newSha1],
5334
- blocks: [attachmentId, newSha1]
5157
+ return [responsePromise, uuid$1];
5158
+ });
5159
+ /**
5160
+ * Takes refresh token and gets a new token pair
5161
+ * @async
5162
+ * @param {string} refreshToken The refresh token used to get new tokens
5163
+ * @returns {Promise<TokenPair>} The new access and refresh tokens
5164
+ */
5165
+ __publicField(this, "_getRenewedTokens", async (refreshToken) => {
5166
+ const promise = this.enqueueRequest({
5167
+ description: "Get renewed tokens",
5168
+ method: HttpMethod.POST,
5169
+ url: "/api/token/refresh/",
5170
+ payload: { refresh: refreshToken },
5171
+ isAuthNeeded: false,
5172
+ blockers: [],
5173
+ blocks: [],
5174
+ // Don't wait for an auth check since this is a refresh token request.
5175
+ checkAuth: false,
5176
+ // Don't wait for other requests to finish, or we might end up in a deadlock.
5177
+ immediate: true
5178
+ }).catch((e) => {
5179
+ console.error("Could not renew tokens; logging out due to error:", e);
5180
+ void this.logout();
5181
+ return void 0;
5335
5182
  });
5183
+ let response = void 0;
5336
5184
  try {
5337
- const result = await promise2;
5338
- void this.client.files.removeCache(attachment.file_sha1);
5339
- return result;
5185
+ response = await promise;
5340
5186
  } catch (e) {
5341
- if (oldFile) {
5342
- store.dispatch(
5343
- updateIssueAttachment({
5344
- ...attachment,
5345
- file_sha1: attachment.file_sha1,
5346
- file: URL.createObjectURL(oldFile)
5347
- })
5348
- );
5349
- }
5350
- throw e;
5187
+ await this.logout();
5351
5188
  }
5352
- };
5353
- const offlineAttachment = {
5354
- ...attachment,
5355
- file_sha1: newSha1,
5356
- file: URL.createObjectURL(newFile)
5357
- };
5358
- const promise = performRequest2();
5359
- return [offlineAttachment, promise];
5189
+ if (!response)
5190
+ return void 0;
5191
+ if (!response.access)
5192
+ throw new Error("Missing access token");
5193
+ if (!response.refresh)
5194
+ throw new Error("Missing refresh token");
5195
+ return { accessToken: response.access, refreshToken: response.refresh };
5196
+ });
5360
5197
  }
5361
- async replaceComponentAttachmentFile(attachmentId, newFile) {
5362
- const { store } = this.client;
5363
- const attachment = store.getState().componentReducer.attachments[attachmentId];
5364
- if (!attachment)
5365
- throw new Error(`Attachment ${attachmentId} not found`);
5366
- let oldFile = void 0;
5367
- const newSha1 = await hashFile(newFile);
5368
- const performRequest2 = async () => {
5369
- oldFile = await this.client.files.fetchCache(attachment.file_sha1);
5370
- if (!oldFile) {
5371
- console.error(`Failed to fetch old file from cache for sha1 ${attachment.file_sha1}.`);
5372
- }
5373
- if (!newFile.objectURL) {
5374
- throw new Error(`newFile["objectURL"] is unexpectedly ${newFile.objectURL}`);
5375
- }
5376
- store.dispatch(
5377
- updateComponentAttachment({ ...attachment, file_sha1: newSha1, file: URL.createObjectURL(newFile) })
5378
- );
5379
- await this.client.files.addCache(newFile, newSha1);
5380
- const [fileProps] = await this.client.files.uploadFileToS3(newSha1).catch((e) => {
5381
- store.dispatch(updateComponentAttachment(attachment));
5382
- throw e;
5383
- });
5384
- const promise2 = this.enqueueRequest({
5385
- description: "Edit attachment",
5386
- method: HttpMethod.PATCH,
5387
- url: `/attachments/components/${attachment.offline_id}/`,
5388
- isResponseBlob: false,
5389
- payload: fileProps,
5390
- blockers: [attachmentId, newSha1],
5391
- blocks: [attachmentId, newSha1]
5392
- });
5393
- try {
5394
- const result = await promise2;
5395
- void this.client.files.removeCache(attachment.file_sha1);
5396
- return result;
5397
- } catch (e) {
5398
- if (oldFile) {
5399
- store.dispatch(
5400
- updateComponentAttachment({
5401
- ...attachment,
5402
- file_sha1: attachment.file_sha1,
5403
- file: URL.createObjectURL(oldFile)
5404
- })
5405
- );
5406
- }
5407
- throw e;
5408
- }
5409
- };
5410
- const offlineAttachment = {
5411
- ...attachment,
5412
- file_sha1: newSha1,
5413
- file: URL.createObjectURL(newFile)
5414
- };
5415
- const promise = performRequest2();
5416
- return [offlineAttachment, promise];
5417
- }
5418
- async replaceComponentTypeAttachmentFile(attachmentId, newFile) {
5419
- const { store } = this.client;
5420
- const attachment = store.getState().componentTypeReducer.attachments[attachmentId];
5421
- if (!attachment)
5422
- throw new Error(`Attachment ${attachmentId} not found`);
5423
- let oldFile = void 0;
5424
- const newSha1 = await hashFile(newFile);
5425
- const performRequest2 = async () => {
5426
- oldFile = await this.client.files.fetchCache(attachment.file_sha1);
5427
- if (!oldFile) {
5428
- console.error(`Failed to fetch old file from cache for sha1 ${attachment.file_sha1}.`);
5429
- }
5430
- if (!newFile.objectURL) {
5431
- throw new Error(`newFile["objectURL"] is unexpectedly ${newFile.objectURL}`);
5432
- }
5433
- store.dispatch(
5434
- updateComponentTypeAttachment({
5435
- ...attachment,
5436
- file_sha1: newSha1,
5437
- file: URL.createObjectURL(newFile)
5438
- })
5439
- );
5440
- await this.client.files.addCache(newFile, newSha1);
5441
- const [fileProps] = await this.client.files.uploadFileToS3(newSha1).catch((e) => {
5442
- store.dispatch(updateComponentTypeAttachment(attachment));
5443
- throw e;
5444
- });
5445
- const promise2 = this.enqueueRequest({
5446
- description: "Edit attachment",
5447
- method: HttpMethod.PATCH,
5448
- url: `/attachments/component_types/${attachment.offline_id}/`,
5449
- isResponseBlob: false,
5450
- payload: fileProps,
5451
- blockers: [attachmentId, newSha1],
5452
- blocks: [attachmentId, newSha1]
5453
- });
5454
- try {
5455
- const result = await promise2;
5456
- void this.client.files.removeCache(attachment.file_sha1);
5457
- return result;
5458
- } catch (e) {
5459
- if (oldFile) {
5460
- store.dispatch(
5461
- updateComponentTypeAttachment({
5462
- ...attachment,
5463
- file_sha1: attachment.file_sha1,
5464
- file: URL.createObjectURL(oldFile)
5465
- })
5466
- );
5467
- }
5468
- throw e;
5469
- }
5470
- };
5471
- const offlineAttachment = {
5472
- ...attachment,
5473
- file_sha1: newSha1,
5474
- file: URL.createObjectURL(newFile)
5475
- };
5476
- const promise = performRequest2();
5477
- return [offlineAttachment, promise];
5478
- }
5479
- async replaceDocumentAttachmentFile(attachmentId, newFile) {
5480
- const { store } = this.client;
5481
- const attachment = store.getState().documentsReducer.attachments[attachmentId];
5482
- if (!attachment)
5483
- throw new Error(`Attachment ${attachmentId} not found`);
5484
- let oldFile = void 0;
5485
- const newSha1 = await hashFile(newFile);
5486
- const performRequest2 = async () => {
5487
- oldFile = await this.client.files.fetchCache(attachment.file_sha1);
5488
- if (!oldFile) {
5489
- console.error(`Failed to fetch old file from cache for sha1 ${attachment.file_sha1}.`);
5490
- }
5491
- if (!newFile.objectURL) {
5492
- throw new Error(`newFile["objectURL"] is unexpectedly ${newFile.objectURL}`);
5493
- }
5494
- store.dispatch(
5495
- updateDocumentAttachment({
5496
- ...attachment,
5497
- file_sha1: newSha1,
5498
- file: URL.createObjectURL(newFile)
5499
- })
5500
- );
5501
- await this.client.files.addCache(newFile, newSha1);
5502
- const [fileProps] = await this.client.files.uploadFileToS3(newSha1).catch((e) => {
5503
- store.dispatch(updateDocumentAttachment(attachment));
5504
- throw e;
5505
- });
5506
- const promise2 = this.enqueueRequest({
5507
- description: "Edit attachment",
5508
- method: HttpMethod.PATCH,
5509
- url: `/attachments/documents/${attachment.offline_id}/`,
5510
- isResponseBlob: false,
5511
- payload: fileProps,
5512
- blockers: [attachmentId, newSha1],
5513
- blocks: [attachmentId, newSha1]
5514
- });
5515
- try {
5516
- const result = await promise2;
5517
- void this.client.files.removeCache(attachment.file_sha1);
5518
- return result;
5519
- } catch (e) {
5520
- if (oldFile) {
5521
- store.dispatch(
5522
- updateDocumentAttachment({
5523
- ...attachment,
5524
- file_sha1: attachment.file_sha1,
5525
- file: URL.createObjectURL(oldFile)
5526
- })
5527
- );
5528
- }
5529
- throw e;
5530
- }
5531
- };
5532
- const offlineAttachment = {
5533
- ...attachment,
5534
- file_sha1: newSha1,
5535
- file: URL.createObjectURL(newFile)
5536
- };
5537
- const promise = performRequest2();
5538
- return [offlineAttachment, promise];
5539
- }
5540
- /**
5541
- * Deletes an attachment and associated data in the cloud, in the Redux store and the cache.
5542
- * @param issueAttachmentId
5543
- */
5544
- deleteIssueAttachment(issueAttachmentId) {
5545
- const { store } = this.client;
5546
- const attachment = selectIssueAttachmentMapping(store.getState())[issueAttachmentId];
5547
- if (!attachment) {
5548
- throw new Error(`Attachment ${issueAttachmentId} not found`);
5549
- }
5550
- store.dispatch(removeIssueAttachment(issueAttachmentId));
5551
- void this.client.files.removeCache(attachment.file_sha1);
5552
- return this.enqueueRequest({
5553
- description: "Delete attachment",
5554
- method: HttpMethod.DELETE,
5555
- url: `/attachments/issues/${issueAttachmentId}/`,
5556
- blockers: [issueAttachmentId],
5557
- blocks: [issueAttachmentId]
5558
- });
5559
- }
5560
- deleteComponentAttachment(componentAttachmentId) {
5561
- const { store } = this.client;
5562
- const attachment = selectComponentAttachmentMapping(store.getState())[componentAttachmentId];
5563
- if (!attachment) {
5564
- throw new Error(`Attachment ${componentAttachmentId} not found`);
5565
- }
5566
- store.dispatch(removeComponentAttachment(componentAttachmentId));
5567
- void this.client.files.removeCache(attachment.file_sha1);
5568
- return this.enqueueRequest({
5569
- description: "Delete attachment",
5570
- method: HttpMethod.DELETE,
5571
- url: `/attachments/components/${componentAttachmentId}/`,
5572
- blockers: [componentAttachmentId],
5573
- blocks: [componentAttachmentId]
5574
- });
5575
- }
5576
- deleteComponentTypeAttachment(componentTypeAttachmentId) {
5577
- const { store } = this.client;
5578
- const attachment = selectComponentTypeAttachmentMapping(store.getState())[componentTypeAttachmentId];
5579
- if (!attachment) {
5580
- throw new Error(`Attachment ${componentTypeAttachmentId} not found`);
5581
- }
5582
- store.dispatch(removeComponentTypeAttachment(componentTypeAttachmentId));
5583
- void this.client.files.removeCache(attachment.file_sha1);
5584
- return this.enqueueRequest({
5585
- description: "Delete attachment",
5586
- method: HttpMethod.DELETE,
5587
- url: `/attachments/component_types/${componentTypeAttachmentId}/`,
5588
- blockers: [componentTypeAttachmentId],
5589
- blocks: [componentTypeAttachmentId]
5590
- });
5591
- }
5592
- deleteDocumentAttachment(documentAttachmentId) {
5593
- const { store } = this.client;
5594
- const attachment = store.getState().documentsReducer.attachments[documentAttachmentId];
5595
- if (!attachment) {
5596
- throw new Error(`Attachment ${documentAttachmentId} not found`);
5597
- }
5598
- store.dispatch(removeDocumentAttachment(documentAttachmentId));
5599
- void this.client.files.removeCache(attachment.file_sha1);
5600
- return this.enqueueRequest({
5601
- description: "Delete document attachment",
5602
- method: HttpMethod.DELETE,
5603
- url: `/attachments/documents/${documentAttachmentId}/`,
5604
- blockers: [documentAttachmentId],
5605
- blocks: [documentAttachmentId]
5606
- });
5607
- }
5608
- }
5609
- const EXPIRING_SOON_THRESHOLD = 1800;
5610
- function parseTokens(response) {
5611
- if (!response.access)
5612
- throw new Error("Missing access token");
5613
- if (!response.refresh)
5614
- throw new Error("Missing refresh token");
5615
- return { accessToken: response.access, refreshToken: response.refresh };
5616
- }
5617
- class AuthService extends BaseApiService {
5618
- constructor() {
5619
- super(...arguments);
5620
- __publicField(this, "_getAccessToken", () => this.client.store.getState().authReducer.accessToken);
5621
- __publicField(this, "_getRefreshToken", () => this.client.store.getState().authReducer.refreshToken);
5622
- // _getTokenPair and _getRenewedTokens don't need to use enqueueRequest from the BaseApiService because
5623
- // they are very simple. However, if we need robust error handling or want these operations to queue in the Outbox,
5624
- // we will use enqueueRequest.
5625
- /**
5626
- * Takes credentials and gets a token pair
5627
- * @async
5628
- * @param credentials The username and password for obtaining a token pair
5629
- * @param logoutOnFailure Whether to log out if the request fails
5630
- * @returns An array containing two elements: 1) a Promise for the access and refresh tokens, and 2) the UUID of the
5631
- * request, so the request can be cancelled if necessary.
5632
- */
5633
- __publicField(this, "_getTokenPair", (credentials, logoutOnFailure = true) => {
5634
- const uuid$1 = uuid.v4();
5635
- const responsePromise = this.enqueueRequest({
5636
- uuid: uuid$1,
5637
- description: "Get token pair",
5638
- method: HttpMethod.POST,
5639
- url: "/api/token/",
5640
- payload: credentials,
5641
- isAuthNeeded: false,
5642
- checkAuth: false,
5643
- blockers: [],
5644
- blocks: []
5645
- }).then(parseTokens).catch((e) => {
5646
- if (logoutOnFailure) {
5647
- void this.logout().then();
5648
- }
5649
- throw e;
5650
- });
5651
- return [responsePromise, uuid$1];
5652
- });
5653
- /**
5654
- * Takes refresh token and gets a new token pair
5655
- * @async
5656
- * @param {string} refreshToken The refresh token used to get new tokens
5657
- * @returns {Promise<TokenPair>} The new access and refresh tokens
5658
- */
5659
- __publicField(this, "_getRenewedTokens", async (refreshToken) => {
5660
- const promise = this.enqueueRequest({
5661
- description: "Get renewed tokens",
5662
- method: HttpMethod.POST,
5663
- url: "/api/token/refresh/",
5664
- payload: { refresh: refreshToken },
5665
- isAuthNeeded: false,
5666
- blockers: [],
5667
- blocks: [],
5668
- // Don't wait for an auth check since this is a refresh token request.
5669
- checkAuth: false,
5670
- // Don't wait for other requests to finish, or we might end up in a deadlock.
5671
- immediate: true
5672
- }).catch((e) => {
5673
- console.error("Could not renew tokens; logging out due to error:", e);
5674
- void this.logout();
5675
- return void 0;
5676
- });
5677
- let response = void 0;
5678
- try {
5679
- response = await promise;
5680
- } catch (e) {
5681
- await this.logout();
5682
- }
5683
- if (!response)
5684
- return void 0;
5685
- if (!response.access)
5686
- throw new Error("Missing access token");
5687
- if (!response.refresh)
5688
- throw new Error("Missing refresh token");
5689
- return { accessToken: response.access, refreshToken: response.refresh };
5690
- });
5691
- }
5692
- /**
5693
- * Attempts to log into Hemora using given credentials
5694
- * @param {string} username
5695
- * @param {string} password
5696
- */
5697
- async login(username, password) {
5198
+ /**
5199
+ * Attempts to log into Hemora using given credentials
5200
+ * @param {string} username
5201
+ * @param {string} password
5202
+ */
5203
+ async login(username, password) {
5698
5204
  const { store } = this.client;
5699
5205
  const [promise, uuid$1] = this._getTokenPair({ username, password }, false);
5700
5206
  const initialDataUuid = uuid.v4();
@@ -6297,55 +5803,270 @@ var __publicField = (obj, key, value) => {
6297
5803
  store.dispatch(addStages(result));
6298
5804
  }
6299
5805
  }
6300
- class ComponentTypeService extends BaseApiService {
6301
- add(componentType) {
6302
- const offlineComponentType = offline(componentType);
5806
+ const AttachmentModelMeta = {
5807
+ [AttachmentModel.Issue]: {
5808
+ name: "issue",
5809
+ attachUrlPrefix: "/issues",
5810
+ deleteUrlPrefix: "/issues",
5811
+ fetchUrlPostfix: "/issue-attachments"
5812
+ },
5813
+ [AttachmentModel.Component]: {
5814
+ name: "component",
5815
+ attachUrlPrefix: "/components",
5816
+ deleteUrlPrefix: "/components",
5817
+ fetchUrlPostfix: "/component-attachments"
5818
+ },
5819
+ [AttachmentModel.ComponentType]: {
5820
+ name: "component type",
5821
+ attachUrlPrefix: "/components/types",
5822
+ deleteUrlPrefix: "/components/types",
5823
+ fetchUrlPostfix: "/component-type-attachments"
5824
+ },
5825
+ [AttachmentModel.Project]: {
5826
+ name: "component project",
5827
+ attachUrlPrefix: "/projects",
5828
+ deleteUrlPrefix: "/projects",
5829
+ fetchUrlPostfix: "/attachments"
5830
+ },
5831
+ [AttachmentModel.Document]: {
5832
+ name: "document",
5833
+ attachUrlPrefix: "/documents",
5834
+ deleteUrlPrefix: "/documents",
5835
+ fetchUrlPostfix: "/document-attachments"
5836
+ }
5837
+ };
5838
+ class BaseAttachmentService extends BaseApiService {
5839
+ getNumberOfAttachmentsWithSha1(sha1) {
5840
+ const {
5841
+ issueReducer: issueReducer2,
5842
+ componentReducer: componentReducer2,
5843
+ componentTypeReducer: componentTypeReducer2,
5844
+ documentsReducer: documentsReducer2,
5845
+ projectReducer: projectReducer2,
5846
+ formSubmissionReducer: formSubmissionReducer2,
5847
+ formRevisionReducer: formRevisionReducer2
5848
+ } = this.client.store.getState();
5849
+ const objectsWithSha1 = [].concat(
5850
+ Object.values(issueReducer2.attachments),
5851
+ Object.values(componentReducer2.attachments),
5852
+ Object.values(componentTypeReducer2.attachments),
5853
+ Object.values(documentsReducer2.attachments),
5854
+ Object.values(projectReducer2.attachments),
5855
+ Object.values(formRevisionReducer2.attachments),
5856
+ Object.values(formSubmissionReducer2.attachments)
5857
+ );
5858
+ return objectsWithSha1.filter((object) => object.file_sha1 === sha1).length;
5859
+ }
5860
+ processPresignedUrls(presignedUrls) {
5861
+ for (const [sha1, presignedUrl] of Object.entries(presignedUrls)) {
5862
+ void this.enqueueRequest({
5863
+ url: presignedUrl.url,
5864
+ description: "Upload file to S3",
5865
+ method: HttpMethod.POST,
5866
+ isExternalUrl: true,
5867
+ isAuthNeeded: false,
5868
+ attachmentHash: sha1,
5869
+ // TODO: can we use the sha1 as the blocker?
5870
+ blockers: [`s3-${presignedUrl.fields.key}`],
5871
+ blocks: [sha1],
5872
+ s3url: presignedUrl
5873
+ });
5874
+ }
5875
+ }
5876
+ // Note that currently the fetching of attachments for all models dependds on the active projectId. This may change in the future. And
5877
+ // so for some attachment model services, this method will have to be overridden.
5878
+ async getAttachments(actions) {
6303
5879
  const { store } = this.client;
6304
5880
  const activeProjectId = store.getState().projectReducer.activeProjectId;
6305
- store.dispatch(addComponentType(offlineComponentType));
5881
+ const meta = AttachmentModelMeta[this.attachmentModel];
5882
+ const result = await this.enqueueRequest({
5883
+ description: `Get ${meta.name} attachments`,
5884
+ method: HttpMethod.GET,
5885
+ url: `/projects/${activeProjectId}${meta.fetchUrlPostfix}/`,
5886
+ blocks: [],
5887
+ blockers: []
5888
+ });
5889
+ store.dispatch(actions.setAttachments(result));
5890
+ }
5891
+ async attachFiles(files, modelId, buildOfflineAttachment, actions) {
5892
+ const { store } = this.client;
5893
+ const currentUser = store.getState().userReducer.currentUser;
5894
+ const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
5895
+ const offlineAttachments = [];
5896
+ const attachmentPayloads = [];
5897
+ const filePayloads = {};
5898
+ for (const file of files) {
5899
+ const sha1 = await hashFile(file);
5900
+ if (!(sha1 in filePayloads)) {
5901
+ filePayloads[sha1] = {
5902
+ sha1,
5903
+ file_type: file.type,
5904
+ extension: file.name.split(".").pop(),
5905
+ size: file.size
5906
+ };
5907
+ await this.client.files.addCache(file, sha1);
5908
+ }
5909
+ const offlineAttachment = buildOfflineAttachment({
5910
+ file,
5911
+ sha1,
5912
+ submittedAt,
5913
+ createdBy: currentUser.id,
5914
+ description: "",
5915
+ modelId
5916
+ });
5917
+ offlineAttachments.push(offlineAttachment);
5918
+ attachmentPayloads.push({
5919
+ offline_id: offlineAttachment.offline_id,
5920
+ name: offlineAttachment.file_name,
5921
+ sha1: offlineAttachment.file_sha1,
5922
+ description: offlineAttachment.description
5923
+ });
5924
+ }
5925
+ store.dispatch(actions.addAttachments(offlineAttachments));
5926
+ const meta = AttachmentModelMeta[this.attachmentModel];
6306
5927
  const promise = this.enqueueRequest({
6307
- description: "Create ComponentType",
5928
+ description: `Attach files to ${meta.name}`,
6308
5929
  method: HttpMethod.POST,
6309
- url: `/projects/${activeProjectId}/component-types/`,
6310
- payload: { ...offlineComponentType },
6311
- blockers: [],
6312
- blocks: [offlineComponentType.offline_id]
5930
+ url: `${meta.attachUrlPrefix}/${modelId}/attach/`,
5931
+ payload: {
5932
+ submitted_at: submittedAt,
5933
+ attachments: attachmentPayloads,
5934
+ files: Object.values(filePayloads)
5935
+ },
5936
+ blocks: offlineAttachments.map((attachment) => attachment.offline_id),
5937
+ blockers: offlineAttachments.map((attachment) => attachment.file_sha1)
6313
5938
  });
6314
- return [offlineComponentType, promise];
6315
- }
6316
- update(componentType) {
6317
- this.client.store.dispatch(addComponentType(componentType));
6318
- return this.enqueueRequest({
6319
- description: "Update ComponentType",
6320
- method: HttpMethod.PATCH,
6321
- url: `/components/types/${componentType.offline_id}/`,
6322
- payload: componentType,
6323
- blockers: [componentType.offline_id],
6324
- blocks: [componentType.offline_id]
5939
+ promise.then(({ attachments, presigned_urls }) => {
5940
+ store.dispatch(actions.updateAttachments(attachments));
5941
+ this.processPresignedUrls(presigned_urls);
5942
+ }).catch(() => {
5943
+ store.dispatch(actions.removeAttachments(offlineAttachments.map((attachment) => attachment.offline_id)));
6325
5944
  });
5945
+ return [offlineAttachments, promise.then(({ attachments }) => attachments)];
6326
5946
  }
6327
- async delete(componentTypeId) {
5947
+ async deleteAttachment(attachmendId, actions, selectors) {
6328
5948
  const { store } = this.client;
6329
- const state = store.getState();
6330
- const componentType = selectComponentType(componentTypeId)(state);
6331
- if (!componentType) {
6332
- throw new Error("Expected componentType to exist");
6333
- }
6334
- const stagesOfComponentType = selectStagesFromComponentType(componentTypeId)(state) ?? [];
6335
- const attachmentsOfComponentType = selectAttachmentsOfComponentType(componentTypeId)(state);
6336
- store.dispatch(deleteComponentType(componentTypeId));
6337
- if (stagesOfComponentType.length > 0) {
6338
- const stagesOfComponentTypeIds = stagesOfComponentType.map(
6339
- (componentTypeStage) => componentTypeStage.offline_id
5949
+ const attachment = selectors.selectAttachment(attachmendId)(store.getState());
5950
+ if (!attachment) {
5951
+ throw new Error(
5952
+ `Attempting to delete attachment with offline_id ${attachmendId} that does not exist in the store`
6340
5953
  );
6341
- store.dispatch(removeStages(stagesOfComponentTypeIds));
6342
- }
6343
- if (attachmentsOfComponentType.length > 0) {
6344
- const attachmentsOfComponentTypeIds = attachmentsOfComponentType.map(({ offline_id }) => offline_id);
6345
- store.dispatch(removeComponentTypeAttachments(attachmentsOfComponentTypeIds));
6346
5954
  }
6347
- return this.enqueueRequest({
6348
- description: "Delete ComponentType",
5955
+ store.dispatch(actions.removeAttachment(attachment.offline_id));
5956
+ const meta = AttachmentModelMeta[this.attachmentModel];
5957
+ const promise = this.enqueueRequest({
5958
+ description: "Delete attachment",
5959
+ method: HttpMethod.DELETE,
5960
+ url: `${meta.deleteUrlPrefix}/attachments/${attachmendId}/`,
5961
+ blockers: [attachmendId],
5962
+ blocks: []
5963
+ });
5964
+ promise.then(() => {
5965
+ if (this.getNumberOfAttachmentsWithSha1(attachment.file_sha1) === 0) {
5966
+ void this.client.files.removeCache(attachment.file_sha1);
5967
+ }
5968
+ }).catch(() => {
5969
+ store.dispatch(actions.setAttachment(attachment));
5970
+ });
5971
+ return promise;
5972
+ }
5973
+ }
5974
+ class ComponentAttachmentService extends BaseAttachmentService {
5975
+ constructor() {
5976
+ super(...arguments);
5977
+ __publicField(this, "attachmentModel", AttachmentModel.Component);
5978
+ }
5979
+ buildOfflineAttachment(data) {
5980
+ return offline({
5981
+ file: URL.createObjectURL(data.file),
5982
+ file_sha1: data.sha1,
5983
+ created_by: data.createdBy,
5984
+ file_name: data.file.name,
5985
+ file_type: data.file.type,
5986
+ submitted_at: data.submittedAt,
5987
+ description: data.description,
5988
+ component: data.modelId
5989
+ });
5990
+ }
5991
+ async attachFilesToComponent(files, componentId) {
5992
+ return this.attachFiles(
5993
+ files,
5994
+ componentId,
5995
+ this.buildOfflineAttachment.bind(this),
5996
+ {
5997
+ addAttachments: addComponentAttachments,
5998
+ updateAttachments: updateComponentAttachments,
5999
+ removeAttachments: removeComponentAttachments
6000
+ }
6001
+ );
6002
+ }
6003
+ deleteComponentAttachment(attachmentId) {
6004
+ return this.deleteAttachment(
6005
+ attachmentId,
6006
+ {
6007
+ setAttachment: setComponentAttachment,
6008
+ removeAttachment: removeComponentAttachment
6009
+ },
6010
+ {
6011
+ selectAttachment: selectComponentAttachment
6012
+ }
6013
+ );
6014
+ }
6015
+ async refreshStore() {
6016
+ return this.getAttachments({
6017
+ setAttachments: setComponentAttachments
6018
+ });
6019
+ }
6020
+ }
6021
+ class ComponentTypeService extends BaseApiService {
6022
+ add(componentType) {
6023
+ const offlineComponentType = offline(componentType);
6024
+ const { store } = this.client;
6025
+ const activeProjectId = store.getState().projectReducer.activeProjectId;
6026
+ store.dispatch(addComponentType(offlineComponentType));
6027
+ const promise = this.enqueueRequest({
6028
+ description: "Create ComponentType",
6029
+ method: HttpMethod.POST,
6030
+ url: `/projects/${activeProjectId}/component-types/`,
6031
+ payload: { ...offlineComponentType },
6032
+ blockers: [],
6033
+ blocks: [offlineComponentType.offline_id]
6034
+ });
6035
+ return [offlineComponentType, promise];
6036
+ }
6037
+ update(componentType) {
6038
+ this.client.store.dispatch(addComponentType(componentType));
6039
+ return this.enqueueRequest({
6040
+ description: "Update ComponentType",
6041
+ method: HttpMethod.PATCH,
6042
+ url: `/components/types/${componentType.offline_id}/`,
6043
+ payload: componentType,
6044
+ blockers: [componentType.offline_id],
6045
+ blocks: [componentType.offline_id]
6046
+ });
6047
+ }
6048
+ async delete(componentTypeId) {
6049
+ const { store } = this.client;
6050
+ const state = store.getState();
6051
+ const componentType = selectComponentType(componentTypeId)(state);
6052
+ if (!componentType) {
6053
+ throw new Error("Expected componentType to exist");
6054
+ }
6055
+ const stagesOfComponentType = selectStagesFromComponentType(componentTypeId)(state) ?? [];
6056
+ const attachmentsOfComponentType = selectAttachmentsOfComponentType(componentTypeId)(state);
6057
+ store.dispatch(deleteComponentType(componentTypeId));
6058
+ if (stagesOfComponentType.length > 0) {
6059
+ const stagesOfComponentTypeIds = stagesOfComponentType.map(
6060
+ (componentTypeStage) => componentTypeStage.offline_id
6061
+ );
6062
+ store.dispatch(removeStages(stagesOfComponentTypeIds));
6063
+ }
6064
+ if (attachmentsOfComponentType.length > 0) {
6065
+ const attachmentsOfComponentTypeIds = attachmentsOfComponentType.map(({ offline_id }) => offline_id);
6066
+ store.dispatch(removeComponentTypeAttachments(attachmentsOfComponentTypeIds));
6067
+ }
6068
+ return this.enqueueRequest({
6069
+ description: "Delete ComponentType",
6349
6070
  method: HttpMethod.DELETE,
6350
6071
  url: `/components/types/${componentTypeId}/`,
6351
6072
  blockers: [componentTypeId],
@@ -6369,6 +6090,53 @@ var __publicField = (obj, key, value) => {
6369
6090
  store.dispatch(setComponentTypes(result));
6370
6091
  }
6371
6092
  }
6093
+ class ComponentTypeAttachmentService extends BaseAttachmentService {
6094
+ constructor() {
6095
+ super(...arguments);
6096
+ __publicField(this, "attachmentModel", AttachmentModel.ComponentType);
6097
+ }
6098
+ buildOfflineAttachment(data) {
6099
+ return offline({
6100
+ file: URL.createObjectURL(data.file),
6101
+ file_sha1: data.sha1,
6102
+ created_by: data.createdBy,
6103
+ file_name: data.file.name,
6104
+ file_type: data.file.type,
6105
+ submitted_at: data.submittedAt,
6106
+ description: data.description,
6107
+ component_type: data.modelId
6108
+ });
6109
+ }
6110
+ async attachFilesToComponentType(files, componentTypeId) {
6111
+ return this.attachFiles(
6112
+ files,
6113
+ componentTypeId,
6114
+ this.buildOfflineAttachment.bind(this),
6115
+ {
6116
+ addAttachments: addComponentTypeAttachments,
6117
+ updateAttachments: updateComponentTypeAttachments,
6118
+ removeAttachments: removeComponentTypeAttachments
6119
+ }
6120
+ );
6121
+ }
6122
+ deleteComponentTypeAttachment(attachmentId) {
6123
+ return this.deleteAttachment(
6124
+ attachmentId,
6125
+ {
6126
+ setAttachment: setComponentTypeAttachment,
6127
+ removeAttachment: removeComponentTypeAttachment
6128
+ },
6129
+ {
6130
+ selectAttachment: selectComponentTypeAttachment
6131
+ }
6132
+ );
6133
+ }
6134
+ async refreshStore() {
6135
+ return this.getAttachments({
6136
+ setAttachments: setComponentTypeAttachments
6137
+ });
6138
+ }
6139
+ }
6372
6140
  class IssueCommentService extends BaseApiService {
6373
6141
  // Omit author and submitted_at since these will always be set internally
6374
6142
  add(comment) {
@@ -6465,11 +6233,53 @@ var __publicField = (obj, key, value) => {
6465
6233
  store.dispatch(setIssueUpdates(filteredResult));
6466
6234
  }
6467
6235
  }
6236
+ class IssueAttachmentService extends BaseAttachmentService {
6237
+ constructor() {
6238
+ super(...arguments);
6239
+ __publicField(this, "attachmentModel", AttachmentModel.Issue);
6240
+ }
6241
+ buildOfflineAttachment(data) {
6242
+ return offline({
6243
+ file: URL.createObjectURL(data.file),
6244
+ file_sha1: data.sha1,
6245
+ created_by: data.createdBy,
6246
+ file_name: data.file.name,
6247
+ file_type: data.file.type,
6248
+ submitted_at: data.submittedAt,
6249
+ description: data.description,
6250
+ issue: data.modelId
6251
+ });
6252
+ }
6253
+ async attachFilesToIssue(files, issueId) {
6254
+ return this.attachFiles(files, issueId, this.buildOfflineAttachment.bind(this), {
6255
+ addAttachments: addIssueAttachments,
6256
+ updateAttachments: updateIssueAttachments,
6257
+ removeAttachments: removeIssueAttachments
6258
+ });
6259
+ }
6260
+ deleteIssueAttachment(attachmentId) {
6261
+ return this.deleteAttachment(
6262
+ attachmentId,
6263
+ {
6264
+ setAttachment: setIssueAttachment,
6265
+ removeAttachment: removeIssueAttachment
6266
+ },
6267
+ {
6268
+ selectAttachment: selectIssueAttachment
6269
+ }
6270
+ );
6271
+ }
6272
+ async refreshStore() {
6273
+ return this.getAttachments({
6274
+ setAttachments: setIssueAttachments
6275
+ });
6276
+ }
6277
+ }
6468
6278
  class IssueService extends BaseApiService {
6469
6279
  // Basic CRUD functions
6470
6280
  // TODO: Once all models are represented in `Created<TModel>`, use `Created` in `OptimisticModelResult`, so we don't
6471
6281
  // have to repeat it for all optimistic model results (all optimistic results are created).
6472
- add(issue, issue_type = null) {
6282
+ add(issue, issueType = null) {
6473
6283
  const { store } = this.client;
6474
6284
  const dateWithoutMilliseconds = /* @__PURE__ */ new Date();
6475
6285
  const state = store.getState();
@@ -6496,7 +6306,7 @@ var __publicField = (obj, key, value) => {
6496
6306
  url: "/issues/",
6497
6307
  queryParams: {
6498
6308
  workspace_id: workspaceId,
6499
- ...issue_type ? { issue_type } : {}
6309
+ ...issueType ? { issue_type: issueType } : {}
6500
6310
  },
6501
6311
  payload: issuePayload,
6502
6312
  blockers: [
@@ -6633,7 +6443,7 @@ var __publicField = (obj, key, value) => {
6633
6443
  this.client.store.dispatch(updateIssue(issueToBeUpdated));
6634
6444
  this.client.store.dispatch(removeIssueUpdate(offlineIssueUpdate.offline_id));
6635
6445
  });
6636
- const fullIssue = this.client.store.getState().issueReducer.issues[issue.offline_id];
6446
+ const fullIssue = state.issueReducer.issues[issue.offline_id];
6637
6447
  return [fullIssue, promise];
6638
6448
  }
6639
6449
  async remove(id) {
@@ -6684,14 +6494,15 @@ var __publicField = (obj, key, value) => {
6684
6494
  class IssueTypeService extends BaseApiService {
6685
6495
  add(payload) {
6686
6496
  const { store } = this.client;
6687
- const activeOrganizationId = store.getState().organizationReducer.activeOrganizationId;
6497
+ const state = store.getState();
6498
+ const activeOrganizationId = state.organizationReducer.activeOrganizationId;
6688
6499
  if (!activeOrganizationId) {
6689
6500
  throw new Error(`No active organization, got ${activeOrganizationId} for activeOrganizationId.`);
6690
6501
  }
6691
6502
  const offlineIssueType = offline({
6692
6503
  ...payload,
6693
6504
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
6694
- created_by: store.getState().userReducer.currentUser.id,
6505
+ created_by: state.userReducer.currentUser.id,
6695
6506
  organization: activeOrganizationId
6696
6507
  });
6697
6508
  store.dispatch(addIssueType(offlineIssueType));
@@ -6744,11 +6555,12 @@ var __publicField = (obj, key, value) => {
6744
6555
  }
6745
6556
  delete(issueTypeId) {
6746
6557
  const { store } = this.client;
6747
- const issueTypeToDelete = store.getState().issueTypeReducer.issueTypes[issueTypeId];
6558
+ const state = store.getState();
6559
+ const issueTypeToDelete = state.issueTypeReducer.issueTypes[issueTypeId];
6748
6560
  if (!issueTypeToDelete) {
6749
6561
  throw new Error(`IssueType with offline_id ${issueTypeId} does not exist in the store.`);
6750
6562
  }
6751
- const issuesOfIssueType = selectIssuesOfIssueType(issueTypeId)(store.getState()) ?? [];
6563
+ const issuesOfIssueType = selectIssuesOfIssueType(issueTypeId)(state) ?? [];
6752
6564
  store.dispatch(removeIssueType(issueTypeId));
6753
6565
  store.dispatch(removeIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
6754
6566
  const promise = this.enqueueRequest({
@@ -6797,13 +6609,17 @@ var __publicField = (obj, key, value) => {
6797
6609
  return result;
6798
6610
  });
6799
6611
  }
6800
- async fetchProjectUsers(projectId) {
6612
+ async fetchProjectUsers() {
6613
+ const projectId = this.client.store.getState().projectReducer.activeProjectId;
6801
6614
  return this.enqueueRequest({
6802
6615
  description: "Fetch users",
6803
6616
  method: HttpMethod.GET,
6804
6617
  url: `/projects/${projectId}/users/`,
6805
6618
  blockers: [],
6806
6619
  blocks: []
6620
+ }).then((users) => {
6621
+ this.client.store.dispatch(addUsers(users));
6622
+ return users;
6807
6623
  });
6808
6624
  }
6809
6625
  async fetchOrganizationUsers(orgId) {
@@ -6818,6 +6634,7 @@ var __publicField = (obj, key, value) => {
6818
6634
  // TODO:
6819
6635
  // Don't accept updateStore in ComponentService.list. Just return the offline objects and promise. Here, if
6820
6636
  // overwrite, use setComponents. Otherwise, use bulkAddComponents.
6637
+ // TODO: This needs major cleanup
6821
6638
  async _processInitialData(data, overwrite) {
6822
6639
  var _a2, _b, _c;
6823
6640
  const workspaces = {};
@@ -6878,8 +6695,11 @@ var __publicField = (obj, key, value) => {
6878
6695
  currentOrgId = firstOrg.id;
6879
6696
  }
6880
6697
  if (currentOrgId) {
6881
- await this.client.organizations.fetchInitialOrganizationData(currentOrgId, false);
6882
- void this.client.teams.refreshStore();
6698
+ const initialOrgData = await this.client.organizations.fetchInitialOrganizationData(currentOrgId, false);
6699
+ currentOrgId = initialOrgData.organization.id;
6700
+ }
6701
+ if (!currentOrgId) {
6702
+ throw new Error("No organization found");
6883
6703
  }
6884
6704
  if (!isProjectIdValid) {
6885
6705
  if (validProjects.length !== 0) {
@@ -6903,13 +6723,6 @@ var __publicField = (obj, key, value) => {
6903
6723
  store.dispatch(setActiveProjectId(currentProjectId));
6904
6724
  }
6905
6725
  }
6906
- if (currentProjectId) {
6907
- const usersResultPromise = this.fetchProjectUsers(currentProjectId);
6908
- const projectAccessRefreshPromise = this.client.projectAccesses.refreshStore();
6909
- const usersResult = await usersResultPromise;
6910
- await projectAccessRefreshPromise;
6911
- store.dispatch(addUsers(usersResult));
6912
- }
6913
6726
  let currentWorkspaceId;
6914
6727
  const oldWorkspaceId = this.client.store.getState().workspaceReducer.activeWorkspaceId;
6915
6728
  if (overwrite || !oldWorkspaceId) {
@@ -6917,44 +6730,44 @@ var __publicField = (obj, key, value) => {
6917
6730
  } else {
6918
6731
  currentWorkspaceId = oldWorkspaceId;
6919
6732
  }
6920
- if (currentWorkspaceId && currentProjectId) {
6733
+ if (currentWorkspaceId) {
6921
6734
  store.dispatch(setActiveWorkspaceId(currentWorkspaceId));
6922
- void this.client.categories.refreshStore().then(() => {
6923
- void this.client.issues.refreshStore().then(() => {
6924
- void this.client.issueComments.refreshStore().then();
6925
- });
6735
+ }
6736
+ if (currentProjectId) {
6737
+ void this.client.projectAccesses.refreshStore();
6738
+ void this.client.projectFiles.refreshStore();
6739
+ void this.client.projectAttachments.refreshStore();
6740
+ let issuesPromise;
6741
+ void Promise.allSettled([
6742
+ this.client.categories.refreshStore(),
6743
+ this.client.issueTypes.refreshStore()
6744
+ ]).then(() => {
6745
+ issuesPromise = this.client.issues.refreshStore();
6926
6746
  });
6927
- void this.client.projectFiles.refreshStore().then();
6928
- void this.client.componentTypes.refreshStore().then(() => {
6929
- void this.client.componentStages.refreshStore().then(() => {
6930
- void this.client.components.refreshStore(overwrite).then();
6747
+ void Promise.allSettled([
6748
+ this.client.componentTypes.refreshStore(),
6749
+ this.client.componentStages.refreshStore()
6750
+ ]).then(() => {
6751
+ void this.client.components.refreshStore(overwrite).then(() => {
6752
+ void this.client.componentStageCompletions.refreshStore();
6753
+ void this.client.componentTypeAttachments.refreshStore();
6754
+ void this.client.componentAttachments.refreshStore();
6931
6755
  });
6932
- void this.client.componentStageCompletions.refreshStore().then();
6933
6756
  });
6934
- void this.client.userForms.refreshStore().then(() => {
6935
- void this.client.userFormSubmissions.refreshStore().then();
6757
+ void this.client.documents.refreshStore().then(() => {
6758
+ void this.client.documentAttachments.refreshStore();
6936
6759
  });
6937
- }
6938
- if (currentProjectId) {
6939
- const [_offlineAttachments, promise] = this.client.attachments.fetchAll(currentProjectId);
6940
- void promise.then((result) => {
6941
- const {
6942
- issue_attachments,
6943
- component_type_attachments,
6944
- component_attachments,
6945
- project_attachments,
6946
- document_attachments
6947
- } = result;
6948
- store.dispatch(setIssueAttachments(issue_attachments));
6949
- store.dispatch(setComponentAttachments(component_attachments));
6950
- store.dispatch(setComponentTypeAttachments(component_type_attachments));
6951
- store.dispatch(setProjectAttachments(project_attachments));
6952
- store.dispatch(setDocumentAttachments(document_attachments));
6760
+ void this.client.userForms.refreshStore().then(() => {
6761
+ void this.client.userFormSubmissions.refreshStore();
6953
6762
  });
6954
- void this.client.documents.refreshStore();
6763
+ void this.client.agent.refreshStore();
6764
+ void this.fetchProjectUsers();
6765
+ await issuesPromise;
6766
+ void this.client.issueAttachments.refreshStore();
6767
+ void this.client.issueComments.refreshStore();
6955
6768
  void this.client.issueUpdates.refreshStore();
6956
- void this.client.issueTypes.refreshStore();
6957
6769
  }
6770
+ void this.client.teams.refreshStore();
6958
6771
  store.dispatch(setIsFetchingInitialData(false));
6959
6772
  if (overwrite) {
6960
6773
  console.log("Overwriting data");
@@ -7052,6 +6865,7 @@ var __publicField = (obj, key, value) => {
7052
6865
  });
7053
6866
  return promise;
7054
6867
  }
6868
+ // TODO: This needs to be seperated into a update and create method
7055
6869
  saveActive() {
7056
6870
  const { store } = this.client;
7057
6871
  const state = store.getState();
@@ -7117,6 +6931,48 @@ var __publicField = (obj, key, value) => {
7117
6931
  });
7118
6932
  }
7119
6933
  }
6934
+ class ProjectAttachmentService extends BaseAttachmentService {
6935
+ constructor() {
6936
+ super(...arguments);
6937
+ __publicField(this, "attachmentModel", AttachmentModel.Project);
6938
+ }
6939
+ buildOfflineAttachment(data) {
6940
+ return offline({
6941
+ file: URL.createObjectURL(data.file),
6942
+ file_sha1: data.sha1,
6943
+ created_by: data.createdBy,
6944
+ file_name: data.file.name,
6945
+ file_type: data.file.type,
6946
+ submitted_at: data.submittedAt,
6947
+ description: data.description,
6948
+ project: data.modelId
6949
+ });
6950
+ }
6951
+ async attachFilesToProject(files, projectId) {
6952
+ return this.attachFiles(files, projectId, this.buildOfflineAttachment.bind(this), {
6953
+ addAttachments: addProjectAttachments,
6954
+ updateAttachments: updateProjectAttachments,
6955
+ removeAttachments: removeProjectAttachments
6956
+ });
6957
+ }
6958
+ deleteProjectAttachment(attachmentId) {
6959
+ return this.deleteAttachment(
6960
+ attachmentId,
6961
+ {
6962
+ setAttachment: setProjectAttachment,
6963
+ removeAttachment: removeProjectAttachment
6964
+ },
6965
+ {
6966
+ selectAttachment: selectProjectAttachment
6967
+ }
6968
+ );
6969
+ }
6970
+ async refreshStore() {
6971
+ return this.getAttachments({
6972
+ setAttachments: setProjectAttachments
6973
+ });
6974
+ }
6975
+ }
7120
6976
  class ProjectService extends BaseApiService {
7121
6977
  /**
7122
6978
  * Creates a new project. Due to the nature of project creation,
@@ -8508,6 +8364,48 @@ var __publicField = (obj, key, value) => {
8508
8364
  store.dispatch(addDocuments(await organizationDocumentsPromise));
8509
8365
  }
8510
8366
  }
8367
+ class DocumentAttachmentService extends BaseAttachmentService {
8368
+ constructor() {
8369
+ super(...arguments);
8370
+ __publicField(this, "attachmentModel", AttachmentModel.Document);
8371
+ }
8372
+ buildOfflineAttachment(data) {
8373
+ return offline({
8374
+ file: URL.createObjectURL(data.file),
8375
+ file_sha1: data.sha1,
8376
+ created_by: data.createdBy,
8377
+ file_name: data.file.name,
8378
+ file_type: data.file.type,
8379
+ submitted_at: data.submittedAt,
8380
+ description: data.description,
8381
+ document: data.modelId
8382
+ });
8383
+ }
8384
+ async attachFilesToDocument(files, documentId) {
8385
+ return this.attachFiles(files, documentId, this.buildOfflineAttachment.bind(this), {
8386
+ addAttachments: addDocumentAttachments,
8387
+ updateAttachments: updateDocumentAttachments,
8388
+ removeAttachments: removeDocumentAttachments
8389
+ });
8390
+ }
8391
+ deleteDocumentAttachment(attachmentId) {
8392
+ return this.deleteAttachment(
8393
+ attachmentId,
8394
+ {
8395
+ setAttachment: setDocumentAttachment,
8396
+ removeAttachment: removeDocumentAttachment
8397
+ },
8398
+ {
8399
+ selectAttachment: selectDocumentAttachment
8400
+ }
8401
+ );
8402
+ }
8403
+ async refreshStore() {
8404
+ return this.getAttachments({
8405
+ setAttachments: setDocumentAttachments
8406
+ });
8407
+ }
8408
+ }
8511
8409
  class AgentService extends BaseApiService {
8512
8410
  async startConversation(prompt) {
8513
8411
  const activeProjectId = this.client.store.getState().projectReducer.activeProjectId;
@@ -8742,7 +8640,6 @@ var __publicField = (obj, key, value) => {
8742
8640
  __publicField(this, "store");
8743
8641
  __publicField(this, "agent", new AgentService(this));
8744
8642
  __publicField(this, "files", new FileService(this));
8745
- __publicField(this, "attachments", new AttachmentService(this));
8746
8643
  __publicField(this, "auth", new AuthService(this));
8747
8644
  __publicField(this, "categories", new CategoryService(this));
8748
8645
  __publicField(this, "projectAccesses", new ProjectAccessService(this));
@@ -8752,21 +8649,26 @@ var __publicField = (obj, key, value) => {
8752
8649
  __publicField(this, "issueTypes", new IssueTypeService(this));
8753
8650
  __publicField(this, "issueComments", new IssueCommentService(this));
8754
8651
  __publicField(this, "issueUpdates", new IssueUpdateService(this));
8652
+ __publicField(this, "issueAttachments", new IssueAttachmentService(this));
8755
8653
  __publicField(this, "workspaces", new WorkspaceService(this));
8756
8654
  __publicField(this, "main", new MainService(this));
8757
8655
  __publicField(this, "components", new ComponentService(this));
8656
+ __publicField(this, "componentAttachments", new ComponentAttachmentService(this));
8758
8657
  __publicField(this, "componentTypes", new ComponentTypeService(this));
8658
+ __publicField(this, "componentTypeAttachments", new ComponentTypeAttachmentService(this));
8759
8659
  __publicField(this, "componentStages", new ComponentStageService(this));
8760
8660
  __publicField(this, "componentStageCompletions", new ComponentStageCompletionService(this));
8761
8661
  __publicField(this, "userForms", new UserFormService(this));
8762
8662
  __publicField(this, "userFormSubmissions", new UserFormSubmissionService(this));
8763
8663
  __publicField(this, "projects", new ProjectService(this));
8764
8664
  __publicField(this, "projectFiles", new ProjectFileService(this));
8665
+ __publicField(this, "projectAttachments", new ProjectAttachmentService(this));
8765
8666
  __publicField(this, "emailVerification", new EmailVerificationService(this));
8766
8667
  __publicField(this, "emailDomains", new EmailDomainsService(this));
8767
8668
  __publicField(this, "licenses", new LicenseService(this));
8768
8669
  __publicField(this, "documents", new DocumentService(this));
8769
8670
  __publicField(this, "teams", new TeamService(this));
8671
+ __publicField(this, "documentAttachments", new DocumentAttachmentService(this));
8770
8672
  this.API_URL = apiUrl;
8771
8673
  this.store = store;
8772
8674
  }
@@ -8948,406 +8850,152 @@ var __publicField = (obj, key, value) => {
8948
8850
  saveAs(blob, name);
8949
8851
  },
8950
8852
  [name, file]
8951
- );
8952
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
8953
- /* @__PURE__ */ jsxRuntime.jsx(
8954
- "button",
8955
- {
8956
- className: styles$c.FullScreenImageContainer,
8957
- type: "button",
8958
- onClick: () => {
8959
- setShowPreview(false);
8960
- },
8961
- children: /* @__PURE__ */ jsxRuntime.jsx(
8962
- "img",
8963
- {
8964
- className: styles$c.FullScreenImage,
8965
- src: url,
8966
- alt: name,
8967
- onClick: (e) => {
8968
- e.stopPropagation();
8969
- }
8970
- }
8971
- )
8972
- }
8973
- ),
8974
- /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$c.TopBarContainer, align: "center", children: [
8975
- /* @__PURE__ */ jsxRuntime.jsx(
8976
- blocks.IconButton,
8977
- {
8978
- className: styles$c.longIconButton,
8979
- variant: "soft",
8980
- "aria-label": "Exit preview",
8981
- onClick: () => {
8982
- setShowPreview(false);
8983
- },
8984
- children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiArrowLeftLine" })
8985
- }
8986
- ),
8987
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$c.fileName, children: name }),
8988
- /* @__PURE__ */ jsxRuntime.jsx(
8989
- blocks.IconButton,
8990
- {
8991
- className: styles$c.longIconButton,
8992
- variant: "soft",
8993
- "aria-label": `Download ${name}`,
8994
- onClick: handleDownload,
8995
- children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiDownload2Line" })
8996
- }
8997
- )
8998
- ] })
8999
- ] });
9000
- });
9001
- FullScreenImagePreview.displayName = "FullScreenImagePreview";
9002
- const InputWithLabel = (props) => {
9003
- const { label, children, size, severity, inputId, labelId, image, flexProps } = props;
9004
- const [resolvedImage, setResolvedImage] = React.useState(void 0);
9005
- const [showImagePreview, setShowImagePreview] = React.useState(false);
9006
- React.useEffect(() => {
9007
- if (image instanceof Promise) {
9008
- image.then(setResolvedImage).catch(console.error);
9009
- } else {
9010
- setResolvedImage(image);
9011
- }
9012
- }, [image]);
9013
- const resolvedImageURL = resolvedImage ? URL.createObjectURL(resolvedImage) : void 0;
9014
- return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
9015
- resolvedImage && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
9016
- /* @__PURE__ */ jsxRuntime.jsx(
9017
- "img",
9018
- {
9019
- className: styles$c.previewImage,
9020
- src: resolvedImageURL,
9021
- alt: resolvedImage.name,
9022
- onClick: () => {
9023
- setShowImagePreview(true);
9024
- }
9025
- }
9026
- ),
9027
- showImagePreview && /* @__PURE__ */ jsxRuntime.jsx(
9028
- FullScreenImagePreview,
9029
- {
9030
- file: resolvedImage,
9031
- url: resolvedImageURL,
9032
- name: resolvedImage.name,
9033
- setShowPreview: setShowImagePreview
9034
- }
9035
- )
9036
- ] }),
9037
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", gap: "1", asChild: true, ...flexProps, children: /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: inputId, children: [
9038
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size, severity, id: labelId, children: label }),
9039
- children
9040
- ] }) })
9041
- ] });
9042
- };
9043
- const InputWithHelpText = (props) => {
9044
- const { helpText, children, severity } = props;
9045
- return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "1", children: [
9046
- children,
9047
- /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity, className: styles$c.description, children: helpText }) })
9048
- ] });
9049
- };
9050
- const InputWithLabelAndHelpText = (props) => {
9051
- const { children, ...restProps } = props;
9052
- return /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { ...restProps, children });
9053
- };
9054
- const useFormikInput = (props) => {
9055
- const { id, field, formId: formId2, size, showInputOnly, ...rest } = props;
9056
- const [fieldProps, meta, helpers] = formik.useField(field.getId());
9057
- const { touched } = meta;
9058
- const helpText = meta.error ?? field.description;
9059
- const severity = meta.error ? "danger" : void 0;
9060
- const inputId = id ?? `${formId2}-${field.getId()}-input`;
9061
- const labelId = `${inputId}-label`;
9062
- const label = field.required ? `${field.label} *` : field.label;
9063
- const fieldPropsWithValidation = React.useMemo(() => {
9064
- const handleChange = (e) => {
9065
- const value = field.getValueFromChangeEvent(e);
9066
- void helpers.setValue(value, false).then();
9067
- if (touched || !field.onlyValidateAfterTouched) {
9068
- helpers.setError(field.getError(value));
9069
- }
9070
- };
9071
- const handleBlur = (e) => {
9072
- void helpers.setTouched(true, false).then();
9073
- helpers.setError(field.getError(field.getValueFromChangeEvent(e)));
9074
- };
9075
- return {
9076
- ...fieldProps,
9077
- onChange: handleChange,
9078
- onBlur: handleBlur
9079
- };
9080
- }, [field, fieldProps, helpers, touched]);
9081
- return [
9082
- {
9083
- helpText,
9084
- size,
9085
- severity,
9086
- inputId,
9087
- labelId,
9088
- label,
9089
- showInputOnly,
9090
- fieldProps: fieldPropsWithValidation,
9091
- helpers,
9092
- field
9093
- },
9094
- { ...rest, "aria-labelledby": labelId }
9095
- ];
9096
- };
9097
- const truthyValues = [true, "true"];
9098
- const BooleanInput = React.memo((props) => {
9099
- const [{ inputId, labelId, size, severity, showInputOnly, field, fieldProps }, rest] = useFormikInput(props);
9100
- let [{ helpText, label }] = useFormikInput(props);
9101
- helpText = showInputOnly ? null : helpText;
9102
- label = showInputOnly ? "" : label;
9103
- const color = blocks.useSeverityColor(severity);
9104
- const value = truthyValues.includes(fieldProps.value);
9105
- return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(
9106
- InputWithLabel,
9107
- {
9108
- size,
9109
- severity,
9110
- inputId,
9111
- labelId,
9112
- label,
9113
- image: showInputOnly ? void 0 : field.image,
9114
- flexProps: { direction: "row-reverse", justify: "end", align: "center", gap: "2" },
9115
- children: /* @__PURE__ */ jsxRuntime.jsx(
9116
- blocks.Checkbox,
9117
- {
9118
- ...rest,
9119
- ...fieldProps,
9120
- id: inputId,
9121
- color,
9122
- value: value.toString(),
9123
- checked: value,
9124
- onCheckedChange: fieldProps.onChange,
9125
- onChange: void 0,
9126
- onBlur: void 0
9127
- }
9128
- )
9129
- }
9130
- ) });
9131
- });
9132
- BooleanInput.displayName = "BooleanInput";
9133
- var DefaultContext = {
9134
- color: void 0,
9135
- size: void 0,
9136
- className: void 0,
9137
- style: void 0,
9138
- attr: void 0
9139
- };
9140
- var IconContext = React.createContext && /* @__PURE__ */ React.createContext(DefaultContext);
9141
- var _excluded = ["attr", "size", "title"];
9142
- function _objectWithoutProperties(source, excluded) {
9143
- if (source == null)
9144
- return {};
9145
- var target = _objectWithoutPropertiesLoose(source, excluded);
9146
- var key, i;
9147
- if (Object.getOwnPropertySymbols) {
9148
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
9149
- for (i = 0; i < sourceSymbolKeys.length; i++) {
9150
- key = sourceSymbolKeys[i];
9151
- if (excluded.indexOf(key) >= 0)
9152
- continue;
9153
- if (!Object.prototype.propertyIsEnumerable.call(source, key))
9154
- continue;
9155
- target[key] = source[key];
9156
- }
9157
- }
9158
- return target;
9159
- }
9160
- function _objectWithoutPropertiesLoose(source, excluded) {
9161
- if (source == null)
9162
- return {};
9163
- var target = {};
9164
- for (var key in source) {
9165
- if (Object.prototype.hasOwnProperty.call(source, key)) {
9166
- if (excluded.indexOf(key) >= 0)
9167
- continue;
9168
- target[key] = source[key];
9169
- }
9170
- }
9171
- return target;
9172
- }
9173
- function _extends$1() {
9174
- _extends$1 = Object.assign ? Object.assign.bind() : function(target) {
9175
- for (var i = 1; i < arguments.length; i++) {
9176
- var source = arguments[i];
9177
- for (var key in source) {
9178
- if (Object.prototype.hasOwnProperty.call(source, key)) {
9179
- target[key] = source[key];
9180
- }
9181
- }
9182
- }
9183
- return target;
9184
- };
9185
- return _extends$1.apply(this, arguments);
9186
- }
9187
- function ownKeys(e, r) {
9188
- var t = Object.keys(e);
9189
- if (Object.getOwnPropertySymbols) {
9190
- var o = Object.getOwnPropertySymbols(e);
9191
- r && (o = o.filter(function(r2) {
9192
- return Object.getOwnPropertyDescriptor(e, r2).enumerable;
9193
- })), t.push.apply(t, o);
9194
- }
9195
- return t;
9196
- }
9197
- function _objectSpread(e) {
9198
- for (var r = 1; r < arguments.length; r++) {
9199
- var t = null != arguments[r] ? arguments[r] : {};
9200
- r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
9201
- _defineProperty(e, r2, t[r2]);
9202
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
9203
- Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
9204
- });
9205
- }
9206
- return e;
9207
- }
9208
- function _defineProperty(obj, key, value) {
9209
- key = _toPropertyKey(key);
9210
- if (key in obj) {
9211
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
9212
- } else {
9213
- obj[key] = value;
9214
- }
9215
- return obj;
9216
- }
9217
- function _toPropertyKey(t) {
9218
- var i = _toPrimitive(t, "string");
9219
- return "symbol" == typeof i ? i : i + "";
9220
- }
9221
- function _toPrimitive(t, r) {
9222
- if ("object" != typeof t || !t)
9223
- return t;
9224
- var e = t[Symbol.toPrimitive];
9225
- if (void 0 !== e) {
9226
- var i = e.call(t, r || "default");
9227
- if ("object" != typeof i)
9228
- return i;
9229
- throw new TypeError("@@toPrimitive must return a primitive value.");
9230
- }
9231
- return ("string" === r ? String : Number)(t);
9232
- }
9233
- function Tree2Element(tree) {
9234
- return tree && tree.map((node, i) => /* @__PURE__ */ React.createElement(node.tag, _objectSpread({
9235
- key: i
9236
- }, node.attr), Tree2Element(node.child)));
9237
- }
9238
- function GenIcon(data) {
9239
- return (props) => /* @__PURE__ */ React.createElement(IconBase, _extends$1({
9240
- attr: _objectSpread({}, data.attr)
9241
- }, props), Tree2Element(data.child));
9242
- }
9243
- function IconBase(props) {
9244
- var elem = (conf) => {
9245
- var {
9246
- attr,
9247
- size,
9248
- title: title2
9249
- } = props, svgProps = _objectWithoutProperties(props, _excluded);
9250
- var computedSize = size || conf.size || "1em";
9251
- var className;
9252
- if (conf.className)
9253
- className = conf.className;
9254
- if (props.className)
9255
- className = (className ? className + " " : "") + props.className;
9256
- return /* @__PURE__ */ React.createElement("svg", _extends$1({
9257
- stroke: "currentColor",
9258
- fill: "currentColor",
9259
- strokeWidth: "0"
9260
- }, conf.attr, attr, svgProps, {
9261
- className,
9262
- style: _objectSpread(_objectSpread({
9263
- color: props.color || conf.color
9264
- }, conf.style), props.style),
9265
- height: computedSize,
9266
- width: computedSize,
9267
- xmlns: "http://www.w3.org/2000/svg"
9268
- }), title2 && /* @__PURE__ */ React.createElement("title", null, title2), props.children);
9269
- };
9270
- return IconContext !== void 0 ? /* @__PURE__ */ React.createElement(IconContext.Consumer, null, (conf) => elem(conf)) : elem(DefaultContext);
9271
- }
9272
- function RiArrowDownLine(props) {
9273
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M13.0001 16.1716L18.3641 10.8076L19.7783 12.2218L12.0001 20L4.22192 12.2218L5.63614 10.8076L11.0001 16.1716V4H13.0001V16.1716Z" }, "child": [] }] })(props);
9274
- }
9275
- function RiArrowUpLine(props) {
9276
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M13.0001 7.82843V20H11.0001V7.82843L5.63614 13.1924L4.22192 11.7782L12.0001 4L19.7783 11.7782L18.3641 13.1924L13.0001 7.82843Z" }, "child": [] }] })(props);
9277
- }
9278
- function RiCalendarLine(props) {
9279
- 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);
9280
- }
9281
- function RiQrCodeLine(props) {
9282
- 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);
9283
- }
9284
- function RiFileCopyLine(props) {
9285
- 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);
9286
- }
9287
- function RiAlignJustify(props) {
9288
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z" }, "child": [] }] })(props);
9289
- }
9290
- function RiHashtag(props) {
9291
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M7.78428 14L8.2047 10H4V8H8.41491L8.94043 3H10.9514L10.4259 8H14.4149L14.9404 3H16.9514L16.4259 8H20V10H16.2157L15.7953 14H20V16H15.5851L15.0596 21H13.0486L13.5741 16H9.58509L9.05957 21H7.04855L7.57407 16H4V14H7.78428ZM9.7953 14H13.7843L14.2047 10H10.2157L9.7953 14Z" }, "child": [] }] })(props);
9292
- }
9293
- function RiInputField(props) {
9294
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M8 5H11V19H8V21H16V19H13V5H16V3H8V5ZM2 7C1.44772 7 1 7.44772 1 8V16C1 16.5523 1.44772 17 2 17H8V15H3V9H8V7H2ZM16 9H21V15H16V17H22C22.5523 17 23 16.5523 23 16V8C23 7.44772 22.5523 7 22 7H16V9Z" }, "child": [] }] })(props);
9295
- }
9296
- function RiListCheck(props) {
9297
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M8 4H21V6H8V4ZM3 3.5H6V6.5H3V3.5ZM3 10.5H6V13.5H3V10.5ZM3 17.5H6V20.5H3V17.5ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z" }, "child": [] }] })(props);
9298
- }
9299
- function RiImageLine(props) {
9300
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M2.9918 21C2.44405 21 2 20.5551 2 20.0066V3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918ZM20 15V5H4V19L14 9L20 15ZM20 17.8284L14 11.8284L6.82843 19H20V17.8284ZM8 11C6.89543 11 6 10.1046 6 9C6 7.89543 6.89543 7 8 7C9.10457 7 10 7.89543 10 9C10 10.1046 9.10457 11 8 11Z" }, "child": [] }] })(props);
9301
- }
9302
- function RiCheckboxCircleLine(props) {
9303
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11.0026 16L6.75999 11.7574L8.17421 10.3431L11.0026 13.1716L16.6595 7.51472L18.0737 8.92893L11.0026 16Z" }, "child": [] }] })(props);
9304
- }
9305
- function RiCheckboxLine(props) {
9306
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM5 5V19H19V5H5ZM11.0026 16L6.75999 11.7574L8.17421 10.3431L11.0026 13.1716L16.6595 7.51472L18.0737 8.92893L11.0026 16Z" }, "child": [] }] })(props);
9307
- }
9308
- function RiDeleteBin2Line(props) {
9309
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM13.4142 13.9997L15.182 15.7675L13.7678 17.1817L12 15.4139L10.2322 17.1817L8.81802 15.7675L10.5858 13.9997L8.81802 12.232L10.2322 10.8178L12 12.5855L13.7678 10.8178L15.182 12.232L13.4142 13.9997ZM9 4V6H15V4H9Z" }, "child": [] }] })(props);
9310
- }
9311
- function RiMenuFoldLine(props) {
9312
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M21 17.9995V19.9995H3V17.9995H21ZM6.59619 3.90332L8.01041 5.31753L4.82843 8.49951L8.01041 11.6815L6.59619 13.0957L2 8.49951L6.59619 3.90332ZM21 10.9995V12.9995H12V10.9995H21ZM21 3.99951V5.99951H12V3.99951H21Z" }, "child": [] }] })(props);
9313
- }
9314
- function RiUpload2Line(props) {
9315
- return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M4 19H20V12H22V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V12H4V19ZM13 9V16H11V9H6L12 3L18 9H13Z" }, "child": [] }] })(props);
9316
- }
9317
- const emptyBooleanField = {
9318
- ...emptyBaseField,
9319
- type: "boolean"
8853
+ );
8854
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
8855
+ /* @__PURE__ */ jsxRuntime.jsx(
8856
+ "button",
8857
+ {
8858
+ className: styles$c.FullScreenImageContainer,
8859
+ type: "button",
8860
+ onClick: () => {
8861
+ setShowPreview(false);
8862
+ },
8863
+ children: /* @__PURE__ */ jsxRuntime.jsx(
8864
+ "img",
8865
+ {
8866
+ className: styles$c.FullScreenImage,
8867
+ src: url,
8868
+ alt: name,
8869
+ onClick: (e) => {
8870
+ e.stopPropagation();
8871
+ }
8872
+ }
8873
+ )
8874
+ }
8875
+ ),
8876
+ /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$c.TopBarContainer, align: "center", children: [
8877
+ /* @__PURE__ */ jsxRuntime.jsx(
8878
+ blocks.IconButton,
8879
+ {
8880
+ className: styles$c.longIconButton,
8881
+ variant: "soft",
8882
+ "aria-label": "Exit preview",
8883
+ onClick: () => {
8884
+ setShowPreview(false);
8885
+ },
8886
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiArrowLeftLine" })
8887
+ }
8888
+ ),
8889
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$c.fileName, children: name }),
8890
+ /* @__PURE__ */ jsxRuntime.jsx(
8891
+ blocks.IconButton,
8892
+ {
8893
+ className: styles$c.longIconButton,
8894
+ variant: "soft",
8895
+ "aria-label": `Download ${name}`,
8896
+ onClick: handleDownload,
8897
+ children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiDownload2Line" })
8898
+ }
8899
+ )
8900
+ ] })
8901
+ ] });
8902
+ });
8903
+ FullScreenImagePreview.displayName = "FullScreenImagePreview";
8904
+ const InputWithLabel = (props) => {
8905
+ const { label, children, size, severity, inputId, labelId, image, flexProps } = props;
8906
+ const [resolvedImage, setResolvedImage] = React.useState(void 0);
8907
+ const [showImagePreview, setShowImagePreview] = React.useState(false);
8908
+ React.useEffect(() => {
8909
+ if (image instanceof Promise) {
8910
+ image.then(setResolvedImage).catch(console.error);
8911
+ } else {
8912
+ setResolvedImage(image);
8913
+ }
8914
+ }, [image]);
8915
+ const resolvedImageURL = resolvedImage ? URL.createObjectURL(resolvedImage) : void 0;
8916
+ return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
8917
+ resolvedImage && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
8918
+ /* @__PURE__ */ jsxRuntime.jsx(
8919
+ "img",
8920
+ {
8921
+ className: styles$c.previewImage,
8922
+ src: resolvedImageURL,
8923
+ alt: resolvedImage.name,
8924
+ onClick: () => {
8925
+ setShowImagePreview(true);
8926
+ }
8927
+ }
8928
+ ),
8929
+ showImagePreview && /* @__PURE__ */ jsxRuntime.jsx(
8930
+ FullScreenImagePreview,
8931
+ {
8932
+ file: resolvedImage,
8933
+ url: resolvedImageURL,
8934
+ name: resolvedImage.name,
8935
+ setShowPreview: setShowImagePreview
8936
+ }
8937
+ )
8938
+ ] }),
8939
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", gap: "1", asChild: true, ...flexProps, children: /* @__PURE__ */ jsxRuntime.jsxs("label", { htmlFor: inputId, children: [
8940
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size, severity, id: labelId, children: label }),
8941
+ children
8942
+ ] }) })
8943
+ ] });
9320
8944
  };
9321
- const _BooleanField = class _BooleanField extends BaseField {
9322
- constructor(options) {
9323
- super({ ...options, type: "boolean" });
9324
- __publicField(this, "onlyValidateAfterTouched", false);
9325
- }
9326
- // if a BooleanField is required, `false` is considered blank
9327
- isBlank(value) {
9328
- return this.required && !value;
9329
- }
9330
- getValueFromChangeEvent(event) {
9331
- if (typeof event === "boolean")
9332
- return event;
9333
- return event.target.checked;
9334
- }
9335
- serialize() {
9336
- return super._serialize();
9337
- }
9338
- static deserialize(data) {
9339
- if (data.type !== "boolean")
9340
- throw new Error("Type mismatch.");
9341
- return new _BooleanField(data);
9342
- }
9343
- getInput(props) {
9344
- return /* @__PURE__ */ jsxRuntime.jsx(BooleanInput, { ...props, field: this });
9345
- }
8945
+ const InputWithHelpText = (props) => {
8946
+ const { helpText, children, severity } = props;
8947
+ return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "1", children: [
8948
+ children,
8949
+ /* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { direction: "column", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity, className: styles$c.description, children: helpText }) })
8950
+ ] });
8951
+ };
8952
+ const InputWithLabelAndHelpText = (props) => {
8953
+ const { children, ...restProps } = props;
8954
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { ...restProps, children });
8955
+ };
8956
+ const useFormikInput = (props) => {
8957
+ const { id, field, formId: formId2, size, showInputOnly, ...rest } = props;
8958
+ const [fieldProps, meta, helpers] = formik.useField(field.getId());
8959
+ const { touched } = meta;
8960
+ const helpText = meta.error ?? field.description;
8961
+ const severity = meta.error ? "danger" : void 0;
8962
+ const inputId = id ?? `${formId2}-${field.getId()}-input`;
8963
+ const labelId = `${inputId}-label`;
8964
+ const label = field.required ? `${field.label} *` : field.label;
8965
+ const fieldPropsWithValidation = React.useMemo(() => {
8966
+ const handleChange = (e) => {
8967
+ const value = field.getValueFromChangeEvent(e);
8968
+ void helpers.setValue(value, false).then();
8969
+ if (touched || !field.onlyValidateAfterTouched) {
8970
+ helpers.setError(field.getError(value));
8971
+ }
8972
+ };
8973
+ const handleBlur = (e) => {
8974
+ void helpers.setTouched(true, false).then();
8975
+ helpers.setError(field.getError(field.getValueFromChangeEvent(e)));
8976
+ };
8977
+ return {
8978
+ ...fieldProps,
8979
+ onChange: handleChange,
8980
+ onBlur: handleBlur
8981
+ };
8982
+ }, [field, fieldProps, helpers, touched]);
8983
+ return [
8984
+ {
8985
+ helpText,
8986
+ size,
8987
+ severity,
8988
+ inputId,
8989
+ labelId,
8990
+ label,
8991
+ showInputOnly,
8992
+ fieldProps: fieldPropsWithValidation,
8993
+ helpers,
8994
+ field
8995
+ },
8996
+ { ...rest, "aria-labelledby": labelId }
8997
+ ];
9346
8998
  };
9347
- __publicField(_BooleanField, "fieldTypeName", "Checkbox");
9348
- __publicField(_BooleanField, "fieldTypeDescription", "Perfect for both optional and required yes/no questions.");
9349
- __publicField(_BooleanField, "Icon", RiCheckboxCircleLine);
9350
- let BooleanField = _BooleanField;
9351
8999
  function getDefaultExportFromCjs(x) {
9352
9000
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
9353
9001
  }
@@ -9400,8 +9048,8 @@ var __publicField = (obj, key, value) => {
9400
9048
  })(classnames);
9401
9049
  var classnamesExports = classnames.exports;
9402
9050
  const classNames = /* @__PURE__ */ getDefaultExportFromCjs(classnamesExports);
9403
- function _extends() {
9404
- _extends = Object.assign ? Object.assign.bind() : function(target) {
9051
+ function _extends$1() {
9052
+ _extends$1 = Object.assign ? Object.assign.bind() : function(target) {
9405
9053
  for (var i = 1; i < arguments.length; i++) {
9406
9054
  var source = arguments[i];
9407
9055
  for (var key in source) {
@@ -9412,7 +9060,7 @@ var __publicField = (obj, key, value) => {
9412
9060
  }
9413
9061
  return target;
9414
9062
  };
9415
- return _extends.apply(this, arguments);
9063
+ return _extends$1.apply(this, arguments);
9416
9064
  }
9417
9065
  function $e42e1063c40fb3ef$export$b9ecd428b558ff10(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
9418
9066
  return function handleEvent(event) {
@@ -9543,11 +9191,11 @@ var __publicField = (obj, key, value) => {
9543
9191
  } else
9544
9192
  return child;
9545
9193
  });
9546
- return /* @__PURE__ */ React.createElement($5e63c961fc1ce211$var$SlotClone, _extends({}, slotProps, {
9194
+ return /* @__PURE__ */ React.createElement($5e63c961fc1ce211$var$SlotClone, _extends$1({}, slotProps, {
9547
9195
  ref: forwardedRef
9548
9196
  }), /* @__PURE__ */ React.isValidElement(newElement) ? /* @__PURE__ */ React.cloneElement(newElement, void 0, newChildren) : null);
9549
9197
  }
9550
- return /* @__PURE__ */ React.createElement($5e63c961fc1ce211$var$SlotClone, _extends({}, slotProps, {
9198
+ return /* @__PURE__ */ React.createElement($5e63c961fc1ce211$var$SlotClone, _extends$1({}, slotProps, {
9551
9199
  ref: forwardedRef
9552
9200
  }), children);
9553
9201
  });
@@ -9625,7 +9273,7 @@ var __publicField = (obj, key, value) => {
9625
9273
  React.useEffect(() => {
9626
9274
  window[Symbol.for("radix-ui")] = true;
9627
9275
  }, []);
9628
- return /* @__PURE__ */ React.createElement(Comp, _extends({}, primitiveProps, {
9276
+ return /* @__PURE__ */ React.createElement(Comp, _extends$1({}, primitiveProps, {
9629
9277
  ref: forwardedRef
9630
9278
  }));
9631
9279
  });
@@ -10184,9 +9832,9 @@ var __publicField = (obj, key, value) => {
10184
9832
  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)) });
10185
9833
  });
10186
9834
  Inset.displayName = "Inset";
10187
- const sizes$8 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9835
+ const sizes$9 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
10188
9836
  const headingPropDefs = {
10189
- size: { type: "enum", values: sizes$8, default: "6", responsive: true },
9837
+ size: { type: "enum", values: sizes$9, default: "6", responsive: true },
10190
9838
  weight: { ...weightProp, default: "bold" },
10191
9839
  align: alignProp,
10192
9840
  trim: trimProp,
@@ -10199,9 +9847,9 @@ var __publicField = (obj, key, value) => {
10199
9847
  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));
10200
9848
  });
10201
9849
  Heading.displayName = "Heading";
10202
- const sizes$7 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9850
+ const sizes$8 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
10203
9851
  const textPropDefs = {
10204
- size: { type: "enum", values: sizes$7, default: void 0, responsive: true },
9852
+ size: { type: "enum", values: sizes$8, default: void 0, responsive: true },
10205
9853
  weight: weightProp,
10206
9854
  align: alignProp,
10207
9855
  trim: trimProp,
@@ -10214,11 +9862,11 @@ var __publicField = (obj, key, value) => {
10214
9862
  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));
10215
9863
  });
10216
9864
  Text.displayName = "Text";
10217
- const sizes$6 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
10218
- const variants$4 = ["solid", "soft", "outline", "ghost"];
9865
+ const sizes$7 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
9866
+ const variants$5 = ["solid", "soft", "outline", "ghost"];
10219
9867
  const codePropDefs = {
10220
- size: { type: "enum", values: sizes$6, default: void 0, responsive: true },
10221
- variant: { type: "enum", values: variants$4, default: "soft" },
9868
+ size: { type: "enum", values: sizes$7, default: void 0, responsive: true },
9869
+ variant: { type: "enum", values: variants$5, default: "soft" },
10222
9870
  weight: weightProp,
10223
9871
  color: colorProp,
10224
9872
  highContrast: highContrastProp
@@ -10248,6 +9896,202 @@ var __publicField = (obj, key, value) => {
10248
9896
  value
10249
9897
  ]);
10250
9898
  }
9899
+ const $e698a72e93240346$var$CHECKBOX_NAME = "Checkbox";
9900
+ const [$e698a72e93240346$var$createCheckboxContext, $e698a72e93240346$export$b566c4ff5488ea01] = $c512c27ab02ef895$export$50c7b4e9d9f19c1($e698a72e93240346$var$CHECKBOX_NAME);
9901
+ const [$e698a72e93240346$var$CheckboxProvider, $e698a72e93240346$var$useCheckboxContext] = $e698a72e93240346$var$createCheckboxContext($e698a72e93240346$var$CHECKBOX_NAME);
9902
+ const $e698a72e93240346$export$48513f6b9f8ce62d = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
9903
+ const { __scopeCheckbox, name, checked: checkedProp, defaultChecked, required, disabled, value = "on", onCheckedChange, ...checkboxProps } = props;
9904
+ const [button, setButton] = React.useState(null);
9905
+ const composedRefs = $6ed0406888f73fc4$export$c7b2cbe3552a0d05(
9906
+ forwardedRef,
9907
+ (node) => setButton(node)
9908
+ );
9909
+ const hasConsumerStoppedPropagationRef = React.useRef(false);
9910
+ const isFormControl = button ? Boolean(button.closest("form")) : true;
9911
+ const [checked = false, setChecked] = $71cd76cc60e0454e$export$6f32135080cb4c3({
9912
+ prop: checkedProp,
9913
+ defaultProp: defaultChecked,
9914
+ onChange: onCheckedChange
9915
+ });
9916
+ const initialCheckedStateRef = React.useRef(checked);
9917
+ React.useEffect(() => {
9918
+ const form = button === null || button === void 0 ? void 0 : button.form;
9919
+ if (form) {
9920
+ const reset = () => setChecked(initialCheckedStateRef.current);
9921
+ form.addEventListener("reset", reset);
9922
+ return () => form.removeEventListener("reset", reset);
9923
+ }
9924
+ }, [
9925
+ button,
9926
+ setChecked
9927
+ ]);
9928
+ return /* @__PURE__ */ React.createElement($e698a72e93240346$var$CheckboxProvider, {
9929
+ scope: __scopeCheckbox,
9930
+ state: checked,
9931
+ disabled
9932
+ }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.button, _extends$1({
9933
+ type: "button",
9934
+ role: "checkbox",
9935
+ "aria-checked": $e698a72e93240346$var$isIndeterminate(checked) ? "mixed" : checked,
9936
+ "aria-required": required,
9937
+ "data-state": $e698a72e93240346$var$getState(checked),
9938
+ "data-disabled": disabled ? "" : void 0,
9939
+ disabled,
9940
+ value
9941
+ }, checkboxProps, {
9942
+ ref: composedRefs,
9943
+ onKeyDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onKeyDown, (event) => {
9944
+ if (event.key === "Enter")
9945
+ event.preventDefault();
9946
+ }),
9947
+ onClick: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onClick, (event) => {
9948
+ setChecked(
9949
+ (prevChecked) => $e698a72e93240346$var$isIndeterminate(prevChecked) ? true : !prevChecked
9950
+ );
9951
+ if (isFormControl) {
9952
+ hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
9953
+ if (!hasConsumerStoppedPropagationRef.current)
9954
+ event.stopPropagation();
9955
+ }
9956
+ })
9957
+ })), isFormControl && /* @__PURE__ */ React.createElement($e698a72e93240346$var$BubbleInput, {
9958
+ control: button,
9959
+ bubbles: !hasConsumerStoppedPropagationRef.current,
9960
+ name,
9961
+ value,
9962
+ checked,
9963
+ required,
9964
+ disabled,
9965
+ style: {
9966
+ transform: "translateX(-100%)"
9967
+ }
9968
+ }));
9969
+ });
9970
+ const $e698a72e93240346$var$INDICATOR_NAME = "CheckboxIndicator";
9971
+ const $e698a72e93240346$export$59aad738f51d1c05 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
9972
+ const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
9973
+ const context = $e698a72e93240346$var$useCheckboxContext($e698a72e93240346$var$INDICATOR_NAME, __scopeCheckbox);
9974
+ return /* @__PURE__ */ React.createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
9975
+ present: forceMount || $e698a72e93240346$var$isIndeterminate(context.state) || context.state === true
9976
+ }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends$1({
9977
+ "data-state": $e698a72e93240346$var$getState(context.state),
9978
+ "data-disabled": context.disabled ? "" : void 0
9979
+ }, indicatorProps, {
9980
+ ref: forwardedRef,
9981
+ style: {
9982
+ pointerEvents: "none",
9983
+ ...props.style
9984
+ }
9985
+ })));
9986
+ });
9987
+ const $e698a72e93240346$var$BubbleInput = (props) => {
9988
+ const { control, checked, bubbles = true, ...inputProps } = props;
9989
+ const ref = React.useRef(null);
9990
+ const prevChecked = $010c2913dbd2fe3d$export$5cae361ad82dce8b(checked);
9991
+ const controlSize = $db6c3485150b8e66$export$1ab7ae714698c4b8(control);
9992
+ React.useEffect(() => {
9993
+ const input = ref.current;
9994
+ const inputProto = window.HTMLInputElement.prototype;
9995
+ const descriptor = Object.getOwnPropertyDescriptor(inputProto, "checked");
9996
+ const setChecked = descriptor.set;
9997
+ if (prevChecked !== checked && setChecked) {
9998
+ const event = new Event("click", {
9999
+ bubbles
10000
+ });
10001
+ input.indeterminate = $e698a72e93240346$var$isIndeterminate(checked);
10002
+ setChecked.call(input, $e698a72e93240346$var$isIndeterminate(checked) ? false : checked);
10003
+ input.dispatchEvent(event);
10004
+ }
10005
+ }, [
10006
+ prevChecked,
10007
+ checked,
10008
+ bubbles
10009
+ ]);
10010
+ return /* @__PURE__ */ React.createElement("input", _extends$1({
10011
+ type: "checkbox",
10012
+ "aria-hidden": true,
10013
+ defaultChecked: $e698a72e93240346$var$isIndeterminate(checked) ? false : checked
10014
+ }, inputProps, {
10015
+ tabIndex: -1,
10016
+ ref,
10017
+ style: {
10018
+ ...props.style,
10019
+ ...controlSize,
10020
+ position: "absolute",
10021
+ pointerEvents: "none",
10022
+ opacity: 0,
10023
+ margin: 0
10024
+ }
10025
+ }));
10026
+ };
10027
+ function $e698a72e93240346$var$isIndeterminate(checked) {
10028
+ return checked === "indeterminate";
10029
+ }
10030
+ function $e698a72e93240346$var$getState(checked) {
10031
+ return $e698a72e93240346$var$isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
10032
+ }
10033
+ const $e698a72e93240346$export$be92b6f5f03c0fe9 = $e698a72e93240346$export$48513f6b9f8ce62d;
10034
+ const $e698a72e93240346$export$adb584737d712b70 = $e698a72e93240346$export$59aad738f51d1c05;
10035
+ const sizes$6 = ["1", "2", "3"];
10036
+ const variants$4 = ["classic", "surface", "soft"];
10037
+ const checkboxPropDefs = {
10038
+ size: { type: "enum", values: sizes$6, default: "2", responsive: true },
10039
+ variant: { type: "enum", values: variants$4, default: "surface" },
10040
+ color: colorProp,
10041
+ highContrast: highContrastProp
10042
+ };
10043
+ const ThickCheckIcon = React__namespace.forwardRef(({ color = "currentColor", ...props }, forwardedRef) => {
10044
+ return React__namespace.createElement(
10045
+ "svg",
10046
+ { width: "9", height: "9", viewBox: "0 0 9 9", fill: color, xmlns: "http://www.w3.org/2000/svg", ...props, ref: forwardedRef },
10047
+ React__namespace.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M8.53547 0.62293C8.88226 0.849446 8.97976 1.3142 8.75325 1.66099L4.5083 8.1599C4.38833 8.34356 4.19397 8.4655 3.9764 8.49358C3.75883 8.52167 3.53987 8.45309 3.3772 8.30591L0.616113 5.80777C0.308959 5.52987 0.285246 5.05559 0.563148 4.74844C0.84105 4.44128 1.31533 4.41757 1.62249 4.69547L3.73256 6.60459L7.49741 0.840706C7.72393 0.493916 8.18868 0.396414 8.53547 0.62293Z" })
10048
+ );
10049
+ });
10050
+ ThickCheckIcon.displayName = "ThickCheckIcon";
10051
+ const ChevronDownIcon = React__namespace.forwardRef(({ color = "currentColor", ...props }, forwardedRef) => {
10052
+ return React__namespace.createElement(
10053
+ "svg",
10054
+ { width: "9", height: "9", viewBox: "0 0 9 9", fill: color, xmlns: "http://www.w3.org/2000/svg", ...props, ref: forwardedRef },
10055
+ React__namespace.createElement("path", { d: "M0.135232 3.15803C0.324102 2.95657 0.640521 2.94637 0.841971 3.13523L4.5 6.56464L8.158 3.13523C8.3595 2.94637 8.6759 2.95657 8.8648 3.15803C9.0536 3.35949 9.0434 3.67591 8.842 3.86477L4.84197 7.6148C4.64964 7.7951 4.35036 7.7951 4.15803 7.6148L0.158031 3.86477C-0.0434285 3.67591 -0.0536285 3.35949 0.135232 3.15803Z" })
10056
+ );
10057
+ });
10058
+ ChevronDownIcon.displayName = "ChevronDownIcon";
10059
+ const ThickChevronRightIcon = React__namespace.forwardRef(({ color = "currentColor", ...props }, forwardedRef) => {
10060
+ return React__namespace.createElement(
10061
+ "svg",
10062
+ { width: "9", height: "9", viewBox: "0 0 9 9", fill: color, xmlns: "http://www.w3.org/2000/svg", ...props, ref: forwardedRef },
10063
+ React__namespace.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M3.23826 0.201711C3.54108 -0.0809141 4.01567 -0.0645489 4.29829 0.238264L7.79829 3.98826C8.06724 4.27642 8.06724 4.72359 7.79829 5.01174L4.29829 8.76174C4.01567 9.06455 3.54108 9.08092 3.23826 8.79829C2.93545 8.51567 2.91909 8.04108 3.20171 7.73826L6.22409 4.5L3.20171 1.26174C2.91909 0.958928 2.93545 0.484337 3.23826 0.201711Z" })
10064
+ );
10065
+ });
10066
+ ThickChevronRightIcon.displayName = "ThickChevronRightIcon";
10067
+ const InfoCircledIcon = React__namespace.forwardRef(({ color = "currentColor", ...props }, forwardedRef) => {
10068
+ return React__namespace.createElement(
10069
+ "svg",
10070
+ { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props, ref: forwardedRef },
10071
+ React__namespace.createElement("path", { d: "M7.49991 0.876892C3.84222 0.876892 0.877075 3.84204 0.877075 7.49972C0.877075 11.1574 3.84222 14.1226 7.49991 14.1226C11.1576 14.1226 14.1227 11.1574 14.1227 7.49972C14.1227 3.84204 11.1576 0.876892 7.49991 0.876892ZM1.82707 7.49972C1.82707 4.36671 4.36689 1.82689 7.49991 1.82689C10.6329 1.82689 13.1727 4.36671 13.1727 7.49972C13.1727 10.6327 10.6329 13.1726 7.49991 13.1726C4.36689 13.1726 1.82707 10.6327 1.82707 7.49972ZM8.24992 4.49999C8.24992 4.9142 7.91413 5.24999 7.49992 5.24999C7.08571 5.24999 6.74992 4.9142 6.74992 4.49999C6.74992 4.08577 7.08571 3.74999 7.49992 3.74999C7.91413 3.74999 8.24992 4.08577 8.24992 4.49999ZM6.00003 5.99999H6.50003H7.50003C7.77618 5.99999 8.00003 6.22384 8.00003 6.49999V9.99999H8.50003H9.00003V11H8.50003H7.50003H6.50003H6.00003V9.99999H6.50003H7.00003V6.99999H6.50003H6.00003V5.99999Z", fill: color, fillRule: "evenodd", clipRule: "evenodd" })
10072
+ );
10073
+ });
10074
+ InfoCircledIcon.displayName = "InfoCircledIcon";
10075
+ const Checkbox = React__namespace.forwardRef((props, forwardedRef) => {
10076
+ const { rest: marginRest, ...marginProps } = extractMarginProps(props);
10077
+ const { className, style, size = checkboxPropDefs.size.default, variant = checkboxPropDefs.variant.default, color = checkboxPropDefs.color.default, highContrast = checkboxPropDefs.highContrast.default, ...checkboxProps } = marginRest;
10078
+ return React__namespace.createElement(
10079
+ "span",
10080
+ { className: classNames("rt-CheckboxRoot", className, withBreakpoints(size, "rt-r-size"), withMarginProps(marginProps)), style },
10081
+ React__namespace.createElement(
10082
+ $e698a72e93240346$export$be92b6f5f03c0fe9,
10083
+ { "data-accent-color": color, ...checkboxProps, ref: forwardedRef, className: classNames("rt-reset", "rt-CheckboxButton", `rt-variant-${variant}`, {
10084
+ "rt-high-contrast": highContrast
10085
+ }) },
10086
+ React__namespace.createElement(
10087
+ $e698a72e93240346$export$adb584737d712b70,
10088
+ { className: "rt-CheckboxIndicator" },
10089
+ React__namespace.createElement(ThickCheckIcon, { className: "rt-CheckboxIndicatorIcon" })
10090
+ )
10091
+ )
10092
+ );
10093
+ });
10094
+ Checkbox.displayName = "Checkbox";
10251
10095
  function $e02a7d9cb1dc128c$export$c74125a8e3af6bb2(name) {
10252
10096
  const PROVIDER_NAME = name + "CollectionProvider";
10253
10097
  const [createCollectionContext, createCollectionScope] = $c512c27ab02ef895$export$50c7b4e9d9f19c1(PROVIDER_NAME);
@@ -10339,7 +10183,7 @@ var __publicField = (obj, key, value) => {
10339
10183
  scope: props.__scopeRovingFocusGroup
10340
10184
  }, /* @__PURE__ */ React.createElement($d7bdfb9eb0fdf311$var$Collection.Slot, {
10341
10185
  scope: props.__scopeRovingFocusGroup
10342
- }, /* @__PURE__ */ React.createElement($d7bdfb9eb0fdf311$var$RovingFocusGroupImpl, _extends({}, props, {
10186
+ }, /* @__PURE__ */ React.createElement($d7bdfb9eb0fdf311$var$RovingFocusGroupImpl, _extends$1({}, props, {
10343
10187
  ref: forwardedRef
10344
10188
  }))));
10345
10189
  });
@@ -10395,7 +10239,7 @@ var __publicField = (obj, key, value) => {
10395
10239
  ),
10396
10240
  []
10397
10241
  )
10398
- }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
10242
+ }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends$1({
10399
10243
  tabIndex: isTabbingBackOut || focusableItemsCount === 0 ? -1 : 0,
10400
10244
  "data-orientation": orientation
10401
10245
  }, groupProps, {
@@ -10465,7 +10309,7 @@ var __publicField = (obj, key, value) => {
10465
10309
  id,
10466
10310
  focusable,
10467
10311
  active
10468
- }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({
10312
+ }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends$1({
10469
10313
  tabIndex: isCurrentTabStop ? 0 : -1,
10470
10314
  "data-orientation": context.orientation
10471
10315
  }, itemProps, {
@@ -10605,7 +10449,7 @@ var __publicField = (obj, key, value) => {
10605
10449
  onScrollbarYEnabledChange: setScrollbarYEnabled,
10606
10450
  onCornerWidthChange: setCornerWidth,
10607
10451
  onCornerHeightChange: setCornerHeight
10608
- }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
10452
+ }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends$1({
10609
10453
  dir: direction
10610
10454
  }, scrollAreaProps, {
10611
10455
  ref: composedRefs,
@@ -10628,7 +10472,7 @@ var __publicField = (obj, key, value) => {
10628
10472
  dangerouslySetInnerHTML: {
10629
10473
  __html: `[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`
10630
10474
  }
10631
- }), /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
10475
+ }), /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends$1({
10632
10476
  "data-radix-scroll-area-viewport": ""
10633
10477
  }, viewportProps, {
10634
10478
  ref: composedRefs,
@@ -10672,16 +10516,16 @@ var __publicField = (obj, key, value) => {
10672
10516
  onScrollbarXEnabledChange,
10673
10517
  onScrollbarYEnabledChange
10674
10518
  ]);
10675
- return context.type === "hover" ? /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarHover, _extends({}, scrollbarProps, {
10519
+ return context.type === "hover" ? /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarHover, _extends$1({}, scrollbarProps, {
10676
10520
  ref: forwardedRef,
10677
10521
  forceMount
10678
- })) : context.type === "scroll" ? /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarScroll, _extends({}, scrollbarProps, {
10522
+ })) : context.type === "scroll" ? /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarScroll, _extends$1({}, scrollbarProps, {
10679
10523
  ref: forwardedRef,
10680
10524
  forceMount
10681
- })) : context.type === "auto" ? /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarAuto, _extends({}, scrollbarProps, {
10525
+ })) : context.type === "auto" ? /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarAuto, _extends$1({}, scrollbarProps, {
10682
10526
  ref: forwardedRef,
10683
10527
  forceMount
10684
- })) : context.type === "always" ? /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarVisible, _extends({}, scrollbarProps, {
10528
+ })) : context.type === "always" ? /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarVisible, _extends$1({}, scrollbarProps, {
10685
10529
  ref: forwardedRef
10686
10530
  })) : null;
10687
10531
  });
@@ -10717,7 +10561,7 @@ var __publicField = (obj, key, value) => {
10717
10561
  ]);
10718
10562
  return /* @__PURE__ */ React.createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
10719
10563
  present: forceMount || visible
10720
- }, /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarAuto, _extends({
10564
+ }, /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarAuto, _extends$1({
10721
10565
  "data-state": visible ? "visible" : "hidden"
10722
10566
  }, scrollbarProps, {
10723
10567
  ref: forwardedRef
@@ -10787,7 +10631,7 @@ var __publicField = (obj, key, value) => {
10787
10631
  ]);
10788
10632
  return /* @__PURE__ */ React.createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
10789
10633
  present: forceMount || state !== "hidden"
10790
- }, /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarVisible, _extends({
10634
+ }, /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarVisible, _extends$1({
10791
10635
  "data-state": state === "hidden" ? "hidden" : "visible"
10792
10636
  }, scrollbarProps, {
10793
10637
  ref: forwardedRef,
@@ -10817,7 +10661,7 @@ var __publicField = (obj, key, value) => {
10817
10661
  $57acba87d6e25586$var$useResizeObserver(context.content, handleResize);
10818
10662
  return /* @__PURE__ */ React.createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
10819
10663
  present: forceMount || visible
10820
- }, /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarVisible, _extends({
10664
+ }, /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarVisible, _extends$1({
10821
10665
  "data-state": visible ? "visible" : "hidden"
10822
10666
  }, scrollbarProps, {
10823
10667
  ref: forwardedRef
@@ -10851,7 +10695,7 @@ var __publicField = (obj, key, value) => {
10851
10695
  return $57acba87d6e25586$var$getScrollPositionFromPointer(pointerPos, pointerOffsetRef.current, sizes2, dir);
10852
10696
  }
10853
10697
  if (orientation === "horizontal")
10854
- return /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarX, _extends({}, commonProps, {
10698
+ return /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarX, _extends$1({}, commonProps, {
10855
10699
  ref: forwardedRef,
10856
10700
  onThumbPositionChange: () => {
10857
10701
  if (context.viewport && thumbRef.current) {
@@ -10870,7 +10714,7 @@ var __publicField = (obj, key, value) => {
10870
10714
  }
10871
10715
  }));
10872
10716
  if (orientation === "vertical")
10873
- return /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarY, _extends({}, commonProps, {
10717
+ return /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarY, _extends$1({}, commonProps, {
10874
10718
  ref: forwardedRef,
10875
10719
  onThumbPositionChange: () => {
10876
10720
  if (context.viewport && thumbRef.current) {
@@ -10902,7 +10746,7 @@ var __publicField = (obj, key, value) => {
10902
10746
  }, [
10903
10747
  ref
10904
10748
  ]);
10905
- return /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarImpl, _extends({
10749
+ return /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarImpl, _extends$1({
10906
10750
  "data-orientation": "horizontal"
10907
10751
  }, scrollbarProps, {
10908
10752
  ref: composeRefs,
@@ -10950,7 +10794,7 @@ var __publicField = (obj, key, value) => {
10950
10794
  }, [
10951
10795
  ref
10952
10796
  ]);
10953
- return /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarImpl, _extends({
10797
+ return /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaScrollbarImpl, _extends$1({
10954
10798
  "data-orientation": "vertical"
10955
10799
  }, scrollbarProps, {
10956
10800
  ref: composeRefs,
@@ -11046,7 +10890,7 @@ var __publicField = (obj, key, value) => {
11046
10890
  onThumbPointerUp: $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onThumbPointerUp),
11047
10891
  onThumbPositionChange: handleThumbPositionChange,
11048
10892
  onThumbPointerDown: $b1b2314f5f9a1d84$export$25bec8c6f54ee79a(onThumbPointerDown)
11049
- }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, scrollbarProps, {
10893
+ }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends$1({}, scrollbarProps, {
11050
10894
  ref: composeRefs,
11051
10895
  style: {
11052
10896
  position: "absolute",
@@ -11083,7 +10927,7 @@ var __publicField = (obj, key, value) => {
11083
10927
  const scrollbarContext = $57acba87d6e25586$var$useScrollbarContext($57acba87d6e25586$var$THUMB_NAME, props.__scopeScrollArea);
11084
10928
  return /* @__PURE__ */ React.createElement($921a889cee6df7e8$export$99c2b779aa4e8b8b, {
11085
10929
  present: forceMount || scrollbarContext.hasThumb
11086
- }, /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaThumbImpl, _extends({
10930
+ }, /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaThumbImpl, _extends$1({
11087
10931
  ref: forwardedRef
11088
10932
  }, thumbProps)));
11089
10933
  });
@@ -11123,7 +10967,7 @@ var __publicField = (obj, key, value) => {
11123
10967
  debounceScrollEnd,
11124
10968
  onThumbPositionChange
11125
10969
  ]);
11126
- return /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
10970
+ return /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends$1({
11127
10971
  "data-state": scrollbarContext.hasThumb ? "visible" : "hidden"
11128
10972
  }, thumbProps, {
11129
10973
  ref: composedRef,
@@ -11150,7 +10994,7 @@ var __publicField = (obj, key, value) => {
11150
10994
  const context = $57acba87d6e25586$var$useScrollAreaContext($57acba87d6e25586$var$CORNER_NAME, props.__scopeScrollArea);
11151
10995
  const hasBothScrollbarsVisible = Boolean(context.scrollbarX && context.scrollbarY);
11152
10996
  const hasCorner = context.type !== "scroll" && hasBothScrollbarsVisible;
11153
- return hasCorner ? /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaCornerImpl, _extends({}, props, {
10997
+ return hasCorner ? /* @__PURE__ */ React.createElement($57acba87d6e25586$var$ScrollAreaCornerImpl, _extends$1({}, props, {
11154
10998
  ref: forwardedRef
11155
10999
  })) : null;
11156
11000
  });
@@ -11172,7 +11016,7 @@ var __publicField = (obj, key, value) => {
11172
11016
  context.onCornerWidthChange(width);
11173
11017
  setWidth(width);
11174
11018
  });
11175
- return hasSize ? /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({}, cornerProps, {
11019
+ return hasSize ? /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends$1({}, cornerProps, {
11176
11020
  ref: forwardedRef,
11177
11021
  style: {
11178
11022
  width: width1,
@@ -11433,7 +11277,7 @@ var __publicField = (obj, key, value) => {
11433
11277
  scope: props.__scopeSlider
11434
11278
  }, /* @__PURE__ */ React.createElement($faa2e61a3361514f$var$Collection.Slot, {
11435
11279
  scope: props.__scopeSlider
11436
- }, /* @__PURE__ */ React.createElement(SliderOrientation, _extends({
11280
+ }, /* @__PURE__ */ React.createElement(SliderOrientation, _extends$1({
11437
11281
  "aria-disabled": disabled,
11438
11282
  "data-disabled": disabled ? "" : void 0
11439
11283
  }, sliderProps, {
@@ -11515,7 +11359,7 @@ var __publicField = (obj, key, value) => {
11515
11359
  endEdge: isSlidingFromLeft ? "right" : "left",
11516
11360
  direction: isSlidingFromLeft ? 1 : -1,
11517
11361
  size: "width"
11518
- }, /* @__PURE__ */ React.createElement($faa2e61a3361514f$var$SliderImpl, _extends({
11362
+ }, /* @__PURE__ */ React.createElement($faa2e61a3361514f$var$SliderImpl, _extends$1({
11519
11363
  dir: direction,
11520
11364
  "data-orientation": "horizontal"
11521
11365
  }, sliderProps, {
@@ -11575,7 +11419,7 @@ var __publicField = (obj, key, value) => {
11575
11419
  endEdge: isSlidingFromBottom ? "top" : "bottom",
11576
11420
  size: "height",
11577
11421
  direction: isSlidingFromBottom ? 1 : -1
11578
- }, /* @__PURE__ */ React.createElement($faa2e61a3361514f$var$SliderImpl, _extends({
11422
+ }, /* @__PURE__ */ React.createElement($faa2e61a3361514f$var$SliderImpl, _extends$1({
11579
11423
  "data-orientation": "vertical"
11580
11424
  }, sliderProps, {
11581
11425
  ref,
@@ -11608,7 +11452,7 @@ var __publicField = (obj, key, value) => {
11608
11452
  const $faa2e61a3361514f$var$SliderImpl = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
11609
11453
  const { __scopeSlider, onSlideStart, onSlideMove, onSlideEnd, onHomeKeyDown, onEndKeyDown, onStepKeyDown, ...sliderProps } = props;
11610
11454
  const context = $faa2e61a3361514f$var$useSliderContext($faa2e61a3361514f$var$SLIDER_NAME, __scopeSlider);
11611
- return /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({}, sliderProps, {
11455
+ return /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends$1({}, sliderProps, {
11612
11456
  ref: forwardedRef,
11613
11457
  onKeyDown: $e42e1063c40fb3ef$export$b9ecd428b558ff10(props.onKeyDown, (event) => {
11614
11458
  if (event.key === "Home") {
@@ -11649,7 +11493,7 @@ var __publicField = (obj, key, value) => {
11649
11493
  const $faa2e61a3361514f$export$105594979f116971 = /* @__PURE__ */ React.forwardRef((props, forwardedRef) => {
11650
11494
  const { __scopeSlider, ...trackProps } = props;
11651
11495
  const context = $faa2e61a3361514f$var$useSliderContext($faa2e61a3361514f$var$TRACK_NAME, __scopeSlider);
11652
- return /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({
11496
+ return /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends$1({
11653
11497
  "data-disabled": context.disabled ? "" : void 0,
11654
11498
  "data-orientation": context.orientation
11655
11499
  }, trackProps, {
@@ -11669,7 +11513,7 @@ var __publicField = (obj, key, value) => {
11669
11513
  );
11670
11514
  const offsetStart = valuesCount > 1 ? Math.min(...percentages) : 0;
11671
11515
  const offsetEnd = 100 - Math.max(...percentages);
11672
- return /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({
11516
+ return /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends$1({
11673
11517
  "data-orientation": context.orientation,
11674
11518
  "data-disabled": context.disabled ? "" : void 0
11675
11519
  }, rangeProps, {
@@ -11698,7 +11542,7 @@ var __publicField = (obj, key, value) => {
11698
11542
  thumb
11699
11543
  ]
11700
11544
  );
11701
- return /* @__PURE__ */ React.createElement($faa2e61a3361514f$var$SliderThumbImpl, _extends({}, props, {
11545
+ return /* @__PURE__ */ React.createElement($faa2e61a3361514f$var$SliderThumbImpl, _extends$1({}, props, {
11702
11546
  ref: composedRefs,
11703
11547
  index: index2
11704
11548
  }));
@@ -11737,7 +11581,7 @@ var __publicField = (obj, key, value) => {
11737
11581
  }
11738
11582
  }, /* @__PURE__ */ React.createElement($faa2e61a3361514f$var$Collection.ItemSlot, {
11739
11583
  scope: props.__scopeSlider
11740
- }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({
11584
+ }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends$1({
11741
11585
  role: "slider",
11742
11586
  "aria-label": props["aria-label"] || label,
11743
11587
  "aria-valuemin": context.min,
@@ -11777,7 +11621,7 @@ var __publicField = (obj, key, value) => {
11777
11621
  prevValue,
11778
11622
  value
11779
11623
  ]);
11780
- return /* @__PURE__ */ React.createElement("input", _extends({
11624
+ return /* @__PURE__ */ React.createElement("input", _extends$1({
11781
11625
  style: {
11782
11626
  display: "none"
11783
11627
  }
@@ -11996,7 +11840,7 @@ var __publicField = (obj, key, value) => {
11996
11840
  scope: __scopeAvatar,
11997
11841
  imageLoadingStatus,
11998
11842
  onImageLoadingStatusChange: setImageLoadingStatus
11999
- }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({}, avatarProps, {
11843
+ }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends$1({}, avatarProps, {
12000
11844
  ref: forwardedRef
12001
11845
  })));
12002
11846
  });
@@ -12017,7 +11861,7 @@ var __publicField = (obj, key, value) => {
12017
11861
  imageLoadingStatus,
12018
11862
  handleLoadingStatusChange
12019
11863
  ]);
12020
- return imageLoadingStatus === "loaded" ? /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.img, _extends({}, imageProps, {
11864
+ return imageLoadingStatus === "loaded" ? /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.img, _extends$1({}, imageProps, {
12021
11865
  ref: forwardedRef,
12022
11866
  src
12023
11867
  })) : null;
@@ -12038,7 +11882,7 @@ var __publicField = (obj, key, value) => {
12038
11882
  }, [
12039
11883
  delayMs
12040
11884
  ]);
12041
- return canRender && context.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends({}, fallbackProps, {
11885
+ return canRender && context.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.span, _extends$1({}, fallbackProps, {
12042
11886
  ref: forwardedRef
12043
11887
  })) : null;
12044
11888
  });
@@ -12142,7 +11986,7 @@ var __publicField = (obj, key, value) => {
12142
11986
  orientation,
12143
11987
  dir: direction,
12144
11988
  activationMode
12145
- }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
11989
+ }, /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends$1({
12146
11990
  dir: direction,
12147
11991
  "data-orientation": orientation
12148
11992
  }, tabsProps, {
@@ -12154,13 +11998,13 @@ var __publicField = (obj, key, value) => {
12154
11998
  const { __scopeTabs, loop = true, ...listProps } = props;
12155
11999
  const context = $69cb30bb0017df05$var$useTabsContext($69cb30bb0017df05$var$TAB_LIST_NAME, __scopeTabs);
12156
12000
  const rovingFocusGroupScope = $69cb30bb0017df05$var$useRovingFocusGroupScope(__scopeTabs);
12157
- return /* @__PURE__ */ React.createElement($d7bdfb9eb0fdf311$export$be92b6f5f03c0fe9, _extends({
12001
+ return /* @__PURE__ */ React.createElement($d7bdfb9eb0fdf311$export$be92b6f5f03c0fe9, _extends$1({
12158
12002
  asChild: true
12159
12003
  }, rovingFocusGroupScope, {
12160
12004
  orientation: context.orientation,
12161
12005
  dir: context.dir,
12162
12006
  loop
12163
- }), /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
12007
+ }), /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends$1({
12164
12008
  role: "tablist",
12165
12009
  "aria-orientation": context.orientation
12166
12010
  }, listProps, {
@@ -12175,12 +12019,12 @@ var __publicField = (obj, key, value) => {
12175
12019
  const triggerId = $69cb30bb0017df05$var$makeTriggerId(context.baseId, value);
12176
12020
  const contentId = $69cb30bb0017df05$var$makeContentId(context.baseId, value);
12177
12021
  const isSelected = value === context.value;
12178
- return /* @__PURE__ */ React.createElement($d7bdfb9eb0fdf311$export$6d08773d2e66f8f2, _extends({
12022
+ return /* @__PURE__ */ React.createElement($d7bdfb9eb0fdf311$export$6d08773d2e66f8f2, _extends$1({
12179
12023
  asChild: true
12180
12024
  }, rovingFocusGroupScope, {
12181
12025
  focusable: !disabled,
12182
12026
  active: isSelected
12183
- }), /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.button, _extends({
12027
+ }), /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.button, _extends$1({
12184
12028
  type: "button",
12185
12029
  role: "tab",
12186
12030
  "aria-selected": isSelected,
@@ -12230,7 +12074,7 @@ var __publicField = (obj, key, value) => {
12230
12074
  {
12231
12075
  present: forceMount || isSelected
12232
12076
  },
12233
- ({ present }) => /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends({
12077
+ ({ present }) => /* @__PURE__ */ React.createElement($8927f6f2acc4f386$export$250ffa63cdc0d034.div, _extends$1({
12234
12078
  "data-state": isSelected ? "active" : "inactive",
12235
12079
  "data-orientation": context.orientation,
12236
12080
  role: "tabpanel",
@@ -12290,6 +12134,260 @@ var __publicField = (obj, key, value) => {
12290
12134
  Trigger: TabsTrigger,
12291
12135
  Content: TabsContent
12292
12136
  });
12137
+ const truthyValues = [true, "true"];
12138
+ const BooleanInput = React.memo((props) => {
12139
+ const [{ inputId, labelId, size, severity, showInputOnly, field, fieldProps }, rest] = useFormikInput(props);
12140
+ let [{ helpText, label }] = useFormikInput(props);
12141
+ helpText = showInputOnly ? null : helpText;
12142
+ label = showInputOnly ? "" : label;
12143
+ const color = blocks.useSeverityColor(severity);
12144
+ const value = truthyValues.includes(fieldProps.value);
12145
+ return /* @__PURE__ */ jsxRuntime.jsx(InputWithLabelAndHelpText, { helpText, severity, children: /* @__PURE__ */ jsxRuntime.jsx(
12146
+ InputWithLabel,
12147
+ {
12148
+ size,
12149
+ severity,
12150
+ inputId,
12151
+ labelId,
12152
+ label,
12153
+ image: showInputOnly ? void 0 : field.image,
12154
+ flexProps: { direction: "row-reverse", justify: "end", align: "center", gap: "2" },
12155
+ children: /* @__PURE__ */ jsxRuntime.jsx(
12156
+ Checkbox,
12157
+ {
12158
+ ...rest,
12159
+ ...fieldProps,
12160
+ id: inputId,
12161
+ color,
12162
+ value: value.toString(),
12163
+ checked: value,
12164
+ onCheckedChange: fieldProps.onChange,
12165
+ onChange: void 0,
12166
+ onBlur: void 0
12167
+ }
12168
+ )
12169
+ }
12170
+ ) });
12171
+ });
12172
+ BooleanInput.displayName = "BooleanInput";
12173
+ var DefaultContext = {
12174
+ color: void 0,
12175
+ size: void 0,
12176
+ className: void 0,
12177
+ style: void 0,
12178
+ attr: void 0
12179
+ };
12180
+ var IconContext = React.createContext && /* @__PURE__ */ React.createContext(DefaultContext);
12181
+ var _excluded = ["attr", "size", "title"];
12182
+ function _objectWithoutProperties(source, excluded) {
12183
+ if (source == null)
12184
+ return {};
12185
+ var target = _objectWithoutPropertiesLoose(source, excluded);
12186
+ var key, i;
12187
+ if (Object.getOwnPropertySymbols) {
12188
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
12189
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
12190
+ key = sourceSymbolKeys[i];
12191
+ if (excluded.indexOf(key) >= 0)
12192
+ continue;
12193
+ if (!Object.prototype.propertyIsEnumerable.call(source, key))
12194
+ continue;
12195
+ target[key] = source[key];
12196
+ }
12197
+ }
12198
+ return target;
12199
+ }
12200
+ function _objectWithoutPropertiesLoose(source, excluded) {
12201
+ if (source == null)
12202
+ return {};
12203
+ var target = {};
12204
+ for (var key in source) {
12205
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
12206
+ if (excluded.indexOf(key) >= 0)
12207
+ continue;
12208
+ target[key] = source[key];
12209
+ }
12210
+ }
12211
+ return target;
12212
+ }
12213
+ function _extends() {
12214
+ _extends = Object.assign ? Object.assign.bind() : function(target) {
12215
+ for (var i = 1; i < arguments.length; i++) {
12216
+ var source = arguments[i];
12217
+ for (var key in source) {
12218
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
12219
+ target[key] = source[key];
12220
+ }
12221
+ }
12222
+ }
12223
+ return target;
12224
+ };
12225
+ return _extends.apply(this, arguments);
12226
+ }
12227
+ function ownKeys(e, r) {
12228
+ var t = Object.keys(e);
12229
+ if (Object.getOwnPropertySymbols) {
12230
+ var o = Object.getOwnPropertySymbols(e);
12231
+ r && (o = o.filter(function(r2) {
12232
+ return Object.getOwnPropertyDescriptor(e, r2).enumerable;
12233
+ })), t.push.apply(t, o);
12234
+ }
12235
+ return t;
12236
+ }
12237
+ function _objectSpread(e) {
12238
+ for (var r = 1; r < arguments.length; r++) {
12239
+ var t = null != arguments[r] ? arguments[r] : {};
12240
+ r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
12241
+ _defineProperty(e, r2, t[r2]);
12242
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
12243
+ Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
12244
+ });
12245
+ }
12246
+ return e;
12247
+ }
12248
+ function _defineProperty(obj, key, value) {
12249
+ key = _toPropertyKey(key);
12250
+ if (key in obj) {
12251
+ Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
12252
+ } else {
12253
+ obj[key] = value;
12254
+ }
12255
+ return obj;
12256
+ }
12257
+ function _toPropertyKey(t) {
12258
+ var i = _toPrimitive(t, "string");
12259
+ return "symbol" == typeof i ? i : i + "";
12260
+ }
12261
+ function _toPrimitive(t, r) {
12262
+ if ("object" != typeof t || !t)
12263
+ return t;
12264
+ var e = t[Symbol.toPrimitive];
12265
+ if (void 0 !== e) {
12266
+ var i = e.call(t, r || "default");
12267
+ if ("object" != typeof i)
12268
+ return i;
12269
+ throw new TypeError("@@toPrimitive must return a primitive value.");
12270
+ }
12271
+ return ("string" === r ? String : Number)(t);
12272
+ }
12273
+ function Tree2Element(tree) {
12274
+ return tree && tree.map((node, i) => /* @__PURE__ */ React.createElement(node.tag, _objectSpread({
12275
+ key: i
12276
+ }, node.attr), Tree2Element(node.child)));
12277
+ }
12278
+ function GenIcon(data) {
12279
+ return (props) => /* @__PURE__ */ React.createElement(IconBase, _extends({
12280
+ attr: _objectSpread({}, data.attr)
12281
+ }, props), Tree2Element(data.child));
12282
+ }
12283
+ function IconBase(props) {
12284
+ var elem = (conf) => {
12285
+ var {
12286
+ attr,
12287
+ size,
12288
+ title: title2
12289
+ } = props, svgProps = _objectWithoutProperties(props, _excluded);
12290
+ var computedSize = size || conf.size || "1em";
12291
+ var className;
12292
+ if (conf.className)
12293
+ className = conf.className;
12294
+ if (props.className)
12295
+ className = (className ? className + " " : "") + props.className;
12296
+ return /* @__PURE__ */ React.createElement("svg", _extends({
12297
+ stroke: "currentColor",
12298
+ fill: "currentColor",
12299
+ strokeWidth: "0"
12300
+ }, conf.attr, attr, svgProps, {
12301
+ className,
12302
+ style: _objectSpread(_objectSpread({
12303
+ color: props.color || conf.color
12304
+ }, conf.style), props.style),
12305
+ height: computedSize,
12306
+ width: computedSize,
12307
+ xmlns: "http://www.w3.org/2000/svg"
12308
+ }), title2 && /* @__PURE__ */ React.createElement("title", null, title2), props.children);
12309
+ };
12310
+ return IconContext !== void 0 ? /* @__PURE__ */ React.createElement(IconContext.Consumer, null, (conf) => elem(conf)) : elem(DefaultContext);
12311
+ }
12312
+ function RiArrowDownLine(props) {
12313
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M13.0001 16.1716L18.3641 10.8076L19.7783 12.2218L12.0001 20L4.22192 12.2218L5.63614 10.8076L11.0001 16.1716V4H13.0001V16.1716Z" }, "child": [] }] })(props);
12314
+ }
12315
+ function RiArrowUpLine(props) {
12316
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M13.0001 7.82843V20H11.0001V7.82843L5.63614 13.1924L4.22192 11.7782L12.0001 4L19.7783 11.7782L18.3641 13.1924L13.0001 7.82843Z" }, "child": [] }] })(props);
12317
+ }
12318
+ function RiCalendarLine(props) {
12319
+ 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);
12320
+ }
12321
+ function RiQrCodeLine(props) {
12322
+ 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);
12323
+ }
12324
+ function RiFileCopyLine(props) {
12325
+ 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);
12326
+ }
12327
+ function RiAlignJustify(props) {
12328
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z" }, "child": [] }] })(props);
12329
+ }
12330
+ function RiHashtag(props) {
12331
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M7.78428 14L8.2047 10H4V8H8.41491L8.94043 3H10.9514L10.4259 8H14.4149L14.9404 3H16.9514L16.4259 8H20V10H16.2157L15.7953 14H20V16H15.5851L15.0596 21H13.0486L13.5741 16H9.58509L9.05957 21H7.04855L7.57407 16H4V14H7.78428ZM9.7953 14H13.7843L14.2047 10H10.2157L9.7953 14Z" }, "child": [] }] })(props);
12332
+ }
12333
+ function RiInputField(props) {
12334
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M8 5H11V19H8V21H16V19H13V5H16V3H8V5ZM2 7C1.44772 7 1 7.44772 1 8V16C1 16.5523 1.44772 17 2 17H8V15H3V9H8V7H2ZM16 9H21V15H16V17H22C22.5523 17 23 16.5523 23 16V8C23 7.44772 22.5523 7 22 7H16V9Z" }, "child": [] }] })(props);
12335
+ }
12336
+ function RiListCheck(props) {
12337
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M8 4H21V6H8V4ZM3 3.5H6V6.5H3V3.5ZM3 10.5H6V13.5H3V10.5ZM3 17.5H6V20.5H3V17.5ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z" }, "child": [] }] })(props);
12338
+ }
12339
+ function RiImageLine(props) {
12340
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M2.9918 21C2.44405 21 2 20.5551 2 20.0066V3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918ZM20 15V5H4V19L14 9L20 15ZM20 17.8284L14 11.8284L6.82843 19H20V17.8284ZM8 11C6.89543 11 6 10.1046 6 9C6 7.89543 6.89543 7 8 7C9.10457 7 10 7.89543 10 9C10 10.1046 9.10457 11 8 11Z" }, "child": [] }] })(props);
12341
+ }
12342
+ function RiCheckboxCircleLine(props) {
12343
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11.0026 16L6.75999 11.7574L8.17421 10.3431L11.0026 13.1716L16.6595 7.51472L18.0737 8.92893L11.0026 16Z" }, "child": [] }] })(props);
12344
+ }
12345
+ function RiCheckboxLine(props) {
12346
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM5 5V19H19V5H5ZM11.0026 16L6.75999 11.7574L8.17421 10.3431L11.0026 13.1716L16.6595 7.51472L18.0737 8.92893L11.0026 16Z" }, "child": [] }] })(props);
12347
+ }
12348
+ function RiDeleteBin2Line(props) {
12349
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM13.4142 13.9997L15.182 15.7675L13.7678 17.1817L12 15.4139L10.2322 17.1817L8.81802 15.7675L10.5858 13.9997L8.81802 12.232L10.2322 10.8178L12 12.5855L13.7678 10.8178L15.182 12.232L13.4142 13.9997ZM9 4V6H15V4H9Z" }, "child": [] }] })(props);
12350
+ }
12351
+ function RiMenuFoldLine(props) {
12352
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M21 17.9995V19.9995H3V17.9995H21ZM6.59619 3.90332L8.01041 5.31753L4.82843 8.49951L8.01041 11.6815L6.59619 13.0957L2 8.49951L6.59619 3.90332ZM21 10.9995V12.9995H12V10.9995H21ZM21 3.99951V5.99951H12V3.99951H21Z" }, "child": [] }] })(props);
12353
+ }
12354
+ function RiUpload2Line(props) {
12355
+ return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M4 19H20V12H22V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V12H4V19ZM13 9V16H11V9H6L12 3L18 9H13Z" }, "child": [] }] })(props);
12356
+ }
12357
+ const emptyBooleanField = {
12358
+ ...emptyBaseField,
12359
+ type: "boolean"
12360
+ };
12361
+ const _BooleanField = class _BooleanField extends BaseField {
12362
+ constructor(options) {
12363
+ super({ ...options, type: "boolean" });
12364
+ __publicField(this, "onlyValidateAfterTouched", false);
12365
+ }
12366
+ // if a BooleanField is required, `false` is considered blank
12367
+ isBlank(value) {
12368
+ return this.required && !value;
12369
+ }
12370
+ getValueFromChangeEvent(event) {
12371
+ if (typeof event === "boolean")
12372
+ return event;
12373
+ return event.target.checked;
12374
+ }
12375
+ serialize() {
12376
+ return super._serialize();
12377
+ }
12378
+ static deserialize(data) {
12379
+ if (data.type !== "boolean")
12380
+ throw new Error("Type mismatch.");
12381
+ return new _BooleanField(data);
12382
+ }
12383
+ getInput(props) {
12384
+ return /* @__PURE__ */ jsxRuntime.jsx(BooleanInput, { ...props, field: this });
12385
+ }
12386
+ };
12387
+ __publicField(_BooleanField, "fieldTypeName", "Checkbox");
12388
+ __publicField(_BooleanField, "fieldTypeDescription", "Perfect for both optional and required yes/no questions.");
12389
+ __publicField(_BooleanField, "Icon", RiCheckboxCircleLine);
12390
+ let BooleanField = _BooleanField;
12293
12391
  const NumberInput = React.memo((props) => {
12294
12392
  const [{ inputId, labelId, size, severity, showInputOnly, field, fieldProps }, rest] = useFormikInput(props);
12295
12393
  let [{ helpText, label }] = useFormikInput(props);
@@ -13395,7 +13493,7 @@ var __publicField = (obj, key, value) => {
13395
13493
  ] }),
13396
13494
  value && /* @__PURE__ */ jsxRuntime.jsx(Text, { color: "jade", size: "1", children: /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiCheckLine", style: { verticalAlign: "bottom" } }) })
13397
13495
  ] }),
13398
- value && /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { width: "max-content", gap: "2", align: "center", children: [
13496
+ !!value && /* @__PURE__ */ jsxRuntime.jsx(Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(Flex, { width: "max-content", gap: "2", align: "center", children: [
13399
13497
  /* @__PURE__ */ jsxRuntime.jsx(Code, { color: "gray", highContrast: true, children: value }),
13400
13498
  /* @__PURE__ */ jsxRuntime.jsx(
13401
13499
  blocks.IconButton,
@@ -13435,9 +13533,7 @@ var __publicField = (obj, key, value) => {
13435
13533
  }
13436
13534
  );
13437
13535
  setIsScannerLoading(true);
13438
- qrScanner.start().then(() => {
13439
- setIsScannerLoading(false);
13440
- }).catch(() => {
13536
+ void qrScanner.start().finally(() => {
13441
13537
  setIsScannerLoading(false);
13442
13538
  });
13443
13539
  }, [onQrScan]);
@@ -16598,7 +16694,7 @@ var __publicField = (obj, key, value) => {
16598
16694
  }, Symbol.toStringTag, { value: "Module" }));
16599
16695
  exports2.APIError = APIError;
16600
16696
  exports2.AgentService = AgentService;
16601
- exports2.AttachmentService = AttachmentService;
16697
+ exports2.AttachmentModel = AttachmentModel;
16602
16698
  exports2.AuthService = AuthService;
16603
16699
  exports2.BaseApiService = BaseApiService;
16604
16700
  exports2.BaseField = BaseField;
@@ -16609,15 +16705,18 @@ var __publicField = (obj, key, value) => {
16609
16705
  exports2.ColorPicker = ColorPicker;
16610
16706
  exports2.Colors = Colors;
16611
16707
  exports2.ColorsToString = ColorsToString;
16708
+ exports2.ComponentAttachmentService = ComponentAttachmentService;
16612
16709
  exports2.ComponentService = ComponentService;
16613
16710
  exports2.ComponentStageColors = ComponentStageColors;
16614
16711
  exports2.ComponentStageCompletionService = ComponentStageCompletionService;
16615
16712
  exports2.ComponentStageService = ComponentStageService;
16713
+ exports2.ComponentTypeAttachmentService = ComponentTypeAttachmentService;
16616
16714
  exports2.ComponentTypeService = ComponentTypeService;
16617
16715
  exports2.DEFAULT_ISSUE_PRIORITY = DEFAULT_ISSUE_PRIORITY;
16618
16716
  exports2.DEFAULT_ISSUE_STATUS = DEFAULT_ISSUE_STATUS;
16619
16717
  exports2.DateField = DateField;
16620
16718
  exports2.DateInput = DateInput;
16719
+ exports2.DocumentAttachmentService = DocumentAttachmentService;
16621
16720
  exports2.DocumentService = DocumentService;
16622
16721
  exports2.EmailDomainsService = EmailDomainsService;
16623
16722
  exports2.EmailVerificationService = EmailVerificationService;
@@ -16641,6 +16740,7 @@ var __publicField = (obj, key, value) => {
16641
16740
  exports2.InputWithHelpText = InputWithHelpText;
16642
16741
  exports2.InputWithLabel = InputWithLabel;
16643
16742
  exports2.InputWithLabelAndHelpText = InputWithLabelAndHelpText;
16743
+ exports2.IssueAttachmentService = IssueAttachmentService;
16644
16744
  exports2.IssueCommentService = IssueCommentService;
16645
16745
  exports2.IssuePriority = IssuePriority;
16646
16746
  exports2.IssueService = IssueService;
@@ -16673,6 +16773,7 @@ var __publicField = (obj, key, value) => {
16673
16773
  exports2.PatchFormProvider = PatchFormProvider;
16674
16774
  exports2.ProjectAccessLevel = ProjectAccessLevel;
16675
16775
  exports2.ProjectAccessService = ProjectAccessService;
16776
+ exports2.ProjectAttachmentService = ProjectAttachmentService;
16676
16777
  exports2.ProjectFileService = ProjectFileService;
16677
16778
  exports2.ProjectService = ProjectService;
16678
16779
  exports2.ProjectType = ProjectType;
@@ -16907,6 +17008,7 @@ var __publicField = (obj, key, value) => {
16907
17008
  exports2.removeFavouriteProjectId = removeFavouriteProjectId;
16908
17009
  exports2.removeIssue = removeIssue;
16909
17010
  exports2.removeIssueAttachment = removeIssueAttachment;
17011
+ exports2.removeIssueAttachments = removeIssueAttachments;
16910
17012
  exports2.removeIssueComment = removeIssueComment;
16911
17013
  exports2.removeIssueComments = removeIssueComments;
16912
17014
  exports2.removeIssueType = removeIssueType;
@@ -17084,6 +17186,7 @@ var __publicField = (obj, key, value) => {
17084
17186
  exports2.selectProjectAccessForUser = selectProjectAccessForUser;
17085
17187
  exports2.selectProjectAccessUserMapping = selectProjectAccessUserMapping;
17086
17188
  exports2.selectProjectAccesses = selectProjectAccesses;
17189
+ exports2.selectProjectAttachment = selectProjectAttachment;
17087
17190
  exports2.selectProjectAttachmentMapping = selectProjectAttachmentMapping;
17088
17191
  exports2.selectProjectFileVisibility = selectProjectFileVisibility;
17089
17192
  exports2.selectProjectFiles = selectProjectFiles;
@@ -17133,7 +17236,9 @@ var __publicField = (obj, key, value) => {
17133
17236
  exports2.setAppearance = setAppearance;
17134
17237
  exports2.setCategories = setCategories;
17135
17238
  exports2.setCenterMapToProject = setCenterMapToProject;
17239
+ exports2.setComponentAttachment = setComponentAttachment;
17136
17240
  exports2.setComponentAttachments = setComponentAttachments;
17241
+ exports2.setComponentTypeAttachment = setComponentTypeAttachment;
17137
17242
  exports2.setComponentTypeAttachments = setComponentTypeAttachments;
17138
17243
  exports2.setComponentTypes = setComponentTypes;
17139
17244
  exports2.setComponents = setComponents;
@@ -17141,6 +17246,7 @@ var __publicField = (obj, key, value) => {
17141
17246
  exports2.setConversations = setConversations;
17142
17247
  exports2.setCreateProjectType = setCreateProjectType;
17143
17248
  exports2.setCurrentUser = setCurrentUser;
17249
+ exports2.setDocumentAttachment = setDocumentAttachment;
17144
17250
  exports2.setDocumentAttachments = setDocumentAttachments;
17145
17251
  exports2.setDocuments = setDocuments;
17146
17252
  exports2.setEmailDomains = setEmailDomains;
@@ -17157,6 +17263,7 @@ var __publicField = (obj, key, value) => {
17157
17263
  exports2.setIsFetchingInitialData = setIsFetchingInitialData;
17158
17264
  exports2.setIsImportingProjectFile = setIsImportingProjectFile;
17159
17265
  exports2.setIsLoading = setIsLoading;
17266
+ exports2.setIssueAttachment = setIssueAttachment;
17160
17267
  exports2.setIssueAttachments = setIssueAttachments;
17161
17268
  exports2.setIssueComment = setIssueComment;
17162
17269
  exports2.setIssueComments = setIssueComments;
@@ -17171,6 +17278,7 @@ var __publicField = (obj, key, value) => {
17171
17278
  exports2.setOrganizations = setOrganizations;
17172
17279
  exports2.setProfilePicture = setProfilePicture;
17173
17280
  exports2.setProjectAccesses = setProjectAccesses;
17281
+ exports2.setProjectAttachment = setProjectAttachment;
17174
17282
  exports2.setProjectAttachments = setProjectAttachments;
17175
17283
  exports2.setProjectFileVisible = setProjectFileVisible;
17176
17284
  exports2.setProjects = setProjects;
@@ -17205,21 +17313,26 @@ var __publicField = (obj, key, value) => {
17205
17313
  exports2.updateActiveOrganization = updateActiveOrganization;
17206
17314
  exports2.updateComponent = updateComponent;
17207
17315
  exports2.updateComponentAttachment = updateComponentAttachment;
17316
+ exports2.updateComponentAttachments = updateComponentAttachments;
17208
17317
  exports2.updateComponentTypeAttachment = updateComponentTypeAttachment;
17318
+ exports2.updateComponentTypeAttachments = updateComponentTypeAttachments;
17209
17319
  exports2.updateConversation = updateConversation;
17210
17320
  exports2.updateDocumentAttachment = updateDocumentAttachment;
17321
+ exports2.updateDocumentAttachments = updateDocumentAttachments;
17211
17322
  exports2.updateDocuments = updateDocuments;
17212
17323
  exports2.updateFormSubmission = updateFormSubmission;
17213
17324
  exports2.updateFormSubmissionAttachments = updateFormSubmissionAttachments;
17214
17325
  exports2.updateFormSubmissions = updateFormSubmissions;
17215
17326
  exports2.updateIssue = updateIssue;
17216
17327
  exports2.updateIssueAttachment = updateIssueAttachment;
17328
+ exports2.updateIssueAttachments = updateIssueAttachments;
17217
17329
  exports2.updateIssueType = updateIssueType;
17218
17330
  exports2.updateLicense = updateLicense;
17219
17331
  exports2.updateOrCreateProject = updateOrCreateProject;
17220
17332
  exports2.updateOrganizationAccess = updateOrganizationAccess;
17221
17333
  exports2.updateProjectAccess = updateProjectAccess;
17222
17334
  exports2.updateProjectAttachment = updateProjectAttachment;
17335
+ exports2.updateProjectAttachments = updateProjectAttachments;
17223
17336
  exports2.updateStages = updateStages;
17224
17337
  exports2.updateTeam = updateTeam;
17225
17338
  exports2.useAppDispatch = useAppDispatch;