@overmap-ai/core 1.0.74-procedures.3 → 1.0.74-standardizations.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/dist/overmap-core.js +4153 -4035
  2. package/dist/overmap-core.umd.cjs +8 -8
  3. package/dist/sdk/services/AgentService.d.ts +6 -6
  4. package/dist/sdk/services/AssetAttachmentService.d.ts +9 -9
  5. package/dist/sdk/services/AssetProcedureFieldValuesAttachmentService.d.ts +4 -4
  6. package/dist/sdk/services/AssetProcedureFieldValuesService.d.ts +7 -7
  7. package/dist/sdk/services/AssetProcedureFieldsAttachmentService.d.ts +3 -3
  8. package/dist/sdk/services/AssetProcedureFieldsService.d.ts +2 -2
  9. package/dist/sdk/services/AssetProcedureInstanceService.d.ts +4 -4
  10. package/dist/sdk/services/AssetProcedureService.d.ts +4 -4
  11. package/dist/sdk/services/AssetService.d.ts +5 -5
  12. package/dist/sdk/services/AssetStageCompletionService.d.ts +4 -4
  13. package/dist/sdk/services/AssetStageService.d.ts +6 -6
  14. package/dist/sdk/services/AssetTypeAttachmentService.d.ts +9 -9
  15. package/dist/sdk/services/AssetTypeFieldValuesAttachmentService.d.ts +4 -4
  16. package/dist/sdk/services/AssetTypeFieldValuesService.d.ts +6 -6
  17. package/dist/sdk/services/AssetTypeFieldsAttachmentService.d.ts +3 -3
  18. package/dist/sdk/services/AssetTypeFieldsService.d.ts +2 -2
  19. package/dist/sdk/services/AssetTypeService.d.ts +4 -4
  20. package/dist/sdk/services/BaseAttachmentService.d.ts +12 -12
  21. package/dist/sdk/services/CategoryService.d.ts +4 -4
  22. package/dist/sdk/services/DocumentAttachmentService.d.ts +9 -9
  23. package/dist/sdk/services/DocumentService.d.ts +5 -5
  24. package/dist/sdk/services/EmailDomainsService.d.ts +3 -3
  25. package/dist/sdk/services/FormRevisionAttachmentService.d.ts +3 -3
  26. package/dist/sdk/services/FormRevisionService.d.ts +2 -2
  27. package/dist/sdk/services/FormService.d.ts +3 -3
  28. package/dist/sdk/services/FormSubmissionAttachmentService.d.ts +4 -4
  29. package/dist/sdk/services/FormSubmissionService.d.ts +4 -4
  30. package/dist/sdk/services/GeoImageService.d.ts +5 -5
  31. package/dist/sdk/services/IssueAssociationService.d.ts +3 -3
  32. package/dist/sdk/services/IssueAttachmentService.d.ts +9 -9
  33. package/dist/sdk/services/IssueCommentAttachmentService.d.ts +9 -9
  34. package/dist/sdk/services/IssueCommentService.d.ts +4 -4
  35. package/dist/sdk/services/IssueService.d.ts +4 -4
  36. package/dist/sdk/services/IssueTypeAttachmentService.d.ts +9 -9
  37. package/dist/sdk/services/IssueTypeFieldValuesAttachmentService.d.ts +4 -4
  38. package/dist/sdk/services/IssueTypeFieldValuesService.d.ts +4 -4
  39. package/dist/sdk/services/IssueTypeFieldsAttachmentService.d.ts +3 -3
  40. package/dist/sdk/services/IssueTypeFieldsService.d.ts +2 -2
  41. package/dist/sdk/services/IssueTypeService.d.ts +4 -4
  42. package/dist/sdk/services/IssueUpdateService.d.ts +2 -2
  43. package/dist/sdk/services/LicenseService.d.ts +2 -2
  44. package/dist/sdk/services/OrganizationAccessService.d.ts +2 -5
  45. package/dist/sdk/services/OrganizationService.d.ts +3 -3
  46. package/dist/sdk/services/ProjectAccessService.d.ts +3 -6
  47. package/dist/sdk/services/ProjectAttachmentService.d.ts +11 -11
  48. package/dist/sdk/services/ProjectFileService.d.ts +3 -3
  49. package/dist/sdk/services/ProjectService.d.ts +5 -5
  50. package/dist/sdk/services/TeamService.d.ts +7 -7
  51. package/dist/sdk/services/UserService.d.ts +2 -2
  52. package/dist/store/adapters/index.d.ts +2 -0
  53. package/dist/store/adapters/modelAdapter.d.ts +15 -0
  54. package/dist/store/adapters/selectionAdapter.d.ts +13 -0
  55. package/dist/store/index.d.ts +1 -1
  56. package/dist/store/slices/agentsSlice.d.ts +8 -9
  57. package/dist/store/slices/assetAttachmentSlice.d.ts +20 -15
  58. package/dist/store/slices/assetProcedureFieldValuesAttachmentSlice.d.ts +20 -15
  59. package/dist/store/slices/assetProcedureFieldValuesSlice.d.ts +21 -16
  60. package/dist/store/slices/assetProcedureFieldsAttachmentSlice.d.ts +19 -14
  61. package/dist/store/slices/assetProcedureFieldsSlice.d.ts +21 -16
  62. package/dist/store/slices/assetProcedureInstanceSlice.d.ts +21 -16
  63. package/dist/store/slices/assetProcedureSlice.d.ts +20 -15
  64. package/dist/store/slices/assetSlice.d.ts +21 -16
  65. package/dist/store/slices/assetStageCompletionSlice.d.ts +16 -11
  66. package/dist/store/slices/assetStageSlice.d.ts +24 -19
  67. package/dist/store/slices/assetTypeAttachmentSlice.d.ts +20 -15
  68. package/dist/store/slices/assetTypeFieldValuesAttachmentSlice.d.ts +20 -15
  69. package/dist/store/slices/assetTypeFieldValuesSlice.d.ts +21 -16
  70. package/dist/store/slices/assetTypeFieldsAttachmentSlice.d.ts +20 -15
  71. package/dist/store/slices/assetTypeFieldsSlice.d.ts +21 -16
  72. package/dist/store/slices/assetTypeSlice.d.ts +18 -13
  73. package/dist/store/slices/authSlice.d.ts +3 -3
  74. package/dist/store/slices/categorySlice.d.ts +10 -8
  75. package/dist/store/slices/documentAttachmentSlice.d.ts +20 -15
  76. package/dist/store/slices/documentSlice.d.ts +4 -5
  77. package/dist/store/slices/emailDomainsSlice.d.ts +11 -9
  78. package/dist/store/slices/fileSlice.d.ts +2 -2
  79. package/dist/store/slices/formRevisionAttachmentSlice.d.ts +19 -14
  80. package/dist/store/slices/formRevisionSlice.d.ts +18 -13
  81. package/dist/store/slices/formSlice.d.ts +14 -16
  82. package/dist/store/slices/formSubmissionAttachmentSlice.d.ts +19 -14
  83. package/dist/store/slices/formSubmissionSlice.d.ts +20 -15
  84. package/dist/store/slices/geoImageSlice.d.ts +20 -15
  85. package/dist/store/slices/issueAssociationSlice.d.ts +18 -13
  86. package/dist/store/slices/issueAttachmentSlice.d.ts +18 -13
  87. package/dist/store/slices/issueCommentAttachmentSlice.d.ts +20 -15
  88. package/dist/store/slices/issueCommentSlice.d.ts +15 -10
  89. package/dist/store/slices/issueSlice.d.ts +15 -10
  90. package/dist/store/slices/issueTypeAttachmentSlice.d.ts +20 -15
  91. package/dist/store/slices/issueTypeFieldValuesAttachmentSlice.d.ts +20 -15
  92. package/dist/store/slices/issueTypeFieldValuesSlice.d.ts +20 -15
  93. package/dist/store/slices/issueTypeFieldsAttachmentSlice.d.ts +20 -15
  94. package/dist/store/slices/issueTypeFieldsSlice.d.ts +22 -17
  95. package/dist/store/slices/issueTypeSlice.d.ts +15 -13
  96. package/dist/store/slices/issueUpdateSlice.d.ts +14 -9
  97. package/dist/store/slices/licenseSlice.d.ts +8 -9
  98. package/dist/store/slices/organizationAccessSlice.d.ts +10 -8
  99. package/dist/store/slices/organizationSlice.d.ts +45 -11
  100. package/dist/store/slices/outboxSlice.d.ts +2 -2
  101. package/dist/store/slices/projectAccessSlice.d.ts +13 -8
  102. package/dist/store/slices/projectAttachmentSlice.d.ts +19 -14
  103. package/dist/store/slices/projectFileSlice.d.ts +19 -14
  104. package/dist/store/slices/projectSlice.d.ts +42 -17
  105. package/dist/store/slices/rehydratedSlice.d.ts +2 -2
  106. package/dist/store/slices/teamSlice.d.ts +13 -11
  107. package/dist/store/slices/userSlice.d.ts +47 -10
  108. package/dist/store/slices/versioningSlice.d.ts +1 -2
  109. package/dist/store/store.d.ts +53 -54
  110. package/dist/store/typings.d.ts +5 -2
  111. package/dist/typings/models/agents.d.ts +2 -2
  112. package/dist/typings/models/assets.d.ts +19 -19
  113. package/dist/typings/models/attachments.d.ts +3 -3
  114. package/dist/typings/models/base.d.ts +12 -8
  115. package/dist/typings/models/categories.d.ts +3 -3
  116. package/dist/typings/models/documents.d.ts +4 -4
  117. package/dist/typings/models/emailDomain.d.ts +3 -3
  118. package/dist/typings/models/emailVerification.d.ts +5 -5
  119. package/dist/typings/models/forms.d.ts +8 -8
  120. package/dist/typings/models/geoImages.d.ts +4 -3
  121. package/dist/typings/models/index.d.ts +0 -1
  122. package/dist/typings/models/issueTypes.d.ts +3 -3
  123. package/dist/typings/models/issues.d.ts +13 -13
  124. package/dist/typings/models/license.d.ts +3 -3
  125. package/dist/typings/models/organizations.d.ts +9 -3
  126. package/dist/typings/models/projects.d.ts +11 -5
  127. package/dist/typings/models/teams.d.ts +4 -4
  128. package/dist/typings/models/users.d.ts +2 -4
  129. package/dist/utils/offline.d.ts +3 -3
  130. package/dist/utils/utils.d.ts +2 -2
  131. package/package.json +5 -5
  132. package/dist/store/adapter.d.ts +0 -15
  133. package/dist/typings/models/access.d.ts +0 -12
@@ -1,15 +1,15 @@
1
- (function(i,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("uuid"),require("@reduxjs/toolkit"),require("file-saver"),require("@redux-offline/redux-offline"),require("@redux-offline/redux-offline/lib/defaults"),require("localforage"),require("redux-persist-migrate"),require("superagent"),require("dependency-graph"),require("idb"),require("@redux-offline/redux-offline/lib/constants"),require("jwt-decode")):typeof define=="function"&&define.amd?define(["exports","uuid","@reduxjs/toolkit","file-saver","@redux-offline/redux-offline","@redux-offline/redux-offline/lib/defaults","localforage","redux-persist-migrate","superagent","dependency-graph","idb","@redux-offline/redux-offline/lib/constants","jwt-decode"],O):(i=typeof globalThis<"u"?globalThis:i||self,O(i["overmap-core"]={},i.uuid,i.toolkit,i.fileSaver,i.reduxOffline,i.offlineConfig,i.localforage,i.createMigration,i.request,i.dependencyGraph,i.idb,i.constants,i.jwtDecode))})(this,function(i,O,u,Cu,Du,Tn,zu,Vu,_e,Uu,$u,Bu,Gu){"use strict";var Wy=Object.defineProperty;var Ky=(i,O,u)=>O in i?Wy(i,O,{enumerable:!0,configurable:!0,writable:!0,value:u}):i[O]=u;var y=(i,O,u)=>Ky(i,typeof O!="symbol"?O+"":O,u);var ku;const _n=Object.freeze([]),Fn=Object.freeze({});var Ft=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(Ft||{}),It=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(It||{}),l=(t=>(t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.DELETE="DELETE",t))(l||{}),In=(t=>(t.Issue="issue",t.Asset="asset",t.AssetType="asset_type",t.Project="project",t.Document="document",t))(In||{}),Rt=(t=>(t[t.LOWEST=0]="LOWEST",t[t.LOW=2]="LOW",t[t.MEDIUM=4]="MEDIUM",t[t.HIGH=6]="HIGH",t[t.HIGHEST=8]="HIGHEST",t))(Rt||{}),Pt=(t=>(t[t.BACKLOG=0]="BACKLOG",t[t.SELECTED=2]="SELECTED",t[t.DONE=4]="DONE",t))(Pt||{}),w=(t=>(t.STATUS="status",t.PRIORITY="priority",t.CATEGORY="category",t.DESCRIPTION="description",t.TITLE="title",t.ASSIGNED_TO="assigned_to",t.DUE_DATE="due_date",t))(w||{}),Rn=(t=>(t.COMPLETED="checkout.completed",t.CLOSED="checkout.closed",t))(Rn||{}),Pn=(t=>(t[t.PRO=0]="PRO",t))(Pn||{}),On=(t=>(t[t.ACTIVE=0]="ACTIVE",t[t.PAUSED=2]="PAUSED",t[t.CANCELLED=4]="CANCELLED",t[t.INACTIVE=6]="INACTIVE",t[t.PAST_DUE=8]="PAST_DUE",t))(On||{});const Lu=Pt.BACKLOG,Nu=Rt.MEDIUM,vn=6e4;function I(t){return{addOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},addMany:(f,p)=>{for(const A of p.payload){const T=t(A);f.instances[T]=A}},setOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},setMany:(f,p)=>{for(const A of p.payload){const T=t(A);f.instances[T]=A}},updateOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},updateMany:(f,p)=>{for(const A of p.payload){const T=t(A);f.instances[T]=A}},deleteOne:(f,p)=>{delete f.instances[p.payload]},deleteMany:(f,p)=>{for(const A of p.payload)delete f.instances[A]},initialize:(f,p)=>{f.instances={};for(const A of p.payload){const T=t(A);f.instances[T]=A}},getInitialState:f=>({...f,instances:{}})}}ku=Symbol.toStringTag;class wn{constructor(){y(this,ku,"Promise");y(this,"_promise");y(this,"_resolve");y(this,"_reject");y(this,"_state","pending");this._resolve=null,this._reject=null,this._promise=new Promise((e,s)=>{this._resolve=e,this._reject=s})}get state(){return this._state}then(e,s){return this._promise.then(e,s)}catch(e){return this._promise.catch(e)}resolve(e){if(!this._resolve)throw new Error("No resolve callback");this._resolve(e),this._state="fulfilled"}reject(e){if(!this._reject)throw e;this._reject(e),this._state="rejected"}finally(e){throw new Error("`finally` not implemented")}}const Hu=t=>({type:"Point",coordinates:t}),Wu=t=>({type:"MultiPoint",coordinates:t}),Ku=(t,e)=>t[0]===e[0]&&t[1]===e[1];let Ot=!1;["true","1"].includes("".toLowerCase())&&(Ot=!0);function Yu(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;const s=Object.keys(t),n=Object.keys(e),a=s.length;if(a!==n.length)return!1;for(let c=0;c<a;c++){const r=s[c];if(!Object.prototype.hasOwnProperty.call(e,r)||t[r]!==e[r])return!1}return!0}function vt(t){const e={};return function(){const s=Array.prototype.slice.call(arguments);return s in e?(Ot&&console.debug(`Memoization debug: Using memorized return value for ${t.toString()}(`,s,")"),e[s]):(Ot&&console.debug(`Memoization debug: Cache miss! Memoizing ${t.toString()}(`,s,")"),e[s]=t.apply(this,s))}}function Ju(t,e){if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}const g=t=>t.length===0?_n:t,Fe=t=>Object.keys(t).length===0?Fn:t,En=vt(t=>{if(!t)return"";const e=new Date(t),s=e.getFullYear()===wt.getFullYear(),n={day:"numeric",month:"short"};return s||(n.year="numeric"),e.toLocaleDateString([],n)}),Xu=new Intl.RelativeTimeFormat([],{style:"long",numeric:"auto"}),Qu=1e3*86400,wt=new Date,Zu=t=>new Date(t).toDateString()===wt.toDateString(),xu=vt((t,e,s)=>{const n=Math.round((new Date(t).getTime()-wt.getTime())/Qu);return n<e||n>s?En(t):Xu.format(n,"days")});function eh(t){return new Uint8Array(t).reduce((s,n)=>s+n.toString(16).padStart(2,"0"),"")}const Et=async(t,e)=>{e||(e=await Ie(t));let s=t.type;if(s.includes("/")&&(s=s.split("/")[1]),!s)throw new Error(`Could not extract file type from ${t.type}`);return`${e}.${s}`};function Ie(t){return new Promise((e,s)=>{const n=new FileReader;n.onload=()=>{const a=n.result;if(!a){s(new Error("FileReader did not return a valid ArrayBuffer."));return}crypto.subtle.digest("SHA-1",a).then(c=>{const r=eh(c);e(r)})},n.readAsArrayBuffer(t)})}function th(t){if(!t.name||!t.type||!t.size){const e="File has no name, type, and/or size";throw new Error(e)}return`${t.name}&${t.type}${t.size}`}function jn(t,e){return new File([t],e,{type:t.type})}function sh(t,e){const s=document.createElement("a");s.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(e)),s.setAttribute("download",t),s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)}const ih=async t=>{const e={};for(const s of t){const n=await Ie(s);e[n]={sha1:n,extension:s.name.split(".").pop()||"",file_type:s.type,size:s.size}}return Object.values(e)},qn=async t=>(await fetch(t)).blob(),nh=t=>new Promise((e,s)=>{const n=new FileReader;n.onloadend=()=>{var a;e(((a=n.result)==null?void 0:a.toString())||"")},n.readAsDataURL(t)});function ah(t){const e=new Blob([t]);Cu.saveAs(e,t.name)}const Mn={};function ch(t,e,s,...n){const a=Mn[t];let c=!1;a?a[e]||(a[e]=!0,c=!0):(Mn[t]={[e]:!0},c=!0),c&&console[s](...n)}const kn=["created_at","updated_at","index","revision"];function F(t){return{...t,offline_id:O.v4()}}function Cn(t){const e={};for(const s of t)e[s.offline_id]=s;return e}function rh(t,e=void 0,s=255){let n=t.replace(/[^a-z0-9_\-.]/gi,"_").replace(/_{2,}/g,"_");if(!e){const c=t.split(".");c.length>1&&(e=c[c.length-1])}e&&!e.startsWith(".")&&(e="."+e);const a=e?e.length:0;return n.length+a>s&&(n=n.slice(0,s-a)+(e||"")),n}function dh(t){return t.toLowerCase().replace(" ","-")}function oh(t,e=!1){return t.normalize("NFKD").toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/[-\s]+/g,e?"_":"-")}function lh(t,e){if(t.length<=e)return t;const s=t.slice(0,e-1);return s.slice(0,s.lastIndexOf(" "))+"…"}const S=t=>e=>s=>t(s,e);function Dn(t,e,s){return s.findIndex(n=>n.offline_id===t.offline_id)===e}function uh(t,e,s){return s.findIndex(n=>n.file_sha1===t.file_sha1)===e}const hh=/^.+@.+\..+$/;function v(t){const e={...t};for(const s of kn)s in e&&delete e[s];return e}const Me=I(t=>t.offline_id),zn=Me.getInitialState({}),jt=u.createSlice({name:"agents",initialState:zn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,zn)),reducers:{initializeConversations:Me.initialize,addConversation:Me.addOne,setConversation:Me.setOne,updateConversation:Me.updateOne}}),{initializeConversations:Vn,addConversation:Un,setConversation:$n,updateConversation:Bn}=jt.actions,qt=t=>t.agentsReducer.instances,mh=u.createSelector([qt],t=>Object.values(t)),fh=S(u.createSelector([qt,(t,e)=>e],(t,e)=>t[e])),Gn=jt.reducer,k=I(t=>t.offline_id),Ln=k.getInitialState({}),Mt=u.createSlice({name:"assetAttachments",initialState:Ln,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ln)),reducers:{initializeAssetAttachments:k.initialize,addAssetAttachment:k.addOne,addAssetAttachments:k.addMany,setAssetAttachment:k.setOne,setAssetAttachments:k.setMany,updateAssetAttachment:k.updateOne,updateAssetAttachments:k.updateMany,deleteAssetAttachment:k.deleteOne,deleteAssetAttachments:k.deleteMany}}),{initializeAssetAttachments:kt,addAssetAttachment:ph,addAssetAttachments:Ct,setAssetAttachment:Nn,setAssetAttachments:Ah,updateAssetAttachment:yh,updateAssetAttachments:Hn,deleteAssetAttachment:Wn,deleteAssetAttachments:Dt}=Mt.actions,Kn=t=>t.assetAttachmentReducer.instances,Yn=u.createSelector([Kn],t=>Object.values(t)),Jn=t=>e=>e.assetAttachmentReducer.instances[t],Xn=S(u.createSelector([Yn,(t,e)=>e],(t,e)=>g(t.filter(({asset:s})=>e===s)))),Qn=Mt.reducer,C=I(t=>t.offline_id),Zn=C.getInitialState({}),zt=u.createSlice({name:"assetProcedureFieldsAttachments",initialState:Zn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Zn)),reducers:{initializeAssetProcedureFieldsAttachments:C.initialize,addAssetProcedureFieldsAttachment:C.addOne,addAssetProcedureFieldsAttachments:C.addMany,setAssetProcedureFieldsAttachment:C.setOne,setAssetProcedureFieldsAttachments:C.setMany,updateAssetProcedureFieldsAttachment:C.updateOne,updateAssetProcedureFieldsAttachments:C.updateMany,deleteAssetProcedureFieldsAttachment:C.deleteOne,deleteAssetProcedureFieldsAttachments:C.deleteMany}}),{initializeAssetProcedureFieldsAttachments:xn,addAssetProcedureFieldsAttachment:Sh,addAssetProcedureFieldsAttachments:ea,setAssetProcedureFieldsAttachment:gh,setAssetProcedureFieldsAttachments:bh,updateAssetProcedureFieldsAttachment:Th,updateAssetProcedureFieldsAttachments:ta,deleteAssetProcedureFieldsAttachment:_h,deleteAssetProcedureFieldsAttachments:sa}=zt.actions,ia=t=>t.assetProcedureFieldsAttachmentReducer.instances,na=u.createSelector([ia],t=>Object.values(t)),Fh=S(u.createSelector([na,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),Ih=t=>e=>e.assetProcedureFieldsAttachmentReducer.instances[t],aa=zt.reducer,D=I(t=>t.offline_id),ca=D.getInitialState({}),Vt=u.createSlice({name:"assetProcedureFields",initialState:ca,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ca)),reducers:{initializeAssetProcedureFields:D.initialize,addAssetProcedureFields:D.addOne,addAssetProcedureFieldsMany:D.addMany,setAssetProcedureFields:D.setOne,setAssetProcedureFieldsMany:D.setMany,updateAssetProcedureFields:D.updateOne,updateAssetProcedureFieldsMany:D.updateMany,deleteAssetProcedureFields:D.deleteOne,deleteAssetProcedureFieldsMany:D.deleteMany}}),{initializeAssetProcedureFields:ra,addAssetProcedureFields:da,addAssetProcedureFieldsMany:Rh,setAssetProcedureFields:Ph,setAssetProcedureFieldsMany:Oh,updateAssetProcedureFields:oa,updateAssetProcedureFieldsMany:vh,deleteAssetProcedureFields:la,deleteAssetProcedureFieldsMany:wh}=Vt.actions,ua=t=>t.assetProcedureFieldsReducer.instances,Ut=u.createSelector([ua],t=>Object.values(t)),Eh=S(u.createSelector([Ut,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),jh=S(u.createSelector([Ut,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_procedure===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),qh=t=>e=>e.assetProcedureFieldsReducer.instances[t],ha=Vt.reducer,z=I(t=>t.offline_id),ma=z.getInitialState({}),$t=u.createSlice({name:"assetProcedureFieldValuesAttachments",initialState:ma,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ma)),reducers:{initializeAssetProcedureFieldValuesAttachments:z.initialize,addAssetProcedureFieldValuesAttachment:z.addOne,addAssetProcedureFieldValuesAttachments:z.addMany,setAssetProcedureFieldValuesAttachment:z.setOne,setAssetProcedureFieldValuesAttachments:z.setMany,updateAssetProcedureFieldValuesAttachment:z.updateOne,updateAssetProcedureFieldValuesAttachments:z.updateMany,deleteAssetProcedureFieldValuesAttachment:z.deleteOne,deleteAssetProcedureFieldValuesAttachments:z.deleteMany}}),{initializeAssetProcedureFieldValuesAttachments:fa,addAssetProcedureFieldValuesAttachment:Mh,addAssetProcedureFieldValuesAttachments:Je,setAssetProcedureFieldValuesAttachment:kh,setAssetProcedureFieldValuesAttachments:Ch,updateAssetProcedureFieldValuesAttachment:Dh,updateAssetProcedureFieldValuesAttachments:pa,deleteAssetProcedureFieldValuesAttachment:zh,deleteAssetProcedureFieldValuesAttachments:Xe}=$t.actions,Bt=t=>t.assetProcedureFieldValuesAttachmentReducer.instances,Aa=u.createSelector([Bt],t=>Object.values(t)),Vh=t=>e=>e.assetProcedureFieldValuesAttachmentReducer.instances[t],ya=S(u.createSelector([Bt,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.offline_id)))})),Sa=S(u.createSelector([Aa,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),ga=$t.reducer,V=I(t=>t.offline_id),ba=V.getInitialState({}),Gt=u.createSlice({name:"assetProcedureFieldValues",initialState:ba,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ba)),reducers:{initializeAssetProcedureFieldValues:V.initialize,addAssetProcedureFieldValues:V.addOne,addAssetProcedureFieldValuesMany:V.addMany,setAssetProcedureFieldValues:V.setOne,setAssetProcedureFieldValuesMany:V.setMany,updateAssetProcedureFieldValues:V.updateOne,updateAssetProcedureFieldValuesMany:V.updateMany,deleteAssetProcedureFieldValues:V.deleteOne,deleteAssetProcedureFieldValuesMany:V.deleteMany}}),{initializeAssetProcedureFieldValues:Ta,addAssetProcedureFieldValues:Lt,addAssetProcedureFieldValuesMany:_a,setAssetProcedureFieldValues:Uh,setAssetProcedureFieldValuesMany:$h,updateAssetProcedureFieldValues:ke,updateAssetProcedureFieldValuesMany:Fa,deleteAssetProcedureFieldValues:Nt,deleteAssetProcedureFieldValuesMany:Ia}=Gt.actions,Ra=t=>t.assetProcedureFieldValuesReducer.instances,Ht=u.createSelector([Ra],t=>Object.values(t)),Bh=S(u.createSelector([Ht,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),Gh=S(u.createSelector([Ht,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure_instance===e)))),Wt=t=>e=>e.assetProcedureFieldValuesReducer.instances[t],Pa=Gt.reducer,U=I(t=>t.offline_id),Oa=U.getInitialState({}),Kt=u.createSlice({name:"assetProcedureInstances",initialState:Oa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Oa)),reducers:{initializeAssetProcedureInstances:U.initialize,addAssetProcedureInstance:U.addOne,addAssetProcedureInstances:U.addMany,setAssetProcedureInstance:U.setOne,setAssetProcedureInstances:U.setMany,updateAssetProcedureInstance:U.updateOne,updateAssetProcedureInstances:U.updateMany,deleteAssetProcedureInstance:U.deleteOne,deleteAssetProcedureInstances:U.deleteMany}}),{initializeAssetProcedureInstances:va,addAssetProcedureInstance:Yt,addAssetProcedureInstances:wa,updateAssetProcedureInstance:Ce,updateAssetProcedureInstances:Lh,deleteAssetProcedureInstance:Jt,deleteAssetProcedureInstances:Ea,setAssetProcedureInstance:Nh,setAssetProcedureInstances:Hh}=Kt.actions,Xt=t=>t.assetProcedureInstanceReducer.instances,Qt=u.createSelector([Xt],t=>Object.values(t)),ja=S(u.createSelector([Qt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),Wh=S(u.createSelector([Qt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),Zt=t=>e=>e.assetProcedureInstanceReducer.instances[t],Kh=S(u.createSelector([Xt,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return g(s)})),qa=Kt.reducer,$=I(t=>t.offline_id),Ma=$.getInitialState({}),xt=u.createSlice({name:"assetProcedures",initialState:Ma,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ma)),reducers:{initializeAssetProcedures:$.initialize,addAssetProcedure:$.addOne,addAssetProcedures:$.addMany,setAssetProcedure:$.setOne,setAssetProcedures:$.setMany,updateAssetProcedure:$.updateOne,updateAssetProcedures:$.updateMany,deleteAssetProcedure:$.deleteOne,deleteAssetProcedures:$.deleteMany}}),{initializeAssetProcedures:ka,addAssetProcedure:es,addAssetProcedures:Yh,updateAssetProcedure:De,updateAssetProcedures:Jh,deleteAssetProcedure:ts,deleteAssetProcedures:Xh,setAssetProcedure:Qh,setAssetProcedures:Zh}=xt.actions,ss=t=>t.assetProcedureReducer.instances,Ca=u.createSelector([ss],t=>Object.values(t)),xh=S(u.createSelector([Ca,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),is=t=>e=>e.assetProcedureReducer.instances[t],em=S(u.createSelector([ss,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return g(s)})),Da=xt.reducer,B=I(t=>t.offline_id),za=B.getInitialState({}),ns=u.createSlice({name:"assets",initialState:za,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,za)),reducers:{initializeAssets:B.initialize,addAsset:B.addOne,addAssets:B.addMany,setAsset:B.setOne,setAssets:B.setMany,updateAsset:B.updateOne,updateAssets:B.updateMany,deleteAsset:B.deleteOne,deleteAssets:B.deleteMany}}),{initializeAssets:Va,addAsset:as,addAssets:cs,updateAsset:ze,updateAssets:tm,deleteAsset:rs,deleteAssets:Ua,setAsset:sm,setAssets:im}=ns.actions,ds=t=>t.assetReducer.instances,$a=u.createSelector([ds],t=>g(Object.values(t))),os=S(u.createSelector([$a,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),ls=t=>e=>e.assetReducer.instances[t],nm=S(u.createSelector([ds,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return g(s)})),am=t=>e=>os(t)(e).length,Ba=ns.reducer,he=I(t=>t.offline_id),Ga=he.getInitialState({}),us=u.createSlice({name:"assetStageCompletions",initialState:Ga,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ga)),reducers:{initializeAssetStageCompletions:he.initialize,addAssetStageCompletion:he.addOne,addAssetStageCompletions:he.addMany,updateAssetStageCompletion:he.updateOne,updateAssetStageCompletions:he.updateMany,deleteAssetStageCompletion:he.deleteOne,deleteAssetStageCompletions:he.deleteMany}}),{initializeAssetStageCompletions:La,addAssetStageCompletion:hs,addAssetStageCompletions:ms,updateAssetStageCompletion:Na,updateAssetStageCompletions:Ha,deleteAssetStageCompletion:fs,deleteAssetStageCompletions:ps}=us.actions,Wa=us.reducer,As=t=>t.assetStageCompletionReducer.instances,cm=u.createSelector([As],t=>Object.values(t)),Ka=t=>e=>e.assetStageCompletionReducer.instances[t],Ya=S(u.createSelector([As,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.offline_id)))})),G=I(t=>t.offline_id),Ja=G.getInitialState({}),ys=u.createSlice({name:"assetStages",initialState:Ja,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ja)),reducers:{initializeAssetStages:G.initialize,setAssetStage:G.setOne,setAssetStages:G.setMany,addAssetStage:G.addOne,addAssetStages:G.addMany,updateAssetStage:G.updateOne,updateAssetStages:G.updateMany,deleteAssetStage:G.deleteOne,deleteAssetStages:G.deleteMany}}),{initializeAssetStages:Xa,setAssetStage:Qa,setAssetStages:rm,addAssetStage:dm,addAssetStages:Ss,updateAssetStage:gs,updateAssetStages:Qe,deleteAssetStage:om,deleteAssetStages:bs}=ys.actions,Za=ys.reducer,Ze=t=>t.assetStageReducer.instances,xa=t=>e=>e.assetStageReducer.instances[t],ec=u.createSelector([Ze],t=>Object.values(t)),lm=S(u.createSelector([Ze,(t,e)=>e],(t,e)=>{const s={};for(const[n,a]of Object.entries(t))a.asset_procedure===e&&(s[n]=a);return Fe(s)})),um=S(u.createSelector([ec,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),Ts=S(u.createSelector([Ze,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectStagesFromStageIds: No stage exists with the id",n)}return g(s)})),L=I(t=>t.offline_id),tc=L.getInitialState({}),_s=u.createSlice({name:"assetTypeAttachments",initialState:tc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,tc)),reducers:{initializeAssetTypeAttachments:L.initialize,addAssetTypeAttachment:L.addOne,addAssetTypeAttachments:L.addMany,setAssetTypeAttachment:L.setOne,setAssetTypeAttachments:L.setMany,updateAssetTypeAttachment:L.updateOne,updateAssetTypeAttachments:L.updateMany,deleteAssetTypeAttachment:L.deleteOne,deleteAssetTypeAttachments:L.deleteMany}}),{initializeAssetTypeAttachments:sc,addAssetTypeAttachment:hm,addAssetTypeAttachments:Fs,setAssetTypeAttachment:ic,setAssetTypeAttachments:mm,updateAssetTypeAttachment:fm,updateAssetTypeAttachments:nc,deleteAssetTypeAttachment:ac,deleteAssetTypeAttachments:Is}=_s.actions,cc=t=>t.assetTypeAttachmentReducer.instances,rc=u.createSelector([cc],t=>Object.values(t)),dc=t=>e=>e.assetTypeAttachmentReducer.instances[t],oc=S(u.createSelector([rc,(t,e)=>e],(t,e)=>g(t.filter(({asset_type:s})=>e===s)))),lc=_s.reducer,N=I(t=>t.offline_id),uc=N.getInitialState({}),Rs=u.createSlice({name:"assetTypeFieldsAttachments",initialState:uc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,uc)),reducers:{initializeAssetTypeFieldsAttachments:N.initialize,addAssetTypeFieldsAttachment:N.addOne,addAssetTypeFieldsAttachments:N.addMany,setAssetTypeFieldsAttachment:N.setOne,setAssetTypeFieldsAttachments:N.setMany,updateAssetTypeFieldsAttachment:N.updateOne,updateAssetTypeFieldsAttachments:N.updateMany,deleteAssetTypeFieldsAttachment:N.deleteOne,deleteAssetTypeFieldsAttachments:N.deleteMany}}),{initializeAssetTypeFieldsAttachments:hc,addAssetTypeFieldsAttachment:pm,addAssetTypeFieldsAttachments:mc,setAssetTypeFieldsAttachment:Am,setAssetTypeFieldsAttachments:ym,updateAssetTypeFieldsAttachment:Sm,updateAssetTypeFieldsAttachments:fc,deleteAssetTypeFieldsAttachment:gm,deleteAssetTypeFieldsAttachments:pc}=Rs.actions,Ac=t=>t.assetTypeFieldsAttachmentReducer.instances,yc=u.createSelector([Ac],t=>Object.values(t)),bm=S(u.createSelector([yc,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),Tm=t=>e=>e.assetTypeFieldsAttachmentReducer.instances[t],Sc=Rs.reducer,H=I(t=>t.offline_id),gc=H.getInitialState({}),Ps=u.createSlice({name:"assetTypeFields",initialState:gc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,gc)),reducers:{initializeAssetTypeFields:H.initialize,addAssetTypeFields:H.addOne,addAssetTypeFieldsMany:H.addMany,setAssetTypeFields:H.setOne,setAssetTypeFieldsMany:H.setMany,updateAssetTypeFields:H.updateOne,updateAssetTypeFieldsMany:H.updateMany,deleteAssetTypeFields:H.deleteOne,deleteAssetTypeFieldsMany:H.deleteMany}}),{initializeAssetTypeFields:bc,addAssetTypeFields:Tc,addAssetTypeFieldsMany:_m,setAssetTypeFields:Fm,setAssetTypeFieldsMany:Im,updateAssetTypeFields:_c,updateAssetTypeFieldsMany:Rm,deleteAssetTypeFields:Fc,deleteAssetTypeFieldsMany:Pm}=Ps.actions,Ic=t=>t.assetTypeFieldsReducer.instances,xe=u.createSelector([Ic],t=>Object.values(t)),Om=S(u.createSelector([xe,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),vm=S(u.createSelector([xe,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),wm=t=>e=>e.assetTypeFieldsReducer.instances[t],Rc=Ps.reducer,W=I(t=>t.offline_id),Pc=W.getInitialState({}),Os=u.createSlice({name:"assetTypeFieldValuesAttachments",initialState:Pc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Pc)),reducers:{initializeAssetTypeFieldValuesAttachments:W.initialize,addAssetTypeFieldValuesAttachment:W.addOne,addAssetTypeFieldValuesAttachments:W.addMany,setAssetTypeFieldValuesAttachment:W.setOne,setAssetTypeFieldValuesAttachments:W.setMany,updateAssetTypeFieldValuesAttachment:W.updateOne,updateAssetTypeFieldValuesAttachments:W.updateMany,deleteAssetTypeFieldValuesAttachment:W.deleteOne,deleteAssetTypeFieldValuesAttachments:W.deleteMany}}),{initializeAssetTypeFieldValuesAttachments:Oc,addAssetTypeFieldValuesAttachment:Em,addAssetTypeFieldValuesAttachments:et,setAssetTypeFieldValuesAttachment:jm,setAssetTypeFieldValuesAttachments:qm,updateAssetTypeFieldValuesAttachment:Mm,updateAssetTypeFieldValuesAttachments:vc,deleteAssetTypeFieldValuesAttachment:km,deleteAssetTypeFieldValuesAttachments:tt}=Os.actions,vs=t=>t.assetTypeFieldValuesAttachmentReducer.instances,wc=u.createSelector([vs],t=>Object.values(t)),Cm=t=>e=>e.assetTypeFieldValuesAttachmentReducer.instances[t],Ec=S(u.createSelector([vs,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.offline_id)))})),jc=S(u.createSelector([wc,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),qc=Os.reducer,K=I(t=>t.offline_id),Mc=K.getInitialState({}),ws=u.createSlice({name:"assetTypeFieldValues",initialState:Mc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Mc)),reducers:{initializeAssetTypeFieldValues:K.initialize,addAssetTypeFieldValues:K.addOne,addAssetTypeFieldValuesMany:K.addMany,setAssetTypeFieldValues:K.setOne,setAssetTypeFieldValuesMany:K.setMany,updateAssetTypeFieldValues:K.updateOne,updateAssetTypeFieldValuesMany:K.updateMany,deleteAssetTypeFieldValues:K.deleteOne,deleteAssetTypeFieldValuesMany:K.deleteMany}}),{initializeAssetTypeFieldValues:kc,addAssetTypeFieldValues:Es,addAssetTypeFieldValuesMany:Cc,setAssetTypeFieldValues:Dm,setAssetTypeFieldValuesMany:zm,updateAssetTypeFieldValues:Ve,updateAssetTypeFieldValuesMany:Dc,deleteAssetTypeFieldValues:js,deleteAssetTypeFieldValuesMany:zc}=ws.actions,Vc=t=>t.assetTypeFieldValuesReducer.instances,qs=u.createSelector([Vc],t=>Object.values(t)),Vm=S(u.createSelector([qs,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),Um=S(u.createSelector([xe,qs,(t,e)=>e],(t,e,s)=>{const n=new Set(t.filter(a=>a.asset_type===s).map(a=>a.offline_id));return g(e.filter(a=>n.has(a.fields_revision)))})),Ms=t=>e=>e.assetTypeFieldValuesReducer.instances[t],Uc=ws.reducer,Y=I(t=>t.offline_id),$c=Y.getInitialState({}),ks=u.createSlice({name:"assetTypes",initialState:$c,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,$c)),reducers:{initializeAssetTypes:Y.initialize,setAssetType:Y.setOne,setAssetTypes:Y.setMany,addAssetType:Y.addOne,addAssetTypes:Y.addMany,updateAssetType:Y.updateOne,updateAssetTypes:Y.updateMany,deleteAssetType:Y.deleteOne,deleteAssetTypes:Y.deleteMany}}),{initializeAssetTypes:Bc,setAssetType:$m,setAssetTypes:Bm,addAssetType:Cs,addAssetTypes:Gm,updateAssetType:Ue,updateAssetTypes:Lm,deleteAssetType:Ds,deleteAssetTypes:Nm}=ks.actions,zs=t=>t.assetTypeReducer.instances,Hm=u.createSelector([zs],t=>Object.values(t)),Vs=t=>e=>e.assetTypeReducer.instances[t],Wm=S(u.createSelector([zs,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectAssetTypesByIds: No assetType exists with the id",n)}return g(s)})),Gc=ks.reducer,Lc={accessToken:"",refreshToken:"",isLoggedIn:!1},st=u.createSlice({name:"auth",initialState:Lc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Lc)),reducers:{setTokens:(t,e)=>{t.accessToken=e.payload.accessToken,t.refreshToken=e.payload.refreshToken},clearTokens:t=>{t.accessToken="",t.refreshToken=""},setLoggedIn:(t,e)=>{e.payload||st.caseReducers.clearTokens(t),t.isLoggedIn=e.payload}}}),{setTokens:Km,clearTokens:Ym,setLoggedIn:Nc}=st.actions,Jm=t=>t.authReducer.accessToken,Xm=t=>t.authReducer.isLoggedIn,Hc=st.reducer,$e=I(t=>t.offline_id),Wc=$e.getInitialState({}),Us=u.createSlice({name:"categories",initialState:Wc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Wc)),reducers:{initializeCategories:$e.initialize,addCategory:$e.addOne,updateCategory:$e.updateOne,deleteCategory:$e.deleteOne}}),{initializeCategories:Kc,addCategory:$s,updateCategory:Yc,deleteCategory:Jc}=Us.actions,Bs=t=>t.categoryReducer.instances,Qm=u.createSelector([Bs],t=>Object.values(t)),Gs=t=>e=>e.categoryReducer.instances[t],Zm=S(u.createSelector([Bs,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectCategoryByIds: No category exists with the id",n)}return g(s)})),xm=t=>e=>Object.values(e.issueReducer.instances).filter(s=>s.category===t).length,Xc=Us.reducer,J=I(t=>t.offline_id),Qc=J.getInitialState({}),Ls=u.createSlice({name:"documentAttachments",initialState:Qc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Qc)),reducers:{initializeDocumentAttachments:J.initialize,addDocumentAttachment:J.addOne,addDocumentAttachments:J.addMany,setDocumentAttachment:J.setOne,setDocumentAttachments:J.setMany,updateDocumentAttachment:J.updateOne,updateDocumentAttachments:J.updateMany,deleteDocumentAttachment:J.deleteOne,deleteDocumentAttachments:J.deleteMany}}),{initializeDocumentAttachments:Zc,addDocumentAttachment:ef,addDocumentAttachments:xc,setDocumentAttachment:er,setDocumentAttachments:tf,updateDocumentAttachment:sf,updateDocumentAttachments:tr,deleteDocumentAttachment:sr,deleteDocumentAttachments:ir}=Ls.actions,nr=t=>t.documentAttachmentReducer.instances,ar=u.createSelector([nr],t=>Object.values(t)),cr=t=>e=>e.documentAttachmentReducer.instances[t],nf=S(u.createSelector([ar,(t,e)=>e],(t,e)=>g(t.filter(({document:s})=>e===s)))),rr=Ls.reducer,dr={documents:{}},Ns=u.createSlice({name:"documents",initialState:dr,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,dr)}),reducers:{setDocuments:(t,e)=>{if(e.payload.filter(Dn).length!==e.payload.length)throw new Error("Tried to use setIssues reducer with duplicate ID's");t.documents=Cn(e.payload)},addDocuments:(t,e)=>{for(const s of e.payload)if(s.offline_id in t.documents)throw new Error(`attempting to add a document with offline_id ${s.offline_id} which already exists in state.documents.`);for(const s of e.payload){if(s.parent_document&&t.documents[s.parent_document]){const n=t.documents[s.parent_document];t.documents[s.parent_document]={...n,children_documents:[...n.children_documents,s.offline_id]}}t.documents[s.offline_id]=s}},updateDocuments:(t,e)=>{for(const s of e.payload)if(!(s.offline_id in t.documents))throw new Error(`attempting to update a document with offline_id ${s.offline_id} which doesn't exists in state.documents.`);for(const s of e.payload){const n=t.documents[s.offline_id];if(s.organization!==void 0&&s.organization!==n.organization)throw new Error("organization cannot be updated");if(s.project!==void 0&&s.project!==n.project)throw new Error("project cannot be updated");t.documents[s.offline_id]={...n,...s}}},moveDocument:(t,e)=>{const{documentId:s,targetDocumentId:n,position:a}=e.payload;if(!(s in t.documents))throw new Error(`attempting to move a document with offline_id ${s} which doesn't exist in state.documents`);const c=t.documents[s];if(c.parent_document&&t.documents[c.parent_document]){const{children_documents:r}=t.documents[c.parent_document];t.documents[c.parent_document].children_documents.splice(r.indexOf(c.offline_id),1)}if(n){const r=t.documents[n],o=r!=null&&r.parent_document?t.documents[r.parent_document]:null;switch(a){case"left":if(!o)throw new Error("attempting to move a document to the left of a document with no parent_document");t.documents[r.parent_document].children_documents.splice(o.children_documents.indexOf(r.offline_id),0,c.offline_id),t.documents[s].parent_document=o.offline_id;break;case"right":if(!o)throw new Error("attempting to move a document to the left of a document with no parent_document");t.documents[r.parent_document].children_documents.splice(o.children_documents.indexOf(r.offline_id)+1,0,c.offline_id),t.documents[s].parent_document=o.offline_id;break;case"left-child":if(!r)throw new Error("attempting to move a document to the left-child of a document that doesn't exist");t.documents[n].children_documents.unshift(c.offline_id),t.documents[s].parent_document=r.offline_id;break;case"right-child":if(!r)throw new Error("attempting to move a document to the left-child of a document that doesn't exist");t.documents[n].children_documents.push(c.offline_id),t.documents[s].parent_document=r.offline_id}}else t.documents[s].parent_document=null},removeDocuments:(t,e)=>{for(const s of e.payload)if(!(s in t.documents))throw new Error(`attempting to delete a document with offline_id ${s} which doesn't exists in state.documents.`);for(const s of e.payload){const n=t.documents[s];if(n.parent_document&&t.documents[n.parent_document]){const a=t.documents[n.parent_document];t.documents[n.parent_document]={...a,children_documents:a.children_documents.filter(c=>c!==n.offline_id)}}delete t.documents[s]}}}}),{setDocuments:or,addDocuments:lr,updateDocuments:me,moveDocument:ur,removeDocuments:Hs}=Ns.actions,Re=t=>t.documentsReducer.documents,hr=u.createSelector([Re],t=>Object.values(t)),mr=t=>e=>e.documentsReducer.documents[t],af=S(u.createSelector([Re,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectDocumentByIds: No document exists with the id",n)}return g(s)})),cf=S(u.createSelector([Re,(t,e)=>e],(t,e)=>{const s=[],n=t[e];if(!n||!n.parent_document)return s;let a=t[n.parent_document];for(;a;)s.push(a.offline_id),a=t[a.parent_document??""];return g(s)})),rf=u.createSelector([hr],t=>g(t.filter(e=>!e.parent_document))),fr=Ns.reducer,it=I(t=>t.offline_id),df=it.getInitialState({}),Ws=u.createSlice({name:"emailDomains",initialState:df,reducers:{initializeEmailDomains:it.initialize,addEmailDomain:it.addOne,deleteEmailDomain:it.deleteOne}}),{initializeEmailDomains:pr,addEmailDomain:Ar,deleteEmailDomain:yr}=Ws.actions,Sr=t=>t.emailDomainsReducer.instances,gr=u.createSelector([Sr],t=>Object.values(t)),of=S(u.createSelector([gr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),br=Ws.reducer,Tr={s3Urls:{}},_r=1e3*60*60,lf=_r*24*7,Ks=u.createSlice({name:"file",initialState:Tr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Tr)),reducers:{setUploadUrl:(t,e)=>{const{url:s,fields:n,sha1:a}=e.payload,c=new Date,r=new Date(c.getTime()+lf);t.s3Urls[a]={url:s,fields:n,exp:r.getTime()}}}}),{setUploadUrl:Fr}=Ks.actions,Ir=t=>e=>{const s=e.fileReducer.s3Urls[t];if(!s)return;const n=new Date().getTime();if(!((s.exp??n)-n<_r))return s},Rr=Ks.reducer,X=I(t=>t.offline_id),Pr=X.getInitialState({}),Ys=u.createSlice({name:"formRevisionAttachments",initialState:Pr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Pr)),reducers:{initializeFormRevisionAttachments:X.initialize,addFormRevisionAttachment:X.addOne,addFormRevisionAttachments:X.addMany,setFormRevisionAttachment:X.setOne,setFormRevisionAttachments:X.setMany,updateFormRevisionAttachment:X.updateOne,updateFormRevisionAttachments:X.updateMany,deleteFormRevisionAttachment:X.deleteOne,deleteFormRevisionAttachments:X.deleteMany}}),{initializeFormRevisionAttachments:Or,addFormRevisionAttachment:uf,addFormRevisionAttachments:vr,setFormRevisionAttachment:hf,setFormRevisionAttachments:mf,updateFormRevisionAttachment:ff,updateFormRevisionAttachments:wr,deleteFormRevisionAttachment:pf,deleteFormRevisionAttachments:Er}=Ys.actions,jr=t=>t.formRevisionAttachmentReducer.instances,Af=S(u.createSelector([jr,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_revision===e)))),qr=Ys.reducer,yf=(t,e)=>{const s=t.revision,n=e.revision;return s===void 0&&n===void 0?t.submitted_at<e.submitted_at?-1:1:s===void 0?1:n===void 0||s<n?-1:1},fe=I(t=>t.offline_id),Mr=fe.getInitialState({}),Js=u.createSlice({name:"formRevisions",initialState:Mr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Mr)),reducers:{initializeFormRevisions:fe.initialize,setFormRevision:fe.setOne,addFormRevision:fe.addOne,addFormRevisions:fe.addMany,deleteFormRevision:fe.deleteOne,deleteFormRevisions:fe.deleteMany}}),{setFormRevision:kr,initializeFormRevisions:Cr,addFormRevision:Xs,addFormRevisions:Dr,deleteFormRevision:Qs,deleteFormRevisions:zr}=Js.actions,nt=t=>t.formRevisionReducer.instances,Vr=u.createSelector([nt],t=>Object.values(t)),Sf=t=>e=>e.formRevisionReducer.instances[t],gf=S(u.createSelector([nt,(t,e)=>e],(t,e)=>{const s=Object.values(t).filter(c=>c.form===e);if(s.length===0)return;const a=s.sort(yf)[s.length-1];return t[a.offline_id]})),Ur=S(u.createSelector([Vr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.form===e)))),$r=Js.reducer,pe=I(t=>t.offline_id),Br=pe.getInitialState({}),Zs=u.createSlice({name:"forms",initialState:Br,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Br)),reducers:{initializeForms:pe.initialize,setForm:pe.setOne,addForm:pe.addOne,addForms:pe.addMany,updateForm:pe.updateOne,deleteForm:pe.deleteOne}}),{initializeForms:Gr,setForm:bf,addForm:xs,addForms:Tf,updateForm:_f,deleteForm:ei}=Zs.actions,Lr=Zs.reducer,Nr=t=>t.formReducer.instances,Ff=u.createSelector([Nr],t=>Object.values(t)),Hr=t=>e=>e.formReducer.instances[t],Q=I(t=>t.offline_id),Wr=Q.getInitialState({}),ti=u.createSlice({name:"formSubmissionAttachments",initialState:Wr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Wr)),reducers:{initializeFormSubmissionAttachments:Q.initialize,addFormSubmissionAttachment:Q.addOne,addFormSubmissionAttachments:Q.addMany,setFormSubmissionAttachment:Q.setOne,setFormSubmissionAttachments:Q.setMany,updateFormSubmissionAttachment:Q.updateOne,updateFormSubmissionAttachments:Q.updateMany,deleteFormSubmissionAttachment:Q.deleteOne,deleteFormSubmissionAttachments:Q.deleteMany}}),{initializeFormSubmissionAttachments:Kr,addFormSubmissionAttachment:If,addFormSubmissionAttachments:at,setFormSubmissionAttachment:Rf,setFormSubmissionAttachments:Pf,updateFormSubmissionAttachment:Of,updateFormSubmissionAttachments:Yr,deleteFormSubmissionAttachment:vf,deleteFormSubmissionAttachments:ct}=ti.actions,si=t=>t.formSubmissionAttachmentReducer.instances,Jr=S(u.createSelector([si,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.offline_id)))})),Xr=S(u.createSelector([si,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_submission===e)))),Qr=ti.reducer,Z=I(t=>t.offline_id),Zr=Z.getInitialState({}),ii=u.createSlice({name:"formSubmissions",initialState:Zr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Zr)),reducers:{initializeFormSubmissions:Z.initialize,setFormSubmission:Z.setOne,setFormSubmissions:Z.setMany,addFormSubmission:Z.addOne,addFormSubmissions:Z.addMany,updateFormSubmission:Z.updateOne,updateFormSubmissions:Z.updateMany,deleteFormSubmission:Z.deleteOne,deleteFormSubmissions:Z.deleteMany}}),{initializeFormSubmissions:xr,setFormSubmission:rt,setFormSubmissions:wf,addFormSubmission:ni,addFormSubmissions:dt,updateFormSubmission:ed,updateFormSubmissions:Ef,deleteFormSubmission:ai,deleteFormSubmissions:ot}=ii.actions,ci=t=>t.formSubmissionReducer.instances,ri=u.createSelector([ci],t=>Object.values(t)),di=t=>e=>e.formSubmissionReducer.instances[t],td=S(u.createSelector([ci,nt,(t,e)=>e],(t,e,s)=>{const n=new Set;for(const a of Object.values(e))a.form===s&&n.add(a.offline_id);return Object.values(t).filter(a=>n.has(a.form_revision))})),sd=S(u.createSelector([ri,(t,e)=>e],(t,e)=>Object.values(t).filter(s=>s.issue===e))),id=S(u.createSelector([ri,(t,e)=>e],(t,e)=>t.filter(s=>s.asset===e))),nd=ii.reducer,x=I(t=>t.offline_id),ad=x.getInitialState({}),oi=u.createSlice({name:"geoImages",initialState:ad,extraReducers:t=>{t.addCase("RESET",e=>{Object.assign(e,ad)})},reducers:{initializeGeoImages:x.initialize,setGeoImage:x.setOne,setGeoImages:x.setMany,addGeoImage:x.addOne,addGeoImages:x.addMany,updateGeoImage:x.updateOne,updateGeoImages:x.updateMany,deleteGeoImage:x.deleteOne,deleteGeoImages:x.deleteMany}}),{initializeGeoImages:cd,setGeoImage:Be,setGeoImages:rd,addGeoImage:dd,addGeoImages:od,updateGeoImage:ld,updateGeoImages:jf,deleteGeoImage:li,deleteGeoImages:ud}=oi.actions,hd=t=>t.geoImageReducer.instances,md=u.createSelector([hd],t=>Object.values(t)),ui=t=>e=>e.geoImageReducer.instances[t],qf=S(u.createSelector([md,(t,e)=>e],(t,e)=>g(t.filter(s=>s.project===e)))),fd=oi.reducer,ee=I(t=>t.offline_id),pd=ee.getInitialState({}),hi=u.createSlice({name:"issueAssociations",initialState:pd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,pd)),reducers:{initializeIssueAssociations:ee.initialize,addIssueAssociation:ee.addOne,addIssueAssociations:ee.addMany,setIssueAssociation:ee.setOne,setIssueAssociations:ee.setMany,updateIssueAssociation:ee.updateOne,updateIssueAssociations:ee.updateMany,deleteIssueAssociation:ee.deleteOne,deleteIssueAssociations:ee.deleteMany}}),{initializeIssueAssociations:Ad,setIssueAssociations:Mf,setIssueAssociation:kf,updateIssueAssociation:yd,updateIssueAssociations:Cf,addIssueAssociation:mi,addIssueAssociations:fi,deleteIssueAssociation:pi,deleteIssueAssociations:Ai}=hi.actions,Ge=t=>t.issueAssociationReducer.instances,Df=u.createSelector([Ge],t=>Object.values(t)),Sd=t=>e=>e.issueAssociationReducer.instances[t],gd=S(u.createSelector([Ge,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.associated_issue===e)))),bd=S(u.createSelector([Ge,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Td=S(u.createSelector([Ge,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.asset===e)))),_d=hi.reducer,te=I(t=>t.offline_id),Fd=te.getInitialState({}),yi=u.createSlice({name:"issueAttachments",initialState:Fd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Fd)),reducers:{initializeIssueAttachments:te.initialize,addIssueAttachment:te.addOne,addIssueAttachments:te.addMany,setIssueAttachment:te.setOne,setIssueAttachments:te.setMany,updateIssueAttachment:te.updateOne,updateIssueAttachments:te.updateMany,deleteIssueAttachment:te.deleteOne,deleteIssueAttachments:te.deleteMany}}),{initializeIssueAttachments:Si,addIssueAttachment:zf,addIssueAttachments:gi,setIssueAttachment:Id,setIssueAttachments:Vf,updateIssueAttachment:Uf,updateIssueAttachments:Rd,deleteIssueAttachment:Pd,deleteIssueAttachments:bi}=yi.actions,Od=t=>t.issueAttachmentReducer.instances,vd=u.createSelector([Od],t=>Object.values(t)),wd=S(u.createSelector([vd,(t,e)=>e],(t,e)=>g(t.filter(({issue:s})=>e===s)))),Ed=t=>e=>e.issueAttachmentReducer.instances[t],jd=yi.reducer,se=I(t=>t.offline_id),qd=se.getInitialState({}),Ti=u.createSlice({name:"issueCommentAttachments",initialState:qd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,qd)),reducers:{initializeIssueCommentAttachments:se.initialize,addIssueCommentAttachment:se.addOne,addIssueCommentAttachments:se.addMany,setIssueCommentAttachment:se.setOne,setIssueCommentAttachments:se.setMany,updateIssueCommentAttachment:se.updateOne,updateIssueCommentAttachments:se.updateMany,deleteIssueCommentAttachment:se.deleteOne,deleteIssueCommentAttachments:se.deleteMany}}),{initializeIssueCommentAttachments:_i,addIssueCommentAttachment:$f,addIssueCommentAttachments:Md,setIssueCommentAttachment:kd,setIssueCommentAttachments:Bf,updateIssueCommentAttachment:Gf,updateIssueCommentAttachments:Cd,deleteIssueCommentAttachment:Dd,deleteIssueCommentAttachments:zd}=Ti.actions,Vd=t=>t.issueCommentAttachmentReducer.instances,Ud=u.createSelector([Vd],t=>Object.values(t)),$d=t=>e=>e.issueCommentAttachmentReducer.instances[t],Lf=S(u.createSelector([Ud,(t,e)=>e],(t,e)=>g(t.filter(({issue_comment:s})=>e===s)))),Bd=Ti.reducer,Ae=I(t=>t.offline_id),Gd=Ae.getInitialState({}),Fi=u.createSlice({name:"issueComments",initialState:Gd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Gd)),reducers:{addIssueComment:Ae.addOne,addIssueComments:Ae.addMany,setIssueComment:Ae.setOne,setIssueComments:Ae.setMany,deleteIssueComment:Ae.deleteOne,deleteIssueComments:Ae.deleteMany}}),{setIssueComments:Ld,setIssueComment:Ii,addIssueComment:Ri,addIssueComments:Nf,deleteIssueComment:Pi,deleteIssueComments:Hf}=Fi.actions,Nd=t=>t.issueCommentReducer.instances,Hd=t=>e=>e.issueCommentReducer.instances[t],Wf=S(u.createSelector([Nd,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Wd=Fi.reducer,ye=I(t=>t.offline_id),Kd=ye.getInitialState({}),Oi=u.createSlice({name:"issues",initialState:Kd,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Kd)}),reducers:{initializeIssues:ye.initialize,addIssue:ye.addOne,addIssues:ye.addMany,updateIssue:ye.updateOne,deleteIssue:ye.deleteOne,deleteIssues:ye.deleteMany}}),{initializeIssues:Yd,addIssue:vi,addIssues:Jd,updateIssue:lt,deleteIssue:wi,deleteIssues:Xd}=Oi.actions,Qd=t=>t.issueReducer.instances,Ei=t=>e=>e.issueReducer.instances[t],Kf=S(u.createSelector([Qd,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectIssuesByIds: No issue exists with the id",n)}return g(s)})),Zd=Oi.reducer,ie=I(t=>t.offline_id),xd=ie.getInitialState({}),ji=u.createSlice({name:"issueTypeAttachments",initialState:xd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,xd)),reducers:{initializeIssueTypeAttachments:ie.initialize,addIssueTypeAttachment:ie.addOne,addIssueTypeAttachments:ie.addMany,setIssueTypeAttachment:ie.setOne,setIssueTypeAttachments:ie.setMany,updateIssueTypeAttachment:ie.updateOne,updateIssueTypeAttachments:ie.updateMany,deleteIssueTypeAttachment:ie.deleteOne,deleteIssueTypeAttachments:ie.deleteMany}}),{initializeIssueTypeAttachments:qi,addIssueTypeAttachment:Yf,addIssueTypeAttachments:eo,setIssueTypeAttachment:to,setIssueTypeAttachments:Jf,updateIssueTypeAttachment:Xf,updateIssueTypeAttachments:so,deleteIssueTypeAttachment:io,deleteIssueTypeAttachments:no}=ji.actions,ao=t=>t.issueTypeAttachmentReducer.instances,co=u.createSelector([ao],t=>Object.values(t)),ro=t=>e=>e.issueTypeAttachmentReducer.instances[t],Qf=S(u.createSelector([co,(t,e)=>e],(t,e)=>g(t.filter(({issue_type:s})=>e===s)))),oo=ji.reducer,ne=I(t=>t.offline_id),lo=ne.getInitialState({}),Mi=u.createSlice({name:"issueTypeFieldsAttachments",initialState:lo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,lo)),reducers:{initializeIssueTypeFieldsAttachments:ne.initialize,addIssueTypeFieldsAttachment:ne.addOne,addIssueTypeFieldsAttachments:ne.addMany,setIssueTypeFieldsAttachment:ne.setOne,setIssueTypeFieldsAttachments:ne.setMany,updateIssueTypeFieldsAttachment:ne.updateOne,updateIssueTypeFieldsAttachments:ne.updateMany,deleteIssueTypeFieldsAttachment:ne.deleteOne,deleteIssueTypeFieldsAttachments:ne.deleteMany}}),{initializeIssueTypeFieldsAttachments:uo,addIssueTypeFieldsAttachment:Zf,addIssueTypeFieldsAttachments:ho,setIssueTypeFieldsAttachment:xf,setIssueTypeFieldsAttachments:ep,updateIssueTypeFieldsAttachment:tp,updateIssueTypeFieldsAttachments:mo,deleteIssueTypeFieldsAttachment:sp,deleteIssueTypeFieldsAttachments:fo}=Mi.actions,po=t=>t.issueTypeFieldsAttachmentReducer.instances,Ao=u.createSelector([po],t=>Object.values(t)),ip=S(u.createSelector([Ao,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),np=t=>e=>e.issueTypeFieldsAttachmentReducer.instances[t],yo=Mi.reducer,ae=I(t=>t.offline_id),So=ae.getInitialState({}),ki=u.createSlice({name:"issueTypeFieldValues",initialState:So,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,So)),reducers:{initializeIssueTypeFieldValues:ae.initialize,addIssueTypeFieldValues:ae.addOne,addIssueTypeFieldValuesMany:ae.addMany,setIssueTypeFieldValues:ae.setOne,setIssueTypeFieldValuesMany:ae.setMany,updateIssueTypeFieldValues:ae.updateOne,updateIssueTypeFieldValuesMany:ae.updateMany,deleteIssueTypeFieldValues:ae.deleteOne,deleteIssueTypeFieldValuesMany:ae.deleteMany}}),{initializeIssueTypeFieldValues:go,addIssueTypeFieldValues:Ci,addIssueTypeFieldValuesMany:ap,setIssueTypeFieldValues:cp,setIssueTypeFieldValuesMany:rp,updateIssueTypeFieldValues:Le,updateIssueTypeFieldValuesMany:dp,deleteIssueTypeFieldValues:Di,deleteIssueTypeFieldValuesMany:op}=ki.actions,bo=t=>t.issueTypeFieldValuesReducer.instances,zi=u.createSelector([bo],t=>Object.values(t)),lp=S(u.createSelector([zi,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue===e)))),Vi=t=>e=>e.issueTypeFieldValuesReducer.instances[t],To=ki.reducer,ce=I(t=>t.offline_id),_o=ce.getInitialState({}),Ui=u.createSlice({name:"issueTypeFields",initialState:_o,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,_o)),reducers:{initializeIssueTypeFields:ce.initialize,addIssueTypeFields:ce.addOne,addIssueTypeFieldsMany:ce.addMany,setIssueTypeFields:ce.setOne,setIssueTypeFieldsMany:ce.setMany,updateIssueTypeFields:ce.updateOne,updateIssueTypeFieldsMany:ce.updateMany,deleteIssueTypeFields:ce.deleteOne,deleteIssueTypeFieldsMany:ce.deleteMany}}),{initializeIssueTypeFields:Fo,addIssueTypeFields:Io,addIssueTypeFieldsMany:up,setIssueTypeFields:hp,setIssueTypeFieldsMany:mp,updateIssueTypeFields:Ro,updateIssueTypeFieldsMany:fp,deleteIssueTypeFields:Po,deleteIssueTypeFieldsMany:pp}=Ui.actions,Oo=t=>t.issueTypeFieldsReducer.instances,ut=u.createSelector([Oo],t=>Object.values(t)),Ap=S(u.createSelector([ut,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue_type===e)))),yp=S(u.createSelector([ut,(t,e)=>e],(t,e)=>t.filter(s=>s.issue_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),Sp=S(u.createSelector([ut,zi,(t,e)=>e],(t,e,s)=>{const n=new Set(t.filter(a=>a.issue_type===s).map(a=>a.offline_id));return g(e.filter(a=>n.has(a.fields_revision)))})),gp=t=>e=>e.issueTypeFieldsReducer.instances[t],vo=Ui.reducer,re=I(t=>t.offline_id),wo=re.getInitialState({}),$i=u.createSlice({name:"issueTypeFieldValuesAttachments",initialState:wo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,wo)),reducers:{initializeIssueTypeFieldValuesAttachments:re.initialize,addIssueTypeFieldValuesAttachment:re.addOne,addIssueTypeFieldValuesAttachments:re.addMany,setIssueTypeFieldValuesAttachment:re.setOne,setIssueTypeFieldValuesAttachments:re.setMany,updateIssueTypeFieldValuesAttachment:re.updateOne,updateIssueTypeFieldValuesAttachments:re.updateMany,deleteIssueTypeFieldValuesAttachment:re.deleteOne,deleteIssueTypeFieldValuesAttachments:re.deleteMany}}),{initializeIssueTypeFieldValuesAttachments:Eo,addIssueTypeFieldValuesAttachment:bp,addIssueTypeFieldValuesAttachments:ht,setIssueTypeFieldValuesAttachment:Tp,setIssueTypeFieldValuesAttachments:_p,updateIssueTypeFieldValuesAttachment:Fp,updateIssueTypeFieldValuesAttachments:jo,deleteIssueTypeFieldValuesAttachment:Ip,deleteIssueTypeFieldValuesAttachments:mt}=$i.actions,Bi=t=>t.issueTypeFieldValuesAttachmentReducer.instances,qo=u.createSelector([Bi],t=>Object.values(t)),Rp=t=>e=>e.issueTypeFieldValuesAttachmentReducer.instances[t],Mo=S(u.createSelector([Bi,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.offline_id)))})),ko=S(u.createSelector([qo,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),Co=$i.reducer,Pe=I(t=>t.offline_id),Do=Pe.getInitialState({}),Gi=u.createSlice({name:"issueTypes",initialState:Do,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Do)}),reducers:{initializeIssueTypes:Pe.initialize,setIssueType:Pe.setOne,addIssueType:Pe.addOne,updateIssueType:Pe.updateOne,removeIssueType:Pe.deleteOne}}),{initializeIssueTypes:zo,setIssueType:Ne,addIssueType:Vo,updateIssueType:Uo,removeIssueType:Li}=Gi.actions,$o=t=>t.issueTypeReducer.instances,Bo=u.createSelector($o,t=>Object.values(t)),Ni=t=>e=>e.issueTypeReducer.instances[t],Pp=t=>e=>{const s=[];for(const n of t){const a=e.issueTypeReducer.instances[n];a?s.push(a):console.warn("selectIssueTypesByIds: No issue type exists with the id",n)}return s},Op=S(u.createSelector([Bo,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Hi=S(u.createSelector([t=>t.issueReducer.instances,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue_type===e)))),vp=t=>e=>Hi(t)(e).length,Go=Gi.reducer,Se=I(t=>t.offline_id),Lo=Se.getInitialState({}),Wi=u.createSlice({name:"issueUpdates",initialState:Lo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Lo)),reducers:{initializeIssueUpdates:Se.setMany,setIssueUpdate:Se.setOne,addIssueUpdate:Se.addOne,addIssueUpdates:Se.addMany,deleteIssueUpdate:Se.deleteOne,deleteIssueUpdates:Se.deleteMany}}),{initializeIssueUpdates:No,setIssueUpdate:wp,addIssueUpdate:Ho,addIssueUpdates:Wo,deleteIssueUpdate:Ko,deleteIssueUpdates:Yo}=Wi.actions,Jo=t=>t.issueUpdateReducer.instances,Xo=S(u.createSelector([Jo,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Qo=Wi.reducer,ft=I(t=>t.offline_id),Zo=ft.getInitialState({}),Ki=u.createSlice({name:"license",initialState:Zo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Zo)),reducers:{initializeLicences:ft.initialize,addLicenses:ft.addMany,updateLicense:ft.updateOne}}),{initializeLicences:xo,addLicenses:Ep,updateLicense:ue}=Ki.actions,pt=t=>t.licenseReducer.instances,jp=t=>e=>e.licenseReducer.instances[t],el=t=>e=>Object.values(e.licenseReducer.instances).find(s=>s.project===t),qp=u.createSelector([pt],t=>g(Object.values(t).filter(e=>e.is_active))),Mp=u.createSelector([pt],t=>Fe(Object.values(t).filter(e=>e.project).reduce((e,s)=>({...e,[s.project]:s}),{}))),tl=Ki.reducer,sl={users:{},currentUser:null},Yi=u.createSlice({name:"users",initialState:sl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sl)),reducers:{setUsers:(t,e)=>{const s={};e.payload.forEach(n=>{s[n.id]=n}),t.users=s},addUsers:(t,e)=>{for(const s of e.payload)t.users[s.id]=s},setCurrentUser:(t,e)=>{t.currentUser=e.payload},setProfilePicture:(t,e)=>{if(!t.currentUser)return;t.currentUser.profile.file=e.payload.file??null,t.currentUser.profile.file_sha1=e.payload.file_sha1??null;const s=t.users[t.currentUser.id];if(!s)throw new Error("Unable to find current user in users slice");s.profile.file=e.payload.file??null,s.profile.file_sha1=e.payload.file_sha1??null},removeUser:(t,e)=>{delete t.users[e.payload]}}}),{setCurrentUser:kp,setProfilePicture:Cp,setUsers:il,addUsers:Dp,removeUser:nl}=Yi.actions,al=Yi.reducer,At=t=>t.userReducer.currentUser,yt=t=>t.userReducer.users,zp=t=>e=>e.userReducer.users[t],Vp=S(u.createSelector([yt,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectUsersByIds: No user exists with the id",n)}return g(s)})),St=I(t=>t.offline_id),cl=St.getInitialState({}),Ji=u.createSlice({name:"organizationAccess",initialState:cl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,cl)),reducers:{initializeOrganizationAccesses:St.initialize,updateOrganizationAccess:St.updateOne,deleteOrganizationAccess:St.deleteOne}}),{initializeOrganizationAccesses:rl,updateOrganizationAccess:dl,deleteOrganizationAccess:ol}=Ji.actions,Xi=t=>t.organizationAccessReducer.instances,Up=t=>e=>e.organizationAccessReducer.instances[t],$p=u.createSelector([At,Xi],(t,e)=>Object.values(e).find(n=>n.user===(t==null?void 0:t.id))??null),Bp=t=>e=>Object.values(e.organizationAccessReducer.instances).find(s=>s.user===t.id),ll=t=>{const e={};for(const s of Object.values(t.organizationAccessReducer.instances))e[s.user]=s;return Fe(e)},ul=Ji.reducer,He=I(t=>t.offline_id),hl=He.getInitialState({}),Qi=u.createSlice({name:"projectAccess",initialState:hl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,hl)),reducers:{initializeProjectAccesses:He.initialize,updateProjectAccess:He.updateOne,deleteProjectAccess:He.deleteOne,deleteProjectAccesses:He.deleteMany}}),{initializeProjectAccesses:Zi,updateProjectAccess:ml,deleteProjectAccess:fl,deleteProjectAccesses:pl}=Qi.actions,xi=t=>t.projectAccessReducer.instances,Al=u.createSelector(xi,t=>Object.values(t)),Gp=t=>e=>e.projectAccessReducer.instances[t],Lp=t=>e=>Object.values(e.projectAccessReducer.instances).find(s=>s.user===t.id),yl=t=>{const e={};for(const s of Object.values(t.projectAccessReducer.instances))e[s.user]=s;return Fe(e)},Sl=Qi.reducer,gl={projects:{}},en=u.createSlice({name:"projects",initialState:gl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,gl)),reducers:{setProjects:(t,e)=>{const s={};e.payload.forEach(n=>{s[n.id]=n}),t.projects=s},updateProject:(t,e)=>{t.projects[e.payload.id]=e.payload},deleteProject:(t,e)=>{delete t.projects[e.payload.id]},acceptProjectInvite:(t,e)=>{if(e.payload in t.projects)t.projects[e.payload].invited=!1;else throw new Error("Accept project invite: user is not in this project")}}}),{setProjects:bl,updateProject:Tl,deleteProject:_l,acceptProjectInvite:Fl}=en.actions,Il=en.reducer,gt=t=>t.projectReducer.projects,Np=u.createSelector([gt],t=>g(Object.values(t))),Hp=t=>e=>e.projectReducer.projects[t],Rl=u.createSelector([xi],t=>Object.values(t).map(e=>e.user)),Pl=u.createSelector([Rl,yt],(t,e)=>t.reduce((s,n)=>({...s,[n]:e[n]}),{})),Wp=u.createSelector([At,Pl,yl],(t,e,s)=>g(Object.values(e).sort((n,a)=>{if(n.id===(t==null?void 0:t.id))return-1;if(a.id===(t==null?void 0:t.id))return 1;const c=s[n.id],r=s[a.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===Ft.ADMIN?-1:1}))),Ol={organizations:{}},tn=u.createSlice({name:"organizations",initialState:Ol,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ol)),reducers:{setOrganizations:(t,e)=>{for(const s of e.payload)t.organizations[s.id]=s}}}),{setOrganizations:vl}=tn.actions,wl=t=>t.organizationReducer.organizations,El=u.createSelector([wl],t=>Object.values(t)),Kp=t=>e=>e.organizationReducer.organizations[t],Yp=u.createSelector([El],t=>g(Object.values(t).filter(e=>e.has_access))),jl=u.createSelector([Xi],t=>Object.values(t).map(e=>e.user)),Jp=S(u.createSelector([gt,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.organization_owner===e)))),Xp=S(u.createSelector([pt,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.organization_owner===e)))),ql=u.createSelector([jl,yt],(t,e)=>Fe(t.reduce((s,n)=>({...s,[n]:e[n]}),{}))),Qp=u.createSelector([At,ql,ll],(t,e,s)=>g(Object.values(e).sort((n,a)=>{if(n.id===(t==null?void 0:t.id))return-1;if(a.id===(t==null?void 0:t.id))return 1;const c=s[n.id],r=s[a.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===It.ADMIN?-1:1}))),Ml=tn.reducer,kl=(t,e,s)=>{const n=t.uuid?t:{...t,uuid:O.v4()};return{payload:n,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:n,BASE_URL:e,serviceName:s}}}}},Cl={deletedRequests:[],latestRetryTime:0},sn=u.createSlice({name:"outbox",initialState:Cl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Cl)),reducers:{enqueueRequest:{reducer:(t,e)=>t,prepare:t=>{console.debug("Preparing to enqueue request",t);const{BASE_URL:e,serviceName:s,...n}=t;return kl(n,e,s)}},markForDeletion(t,e){t.deletedRequests.push(e.payload)},markAsDeleted(t,e){const s=t.deletedRequests.indexOf(e.payload);s!==-1&&t.deletedRequests.splice(s,1)},_setLatestRetryTime:(t,e)=>{t.latestRetryTime=e.payload}}}),Zp=t=>t.outboxReducer.deletedRequests,xp=t=>t.outboxReducer.latestRetryTime,{enqueueRequest:Dl,markForDeletion:eA,markAsDeleted:zl,_setLatestRetryTime:Vl}=sn.actions,Ul=sn.reducer,de=I(t=>t.offline_id),$l=de.getInitialState({}),nn=u.createSlice({name:"projectAttachments",initialState:$l,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,$l)),reducers:{initializeProjectAttachments:de.initialize,addProjectAttachment:de.addOne,addProjectAttachments:de.addMany,setProjectAttachment:de.setOne,setProjectAttachments:de.setMany,updateProjectAttachment:de.updateOne,updateProjectAttachments:de.updateMany,deleteProjectAttachment:de.deleteOne,deleteProjectAttachments:de.deleteMany}}),{initializeProjectAttachments:Bl,addProjectAttachment:tA,addProjectAttachments:Gl,setProjectAttachment:Ll,setProjectAttachments:Nl,updateProjectAttachment:sA,updateProjectAttachments:Hl,deleteProjectAttachment:Wl,deleteProjectAttachments:an}=nn.actions,Kl=t=>t.projectAttachmentReducer.instances,Yl=u.createSelector([Kl],t=>Object.values(t)),Jl=t=>e=>e.projectAttachmentReducer.instances[t],Xl=S(u.createSelector([Yl,(t,e)=>e],(t,e)=>g(t.filter(({project:s})=>e===s)))),Ql=nn.reducer,oe=I(t=>t.offline_id),Zl=oe.getInitialState({activeProjectFileId:null,isImportingProjectFile:!1}),cn=u.createSlice({name:"projectFiles",initialState:Zl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Zl)),reducers:{initializeProjectFiles:oe.initialize,setProjectFile:oe.setOne,setProjectFiles:oe.setMany,addProjectFile:oe.addOne,addProjectFiles:oe.addMany,updateProjectFile:oe.updateOne,updateProjectFiles:oe.updateMany,deleteProjectFile:oe.deleteOne,deleteProjectFiles:oe.deleteMany,setIsImportingProjectFile:(t,e)=>{t.isImportingProjectFile=e.payload},saveActiveProjectFileBounds:(t,e)=>{const s=t.activeProjectFileId;if(!s)throw new Error("Tried to save bounds for active project file, but no active project file was set.");if(!t.instances[s])throw new Error(`Tried to save bounds for active project file, but project file with ID ${s}
2
- doesn't exist.`);t.instances[s].bounds=e.payload},setActiveProjectFileId:(t,e)=>{t.activeProjectFileId=e.payload},resetProjectFileObjectUrls:(t,...e)=>{for(const s in t.instances)delete t.instances[s].objectURL}}}),{initializeProjectFiles:xl,setProjectFile:iA,setProjectFiles:nA,addProjectFile:aA,addProjectFiles:eu,updateProjectFile:rn,updateProjectFiles:cA,deleteProjectFile:tu,deleteProjectFiles:su,setIsImportingProjectFile:iu,setActiveProjectFileId:nu,saveActiveProjectFileBounds:au,resetProjectFileObjectUrls:rA}=cn.actions,cu=t=>t.projectFileReducer.instances,ru=u.createSelector([cu],t=>g(Object.values(t).sort((e,s)=>e.z_index-s.z_index))),dA=t=>e=>e.projectFileReducer.instances[t],oA=t=>t.projectFileReducer.activeProjectFileId,lA=t=>t.projectFileReducer.isImportingProjectFile,du=cn.reducer,uA={isRehydrated:!1},dn=u.createSlice({name:"rehydrated",initialState:uA,reducers:{setRehydrated:(t,e)=>{t.isRehydrated=e.payload}}}),{setRehydrated:hA}=dn.actions,mA=t=>t.rehydratedReducer.isRehydrated,ou=dn.reducer,Oe=I(t=>t.offline_id),lu=Oe.getInitialState({}),on=u.createSlice({name:"teams",initialState:lu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,lu)),reducers:{setTeam:Oe.setOne,initializeTeams:Oe.initialize,addTeam:Oe.addOne,updateTeam:Oe.updateOne,deleteTeam:Oe.deleteOne}}),{setTeam:ve,initializeTeams:uu,addTeam:hu,updateTeam:ln,deleteTeam:un}=on.actions,hn=t=>t.teamReducer.instances,mn=u.createSelector([hn],t=>Object.values(t)),we=t=>e=>e.teamReducer.instances[t],fA=S(u.createSelector([hn,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectTeamsByIds: No team exists with the id",n)}return g(s)})),pA=S(u.createSelector([mn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),AA=S(u.createSelector([mn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.members.includes(e))))),mu=on.reducer,yA={version:0},fu=u.createSlice({name:"versioning",initialState:yA,reducers:{}}),pu=fu.reducer;let Au;function SA(t){Au=t}function We(){return Au}let yu;function gA(t){yu=t}function bA(){return yu}const Su={};class gu{constructor(e){y(this,"client");Su[this.constructor.name]=this,this.client=e}async enqueueRequest(e){return this.client.enqueueRequest(e,this.host,this.constructor.name)}dispatch(e){this.client.store.dispatch(e)}}const bu="versioning",Tu=()=>Iu.length-1,_u=t=>(t[bu]={version:Tu()},t),Fu=()=>_u({}),TA=t=>(t.outboxReducer&&(t.outboxReducer.deletedRequests=[]),t),_A=t=>e=>{var s;return e===void 0&&(e={}),((s=e[bu])==null?void 0:s.version)===Tu()?e:t(e)},Iu=[_u,Fu,Fu,TA],FA=Object.fromEntries(Iu.map((t,e)=>[e,_A(t)])),fn="versioning",Ru={[fn]:pu,fileReducer:Rr,authReducer:Hc,categoryReducer:Xc,assetReducer:Ba,assetAttachmentReducer:Qn,assetStageCompletionReducer:Wa,assetStageReducer:Za,assetTypeReducer:Gc,assetTypeAttachmentReducer:lc,issueReducer:Zd,issueAttachmentReducer:jd,issueTypeReducer:Go,issueTypeAttachmentReducer:oo,organizationReducer:Ml,outboxReducer:Ul,projectReducer:Il,projectAttachmentReducer:Ql,projectAccessReducer:Sl,organizationAccessReducer:ul,projectFileReducer:du,rehydratedReducer:ou,formReducer:Lr,formRevisionReducer:$r,formRevisionAttachmentReducer:qr,formSubmissionAttachmentReducer:Qr,formSubmissionReducer:nd,userReducer:al,emailDomainsReducer:br,licenseReducer:tl,documentsReducer:fr,documentAttachmentReducer:rr,teamReducer:mu,agentsReducer:Gn,issueCommentReducer:Wd,issueCommentAttachmentReducer:Bd,issueUpdateReducer:Qo,geoImageReducer:fd,issueAssociationReducer:_d,issueTypeFieldsReducer:vo,issueTypeFieldValuesReducer:To,issueTypeFieldsAttachmentReducer:yo,issueTypeFieldValuesAttachmentReducer:Co,assetTypeFieldsReducer:Rc,assetTypeFieldValuesReducer:Uc,assetTypeFieldsAttachmentReducer:Sc,assetTypeFieldValuesAttachmentReducer:qc,assetProcedureReducer:Da,assetProcedureInstanceReducer:qa,assetProcedureFieldsReducer:ha,assetProcedureFieldValuesReducer:Pa,assetProcedureFieldsAttachmentReducer:aa,assetProcedureFieldValuesAttachmentReducer:ga},Pu=u.combineReducers(Ru),Ou="RESET",IA=(t,e)=>e.type==="auth/setLoggedIn"&&!e.payload?Pu(void 0,e):Pu(t,e);let pn=null;function ge(){const t=We();if(!t)return console.warn("Client store not set; cannot get outbox coordinator yet."),null;if(pn)return pn;const e=t.getState().offline.outbox,s=je._fromOutbox(e);return pn=s,s}const RA=t=>{if(t)throw t;const e=We();e?e.dispatch({type:"rehydrated/setRehydrated",payload:!0}):console.error("Client store not set")},vu=(t,e,s)=>{const n=ge();return n?(n.addRequest(e),n.getQueue()):(console.warn("Outbox coordinator not set; cannot enqueue request yet."),[])},wu=(t,e,s)=>{const n=ge();if(!n)return console.warn("Outbox coordinator not set; cannot dequeue request yet."),[];const c=e.meta.offlineAction.payload.uuid;return n.remove(c),n.getQueue()};async function PA(t,e){if(!e.payload)throw new Error("Received empty payload");return CA(e)}const OA={...Tn,effect:PA,discard:yn,returnPromises:!0,persistCallback:RA,retry:zA,persistOptions:{storage:zu},queue:{...Tn.queue,enqueue:vu,dequeue:wu,peek:(...t)=>DA(...t)}},vA=Vu(FA,fn),wA=u.compose(Du.offline(OA),vA);function EA(t){function e(s){return typeof s=="object"&&s!==null&&["ok","redirect","clientError","serverError","error"].every(a=>a in s)}if(e(t))return t;if(typeof t=="object"&&t!==null){const s=t;if(e(s.response))return s.response;if(s.response&&e(s.response.response))return s.response.response}}async function An(t,e){const s=Su[t.meta.offline.effect.serviceName];if(!s)throw new Error(`Service ${t.meta.offline.effect.serviceName} not found`);const n=s instanceof R;if(e.store.getState().outboxReducer.deletedRequests.includes(t.payload.uuid))throw new Error("Request was marked for deletion");n&&t.payload.checkAuth!==!1&&await s.auth.prepareAuth();const c={queryParams:"",isAuthNeeded:!0},r=t.meta.offline.effect,{payload:o,headers:m,method:d,queryParams:h,attachmentHash:f,isExternalUrl:p,isAuthNeeded:A,isResponseBlob:T}={...c,...r.request},_=r.request;let b=_.url;const P=f?await e.files.fetchCache(f):void 0;if(f&&!P)throw new Error(`Cannot upload file ${f} because it's not cached.`);!p&&!b.startsWith("http")&&(!b.startsWith("/")&&!b.startsWith("blob:")&&(b="/"+b),b=t.meta.offline.effect.BASE_URL+b);const M=E=>{if(f){const le=_.s3url;if(!le)throw new Error(`No S3 URL for file ${f}`);if("warning"in le)throw new Error(`S3 URL warning for file ${f}`);if(!P)throw new Error(`No file for file ${f}`);const Ye=le.fields["x-amz-checksum-sha1"];if(!Ye)throw new Error(`No checksum for file ${f}`);return E.set("x-amz-checksum-sha1",Ye).field({...o,...le.fields}).attach("file",P)}return E.send(o)},Hy={[l.GET]:()=>T?_e.get(b.toString()).responseType("blob"):_e.get(b.toString()),[l.POST]:()=>{const E=_e.post(b.toString());return M(E)},[l.PATCH]:()=>{const E=_e.patch(b.toString());return M(E)},[l.PUT]:()=>{const E=_e.put(b.toString());return M(E)},[l.DELETE]:()=>{const E=_e.delete(b.toString());return M(E)}}[d];let Te=Hy();if(A&&n){const E=s.auth.getAuthHeader();Te=Te.set("Authorization",E)}m&&(Te=Te.set(m));try{return await Te.query(h)}catch(E){const le=EA(E),Ye=le==null?void 0:le.status;if(n&&Ye===401)return await s.auth.handleUnauthorized(Te,le),Te.query(h);throw new q({response:le,innerError:E,discard:ju.includes(Ye)})}}class jA{constructor(e){y(this,"_all");y(this,"_previous");this._all=[e],this._previous=e,this.then=this.then.bind(this),this.compile=this.compile.bind(this)}then(e){return this._previous&&(this._previous.next=e),this._all.push(e),this._previous=e,{then:this.then,compile:this.compile}}compile(){return this._all}}class Eu{constructor(){y(this,"next");this.next=null}then(e){return new jA(this).then(e)}async run(e){if(this.next)return this.next.run(e);{if(console.debug("Middleware finished. Performing request:",e),!We())throw new Error("Client store not set");const n=bA();if(!n)throw new Error("Client SDK not set");return An(e,n)}}}class qA extends Eu{async run(e){return super.run(e)}}class MA extends Eu{async run(e){return super.run(e)}}const kA=new qA().then(new MA).compile();function CA(t){var e;return(e=kA[0])==null?void 0:e.run(t)}const ju=[400,409,403,404,405,500];function yn(t,e,s=0){var d;if(console.debug("Considering discarding request due to error:",t,`(${typeof t})`,`
1
+ (function(i,j){typeof exports=="object"&&typeof module<"u"?j(exports,require("@redux-offline/redux-offline/lib/types"),require("@reduxjs/toolkit"),require("superagent"),require("uuid"),require("file-saver"),require("@redux-offline/redux-offline"),require("@redux-offline/redux-offline/lib/defaults"),require("buffer"),require("localforage"),require("redux-persist-migrate"),require("@overmap-ai/forms"),require("idb"),require("@redux-offline/redux-offline/lib/constants"),require("jwt-decode"),require("dependency-graph"),require("@tiptap/core")):typeof define=="function"&&define.amd?define(["exports","@redux-offline/redux-offline/lib/types","@reduxjs/toolkit","superagent","uuid","file-saver","@redux-offline/redux-offline","@redux-offline/redux-offline/lib/defaults","buffer","localforage","redux-persist-migrate","@overmap-ai/forms","idb","@redux-offline/redux-offline/lib/constants","jwt-decode","dependency-graph","@tiptap/core"],j):(i=typeof globalThis<"u"?globalThis:i||self,j(i["overmap-core"]={},null,i.toolkit,i.request,i.uuid,i.fileSaver,i.reduxOffline,i.offlineConfig,null,i.localforage,i.createMigration,null,i.idb,i.constants,i.jwtDecode,i.dependencyGraph))})(this,function(i,j,h,Oe,fe,Ul,$l,On,TS,Bl,Gl,bS,Ll,Nl,Hl,Wl){"use strict";var SS=Object.defineProperty;var gS=(i,j,h)=>j in i?SS(i,j,{enumerable:!0,configurable:!0,writable:!0,value:h}):i[j]=h;var f=(i,j,h)=>gS(i,typeof j!="symbol"?j+"":j,h);var Vl;const vn=Object.freeze([]),_n=Object.freeze({});var vt=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(vt||{}),_t=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(_t||{}),l=(t=>(t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.DELETE="DELETE",t))(l||{}),wn=(t=>(t.Issue="issue",t.Asset="asset",t.AssetType="asset_type",t.Project="project",t.Document="document",t))(wn||{}),wt=(t=>(t[t.LOWEST=0]="LOWEST",t[t.LOW=2]="LOW",t[t.MEDIUM=4]="MEDIUM",t[t.HIGH=6]="HIGH",t[t.HIGHEST=8]="HIGHEST",t))(wt||{}),Et=(t=>(t[t.BACKLOG=0]="BACKLOG",t[t.SELECTED=2]="SELECTED",t[t.DONE=4]="DONE",t))(Et||{}),_=(t=>(t.STATUS="status",t.PRIORITY="priority",t.CATEGORY="category",t.DESCRIPTION="description",t.TITLE="title",t.ASSIGNED_TO="assigned_to",t.DUE_DATE="due_date",t))(_||{}),En=(t=>(t.COMPLETED="checkout.completed",t.CLOSED="checkout.closed",t))(En||{}),jn=(t=>(t[t.PRO=0]="PRO",t))(jn||{}),qn=(t=>(t[t.ACTIVE=0]="ACTIVE",t[t.PAUSED=2]="PAUSED",t[t.CANCELLED=4]="CANCELLED",t[t.INACTIVE=6]="INACTIVE",t[t.PAST_DUE=8]="PAST_DUE",t))(qn||{});const Kl=Et.BACKLOG,Yl=wt.MEDIUM,Mn=6e4;function I(t){return{addOne:(p,A)=>{const y=t(A.payload);p.instances[y]=A.payload},addMany:(p,A)=>{for(const y of A.payload){const b=t(y);p.instances[b]=y}},setOne:(p,A)=>{const y=t(A.payload);p.instances[y]=A.payload},setMany:(p,A)=>{for(const y of A.payload){const b=t(y);p.instances[b]=y}},updateOne:(p,A)=>{const y=t(A.payload);p.instances[y]=A.payload},updateMany:(p,A)=>{for(const y of A.payload){const b=t(y);p.instances[b]=y}},deleteOne:(p,A)=>{delete p.instances[A.payload]},deleteMany:(p,A)=>{for(const y of A.payload)delete p.instances[y]},initialize:(p,A)=>{p.instances={};for(const y of A.payload){const b=t(y);p.instances[b]=y}},getInitialState:p=>({...p,instances:{}})}}function Jl(){return{initializeSelection:(m,d)=>{m.selection=Array.from(new Set(d.payload))},selectOne:(m,d)=>{new Set(m.selection).has(d.payload)||m.selection.push(d.payload)},selectMany:(m,d)=>{const o=new Set(m.selection);for(const p of d.payload)o.has(p)||o.add(p);m.selection=Array.from(o)},unselectOne:(m,d)=>{const o=new Set(m.selection);o.has(d.payload)&&(o.delete(d.payload),m.selection=Array.from(o))},unselectMany:(m,d)=>{const o=new Set(m.selection);for(const p of d.payload)o.has(p)&&o.delete(p);m.selection=Array.from(o)},toggleOne:(m,d)=>{const o=new Set(m.selection);o.has(d.payload)?o.delete(d.payload):o.add(d.payload),m.selection=Array.from(o)},toggleMany:(m,d)=>{const o=new Set(m.selection);for(const p of d.payload)o.has(p)?o.delete(p):o.add(p);m.selection=Array.from(o)},getInitialState:m=>({...m,selection:[]})}}Vl=Symbol.toStringTag;class kn{constructor(){f(this,Vl,"Promise");f(this,"_promise");f(this,"_resolve");f(this,"_reject");f(this,"_state","pending");this._resolve=null,this._reject=null,this._promise=new Promise((e,s)=>{this._resolve=e,this._reject=s})}get state(){return this._state}then(e,s){return this._promise.then(e,s)}catch(e){return this._promise.catch(e)}resolve(e){if(!this._resolve)throw new Error("No resolve callback");this._resolve(e),this._state="fulfilled"}reject(e){if(!this._reject)throw e;this._reject(e),this._state="rejected"}finally(e){throw new Error("`finally` not implemented")}}const Xl=t=>({type:"Point",coordinates:t}),Ql=t=>({type:"MultiPoint",coordinates:t}),Zl=(t,e)=>t[0]===e[0]&&t[1]===e[1];let jt=!1;["true","1"].includes("".toLowerCase())&&(jt=!0);function xl(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;const s=Object.keys(t),n=Object.keys(e),a=s.length;if(a!==n.length)return!1;for(let c=0;c<a;c++){const r=s[c];if(!Object.prototype.hasOwnProperty.call(e,r)||t[r]!==e[r])return!1}return!0}function qt(t){const e={};return function(){const s=Array.prototype.slice.call(arguments);return s in e?(jt&&console.debug(`Memoization debug: Using memorized return value for ${t.toString()}(`,s,")"),e[s]):(jt&&console.debug(`Memoization debug: Cache miss! Memoizing ${t.toString()}(`,s,")"),e[s]=t.apply(this,s))}}function eh(t,e){if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(t[s]!==e[s])return!1;return!0}const g=t=>t.length===0?vn:t,ve=t=>Object.keys(t).length===0?_n:t,Cn=qt(t=>{if(!t)return"";const e=new Date(t),s=e.getFullYear()===Mt.getFullYear(),n={day:"numeric",month:"short"};return s||(n.year="numeric"),e.toLocaleDateString([],n)}),th=new Intl.RelativeTimeFormat([],{style:"long",numeric:"auto"}),sh=1e3*86400,Mt=new Date,ih=t=>new Date(t).toDateString()===Mt.toDateString(),nh=qt((t,e,s)=>{const n=Math.round((new Date(t).getTime()-Mt.getTime())/sh);return n<e||n>s?Cn(t):th.format(n,"days")});function ah(t){return new Uint8Array(t).reduce((s,n)=>s+n.toString(16).padStart(2,"0"),"")}const kt=async(t,e)=>{e||(e=await _e(t));let s=t.type;if(s.includes("/")&&(s=s.split("/")[1]),!s)throw new Error(`Could not extract file type from ${t.type}`);return`${e}.${s}`};function _e(t){return new Promise((e,s)=>{const n=new FileReader;n.onload=()=>{const a=n.result;if(!a){s(new Error("FileReader did not return a valid ArrayBuffer."));return}crypto.subtle.digest("SHA-1",a).then(c=>{const r=ah(c);e(r)})},n.readAsArrayBuffer(t)})}function ch(t){if(!t.name||!t.type||!t.size){const e="File has no name, type, and/or size";throw new Error(e)}return`${t.name}&${t.type}${t.size}`}function zn(t,e){return new File([t],e,{type:t.type})}function rh(t,e){const s=document.createElement("a");s.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(e)),s.setAttribute("download",t),s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s)}const dh=async t=>{const e={};for(const s of t){const n=await _e(s);e[n]={sha1:n,extension:s.name.split(".").pop()||"",file_type:s.type,size:s.size}}return Object.values(e)},Dn=async t=>(await fetch(t)).blob(),oh=t=>new Promise((e,s)=>{const n=new FileReader;n.onloadend=()=>{var a;e(((a=n.result)==null?void 0:a.toString())||"")},n.readAsDataURL(t)});function uh(t){const e=new Blob([t]);Ul.saveAs(e,t.name)}const Vn={};function lh(t,e,s,...n){const a=Vn[t];let c=!1;a?a[e]||(a[e]=!0,c=!0):(Vn[t]={[e]:!0},c=!0),c&&console[s](...n)}const Un=["created_at","updated_at","index","revision"];function R(t){return{...t,uuid:fe.v4()}}function $n(t){const e={};for(const s of t)e[s.uuid]=s;return e}function hh(t,e=void 0,s=255){let n=t.replace(/[^a-z0-9_\-.]/gi,"_").replace(/_{2,}/g,"_");if(!e){const c=t.split(".");c.length>1&&(e=c[c.length-1])}e&&!e.startsWith(".")&&(e="."+e);const a=e?e.length:0;return n.length+a>s&&(n=n.slice(0,s-a)+(e||"")),n}function mh(t){return t.toLowerCase().replace(" ","-")}function ph(t,e=!1){return t.normalize("NFKD").toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/[-\s]+/g,e?"_":"-")}function Ah(t,e){if(t.length<=e)return t;const s=t.slice(0,e-1);return s.slice(0,s.lastIndexOf(" "))+"…"}const S=t=>e=>s=>t(s,e);function Bn(t,e,s){return s.findIndex(n=>n.uuid===t.uuid)===e}function yh(t,e,s){return s.findIndex(n=>n.file_sha1===t.file_sha1)===e}const fh=/^.+@.+\..+$/;function v(t){const e={...t};for(const s of[...Un,"created_by"])s in e&&delete e[s];return e}const ze=I(t=>t.uuid),Gn=ze.getInitialState({}),Ct=h.createSlice({name:"agents",initialState:Gn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Gn)),reducers:{initializeConversations:ze.initialize,addConversation:ze.addOne,setConversation:ze.setOne,updateConversation:ze.updateOne}}),{initializeConversations:Ln,addConversation:Nn,setConversation:Hn,updateConversation:Wn}=Ct.actions,zt=t=>t.agentsReducer.instances,Sh=h.createSelector([zt],t=>Object.values(t)),gh=S(h.createSelector([zt,(t,e)=>e],(t,e)=>t[e])),Kn=Ct.reducer,C=I(t=>t.uuid),Yn=C.getInitialState({}),Dt=h.createSlice({name:"assetAttachments",initialState:Yn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Yn)),reducers:{initializeAssetAttachments:C.initialize,addAssetAttachment:C.addOne,addAssetAttachments:C.addMany,setAssetAttachment:C.setOne,setAssetAttachments:C.setMany,updateAssetAttachment:C.updateOne,updateAssetAttachments:C.updateMany,deleteAssetAttachment:C.deleteOne,deleteAssetAttachments:C.deleteMany}}),{initializeAssetAttachments:Vt,addAssetAttachment:Th,addAssetAttachments:Ut,setAssetAttachment:Jn,setAssetAttachments:bh,updateAssetAttachment:Ih,updateAssetAttachments:Xn,deleteAssetAttachment:Qn,deleteAssetAttachments:$t}=Dt.actions,Zn=t=>t.assetAttachmentReducer.instances,xn=h.createSelector([Zn],t=>Object.values(t)),ea=t=>e=>e.assetAttachmentReducer.instances[t],ta=S(h.createSelector([xn,(t,e)=>e],(t,e)=>g(t.filter(({asset:s})=>e===s)))),sa=Dt.reducer,z=I(t=>t.uuid),ia=z.getInitialState({}),Bt=h.createSlice({name:"assetProcedureFieldsAttachments",initialState:ia,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ia)),reducers:{initializeAssetProcedureFieldsAttachments:z.initialize,addAssetProcedureFieldsAttachment:z.addOne,addAssetProcedureFieldsAttachments:z.addMany,setAssetProcedureFieldsAttachment:z.setOne,setAssetProcedureFieldsAttachments:z.setMany,updateAssetProcedureFieldsAttachment:z.updateOne,updateAssetProcedureFieldsAttachments:z.updateMany,deleteAssetProcedureFieldsAttachment:z.deleteOne,deleteAssetProcedureFieldsAttachments:z.deleteMany}}),{initializeAssetProcedureFieldsAttachments:na,addAssetProcedureFieldsAttachment:Fh,addAssetProcedureFieldsAttachments:aa,setAssetProcedureFieldsAttachment:Rh,setAssetProcedureFieldsAttachments:Ph,updateAssetProcedureFieldsAttachment:Oh,updateAssetProcedureFieldsAttachments:ca,deleteAssetProcedureFieldsAttachment:vh,deleteAssetProcedureFieldsAttachments:ra}=Bt.actions,da=t=>t.assetProcedureFieldsAttachmentReducer.instances,oa=h.createSelector([da],t=>Object.values(t)),_h=S(h.createSelector([oa,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),wh=t=>e=>e.assetProcedureFieldsAttachmentReducer.instances[t],ua=Bt.reducer,D=I(t=>t.uuid),la=D.getInitialState({}),Gt=h.createSlice({name:"assetProcedureFields",initialState:la,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,la)),reducers:{initializeAssetProcedureFields:D.initialize,addAssetProcedureFields:D.addOne,addAssetProcedureFieldsMany:D.addMany,setAssetProcedureFields:D.setOne,setAssetProcedureFieldsMany:D.setMany,updateAssetProcedureFields:D.updateOne,updateAssetProcedureFieldsMany:D.updateMany,deleteAssetProcedureFields:D.deleteOne,deleteAssetProcedureFieldsMany:D.deleteMany}}),{initializeAssetProcedureFields:ha,addAssetProcedureFields:ma,addAssetProcedureFieldsMany:Eh,setAssetProcedureFields:jh,setAssetProcedureFieldsMany:qh,updateAssetProcedureFields:pa,updateAssetProcedureFieldsMany:Mh,deleteAssetProcedureFields:Aa,deleteAssetProcedureFieldsMany:kh}=Gt.actions,ya=t=>t.assetProcedureFieldsReducer.instances,Lt=h.createSelector([ya],t=>Object.values(t)),Ch=S(h.createSelector([Lt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),zh=S(h.createSelector([Lt,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_procedure===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),Dh=t=>e=>e.assetProcedureFieldsReducer.instances[t],fa=Gt.reducer,V=I(t=>t.uuid),Sa=V.getInitialState({}),Nt=h.createSlice({name:"assetProcedureFieldValuesAttachments",initialState:Sa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Sa)),reducers:{initializeAssetProcedureFieldValuesAttachments:V.initialize,addAssetProcedureFieldValuesAttachment:V.addOne,addAssetProcedureFieldValuesAttachments:V.addMany,setAssetProcedureFieldValuesAttachment:V.setOne,setAssetProcedureFieldValuesAttachments:V.setMany,updateAssetProcedureFieldValuesAttachment:V.updateOne,updateAssetProcedureFieldValuesAttachments:V.updateMany,deleteAssetProcedureFieldValuesAttachment:V.deleteOne,deleteAssetProcedureFieldValuesAttachments:V.deleteMany}}),{initializeAssetProcedureFieldValuesAttachments:ga,addAssetProcedureFieldValuesAttachment:Vh,addAssetProcedureFieldValuesAttachments:xe,setAssetProcedureFieldValuesAttachment:Uh,setAssetProcedureFieldValuesAttachments:$h,updateAssetProcedureFieldValuesAttachment:Bh,updateAssetProcedureFieldValuesAttachments:Ta,deleteAssetProcedureFieldValuesAttachment:Gh,deleteAssetProcedureFieldValuesAttachments:et}=Nt.actions,Ht=t=>t.assetProcedureFieldValuesAttachmentReducer.instances,ba=h.createSelector([Ht],t=>Object.values(t)),Lh=t=>e=>e.assetProcedureFieldValuesAttachmentReducer.instances[t],Ia=S(h.createSelector([Ht,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.uuid)))})),Fa=S(h.createSelector([ba,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),Ra=Nt.reducer,U=I(t=>t.uuid),Pa=U.getInitialState({}),Wt=h.createSlice({name:"assetProcedureFieldValues",initialState:Pa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Pa)),reducers:{initializeAssetProcedureFieldValues:U.initialize,addAssetProcedureFieldValues:U.addOne,addAssetProcedureFieldValuesMany:U.addMany,setAssetProcedureFieldValues:U.setOne,setAssetProcedureFieldValuesMany:U.setMany,updateAssetProcedureFieldValues:U.updateOne,updateAssetProcedureFieldValuesMany:U.updateMany,deleteAssetProcedureFieldValues:U.deleteOne,deleteAssetProcedureFieldValuesMany:U.deleteMany}}),{initializeAssetProcedureFieldValues:Oa,addAssetProcedureFieldValues:Kt,addAssetProcedureFieldValuesMany:va,setAssetProcedureFieldValues:Nh,setAssetProcedureFieldValuesMany:Hh,updateAssetProcedureFieldValues:De,updateAssetProcedureFieldValuesMany:_a,deleteAssetProcedureFieldValues:Yt,deleteAssetProcedureFieldValuesMany:wa}=Wt.actions,Ea=t=>t.assetProcedureFieldValuesReducer.instances,Jt=h.createSelector([Ea],t=>Object.values(t)),Wh=S(h.createSelector([Jt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),Kh=S(h.createSelector([Jt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure_instance===e)))),Xt=t=>e=>e.assetProcedureFieldValuesReducer.instances[t],ja=Wt.reducer,$=I(t=>t.uuid),qa=$.getInitialState({}),Qt=h.createSlice({name:"assetProcedureInstances",initialState:qa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,qa)),reducers:{initializeAssetProcedureInstances:$.initialize,addAssetProcedureInstance:$.addOne,addAssetProcedureInstances:$.addMany,setAssetProcedureInstance:$.setOne,setAssetProcedureInstances:$.setMany,updateAssetProcedureInstance:$.updateOne,updateAssetProcedureInstances:$.updateMany,deleteAssetProcedureInstance:$.deleteOne,deleteAssetProcedureInstances:$.deleteMany}}),{initializeAssetProcedureInstances:Ma,addAssetProcedureInstance:Zt,addAssetProcedureInstances:ka,updateAssetProcedureInstance:Ve,updateAssetProcedureInstances:Yh,deleteAssetProcedureInstance:xt,deleteAssetProcedureInstances:Ca,setAssetProcedureInstance:Jh,setAssetProcedureInstances:Xh}=Qt.actions,es=t=>t.assetProcedureInstanceReducer.instances,ts=h.createSelector([es],t=>Object.values(t)),za=S(h.createSelector([ts,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),Qh=S(h.createSelector([ts,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),ss=t=>e=>e.assetProcedureInstanceReducer.instances[t],Zh=S(h.createSelector([es,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return g(s)})),Da=Qt.reducer,B=I(t=>t.uuid),Va=B.getInitialState({}),is=h.createSlice({name:"assetProcedures",initialState:Va,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Va)),reducers:{initializeAssetProcedures:B.initialize,addAssetProcedure:B.addOne,addAssetProcedures:B.addMany,setAssetProcedure:B.setOne,setAssetProcedures:B.setMany,updateAssetProcedure:B.updateOne,updateAssetProcedures:B.updateMany,deleteAssetProcedure:B.deleteOne,deleteAssetProcedures:B.deleteMany}}),{initializeAssetProcedures:Ua,addAssetProcedure:ns,addAssetProcedures:xh,updateAssetProcedure:Ue,updateAssetProcedures:em,deleteAssetProcedure:as,deleteAssetProcedures:tm,setAssetProcedure:sm,setAssetProcedures:im}=is.actions,cs=t=>t.assetProcedureReducer.instances,$a=h.createSelector([cs],t=>Object.values(t)),nm=S(h.createSelector([$a,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),rs=t=>e=>e.assetProcedureReducer.instances[t],am=S(h.createSelector([cs,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return g(s)})),Ba=is.reducer,G=I(t=>t.uuid),Ga=G.getInitialState({}),ds=h.createSlice({name:"assets",initialState:Ga,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ga)),reducers:{initializeAssets:G.initialize,addAsset:G.addOne,addAssets:G.addMany,setAsset:G.setOne,setAssets:G.setMany,updateAsset:G.updateOne,updateAssets:G.updateMany,deleteAsset:G.deleteOne,deleteAssets:G.deleteMany}}),{initializeAssets:La,addAsset:os,addAssets:us,updateAsset:$e,updateAssets:cm,deleteAsset:ls,deleteAssets:Na,setAsset:rm,setAssets:dm}=ds.actions,hs=t=>t.assetReducer.instances,Ha=h.createSelector([hs],t=>g(Object.values(t))),ms=S(h.createSelector([Ha,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),ps=t=>e=>e.assetReducer.instances[t],om=S(h.createSelector([hs,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return g(s)})),um=t=>e=>ms(t)(e).length,Wa=ds.reducer,Ae=I(t=>t.uuid),Ka=Ae.getInitialState({}),As=h.createSlice({name:"assetStageCompletions",initialState:Ka,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ka)),reducers:{initializeAssetStageCompletions:Ae.initialize,addAssetStageCompletion:Ae.addOne,addAssetStageCompletions:Ae.addMany,updateAssetStageCompletion:Ae.updateOne,updateAssetStageCompletions:Ae.updateMany,deleteAssetStageCompletion:Ae.deleteOne,deleteAssetStageCompletions:Ae.deleteMany}}),{initializeAssetStageCompletions:Ya,addAssetStageCompletion:ys,addAssetStageCompletions:fs,updateAssetStageCompletion:Ja,updateAssetStageCompletions:Xa,deleteAssetStageCompletion:Ss,deleteAssetStageCompletions:gs}=As.actions,Qa=As.reducer,Ts=t=>t.assetStageCompletionReducer.instances,lm=h.createSelector([Ts],t=>Object.values(t)),Za=t=>e=>e.assetStageCompletionReducer.instances[t],xa=S(h.createSelector([Ts,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.uuid)))})),L=I(t=>t.uuid),ec=L.getInitialState({}),bs=h.createSlice({name:"assetStages",initialState:ec,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ec)),reducers:{initializeAssetStages:L.initialize,setAssetStage:L.setOne,setAssetStages:L.setMany,addAssetStage:L.addOne,addAssetStages:L.addMany,updateAssetStage:L.updateOne,updateAssetStages:L.updateMany,deleteAssetStage:L.deleteOne,deleteAssetStages:L.deleteMany}}),{initializeAssetStages:tc,setAssetStage:sc,setAssetStages:hm,addAssetStage:mm,addAssetStages:Is,updateAssetStage:Fs,updateAssetStages:tt,deleteAssetStage:pm,deleteAssetStages:Rs}=bs.actions,ic=bs.reducer,st=t=>t.assetStageReducer.instances,nc=t=>e=>e.assetStageReducer.instances[t],ac=h.createSelector([st],t=>Object.values(t)),Am=S(h.createSelector([st,(t,e)=>e],(t,e)=>{const s={};for(const[n,a]of Object.entries(t))a.asset_procedure===e&&(s[n]=a);return ve(s)})),ym=S(h.createSelector([ac,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),Ps=S(h.createSelector([st,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectStagesFromStageIds: No stage exists with the id",n)}return g(s)})),N=I(t=>t.uuid),cc=N.getInitialState({}),Os=h.createSlice({name:"assetTypeAttachments",initialState:cc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,cc)),reducers:{initializeAssetTypeAttachments:N.initialize,addAssetTypeAttachment:N.addOne,addAssetTypeAttachments:N.addMany,setAssetTypeAttachment:N.setOne,setAssetTypeAttachments:N.setMany,updateAssetTypeAttachment:N.updateOne,updateAssetTypeAttachments:N.updateMany,deleteAssetTypeAttachment:N.deleteOne,deleteAssetTypeAttachments:N.deleteMany}}),{initializeAssetTypeAttachments:rc,addAssetTypeAttachment:fm,addAssetTypeAttachments:vs,setAssetTypeAttachment:dc,setAssetTypeAttachments:Sm,updateAssetTypeAttachment:gm,updateAssetTypeAttachments:oc,deleteAssetTypeAttachment:uc,deleteAssetTypeAttachments:_s}=Os.actions,lc=t=>t.assetTypeAttachmentReducer.instances,hc=h.createSelector([lc],t=>Object.values(t)),mc=t=>e=>e.assetTypeAttachmentReducer.instances[t],pc=S(h.createSelector([hc,(t,e)=>e],(t,e)=>g(t.filter(({asset_type:s})=>e===s)))),Ac=Os.reducer,H=I(t=>t.uuid),yc=H.getInitialState({}),ws=h.createSlice({name:"assetTypeFieldsAttachments",initialState:yc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,yc)),reducers:{initializeAssetTypeFieldsAttachments:H.initialize,addAssetTypeFieldsAttachment:H.addOne,addAssetTypeFieldsAttachments:H.addMany,setAssetTypeFieldsAttachment:H.setOne,setAssetTypeFieldsAttachments:H.setMany,updateAssetTypeFieldsAttachment:H.updateOne,updateAssetTypeFieldsAttachments:H.updateMany,deleteAssetTypeFieldsAttachment:H.deleteOne,deleteAssetTypeFieldsAttachments:H.deleteMany}}),{initializeAssetTypeFieldsAttachments:fc,addAssetTypeFieldsAttachment:Tm,addAssetTypeFieldsAttachments:Sc,setAssetTypeFieldsAttachment:bm,setAssetTypeFieldsAttachments:Im,updateAssetTypeFieldsAttachment:Fm,updateAssetTypeFieldsAttachments:gc,deleteAssetTypeFieldsAttachment:Rm,deleteAssetTypeFieldsAttachments:Tc}=ws.actions,bc=t=>t.assetTypeFieldsAttachmentReducer.instances,Ic=h.createSelector([bc],t=>Object.values(t)),Pm=S(h.createSelector([Ic,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),Om=t=>e=>e.assetTypeFieldsAttachmentReducer.instances[t],Fc=ws.reducer,W=I(t=>t.uuid),Rc=W.getInitialState({}),Es=h.createSlice({name:"assetTypeFields",initialState:Rc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Rc)),reducers:{initializeAssetTypeFields:W.initialize,addAssetTypeFields:W.addOne,addAssetTypeFieldsMany:W.addMany,setAssetTypeFields:W.setOne,setAssetTypeFieldsMany:W.setMany,updateAssetTypeFields:W.updateOne,updateAssetTypeFieldsMany:W.updateMany,deleteAssetTypeFields:W.deleteOne,deleteAssetTypeFieldsMany:W.deleteMany}}),{initializeAssetTypeFields:Pc,addAssetTypeFields:Oc,addAssetTypeFieldsMany:vm,setAssetTypeFields:_m,setAssetTypeFieldsMany:wm,updateAssetTypeFields:vc,updateAssetTypeFieldsMany:Em,deleteAssetTypeFields:_c,deleteAssetTypeFieldsMany:jm}=Es.actions,wc=t=>t.assetTypeFieldsReducer.instances,it=h.createSelector([wc],t=>Object.values(t)),qm=S(h.createSelector([it,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),Mm=S(h.createSelector([it,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),km=t=>e=>e.assetTypeFieldsReducer.instances[t],Ec=Es.reducer,K=I(t=>t.uuid),jc=K.getInitialState({}),js=h.createSlice({name:"assetTypeFieldValuesAttachments",initialState:jc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,jc)),reducers:{initializeAssetTypeFieldValuesAttachments:K.initialize,addAssetTypeFieldValuesAttachment:K.addOne,addAssetTypeFieldValuesAttachments:K.addMany,setAssetTypeFieldValuesAttachment:K.setOne,setAssetTypeFieldValuesAttachments:K.setMany,updateAssetTypeFieldValuesAttachment:K.updateOne,updateAssetTypeFieldValuesAttachments:K.updateMany,deleteAssetTypeFieldValuesAttachment:K.deleteOne,deleteAssetTypeFieldValuesAttachments:K.deleteMany}}),{initializeAssetTypeFieldValuesAttachments:qc,addAssetTypeFieldValuesAttachment:Cm,addAssetTypeFieldValuesAttachments:nt,setAssetTypeFieldValuesAttachment:zm,setAssetTypeFieldValuesAttachments:Dm,updateAssetTypeFieldValuesAttachment:Vm,updateAssetTypeFieldValuesAttachments:Mc,deleteAssetTypeFieldValuesAttachment:Um,deleteAssetTypeFieldValuesAttachments:at}=js.actions,qs=t=>t.assetTypeFieldValuesAttachmentReducer.instances,kc=h.createSelector([qs],t=>Object.values(t)),$m=t=>e=>e.assetTypeFieldValuesAttachmentReducer.instances[t],Cc=S(h.createSelector([qs,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.uuid)))})),zc=S(h.createSelector([kc,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),Dc=js.reducer,Y=I(t=>t.uuid),Vc=Y.getInitialState({}),Ms=h.createSlice({name:"assetTypeFieldValues",initialState:Vc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Vc)),reducers:{initializeAssetTypeFieldValues:Y.initialize,addAssetTypeFieldValues:Y.addOne,addAssetTypeFieldValuesMany:Y.addMany,setAssetTypeFieldValues:Y.setOne,setAssetTypeFieldValuesMany:Y.setMany,updateAssetTypeFieldValues:Y.updateOne,updateAssetTypeFieldValuesMany:Y.updateMany,deleteAssetTypeFieldValues:Y.deleteOne,deleteAssetTypeFieldValuesMany:Y.deleteMany}}),{initializeAssetTypeFieldValues:Uc,addAssetTypeFieldValues:ks,addAssetTypeFieldValuesMany:$c,setAssetTypeFieldValues:Bm,setAssetTypeFieldValuesMany:Gm,updateAssetTypeFieldValues:Be,updateAssetTypeFieldValuesMany:Bc,deleteAssetTypeFieldValues:Cs,deleteAssetTypeFieldValuesMany:Gc}=Ms.actions,Lc=t=>t.assetTypeFieldValuesReducer.instances,zs=h.createSelector([Lc],t=>Object.values(t)),Lm=S(h.createSelector([zs,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),Nm=S(h.createSelector([it,zs,(t,e)=>e],(t,e,s)=>{const n=new Set(t.filter(a=>a.asset_type===s).map(a=>a.uuid));return g(e.filter(a=>n.has(a.fields_revision)))})),Ds=t=>e=>e.assetTypeFieldValuesReducer.instances[t],Nc=Ms.reducer,J=I(t=>t.uuid),Hc=J.getInitialState({}),Vs=h.createSlice({name:"assetTypes",initialState:Hc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Hc)),reducers:{initializeAssetTypes:J.initialize,setAssetType:J.setOne,setAssetTypes:J.setMany,addAssetType:J.addOne,addAssetTypes:J.addMany,updateAssetType:J.updateOne,updateAssetTypes:J.updateMany,deleteAssetType:J.deleteOne,deleteAssetTypes:J.deleteMany}}),{initializeAssetTypes:Wc,setAssetType:Hm,setAssetTypes:Wm,addAssetType:Us,addAssetTypes:Km,updateAssetType:Ge,updateAssetTypes:Ym,deleteAssetType:$s,deleteAssetTypes:Jm}=Vs.actions,Bs=t=>t.assetTypeReducer.instances,Xm=h.createSelector([Bs],t=>Object.values(t)),Gs=t=>e=>e.assetTypeReducer.instances[t],Qm=S(h.createSelector([Bs,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectAssetTypesByIds: No assetType exists with the id",n)}return g(s)})),Kc=Vs.reducer,Yc={accessToken:"",refreshToken:"",isLoggedIn:!1},ct=h.createSlice({name:"auth",initialState:Yc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Yc)),reducers:{setTokens:(t,e)=>{t.accessToken=e.payload.accessToken,t.refreshToken=e.payload.refreshToken},clearTokens:t=>{t.accessToken="",t.refreshToken=""},setLoggedIn:(t,e)=>{e.payload||ct.caseReducers.clearTokens(t),t.isLoggedIn=e.payload}}}),{setTokens:Zm,clearTokens:xm,setLoggedIn:Jc}=ct.actions,ep=t=>t.authReducer.accessToken,tp=t=>t.authReducer.isLoggedIn,Xc=ct.reducer,Le=I(t=>t.uuid),Qc=Le.getInitialState({}),Ls=h.createSlice({name:"categories",initialState:Qc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Qc)),reducers:{initializeCategories:Le.initialize,addCategory:Le.addOne,updateCategory:Le.updateOne,deleteCategory:Le.deleteOne}}),{initializeCategories:Zc,addCategory:Ns,updateCategory:xc,deleteCategory:er}=Ls.actions,Hs=t=>t.categoryReducer.instances,sp=h.createSelector([Hs],t=>Object.values(t)),Ws=t=>e=>e.categoryReducer.instances[t],ip=S(h.createSelector([Hs,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectCategoryByIds: No category exists with the id",n)}return g(s)})),np=t=>e=>Object.values(e.issueReducer.instances).filter(s=>s.category===t).length,tr=Ls.reducer,X=I(t=>t.uuid),sr=X.getInitialState({}),Ks=h.createSlice({name:"documentAttachments",initialState:sr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sr)),reducers:{initializeDocumentAttachments:X.initialize,addDocumentAttachment:X.addOne,addDocumentAttachments:X.addMany,setDocumentAttachment:X.setOne,setDocumentAttachments:X.setMany,updateDocumentAttachment:X.updateOne,updateDocumentAttachments:X.updateMany,deleteDocumentAttachment:X.deleteOne,deleteDocumentAttachments:X.deleteMany}}),{initializeDocumentAttachments:ir,addDocumentAttachment:ap,addDocumentAttachments:nr,setDocumentAttachment:ar,setDocumentAttachments:cp,updateDocumentAttachment:rp,updateDocumentAttachments:cr,deleteDocumentAttachment:rr,deleteDocumentAttachments:dr}=Ks.actions,or=t=>t.documentAttachmentReducer.instances,ur=h.createSelector([or],t=>Object.values(t)),lr=t=>e=>e.documentAttachmentReducer.instances[t],dp=S(h.createSelector([ur,(t,e)=>e],(t,e)=>g(t.filter(({document:s})=>e===s)))),hr=Ks.reducer,mr={documents:{}},Ys=h.createSlice({name:"documents",initialState:mr,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,mr)}),reducers:{setDocuments:(t,e)=>{if(e.payload.filter(Bn).length!==e.payload.length)throw new Error("Tried to use setIssues reducer with duplicate ID's");t.documents=$n(e.payload)},addDocuments:(t,e)=>{for(const s of e.payload)if(s.uuid in t.documents)throw new Error(`attempting to add a document with uuid ${s.uuid} which already exists in state.documents.`);for(const s of e.payload){if(s.parent_document&&t.documents[s.parent_document]){const n=t.documents[s.parent_document];t.documents[s.parent_document]={...n,children_documents:[...n.children_documents,s.uuid]}}t.documents[s.uuid]=s}},updateDocuments:(t,e)=>{for(const s of e.payload)if(!(s.uuid in t.documents))throw new Error(`attempting to update a document with uuid ${s.uuid} which doesn't exists in state.documents.`);for(const s of e.payload){const n=t.documents[s.uuid];if(s.organization!==void 0&&s.organization!==n.organization)throw new Error("organization cannot be updated");if(s.project!==void 0&&s.project!==n.project)throw new Error("project cannot be updated");t.documents[s.uuid]={...n,...s}}},moveDocument:(t,e)=>{const{documentId:s,targetDocumentId:n,position:a}=e.payload;if(!(s in t.documents))throw new Error(`attempting to move a document with uuid ${s} which doesn't exist in state.documents`);const c=t.documents[s];if(c.parent_document&&t.documents[c.parent_document]){const{children_documents:r}=t.documents[c.parent_document];t.documents[c.parent_document].children_documents.splice(r.indexOf(c.uuid),1)}if(n){const r=t.documents[n],u=r!=null&&r.parent_document?t.documents[r.parent_document]:null;switch(a){case"left":if(!u)throw new Error("attempting to move a document to the left of a document with no parent_document");t.documents[r.parent_document].children_documents.splice(u.children_documents.indexOf(r.uuid),0,c.uuid),t.documents[s].parent_document=u.uuid;break;case"right":if(!u)throw new Error("attempting to move a document to the left of a document with no parent_document");t.documents[r.parent_document].children_documents.splice(u.children_documents.indexOf(r.uuid)+1,0,c.uuid),t.documents[s].parent_document=u.uuid;break;case"left-child":if(!r)throw new Error("attempting to move a document to the left-child of a document that doesn't exist");t.documents[n].children_documents.unshift(c.uuid),t.documents[s].parent_document=r.uuid;break;case"right-child":if(!r)throw new Error("attempting to move a document to the left-child of a document that doesn't exist");t.documents[n].children_documents.push(c.uuid),t.documents[s].parent_document=r.uuid}}else t.documents[s].parent_document=null},removeDocuments:(t,e)=>{for(const s of e.payload)if(!(s in t.documents))throw new Error(`attempting to delete a document with uuid ${s} which doesn't exists in state.documents.`);for(const s of e.payload){const n=t.documents[s];if(n.parent_document&&t.documents[n.parent_document]){const a=t.documents[n.parent_document];t.documents[n.parent_document]={...a,children_documents:a.children_documents.filter(c=>c!==n.uuid)}}delete t.documents[s]}}}}),{setDocuments:pr,addDocuments:Ar,updateDocuments:ye,moveDocument:yr,removeDocuments:Js}=Ys.actions,we=t=>t.documentsReducer.documents,fr=h.createSelector([we],t=>Object.values(t)),Sr=t=>e=>e.documentsReducer.documents[t],op=S(h.createSelector([we,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectDocumentByIds: No document exists with the id",n)}return g(s)})),up=S(h.createSelector([we,(t,e)=>e],(t,e)=>{const s=[],n=t[e];if(!n||!n.parent_document)return s;let a=t[n.parent_document];for(;a;)s.push(a.uuid),a=t[a.parent_document??""];return g(s)})),lp=h.createSelector([fr],t=>g(t.filter(e=>!e.parent_document))),gr=Ys.reducer,rt=I(t=>t.uuid),hp=rt.getInitialState({}),Xs=h.createSlice({name:"emailDomains",initialState:hp,reducers:{initializeEmailDomains:rt.initialize,addEmailDomain:rt.addOne,deleteEmailDomain:rt.deleteOne}}),{initializeEmailDomains:Tr,addEmailDomain:br,deleteEmailDomain:Ir}=Xs.actions,Fr=t=>t.emailDomainsReducer.instances,Rr=h.createSelector([Fr],t=>Object.values(t)),mp=S(h.createSelector([Rr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Pr=Xs.reducer,Or={s3Urls:{}},vr=1e3*60*60,pp=vr*24*7,Qs=h.createSlice({name:"file",initialState:Or,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Or)),reducers:{setUploadUrl:(t,e)=>{const{url:s,fields:n,sha1:a}=e.payload,c=new Date,r=new Date(c.getTime()+pp);t.s3Urls[a]={url:s,fields:n,exp:r.getTime()}}}}),{setUploadUrl:_r}=Qs.actions,wr=t=>e=>{const s=e.fileReducer.s3Urls[t];if(!s)return;const n=new Date().getTime();if(!((s.exp??n)-n<vr))return s},Er=Qs.reducer,Q=I(t=>t.uuid),jr=Q.getInitialState({}),Zs=h.createSlice({name:"formRevisionAttachments",initialState:jr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,jr)),reducers:{initializeFormRevisionAttachments:Q.initialize,addFormRevisionAttachment:Q.addOne,addFormRevisionAttachments:Q.addMany,setFormRevisionAttachment:Q.setOne,setFormRevisionAttachments:Q.setMany,updateFormRevisionAttachment:Q.updateOne,updateFormRevisionAttachments:Q.updateMany,deleteFormRevisionAttachment:Q.deleteOne,deleteFormRevisionAttachments:Q.deleteMany}}),{initializeFormRevisionAttachments:qr,addFormRevisionAttachment:Ap,addFormRevisionAttachments:Mr,setFormRevisionAttachment:yp,setFormRevisionAttachments:fp,updateFormRevisionAttachment:Sp,updateFormRevisionAttachments:kr,deleteFormRevisionAttachment:gp,deleteFormRevisionAttachments:Cr}=Zs.actions,zr=t=>t.formRevisionAttachmentReducer.instances,Tp=S(h.createSelector([zr,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_revision===e)))),Dr=Zs.reducer,bp=(t,e)=>{const s=t.revision,n=e.revision;return s===void 0&&n===void 0?t.submitted_at<e.submitted_at?-1:1:s===void 0?1:n===void 0||s<n?-1:1},Se=I(t=>t.uuid),Vr=Se.getInitialState({}),xs=h.createSlice({name:"formRevisions",initialState:Vr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Vr)),reducers:{initializeFormRevisions:Se.initialize,setFormRevision:Se.setOne,addFormRevision:Se.addOne,addFormRevisions:Se.addMany,deleteFormRevision:Se.deleteOne,deleteFormRevisions:Se.deleteMany}}),{setFormRevision:Ur,initializeFormRevisions:$r,addFormRevision:ei,addFormRevisions:Br,deleteFormRevision:ti,deleteFormRevisions:Gr}=xs.actions,dt=t=>t.formRevisionReducer.instances,Lr=h.createSelector([dt],t=>Object.values(t)),Ip=t=>e=>e.formRevisionReducer.instances[t],Fp=S(h.createSelector([dt,(t,e)=>e],(t,e)=>{const s=Object.values(t).filter(c=>c.form===e);if(s.length===0)return;const a=s.sort(bp)[s.length-1];return t[a.uuid]})),Nr=S(h.createSelector([Lr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.form===e)))),Hr=xs.reducer,ge=I(t=>t.uuid),Wr=ge.getInitialState({}),si=h.createSlice({name:"forms",initialState:Wr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Wr)),reducers:{initializeForms:ge.initialize,setForm:ge.setOne,addForm:ge.addOne,addForms:ge.addMany,updateForm:ge.updateOne,deleteForm:ge.deleteOne}}),{initializeForms:Kr,setForm:Rp,addForm:ii,addForms:Pp,updateForm:Op,deleteForm:ni}=si.actions,Yr=si.reducer,Jr=t=>t.formReducer.instances,vp=h.createSelector([Jr],t=>Object.values(t)),Xr=t=>e=>e.formReducer.instances[t],Z=I(t=>t.uuid),Qr=Z.getInitialState({}),ai=h.createSlice({name:"formSubmissionAttachments",initialState:Qr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Qr)),reducers:{initializeFormSubmissionAttachments:Z.initialize,addFormSubmissionAttachment:Z.addOne,addFormSubmissionAttachments:Z.addMany,setFormSubmissionAttachment:Z.setOne,setFormSubmissionAttachments:Z.setMany,updateFormSubmissionAttachment:Z.updateOne,updateFormSubmissionAttachments:Z.updateMany,deleteFormSubmissionAttachment:Z.deleteOne,deleteFormSubmissionAttachments:Z.deleteMany}}),{initializeFormSubmissionAttachments:Zr,addFormSubmissionAttachment:_p,addFormSubmissionAttachments:ot,setFormSubmissionAttachment:wp,setFormSubmissionAttachments:Ep,updateFormSubmissionAttachment:jp,updateFormSubmissionAttachments:xr,deleteFormSubmissionAttachment:qp,deleteFormSubmissionAttachments:ut}=ai.actions,ci=t=>t.formSubmissionAttachmentReducer.instances,ed=S(h.createSelector([ci,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.uuid)))})),td=S(h.createSelector([ci,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_submission===e)))),sd=ai.reducer,x=I(t=>t.uuid),id=x.getInitialState({}),ri=h.createSlice({name:"formSubmissions",initialState:id,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,id)),reducers:{initializeFormSubmissions:x.initialize,setFormSubmission:x.setOne,setFormSubmissions:x.setMany,addFormSubmission:x.addOne,addFormSubmissions:x.addMany,updateFormSubmission:x.updateOne,updateFormSubmissions:x.updateMany,deleteFormSubmission:x.deleteOne,deleteFormSubmissions:x.deleteMany}}),{initializeFormSubmissions:nd,setFormSubmission:lt,setFormSubmissions:Mp,addFormSubmission:di,addFormSubmissions:ht,updateFormSubmission:ad,updateFormSubmissions:kp,deleteFormSubmission:oi,deleteFormSubmissions:mt}=ri.actions,ui=t=>t.formSubmissionReducer.instances,li=h.createSelector([ui],t=>Object.values(t)),hi=t=>e=>e.formSubmissionReducer.instances[t],cd=S(h.createSelector([ui,dt,(t,e)=>e],(t,e,s)=>{const n=new Set;for(const a of Object.values(e))a.form===s&&n.add(a.uuid);return Object.values(t).filter(a=>n.has(a.form_revision))})),rd=S(h.createSelector([li,(t,e)=>e],(t,e)=>Object.values(t).filter(s=>s.issue===e))),dd=S(h.createSelector([li,(t,e)=>e],(t,e)=>t.filter(s=>s.asset===e))),od=ri.reducer,ee=I(t=>t.uuid),ud=ee.getInitialState({}),mi=h.createSlice({name:"geoImages",initialState:ud,extraReducers:t=>{t.addCase("RESET",e=>{Object.assign(e,ud)})},reducers:{initializeGeoImages:ee.initialize,setGeoImage:ee.setOne,setGeoImages:ee.setMany,addGeoImage:ee.addOne,addGeoImages:ee.addMany,updateGeoImage:ee.updateOne,updateGeoImages:ee.updateMany,deleteGeoImage:ee.deleteOne,deleteGeoImages:ee.deleteMany}}),{initializeGeoImages:ld,setGeoImage:Ne,setGeoImages:hd,addGeoImage:md,addGeoImages:pd,updateGeoImage:Ad,updateGeoImages:Cp,deleteGeoImage:pi,deleteGeoImages:yd}=mi.actions,fd=t=>t.geoImageReducer.instances,Sd=h.createSelector([fd],t=>Object.values(t)),Ai=t=>e=>e.geoImageReducer.instances[t],zp=S(h.createSelector([Sd,(t,e)=>e],(t,e)=>g(t.filter(s=>s.project===e)))),gd=mi.reducer,te=I(t=>t.uuid),Td=te.getInitialState({}),yi=h.createSlice({name:"issueAssociations",initialState:Td,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Td)),reducers:{initializeIssueAssociations:te.initialize,addIssueAssociation:te.addOne,addIssueAssociations:te.addMany,setIssueAssociation:te.setOne,setIssueAssociations:te.setMany,updateIssueAssociation:te.updateOne,updateIssueAssociations:te.updateMany,deleteIssueAssociation:te.deleteOne,deleteIssueAssociations:te.deleteMany}}),{initializeIssueAssociations:bd,setIssueAssociations:Dp,setIssueAssociation:Vp,updateIssueAssociation:Id,updateIssueAssociations:Up,addIssueAssociation:fi,addIssueAssociations:Si,deleteIssueAssociation:gi,deleteIssueAssociations:Ti}=yi.actions,He=t=>t.issueAssociationReducer.instances,$p=h.createSelector([He],t=>Object.values(t)),Fd=t=>e=>e.issueAssociationReducer.instances[t],Rd=S(h.createSelector([He,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.associated_issue===e)))),Pd=S(h.createSelector([He,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Od=S(h.createSelector([He,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.asset===e)))),vd=yi.reducer,se=I(t=>t.uuid),_d=se.getInitialState({}),bi=h.createSlice({name:"issueAttachments",initialState:_d,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,_d)),reducers:{initializeIssueAttachments:se.initialize,addIssueAttachment:se.addOne,addIssueAttachments:se.addMany,setIssueAttachment:se.setOne,setIssueAttachments:se.setMany,updateIssueAttachment:se.updateOne,updateIssueAttachments:se.updateMany,deleteIssueAttachment:se.deleteOne,deleteIssueAttachments:se.deleteMany}}),{initializeIssueAttachments:Ii,addIssueAttachment:Bp,addIssueAttachments:Fi,setIssueAttachment:wd,setIssueAttachments:Gp,updateIssueAttachment:Lp,updateIssueAttachments:Ed,deleteIssueAttachment:jd,deleteIssueAttachments:Ri}=bi.actions,qd=t=>t.issueAttachmentReducer.instances,Md=h.createSelector([qd],t=>Object.values(t)),kd=S(h.createSelector([Md,(t,e)=>e],(t,e)=>g(t.filter(({issue:s})=>e===s)))),Cd=t=>e=>e.issueAttachmentReducer.instances[t],zd=bi.reducer,ie=I(t=>t.uuid),Dd=ie.getInitialState({}),Pi=h.createSlice({name:"issueCommentAttachments",initialState:Dd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dd)),reducers:{initializeIssueCommentAttachments:ie.initialize,addIssueCommentAttachment:ie.addOne,addIssueCommentAttachments:ie.addMany,setIssueCommentAttachment:ie.setOne,setIssueCommentAttachments:ie.setMany,updateIssueCommentAttachment:ie.updateOne,updateIssueCommentAttachments:ie.updateMany,deleteIssueCommentAttachment:ie.deleteOne,deleteIssueCommentAttachments:ie.deleteMany}}),{initializeIssueCommentAttachments:Oi,addIssueCommentAttachment:Np,addIssueCommentAttachments:Vd,setIssueCommentAttachment:Ud,setIssueCommentAttachments:Hp,updateIssueCommentAttachment:Wp,updateIssueCommentAttachments:$d,deleteIssueCommentAttachment:Bd,deleteIssueCommentAttachments:Gd}=Pi.actions,Ld=t=>t.issueCommentAttachmentReducer.instances,Nd=h.createSelector([Ld],t=>Object.values(t)),Hd=t=>e=>e.issueCommentAttachmentReducer.instances[t],Kp=S(h.createSelector([Nd,(t,e)=>e],(t,e)=>g(t.filter(({issue_comment:s})=>e===s)))),Wd=Pi.reducer,Te=I(t=>t.uuid),Kd=Te.getInitialState({}),vi=h.createSlice({name:"issueComments",initialState:Kd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Kd)),reducers:{addIssueComment:Te.addOne,addIssueComments:Te.addMany,setIssueComment:Te.setOne,setIssueComments:Te.setMany,deleteIssueComment:Te.deleteOne,deleteIssueComments:Te.deleteMany}}),{setIssueComments:Yd,setIssueComment:_i,addIssueComment:wi,addIssueComments:Yp,deleteIssueComment:Ei,deleteIssueComments:Jp}=vi.actions,Jd=t=>t.issueCommentReducer.instances,ji=t=>e=>e.issueCommentReducer.instances[t],Xp=S(h.createSelector([Jd,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Xd=vi.reducer,be=I(t=>t.uuid),Qd=be.getInitialState({}),qi=h.createSlice({name:"issues",initialState:Qd,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Qd)}),reducers:{initializeIssues:be.initialize,addIssue:be.addOne,addIssues:be.addMany,updateIssue:be.updateOne,deleteIssue:be.deleteOne,deleteIssues:be.deleteMany}}),{initializeIssues:Zd,addIssue:Mi,addIssues:xd,updateIssue:pt,deleteIssue:ki,deleteIssues:eo}=qi.actions,to=t=>t.issueReducer.instances,Ci=t=>e=>e.issueReducer.instances[t],Qp=S(h.createSelector([to,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectIssuesByIds: No issue exists with the id",n)}return g(s)})),so=qi.reducer,ne=I(t=>t.uuid),io=ne.getInitialState({}),zi=h.createSlice({name:"issueTypeAttachments",initialState:io,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,io)),reducers:{initializeIssueTypeAttachments:ne.initialize,addIssueTypeAttachment:ne.addOne,addIssueTypeAttachments:ne.addMany,setIssueTypeAttachment:ne.setOne,setIssueTypeAttachments:ne.setMany,updateIssueTypeAttachment:ne.updateOne,updateIssueTypeAttachments:ne.updateMany,deleteIssueTypeAttachment:ne.deleteOne,deleteIssueTypeAttachments:ne.deleteMany}}),{initializeIssueTypeAttachments:Di,addIssueTypeAttachment:Zp,addIssueTypeAttachments:no,setIssueTypeAttachment:ao,setIssueTypeAttachments:xp,updateIssueTypeAttachment:eA,updateIssueTypeAttachments:co,deleteIssueTypeAttachment:ro,deleteIssueTypeAttachments:oo}=zi.actions,uo=t=>t.issueTypeAttachmentReducer.instances,lo=h.createSelector([uo],t=>Object.values(t)),ho=t=>e=>e.issueTypeAttachmentReducer.instances[t],tA=S(h.createSelector([lo,(t,e)=>e],(t,e)=>g(t.filter(({issue_type:s})=>e===s)))),mo=zi.reducer,ae=I(t=>t.uuid),po=ae.getInitialState({}),Vi=h.createSlice({name:"issueTypeFieldsAttachments",initialState:po,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,po)),reducers:{initializeIssueTypeFieldsAttachments:ae.initialize,addIssueTypeFieldsAttachment:ae.addOne,addIssueTypeFieldsAttachments:ae.addMany,setIssueTypeFieldsAttachment:ae.setOne,setIssueTypeFieldsAttachments:ae.setMany,updateIssueTypeFieldsAttachment:ae.updateOne,updateIssueTypeFieldsAttachments:ae.updateMany,deleteIssueTypeFieldsAttachment:ae.deleteOne,deleteIssueTypeFieldsAttachments:ae.deleteMany}}),{initializeIssueTypeFieldsAttachments:Ao,addIssueTypeFieldsAttachment:sA,addIssueTypeFieldsAttachments:yo,setIssueTypeFieldsAttachment:iA,setIssueTypeFieldsAttachments:nA,updateIssueTypeFieldsAttachment:aA,updateIssueTypeFieldsAttachments:fo,deleteIssueTypeFieldsAttachment:cA,deleteIssueTypeFieldsAttachments:So}=Vi.actions,go=t=>t.issueTypeFieldsAttachmentReducer.instances,To=h.createSelector([go],t=>Object.values(t)),rA=S(h.createSelector([To,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),dA=t=>e=>e.issueTypeFieldsAttachmentReducer.instances[t],bo=Vi.reducer,ce=I(t=>t.uuid),Io=ce.getInitialState({}),Ui=h.createSlice({name:"issueTypeFieldValues",initialState:Io,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Io)),reducers:{initializeIssueTypeFieldValues:ce.initialize,addIssueTypeFieldValues:ce.addOne,addIssueTypeFieldValuesMany:ce.addMany,setIssueTypeFieldValues:ce.setOne,setIssueTypeFieldValuesMany:ce.setMany,updateIssueTypeFieldValues:ce.updateOne,updateIssueTypeFieldValuesMany:ce.updateMany,deleteIssueTypeFieldValues:ce.deleteOne,deleteIssueTypeFieldValuesMany:ce.deleteMany}}),{initializeIssueTypeFieldValues:Fo,addIssueTypeFieldValues:$i,addIssueTypeFieldValuesMany:oA,setIssueTypeFieldValues:uA,setIssueTypeFieldValuesMany:lA,updateIssueTypeFieldValues:We,updateIssueTypeFieldValuesMany:hA,deleteIssueTypeFieldValues:Bi,deleteIssueTypeFieldValuesMany:mA}=Ui.actions,Ro=t=>t.issueTypeFieldValuesReducer.instances,Gi=h.createSelector([Ro],t=>Object.values(t)),pA=S(h.createSelector([Gi,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue===e)))),Li=t=>e=>e.issueTypeFieldValuesReducer.instances[t],Po=Ui.reducer,re=I(t=>t.uuid),Oo=re.getInitialState({}),Ni=h.createSlice({name:"issueTypeFields",initialState:Oo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Oo)),reducers:{initializeIssueTypeFields:re.initialize,addIssueTypeFields:re.addOne,addIssueTypeFieldsMany:re.addMany,setIssueTypeFields:re.setOne,setIssueTypeFieldsMany:re.setMany,updateIssueTypeFields:re.updateOne,updateIssueTypeFieldsMany:re.updateMany,deleteIssueTypeFields:re.deleteOne,deleteIssueTypeFieldsMany:re.deleteMany}}),{initializeIssueTypeFields:vo,addIssueTypeFields:_o,addIssueTypeFieldsMany:AA,setIssueTypeFields:yA,setIssueTypeFieldsMany:fA,updateIssueTypeFields:wo,updateIssueTypeFieldsMany:SA,deleteIssueTypeFields:Eo,deleteIssueTypeFieldsMany:gA}=Ni.actions,jo=t=>t.issueTypeFieldsReducer.instances,At=h.createSelector([jo],t=>Object.values(t)),TA=S(h.createSelector([At,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue_type===e)))),bA=S(h.createSelector([At,(t,e)=>e],(t,e)=>t.filter(s=>s.issue_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),IA=S(h.createSelector([At,Gi,(t,e)=>e],(t,e,s)=>{const n=new Set(t.filter(a=>a.issue_type===s).map(a=>a.uuid));return g(e.filter(a=>n.has(a.fields_revision)))})),FA=t=>e=>e.issueTypeFieldsReducer.instances[t],qo=Ni.reducer,de=I(t=>t.uuid),Mo=de.getInitialState({}),Hi=h.createSlice({name:"issueTypeFieldValuesAttachments",initialState:Mo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Mo)),reducers:{initializeIssueTypeFieldValuesAttachments:de.initialize,addIssueTypeFieldValuesAttachment:de.addOne,addIssueTypeFieldValuesAttachments:de.addMany,setIssueTypeFieldValuesAttachment:de.setOne,setIssueTypeFieldValuesAttachments:de.setMany,updateIssueTypeFieldValuesAttachment:de.updateOne,updateIssueTypeFieldValuesAttachments:de.updateMany,deleteIssueTypeFieldValuesAttachment:de.deleteOne,deleteIssueTypeFieldValuesAttachments:de.deleteMany}}),{initializeIssueTypeFieldValuesAttachments:ko,addIssueTypeFieldValuesAttachment:RA,addIssueTypeFieldValuesAttachments:yt,setIssueTypeFieldValuesAttachment:PA,setIssueTypeFieldValuesAttachments:OA,updateIssueTypeFieldValuesAttachment:vA,updateIssueTypeFieldValuesAttachments:Co,deleteIssueTypeFieldValuesAttachment:_A,deleteIssueTypeFieldValuesAttachments:ft}=Hi.actions,Wi=t=>t.issueTypeFieldValuesAttachmentReducer.instances,zo=h.createSelector([Wi],t=>Object.values(t)),wA=t=>e=>e.issueTypeFieldValuesAttachmentReducer.instances[t],Do=S(h.createSelector([Wi,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.uuid)))})),Vo=S(h.createSelector([zo,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),Uo=Hi.reducer,Ee=I(t=>t.uuid),$o=Ee.getInitialState({}),Ki=h.createSlice({name:"issueTypes",initialState:$o,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,$o)}),reducers:{initializeIssueTypes:Ee.initialize,setIssueType:Ee.setOne,addIssueType:Ee.addOne,updateIssueType:Ee.updateOne,removeIssueType:Ee.deleteOne}}),{initializeIssueTypes:Bo,setIssueType:Ke,addIssueType:Go,updateIssueType:Lo,removeIssueType:Yi}=Ki.actions,No=t=>t.issueTypeReducer.instances,Ho=h.createSelector(No,t=>Object.values(t)),Ji=t=>e=>e.issueTypeReducer.instances[t],EA=t=>e=>{const s=[];for(const n of t){const a=e.issueTypeReducer.instances[n];a?s.push(a):console.warn("selectIssueTypesByIds: No issue type exists with the id",n)}return s},jA=S(h.createSelector([Ho,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Xi=S(h.createSelector([t=>t.issueReducer.instances,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue_type===e)))),qA=t=>e=>Xi(t)(e).length,Wo=Ki.reducer,Ie=I(t=>t.uuid),Ko=Ie.getInitialState({}),Qi=h.createSlice({name:"issueUpdates",initialState:Ko,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ko)),reducers:{initializeIssueUpdates:Ie.setMany,setIssueUpdate:Ie.setOne,addIssueUpdate:Ie.addOne,addIssueUpdates:Ie.addMany,deleteIssueUpdate:Ie.deleteOne,deleteIssueUpdates:Ie.deleteMany}}),{initializeIssueUpdates:Yo,setIssueUpdate:MA,addIssueUpdate:Jo,addIssueUpdates:Xo,deleteIssueUpdate:Qo,deleteIssueUpdates:Zo}=Qi.actions,xo=t=>t.issueUpdateReducer.instances,eu=S(h.createSelector([xo,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),tu=Qi.reducer,St=I(t=>t.uuid),su=St.getInitialState({}),Zi=h.createSlice({name:"license",initialState:su,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,su)),reducers:{initializeLicences:St.initialize,addLicenses:St.addMany,updateLicense:St.updateOne}}),{initializeLicences:iu,addLicenses:kA,updateLicense:pe}=Zi.actions,gt=t=>t.licenseReducer.instances,CA=t=>e=>e.licenseReducer.instances[t],nu=t=>e=>Object.values(e.licenseReducer.instances).find(s=>s.project===t),zA=h.createSelector([gt],t=>g(Object.values(t).filter(e=>e.is_active))),DA=h.createSelector([gt],t=>ve(Object.values(t).filter(e=>e.project).reduce((e,s)=>({...e,[s.project]:s}),{}))),au=Zi.reducer,k=I(t=>t.id),cu=k.getInitialState({currentUser:null}),xi=h.createSlice({name:"users",initialState:cu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,cu)),reducers:{initializeUsers:k.initialize,setUsers:k.setMany,setUser:k.setOne,addUsers:k.addMany,addUser:k.addOne,updateUsers:k.updateMany,updateUser:k.updateOne,deleteUser:k.deleteOne,deleteUsers:k.deleteMany,removeUser:k.deleteOne,setCurrentUser:(t,e)=>{t.currentUser=e.payload},setProfilePicture:(t,e)=>{if(!t.currentUser)return;t.currentUser.profile.file=e.payload.file??null,t.currentUser.profile.file_sha1=e.payload.file_sha1??null;const s=t.instances[t.currentUser.id];if(!s)throw new Error("Unable to find current user in users slice");s.profile.file=e.payload.file??null,s.profile.file_sha1=e.payload.file_sha1??null}}}),{initializeUsers:ru,setUsers:VA,setUser:UA,addUsers:$A,addUser:BA,updateUsers:GA,updateUser:LA,deleteUser:NA,deleteUsers:HA,removeUser:du,setCurrentUser:WA,setProfilePicture:KA}=xi.actions,ou=xi.reducer,Tt=t=>t.userReducer.currentUser,bt=t=>t.userReducer.instances,YA=t=>e=>e.userReducer.instances[t],JA=S(h.createSelector([bt,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectUsersByIds: No user exists with the uuid",n)}return g(s)})),It=I(t=>t.uuid),uu=It.getInitialState({}),en=h.createSlice({name:"organizationAccess",initialState:uu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,uu)),reducers:{initializeOrganizationAccesses:It.initialize,updateOrganizationAccess:It.updateOne,deleteOrganizationAccess:It.deleteOne}}),{initializeOrganizationAccesses:lu,updateOrganizationAccess:hu,deleteOrganizationAccess:mu}=en.actions,tn=t=>t.organizationAccessReducer.instances,XA=t=>e=>e.organizationAccessReducer.instances[t],QA=h.createSelector([Tt,tn],(t,e)=>Object.values(e).find(n=>n.user===(t==null?void 0:t.id))??null),ZA=t=>e=>Object.values(e.organizationAccessReducer.instances).find(s=>s.user===t.id),pu=t=>{const e={};for(const s of Object.values(t.organizationAccessReducer.instances))e[s.user]=s;return ve(e)},Au=en.reducer,Ye=I(t=>t.uuid),yu=Ye.getInitialState({}),sn=h.createSlice({name:"projectAccess",initialState:yu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,yu)),reducers:{initializeProjectAccesses:Ye.initialize,updateProjectAccess:Ye.updateOne,deleteProjectAccess:Ye.deleteOne,deleteProjectAccesses:Ye.deleteMany}}),{initializeProjectAccesses:nn,updateProjectAccess:fu,deleteProjectAccess:Su,deleteProjectAccesses:gu}=sn.actions,an=t=>t.projectAccessReducer.instances,Tu=h.createSelector(an,t=>Object.values(t)),xA=t=>e=>e.projectAccessReducer.instances[t],ey=t=>e=>Object.values(e.projectAccessReducer.instances).find(s=>s.user===t.id),bu=t=>{const e={};for(const s of Object.values(t.projectAccessReducer.instances))e[s.user]=s;return ve(e)},Iu=sn.reducer,oe=I(t=>t.uuid),Fu=oe.getInitialState({}),cn=h.createSlice({name:"projects",initialState:Fu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Fu)),reducers:{initializeProjects:oe.initialize,setProjects:oe.setMany,setProject:oe.setOne,addProjects:oe.addMany,addProject:oe.addOne,updateProjects:oe.updateMany,updateProject:oe.updateOne,deleteProject:oe.deleteOne,deleteProjects:oe.deleteMany,acceptProjectInvite:(t,e)=>{if(e.payload in t.instances)t.instances[e.payload].invited=!1;else throw new Error("Accept project invite: user is not in this project")}}}),{initializeProjects:ty,setProjects:Ru,setProject:sy,addProjects:iy,addProject:ny,updateProjects:ay,updateProject:Pu,deleteProject:Ou,deleteProjects:cy,acceptProjectInvite:vu}=cn.actions,_u=cn.reducer,Ft=t=>t.projectReducer.instances,ry=h.createSelector([Ft],t=>g(Object.values(t))),dy=t=>e=>e.projectReducer.instances[t],wu=h.createSelector([an],t=>Object.values(t).map(e=>e.user)),Eu=h.createSelector([wu,bt],(t,e)=>t.reduce((s,n)=>({...s,[n]:e[n]}),{})),oy=h.createSelector([Tt,Eu,bu],(t,e,s)=>g(Object.values(e).sort((n,a)=>{if(n.id===(t==null?void 0:t.id))return-1;if(a.id===(t==null?void 0:t.id))return 1;const c=s[n.id],r=s[a.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===vt.ADMIN?-1:1}))),ue=I(t=>t.uuid),ju=ue.getInitialState({}),rn=h.createSlice({name:"organizations",initialState:ju,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ju)),reducers:{initializeOrganizations:ue.initialize,setOrganizations:ue.setMany,setOrganization:ue.setOne,addOrganizations:ue.addMany,addOrganization:ue.addOne,updateOrganizations:ue.updateMany,updateOrganization:ue.updateOne,deleteOrganization:ue.deleteOne,deleteOrganizations:ue.deleteMany}}),{initializeOrganizations:uy,setOrganizations:qu,setOrganization:ly,addOrganizations:hy,addOrganization:my,updateOrganizations:py,updateOrganization:Ay,deleteOrganization:yy,deleteOrganizations:fy}=rn.actions,Mu=t=>t.organizationReducer.instances,ku=h.createSelector([Mu],t=>Object.values(t)),Sy=t=>e=>e.organizationReducer.instances[t],gy=h.createSelector([ku],t=>g(Object.values(t).filter(e=>e.has_access))),Cu=h.createSelector([tn],t=>Object.values(t).map(e=>e.user)),Ty=S(h.createSelector([Ft,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.organization_owner===e)))),by=S(h.createSelector([gt,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.organization_owner===e)))),zu=h.createSelector([Cu,bt],(t,e)=>ve(t.reduce((s,n)=>({...s,[n]:e[n]}),{}))),Iy=h.createSelector([Tt,zu,pu],(t,e,s)=>g(Object.values(e).sort((n,a)=>{if(n.id===(t==null?void 0:t.id))return-1;if(a.id===(t==null?void 0:t.id))return 1;const c=s[n.id],r=s[a.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===_t.ADMIN?-1:1}))),Du=rn.reducer,Vu=(t,e,s)=>{const n=t.uuid?t:{...t,uuid:fe.v4()};return{payload:n,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:n,BASE_URL:e,serviceName:s}}}}},Uu={deletedRequests:[],latestRetryTime:0},dn=h.createSlice({name:"outbox",initialState:Uu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Uu)),reducers:{enqueueRequest:{reducer:(t,e)=>t,prepare:t=>{console.debug("Preparing to enqueue request",t);const{BASE_URL:e,serviceName:s,...n}=t;return Vu(n,e,s)}},markForDeletion(t,e){t.deletedRequests.push(e.payload)},markAsDeleted(t,e){const s=t.deletedRequests.indexOf(e.payload);s!==-1&&t.deletedRequests.splice(s,1)},_setLatestRetryTime:(t,e)=>{t.latestRetryTime=e.payload}}}),Fy=t=>t.outboxReducer.deletedRequests,Ry=t=>t.outboxReducer.latestRetryTime,{enqueueRequest:$u,markForDeletion:Py,markAsDeleted:Bu,_setLatestRetryTime:Gu}=dn.actions,Lu=dn.reducer,le=I(t=>t.uuid),Nu=le.getInitialState({}),on=h.createSlice({name:"projectAttachments",initialState:Nu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Nu)),reducers:{initializeProjectAttachments:le.initialize,addProjectAttachment:le.addOne,addProjectAttachments:le.addMany,setProjectAttachment:le.setOne,setProjectAttachments:le.setMany,updateProjectAttachment:le.updateOne,updateProjectAttachments:le.updateMany,deleteProjectAttachment:le.deleteOne,deleteProjectAttachments:le.deleteMany}}),{initializeProjectAttachments:Hu,addProjectAttachment:Oy,addProjectAttachments:Wu,setProjectAttachment:Ku,setProjectAttachments:Yu,updateProjectAttachment:vy,updateProjectAttachments:Ju,deleteProjectAttachment:Xu,deleteProjectAttachments:un}=on.actions,Qu=t=>t.projectAttachmentReducer.instances,Zu=h.createSelector([Qu],t=>Object.values(t)),xu=t=>e=>e.projectAttachmentReducer.instances[t],el=S(h.createSelector([Zu,(t,e)=>e],(t,e)=>g(t.filter(({project:s})=>e===s)))),tl=on.reducer,he=I(t=>t.uuid),sl=he.getInitialState({activeProjectFileId:null,isImportingProjectFile:!1}),ln=h.createSlice({name:"projectFiles",initialState:sl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sl)),reducers:{initializeProjectFiles:he.initialize,setProjectFile:he.setOne,setProjectFiles:he.setMany,addProjectFile:he.addOne,addProjectFiles:he.addMany,updateProjectFile:he.updateOne,updateProjectFiles:he.updateMany,deleteProjectFile:he.deleteOne,deleteProjectFiles:he.deleteMany,setIsImportingProjectFile:(t,e)=>{t.isImportingProjectFile=e.payload},saveActiveProjectFileBounds:(t,e)=>{const s=t.activeProjectFileId;if(!s)throw new Error("Tried to save bounds for active project file, but no active project file was set.");if(!t.instances[s])throw new Error(`Tried to save bounds for active project file, but project file with ID ${s}
2
+ doesn't exist.`);t.instances[s].bounds=e.payload},setActiveProjectFileId:(t,e)=>{t.activeProjectFileId=e.payload},resetProjectFileObjectUrls:(t,...e)=>{for(const s in t.instances)delete t.instances[s].objectURL}}}),{initializeProjectFiles:il,setProjectFile:_y,setProjectFiles:wy,addProjectFile:Ey,addProjectFiles:nl,updateProjectFile:hn,updateProjectFiles:jy,deleteProjectFile:al,deleteProjectFiles:cl,setIsImportingProjectFile:rl,setActiveProjectFileId:dl,saveActiveProjectFileBounds:ol,resetProjectFileObjectUrls:qy}=ln.actions,ul=t=>t.projectFileReducer.instances,ll=h.createSelector([ul],t=>g(Object.values(t).sort((e,s)=>e.z_index-s.z_index))),My=t=>e=>e.projectFileReducer.instances[t],ky=t=>t.projectFileReducer.activeProjectFileId,Cy=t=>t.projectFileReducer.isImportingProjectFile,hl=ln.reducer,zy={isRehydrated:!1},mn=h.createSlice({name:"rehydrated",initialState:zy,reducers:{setRehydrated:(t,e)=>{t.isRehydrated=e.payload}}}),{setRehydrated:Dy}=mn.actions,Vy=t=>t.rehydratedReducer.isRehydrated,ml=mn.reducer,je=I(t=>t.uuid),pl=je.getInitialState({}),pn=h.createSlice({name:"teams",initialState:pl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,pl)),reducers:{setTeam:je.setOne,initializeTeams:je.initialize,addTeam:je.addOne,updateTeam:je.updateOne,deleteTeam:je.deleteOne}}),{setTeam:qe,initializeTeams:Al,addTeam:yl,updateTeam:An,deleteTeam:yn}=pn.actions,fn=t=>t.teamReducer.instances,Sn=h.createSelector([fn],t=>Object.values(t)),Me=t=>e=>e.teamReducer.instances[t],Uy=S(h.createSelector([fn,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectTeamsByIds: No team exists with the id",n)}return g(s)})),$y=S(h.createSelector([Sn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),By=S(h.createSelector([Sn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.members.includes(e))))),fl=pn.reducer,Gy={version:0},Sl=h.createSlice({name:"versioning",initialState:Gy,reducers:{}}),gl=Sl.reducer;let Tl;function Ly(t){Tl=t}function Je(){return Tl}let bl;function Ny(t){bl=t}function Hy(){return bl}const Il={};class Fl{constructor(e){f(this,"client");Il[this.constructor.name]=this,this.client=e}async enqueueRequest(e){return this.client.enqueueRequest(e,this.host,this.constructor.name)}dispatch(e){this.client.store.dispatch(e)}}const Rl="versioning",Pl=()=>_l.length-1,Ol=t=>(t[Rl]={version:Pl()},t),vl=()=>Ol({}),Wy=t=>(t.outboxReducer&&(t.outboxReducer.deletedRequests=[]),t),Ky=t=>e=>{var s;return e===void 0&&(e={}),((s=e[Rl])==null?void 0:s.version)===Pl()?e:t(e)},_l=[Ol,vl,vl,Wy],Yy=Object.fromEntries(_l.map((t,e)=>[e,Ky(t)])),gn="versioning",wl={[gn]:gl,fileReducer:Er,authReducer:Xc,categoryReducer:tr,assetReducer:Wa,assetAttachmentReducer:sa,assetStageCompletionReducer:Qa,assetStageReducer:ic,assetTypeReducer:Kc,assetTypeAttachmentReducer:Ac,issueReducer:so,issueAttachmentReducer:zd,issueTypeReducer:Wo,issueTypeAttachmentReducer:mo,organizationReducer:Du,outboxReducer:Lu,projectReducer:_u,projectAttachmentReducer:tl,projectAccessReducer:Iu,organizationAccessReducer:Au,projectFileReducer:hl,rehydratedReducer:ml,formReducer:Yr,formRevisionReducer:Hr,formRevisionAttachmentReducer:Dr,formSubmissionAttachmentReducer:sd,formSubmissionReducer:od,userReducer:ou,emailDomainsReducer:Pr,licenseReducer:au,documentsReducer:gr,documentAttachmentReducer:hr,teamReducer:fl,agentsReducer:Kn,issueCommentReducer:Xd,issueCommentAttachmentReducer:Wd,issueUpdateReducer:tu,geoImageReducer:gd,issueAssociationReducer:vd,issueTypeFieldsReducer:qo,issueTypeFieldValuesReducer:Po,issueTypeFieldsAttachmentReducer:bo,issueTypeFieldValuesAttachmentReducer:Uo,assetTypeFieldsReducer:Ec,assetTypeFieldValuesReducer:Nc,assetTypeFieldsAttachmentReducer:Fc,assetTypeFieldValuesAttachmentReducer:Dc,assetProcedureReducer:Ba,assetProcedureInstanceReducer:Da,assetProcedureFieldsReducer:fa,assetProcedureFieldValuesReducer:ja,assetProcedureFieldsAttachmentReducer:ua,assetProcedureFieldValuesAttachmentReducer:Ra},El=h.combineReducers(wl),jl="RESET",Jy=(t,e)=>e.type==="auth/setLoggedIn"&&!e.payload?El(void 0,e):El(t,e);let Tn=null;function Fe(){const t=Je();if(!t)return console.warn("Client store not set; cannot get outbox coordinator yet."),null;if(Tn)return Tn;const e=t.getState().offline.outbox,s=Ce._fromOutbox(e);return Tn=s,s}const Xy=t=>{if(t)throw t;const e=Je();e?e.dispatch({type:"rehydrated/setRehydrated",payload:!0}):console.error("Client store not set")},ql=(t,e,s)=>{const n=Fe();return n?(n.addRequest(e),n.getQueue()):(console.warn("Outbox coordinator not set; cannot enqueue request yet."),[])},Ml=(t,e,s)=>{const n=Fe();if(!n)return console.warn("Outbox coordinator not set; cannot dequeue request yet."),[];const c=e.meta.offlineAction.payload.uuid;return n.remove(c),n.getQueue()};async function Qy(t,e){if(!e.payload)throw new Error("Received empty payload");return rf(e)}const Zy={...On,effect:Qy,discard:In,returnPromises:!0,persistCallback:Xy,retry:of,persistOptions:{storage:Bl},queue:{...On.queue,enqueue:ql,dequeue:Ml,peek:(...t)=>df(...t)}},xy=Gl(Yy,gn),ef=h.compose($l.offline(Zy),xy);function tf(t){function e(s){return typeof s=="object"&&s!==null&&["ok","redirect","clientError","serverError","error"].every(a=>a in s)}if(e(t))return t;if(typeof t=="object"&&t!==null){const s=t;if(e(s.response))return s.response;if(s.response&&e(s.response.response))return s.response.response}}async function bn(t,e){const s=Il[t.meta.offline.effect.serviceName];if(!s)throw new Error(`Service ${t.meta.offline.effect.serviceName} not found`);const n=s instanceof P;if(e.store.getState().outboxReducer.deletedRequests.includes(t.payload.uuid))throw new Error("Request was marked for deletion");n&&t.payload.checkAuth!==!1&&await s.auth.prepareAuth();const c={queryParams:"",isAuthNeeded:!0},r=t.meta.offline.effect,{payload:u,headers:m,method:d,queryParams:o,attachmentHash:p,isExternalUrl:A,isAuthNeeded:y,isResponseBlob:b}={...c,...r.request},F=r.request;let T=F.url;const O=p?await e.files.fetchCache(p):void 0;if(p&&!O)throw new Error(`Cannot upload file ${p} because it's not cached.`);!A&&!T.startsWith("http")&&(!T.startsWith("/")&&!T.startsWith("blob:")&&(T="/"+T),T=t.meta.offline.effect.BASE_URL+T);const M=w=>{if(p){const me=F.s3url;if(!me)throw new Error(`No S3 URL for file ${p}`);if("warning"in me)throw new Error(`S3 URL warning for file ${p}`);if(!O)throw new Error(`No file for file ${p}`);const Ze=me.fields["x-amz-checksum-sha1"];if(!Ze)throw new Error(`No checksum for file ${p}`);return w.set("x-amz-checksum-sha1",Ze).field({...u,...me.fields}).attach("file",O)}return w.send(u)},fS={[l.GET]:()=>b?Oe.get(T.toString()).responseType("blob"):Oe.get(T.toString()),[l.POST]:()=>{const w=Oe.post(T.toString());return M(w)},[l.PATCH]:()=>{const w=Oe.patch(T.toString());return M(w)},[l.PUT]:()=>{const w=Oe.put(T.toString());return M(w)},[l.DELETE]:()=>{const w=Oe.delete(T.toString());return M(w)}}[d];let Pe=fS();if(y&&n){const w=s.auth.getAuthHeader();Pe=Pe.set("Authorization",w)}m&&(Pe=Pe.set(m));try{return await Pe.query(o)}catch(w){const me=tf(w),Ze=me==null?void 0:me.status;if(n&&Ze===401)return await s.auth.handleUnauthorized(Pe,me),Pe.query(o);throw new q({response:me,innerError:w,discard:Cl.includes(Ze)})}}class sf{constructor(e){f(this,"_all");f(this,"_previous");this._all=[e],this._previous=e,this.then=this.then.bind(this),this.compile=this.compile.bind(this)}then(e){return this._previous&&(this._previous.next=e),this._all.push(e),this._previous=e,{then:this.then,compile:this.compile}}compile(){return this._all}}class kl{constructor(){f(this,"next");this.next=null}then(e){return new sf(this).then(e)}async run(e){if(this.next)return this.next.run(e);{if(console.debug("Middleware finished. Performing request:",e),!Je())throw new Error("Client store not set");const n=Hy();if(!n)throw new Error("Client SDK not set");return bn(e,n)}}}class nf extends kl{async run(e){return super.run(e)}}class af extends kl{async run(e){return super.run(e)}}const cf=new nf().then(new af).compile();function rf(t){var e;return(e=cf[0])==null?void 0:e.run(t)}const Cl=[400,409,403,404,405,500];function In(t,e,s=0){var d;if(console.debug("Considering discarding request due to error:",t,`(${typeof t})`,`
3
3
  Action:`,e,`
4
- Retries:`,s),!(t instanceof Error))throw console.error("ENCOUNTERED NON-ERROR ERROR:",t,"(throwing immediately, which may lead to unexpected behavior)"),t;const n=We(),c=n.getState().outboxReducer.deletedRequests,r=e.payload.uuid;function o(){n.dispatch(zl(r));const h=ge();if(!h)throw new Error("Outbox coordinator not set");h.remove(e.payload.uuid);const f=e.meta.offline.rollback;throw f&&(console.warn("Rolling back request due to SDK error:",e),n.dispatch(f)),t}if(t instanceof q&&t.options.discard)return console.debug("Discarding request due to explicit discard:",e),o();if(c.includes(r))return console.debug("Discarding request due to deletion:",e),o();if(t instanceof q){const h=t.status||((d=t.response)==null?void 0:d.status);if(h||console.warn("Error has no status code:",t),h!==void 0&&ju.includes(h)){console.warn("Discarding request due to error:",t,`
5
- Action:`,e);const f=ge();if(!f)throw new Error("Outbox coordinator not set");f.remove(e.payload.uuid),t.options.discard=!0,o()}}console.debug("Registering a retry for request:",e.payload.uuid);const m=ge();if(!m)throw new Error("Outbox coordinator not set");return m.registerRetry(e.payload.uuid),!1}function DA(t,e,s){var n;return(n=ge())==null?void 0:n.peek()}function zA(t,e){return We().dispatch(Vl(new Date().getTime())),vn}const Ee="An unknown error occurred",VA=500,qu=["non_field_errors","detail"];function UA(t,e){let s;if(t!=null&&t.body)if(typeof t.body=="object"){const n=t.body;if(typeof n.error=="string")s=n.error;else if(typeof n.message=="string")s=n.message;else try{s=Object.entries(n).map(([a,c])=>typeof c=="string"?qu.includes(a)?c:`${a}: ${c}`:Array.isArray(c)?qu.includes(a)?c.join(`
4
+ Retries:`,s),!(t instanceof Error))throw console.error("ENCOUNTERED NON-ERROR ERROR:",t,"(throwing immediately, which may lead to unexpected behavior)"),t;const n=Je(),c=n.getState().outboxReducer.deletedRequests,r=e.payload.uuid;function u(){n.dispatch(Bu(r));const o=Fe();if(!o)throw new Error("Outbox coordinator not set");o.remove(e.payload.uuid);const p=e.meta.offline.rollback;throw p&&(console.warn("Rolling back request due to SDK error:",e),n.dispatch(p)),t}if(t instanceof q&&t.options.discard)return console.debug("Discarding request due to explicit discard:",e),u();if(c.includes(r))return console.debug("Discarding request due to deletion:",e),u();if(t instanceof q){const o=t.status||((d=t.response)==null?void 0:d.status);if(o||console.warn("Error has no status code:",t),o!==void 0&&Cl.includes(o)){console.warn("Discarding request due to error:",t,`
5
+ Action:`,e);const p=Fe();if(!p)throw new Error("Outbox coordinator not set");p.remove(e.payload.uuid),t.options.discard=!0,u()}}console.debug("Registering a retry for request:",e.payload.uuid);const m=Fe();if(!m)throw new Error("Outbox coordinator not set");return m.registerRetry(e.payload.uuid),!1}function df(t,e,s){var n;return(n=Fe())==null?void 0:n.peek()}function of(t,e){return Je().dispatch(Gu(new Date().getTime())),Mn}const ke="An unknown error occurred",uf=500,zl=["non_field_errors","detail"];function lf(t,e){let s;if(t!=null&&t.body)if(typeof t.body=="object"){const n=t.body;if(typeof n.error=="string")s=n.error;else if(typeof n.message=="string")s=n.message;else try{s=Object.entries(n).map(([a,c])=>typeof c=="string"?zl.includes(a)?c:`${a}: ${c}`:Array.isArray(c)?zl.includes(a)?c.join(`
6
6
  `):c.map(r=>`${a}: ${r}`).join(`
7
7
  `):`${a}: ${JSON.stringify(c)}`).join(`
8
- `)}catch(a){console.error("Failed to extract error message from response body",a)}}else typeof t.body=="string"&&(s=t.body);else t!=null&&t.text?s=t.text:e instanceof Error&&(s=e.message);return!s||s.length>VA?Ee:s}class q extends Error{constructor(s){super(Ee);y(this,"status");y(this,"response");y(this,"message");y(this,"options");const{response:n,innerError:a}=s;this.message=s.message??UA(n,a)??Ee,this.status=(n==null?void 0:n.status)??0,this.response=n,s.discard=s.discard??!1,this.options=s}}class $A{constructor(e){y(this,"store");this.store=e}async enqueueRequest(e,s,n){return this._enqueueRequest(e,s,n).then(a=>{if(a instanceof q)throw a;return a})}_enqueueRequest(e,s,n){const a=new wn,c={...e,BASE_URL:s,serviceName:n};if(e.immediate){const r={...c,uuid:e.uuid??O.v4()},o={payload:r,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:r,BASE_URL:s,serviceName:n}}}};An(o,this).then(m=>{a.resolve(m.body)}).catch(m=>{yn(m,o),m instanceof Error?a.reject(m):a.reject(new Error((m??Ee).toString()))})}else{const r=this.store.dispatch(Dl(c)),o=d=>{if(d)a.resolve(d.body);else{const h=new q({message:"Could not get a response from the server.",response:d,discard:!0});a.reject(h)}},m=d=>{d instanceof q?d.options.discard=!0:(console.error("Received an unexpected error while processing a request:",d,`
9
- Converting error to APIError and discarding.`),d=new q({message:"An error occurred while processing the request.",innerError:d,discard:!0})),a.reject(d)};r.then(o,m)}return a}}class je{constructor(){y(this,"graph");y(this,"requestAttemptCounter");this.graph=new Uu.DepGraph,this.requestAttemptCounter={}}static _fromOutbox(e){const s=new je;for(let n=0;n<e.length;n++){const a=e[n];if(!a){console.error("Outbox item was undefined");continue}s.sneakRequest(a);for(let c=0;c<n;c++){const r=e[c];if(!r){console.error("Previous outbox item was undefined");continue}r.payload.uuid!==a.payload.uuid&&r.payload.blocks.some(o=>a.payload.blockers.includes(o))&&je._addDependency(a.payload.uuid,r.payload.uuid,s.graph)}}return s}_addDependency(e,s){je._addDependency(e,s,this.graph)}static _addDependency(e,s,n){if(e===s)throw new Error(`Tried to add dependency from node to itself: ${e}`);if(!n.hasNode(e))throw new Error(`Tried to add dependency from non-existent node: ${e} (to node: ${s})`);if(!n.hasNode(s))throw new Error(`Tried to add dependency to non-existent node: ${s} (from node: ${e})`);n.addDependency(e,s)}addRequest(e){if(this.graph.addNode(e.payload.uuid,e),!(e.payload.blockers.length===0||this.graph.size()===1))for(const s of this.graph.overallOrder()){if(s===e.payload.uuid)continue;const n=this.graph.getNodeData(s);e.payload.blockers.some(a=>n.payload.blocks.includes(a))&&this._addDependency(e.payload.uuid,s)}}insertRequest(e){this.graph.addNode(e.payload.uuid,e);for(const s of this.graph.overallOrder()){if(s===e.payload.uuid)continue;this.graph.getNodeData(s).payload.blockers.some(a=>e.payload.blocks.includes(a))&&this._addDependency(s,e.payload.uuid)}}sneakRequest(e){this.graph.addNode(e.payload.uuid,e)}_getNextNode(){const e=this.graph.overallOrder(!0);let s=1/0,n;for(const a of e){const c=this.requestAttemptCounter[a]||0;c<s&&(s=c,n=a)}return n}peek(){const e=this._getNextNode();if(e)return this.graph.getNodeData(e)}remove(e){this.graph.removeNode(e),delete this.requestAttemptCounter[e]}pop(){const e=this.peek();return e&&this.graph.removeNode(e.payload.uuid),e}getQueue(){const e=this.graph.overallOrder().map(n=>this.graph.getNodeData(n)),s=this._getNextNode();if(s){const n=this.graph.getNodeData(s),a=e.findIndex(c=>c.payload.uuid===n.payload.uuid);a!==-1&&(e.splice(a,1),e.unshift(n))}return e}getReady(){let e=this.graph.overallOrder(!0).map(s=>this.graph.getNodeData(s));return e=e.sort((s,n)=>s.meta.offline.effect.timestamp.localeCompare(n.meta.offline.effect.timestamp)),e=e.sort((s,n)=>{const a=this.requestAttemptCounter[s.payload.uuid]||0,c=this.requestAttemptCounter[n.payload.uuid]||0;return a-c}),e}registerRetry(e){this.requestAttemptCounter[e]=(this.requestAttemptCounter[e]||0)+1}}const BA=(t,e)=>{const s=new e(t);return gA(s),SA(t),s};class R extends gu{constructor(s,n){super(s);y(this,"auth");this.auth=n}}class GA extends R{async startConversation(e,s){return this.enqueueRequest({description:"Start agent conversation",method:l.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:s},blockers:["prompt"],blocks:["prompt"]}).then(n=>(this.dispatch(Un(n)),n))}async continueConversation(e,s,n){return this.enqueueRequest({description:"Prompt agent",method:l.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:n},blockers:["prompt"],blocks:["prompt"],queryParams:{conversation_id:s}}).then(a=>{this.dispatch(Bn(a))})}async fetchDetails(e){return this.enqueueRequest({description:"Get agent conversation",method:l.GET,url:`/agents/conversations/${e}/`,blockers:["conversation"],blocks:["conversation"]}).then(s=>{this.dispatch($n(s))})}async rate(e,s){return this.enqueueRequest({description:"Rate agent response",method:l.PUT,url:`/agents/responses/${e}/rate/`,payload:{rating:s},blockers:["rate"],blocks:["rate"]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get agent conversation history",method:l.GET,url:`/projects/${e}/agent-conversations/`,blockers:["agent-conversations"],blocks:["agent-conversations"]});this.dispatch(Vn(s))}}class j extends R{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:n,assetTypeAttachmentReducer:a,documentAttachmentReducer:c,projectAttachmentReducer:r,formRevisionAttachmentReducer:o,formSubmissionAttachmentReducer:m,geoImageReducer:d,assetTypeFieldsAttachmentReducer:h,assetTypeFieldValuesAttachmentReducer:f,issueTypeFieldsAttachmentReducer:p,issueTypeFieldValuesAttachmentReducer:A}=this.client.store.getState();return[].concat(Object.values(s.instances),Object.values(n.instances),Object.values(a.instances),Object.values(c.instances),Object.values(r.instances),Object.values(o.instances),Object.values(m.instances),Object.values(d.instances),Object.values(h.instances),Object.values(f.instances),Object.values(p.instances),Object.values(A.instances)).filter(_=>_.file_sha1===e).length}processPresignedUrls(e){const s={};for(const[n,a]of Object.entries(e))s[n]=this.enqueueRequest({url:a.url,description:"Upload file to S3",method:l.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:n,blockers:[`s3-${a.fields.key}`],blocks:[n],s3url:a});return s}async getFilePayload(e){const s=await Ie(e),n={sha1:s,file_type:e.type,extension:e.name.split(".").pop(),size:e.size};return await this.client.files.addCache(e,s),n}}class be extends j{async _bulkAdd(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=[],r=[],o={};for(const h of e){const{modelId:f,file:p}=h,A=await this.getFilePayload(p);A.sha1 in o||(o[A.sha1]=A);const T=this.buildOfflineAttachment({file:p,file_sha1:A.sha1,submitted_at:a,created_by:n,description:"",modelId:f});c.push(T),r.push(this.buildAttachmentPayload({offline_id:T.offline_id,file_name:T.file_name,file_sha1:T.file_sha1,file_extension:A.extension,description:T.description,modelId:f}))}this.dispatch(this.addAttachments(c));const m=this.enqueueRequest({description:`Add ${this.name}`,method:l.POST,url:`${this.url}/bulk/`,payload:{submitted_at:a,attachments:r,files:Object.values(o)},blocks:c.map(h=>h.offline_id),blockers:c.map(h=>h.file_sha1)});return m.then(({attachments:h,presigned_urls:f})=>{this.dispatch(this.updateAttachments(h)),this.processPresignedUrls(f)}).catch(()=>{this.dispatch(this.removeAttachments(c.map(h=>h.offline_id)))}),[c,m.then(({attachments:h})=>h)]}async _delete(e){const{store:s}=this.client,n=this.selectAttachment(e)(s.getState());if(!n)throw new Error(`Attempting to delete attachment with offline_id ${e} that does not exist in the store`);this.dispatch(this.removeAttachment(n.offline_id));const a=this.enqueueRequest({description:`Delete ${this.name}`,method:l.DELETE,url:`${this.url}/${e}/`,blockers:[e],blocks:[]});return a.then(()=>{this.getNumberOfAttachmentsWithSha1(n.file_sha1)===0&&this.client.files.removeCache(n.file_sha1)}).catch(()=>{this.dispatch(this.setAttachment(n))}),a}}class LA extends be{constructor(){super(...arguments);y(this,"name","Asset Attachment");y(this,"url","/asset-attachments");y(this,"initializeAttachments",kt);y(this,"addAttachments",Ct);y(this,"updateAttachments",Hn);y(this,"removeAttachments",Dt);y(this,"removeAttachment",Wn);y(this,"setAttachment",Nn);y(this,"selectAttachment",Jn)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset:s.modelId})}buildAttachmentPayload(s){return{...s,asset:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.assetId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get asset attachments",method:l.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blocks:[],blockers:[]});this.dispatch(kt(n))}}class NA extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=d,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const T=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(T);const _={offline_id:T.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,fields_revision:h};r.push(_)}this.dispatch(ea(c));const o=this.enqueueRequest({description:"Add asset procedure fields attachments",method:l.POST,url:"/asset-procedure-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.offline_id)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(ta(d.attachments))}).catch(()=>{this.dispatch(sa(c.map(d=>d.offline_id)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure fields attachments",method:l.GET,url:"/asset-procedure-fields-attachments/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(xn(s))}}class HA extends R{add(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(da(c));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:l.POST,url:"/asset-procedure-fields/",payload:c,blockers:[c.asset_procedure],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(oa(m))}).catch(m=>{throw this.dispatch(la(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:l.GET,url:"/asset-procedure-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(ra(s))}}function Ke(t,e){const s=[];let n=0;const a=t.length;for(;n<a;)s.push(t.slice(n,n+=e));return s}class WA extends j{async bulkAdd(e,s){var d;const n=new Date().toISOString(),a=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,c=Ke(e,s??e.length),r=[],o=[];for(const h of c){const f={},p=[];for(const A of h){const{fieldValuesId:T,fieldIdentifier:_,file:b}=A,P=await this.getFilePayload(b);P.sha1 in f||(f[P.sha1]=P);const M=F({file:URL.createObjectURL(b),file_type:b.type,file_name:b.name,file_sha1:P.sha1,created_by:a,field_values:T,submitted_at:n,field_identifier:_});r.push(M);const _t={offline_id:M.offline_id,file_name:b.name,file_sha1:P.sha1,file_extension:P.extension,field_identifier:_,field_values:T};p.push(_t)}o.push({submitted_at:n,attachments:p,files:Object.values(f)})}this.dispatch(Je(r));const m=o.map(h=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:l.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:h,blockers:h.attachments.map(f=>f.field_values),blocks:h.attachments.map(f=>f.offline_id)}));return Promise.all(m).then(h=>{for(const p of h)this.processPresignedUrls(p.presigned_urls);const f=h.flatMap(p=>p.attachments);this.dispatch(pa(f))}).catch(h=>{throw this.dispatch(Xe(r.map(f=>f.offline_id))),h}),[r,m.map(h=>h.then(({attachments:f})=>f))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=ya(e)(n);this.dispatch(Xe(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:l.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(Je(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values attachments",method:l.GET,url:"/asset-procedure-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(fa(s))}}const KA=t=>Array.isArray(t)&&t[0]instanceof File,qe=t=>{const e={},s={};for(const n in t){const a=t[n];a instanceof File?e[n]=[a]:KA(a)?e[n]=a:a!==void 0&&(s[n]=a)}return{values:s,files:e}};class YA extends j{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add form submission",method:l.POST,url:"/form-submissions/",payload:v(a),blockers:["add-form-entry",e.form_revision,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[a.offline_id]});return this.dispatch(ni(a)),c.then(o=>(this.dispatch(rt(o)),o)).catch(()=>{this.dispatch(ai(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=di(e.offline_id)(n);if(!a)throw new Error(`Expected submission with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(ed(c));const r=this.enqueueRequest({description:"Delete user form submissions",method:l.PATCH,url:`/form-submissions/${c.offline_id}/`,payload:e,blockers:[c.offline_id],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(rt(o))}).catch(()=>{this.dispatch(rt(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=di(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=Xr(e)(n);this.dispatch(ai(e)),this.dispatch(ct(c.map(r=>r.offline_id)));try{return await this.enqueueRequest({description:"Delete user form submissions",method:l.DELETE,url:`/form-submissions/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ni(a)),this.dispatch(at(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch form submissions",method:l.GET,url:"/form-submissions/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(xr(s))}}class JA extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset procedure field values",method:l.POST,url:"/asset-procedure-field-values/",payload:a,blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[a.offline_id]});return this.dispatch(Lt(a)),c.then(o=>(this.dispatch(ke(o)),o)).catch(()=>{this.dispatch(Nt(a.offline_id))}),[a,c]}bulkAdd(e,s){var d;const n=new Date().toISOString(),{values:a}=qe(e.values),c=[],r=Ke(e.payloads,s??e.payloads.length),o=[];for(const h of r){const f=[];for(const p of h){const A=F({...p,values:qe(p.values).values,created_by:(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,submitted_at:n});c.push(A),f.push({offline_id:A.offline_id,asset:p.asset,fields_revision:p.fields_revision,asset_procedure_instance:p.asset_procedure_instance,published_at:p.published_at,values:A.values})}o.push({submitted_at:n,values:a,field_values:f})}this.dispatch(_a(c));const m=[];for(const h of o){const f=h.field_values.map(b=>b.asset),p=h.field_values.map(b=>b.fields_revision),A=h.field_values.map(b=>b.asset_procedure_instance),T=h.field_values.map(b=>b.offline_id),_=this.enqueueRequest({description:"Bulk add asset procedure field values",method:l.POST,url:"/asset-procedure-field-values/bulk/",payload:h,blockers:[...f,...p,...A],blocks:T});m.push(_)}return Promise.all(m).then(h=>{this.dispatch(Fa(h.flat()))}).catch(()=>{this.dispatch(Ia(c.map(h=>h.offline_id)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=Wt(e.offline_id)(n);if(!a)throw new Error(`Expected AssetProcedureFieldValues with offline_id ${e.offline_id} to exist`);const{values:c}=qe(e.values??{}),r={...a,...e,values:{...a.values,...c}};this.dispatch(ke(r));const o=this.enqueueRequest({description:"Update asset procedure field values",method:l.PATCH,url:`/asset-procedure-field-values/${e.offline_id}/`,payload:{...e,values:{...a.values,...c}},blockers:[r.fields_revision,r.asset,r.asset_procedure_instance],blocks:[r.offline_id]});return o.then(m=>{this.dispatch(ke(m))}).catch(()=>{this.dispatch(ke(a))}),[r,o]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Wt(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=Sa(e)(n);this.dispatch(Nt(e)),this.dispatch(Xe(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete asset procedure field values",method:l.DELETE,url:`/asset-procedure-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Lt(a)),this.dispatch(Je(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values",method:l.GET,url:"/asset-procedure-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Ta(s))}}class XA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Yt(c));const r=this.enqueueRequest({description:"Create asset procedure instance",method:l.POST,url:"/asset-procedure-instances/",payload:{...c},blockers:[e.asset_procedure,e.asset_type],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(Ce(o))}).catch(()=>{this.dispatch(Jt(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=Zt(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset procedure instance with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(Ce(a));const c=this.enqueueRequest({description:"Update asset procedure instance",method:l.PATCH,url:`/asset-procedure-instances/${e.offline_id}/`,payload:{asset_procedure:e.asset_procedure,asset_type:e.asset_type},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(Ce(r))}).catch(()=>{this.dispatch(Ce(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=Zt(e)(n);if(!a)throw new Error(`Expected asset procedure instance with offline_id ${e} to exist`);return this.dispatch(Jt(e)),this.enqueueRequest({description:"Delete asset procedure instance",method:l.DELETE,url:`/asset-procedure-instances/${e}/`,blockers:[e],blocks:[]}).catch(c=>{throw this.dispatch(Yt(a)),c})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure instances",method:l.GET,url:"/asset-procedure-instances/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(va(s))}}class QA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(es(c));const r=this.enqueueRequest({description:"Create asset procedure",method:l.POST,url:"/asset-procedures/",queryParams:{organization_id:e.organization.toString()},payload:{...c},blockers:[],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(De(o))}).catch(()=>{this.dispatch(ts(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=is(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset procedure with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(De(a));const c=this.enqueueRequest({description:"Update asset procedure",method:l.PATCH,url:`/asset-procedures/${e.offline_id}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(De(r))}).catch(()=>{this.dispatch(De(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=is(e)(n);if(!a)throw new Error(`Expected asset procedure with offline_id ${e} to exist`);const c=ja(e)(n);return this.dispatch(ts(e)),this.dispatch(Ea(c.map(r=>r.offline_id))),this.enqueueRequest({description:"Delete asset procedure",method:l.DELETE,url:`/asset-procedures/${e}/`,blockers:[e],blocks:[]}).catch(r=>{throw this.dispatch(es(a)),this.dispatch(wa(c)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedures",method:l.GET,url:"/asset-procedures/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(ka(s))}}class ZA extends R{add(e){const{store:s}=this.client;if(!e.canvas_marker&&!e.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");const n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(as(c));const r=this.enqueueRequest({description:"Create asset",method:l.POST,url:"/assets/",payload:v(c),blockers:[c.asset_type],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(ze(o))}).catch(()=>{this.dispatch(rs(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=ls(e.offline_id)(s.getState());if(!n)throw new Error(`No asset with id ${e.offline_id} found in the store`);const a={...n,...e};if(!a.canvas_marker&&!a.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");this.dispatch(ze(a));const c=this.enqueueRequest({description:"Edit asset",method:l.PATCH,url:`/assets/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.then(r=>{this.dispatch(ze(r))}).catch(()=>{this.dispatch(ze(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=ls(e)(n);if(!a)throw new Error(`No asset with id ${e} found in the store`);const c=Xn(e)(n),r=id(e)(n),o=Td(e)(n);if(this.dispatch(rs(e)),c.length>0){const m=c.map(({offline_id:d})=>d);this.dispatch(Dt(m))}if(r.length>0){const m=r.map(({offline_id:d})=>d);this.dispatch(ot(m))}if(o.length>0){const m=o.map(({offline_id:d})=>d);this.dispatch(Ai(m))}return this.enqueueRequest({description:"Delete asset",method:l.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(as(a)),this.dispatch(Ct(c)),this.dispatch(dt(r)),this.dispatch(fi(o)),m})}bulkAdd(e,s,n,a){const c=new Date().toISOString(),r=O.v4(),o=Ke(e,a).map(h=>{const f=h.map(p=>F(p));return{batchId:O.v4(),payload:{transaction_id:r,submitted_at:c,asset_type:s,project:n,assets:f}}}),m=[];let d=null;for(const h of o){const{batchId:f,payload:p}=h,A=p.assets.map(P=>P.offline_id),T=[s];d&&T.push(d);const _=A;_.push(f);const b=this.enqueueRequest({description:"Batch create assets",method:l.POST,url:"/assets/bulk/",payload:p,blockers:T,blocks:_});d=h.batchId,m.push(b)}return Promise.all(m).then(h=>{const f=h.flat();this.dispatch(cs(f))}),m}async refreshStore(e){const s=await this.enqueueRequest({description:"Get assets",method:l.GET,url:"/assets/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Va(s))}}class xA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(hs(c));const r=this.enqueueRequest({description:"Add asset stage completion",method:l.POST,url:"/asset-stage-completions/",payload:v(c),blockers:[e.asset,e.stage],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(Na(o))}).catch(()=>{this.dispatch(fs(c.offline_id))}),[c,r]}delete(e){const{store:s}=this.client,n=Ka(e)(s.getState());if(!n)throw new Error(`Expected asset stage completion with id ${e} to exist`);this.dispatch(fs(e));const a=this.enqueueRequest({description:"Delete asset stage completion",method:l.DELETE,url:`/asset-stage-completions/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(hs(n))}),a}bulkAdd(e){const{store:s}=this.client,n=new Date().toISOString(),a=s.getState().userReducer.currentUser.id,c=e.map(d=>F(d)),r=c.map(d=>({...d,created_by:a,submitted_at:n})),o=r.map(({offline_id:d})=>d);this.dispatch(ms(r));const m=this.enqueueRequest({description:"Bulk create asset stage completions",method:l.POST,url:"/asset-stage-completions/bulk/",payload:{submitted_at:n,completions:c},blockers:[...e.map(d=>d.asset_procedure_instance),...e.map(d=>d.stage),...e.map(d=>d.asset)],blocks:o});return m.then(d=>{this.dispatch(Ha(d))}).catch(()=>{this.dispatch(ps(o))}),[r,m]}bulkDelete(e){const{store:s}=this.client,n=Ya(e)(s.getState());this.dispatch(ps(e));const a=this.enqueueRequest({description:"Deleting asset stage completions",method:l.DELETE,url:"/asset-stage-completions/bulk/",payload:{completion_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(ms(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stage completions",method:l.GET,url:"/asset-stage-completions/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(La(s))}}class ey extends R{bulkAdd(e,s){const n=new Date().toISOString(),a=this.client.store.getState().userReducer.currentUser.id,c=e.map(m=>F(m)),r=c.map(m=>({...m,asset_procedure:s,created_by:a,submitted_at:n}));this.dispatch(Ss(r));const o=this.enqueueRequest({description:"Add asset stages",method:l.POST,url:"/asset-stages/bulk/",payload:{submitted_at:n,asset_procedure:s,stages:c},blockers:[s],blocks:c.map(({offline_id:m})=>m)});return o.then(m=>{this.dispatch(Qe(m))}).catch(()=>{this.dispatch(bs(r.map(({offline_id:m})=>m)))}),[r,o]}async bulkUpdate(e,s){const a=this.client.store.getState(),c=Ts(e.map(({offline_id:r})=>r))(a);return this.dispatch(Qe(e)),this.enqueueRequest({description:"Edit asset stages",method:l.PATCH,url:`/asset-procedures/${s}/bulk-update-stages/`,payload:{stages:e},blockers:[s],blocks:e.map(({offline_id:r})=>r)}).catch(r=>{throw this.dispatch(Qe(c)),r})}async bulkDelete(e){const{store:s}=this.client,n=Ts(e)(s.getState());this.dispatch(bs(e));const a=this.enqueueRequest({description:"Delete asset stages",method:l.DELETE,url:"/asset-stages/bulk/",payload:{stage_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(Ss(n))}),a}update(e){const{store:s}=this.client,n=xa(e.offline_id)(s.getState());if(!n)throw new Error(`No asset stage with id ${e.offline_id} found in the store`);const a={...n,...e};this.dispatch(gs(a));const c=this.enqueueRequest({description:"Update asset stage",method:l.PATCH,url:`/asset-stages/${n.offline_id}/`,payload:{name:e.name,description:e.description,priority:e.priority,color:e.color},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(gs(r))}).catch(()=>{this.dispatch(Qa(n))}),[a,c]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stages",method:l.GET,url:"/asset-stages/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Xa(s))}}class ty extends be{constructor(){super(...arguments);y(this,"name","Asset Type Attachment");y(this,"url","/asset-type-attachments");y(this,"addAttachments",Fs);y(this,"updateAttachments",nc);y(this,"removeAttachments",Is);y(this,"removeAttachment",ac);y(this,"setAttachment",ic);y(this,"selectAttachment",dc)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset_type:s.modelId})}buildAttachmentPayload(s){return{...s,asset_type:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.assetTypeId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get asset type attachments",method:l.GET,url:`${this.url}/`,queryParams:{organization:s.toString()},blocks:[],blockers:[]});this.dispatch(sc(n))}}class sy extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=d,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const T=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(T);const _={offline_id:T.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,fields_revision:h};r.push(_)}this.dispatch(mc(c));const o=this.enqueueRequest({description:"Add asset type fields attachments",method:l.POST,url:"/asset-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.offline_id)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(fc(d.attachments))}).catch(()=>{this.dispatch(pc(c.map(d=>d.offline_id)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type fields attachments",method:l.GET,url:"/asset-type-fields-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(hc(s))}}class iy extends R{add(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Tc(c));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:l.POST,url:"/asset-type-fields/",payload:c,blockers:[c.asset_type],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(_c(m))}).catch(m=>{throw this.dispatch(Fc(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Type Fields",method:l.GET,url:"/asset-type-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(bc(s))}}class ny extends j{async bulkAdd(e,s){var d;const n=new Date().toISOString(),a=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,c=Ke(e,s??e.length),r=[],o=[];for(const h of c){const f={},p=[];for(const A of h){const{fieldValuesId:T,fieldIdentifier:_,file:b}=A,P=await this.getFilePayload(b);P.sha1 in f||(f[P.sha1]=P);const M=F({file:URL.createObjectURL(b),file_type:b.type,file_name:b.name,file_sha1:P.sha1,created_by:a,field_values:T,submitted_at:n,field_identifier:_});r.push(M);const _t={offline_id:M.offline_id,file_name:b.name,file_sha1:P.sha1,file_extension:P.extension,field_identifier:_,field_values:T};p.push(_t)}o.push({submitted_at:n,attachments:p,files:Object.values(f)})}this.dispatch(et(r));const m=o.map(h=>this.enqueueRequest({description:"Add asset type field values attachments",method:l.POST,url:"/asset-type-field-values-attachments/bulk/",payload:h,blockers:h.attachments.map(f=>f.field_values),blocks:h.attachments.map(f=>f.offline_id)}));return Promise.all(m).then(h=>{for(const p of h)this.processPresignedUrls(p.presigned_urls);const f=h.flatMap(p=>p.attachments);this.dispatch(vc(f))}).catch(h=>{throw this.dispatch(tt(r.map(f=>f.offline_id))),h}),[r,m.map(h=>h.then(({attachments:f})=>f))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Ec(e)(n);this.dispatch(tt(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:l.DELETE,url:"/asset-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(et(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values attachments",method:l.GET,url:"/asset-type-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Oc(s))}}class ay extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset type field values",method:l.POST,url:"/asset-type-field-values/",payload:v(a),blockers:[e.asset,e.fields_revision],blocks:[a.offline_id]});return this.dispatch(Es(a)),c.then(o=>(this.dispatch(Ve(o)),o)).catch(()=>{this.dispatch(js(a.offline_id))}),[a,c]}bulkAdd(e,s){var d;const n=new Date().toISOString(),{values:a}=qe(e.values),c=[],r=Ke(e.payloads,s??e.payloads.length),o=[];for(const h of r){const f=[];for(const p of h){const A=F({...p,values:qe(p.values).values,created_by:(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,submitted_at:n});c.push(A),f.push({offline_id:A.offline_id,asset:p.asset,fields_revision:p.fields_revision,published_at:p.published_at,values:A.values})}o.push({submitted_at:n,values:a,field_values:f})}this.dispatch(Cc(c));const m=[];for(const h of o){const f=h.field_values.map(_=>_.asset),p=h.field_values.map(_=>_.fields_revision),A=h.field_values.map(_=>_.offline_id),T=this.enqueueRequest({description:"Bulk add asset type field values",method:l.POST,url:"/asset-type-field-values/bulk/",payload:h,blockers:[...f,...p],blocks:A});m.push(T)}return Promise.all(m).then(h=>{this.dispatch(Dc(h.flat()))}).catch(()=>{this.dispatch(zc(c.map(h=>h.offline_id)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=Ms(e.offline_id)(n);if(!a)throw new Error(`Expected AssetTypeFieldValues with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(Ve(c));const r=this.enqueueRequest({description:"Delete asset type field values",method:l.PATCH,url:`/asset-type-field-values/${e.offline_id}/`,payload:e,blockers:[c.offline_id,c.fields_revision,c.asset],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(Ve(o))}).catch(()=>{this.dispatch(Ve(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Ms(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=jc(e)(n);this.dispatch(js(e)),this.dispatch(tt(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete asset type field values",method:l.DELETE,url:`/asset-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Es(a)),this.dispatch(et(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values",method:l.GET,url:"/asset-type-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(kc(s))}}class cy extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Cs(c));const r=this.enqueueRequest({description:"Create asset type",method:l.POST,url:"/asset-types/",payload:v(c),blockers:[],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(Ue(o))}).catch(()=>{this.dispatch(Ds(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=Vs(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset type with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(Ue(a));const c=this.enqueueRequest({description:"Update asset type",method:l.PATCH,url:`/asset-types/${e.offline_id}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(Ue(r))}).catch(()=>{this.dispatch(Ue(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Vs(e)(n);if(!a)throw new Error(`Expected asset type with offline_id ${e} to exist`);const c=os(e)(n),r=oc(e)(n);return this.dispatch(Ds(e)),this.dispatch(Ua(c.map(o=>o.offline_id))),this.dispatch(Is(r.map(({offline_id:o})=>o))),this.enqueueRequest({description:"Delete asset type",method:l.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(o=>{throw this.dispatch(Cs(a)),this.dispatch(cs(c)),this.dispatch(Fs(r)),o})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset types",method:l.GET,url:"/asset-types/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Bc(s))}}class ry extends R{add(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch($s(c));const r=this.enqueueRequest({description:"Create Category",method:l.POST,url:"/categories/",payload:v(c),blockers:[e.project.toString()],blocks:[c.offline_id]});return[c,r]}update(e){const s=this.client.store.getState(),n=Gs(e.offline_id)(s);if(!n)throw new Error(`Expected an existing category with offline_id ${e.offline_id}`);const a={...n,...e};this.dispatch(Yc(a));const c=this.enqueueRequest({description:"Edit Category",method:l.PATCH,url:`/categories/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return[a,c]}remove(e){const{store:s}=this.client,n=Gs(e)(s.getState());if(!n)throw new Error(`No category with id ${e} found in the store`);this.dispatch(Jc(e));const a=this.enqueueRequest({description:"Delete Category",method:l.DELETE,url:`/categories/${n.offline_id}/`,blockers:[n.offline_id],blocks:[]});return a.catch(()=>{this.dispatch($s(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get categories",method:l.GET,url:"/categories/",queryParams:{project:e.toString()},blocks:[],blockers:[]});this.dispatch(Kc(s))}}class dy extends be{constructor(){super(...arguments);y(this,"name","Document Attachment");y(this,"url","/document-attachments");y(this,"addAttachments",xc);y(this,"updateAttachments",tr);y(this,"removeAttachments",ir);y(this,"removeAttachment",sr);y(this,"setAttachment",er);y(this,"selectAttachment",cr)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,document:s.modelId})}buildAttachmentPayload(s){return{...s,document:s.modelId}}async bulkAdd(s){var f;const{store:n}=this.client,a=(f=n.getState().userReducer.currentUser)==null?void 0:f.id,c=new Date().toISOString(),r=[],o=[],m={},d={};for(const p of s){const{documentId:A,file:T}=p,_=await this.getFilePayload(T);_.sha1 in m||(m[_.sha1]=_,d[_.sha1]=[]);const b=this.buildOfflineAttachment({file:T,file_sha1:_.sha1,submitted_at:c,created_by:a,description:"",modelId:A});r.push(b),o.push({offline_id:b.offline_id,file_name:b.file_name,file_sha1:b.file_sha1,file_extension:_.extension,description:b.description,document:A}),d[_.sha1].push(b.offline_id)}this.dispatch(this.addAttachments(r));const h=this.enqueueRequest({description:"Attach files to document",method:l.POST,url:"/document-attachments/bulk/",payload:{submitted_at:c,attachments:o,files:Object.values(m)},blocks:r.map(p=>p.offline_id),blockers:r.map(p=>p.file_sha1)});return h.then(({attachments:p,presigned_urls:A})=>{this.dispatch(this.updateAttachments(p));const T=this.processPresignedUrls(A);for(const[_,b]of Object.entries(T))b.then(()=>{const P=d[_];for(const M of P)this.makeReadable(M)})}).catch(()=>{this.dispatch(this.removeAttachments(r.map(p=>p.offline_id)))}),[r,h.then(({attachments:p})=>p)]}async delete(s){return this._delete(s)}makeReadable(s){this.enqueueRequest({description:"Add attachment to AI assistant",method:l.PATCH,url:`/document-attachments/${s}/`,payload:{readable_to_assistant:!0},blockers:["index-document-attachment",s],blocks:["index-document-attachment"]})}async refreshStore(s,n){const a=await this.enqueueRequest({description:"Get document attachments",method:l.GET,url:`/projects/${s}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(Zc(a));const c=await this.enqueueRequest({description:"Get document attachments",method:l.GET,url:`/organizations/${n}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(this.addAttachments(c))}}class oy extends R{add(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(lr([c]));const r=this.enqueueRequest({description:"Create Document",method:l.POST,url:"/documents/",payload:v(c),queryParams:{parent_document:c.parent_document??void 0},blockers:c.parent_document?[c.parent_document]:[],blocks:[c.offline_id]});return r.catch(()=>{this.dispatch(Hs([c.offline_id]))}),[c,r]}update(e){const{store:s}=this.client,n=s.getState().documentsReducer.documents[e.offline_id];if(!n)throw new Error(`attempting to update a document with offline_id ${e.offline_id} that does not exist in store.documents`);const a={...n,...e};this.dispatch(me([a]));const c=this.enqueueRequest({description:"Update Document",method:l.PATCH,url:`/documents/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.catch(()=>{me([n])}),[a,c]}move(e,s,n){const{store:a}=this.client,c=Re(a.getState()),r=[],o=c[e];if(!o)throw new Error(`attempting to move a document with offline_id ${e} that does not exist in store.documents`);if(r.push(o),o.parent_document&&r.push(c[o.parent_document]),s){const d=c[s];if(!d)throw new Error(`attempting to move a document to target with offline_id ${s} that does not exist in store.documents`);r.push(d),d.parent_document&&r.push(c[d.parent_document])}this.dispatch(ur({documentId:e,targetDocumentId:s,position:n}));const m=this.enqueueRequest({description:"Move Document",method:l.PATCH,url:`/documents/${e}/move/`,queryParams:{target:s??void 0,position:n},blockers:[e],blocks:[]});return m.then(d=>{this.dispatch(me(d))}).catch(()=>{this.dispatch(me(r))}),m}delete(e){const{store:s}=this.client,n=Re(s.getState()),a=mr(e)(s.getState());if(!a)throw new Error(`attempting to delete a document with offline_id ${e} that does not exist in store.documents`);const c=a.parent_document?n[a.parent_document]:void 0;this.dispatch(Hs([e]));const r=this.enqueueRequest({description:"Delete Document",method:l.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return r.then(o=>{this.dispatch(me(o))}).catch(()=>{this.dispatch(me([a])),c&&this.dispatch(me([c]))}),r}async refreshStore(e,s){const n=this.enqueueRequest({description:"Get project documents",method:l.GET,url:`/projects/${e}/documents/`,blockers:[],blocks:[]}),a=this.enqueueRequest({description:"Get organization documents",method:l.GET,url:`/organizations/${s}/documents/`,blockers:[],blocks:[]});this.dispatch(or([...await n,...await a]))}}class ly extends R{async add(e,s){return this.enqueueRequest({description:"Add email domain to organization",method:l.POST,url:`/organizations/${e}/email-domains/`,payload:{email:s},blockers:[e.toString(),"create-org"],blocks:[]})}async remove(e){return this.dispatch(yr(e.offline_id)),this.enqueueRequest({description:"Remove email domain from organization",method:l.DELETE,url:`/organizations/${e.organization}/email-domains/${e.offline_id}/`,blockers:[e.domain],blocks:[]}).catch(s=>{throw this.dispatch(Ar(e)),s})}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch email domains for organization",method:l.GET,url:`/organizations/${e}/email-domains/`,blockers:[e.toString()],blocks:[]});this.dispatch(pr(s))}}class uy extends R{async getVerificationCode(e){return this.enqueueRequest({description:"Get verification code",method:l.GET,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}validateVerificationCode(e,s=void 0){return this.enqueueRequest({description:"Validate verification code",method:l.POST,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,payload:s,blockers:[],blocks:[]})}}const bt={},Sn=new Set;let Tt=0,gn=0,bn=0;const hy=20;class my extends R{constructor(){super(...arguments);y(this,"host");y(this,"_dbPromise",$u.openDB("fileCache",1,{upgrade(s){s.createObjectStore("files")}}))}async renewUploadUrl(s){const n=await this.fetchCache(s);if(!n)throw new Error(`File with sha1 ${s} not found in cache`);const a=await Et(n,s),c=await this.enqueueRequest({description:"Get S3 URL",method:l.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await Ie(n),file_type:n.type,extension:n.name.split(".").pop(),size:n.size.toString()},blockers:[],blocks:[`s3-${a}`]});return"url"in c&&this.dispatch(Fr({sha1:s,...c})),c}async addCache(s,n){if(Sn.has(n))return;if(!s.type){const r=s.name.split("."),o=r[r.length-1];s=new File([s],s.name,{type:o})}if(!s.name||!s.size||!s.type)throw new Error("Cannot add files to cache that do not have a name, size and type.");const a=await this._dbPromise;!!await a.get("files",n)?(console.error("File already cached (this is unexpected at this point):",s.name,n),Tt++):(await a.put("files",s,n),gn++),Sn.add(n),bn++,bn%hy===0&&console.debug(`File cache summary: ${Tt} hits and ${gn} misses, ${Tt/(Tt+gn)*100}% hit rate over ${bn} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),Sn.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const n=this.client.store.getState();return Ir(s)(n)??await this.renewUploadUrl(s)}async uploadFileToS3(s){const n=await this.fetchCache(s);if(!n)throw new Error(`File with sha1 ${s} not found in cache`);const a=await Et(n,s),c={file_name:n.name,file_sha1:s,file:a},r=await this.getOrRenewUploadUrl(s);if("warning"in r){if(r.warning==="already_uploaded")return[c,Promise.resolve(void 0).then()];throw new Error(r.warning)}const o=r.url,m=this.enqueueRequest({url:o,description:"Upload file",method:l.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:s,blockers:[`s3-${a}`],blocks:[s],s3url:r});return[c,m]}async fetchFileFromUrl(s,n,a){const c=s.split("?")[0]??s,r=await this.fetchCache(n);if(r){if(!r.name)throw new Error("Cached file unexpectedly has no name.");return r}if(s.startsWith("blob:")){const h=await qn(s),f=new File([h],a??n,{type:h.type});return await this.addCache(f,n),f}let o=bt[c],m=!0;o?m=!1:(o=new Promise(h=>{this.enqueueRequest({description:"Download file",method:l.GET,url:s,isExternalUrl:!0,isResponseBlob:!0,isAuthNeeded:!1,blockers:[n],blocks:[n]}).then(f=>{const p=new File([f],a??n,{type:f.type});h(p)})}),bt[c]=o);let d;try{d=await o}catch(h){throw m&&h instanceof q&&delete bt[c],h}if(m){const h=await Ie(d);if(h!==n){const A=`The hash of the file returned from the server (${h}) does not match the
8
+ `)}catch(a){console.error("Failed to extract error message from response body",a)}}else typeof t.body=="string"&&(s=t.body);else t!=null&&t.text?s=t.text:e instanceof Error&&(s=e.message);return!s||s.length>uf?ke:s}class q extends Error{constructor(s){super(ke);f(this,"status");f(this,"response");f(this,"message");f(this,"options");const{response:n,innerError:a}=s;this.message=s.message??lf(n,a)??ke,this.status=(n==null?void 0:n.status)??0,this.response=n,s.discard=s.discard??!1,this.options=s}}class hf extends Fl{constructor(e){super(e)}}class P extends Fl{constructor(s,n){super(s);f(this,"auth");this.auth=n}}class mf extends P{async startConversation(e,s){return this.enqueueRequest({description:"Start agent conversation",method:l.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:s},blockers:["prompt"],blocks:["prompt"]}).then(n=>(this.dispatch(Nn(n)),n))}async continueConversation(e,s,n){return this.enqueueRequest({description:"Prompt agent",method:l.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:n},blockers:["prompt"],blocks:["prompt"],queryParams:{conversation_id:s}}).then(a=>{this.dispatch(Wn(a))})}async fetchDetails(e){return this.enqueueRequest({description:"Get agent conversation",method:l.GET,url:`/agents/conversations/${e}/`,blockers:["conversation"],blocks:["conversation"]}).then(s=>{this.dispatch(Hn(s))})}async rate(e,s){return this.enqueueRequest({description:"Rate agent response",method:l.PUT,url:`/agents/responses/${e}/rate/`,payload:{rating:s},blockers:["rate"],blocks:["rate"]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get agent conversation history",method:l.GET,url:`/projects/${e}/agent-conversations/`,blockers:["agent-conversations"],blocks:["agent-conversations"]});this.dispatch(Ln(s))}}class E extends P{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:n,assetTypeAttachmentReducer:a,documentAttachmentReducer:c,projectAttachmentReducer:r,formRevisionAttachmentReducer:u,formSubmissionAttachmentReducer:m,geoImageReducer:d,assetTypeFieldsAttachmentReducer:o,assetTypeFieldValuesAttachmentReducer:p,issueTypeFieldsAttachmentReducer:A,issueTypeFieldValuesAttachmentReducer:y}=this.client.store.getState();return[].concat(Object.values(s.instances),Object.values(n.instances),Object.values(a.instances),Object.values(c.instances),Object.values(r.instances),Object.values(u.instances),Object.values(m.instances),Object.values(d.instances),Object.values(o.instances),Object.values(p.instances),Object.values(A.instances),Object.values(y.instances)).filter(F=>F.file_sha1===e).length}processPresignedUrls(e){const s={};for(const[n,a]of Object.entries(e))s[n]=this.enqueueRequest({url:a.url,description:"Upload file to S3",method:l.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:n,blockers:[`s3-${a.fields.key}`],blocks:[n],s3url:a});return s}async getFilePayload(e){const s=await _e(e),n={sha1:s,file_type:e.type,extension:e.name.split(".").pop(),size:e.size};return await this.client.files.addCache(e,s),n}}class Re extends E{async _bulkAdd(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=[],r=[],u={};for(const o of e){const{modelUuid:p,file:A}=o,y=await this.getFilePayload(A);y.sha1 in u||(u[y.sha1]=y);const b=this.buildOfflineAttachment({file:A,file_sha1:y.sha1,submitted_at:a,created_by:n,description:"",modelUuid:p});c.push(b),r.push(this.buildAttachmentPayload({uuid:b.uuid,file_name:b.file_name,file_sha1:b.file_sha1,file_extension:y.extension,description:b.description,modelUuid:p}))}this.dispatch(this.addAttachments(c));const m=this.enqueueRequest({description:`Add ${this.name}`,method:l.POST,url:`${this.url}/bulk/`,payload:{submitted_at:a,attachments:r,files:Object.values(u)},blocks:c.map(o=>o.uuid),blockers:c.map(o=>o.file_sha1)});return m.then(({attachments:o,presigned_urls:p})=>{this.dispatch(this.updateAttachments(o)),this.processPresignedUrls(p)}).catch(()=>{this.dispatch(this.removeAttachments(c.map(o=>o.uuid)))}),[c,m.then(({attachments:o})=>o)]}async _delete(e){const{store:s}=this.client,n=this.selectAttachment(e)(s.getState());if(!n)throw new Error(`Attempting to delete attachment with uuid ${e} that does not exist in the store`);this.dispatch(this.removeAttachment(n.uuid));const a=this.enqueueRequest({description:`Delete ${this.name}`,method:l.DELETE,url:`${this.url}/${e}/`,blockers:[e],blocks:[]});return a.then(()=>{this.getNumberOfAttachmentsWithSha1(n.file_sha1)===0&&this.client.files.removeCache(n.file_sha1)}).catch(()=>{this.dispatch(this.setAttachment(n))}),a}}class pf extends Re{constructor(){super(...arguments);f(this,"name","Asset Attachment");f(this,"url","/asset-attachments");f(this,"initializeAttachments",Vt);f(this,"addAttachments",Ut);f(this,"updateAttachments",Xn);f(this,"removeAttachments",$t);f(this,"removeAttachment",Qn);f(this,"setAttachment",Jn);f(this,"selectAttachment",ea)}buildOfflineAttachment(s){return R({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset:s.modelUuid})}buildAttachmentPayload(s){return{...s,asset:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelUuid:n.assetUuid,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get asset attachments",method:l.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch(Vt(n))}}class Af extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:o,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in a||(a[y.sha1]=y);const b=R({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:n,fields_revision:o,submitted_at:s,field_identifier:p});c.push(b);const F={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:o};r.push(F)}this.dispatch(aa(c));const u=this.enqueueRequest({description:"Add asset procedure fields attachments",method:l.POST,url:"/asset-procedure-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.uuid)});return u.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(ca(d.attachments))}).catch(()=>{this.dispatch(ra(c.map(d=>d.uuid)))}),[c,u.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure fields attachments",method:l.GET,url:"/asset-procedure-fields-attachments/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(na(s))}}class yf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.id,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(ma(c));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:l.POST,url:"/asset-procedure-fields/",payload:c,blockers:[c.asset_procedure],blocks:[c.uuid]});return r.then(m=>{this.dispatch(pa(m))}).catch(m=>{throw this.dispatch(Aa(c.uuid)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:l.GET,url:"/asset-procedure-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(ha(s))}}function Xe(t,e){const s=[];let n=0;const a=t.length;for(;n<a;)s.push(t.slice(n,n+=e));return s}class ff extends E{async bulkAdd(e,s){var d;const n=new Date().toISOString(),a=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,c=Xe(e,s??e.length),r=[],u=[];for(const o of c){const p={},A=[];for(const y of o){const{fieldValuesUuid:b,fieldIdentifier:F,file:T}=y,O=await this.getFilePayload(T);O.sha1 in p||(p[O.sha1]=O);const M=R({file:URL.createObjectURL(T),file_type:T.type,file_name:T.name,file_sha1:O.sha1,created_by:a,field_values:b,submitted_at:n,field_identifier:F});r.push(M);const Ot={uuid:M.uuid,file_name:T.name,file_sha1:O.sha1,file_extension:O.extension,field_identifier:F,field_values:b};A.push(Ot)}u.push({submitted_at:n,attachments:A,files:Object.values(p)})}this.dispatch(xe(r));const m=u.map(o=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:l.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:o,blockers:o.attachments.map(p=>p.field_values),blocks:o.attachments.map(p=>p.uuid)}));return Promise.all(m).then(o=>{for(const A of o)this.processPresignedUrls(A.presigned_urls);const p=o.flatMap(A=>A.attachments);this.dispatch(Ta(p))}).catch(o=>{throw this.dispatch(et(r.map(p=>p.uuid))),o}),[r,m.map(o=>o.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Ia(e)(n);this.dispatch(et(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:l.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(xe(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values attachments",method:l.GET,url:"/asset-procedure-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(ga(s))}}const Sf=t=>Array.isArray(t)&&t[0]instanceof File,Qe=t=>{const e={},s={};for(const n in t){const a=t[n];a instanceof File?e[n]=[a]:Sf(a)?e[n]=a:a!==void 0&&(s[n]=a)}return{values:s,files:e}};class gf extends E{add(e){var r;const{store:s}=this.client,n=s.getState(),a=R({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add form submission",method:l.POST,url:"/form-submissions/",payload:v(a),blockers:["add-form-entry",e.form_revision,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[a.uuid]});return this.dispatch(di(a)),c.then(u=>(this.dispatch(lt(u)),u)).catch(()=>{this.dispatch(oi(a.uuid))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=hi(e.uuid)(n);if(!a)throw new Error(`Expected submission with uuid ${e.uuid} to exist`);const c={...a,...e};this.dispatch(ad(c));const r=this.enqueueRequest({description:"Delete user form submissions",method:l.PATCH,url:`/form-submissions/${c.uuid}/`,payload:e,blockers:[c.uuid],blocks:[c.uuid]});return r.then(u=>{this.dispatch(lt(u))}).catch(()=>{this.dispatch(lt(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=hi(e)(n);if(!a)throw new Error(`Expected submission with uuid ${e} to exist`);const c=td(e)(n);this.dispatch(oi(e)),this.dispatch(ut(c.map(r=>r.uuid)));try{return await this.enqueueRequest({description:"Delete user form submissions",method:l.DELETE,url:`/form-submissions/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(di(a)),this.dispatch(ot(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch form submissions",method:l.GET,url:"/form-submissions/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(nd(s))}}class Tf extends P{add(e){var r;const{store:s}=this.client,n=s.getState(),a=R({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset procedure field values",method:l.POST,url:"/asset-procedure-field-values/",payload:v(a),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[a.uuid]});return this.dispatch(Kt(a)),c.then(u=>(this.dispatch(De(u)),u)).catch(()=>{this.dispatch(Yt(a.uuid))}),[a,c]}bulkAdd(e,s){var d;const n=new Date().toISOString(),{values:a}=Qe(e.values),c=[],r=Xe(e.payloads,s??e.payloads.length),u=[];for(const o of r){const p=[];for(const A of o){const y=R({...A,values:Qe(A.values).values,created_by:(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,submitted_at:n});c.push(y),p.push({uuid:y.uuid,asset:A.asset,fields_revision:A.fields_revision,asset_procedure_instance:A.asset_procedure_instance,published_at:A.published_at,values:y.values})}u.push({submitted_at:n,values:a,field_values:p})}this.dispatch(va(c));const m=[];for(const o of u){const p=o.field_values.map(T=>T.asset),A=o.field_values.map(T=>T.fields_revision),y=o.field_values.map(T=>T.asset_procedure_instance),b=o.field_values.map(T=>T.uuid),F=this.enqueueRequest({description:"Bulk add asset procedure field values",method:l.POST,url:"/asset-procedure-field-values/bulk/",payload:o,blockers:[...p,...A,...y],blocks:b});m.push(F)}return Promise.all(m).then(o=>{this.dispatch(_a(o.flat()))}).catch(()=>{this.dispatch(wa(c.map(o=>o.uuid)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=Xt(e.uuid)(n);if(!a)throw new Error(`Expected AssetProcedureFieldValues with uuid ${e.uuid} to exist`);const c={...a,...e};this.dispatch(De(c));const r=this.enqueueRequest({description:"Update asset procedure field values",method:l.PATCH,url:`/asset-procedure-field-values/${e.uuid}/`,payload:e,blockers:[c.fields_revision,c.asset,c.asset_procedure_instance],blocks:[c.uuid]});return r.then(u=>{this.dispatch(De(u))}).catch(()=>{this.dispatch(De(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Xt(e)(n);if(!a)throw new Error(`Expected submission with uuid ${e} to exist`);const c=Fa(e)(n);this.dispatch(Yt(e)),this.dispatch(et(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset procedure field values",method:l.DELETE,url:`/asset-procedure-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Kt(a)),this.dispatch(xe(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values",method:l.GET,url:"/asset-procedure-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Oa(s))}}class bf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.id,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Zt(c));const r=this.enqueueRequest({description:"Create asset procedure instance",method:l.POST,url:"/asset-procedure-instances/",payload:v(c),blockers:[e.asset_procedure,e.asset_type],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Ve(m))}).catch(()=>{this.dispatch(xt(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,n=ss(e.uuid)(s.getState());if(!n)throw new Error(`Expected asset procedure instance with uuid ${e.uuid} to exist`);const a={...n,...e};this.dispatch(Ve(a));const c=this.enqueueRequest({description:"Update asset procedure instance",method:l.PATCH,url:`/asset-procedure-instances/${e.uuid}/`,payload:e,blockers:[n.uuid],blocks:[n.uuid]});return c.then(r=>{this.dispatch(Ve(r))}).catch(()=>{this.dispatch(Ve(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=ss(e)(n);if(!a)throw new Error(`Expected asset procedure instance with uuid ${e} to exist`);return this.dispatch(xt(e)),this.enqueueRequest({description:"Delete asset procedure instance",method:l.DELETE,url:`/asset-procedure-instances/${e}/`,blockers:[e],blocks:[]}).catch(c=>{throw this.dispatch(Zt(a)),c})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure instances",method:l.GET,url:"/asset-procedure-instances/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Ma(s))}}class If extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.id,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(ns(c));const r=this.enqueueRequest({description:"Create asset procedure",method:l.POST,url:"/asset-procedures/",payload:v(c),blockers:[],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Ue(m))}).catch(()=>{this.dispatch(as(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,n=rs(e.uuid)(s.getState());if(!n)throw new Error(`Expected asset procedure with uuid ${e.uuid} to exist`);const a={...n,...e};this.dispatch(Ue(a));const c=this.enqueueRequest({description:"Update asset procedure",method:l.PATCH,url:`/asset-procedures/${e.uuid}/`,payload:e,blockers:[n.uuid],blocks:[n.uuid]});return c.then(r=>{this.dispatch(Ue(r))}).catch(()=>{this.dispatch(Ue(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=rs(e)(n);if(!a)throw new Error(`Expected asset procedure with uuid ${e} to exist`);const c=za(e)(n);return this.dispatch(as(e)),this.dispatch(Ca(c.map(r=>r.uuid))),this.enqueueRequest({description:"Delete asset procedure",method:l.DELETE,url:`/asset-procedures/${e}/`,blockers:[e],blocks:[]}).catch(r=>{throw this.dispatch(ns(a)),this.dispatch(ka(c)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedures",method:l.GET,url:"/asset-procedures/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Ua(s))}}class Ff extends P{add(e){var u;const{store:s}=this.client;if(!e.canvas_marker&&!e.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");const n=(u=s.getState().userReducer.currentUser)==null?void 0:u.id,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(os(c));const r=this.enqueueRequest({description:"Create asset",method:l.POST,url:"/assets/",payload:v(c),blockers:[c.asset_type],blocks:[c.uuid]});return r.then(m=>{this.dispatch($e(m))}).catch(()=>{this.dispatch(ls(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,n=ps(e.uuid)(s.getState());if(!n)throw new Error(`No asset with uuid ${e.uuid} found in the store`);const a={...n,...e};if(!a.canvas_marker&&!a.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");this.dispatch($e(a));const c=this.enqueueRequest({description:"Edit asset",method:l.PATCH,url:`/assets/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.then(r=>{this.dispatch($e(r))}).catch(()=>{this.dispatch($e(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=ps(e)(n);if(!a)throw new Error(`No asset with uuid ${e} found in the store`);const c=ta(e)(n),r=dd(e)(n),u=Od(e)(n);if(this.dispatch(ls(e)),c.length>0){const m=c.map(({uuid:d})=>d);this.dispatch($t(m))}if(r.length>0){const m=r.map(({uuid:d})=>d);this.dispatch(mt(m))}if(u.length>0){const m=u.map(({uuid:d})=>d);this.dispatch(Ti(m))}return this.enqueueRequest({description:"Delete asset",method:l.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(os(a)),this.dispatch(Ut(c)),this.dispatch(ht(r)),this.dispatch(Si(u)),m})}bulkAdd(e,s,n,a){const c=new Date().toISOString(),r=fe.v4(),u=Xe(e,a).map(o=>{const p=o.map(A=>R(A));return{batchId:fe.v4(),payload:{transaction_id:r,submitted_at:c,asset_type:s,project:n,assets:p}}}),m=[];let d=null;for(const o of u){const{batchId:p,payload:A}=o,y=A.assets.map(O=>O.uuid),b=[s];d&&b.push(d);const F=y;F.push(p);const T=this.enqueueRequest({description:"Batch create assets",method:l.POST,url:"/assets/bulk/",payload:A,blockers:b,blocks:F});d=o.batchId,m.push(T)}return Promise.all(m).then(o=>{const p=o.flat();this.dispatch(us(p))}),m}async refreshStore(e){const s=await this.enqueueRequest({description:"Get assets",method:l.GET,url:"/assets/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(La(s))}}class Rf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.id,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(ys(c));const r=this.enqueueRequest({description:"Add asset stage completion",method:l.POST,url:"/asset-stage-completions/",payload:v(c),blockers:[e.asset,e.stage],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Ja(m))}).catch(()=>{this.dispatch(Ss(c.uuid))}),[c,r]}delete(e){const{store:s}=this.client,n=Za(e)(s.getState());if(!n)throw new Error(`Expected asset stage completion with uuid ${e} to exist`);this.dispatch(Ss(e));const a=this.enqueueRequest({description:"Delete asset stage completion",method:l.DELETE,url:`/asset-stage-completions/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(ys(n))}),a}bulkAdd(e){var d;const{store:s}=this.client,n=new Date().toISOString(),a=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,c=e.map(o=>R(o)),r=c.map(o=>({...o,created_by:a,submitted_at:n})),u=r.map(({uuid:o})=>o);this.dispatch(fs(r));const m=this.enqueueRequest({description:"Bulk create asset stage completions",method:l.POST,url:"/asset-stage-completions/bulk/",payload:{submitted_at:n,completions:c},blockers:[...e.map(o=>o.asset_procedure_instance),...e.map(o=>o.stage),...e.map(o=>o.asset)],blocks:u});return m.then(o=>{this.dispatch(Xa(o))}).catch(()=>{this.dispatch(gs(u))}),[r,m]}bulkDelete(e){const{store:s}=this.client,n=xa(e)(s.getState());this.dispatch(gs(e));const a=this.enqueueRequest({description:"Deleting asset stage completions",method:l.DELETE,url:"/asset-stage-completions/bulk/",payload:{completion_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(fs(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stage completions",method:l.GET,url:"/asset-stage-completions/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Ya(s))}}class Pf extends P{bulkAdd(e,s){var m;const n=new Date().toISOString(),a=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c=e.map(d=>R(d)),r=c.map(d=>({...d,asset_procedure:s,created_by:a,submitted_at:n}));this.dispatch(Is(r));const u=this.enqueueRequest({description:"Add asset stages",method:l.POST,url:"/asset-stages/bulk/",payload:{submitted_at:n,asset_procedure:s,stages:c},blockers:[s],blocks:c.map(({uuid:d})=>d)});return u.then(d=>{this.dispatch(tt(d))}).catch(()=>{this.dispatch(Rs(r.map(({uuid:d})=>d)))}),[r,u]}async bulkUpdate(e,s){const a=this.client.store.getState(),c=Ps(e.map(({uuid:r})=>r))(a);return this.dispatch(tt(e)),this.enqueueRequest({description:"Edit asset stages",method:l.PATCH,url:`/asset-procedures/${s}/bulk-update-stages/`,payload:{stages:e},blockers:[s],blocks:e.map(({uuid:r})=>r)}).catch(r=>{throw this.dispatch(tt(c)),r})}async bulkDelete(e){const{store:s}=this.client,n=Ps(e)(s.getState());this.dispatch(Rs(e));const a=this.enqueueRequest({description:"Delete asset stages",method:l.DELETE,url:"/asset-stages/bulk/",payload:{stage_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(Is(n))}),a}update(e){const{store:s}=this.client,n=nc(e.uuid)(s.getState());if(!n)throw new Error(`No asset stage with uuid ${e.uuid} found in the store`);const a={...n,...e};this.dispatch(Fs(a));const c=this.enqueueRequest({description:"Update asset stage",method:l.PATCH,url:`/asset-stages/${n.uuid}/`,payload:{name:e.name,description:e.description,priority:e.priority,color:e.color},blockers:[n.uuid],blocks:[n.uuid]});return c.then(r=>{this.dispatch(Fs(r))}).catch(()=>{this.dispatch(sc(n))}),[a,c]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stages",method:l.GET,url:"/asset-stages/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(tc(s))}}class Of extends Re{constructor(){super(...arguments);f(this,"name","Asset Type Attachment");f(this,"url","/asset-type-attachments");f(this,"addAttachments",vs);f(this,"updateAttachments",oc);f(this,"removeAttachments",_s);f(this,"removeAttachment",uc);f(this,"setAttachment",dc);f(this,"selectAttachment",mc)}buildOfflineAttachment(s){return R({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset_type:s.modelUuid})}buildAttachmentPayload(s){return{...s,asset_type:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelUuid:n.assetTypeUuid,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get asset type attachments",method:l.GET,url:`${this.url}/`,queryParams:{organization:s},blocks:[],blockers:[]});this.dispatch(rc(n))}}class vf extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:o,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in a||(a[y.sha1]=y);const b=R({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:n,fields_revision:o,submitted_at:s,field_identifier:p});c.push(b);const F={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:o};r.push(F)}this.dispatch(Sc(c));const u=this.enqueueRequest({description:"Add asset type fields attachments",method:l.POST,url:"/asset-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.uuid)});return u.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(gc(d.attachments))}).catch(()=>{this.dispatch(Tc(c.map(d=>d.uuid)))}),[c,u.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type fields attachments",method:l.GET,url:"/asset-type-fields-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(fc(s))}}class _f extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.id,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Oc(c));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:l.POST,url:"/asset-type-fields/",payload:c,blockers:[c.asset_type],blocks:[c.uuid]});return r.then(m=>{this.dispatch(vc(m))}).catch(m=>{throw this.dispatch(_c(c.uuid)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Type Fields",method:l.GET,url:"/asset-type-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Pc(s))}}class wf extends E{async bulkAdd(e,s){var d;const n=new Date().toISOString(),a=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,c=Xe(e,s??e.length),r=[],u=[];for(const o of c){const p={},A=[];for(const y of o){const{fieldValuesUuid:b,fieldIdentifier:F,file:T}=y,O=await this.getFilePayload(T);O.sha1 in p||(p[O.sha1]=O);const M=R({file:URL.createObjectURL(T),file_type:T.type,file_name:T.name,file_sha1:O.sha1,created_by:a,field_values:b,submitted_at:n,field_identifier:F});r.push(M);const Ot={uuid:M.uuid,file_name:T.name,file_sha1:O.sha1,file_extension:O.extension,field_identifier:F,field_values:b};A.push(Ot)}u.push({submitted_at:n,attachments:A,files:Object.values(p)})}this.dispatch(nt(r));const m=u.map(o=>this.enqueueRequest({description:"Add asset type field values attachments",method:l.POST,url:"/asset-type-field-values-attachments/bulk/",payload:o,blockers:o.attachments.map(p=>p.field_values),blocks:o.attachments.map(p=>p.uuid)}));return Promise.all(m).then(o=>{for(const A of o)this.processPresignedUrls(A.presigned_urls);const p=o.flatMap(A=>A.attachments);this.dispatch(Mc(p))}).catch(o=>{throw this.dispatch(at(r.map(p=>p.uuid))),o}),[r,m.map(o=>o.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Cc(e)(n);this.dispatch(at(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:l.DELETE,url:"/asset-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(nt(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values attachments",method:l.GET,url:"/asset-type-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(qc(s))}}class Ef extends P{add(e){var r;const{store:s}=this.client,n=s.getState(),a=R({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset type field values",method:l.POST,url:"/asset-type-field-values/",payload:v(a),blockers:[e.asset,e.fields_revision],blocks:[a.uuid]});return this.dispatch(ks(a)),c.then(u=>(this.dispatch(Be(u)),u)).catch(()=>{this.dispatch(Cs(a.uuid))}),[a,c]}bulkAdd(e,s){var d;const n=new Date().toISOString(),{values:a}=Qe(e.values),c=[],r=Xe(e.payloads,s??e.payloads.length),u=[];for(const o of r){const p=[];for(const A of o){const y=R({...A,values:Qe(A.values).values,created_by:(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,submitted_at:n});c.push(y),p.push({uuid:y.uuid,asset:A.asset,fields_revision:A.fields_revision,published_at:A.published_at,values:y.values})}u.push({submitted_at:n,values:a,field_values:p})}this.dispatch($c(c));const m=[];for(const o of u){const p=o.field_values.map(F=>F.asset),A=o.field_values.map(F=>F.fields_revision),y=o.field_values.map(F=>F.uuid),b=this.enqueueRequest({description:"Bulk add asset type field values",method:l.POST,url:"/asset-type-field-values/bulk/",payload:o,blockers:[...p,...A],blocks:y});m.push(b)}return Promise.all(m).then(o=>{this.dispatch(Bc(o.flat()))}).catch(()=>{this.dispatch(Gc(c.map(o=>o.uuid)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=Ds(e.uuid)(n);if(!a)throw new Error(`Expected AssetTypeFieldValues with uuid ${e.uuid} to exist`);const c={...a,...e};this.dispatch(Be(c));const r=this.enqueueRequest({description:"Delete asset type field values",method:l.PATCH,url:`/asset-type-field-values/${e.uuid}/`,payload:e,blockers:[c.uuid,c.fields_revision,c.asset],blocks:[c.uuid]});return r.then(u=>{this.dispatch(Be(u))}).catch(()=>{this.dispatch(Be(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Ds(e)(n);if(!a)throw new Error(`Expected submission with uuid ${e} to exist`);const c=zc(e)(n);this.dispatch(Cs(e)),this.dispatch(at(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset type field values",method:l.DELETE,url:`/asset-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ks(a)),this.dispatch(nt(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values",method:l.GET,url:"/asset-type-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Uc(s))}}class jf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.id,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Us(c));const r=this.enqueueRequest({description:"Create asset type",method:l.POST,url:"/asset-types/",payload:v(c),blockers:[],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Ge(m))}).catch(()=>{this.dispatch($s(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,n=Gs(e.uuid)(s.getState());if(!n)throw new Error(`Expected asset type with uuid ${e.uuid} to exist`);const a={...n,...e};this.dispatch(Ge(a));const c=this.enqueueRequest({description:"Update asset type",method:l.PATCH,url:`/asset-types/${e.uuid}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[n.uuid],blocks:[n.uuid]});return c.then(r=>{this.dispatch(Ge(r))}).catch(()=>{this.dispatch(Ge(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Gs(e)(n);if(!a)throw new Error(`Expected asset type with uuid ${e} to exist`);const c=ms(e)(n),r=pc(e)(n);return this.dispatch($s(e)),this.dispatch(Na(c.map(u=>u.uuid))),this.dispatch(_s(r.map(({uuid:u})=>u))),this.enqueueRequest({description:"Delete asset type",method:l.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(u=>{throw this.dispatch(Us(a)),this.dispatch(us(c)),this.dispatch(vs(r)),u})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset types",method:l.GET,url:"/asset-types/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Wc(s))}}class qf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.id,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Ns(c));const r=this.enqueueRequest({description:"Create Category",method:l.POST,url:"/categories/",payload:v(c),blockers:[e.project],blocks:[c.uuid]});return[c,r]}update(e){const s=this.client.store.getState(),n=Ws(e.uuid)(s);if(!n)throw new Error(`Expected an existing category with uuid ${e.uuid}`);const a={...n,...e};this.dispatch(xc(a));const c=this.enqueueRequest({description:"Edit Category",method:l.PATCH,url:`/categories/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return[a,c]}remove(e){const{store:s}=this.client,n=Ws(e)(s.getState());if(!n)throw new Error(`No category with uuid ${e} found in the store`);this.dispatch(er(e));const a=this.enqueueRequest({description:"Delete Category",method:l.DELETE,url:`/categories/${n.uuid}/`,blockers:[n.uuid],blocks:[]});return a.catch(()=>{this.dispatch(Ns(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get categories",method:l.GET,url:"/categories/",queryParams:{project:e},blocks:[],blockers:[]});this.dispatch(Zc(s))}}class Mf extends Re{constructor(){super(...arguments);f(this,"name","Document Attachment");f(this,"url","/document-attachments");f(this,"addAttachments",nr);f(this,"updateAttachments",cr);f(this,"removeAttachments",dr);f(this,"removeAttachment",rr);f(this,"setAttachment",ar);f(this,"selectAttachment",lr)}buildOfflineAttachment(s){return R({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,document:s.modelUuid})}buildAttachmentPayload(s){return{...s,document:s.modelUuid}}async bulkAdd(s){var p;const{store:n}=this.client,a=(p=n.getState().userReducer.currentUser)==null?void 0:p.id,c=new Date().toISOString(),r=[],u=[],m={},d={};for(const A of s){const{documentUuid:y,file:b}=A,F=await this.getFilePayload(b);F.sha1 in m||(m[F.sha1]=F,d[F.sha1]=[]);const T=this.buildOfflineAttachment({file:b,file_sha1:F.sha1,submitted_at:c,created_by:a,description:"",modelUuid:y});r.push(T),u.push({uuid:T.uuid,file_name:T.file_name,file_sha1:T.file_sha1,file_extension:F.extension,description:T.description,document:y}),d[F.sha1].push(T.uuid)}this.dispatch(this.addAttachments(r));const o=this.enqueueRequest({description:"Attach files to document",method:l.POST,url:"/document-attachments/bulk/",payload:{submitted_at:c,attachments:u,files:Object.values(m)},blocks:r.map(A=>A.uuid),blockers:r.map(A=>A.file_sha1)});return o.then(({attachments:A,presigned_urls:y})=>{this.dispatch(this.updateAttachments(A));const b=this.processPresignedUrls(y);for(const[F,T]of Object.entries(b))T.then(()=>{const O=d[F];for(const M of O)this.makeReadable(M)})}).catch(()=>{this.dispatch(this.removeAttachments(r.map(A=>A.uuid)))}),[r,o.then(({attachments:A})=>A)]}async delete(s){return this._delete(s)}makeReadable(s){this.enqueueRequest({description:"Add attachment to AI assistant",method:l.PATCH,url:`/document-attachments/${s}/`,payload:{readable_to_assistant:!0},blockers:["index-document-attachment",s],blocks:["index-document-attachment"]})}async refreshStore(s,n){const a=await this.enqueueRequest({description:"Get document attachments",method:l.GET,url:`/projects/${s}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(ir(a));const c=await this.enqueueRequest({description:"Get document attachments",method:l.GET,url:`/organizations/${n}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(this.addAttachments(c))}}class kf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.id,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Ar([c]));const r=this.enqueueRequest({description:"Create Document",method:l.POST,url:"/documents/",payload:v(c),queryParams:{parent_document:c.parent_document??void 0},blockers:c.parent_document?[c.parent_document]:[],blocks:[c.uuid]});return r.catch(()=>{this.dispatch(Js([c.uuid]))}),[c,r]}update(e){const{store:s}=this.client,n=s.getState().documentsReducer.documents[e.uuid];if(!n)throw new Error(`attempting to update a document with uuid ${e.uuid} that does not exist in store.documents`);const a={...n,...e};this.dispatch(ye([a]));const c=this.enqueueRequest({description:"Update Document",method:l.PATCH,url:`/documents/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.catch(()=>{ye([n])}),[a,c]}move(e,s,n){const{store:a}=this.client,c=we(a.getState()),r=[],u=c[e];if(!u)throw new Error(`attempting to move a document with uuid ${e} that does not exist in store.documents`);if(r.push(u),u.parent_document&&r.push(c[u.parent_document]),s){const d=c[s];if(!d)throw new Error(`attempting to move a document to target with uuid ${s} that does not exist in store.documents`);r.push(d),d.parent_document&&r.push(c[d.parent_document])}this.dispatch(yr({documentId:e,targetDocumentId:s,position:n}));const m=this.enqueueRequest({description:"Move Document",method:l.PATCH,url:`/documents/${e}/move/`,queryParams:{target:s??void 0,position:n},blockers:[e],blocks:[]});return m.then(d=>{this.dispatch(ye(d))}).catch(()=>{this.dispatch(ye(r))}),m}delete(e){const{store:s}=this.client,n=we(s.getState()),a=Sr(e)(s.getState());if(!a)throw new Error(`attempting to delete a document with uuid ${e} that does not exist in store.documents`);const c=a.parent_document?n[a.parent_document]:void 0;this.dispatch(Js([e]));const r=this.enqueueRequest({description:"Delete Document",method:l.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return r.then(u=>{this.dispatch(ye(u))}).catch(()=>{this.dispatch(ye([a])),c&&this.dispatch(ye([c]))}),r}async refreshStore(e,s){const n=this.enqueueRequest({description:"Get project documents",method:l.GET,url:`/projects/${e}/documents/`,blockers:[],blocks:[]}),a=this.enqueueRequest({description:"Get organization documents",method:l.GET,url:`/organizations/${s}/documents/`,blockers:[],blocks:[]});this.dispatch(pr([...await n,...await a]))}}class Cf extends P{async add(e,s){return this.enqueueRequest({description:"Add email domain to organization",method:l.POST,url:"/organization-email-domains/",payload:{email:s,organization:e},blockers:[e,"create-org"],blocks:[]})}async remove(e){return this.dispatch(Ir(e.uuid)),this.enqueueRequest({description:"Remove email domain from organization",method:l.DELETE,url:`/organization-email-domains/${e.uuid}/`,blockers:[e.domain],blocks:[]}).catch(s=>{throw this.dispatch(br(e)),s})}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch email domains for organization",method:l.GET,url:"/organization-email-domains/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(Tr(s))}}class zf extends P{async getVerificationCode(e){return this.enqueueRequest({description:"Get verification code",method:l.GET,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}validateVerificationCode(e,s=void 0){return this.enqueueRequest({description:"Validate verification code",method:l.POST,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,payload:s,blockers:[],blocks:[]})}}const Rt={},Fn=new Set;let Pt=0,Rn=0,Pn=0;const Df=20;class Vf extends P{constructor(){super(...arguments);f(this,"host");f(this,"_dbPromise",Ll.openDB("fileCache",1,{upgrade(s){s.createObjectStore("files")}}))}async renewUploadUrl(s){const n=await this.fetchCache(s);if(!n)throw new Error(`File with sha1 ${s} not found in cache`);const a=await kt(n,s),c=await this.enqueueRequest({description:"Get S3 URL",method:l.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await _e(n),file_type:n.type,extension:n.name.split(".").pop(),size:n.size.toString()},blockers:[],blocks:[`s3-${a}`]});return"url"in c&&this.dispatch(_r({sha1:s,...c})),c}async addCache(s,n){if(Fn.has(n))return;if(!s.type){const r=s.name.split("."),u=r[r.length-1];s=new File([s],s.name,{type:u})}if(!s.name||!s.size||!s.type)throw new Error("Cannot add files to cache that do not have a name, size and type.");const a=await this._dbPromise;!!await a.get("files",n)?(console.error("File already cached (this is unexpected at this point):",s.name,n),Pt++):(await a.put("files",s,n),Rn++),Fn.add(n),Pn++,Pn%Df===0&&console.debug(`File cache summary: ${Pt} hits and ${Rn} misses, ${Pt/(Pt+Rn)*100}% hit rate over ${Pn} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),Fn.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const n=this.client.store.getState();return wr(s)(n)??await this.renewUploadUrl(s)}async uploadFileToS3(s){const n=await this.fetchCache(s);if(!n)throw new Error(`File with sha1 ${s} not found in cache`);const a=await kt(n,s),c={file_name:n.name,file_sha1:s,file:a},r=await this.getOrRenewUploadUrl(s);if("warning"in r){if(r.warning==="already_uploaded")return[c,Promise.resolve(void 0).then()];throw new Error(r.warning)}const u=r.url,m=this.enqueueRequest({url:u,description:"Upload file",method:l.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:s,blockers:[`s3-${a}`],blocks:[s],s3url:r});return[c,m]}async fetchFileFromUrl(s,n,a){const c=s.split("?")[0]??s,r=await this.fetchCache(n);if(r){if(!r.name)throw new Error("Cached file unexpectedly has no name.");return r}if(s.startsWith("blob:")){const o=await Dn(s),p=new File([o],a??n,{type:o.type});return await this.addCache(p,n),p}let u=Rt[c],m=!0;u?m=!1:(u=new Promise(o=>{this.enqueueRequest({description:"Download file",method:l.GET,url:s,isExternalUrl:!0,isResponseBlob:!0,isAuthNeeded:!1,blockers:[n],blocks:[n]}).then(p=>{const A=new File([p],a??n,{type:p.type});o(A)})}),Rt[c]=u);let d;try{d=await u}catch(o){throw m&&o instanceof q&&delete Rt[c],o}if(m){const o=await _e(d);if(o!==n){const y=`The hash of the file returned from the server (${o}) does not match the
10
9
  expected hash (${n}). This can happen if you're using a local development server and the
11
10
  isExternalUrl flag in the request details is set to true, because instead of requesting the local
12
11
  REST API, you will be requesting localhost:80 (where this app runs), resulting in a transformed blob
13
- (with an offline_id attached) being returned. Alternatively, you may be running with
12
+ (with an uuid attached) being returned. Alternatively, you may be running with
14
13
  import.meta.env.PROD, which will result in some file requests being treated as
15
- external URLs and therefore not prepended with VITE_API_URL.`;throw new Error(A)}const f=d.type.split("/")[1];if(!f)throw new Error("File has no extension");const p=a??h+"."+f;if(d=jn(d,p),!d.name)throw new Error("Failed to set file's name");await this.addCache(d,h),bt[c]=new Promise(A=>{A(d)})}return d}}class fy extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{revisionId:h,fieldIdentifier:f,file:p}=d,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const T=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,form_revision:h,submitted_at:s,field_identifier:f});c.push(T);const _={offline_id:T.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,form_revision:h};r.push(_)}this.dispatch(vr(c));const o=this.enqueueRequest({description:"Attach files to form revision",method:l.POST,url:"/form-revision-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.form_revision),blocks:c.map(d=>d.offline_id)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(wr(d.attachments))}).catch(()=>{this.dispatch(Er(c.map(d=>d.offline_id)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization form revision attachments",method:l.GET,url:"/form-revision-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(Or(s))}}class py extends j{add(e){var o;const{store:s}=this.client,a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=F({...e,created_by:a,submitted_at:new Date().toISOString()});this.dispatch(Xs(c));const r=this.enqueueRequest({description:"Create form revision",method:l.POST,url:"/form-revisions/",payload:v(c),blockers:[e.form],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(kr(m))}).catch(()=>{this.dispatch(Qs(c.offline_id))}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization form revisions",method:l.GET,url:"/form-revisions/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(Cr(s))}}const Ay=async t=>{const e={},s=[];for(const n of t){if(n.type!=="section")throw new Error(`Expected ISerializedField type to be a section. Got ${n.type} instead.`);const{fields:a}=n,c=[];for(const r of a){if(r.image){if(r.image instanceof Promise)try{e[r.identifier]=await r.image}catch(o){console.error("Failed to get image from promise",o)}else e[r.identifier]=r.image;delete r.image}c.push(r)}s.push({...n,fields:c})}return{fields:s,images:e}};class yy extends j{add(e,s){var d;const{store:n}=this.client,a=new Date().toISOString(),c=(d=n.getState().userReducer.currentUser)==null?void 0:d.id,r=F({...e,submitted_at:a,created_by:c}),o=F({...s,form:r.offline_id,submitted_at:a,created_by:c});this.dispatch(xs(r)),this.dispatch(Xs(o));const m=this.enqueueRequest({description:"Create form",method:l.POST,url:"/forms/",payload:{...v(r),initial_revision:{offline_id:o.offline_id,submitted_at:o.submitted_at,title:o.title,description:o.description,fields:o.fields}},blockers:[],blocks:[r.offline_id,o.offline_id]});return m.catch(h=>{throw this.dispatch(ei(r.offline_id)),this.dispatch(Qs(o.offline_id)),h}),[r,o,m]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Hr(e)(n);if(!a)throw new Error("Expected form to exist");const c=td(e)(n);c.length>0&&this.dispatch(ot(c.map(({offline_id:o})=>o)));const r=Ur(e)(n);r.length>0&&this.dispatch(zr(r.map(({offline_id:o})=>o))),this.dispatch(ei(e));try{return await this.enqueueRequest({description:"Delete form",method:l.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(o){throw this.dispatch(xs(a)),r.length>0&&this.dispatch(Dr(r)),c.length>0&&this.dispatch(dt(c)),o}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization forms",method:l.GET,url:"/forms/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(Gr(s))}}class Sy extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{submissionId:h,fieldIdentifier:f,file:p}=d,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const T=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,form_submission:h,submitted_at:s,field_identifier:f});c.push(T);const _={offline_id:T.offline_id,file_name:p.name,file_sha1:A.sha1,file_extension:A.extension,field_identifier:f,form_submission:h};r.push(_)}this.dispatch(at(c));const o=this.enqueueRequest({description:"Attach files to form submission",method:l.POST,url:"/form-submission-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.form_submission),blocks:c.map(d=>d.offline_id)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(Yr(d.attachments))}).catch(d=>{throw this.dispatch(ct(c.map(h=>h.offline_id))),d}),[c,o.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Jr(e)(n);this.dispatch(ct(e));try{await this.enqueueRequest({description:"Delete form submission attachments",method:l.DELETE,url:"/form-submission-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(at(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get form submission attachments",method:l.GET,url:"/form-submission-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Kr(s))}}class gy extends j{async add(e){var f;const{store:s}=this.client,{file:n,...a}=e,c=new Date().toISOString(),r=(f=s.getState().userReducer.currentUser)==null?void 0:f.id,o=a.project,m=await this.getFilePayload(n),d=F({...a,file_name:n.name,file_sha1:m.sha1,file:URL.createObjectURL(n),submitted_at:c,created_by:r});this.dispatch(dd(d));const h=this.enqueueRequest({description:"Add geo image",method:l.POST,url:"/geo-images/",payload:{offline_id:d.offline_id,submitted_at:c,title:d.title,description:d.description,geo_marker:d.geo_marker,canvas_marker:d.canvas_marker,sha1:d.file_sha1,project:d.project,file_name:d.file_name,direction:d.direction,original_date:d.original_date,file:m},blocks:[o.toString()],blockers:[o.toString()]});return h.then(p=>{this.processPresignedUrls(p.presigned_urls),this.dispatch(Be(p.geo_image))}).catch(()=>{this.dispatch(li(d.offline_id))}),[d,h.then(p=>p.geo_image)]}async bulkAdd(e,s){var f;const{store:n}=this.client,a=new Date().toISOString(),c=(f=n.getState().userReducer.currentUser)==null?void 0:f.id,r=[],o=[],m=[],d={};for(const p of e){const{file:A,...T}=p,_=await this.getFilePayload(A);_.sha1 in d||(d[_.sha1]=_);const b=F({...T,file_name:A.name,file_sha1:_.sha1,file:URL.createObjectURL(A),submitted_at:a,created_by:c,project:s});r.push(b),o.push(b.offline_id),m.push({offline_id:b.offline_id,sha1:b.file_sha1,file_name:b.file_name,title:b.title,description:b.description,geo_marker:b.geo_marker,canvas_marker:b.canvas_marker,direction:b.direction,original_date:b.original_date})}this.dispatch(od(r));const h=this.enqueueRequest({description:"Bulk add geo images",method:l.POST,url:"/geo-images/bulk/",payload:{submitted_at:a,project:s,geo_images:m,files:Object.values(d)},blocks:[s.toString()],blockers:o});return h.then(p=>{this.processPresignedUrls(p.presigned_urls),this.dispatch(rd(p.geo_images))}).catch(()=>{this.dispatch(ud(o))}),[r,h.then(p=>p.geo_images)]}update(e){const{store:s}=this.client,n=s.getState(),a=ui(e.offline_id)(n);if(!a)throw new Error(`Map image with offline_id ${e.offline_id} does not exist in the store`);const c={...a,...e};this.dispatch(ld(c));const r=this.enqueueRequest({description:"Update geo image",method:l.PATCH,url:`/geo-images/${e.offline_id}/`,payload:e,blocks:[e.offline_id],blockers:[e.offline_id]});return r.then(o=>{this.dispatch(Be(o))}).catch(()=>{this.dispatch(Be(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=ui(e)(n);if(!a)throw new Error(`Map image with offline_id ${e} does not exist in the store`);this.dispatch(li(e));const c=this.enqueueRequest({description:"Delete geo image",method:l.DELETE,url:`/geo-images/${e}/`,blocks:[e],blockers:[e]});return c.catch(()=>{this.dispatch(Be(a))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get geo images",method:l.GET,url:`/projects/${e}/geo-images/`,blocks:[e.toString()],blockers:[]});this.dispatch(cd(s))}}class by extends R{add(e){var o;const{store:s}=this.client,n=new Date().toISOString(),a=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=F({...e,submitted_at:n,created_by:a});this.dispatch(mi(c));const r=this.enqueueRequest({description:"Add issue association",method:l.POST,url:"/issue-associations/",payload:v(c),blockers:[e.associated_issue,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(yd(m))}).catch(()=>{this.dispatch(pi(c.offline_id))}),[c,r]}async delete(e){const{store:s}=this.client,n=Sd(e)(s.getState());if(!n)throw new Error(`Issue association with id ${e} not found in store.`);this.dispatch(pi(e));const a=this.enqueueRequest({description:"Delete issue association",method:l.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(mi(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch issue associations",method:l.GET,url:"/issue-associations/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Ad(s))}}class Ty extends be{constructor(){super(...arguments);y(this,"name","Issue Attachment");y(this,"url","/issue-attachments");y(this,"initializeAttachments",Si);y(this,"addAttachments",gi);y(this,"updateAttachments",Rd);y(this,"removeAttachments",bi);y(this,"removeAttachment",Pd);y(this,"setAttachment",Id);y(this,"selectAttachment",Ed)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue:s.modelId})}buildAttachmentPayload(s){return{...s,issue:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.issueId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get issue attachments",method:l.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blocks:[],blockers:[]});this.dispatch(Si(n))}}class _y extends be{constructor(){super(...arguments);y(this,"name","Issue Comment Attachment");y(this,"url","/issue-comment-attachments");y(this,"initializeAttachments",_i);y(this,"addAttachments",Md);y(this,"updateAttachments",Cd);y(this,"removeAttachments",zd);y(this,"removeAttachment",Dd);y(this,"setAttachment",kd);y(this,"selectAttachment",$d)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue_comment:s.modelId})}buildAttachmentPayload(s){return{...s,issue_comment:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.issueCommentId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get issue comment attachments",method:l.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blocks:[],blockers:[]});this.dispatch(_i(n))}}class Fy extends R{add(e){var c;const{store:s}=this.client,n=F({...e,author:(c=s.getState().userReducer.currentUser)==null?void 0:c.id,submitted_at:new Date().toISOString()});this.dispatch(Ri(n));const a=this.enqueueRequest({description:"Add issue comment",method:l.POST,url:"/issue-comments/",payload:v(n),blockers:[e.issue],blocks:[n.offline_id]});return a.catch(()=>{this.dispatch(Pi(n.offline_id))}),[n,a]}update(e){const{store:s}=this.client,n=Hd(e.offline_id)(s.getState());if(!n)throw new Error(`Comment with offline_id ${e.offline_id} not found in store`);const a={...n,...e};this.dispatch(Ii(a));const c=this.enqueueRequest({description:"Edit issue comment",method:l.PATCH,url:`/issue-comments/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.catch(()=>{this.dispatch(Ii(n))}),[a,c]}remove(e){const s=this.client.store.getState().issueCommentReducer.instances[e];if(!s)throw new Error(`Comment with offline_id ${e} not found in store`);this.dispatch(Pi(e));const n=this.enqueueRequest({description:"Delete comment",method:l.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return n.catch(()=>{this.dispatch(Ri(s))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Get comments",method:l.GET,url:"/issue-comments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Ld(s))}}class Iy extends R{add(e){var m;const{store:s}=this.client,n=s.getState(),a=new Date().toISOString(),c=(m=n.userReducer.currentUser)==null?void 0:m.id,r=F({...e,submitted_at:a,created_by:c});this.dispatch(vi(r));const o=this.enqueueRequest({description:"Create issue",method:l.POST,url:"/issues/",payload:v(r),blockers:["add-issue",r.project.toString(),r.issue_type,...r.category?[r.category]:[]],blocks:[r.offline_id]});return o.then(d=>{this.dispatch(lt(d))}).catch(d=>{throw this.dispatch(wi(r.offline_id)),d}),[r,o]}update(e){var m;const s=this.client.store.getState(),n=Ei(e.offline_id)(s);if(!n)throw new Error(`Attempting to update an issue with offline_id ${e.offline_id} that doesn't exist in the store`);const a={...n,...e};this.dispatch(lt(a));const c={};for(const d of[w.TITLE,w.DESCRIPTION,w.STATUS,w.CATEGORY,w.PRIORITY,w.ASSIGNED_TO,w.DUE_DATE])if(d in e&&e[d]!==n[d])switch(d){case w.PRIORITY:case w.STATUS:{const h=e[d];c[d]=h!==void 0?Number(h):null;break}case w.DUE_DATE:case w.DESCRIPTION:case w.TITLE:c[d]=e[d]??null;break;case w.CATEGORY:{let h=null;const f=e[d];if(f&&(h=s.categoryReducer.instances[f]??null,!h))throw new Error(`Trying to update issue category to ${f} which does not exist in store`);c[d]=h?{name:h.name,color:h.color,offline_id:h.offline_id}:null;break}case w.ASSIGNED_TO:{let h=null;const f=e[d];if(f&&(h=s.userReducer.users[f]??null,!h))throw new Error(`Trying to update issue assigned_to to ${f} which does not exist in store`);c[d]=h?{full_name:h.username,id:h.id}:null;break}}const r=F({created_by:(m=s.userReducer.currentUser)==null?void 0:m.id,submitted_at:new Date().toISOString(),issue:n.offline_id,changes:c});this.dispatch(Ho(r));const o=this.enqueueRequest({description:"Edit issue",method:l.PATCH,url:`/issues/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return o.catch(()=>{this.dispatch(lt(n)),this.dispatch(Ko(r.offline_id))}),[a,o]}async remove(e){const{store:s}=this.client,n=s.getState(),a=Ei(e)(n);if(!a)throw new Error(`No issue with id ${e} found in the store`);const c=wd(e)(n),r=Xo(e)(n),o=sd(e)(n),m={};for(const h of gd(e)(n))m[h.offline_id]=h;for(const h of bd(e)(n))m[h.offline_id]=h;const d=Object.values(m);this.dispatch(wi(e)),c.length>0&&this.dispatch(bi(c.map(({offline_id:h})=>h))),r.length>0&&this.dispatch(Yo(r.map(({offline_id:h})=>h))),o.length>0&&this.dispatch(ot(o.map(({offline_id:h})=>h))),d.length>0&&this.dispatch(Ai(d.map(({offline_id:h})=>h)));try{return await this.enqueueRequest({description:"Delete issue",method:l.DELETE,url:`/issues/${e}/`,blockers:[e],blocks:[]})}catch(h){throw this.dispatch(vi(a)),this.dispatch(gi(c)),this.dispatch(Wo(r)),this.dispatch(dt(o)),this.dispatch(fi(d)),h}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issues",method:l.GET,url:"/issues/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Yd(s))}}class Ry extends be{constructor(){super(...arguments);y(this,"name","Issue Type Attachment");y(this,"url","/issue-type-attachments");y(this,"initializeAttachments",qi);y(this,"addAttachments",eo);y(this,"updateAttachments",so);y(this,"removeAttachments",no);y(this,"removeAttachment",io);y(this,"setAttachment",to);y(this,"selectAttachment",ro)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue_type:s.modelId})}buildAttachmentPayload(s){return{...s,issue_type:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.issueTypeId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get issue type attachments",method:l.GET,url:`${this.url}/`,queryParams:{organization:s.toString()},blocks:[],blockers:[]});this.dispatch(qi(n))}}class Py extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=d,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const T=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(T);const _={offline_id:T.offline_id,file_name:p.name,file_extension:A.extension,field_identifier:f,file_sha1:A.sha1,fields_revision:h};r.push(_)}this.dispatch(ho(c));const o=this.enqueueRequest({description:"Add issue type fields attachments",method:l.POST,url:"/issue-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.offline_id)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(mo(d.attachments))}).catch(()=>{this.dispatch(fo(c.map(d=>d.offline_id)))}),[c,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"get issue type fields attachments",method:l.GET,url:"/issue-type-fields-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(uo(s))}}class Oy extends R{add(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Io(c));const r=this.enqueueRequest({description:"Add Issue Type Fields",method:l.POST,url:"/issue-type-fields/",payload:v(c),blockers:[c.issue_type],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(Ro(m))}).catch(m=>{throw this.dispatch(Po(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Issue Type Fields",method:l.GET,url:"/issue-type-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Fo(s))}}class vy extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{fieldValuesId:h,fieldIdentifier:f,file:p}=d,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const T=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,field_values:h,submitted_at:s,field_identifier:f});c.push(T);const _={offline_id:T.offline_id,file_name:p.name,file_sha1:A.sha1,file_extension:A.extension,field_identifier:f,field_values:h};r.push(_)}this.dispatch(ht(c));const o=this.enqueueRequest({description:"Add issue type field values attachments",method:l.POST,url:"/issue-type-field-values-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.field_values),blocks:c.map(d=>d.offline_id)});return o.then(({presigned_urls:d,attachments:h})=>{this.processPresignedUrls(d),this.dispatch(jo(h))}).catch(d=>{throw this.dispatch(mt(c.map(h=>h.offline_id))),d}),[c,o.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Mo(e)(n);this.dispatch(mt(e));try{await this.enqueueRequest({description:"Delete issue type field values attachments",method:l.DELETE,url:"/issue-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(ht(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values attachments",method:l.GET,url:"/issue-type-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Eo(s))}}class wy extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add issue type field values",method:l.POST,url:"/issue-type-field-values/",payload:v(a),blockers:[e.issue,e.fields_revision],blocks:[a.offline_id]});return this.dispatch(Ci(a)),c.then(o=>(this.dispatch(Le(o)),o)).catch(()=>{this.dispatch(Di(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=Vi(e.offline_id)(n);if(!a)throw new Error(`Expected IssueTypeFieldValues with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(Le(c));const r=this.enqueueRequest({description:"Update issue type field values",method:l.PATCH,url:`/issue-type-field-values/${e.offline_id}/`,payload:e,blockers:[c.offline_id,c.fields_revision,c.issue],blocks:[c.offline_id]});return r.then(o=>{this.dispatch(Le(o))}).catch(()=>{this.dispatch(Le(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Vi(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=ko(e)(n);this.dispatch(Di(e)),this.dispatch(mt(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete issue type field values",method:l.DELETE,url:`/issue-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Ci(a)),this.dispatch(ht(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values",method:l.GET,url:"/issue-type-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(go(s))}}class Ey extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,submitted_at:new Date().toISOString(),created_by:(r=n.userReducer.currentUser)==null?void 0:r.id});this.dispatch(Vo(a));const c=this.enqueueRequest({method:l.POST,url:"/issue-types/",payload:v(a),blockers:[],blocks:[a.offline_id]});return c.then(o=>{this.dispatch(Ne(o))}).catch(()=>{this.dispatch(Li(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=Ni(e.offline_id)(n);if(!a)throw new Error(`IssueType with offline_id ${e.offline_id} does not exist in the store.`);const c={...a,...e};this.dispatch(Uo(c));const r=this.enqueueRequest({method:l.PATCH,url:`/issue-types/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return r.then(o=>{this.dispatch(Ne(o))}).catch(()=>{this.dispatch(Ne(a))}),[c,r]}delete(e){const{store:s}=this.client,n=s.getState(),a=Ni(e)(n);if(!a)throw new Error(`IssueType with offline_id ${e} does not exist in the store.`);const c=Hi(e)(n);this.dispatch(Li(e)),this.dispatch(Xd(c.map(o=>o.offline_id)));const r=this.enqueueRequest({method:l.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return r.catch(()=>{this.dispatch(Ne(a)),this.dispatch(Jd(c))}),r}async refreshStore(e){const s=await this.enqueueRequest({method:l.GET,url:"/issue-types/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(zo(s))}}class jy extends R{async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue updates",method:l.GET,url:"/issue-updates/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(No(s))}}class qy extends gu{constructor(e){super(e)}}const My=1800;function ky(t){if(!t.access)throw new Error("Missing access token");if(!t.refresh)throw new Error("Missing refresh token");return{accessToken:t.access,refreshToken:t.refresh}}class Cy extends qy{constructor(){super(...arguments);y(this,"_getRenewedTokens",async s=>{const n=this.enqueueRequest({description:"Get renewed tokens",method:l.POST,url:this.refreshTokensUrl,payload:{refresh:s},isAuthNeeded:!1,blockers:[],blocks:[],checkAuth:!1,immediate:!0});let a;try{a=await n}catch(c){console.error("Could not renew tokens; clearing auth",c),this.clearAuth();return}if(!a.access)throw new Error("Missing access token");return{accessToken:a.access,refreshToken:a.refresh??this.getRefreshToken()}})}clearAuth(){console.debug(this.constructor.name,"clearing auth;"),this.dispatch(Nc(!1)),this.clearTokens(),this.dispatch({type:Bu.RESET_STATE}),this.dispatch({type:Ou})}async renewTokens(){const s=this.getRefreshToken();if(!s)throw new Error("No refresh token found");console.debug(this.constructor.name,"renewing tokens");try{const n=await this._getRenewedTokens(s);if(!n)return;console.log("Got renewed tokens"),this.setTokens(n)}catch(n){throw console.error("Could not renew tokens; clearing auth",n),this.clearAuth(),n}}tokenIsExpiringSoon(){const s=this.getAccessToken();if(!s)return!1;const n=Date.now()/1e3;let a;try{a=Gu(s).exp??n}catch{a=n}return a-n<My}getAuthHeader(){return`Bearer ${this.getAccessToken()}`}async prepareAuth(){if(this.tokenIsExpiringSoon()){console.debug(this.constructor.name,"preparing auth");try{await this.renewTokens()}catch(s){return s instanceof q&&this.clearAuth(),s instanceof Error?Promise.reject(s):Promise.reject(new Error((s??Ee).toString()))}}}async handleUnauthorized(s,n){const a=this.client.store.getState();if(s.url.endsWith("/token/refresh/"))throw a.authReducer.isLoggedIn&&console.warn("No signed-in user to sign out."),this.clearAuth(),new q({message:"You have been signed out due to inactivity.",response:n,discard:!0});if(a.authReducer.isLoggedIn)await this.renewTokens();else throw console.debug("Forbidden; user is not logged in."),new q({message:"Incorrect username or password.",response:n,discard:!0})}async initAuth(s){const n=O.v4();return console.debug(this.constructor.name,"Initiating auth"),this.enqueueRequest({uuid:n,description:"Get token pair",method:l.POST,url:this.initTokensUrl,payload:s,isAuthNeeded:!1,checkAuth:!1,immediate:!0,blockers:[],blocks:[]}).then(a=>{this.setTokens(ky(a))})}}class Dy extends R{async getLicense(e){const s=await this.enqueueRequest({description:"Get license",method:l.GET,url:`/billing/${e.offline_id}/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(ue(s)),s}async pauseLicense(e){const s=await this.enqueueRequest({description:"Pause license",method:l.DELETE,url:`/billing/${e.offline_id}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(ue(s)),s}async resumeLicense(e){const s=await this.enqueueRequest({description:"Resume license",method:l.PATCH,url:`/billing/${e.offline_id}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(ue(s)),s}async cancelLicense(e){const s=await this.enqueueRequest({description:"Cancel license",method:l.DELETE,url:`/billing/${e.offline_id}/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(ue(s)),s}async attachLicenseToProject(e,s){const n=await this.enqueueRequest({description:"Attach license",method:l.PATCH,url:`/billing/${e.offline_id}/project/`,isAuthNeeded:!0,payload:{project:s.id},blockers:[e.organization_owner?e.organization_owner.toString():"",s.id?s.id.toString():""],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(ue(n)),n}async detachLicenseFromProject(e){const s=await this.enqueueRequest({description:"Detach license",method:l.DELETE,url:`/billing/${e.offline_id}/project/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(ue(s)),s}async getLatestTransaction(e){return await this.enqueueRequest({description:"Get latest transaction",method:l.GET,url:`/billing/${e.offline_id}/transaction/`,isAuthNeeded:!0,blockers:[e.offline_id],blocks:[e.offline_id]})}async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Get licenses",method:l.GET,url:`/organizations/${s}/licenses/`,isAuthNeeded:!0,blockers:[s.toString()],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of a)n[r.offline_id]=r;const c=await this.enqueueRequest({description:"Get licenses",method:l.GET,url:`/projects/${e}/licenses/`,isAuthNeeded:!0,blockers:[e.toString()],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of c)n[r.offline_id]=r;this.dispatch(xo(Object.values(n)))}}class zy extends R{async update(e){const s=this.enqueueRequest({description:"Edit organization access",method:l.PATCH,url:`/organizations/${e.organization}/access/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return s.then(()=>{this.dispatch(dl(e))}),s}async remove(e){return this.dispatch(ol(e.offline_id)),this.dispatch(nl(e.user)),this.enqueueRequest({description:"Remove organization access",method:l.DELETE,url:`/organizations/${e.organization}/access/${e.offline_id}/`,blockers:[e.offline_id],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization accesses",method:l.GET,url:`/organizations/${e}/access/`,blockers:[],blocks:[]});this.dispatch(rl(s))}}class Vy extends R{create(e){return this.enqueueRequest({description:"Create organization",method:l.POST,url:"/organizations/",payload:{name:e},blockers:[],blocks:[`add-org-${e}`,"create-org"]})}async update(e){return this.enqueueRequest({description:"Edit organization",method:l.PATCH,url:`/organizations/${e.id}/`,payload:e,blockers:[`add-org-${e.name}`,e.id.toString()],blocks:[e.id.toString()]})}async invite(e,s){return this.enqueueRequest({description:"Invite user to organization",method:l.POST,url:`/organizations/${e}/invite/${s}/`,blockers:[],blocks:[]})}async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Get organizations",method:l.GET,url:`/projects/${e}/organizations/`,blockers:[],blocks:[]});for(const r of a)n[r.id]=r;const c=await this.enqueueRequest({description:"Get organization",method:l.GET,url:`/organizations/${s}/`,blockers:[],blocks:[]});n[c.id]=c,this.dispatch(vl(Object.values(n)))}}class Uy extends R{async update(e){return this.dispatch(ml(e)),this.enqueueRequest({description:"Edit project access",method:l.PATCH,url:`/access/${e.offline_id}/`,payload:e,blockers:[e.offline_id,"change-access-level"],blocks:[e.offline_id]})}async remove(e){return this.dispatch(fl(e)),this.enqueueRequest({description:"Delete project access",method:l.DELETE,url:`/access/${e}/`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project accesses",method:l.GET,url:`/projects/${e}/access/`,blockers:[],blocks:[]});this.dispatch(Zi(s))}}class $y extends be{constructor(){super(...arguments);y(this,"name","Project Attachment");y(this,"url","/project-attachments");y(this,"addAttachments",Gl);y(this,"updateAttachments",Hl);y(this,"removeAttachments",an);y(this,"removeAttachment",Wl);y(this,"setAttachment",Ll);y(this,"selectAttachment",Jl)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,project:s.modelId})}buildAttachmentPayload(s){return{...s,project:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.projectId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get project attachments",method:l.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blockers:[],blocks:[]});this.dispatch(Bl(n))}}class By extends R{async saveExisting(e){if(!e.offline_id)throw new Error("You can only use this method to save existing project files. The one provided has no offline_id.");const s={...e};delete s.file;const n=this.enqueueRequest({method:l.PATCH,url:`/projects/files/${e.offline_id}/`,payload:s,blockers:[e.offline_id],blocks:[e.offline_id]});return n.then(a=>{this.dispatch(rn(a))}),n}saveActive(){const{store:e}=this.client,s=e.getState(),n=s.projectFileReducer.activeProjectFileId;if(!n)throw new Error("No active project file");const a=s.projectFileReducer.instances[n];if(!a)throw new Error("No active project file");if(!a.bounds&&!a.canvas_bounds)throw new Error("Project file must either have bounds or canvas_bounds set");let c;if(typeof a.file=="string"&&!a.file.startsWith("blob:")){const m={...a};delete m.file,c={method:l.PATCH,url:`/projects/files/${n}/`,payload:m,blockers:[n],blocks:[n]}}else c=new Promise((m,d)=>{this.client.files.uploadFileToS3(a.file_sha1).then(([h])=>{m({method:l.POST,url:`/projects/${a.project}/files/`,payload:{...a,...h},blockers:[n],blocks:[n]})}).catch(d)});const o=Promise.resolve(c).then(m=>this.enqueueRequest(m));return o.then(m=>{this.dispatch(rn(m))}),this.dispatch(au),this.dispatch(nu(null)),this.dispatch(iu(!1)),[a,o]}delete(e){return this.dispatch(tu(e)),this.enqueueRequest({method:l.DELETE,url:`/projects/files/${e}`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project files",method:l.GET,url:`/projects/${e}/files/`,blockers:[],blocks:[]});this.dispatch(xl(s))}}class Gy extends R{async add(e){if(!e.bounds&&!e.canvas_bounds)throw new Error("Project must either have bounds or canvas_bounds set");return await this.enqueueRequest({description:"Create project",method:l.POST,url:"/projects/",payload:{name:e.name,bounds:e.bounds,organization_owner:e.organization_owner},blockers:[],blocks:[]})}async update(e){if(!e.bounds&&!e.canvas_bounds)throw new Error("Project must either have bounds or canvas_bounds set");return this.dispatch(Tl(e)),await this.enqueueRequest({description:"Update project",method:l.PATCH,url:`/projects/${e.id}/`,payload:{name:e.name,bounds:e.bounds},blockers:[e.id.toString()],blocks:[e.id.toString()]})}async delete(e){const{store:s}=this.client,n=s.getState(),a=gt(n),c=a[e];if(!c)throw new Error("Expected project to exist");const r=ru(n).filter(h=>h.project===e);this.dispatch(su(r.map(({offline_id:h})=>h)));const o=Xl(c.id)(n);this.dispatch(an(o.map(({offline_id:h})=>h)));const m=Al(n);this.dispatch(pl(m.map(({offline_id:h})=>h))),this.dispatch({type:"rehydrated/setRehydrated",payload:!1}),this.dispatch(_l(c));const d=el(c.id)(n);d&&this.dispatch(ue({...d,project:null}));try{await this.enqueueRequest({description:"Delete project",method:l.DELETE,url:`/projects/${e}/`,blockers:[e.toString()],blocks:[]}),this.dispatch({type:"rehydrated/setRehydrated",payload:!0})}catch(h){throw this.dispatch(bl(Object.values(a))),this.dispatch(Zi(Object.values(m))),this.dispatch(eu(r)),this.dispatch(Nl(o)),this.dispatch({type:"rehydrated/setRehydrated",payload:!0}),d&&this.dispatch(ue({...d,project:c.id})),h}}invite(e,s){const n=O.v4();return this.enqueueRequest({description:"Invite user to project",method:l.POST,url:`/projects/${e}/invite/${s}/`,payload:{offline_id:n},blockers:[],blocks:[n]})}joinProject(e,s,n){return this.enqueueRequest({description:"Join project",method:l.GET,url:`/projects/${e}/join-project/${s}/${n}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}async acceptInvite(e){return this.enqueueRequest({description:"Accept project invite",method:l.PATCH,url:`/projects/${e}/accept-invite/`,blockers:[e.toString()],blocks:[e.toString()]}).then(()=>{this.dispatch(Fl(e))})}}class Ly extends R{add(e){const s=F({...e,submitted_at:new Date().toISOString()});this.dispatch(hu(s));const n=this.enqueueRequest({description:"Create team",method:l.POST,url:`/organizations/${e.organization}/teams/`,payload:s,blockers:[],blocks:[s.offline_id]});return n.then(a=>{this.dispatch(ve(a))}).catch(()=>{this.dispatch(un(s.offline_id))}),[s,n]}update(e){const{store:s}=this.client,n=we(e.offline_id)(s.getState());if(!n)throw new Error(`Expected team with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(ln(a));const c=this.enqueueRequest({description:"Update team",method:l.PATCH,url:`/organizations/teams/${e.offline_id}/`,payload:v(e),blockers:[e.offline_id],blocks:[e.offline_id]});return c.then(r=>{this.dispatch(ve(r))}).catch(()=>{this.dispatch(ve(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=we(e)(n);if(!a)throw new Error(`Expected team with id ${e} to exist`);this.dispatch(un(e));try{return await this.enqueueRequest({description:"Delete team",method:l.DELETE,url:`/organizations/teams/${e}/`,blockers:[e],blocks:[e]})}catch(c){throw this.dispatch(ve(a)),c}}async setMembers(e,s){const{store:n}=this.client,a=we(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);if(s.length!==new Set(s).size)throw new Error("Duplicate members found in the list");this.dispatch(ln({...a,members:s}));const c=this.enqueueRequest({description:"Set team members",method:l.PUT,url:`/organizations/teams/${e}/set-members/`,payload:{users:s},blockers:[e],blocks:[e]});return c.catch(()=>{this.dispatch(ve(a))}),c}async addMembers(e,s){const{store:n}=this.client,a=we(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);const c=[...a.members,...s];return this.setMembers(e,c)}async removeMembers(e,s){const{store:n}=this.client,a=we(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);const c=a.members.filter(r=>!s.includes(r));return this.setMembers(e,c)}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch teams",method:l.GET,url:`/organizations/${e}/teams/`,blockers:[],blocks:[]});this.dispatch(uu(s))}}class Ny extends R{async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Fetch organization users",method:l.GET,url:`/organizations/${s}/users/`,blockers:[],blocks:[]});for(const r of a)n[r.id]=r;const c=await this.enqueueRequest({description:"Fetch project users",method:l.GET,url:`/projects/${e}/users/`,blockers:[],blocks:[]});for(const r of c)n[r.id]=r;this.dispatch(il(Object.values(n)))}}var Mu=(t=>(t[t.USER_REGISTRATION=0]="USER_REGISTRATION",t[t.APPLICATION_INVITE=2]="APPLICATION_INVITE",t[t.PROJECT_INVITE=4]="PROJECT_INVITE",t[t.ORGANIZATION_INVITE=6]="ORGANIZATION_INVITE",t[t.ADD_EMAIL_DOMAIN=8]="ADD_EMAIL_DOMAIN",t[t.RESET_PASSWORD=10]="RESET_PASSWORD",t))(Mu||{});i.APIError=q,i.AgentService=GA,i.AssetAttachmentService=LA,i.AssetProcedureFieldValuesAttachmentService=WA,i.AssetProcedureFieldValuesService=JA,i.AssetProcedureFieldsAttachmentService=NA,i.AssetProcedureFieldsService=HA,i.AssetProcedureInstanceService=XA,i.AssetProcedureService=QA,i.AssetService=ZA,i.AssetStageCompletionService=xA,i.AssetStageService=ey,i.AssetTypeAttachmentService=ty,i.AssetTypeFieldValuesAttachmentService=ny,i.AssetTypeFieldValuesService=ay,i.AssetTypeFieldsAttachmentService=sy,i.AssetTypeFieldsService=iy,i.AssetTypeService=cy,i.AttachmentModel=In,i.BaseApiService=R,i.BaseSDK=$A,i.COMMON_AUTO_FIELDS=kn,i.CategoryService=ry,i.DEFAULT_ISSUE_PRIORITY=Nu,i.DEFAULT_ISSUE_STATUS=Lu,i.DeferredPromise=wn,i.DocumentAttachmentService=dy,i.DocumentService=oy,i.EMPTY_ARRAY=_n,i.EMPTY_OBJECT=Fn,i.EmailDomainsService=ly,i.EmailVerificationService=uy,i.FileService=my,i.FormRevisionAttachmentService=fy,i.FormRevisionService=py,i.FormService=yy,i.FormSubmissionAttachmentService=Sy,i.FormSubmissionService=YA,i.GeoImageService=gy,i.HttpMethod=l,i.IssueAssociationService=by,i.IssueAttachmentService=Ty,i.IssueCommentAttachmentService=_y,i.IssueCommentService=Fy,i.IssuePriority=Rt,i.IssueService=Iy,i.IssueStatus=Pt,i.IssueTypeAttachmentService=Ry,i.IssueTypeFieldValuesAttachmentService=vy,i.IssueTypeFieldValuesService=wy,i.IssueTypeFieldsAttachmentService=Py,i.IssueTypeFieldsService=Oy,i.IssueTypeService=Ey,i.IssueUpdateChange=w,i.IssueUpdateService=jy,i.JWTService=Cy,i.LicenseLevel=Pn,i.LicenseService=Dy,i.LicenseStatus=On,i.OUTBOX_RETRY_DELAY=vn,i.OrganizationAccessLevel=It,i.OrganizationAccessService=zy,i.OrganizationService=Vy,i.OutboxCoordinator=je,i.PaddleCheckoutEvent=Rn,i.ProjectAccessLevel=Ft,i.ProjectAccessService=Uy,i.ProjectAttachmentService=$y,i.ProjectFileService=By,i.ProjectService=Gy,i.TeamService=Ly,i.UNKNOWN_ERROR_MESSAGE=Ee,i.UserService=Ny,i.VERSION_REDUCER_KEY=fn,i.VerificationCodeType=Mu,i._setLatestRetryTime=Vl,i.acceptProjectInvite=Fl,i.addAsset=as,i.addAssetAttachment=ph,i.addAssetAttachments=Ct,i.addAssetProcedure=es,i.addAssetProcedureFieldValues=Lt,i.addAssetProcedureFieldValuesAttachment=Mh,i.addAssetProcedureFieldValuesAttachments=Je,i.addAssetProcedureFieldValuesMany=_a,i.addAssetProcedureFields=da,i.addAssetProcedureFieldsAttachment=Sh,i.addAssetProcedureFieldsAttachments=ea,i.addAssetProcedureFieldsMany=Rh,i.addAssetProcedureInstance=Yt,i.addAssetProcedureInstances=wa,i.addAssetProcedures=Yh,i.addAssetStage=dm,i.addAssetStageCompletion=hs,i.addAssetStageCompletions=ms,i.addAssetStages=Ss,i.addAssetType=Cs,i.addAssetTypeAttachment=hm,i.addAssetTypeAttachments=Fs,i.addAssetTypeFieldValues=Es,i.addAssetTypeFieldValuesAttachment=Em,i.addAssetTypeFieldValuesAttachments=et,i.addAssetTypeFieldValuesMany=Cc,i.addAssetTypeFields=Tc,i.addAssetTypeFieldsAttachment=pm,i.addAssetTypeFieldsAttachments=mc,i.addAssetTypeFieldsMany=_m,i.addAssetTypes=Gm,i.addAssets=cs,i.addCategory=$s,i.addConversation=Un,i.addDocumentAttachment=ef,i.addDocumentAttachments=xc,i.addDocuments=lr,i.addEmailDomain=Ar,i.addForm=xs,i.addFormRevision=Xs,i.addFormRevisionAttachment=uf,i.addFormRevisionAttachments=vr,i.addFormRevisions=Dr,i.addFormSubmission=ni,i.addFormSubmissionAttachment=If,i.addFormSubmissionAttachments=at,i.addFormSubmissions=dt,i.addForms=Tf,i.addGeoImage=dd,i.addGeoImages=od,i.addIssue=vi,i.addIssueAssociation=mi,i.addIssueAssociations=fi,i.addIssueAttachment=zf,i.addIssueAttachments=gi,i.addIssueComment=Ri,i.addIssueCommentAttachment=$f,i.addIssueCommentAttachments=Md,i.addIssueComments=Nf,i.addIssueType=Vo,i.addIssueTypeAttachment=Yf,i.addIssueTypeAttachments=eo,i.addIssueTypeFieldValues=Ci,i.addIssueTypeFieldValuesAttachment=bp,i.addIssueTypeFieldValuesAttachments=ht,i.addIssueTypeFieldValuesMany=ap,i.addIssueTypeFields=Io,i.addIssueTypeFieldsAttachment=Zf,i.addIssueTypeFieldsAttachments=ho,i.addIssueTypeFieldsMany=up,i.addIssueUpdate=Ho,i.addIssueUpdates=Wo,i.addIssues=Jd,i.addLicenses=Ep,i.addProjectAttachment=tA,i.addProjectAttachments=Gl,i.addProjectFile=aA,i.addProjectFiles=eu,i.addTeam=hu,i.addUsers=Dp,i.agentsReducer=Gn,i.agentsSlice=jt,i.areArraysEqual=Ju,i.assetAttachmentReducer=Qn,i.assetAttachmentSlice=Mt,i.assetProcedureFieldValuesAttachmentReducer=ga,i.assetProcedureFieldValuesAttachmentSlice=$t,i.assetProcedureFieldValuesReducer=Pa,i.assetProcedureFieldValuesSlice=Gt,i.assetProcedureFieldsAttachmentReducer=aa,i.assetProcedureFieldsAttachmentSlice=zt,i.assetProcedureFieldsReducer=ha,i.assetProcedureFieldsSlice=Vt,i.assetProcedureInstanceReducer=qa,i.assetProcedureInstanceSlice=Kt,i.assetProcedureReducer=Da,i.assetProcedureSlice=xt,i.assetReducer=Ba,i.assetSlice=ns,i.assetStageCompletionReducer=Wa,i.assetStageCompletionSlice=us,i.assetStageReducer=Za,i.assetStageSlice=ys,i.assetTypeAttachmentReducer=lc,i.assetTypeAttachmentSlice=_s,i.assetTypeFieldValuesAttachmentReducer=qc,i.assetTypeFieldValuesAttachmentSlice=Os,i.assetTypeFieldValuesReducer=Uc,i.assetTypeFieldValuesSlice=ws,i.assetTypeFieldsAttachmentReducer=Sc,i.assetTypeFieldsAttachmentSlice=Rs,i.assetTypeFieldsReducer=Rc,i.assetTypeFieldsSlice=Ps,i.assetTypeReducer=Gc,i.assetTypeSlice=ks,i.authReducer=Hc,i.authSlice=st,i.blobToBase64=nh,i.categoryReducer=Xc,i.categorySlice=Us,i.clearTokens=Ym,i.constructUploadedFilePayloads=ih,i.coordinatesAreEqual=Ku,i.createModelAdapter=I,i.createMultiPointGeometry=Wu,i.createOfflineAction=kl,i.createPayload=v,i.createPointGeometry=Hu,i.deleteAsset=rs,i.deleteAssetAttachment=Wn,i.deleteAssetAttachments=Dt,i.deleteAssetProcedure=ts,i.deleteAssetProcedureFieldValues=Nt,i.deleteAssetProcedureFieldValuesAttachment=zh,i.deleteAssetProcedureFieldValuesAttachments=Xe,i.deleteAssetProcedureFieldValuesMany=Ia,i.deleteAssetProcedureFields=la,i.deleteAssetProcedureFieldsAttachment=_h,i.deleteAssetProcedureFieldsAttachments=sa,i.deleteAssetProcedureFieldsMany=wh,i.deleteAssetProcedureInstance=Jt,i.deleteAssetProcedureInstances=Ea,i.deleteAssetProcedures=Xh,i.deleteAssetStage=om,i.deleteAssetStageCompletion=fs,i.deleteAssetStageCompletions=ps,i.deleteAssetStages=bs,i.deleteAssetType=Ds,i.deleteAssetTypeAttachment=ac,i.deleteAssetTypeAttachments=Is,i.deleteAssetTypeFieldValues=js,i.deleteAssetTypeFieldValuesAttachment=km,i.deleteAssetTypeFieldValuesAttachments=tt,i.deleteAssetTypeFieldValuesMany=zc,i.deleteAssetTypeFields=Fc,i.deleteAssetTypeFieldsAttachment=gm,i.deleteAssetTypeFieldsAttachments=pc,i.deleteAssetTypeFieldsMany=Pm,i.deleteAssetTypes=Nm,i.deleteAssets=Ua,i.deleteCategory=Jc,i.deleteDocumentAttachment=sr,i.deleteDocumentAttachments=ir,i.deleteEmailDomain=yr,i.deleteForm=ei,i.deleteFormRevision=Qs,i.deleteFormRevisionAttachment=pf,i.deleteFormRevisionAttachments=Er,i.deleteFormRevisions=zr,i.deleteFormSubmission=ai,i.deleteFormSubmissionAttachment=vf,i.deleteFormSubmissionAttachments=ct,i.deleteFormSubmissions=ot,i.deleteGeoImage=li,i.deleteGeoImages=ud,i.deleteIssue=wi,i.deleteIssueAssociation=pi,i.deleteIssueAssociations=Ai,i.deleteIssueAttachment=Pd,i.deleteIssueAttachments=bi,i.deleteIssueComment=Pi,i.deleteIssueCommentAttachment=Dd,i.deleteIssueCommentAttachments=zd,i.deleteIssueComments=Hf,i.deleteIssueTypeAttachment=io,i.deleteIssueTypeAttachments=no,i.deleteIssueTypeFieldValues=Di,i.deleteIssueTypeFieldValuesAttachment=Ip,i.deleteIssueTypeFieldValuesAttachments=mt,i.deleteIssueTypeFieldValuesMany=op,i.deleteIssueTypeFields=Po,i.deleteIssueTypeFieldsAttachment=sp,i.deleteIssueTypeFieldsAttachments=fo,i.deleteIssueTypeFieldsMany=pp,i.deleteIssueUpdate=Ko,i.deleteIssueUpdates=Yo,i.deleteIssues=Xd,i.deleteOrganizationAccess=ol,i.deleteProject=_l,i.deleteProjectAccess=fl,i.deleteProjectAccesses=pl,i.deleteProjectAttachment=Wl,i.deleteProjectAttachments=an,i.deleteProjectFile=tu,i.deleteProjectFiles=su,i.deleteTeam=un,i.dequeue=wu,i.discard=yn,i.documentAttachmentReducer=rr,i.documentAttachmentSlice=Ls,i.documentSlice=Ns,i.documentsReducer=fr,i.downloadFile=ah,i.downloadInMemoryFile=sh,i.emailDomainsReducer=br,i.emailDomainsSlice=Ws,i.emailRegex=hh,i.enqueue=vu,i.enqueueRequest=Dl,i.fallbackToEmptyArray=g,i.fallbackToEmptyObject=Fe,i.fileReducer=Rr,i.fileSlice=Ks,i.fileToBlob=qn,i.formReducer=Lr,i.formRevisionAttachmentReducer=qr,i.formRevisionAttachmentSlice=Ys,i.formRevisionReducer=$r,i.formRevisionsSlice=Js,i.formSlice=Zs,i.formSubmissionAttachmentReducer=Qr,i.formSubmissionAttachmentSlice=ti,i.formSubmissionReducer=nd,i.formSubmissionSlice=ii,i.geoImageReducer=fd,i.geoImageSlice=oi,i.getFileIdentifier=th,i.getFileS3Key=Et,i.getLocalDateString=En,i.getLocalRelativeDateString=xu,i.getOutboxCoordinator=ge,i.getRenamedFile=jn,i.hashFile=Ie,i.initSDK=BA,i.initializeAssetAttachments=kt,i.initializeAssetProcedureFieldValues=Ta,i.initializeAssetProcedureFieldValuesAttachments=fa,i.initializeAssetProcedureFields=ra,i.initializeAssetProcedureFieldsAttachments=xn,i.initializeAssetProcedureInstances=va,i.initializeAssetProcedures=ka,i.initializeAssetStageCompletions=La,i.initializeAssetStages=Xa,i.initializeAssetTypeAttachments=sc,i.initializeAssetTypeFieldValues=kc,i.initializeAssetTypeFieldValuesAttachments=Oc,i.initializeAssetTypeFields=bc,i.initializeAssetTypeFieldsAttachments=hc,i.initializeAssetTypes=Bc,i.initializeAssets=Va,i.initializeCategories=Kc,i.initializeConversations=Vn,i.initializeDocumentAttachments=Zc,i.initializeEmailDomains=pr,i.initializeFormRevisionAttachments=Or,i.initializeFormRevisions=Cr,i.initializeFormSubmissionAttachments=Kr,i.initializeFormSubmissions=xr,i.initializeForms=Gr,i.initializeGeoImages=cd,i.initializeIssueAssociations=Ad,i.initializeIssueAttachments=Si,i.initializeIssueCommentAttachments=_i,i.initializeIssueTypeAttachments=qi,i.initializeIssueTypeFieldValues=go,i.initializeIssueTypeFieldValuesAttachments=Eo,i.initializeIssueTypeFields=Fo,i.initializeIssueTypeFieldsAttachments=uo,i.initializeIssueTypes=zo,i.initializeIssueUpdates=No,i.initializeIssues=Yd,i.initializeLicences=xo,i.initializeOrganizationAccesses=rl,i.initializeProjectAccesses=Zi,i.initializeProjectAttachments=Bl,i.initializeProjectFiles=xl,i.initializeTeams=uu,i.isToday=Zu,i.issueAssociationReducer=_d,i.issueAssociationSlice=hi,i.issueAttachmentReducer=jd,i.issueAttachmentSlice=yi,i.issueCommentAttachmentReducer=Bd,i.issueCommentAttachmentSlice=Ti,i.issueCommentReducer=Wd,i.issueCommentSlice=Fi,i.issueReducer=Zd,i.issueSlice=Oi,i.issueTypeAttachmentReducer=oo,i.issueTypeAttachmentSlice=ji,i.issueTypeFieldValuesAttachmentReducer=Co,i.issueTypeFieldValuesAttachmentSlice=$i,i.issueTypeFieldValuesReducer=To,i.issueTypeFieldValuesSlice=ki,i.issueTypeFieldsAttachmentReducer=yo,i.issueTypeFieldsAttachmentSlice=Mi,i.issueTypeFieldsReducer=vo,i.issueTypeFieldsSlice=Ui,i.issueTypeReducer=Go,i.issueTypeSlice=Gi,i.issueUpdateReducer=Qo,i.issueUpdateSlice=Wi,i.licenseReducer=tl,i.licenseSlice=Ki,i.logOnlyOnce=ch,i.markAsDeleted=zl,i.markForDeletion=eA,i.memoize=vt,i.moveDocument=ur,i.offline=F,i.onlyUniqueHashes=uh,i.onlyUniqueOfflineIds=Dn,i.organizationAccessReducer=ul,i.organizationAccessSlice=Ji,i.organizationReducer=Ml,i.organizationSlice=tn,i.outboxReducer=Ul,i.outboxSlice=sn,i.overmapEnhancer=wA,i.overmapReducers=Ru,i.overmapRootReducer=IA,i.performRequest=An,i.projectAccessReducer=Sl,i.projectAccessSlice=Qi,i.projectAttachmentReducer=Ql,i.projectAttachmentSlice=nn,i.projectFileReducer=du,i.projectFileSlice=cn,i.projectReducer=Il,i.projectSlice=en,i.rehydratedReducer=ou,i.rehydratedSlice=dn,i.removeDocuments=Hs,i.removeIssueType=Li,i.removeUser=nl,i.resetProjectFileObjectUrls=rA,i.resetStore=Ou,i.restructureCreateSelectorWithArgs=S,i.saveActiveProjectFileBounds=au,i.selectAccessToken=Jm,i.selectActiveOrganizationAccess=$p,i.selectActiveProjectFileId=oA,i.selectActiveStatusLicenses=qp,i.selectAllDocumentAttachments=ar,i.selectAllProjectAttachments=Yl,i.selectAncestorIdsOfDocument=cf,i.selectAssetAttachmentById=Jn,i.selectAssetAttachmentMapping=Kn,i.selectAssetAttachments=Yn,i.selectAssetById=ls,i.selectAssetProcedureById=is,i.selectAssetProcedureFieldValues=Ht,i.selectAssetProcedureFieldValuesAttachmentById=Vh,i.selectAssetProcedureFieldValuesAttachments=Aa,i.selectAssetProcedureFieldValuesAttachmentsByIds=ya,i.selectAssetProcedureFieldValuesAttachmentsMapping=Bt,i.selectAssetProcedureFieldValuesById=Wt,i.selectAssetProcedureFieldValuesMapping=Ra,i.selectAssetProcedureFieldValuesOfAsset=Bh,i.selectAssetProcedureFields=Ut,i.selectAssetProcedureFieldsAttachmentById=Ih,i.selectAssetProcedureFieldsAttachments=na,i.selectAssetProcedureFieldsAttachmentsMapping=ia,i.selectAssetProcedureFieldsById=qh,i.selectAssetProcedureFieldsMapping=ua,i.selectAssetProcedureFieldsOfAssetProcedure=Eh,i.selectAssetProcedureInstanceById=Zt,i.selectAssetProcedureInstances=Qt,i.selectAssetProcedureInstancesByIds=Kh,i.selectAssetProcedureInstancesMapping=Xt,i.selectAssetProcedureInstancesOfAssetProcedure=ja,i.selectAssetProcedureInstancesOfAssetType=Wh,i.selectAssetProcedures=Ca,i.selectAssetProceduresByIds=em,i.selectAssetProceduresMapping=ss,i.selectAssetProceduresOfOrganization=xh,i.selectAssetStageById=xa,i.selectAssetStageCompletionById=Ka,i.selectAssetStageCompletionMapping=As,i.selectAssetStageCompletions=cm,i.selectAssetStageCompletionsByIds=Ya,i.selectAssetStages=ec,i.selectAssetStagesByIds=Ts,i.selectAssetStagesMappingOfAssetProcedure=lm,i.selectAssetStagesOfAssetProcedure=um,i.selectAssetTypeAttachmentById=dc,i.selectAssetTypeAttachmentMapping=cc,i.selectAssetTypeAttachments=rc,i.selectAssetTypeById=Vs,i.selectAssetTypeFieldValues=qs,i.selectAssetTypeFieldValuesAttachmentById=Cm,i.selectAssetTypeFieldValuesAttachments=wc,i.selectAssetTypeFieldValuesAttachmentsByIds=Ec,i.selectAssetTypeFieldValuesAttachmentsMapping=vs,i.selectAssetTypeFieldValuesById=Ms,i.selectAssetTypeFieldValuesMapping=Vc,i.selectAssetTypeFieldValuesOfAsset=Vm,i.selectAssetTypeFields=xe,i.selectAssetTypeFieldsAttachmentById=Tm,i.selectAssetTypeFieldsAttachments=yc,i.selectAssetTypeFieldsAttachmentsMapping=Ac,i.selectAssetTypeFieldsById=wm,i.selectAssetTypeFieldsMapping=Ic,i.selectAssetTypeFieldsOfAssetType=Om,i.selectAssetTypeValuesOfAssetType=Um,i.selectAssetTypes=Hm,i.selectAssetTypesByIds=Wm,i.selectAssetTypesMapping=zs,i.selectAssets=$a,i.selectAssetsByIds=nm,i.selectAssetsMapping=ds,i.selectAssetsOfAssetType=os,i.selectAttachmentsOfAsset=Xn,i.selectAttachmentsOfAssetProcedureFieldValues=Sa,i.selectAttachmentsOfAssetProcedureFields=Fh,i.selectAttachmentsOfAssetType=oc,i.selectAttachmentsOfAssetTypeFieldValues=jc,i.selectAttachmentsOfAssetTypeFields=bm,i.selectAttachmentsOfDocument=nf,i.selectAttachmentsOfFormRevision=Af,i.selectAttachmentsOfFormSubmission=Xr,i.selectAttachmentsOfIssue=wd,i.selectAttachmentsOfIssueComment=Lf,i.selectAttachmentsOfIssueType=Qf,i.selectAttachmentsOfIssueTypeFieldValues=ko,i.selectAttachmentsOfIssueTypeFields=ip,i.selectAttachmentsOfProject=Xl,i.selectCategories=Qm,i.selectCategoriesByIds=Zm,i.selectCategoryById=Gs,i.selectCategoryMapping=Bs,i.selectCommentsOfIssue=Wf,i.selectConversation=fh,i.selectConversationMapping=qt,i.selectConversations=mh,i.selectCurrentUser=At,i.selectDeletedRequests=Zp,i.selectDocumentAttachmentById=cr,i.selectDocumentAttachmentMapping=nr,i.selectDocumentById=mr,i.selectDocuments=hr,i.selectDocumentsByIds=af,i.selectDocumentsMapping=Re,i.selectEmailDomains=gr,i.selectEmailDomainsAsMapping=Sr,i.selectEmailDomainsOfOrganization=of,i.selectFieldValuesOfAssetProcedureInstance=Gh,i.selectFormById=Hr,i.selectFormMapping=Nr,i.selectFormRevisionAttachmentsMapping=jr,i.selectFormRevisionById=Sf,i.selectFormRevisionMapping=nt,i.selectFormRevisions=Vr,i.selectFormRevisionsOfForm=Ur,i.selectFormSubmissionAttachemntsByIds=Jr,i.selectFormSubmissionAttachmentsMapping=si,i.selectFormSubmissionById=di,i.selectFormSubmissions=ri,i.selectFormSubmissionsMapping=ci,i.selectFormSubmissionsOfAsset=id,i.selectFormSubmissionsOfForm=td,i.selectFormSubmissionsOfIssue=sd,i.selectForms=Ff,i.selectGeoImageById=ui,i.selectGeoImageMapping=hd,i.selectGeoImages=md,i.selectGeoImagesOfProject=qf,i.selectIsImportingProjectFile=lA,i.selectIsLoggedIn=Xm,i.selectIssueAssociationById=Sd,i.selectIssueAssociationMapping=Ge,i.selectIssueAssociations=Df,i.selectIssueAssociationsOfAsset=Td,i.selectIssueAssociationsOfIssue=bd,i.selectIssueAssociationsToIssue=gd,i.selectIssueAttachmentById=Ed,i.selectIssueAttachmentMapping=Od,i.selectIssueAttachments=vd,i.selectIssueById=Ei,i.selectIssueCommentAttachmentById=$d,i.selectIssueCommentAttachmentMapping=Vd,i.selectIssueCommentAttachments=Ud,i.selectIssueCommentById=Hd,i.selectIssueCommentMapping=Nd,i.selectIssueCountOfCategory=xm,i.selectIssueMapping=Qd,i.selectIssueTypeAttachmentById=ro,i.selectIssueTypeAttachmentMapping=ao,i.selectIssueTypeAttachments=co,i.selectIssueTypeById=Ni,i.selectIssueTypeFieldValues=zi,i.selectIssueTypeFieldValuesAttachmentById=Rp,i.selectIssueTypeFieldValuesAttachments=qo,i.selectIssueTypeFieldValuesAttachmentsByIds=Mo,i.selectIssueTypeFieldValuesAttachmentsMapping=Bi,i.selectIssueTypeFieldValuesById=Vi,i.selectIssueTypeFieldValuesMapping=bo,i.selectIssueTypeFieldValuesOfIssue=lp,i.selectIssueTypeFields=ut,i.selectIssueTypeFieldsAttachmentById=np,i.selectIssueTypeFieldsAttachments=Ao,i.selectIssueTypeFieldsAttachmentsMapping=po,i.selectIssueTypeFieldsById=gp,i.selectIssueTypeFieldsMapping=Oo,i.selectIssueTypeFieldsOfIssueType=Ap,i.selectIssueTypeMapping=$o,i.selectIssueTypeValuesOfIssueType=Sp,i.selectIssueTypes=Bo,i.selectIssueTypesByIds=Pp,i.selectIssueTypesOfOrganization=Op,i.selectIssueUpdateMapping=Jo,i.selectIssueUpdatesOfIssue=Xo,i.selectIssuesByIds=Kf,i.selectIssuesOfIssueType=Hi,i.selectIssuesOfIssueTypeCount=vp,i.selectLatestAssetProcedureFieldsOfAssetProcedure=jh,i.selectLatestAssetTypeFieldsOfAssetType=vm,i.selectLatestFormRevisionOfForm=gf,i.selectLatestIssueTypeFieldsOfIssueType=yp,i.selectLatestRetryTime=xp,i.selectLicense=jp,i.selectLicenseForProject=el,i.selectLicenses=pt,i.selectLicensesForProjectsMapping=Mp,i.selectLicensesOfOrganization=Xp,i.selectNumberOfAssetsOfAssetType=am,i.selectOrganizationAccessById=Up,i.selectOrganizationAccessForUser=Bp,i.selectOrganizationAccessUserMapping=ll,i.selectOrganizationAccesses=Xi,i.selectOrganizationById=Kp,i.selectOrganizationUsersAsMapping=ql,i.selectOrganizationUsersIds=jl,i.selectOrganizations=El,i.selectOrganizationsMapping=wl,i.selectOrganizationsWithAccess=Yp,i.selectProjectAccessById=Gp,i.selectProjectAccessForUser=Lp,i.selectProjectAccessMapping=xi,i.selectProjectAccessUserMapping=yl,i.selectProjectAccesses=Al,i.selectProjectAttachmentById=Jl,i.selectProjectAttachmentMapping=Kl,i.selectProjectById=Hp,i.selectProjectFileById=dA,i.selectProjectFileMapping=cu,i.selectProjectFiles=ru,i.selectProjectMapping=gt,i.selectProjectUsersAsMapping=Pl,i.selectProjectUsersIds=Rl,i.selectProjects=Np,i.selectProjectsOfOrganization=Jp,i.selectRehydrated=mA,i.selectRootDocuments=rf,i.selectSortedOrganizationUsers=Qp,i.selectSortedProjectUsers=Wp,i.selectStageMapping=Ze,i.selectTeamById=we,i.selectTeams=mn,i.selectTeamsByIds=fA,i.selectTeamsMapping=hn,i.selectTeamsOfOrganization=pA,i.selectTeamsOfUser=AA,i.selectUploadUrl=Ir,i.selectUserById=zp,i.selectUsersByIds=Vp,i.selectUsersMapping=yt,i.separateFilesFromValues=qe,i.separateImageFromFields=Ay,i.setActiveProjectFileId=nu,i.setAsset=sm,i.setAssetAttachment=Nn,i.setAssetAttachments=Ah,i.setAssetProcedure=Qh,i.setAssetProcedureFieldValues=Uh,i.setAssetProcedureFieldValuesAttachment=kh,i.setAssetProcedureFieldValuesAttachments=Ch,i.setAssetProcedureFieldValuesMany=$h,i.setAssetProcedureFields=Ph,i.setAssetProcedureFieldsAttachment=gh,i.setAssetProcedureFieldsAttachments=bh,i.setAssetProcedureFieldsMany=Oh,i.setAssetProcedureInstance=Nh,i.setAssetProcedureInstances=Hh,i.setAssetProcedures=Zh,i.setAssetStage=Qa,i.setAssetStages=rm,i.setAssetType=$m,i.setAssetTypeAttachment=ic,i.setAssetTypeAttachments=mm,i.setAssetTypeFieldValues=Dm,i.setAssetTypeFieldValuesAttachment=jm,i.setAssetTypeFieldValuesAttachments=qm,i.setAssetTypeFieldValuesMany=zm,i.setAssetTypeFields=Fm,i.setAssetTypeFieldsAttachment=Am,i.setAssetTypeFieldsAttachments=ym,i.setAssetTypeFieldsMany=Im,i.setAssetTypes=Bm,i.setAssets=im,i.setConversation=$n,i.setCurrentUser=kp,i.setDocumentAttachment=er,i.setDocumentAttachments=tf,i.setDocuments=or,i.setForm=bf,i.setFormRevision=kr,i.setFormRevisionAttachment=hf,i.setFormRevisionAttachments=mf,i.setFormSubmission=rt,i.setFormSubmissionAttachment=Rf,i.setFormSubmissionAttachments=Pf,i.setFormSubmissions=wf,i.setGeoImage=Be,i.setGeoImages=rd,i.setIsImportingProjectFile=iu,i.setIssueAssociation=kf,i.setIssueAssociations=Mf,i.setIssueAttachment=Id,i.setIssueAttachments=Vf,i.setIssueComment=Ii,i.setIssueCommentAttachment=kd,i.setIssueCommentAttachments=Bf,i.setIssueComments=Ld,i.setIssueType=Ne,i.setIssueTypeAttachment=to,i.setIssueTypeAttachments=Jf,i.setIssueTypeFieldValues=cp,i.setIssueTypeFieldValuesAttachment=Tp,i.setIssueTypeFieldValuesAttachments=_p,i.setIssueTypeFieldValuesMany=rp,i.setIssueTypeFields=hp,i.setIssueTypeFieldsAttachment=xf,i.setIssueTypeFieldsAttachments=ep,i.setIssueTypeFieldsMany=mp,i.setIssueUpdate=wp,i.setLoggedIn=Nc,i.setOrganizations=vl,i.setProfilePicture=Cp,i.setProjectAttachment=Ll,i.setProjectAttachments=Nl,i.setProjectFile=iA,i.setProjectFiles=nA,i.setProjects=bl,i.setRehydrated=hA,i.setTeam=ve,i.setTokens=Km,i.setUploadUrl=Fr,i.setUsers=il,i.shallowEqual=Yu,i.slugify=oh,i.spacesToDashesLower=dh,i.teamReducer=mu,i.teamSlice=on,i.toFileNameSafeString=rh,i.toOfflineIdRecord=Cn,i.truncate=lh,i.updateAsset=ze,i.updateAssetAttachment=yh,i.updateAssetAttachments=Hn,i.updateAssetProcedure=De,i.updateAssetProcedureFieldValues=ke,i.updateAssetProcedureFieldValuesAttachment=Dh,i.updateAssetProcedureFieldValuesAttachments=pa,i.updateAssetProcedureFieldValuesMany=Fa,i.updateAssetProcedureFields=oa,i.updateAssetProcedureFieldsAttachment=Th,i.updateAssetProcedureFieldsAttachments=ta,i.updateAssetProcedureFieldsMany=vh,i.updateAssetProcedureInstance=Ce,i.updateAssetProcedureInstances=Lh,i.updateAssetProcedures=Jh,i.updateAssetStage=gs,i.updateAssetStageCompletion=Na,i.updateAssetStageCompletions=Ha,i.updateAssetStages=Qe,i.updateAssetType=Ue,i.updateAssetTypeAttachment=fm,i.updateAssetTypeAttachments=nc,i.updateAssetTypeFieldValues=Ve,i.updateAssetTypeFieldValuesAttachment=Mm,i.updateAssetTypeFieldValuesAttachments=vc,i.updateAssetTypeFieldValuesMany=Dc,i.updateAssetTypeFields=_c,i.updateAssetTypeFieldsAttachment=Sm,i.updateAssetTypeFieldsAttachments=fc,i.updateAssetTypeFieldsMany=Rm,i.updateAssetTypes=Lm,i.updateAssets=tm,i.updateCategory=Yc,i.updateConversation=Bn,i.updateDocumentAttachment=sf,i.updateDocumentAttachments=tr,i.updateDocuments=me,i.updateForm=_f,i.updateFormRevisionAttachment=ff,i.updateFormRevisionAttachments=wr,i.updateFormSubmission=ed,i.updateFormSubmissionAttachment=Of,i.updateFormSubmissionAttachments=Yr,i.updateFormSubmissions=Ef,i.updateGeoImage=ld,i.updateGeoImages=jf,i.updateIssue=lt,i.updateIssueAssociation=yd,i.updateIssueAssociations=Cf,i.updateIssueAttachment=Uf,i.updateIssueAttachments=Rd,i.updateIssueCommentAttachment=Gf,i.updateIssueCommentAttachments=Cd,i.updateIssueType=Uo,i.updateIssueTypeAttachment=Xf,i.updateIssueTypeAttachments=so,i.updateIssueTypeFieldValues=Le,i.updateIssueTypeFieldValuesAttachment=Fp,i.updateIssueTypeFieldValuesAttachments=jo,i.updateIssueTypeFieldValuesMany=dp,i.updateIssueTypeFields=Ro,i.updateIssueTypeFieldsAttachment=tp,i.updateIssueTypeFieldsAttachments=mo,i.updateIssueTypeFieldsMany=fp,i.updateLicense=ue,i.updateOrganizationAccess=dl,i.updateProject=Tl,i.updateProjectAccess=ml,i.updateProjectAttachment=sA,i.updateProjectAttachments=Hl,i.updateProjectFile=rn,i.updateProjectFiles=cA,i.updateTeam=ln,i.userReducer=al,i.userSlice=Yi,i.versioningReducer=pu,i.versioningSlice=fu,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
14
+ external URLs and therefore not prepended with VITE_API_URL.`;throw new Error(y)}const p=d.type.split("/")[1];if(!p)throw new Error("File has no extension");const A=a??o+"."+p;if(d=zn(d,A),!d.name)throw new Error("Failed to set file's name");await this.addCache(d,o),Rt[c]=new Promise(y=>{y(d)})}return d}}class Uf extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{revisionUuid:o,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in a||(a[y.sha1]=y);const b=R({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:n,form_revision:o,submitted_at:s,field_identifier:p});c.push(b);const F={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,form_revision:o};r.push(F)}this.dispatch(Mr(c));const u=this.enqueueRequest({description:"Attach files to form revision",method:l.POST,url:"/form-revision-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.form_revision),blocks:c.map(d=>d.uuid)});return u.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(kr(d.attachments))}).catch(()=>{this.dispatch(Cr(c.map(d=>d.uuid)))}),[c,u.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization form revision attachments",method:l.GET,url:"/form-revision-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(qr(s))}}class $f extends E{add(e){var u;const{store:s}=this.client,a=(u=s.getState().userReducer.currentUser)==null?void 0:u.id,c=R({...e,created_by:a,submitted_at:new Date().toISOString()});this.dispatch(ei(c));const r=this.enqueueRequest({description:"Create form revision",method:l.POST,url:"/form-revisions/",payload:v(c),blockers:[e.form],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Ur(m))}).catch(()=>{this.dispatch(ti(c.uuid))}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization form revisions",method:l.GET,url:"/form-revisions/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch($r(s))}}const Bf=async t=>{const e={},s=[];for(const n of t){if(n.type!=="section")throw new Error(`Expected ISerializedField type to be a section. Got ${n.type} instead.`);const{fields:a}=n,c=[];for(const r of a){if(r.image){if(r.image instanceof Promise)try{e[r.identifier]=await r.image}catch(u){console.error("Failed to get image from promise",u)}else e[r.identifier]=r.image;delete r.image}c.push(r)}s.push({...n,fields:c})}return{fields:s,images:e}};class Gf extends E{add(e,s){var d;const{store:n}=this.client,a=new Date().toISOString(),c=(d=n.getState().userReducer.currentUser)==null?void 0:d.id,r=R({...e,submitted_at:a,created_by:c}),u=R({...s,form:r.uuid,submitted_at:a,created_by:c});this.dispatch(ii(r)),this.dispatch(ei(u));const m=this.enqueueRequest({description:"Create form",method:l.POST,url:"/forms/",payload:{...v(r),initial_revision:{uuid:u.uuid,submitted_at:u.submitted_at,title:u.title,description:u.description,fields:u.fields}},blockers:[],blocks:[r.uuid,u.uuid]});return m.catch(o=>{throw this.dispatch(ni(r.uuid)),this.dispatch(ti(u.uuid)),o}),[r,u,m]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Xr(e)(n);if(!a)throw new Error("Expected form to exist");const c=cd(e)(n);c.length>0&&this.dispatch(mt(c.map(({uuid:u})=>u)));const r=Nr(e)(n);r.length>0&&this.dispatch(Gr(r.map(({uuid:u})=>u))),this.dispatch(ni(e));try{return await this.enqueueRequest({description:"Delete form",method:l.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(u){throw this.dispatch(ii(a)),r.length>0&&this.dispatch(Br(r)),c.length>0&&this.dispatch(ht(c)),u}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization forms",method:l.GET,url:"/forms/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(Kr(s))}}class Lf extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{submissionUuid:o,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in a||(a[y.sha1]=y);const b=R({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:n,form_submission:o,submitted_at:s,field_identifier:p});c.push(b);const F={uuid:b.uuid,file_name:A.name,file_sha1:y.sha1,file_extension:y.extension,field_identifier:p,form_submission:o};r.push(F)}this.dispatch(ot(c));const u=this.enqueueRequest({description:"Attach files to form submission",method:l.POST,url:"/form-submission-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.form_submission),blocks:c.map(d=>d.uuid)});return u.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(xr(d.attachments))}).catch(d=>{throw this.dispatch(ut(c.map(o=>o.uuid))),d}),[c,u.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=ed(e)(n);this.dispatch(ut(e));try{await this.enqueueRequest({description:"Delete form submission attachments",method:l.DELETE,url:"/form-submission-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(ot(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get form submission attachments",method:l.GET,url:"/form-submission-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Zr(s))}}class Nf extends E{async add(e){var p;const{store:s}=this.client,{file:n,...a}=e,c=new Date().toISOString(),r=(p=s.getState().userReducer.currentUser)==null?void 0:p.id,u=a.project,m=await this.getFilePayload(n),d=R({...a,file_name:n.name,file_sha1:m.sha1,file:URL.createObjectURL(n),submitted_at:c,created_by:r});this.dispatch(md(d));const o=this.enqueueRequest({description:"Add geo image",method:l.POST,url:"/geo-images/",payload:{uuid:d.uuid,submitted_at:c,title:d.title,description:d.description,geo_marker:d.geo_marker,canvas_marker:d.canvas_marker,sha1:d.file_sha1,project:d.project,file_name:d.file_name,direction:d.direction,original_date:d.original_date,file:m},blocks:[u],blockers:[u]});return o.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(Ne(A.geo_image))}).catch(()=>{this.dispatch(pi(d.uuid))}),[d,o.then(A=>A.geo_image)]}async bulkAdd(e,s){var p;const{store:n}=this.client,a=new Date().toISOString(),c=(p=n.getState().userReducer.currentUser)==null?void 0:p.id,r=[],u=[],m=[],d={};for(const A of e){const{file:y,...b}=A,F=await this.getFilePayload(y);F.sha1 in d||(d[F.sha1]=F);const T=R({...b,file_name:y.name,file_sha1:F.sha1,file:URL.createObjectURL(y),submitted_at:a,created_by:c,project:s});r.push(T),u.push(T.uuid),m.push({uuid:T.uuid,sha1:T.file_sha1,file_name:T.file_name,title:T.title,description:T.description,geo_marker:T.geo_marker,canvas_marker:T.canvas_marker,direction:T.direction,original_date:T.original_date})}this.dispatch(pd(r));const o=this.enqueueRequest({description:"Bulk add geo images",method:l.POST,url:"/geo-images/bulk/",payload:{submitted_at:a,project:s,geo_images:m,files:Object.values(d)},blocks:[s],blockers:u});return o.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(hd(A.geo_images))}).catch(()=>{this.dispatch(yd(u))}),[r,o.then(A=>A.geo_images)]}update(e){const{store:s}=this.client,n=s.getState(),a=Ai(e.uuid)(n);if(!a)throw new Error(`Map image with uuid ${e.uuid} does not exist in the store`);const c={...a,...e};this.dispatch(Ad(c));const r=this.enqueueRequest({description:"Update geo image",method:l.PATCH,url:`/geo-images/${e.uuid}/`,payload:e,blocks:[e.uuid],blockers:[e.uuid]});return r.then(u=>{this.dispatch(Ne(u))}).catch(()=>{this.dispatch(Ne(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Ai(e)(n);if(!a)throw new Error(`Map image with uuid ${e} does not exist in the store`);this.dispatch(pi(e));const c=this.enqueueRequest({description:"Delete geo image",method:l.DELETE,url:`/geo-images/${e}/`,blocks:[e],blockers:[e]});return c.catch(()=>{this.dispatch(Ne(a))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get geo images",method:l.GET,url:"/geo-images/",queryParams:{project:e},blocks:[e],blockers:[]});this.dispatch(ld(s))}}class Hf extends P{add(e){var u;const{store:s}=this.client,n=new Date().toISOString(),a=(u=s.getState().userReducer.currentUser)==null?void 0:u.id,c=R({...e,submitted_at:n,created_by:a});this.dispatch(fi(c));const r=this.enqueueRequest({description:"Add issue association",method:l.POST,url:"/issue-associations/",payload:v(c),blockers:[e.associated_issue,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Id(m))}).catch(()=>{this.dispatch(gi(c.uuid))}),[c,r]}async delete(e){const{store:s}=this.client,n=Fd(e)(s.getState());if(!n)throw new Error(`Issue association with uuid ${e} not found in store.`);this.dispatch(gi(e));const a=this.enqueueRequest({description:"Delete issue association",method:l.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(fi(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch issue associations",method:l.GET,url:"/issue-associations/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(bd(s))}}class Wf extends Re{constructor(){super(...arguments);f(this,"name","Issue Attachment");f(this,"url","/issue-attachments");f(this,"initializeAttachments",Ii);f(this,"addAttachments",Fi);f(this,"updateAttachments",Ed);f(this,"removeAttachments",Ri);f(this,"removeAttachment",jd);f(this,"setAttachment",wd);f(this,"selectAttachment",Cd)}buildOfflineAttachment(s){return R({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue:s.modelUuid})}buildAttachmentPayload(s){return{...s,issue:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelUuid:n.issueUuid,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get issue attachments",method:l.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch(Ii(n))}}class Kf extends Re{constructor(){super(...arguments);f(this,"name","Issue Comment Attachment");f(this,"url","/issue-comment-attachments");f(this,"initializeAttachments",Oi);f(this,"addAttachments",Vd);f(this,"updateAttachments",$d);f(this,"removeAttachments",Gd);f(this,"removeAttachment",Bd);f(this,"setAttachment",Ud);f(this,"selectAttachment",Hd)}buildOfflineAttachment(s){return R({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue_comment:s.modelUuid})}buildAttachmentPayload(s){return{...s,issue_comment:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelUuid:n.issueCommentUuid,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get issue comment attachments",method:l.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch(Oi(n))}}class Yf extends P{add(e){var c;const{store:s}=this.client,n=R({...e,author:(c=s.getState().userReducer.currentUser)==null?void 0:c.id,submitted_at:new Date().toISOString()});this.dispatch(wi(n));const a=this.enqueueRequest({description:"Add issue comment",method:l.POST,url:"/issue-comments/",payload:v(n),blockers:[e.issue],blocks:[n.uuid]});return a.catch(()=>{this.dispatch(Ei(n.uuid))}),[n,a]}update(e){const{store:s}=this.client,n=ji(e.uuid)(s.getState());if(!n)throw new Error(`Comment with uuid ${e.uuid} not found in store`);const a={...n,...e};this.dispatch(_i(a));const c=this.enqueueRequest({description:"Edit issue comment",method:l.PATCH,url:`/issue-comments/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.catch(()=>{this.dispatch(_i(n))}),[a,c]}remove(e){const{store:s}=this.client,n=ji(e)(s.getState());if(!n)throw new Error(`Comment with uuid ${e} not found in store`);this.dispatch(Ei(e));const a=this.enqueueRequest({description:"Delete comment",method:l.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(wi(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get comments",method:l.GET,url:"/issue-comments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Yd(s))}}class Jf extends P{add(e){var m;const{store:s}=this.client,n=s.getState(),a=new Date().toISOString(),c=(m=n.userReducer.currentUser)==null?void 0:m.id,r=R({...e,submitted_at:a,created_by:c});this.dispatch(Mi(r));const u=this.enqueueRequest({description:"Create issue",method:l.POST,url:"/issues/",payload:v(r),blockers:["add-issue",r.project,r.issue_type,...r.category?[r.category]:[]],blocks:[r.uuid]});return u.then(d=>{this.dispatch(pt(d))}).catch(d=>{throw this.dispatch(ki(r.uuid)),d}),[r,u]}update(e){var m;const s=this.client.store.getState(),n=Ci(e.uuid)(s);if(!n)throw new Error(`Attempting to update an issue with uuid ${e.uuid} that doesn't exist in the store`);const a={...n,...e};this.dispatch(pt(a));const c={};for(const d of[_.TITLE,_.DESCRIPTION,_.STATUS,_.CATEGORY,_.PRIORITY,_.ASSIGNED_TO,_.DUE_DATE])if(d in e&&e[d]!==n[d])switch(d){case _.PRIORITY:case _.STATUS:{const o=e[d];c[d]=o!==void 0?Number(o):null;break}case _.DUE_DATE:case _.DESCRIPTION:case _.TITLE:c[d]=e[d]??null;break;case _.CATEGORY:{let o=null;const p=e[d];if(p&&(o=s.categoryReducer.instances[p]??null,!o))throw new Error(`Trying to update issue category to ${p} which does not exist in store`);c[d]=o?{name:o.name,color:o.color,uuid:o.uuid}:null;break}case _.ASSIGNED_TO:{let o=null;const p=e[d];if(p&&(o=s.userReducer.instances[p]??null,!o))throw new Error(`Trying to update issue assigned_to to ${p} which does not exist in store`);c[d]=o?{full_name:o.username,id:o.id}:null;break}}const r=R({created_by:(m=s.userReducer.currentUser)==null?void 0:m.id,submitted_at:new Date().toISOString(),issue:n.uuid,changes:c});this.dispatch(Jo(r));const u=this.enqueueRequest({description:"Edit issue",method:l.PATCH,url:`/issues/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return u.catch(()=>{this.dispatch(pt(n)),this.dispatch(Qo(r.uuid))}),[a,u]}async remove(e){const{store:s}=this.client,n=s.getState(),a=Ci(e)(n);if(!a)throw new Error(`No issue with uuid ${e} found in the store`);const c=kd(e)(n),r=eu(e)(n),u=rd(e)(n),m={};for(const o of Rd(e)(n))m[o.uuid]=o;for(const o of Pd(e)(n))m[o.uuid]=o;const d=Object.values(m);this.dispatch(ki(e)),c.length>0&&this.dispatch(Ri(c.map(({uuid:o})=>o))),r.length>0&&this.dispatch(Zo(r.map(({uuid:o})=>o))),u.length>0&&this.dispatch(mt(u.map(({uuid:o})=>o))),d.length>0&&this.dispatch(Ti(d.map(({uuid:o})=>o)));try{return await this.enqueueRequest({description:"Delete issue",method:l.DELETE,url:`/issues/${e}/`,blockers:[e],blocks:[]})}catch(o){throw this.dispatch(Mi(a)),this.dispatch(Fi(c)),this.dispatch(Xo(r)),this.dispatch(ht(u)),this.dispatch(Si(d)),o}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issues",method:l.GET,url:"/issues/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Zd(s))}}class Xf extends Re{constructor(){super(...arguments);f(this,"name","Issue Type Attachment");f(this,"url","/issue-type-attachments");f(this,"initializeAttachments",Di);f(this,"addAttachments",no);f(this,"updateAttachments",co);f(this,"removeAttachments",oo);f(this,"removeAttachment",ro);f(this,"setAttachment",ao);f(this,"selectAttachment",ho)}buildOfflineAttachment(s){return R({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue_type:s.modelUuid})}buildAttachmentPayload(s){return{...s,issue_type:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelUuid:n.issueTypeUuid,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get issue type attachments",method:l.GET,url:`${this.url}/`,queryParams:{organization:s},blocks:[],blockers:[]});this.dispatch(Di(n))}}class Qf extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:o,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in a||(a[y.sha1]=y);const b=R({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:n,fields_revision:o,submitted_at:s,field_identifier:p});c.push(b);const F={uuid:b.uuid,file_name:A.name,file_extension:y.extension,field_identifier:p,file_sha1:y.sha1,fields_revision:o};r.push(F)}this.dispatch(yo(c));const u=this.enqueueRequest({description:"Add issue type fields attachments",method:l.POST,url:"/issue-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.fields_revision),blocks:c.map(d=>d.uuid)});return u.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(fo(d.attachments))}).catch(()=>{this.dispatch(So(c.map(d=>d.uuid)))}),[c,u.then(({attachments:d})=>d)]}async refreshStore(e){const s=await this.enqueueRequest({description:"get issue type fields attachments",method:l.GET,url:"/issue-type-fields-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(Ao(s))}}class Zf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.id,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(_o(c));const r=this.enqueueRequest({description:"Add Issue Type Fields",method:l.POST,url:"/issue-type-fields/",payload:v(c),blockers:[c.issue_type],blocks:[c.uuid]});return r.then(m=>{this.dispatch(wo(m))}).catch(m=>{throw this.dispatch(Eo(c.uuid)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Issue Type Fields",method:l.GET,url:"/issue-type-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(vo(s))}}class xf extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const d of e){const{fieldValuesUuid:o,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in a||(a[y.sha1]=y);const b=R({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:n,field_values:o,submitted_at:s,field_identifier:p});c.push(b);const F={uuid:b.uuid,file_name:A.name,file_sha1:y.sha1,file_extension:y.extension,field_identifier:p,field_values:o};r.push(F)}this.dispatch(yt(c));const u=this.enqueueRequest({description:"Add issue type field values attachments",method:l.POST,url:"/issue-type-field-values-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(d=>d.field_values),blocks:c.map(d=>d.uuid)});return u.then(({presigned_urls:d,attachments:o})=>{this.processPresignedUrls(d),this.dispatch(Co(o))}).catch(d=>{throw this.dispatch(ft(c.map(o=>o.uuid))),d}),[c,u.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Do(e)(n);this.dispatch(ft(e));try{await this.enqueueRequest({description:"Delete issue type field values attachments",method:l.DELETE,url:"/issue-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(yt(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values attachments",method:l.GET,url:"/issue-type-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(ko(s))}}class eS extends P{add(e){var r;const{store:s}=this.client,n=s.getState(),a=R({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add issue type field values",method:l.POST,url:"/issue-type-field-values/",payload:v(a),blockers:[e.issue,e.fields_revision],blocks:[a.uuid]});return this.dispatch($i(a)),c.then(u=>(this.dispatch(We(u)),u)).catch(()=>{this.dispatch(Bi(a.uuid))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=Li(e.uuid)(n);if(!a)throw new Error(`Expected IssueTypeFieldValues with uuid ${e.uuid} to exist`);const c={...a,...e};this.dispatch(We(c));const r=this.enqueueRequest({description:"Update issue type field values",method:l.PATCH,url:`/issue-type-field-values/${e.uuid}/`,payload:e,blockers:[c.uuid,c.fields_revision,c.issue],blocks:[c.uuid]});return r.then(u=>{this.dispatch(We(u))}).catch(()=>{this.dispatch(We(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Li(e)(n);if(!a)throw new Error(`Expected submission with uuid ${e} to exist`);const c=Vo(e)(n);this.dispatch(Bi(e)),this.dispatch(ft(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete issue type field values",method:l.DELETE,url:`/issue-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch($i(a)),this.dispatch(yt(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values",method:l.GET,url:"/issue-type-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Fo(s))}}class tS extends P{add(e){var r;const{store:s}=this.client,n=s.getState(),a=R({...e,submitted_at:new Date().toISOString(),created_by:(r=n.userReducer.currentUser)==null?void 0:r.id});this.dispatch(Go(a));const c=this.enqueueRequest({method:l.POST,url:"/issue-types/",payload:v(a),blockers:[],blocks:[a.uuid]});return c.then(u=>{this.dispatch(Ke(u))}).catch(()=>{this.dispatch(Yi(a.uuid))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=Ji(e.uuid)(n);if(!a)throw new Error(`IssueType with uuid ${e.uuid} does not exist in the store.`);const c={...a,...e};this.dispatch(Lo(c));const r=this.enqueueRequest({method:l.PATCH,url:`/issue-types/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return r.then(u=>{this.dispatch(Ke(u))}).catch(()=>{this.dispatch(Ke(a))}),[c,r]}delete(e){const{store:s}=this.client,n=s.getState(),a=Ji(e)(n);if(!a)throw new Error(`IssueType with uuid ${e} does not exist in the store.`);const c=Xi(e)(n);this.dispatch(Yi(e)),this.dispatch(eo(c.map(u=>u.uuid)));const r=this.enqueueRequest({method:l.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return r.catch(()=>{this.dispatch(Ke(a)),this.dispatch(xd(c))}),r}async refreshStore(e){const s=await this.enqueueRequest({method:l.GET,url:"/issue-types/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Bo(s))}}class sS extends P{async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue updates",method:l.GET,url:"/issue-updates/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Yo(s))}}const iS=1800;function nS(t){if(!t.access)throw new Error("Missing access token");if(!t.refresh)throw new Error("Missing refresh token");return{accessToken:t.access,refreshToken:t.refresh}}class aS extends hf{constructor(){super(...arguments);f(this,"_getRenewedTokens",async s=>{const n=this.enqueueRequest({description:"Get renewed tokens",method:l.POST,url:this.refreshTokensUrl,payload:{refresh:s},isAuthNeeded:!1,blockers:[],blocks:[],checkAuth:!1,immediate:!0});let a;try{a=await n}catch(c){console.error("Could not renew tokens; clearing auth",c),this.clearAuth();return}if(!a.access)throw new Error("Missing access token");return{accessToken:a.access,refreshToken:a.refresh??this.getRefreshToken()}})}clearAuth(){console.debug(this.constructor.name,"clearing auth;"),this.dispatch(Jc(!1)),this.clearTokens(),this.dispatch({type:Nl.RESET_STATE}),this.dispatch({type:jl})}async renewTokens(){const s=this.getRefreshToken();if(!s)throw new Error("No refresh token found");console.debug(this.constructor.name,"renewing tokens");try{const n=await this._getRenewedTokens(s);if(!n)return;console.log("Got renewed tokens"),this.setTokens(n)}catch(n){throw console.error("Could not renew tokens; clearing auth",n),this.clearAuth(),n}}tokenIsExpiringSoon(){const s=this.getAccessToken();if(!s)return!1;const n=Date.now()/1e3;let a;try{a=Hl(s).exp??n}catch{a=n}return a-n<iS}getAuthHeader(){return`Bearer ${this.getAccessToken()}`}async prepareAuth(){if(this.tokenIsExpiringSoon()){console.debug(this.constructor.name,"preparing auth");try{await this.renewTokens()}catch(s){return s instanceof q&&this.clearAuth(),s instanceof Error?Promise.reject(s):Promise.reject(new Error((s??ke).toString()))}}}async handleUnauthorized(s,n){const a=this.client.store.getState();if(s.url.endsWith("/token/refresh/"))throw a.authReducer.isLoggedIn&&console.warn("No signed-in user to sign out."),this.clearAuth(),new q({message:"You have been signed out due to inactivity.",response:n,discard:!0});if(a.authReducer.isLoggedIn)await this.renewTokens();else throw console.debug("Forbidden; user is not logged in."),new q({message:"Incorrect username or password.",response:n,discard:!0})}async initAuth(s){const n=fe.v4();return console.debug(this.constructor.name,"Initiating auth"),this.enqueueRequest({uuid:n,description:"Get token pair",method:l.POST,url:this.initTokensUrl,payload:s,isAuthNeeded:!1,checkAuth:!1,immediate:!0,blockers:[],blocks:[]}).then(a=>{this.setTokens(nS(a))})}}class cS extends P{async getLicense(e){const s=await this.enqueueRequest({description:"Get license",method:l.GET,url:`/billing/${e.uuid}/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:[]});return this.dispatch(pe(s)),s}async pauseLicense(e){const s=await this.enqueueRequest({description:"Pause license",method:l.DELETE,url:`/billing/${e.uuid}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:[]});return this.dispatch(pe(s)),s}async resumeLicense(e){const s=await this.enqueueRequest({description:"Resume license",method:l.PATCH,url:`/billing/${e.uuid}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:[]});return this.dispatch(pe(s)),s}async cancelLicense(e){const s=await this.enqueueRequest({description:"Cancel license",method:l.DELETE,url:`/billing/${e.uuid}/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:[]});return this.dispatch(pe(s)),s}async attachLicenseToProject(e,s){const n=await this.enqueueRequest({description:"Attach license",method:l.PATCH,url:`/billing/${e.uuid}/project/`,isAuthNeeded:!0,payload:{project:s.uuid},blockers:[e.organization_owner,s.uuid],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(pe(n)),n}async detachLicenseFromProject(e){const s=await this.enqueueRequest({description:"Detach license",method:l.DELETE,url:`/billing/${e.uuid}/project/`,isAuthNeeded:!0,blockers:[e.organization_owner],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(pe(s)),s}async getLatestTransaction(e){return await this.enqueueRequest({description:"Get latest transaction",method:l.GET,url:`/billing/${e.uuid}/transaction/`,isAuthNeeded:!0,blockers:[e.uuid],blocks:[e.uuid]})}async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Get licenses",method:l.GET,url:`/organizations/${s}/licenses/`,isAuthNeeded:!0,blockers:[s],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of a)n[r.uuid]=r;const c=await this.enqueueRequest({description:"Get licenses",method:l.GET,url:`/projects/${e}/licenses/`,isAuthNeeded:!0,blockers:[e],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of c)n[r.uuid]=r;this.dispatch(iu(Object.values(n)))}}class rS extends P{async update(e){const s=this.enqueueRequest({description:"Edit organization access",method:l.PATCH,url:`/organization-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return s.then(()=>{this.dispatch(hu(e))}),s}async remove(e){return this.dispatch(mu(e.uuid)),this.dispatch(du(e.user)),this.enqueueRequest({description:"Remove organization access",method:l.DELETE,url:`/organization-accesses/${e.uuid}/`,blockers:[e.uuid],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization accesses",method:l.GET,url:"/organization-accesses/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(lu(s))}}class dS extends P{create(e){return this.enqueueRequest({description:"Create organization",method:l.POST,url:"/organizations/",payload:{name:e},blockers:[],blocks:[`add-org-${e}`,"create-org"]})}async update(e){return this.enqueueRequest({description:"Edit organization",method:l.PATCH,url:`/organizations/${e.uuid}/`,payload:e,blockers:[`add-org-${e.name}`,e.uuid],blocks:[e.uuid]})}async invite(e,s){return this.enqueueRequest({description:"Invite user to organization",method:l.POST,url:`/organizations/${e}/invite/${s}/`,blockers:[],blocks:[]})}async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Get organizations",method:l.GET,url:`/projects/${e}/organizations/`,blockers:[],blocks:[]});for(const r of a)n[r.uuid]=r;const c=await this.enqueueRequest({description:"Get organization",method:l.GET,url:`/organizations/${s}/`,blockers:[],blocks:[]});n[c.uuid]=c,this.dispatch(qu(Object.values(n)))}}class oS extends P{async update(e){return this.dispatch(fu(e)),this.enqueueRequest({description:"Edit project access",method:l.PATCH,url:`/project-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid,"change-access-level"],blocks:[e.uuid]})}async remove(e){return this.dispatch(Su(e)),this.enqueueRequest({description:"Delete project access",method:l.DELETE,url:`/project-accesses/${e}/`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project accesses",method:l.GET,url:"/project-accesses/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(nn(s))}}class uS extends Re{constructor(){super(...arguments);f(this,"name","Project Attachment");f(this,"url","/project-attachments");f(this,"addAttachments",Wu);f(this,"updateAttachments",Ju);f(this,"removeAttachments",un);f(this,"removeAttachment",Xu);f(this,"setAttachment",Ku);f(this,"selectAttachment",xu)}buildOfflineAttachment(s){return R({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,project:s.modelUuid})}buildAttachmentPayload(s){return{...s,project:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelUuid:n.projectUuid,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get project attachments",method:l.GET,url:`${this.url}/`,queryParams:{project:s},blockers:[],blocks:[]});this.dispatch(Hu(n))}}class lS extends P{async saveExisting(e){if(!e.uuid)throw new Error("You can only use this method to save existing project files. The one provided has no uuid.");const s={...e};delete s.file;const n=this.enqueueRequest({method:l.PATCH,url:`/projects/files/${e.uuid}/`,payload:s,blockers:[e.uuid],blocks:[e.uuid]});return n.then(a=>{this.dispatch(hn(a))}),n}saveActive(){const{store:e}=this.client,s=e.getState(),n=s.projectFileReducer.activeProjectFileId;if(!n)throw new Error("No active project file");const a=s.projectFileReducer.instances[n];if(!a)throw new Error("No active project file");if(!a.bounds&&!a.canvas_bounds)throw new Error("Project file must either have bounds or canvas_bounds set");let c;if(typeof a.file=="string"&&!a.file.startsWith("blob:")){const m={...a};delete m.file,c={method:l.PATCH,url:`/projects/files/${n}/`,payload:m,blockers:[n],blocks:[n]}}else c=new Promise((m,d)=>{this.client.files.uploadFileToS3(a.file_sha1).then(([o])=>{m({method:l.POST,url:`/projects/${a.project}/files/`,payload:{...a,...o},blockers:[n],blocks:[n]})}).catch(d)});const u=Promise.resolve(c).then(m=>this.enqueueRequest(m));return u.then(m=>{this.dispatch(hn(m))}),this.dispatch(ol),this.dispatch(dl(null)),this.dispatch(rl(!1)),[a,u]}delete(e){return this.dispatch(al(e)),this.enqueueRequest({method:l.DELETE,url:`/projects/files/${e}`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project files",method:l.GET,url:`/projects/${e}/files/`,blockers:[],blocks:[]});this.dispatch(il(s))}}class hS extends P{async add(e){if(!e.bounds&&!e.canvas_bounds)throw new Error("Project must either have bounds or canvas_bounds set");return await this.enqueueRequest({description:"Create project",method:l.POST,url:"/projects/",payload:{name:e.name,bounds:e.bounds,organization_owner:e.organization_owner},blockers:[],blocks:[]})}async update(e){if(!e.bounds&&!e.canvas_bounds)throw new Error("Project must either have bounds or canvas_bounds set");return this.dispatch(Pu(e)),await this.enqueueRequest({description:"Update project",method:l.PATCH,url:`/projects/${e.uuid}/`,payload:{name:e.name,bounds:e.bounds},blockers:[e.uuid],blocks:[e.uuid]})}async delete(e){const{store:s}=this.client,n=s.getState(),a=Ft(n),c=a[e];if(!c)throw new Error("Expected project to exist");const r=ll(n).filter(o=>o.project===e);this.dispatch(cl(r.map(({uuid:o})=>o)));const u=el(c.uuid)(n);this.dispatch(un(u.map(({uuid:o})=>o)));const m=Tu(n);this.dispatch(gu(m.map(({uuid:o})=>o))),this.dispatch({type:"rehydrated/setRehydrated",payload:!1}),this.dispatch(Ou(c.uuid));const d=nu(c.uuid)(n);d&&this.dispatch(pe({...d,project:null}));try{await this.enqueueRequest({description:"Delete project",method:l.DELETE,url:`/projects/${e}/`,blockers:[e],blocks:[]}),this.dispatch({type:"rehydrated/setRehydrated",payload:!0})}catch(o){throw this.dispatch(Ru(Object.values(a))),this.dispatch(nn(Object.values(m))),this.dispatch(nl(r)),this.dispatch(Yu(u)),this.dispatch({type:"rehydrated/setRehydrated",payload:!0}),d&&this.dispatch(pe({...d,project:c.uuid})),o}}invite(e,s){const n=fe.v4();return this.enqueueRequest({description:"Invite user to project",method:l.POST,url:`/projects/${e}/invite/${s}/`,payload:{uuid:n},blockers:[],blocks:[n]})}joinProject(e,s,n){return this.enqueueRequest({description:"Join project",method:l.GET,url:`/projects/${e}/join-project/${s}/${n}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}async acceptInvite(e){return this.enqueueRequest({description:"Accept project invite",method:l.PATCH,url:`/projects/${e}/accept-invite/`,blockers:[e],blocks:[e]}).then(()=>{this.dispatch(vu(e))})}}class mS extends P{add(e){const s=R({...e,submitted_at:new Date().toISOString()});this.dispatch(yl(s));const n=this.enqueueRequest({description:"Create team",method:l.POST,url:"/teams/",payload:s,blockers:[],blocks:[s.uuid]});return n.then(a=>{this.dispatch(qe(a))}).catch(()=>{this.dispatch(yn(s.uuid))}),[s,n]}update(e){const{store:s}=this.client,n=Me(e.uuid)(s.getState());if(!n)throw new Error(`Expected team with uuid ${e.uuid} to exist`);const a={...n,...e};this.dispatch(An(a));const c=this.enqueueRequest({description:"Update team",method:l.PATCH,url:`/teams/${e.uuid}/`,payload:v(e),blockers:[e.uuid],blocks:[e.uuid]});return c.then(r=>{this.dispatch(qe(r))}).catch(()=>{this.dispatch(qe(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Me(e)(n);if(!a)throw new Error(`Expected team with uuid ${e} to exist`);this.dispatch(yn(e));try{return await this.enqueueRequest({description:"Delete team",method:l.DELETE,url:`/teams/${e}/`,blockers:[e],blocks:[e]})}catch(c){throw this.dispatch(qe(a)),c}}async setMembers(e,s){const{store:n}=this.client,a=Me(e)(n.getState());if(!a)throw new Error(`Expected team with uuid ${e} to exist`);if(s.length!==new Set(s).size)throw new Error("Duplicate members found in the list");this.dispatch(An({...a,members:s}));const c=this.enqueueRequest({description:"Set team members",method:l.PUT,url:`/teams/${e}/set-members/`,payload:{users:s},blockers:[e],blocks:[e]});return c.catch(()=>{this.dispatch(qe(a))}),c}async addMembers(e,s){const{store:n}=this.client,a=Me(e)(n.getState());if(!a)throw new Error(`Expected team with uuid ${e} to exist`);const c=[...a.members,...s];return this.setMembers(e,c)}async removeMembers(e,s){const{store:n}=this.client,a=Me(e)(n.getState());if(!a)throw new Error(`Expected team with uuid ${e} to exist`);const c=a.members.filter(r=>!s.includes(r));return this.setMembers(e,c)}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch teams",method:l.GET,url:"/teams/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Al(s))}}class pS extends P{async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Fetch organization users",method:l.GET,url:`/organizations/${s}/users/`,blockers:[],blocks:[]});for(const r of a)n[r.id]=r;const c=await this.enqueueRequest({description:"Fetch project users",method:l.GET,url:`/projects/${e}/users/`,blockers:[],blocks:[]});for(const r of c)n[r.id]=r;this.dispatch(ru(Object.values(n)))}}class AS{constructor(e){f(this,"store");this.store=e}async enqueueRequest(e,s,n){return this._enqueueRequest(e,s,n).then(a=>{if(a instanceof q)throw a;return a})}_enqueueRequest(e,s,n){const a=new kn,c={...e,BASE_URL:s,serviceName:n};if(e.immediate){const r={...c,uuid:e.uuid??fe.v4()},u={payload:r,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:r,BASE_URL:s,serviceName:n}}}};bn(u,this).then(m=>{a.resolve(m.body)}).catch(m=>{In(m,u),m instanceof Error?a.reject(m):a.reject(new Error((m??ke).toString()))})}else{const r=this.store.dispatch($u(c)),u=d=>{if(d)a.resolve(d.body);else{const o=new q({message:"Could not get a response from the server.",response:d,discard:!0});a.reject(o)}},m=d=>{d instanceof q?d.options.discard=!0:(console.error("Received an unexpected error while processing a request:",d,`
15
+ Converting error to APIError and discarding.`),d=new q({message:"An error occurred while processing the request.",innerError:d,discard:!0})),a.reject(d)};r.then(u,m)}return a}}class Ce{constructor(){f(this,"graph");f(this,"requestAttemptCounter");this.graph=new Wl.DepGraph,this.requestAttemptCounter={}}static _fromOutbox(e){const s=new Ce;for(let n=0;n<e.length;n++){const a=e[n];if(!a){console.error("Outbox item was undefined");continue}s.sneakRequest(a);for(let c=0;c<n;c++){const r=e[c];if(!r){console.error("Previous outbox item was undefined");continue}r.payload.uuid!==a.payload.uuid&&r.payload.blocks.some(u=>a.payload.blockers.includes(u))&&Ce._addDependency(a.payload.uuid,r.payload.uuid,s.graph)}}return s}_addDependency(e,s){Ce._addDependency(e,s,this.graph)}static _addDependency(e,s,n){if(e===s)throw new Error(`Tried to add dependency from node to itself: ${e}`);if(!n.hasNode(e))throw new Error(`Tried to add dependency from non-existent node: ${e} (to node: ${s})`);if(!n.hasNode(s))throw new Error(`Tried to add dependency to non-existent node: ${s} (from node: ${e})`);n.addDependency(e,s)}addRequest(e){if(this.graph.addNode(e.payload.uuid,e),!(e.payload.blockers.length===0||this.graph.size()===1))for(const s of this.graph.overallOrder()){if(s===e.payload.uuid)continue;const n=this.graph.getNodeData(s);e.payload.blockers.some(a=>n.payload.blocks.includes(a))&&this._addDependency(e.payload.uuid,s)}}insertRequest(e){this.graph.addNode(e.payload.uuid,e);for(const s of this.graph.overallOrder()){if(s===e.payload.uuid)continue;this.graph.getNodeData(s).payload.blockers.some(a=>e.payload.blocks.includes(a))&&this._addDependency(s,e.payload.uuid)}}sneakRequest(e){this.graph.addNode(e.payload.uuid,e)}_getNextNode(){const e=this.graph.overallOrder(!0);let s=1/0,n;for(const a of e){const c=this.requestAttemptCounter[a]||0;c<s&&(s=c,n=a)}return n}peek(){const e=this._getNextNode();if(e)return this.graph.getNodeData(e)}remove(e){this.graph.removeNode(e),delete this.requestAttemptCounter[e]}pop(){const e=this.peek();return e&&this.graph.removeNode(e.payload.uuid),e}getQueue(){const e=this.graph.overallOrder().map(n=>this.graph.getNodeData(n)),s=this._getNextNode();if(s){const n=this.graph.getNodeData(s),a=e.findIndex(c=>c.payload.uuid===n.payload.uuid);a!==-1&&(e.splice(a,1),e.unshift(n))}return e}getReady(){let e=this.graph.overallOrder(!0).map(s=>this.graph.getNodeData(s));return e=e.sort((s,n)=>s.meta.offline.effect.timestamp.localeCompare(n.meta.offline.effect.timestamp)),e=e.sort((s,n)=>{const a=this.requestAttemptCounter[s.payload.uuid]||0,c=this.requestAttemptCounter[n.payload.uuid]||0;return a-c}),e}registerRetry(e){this.requestAttemptCounter[e]=(this.requestAttemptCounter[e]||0)+1}}const yS=(t,e)=>{const s=new e(t);return Ny(s),Ly(t),s};var Dl=(t=>(t[t.USER_REGISTRATION=0]="USER_REGISTRATION",t[t.APPLICATION_INVITE=2]="APPLICATION_INVITE",t[t.PROJECT_INVITE=4]="PROJECT_INVITE",t[t.ORGANIZATION_INVITE=6]="ORGANIZATION_INVITE",t[t.ADD_EMAIL_DOMAIN=8]="ADD_EMAIL_DOMAIN",t[t.RESET_PASSWORD=10]="RESET_PASSWORD",t))(Dl||{});i.APIError=q,i.AgentService=mf,i.AssetAttachmentService=pf,i.AssetProcedureFieldValuesAttachmentService=ff,i.AssetProcedureFieldValuesService=Tf,i.AssetProcedureFieldsAttachmentService=Af,i.AssetProcedureFieldsService=yf,i.AssetProcedureInstanceService=bf,i.AssetProcedureService=If,i.AssetService=Ff,i.AssetStageCompletionService=Rf,i.AssetStageService=Pf,i.AssetTypeAttachmentService=Of,i.AssetTypeFieldValuesAttachmentService=wf,i.AssetTypeFieldValuesService=Ef,i.AssetTypeFieldsAttachmentService=vf,i.AssetTypeFieldsService=_f,i.AssetTypeService=jf,i.AttachmentModel=wn,i.BaseApiService=P,i.BaseSDK=AS,i.COMMON_AUTO_FIELDS=Un,i.CategoryService=qf,i.DEFAULT_ISSUE_PRIORITY=Yl,i.DEFAULT_ISSUE_STATUS=Kl,i.DeferredPromise=kn,i.DocumentAttachmentService=Mf,i.DocumentService=kf,i.EMPTY_ARRAY=vn,i.EMPTY_OBJECT=_n,i.EmailDomainsService=Cf,i.EmailVerificationService=zf,i.FileService=Vf,i.FormRevisionAttachmentService=Uf,i.FormRevisionService=$f,i.FormService=Gf,i.FormSubmissionAttachmentService=Lf,i.FormSubmissionService=gf,i.GeoImageService=Nf,i.HttpMethod=l,i.IssueAssociationService=Hf,i.IssueAttachmentService=Wf,i.IssueCommentAttachmentService=Kf,i.IssueCommentService=Yf,i.IssuePriority=wt,i.IssueService=Jf,i.IssueStatus=Et,i.IssueTypeAttachmentService=Xf,i.IssueTypeFieldValuesAttachmentService=xf,i.IssueTypeFieldValuesService=eS,i.IssueTypeFieldsAttachmentService=Qf,i.IssueTypeFieldsService=Zf,i.IssueTypeService=tS,i.IssueUpdateChange=_,i.IssueUpdateService=sS,i.JWTService=aS,i.LicenseLevel=jn,i.LicenseService=cS,i.LicenseStatus=qn,i.OUTBOX_RETRY_DELAY=Mn,i.OrganizationAccessLevel=_t,i.OrganizationAccessService=rS,i.OrganizationService=dS,i.OutboxCoordinator=Ce,i.PaddleCheckoutEvent=En,i.ProjectAccessLevel=vt,i.ProjectAccessService=oS,i.ProjectAttachmentService=uS,i.ProjectFileService=lS,i.ProjectService=hS,i.TeamService=mS,i.UNKNOWN_ERROR_MESSAGE=ke,i.UserService=pS,i.VERSION_REDUCER_KEY=gn,i.VerificationCodeType=Dl,i._setLatestRetryTime=Gu,i.acceptProjectInvite=vu,i.addAsset=os,i.addAssetAttachment=Th,i.addAssetAttachments=Ut,i.addAssetProcedure=ns,i.addAssetProcedureFieldValues=Kt,i.addAssetProcedureFieldValuesAttachment=Vh,i.addAssetProcedureFieldValuesAttachments=xe,i.addAssetProcedureFieldValuesMany=va,i.addAssetProcedureFields=ma,i.addAssetProcedureFieldsAttachment=Fh,i.addAssetProcedureFieldsAttachments=aa,i.addAssetProcedureFieldsMany=Eh,i.addAssetProcedureInstance=Zt,i.addAssetProcedureInstances=ka,i.addAssetProcedures=xh,i.addAssetStage=mm,i.addAssetStageCompletion=ys,i.addAssetStageCompletions=fs,i.addAssetStages=Is,i.addAssetType=Us,i.addAssetTypeAttachment=fm,i.addAssetTypeAttachments=vs,i.addAssetTypeFieldValues=ks,i.addAssetTypeFieldValuesAttachment=Cm,i.addAssetTypeFieldValuesAttachments=nt,i.addAssetTypeFieldValuesMany=$c,i.addAssetTypeFields=Oc,i.addAssetTypeFieldsAttachment=Tm,i.addAssetTypeFieldsAttachments=Sc,i.addAssetTypeFieldsMany=vm,i.addAssetTypes=Km,i.addAssets=us,i.addCategory=Ns,i.addConversation=Nn,i.addDocumentAttachment=ap,i.addDocumentAttachments=nr,i.addDocuments=Ar,i.addEmailDomain=br,i.addForm=ii,i.addFormRevision=ei,i.addFormRevisionAttachment=Ap,i.addFormRevisionAttachments=Mr,i.addFormRevisions=Br,i.addFormSubmission=di,i.addFormSubmissionAttachment=_p,i.addFormSubmissionAttachments=ot,i.addFormSubmissions=ht,i.addForms=Pp,i.addGeoImage=md,i.addGeoImages=pd,i.addIssue=Mi,i.addIssueAssociation=fi,i.addIssueAssociations=Si,i.addIssueAttachment=Bp,i.addIssueAttachments=Fi,i.addIssueComment=wi,i.addIssueCommentAttachment=Np,i.addIssueCommentAttachments=Vd,i.addIssueComments=Yp,i.addIssueType=Go,i.addIssueTypeAttachment=Zp,i.addIssueTypeAttachments=no,i.addIssueTypeFieldValues=$i,i.addIssueTypeFieldValuesAttachment=RA,i.addIssueTypeFieldValuesAttachments=yt,i.addIssueTypeFieldValuesMany=oA,i.addIssueTypeFields=_o,i.addIssueTypeFieldsAttachment=sA,i.addIssueTypeFieldsAttachments=yo,i.addIssueTypeFieldsMany=AA,i.addIssueUpdate=Jo,i.addIssueUpdates=Xo,i.addIssues=xd,i.addLicenses=kA,i.addOrganization=my,i.addOrganizations=hy,i.addProject=ny,i.addProjectAttachment=Oy,i.addProjectAttachments=Wu,i.addProjectFile=Ey,i.addProjectFiles=nl,i.addProjects=iy,i.addTeam=yl,i.addUser=BA,i.addUsers=$A,i.agentsReducer=Kn,i.agentsSlice=Ct,i.areArraysEqual=eh,i.assetAttachmentReducer=sa,i.assetAttachmentSlice=Dt,i.assetProcedureFieldValuesAttachmentReducer=Ra,i.assetProcedureFieldValuesAttachmentSlice=Nt,i.assetProcedureFieldValuesReducer=ja,i.assetProcedureFieldValuesSlice=Wt,i.assetProcedureFieldsAttachmentReducer=ua,i.assetProcedureFieldsAttachmentSlice=Bt,i.assetProcedureFieldsReducer=fa,i.assetProcedureFieldsSlice=Gt,i.assetProcedureInstanceReducer=Da,i.assetProcedureInstanceSlice=Qt,i.assetProcedureReducer=Ba,i.assetProcedureSlice=is,i.assetReducer=Wa,i.assetSlice=ds,i.assetStageCompletionReducer=Qa,i.assetStageCompletionSlice=As,i.assetStageReducer=ic,i.assetStageSlice=bs,i.assetTypeAttachmentReducer=Ac,i.assetTypeAttachmentSlice=Os,i.assetTypeFieldValuesAttachmentReducer=Dc,i.assetTypeFieldValuesAttachmentSlice=js,i.assetTypeFieldValuesReducer=Nc,i.assetTypeFieldValuesSlice=Ms,i.assetTypeFieldsAttachmentReducer=Fc,i.assetTypeFieldsAttachmentSlice=ws,i.assetTypeFieldsReducer=Ec,i.assetTypeFieldsSlice=Es,i.assetTypeReducer=Kc,i.assetTypeSlice=Vs,i.authReducer=Xc,i.authSlice=ct,i.blobToBase64=oh,i.categoryReducer=tr,i.categorySlice=Ls,i.clearTokens=xm,i.constructUploadedFilePayloads=dh,i.coordinatesAreEqual=Zl,i.createModelAdapter=I,i.createMultiPointGeometry=Ql,i.createOfflineAction=Vu,i.createPayload=v,i.createPointGeometry=Xl,i.createSelectionAdapter=Jl,i.deleteAsset=ls,i.deleteAssetAttachment=Qn,i.deleteAssetAttachments=$t,i.deleteAssetProcedure=as,i.deleteAssetProcedureFieldValues=Yt,i.deleteAssetProcedureFieldValuesAttachment=Gh,i.deleteAssetProcedureFieldValuesAttachments=et,i.deleteAssetProcedureFieldValuesMany=wa,i.deleteAssetProcedureFields=Aa,i.deleteAssetProcedureFieldsAttachment=vh,i.deleteAssetProcedureFieldsAttachments=ra,i.deleteAssetProcedureFieldsMany=kh,i.deleteAssetProcedureInstance=xt,i.deleteAssetProcedureInstances=Ca,i.deleteAssetProcedures=tm,i.deleteAssetStage=pm,i.deleteAssetStageCompletion=Ss,i.deleteAssetStageCompletions=gs,i.deleteAssetStages=Rs,i.deleteAssetType=$s,i.deleteAssetTypeAttachment=uc,i.deleteAssetTypeAttachments=_s,i.deleteAssetTypeFieldValues=Cs,i.deleteAssetTypeFieldValuesAttachment=Um,i.deleteAssetTypeFieldValuesAttachments=at,i.deleteAssetTypeFieldValuesMany=Gc,i.deleteAssetTypeFields=_c,i.deleteAssetTypeFieldsAttachment=Rm,i.deleteAssetTypeFieldsAttachments=Tc,i.deleteAssetTypeFieldsMany=jm,i.deleteAssetTypes=Jm,i.deleteAssets=Na,i.deleteCategory=er,i.deleteDocumentAttachment=rr,i.deleteDocumentAttachments=dr,i.deleteEmailDomain=Ir,i.deleteForm=ni,i.deleteFormRevision=ti,i.deleteFormRevisionAttachment=gp,i.deleteFormRevisionAttachments=Cr,i.deleteFormRevisions=Gr,i.deleteFormSubmission=oi,i.deleteFormSubmissionAttachment=qp,i.deleteFormSubmissionAttachments=ut,i.deleteFormSubmissions=mt,i.deleteGeoImage=pi,i.deleteGeoImages=yd,i.deleteIssue=ki,i.deleteIssueAssociation=gi,i.deleteIssueAssociations=Ti,i.deleteIssueAttachment=jd,i.deleteIssueAttachments=Ri,i.deleteIssueComment=Ei,i.deleteIssueCommentAttachment=Bd,i.deleteIssueCommentAttachments=Gd,i.deleteIssueComments=Jp,i.deleteIssueTypeAttachment=ro,i.deleteIssueTypeAttachments=oo,i.deleteIssueTypeFieldValues=Bi,i.deleteIssueTypeFieldValuesAttachment=_A,i.deleteIssueTypeFieldValuesAttachments=ft,i.deleteIssueTypeFieldValuesMany=mA,i.deleteIssueTypeFields=Eo,i.deleteIssueTypeFieldsAttachment=cA,i.deleteIssueTypeFieldsAttachments=So,i.deleteIssueTypeFieldsMany=gA,i.deleteIssueUpdate=Qo,i.deleteIssueUpdates=Zo,i.deleteIssues=eo,i.deleteOrganization=yy,i.deleteOrganizationAccess=mu,i.deleteOrganizations=fy,i.deleteProject=Ou,i.deleteProjectAccess=Su,i.deleteProjectAccesses=gu,i.deleteProjectAttachment=Xu,i.deleteProjectAttachments=un,i.deleteProjectFile=al,i.deleteProjectFiles=cl,i.deleteProjects=cy,i.deleteTeam=yn,i.deleteUser=NA,i.deleteUsers=HA,i.dequeue=Ml,i.discard=In,i.documentAttachmentReducer=hr,i.documentAttachmentSlice=Ks,i.documentSlice=Ys,i.documentsReducer=gr,i.downloadFile=uh,i.downloadInMemoryFile=rh,i.emailDomainsReducer=Pr,i.emailDomainsSlice=Xs,i.emailRegex=fh,i.enqueue=ql,i.enqueueRequest=$u,i.fallbackToEmptyArray=g,i.fallbackToEmptyObject=ve,i.fileReducer=Er,i.fileSlice=Qs,i.fileToBlob=Dn,i.formReducer=Yr,i.formRevisionAttachmentReducer=Dr,i.formRevisionAttachmentSlice=Zs,i.formRevisionReducer=Hr,i.formRevisionsSlice=xs,i.formSlice=si,i.formSubmissionAttachmentReducer=sd,i.formSubmissionAttachmentSlice=ai,i.formSubmissionReducer=od,i.formSubmissionSlice=ri,i.geoImageReducer=gd,i.geoImageSlice=mi,i.getFileIdentifier=ch,i.getFileS3Key=kt,i.getLocalDateString=Cn,i.getLocalRelativeDateString=nh,i.getOutboxCoordinator=Fe,i.getRenamedFile=zn,i.hashFile=_e,i.initSDK=yS,i.initializeAssetAttachments=Vt,i.initializeAssetProcedureFieldValues=Oa,i.initializeAssetProcedureFieldValuesAttachments=ga,i.initializeAssetProcedureFields=ha,i.initializeAssetProcedureFieldsAttachments=na,i.initializeAssetProcedureInstances=Ma,i.initializeAssetProcedures=Ua,i.initializeAssetStageCompletions=Ya,i.initializeAssetStages=tc,i.initializeAssetTypeAttachments=rc,i.initializeAssetTypeFieldValues=Uc,i.initializeAssetTypeFieldValuesAttachments=qc,i.initializeAssetTypeFields=Pc,i.initializeAssetTypeFieldsAttachments=fc,i.initializeAssetTypes=Wc,i.initializeAssets=La,i.initializeCategories=Zc,i.initializeConversations=Ln,i.initializeDocumentAttachments=ir,i.initializeEmailDomains=Tr,i.initializeFormRevisionAttachments=qr,i.initializeFormRevisions=$r,i.initializeFormSubmissionAttachments=Zr,i.initializeFormSubmissions=nd,i.initializeForms=Kr,i.initializeGeoImages=ld,i.initializeIssueAssociations=bd,i.initializeIssueAttachments=Ii,i.initializeIssueCommentAttachments=Oi,i.initializeIssueTypeAttachments=Di,i.initializeIssueTypeFieldValues=Fo,i.initializeIssueTypeFieldValuesAttachments=ko,i.initializeIssueTypeFields=vo,i.initializeIssueTypeFieldsAttachments=Ao,i.initializeIssueTypes=Bo,i.initializeIssueUpdates=Yo,i.initializeIssues=Zd,i.initializeLicences=iu,i.initializeOrganizationAccesses=lu,i.initializeOrganizations=uy,i.initializeProjectAccesses=nn,i.initializeProjectAttachments=Hu,i.initializeProjectFiles=il,i.initializeProjects=ty,i.initializeTeams=Al,i.initializeUsers=ru,i.isToday=ih,i.issueAssociationReducer=vd,i.issueAssociationSlice=yi,i.issueAttachmentReducer=zd,i.issueAttachmentSlice=bi,i.issueCommentAttachmentReducer=Wd,i.issueCommentAttachmentSlice=Pi,i.issueCommentReducer=Xd,i.issueCommentSlice=vi,i.issueReducer=so,i.issueSlice=qi,i.issueTypeAttachmentReducer=mo,i.issueTypeAttachmentSlice=zi,i.issueTypeFieldValuesAttachmentReducer=Uo,i.issueTypeFieldValuesAttachmentSlice=Hi,i.issueTypeFieldValuesReducer=Po,i.issueTypeFieldValuesSlice=Ui,i.issueTypeFieldsAttachmentReducer=bo,i.issueTypeFieldsAttachmentSlice=Vi,i.issueTypeFieldsReducer=qo,i.issueTypeFieldsSlice=Ni,i.issueTypeReducer=Wo,i.issueTypeSlice=Ki,i.issueUpdateReducer=tu,i.issueUpdateSlice=Qi,i.licenseReducer=au,i.licenseSlice=Zi,i.logOnlyOnce=lh,i.markAsDeleted=Bu,i.markForDeletion=Py,i.memoize=qt,i.moveDocument=yr,i.offline=R,i.onlyUniqueHashes=yh,i.onlyUniqueOfflineIds=Bn,i.organizationAccessReducer=Au,i.organizationAccessSlice=en,i.organizationReducer=Du,i.organizationSlice=rn,i.outboxReducer=Lu,i.outboxSlice=dn,i.overmapEnhancer=ef,i.overmapReducers=wl,i.overmapRootReducer=Jy,i.performRequest=bn,i.projectAccessReducer=Iu,i.projectAccessSlice=sn,i.projectAttachmentReducer=tl,i.projectAttachmentSlice=on,i.projectFileReducer=hl,i.projectFileSlice=ln,i.projectReducer=_u,i.projectSlice=cn,i.rehydratedReducer=ml,i.rehydratedSlice=mn,i.removeDocuments=Js,i.removeIssueType=Yi,i.removeUser=du,i.resetProjectFileObjectUrls=qy,i.resetStore=jl,i.restructureCreateSelectorWithArgs=S,i.saveActiveProjectFileBounds=ol,i.selectAccessToken=ep,i.selectActiveOrganizationAccess=QA,i.selectActiveProjectFileId=ky,i.selectActiveStatusLicenses=zA,i.selectAllDocumentAttachments=ur,i.selectAllProjectAttachments=Zu,i.selectAncestorIdsOfDocument=up,i.selectAssetAttachmentById=ea,i.selectAssetAttachmentMapping=Zn,i.selectAssetAttachments=xn,i.selectAssetById=ps,i.selectAssetProcedureById=rs,i.selectAssetProcedureFieldValues=Jt,i.selectAssetProcedureFieldValuesAttachmentById=Lh,i.selectAssetProcedureFieldValuesAttachments=ba,i.selectAssetProcedureFieldValuesAttachmentsByIds=Ia,i.selectAssetProcedureFieldValuesAttachmentsMapping=Ht,i.selectAssetProcedureFieldValuesById=Xt,i.selectAssetProcedureFieldValuesMapping=Ea,i.selectAssetProcedureFieldValuesOfAsset=Wh,i.selectAssetProcedureFields=Lt,i.selectAssetProcedureFieldsAttachmentById=wh,i.selectAssetProcedureFieldsAttachments=oa,i.selectAssetProcedureFieldsAttachmentsMapping=da,i.selectAssetProcedureFieldsById=Dh,i.selectAssetProcedureFieldsMapping=ya,i.selectAssetProcedureFieldsOfAssetProcedure=Ch,i.selectAssetProcedureInstanceById=ss,i.selectAssetProcedureInstances=ts,i.selectAssetProcedureInstancesByIds=Zh,i.selectAssetProcedureInstancesMapping=es,i.selectAssetProcedureInstancesOfAssetProcedure=za,i.selectAssetProcedureInstancesOfAssetType=Qh,i.selectAssetProcedures=$a,i.selectAssetProceduresByIds=am,i.selectAssetProceduresMapping=cs,i.selectAssetProceduresOfOrganization=nm,i.selectAssetStageById=nc,i.selectAssetStageCompletionById=Za,i.selectAssetStageCompletionMapping=Ts,i.selectAssetStageCompletions=lm,i.selectAssetStageCompletionsByIds=xa,i.selectAssetStages=ac,i.selectAssetStagesByIds=Ps,i.selectAssetStagesMappingOfAssetProcedure=Am,i.selectAssetStagesOfAssetProcedure=ym,i.selectAssetTypeAttachmentById=mc,i.selectAssetTypeAttachmentMapping=lc,i.selectAssetTypeAttachments=hc,i.selectAssetTypeById=Gs,i.selectAssetTypeFieldValues=zs,i.selectAssetTypeFieldValuesAttachmentById=$m,i.selectAssetTypeFieldValuesAttachments=kc,i.selectAssetTypeFieldValuesAttachmentsByIds=Cc,i.selectAssetTypeFieldValuesAttachmentsMapping=qs,i.selectAssetTypeFieldValuesById=Ds,i.selectAssetTypeFieldValuesMapping=Lc,i.selectAssetTypeFieldValuesOfAsset=Lm,i.selectAssetTypeFields=it,i.selectAssetTypeFieldsAttachmentById=Om,i.selectAssetTypeFieldsAttachments=Ic,i.selectAssetTypeFieldsAttachmentsMapping=bc,i.selectAssetTypeFieldsById=km,i.selectAssetTypeFieldsMapping=wc,i.selectAssetTypeFieldsOfAssetType=qm,i.selectAssetTypeValuesOfAssetType=Nm,i.selectAssetTypes=Xm,i.selectAssetTypesByIds=Qm,i.selectAssetTypesMapping=Bs,i.selectAssets=Ha,i.selectAssetsByIds=om,i.selectAssetsMapping=hs,i.selectAssetsOfAssetType=ms,i.selectAttachmentsOfAsset=ta,i.selectAttachmentsOfAssetProcedureFieldValues=Fa,i.selectAttachmentsOfAssetProcedureFields=_h,i.selectAttachmentsOfAssetType=pc,i.selectAttachmentsOfAssetTypeFieldValues=zc,i.selectAttachmentsOfAssetTypeFields=Pm,i.selectAttachmentsOfDocument=dp,i.selectAttachmentsOfFormRevision=Tp,i.selectAttachmentsOfFormSubmission=td,i.selectAttachmentsOfIssue=kd,i.selectAttachmentsOfIssueComment=Kp,i.selectAttachmentsOfIssueType=tA,i.selectAttachmentsOfIssueTypeFieldValues=Vo,i.selectAttachmentsOfIssueTypeFields=rA,i.selectAttachmentsOfProject=el,i.selectCategories=sp,i.selectCategoriesByIds=ip,i.selectCategoryById=Ws,i.selectCategoryMapping=Hs,i.selectCommentsOfIssue=Xp,i.selectConversation=gh,i.selectConversationMapping=zt,i.selectConversations=Sh,i.selectCurrentUser=Tt,i.selectDeletedRequests=Fy,i.selectDocumentAttachmentById=lr,i.selectDocumentAttachmentMapping=or,i.selectDocumentById=Sr,i.selectDocuments=fr,i.selectDocumentsByIds=op,i.selectDocumentsMapping=we,i.selectEmailDomains=Rr,i.selectEmailDomainsAsMapping=Fr,i.selectEmailDomainsOfOrganization=mp,i.selectFieldValuesOfAssetProcedureInstance=Kh,i.selectFormById=Xr,i.selectFormMapping=Jr,i.selectFormRevisionAttachmentsMapping=zr,i.selectFormRevisionById=Ip,i.selectFormRevisionMapping=dt,i.selectFormRevisions=Lr,i.selectFormRevisionsOfForm=Nr,i.selectFormSubmissionAttachemntsByIds=ed,i.selectFormSubmissionAttachmentsMapping=ci,i.selectFormSubmissionById=hi,i.selectFormSubmissions=li,i.selectFormSubmissionsMapping=ui,i.selectFormSubmissionsOfAsset=dd,i.selectFormSubmissionsOfForm=cd,i.selectFormSubmissionsOfIssue=rd,i.selectForms=vp,i.selectGeoImageById=Ai,i.selectGeoImageMapping=fd,i.selectGeoImages=Sd,i.selectGeoImagesOfProject=zp,i.selectIsImportingProjectFile=Cy,i.selectIsLoggedIn=tp,i.selectIssueAssociationById=Fd,i.selectIssueAssociationMapping=He,i.selectIssueAssociations=$p,i.selectIssueAssociationsOfAsset=Od,i.selectIssueAssociationsOfIssue=Pd,i.selectIssueAssociationsToIssue=Rd,i.selectIssueAttachmentById=Cd,i.selectIssueAttachmentMapping=qd,i.selectIssueAttachments=Md,i.selectIssueById=Ci,i.selectIssueCommentAttachmentById=Hd,i.selectIssueCommentAttachmentMapping=Ld,i.selectIssueCommentAttachments=Nd,i.selectIssueCommentById=ji,i.selectIssueCommentMapping=Jd,i.selectIssueCountOfCategory=np,i.selectIssueMapping=to,i.selectIssueTypeAttachmentById=ho,i.selectIssueTypeAttachmentMapping=uo,i.selectIssueTypeAttachments=lo,i.selectIssueTypeById=Ji,i.selectIssueTypeFieldValues=Gi,i.selectIssueTypeFieldValuesAttachmentById=wA,i.selectIssueTypeFieldValuesAttachments=zo,i.selectIssueTypeFieldValuesAttachmentsByIds=Do,i.selectIssueTypeFieldValuesAttachmentsMapping=Wi,i.selectIssueTypeFieldValuesById=Li,i.selectIssueTypeFieldValuesMapping=Ro,i.selectIssueTypeFieldValuesOfIssue=pA,i.selectIssueTypeFields=At,i.selectIssueTypeFieldsAttachmentById=dA,i.selectIssueTypeFieldsAttachments=To,i.selectIssueTypeFieldsAttachmentsMapping=go,i.selectIssueTypeFieldsById=FA,i.selectIssueTypeFieldsMapping=jo,i.selectIssueTypeFieldsOfIssueType=TA,i.selectIssueTypeMapping=No,i.selectIssueTypeValuesOfIssueType=IA,i.selectIssueTypes=Ho,i.selectIssueTypesByIds=EA,i.selectIssueTypesOfOrganization=jA,i.selectIssueUpdateMapping=xo,i.selectIssueUpdatesOfIssue=eu,i.selectIssuesByIds=Qp,i.selectIssuesOfIssueType=Xi,i.selectIssuesOfIssueTypeCount=qA,i.selectLatestAssetProcedureFieldsOfAssetProcedure=zh,i.selectLatestAssetTypeFieldsOfAssetType=Mm,i.selectLatestFormRevisionOfForm=Fp,i.selectLatestIssueTypeFieldsOfIssueType=bA,i.selectLatestRetryTime=Ry,i.selectLicense=CA,i.selectLicenseForProject=nu,i.selectLicenses=gt,i.selectLicensesForProjectsMapping=DA,i.selectLicensesOfOrganization=by,i.selectNumberOfAssetsOfAssetType=um,i.selectOrganizationAccessById=XA,i.selectOrganizationAccessForUser=ZA,i.selectOrganizationAccessUserMapping=pu,i.selectOrganizationAccesses=tn,i.selectOrganizationById=Sy,i.selectOrganizationUsersAsMapping=zu,i.selectOrganizationUsersIds=Cu,i.selectOrganizations=ku,i.selectOrganizationsMapping=Mu,i.selectOrganizationsWithAccess=gy,i.selectProjectAccessById=xA,i.selectProjectAccessForUser=ey,i.selectProjectAccessMapping=an,i.selectProjectAccessUserMapping=bu,i.selectProjectAccesses=Tu,i.selectProjectAttachmentById=xu,i.selectProjectAttachmentMapping=Qu,i.selectProjectById=dy,i.selectProjectFileById=My,i.selectProjectFileMapping=ul,i.selectProjectFiles=ll,i.selectProjectMapping=Ft,i.selectProjectUsersAsMapping=Eu,i.selectProjectUsersIds=wu,i.selectProjects=ry,i.selectProjectsOfOrganization=Ty,i.selectRehydrated=Vy,i.selectRootDocuments=lp,i.selectSortedOrganizationUsers=Iy,i.selectSortedProjectUsers=oy,i.selectStageMapping=st,i.selectTeamById=Me,i.selectTeams=Sn,i.selectTeamsByIds=Uy,i.selectTeamsMapping=fn,i.selectTeamsOfOrganization=$y,i.selectTeamsOfUser=By,i.selectUploadUrl=wr,i.selectUserById=YA,i.selectUsersByIds=JA,i.selectUsersMapping=bt,i.separateFilesFromValues=Qe,i.separateImageFromFields=Bf,i.setActiveProjectFileId=dl,i.setAsset=rm,i.setAssetAttachment=Jn,i.setAssetAttachments=bh,i.setAssetProcedure=sm,i.setAssetProcedureFieldValues=Nh,i.setAssetProcedureFieldValuesAttachment=Uh,i.setAssetProcedureFieldValuesAttachments=$h,i.setAssetProcedureFieldValuesMany=Hh,i.setAssetProcedureFields=jh,i.setAssetProcedureFieldsAttachment=Rh,i.setAssetProcedureFieldsAttachments=Ph,i.setAssetProcedureFieldsMany=qh,i.setAssetProcedureInstance=Jh,i.setAssetProcedureInstances=Xh,i.setAssetProcedures=im,i.setAssetStage=sc,i.setAssetStages=hm,i.setAssetType=Hm,i.setAssetTypeAttachment=dc,i.setAssetTypeAttachments=Sm,i.setAssetTypeFieldValues=Bm,i.setAssetTypeFieldValuesAttachment=zm,i.setAssetTypeFieldValuesAttachments=Dm,i.setAssetTypeFieldValuesMany=Gm,i.setAssetTypeFields=_m,i.setAssetTypeFieldsAttachment=bm,i.setAssetTypeFieldsAttachments=Im,i.setAssetTypeFieldsMany=wm,i.setAssetTypes=Wm,i.setAssets=dm,i.setConversation=Hn,i.setCurrentUser=WA,i.setDocumentAttachment=ar,i.setDocumentAttachments=cp,i.setDocuments=pr,i.setForm=Rp,i.setFormRevision=Ur,i.setFormRevisionAttachment=yp,i.setFormRevisionAttachments=fp,i.setFormSubmission=lt,i.setFormSubmissionAttachment=wp,i.setFormSubmissionAttachments=Ep,i.setFormSubmissions=Mp,i.setGeoImage=Ne,i.setGeoImages=hd,i.setIsImportingProjectFile=rl,i.setIssueAssociation=Vp,i.setIssueAssociations=Dp,i.setIssueAttachment=wd,i.setIssueAttachments=Gp,i.setIssueComment=_i,i.setIssueCommentAttachment=Ud,i.setIssueCommentAttachments=Hp,i.setIssueComments=Yd,i.setIssueType=Ke,i.setIssueTypeAttachment=ao,i.setIssueTypeAttachments=xp,i.setIssueTypeFieldValues=uA,i.setIssueTypeFieldValuesAttachment=PA,i.setIssueTypeFieldValuesAttachments=OA,i.setIssueTypeFieldValuesMany=lA,i.setIssueTypeFields=yA,i.setIssueTypeFieldsAttachment=iA,i.setIssueTypeFieldsAttachments=nA,i.setIssueTypeFieldsMany=fA,i.setIssueUpdate=MA,i.setLoggedIn=Jc,i.setOrganization=ly,i.setOrganizations=qu,i.setProfilePicture=KA,i.setProject=sy,i.setProjectAttachment=Ku,i.setProjectAttachments=Yu,i.setProjectFile=_y,i.setProjectFiles=wy,i.setProjects=Ru,i.setRehydrated=Dy,i.setTeam=qe,i.setTokens=Zm,i.setUploadUrl=_r,i.setUser=UA,i.setUsers=VA,i.shallowEqual=xl,i.slugify=ph,i.spacesToDashesLower=mh,i.teamReducer=fl,i.teamSlice=pn,i.toFileNameSafeString=hh,i.toOfflineIdRecord=$n,i.truncate=Ah,i.updateAsset=$e,i.updateAssetAttachment=Ih,i.updateAssetAttachments=Xn,i.updateAssetProcedure=Ue,i.updateAssetProcedureFieldValues=De,i.updateAssetProcedureFieldValuesAttachment=Bh,i.updateAssetProcedureFieldValuesAttachments=Ta,i.updateAssetProcedureFieldValuesMany=_a,i.updateAssetProcedureFields=pa,i.updateAssetProcedureFieldsAttachment=Oh,i.updateAssetProcedureFieldsAttachments=ca,i.updateAssetProcedureFieldsMany=Mh,i.updateAssetProcedureInstance=Ve,i.updateAssetProcedureInstances=Yh,i.updateAssetProcedures=em,i.updateAssetStage=Fs,i.updateAssetStageCompletion=Ja,i.updateAssetStageCompletions=Xa,i.updateAssetStages=tt,i.updateAssetType=Ge,i.updateAssetTypeAttachment=gm,i.updateAssetTypeAttachments=oc,i.updateAssetTypeFieldValues=Be,i.updateAssetTypeFieldValuesAttachment=Vm,i.updateAssetTypeFieldValuesAttachments=Mc,i.updateAssetTypeFieldValuesMany=Bc,i.updateAssetTypeFields=vc,i.updateAssetTypeFieldsAttachment=Fm,i.updateAssetTypeFieldsAttachments=gc,i.updateAssetTypeFieldsMany=Em,i.updateAssetTypes=Ym,i.updateAssets=cm,i.updateCategory=xc,i.updateConversation=Wn,i.updateDocumentAttachment=rp,i.updateDocumentAttachments=cr,i.updateDocuments=ye,i.updateForm=Op,i.updateFormRevisionAttachment=Sp,i.updateFormRevisionAttachments=kr,i.updateFormSubmission=ad,i.updateFormSubmissionAttachment=jp,i.updateFormSubmissionAttachments=xr,i.updateFormSubmissions=kp,i.updateGeoImage=Ad,i.updateGeoImages=Cp,i.updateIssue=pt,i.updateIssueAssociation=Id,i.updateIssueAssociations=Up,i.updateIssueAttachment=Lp,i.updateIssueAttachments=Ed,i.updateIssueCommentAttachment=Wp,i.updateIssueCommentAttachments=$d,i.updateIssueType=Lo,i.updateIssueTypeAttachment=eA,i.updateIssueTypeAttachments=co,i.updateIssueTypeFieldValues=We,i.updateIssueTypeFieldValuesAttachment=vA,i.updateIssueTypeFieldValuesAttachments=Co,i.updateIssueTypeFieldValuesMany=hA,i.updateIssueTypeFields=wo,i.updateIssueTypeFieldsAttachment=aA,i.updateIssueTypeFieldsAttachments=fo,i.updateIssueTypeFieldsMany=SA,i.updateLicense=pe,i.updateOrganization=Ay,i.updateOrganizationAccess=hu,i.updateOrganizations=py,i.updateProject=Pu,i.updateProjectAccess=fu,i.updateProjectAttachment=vy,i.updateProjectAttachments=Ju,i.updateProjectFile=hn,i.updateProjectFiles=jy,i.updateProjects=ay,i.updateTeam=An,i.updateUser=LA,i.updateUsers=GA,i.userReducer=ou,i.userSlice=xi,i.versioningReducer=gl,i.versioningSlice=Sl,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});