@overmap-ai/core 1.0.74-updates.1 → 1.0.74-updates.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/overmap-core.js +354 -325
  2. package/dist/overmap-core.umd.cjs +6 -6
  3. package/dist/store/slices/assetAttachmentSlice.d.ts +1 -1
  4. package/dist/store/slices/assetProcedureFieldValuesAttachmentSlice.d.ts +3 -3
  5. package/dist/store/slices/assetProcedureFieldValuesSlice.d.ts +4 -4
  6. package/dist/store/slices/assetProcedureFieldsAttachmentSlice.d.ts +2 -2
  7. package/dist/store/slices/assetProcedureFieldsSlice.d.ts +4 -4
  8. package/dist/store/slices/assetProcedureInstanceSlice.d.ts +4 -4
  9. package/dist/store/slices/assetProcedureSlice.d.ts +1 -1
  10. package/dist/store/slices/assetSlice.d.ts +4 -4
  11. package/dist/store/slices/assetStageCompletionSlice.d.ts +1 -1
  12. package/dist/store/slices/assetStageSlice.d.ts +4 -4
  13. package/dist/store/slices/assetTypeAttachmentSlice.d.ts +1 -1
  14. package/dist/store/slices/assetTypeFieldValuesAttachmentSlice.d.ts +3 -3
  15. package/dist/store/slices/assetTypeFieldValuesSlice.d.ts +4 -4
  16. package/dist/store/slices/assetTypeFieldsAttachmentSlice.d.ts +3 -3
  17. package/dist/store/slices/assetTypeFieldsSlice.d.ts +4 -4
  18. package/dist/store/slices/categorySlice.d.ts +1 -1
  19. package/dist/store/slices/documentAttachmentSlice.d.ts +1 -1
  20. package/dist/store/slices/documentSlice.d.ts +1 -1
  21. package/dist/store/slices/formRevisionAttachmentSlice.d.ts +2 -2
  22. package/dist/store/slices/formRevisionSlice.d.ts +4 -4
  23. package/dist/store/slices/formSlice.d.ts +2 -6
  24. package/dist/store/slices/formSubmissionAttachmentSlice.d.ts +2 -2
  25. package/dist/store/slices/formSubmissionSlice.d.ts +3 -3
  26. package/dist/store/slices/geoImageSlice.d.ts +2 -2
  27. package/dist/store/slices/issueAssociationSlice.d.ts +1 -1
  28. package/dist/store/slices/issueAttachmentSlice.d.ts +1 -1
  29. package/dist/store/slices/issueCommentAttachmentSlice.d.ts +1 -1
  30. package/dist/store/slices/issueCommentSlice.d.ts +1 -1
  31. package/dist/store/slices/issueSlice.d.ts +1 -1
  32. package/dist/store/slices/issueTypeAttachmentSlice.d.ts +1 -1
  33. package/dist/store/slices/issueTypeFieldValuesAttachmentSlice.d.ts +3 -3
  34. package/dist/store/slices/issueTypeFieldValuesSlice.d.ts +3 -3
  35. package/dist/store/slices/issueTypeFieldsAttachmentSlice.d.ts +3 -3
  36. package/dist/store/slices/issueTypeFieldsSlice.d.ts +5 -5
  37. package/dist/store/slices/issueTypeSlice.d.ts +2 -2
  38. package/dist/store/slices/licenseSlice.d.ts +1 -1
  39. package/dist/store/slices/organizationAccessSlice.d.ts +1 -1
  40. package/dist/store/slices/organizationSlice.d.ts +3 -3
  41. package/dist/store/slices/projectAccessSlice.d.ts +1 -1
  42. package/dist/store/slices/projectAttachmentSlice.d.ts +1 -1
  43. package/dist/store/slices/projectFileSlice.d.ts +2 -2
  44. package/dist/store/slices/projectSlice.d.ts +2 -2
  45. package/dist/store/slices/teamSlice.d.ts +2 -2
  46. package/dist/store/slices/userSlice.d.ts +2 -2
  47. package/dist/typings/models/assets.d.ts +2 -2
  48. package/dist/typings/models/base.d.ts +1 -1
  49. package/dist/typings/models/geo.d.ts +1 -4
  50. package/package.json +1 -1
@@ -1,15 +1,15 @@
1
- (function(i,_){typeof exports=="object"&&typeof module<"u"?_(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"],_):(i=typeof globalThis<"u"?globalThis:i||self,_(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,_,l,Vl,Ul,Pn,$l,Bl,Pe,Gl,Ll,Nl,Hl){"use strict";var yS=Object.defineProperty;var fS=(i,_,l)=>_ in i?yS(i,_,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[_]=l;var f=(i,_,l)=>fS(i,typeof _!="symbol"?_+"":_,l);var Dl;const On=Object.freeze([]),vn=Object.freeze({});var Ot=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(Ot||{}),vt=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(vt||{}),o=(t=>(t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.DELETE="DELETE",t))(o||{}),_n=(t=>(t.Issue="issue",t.Asset="asset",t.AssetType="asset_type",t.Project="project",t.Document="document",t))(_n||{}),_t=(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))(_t||{}),wt=(t=>(t[t.BACKLOG=0]="BACKLOG",t[t.SELECTED=2]="SELECTED",t[t.DONE=4]="DONE",t))(wt||{}),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||{}),wn=(t=>(t.COMPLETED="checkout.completed",t.CLOSED="checkout.closed",t))(wn||{}),En=(t=>(t[t.PRO=0]="PRO",t))(En||{}),jn=(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))(jn||{});const Wl=wt.BACKLOG,Kl=_t.MEDIUM,qn=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:{}})}}Dl=Symbol.toStringTag;class Mn{constructor(){f(this,Dl,"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 Yl=t=>({type:"Point",coordinates:t}),Jl=t=>({type:"MultiPoint",coordinates:t}),Xl=(t,e)=>t[0]===e[0]&&t[1]===e[1];let Et=!1;["true","1"].includes("".toLowerCase())&&(Et=!0);function Ql(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 jt(t){const e={};return function(){const s=Array.prototype.slice.call(arguments);return s in e?(Et&&console.debug(`Memoization debug: Using memorized return value for ${t.toString()}(`,s,")"),e[s]):(Et&&console.debug(`Memoization debug: Cache miss! Memoizing ${t.toString()}(`,s,")"),e[s]=t.apply(this,s))}}function Zl(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?On:t,Oe=t=>Object.keys(t).length===0?vn:t,Cn=jt(t=>{if(!t)return"";const e=new Date(t),s=e.getFullYear()===qt.getFullYear(),n={day:"numeric",month:"short"};return s||(n.year="numeric"),e.toLocaleDateString([],n)}),xl=new Intl.RelativeTimeFormat([],{style:"long",numeric:"auto"}),eh=1e3*86400,qt=new Date,th=t=>new Date(t).toDateString()===qt.toDateString(),sh=jt((t,e,s)=>{const n=Math.round((new Date(t).getTime()-qt.getTime())/eh);return n<e||n>s?Cn(t):xl.format(n,"days")});function ih(t){return new Uint8Array(t).reduce((s,n)=>s+n.toString(16).padStart(2,"0"),"")}const Mt=async(t,e)=>{e||(e=await ve(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 ve(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=ih(c);e(r)})},n.readAsArrayBuffer(t)})}function nh(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 kn(t,e){return new File([t],e,{type:t.type})}function ah(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 ch=async t=>{const e={};for(const s of t){const n=await ve(s);e[n]={sha1:n,extension:s.name.split(".").pop()||"",file_type:s.type,size:s.size}}return Object.values(e)},zn=async t=>(await fetch(t)).blob(),rh=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 dh(t){const e=new Blob([t]);Vl.saveAs(e,t.name)}const Dn={};function uh(t,e,s,...n){const a=Dn[t];let c=!1;a?a[e]||(a[e]=!0,c=!0):(Dn[t]={[e]:!0},c=!0),c&&console[s](...n)}const Vn=["created_at","updated_at","index","revision"];function R(t){return{...t,uuid:_.v4()}}function Un(t){const e={};for(const s of t)e[s.uuid]=s;return e}function oh(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 lh(t){return t.toLowerCase().replace(" ","-")}function hh(t,e=!1){return t.normalize("NFKD").toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/[-\s]+/g,e?"_":"-")}function mh(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 $n(t,e,s){return s.findIndex(n=>n.uuid===t.uuid)===e}function ph(t,e,s){return s.findIndex(n=>n.file_sha1===t.file_sha1)===e}const Ah=/^.+@.+\..+$/;function v(t){const e={...t};for(const s of[...Vn,"created_by"])s in e&&delete e[s];return e}const ke=I(t=>t.uuid),Bn=ke.getInitialState({}),Ct=l.createSlice({name:"agents",initialState:Bn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Bn)),reducers:{initializeConversations:ke.initialize,addConversation:ke.addOne,setConversation:ke.setOne,updateConversation:ke.updateOne}}),{initializeConversations:Gn,addConversation:Ln,setConversation:Nn,updateConversation:Hn}=Ct.actions,kt=t=>t.agentsReducer.instances,yh=l.createSelector([kt],t=>Object.values(t)),fh=S(l.createSelector([kt,(t,e)=>e],(t,e)=>t[e])),Wn=Ct.reducer,k=I(t=>t.uuid),Kn=k.getInitialState({}),zt=l.createSlice({name:"assetAttachments",initialState:Kn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Kn)),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:Dt,addAssetAttachment:Sh,addAssetAttachments:Vt,setAssetAttachment:Yn,setAssetAttachments:gh,updateAssetAttachment:Th,updateAssetAttachments:Jn,deleteAssetAttachment:Xn,deleteAssetAttachments:Ut}=zt.actions,Qn=t=>t.assetAttachmentReducer.instances,Zn=l.createSelector([Qn],t=>Object.values(t)),xn=t=>e=>e.assetAttachmentReducer.instances[t],ea=S(l.createSelector([Zn,(t,e)=>e],(t,e)=>g(t.filter(({asset:s})=>e===s)))),ta=zt.reducer,z=I(t=>t.uuid),sa=z.getInitialState({}),$t=l.createSlice({name:"assetProcedureFieldsAttachments",initialState:sa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sa)),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:ia,addAssetProcedureFieldsAttachment:bh,addAssetProcedureFieldsAttachments:na,setAssetProcedureFieldsAttachment:Ih,setAssetProcedureFieldsAttachments:Fh,updateAssetProcedureFieldsAttachment:Rh,updateAssetProcedureFieldsAttachments:aa,deleteAssetProcedureFieldsAttachment:Ph,deleteAssetProcedureFieldsAttachments:ca}=$t.actions,ra=t=>t.assetProcedureFieldsAttachmentReducer.instances,da=l.createSelector([ra],t=>Object.values(t)),Oh=S(l.createSelector([da,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),vh=t=>e=>e.assetProcedureFieldsAttachmentReducer.instances[t],ua=$t.reducer,D=I(t=>t.uuid),oa=D.getInitialState({}),Bt=l.createSlice({name:"assetProcedureFields",initialState:oa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,oa)),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:la,addAssetProcedureFields:ha,addAssetProcedureFieldsMany:_h,setAssetProcedureFields:wh,setAssetProcedureFieldsMany:Eh,updateAssetProcedureFields:ma,updateAssetProcedureFieldsMany:jh,deleteAssetProcedureFields:pa,deleteAssetProcedureFieldsMany:qh}=Bt.actions,Aa=t=>t.assetProcedureFieldsReducer.instances,Gt=l.createSelector([Aa],t=>Object.values(t)),Mh=S(l.createSelector([Gt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),Ch=S(l.createSelector([Gt,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_procedure===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),kh=t=>e=>e.assetProcedureFieldsReducer.instances[t],ya=Bt.reducer,V=I(t=>t.uuid),fa=V.getInitialState({}),Lt=l.createSlice({name:"assetProcedureFieldValuesAttachments",initialState:fa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,fa)),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:Sa,addAssetProcedureFieldValuesAttachment:zh,addAssetProcedureFieldValuesAttachments:Ze,setAssetProcedureFieldValuesAttachment:Dh,setAssetProcedureFieldValuesAttachments:Vh,updateAssetProcedureFieldValuesAttachment:Uh,updateAssetProcedureFieldValuesAttachments:ga,deleteAssetProcedureFieldValuesAttachment:$h,deleteAssetProcedureFieldValuesAttachments:xe}=Lt.actions,Nt=t=>t.assetProcedureFieldValuesAttachmentReducer.instances,Ta=l.createSelector([Nt],t=>Object.values(t)),Bh=t=>e=>e.assetProcedureFieldValuesAttachmentReducer.instances[t],ba=S(l.createSelector([Nt,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.uuid)))})),Ia=S(l.createSelector([Ta,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),Fa=Lt.reducer,U=I(t=>t.uuid),Ra=U.getInitialState({}),Ht=l.createSlice({name:"assetProcedureFieldValues",initialState:Ra,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ra)),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:Pa,addAssetProcedureFieldValues:Wt,addAssetProcedureFieldValuesMany:Oa,setAssetProcedureFieldValues:Gh,setAssetProcedureFieldValuesMany:Lh,updateAssetProcedureFieldValues:ze,updateAssetProcedureFieldValuesMany:va,deleteAssetProcedureFieldValues:Kt,deleteAssetProcedureFieldValuesMany:_a}=Ht.actions,wa=t=>t.assetProcedureFieldValuesReducer.instances,Yt=l.createSelector([wa],t=>Object.values(t)),Nh=S(l.createSelector([Yt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),Hh=S(l.createSelector([Yt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure_instance===e)))),Jt=t=>e=>e.assetProcedureFieldValuesReducer.instances[t],Ea=Ht.reducer,$=I(t=>t.uuid),ja=$.getInitialState({}),Xt=l.createSlice({name:"assetProcedureInstances",initialState:ja,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ja)),reducers:{initializeAssetProcedureInstances:$.initialize,addAssetProcedureInstance:$.addOne,addAssetProcedureInstances:$.addMany,setAssetProcedureInstance:$.setOne,setAssetProcedureInstances:$.setMany,updateAssetProcedureInstance:$.updateOne,updateAssetProcedureInstances:$.updateMany,deleteAssetProcedureInstance:$.deleteOne,deleteAssetProcedureInstances:$.deleteMany}}),{initializeAssetProcedureInstances:qa,addAssetProcedureInstance:Qt,addAssetProcedureInstances:Ma,updateAssetProcedureInstance:De,updateAssetProcedureInstances:Wh,deleteAssetProcedureInstance:Zt,deleteAssetProcedureInstances:Ca,setAssetProcedureInstance:Kh,setAssetProcedureInstances:Yh}=Xt.actions,xt=t=>t.assetProcedureInstanceReducer.instances,es=l.createSelector([xt],t=>Object.values(t)),ka=S(l.createSelector([es,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),Jh=S(l.createSelector([es,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),ts=t=>e=>e.assetProcedureInstanceReducer.instances[t],Xh=S(l.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)})),za=Xt.reducer,B=I(t=>t.uuid),Da=B.getInitialState({}),ss=l.createSlice({name:"assetProcedures",initialState:Da,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Da)),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:Va,addAssetProcedure:is,addAssetProcedures:Qh,updateAssetProcedure:Ve,updateAssetProcedures:Zh,deleteAssetProcedure:ns,deleteAssetProcedures:xh,setAssetProcedure:em,setAssetProcedures:tm}=ss.actions,as=t=>t.assetProcedureReducer.instances,Ua=l.createSelector([as],t=>Object.values(t)),sm=S(l.createSelector([Ua,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),cs=t=>e=>e.assetProcedureReducer.instances[t],im=S(l.createSelector([as,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return g(s)})),$a=ss.reducer,G=I(t=>t.uuid),Ba=G.getInitialState({}),rs=l.createSlice({name:"assets",initialState:Ba,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ba)),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:Ga,addAsset:ds,addAssets:us,updateAsset:Ue,updateAssets:nm,deleteAsset:os,deleteAssets:La,setAsset:am,setAssets:cm}=rs.actions,ls=t=>t.assetReducer.instances,Na=l.createSelector([ls],t=>g(Object.values(t))),hs=S(l.createSelector([Na,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),ms=t=>e=>e.assetReducer.instances[t],rm=S(l.createSelector([ls,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return g(s)})),dm=t=>e=>hs(t)(e).length,Ha=rs.reducer,Ae=I(t=>t.uuid),Wa=Ae.getInitialState({}),ps=l.createSlice({name:"assetStageCompletions",initialState:Wa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Wa)),reducers:{initializeAssetStageCompletions:Ae.initialize,addAssetStageCompletion:Ae.addOne,addAssetStageCompletions:Ae.addMany,updateAssetStageCompletion:Ae.updateOne,updateAssetStageCompletions:Ae.updateMany,deleteAssetStageCompletion:Ae.deleteOne,deleteAssetStageCompletions:Ae.deleteMany}}),{initializeAssetStageCompletions:Ka,addAssetStageCompletion:As,addAssetStageCompletions:ys,updateAssetStageCompletion:Ya,updateAssetStageCompletions:Ja,deleteAssetStageCompletion:fs,deleteAssetStageCompletions:Ss}=ps.actions,Xa=ps.reducer,gs=t=>t.assetStageCompletionReducer.instances,um=l.createSelector([gs],t=>Object.values(t)),Qa=t=>e=>e.assetStageCompletionReducer.instances[t],Za=S(l.createSelector([gs,(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),xa=L.getInitialState({}),Ts=l.createSlice({name:"assetStages",initialState:xa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,xa)),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:ec,setAssetStage:tc,setAssetStages:om,addAssetStage:lm,addAssetStages:bs,updateAssetStage:Is,updateAssetStages:et,deleteAssetStage:hm,deleteAssetStages:Fs}=Ts.actions,sc=Ts.reducer,tt=t=>t.assetStageReducer.instances,ic=t=>e=>e.assetStageReducer.instances[t],nc=l.createSelector([tt],t=>Object.values(t)),mm=S(l.createSelector([tt,(t,e)=>e],(t,e)=>{const s={};for(const[n,a]of Object.entries(t))a.asset_procedure===e&&(s[n]=a);return Oe(s)})),pm=S(l.createSelector([nc,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),Rs=S(l.createSelector([tt,(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),ac=N.getInitialState({}),Ps=l.createSlice({name:"assetTypeAttachments",initialState:ac,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ac)),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:cc,addAssetTypeAttachment:Am,addAssetTypeAttachments:Os,setAssetTypeAttachment:rc,setAssetTypeAttachments:ym,updateAssetTypeAttachment:fm,updateAssetTypeAttachments:dc,deleteAssetTypeAttachment:uc,deleteAssetTypeAttachments:vs}=Ps.actions,oc=t=>t.assetTypeAttachmentReducer.instances,lc=l.createSelector([oc],t=>Object.values(t)),hc=t=>e=>e.assetTypeAttachmentReducer.instances[t],mc=S(l.createSelector([lc,(t,e)=>e],(t,e)=>g(t.filter(({asset_type:s})=>e===s)))),pc=Ps.reducer,H=I(t=>t.uuid),Ac=H.getInitialState({}),_s=l.createSlice({name:"assetTypeFieldsAttachments",initialState:Ac,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ac)),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:yc,addAssetTypeFieldsAttachment:Sm,addAssetTypeFieldsAttachments:fc,setAssetTypeFieldsAttachment:gm,setAssetTypeFieldsAttachments:Tm,updateAssetTypeFieldsAttachment:bm,updateAssetTypeFieldsAttachments:Sc,deleteAssetTypeFieldsAttachment:Im,deleteAssetTypeFieldsAttachments:gc}=_s.actions,Tc=t=>t.assetTypeFieldsAttachmentReducer.instances,bc=l.createSelector([Tc],t=>Object.values(t)),Fm=S(l.createSelector([bc,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),Rm=t=>e=>e.assetTypeFieldsAttachmentReducer.instances[t],Ic=_s.reducer,W=I(t=>t.uuid),Fc=W.getInitialState({}),ws=l.createSlice({name:"assetTypeFields",initialState:Fc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Fc)),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:Rc,addAssetTypeFields:Pc,addAssetTypeFieldsMany:Pm,setAssetTypeFields:Om,setAssetTypeFieldsMany:vm,updateAssetTypeFields:Oc,updateAssetTypeFieldsMany:_m,deleteAssetTypeFields:vc,deleteAssetTypeFieldsMany:wm}=ws.actions,_c=t=>t.assetTypeFieldsReducer.instances,st=l.createSelector([_c],t=>Object.values(t)),Em=S(l.createSelector([st,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),jm=S(l.createSelector([st,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),qm=t=>e=>e.assetTypeFieldsReducer.instances[t],wc=ws.reducer,K=I(t=>t.uuid),Ec=K.getInitialState({}),Es=l.createSlice({name:"assetTypeFieldValuesAttachments",initialState:Ec,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ec)),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:jc,addAssetTypeFieldValuesAttachment:Mm,addAssetTypeFieldValuesAttachments:it,setAssetTypeFieldValuesAttachment:Cm,setAssetTypeFieldValuesAttachments:km,updateAssetTypeFieldValuesAttachment:zm,updateAssetTypeFieldValuesAttachments:qc,deleteAssetTypeFieldValuesAttachment:Dm,deleteAssetTypeFieldValuesAttachments:nt}=Es.actions,js=t=>t.assetTypeFieldValuesAttachmentReducer.instances,Mc=l.createSelector([js],t=>Object.values(t)),Vm=t=>e=>e.assetTypeFieldValuesAttachmentReducer.instances[t],Cc=S(l.createSelector([js,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.uuid)))})),kc=S(l.createSelector([Mc,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),zc=Es.reducer,Y=I(t=>t.uuid),Dc=Y.getInitialState({}),qs=l.createSlice({name:"assetTypeFieldValues",initialState:Dc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dc)),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:Vc,addAssetTypeFieldValues:Ms,addAssetTypeFieldValuesMany:Uc,setAssetTypeFieldValues:Um,setAssetTypeFieldValuesMany:$m,updateAssetTypeFieldValues:$e,updateAssetTypeFieldValuesMany:$c,deleteAssetTypeFieldValues:Cs,deleteAssetTypeFieldValuesMany:Bc}=qs.actions,Gc=t=>t.assetTypeFieldValuesReducer.instances,ks=l.createSelector([Gc],t=>Object.values(t)),Bm=S(l.createSelector([ks,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),Gm=S(l.createSelector([st,ks,(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)))})),zs=t=>e=>e.assetTypeFieldValuesReducer.instances[t],Lc=qs.reducer,J=I(t=>t.uuid),Nc=J.getInitialState({}),Ds=l.createSlice({name:"assetTypes",initialState:Nc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Nc)),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:Hc,setAssetType:Lm,setAssetTypes:Nm,addAssetType:Vs,addAssetTypes:Hm,updateAssetType:Be,updateAssetTypes:Wm,deleteAssetType:Us,deleteAssetTypes:Km}=Ds.actions,$s=t=>t.assetTypeReducer.instances,Ym=l.createSelector([$s],t=>Object.values(t)),Bs=t=>e=>e.assetTypeReducer.instances[t],Jm=S(l.createSelector([$s,(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)})),Wc=Ds.reducer,Kc={accessToken:"",refreshToken:"",isLoggedIn:!1},at=l.createSlice({name:"auth",initialState:Kc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Kc)),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||at.caseReducers.clearTokens(t),t.isLoggedIn=e.payload}}}),{setTokens:Xm,clearTokens:Qm,setLoggedIn:Yc}=at.actions,Zm=t=>t.authReducer.accessToken,xm=t=>t.authReducer.isLoggedIn,Jc=at.reducer,Ge=I(t=>t.uuid),Xc=Ge.getInitialState({}),Gs=l.createSlice({name:"categories",initialState:Xc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Xc)),reducers:{initializeCategories:Ge.initialize,addCategory:Ge.addOne,updateCategory:Ge.updateOne,deleteCategory:Ge.deleteOne}}),{initializeCategories:Qc,addCategory:Ls,updateCategory:Zc,deleteCategory:xc}=Gs.actions,Ns=t=>t.categoryReducer.instances,ep=l.createSelector([Ns],t=>Object.values(t)),Hs=t=>e=>e.categoryReducer.instances[t],tp=S(l.createSelector([Ns,(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)})),sp=t=>e=>Object.values(e.issueReducer.instances).filter(s=>s.category===t).length,er=Gs.reducer,X=I(t=>t.uuid),tr=X.getInitialState({}),Ws=l.createSlice({name:"documentAttachments",initialState:tr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,tr)),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:sr,addDocumentAttachment:ip,addDocumentAttachments:ir,setDocumentAttachment:nr,setDocumentAttachments:np,updateDocumentAttachment:ap,updateDocumentAttachments:ar,deleteDocumentAttachment:cr,deleteDocumentAttachments:rr}=Ws.actions,dr=t=>t.documentAttachmentReducer.instances,ur=l.createSelector([dr],t=>Object.values(t)),or=t=>e=>e.documentAttachmentReducer.instances[t],cp=S(l.createSelector([ur,(t,e)=>e],(t,e)=>g(t.filter(({document:s})=>e===s)))),lr=Ws.reducer,hr={documents:{}},Ks=l.createSlice({name:"documents",initialState:hr,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,hr)}),reducers:{setDocuments:(t,e)=>{if(e.payload.filter($n).length!==e.payload.length)throw new Error("Tried to use setIssues reducer with duplicate ID's");t.documents=Un(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:mr,addDocuments:pr,updateDocuments:ye,moveDocument:Ar,removeDocuments:Ys}=Ks.actions,_e=t=>t.documentsReducer.documents,yr=l.createSelector([_e],t=>Object.values(t)),fr=t=>e=>e.documentsReducer.documents[t],rp=S(l.createSelector([_e,(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)})),dp=S(l.createSelector([_e,(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)})),up=l.createSelector([yr],t=>g(t.filter(e=>!e.parent_document))),Sr=Ks.reducer,ct=I(t=>t.uuid),op=ct.getInitialState({}),Js=l.createSlice({name:"emailDomains",initialState:op,reducers:{initializeEmailDomains:ct.initialize,addEmailDomain:ct.addOne,deleteEmailDomain:ct.deleteOne}}),{initializeEmailDomains:gr,addEmailDomain:Tr,deleteEmailDomain:br}=Js.actions,Ir=t=>t.emailDomainsReducer.instances,Fr=l.createSelector([Ir],t=>Object.values(t)),lp=S(l.createSelector([Fr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Rr=Js.reducer,Pr={s3Urls:{}},Or=1e3*60*60,hp=Or*24*7,Xs=l.createSlice({name:"file",initialState:Pr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Pr)),reducers:{setUploadUrl:(t,e)=>{const{url:s,fields:n,sha1:a}=e.payload,c=new Date,r=new Date(c.getTime()+hp);t.s3Urls[a]={url:s,fields:n,exp:r.getTime()}}}}),{setUploadUrl:vr}=Xs.actions,_r=t=>e=>{const s=e.fileReducer.s3Urls[t];if(!s)return;const n=new Date().getTime();if(!((s.exp??n)-n<Or))return s},wr=Xs.reducer,Q=I(t=>t.uuid),Er=Q.getInitialState({}),Qs=l.createSlice({name:"formRevisionAttachments",initialState:Er,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Er)),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:jr,addFormRevisionAttachment:mp,addFormRevisionAttachments:qr,setFormRevisionAttachment:pp,setFormRevisionAttachments:Ap,updateFormRevisionAttachment:yp,updateFormRevisionAttachments:Mr,deleteFormRevisionAttachment:fp,deleteFormRevisionAttachments:Cr}=Qs.actions,kr=t=>t.formRevisionAttachmentReducer.instances,Sp=S(l.createSelector([kr,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_revision===e)))),zr=Qs.reducer,gp=(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.uuid),Dr=fe.getInitialState({}),Zs=l.createSlice({name:"formRevisions",initialState:Dr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dr)),reducers:{initializeFormRevisions:fe.initialize,setFormRevision:fe.setOne,addFormRevision:fe.addOne,addFormRevisions:fe.addMany,deleteFormRevision:fe.deleteOne,deleteFormRevisions:fe.deleteMany}}),{setFormRevision:Vr,initializeFormRevisions:Ur,addFormRevision:xs,addFormRevisions:$r,deleteFormRevision:ei,deleteFormRevisions:Br}=Zs.actions,rt=t=>t.formRevisionReducer.instances,Gr=l.createSelector([rt],t=>Object.values(t)),Tp=t=>e=>e.formRevisionReducer.instances[t],bp=S(l.createSelector([rt,(t,e)=>e],(t,e)=>{const s=Object.values(t).filter(c=>c.form===e);if(s.length===0)return;const a=s.sort(gp)[s.length-1];return t[a.uuid]})),Lr=S(l.createSelector([Gr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.form===e)))),Nr=Zs.reducer,Se=I(t=>t.uuid),Hr=Se.getInitialState({}),ti=l.createSlice({name:"forms",initialState:Hr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Hr)),reducers:{initializeForms:Se.initialize,setForm:Se.setOne,addForm:Se.addOne,addForms:Se.addMany,updateForm:Se.updateOne,deleteForm:Se.deleteOne}}),{initializeForms:Wr,setForm:Ip,addForm:si,addForms:Fp,updateForm:Rp,deleteForm:ii}=ti.actions,Kr=ti.reducer,Yr=t=>t.formReducer.instances,Pp=l.createSelector([Yr],t=>Object.values(t)),Jr=t=>e=>e.formReducer.instances[t],Z=I(t=>t.uuid),Xr=Z.getInitialState({}),ni=l.createSlice({name:"formSubmissionAttachments",initialState:Xr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Xr)),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:Qr,addFormSubmissionAttachment:Op,addFormSubmissionAttachments:dt,setFormSubmissionAttachment:vp,setFormSubmissionAttachments:_p,updateFormSubmissionAttachment:wp,updateFormSubmissionAttachments:Zr,deleteFormSubmissionAttachment:Ep,deleteFormSubmissionAttachments:ut}=ni.actions,ai=t=>t.formSubmissionAttachmentReducer.instances,xr=S(l.createSelector([ai,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.uuid)))})),ed=S(l.createSelector([ai,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_submission===e)))),td=ni.reducer,x=I(t=>t.uuid),sd=x.getInitialState({}),ci=l.createSlice({name:"formSubmissions",initialState:sd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sd)),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:id,setFormSubmission:ot,setFormSubmissions:jp,addFormSubmission:ri,addFormSubmissions:lt,updateFormSubmission:nd,updateFormSubmissions:qp,deleteFormSubmission:di,deleteFormSubmissions:ht}=ci.actions,ui=t=>t.formSubmissionReducer.instances,oi=l.createSelector([ui],t=>Object.values(t)),li=t=>e=>e.formSubmissionReducer.instances[t],ad=S(l.createSelector([ui,rt,(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))})),cd=S(l.createSelector([oi,(t,e)=>e],(t,e)=>Object.values(t).filter(s=>s.issue===e))),rd=S(l.createSelector([oi,(t,e)=>e],(t,e)=>t.filter(s=>s.asset===e))),dd=ci.reducer,ee=I(t=>t.uuid),ud=ee.getInitialState({}),hi=l.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:od,setGeoImage:Le,setGeoImages:ld,addGeoImage:hd,addGeoImages:md,updateGeoImage:pd,updateGeoImages:Mp,deleteGeoImage:mi,deleteGeoImages:Ad}=hi.actions,yd=t=>t.geoImageReducer.instances,fd=l.createSelector([yd],t=>Object.values(t)),pi=t=>e=>e.geoImageReducer.instances[t],Cp=S(l.createSelector([fd,(t,e)=>e],(t,e)=>g(t.filter(s=>s.project===e)))),Sd=hi.reducer,te=I(t=>t.uuid),gd=te.getInitialState({}),Ai=l.createSlice({name:"issueAssociations",initialState:gd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,gd)),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:Td,setIssueAssociations:kp,setIssueAssociation:zp,updateIssueAssociation:bd,updateIssueAssociations:Dp,addIssueAssociation:yi,addIssueAssociations:fi,deleteIssueAssociation:Si,deleteIssueAssociations:gi}=Ai.actions,Ne=t=>t.issueAssociationReducer.instances,Vp=l.createSelector([Ne],t=>Object.values(t)),Id=t=>e=>e.issueAssociationReducer.instances[t],Fd=S(l.createSelector([Ne,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.associated_issue===e)))),Rd=S(l.createSelector([Ne,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Pd=S(l.createSelector([Ne,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.asset===e)))),Od=Ai.reducer,se=I(t=>t.uuid),vd=se.getInitialState({}),Ti=l.createSlice({name:"issueAttachments",initialState:vd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,vd)),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:bi,addIssueAttachment:Up,addIssueAttachments:Ii,setIssueAttachment:_d,setIssueAttachments:$p,updateIssueAttachment:Bp,updateIssueAttachments:wd,deleteIssueAttachment:Ed,deleteIssueAttachments:Fi}=Ti.actions,jd=t=>t.issueAttachmentReducer.instances,qd=l.createSelector([jd],t=>Object.values(t)),Md=S(l.createSelector([qd,(t,e)=>e],(t,e)=>g(t.filter(({issue:s})=>e===s)))),Cd=t=>e=>e.issueAttachmentReducer.instances[t],kd=Ti.reducer,ie=I(t=>t.uuid),zd=ie.getInitialState({}),Ri=l.createSlice({name:"issueCommentAttachments",initialState:zd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,zd)),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:Pi,addIssueCommentAttachment:Gp,addIssueCommentAttachments:Dd,setIssueCommentAttachment:Vd,setIssueCommentAttachments:Lp,updateIssueCommentAttachment:Np,updateIssueCommentAttachments:Ud,deleteIssueCommentAttachment:$d,deleteIssueCommentAttachments:Bd}=Ri.actions,Gd=t=>t.issueCommentAttachmentReducer.instances,Ld=l.createSelector([Gd],t=>Object.values(t)),Nd=t=>e=>e.issueCommentAttachmentReducer.instances[t],Hp=S(l.createSelector([Ld,(t,e)=>e],(t,e)=>g(t.filter(({issue_comment:s})=>e===s)))),Hd=Ri.reducer,ge=I(t=>t.uuid),Wd=ge.getInitialState({}),Oi=l.createSlice({name:"issueComments",initialState:Wd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Wd)),reducers:{addIssueComment:ge.addOne,addIssueComments:ge.addMany,setIssueComment:ge.setOne,setIssueComments:ge.setMany,deleteIssueComment:ge.deleteOne,deleteIssueComments:ge.deleteMany}}),{setIssueComments:Kd,setIssueComment:vi,addIssueComment:_i,addIssueComments:Wp,deleteIssueComment:wi,deleteIssueComments:Kp}=Oi.actions,Yd=t=>t.issueCommentReducer.instances,Ei=t=>e=>e.issueCommentReducer.instances[t],Yp=S(l.createSelector([Yd,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Jd=Oi.reducer,Te=I(t=>t.uuid),Xd=Te.getInitialState({}),ji=l.createSlice({name:"issues",initialState:Xd,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Xd)}),reducers:{initializeIssues:Te.initialize,addIssue:Te.addOne,addIssues:Te.addMany,updateIssue:Te.updateOne,deleteIssue:Te.deleteOne,deleteIssues:Te.deleteMany}}),{initializeIssues:Qd,addIssue:qi,addIssues:Zd,updateIssue:mt,deleteIssue:Mi,deleteIssues:xd}=ji.actions,eu=t=>t.issueReducer.instances,Ci=t=>e=>e.issueReducer.instances[t],Jp=S(l.createSelector([eu,(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)})),tu=ji.reducer,ne=I(t=>t.uuid),su=ne.getInitialState({}),ki=l.createSlice({name:"issueTypeAttachments",initialState:su,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,su)),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:zi,addIssueTypeAttachment:Xp,addIssueTypeAttachments:iu,setIssueTypeAttachment:nu,setIssueTypeAttachments:Qp,updateIssueTypeAttachment:Zp,updateIssueTypeAttachments:au,deleteIssueTypeAttachment:cu,deleteIssueTypeAttachments:ru}=ki.actions,du=t=>t.issueTypeAttachmentReducer.instances,uu=l.createSelector([du],t=>Object.values(t)),ou=t=>e=>e.issueTypeAttachmentReducer.instances[t],xp=S(l.createSelector([uu,(t,e)=>e],(t,e)=>g(t.filter(({issue_type:s})=>e===s)))),lu=ki.reducer,ae=I(t=>t.uuid),hu=ae.getInitialState({}),Di=l.createSlice({name:"issueTypeFieldsAttachments",initialState:hu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,hu)),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:mu,addIssueTypeFieldsAttachment:eA,addIssueTypeFieldsAttachments:pu,setIssueTypeFieldsAttachment:tA,setIssueTypeFieldsAttachments:sA,updateIssueTypeFieldsAttachment:iA,updateIssueTypeFieldsAttachments:Au,deleteIssueTypeFieldsAttachment:nA,deleteIssueTypeFieldsAttachments:yu}=Di.actions,fu=t=>t.issueTypeFieldsAttachmentReducer.instances,Su=l.createSelector([fu],t=>Object.values(t)),aA=S(l.createSelector([Su,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),cA=t=>e=>e.issueTypeFieldsAttachmentReducer.instances[t],gu=Di.reducer,ce=I(t=>t.uuid),Tu=ce.getInitialState({}),Vi=l.createSlice({name:"issueTypeFieldValues",initialState:Tu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Tu)),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:bu,addIssueTypeFieldValues:Ui,addIssueTypeFieldValuesMany:rA,setIssueTypeFieldValues:dA,setIssueTypeFieldValuesMany:uA,updateIssueTypeFieldValues:He,updateIssueTypeFieldValuesMany:oA,deleteIssueTypeFieldValues:$i,deleteIssueTypeFieldValuesMany:lA}=Vi.actions,Iu=t=>t.issueTypeFieldValuesReducer.instances,Bi=l.createSelector([Iu],t=>Object.values(t)),hA=S(l.createSelector([Bi,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue===e)))),Gi=t=>e=>e.issueTypeFieldValuesReducer.instances[t],Fu=Vi.reducer,re=I(t=>t.uuid),Ru=re.getInitialState({}),Li=l.createSlice({name:"issueTypeFields",initialState:Ru,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ru)),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:Pu,addIssueTypeFields:Ou,addIssueTypeFieldsMany:mA,setIssueTypeFields:pA,setIssueTypeFieldsMany:AA,updateIssueTypeFields:vu,updateIssueTypeFieldsMany:yA,deleteIssueTypeFields:_u,deleteIssueTypeFieldsMany:fA}=Li.actions,wu=t=>t.issueTypeFieldsReducer.instances,pt=l.createSelector([wu],t=>Object.values(t)),SA=S(l.createSelector([pt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue_type===e)))),gA=S(l.createSelector([pt,(t,e)=>e],(t,e)=>t.filter(s=>s.issue_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),TA=S(l.createSelector([pt,Bi,(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)))})),bA=t=>e=>e.issueTypeFieldsReducer.instances[t],Eu=Li.reducer,de=I(t=>t.uuid),ju=de.getInitialState({}),Ni=l.createSlice({name:"issueTypeFieldValuesAttachments",initialState:ju,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ju)),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:qu,addIssueTypeFieldValuesAttachment:IA,addIssueTypeFieldValuesAttachments:At,setIssueTypeFieldValuesAttachment:FA,setIssueTypeFieldValuesAttachments:RA,updateIssueTypeFieldValuesAttachment:PA,updateIssueTypeFieldValuesAttachments:Mu,deleteIssueTypeFieldValuesAttachment:OA,deleteIssueTypeFieldValuesAttachments:yt}=Ni.actions,Hi=t=>t.issueTypeFieldValuesAttachmentReducer.instances,Cu=l.createSelector([Hi],t=>Object.values(t)),vA=t=>e=>e.issueTypeFieldValuesAttachmentReducer.instances[t],ku=S(l.createSelector([Hi,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.uuid)))})),zu=S(l.createSelector([Cu,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),Du=Ni.reducer,we=I(t=>t.uuid),Vu=we.getInitialState({}),Wi=l.createSlice({name:"issueTypes",initialState:Vu,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Vu)}),reducers:{initializeIssueTypes:we.initialize,setIssueType:we.setOne,addIssueType:we.addOne,updateIssueType:we.updateOne,removeIssueType:we.deleteOne}}),{initializeIssueTypes:Uu,setIssueType:We,addIssueType:$u,updateIssueType:Bu,removeIssueType:Ki}=Wi.actions,Gu=t=>t.issueTypeReducer.instances,Lu=l.createSelector(Gu,t=>Object.values(t)),Yi=t=>e=>e.issueTypeReducer.instances[t],_A=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},wA=S(l.createSelector([Lu,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Ji=S(l.createSelector([t=>t.issueReducer.instances,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue_type===e)))),EA=t=>e=>Ji(t)(e).length,Nu=Wi.reducer,be=I(t=>t.uuid),Hu=be.getInitialState({}),Xi=l.createSlice({name:"issueUpdates",initialState:Hu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Hu)),reducers:{initializeIssueUpdates:be.setMany,setIssueUpdate:be.setOne,addIssueUpdate:be.addOne,addIssueUpdates:be.addMany,deleteIssueUpdate:be.deleteOne,deleteIssueUpdates:be.deleteMany}}),{initializeIssueUpdates:Wu,setIssueUpdate:jA,addIssueUpdate:Ku,addIssueUpdates:Yu,deleteIssueUpdate:Ju,deleteIssueUpdates:Xu}=Xi.actions,Qu=t=>t.issueUpdateReducer.instances,Zu=S(l.createSelector([Qu,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),xu=Xi.reducer,ft=I(t=>t.uuid),eo=ft.getInitialState({}),Qi=l.createSlice({name:"license",initialState:eo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,eo)),reducers:{initializeLicences:ft.initialize,addLicenses:ft.addMany,updateLicense:ft.updateOne}}),{initializeLicences:to,addLicenses:qA,updateLicense:pe}=Qi.actions,St=t=>t.licenseReducer.instances,MA=t=>e=>e.licenseReducer.instances[t],so=t=>e=>Object.values(e.licenseReducer.instances).find(s=>s.project===t),CA=l.createSelector([St],t=>g(Object.values(t).filter(e=>e.is_active))),kA=l.createSelector([St],t=>Oe(Object.values(t).filter(e=>e.project).reduce((e,s)=>({...e,[s.project]:s}),{}))),io=Qi.reducer,C=I(t=>t.uuid),no=C.getInitialState({currentUser:null}),Zi=l.createSlice({name:"users",initialState:no,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,no)),reducers:{initializeUsers:C.initialize,setUsers:C.setMany,setUser:C.setOne,addUsers:C.addMany,addUser:C.addOne,updateUsers:C.updateMany,updateUser:C.updateOne,deleteUser:C.deleteOne,deleteUsers:C.deleteMany,removeUser:C.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.uuid];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:zA,setUsers:ao,setUser:DA,addUsers:VA,addUser:UA,updateUsers:$A,updateUser:BA,deleteUser:GA,deleteUsers:LA,removeUser:co,setCurrentUser:NA,setProfilePicture:HA}=Zi.actions,ro=Zi.reducer,gt=t=>t.userReducer.currentUser,Tt=t=>t.userReducer.instances,WA=t=>e=>e.userReducer.instances[t],KA=S(l.createSelector([Tt,(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)})),bt=I(t=>t.uuid),uo=bt.getInitialState({}),xi=l.createSlice({name:"organizationAccess",initialState:uo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,uo)),reducers:{initializeOrganizationAccesses:bt.initialize,updateOrganizationAccess:bt.updateOne,deleteOrganizationAccess:bt.deleteOne}}),{initializeOrganizationAccesses:oo,updateOrganizationAccess:lo,deleteOrganizationAccess:ho}=xi.actions,en=t=>t.organizationAccessReducer.instances,YA=t=>e=>e.organizationAccessReducer.instances[t],JA=l.createSelector([gt,en],(t,e)=>Object.values(e).find(n=>n.user===(t==null?void 0:t.uuid))??null),XA=t=>e=>Object.values(e.organizationAccessReducer.instances).find(s=>s.user===t.uuid),mo=t=>{const e={};for(const s of Object.values(t.organizationAccessReducer.instances))e[s.user]=s;return Oe(e)},po=xi.reducer,Ke=I(t=>t.uuid),Ao=Ke.getInitialState({}),tn=l.createSlice({name:"projectAccess",initialState:Ao,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ao)),reducers:{initializeProjectAccesses:Ke.initialize,updateProjectAccess:Ke.updateOne,deleteProjectAccess:Ke.deleteOne,deleteProjectAccesses:Ke.deleteMany}}),{initializeProjectAccesses:sn,updateProjectAccess:yo,deleteProjectAccess:fo,deleteProjectAccesses:So}=tn.actions,nn=t=>t.projectAccessReducer.instances,go=l.createSelector(nn,t=>Object.values(t)),QA=t=>e=>e.projectAccessReducer.instances[t],ZA=t=>e=>Object.values(e.projectAccessReducer.instances).find(s=>s.user===t.uuid),To=t=>{const e={};for(const s of Object.values(t.projectAccessReducer.instances))e[s.user]=s;return Oe(e)},bo=tn.reducer,ue=I(t=>t.uuid),Io=ue.getInitialState({}),an=l.createSlice({name:"projects",initialState:Io,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Io)),reducers:{initializeProjects:ue.initialize,setProjects:ue.setMany,setProject:ue.setOne,addProjects:ue.addMany,addProject:ue.addOne,updateProjects:ue.updateMany,updateProject:ue.updateOne,deleteProject:ue.deleteOne,deleteProjects:ue.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:xA,setProjects:Fo,setProject:ey,addProjects:ty,addProject:sy,updateProjects:iy,updateProject:Ro,deleteProject:Po,deleteProjects:ny,acceptProjectInvite:Oo}=an.actions,vo=an.reducer,It=t=>t.projectReducer.instances,ay=l.createSelector([It],t=>g(Object.values(t))),cy=t=>e=>e.projectReducer.instances[t],_o=l.createSelector([nn],t=>Object.values(t).map(e=>e.user)),wo=l.createSelector([_o,Tt],(t,e)=>t.reduce((s,n)=>({...s,[n]:e[n]}),{})),ry=l.createSelector([gt,wo,To],(t,e,s)=>g(Object.values(e).sort((n,a)=>{if(n.uuid===(t==null?void 0:t.uuid))return-1;if(a.uuid===(t==null?void 0:t.uuid))return 1;const c=s[n.uuid],r=s[a.uuid];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)===Ot.ADMIN?-1:1}))),oe=I(t=>t.uuid),Eo=oe.getInitialState({}),cn=l.createSlice({name:"organizations",initialState:Eo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Eo)),reducers:{initializeOrganizations:oe.initialize,setOrganizations:oe.setMany,setOrganization:oe.setOne,addOrganizations:oe.addMany,addOrganization:oe.addOne,updateOrganizations:oe.updateMany,updateOrganization:oe.updateOne,deleteOrganization:oe.deleteOne,deleteOrganizations:oe.deleteMany}}),{initializeOrganizations:dy,setOrganizations:jo,setOrganization:uy,addOrganizations:oy,addOrganization:ly,updateOrganizations:hy,updateOrganization:my,deleteOrganization:py,deleteOrganizations:Ay}=cn.actions,qo=t=>t.organizationReducer.instances,Mo=l.createSelector([qo],t=>Object.values(t)),yy=t=>e=>e.organizationReducer.instances[t],fy=l.createSelector([Mo],t=>g(Object.values(t).filter(e=>e.has_access))),Co=l.createSelector([en],t=>Object.values(t).map(e=>e.user)),Sy=S(l.createSelector([It,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.organization_owner===e)))),gy=S(l.createSelector([St,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.organization_owner===e)))),ko=l.createSelector([Co,Tt],(t,e)=>Oe(t.reduce((s,n)=>({...s,[n]:e[n]}),{}))),Ty=l.createSelector([gt,ko,mo],(t,e,s)=>g(Object.values(e).sort((n,a)=>{if(n.uuid===(t==null?void 0:t.uuid))return-1;if(a.uuid===(t==null?void 0:t.uuid))return 1;const c=s[n.uuid],r=s[a.uuid];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}))),zo=cn.reducer,Do=(t,e,s)=>{const n=t.uuid?t:{...t,uuid:_.v4()};return{payload:n,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:n,BASE_URL:e,serviceName:s}}}}},Vo={deletedRequests:[],latestRetryTime:0},rn=l.createSlice({name:"outbox",initialState:Vo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Vo)),reducers:{enqueueRequest:{reducer:(t,e)=>t,prepare:t=>{console.debug("Preparing to enqueue request",t);const{BASE_URL:e,serviceName:s,...n}=t;return Do(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}}}),by=t=>t.outboxReducer.deletedRequests,Iy=t=>t.outboxReducer.latestRetryTime,{enqueueRequest:Uo,markForDeletion:Fy,markAsDeleted:$o,_setLatestRetryTime:Bo}=rn.actions,Go=rn.reducer,le=I(t=>t.uuid),Lo=le.getInitialState({}),dn=l.createSlice({name:"projectAttachments",initialState:Lo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Lo)),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:No,addProjectAttachment:Ry,addProjectAttachments:Ho,setProjectAttachment:Wo,setProjectAttachments:Ko,updateProjectAttachment:Py,updateProjectAttachments:Yo,deleteProjectAttachment:Jo,deleteProjectAttachments:un}=dn.actions,Xo=t=>t.projectAttachmentReducer.instances,Qo=l.createSelector([Xo],t=>Object.values(t)),Zo=t=>e=>e.projectAttachmentReducer.instances[t],xo=S(l.createSelector([Qo,(t,e)=>e],(t,e)=>g(t.filter(({project:s})=>e===s)))),el=dn.reducer,he=I(t=>t.uuid),tl=he.getInitialState({activeProjectFileId:null,isImportingProjectFile:!1}),on=l.createSlice({name:"projectFiles",initialState:tl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,tl)),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:sl,setProjectFile:Oy,setProjectFiles:vy,addProjectFile:_y,addProjectFiles:il,updateProjectFile:ln,updateProjectFiles:wy,deleteProjectFile:nl,deleteProjectFiles:al,setIsImportingProjectFile:cl,setActiveProjectFileId:rl,saveActiveProjectFileBounds:dl,resetProjectFileObjectUrls:Ey}=on.actions,ul=t=>t.projectFileReducer.instances,ol=l.createSelector([ul],t=>g(Object.values(t).sort((e,s)=>e.z_index-s.z_index))),jy=t=>e=>e.projectFileReducer.instances[t],qy=t=>t.projectFileReducer.activeProjectFileId,My=t=>t.projectFileReducer.isImportingProjectFile,ll=on.reducer,Cy={isRehydrated:!1},hn=l.createSlice({name:"rehydrated",initialState:Cy,reducers:{setRehydrated:(t,e)=>{t.isRehydrated=e.payload}}}),{setRehydrated:ky}=hn.actions,zy=t=>t.rehydratedReducer.isRehydrated,hl=hn.reducer,Ee=I(t=>t.uuid),ml=Ee.getInitialState({}),mn=l.createSlice({name:"teams",initialState:ml,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ml)),reducers:{setTeam:Ee.setOne,initializeTeams:Ee.initialize,addTeam:Ee.addOne,updateTeam:Ee.updateOne,deleteTeam:Ee.deleteOne}}),{setTeam:je,initializeTeams:pl,addTeam:Al,updateTeam:pn,deleteTeam:An}=mn.actions,yn=t=>t.teamReducer.instances,fn=l.createSelector([yn],t=>Object.values(t)),qe=t=>e=>e.teamReducer.instances[t],Dy=S(l.createSelector([yn,(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)})),Vy=S(l.createSelector([fn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Uy=S(l.createSelector([fn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.members.includes(e))))),yl=mn.reducer,$y={version:0},fl=l.createSlice({name:"versioning",initialState:$y,reducers:{}}),Sl=fl.reducer;let gl;function By(t){gl=t}function Ye(){return gl}let Tl;function Gy(t){Tl=t}function Ly(){return Tl}const bl={};class Il{constructor(e){f(this,"client");bl[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 Fl="versioning",Rl=()=>vl.length-1,Pl=t=>(t[Fl]={version:Rl()},t),Ol=()=>Pl({}),Ny=t=>(t.outboxReducer&&(t.outboxReducer.deletedRequests=[]),t),Hy=t=>e=>{var s;return e===void 0&&(e={}),((s=e[Fl])==null?void 0:s.version)===Rl()?e:t(e)},vl=[Pl,Ol,Ol,Ny],Wy=Object.fromEntries(vl.map((t,e)=>[e,Hy(t)])),Sn="versioning",_l={[Sn]:Sl,fileReducer:wr,authReducer:Jc,categoryReducer:er,assetReducer:Ha,assetAttachmentReducer:ta,assetStageCompletionReducer:Xa,assetStageReducer:sc,assetTypeReducer:Wc,assetTypeAttachmentReducer:pc,issueReducer:tu,issueAttachmentReducer:kd,issueTypeReducer:Nu,issueTypeAttachmentReducer:lu,organizationReducer:zo,outboxReducer:Go,projectReducer:vo,projectAttachmentReducer:el,projectAccessReducer:bo,organizationAccessReducer:po,projectFileReducer:ll,rehydratedReducer:hl,formReducer:Kr,formRevisionReducer:Nr,formRevisionAttachmentReducer:zr,formSubmissionAttachmentReducer:td,formSubmissionReducer:dd,userReducer:ro,emailDomainsReducer:Rr,licenseReducer:io,documentsReducer:Sr,documentAttachmentReducer:lr,teamReducer:yl,agentsReducer:Wn,issueCommentReducer:Jd,issueCommentAttachmentReducer:Hd,issueUpdateReducer:xu,geoImageReducer:Sd,issueAssociationReducer:Od,issueTypeFieldsReducer:Eu,issueTypeFieldValuesReducer:Fu,issueTypeFieldsAttachmentReducer:gu,issueTypeFieldValuesAttachmentReducer:Du,assetTypeFieldsReducer:wc,assetTypeFieldValuesReducer:Lc,assetTypeFieldsAttachmentReducer:Ic,assetTypeFieldValuesAttachmentReducer:zc,assetProcedureReducer:$a,assetProcedureInstanceReducer:za,assetProcedureFieldsReducer:ya,assetProcedureFieldValuesReducer:Ea,assetProcedureFieldsAttachmentReducer:ua,assetProcedureFieldValuesAttachmentReducer:Fa},wl=l.combineReducers(_l),El="RESET",Ky=(t,e)=>e.type==="auth/setLoggedIn"&&!e.payload?wl(void 0,e):wl(t,e);let gn=null;function Ie(){const t=Ye();if(!t)return console.warn("Client store not set; cannot get outbox coordinator yet."),null;if(gn)return gn;const e=t.getState().offline.outbox,s=Ce._fromOutbox(e);return gn=s,s}const Yy=t=>{if(t)throw t;const e=Ye();e?e.dispatch({type:"rehydrated/setRehydrated",payload:!0}):console.error("Client store not set")},jl=(t,e,s)=>{const n=Ie();return n?(n.addRequest(e),n.getQueue()):(console.warn("Outbox coordinator not set; cannot enqueue request yet."),[])},ql=(t,e,s)=>{const n=Ie();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 Jy(t,e){if(!e.payload)throw new Error("Received empty payload");return af(e)}const Xy={...Pn,effect:Jy,discard:bn,returnPromises:!0,persistCallback:Yy,retry:rf,persistOptions:{storage:$l},queue:{...Pn.queue,enqueue:jl,dequeue:ql,peek:(...t)=>cf(...t)}},Qy=Bl(Wy,Sn),Zy=l.compose(Ul.offline(Xy),Qy);function xy(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 Tn(t,e){const s=bl[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:h,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=E=>{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 Qe=me.fields["x-amz-checksum-sha1"];if(!Qe)throw new Error(`No checksum for file ${p}`);return E.set("x-amz-checksum-sha1",Qe).field({...u,...me.fields}).attach("file",O)}return E.send(u)},AS={[o.GET]:()=>b?Pe.get(T.toString()).responseType("blob"):Pe.get(T.toString()),[o.POST]:()=>{const E=Pe.post(T.toString());return M(E)},[o.PATCH]:()=>{const E=Pe.patch(T.toString());return M(E)},[o.PUT]:()=>{const E=Pe.put(T.toString());return M(E)},[o.DELETE]:()=>{const E=Pe.delete(T.toString());return M(E)}}[d];let Re=AS();if(y&&n){const E=s.auth.getAuthHeader();Re=Re.set("Authorization",E)}m&&(Re=Re.set(m));try{return await Re.query(h)}catch(E){const me=xy(E),Qe=me==null?void 0:me.status;if(n&&Qe===401)return await s.auth.handleUnauthorized(Re,me),Re.query(h);throw new q({response:me,innerError:E,discard:Cl.includes(Qe)})}}class ef{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 Ml{constructor(){f(this,"next");this.next=null}then(e){return new ef(this).then(e)}async run(e){if(this.next)return this.next.run(e);{if(console.debug("Middleware finished. Performing request:",e),!Ye())throw new Error("Client store not set");const n=Ly();if(!n)throw new Error("Client SDK not set");return Tn(e,n)}}}class tf extends Ml{async run(e){return super.run(e)}}class sf extends Ml{async run(e){return super.run(e)}}const nf=new tf().then(new sf).compile();function af(t){var e;return(e=nf[0])==null?void 0:e.run(t)}const Cl=[400,409,403,404,405,500];function bn(t,e,s=0){var d;if(console.debug("Considering discarding request due to error:",t,`(${typeof t})`,`
1
+ (function(i,_){typeof exports=="object"&&typeof module<"u"?_(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"],_):(i=typeof globalThis<"u"?globalThis:i||self,_(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,_,l,Vl,Ul,Pn,$l,Bl,Pe,Gl,Ll,Nl,Hl){"use strict";var yS=Object.defineProperty;var fS=(i,_,l)=>_ in i?yS(i,_,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[_]=l;var f=(i,_,l)=>fS(i,typeof _!="symbol"?_+"":_,l);var Dl;const On=Object.freeze([]),vn=Object.freeze({});var Ot=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(Ot||{}),vt=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(vt||{}),o=(t=>(t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.DELETE="DELETE",t))(o||{}),_n=(t=>(t.Issue="issue",t.Asset="asset",t.AssetType="asset_type",t.Project="project",t.Document="document",t))(_n||{}),_t=(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))(_t||{}),wt=(t=>(t[t.BACKLOG=0]="BACKLOG",t[t.SELECTED=2]="SELECTED",t[t.DONE=4]="DONE",t))(wt||{}),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||{}),wn=(t=>(t.COMPLETED="checkout.completed",t.CLOSED="checkout.closed",t))(wn||{}),En=(t=>(t[t.PRO=0]="PRO",t))(En||{}),jn=(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))(jn||{});const Wl=wt.BACKLOG,Kl=_t.MEDIUM,qn=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:{}})}}Dl=Symbol.toStringTag;class Mn{constructor(){f(this,Dl,"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 Yl=t=>({type:"Point",coordinates:t}),Jl=t=>({type:"MultiPoint",coordinates:t}),Xl=(t,e)=>t[0]===e[0]&&t[1]===e[1];let Et=!1;["true","1"].includes("".toLowerCase())&&(Et=!0);function Ql(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 jt(t){const e={};return function(){const s=Array.prototype.slice.call(arguments);return s in e?(Et&&console.debug(`Memoization debug: Using memorized return value for ${t.toString()}(`,s,")"),e[s]):(Et&&console.debug(`Memoization debug: Cache miss! Memoizing ${t.toString()}(`,s,")"),e[s]=t.apply(this,s))}}function Zl(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?On:t,Oe=t=>Object.keys(t).length===0?vn:t,kn=jt(t=>{if(!t)return"";const e=new Date(t),s=e.getFullYear()===qt.getFullYear(),n={day:"numeric",month:"short"};return s||(n.year="numeric"),e.toLocaleDateString([],n)}),xl=new Intl.RelativeTimeFormat([],{style:"long",numeric:"auto"}),eh=1e3*86400,qt=new Date,th=t=>new Date(t).toDateString()===qt.toDateString(),sh=jt((t,e,s)=>{const n=Math.round((new Date(t).getTime()-qt.getTime())/eh);return n<e||n>s?kn(t):xl.format(n,"days")});function ih(t){return new Uint8Array(t).reduce((s,n)=>s+n.toString(16).padStart(2,"0"),"")}const Mt=async(t,e)=>{e||(e=await ve(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 ve(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=ih(c);e(r)})},n.readAsArrayBuffer(t)})}function nh(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 Cn(t,e){return new File([t],e,{type:t.type})}function ah(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 ch=async t=>{const e={};for(const s of t){const n=await ve(s);e[n]={sha1:n,extension:s.name.split(".").pop()||"",file_type:s.type,size:s.size}}return Object.values(e)},zn=async t=>(await fetch(t)).blob(),rh=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 dh(t){const e=new Blob([t]);Vl.saveAs(e,t.name)}const Dn={};function uh(t,e,s,...n){const a=Dn[t];let c=!1;a?a[e]||(a[e]=!0,c=!0):(Dn[t]={[e]:!0},c=!0),c&&console[s](...n)}const Vn=["created_at","updated_at","index","revision"];function R(t){return{...t,uuid:_.v4()}}function Un(t){const e={};for(const s of t)e[s.uuid]=s;return e}function oh(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 lh(t){return t.toLowerCase().replace(" ","-")}function hh(t,e=!1){return t.normalize("NFKD").toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/[-\s]+/g,e?"_":"-")}function mh(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 $n(t,e,s){return s.findIndex(n=>n.uuid===t.uuid)===e}function ph(t,e,s){return s.findIndex(n=>n.file_sha1===t.file_sha1)===e}const Ah=/^.+@.+\..+$/;function v(t){const e={...t};for(const s of[...Vn,"created_by"])s in e&&delete e[s];return e}const Ce=I(t=>t.uuid),Bn=Ce.getInitialState({}),kt=l.createSlice({name:"agents",initialState:Bn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Bn)),reducers:{initializeConversations:Ce.initialize,addConversation:Ce.addOne,setConversation:Ce.setOne,updateConversation:Ce.updateOne}}),{initializeConversations:Gn,addConversation:Ln,setConversation:Nn,updateConversation:Hn}=kt.actions,Ct=t=>t.agentsReducer.instances,yh=l.createSelector([Ct],t=>Object.values(t)),fh=S(l.createSelector([Ct,(t,e)=>e],(t,e)=>t[e])),Wn=kt.reducer,C=I(t=>t.uuid),Kn=C.getInitialState({}),zt=l.createSlice({name:"assetAttachments",initialState:Kn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Kn)),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:Dt,addAssetAttachment:Sh,addAssetAttachments:Vt,setAssetAttachment:Yn,setAssetAttachments:gh,updateAssetAttachment:Th,updateAssetAttachments:Jn,deleteAssetAttachment:Xn,deleteAssetAttachments:Ut}=zt.actions,Qn=t=>t.assetAttachmentReducer.instances,Zn=l.createSelector([Qn],t=>Object.values(t)),xn=t=>e=>e.assetAttachmentReducer.instances[t],ea=S(l.createSelector([Zn,(t,e)=>e],(t,e)=>g(t.filter(({asset:s})=>e===s)))),ta=zt.reducer,z=I(t=>t.uuid),sa=z.getInitialState({}),$t=l.createSlice({name:"assetProcedureFieldsAttachments",initialState:sa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sa)),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:ia,addAssetProcedureFieldsAttachment:bh,addAssetProcedureFieldsAttachments:na,setAssetProcedureFieldsAttachment:Ih,setAssetProcedureFieldsAttachments:Fh,updateAssetProcedureFieldsAttachment:Rh,updateAssetProcedureFieldsAttachments:aa,deleteAssetProcedureFieldsAttachment:Ph,deleteAssetProcedureFieldsAttachments:ca}=$t.actions,ra=t=>t.assetProcedureFieldsAttachmentReducer.instances,da=l.createSelector([ra],t=>Object.values(t)),Oh=S(l.createSelector([da,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),vh=t=>e=>e.assetProcedureFieldsAttachmentReducer.instances[t],ua=$t.reducer,D=I(t=>t.uuid),oa=D.getInitialState({}),Bt=l.createSlice({name:"assetProcedureFields",initialState:oa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,oa)),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:la,addAssetProcedureFields:ha,addAssetProcedureFieldsMany:_h,setAssetProcedureFields:wh,setAssetProcedureFieldsMany:Eh,updateAssetProcedureFields:ma,updateAssetProcedureFieldsMany:jh,deleteAssetProcedureFields:pa,deleteAssetProcedureFieldsMany:qh}=Bt.actions,Aa=t=>t.assetProcedureFieldsReducer.instances,Gt=l.createSelector([Aa],t=>Object.values(t)),Mh=S(l.createSelector([Gt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),kh=S(l.createSelector([Gt,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_procedure===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),Ch=t=>e=>e.assetProcedureFieldsReducer.instances[t],ya=Bt.reducer,V=I(t=>t.uuid),fa=V.getInitialState({}),Lt=l.createSlice({name:"assetProcedureFieldValuesAttachments",initialState:fa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,fa)),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:Sa,addAssetProcedureFieldValuesAttachment:zh,addAssetProcedureFieldValuesAttachments:Ze,setAssetProcedureFieldValuesAttachment:Dh,setAssetProcedureFieldValuesAttachments:Vh,updateAssetProcedureFieldValuesAttachment:Uh,updateAssetProcedureFieldValuesAttachments:ga,deleteAssetProcedureFieldValuesAttachment:$h,deleteAssetProcedureFieldValuesAttachments:xe}=Lt.actions,Nt=t=>t.assetProcedureFieldValuesAttachmentReducer.instances,Ta=l.createSelector([Nt],t=>Object.values(t)),Bh=t=>e=>e.assetProcedureFieldValuesAttachmentReducer.instances[t],ba=S(l.createSelector([Nt,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.uuid)))})),Ia=S(l.createSelector([Ta,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),Fa=Lt.reducer,U=I(t=>t.uuid),Ra=U.getInitialState({}),Ht=l.createSlice({name:"assetProcedureFieldValues",initialState:Ra,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ra)),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:Pa,addAssetProcedureFieldValues:Wt,addAssetProcedureFieldValuesMany:Oa,setAssetProcedureFieldValues:Gh,setAssetProcedureFieldValuesMany:Lh,updateAssetProcedureFieldValues:ze,updateAssetProcedureFieldValuesMany:va,deleteAssetProcedureFieldValues:Kt,deleteAssetProcedureFieldValuesMany:_a}=Ht.actions,wa=t=>t.assetProcedureFieldValuesReducer.instances,Yt=l.createSelector([wa],t=>Object.values(t)),Nh=S(l.createSelector([Yt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),Hh=S(l.createSelector([Yt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure_instance===e)))),Jt=t=>e=>e.assetProcedureFieldValuesReducer.instances[t],Ea=Ht.reducer,$=I(t=>t.uuid),ja=$.getInitialState({}),Xt=l.createSlice({name:"assetProcedureInstances",initialState:ja,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ja)),reducers:{initializeAssetProcedureInstances:$.initialize,addAssetProcedureInstance:$.addOne,addAssetProcedureInstances:$.addMany,setAssetProcedureInstance:$.setOne,setAssetProcedureInstances:$.setMany,updateAssetProcedureInstance:$.updateOne,updateAssetProcedureInstances:$.updateMany,deleteAssetProcedureInstance:$.deleteOne,deleteAssetProcedureInstances:$.deleteMany}}),{initializeAssetProcedureInstances:qa,addAssetProcedureInstance:Qt,addAssetProcedureInstances:Ma,updateAssetProcedureInstance:De,updateAssetProcedureInstances:Wh,deleteAssetProcedureInstance:Zt,deleteAssetProcedureInstances:ka,setAssetProcedureInstance:Kh,setAssetProcedureInstances:Yh}=Xt.actions,xt=t=>t.assetProcedureInstanceReducer.instances,es=l.createSelector([xt],t=>Object.values(t)),Ca=S(l.createSelector([es,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),Jh=S(l.createSelector([es,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),ts=t=>e=>e.assetProcedureInstanceReducer.instances[t],Xh=S(l.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)})),za=Xt.reducer,B=I(t=>t.uuid),Da=B.getInitialState({}),ss=l.createSlice({name:"assetProcedures",initialState:Da,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Da)),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:Va,addAssetProcedure:is,addAssetProcedures:Qh,updateAssetProcedure:Ve,updateAssetProcedures:Zh,deleteAssetProcedure:ns,deleteAssetProcedures:xh,setAssetProcedure:em,setAssetProcedures:tm}=ss.actions,as=t=>t.assetProcedureReducer.instances,Ua=l.createSelector([as],t=>Object.values(t)),sm=S(l.createSelector([Ua,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),cs=t=>e=>e.assetProcedureReducer.instances[t],im=S(l.createSelector([as,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return g(s)})),$a=ss.reducer,G=I(t=>t.uuid),Ba=G.getInitialState({}),rs=l.createSlice({name:"assets",initialState:Ba,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ba)),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:Ga,addAsset:ds,addAssets:us,updateAsset:Ue,updateAssets:nm,deleteAsset:os,deleteAssets:La,setAsset:am,setAssets:cm}=rs.actions,ls=t=>t.assetReducer.instances,Na=l.createSelector([ls],t=>g(Object.values(t))),hs=S(l.createSelector([Na,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),ms=t=>e=>e.assetReducer.instances[t],rm=S(l.createSelector([ls,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return g(s)})),dm=t=>e=>hs(t)(e).length,Ha=rs.reducer,Ae=I(t=>t.uuid),Wa=Ae.getInitialState({}),ps=l.createSlice({name:"assetStageCompletions",initialState:Wa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Wa)),reducers:{initializeAssetStageCompletions:Ae.initialize,addAssetStageCompletion:Ae.addOne,addAssetStageCompletions:Ae.addMany,updateAssetStageCompletion:Ae.updateOne,updateAssetStageCompletions:Ae.updateMany,deleteAssetStageCompletion:Ae.deleteOne,deleteAssetStageCompletions:Ae.deleteMany}}),{initializeAssetStageCompletions:Ka,addAssetStageCompletion:As,addAssetStageCompletions:ys,updateAssetStageCompletion:Ya,updateAssetStageCompletions:Ja,deleteAssetStageCompletion:fs,deleteAssetStageCompletions:Ss}=ps.actions,Xa=ps.reducer,gs=t=>t.assetStageCompletionReducer.instances,um=l.createSelector([gs],t=>Object.values(t)),Qa=t=>e=>e.assetStageCompletionReducer.instances[t],Za=S(l.createSelector([gs,(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),xa=L.getInitialState({}),Ts=l.createSlice({name:"assetStages",initialState:xa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,xa)),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:ec,setAssetStage:tc,setAssetStages:om,addAssetStage:lm,addAssetStages:bs,updateAssetStage:Is,updateAssetStages:et,deleteAssetStage:hm,deleteAssetStages:Fs}=Ts.actions,sc=Ts.reducer,tt=t=>t.assetStageReducer.instances,ic=t=>e=>e.assetStageReducer.instances[t],nc=l.createSelector([tt],t=>Object.values(t)),mm=S(l.createSelector([tt,(t,e)=>e],(t,e)=>{const s={};for(const[n,a]of Object.entries(t))a.asset_procedure===e&&(s[n]=a);return Oe(s)})),pm=S(l.createSelector([nc,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_procedure===e)))),Rs=S(l.createSelector([tt,(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),ac=N.getInitialState({}),Ps=l.createSlice({name:"assetTypeAttachments",initialState:ac,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ac)),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:cc,addAssetTypeAttachment:Am,addAssetTypeAttachments:Os,setAssetTypeAttachment:rc,setAssetTypeAttachments:ym,updateAssetTypeAttachment:fm,updateAssetTypeAttachments:dc,deleteAssetTypeAttachment:uc,deleteAssetTypeAttachments:vs}=Ps.actions,oc=t=>t.assetTypeAttachmentReducer.instances,lc=l.createSelector([oc],t=>Object.values(t)),hc=t=>e=>e.assetTypeAttachmentReducer.instances[t],mc=S(l.createSelector([lc,(t,e)=>e],(t,e)=>g(t.filter(({asset_type:s})=>e===s)))),pc=Ps.reducer,H=I(t=>t.uuid),Ac=H.getInitialState({}),_s=l.createSlice({name:"assetTypeFieldsAttachments",initialState:Ac,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ac)),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:yc,addAssetTypeFieldsAttachment:Sm,addAssetTypeFieldsAttachments:fc,setAssetTypeFieldsAttachment:gm,setAssetTypeFieldsAttachments:Tm,updateAssetTypeFieldsAttachment:bm,updateAssetTypeFieldsAttachments:Sc,deleteAssetTypeFieldsAttachment:Im,deleteAssetTypeFieldsAttachments:gc}=_s.actions,Tc=t=>t.assetTypeFieldsAttachmentReducer.instances,bc=l.createSelector([Tc],t=>Object.values(t)),Fm=S(l.createSelector([bc,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),Rm=t=>e=>e.assetTypeFieldsAttachmentReducer.instances[t],Ic=_s.reducer,W=I(t=>t.uuid),Fc=W.getInitialState({}),ws=l.createSlice({name:"assetTypeFields",initialState:Fc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Fc)),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:Rc,addAssetTypeFields:Pc,addAssetTypeFieldsMany:Pm,setAssetTypeFields:Om,setAssetTypeFieldsMany:vm,updateAssetTypeFields:Oc,updateAssetTypeFieldsMany:_m,deleteAssetTypeFields:vc,deleteAssetTypeFieldsMany:wm}=ws.actions,_c=t=>t.assetTypeFieldsReducer.instances,st=l.createSelector([_c],t=>Object.values(t)),Em=S(l.createSelector([st,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset_type===e)))),jm=S(l.createSelector([st,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),qm=t=>e=>e.assetTypeFieldsReducer.instances[t],wc=ws.reducer,K=I(t=>t.uuid),Ec=K.getInitialState({}),Es=l.createSlice({name:"assetTypeFieldValuesAttachments",initialState:Ec,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ec)),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:jc,addAssetTypeFieldValuesAttachment:Mm,addAssetTypeFieldValuesAttachments:it,setAssetTypeFieldValuesAttachment:km,setAssetTypeFieldValuesAttachments:Cm,updateAssetTypeFieldValuesAttachment:zm,updateAssetTypeFieldValuesAttachments:qc,deleteAssetTypeFieldValuesAttachment:Dm,deleteAssetTypeFieldValuesAttachments:nt}=Es.actions,js=t=>t.assetTypeFieldValuesAttachmentReducer.instances,Mc=l.createSelector([js],t=>Object.values(t)),Vm=t=>e=>e.assetTypeFieldValuesAttachmentReducer.instances[t],kc=S(l.createSelector([js,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.uuid)))})),Cc=S(l.createSelector([Mc,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),zc=Es.reducer,Y=I(t=>t.uuid),Dc=Y.getInitialState({}),qs=l.createSlice({name:"assetTypeFieldValues",initialState:Dc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dc)),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:Vc,addAssetTypeFieldValues:Ms,addAssetTypeFieldValuesMany:Uc,setAssetTypeFieldValues:Um,setAssetTypeFieldValuesMany:$m,updateAssetTypeFieldValues:$e,updateAssetTypeFieldValuesMany:$c,deleteAssetTypeFieldValues:ks,deleteAssetTypeFieldValuesMany:Bc}=qs.actions,Gc=t=>t.assetTypeFieldValuesReducer.instances,Cs=l.createSelector([Gc],t=>Object.values(t)),Bm=S(l.createSelector([Cs,(t,e)=>e],(t,e)=>g(t.filter(s=>s.asset===e)))),Gm=S(l.createSelector([st,Cs,(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)))})),zs=t=>e=>e.assetTypeFieldValuesReducer.instances[t],Lc=qs.reducer,J=I(t=>t.uuid),Nc=J.getInitialState({}),Ds=l.createSlice({name:"assetTypes",initialState:Nc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Nc)),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:Hc,setAssetType:Lm,setAssetTypes:Nm,addAssetType:Vs,addAssetTypes:Hm,updateAssetType:Be,updateAssetTypes:Wm,deleteAssetType:Us,deleteAssetTypes:Km}=Ds.actions,$s=t=>t.assetTypeReducer.instances,Ym=l.createSelector([$s],t=>Object.values(t)),Bs=t=>e=>e.assetTypeReducer.instances[t],Jm=S(l.createSelector([$s,(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)})),Wc=Ds.reducer,Kc={accessToken:"",refreshToken:"",isLoggedIn:!1},at=l.createSlice({name:"auth",initialState:Kc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Kc)),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||at.caseReducers.clearTokens(t),t.isLoggedIn=e.payload}}}),{setTokens:Xm,clearTokens:Qm,setLoggedIn:Yc}=at.actions,Zm=t=>t.authReducer.accessToken,xm=t=>t.authReducer.isLoggedIn,Jc=at.reducer,Ge=I(t=>t.uuid),Xc=Ge.getInitialState({}),Gs=l.createSlice({name:"categories",initialState:Xc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Xc)),reducers:{initializeCategories:Ge.initialize,addCategory:Ge.addOne,updateCategory:Ge.updateOne,deleteCategory:Ge.deleteOne}}),{initializeCategories:Qc,addCategory:Ls,updateCategory:Zc,deleteCategory:xc}=Gs.actions,Ns=t=>t.categoryReducer.instances,ep=l.createSelector([Ns],t=>Object.values(t)),Hs=t=>e=>e.categoryReducer.instances[t],tp=S(l.createSelector([Ns,(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)})),sp=t=>e=>Object.values(e.issueReducer.instances).filter(s=>s.category===t).length,er=Gs.reducer,X=I(t=>t.uuid),tr=X.getInitialState({}),Ws=l.createSlice({name:"documentAttachments",initialState:tr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,tr)),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:sr,addDocumentAttachment:ip,addDocumentAttachments:ir,setDocumentAttachment:nr,setDocumentAttachments:np,updateDocumentAttachment:ap,updateDocumentAttachments:ar,deleteDocumentAttachment:cr,deleteDocumentAttachments:rr}=Ws.actions,dr=t=>t.documentAttachmentReducer.instances,ur=l.createSelector([dr],t=>Object.values(t)),or=t=>e=>e.documentAttachmentReducer.instances[t],cp=S(l.createSelector([ur,(t,e)=>e],(t,e)=>g(t.filter(({document:s})=>e===s)))),lr=Ws.reducer,hr={documents:{}},Ks=l.createSlice({name:"documents",initialState:hr,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,hr)}),reducers:{setDocuments:(t,e)=>{if(e.payload.filter($n).length!==e.payload.length)throw new Error("Tried to use setIssues reducer with duplicate ID's");t.documents=Un(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:mr,addDocuments:pr,updateDocuments:ye,moveDocument:Ar,removeDocuments:Ys}=Ks.actions,_e=t=>t.documentsReducer.documents,yr=l.createSelector([_e],t=>Object.values(t)),fr=t=>e=>e.documentsReducer.documents[t],rp=S(l.createSelector([_e,(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)})),dp=S(l.createSelector([_e,(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)})),up=l.createSelector([yr],t=>g(t.filter(e=>!e.parent_document))),Sr=Ks.reducer,ct=I(t=>t.uuid),op=ct.getInitialState({}),Js=l.createSlice({name:"emailDomains",initialState:op,reducers:{initializeEmailDomains:ct.initialize,addEmailDomain:ct.addOne,deleteEmailDomain:ct.deleteOne}}),{initializeEmailDomains:gr,addEmailDomain:Tr,deleteEmailDomain:br}=Js.actions,Ir=t=>t.emailDomainsReducer.instances,Fr=l.createSelector([Ir],t=>Object.values(t)),lp=S(l.createSelector([Fr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Rr=Js.reducer,Pr={s3Urls:{}},Or=1e3*60*60,hp=Or*24*7,Xs=l.createSlice({name:"file",initialState:Pr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Pr)),reducers:{setUploadUrl:(t,e)=>{const{url:s,fields:n,sha1:a}=e.payload,c=new Date,r=new Date(c.getTime()+hp);t.s3Urls[a]={url:s,fields:n,exp:r.getTime()}}}}),{setUploadUrl:vr}=Xs.actions,_r=t=>e=>{const s=e.fileReducer.s3Urls[t];if(!s)return;const n=new Date().getTime();if(!((s.exp??n)-n<Or))return s},wr=Xs.reducer,Q=I(t=>t.uuid),Er=Q.getInitialState({}),Qs=l.createSlice({name:"formRevisionAttachments",initialState:Er,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Er)),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:jr,addFormRevisionAttachment:mp,addFormRevisionAttachments:qr,setFormRevisionAttachment:pp,setFormRevisionAttachments:Ap,updateFormRevisionAttachment:yp,updateFormRevisionAttachments:Mr,deleteFormRevisionAttachment:fp,deleteFormRevisionAttachments:kr}=Qs.actions,Cr=t=>t.formRevisionAttachmentReducer.instances,Sp=S(l.createSelector([Cr,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_revision===e)))),zr=Qs.reducer,gp=(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.uuid),Dr=fe.getInitialState({}),Zs=l.createSlice({name:"formRevisions",initialState:Dr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dr)),reducers:{initializeFormRevisions:fe.initialize,setFormRevision:fe.setOne,addFormRevision:fe.addOne,addFormRevisions:fe.addMany,deleteFormRevision:fe.deleteOne,deleteFormRevisions:fe.deleteMany}}),{setFormRevision:Vr,initializeFormRevisions:Ur,addFormRevision:xs,addFormRevisions:$r,deleteFormRevision:ei,deleteFormRevisions:Br}=Zs.actions,rt=t=>t.formRevisionReducer.instances,Gr=l.createSelector([rt],t=>Object.values(t)),Tp=t=>e=>e.formRevisionReducer.instances[t],bp=S(l.createSelector([rt,(t,e)=>e],(t,e)=>{const s=Object.values(t).filter(c=>c.form===e);if(s.length===0)return;const a=s.sort(gp)[s.length-1];return t[a.uuid]})),Lr=S(l.createSelector([Gr,(t,e)=>e],(t,e)=>g(t.filter(s=>s.form===e)))),Nr=Zs.reducer,Se=I(t=>t.uuid),Hr=Se.getInitialState({}),ti=l.createSlice({name:"forms",initialState:Hr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Hr)),reducers:{initializeForms:Se.initialize,setForm:Se.setOne,addForm:Se.addOne,addForms:Se.addMany,updateForm:Se.updateOne,deleteForm:Se.deleteOne}}),{initializeForms:Wr,setForm:Ip,addForm:si,addForms:Fp,updateForm:Rp,deleteForm:ii}=ti.actions,Kr=ti.reducer,Yr=t=>t.formReducer.instances,Pp=l.createSelector([Yr],t=>Object.values(t)),Jr=t=>e=>e.formReducer.instances[t],Z=I(t=>t.uuid),Xr=Z.getInitialState({}),ni=l.createSlice({name:"formSubmissionAttachments",initialState:Xr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Xr)),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:Qr,addFormSubmissionAttachment:Op,addFormSubmissionAttachments:dt,setFormSubmissionAttachment:vp,setFormSubmissionAttachments:_p,updateFormSubmissionAttachment:wp,updateFormSubmissionAttachments:Zr,deleteFormSubmissionAttachment:Ep,deleteFormSubmissionAttachments:ut}=ni.actions,ai=t=>t.formSubmissionAttachmentReducer.instances,xr=S(l.createSelector([ai,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.uuid)))})),ed=S(l.createSelector([ai,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.form_submission===e)))),td=ni.reducer,x=I(t=>t.uuid),sd=x.getInitialState({}),ci=l.createSlice({name:"formSubmissions",initialState:sd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sd)),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:id,setFormSubmission:ot,setFormSubmissions:jp,addFormSubmission:ri,addFormSubmissions:lt,updateFormSubmission:nd,updateFormSubmissions:qp,deleteFormSubmission:di,deleteFormSubmissions:ht}=ci.actions,ui=t=>t.formSubmissionReducer.instances,oi=l.createSelector([ui],t=>Object.values(t)),li=t=>e=>e.formSubmissionReducer.instances[t],ad=S(l.createSelector([ui,rt,(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))})),cd=S(l.createSelector([oi,(t,e)=>e],(t,e)=>Object.values(t).filter(s=>s.issue===e))),rd=S(l.createSelector([oi,(t,e)=>e],(t,e)=>t.filter(s=>s.asset===e))),dd=ci.reducer,ee=I(t=>t.uuid),ud=ee.getInitialState({}),hi=l.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:od,setGeoImage:Le,setGeoImages:ld,addGeoImage:hd,addGeoImages:md,updateGeoImage:pd,updateGeoImages:Mp,deleteGeoImage:mi,deleteGeoImages:Ad}=hi.actions,yd=t=>t.geoImageReducer.instances,fd=l.createSelector([yd],t=>Object.values(t)),pi=t=>e=>e.geoImageReducer.instances[t],kp=S(l.createSelector([fd,(t,e)=>e],(t,e)=>g(t.filter(s=>s.project===e)))),Sd=hi.reducer,te=I(t=>t.uuid),gd=te.getInitialState({}),Ai=l.createSlice({name:"issueAssociations",initialState:gd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,gd)),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:Td,setIssueAssociations:Cp,setIssueAssociation:zp,updateIssueAssociation:bd,updateIssueAssociations:Dp,addIssueAssociation:yi,addIssueAssociations:fi,deleteIssueAssociation:Si,deleteIssueAssociations:gi}=Ai.actions,Ne=t=>t.issueAssociationReducer.instances,Vp=l.createSelector([Ne],t=>Object.values(t)),Id=t=>e=>e.issueAssociationReducer.instances[t],Fd=S(l.createSelector([Ne,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.associated_issue===e)))),Rd=S(l.createSelector([Ne,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Pd=S(l.createSelector([Ne,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.asset===e)))),Od=Ai.reducer,se=I(t=>t.uuid),vd=se.getInitialState({}),Ti=l.createSlice({name:"issueAttachments",initialState:vd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,vd)),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:bi,addIssueAttachment:Up,addIssueAttachments:Ii,setIssueAttachment:_d,setIssueAttachments:$p,updateIssueAttachment:Bp,updateIssueAttachments:wd,deleteIssueAttachment:Ed,deleteIssueAttachments:Fi}=Ti.actions,jd=t=>t.issueAttachmentReducer.instances,qd=l.createSelector([jd],t=>Object.values(t)),Md=S(l.createSelector([qd,(t,e)=>e],(t,e)=>g(t.filter(({issue:s})=>e===s)))),kd=t=>e=>e.issueAttachmentReducer.instances[t],Cd=Ti.reducer,ie=I(t=>t.uuid),zd=ie.getInitialState({}),Ri=l.createSlice({name:"issueCommentAttachments",initialState:zd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,zd)),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:Pi,addIssueCommentAttachment:Gp,addIssueCommentAttachments:Dd,setIssueCommentAttachment:Vd,setIssueCommentAttachments:Lp,updateIssueCommentAttachment:Np,updateIssueCommentAttachments:Ud,deleteIssueCommentAttachment:$d,deleteIssueCommentAttachments:Bd}=Ri.actions,Gd=t=>t.issueCommentAttachmentReducer.instances,Ld=l.createSelector([Gd],t=>Object.values(t)),Nd=t=>e=>e.issueCommentAttachmentReducer.instances[t],Hp=S(l.createSelector([Ld,(t,e)=>e],(t,e)=>g(t.filter(({issue_comment:s})=>e===s)))),Hd=Ri.reducer,ge=I(t=>t.uuid),Wd=ge.getInitialState({}),Oi=l.createSlice({name:"issueComments",initialState:Wd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Wd)),reducers:{addIssueComment:ge.addOne,addIssueComments:ge.addMany,setIssueComment:ge.setOne,setIssueComments:ge.setMany,deleteIssueComment:ge.deleteOne,deleteIssueComments:ge.deleteMany}}),{setIssueComments:Kd,setIssueComment:vi,addIssueComment:_i,addIssueComments:Wp,deleteIssueComment:wi,deleteIssueComments:Kp}=Oi.actions,Yd=t=>t.issueCommentReducer.instances,Ei=t=>e=>e.issueCommentReducer.instances[t],Yp=S(l.createSelector([Yd,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),Jd=Oi.reducer,Te=I(t=>t.uuid),Xd=Te.getInitialState({}),ji=l.createSlice({name:"issues",initialState:Xd,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Xd)}),reducers:{initializeIssues:Te.initialize,addIssue:Te.addOne,addIssues:Te.addMany,updateIssue:Te.updateOne,deleteIssue:Te.deleteOne,deleteIssues:Te.deleteMany}}),{initializeIssues:Qd,addIssue:qi,addIssues:Zd,updateIssue:mt,deleteIssue:Mi,deleteIssues:xd}=ji.actions,eu=t=>t.issueReducer.instances,ki=t=>e=>e.issueReducer.instances[t],Jp=S(l.createSelector([eu,(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)})),tu=ji.reducer,ne=I(t=>t.uuid),su=ne.getInitialState({}),Ci=l.createSlice({name:"issueTypeAttachments",initialState:su,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,su)),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:zi,addIssueTypeAttachment:Xp,addIssueTypeAttachments:iu,setIssueTypeAttachment:nu,setIssueTypeAttachments:Qp,updateIssueTypeAttachment:Zp,updateIssueTypeAttachments:au,deleteIssueTypeAttachment:cu,deleteIssueTypeAttachments:ru}=Ci.actions,du=t=>t.issueTypeAttachmentReducer.instances,uu=l.createSelector([du],t=>Object.values(t)),ou=t=>e=>e.issueTypeAttachmentReducer.instances[t],xp=S(l.createSelector([uu,(t,e)=>e],(t,e)=>g(t.filter(({issue_type:s})=>e===s)))),lu=Ci.reducer,ae=I(t=>t.uuid),hu=ae.getInitialState({}),Di=l.createSlice({name:"issueTypeFieldsAttachments",initialState:hu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,hu)),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:mu,addIssueTypeFieldsAttachment:eA,addIssueTypeFieldsAttachments:pu,setIssueTypeFieldsAttachment:tA,setIssueTypeFieldsAttachments:sA,updateIssueTypeFieldsAttachment:iA,updateIssueTypeFieldsAttachments:Au,deleteIssueTypeFieldsAttachment:nA,deleteIssueTypeFieldsAttachments:yu}=Di.actions,fu=t=>t.issueTypeFieldsAttachmentReducer.instances,Su=l.createSelector([fu],t=>Object.values(t)),aA=S(l.createSelector([Su,(t,e)=>e],(t,e)=>g(t.filter(s=>s.fields_revision===e)))),cA=t=>e=>e.issueTypeFieldsAttachmentReducer.instances[t],gu=Di.reducer,ce=I(t=>t.uuid),Tu=ce.getInitialState({}),Vi=l.createSlice({name:"issueTypeFieldValues",initialState:Tu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Tu)),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:bu,addIssueTypeFieldValues:Ui,addIssueTypeFieldValuesMany:rA,setIssueTypeFieldValues:dA,setIssueTypeFieldValuesMany:uA,updateIssueTypeFieldValues:He,updateIssueTypeFieldValuesMany:oA,deleteIssueTypeFieldValues:$i,deleteIssueTypeFieldValuesMany:lA}=Vi.actions,Iu=t=>t.issueTypeFieldValuesReducer.instances,Bi=l.createSelector([Iu],t=>Object.values(t)),hA=S(l.createSelector([Bi,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue===e)))),Gi=t=>e=>e.issueTypeFieldValuesReducer.instances[t],Fu=Vi.reducer,re=I(t=>t.uuid),Ru=re.getInitialState({}),Li=l.createSlice({name:"issueTypeFields",initialState:Ru,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ru)),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:Pu,addIssueTypeFields:Ou,addIssueTypeFieldsMany:mA,setIssueTypeFields:pA,setIssueTypeFieldsMany:AA,updateIssueTypeFields:vu,updateIssueTypeFieldsMany:yA,deleteIssueTypeFields:_u,deleteIssueTypeFieldsMany:fA}=Li.actions,wu=t=>t.issueTypeFieldsReducer.instances,pt=l.createSelector([wu],t=>Object.values(t)),SA=S(l.createSelector([pt,(t,e)=>e],(t,e)=>g(t.filter(s=>s.issue_type===e)))),gA=S(l.createSelector([pt,(t,e)=>e],(t,e)=>t.filter(s=>s.issue_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),TA=S(l.createSelector([pt,Bi,(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)))})),bA=t=>e=>e.issueTypeFieldsReducer.instances[t],Eu=Li.reducer,de=I(t=>t.uuid),ju=de.getInitialState({}),Ni=l.createSlice({name:"issueTypeFieldValuesAttachments",initialState:ju,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ju)),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:qu,addIssueTypeFieldValuesAttachment:IA,addIssueTypeFieldValuesAttachments:At,setIssueTypeFieldValuesAttachment:FA,setIssueTypeFieldValuesAttachments:RA,updateIssueTypeFieldValuesAttachment:PA,updateIssueTypeFieldValuesAttachments:Mu,deleteIssueTypeFieldValuesAttachment:OA,deleteIssueTypeFieldValuesAttachments:yt}=Ni.actions,Hi=t=>t.issueTypeFieldValuesAttachmentReducer.instances,ku=l.createSelector([Hi],t=>Object.values(t)),vA=t=>e=>e.issueTypeFieldValuesAttachmentReducer.instances[t],Cu=S(l.createSelector([Hi,(t,e)=>e],(t,e)=>{const s=new Set(e);return g(Object.values(t).filter(n=>s.has(n.uuid)))})),zu=S(l.createSelector([ku,(t,e)=>e],(t,e)=>g(t.filter(s=>s.field_values===e)))),Du=Ni.reducer,we=I(t=>t.uuid),Vu=we.getInitialState({}),Wi=l.createSlice({name:"issueTypes",initialState:Vu,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Vu)}),reducers:{initializeIssueTypes:we.initialize,setIssueType:we.setOne,addIssueType:we.addOne,updateIssueType:we.updateOne,removeIssueType:we.deleteOne}}),{initializeIssueTypes:Uu,setIssueType:We,addIssueType:$u,updateIssueType:Bu,removeIssueType:Ki}=Wi.actions,Gu=t=>t.issueTypeReducer.instances,Lu=l.createSelector(Gu,t=>Object.values(t)),Yi=t=>e=>e.issueTypeReducer.instances[t],_A=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},wA=S(l.createSelector([Lu,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Ji=S(l.createSelector([t=>t.issueReducer.instances,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue_type===e)))),EA=t=>e=>Ji(t)(e).length,Nu=Wi.reducer,be=I(t=>t.uuid),Hu=be.getInitialState({}),Xi=l.createSlice({name:"issueUpdates",initialState:Hu,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Hu)),reducers:{initializeIssueUpdates:be.setMany,setIssueUpdate:be.setOne,addIssueUpdate:be.addOne,addIssueUpdates:be.addMany,deleteIssueUpdate:be.deleteOne,deleteIssueUpdates:be.deleteMany}}),{initializeIssueUpdates:Wu,setIssueUpdate:jA,addIssueUpdate:Ku,addIssueUpdates:Yu,deleteIssueUpdate:Ju,deleteIssueUpdates:Xu}=Xi.actions,Qu=t=>t.issueUpdateReducer.instances,Zu=S(l.createSelector([Qu,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.issue===e)))),xu=Xi.reducer,ft=I(t=>t.uuid),eo=ft.getInitialState({}),Qi=l.createSlice({name:"license",initialState:eo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,eo)),reducers:{initializeLicences:ft.initialize,addLicenses:ft.addMany,updateLicense:ft.updateOne}}),{initializeLicences:to,addLicenses:qA,updateLicense:pe}=Qi.actions,St=t=>t.licenseReducer.instances,MA=t=>e=>e.licenseReducer.instances[t],so=t=>e=>Object.values(e.licenseReducer.instances).find(s=>s.project===t),kA=l.createSelector([St],t=>g(Object.values(t).filter(e=>e.is_active))),CA=l.createSelector([St],t=>Oe(Object.values(t).filter(e=>e.project).reduce((e,s)=>({...e,[s.project]:s}),{}))),io=Qi.reducer,k=I(t=>t.uuid),no=k.getInitialState({currentUser:null}),Zi=l.createSlice({name:"users",initialState:no,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,no)),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.uuid];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:zA,setUsers:ao,setUser:DA,addUsers:VA,addUser:UA,updateUsers:$A,updateUser:BA,deleteUser:GA,deleteUsers:LA,removeUser:co,setCurrentUser:NA,setProfilePicture:HA}=Zi.actions,ro=Zi.reducer,gt=t=>t.userReducer.currentUser,Tt=t=>t.userReducer.instances,WA=t=>e=>e.userReducer.instances[t],KA=S(l.createSelector([Tt,(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)})),bt=I(t=>t.uuid),uo=bt.getInitialState({}),xi=l.createSlice({name:"organizationAccess",initialState:uo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,uo)),reducers:{initializeOrganizationAccesses:bt.initialize,updateOrganizationAccess:bt.updateOne,deleteOrganizationAccess:bt.deleteOne}}),{initializeOrganizationAccesses:oo,updateOrganizationAccess:lo,deleteOrganizationAccess:ho}=xi.actions,en=t=>t.organizationAccessReducer.instances,YA=t=>e=>e.organizationAccessReducer.instances[t],JA=l.createSelector([gt,en],(t,e)=>Object.values(e).find(n=>n.user===(t==null?void 0:t.uuid))??null),XA=t=>e=>Object.values(e.organizationAccessReducer.instances).find(s=>s.user===t.uuid),mo=t=>{const e={};for(const s of Object.values(t.organizationAccessReducer.instances))e[s.user]=s;return Oe(e)},po=xi.reducer,Ke=I(t=>t.uuid),Ao=Ke.getInitialState({}),tn=l.createSlice({name:"projectAccess",initialState:Ao,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ao)),reducers:{initializeProjectAccesses:Ke.initialize,updateProjectAccess:Ke.updateOne,deleteProjectAccess:Ke.deleteOne,deleteProjectAccesses:Ke.deleteMany}}),{initializeProjectAccesses:sn,updateProjectAccess:yo,deleteProjectAccess:fo,deleteProjectAccesses:So}=tn.actions,nn=t=>t.projectAccessReducer.instances,go=l.createSelector(nn,t=>Object.values(t)),QA=t=>e=>e.projectAccessReducer.instances[t],ZA=t=>e=>Object.values(e.projectAccessReducer.instances).find(s=>s.user===t.uuid),To=t=>{const e={};for(const s of Object.values(t.projectAccessReducer.instances))e[s.user]=s;return Oe(e)},bo=tn.reducer,ue=I(t=>t.uuid),Io=ue.getInitialState({}),an=l.createSlice({name:"projects",initialState:Io,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Io)),reducers:{initializeProjects:ue.initialize,setProjects:ue.setMany,setProject:ue.setOne,addProjects:ue.addMany,addProject:ue.addOne,updateProjects:ue.updateMany,updateProject:ue.updateOne,deleteProject:ue.deleteOne,deleteProjects:ue.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:xA,setProjects:Fo,setProject:ey,addProjects:ty,addProject:sy,updateProjects:iy,updateProject:Ro,deleteProject:Po,deleteProjects:ny,acceptProjectInvite:Oo}=an.actions,vo=an.reducer,It=t=>t.projectReducer.instances,ay=l.createSelector([It],t=>g(Object.values(t))),cy=t=>e=>e.projectReducer.instances[t],_o=l.createSelector([nn],t=>Object.values(t).map(e=>e.user)),wo=l.createSelector([_o,Tt],(t,e)=>t.reduce((s,n)=>({...s,[n]:e[n]}),{})),ry=l.createSelector([gt,wo,To],(t,e,s)=>g(Object.values(e).sort((n,a)=>{if(n.uuid===(t==null?void 0:t.uuid))return-1;if(a.uuid===(t==null?void 0:t.uuid))return 1;const c=s[n.uuid],r=s[a.uuid];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)===Ot.ADMIN?-1:1}))),oe=I(t=>t.uuid),Eo=oe.getInitialState({}),cn=l.createSlice({name:"organizations",initialState:Eo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Eo)),reducers:{initializeOrganizations:oe.initialize,setOrganizations:oe.setMany,setOrganization:oe.setOne,addOrganizations:oe.addMany,addOrganization:oe.addOne,updateOrganizations:oe.updateMany,updateOrganization:oe.updateOne,deleteOrganization:oe.deleteOne,deleteOrganizations:oe.deleteMany}}),{initializeOrganizations:dy,setOrganizations:jo,setOrganization:uy,addOrganizations:oy,addOrganization:ly,updateOrganizations:hy,updateOrganization:my,deleteOrganization:py,deleteOrganizations:Ay}=cn.actions,qo=t=>t.organizationReducer.instances,Mo=l.createSelector([qo],t=>Object.values(t)),yy=t=>e=>e.organizationReducer.instances[t],fy=l.createSelector([Mo],t=>g(Object.values(t).filter(e=>e.has_access))),ko=l.createSelector([en],t=>Object.values(t).map(e=>e.user)),Sy=S(l.createSelector([It,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.organization_owner===e)))),gy=S(l.createSelector([St,(t,e)=>e],(t,e)=>g(Object.values(t).filter(s=>s.organization_owner===e)))),Co=l.createSelector([ko,Tt],(t,e)=>Oe(t.reduce((s,n)=>({...s,[n]:e[n]}),{}))),Ty=l.createSelector([gt,Co,mo],(t,e,s)=>g(Object.values(e).sort((n,a)=>{if(n.uuid===(t==null?void 0:t.uuid))return-1;if(a.uuid===(t==null?void 0:t.uuid))return 1;const c=s[n.uuid],r=s[a.uuid];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}))),zo=cn.reducer,Do=(t,e,s)=>{const n=t.uuid?t:{...t,uuid:_.v4()};return{payload:n,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:n,BASE_URL:e,serviceName:s}}}}},Vo={deletedRequests:[],latestRetryTime:0},rn=l.createSlice({name:"outbox",initialState:Vo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Vo)),reducers:{enqueueRequest:{reducer:(t,e)=>t,prepare:t=>{console.debug("Preparing to enqueue request",t);const{BASE_URL:e,serviceName:s,...n}=t;return Do(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}}}),by=t=>t.outboxReducer.deletedRequests,Iy=t=>t.outboxReducer.latestRetryTime,{enqueueRequest:Uo,markForDeletion:Fy,markAsDeleted:$o,_setLatestRetryTime:Bo}=rn.actions,Go=rn.reducer,le=I(t=>t.uuid),Lo=le.getInitialState({}),dn=l.createSlice({name:"projectAttachments",initialState:Lo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Lo)),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:No,addProjectAttachment:Ry,addProjectAttachments:Ho,setProjectAttachment:Wo,setProjectAttachments:Ko,updateProjectAttachment:Py,updateProjectAttachments:Yo,deleteProjectAttachment:Jo,deleteProjectAttachments:un}=dn.actions,Xo=t=>t.projectAttachmentReducer.instances,Qo=l.createSelector([Xo],t=>Object.values(t)),Zo=t=>e=>e.projectAttachmentReducer.instances[t],xo=S(l.createSelector([Qo,(t,e)=>e],(t,e)=>g(t.filter(({project:s})=>e===s)))),el=dn.reducer,he=I(t=>t.uuid),tl=he.getInitialState({activeProjectFileId:null,isImportingProjectFile:!1}),on=l.createSlice({name:"projectFiles",initialState:tl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,tl)),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:sl,setProjectFile:Oy,setProjectFiles:vy,addProjectFile:_y,addProjectFiles:il,updateProjectFile:ln,updateProjectFiles:wy,deleteProjectFile:nl,deleteProjectFiles:al,setIsImportingProjectFile:cl,setActiveProjectFileId:rl,saveActiveProjectFileBounds:dl,resetProjectFileObjectUrls:Ey}=on.actions,ul=t=>t.projectFileReducer.instances,ol=l.createSelector([ul],t=>g(Object.values(t).sort((e,s)=>e.z_index-s.z_index))),jy=t=>e=>e.projectFileReducer.instances[t],qy=t=>t.projectFileReducer.activeProjectFileId,My=t=>t.projectFileReducer.isImportingProjectFile,ll=on.reducer,ky={isRehydrated:!1},hn=l.createSlice({name:"rehydrated",initialState:ky,reducers:{setRehydrated:(t,e)=>{t.isRehydrated=e.payload}}}),{setRehydrated:Cy}=hn.actions,zy=t=>t.rehydratedReducer.isRehydrated,hl=hn.reducer,Ee=I(t=>t.uuid),ml=Ee.getInitialState({}),mn=l.createSlice({name:"teams",initialState:ml,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ml)),reducers:{setTeam:Ee.setOne,initializeTeams:Ee.initialize,addTeam:Ee.addOne,updateTeam:Ee.updateOne,deleteTeam:Ee.deleteOne}}),{setTeam:je,initializeTeams:pl,addTeam:Al,updateTeam:pn,deleteTeam:An}=mn.actions,yn=t=>t.teamReducer.instances,fn=l.createSelector([yn],t=>Object.values(t)),qe=t=>e=>e.teamReducer.instances[t],Dy=S(l.createSelector([yn,(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)})),Vy=S(l.createSelector([fn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.organization===e)))),Uy=S(l.createSelector([fn,(t,e)=>e],(t,e)=>g(t.filter(s=>s.members.includes(e))))),yl=mn.reducer,$y={version:0},fl=l.createSlice({name:"versioning",initialState:$y,reducers:{}}),Sl=fl.reducer;let gl;function By(t){gl=t}function Ye(){return gl}let Tl;function Gy(t){Tl=t}function Ly(){return Tl}const bl={};class Il{constructor(e){f(this,"client");bl[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 Fl="versioning",Rl=()=>vl.length-1,Pl=t=>(t[Fl]={version:Rl()},t),Ol=()=>Pl({}),Ny=t=>(t.outboxReducer&&(t.outboxReducer.deletedRequests=[]),t),Hy=t=>e=>{var s;return e===void 0&&(e={}),((s=e[Fl])==null?void 0:s.version)===Rl()?e:t(e)},vl=[Pl,Ol,Ol,Ny],Wy=Object.fromEntries(vl.map((t,e)=>[e,Hy(t)])),Sn="versioning",_l={[Sn]:Sl,fileReducer:wr,authReducer:Jc,categoryReducer:er,assetReducer:Ha,assetAttachmentReducer:ta,assetStageCompletionReducer:Xa,assetStageReducer:sc,assetTypeReducer:Wc,assetTypeAttachmentReducer:pc,issueReducer:tu,issueAttachmentReducer:Cd,issueTypeReducer:Nu,issueTypeAttachmentReducer:lu,organizationReducer:zo,outboxReducer:Go,projectReducer:vo,projectAttachmentReducer:el,projectAccessReducer:bo,organizationAccessReducer:po,projectFileReducer:ll,rehydratedReducer:hl,formReducer:Kr,formRevisionReducer:Nr,formRevisionAttachmentReducer:zr,formSubmissionAttachmentReducer:td,formSubmissionReducer:dd,userReducer:ro,emailDomainsReducer:Rr,licenseReducer:io,documentsReducer:Sr,documentAttachmentReducer:lr,teamReducer:yl,agentsReducer:Wn,issueCommentReducer:Jd,issueCommentAttachmentReducer:Hd,issueUpdateReducer:xu,geoImageReducer:Sd,issueAssociationReducer:Od,issueTypeFieldsReducer:Eu,issueTypeFieldValuesReducer:Fu,issueTypeFieldsAttachmentReducer:gu,issueTypeFieldValuesAttachmentReducer:Du,assetTypeFieldsReducer:wc,assetTypeFieldValuesReducer:Lc,assetTypeFieldsAttachmentReducer:Ic,assetTypeFieldValuesAttachmentReducer:zc,assetProcedureReducer:$a,assetProcedureInstanceReducer:za,assetProcedureFieldsReducer:ya,assetProcedureFieldValuesReducer:Ea,assetProcedureFieldsAttachmentReducer:ua,assetProcedureFieldValuesAttachmentReducer:Fa},wl=l.combineReducers(_l),El="RESET",Ky=(t,e)=>e.type==="auth/setLoggedIn"&&!e.payload?wl(void 0,e):wl(t,e);let gn=null;function Ie(){const t=Ye();if(!t)return console.warn("Client store not set; cannot get outbox coordinator yet."),null;if(gn)return gn;const e=t.getState().offline.outbox,s=ke._fromOutbox(e);return gn=s,s}const Yy=t=>{if(t)throw t;const e=Ye();e?e.dispatch({type:"rehydrated/setRehydrated",payload:!0}):console.error("Client store not set")},jl=(t,e,s)=>{const n=Ie();return n?(n.addRequest(e),n.getQueue()):(console.warn("Outbox coordinator not set; cannot enqueue request yet."),[])},ql=(t,e,s)=>{const n=Ie();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 Jy(t,e){if(!e.payload)throw new Error("Received empty payload");return af(e)}const Xy={...Pn,effect:Jy,discard:bn,returnPromises:!0,persistCallback:Yy,retry:rf,persistOptions:{storage:$l},queue:{...Pn.queue,enqueue:jl,dequeue:ql,peek:(...t)=>cf(...t)}},Qy=Bl(Wy,Sn),Zy=l.compose(Ul.offline(Xy),Qy);function xy(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 Tn(t,e){const s=bl[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:h,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=E=>{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 Qe=me.fields["x-amz-checksum-sha1"];if(!Qe)throw new Error(`No checksum for file ${p}`);return E.set("x-amz-checksum-sha1",Qe).field({...u,...me.fields}).attach("file",O)}return E.send(u)},AS={[o.GET]:()=>b?Pe.get(T.toString()).responseType("blob"):Pe.get(T.toString()),[o.POST]:()=>{const E=Pe.post(T.toString());return M(E)},[o.PATCH]:()=>{const E=Pe.patch(T.toString());return M(E)},[o.PUT]:()=>{const E=Pe.put(T.toString());return M(E)},[o.DELETE]:()=>{const E=Pe.delete(T.toString());return M(E)}}[d];let Re=AS();if(y&&n){const E=s.auth.getAuthHeader();Re=Re.set("Authorization",E)}m&&(Re=Re.set(m));try{return await Re.query(h)}catch(E){const me=xy(E),Qe=me==null?void 0:me.status;if(n&&Qe===401)return await s.auth.handleUnauthorized(Re,me),Re.query(h);throw new q({response:me,innerError:E,discard:kl.includes(Qe)})}}class ef{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 Ml{constructor(){f(this,"next");this.next=null}then(e){return new ef(this).then(e)}async run(e){if(this.next)return this.next.run(e);{if(console.debug("Middleware finished. Performing request:",e),!Ye())throw new Error("Client store not set");const n=Ly();if(!n)throw new Error("Client SDK not set");return Tn(e,n)}}}class tf extends Ml{async run(e){return super.run(e)}}class sf extends Ml{async run(e){return super.run(e)}}const nf=new tf().then(new sf).compile();function af(t){var e;return(e=nf[0])==null?void 0:e.run(t)}const kl=[400,409,403,404,405,500];function bn(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=Ye(),c=n.getState().outboxReducer.deletedRequests,r=e.payload.uuid;function u(){n.dispatch($o(r));const h=Ie();if(!h)throw new Error("Outbox coordinator not set");h.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 h=t.status||((d=t.response)==null?void 0:d.status);if(h||console.warn("Error has no status code:",t),h!==void 0&&Cl.includes(h)){console.warn("Discarding request due to error:",t,`
5
- Action:`,e);const p=Ie();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=Ie();if(!m)throw new Error("Outbox coordinator not set");return m.registerRetry(e.payload.uuid),!1}function cf(t,e,s){var n;return(n=Ie())==null?void 0:n.peek()}function rf(t,e){return Ye().dispatch(Bo(new Date().getTime())),qn}const Me="An unknown error occurred",df=500,kl=["non_field_errors","detail"];function uf(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"?kl.includes(a)?c:`${a}: ${c}`:Array.isArray(c)?kl.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=Ye(),c=n.getState().outboxReducer.deletedRequests,r=e.payload.uuid;function u(){n.dispatch($o(r));const h=Ie();if(!h)throw new Error("Outbox coordinator not set");h.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 h=t.status||((d=t.response)==null?void 0:d.status);if(h||console.warn("Error has no status code:",t),h!==void 0&&kl.includes(h)){console.warn("Discarding request due to error:",t,`
5
+ Action:`,e);const p=Ie();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=Ie();if(!m)throw new Error("Outbox coordinator not set");return m.registerRetry(e.payload.uuid),!1}function cf(t,e,s){var n;return(n=Ie())==null?void 0:n.peek()}function rf(t,e){return Ye().dispatch(Bo(new Date().getTime())),qn}const Me="An unknown error occurred",df=500,Cl=["non_field_errors","detail"];function uf(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"?Cl.includes(a)?c:`${a}: ${c}`:Array.isArray(c)?Cl.includes(a)?c.join(`
6
6
  `):c.map(r=>`${a}: ${r}`).join(`
7
7
  `):`${a}: ${JSON.stringify(c)}`).join(`
8
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>df?Me:s}class q extends Error{constructor(s){super(Me);f(this,"status");f(this,"response");f(this,"message");f(this,"options");const{response:n,innerError:a}=s;this.message=s.message??uf(n,a)??Me,this.status=(n==null?void 0:n.status)??0,this.response=n,s.discard=s.discard??!1,this.options=s}}class of{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 Mn,c={...e,BASE_URL:s,serviceName:n};if(e.immediate){const r={...c,uuid:e.uuid??_.v4()},u={payload:r,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:r,BASE_URL:s,serviceName:n}}}};Tn(u,this).then(m=>{a.resolve(m.body)}).catch(m=>{bn(m,u),m instanceof Error?a.reject(m):a.reject(new Error((m??Me).toString()))})}else{const r=this.store.dispatch(Uo(c)),u=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(u,m)}return a}}class Ce{constructor(){f(this,"graph");f(this,"requestAttemptCounter");this.graph=new Gl.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 lf=(t,e)=>{const s=new e(t);return Gy(s),By(t),s};class P extends Il{constructor(s,n){super(s);f(this,"auth");this.auth=n}}class hf extends P{async startConversation(e,s){return this.enqueueRequest({description:"Start agent conversation",method:o.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:s},blockers:["prompt"],blocks:["prompt"]}).then(n=>(this.dispatch(Ln(n)),n))}async continueConversation(e,s,n){return this.enqueueRequest({description:"Prompt agent",method:o.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:n},blockers:["prompt"],blocks:["prompt"],queryParams:{conversation_id:s}}).then(a=>{this.dispatch(Hn(a))})}async fetchDetails(e){return this.enqueueRequest({description:"Get agent conversation",method:o.GET,url:`/agents/conversations/${e}/`,blockers:["conversation"],blocks:["conversation"]}).then(s=>{this.dispatch(Nn(s))})}async rate(e,s){return this.enqueueRequest({description:"Rate agent response",method:o.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:o.GET,url:`/projects/${e}/agent-conversations/`,blockers:["agent-conversations"],blocks:["agent-conversations"]});this.dispatch(Gn(s))}}class j extends P{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:n,assetTypeAttachmentReducer:a,documentAttachmentReducer:c,projectAttachmentReducer:r,formRevisionAttachmentReducer:u,formSubmissionAttachmentReducer:m,geoImageReducer:d,assetTypeFieldsAttachmentReducer:h,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(h.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:o.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:n,blockers:[`s3-${a.fields.key}`],blocks:[n],s3url:a});return s}async getFilePayload(e){const s=await ve(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 Fe extends j{async _bulkAdd(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.uuid,a=new Date().toISOString(),c=[],r=[],u={};for(const h of e){const{modelUuid:p,file:A}=h,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:o.POST,url:`${this.url}/bulk/`,payload:{submitted_at:a,attachments:r,files:Object.values(u)},blocks:c.map(h=>h.uuid),blockers:c.map(h=>h.file_sha1)});return m.then(({attachments:h,presigned_urls:p})=>{this.dispatch(this.updateAttachments(h)),this.processPresignedUrls(p)}).catch(()=>{this.dispatch(this.removeAttachments(c.map(h=>h.uuid)))}),[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 uuid ${e} that does not exist in the store`);this.dispatch(this.removeAttachment(n.uuid));const a=this.enqueueRequest({description:`Delete ${this.name}`,method:o.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 mf extends Fe{constructor(){super(...arguments);f(this,"name","Asset Attachment");f(this,"url","/asset-attachments");f(this,"initializeAttachments",Dt);f(this,"addAttachments",Vt);f(this,"updateAttachments",Jn);f(this,"removeAttachments",Ut);f(this,"removeAttachment",Xn);f(this,"setAttachment",Yn);f(this,"selectAttachment",xn)}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:o.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch(Dt(n))}}class pf extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.uuid,a={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:h,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:h,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:h};r.push(F)}this.dispatch(na(c));const u=this.enqueueRequest({description:"Add asset procedure fields attachments",method:o.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(aa(d.attachments))}).catch(()=>{this.dispatch(ca(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:o.GET,url:"/asset-procedure-fields-attachments/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(ia(s))}}class Af extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(ha(c));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:o.POST,url:"/asset-procedure-fields/",payload:c,blockers:[c.asset_procedure],blocks:[c.uuid]});return r.then(m=>{this.dispatch(ma(m))}).catch(m=>{throw this.dispatch(pa(c.uuid)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:o.GET,url:"/asset-procedure-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(la(s))}}function Je(t,e){const s=[];let n=0;const a=t.length;for(;n<a;)s.push(t.slice(n,n+=e));return s}class yf 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.uuid,c=Je(e,s??e.length),r=[],u=[];for(const h of c){const p={},A=[];for(const y of h){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 Pt={uuid:M.uuid,file_name:T.name,file_sha1:O.sha1,file_extension:O.extension,field_identifier:F,field_values:b};A.push(Pt)}u.push({submitted_at:n,attachments:A,files:Object.values(p)})}this.dispatch(Ze(r));const m=u.map(h=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:o.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:h,blockers:h.attachments.map(p=>p.field_values),blocks:h.attachments.map(p=>p.uuid)}));return Promise.all(m).then(h=>{for(const A of h)this.processPresignedUrls(A.presigned_urls);const p=h.flatMap(A=>A.attachments);this.dispatch(ga(p))}).catch(h=>{throw this.dispatch(xe(r.map(p=>p.uuid))),h}),[r,m.map(h=>h.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=ba(e)(n);this.dispatch(xe(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:o.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(Ze(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values attachments",method:o.GET,url:"/asset-procedure-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Sa(s))}}const ff=t=>Array.isArray(t)&&t[0]instanceof File,Xe=t=>{const e={},s={};for(const n in t){const a=t[n];a instanceof File?e[n]=[a]:ff(a)?e[n]=a:a!==void 0&&(s[n]=a)}return{values:s,files:e}};class Sf extends j{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.uuid,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add form submission",method:o.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(ri(a)),c.then(u=>(this.dispatch(ot(u)),u)).catch(()=>{this.dispatch(di(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 submission with uuid ${e.uuid} to exist`);const c={...a,...e};this.dispatch(nd(c));const r=this.enqueueRequest({description:"Delete user form submissions",method:o.PATCH,url:`/form-submissions/${c.uuid}/`,payload:e,blockers:[c.uuid],blocks:[c.uuid]});return r.then(u=>{this.dispatch(ot(u))}).catch(()=>{this.dispatch(ot(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=ed(e)(n);this.dispatch(di(e)),this.dispatch(ut(c.map(r=>r.uuid)));try{return await this.enqueueRequest({description:"Delete user form submissions",method:o.DELETE,url:`/form-submissions/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ri(a)),this.dispatch(dt(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch form submissions",method:o.GET,url:"/form-submissions/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(id(s))}}class gf 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.uuid,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset procedure field values",method:o.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(Wt(a)),c.then(u=>(this.dispatch(ze(u)),u)).catch(()=>{this.dispatch(Kt(a.uuid))}),[a,c]}bulkAdd(e,s){var d;const n=new Date().toISOString(),{values:a}=Xe(e.values),c=[],r=Je(e.payloads,s??e.payloads.length),u=[];for(const h of r){const p=[];for(const A of h){const y=R({...A,values:Xe(A.values).values,created_by:(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.uuid,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(Oa(c));const m=[];for(const h of u){const p=h.field_values.map(T=>T.asset),A=h.field_values.map(T=>T.fields_revision),y=h.field_values.map(T=>T.asset_procedure_instance),b=h.field_values.map(T=>T.uuid),F=this.enqueueRequest({description:"Bulk add asset procedure field values",method:o.POST,url:"/asset-procedure-field-values/bulk/",payload:h,blockers:[...p,...A,...y],blocks:b});m.push(F)}return Promise.all(m).then(h=>{this.dispatch(va(h.flat()))}).catch(()=>{this.dispatch(_a(c.map(h=>h.uuid)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=Jt(e.uuid)(n);if(!a)throw new Error(`Expected AssetProcedureFieldValues with uuid ${e.uuid} to exist`);const c={...a,...e};this.dispatch(ze(c));const r=this.enqueueRequest({description:"Update asset procedure field values",method:o.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(ze(u))}).catch(()=>{this.dispatch(ze(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Jt(e)(n);if(!a)throw new Error(`Expected submission with uuid ${e} to exist`);const c=Ia(e)(n);this.dispatch(Kt(e)),this.dispatch(xe(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset procedure field values",method:o.DELETE,url:`/asset-procedure-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Wt(a)),this.dispatch(Ze(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values",method:o.GET,url:"/asset-procedure-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Pa(s))}}class Tf extends P{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Qt(c));const r=this.enqueueRequest({description:"Create asset procedure instance",method:o.POST,url:"/asset-procedure-instances/",payload:v(c),blockers:[e.asset_procedure,e.asset_type],blocks:[c.uuid]});return r.then(u=>{this.dispatch(De(u))}).catch(()=>{this.dispatch(Zt(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,n=ts(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(De(a));const c=this.enqueueRequest({description:"Update asset procedure instance",method:o.PATCH,url:`/asset-procedure-instances/${e.uuid}/`,payload:e,blockers:[n.uuid],blocks:[n.uuid]});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=ts(e)(n);if(!a)throw new Error(`Expected asset procedure instance with uuid ${e} to exist`);return this.dispatch(Zt(e)),this.enqueueRequest({description:"Delete asset procedure instance",method:o.DELETE,url:`/asset-procedure-instances/${e}/`,blockers:[e],blocks:[]}).catch(c=>{throw this.dispatch(Qt(a)),c})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure instances",method:o.GET,url:"/asset-procedure-instances/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(qa(s))}}class bf extends P{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(is(c));const r=this.enqueueRequest({description:"Create asset procedure",method:o.POST,url:"/asset-procedures/",payload:v(c),blockers:[],blocks:[c.uuid]});return r.then(u=>{this.dispatch(Ve(u))}).catch(()=>{this.dispatch(ns(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,n=cs(e.uuid)(s.getState());if(!n)throw new Error(`Expected asset procedure with uuid ${e.uuid} to exist`);const a={...n,...e};this.dispatch(Ve(a));const c=this.enqueueRequest({description:"Update asset procedure",method:o.PATCH,url:`/asset-procedures/${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=cs(e)(n);if(!a)throw new Error(`Expected asset procedure with uuid ${e} to exist`);const c=ka(e)(n);return this.dispatch(ns(e)),this.dispatch(Ca(c.map(r=>r.uuid))),this.enqueueRequest({description:"Delete asset procedure",method:o.DELETE,url:`/asset-procedures/${e}/`,blockers:[e],blocks:[]}).catch(r=>{throw this.dispatch(is(a)),this.dispatch(Ma(c)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedures",method:o.GET,url:"/asset-procedures/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Va(s))}}class If extends P{add(e){const{store:s}=this.client;if(!e.canvas_marker&&!e.geo_json)throw new Error("Asset must have either a canvas_marker or geo_marker");const n=s.getState().userReducer.currentUser.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(ds(c));const r=this.enqueueRequest({description:"Create asset",method:o.POST,url:"/assets/",payload:v(c),blockers:[c.asset_type],blocks:[c.uuid]});return r.then(u=>{this.dispatch(Ue(u))}).catch(()=>{this.dispatch(os(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,n=ms(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_json)throw new Error("Asset must have either a canvas_marker or geo_marker");this.dispatch(Ue(a));const c=this.enqueueRequest({description:"Edit asset",method:o.PATCH,url:`/assets/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.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=ms(e)(n);if(!a)throw new Error(`No asset with uuid ${e} found in the store`);const c=ea(e)(n),r=rd(e)(n),u=Pd(e)(n);if(this.dispatch(os(e)),c.length>0){const m=c.map(({uuid:d})=>d);this.dispatch(Ut(m))}if(r.length>0){const m=r.map(({uuid:d})=>d);this.dispatch(ht(m))}if(u.length>0){const m=u.map(({uuid:d})=>d);this.dispatch(gi(m))}return this.enqueueRequest({description:"Delete asset",method:o.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(ds(a)),this.dispatch(Vt(c)),this.dispatch(lt(r)),this.dispatch(fi(u)),m})}bulkAdd(e,s,n,a){const c=new Date().toISOString(),r=_.v4(),u=Je(e,a).map(h=>{const p=h.map(A=>R(A));return{batchId:_.v4(),payload:{transaction_id:r,submitted_at:c,asset_type:s,project:n,assets:p}}}),m=[];let d=null;for(const h of u){const{batchId:p,payload:A}=h,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:o.POST,url:"/assets/bulk/",payload:A,blockers:b,blocks:F});d=h.batchId,m.push(T)}return Promise.all(m).then(h=>{const p=h.flat();this.dispatch(us(p))}),m}async refreshStore(e){const s=await this.enqueueRequest({description:"Get assets",method:o.GET,url:"/assets/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Ga(s))}}class Ff extends P{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(As(c));const r=this.enqueueRequest({description:"Add asset stage completion",method:o.POST,url:"/asset-stage-completions/",payload:v(c),blockers:[e.asset,e.stage],blocks:[c.uuid]});return r.then(u=>{this.dispatch(Ya(u))}).catch(()=>{this.dispatch(fs(c.uuid))}),[c,r]}delete(e){const{store:s}=this.client,n=Qa(e)(s.getState());if(!n)throw new Error(`Expected asset stage completion with uuid ${e} to exist`);this.dispatch(fs(e));const a=this.enqueueRequest({description:"Delete asset stage completion",method:o.DELETE,url:`/asset-stage-completions/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(As(n))}),a}bulkAdd(e){const{store:s}=this.client,n=new Date().toISOString(),a=s.getState().userReducer.currentUser.uuid,c=e.map(d=>R(d)),r=c.map(d=>({...d,created_by:a,submitted_at:n})),u=r.map(({uuid:d})=>d);this.dispatch(ys(r));const m=this.enqueueRequest({description:"Bulk create asset stage completions",method:o.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:u});return m.then(d=>{this.dispatch(Ja(d))}).catch(()=>{this.dispatch(Ss(u))}),[r,m]}bulkDelete(e){const{store:s}=this.client,n=Za(e)(s.getState());this.dispatch(Ss(e));const a=this.enqueueRequest({description:"Deleting asset stage completions",method:o.DELETE,url:"/asset-stage-completions/bulk/",payload:{completion_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(ys(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stage completions",method:o.GET,url:"/asset-stage-completions/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Ka(s))}}class Rf extends P{bulkAdd(e,s){const n=new Date().toISOString(),a=this.client.store.getState().userReducer.currentUser.uuid,c=e.map(m=>R(m)),r=c.map(m=>({...m,asset_procedure:s,created_by:a,submitted_at:n}));this.dispatch(bs(r));const u=this.enqueueRequest({description:"Add asset stages",method:o.POST,url:"/asset-stages/bulk/",payload:{submitted_at:n,asset_procedure:s,stages:c},blockers:[s],blocks:c.map(({uuid:m})=>m)});return u.then(m=>{this.dispatch(et(m))}).catch(()=>{this.dispatch(Fs(r.map(({uuid:m})=>m)))}),[r,u]}async bulkUpdate(e,s){const a=this.client.store.getState(),c=Rs(e.map(({uuid:r})=>r))(a);return this.dispatch(et(e)),this.enqueueRequest({description:"Edit asset stages",method:o.PATCH,url:`/asset-procedures/${s}/bulk-update-stages/`,payload:{stages:e},blockers:[s],blocks:e.map(({uuid:r})=>r)}).catch(r=>{throw this.dispatch(et(c)),r})}async bulkDelete(e){const{store:s}=this.client,n=Rs(e)(s.getState());this.dispatch(Fs(e));const a=this.enqueueRequest({description:"Delete asset stages",method:o.DELETE,url:"/asset-stages/bulk/",payload:{stage_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(bs(n))}),a}update(e){const{store:s}=this.client,n=ic(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(Is(a));const c=this.enqueueRequest({description:"Update asset stage",method:o.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(Is(r))}).catch(()=>{this.dispatch(tc(n))}),[a,c]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stages",method:o.GET,url:"/asset-stages/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(ec(s))}}class Pf extends Fe{constructor(){super(...arguments);f(this,"name","Asset Type Attachment");f(this,"url","/asset-type-attachments");f(this,"addAttachments",Os);f(this,"updateAttachments",dc);f(this,"removeAttachments",vs);f(this,"removeAttachment",uc);f(this,"setAttachment",rc);f(this,"selectAttachment",hc)}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:o.GET,url:`${this.url}/`,queryParams:{organization:s},blocks:[],blockers:[]});this.dispatch(cc(n))}}class Of extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.uuid,a={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:h,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:h,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:h};r.push(F)}this.dispatch(fc(c));const u=this.enqueueRequest({description:"Add asset type fields attachments",method:o.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(Sc(d.attachments))}).catch(()=>{this.dispatch(gc(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:o.GET,url:"/asset-type-fields-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(yc(s))}}class vf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Pc(c));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:o.POST,url:"/asset-type-fields/",payload:c,blockers:[c.asset_type],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Oc(m))}).catch(m=>{throw this.dispatch(vc(c.uuid)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Type Fields",method:o.GET,url:"/asset-type-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Rc(s))}}class _f 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.uuid,c=Je(e,s??e.length),r=[],u=[];for(const h of c){const p={},A=[];for(const y of h){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 Pt={uuid:M.uuid,file_name:T.name,file_sha1:O.sha1,file_extension:O.extension,field_identifier:F,field_values:b};A.push(Pt)}u.push({submitted_at:n,attachments:A,files:Object.values(p)})}this.dispatch(it(r));const m=u.map(h=>this.enqueueRequest({description:"Add asset type field values attachments",method:o.POST,url:"/asset-type-field-values-attachments/bulk/",payload:h,blockers:h.attachments.map(p=>p.field_values),blocks:h.attachments.map(p=>p.uuid)}));return Promise.all(m).then(h=>{for(const A of h)this.processPresignedUrls(A.presigned_urls);const p=h.flatMap(A=>A.attachments);this.dispatch(qc(p))}).catch(h=>{throw this.dispatch(nt(r.map(p=>p.uuid))),h}),[r,m.map(h=>h.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Cc(e)(n);this.dispatch(nt(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:o.DELETE,url:"/asset-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(it(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values attachments",method:o.GET,url:"/asset-type-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(jc(s))}}class wf 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.uuid,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset type field values",method:o.POST,url:"/asset-type-field-values/",payload:v(a),blockers:[e.asset,e.fields_revision],blocks:[a.uuid]});return this.dispatch(Ms(a)),c.then(u=>(this.dispatch($e(u)),u)).catch(()=>{this.dispatch(Cs(a.uuid))}),[a,c]}bulkAdd(e,s){var d;const n=new Date().toISOString(),{values:a}=Xe(e.values),c=[],r=Je(e.payloads,s??e.payloads.length),u=[];for(const h of r){const p=[];for(const A of h){const y=R({...A,values:Xe(A.values).values,created_by:(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.uuid,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(Uc(c));const m=[];for(const h of u){const p=h.field_values.map(F=>F.asset),A=h.field_values.map(F=>F.fields_revision),y=h.field_values.map(F=>F.uuid),b=this.enqueueRequest({description:"Bulk add asset type field values",method:o.POST,url:"/asset-type-field-values/bulk/",payload:h,blockers:[...p,...A],blocks:y});m.push(b)}return Promise.all(m).then(h=>{this.dispatch($c(h.flat()))}).catch(()=>{this.dispatch(Bc(c.map(h=>h.uuid)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=zs(e.uuid)(n);if(!a)throw new Error(`Expected AssetTypeFieldValues with uuid ${e.uuid} to exist`);const c={...a,...e};this.dispatch($e(c));const r=this.enqueueRequest({description:"Delete asset type field values",method:o.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($e(u))}).catch(()=>{this.dispatch($e(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=zs(e)(n);if(!a)throw new Error(`Expected submission with uuid ${e} to exist`);const c=kc(e)(n);this.dispatch(Cs(e)),this.dispatch(nt(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset type field values",method:o.DELETE,url:`/asset-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Ms(a)),this.dispatch(it(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values",method:o.GET,url:"/asset-type-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Vc(s))}}class Ef extends P{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Vs(c));const r=this.enqueueRequest({description:"Create asset type",method:o.POST,url:"/asset-types/",payload:v(c),blockers:[],blocks:[c.uuid]});return r.then(u=>{this.dispatch(Be(u))}).catch(()=>{this.dispatch(Us(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,n=Bs(e.uuid)(s.getState());if(!n)throw new Error(`Expected asset type with uuid ${e.uuid} to exist`);const a={...n,...e};this.dispatch(Be(a));const c=this.enqueueRequest({description:"Update asset type",method:o.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(Be(r))}).catch(()=>{this.dispatch(Be(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Bs(e)(n);if(!a)throw new Error(`Expected asset type with uuid ${e} to exist`);const c=hs(e)(n),r=mc(e)(n);return this.dispatch(Us(e)),this.dispatch(La(c.map(u=>u.uuid))),this.dispatch(vs(r.map(({uuid:u})=>u))),this.enqueueRequest({description:"Delete asset type",method:o.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(u=>{throw this.dispatch(Vs(a)),this.dispatch(us(c)),this.dispatch(Os(r)),u})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset types",method:o.GET,url:"/asset-types/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Hc(s))}}class jf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Ls(c));const r=this.enqueueRequest({description:"Create Category",method:o.POST,url:"/categories/",payload:v(c),blockers:[e.project.toString()],blocks:[c.uuid]});return[c,r]}update(e){const s=this.client.store.getState(),n=Hs(e.uuid)(s);if(!n)throw new Error(`Expected an existing category with uuid ${e.uuid}`);const a={...n,...e};this.dispatch(Zc(a));const c=this.enqueueRequest({description:"Edit Category",method:o.PATCH,url:`/categories/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return[a,c]}remove(e){const{store:s}=this.client,n=Hs(e)(s.getState());if(!n)throw new Error(`No category with uuid ${e} found in the store`);this.dispatch(xc(e));const a=this.enqueueRequest({description:"Delete Category",method:o.DELETE,url:`/categories/${n.uuid}/`,blockers:[n.uuid],blocks:[]});return a.catch(()=>{this.dispatch(Ls(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get categories",method:o.GET,url:"/categories/",queryParams:{project:e},blocks:[],blockers:[]});this.dispatch(Qc(s))}}class qf extends Fe{constructor(){super(...arguments);f(this,"name","Document Attachment");f(this,"url","/document-attachments");f(this,"addAttachments",ir);f(this,"updateAttachments",ar);f(this,"removeAttachments",rr);f(this,"removeAttachment",cr);f(this,"setAttachment",nr);f(this,"selectAttachment",or)}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.uuid,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 h=this.enqueueRequest({description:"Attach files to document",method:o.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 h.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,h.then(({attachments:A})=>A)]}async delete(s){return this._delete(s)}makeReadable(s){this.enqueueRequest({description:"Add attachment to AI assistant",method:o.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:o.GET,url:`/projects/${s}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(sr(a));const c=await this.enqueueRequest({description:"Get document attachments",method:o.GET,url:`/organizations/${n}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(this.addAttachments(c))}}class Mf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(pr([c]));const r=this.enqueueRequest({description:"Create Document",method:o.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(Ys([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:o.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=_e(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(Ar({documentId:e,targetDocumentId:s,position:n}));const m=this.enqueueRequest({description:"Move Document",method:o.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=_e(s.getState()),a=fr(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(Ys([e]));const r=this.enqueueRequest({description:"Delete Document",method:o.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:o.GET,url:`/projects/${e}/documents/`,blockers:[],blocks:[]}),a=this.enqueueRequest({description:"Get organization documents",method:o.GET,url:`/organizations/${s}/documents/`,blockers:[],blocks:[]});this.dispatch(mr([...await n,...await a]))}}class Cf extends P{async add(e,s){return this.enqueueRequest({description:"Add email domain to organization",method:o.POST,url:`/organizations/${e}/email-domains/`,payload:{email:s},blockers:[e,"create-org"],blocks:[]})}async remove(e){return this.dispatch(br(e.uuid)),this.enqueueRequest({description:"Remove email domain from organization",method:o.DELETE,url:`/organizations/${e.organization}/email-domains/${e.uuid}/`,blockers:[e.domain],blocks:[]}).catch(s=>{throw this.dispatch(Tr(e)),s})}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch email domains for organization",method:o.GET,url:`/organizations/${e}/email-domains/`,blockers:[e],blocks:[]});this.dispatch(gr(s))}}class kf extends P{async getVerificationCode(e){return this.enqueueRequest({description:"Get verification code",method:o.GET,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}validateVerificationCode(e,s=void 0){return this.enqueueRequest({description:"Validate verification code",method:o.POST,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,payload:s,blockers:[],blocks:[]})}}const Ft={},In=new Set;let Rt=0,Fn=0,Rn=0;const zf=20;class Df 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 Mt(n,s),c=await this.enqueueRequest({description:"Get S3 URL",method:o.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await ve(n),file_type:n.type,extension:n.name.split(".").pop(),size:n.size.toString()},blockers:[],blocks:[`s3-${a}`]});return"url"in c&&this.dispatch(vr({sha1:s,...c})),c}async addCache(s,n){if(In.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),Rt++):(await a.put("files",s,n),Fn++),In.add(n),Rn++,Rn%zf===0&&console.debug(`File cache summary: ${Rt} hits and ${Fn} misses, ${Rt/(Rt+Fn)*100}% hit rate over ${Rn} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),In.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const n=this.client.store.getState();return _r(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 Mt(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:o.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 zn(s),p=new File([h],a??n,{type:h.type});return await this.addCache(p,n),p}let u=Ft[c],m=!0;u?m=!1:(u=new Promise(h=>{this.enqueueRequest({description:"Download file",method:o.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});h(A)})}),Ft[c]=u);let d;try{d=await u}catch(h){throw m&&h instanceof q&&delete Ft[c],h}if(m){const h=await ve(d);if(h!==n){const y=`The hash of the file returned from the server (${h}) does not match the
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(u,m)}return a}}class ke{constructor(){f(this,"graph");f(this,"requestAttemptCounter");this.graph=new Gl.DepGraph,this.requestAttemptCounter={}}static _fromOutbox(e){const s=new ke;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))&&ke._addDependency(a.payload.uuid,r.payload.uuid,s.graph)}}return s}_addDependency(e,s){ke._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 lf=(t,e)=>{const s=new e(t);return Gy(s),By(t),s};class P extends Il{constructor(s,n){super(s);f(this,"auth");this.auth=n}}class hf extends P{async startConversation(e,s){return this.enqueueRequest({description:"Start agent conversation",method:o.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:s},blockers:["prompt"],blocks:["prompt"]}).then(n=>(this.dispatch(Ln(n)),n))}async continueConversation(e,s,n){return this.enqueueRequest({description:"Prompt agent",method:o.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:n},blockers:["prompt"],blocks:["prompt"],queryParams:{conversation_id:s}}).then(a=>{this.dispatch(Hn(a))})}async fetchDetails(e){return this.enqueueRequest({description:"Get agent conversation",method:o.GET,url:`/agents/conversations/${e}/`,blockers:["conversation"],blocks:["conversation"]}).then(s=>{this.dispatch(Nn(s))})}async rate(e,s){return this.enqueueRequest({description:"Rate agent response",method:o.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:o.GET,url:`/projects/${e}/agent-conversations/`,blockers:["agent-conversations"],blocks:["agent-conversations"]});this.dispatch(Gn(s))}}class j extends P{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:n,assetTypeAttachmentReducer:a,documentAttachmentReducer:c,projectAttachmentReducer:r,formRevisionAttachmentReducer:u,formSubmissionAttachmentReducer:m,geoImageReducer:d,assetTypeFieldsAttachmentReducer:h,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(h.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:o.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:n,blockers:[`s3-${a.fields.key}`],blocks:[n],s3url:a});return s}async getFilePayload(e){const s=await ve(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 Fe extends j{async _bulkAdd(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.uuid,a=new Date().toISOString(),c=[],r=[],u={};for(const h of e){const{modelUuid:p,file:A}=h,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:o.POST,url:`${this.url}/bulk/`,payload:{submitted_at:a,attachments:r,files:Object.values(u)},blocks:c.map(h=>h.uuid),blockers:c.map(h=>h.file_sha1)});return m.then(({attachments:h,presigned_urls:p})=>{this.dispatch(this.updateAttachments(h)),this.processPresignedUrls(p)}).catch(()=>{this.dispatch(this.removeAttachments(c.map(h=>h.uuid)))}),[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 uuid ${e} that does not exist in the store`);this.dispatch(this.removeAttachment(n.uuid));const a=this.enqueueRequest({description:`Delete ${this.name}`,method:o.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 mf extends Fe{constructor(){super(...arguments);f(this,"name","Asset Attachment");f(this,"url","/asset-attachments");f(this,"initializeAttachments",Dt);f(this,"addAttachments",Vt);f(this,"updateAttachments",Jn);f(this,"removeAttachments",Ut);f(this,"removeAttachment",Xn);f(this,"setAttachment",Yn);f(this,"selectAttachment",xn)}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:o.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch(Dt(n))}}class pf extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.uuid,a={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:h,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:h,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:h};r.push(F)}this.dispatch(na(c));const u=this.enqueueRequest({description:"Add asset procedure fields attachments",method:o.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(aa(d.attachments))}).catch(()=>{this.dispatch(ca(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:o.GET,url:"/asset-procedure-fields-attachments/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(ia(s))}}class Af extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(ha(c));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:o.POST,url:"/asset-procedure-fields/",payload:c,blockers:[c.asset_procedure],blocks:[c.uuid]});return r.then(m=>{this.dispatch(ma(m))}).catch(m=>{throw this.dispatch(pa(c.uuid)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:o.GET,url:"/asset-procedure-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(la(s))}}function Je(t,e){const s=[];let n=0;const a=t.length;for(;n<a;)s.push(t.slice(n,n+=e));return s}class yf 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.uuid,c=Je(e,s??e.length),r=[],u=[];for(const h of c){const p={},A=[];for(const y of h){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 Pt={uuid:M.uuid,file_name:T.name,file_sha1:O.sha1,file_extension:O.extension,field_identifier:F,field_values:b};A.push(Pt)}u.push({submitted_at:n,attachments:A,files:Object.values(p)})}this.dispatch(Ze(r));const m=u.map(h=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:o.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:h,blockers:h.attachments.map(p=>p.field_values),blocks:h.attachments.map(p=>p.uuid)}));return Promise.all(m).then(h=>{for(const A of h)this.processPresignedUrls(A.presigned_urls);const p=h.flatMap(A=>A.attachments);this.dispatch(ga(p))}).catch(h=>{throw this.dispatch(xe(r.map(p=>p.uuid))),h}),[r,m.map(h=>h.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=ba(e)(n);this.dispatch(xe(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:o.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(Ze(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values attachments",method:o.GET,url:"/asset-procedure-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Sa(s))}}const ff=t=>Array.isArray(t)&&t[0]instanceof File,Xe=t=>{const e={},s={};for(const n in t){const a=t[n];a instanceof File?e[n]=[a]:ff(a)?e[n]=a:a!==void 0&&(s[n]=a)}return{values:s,files:e}};class Sf extends j{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.uuid,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add form submission",method:o.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(ri(a)),c.then(u=>(this.dispatch(ot(u)),u)).catch(()=>{this.dispatch(di(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 submission with uuid ${e.uuid} to exist`);const c={...a,...e};this.dispatch(nd(c));const r=this.enqueueRequest({description:"Delete user form submissions",method:o.PATCH,url:`/form-submissions/${c.uuid}/`,payload:e,blockers:[c.uuid],blocks:[c.uuid]});return r.then(u=>{this.dispatch(ot(u))}).catch(()=>{this.dispatch(ot(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=ed(e)(n);this.dispatch(di(e)),this.dispatch(ut(c.map(r=>r.uuid)));try{return await this.enqueueRequest({description:"Delete user form submissions",method:o.DELETE,url:`/form-submissions/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ri(a)),this.dispatch(dt(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch form submissions",method:o.GET,url:"/form-submissions/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(id(s))}}class gf 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.uuid,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset procedure field values",method:o.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(Wt(a)),c.then(u=>(this.dispatch(ze(u)),u)).catch(()=>{this.dispatch(Kt(a.uuid))}),[a,c]}bulkAdd(e,s){var d;const n=new Date().toISOString(),{values:a}=Xe(e.values),c=[],r=Je(e.payloads,s??e.payloads.length),u=[];for(const h of r){const p=[];for(const A of h){const y=R({...A,values:Xe(A.values).values,created_by:(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.uuid,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(Oa(c));const m=[];for(const h of u){const p=h.field_values.map(T=>T.asset),A=h.field_values.map(T=>T.fields_revision),y=h.field_values.map(T=>T.asset_procedure_instance),b=h.field_values.map(T=>T.uuid),F=this.enqueueRequest({description:"Bulk add asset procedure field values",method:o.POST,url:"/asset-procedure-field-values/bulk/",payload:h,blockers:[...p,...A,...y],blocks:b});m.push(F)}return Promise.all(m).then(h=>{this.dispatch(va(h.flat()))}).catch(()=>{this.dispatch(_a(c.map(h=>h.uuid)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=Jt(e.uuid)(n);if(!a)throw new Error(`Expected AssetProcedureFieldValues with uuid ${e.uuid} to exist`);const c={...a,...e};this.dispatch(ze(c));const r=this.enqueueRequest({description:"Update asset procedure field values",method:o.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(ze(u))}).catch(()=>{this.dispatch(ze(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Jt(e)(n);if(!a)throw new Error(`Expected submission with uuid ${e} to exist`);const c=Ia(e)(n);this.dispatch(Kt(e)),this.dispatch(xe(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset procedure field values",method:o.DELETE,url:`/asset-procedure-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Wt(a)),this.dispatch(Ze(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values",method:o.GET,url:"/asset-procedure-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Pa(s))}}class Tf extends P{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Qt(c));const r=this.enqueueRequest({description:"Create asset procedure instance",method:o.POST,url:"/asset-procedure-instances/",payload:v(c),blockers:[e.asset_procedure,e.asset_type],blocks:[c.uuid]});return r.then(u=>{this.dispatch(De(u))}).catch(()=>{this.dispatch(Zt(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,n=ts(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(De(a));const c=this.enqueueRequest({description:"Update asset procedure instance",method:o.PATCH,url:`/asset-procedure-instances/${e.uuid}/`,payload:e,blockers:[n.uuid],blocks:[n.uuid]});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=ts(e)(n);if(!a)throw new Error(`Expected asset procedure instance with uuid ${e} to exist`);return this.dispatch(Zt(e)),this.enqueueRequest({description:"Delete asset procedure instance",method:o.DELETE,url:`/asset-procedure-instances/${e}/`,blockers:[e],blocks:[]}).catch(c=>{throw this.dispatch(Qt(a)),c})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure instances",method:o.GET,url:"/asset-procedure-instances/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(qa(s))}}class bf extends P{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(is(c));const r=this.enqueueRequest({description:"Create asset procedure",method:o.POST,url:"/asset-procedures/",payload:v(c),blockers:[],blocks:[c.uuid]});return r.then(u=>{this.dispatch(Ve(u))}).catch(()=>{this.dispatch(ns(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,n=cs(e.uuid)(s.getState());if(!n)throw new Error(`Expected asset procedure with uuid ${e.uuid} to exist`);const a={...n,...e};this.dispatch(Ve(a));const c=this.enqueueRequest({description:"Update asset procedure",method:o.PATCH,url:`/asset-procedures/${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=cs(e)(n);if(!a)throw new Error(`Expected asset procedure with uuid ${e} to exist`);const c=Ca(e)(n);return this.dispatch(ns(e)),this.dispatch(ka(c.map(r=>r.uuid))),this.enqueueRequest({description:"Delete asset procedure",method:o.DELETE,url:`/asset-procedures/${e}/`,blockers:[e],blocks:[]}).catch(r=>{throw this.dispatch(is(a)),this.dispatch(Ma(c)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedures",method:o.GET,url:"/asset-procedures/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Va(s))}}class If extends P{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.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(ds(c));const r=this.enqueueRequest({description:"Create asset",method:o.POST,url:"/assets/",payload:v(c),blockers:[c.asset_type],blocks:[c.uuid]});return r.then(u=>{this.dispatch(Ue(u))}).catch(()=>{this.dispatch(os(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,n=ms(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(Ue(a));const c=this.enqueueRequest({description:"Edit asset",method:o.PATCH,url:`/assets/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.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=ms(e)(n);if(!a)throw new Error(`No asset with uuid ${e} found in the store`);const c=ea(e)(n),r=rd(e)(n),u=Pd(e)(n);if(this.dispatch(os(e)),c.length>0){const m=c.map(({uuid:d})=>d);this.dispatch(Ut(m))}if(r.length>0){const m=r.map(({uuid:d})=>d);this.dispatch(ht(m))}if(u.length>0){const m=u.map(({uuid:d})=>d);this.dispatch(gi(m))}return this.enqueueRequest({description:"Delete asset",method:o.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(ds(a)),this.dispatch(Vt(c)),this.dispatch(lt(r)),this.dispatch(fi(u)),m})}bulkAdd(e,s,n,a){const c=new Date().toISOString(),r=_.v4(),u=Je(e,a).map(h=>{const p=h.map(A=>R(A));return{batchId:_.v4(),payload:{transaction_id:r,submitted_at:c,asset_type:s,project:n,assets:p}}}),m=[];let d=null;for(const h of u){const{batchId:p,payload:A}=h,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:o.POST,url:"/assets/bulk/",payload:A,blockers:b,blocks:F});d=h.batchId,m.push(T)}return Promise.all(m).then(h=>{const p=h.flat();this.dispatch(us(p))}),m}async refreshStore(e){const s=await this.enqueueRequest({description:"Get assets",method:o.GET,url:"/assets/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Ga(s))}}class Ff extends P{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(As(c));const r=this.enqueueRequest({description:"Add asset stage completion",method:o.POST,url:"/asset-stage-completions/",payload:v(c),blockers:[e.asset,e.stage],blocks:[c.uuid]});return r.then(u=>{this.dispatch(Ya(u))}).catch(()=>{this.dispatch(fs(c.uuid))}),[c,r]}delete(e){const{store:s}=this.client,n=Qa(e)(s.getState());if(!n)throw new Error(`Expected asset stage completion with uuid ${e} to exist`);this.dispatch(fs(e));const a=this.enqueueRequest({description:"Delete asset stage completion",method:o.DELETE,url:`/asset-stage-completions/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(As(n))}),a}bulkAdd(e){const{store:s}=this.client,n=new Date().toISOString(),a=s.getState().userReducer.currentUser.uuid,c=e.map(d=>R(d)),r=c.map(d=>({...d,created_by:a,submitted_at:n})),u=r.map(({uuid:d})=>d);this.dispatch(ys(r));const m=this.enqueueRequest({description:"Bulk create asset stage completions",method:o.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:u});return m.then(d=>{this.dispatch(Ja(d))}).catch(()=>{this.dispatch(Ss(u))}),[r,m]}bulkDelete(e){const{store:s}=this.client,n=Za(e)(s.getState());this.dispatch(Ss(e));const a=this.enqueueRequest({description:"Deleting asset stage completions",method:o.DELETE,url:"/asset-stage-completions/bulk/",payload:{completion_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(ys(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stage completions",method:o.GET,url:"/asset-stage-completions/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Ka(s))}}class Rf extends P{bulkAdd(e,s){const n=new Date().toISOString(),a=this.client.store.getState().userReducer.currentUser.uuid,c=e.map(m=>R(m)),r=c.map(m=>({...m,asset_procedure:s,created_by:a,submitted_at:n}));this.dispatch(bs(r));const u=this.enqueueRequest({description:"Add asset stages",method:o.POST,url:"/asset-stages/bulk/",payload:{submitted_at:n,asset_procedure:s,stages:c},blockers:[s],blocks:c.map(({uuid:m})=>m)});return u.then(m=>{this.dispatch(et(m))}).catch(()=>{this.dispatch(Fs(r.map(({uuid:m})=>m)))}),[r,u]}async bulkUpdate(e,s){const a=this.client.store.getState(),c=Rs(e.map(({uuid:r})=>r))(a);return this.dispatch(et(e)),this.enqueueRequest({description:"Edit asset stages",method:o.PATCH,url:`/asset-procedures/${s}/bulk-update-stages/`,payload:{stages:e},blockers:[s],blocks:e.map(({uuid:r})=>r)}).catch(r=>{throw this.dispatch(et(c)),r})}async bulkDelete(e){const{store:s}=this.client,n=Rs(e)(s.getState());this.dispatch(Fs(e));const a=this.enqueueRequest({description:"Delete asset stages",method:o.DELETE,url:"/asset-stages/bulk/",payload:{stage_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(bs(n))}),a}update(e){const{store:s}=this.client,n=ic(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(Is(a));const c=this.enqueueRequest({description:"Update asset stage",method:o.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(Is(r))}).catch(()=>{this.dispatch(tc(n))}),[a,c]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stages",method:o.GET,url:"/asset-stages/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(ec(s))}}class Pf extends Fe{constructor(){super(...arguments);f(this,"name","Asset Type Attachment");f(this,"url","/asset-type-attachments");f(this,"addAttachments",Os);f(this,"updateAttachments",dc);f(this,"removeAttachments",vs);f(this,"removeAttachment",uc);f(this,"setAttachment",rc);f(this,"selectAttachment",hc)}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:o.GET,url:`${this.url}/`,queryParams:{organization:s},blocks:[],blockers:[]});this.dispatch(cc(n))}}class Of extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.uuid,a={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:h,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:h,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:h};r.push(F)}this.dispatch(fc(c));const u=this.enqueueRequest({description:"Add asset type fields attachments",method:o.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(Sc(d.attachments))}).catch(()=>{this.dispatch(gc(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:o.GET,url:"/asset-type-fields-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(yc(s))}}class vf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Pc(c));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:o.POST,url:"/asset-type-fields/",payload:c,blockers:[c.asset_type],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Oc(m))}).catch(m=>{throw this.dispatch(vc(c.uuid)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Type Fields",method:o.GET,url:"/asset-type-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Rc(s))}}class _f 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.uuid,c=Je(e,s??e.length),r=[],u=[];for(const h of c){const p={},A=[];for(const y of h){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 Pt={uuid:M.uuid,file_name:T.name,file_sha1:O.sha1,file_extension:O.extension,field_identifier:F,field_values:b};A.push(Pt)}u.push({submitted_at:n,attachments:A,files:Object.values(p)})}this.dispatch(it(r));const m=u.map(h=>this.enqueueRequest({description:"Add asset type field values attachments",method:o.POST,url:"/asset-type-field-values-attachments/bulk/",payload:h,blockers:h.attachments.map(p=>p.field_values),blocks:h.attachments.map(p=>p.uuid)}));return Promise.all(m).then(h=>{for(const A of h)this.processPresignedUrls(A.presigned_urls);const p=h.flatMap(A=>A.attachments);this.dispatch(qc(p))}).catch(h=>{throw this.dispatch(nt(r.map(p=>p.uuid))),h}),[r,m.map(h=>h.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=kc(e)(n);this.dispatch(nt(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:o.DELETE,url:"/asset-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(it(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values attachments",method:o.GET,url:"/asset-type-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(jc(s))}}class wf 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.uuid,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset type field values",method:o.POST,url:"/asset-type-field-values/",payload:v(a),blockers:[e.asset,e.fields_revision],blocks:[a.uuid]});return this.dispatch(Ms(a)),c.then(u=>(this.dispatch($e(u)),u)).catch(()=>{this.dispatch(ks(a.uuid))}),[a,c]}bulkAdd(e,s){var d;const n=new Date().toISOString(),{values:a}=Xe(e.values),c=[],r=Je(e.payloads,s??e.payloads.length),u=[];for(const h of r){const p=[];for(const A of h){const y=R({...A,values:Xe(A.values).values,created_by:(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.uuid,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(Uc(c));const m=[];for(const h of u){const p=h.field_values.map(F=>F.asset),A=h.field_values.map(F=>F.fields_revision),y=h.field_values.map(F=>F.uuid),b=this.enqueueRequest({description:"Bulk add asset type field values",method:o.POST,url:"/asset-type-field-values/bulk/",payload:h,blockers:[...p,...A],blocks:y});m.push(b)}return Promise.all(m).then(h=>{this.dispatch($c(h.flat()))}).catch(()=>{this.dispatch(Bc(c.map(h=>h.uuid)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=zs(e.uuid)(n);if(!a)throw new Error(`Expected AssetTypeFieldValues with uuid ${e.uuid} to exist`);const c={...a,...e};this.dispatch($e(c));const r=this.enqueueRequest({description:"Delete asset type field values",method:o.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($e(u))}).catch(()=>{this.dispatch($e(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=zs(e)(n);if(!a)throw new Error(`Expected submission with uuid ${e} to exist`);const c=Cc(e)(n);this.dispatch(ks(e)),this.dispatch(nt(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset type field values",method:o.DELETE,url:`/asset-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Ms(a)),this.dispatch(it(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values",method:o.GET,url:"/asset-type-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Vc(s))}}class Ef extends P{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Vs(c));const r=this.enqueueRequest({description:"Create asset type",method:o.POST,url:"/asset-types/",payload:v(c),blockers:[],blocks:[c.uuid]});return r.then(u=>{this.dispatch(Be(u))}).catch(()=>{this.dispatch(Us(c.uuid))}),[c,r]}update(e){const{store:s}=this.client,n=Bs(e.uuid)(s.getState());if(!n)throw new Error(`Expected asset type with uuid ${e.uuid} to exist`);const a={...n,...e};this.dispatch(Be(a));const c=this.enqueueRequest({description:"Update asset type",method:o.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(Be(r))}).catch(()=>{this.dispatch(Be(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Bs(e)(n);if(!a)throw new Error(`Expected asset type with uuid ${e} to exist`);const c=hs(e)(n),r=mc(e)(n);return this.dispatch(Us(e)),this.dispatch(La(c.map(u=>u.uuid))),this.dispatch(vs(r.map(({uuid:u})=>u))),this.enqueueRequest({description:"Delete asset type",method:o.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(u=>{throw this.dispatch(Vs(a)),this.dispatch(us(c)),this.dispatch(Os(r)),u})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset types",method:o.GET,url:"/asset-types/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Hc(s))}}class jf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Ls(c));const r=this.enqueueRequest({description:"Create Category",method:o.POST,url:"/categories/",payload:v(c),blockers:[e.project.toString()],blocks:[c.uuid]});return[c,r]}update(e){const s=this.client.store.getState(),n=Hs(e.uuid)(s);if(!n)throw new Error(`Expected an existing category with uuid ${e.uuid}`);const a={...n,...e};this.dispatch(Zc(a));const c=this.enqueueRequest({description:"Edit Category",method:o.PATCH,url:`/categories/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return[a,c]}remove(e){const{store:s}=this.client,n=Hs(e)(s.getState());if(!n)throw new Error(`No category with uuid ${e} found in the store`);this.dispatch(xc(e));const a=this.enqueueRequest({description:"Delete Category",method:o.DELETE,url:`/categories/${n.uuid}/`,blockers:[n.uuid],blocks:[]});return a.catch(()=>{this.dispatch(Ls(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get categories",method:o.GET,url:"/categories/",queryParams:{project:e},blocks:[],blockers:[]});this.dispatch(Qc(s))}}class qf extends Fe{constructor(){super(...arguments);f(this,"name","Document Attachment");f(this,"url","/document-attachments");f(this,"addAttachments",ir);f(this,"updateAttachments",ar);f(this,"removeAttachments",rr);f(this,"removeAttachment",cr);f(this,"setAttachment",nr);f(this,"selectAttachment",or)}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.uuid,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 h=this.enqueueRequest({description:"Attach files to document",method:o.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 h.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,h.then(({attachments:A})=>A)]}async delete(s){return this._delete(s)}makeReadable(s){this.enqueueRequest({description:"Add attachment to AI assistant",method:o.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:o.GET,url:`/projects/${s}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(sr(a));const c=await this.enqueueRequest({description:"Get document attachments",method:o.GET,url:`/organizations/${n}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(this.addAttachments(c))}}class Mf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(pr([c]));const r=this.enqueueRequest({description:"Create Document",method:o.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(Ys([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:o.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=_e(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(Ar({documentId:e,targetDocumentId:s,position:n}));const m=this.enqueueRequest({description:"Move Document",method:o.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=_e(s.getState()),a=fr(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(Ys([e]));const r=this.enqueueRequest({description:"Delete Document",method:o.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:o.GET,url:`/projects/${e}/documents/`,blockers:[],blocks:[]}),a=this.enqueueRequest({description:"Get organization documents",method:o.GET,url:`/organizations/${s}/documents/`,blockers:[],blocks:[]});this.dispatch(mr([...await n,...await a]))}}class kf extends P{async add(e,s){return this.enqueueRequest({description:"Add email domain to organization",method:o.POST,url:`/organizations/${e}/email-domains/`,payload:{email:s},blockers:[e,"create-org"],blocks:[]})}async remove(e){return this.dispatch(br(e.uuid)),this.enqueueRequest({description:"Remove email domain from organization",method:o.DELETE,url:`/organizations/${e.organization}/email-domains/${e.uuid}/`,blockers:[e.domain],blocks:[]}).catch(s=>{throw this.dispatch(Tr(e)),s})}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch email domains for organization",method:o.GET,url:`/organizations/${e}/email-domains/`,blockers:[e],blocks:[]});this.dispatch(gr(s))}}class Cf extends P{async getVerificationCode(e){return this.enqueueRequest({description:"Get verification code",method:o.GET,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}validateVerificationCode(e,s=void 0){return this.enqueueRequest({description:"Validate verification code",method:o.POST,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,payload:s,blockers:[],blocks:[]})}}const Ft={},In=new Set;let Rt=0,Fn=0,Rn=0;const zf=20;class Df 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 Mt(n,s),c=await this.enqueueRequest({description:"Get S3 URL",method:o.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await ve(n),file_type:n.type,extension:n.name.split(".").pop(),size:n.size.toString()},blockers:[],blocks:[`s3-${a}`]});return"url"in c&&this.dispatch(vr({sha1:s,...c})),c}async addCache(s,n){if(In.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),Rt++):(await a.put("files",s,n),Fn++),In.add(n),Rn++,Rn%zf===0&&console.debug(`File cache summary: ${Rt} hits and ${Fn} misses, ${Rt/(Rt+Fn)*100}% hit rate over ${Rn} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),In.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const n=this.client.store.getState();return _r(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 Mt(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:o.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 zn(s),p=new File([h],a??n,{type:h.type});return await this.addCache(p,n),p}let u=Ft[c],m=!0;u?m=!1:(u=new Promise(h=>{this.enqueueRequest({description:"Download file",method:o.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});h(A)})}),Ft[c]=u);let d;try{d=await u}catch(h){throw m&&h instanceof q&&delete Ft[c],h}if(m){const h=await ve(d);if(h!==n){const y=`The hash of the file returned from the server (${h}) does not match the
10
10
  expected hash (${n}). This can happen if you're using a local development server and the
11
11
  isExternalUrl flag in the request details is set to true, because instead of requesting the local
12
12
  REST API, you will be requesting localhost:80 (where this app runs), resulting in a transformed blob
13
13
  (with an uuid attached) being returned. Alternatively, you may be running with
14
14
  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(y)}const p=d.type.split("/")[1];if(!p)throw new Error("File has no extension");const A=a??h+"."+p;if(d=kn(d,A),!d.name)throw new Error("Failed to set file's name");await this.addCache(d,h),Ft[c]=new Promise(y=>{y(d)})}return d}}class Vf extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.uuid,a={},c=[],r=[];for(const d of e){const{revisionUuid:h,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:h,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:h};r.push(F)}this.dispatch(qr(c));const u=this.enqueueRequest({description:"Attach files to form revision",method:o.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(Mr(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:o.GET,url:"/form-revision-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(jr(s))}}class Uf extends j{add(e){var u;const{store:s}=this.client,a=(u=s.getState().userReducer.currentUser)==null?void 0:u.uuid,c=R({...e,created_by:a,submitted_at:new Date().toISOString()});this.dispatch(xs(c));const r=this.enqueueRequest({description:"Create form revision",method:o.POST,url:"/form-revisions/",payload:v(c),blockers:[e.form],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Vr(m))}).catch(()=>{this.dispatch(ei(c.uuid))}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization form revisions",method:o.GET,url:"/form-revisions/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(Ur(s))}}const $f=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 Bf 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.uuid,r=R({...e,submitted_at:a,created_by:c}),u=R({...s,form:r.uuid,submitted_at:a,created_by:c});this.dispatch(si(r)),this.dispatch(xs(u));const m=this.enqueueRequest({description:"Create form",method:o.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(h=>{throw this.dispatch(ii(r.uuid)),this.dispatch(ei(u.uuid)),h}),[r,u,m]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Jr(e)(n);if(!a)throw new Error("Expected form to exist");const c=ad(e)(n);c.length>0&&this.dispatch(ht(c.map(({uuid:u})=>u)));const r=Lr(e)(n);r.length>0&&this.dispatch(Br(r.map(({uuid:u})=>u))),this.dispatch(ii(e));try{return await this.enqueueRequest({description:"Delete form",method:o.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(u){throw this.dispatch(si(a)),r.length>0&&this.dispatch($r(r)),c.length>0&&this.dispatch(lt(c)),u}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization forms",method:o.GET,url:"/forms/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(Wr(s))}}class Gf extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.uuid,a={},c=[],r=[];for(const d of e){const{submissionUuid:h,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:h,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:h};r.push(F)}this.dispatch(dt(c));const u=this.enqueueRequest({description:"Attach files to form submission",method:o.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(Zr(d.attachments))}).catch(d=>{throw this.dispatch(ut(c.map(h=>h.uuid))),d}),[c,u.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=xr(e)(n);this.dispatch(ut(e));try{await this.enqueueRequest({description:"Delete form submission attachments",method:o.DELETE,url:"/form-submission-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(dt(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get form submission attachments",method:o.GET,url:"/form-submission-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Qr(s))}}class Lf extends j{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.uuid,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(hd(d));const h=this.enqueueRequest({description:"Add geo image",method:o.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.toString()],blockers:[u.toString()]});return h.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(Le(A.geo_image))}).catch(()=>{this.dispatch(mi(d.uuid))}),[d,h.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.uuid,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(md(r));const h=this.enqueueRequest({description:"Bulk add geo images",method:o.POST,url:"/geo-images/bulk/",payload:{submitted_at:a,project:s,geo_images:m,files:Object.values(d)},blocks:[s.toString()],blockers:u});return h.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(ld(A.geo_images))}).catch(()=>{this.dispatch(Ad(u))}),[r,h.then(A=>A.geo_images)]}update(e){const{store:s}=this.client,n=s.getState(),a=pi(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(pd(c));const r=this.enqueueRequest({description:"Update geo image",method:o.PATCH,url:`/geo-images/${e.uuid}/`,payload:e,blocks:[e.uuid],blockers:[e.uuid]});return r.then(u=>{this.dispatch(Le(u))}).catch(()=>{this.dispatch(Le(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=pi(e)(n);if(!a)throw new Error(`Map image with uuid ${e} does not exist in the store`);this.dispatch(mi(e));const c=this.enqueueRequest({description:"Delete geo image",method:o.DELETE,url:`/geo-images/${e}/`,blocks:[e],blockers:[e]});return c.catch(()=>{this.dispatch(Le(a))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get geo images",method:o.GET,url:`/projects/${e}/geo-images/`,blocks:[e],blockers:[]});this.dispatch(od(s))}}class Nf 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.uuid,c=R({...e,submitted_at:n,created_by:a});this.dispatch(yi(c));const r=this.enqueueRequest({description:"Add issue association",method:o.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(bd(m))}).catch(()=>{this.dispatch(Si(c.uuid))}),[c,r]}async delete(e){const{store:s}=this.client,n=Id(e)(s.getState());if(!n)throw new Error(`Issue association with uuid ${e} not found in store.`);this.dispatch(Si(e));const a=this.enqueueRequest({description:"Delete issue association",method:o.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(yi(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch issue associations",method:o.GET,url:"/issue-associations/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Td(s))}}class Hf extends Fe{constructor(){super(...arguments);f(this,"name","Issue Attachment");f(this,"url","/issue-attachments");f(this,"initializeAttachments",bi);f(this,"addAttachments",Ii);f(this,"updateAttachments",wd);f(this,"removeAttachments",Fi);f(this,"removeAttachment",Ed);f(this,"setAttachment",_d);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:o.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch(bi(n))}}class Wf extends Fe{constructor(){super(...arguments);f(this,"name","Issue Comment Attachment");f(this,"url","/issue-comment-attachments");f(this,"initializeAttachments",Pi);f(this,"addAttachments",Dd);f(this,"updateAttachments",Ud);f(this,"removeAttachments",Bd);f(this,"removeAttachment",$d);f(this,"setAttachment",Vd);f(this,"selectAttachment",Nd)}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:o.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch(Pi(n))}}class Kf extends P{add(e){var c;const{store:s}=this.client,n=R({...e,author:(c=s.getState().userReducer.currentUser)==null?void 0:c.uuid,submitted_at:new Date().toISOString()});this.dispatch(_i(n));const a=this.enqueueRequest({description:"Add issue comment",method:o.POST,url:"/issue-comments/",payload:v(n),blockers:[e.issue],blocks:[n.uuid]});return a.catch(()=>{this.dispatch(wi(n.uuid))}),[n,a]}update(e){const{store:s}=this.client,n=Ei(e.uuid)(s.getState());if(!n)throw new Error(`Comment with uuid ${e.uuid} not found in store`);const a={...n,...e};this.dispatch(vi(a));const c=this.enqueueRequest({description:"Edit issue comment",method:o.PATCH,url:`/issue-comments/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.catch(()=>{this.dispatch(vi(n))}),[a,c]}remove(e){const{store:s}=this.client,n=Ei(e)(s.getState());if(!n)throw new Error(`Comment with uuid ${e} not found in store`);this.dispatch(wi(e));const a=this.enqueueRequest({description:"Delete comment",method:o.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(_i(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get comments",method:o.GET,url:"/issue-comments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Kd(s))}}class Yf 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.uuid,r=R({...e,submitted_at:a,created_by:c});this.dispatch(qi(r));const u=this.enqueueRequest({description:"Create issue",method:o.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(mt(d))}).catch(d=>{throw this.dispatch(Mi(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(mt(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 p=e[d];if(p&&(h=s.categoryReducer.instances[p]??null,!h))throw new Error(`Trying to update issue category to ${p} which does not exist in store`);c[d]=h?{name:h.name,color:h.color,uuid:h.uuid}:null;break}case w.ASSIGNED_TO:{let h=null;const p=e[d];if(p&&(h=s.userReducer.instances[p]??null,!h))throw new Error(`Trying to update issue assigned_to to ${p} which does not exist in store`);c[d]=h?{full_name:h.username,uuid:h.uuid}:null;break}}const r=R({created_by:(m=s.userReducer.currentUser)==null?void 0:m.uuid,submitted_at:new Date().toISOString(),issue:n.uuid,changes:c});this.dispatch(Ku(r));const u=this.enqueueRequest({description:"Edit issue",method:o.PATCH,url:`/issues/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return u.catch(()=>{this.dispatch(mt(n)),this.dispatch(Ju(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=Md(e)(n),r=Zu(e)(n),u=cd(e)(n),m={};for(const h of Fd(e)(n))m[h.uuid]=h;for(const h of Rd(e)(n))m[h.uuid]=h;const d=Object.values(m);this.dispatch(Mi(e)),c.length>0&&this.dispatch(Fi(c.map(({uuid:h})=>h))),r.length>0&&this.dispatch(Xu(r.map(({uuid:h})=>h))),u.length>0&&this.dispatch(ht(u.map(({uuid:h})=>h))),d.length>0&&this.dispatch(gi(d.map(({uuid:h})=>h)));try{return await this.enqueueRequest({description:"Delete issue",method:o.DELETE,url:`/issues/${e}/`,blockers:[e],blocks:[]})}catch(h){throw this.dispatch(qi(a)),this.dispatch(Ii(c)),this.dispatch(Yu(r)),this.dispatch(lt(u)),this.dispatch(fi(d)),h}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issues",method:o.GET,url:"/issues/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Qd(s))}}class Jf extends Fe{constructor(){super(...arguments);f(this,"name","Issue Type Attachment");f(this,"url","/issue-type-attachments");f(this,"initializeAttachments",zi);f(this,"addAttachments",iu);f(this,"updateAttachments",au);f(this,"removeAttachments",ru);f(this,"removeAttachment",cu);f(this,"setAttachment",nu);f(this,"selectAttachment",ou)}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:o.GET,url:`${this.url}/`,queryParams:{organization:s},blocks:[],blockers:[]});this.dispatch(zi(n))}}class Xf extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.uuid,a={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:h,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:h,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:h};r.push(F)}this.dispatch(pu(c));const u=this.enqueueRequest({description:"Add issue type fields attachments",method:o.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(Au(d.attachments))}).catch(()=>{this.dispatch(yu(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:o.GET,url:"/issue-type-fields-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(mu(s))}}class Qf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Ou(c));const r=this.enqueueRequest({description:"Add Issue Type Fields",method:o.POST,url:"/issue-type-fields/",payload:v(c),blockers:[c.issue_type],blocks:[c.uuid]});return r.then(m=>{this.dispatch(vu(m))}).catch(m=>{throw this.dispatch(_u(c.uuid)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Issue Type Fields",method:o.GET,url:"/issue-type-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Pu(s))}}class Zf extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.uuid,a={},c=[],r=[];for(const d of e){const{fieldValuesUuid:h,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:h,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:h};r.push(F)}this.dispatch(At(c));const u=this.enqueueRequest({description:"Add issue type field values attachments",method:o.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:h})=>{this.processPresignedUrls(d),this.dispatch(Mu(h))}).catch(d=>{throw this.dispatch(yt(c.map(h=>h.uuid))),d}),[c,u.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=ku(e)(n);this.dispatch(yt(e));try{await this.enqueueRequest({description:"Delete issue type field values attachments",method:o.DELETE,url:"/issue-type-field-values-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 issue type field values attachments",method:o.GET,url:"/issue-type-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(qu(s))}}class xf 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.uuid,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add issue type field values",method:o.POST,url:"/issue-type-field-values/",payload:v(a),blockers:[e.issue,e.fields_revision],blocks:[a.uuid]});return this.dispatch(Ui(a)),c.then(u=>(this.dispatch(He(u)),u)).catch(()=>{this.dispatch($i(a.uuid))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=Gi(e.uuid)(n);if(!a)throw new Error(`Expected IssueTypeFieldValues with uuid ${e.uuid} to exist`);const c={...a,...e};this.dispatch(He(c));const r=this.enqueueRequest({description:"Update issue type field values",method:o.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(He(u))}).catch(()=>{this.dispatch(He(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Gi(e)(n);if(!a)throw new Error(`Expected submission with uuid ${e} to exist`);const c=zu(e)(n);this.dispatch($i(e)),this.dispatch(yt(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete issue type field values",method:o.DELETE,url:`/issue-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Ui(a)),this.dispatch(At(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values",method:o.GET,url:"/issue-type-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(bu(s))}}class eS 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.uuid});this.dispatch($u(a));const c=this.enqueueRequest({method:o.POST,url:"/issue-types/",payload:v(a),blockers:[],blocks:[a.uuid]});return c.then(u=>{this.dispatch(We(u))}).catch(()=>{this.dispatch(Ki(a.uuid))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=Yi(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(Bu(c));const r=this.enqueueRequest({method:o.PATCH,url:`/issue-types/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return r.then(u=>{this.dispatch(We(u))}).catch(()=>{this.dispatch(We(a))}),[c,r]}delete(e){const{store:s}=this.client,n=s.getState(),a=Yi(e)(n);if(!a)throw new Error(`IssueType with uuid ${e} does not exist in the store.`);const c=Ji(e)(n);this.dispatch(Ki(e)),this.dispatch(xd(c.map(u=>u.uuid)));const r=this.enqueueRequest({method:o.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return r.catch(()=>{this.dispatch(We(a)),this.dispatch(Zd(c))}),r}async refreshStore(e){const s=await this.enqueueRequest({method:o.GET,url:"/issue-types/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Uu(s))}}class tS extends P{async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue updates",method:o.GET,url:"/issue-updates/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Wu(s))}}class sS extends Il{constructor(e){super(e)}}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 sS{constructor(){super(...arguments);f(this,"_getRenewedTokens",async s=>{const n=this.enqueueRequest({description:"Get renewed tokens",method:o.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(Yc(!1)),this.clearTokens(),this.dispatch({type:Nl.RESET_STATE}),this.dispatch({type:El})}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??Me).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=_.v4();return console.debug(this.constructor.name,"Initiating auth"),this.enqueueRequest({uuid:n,description:"Get token pair",method:o.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:o.GET,url:`/billing/${e.uuid}/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(pe(s)),s}async pauseLicense(e){const s=await this.enqueueRequest({description:"Pause license",method:o.DELETE,url:`/billing/${e.uuid}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(pe(s)),s}async resumeLicense(e){const s=await this.enqueueRequest({description:"Resume license",method:o.PATCH,url:`/billing/${e.uuid}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(pe(s)),s}async cancelLicense(e){const s=await this.enqueueRequest({description:"Cancel license",method:o.DELETE,url:`/billing/${e.uuid}/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(pe(s)),s}async attachLicenseToProject(e,s){const n=await this.enqueueRequest({description:"Attach license",method:o.PATCH,url:`/billing/${e.uuid}/project/`,isAuthNeeded:!0,payload:{project:s.uuid},blockers:[e.organization_owner?e.organization_owner.toString():"",s.uuid?s.uuid.toString():""],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:o.DELETE,url:`/billing/${e.uuid}/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(pe(s)),s}async getLatestTransaction(e){return await this.enqueueRequest({description:"Get latest transaction",method:o.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:o.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:o.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(to(Object.values(n)))}}class rS extends P{async update(e){const s=this.enqueueRequest({description:"Edit organization access",method:o.PATCH,url:`/organizations/${e.organization}/access/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return s.then(()=>{this.dispatch(lo(e))}),s}async remove(e){return this.dispatch(ho(e.uuid)),this.dispatch(co(e.user)),this.enqueueRequest({description:"Remove organization access",method:o.DELETE,url:`/organizations/${e.organization}/access/${e.uuid}/`,blockers:[e.uuid],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization accesses",method:o.GET,url:`/organizations/${e}/access/`,blockers:[],blocks:[]});this.dispatch(oo(s))}}class dS extends P{create(e){return this.enqueueRequest({description:"Create organization",method:o.POST,url:"/organizations/",payload:{name:e},blockers:[],blocks:[`add-org-${e}`,"create-org"]})}async update(e){return this.enqueueRequest({description:"Edit organization",method:o.PATCH,url:`/organizations/${e.uuid}/`,payload:e,blockers:[`add-org-${e.name}`,e.uuid.toString()],blocks:[e.uuid.toString()]})}async invite(e,s){return this.enqueueRequest({description:"Invite user to organization",method:o.POST,url:`/organizations/${e}/invite/${s}/`,blockers:[],blocks:[]})}async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Get organizations",method:o.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:o.GET,url:`/organizations/${s}/`,blockers:[],blocks:[]});n[c.uuid]=c,this.dispatch(jo(Object.values(n)))}}class uS extends P{async update(e){return this.dispatch(yo(e)),this.enqueueRequest({description:"Edit project access",method:o.PATCH,url:`/project-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid,"change-access-level"],blocks:[e.uuid]})}async remove(e){return this.dispatch(fo(e)),this.enqueueRequest({description:"Delete project access",method:o.DELETE,url:`/project-accesses/${e}/`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project accesses",method:o.GET,url:"/project-accesses/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(sn(s))}}class oS extends Fe{constructor(){super(...arguments);f(this,"name","Project Attachment");f(this,"url","/project-attachments");f(this,"addAttachments",Ho);f(this,"updateAttachments",Yo);f(this,"removeAttachments",un);f(this,"removeAttachment",Jo);f(this,"setAttachment",Wo);f(this,"selectAttachment",Zo)}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:o.GET,url:`${this.url}/`,queryParams:{project:s},blockers:[],blocks:[]});this.dispatch(No(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:o.PATCH,url:`/projects/files/${e.uuid}/`,payload:s,blockers:[e.uuid],blocks:[e.uuid]});return n.then(a=>{this.dispatch(ln(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:o.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:o.POST,url:`/projects/${a.project}/files/`,payload:{...a,...h},blockers:[n],blocks:[n]})}).catch(d)});const u=Promise.resolve(c).then(m=>this.enqueueRequest(m));return u.then(m=>{this.dispatch(ln(m))}),this.dispatch(dl),this.dispatch(rl(null)),this.dispatch(cl(!1)),[a,u]}delete(e){return this.dispatch(nl(e)),this.enqueueRequest({method:o.DELETE,url:`/projects/files/${e}`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project files",method:o.GET,url:`/projects/${e}/files/`,blockers:[],blocks:[]});this.dispatch(sl(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:o.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(Ro(e)),await this.enqueueRequest({description:"Update project",method:o.PATCH,url:`/projects/${e.uuid}/`,payload:{name:e.name,bounds:e.bounds},blockers:[e.uuid.toString()],blocks:[e.uuid.toString()]})}async delete(e){const{store:s}=this.client,n=s.getState(),a=It(n),c=a[e];if(!c)throw new Error("Expected project to exist");const r=ol(n).filter(h=>h.project===e);this.dispatch(al(r.map(({uuid:h})=>h)));const u=xo(c.uuid)(n);this.dispatch(un(u.map(({uuid:h})=>h)));const m=go(n);this.dispatch(So(m.map(({uuid:h})=>h))),this.dispatch({type:"rehydrated/setRehydrated",payload:!1}),this.dispatch(Po(c.uuid));const d=so(c.uuid)(n);d&&this.dispatch(pe({...d,project:null}));try{await this.enqueueRequest({description:"Delete project",method:o.DELETE,url:`/projects/${e}/`,blockers:[e.toString()],blocks:[]}),this.dispatch({type:"rehydrated/setRehydrated",payload:!0})}catch(h){throw this.dispatch(Fo(Object.values(a))),this.dispatch(sn(Object.values(m))),this.dispatch(il(r)),this.dispatch(Ko(u)),this.dispatch({type:"rehydrated/setRehydrated",payload:!0}),d&&this.dispatch(pe({...d,project:c.uuid})),h}}invite(e,s){const n=_.v4();return this.enqueueRequest({description:"Invite user to project",method:o.POST,url:`/projects/${e}/invite/${s}/`,payload:{uuid:n},blockers:[],blocks:[n]})}joinProject(e,s,n){return this.enqueueRequest({description:"Join project",method:o.GET,url:`/projects/${e}/join-project/${s}/${n}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}async acceptInvite(e){return this.enqueueRequest({description:"Accept project invite",method:o.PATCH,url:`/projects/${e}/accept-invite/`,blockers:[e.toString()],blocks:[e.toString()]}).then(()=>{this.dispatch(Oo(e))})}}class mS extends P{add(e){const s=R({...e,submitted_at:new Date().toISOString()});this.dispatch(Al(s));const n=this.enqueueRequest({description:"Create team",method:o.POST,url:`/organizations/${e.organization}/teams/`,payload:s,blockers:[],blocks:[s.uuid]});return n.then(a=>{this.dispatch(je(a))}).catch(()=>{this.dispatch(An(s.uuid))}),[s,n]}update(e){const{store:s}=this.client,n=qe(e.uuid)(s.getState());if(!n)throw new Error(`Expected team with uuid ${e.uuid} to exist`);const a={...n,...e};this.dispatch(pn(a));const c=this.enqueueRequest({description:"Update team",method:o.PATCH,url:`/organizations/teams/${e.uuid}/`,payload:v(e),blockers:[e.uuid],blocks:[e.uuid]});return c.then(r=>{this.dispatch(je(r))}).catch(()=>{this.dispatch(je(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=qe(e)(n);if(!a)throw new Error(`Expected team with uuid ${e} to exist`);this.dispatch(An(e));try{return await this.enqueueRequest({description:"Delete team",method:o.DELETE,url:`/organizations/teams/${e}/`,blockers:[e],blocks:[e]})}catch(c){throw this.dispatch(je(a)),c}}async setMembers(e,s){const{store:n}=this.client,a=qe(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(pn({...a,members:s}));const c=this.enqueueRequest({description:"Set team members",method:o.PUT,url:`/organizations/teams/${e}/set-members/`,payload:{users:s},blockers:[e],blocks:[e]});return c.catch(()=>{this.dispatch(je(a))}),c}async addMembers(e,s){const{store:n}=this.client,a=qe(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=qe(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:o.GET,url:`/organizations/${e}/teams/`,blockers:[],blocks:[]});this.dispatch(pl(s))}}class pS extends P{async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Fetch organization users",method:o.GET,url:`/organizations/${s}/users/`,blockers:[],blocks:[]});for(const r of a)n[r.uuid]=r;const c=await this.enqueueRequest({description:"Fetch project users",method:o.GET,url:`/projects/${e}/users/`,blockers:[],blocks:[]});for(const r of c)n[r.uuid]=r;this.dispatch(ao(Object.values(n)))}}var zl=(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))(zl||{});i.APIError=q,i.AgentService=hf,i.AssetAttachmentService=mf,i.AssetProcedureFieldValuesAttachmentService=yf,i.AssetProcedureFieldValuesService=gf,i.AssetProcedureFieldsAttachmentService=pf,i.AssetProcedureFieldsService=Af,i.AssetProcedureInstanceService=Tf,i.AssetProcedureService=bf,i.AssetService=If,i.AssetStageCompletionService=Ff,i.AssetStageService=Rf,i.AssetTypeAttachmentService=Pf,i.AssetTypeFieldValuesAttachmentService=_f,i.AssetTypeFieldValuesService=wf,i.AssetTypeFieldsAttachmentService=Of,i.AssetTypeFieldsService=vf,i.AssetTypeService=Ef,i.AttachmentModel=_n,i.BaseApiService=P,i.BaseSDK=of,i.COMMON_AUTO_FIELDS=Vn,i.CategoryService=jf,i.DEFAULT_ISSUE_PRIORITY=Kl,i.DEFAULT_ISSUE_STATUS=Wl,i.DeferredPromise=Mn,i.DocumentAttachmentService=qf,i.DocumentService=Mf,i.EMPTY_ARRAY=On,i.EMPTY_OBJECT=vn,i.EmailDomainsService=Cf,i.EmailVerificationService=kf,i.FileService=Df,i.FormRevisionAttachmentService=Vf,i.FormRevisionService=Uf,i.FormService=Bf,i.FormSubmissionAttachmentService=Gf,i.FormSubmissionService=Sf,i.GeoImageService=Lf,i.HttpMethod=o,i.IssueAssociationService=Nf,i.IssueAttachmentService=Hf,i.IssueCommentAttachmentService=Wf,i.IssueCommentService=Kf,i.IssuePriority=_t,i.IssueService=Yf,i.IssueStatus=wt,i.IssueTypeAttachmentService=Jf,i.IssueTypeFieldValuesAttachmentService=Zf,i.IssueTypeFieldValuesService=xf,i.IssueTypeFieldsAttachmentService=Xf,i.IssueTypeFieldsService=Qf,i.IssueTypeService=eS,i.IssueUpdateChange=w,i.IssueUpdateService=tS,i.JWTService=aS,i.LicenseLevel=En,i.LicenseService=cS,i.LicenseStatus=jn,i.OUTBOX_RETRY_DELAY=qn,i.OrganizationAccessLevel=vt,i.OrganizationAccessService=rS,i.OrganizationService=dS,i.OutboxCoordinator=Ce,i.PaddleCheckoutEvent=wn,i.ProjectAccessLevel=Ot,i.ProjectAccessService=uS,i.ProjectAttachmentService=oS,i.ProjectFileService=lS,i.ProjectService=hS,i.TeamService=mS,i.UNKNOWN_ERROR_MESSAGE=Me,i.UserService=pS,i.VERSION_REDUCER_KEY=Sn,i.VerificationCodeType=zl,i._setLatestRetryTime=Bo,i.acceptProjectInvite=Oo,i.addAsset=ds,i.addAssetAttachment=Sh,i.addAssetAttachments=Vt,i.addAssetProcedure=is,i.addAssetProcedureFieldValues=Wt,i.addAssetProcedureFieldValuesAttachment=zh,i.addAssetProcedureFieldValuesAttachments=Ze,i.addAssetProcedureFieldValuesMany=Oa,i.addAssetProcedureFields=ha,i.addAssetProcedureFieldsAttachment=bh,i.addAssetProcedureFieldsAttachments=na,i.addAssetProcedureFieldsMany=_h,i.addAssetProcedureInstance=Qt,i.addAssetProcedureInstances=Ma,i.addAssetProcedures=Qh,i.addAssetStage=lm,i.addAssetStageCompletion=As,i.addAssetStageCompletions=ys,i.addAssetStages=bs,i.addAssetType=Vs,i.addAssetTypeAttachment=Am,i.addAssetTypeAttachments=Os,i.addAssetTypeFieldValues=Ms,i.addAssetTypeFieldValuesAttachment=Mm,i.addAssetTypeFieldValuesAttachments=it,i.addAssetTypeFieldValuesMany=Uc,i.addAssetTypeFields=Pc,i.addAssetTypeFieldsAttachment=Sm,i.addAssetTypeFieldsAttachments=fc,i.addAssetTypeFieldsMany=Pm,i.addAssetTypes=Hm,i.addAssets=us,i.addCategory=Ls,i.addConversation=Ln,i.addDocumentAttachment=ip,i.addDocumentAttachments=ir,i.addDocuments=pr,i.addEmailDomain=Tr,i.addForm=si,i.addFormRevision=xs,i.addFormRevisionAttachment=mp,i.addFormRevisionAttachments=qr,i.addFormRevisions=$r,i.addFormSubmission=ri,i.addFormSubmissionAttachment=Op,i.addFormSubmissionAttachments=dt,i.addFormSubmissions=lt,i.addForms=Fp,i.addGeoImage=hd,i.addGeoImages=md,i.addIssue=qi,i.addIssueAssociation=yi,i.addIssueAssociations=fi,i.addIssueAttachment=Up,i.addIssueAttachments=Ii,i.addIssueComment=_i,i.addIssueCommentAttachment=Gp,i.addIssueCommentAttachments=Dd,i.addIssueComments=Wp,i.addIssueType=$u,i.addIssueTypeAttachment=Xp,i.addIssueTypeAttachments=iu,i.addIssueTypeFieldValues=Ui,i.addIssueTypeFieldValuesAttachment=IA,i.addIssueTypeFieldValuesAttachments=At,i.addIssueTypeFieldValuesMany=rA,i.addIssueTypeFields=Ou,i.addIssueTypeFieldsAttachment=eA,i.addIssueTypeFieldsAttachments=pu,i.addIssueTypeFieldsMany=mA,i.addIssueUpdate=Ku,i.addIssueUpdates=Yu,i.addIssues=Zd,i.addLicenses=qA,i.addOrganization=ly,i.addOrganizations=oy,i.addProject=sy,i.addProjectAttachment=Ry,i.addProjectAttachments=Ho,i.addProjectFile=_y,i.addProjectFiles=il,i.addProjects=ty,i.addTeam=Al,i.addUser=UA,i.addUsers=VA,i.agentsReducer=Wn,i.agentsSlice=Ct,i.areArraysEqual=Zl,i.assetAttachmentReducer=ta,i.assetAttachmentSlice=zt,i.assetProcedureFieldValuesAttachmentReducer=Fa,i.assetProcedureFieldValuesAttachmentSlice=Lt,i.assetProcedureFieldValuesReducer=Ea,i.assetProcedureFieldValuesSlice=Ht,i.assetProcedureFieldsAttachmentReducer=ua,i.assetProcedureFieldsAttachmentSlice=$t,i.assetProcedureFieldsReducer=ya,i.assetProcedureFieldsSlice=Bt,i.assetProcedureInstanceReducer=za,i.assetProcedureInstanceSlice=Xt,i.assetProcedureReducer=$a,i.assetProcedureSlice=ss,i.assetReducer=Ha,i.assetSlice=rs,i.assetStageCompletionReducer=Xa,i.assetStageCompletionSlice=ps,i.assetStageReducer=sc,i.assetStageSlice=Ts,i.assetTypeAttachmentReducer=pc,i.assetTypeAttachmentSlice=Ps,i.assetTypeFieldValuesAttachmentReducer=zc,i.assetTypeFieldValuesAttachmentSlice=Es,i.assetTypeFieldValuesReducer=Lc,i.assetTypeFieldValuesSlice=qs,i.assetTypeFieldsAttachmentReducer=Ic,i.assetTypeFieldsAttachmentSlice=_s,i.assetTypeFieldsReducer=wc,i.assetTypeFieldsSlice=ws,i.assetTypeReducer=Wc,i.assetTypeSlice=Ds,i.authReducer=Jc,i.authSlice=at,i.blobToBase64=rh,i.categoryReducer=er,i.categorySlice=Gs,i.clearTokens=Qm,i.constructUploadedFilePayloads=ch,i.coordinatesAreEqual=Xl,i.createModelAdapter=I,i.createMultiPointGeometry=Jl,i.createOfflineAction=Do,i.createPayload=v,i.createPointGeometry=Yl,i.deleteAsset=os,i.deleteAssetAttachment=Xn,i.deleteAssetAttachments=Ut,i.deleteAssetProcedure=ns,i.deleteAssetProcedureFieldValues=Kt,i.deleteAssetProcedureFieldValuesAttachment=$h,i.deleteAssetProcedureFieldValuesAttachments=xe,i.deleteAssetProcedureFieldValuesMany=_a,i.deleteAssetProcedureFields=pa,i.deleteAssetProcedureFieldsAttachment=Ph,i.deleteAssetProcedureFieldsAttachments=ca,i.deleteAssetProcedureFieldsMany=qh,i.deleteAssetProcedureInstance=Zt,i.deleteAssetProcedureInstances=Ca,i.deleteAssetProcedures=xh,i.deleteAssetStage=hm,i.deleteAssetStageCompletion=fs,i.deleteAssetStageCompletions=Ss,i.deleteAssetStages=Fs,i.deleteAssetType=Us,i.deleteAssetTypeAttachment=uc,i.deleteAssetTypeAttachments=vs,i.deleteAssetTypeFieldValues=Cs,i.deleteAssetTypeFieldValuesAttachment=Dm,i.deleteAssetTypeFieldValuesAttachments=nt,i.deleteAssetTypeFieldValuesMany=Bc,i.deleteAssetTypeFields=vc,i.deleteAssetTypeFieldsAttachment=Im,i.deleteAssetTypeFieldsAttachments=gc,i.deleteAssetTypeFieldsMany=wm,i.deleteAssetTypes=Km,i.deleteAssets=La,i.deleteCategory=xc,i.deleteDocumentAttachment=cr,i.deleteDocumentAttachments=rr,i.deleteEmailDomain=br,i.deleteForm=ii,i.deleteFormRevision=ei,i.deleteFormRevisionAttachment=fp,i.deleteFormRevisionAttachments=Cr,i.deleteFormRevisions=Br,i.deleteFormSubmission=di,i.deleteFormSubmissionAttachment=Ep,i.deleteFormSubmissionAttachments=ut,i.deleteFormSubmissions=ht,i.deleteGeoImage=mi,i.deleteGeoImages=Ad,i.deleteIssue=Mi,i.deleteIssueAssociation=Si,i.deleteIssueAssociations=gi,i.deleteIssueAttachment=Ed,i.deleteIssueAttachments=Fi,i.deleteIssueComment=wi,i.deleteIssueCommentAttachment=$d,i.deleteIssueCommentAttachments=Bd,i.deleteIssueComments=Kp,i.deleteIssueTypeAttachment=cu,i.deleteIssueTypeAttachments=ru,i.deleteIssueTypeFieldValues=$i,i.deleteIssueTypeFieldValuesAttachment=OA,i.deleteIssueTypeFieldValuesAttachments=yt,i.deleteIssueTypeFieldValuesMany=lA,i.deleteIssueTypeFields=_u,i.deleteIssueTypeFieldsAttachment=nA,i.deleteIssueTypeFieldsAttachments=yu,i.deleteIssueTypeFieldsMany=fA,i.deleteIssueUpdate=Ju,i.deleteIssueUpdates=Xu,i.deleteIssues=xd,i.deleteOrganization=py,i.deleteOrganizationAccess=ho,i.deleteOrganizations=Ay,i.deleteProject=Po,i.deleteProjectAccess=fo,i.deleteProjectAccesses=So,i.deleteProjectAttachment=Jo,i.deleteProjectAttachments=un,i.deleteProjectFile=nl,i.deleteProjectFiles=al,i.deleteProjects=ny,i.deleteTeam=An,i.deleteUser=GA,i.deleteUsers=LA,i.dequeue=ql,i.discard=bn,i.documentAttachmentReducer=lr,i.documentAttachmentSlice=Ws,i.documentSlice=Ks,i.documentsReducer=Sr,i.downloadFile=dh,i.downloadInMemoryFile=ah,i.emailDomainsReducer=Rr,i.emailDomainsSlice=Js,i.emailRegex=Ah,i.enqueue=jl,i.enqueueRequest=Uo,i.fallbackToEmptyArray=g,i.fallbackToEmptyObject=Oe,i.fileReducer=wr,i.fileSlice=Xs,i.fileToBlob=zn,i.formReducer=Kr,i.formRevisionAttachmentReducer=zr,i.formRevisionAttachmentSlice=Qs,i.formRevisionReducer=Nr,i.formRevisionsSlice=Zs,i.formSlice=ti,i.formSubmissionAttachmentReducer=td,i.formSubmissionAttachmentSlice=ni,i.formSubmissionReducer=dd,i.formSubmissionSlice=ci,i.geoImageReducer=Sd,i.geoImageSlice=hi,i.getFileIdentifier=nh,i.getFileS3Key=Mt,i.getLocalDateString=Cn,i.getLocalRelativeDateString=sh,i.getOutboxCoordinator=Ie,i.getRenamedFile=kn,i.hashFile=ve,i.initSDK=lf,i.initializeAssetAttachments=Dt,i.initializeAssetProcedureFieldValues=Pa,i.initializeAssetProcedureFieldValuesAttachments=Sa,i.initializeAssetProcedureFields=la,i.initializeAssetProcedureFieldsAttachments=ia,i.initializeAssetProcedureInstances=qa,i.initializeAssetProcedures=Va,i.initializeAssetStageCompletions=Ka,i.initializeAssetStages=ec,i.initializeAssetTypeAttachments=cc,i.initializeAssetTypeFieldValues=Vc,i.initializeAssetTypeFieldValuesAttachments=jc,i.initializeAssetTypeFields=Rc,i.initializeAssetTypeFieldsAttachments=yc,i.initializeAssetTypes=Hc,i.initializeAssets=Ga,i.initializeCategories=Qc,i.initializeConversations=Gn,i.initializeDocumentAttachments=sr,i.initializeEmailDomains=gr,i.initializeFormRevisionAttachments=jr,i.initializeFormRevisions=Ur,i.initializeFormSubmissionAttachments=Qr,i.initializeFormSubmissions=id,i.initializeForms=Wr,i.initializeGeoImages=od,i.initializeIssueAssociations=Td,i.initializeIssueAttachments=bi,i.initializeIssueCommentAttachments=Pi,i.initializeIssueTypeAttachments=zi,i.initializeIssueTypeFieldValues=bu,i.initializeIssueTypeFieldValuesAttachments=qu,i.initializeIssueTypeFields=Pu,i.initializeIssueTypeFieldsAttachments=mu,i.initializeIssueTypes=Uu,i.initializeIssueUpdates=Wu,i.initializeIssues=Qd,i.initializeLicences=to,i.initializeOrganizationAccesses=oo,i.initializeOrganizations=dy,i.initializeProjectAccesses=sn,i.initializeProjectAttachments=No,i.initializeProjectFiles=sl,i.initializeProjects=xA,i.initializeTeams=pl,i.initializeUsers=zA,i.isToday=th,i.issueAssociationReducer=Od,i.issueAssociationSlice=Ai,i.issueAttachmentReducer=kd,i.issueAttachmentSlice=Ti,i.issueCommentAttachmentReducer=Hd,i.issueCommentAttachmentSlice=Ri,i.issueCommentReducer=Jd,i.issueCommentSlice=Oi,i.issueReducer=tu,i.issueSlice=ji,i.issueTypeAttachmentReducer=lu,i.issueTypeAttachmentSlice=ki,i.issueTypeFieldValuesAttachmentReducer=Du,i.issueTypeFieldValuesAttachmentSlice=Ni,i.issueTypeFieldValuesReducer=Fu,i.issueTypeFieldValuesSlice=Vi,i.issueTypeFieldsAttachmentReducer=gu,i.issueTypeFieldsAttachmentSlice=Di,i.issueTypeFieldsReducer=Eu,i.issueTypeFieldsSlice=Li,i.issueTypeReducer=Nu,i.issueTypeSlice=Wi,i.issueUpdateReducer=xu,i.issueUpdateSlice=Xi,i.licenseReducer=io,i.licenseSlice=Qi,i.logOnlyOnce=uh,i.markAsDeleted=$o,i.markForDeletion=Fy,i.memoize=jt,i.moveDocument=Ar,i.offline=R,i.onlyUniqueHashes=ph,i.onlyUniqueOfflineIds=$n,i.organizationAccessReducer=po,i.organizationAccessSlice=xi,i.organizationReducer=zo,i.organizationSlice=cn,i.outboxReducer=Go,i.outboxSlice=rn,i.overmapEnhancer=Zy,i.overmapReducers=_l,i.overmapRootReducer=Ky,i.performRequest=Tn,i.projectAccessReducer=bo,i.projectAccessSlice=tn,i.projectAttachmentReducer=el,i.projectAttachmentSlice=dn,i.projectFileReducer=ll,i.projectFileSlice=on,i.projectReducer=vo,i.projectSlice=an,i.rehydratedReducer=hl,i.rehydratedSlice=hn,i.removeDocuments=Ys,i.removeIssueType=Ki,i.removeUser=co,i.resetProjectFileObjectUrls=Ey,i.resetStore=El,i.restructureCreateSelectorWithArgs=S,i.saveActiveProjectFileBounds=dl,i.selectAccessToken=Zm,i.selectActiveOrganizationAccess=JA,i.selectActiveProjectFileId=qy,i.selectActiveStatusLicenses=CA,i.selectAllDocumentAttachments=ur,i.selectAllProjectAttachments=Qo,i.selectAncestorIdsOfDocument=dp,i.selectAssetAttachmentById=xn,i.selectAssetAttachmentMapping=Qn,i.selectAssetAttachments=Zn,i.selectAssetById=ms,i.selectAssetProcedureById=cs,i.selectAssetProcedureFieldValues=Yt,i.selectAssetProcedureFieldValuesAttachmentById=Bh,i.selectAssetProcedureFieldValuesAttachments=Ta,i.selectAssetProcedureFieldValuesAttachmentsByIds=ba,i.selectAssetProcedureFieldValuesAttachmentsMapping=Nt,i.selectAssetProcedureFieldValuesById=Jt,i.selectAssetProcedureFieldValuesMapping=wa,i.selectAssetProcedureFieldValuesOfAsset=Nh,i.selectAssetProcedureFields=Gt,i.selectAssetProcedureFieldsAttachmentById=vh,i.selectAssetProcedureFieldsAttachments=da,i.selectAssetProcedureFieldsAttachmentsMapping=ra,i.selectAssetProcedureFieldsById=kh,i.selectAssetProcedureFieldsMapping=Aa,i.selectAssetProcedureFieldsOfAssetProcedure=Mh,i.selectAssetProcedureInstanceById=ts,i.selectAssetProcedureInstances=es,i.selectAssetProcedureInstancesByIds=Xh,i.selectAssetProcedureInstancesMapping=xt,i.selectAssetProcedureInstancesOfAssetProcedure=ka,i.selectAssetProcedureInstancesOfAssetType=Jh,i.selectAssetProcedures=Ua,i.selectAssetProceduresByIds=im,i.selectAssetProceduresMapping=as,i.selectAssetProceduresOfOrganization=sm,i.selectAssetStageById=ic,i.selectAssetStageCompletionById=Qa,i.selectAssetStageCompletionMapping=gs,i.selectAssetStageCompletions=um,i.selectAssetStageCompletionsByIds=Za,i.selectAssetStages=nc,i.selectAssetStagesByIds=Rs,i.selectAssetStagesMappingOfAssetProcedure=mm,i.selectAssetStagesOfAssetProcedure=pm,i.selectAssetTypeAttachmentById=hc,i.selectAssetTypeAttachmentMapping=oc,i.selectAssetTypeAttachments=lc,i.selectAssetTypeById=Bs,i.selectAssetTypeFieldValues=ks,i.selectAssetTypeFieldValuesAttachmentById=Vm,i.selectAssetTypeFieldValuesAttachments=Mc,i.selectAssetTypeFieldValuesAttachmentsByIds=Cc,i.selectAssetTypeFieldValuesAttachmentsMapping=js,i.selectAssetTypeFieldValuesById=zs,i.selectAssetTypeFieldValuesMapping=Gc,i.selectAssetTypeFieldValuesOfAsset=Bm,i.selectAssetTypeFields=st,i.selectAssetTypeFieldsAttachmentById=Rm,i.selectAssetTypeFieldsAttachments=bc,i.selectAssetTypeFieldsAttachmentsMapping=Tc,i.selectAssetTypeFieldsById=qm,i.selectAssetTypeFieldsMapping=_c,i.selectAssetTypeFieldsOfAssetType=Em,i.selectAssetTypeValuesOfAssetType=Gm,i.selectAssetTypes=Ym,i.selectAssetTypesByIds=Jm,i.selectAssetTypesMapping=$s,i.selectAssets=Na,i.selectAssetsByIds=rm,i.selectAssetsMapping=ls,i.selectAssetsOfAssetType=hs,i.selectAttachmentsOfAsset=ea,i.selectAttachmentsOfAssetProcedureFieldValues=Ia,i.selectAttachmentsOfAssetProcedureFields=Oh,i.selectAttachmentsOfAssetType=mc,i.selectAttachmentsOfAssetTypeFieldValues=kc,i.selectAttachmentsOfAssetTypeFields=Fm,i.selectAttachmentsOfDocument=cp,i.selectAttachmentsOfFormRevision=Sp,i.selectAttachmentsOfFormSubmission=ed,i.selectAttachmentsOfIssue=Md,i.selectAttachmentsOfIssueComment=Hp,i.selectAttachmentsOfIssueType=xp,i.selectAttachmentsOfIssueTypeFieldValues=zu,i.selectAttachmentsOfIssueTypeFields=aA,i.selectAttachmentsOfProject=xo,i.selectCategories=ep,i.selectCategoriesByIds=tp,i.selectCategoryById=Hs,i.selectCategoryMapping=Ns,i.selectCommentsOfIssue=Yp,i.selectConversation=fh,i.selectConversationMapping=kt,i.selectConversations=yh,i.selectCurrentUser=gt,i.selectDeletedRequests=by,i.selectDocumentAttachmentById=or,i.selectDocumentAttachmentMapping=dr,i.selectDocumentById=fr,i.selectDocuments=yr,i.selectDocumentsByIds=rp,i.selectDocumentsMapping=_e,i.selectEmailDomains=Fr,i.selectEmailDomainsAsMapping=Ir,i.selectEmailDomainsOfOrganization=lp,i.selectFieldValuesOfAssetProcedureInstance=Hh,i.selectFormById=Jr,i.selectFormMapping=Yr,i.selectFormRevisionAttachmentsMapping=kr,i.selectFormRevisionById=Tp,i.selectFormRevisionMapping=rt,i.selectFormRevisions=Gr,i.selectFormRevisionsOfForm=Lr,i.selectFormSubmissionAttachemntsByIds=xr,i.selectFormSubmissionAttachmentsMapping=ai,i.selectFormSubmissionById=li,i.selectFormSubmissions=oi,i.selectFormSubmissionsMapping=ui,i.selectFormSubmissionsOfAsset=rd,i.selectFormSubmissionsOfForm=ad,i.selectFormSubmissionsOfIssue=cd,i.selectForms=Pp,i.selectGeoImageById=pi,i.selectGeoImageMapping=yd,i.selectGeoImages=fd,i.selectGeoImagesOfProject=Cp,i.selectIsImportingProjectFile=My,i.selectIsLoggedIn=xm,i.selectIssueAssociationById=Id,i.selectIssueAssociationMapping=Ne,i.selectIssueAssociations=Vp,i.selectIssueAssociationsOfAsset=Pd,i.selectIssueAssociationsOfIssue=Rd,i.selectIssueAssociationsToIssue=Fd,i.selectIssueAttachmentById=Cd,i.selectIssueAttachmentMapping=jd,i.selectIssueAttachments=qd,i.selectIssueById=Ci,i.selectIssueCommentAttachmentById=Nd,i.selectIssueCommentAttachmentMapping=Gd,i.selectIssueCommentAttachments=Ld,i.selectIssueCommentById=Ei,i.selectIssueCommentMapping=Yd,i.selectIssueCountOfCategory=sp,i.selectIssueMapping=eu,i.selectIssueTypeAttachmentById=ou,i.selectIssueTypeAttachmentMapping=du,i.selectIssueTypeAttachments=uu,i.selectIssueTypeById=Yi,i.selectIssueTypeFieldValues=Bi,i.selectIssueTypeFieldValuesAttachmentById=vA,i.selectIssueTypeFieldValuesAttachments=Cu,i.selectIssueTypeFieldValuesAttachmentsByIds=ku,i.selectIssueTypeFieldValuesAttachmentsMapping=Hi,i.selectIssueTypeFieldValuesById=Gi,i.selectIssueTypeFieldValuesMapping=Iu,i.selectIssueTypeFieldValuesOfIssue=hA,i.selectIssueTypeFields=pt,i.selectIssueTypeFieldsAttachmentById=cA,i.selectIssueTypeFieldsAttachments=Su,i.selectIssueTypeFieldsAttachmentsMapping=fu,i.selectIssueTypeFieldsById=bA,i.selectIssueTypeFieldsMapping=wu,i.selectIssueTypeFieldsOfIssueType=SA,i.selectIssueTypeMapping=Gu,i.selectIssueTypeValuesOfIssueType=TA,i.selectIssueTypes=Lu,i.selectIssueTypesByIds=_A,i.selectIssueTypesOfOrganization=wA,i.selectIssueUpdateMapping=Qu,i.selectIssueUpdatesOfIssue=Zu,i.selectIssuesByIds=Jp,i.selectIssuesOfIssueType=Ji,i.selectIssuesOfIssueTypeCount=EA,i.selectLatestAssetProcedureFieldsOfAssetProcedure=Ch,i.selectLatestAssetTypeFieldsOfAssetType=jm,i.selectLatestFormRevisionOfForm=bp,i.selectLatestIssueTypeFieldsOfIssueType=gA,i.selectLatestRetryTime=Iy,i.selectLicense=MA,i.selectLicenseForProject=so,i.selectLicenses=St,i.selectLicensesForProjectsMapping=kA,i.selectLicensesOfOrganization=gy,i.selectNumberOfAssetsOfAssetType=dm,i.selectOrganizationAccessById=YA,i.selectOrganizationAccessForUser=XA,i.selectOrganizationAccessUserMapping=mo,i.selectOrganizationAccesses=en,i.selectOrganizationById=yy,i.selectOrganizationUsersAsMapping=ko,i.selectOrganizationUsersIds=Co,i.selectOrganizations=Mo,i.selectOrganizationsMapping=qo,i.selectOrganizationsWithAccess=fy,i.selectProjectAccessById=QA,i.selectProjectAccessForUser=ZA,i.selectProjectAccessMapping=nn,i.selectProjectAccessUserMapping=To,i.selectProjectAccesses=go,i.selectProjectAttachmentById=Zo,i.selectProjectAttachmentMapping=Xo,i.selectProjectById=cy,i.selectProjectFileById=jy,i.selectProjectFileMapping=ul,i.selectProjectFiles=ol,i.selectProjectMapping=It,i.selectProjectUsersAsMapping=wo,i.selectProjectUsersIds=_o,i.selectProjects=ay,i.selectProjectsOfOrganization=Sy,i.selectRehydrated=zy,i.selectRootDocuments=up,i.selectSortedOrganizationUsers=Ty,i.selectSortedProjectUsers=ry,i.selectStageMapping=tt,i.selectTeamById=qe,i.selectTeams=fn,i.selectTeamsByIds=Dy,i.selectTeamsMapping=yn,i.selectTeamsOfOrganization=Vy,i.selectTeamsOfUser=Uy,i.selectUploadUrl=_r,i.selectUserById=WA,i.selectUsersByIds=KA,i.selectUsersMapping=Tt,i.separateFilesFromValues=Xe,i.separateImageFromFields=$f,i.setActiveProjectFileId=rl,i.setAsset=am,i.setAssetAttachment=Yn,i.setAssetAttachments=gh,i.setAssetProcedure=em,i.setAssetProcedureFieldValues=Gh,i.setAssetProcedureFieldValuesAttachment=Dh,i.setAssetProcedureFieldValuesAttachments=Vh,i.setAssetProcedureFieldValuesMany=Lh,i.setAssetProcedureFields=wh,i.setAssetProcedureFieldsAttachment=Ih,i.setAssetProcedureFieldsAttachments=Fh,i.setAssetProcedureFieldsMany=Eh,i.setAssetProcedureInstance=Kh,i.setAssetProcedureInstances=Yh,i.setAssetProcedures=tm,i.setAssetStage=tc,i.setAssetStages=om,i.setAssetType=Lm,i.setAssetTypeAttachment=rc,i.setAssetTypeAttachments=ym,i.setAssetTypeFieldValues=Um,i.setAssetTypeFieldValuesAttachment=Cm,i.setAssetTypeFieldValuesAttachments=km,i.setAssetTypeFieldValuesMany=$m,i.setAssetTypeFields=Om,i.setAssetTypeFieldsAttachment=gm,i.setAssetTypeFieldsAttachments=Tm,i.setAssetTypeFieldsMany=vm,i.setAssetTypes=Nm,i.setAssets=cm,i.setConversation=Nn,i.setCurrentUser=NA,i.setDocumentAttachment=nr,i.setDocumentAttachments=np,i.setDocuments=mr,i.setForm=Ip,i.setFormRevision=Vr,i.setFormRevisionAttachment=pp,i.setFormRevisionAttachments=Ap,i.setFormSubmission=ot,i.setFormSubmissionAttachment=vp,i.setFormSubmissionAttachments=_p,i.setFormSubmissions=jp,i.setGeoImage=Le,i.setGeoImages=ld,i.setIsImportingProjectFile=cl,i.setIssueAssociation=zp,i.setIssueAssociations=kp,i.setIssueAttachment=_d,i.setIssueAttachments=$p,i.setIssueComment=vi,i.setIssueCommentAttachment=Vd,i.setIssueCommentAttachments=Lp,i.setIssueComments=Kd,i.setIssueType=We,i.setIssueTypeAttachment=nu,i.setIssueTypeAttachments=Qp,i.setIssueTypeFieldValues=dA,i.setIssueTypeFieldValuesAttachment=FA,i.setIssueTypeFieldValuesAttachments=RA,i.setIssueTypeFieldValuesMany=uA,i.setIssueTypeFields=pA,i.setIssueTypeFieldsAttachment=tA,i.setIssueTypeFieldsAttachments=sA,i.setIssueTypeFieldsMany=AA,i.setIssueUpdate=jA,i.setLoggedIn=Yc,i.setOrganization=uy,i.setOrganizations=jo,i.setProfilePicture=HA,i.setProject=ey,i.setProjectAttachment=Wo,i.setProjectAttachments=Ko,i.setProjectFile=Oy,i.setProjectFiles=vy,i.setProjects=Fo,i.setRehydrated=ky,i.setTeam=je,i.setTokens=Xm,i.setUploadUrl=vr,i.setUser=DA,i.setUsers=ao,i.shallowEqual=Ql,i.slugify=hh,i.spacesToDashesLower=lh,i.teamReducer=yl,i.teamSlice=mn,i.toFileNameSafeString=oh,i.toOfflineIdRecord=Un,i.truncate=mh,i.updateAsset=Ue,i.updateAssetAttachment=Th,i.updateAssetAttachments=Jn,i.updateAssetProcedure=Ve,i.updateAssetProcedureFieldValues=ze,i.updateAssetProcedureFieldValuesAttachment=Uh,i.updateAssetProcedureFieldValuesAttachments=ga,i.updateAssetProcedureFieldValuesMany=va,i.updateAssetProcedureFields=ma,i.updateAssetProcedureFieldsAttachment=Rh,i.updateAssetProcedureFieldsAttachments=aa,i.updateAssetProcedureFieldsMany=jh,i.updateAssetProcedureInstance=De,i.updateAssetProcedureInstances=Wh,i.updateAssetProcedures=Zh,i.updateAssetStage=Is,i.updateAssetStageCompletion=Ya,i.updateAssetStageCompletions=Ja,i.updateAssetStages=et,i.updateAssetType=Be,i.updateAssetTypeAttachment=fm,i.updateAssetTypeAttachments=dc,i.updateAssetTypeFieldValues=$e,i.updateAssetTypeFieldValuesAttachment=zm,i.updateAssetTypeFieldValuesAttachments=qc,i.updateAssetTypeFieldValuesMany=$c,i.updateAssetTypeFields=Oc,i.updateAssetTypeFieldsAttachment=bm,i.updateAssetTypeFieldsAttachments=Sc,i.updateAssetTypeFieldsMany=_m,i.updateAssetTypes=Wm,i.updateAssets=nm,i.updateCategory=Zc,i.updateConversation=Hn,i.updateDocumentAttachment=ap,i.updateDocumentAttachments=ar,i.updateDocuments=ye,i.updateForm=Rp,i.updateFormRevisionAttachment=yp,i.updateFormRevisionAttachments=Mr,i.updateFormSubmission=nd,i.updateFormSubmissionAttachment=wp,i.updateFormSubmissionAttachments=Zr,i.updateFormSubmissions=qp,i.updateGeoImage=pd,i.updateGeoImages=Mp,i.updateIssue=mt,i.updateIssueAssociation=bd,i.updateIssueAssociations=Dp,i.updateIssueAttachment=Bp,i.updateIssueAttachments=wd,i.updateIssueCommentAttachment=Np,i.updateIssueCommentAttachments=Ud,i.updateIssueType=Bu,i.updateIssueTypeAttachment=Zp,i.updateIssueTypeAttachments=au,i.updateIssueTypeFieldValues=He,i.updateIssueTypeFieldValuesAttachment=PA,i.updateIssueTypeFieldValuesAttachments=Mu,i.updateIssueTypeFieldValuesMany=oA,i.updateIssueTypeFields=vu,i.updateIssueTypeFieldsAttachment=iA,i.updateIssueTypeFieldsAttachments=Au,i.updateIssueTypeFieldsMany=yA,i.updateLicense=pe,i.updateOrganization=my,i.updateOrganizationAccess=lo,i.updateOrganizations=hy,i.updateProject=Ro,i.updateProjectAccess=yo,i.updateProjectAttachment=Py,i.updateProjectAttachments=Yo,i.updateProjectFile=ln,i.updateProjectFiles=wy,i.updateProjects=iy,i.updateTeam=pn,i.updateUser=BA,i.updateUsers=$A,i.userReducer=ro,i.userSlice=Zi,i.versioningReducer=Sl,i.versioningSlice=fl,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
15
+ 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??h+"."+p;if(d=Cn(d,A),!d.name)throw new Error("Failed to set file's name");await this.addCache(d,h),Ft[c]=new Promise(y=>{y(d)})}return d}}class Vf extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.uuid,a={},c=[],r=[];for(const d of e){const{revisionUuid:h,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:h,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:h};r.push(F)}this.dispatch(qr(c));const u=this.enqueueRequest({description:"Attach files to form revision",method:o.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(Mr(d.attachments))}).catch(()=>{this.dispatch(kr(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:o.GET,url:"/form-revision-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(jr(s))}}class Uf extends j{add(e){var u;const{store:s}=this.client,a=(u=s.getState().userReducer.currentUser)==null?void 0:u.uuid,c=R({...e,created_by:a,submitted_at:new Date().toISOString()});this.dispatch(xs(c));const r=this.enqueueRequest({description:"Create form revision",method:o.POST,url:"/form-revisions/",payload:v(c),blockers:[e.form],blocks:[c.uuid]});return r.then(m=>{this.dispatch(Vr(m))}).catch(()=>{this.dispatch(ei(c.uuid))}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization form revisions",method:o.GET,url:"/form-revisions/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(Ur(s))}}const $f=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 Bf 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.uuid,r=R({...e,submitted_at:a,created_by:c}),u=R({...s,form:r.uuid,submitted_at:a,created_by:c});this.dispatch(si(r)),this.dispatch(xs(u));const m=this.enqueueRequest({description:"Create form",method:o.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(h=>{throw this.dispatch(ii(r.uuid)),this.dispatch(ei(u.uuid)),h}),[r,u,m]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Jr(e)(n);if(!a)throw new Error("Expected form to exist");const c=ad(e)(n);c.length>0&&this.dispatch(ht(c.map(({uuid:u})=>u)));const r=Lr(e)(n);r.length>0&&this.dispatch(Br(r.map(({uuid:u})=>u))),this.dispatch(ii(e));try{return await this.enqueueRequest({description:"Delete form",method:o.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(u){throw this.dispatch(si(a)),r.length>0&&this.dispatch($r(r)),c.length>0&&this.dispatch(lt(c)),u}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization forms",method:o.GET,url:"/forms/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(Wr(s))}}class Gf extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.uuid,a={},c=[],r=[];for(const d of e){const{submissionUuid:h,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:h,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:h};r.push(F)}this.dispatch(dt(c));const u=this.enqueueRequest({description:"Attach files to form submission",method:o.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(Zr(d.attachments))}).catch(d=>{throw this.dispatch(ut(c.map(h=>h.uuid))),d}),[c,u.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=xr(e)(n);this.dispatch(ut(e));try{await this.enqueueRequest({description:"Delete form submission attachments",method:o.DELETE,url:"/form-submission-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(dt(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get form submission attachments",method:o.GET,url:"/form-submission-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Qr(s))}}class Lf extends j{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.uuid,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(hd(d));const h=this.enqueueRequest({description:"Add geo image",method:o.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.toString()],blockers:[u.toString()]});return h.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(Le(A.geo_image))}).catch(()=>{this.dispatch(mi(d.uuid))}),[d,h.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.uuid,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(md(r));const h=this.enqueueRequest({description:"Bulk add geo images",method:o.POST,url:"/geo-images/bulk/",payload:{submitted_at:a,project:s,geo_images:m,files:Object.values(d)},blocks:[s.toString()],blockers:u});return h.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(ld(A.geo_images))}).catch(()=>{this.dispatch(Ad(u))}),[r,h.then(A=>A.geo_images)]}update(e){const{store:s}=this.client,n=s.getState(),a=pi(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(pd(c));const r=this.enqueueRequest({description:"Update geo image",method:o.PATCH,url:`/geo-images/${e.uuid}/`,payload:e,blocks:[e.uuid],blockers:[e.uuid]});return r.then(u=>{this.dispatch(Le(u))}).catch(()=>{this.dispatch(Le(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=pi(e)(n);if(!a)throw new Error(`Map image with uuid ${e} does not exist in the store`);this.dispatch(mi(e));const c=this.enqueueRequest({description:"Delete geo image",method:o.DELETE,url:`/geo-images/${e}/`,blocks:[e],blockers:[e]});return c.catch(()=>{this.dispatch(Le(a))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get geo images",method:o.GET,url:`/projects/${e}/geo-images/`,blocks:[e],blockers:[]});this.dispatch(od(s))}}class Nf 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.uuid,c=R({...e,submitted_at:n,created_by:a});this.dispatch(yi(c));const r=this.enqueueRequest({description:"Add issue association",method:o.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(bd(m))}).catch(()=>{this.dispatch(Si(c.uuid))}),[c,r]}async delete(e){const{store:s}=this.client,n=Id(e)(s.getState());if(!n)throw new Error(`Issue association with uuid ${e} not found in store.`);this.dispatch(Si(e));const a=this.enqueueRequest({description:"Delete issue association",method:o.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(yi(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch issue associations",method:o.GET,url:"/issue-associations/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Td(s))}}class Hf extends Fe{constructor(){super(...arguments);f(this,"name","Issue Attachment");f(this,"url","/issue-attachments");f(this,"initializeAttachments",bi);f(this,"addAttachments",Ii);f(this,"updateAttachments",wd);f(this,"removeAttachments",Fi);f(this,"removeAttachment",Ed);f(this,"setAttachment",_d);f(this,"selectAttachment",kd)}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:o.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch(bi(n))}}class Wf extends Fe{constructor(){super(...arguments);f(this,"name","Issue Comment Attachment");f(this,"url","/issue-comment-attachments");f(this,"initializeAttachments",Pi);f(this,"addAttachments",Dd);f(this,"updateAttachments",Ud);f(this,"removeAttachments",Bd);f(this,"removeAttachment",$d);f(this,"setAttachment",Vd);f(this,"selectAttachment",Nd)}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:o.GET,url:`${this.url}/`,queryParams:{project:s},blocks:[],blockers:[]});this.dispatch(Pi(n))}}class Kf extends P{add(e){var c;const{store:s}=this.client,n=R({...e,author:(c=s.getState().userReducer.currentUser)==null?void 0:c.uuid,submitted_at:new Date().toISOString()});this.dispatch(_i(n));const a=this.enqueueRequest({description:"Add issue comment",method:o.POST,url:"/issue-comments/",payload:v(n),blockers:[e.issue],blocks:[n.uuid]});return a.catch(()=>{this.dispatch(wi(n.uuid))}),[n,a]}update(e){const{store:s}=this.client,n=Ei(e.uuid)(s.getState());if(!n)throw new Error(`Comment with uuid ${e.uuid} not found in store`);const a={...n,...e};this.dispatch(vi(a));const c=this.enqueueRequest({description:"Edit issue comment",method:o.PATCH,url:`/issue-comments/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return c.catch(()=>{this.dispatch(vi(n))}),[a,c]}remove(e){const{store:s}=this.client,n=Ei(e)(s.getState());if(!n)throw new Error(`Comment with uuid ${e} not found in store`);this.dispatch(wi(e));const a=this.enqueueRequest({description:"Delete comment",method:o.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(_i(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get comments",method:o.GET,url:"/issue-comments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Kd(s))}}class Yf 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.uuid,r=R({...e,submitted_at:a,created_by:c});this.dispatch(qi(r));const u=this.enqueueRequest({description:"Create issue",method:o.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(mt(d))}).catch(d=>{throw this.dispatch(Mi(r.uuid)),d}),[r,u]}update(e){var m;const s=this.client.store.getState(),n=ki(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(mt(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 p=e[d];if(p&&(h=s.categoryReducer.instances[p]??null,!h))throw new Error(`Trying to update issue category to ${p} which does not exist in store`);c[d]=h?{name:h.name,color:h.color,uuid:h.uuid}:null;break}case w.ASSIGNED_TO:{let h=null;const p=e[d];if(p&&(h=s.userReducer.instances[p]??null,!h))throw new Error(`Trying to update issue assigned_to to ${p} which does not exist in store`);c[d]=h?{full_name:h.username,uuid:h.uuid}:null;break}}const r=R({created_by:(m=s.userReducer.currentUser)==null?void 0:m.uuid,submitted_at:new Date().toISOString(),issue:n.uuid,changes:c});this.dispatch(Ku(r));const u=this.enqueueRequest({description:"Edit issue",method:o.PATCH,url:`/issues/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return u.catch(()=>{this.dispatch(mt(n)),this.dispatch(Ju(r.uuid))}),[a,u]}async remove(e){const{store:s}=this.client,n=s.getState(),a=ki(e)(n);if(!a)throw new Error(`No issue with uuid ${e} found in the store`);const c=Md(e)(n),r=Zu(e)(n),u=cd(e)(n),m={};for(const h of Fd(e)(n))m[h.uuid]=h;for(const h of Rd(e)(n))m[h.uuid]=h;const d=Object.values(m);this.dispatch(Mi(e)),c.length>0&&this.dispatch(Fi(c.map(({uuid:h})=>h))),r.length>0&&this.dispatch(Xu(r.map(({uuid:h})=>h))),u.length>0&&this.dispatch(ht(u.map(({uuid:h})=>h))),d.length>0&&this.dispatch(gi(d.map(({uuid:h})=>h)));try{return await this.enqueueRequest({description:"Delete issue",method:o.DELETE,url:`/issues/${e}/`,blockers:[e],blocks:[]})}catch(h){throw this.dispatch(qi(a)),this.dispatch(Ii(c)),this.dispatch(Yu(r)),this.dispatch(lt(u)),this.dispatch(fi(d)),h}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issues",method:o.GET,url:"/issues/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Qd(s))}}class Jf extends Fe{constructor(){super(...arguments);f(this,"name","Issue Type Attachment");f(this,"url","/issue-type-attachments");f(this,"initializeAttachments",zi);f(this,"addAttachments",iu);f(this,"updateAttachments",au);f(this,"removeAttachments",ru);f(this,"removeAttachment",cu);f(this,"setAttachment",nu);f(this,"selectAttachment",ou)}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:o.GET,url:`${this.url}/`,queryParams:{organization:s},blocks:[],blockers:[]});this.dispatch(zi(n))}}class Xf extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.uuid,a={},c=[],r=[];for(const d of e){const{fieldsRevisionUuid:h,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:h,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:h};r.push(F)}this.dispatch(pu(c));const u=this.enqueueRequest({description:"Add issue type fields attachments",method:o.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(Au(d.attachments))}).catch(()=>{this.dispatch(yu(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:o.GET,url:"/issue-type-fields-attachments/",queryParams:{organization:e},blockers:[e],blocks:[]});this.dispatch(mu(s))}}class Qf extends P{add(e){var u;const{store:s}=this.client,n=(u=s.getState().userReducer.currentUser)==null?void 0:u.uuid,a=new Date().toISOString(),c=R({...e,created_by:n,submitted_at:a});this.dispatch(Ou(c));const r=this.enqueueRequest({description:"Add Issue Type Fields",method:o.POST,url:"/issue-type-fields/",payload:v(c),blockers:[c.issue_type],blocks:[c.uuid]});return r.then(m=>{this.dispatch(vu(m))}).catch(m=>{throw this.dispatch(_u(c.uuid)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Issue Type Fields",method:o.GET,url:"/issue-type-fields/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Pu(s))}}class Zf extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.uuid,a={},c=[],r=[];for(const d of e){const{fieldValuesUuid:h,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:h,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:h};r.push(F)}this.dispatch(At(c));const u=this.enqueueRequest({description:"Add issue type field values attachments",method:o.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:h})=>{this.processPresignedUrls(d),this.dispatch(Mu(h))}).catch(d=>{throw this.dispatch(yt(c.map(h=>h.uuid))),d}),[c,u.then(({attachments:d})=>d)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Cu(e)(n);this.dispatch(yt(e));try{await this.enqueueRequest({description:"Delete issue type field values attachments",method:o.DELETE,url:"/issue-type-field-values-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 issue type field values attachments",method:o.GET,url:"/issue-type-field-values-attachments/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(qu(s))}}class xf 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.uuid,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add issue type field values",method:o.POST,url:"/issue-type-field-values/",payload:v(a),blockers:[e.issue,e.fields_revision],blocks:[a.uuid]});return this.dispatch(Ui(a)),c.then(u=>(this.dispatch(He(u)),u)).catch(()=>{this.dispatch($i(a.uuid))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=Gi(e.uuid)(n);if(!a)throw new Error(`Expected IssueTypeFieldValues with uuid ${e.uuid} to exist`);const c={...a,...e};this.dispatch(He(c));const r=this.enqueueRequest({description:"Update issue type field values",method:o.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(He(u))}).catch(()=>{this.dispatch(He(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Gi(e)(n);if(!a)throw new Error(`Expected submission with uuid ${e} to exist`);const c=zu(e)(n);this.dispatch($i(e)),this.dispatch(yt(c.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete issue type field values",method:o.DELETE,url:`/issue-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Ui(a)),this.dispatch(At(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values",method:o.GET,url:"/issue-type-field-values/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(bu(s))}}class eS 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.uuid});this.dispatch($u(a));const c=this.enqueueRequest({method:o.POST,url:"/issue-types/",payload:v(a),blockers:[],blocks:[a.uuid]});return c.then(u=>{this.dispatch(We(u))}).catch(()=>{this.dispatch(Ki(a.uuid))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=Yi(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(Bu(c));const r=this.enqueueRequest({method:o.PATCH,url:`/issue-types/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return r.then(u=>{this.dispatch(We(u))}).catch(()=>{this.dispatch(We(a))}),[c,r]}delete(e){const{store:s}=this.client,n=s.getState(),a=Yi(e)(n);if(!a)throw new Error(`IssueType with uuid ${e} does not exist in the store.`);const c=Ji(e)(n);this.dispatch(Ki(e)),this.dispatch(xd(c.map(u=>u.uuid)));const r=this.enqueueRequest({method:o.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return r.catch(()=>{this.dispatch(We(a)),this.dispatch(Zd(c))}),r}async refreshStore(e){const s=await this.enqueueRequest({method:o.GET,url:"/issue-types/",queryParams:{organization:e},blockers:[],blocks:[]});this.dispatch(Uu(s))}}class tS extends P{async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue updates",method:o.GET,url:"/issue-updates/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(Wu(s))}}class sS extends Il{constructor(e){super(e)}}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 sS{constructor(){super(...arguments);f(this,"_getRenewedTokens",async s=>{const n=this.enqueueRequest({description:"Get renewed tokens",method:o.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(Yc(!1)),this.clearTokens(),this.dispatch({type:Nl.RESET_STATE}),this.dispatch({type:El})}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??Me).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=_.v4();return console.debug(this.constructor.name,"Initiating auth"),this.enqueueRequest({uuid:n,description:"Get token pair",method:o.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:o.GET,url:`/billing/${e.uuid}/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(pe(s)),s}async pauseLicense(e){const s=await this.enqueueRequest({description:"Pause license",method:o.DELETE,url:`/billing/${e.uuid}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(pe(s)),s}async resumeLicense(e){const s=await this.enqueueRequest({description:"Resume license",method:o.PATCH,url:`/billing/${e.uuid}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(pe(s)),s}async cancelLicense(e){const s=await this.enqueueRequest({description:"Cancel license",method:o.DELETE,url:`/billing/${e.uuid}/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(pe(s)),s}async attachLicenseToProject(e,s){const n=await this.enqueueRequest({description:"Attach license",method:o.PATCH,url:`/billing/${e.uuid}/project/`,isAuthNeeded:!0,payload:{project:s.uuid},blockers:[e.organization_owner?e.organization_owner.toString():"",s.uuid?s.uuid.toString():""],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:o.DELETE,url:`/billing/${e.uuid}/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(pe(s)),s}async getLatestTransaction(e){return await this.enqueueRequest({description:"Get latest transaction",method:o.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:o.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:o.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(to(Object.values(n)))}}class rS extends P{async update(e){const s=this.enqueueRequest({description:"Edit organization access",method:o.PATCH,url:`/organizations/${e.organization}/access/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return s.then(()=>{this.dispatch(lo(e))}),s}async remove(e){return this.dispatch(ho(e.uuid)),this.dispatch(co(e.user)),this.enqueueRequest({description:"Remove organization access",method:o.DELETE,url:`/organizations/${e.organization}/access/${e.uuid}/`,blockers:[e.uuid],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization accesses",method:o.GET,url:`/organizations/${e}/access/`,blockers:[],blocks:[]});this.dispatch(oo(s))}}class dS extends P{create(e){return this.enqueueRequest({description:"Create organization",method:o.POST,url:"/organizations/",payload:{name:e},blockers:[],blocks:[`add-org-${e}`,"create-org"]})}async update(e){return this.enqueueRequest({description:"Edit organization",method:o.PATCH,url:`/organizations/${e.uuid}/`,payload:e,blockers:[`add-org-${e.name}`,e.uuid.toString()],blocks:[e.uuid.toString()]})}async invite(e,s){return this.enqueueRequest({description:"Invite user to organization",method:o.POST,url:`/organizations/${e}/invite/${s}/`,blockers:[],blocks:[]})}async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Get organizations",method:o.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:o.GET,url:`/organizations/${s}/`,blockers:[],blocks:[]});n[c.uuid]=c,this.dispatch(jo(Object.values(n)))}}class uS extends P{async update(e){return this.dispatch(yo(e)),this.enqueueRequest({description:"Edit project access",method:o.PATCH,url:`/project-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid,"change-access-level"],blocks:[e.uuid]})}async remove(e){return this.dispatch(fo(e)),this.enqueueRequest({description:"Delete project access",method:o.DELETE,url:`/project-accesses/${e}/`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project accesses",method:o.GET,url:"/project-accesses/",queryParams:{project:e},blockers:[],blocks:[]});this.dispatch(sn(s))}}class oS extends Fe{constructor(){super(...arguments);f(this,"name","Project Attachment");f(this,"url","/project-attachments");f(this,"addAttachments",Ho);f(this,"updateAttachments",Yo);f(this,"removeAttachments",un);f(this,"removeAttachment",Jo);f(this,"setAttachment",Wo);f(this,"selectAttachment",Zo)}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:o.GET,url:`${this.url}/`,queryParams:{project:s},blockers:[],blocks:[]});this.dispatch(No(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:o.PATCH,url:`/projects/files/${e.uuid}/`,payload:s,blockers:[e.uuid],blocks:[e.uuid]});return n.then(a=>{this.dispatch(ln(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:o.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:o.POST,url:`/projects/${a.project}/files/`,payload:{...a,...h},blockers:[n],blocks:[n]})}).catch(d)});const u=Promise.resolve(c).then(m=>this.enqueueRequest(m));return u.then(m=>{this.dispatch(ln(m))}),this.dispatch(dl),this.dispatch(rl(null)),this.dispatch(cl(!1)),[a,u]}delete(e){return this.dispatch(nl(e)),this.enqueueRequest({method:o.DELETE,url:`/projects/files/${e}`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project files",method:o.GET,url:`/projects/${e}/files/`,blockers:[],blocks:[]});this.dispatch(sl(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:o.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(Ro(e)),await this.enqueueRequest({description:"Update project",method:o.PATCH,url:`/projects/${e.uuid}/`,payload:{name:e.name,bounds:e.bounds},blockers:[e.uuid.toString()],blocks:[e.uuid.toString()]})}async delete(e){const{store:s}=this.client,n=s.getState(),a=It(n),c=a[e];if(!c)throw new Error("Expected project to exist");const r=ol(n).filter(h=>h.project===e);this.dispatch(al(r.map(({uuid:h})=>h)));const u=xo(c.uuid)(n);this.dispatch(un(u.map(({uuid:h})=>h)));const m=go(n);this.dispatch(So(m.map(({uuid:h})=>h))),this.dispatch({type:"rehydrated/setRehydrated",payload:!1}),this.dispatch(Po(c.uuid));const d=so(c.uuid)(n);d&&this.dispatch(pe({...d,project:null}));try{await this.enqueueRequest({description:"Delete project",method:o.DELETE,url:`/projects/${e}/`,blockers:[e.toString()],blocks:[]}),this.dispatch({type:"rehydrated/setRehydrated",payload:!0})}catch(h){throw this.dispatch(Fo(Object.values(a))),this.dispatch(sn(Object.values(m))),this.dispatch(il(r)),this.dispatch(Ko(u)),this.dispatch({type:"rehydrated/setRehydrated",payload:!0}),d&&this.dispatch(pe({...d,project:c.uuid})),h}}invite(e,s){const n=_.v4();return this.enqueueRequest({description:"Invite user to project",method:o.POST,url:`/projects/${e}/invite/${s}/`,payload:{uuid:n},blockers:[],blocks:[n]})}joinProject(e,s,n){return this.enqueueRequest({description:"Join project",method:o.GET,url:`/projects/${e}/join-project/${s}/${n}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}async acceptInvite(e){return this.enqueueRequest({description:"Accept project invite",method:o.PATCH,url:`/projects/${e}/accept-invite/`,blockers:[e.toString()],blocks:[e.toString()]}).then(()=>{this.dispatch(Oo(e))})}}class mS extends P{add(e){const s=R({...e,submitted_at:new Date().toISOString()});this.dispatch(Al(s));const n=this.enqueueRequest({description:"Create team",method:o.POST,url:`/organizations/${e.organization}/teams/`,payload:s,blockers:[],blocks:[s.uuid]});return n.then(a=>{this.dispatch(je(a))}).catch(()=>{this.dispatch(An(s.uuid))}),[s,n]}update(e){const{store:s}=this.client,n=qe(e.uuid)(s.getState());if(!n)throw new Error(`Expected team with uuid ${e.uuid} to exist`);const a={...n,...e};this.dispatch(pn(a));const c=this.enqueueRequest({description:"Update team",method:o.PATCH,url:`/organizations/teams/${e.uuid}/`,payload:v(e),blockers:[e.uuid],blocks:[e.uuid]});return c.then(r=>{this.dispatch(je(r))}).catch(()=>{this.dispatch(je(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=qe(e)(n);if(!a)throw new Error(`Expected team with uuid ${e} to exist`);this.dispatch(An(e));try{return await this.enqueueRequest({description:"Delete team",method:o.DELETE,url:`/organizations/teams/${e}/`,blockers:[e],blocks:[e]})}catch(c){throw this.dispatch(je(a)),c}}async setMembers(e,s){const{store:n}=this.client,a=qe(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(pn({...a,members:s}));const c=this.enqueueRequest({description:"Set team members",method:o.PUT,url:`/organizations/teams/${e}/set-members/`,payload:{users:s},blockers:[e],blocks:[e]});return c.catch(()=>{this.dispatch(je(a))}),c}async addMembers(e,s){const{store:n}=this.client,a=qe(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=qe(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:o.GET,url:`/organizations/${e}/teams/`,blockers:[],blocks:[]});this.dispatch(pl(s))}}class pS extends P{async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Fetch organization users",method:o.GET,url:`/organizations/${s}/users/`,blockers:[],blocks:[]});for(const r of a)n[r.uuid]=r;const c=await this.enqueueRequest({description:"Fetch project users",method:o.GET,url:`/projects/${e}/users/`,blockers:[],blocks:[]});for(const r of c)n[r.uuid]=r;this.dispatch(ao(Object.values(n)))}}var zl=(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))(zl||{});i.APIError=q,i.AgentService=hf,i.AssetAttachmentService=mf,i.AssetProcedureFieldValuesAttachmentService=yf,i.AssetProcedureFieldValuesService=gf,i.AssetProcedureFieldsAttachmentService=pf,i.AssetProcedureFieldsService=Af,i.AssetProcedureInstanceService=Tf,i.AssetProcedureService=bf,i.AssetService=If,i.AssetStageCompletionService=Ff,i.AssetStageService=Rf,i.AssetTypeAttachmentService=Pf,i.AssetTypeFieldValuesAttachmentService=_f,i.AssetTypeFieldValuesService=wf,i.AssetTypeFieldsAttachmentService=Of,i.AssetTypeFieldsService=vf,i.AssetTypeService=Ef,i.AttachmentModel=_n,i.BaseApiService=P,i.BaseSDK=of,i.COMMON_AUTO_FIELDS=Vn,i.CategoryService=jf,i.DEFAULT_ISSUE_PRIORITY=Kl,i.DEFAULT_ISSUE_STATUS=Wl,i.DeferredPromise=Mn,i.DocumentAttachmentService=qf,i.DocumentService=Mf,i.EMPTY_ARRAY=On,i.EMPTY_OBJECT=vn,i.EmailDomainsService=kf,i.EmailVerificationService=Cf,i.FileService=Df,i.FormRevisionAttachmentService=Vf,i.FormRevisionService=Uf,i.FormService=Bf,i.FormSubmissionAttachmentService=Gf,i.FormSubmissionService=Sf,i.GeoImageService=Lf,i.HttpMethod=o,i.IssueAssociationService=Nf,i.IssueAttachmentService=Hf,i.IssueCommentAttachmentService=Wf,i.IssueCommentService=Kf,i.IssuePriority=_t,i.IssueService=Yf,i.IssueStatus=wt,i.IssueTypeAttachmentService=Jf,i.IssueTypeFieldValuesAttachmentService=Zf,i.IssueTypeFieldValuesService=xf,i.IssueTypeFieldsAttachmentService=Xf,i.IssueTypeFieldsService=Qf,i.IssueTypeService=eS,i.IssueUpdateChange=w,i.IssueUpdateService=tS,i.JWTService=aS,i.LicenseLevel=En,i.LicenseService=cS,i.LicenseStatus=jn,i.OUTBOX_RETRY_DELAY=qn,i.OrganizationAccessLevel=vt,i.OrganizationAccessService=rS,i.OrganizationService=dS,i.OutboxCoordinator=ke,i.PaddleCheckoutEvent=wn,i.ProjectAccessLevel=Ot,i.ProjectAccessService=uS,i.ProjectAttachmentService=oS,i.ProjectFileService=lS,i.ProjectService=hS,i.TeamService=mS,i.UNKNOWN_ERROR_MESSAGE=Me,i.UserService=pS,i.VERSION_REDUCER_KEY=Sn,i.VerificationCodeType=zl,i._setLatestRetryTime=Bo,i.acceptProjectInvite=Oo,i.addAsset=ds,i.addAssetAttachment=Sh,i.addAssetAttachments=Vt,i.addAssetProcedure=is,i.addAssetProcedureFieldValues=Wt,i.addAssetProcedureFieldValuesAttachment=zh,i.addAssetProcedureFieldValuesAttachments=Ze,i.addAssetProcedureFieldValuesMany=Oa,i.addAssetProcedureFields=ha,i.addAssetProcedureFieldsAttachment=bh,i.addAssetProcedureFieldsAttachments=na,i.addAssetProcedureFieldsMany=_h,i.addAssetProcedureInstance=Qt,i.addAssetProcedureInstances=Ma,i.addAssetProcedures=Qh,i.addAssetStage=lm,i.addAssetStageCompletion=As,i.addAssetStageCompletions=ys,i.addAssetStages=bs,i.addAssetType=Vs,i.addAssetTypeAttachment=Am,i.addAssetTypeAttachments=Os,i.addAssetTypeFieldValues=Ms,i.addAssetTypeFieldValuesAttachment=Mm,i.addAssetTypeFieldValuesAttachments=it,i.addAssetTypeFieldValuesMany=Uc,i.addAssetTypeFields=Pc,i.addAssetTypeFieldsAttachment=Sm,i.addAssetTypeFieldsAttachments=fc,i.addAssetTypeFieldsMany=Pm,i.addAssetTypes=Hm,i.addAssets=us,i.addCategory=Ls,i.addConversation=Ln,i.addDocumentAttachment=ip,i.addDocumentAttachments=ir,i.addDocuments=pr,i.addEmailDomain=Tr,i.addForm=si,i.addFormRevision=xs,i.addFormRevisionAttachment=mp,i.addFormRevisionAttachments=qr,i.addFormRevisions=$r,i.addFormSubmission=ri,i.addFormSubmissionAttachment=Op,i.addFormSubmissionAttachments=dt,i.addFormSubmissions=lt,i.addForms=Fp,i.addGeoImage=hd,i.addGeoImages=md,i.addIssue=qi,i.addIssueAssociation=yi,i.addIssueAssociations=fi,i.addIssueAttachment=Up,i.addIssueAttachments=Ii,i.addIssueComment=_i,i.addIssueCommentAttachment=Gp,i.addIssueCommentAttachments=Dd,i.addIssueComments=Wp,i.addIssueType=$u,i.addIssueTypeAttachment=Xp,i.addIssueTypeAttachments=iu,i.addIssueTypeFieldValues=Ui,i.addIssueTypeFieldValuesAttachment=IA,i.addIssueTypeFieldValuesAttachments=At,i.addIssueTypeFieldValuesMany=rA,i.addIssueTypeFields=Ou,i.addIssueTypeFieldsAttachment=eA,i.addIssueTypeFieldsAttachments=pu,i.addIssueTypeFieldsMany=mA,i.addIssueUpdate=Ku,i.addIssueUpdates=Yu,i.addIssues=Zd,i.addLicenses=qA,i.addOrganization=ly,i.addOrganizations=oy,i.addProject=sy,i.addProjectAttachment=Ry,i.addProjectAttachments=Ho,i.addProjectFile=_y,i.addProjectFiles=il,i.addProjects=ty,i.addTeam=Al,i.addUser=UA,i.addUsers=VA,i.agentsReducer=Wn,i.agentsSlice=kt,i.areArraysEqual=Zl,i.assetAttachmentReducer=ta,i.assetAttachmentSlice=zt,i.assetProcedureFieldValuesAttachmentReducer=Fa,i.assetProcedureFieldValuesAttachmentSlice=Lt,i.assetProcedureFieldValuesReducer=Ea,i.assetProcedureFieldValuesSlice=Ht,i.assetProcedureFieldsAttachmentReducer=ua,i.assetProcedureFieldsAttachmentSlice=$t,i.assetProcedureFieldsReducer=ya,i.assetProcedureFieldsSlice=Bt,i.assetProcedureInstanceReducer=za,i.assetProcedureInstanceSlice=Xt,i.assetProcedureReducer=$a,i.assetProcedureSlice=ss,i.assetReducer=Ha,i.assetSlice=rs,i.assetStageCompletionReducer=Xa,i.assetStageCompletionSlice=ps,i.assetStageReducer=sc,i.assetStageSlice=Ts,i.assetTypeAttachmentReducer=pc,i.assetTypeAttachmentSlice=Ps,i.assetTypeFieldValuesAttachmentReducer=zc,i.assetTypeFieldValuesAttachmentSlice=Es,i.assetTypeFieldValuesReducer=Lc,i.assetTypeFieldValuesSlice=qs,i.assetTypeFieldsAttachmentReducer=Ic,i.assetTypeFieldsAttachmentSlice=_s,i.assetTypeFieldsReducer=wc,i.assetTypeFieldsSlice=ws,i.assetTypeReducer=Wc,i.assetTypeSlice=Ds,i.authReducer=Jc,i.authSlice=at,i.blobToBase64=rh,i.categoryReducer=er,i.categorySlice=Gs,i.clearTokens=Qm,i.constructUploadedFilePayloads=ch,i.coordinatesAreEqual=Xl,i.createModelAdapter=I,i.createMultiPointGeometry=Jl,i.createOfflineAction=Do,i.createPayload=v,i.createPointGeometry=Yl,i.deleteAsset=os,i.deleteAssetAttachment=Xn,i.deleteAssetAttachments=Ut,i.deleteAssetProcedure=ns,i.deleteAssetProcedureFieldValues=Kt,i.deleteAssetProcedureFieldValuesAttachment=$h,i.deleteAssetProcedureFieldValuesAttachments=xe,i.deleteAssetProcedureFieldValuesMany=_a,i.deleteAssetProcedureFields=pa,i.deleteAssetProcedureFieldsAttachment=Ph,i.deleteAssetProcedureFieldsAttachments=ca,i.deleteAssetProcedureFieldsMany=qh,i.deleteAssetProcedureInstance=Zt,i.deleteAssetProcedureInstances=ka,i.deleteAssetProcedures=xh,i.deleteAssetStage=hm,i.deleteAssetStageCompletion=fs,i.deleteAssetStageCompletions=Ss,i.deleteAssetStages=Fs,i.deleteAssetType=Us,i.deleteAssetTypeAttachment=uc,i.deleteAssetTypeAttachments=vs,i.deleteAssetTypeFieldValues=ks,i.deleteAssetTypeFieldValuesAttachment=Dm,i.deleteAssetTypeFieldValuesAttachments=nt,i.deleteAssetTypeFieldValuesMany=Bc,i.deleteAssetTypeFields=vc,i.deleteAssetTypeFieldsAttachment=Im,i.deleteAssetTypeFieldsAttachments=gc,i.deleteAssetTypeFieldsMany=wm,i.deleteAssetTypes=Km,i.deleteAssets=La,i.deleteCategory=xc,i.deleteDocumentAttachment=cr,i.deleteDocumentAttachments=rr,i.deleteEmailDomain=br,i.deleteForm=ii,i.deleteFormRevision=ei,i.deleteFormRevisionAttachment=fp,i.deleteFormRevisionAttachments=kr,i.deleteFormRevisions=Br,i.deleteFormSubmission=di,i.deleteFormSubmissionAttachment=Ep,i.deleteFormSubmissionAttachments=ut,i.deleteFormSubmissions=ht,i.deleteGeoImage=mi,i.deleteGeoImages=Ad,i.deleteIssue=Mi,i.deleteIssueAssociation=Si,i.deleteIssueAssociations=gi,i.deleteIssueAttachment=Ed,i.deleteIssueAttachments=Fi,i.deleteIssueComment=wi,i.deleteIssueCommentAttachment=$d,i.deleteIssueCommentAttachments=Bd,i.deleteIssueComments=Kp,i.deleteIssueTypeAttachment=cu,i.deleteIssueTypeAttachments=ru,i.deleteIssueTypeFieldValues=$i,i.deleteIssueTypeFieldValuesAttachment=OA,i.deleteIssueTypeFieldValuesAttachments=yt,i.deleteIssueTypeFieldValuesMany=lA,i.deleteIssueTypeFields=_u,i.deleteIssueTypeFieldsAttachment=nA,i.deleteIssueTypeFieldsAttachments=yu,i.deleteIssueTypeFieldsMany=fA,i.deleteIssueUpdate=Ju,i.deleteIssueUpdates=Xu,i.deleteIssues=xd,i.deleteOrganization=py,i.deleteOrganizationAccess=ho,i.deleteOrganizations=Ay,i.deleteProject=Po,i.deleteProjectAccess=fo,i.deleteProjectAccesses=So,i.deleteProjectAttachment=Jo,i.deleteProjectAttachments=un,i.deleteProjectFile=nl,i.deleteProjectFiles=al,i.deleteProjects=ny,i.deleteTeam=An,i.deleteUser=GA,i.deleteUsers=LA,i.dequeue=ql,i.discard=bn,i.documentAttachmentReducer=lr,i.documentAttachmentSlice=Ws,i.documentSlice=Ks,i.documentsReducer=Sr,i.downloadFile=dh,i.downloadInMemoryFile=ah,i.emailDomainsReducer=Rr,i.emailDomainsSlice=Js,i.emailRegex=Ah,i.enqueue=jl,i.enqueueRequest=Uo,i.fallbackToEmptyArray=g,i.fallbackToEmptyObject=Oe,i.fileReducer=wr,i.fileSlice=Xs,i.fileToBlob=zn,i.formReducer=Kr,i.formRevisionAttachmentReducer=zr,i.formRevisionAttachmentSlice=Qs,i.formRevisionReducer=Nr,i.formRevisionsSlice=Zs,i.formSlice=ti,i.formSubmissionAttachmentReducer=td,i.formSubmissionAttachmentSlice=ni,i.formSubmissionReducer=dd,i.formSubmissionSlice=ci,i.geoImageReducer=Sd,i.geoImageSlice=hi,i.getFileIdentifier=nh,i.getFileS3Key=Mt,i.getLocalDateString=kn,i.getLocalRelativeDateString=sh,i.getOutboxCoordinator=Ie,i.getRenamedFile=Cn,i.hashFile=ve,i.initSDK=lf,i.initializeAssetAttachments=Dt,i.initializeAssetProcedureFieldValues=Pa,i.initializeAssetProcedureFieldValuesAttachments=Sa,i.initializeAssetProcedureFields=la,i.initializeAssetProcedureFieldsAttachments=ia,i.initializeAssetProcedureInstances=qa,i.initializeAssetProcedures=Va,i.initializeAssetStageCompletions=Ka,i.initializeAssetStages=ec,i.initializeAssetTypeAttachments=cc,i.initializeAssetTypeFieldValues=Vc,i.initializeAssetTypeFieldValuesAttachments=jc,i.initializeAssetTypeFields=Rc,i.initializeAssetTypeFieldsAttachments=yc,i.initializeAssetTypes=Hc,i.initializeAssets=Ga,i.initializeCategories=Qc,i.initializeConversations=Gn,i.initializeDocumentAttachments=sr,i.initializeEmailDomains=gr,i.initializeFormRevisionAttachments=jr,i.initializeFormRevisions=Ur,i.initializeFormSubmissionAttachments=Qr,i.initializeFormSubmissions=id,i.initializeForms=Wr,i.initializeGeoImages=od,i.initializeIssueAssociations=Td,i.initializeIssueAttachments=bi,i.initializeIssueCommentAttachments=Pi,i.initializeIssueTypeAttachments=zi,i.initializeIssueTypeFieldValues=bu,i.initializeIssueTypeFieldValuesAttachments=qu,i.initializeIssueTypeFields=Pu,i.initializeIssueTypeFieldsAttachments=mu,i.initializeIssueTypes=Uu,i.initializeIssueUpdates=Wu,i.initializeIssues=Qd,i.initializeLicences=to,i.initializeOrganizationAccesses=oo,i.initializeOrganizations=dy,i.initializeProjectAccesses=sn,i.initializeProjectAttachments=No,i.initializeProjectFiles=sl,i.initializeProjects=xA,i.initializeTeams=pl,i.initializeUsers=zA,i.isToday=th,i.issueAssociationReducer=Od,i.issueAssociationSlice=Ai,i.issueAttachmentReducer=Cd,i.issueAttachmentSlice=Ti,i.issueCommentAttachmentReducer=Hd,i.issueCommentAttachmentSlice=Ri,i.issueCommentReducer=Jd,i.issueCommentSlice=Oi,i.issueReducer=tu,i.issueSlice=ji,i.issueTypeAttachmentReducer=lu,i.issueTypeAttachmentSlice=Ci,i.issueTypeFieldValuesAttachmentReducer=Du,i.issueTypeFieldValuesAttachmentSlice=Ni,i.issueTypeFieldValuesReducer=Fu,i.issueTypeFieldValuesSlice=Vi,i.issueTypeFieldsAttachmentReducer=gu,i.issueTypeFieldsAttachmentSlice=Di,i.issueTypeFieldsReducer=Eu,i.issueTypeFieldsSlice=Li,i.issueTypeReducer=Nu,i.issueTypeSlice=Wi,i.issueUpdateReducer=xu,i.issueUpdateSlice=Xi,i.licenseReducer=io,i.licenseSlice=Qi,i.logOnlyOnce=uh,i.markAsDeleted=$o,i.markForDeletion=Fy,i.memoize=jt,i.moveDocument=Ar,i.offline=R,i.onlyUniqueHashes=ph,i.onlyUniqueOfflineIds=$n,i.organizationAccessReducer=po,i.organizationAccessSlice=xi,i.organizationReducer=zo,i.organizationSlice=cn,i.outboxReducer=Go,i.outboxSlice=rn,i.overmapEnhancer=Zy,i.overmapReducers=_l,i.overmapRootReducer=Ky,i.performRequest=Tn,i.projectAccessReducer=bo,i.projectAccessSlice=tn,i.projectAttachmentReducer=el,i.projectAttachmentSlice=dn,i.projectFileReducer=ll,i.projectFileSlice=on,i.projectReducer=vo,i.projectSlice=an,i.rehydratedReducer=hl,i.rehydratedSlice=hn,i.removeDocuments=Ys,i.removeIssueType=Ki,i.removeUser=co,i.resetProjectFileObjectUrls=Ey,i.resetStore=El,i.restructureCreateSelectorWithArgs=S,i.saveActiveProjectFileBounds=dl,i.selectAccessToken=Zm,i.selectActiveOrganizationAccess=JA,i.selectActiveProjectFileId=qy,i.selectActiveStatusLicenses=kA,i.selectAllDocumentAttachments=ur,i.selectAllProjectAttachments=Qo,i.selectAncestorIdsOfDocument=dp,i.selectAssetAttachmentById=xn,i.selectAssetAttachmentMapping=Qn,i.selectAssetAttachments=Zn,i.selectAssetById=ms,i.selectAssetProcedureById=cs,i.selectAssetProcedureFieldValues=Yt,i.selectAssetProcedureFieldValuesAttachmentById=Bh,i.selectAssetProcedureFieldValuesAttachments=Ta,i.selectAssetProcedureFieldValuesAttachmentsByIds=ba,i.selectAssetProcedureFieldValuesAttachmentsMapping=Nt,i.selectAssetProcedureFieldValuesById=Jt,i.selectAssetProcedureFieldValuesMapping=wa,i.selectAssetProcedureFieldValuesOfAsset=Nh,i.selectAssetProcedureFields=Gt,i.selectAssetProcedureFieldsAttachmentById=vh,i.selectAssetProcedureFieldsAttachments=da,i.selectAssetProcedureFieldsAttachmentsMapping=ra,i.selectAssetProcedureFieldsById=Ch,i.selectAssetProcedureFieldsMapping=Aa,i.selectAssetProcedureFieldsOfAssetProcedure=Mh,i.selectAssetProcedureInstanceById=ts,i.selectAssetProcedureInstances=es,i.selectAssetProcedureInstancesByIds=Xh,i.selectAssetProcedureInstancesMapping=xt,i.selectAssetProcedureInstancesOfAssetProcedure=Ca,i.selectAssetProcedureInstancesOfAssetType=Jh,i.selectAssetProcedures=Ua,i.selectAssetProceduresByIds=im,i.selectAssetProceduresMapping=as,i.selectAssetProceduresOfOrganization=sm,i.selectAssetStageById=ic,i.selectAssetStageCompletionById=Qa,i.selectAssetStageCompletionMapping=gs,i.selectAssetStageCompletions=um,i.selectAssetStageCompletionsByIds=Za,i.selectAssetStages=nc,i.selectAssetStagesByIds=Rs,i.selectAssetStagesMappingOfAssetProcedure=mm,i.selectAssetStagesOfAssetProcedure=pm,i.selectAssetTypeAttachmentById=hc,i.selectAssetTypeAttachmentMapping=oc,i.selectAssetTypeAttachments=lc,i.selectAssetTypeById=Bs,i.selectAssetTypeFieldValues=Cs,i.selectAssetTypeFieldValuesAttachmentById=Vm,i.selectAssetTypeFieldValuesAttachments=Mc,i.selectAssetTypeFieldValuesAttachmentsByIds=kc,i.selectAssetTypeFieldValuesAttachmentsMapping=js,i.selectAssetTypeFieldValuesById=zs,i.selectAssetTypeFieldValuesMapping=Gc,i.selectAssetTypeFieldValuesOfAsset=Bm,i.selectAssetTypeFields=st,i.selectAssetTypeFieldsAttachmentById=Rm,i.selectAssetTypeFieldsAttachments=bc,i.selectAssetTypeFieldsAttachmentsMapping=Tc,i.selectAssetTypeFieldsById=qm,i.selectAssetTypeFieldsMapping=_c,i.selectAssetTypeFieldsOfAssetType=Em,i.selectAssetTypeValuesOfAssetType=Gm,i.selectAssetTypes=Ym,i.selectAssetTypesByIds=Jm,i.selectAssetTypesMapping=$s,i.selectAssets=Na,i.selectAssetsByIds=rm,i.selectAssetsMapping=ls,i.selectAssetsOfAssetType=hs,i.selectAttachmentsOfAsset=ea,i.selectAttachmentsOfAssetProcedureFieldValues=Ia,i.selectAttachmentsOfAssetProcedureFields=Oh,i.selectAttachmentsOfAssetType=mc,i.selectAttachmentsOfAssetTypeFieldValues=Cc,i.selectAttachmentsOfAssetTypeFields=Fm,i.selectAttachmentsOfDocument=cp,i.selectAttachmentsOfFormRevision=Sp,i.selectAttachmentsOfFormSubmission=ed,i.selectAttachmentsOfIssue=Md,i.selectAttachmentsOfIssueComment=Hp,i.selectAttachmentsOfIssueType=xp,i.selectAttachmentsOfIssueTypeFieldValues=zu,i.selectAttachmentsOfIssueTypeFields=aA,i.selectAttachmentsOfProject=xo,i.selectCategories=ep,i.selectCategoriesByIds=tp,i.selectCategoryById=Hs,i.selectCategoryMapping=Ns,i.selectCommentsOfIssue=Yp,i.selectConversation=fh,i.selectConversationMapping=Ct,i.selectConversations=yh,i.selectCurrentUser=gt,i.selectDeletedRequests=by,i.selectDocumentAttachmentById=or,i.selectDocumentAttachmentMapping=dr,i.selectDocumentById=fr,i.selectDocuments=yr,i.selectDocumentsByIds=rp,i.selectDocumentsMapping=_e,i.selectEmailDomains=Fr,i.selectEmailDomainsAsMapping=Ir,i.selectEmailDomainsOfOrganization=lp,i.selectFieldValuesOfAssetProcedureInstance=Hh,i.selectFormById=Jr,i.selectFormMapping=Yr,i.selectFormRevisionAttachmentsMapping=Cr,i.selectFormRevisionById=Tp,i.selectFormRevisionMapping=rt,i.selectFormRevisions=Gr,i.selectFormRevisionsOfForm=Lr,i.selectFormSubmissionAttachemntsByIds=xr,i.selectFormSubmissionAttachmentsMapping=ai,i.selectFormSubmissionById=li,i.selectFormSubmissions=oi,i.selectFormSubmissionsMapping=ui,i.selectFormSubmissionsOfAsset=rd,i.selectFormSubmissionsOfForm=ad,i.selectFormSubmissionsOfIssue=cd,i.selectForms=Pp,i.selectGeoImageById=pi,i.selectGeoImageMapping=yd,i.selectGeoImages=fd,i.selectGeoImagesOfProject=kp,i.selectIsImportingProjectFile=My,i.selectIsLoggedIn=xm,i.selectIssueAssociationById=Id,i.selectIssueAssociationMapping=Ne,i.selectIssueAssociations=Vp,i.selectIssueAssociationsOfAsset=Pd,i.selectIssueAssociationsOfIssue=Rd,i.selectIssueAssociationsToIssue=Fd,i.selectIssueAttachmentById=kd,i.selectIssueAttachmentMapping=jd,i.selectIssueAttachments=qd,i.selectIssueById=ki,i.selectIssueCommentAttachmentById=Nd,i.selectIssueCommentAttachmentMapping=Gd,i.selectIssueCommentAttachments=Ld,i.selectIssueCommentById=Ei,i.selectIssueCommentMapping=Yd,i.selectIssueCountOfCategory=sp,i.selectIssueMapping=eu,i.selectIssueTypeAttachmentById=ou,i.selectIssueTypeAttachmentMapping=du,i.selectIssueTypeAttachments=uu,i.selectIssueTypeById=Yi,i.selectIssueTypeFieldValues=Bi,i.selectIssueTypeFieldValuesAttachmentById=vA,i.selectIssueTypeFieldValuesAttachments=ku,i.selectIssueTypeFieldValuesAttachmentsByIds=Cu,i.selectIssueTypeFieldValuesAttachmentsMapping=Hi,i.selectIssueTypeFieldValuesById=Gi,i.selectIssueTypeFieldValuesMapping=Iu,i.selectIssueTypeFieldValuesOfIssue=hA,i.selectIssueTypeFields=pt,i.selectIssueTypeFieldsAttachmentById=cA,i.selectIssueTypeFieldsAttachments=Su,i.selectIssueTypeFieldsAttachmentsMapping=fu,i.selectIssueTypeFieldsById=bA,i.selectIssueTypeFieldsMapping=wu,i.selectIssueTypeFieldsOfIssueType=SA,i.selectIssueTypeMapping=Gu,i.selectIssueTypeValuesOfIssueType=TA,i.selectIssueTypes=Lu,i.selectIssueTypesByIds=_A,i.selectIssueTypesOfOrganization=wA,i.selectIssueUpdateMapping=Qu,i.selectIssueUpdatesOfIssue=Zu,i.selectIssuesByIds=Jp,i.selectIssuesOfIssueType=Ji,i.selectIssuesOfIssueTypeCount=EA,i.selectLatestAssetProcedureFieldsOfAssetProcedure=kh,i.selectLatestAssetTypeFieldsOfAssetType=jm,i.selectLatestFormRevisionOfForm=bp,i.selectLatestIssueTypeFieldsOfIssueType=gA,i.selectLatestRetryTime=Iy,i.selectLicense=MA,i.selectLicenseForProject=so,i.selectLicenses=St,i.selectLicensesForProjectsMapping=CA,i.selectLicensesOfOrganization=gy,i.selectNumberOfAssetsOfAssetType=dm,i.selectOrganizationAccessById=YA,i.selectOrganizationAccessForUser=XA,i.selectOrganizationAccessUserMapping=mo,i.selectOrganizationAccesses=en,i.selectOrganizationById=yy,i.selectOrganizationUsersAsMapping=Co,i.selectOrganizationUsersIds=ko,i.selectOrganizations=Mo,i.selectOrganizationsMapping=qo,i.selectOrganizationsWithAccess=fy,i.selectProjectAccessById=QA,i.selectProjectAccessForUser=ZA,i.selectProjectAccessMapping=nn,i.selectProjectAccessUserMapping=To,i.selectProjectAccesses=go,i.selectProjectAttachmentById=Zo,i.selectProjectAttachmentMapping=Xo,i.selectProjectById=cy,i.selectProjectFileById=jy,i.selectProjectFileMapping=ul,i.selectProjectFiles=ol,i.selectProjectMapping=It,i.selectProjectUsersAsMapping=wo,i.selectProjectUsersIds=_o,i.selectProjects=ay,i.selectProjectsOfOrganization=Sy,i.selectRehydrated=zy,i.selectRootDocuments=up,i.selectSortedOrganizationUsers=Ty,i.selectSortedProjectUsers=ry,i.selectStageMapping=tt,i.selectTeamById=qe,i.selectTeams=fn,i.selectTeamsByIds=Dy,i.selectTeamsMapping=yn,i.selectTeamsOfOrganization=Vy,i.selectTeamsOfUser=Uy,i.selectUploadUrl=_r,i.selectUserById=WA,i.selectUsersByIds=KA,i.selectUsersMapping=Tt,i.separateFilesFromValues=Xe,i.separateImageFromFields=$f,i.setActiveProjectFileId=rl,i.setAsset=am,i.setAssetAttachment=Yn,i.setAssetAttachments=gh,i.setAssetProcedure=em,i.setAssetProcedureFieldValues=Gh,i.setAssetProcedureFieldValuesAttachment=Dh,i.setAssetProcedureFieldValuesAttachments=Vh,i.setAssetProcedureFieldValuesMany=Lh,i.setAssetProcedureFields=wh,i.setAssetProcedureFieldsAttachment=Ih,i.setAssetProcedureFieldsAttachments=Fh,i.setAssetProcedureFieldsMany=Eh,i.setAssetProcedureInstance=Kh,i.setAssetProcedureInstances=Yh,i.setAssetProcedures=tm,i.setAssetStage=tc,i.setAssetStages=om,i.setAssetType=Lm,i.setAssetTypeAttachment=rc,i.setAssetTypeAttachments=ym,i.setAssetTypeFieldValues=Um,i.setAssetTypeFieldValuesAttachment=km,i.setAssetTypeFieldValuesAttachments=Cm,i.setAssetTypeFieldValuesMany=$m,i.setAssetTypeFields=Om,i.setAssetTypeFieldsAttachment=gm,i.setAssetTypeFieldsAttachments=Tm,i.setAssetTypeFieldsMany=vm,i.setAssetTypes=Nm,i.setAssets=cm,i.setConversation=Nn,i.setCurrentUser=NA,i.setDocumentAttachment=nr,i.setDocumentAttachments=np,i.setDocuments=mr,i.setForm=Ip,i.setFormRevision=Vr,i.setFormRevisionAttachment=pp,i.setFormRevisionAttachments=Ap,i.setFormSubmission=ot,i.setFormSubmissionAttachment=vp,i.setFormSubmissionAttachments=_p,i.setFormSubmissions=jp,i.setGeoImage=Le,i.setGeoImages=ld,i.setIsImportingProjectFile=cl,i.setIssueAssociation=zp,i.setIssueAssociations=Cp,i.setIssueAttachment=_d,i.setIssueAttachments=$p,i.setIssueComment=vi,i.setIssueCommentAttachment=Vd,i.setIssueCommentAttachments=Lp,i.setIssueComments=Kd,i.setIssueType=We,i.setIssueTypeAttachment=nu,i.setIssueTypeAttachments=Qp,i.setIssueTypeFieldValues=dA,i.setIssueTypeFieldValuesAttachment=FA,i.setIssueTypeFieldValuesAttachments=RA,i.setIssueTypeFieldValuesMany=uA,i.setIssueTypeFields=pA,i.setIssueTypeFieldsAttachment=tA,i.setIssueTypeFieldsAttachments=sA,i.setIssueTypeFieldsMany=AA,i.setIssueUpdate=jA,i.setLoggedIn=Yc,i.setOrganization=uy,i.setOrganizations=jo,i.setProfilePicture=HA,i.setProject=ey,i.setProjectAttachment=Wo,i.setProjectAttachments=Ko,i.setProjectFile=Oy,i.setProjectFiles=vy,i.setProjects=Fo,i.setRehydrated=Cy,i.setTeam=je,i.setTokens=Xm,i.setUploadUrl=vr,i.setUser=DA,i.setUsers=ao,i.shallowEqual=Ql,i.slugify=hh,i.spacesToDashesLower=lh,i.teamReducer=yl,i.teamSlice=mn,i.toFileNameSafeString=oh,i.toOfflineIdRecord=Un,i.truncate=mh,i.updateAsset=Ue,i.updateAssetAttachment=Th,i.updateAssetAttachments=Jn,i.updateAssetProcedure=Ve,i.updateAssetProcedureFieldValues=ze,i.updateAssetProcedureFieldValuesAttachment=Uh,i.updateAssetProcedureFieldValuesAttachments=ga,i.updateAssetProcedureFieldValuesMany=va,i.updateAssetProcedureFields=ma,i.updateAssetProcedureFieldsAttachment=Rh,i.updateAssetProcedureFieldsAttachments=aa,i.updateAssetProcedureFieldsMany=jh,i.updateAssetProcedureInstance=De,i.updateAssetProcedureInstances=Wh,i.updateAssetProcedures=Zh,i.updateAssetStage=Is,i.updateAssetStageCompletion=Ya,i.updateAssetStageCompletions=Ja,i.updateAssetStages=et,i.updateAssetType=Be,i.updateAssetTypeAttachment=fm,i.updateAssetTypeAttachments=dc,i.updateAssetTypeFieldValues=$e,i.updateAssetTypeFieldValuesAttachment=zm,i.updateAssetTypeFieldValuesAttachments=qc,i.updateAssetTypeFieldValuesMany=$c,i.updateAssetTypeFields=Oc,i.updateAssetTypeFieldsAttachment=bm,i.updateAssetTypeFieldsAttachments=Sc,i.updateAssetTypeFieldsMany=_m,i.updateAssetTypes=Wm,i.updateAssets=nm,i.updateCategory=Zc,i.updateConversation=Hn,i.updateDocumentAttachment=ap,i.updateDocumentAttachments=ar,i.updateDocuments=ye,i.updateForm=Rp,i.updateFormRevisionAttachment=yp,i.updateFormRevisionAttachments=Mr,i.updateFormSubmission=nd,i.updateFormSubmissionAttachment=wp,i.updateFormSubmissionAttachments=Zr,i.updateFormSubmissions=qp,i.updateGeoImage=pd,i.updateGeoImages=Mp,i.updateIssue=mt,i.updateIssueAssociation=bd,i.updateIssueAssociations=Dp,i.updateIssueAttachment=Bp,i.updateIssueAttachments=wd,i.updateIssueCommentAttachment=Np,i.updateIssueCommentAttachments=Ud,i.updateIssueType=Bu,i.updateIssueTypeAttachment=Zp,i.updateIssueTypeAttachments=au,i.updateIssueTypeFieldValues=He,i.updateIssueTypeFieldValuesAttachment=PA,i.updateIssueTypeFieldValuesAttachments=Mu,i.updateIssueTypeFieldValuesMany=oA,i.updateIssueTypeFields=vu,i.updateIssueTypeFieldsAttachment=iA,i.updateIssueTypeFieldsAttachments=Au,i.updateIssueTypeFieldsMany=yA,i.updateLicense=pe,i.updateOrganization=my,i.updateOrganizationAccess=lo,i.updateOrganizations=hy,i.updateProject=Ro,i.updateProjectAccess=yo,i.updateProjectAttachment=Py,i.updateProjectAttachments=Yo,i.updateProjectFile=ln,i.updateProjectFiles=wy,i.updateProjects=iy,i.updateTeam=pn,i.updateUser=BA,i.updateUsers=$A,i.userReducer=ro,i.userSlice=Zi,i.versioningReducer=Sl,i.versioningSlice=fl,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});