@overmap-ai/core 1.0.74-procedures.1 → 1.0.74-procedures.2
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.
- package/dist/enums/access.d.ts +6 -4
- package/dist/overmap-core.js +886 -875
- package/dist/overmap-core.umd.cjs +6 -6
- package/dist/typings/models/access.d.ts +0 -1
- package/dist/typings/models/assets.d.ts +3 -3
- package/dist/typings/models/base.d.ts +4 -1
- package/dist/typings/models/forms.d.ts +2 -2
- package/dist/typings/models/geoImages.d.ts +3 -3
- package/dist/typings/models/issues.d.ts +3 -3
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
(function(i,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("uuid"),require("@reduxjs/toolkit"),require("file-saver"),require("@redux-offline/redux-offline"),require("@redux-offline/redux-offline/lib/defaults"),require("localforage"),require("redux-persist-migrate"),require("superagent"),require("dependency-graph"),require("idb"),require("@redux-offline/redux-offline/lib/constants"),require("jwt-decode")):typeof define=="function"&&define.amd?define(["exports","uuid","@reduxjs/toolkit","file-saver","@redux-offline/redux-offline","@redux-offline/redux-offline/lib/defaults","localforage","redux-persist-migrate","superagent","dependency-graph","idb","@redux-offline/redux-offline/lib/constants","jwt-decode"],O):(i=typeof globalThis<"u"?globalThis:i||self,O(i["overmap-core"]={},i.uuid,i.toolkit,i.fileSaver,i.reduxOffline,i.offlineConfig,i.localforage,i.createMigration,i.request,i.dependencyGraph,i.idb,i.constants,i.jwtDecode))})(this,function(i,O,l,du,lu,gn,uu,hu,Se,mu,fu,pu,Au){"use strict";var fy=Object.defineProperty;var py=(i,O,l)=>O in i?fy(i,O,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[O]=l;var g=(i,O,l)=>py(i,typeof O!="symbol"?O+"":O,l);var ou;const bn=Object.freeze([]),_n=Object.freeze({});var gt=(t=>(t[t.BASIC=0]="BASIC",t[t.ADMIN=2]="ADMIN",t))(gt||{}),bt=(t=>(t[t.BASIC=0]="BASIC",t[t.ADMIN=2]="ADMIN",t))(bt||{}),u=(t=>(t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.DELETE="DELETE",t))(u||{}),Tn=(t=>(t.Issue="issue",t.Asset="asset",t.AssetType="asset_type",t.Project="project",t.Document="document",t))(Tn||{}),_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||{}),Tt=(t=>(t[t.BACKLOG=0]="BACKLOG",t[t.SELECTED=2]="SELECTED",t[t.DONE=4]="DONE",t))(Tt||{}),v=(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))(v||{}),Fn=(t=>(t.COMPLETED="checkout.completed",t.CLOSED="checkout.closed",t))(Fn||{}),In=(t=>(t[t.PRO=0]="PRO",t))(In||{}),Rn=(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))(Rn||{});const yu=Tt.BACKLOG,Su=_t.MEDIUM,Pn=6e4;function I(t){return{addOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},addMany:(f,p)=>{for(const A of p.payload){const _=t(A);f.instances[_]=A}},setOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},setMany:(f,p)=>{for(const A of p.payload){const _=t(A);f.instances[_]=A}},updateOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},updateMany:(f,p)=>{for(const A of p.payload){const _=t(A);f.instances[_]=A}},deleteOne:(f,p)=>{delete f.instances[p.payload]},deleteMany:(f,p)=>{for(const A of p.payload)delete f.instances[A]},initialize:(f,p)=>{f.instances={};for(const A of p.payload){const _=t(A);f.instances[_]=A}},getInitialState:f=>({...f,instances:{}})}}ou=Symbol.toStringTag;class On{constructor(){g(this,ou,"Promise");g(this,"_promise");g(this,"_resolve");g(this,"_reject");g(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 gu=t=>({type:"Point",coordinates:t}),bu=t=>({type:"MultiPoint",coordinates:t}),_u=(t,e)=>t[0]===e[0]&&t[1]===e[1];let Ft=!1;["true","1"].includes("".toLowerCase())&&(Ft=!0);function vn(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 It(t){const e={};return function(){const s=Array.prototype.slice.call(arguments);return s in e?(Ft&&console.debug(`Memoization debug: Using memorized return value for ${t.toString()}(`,s,")"),e[s]):(Ft&&console.debug(`Memoization debug: Cache miss! Memoizing ${t.toString()}(`,s,")"),e[s]=t.apply(this,s))}}function Tu(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 S=t=>t.length===0?bn:t,ge=t=>Object.keys(t).length===0?_n:t,wn=It(t=>{if(!t)return"";const e=new Date(t),s=e.getFullYear()===Rt.getFullYear(),n={day:"numeric",month:"short"};return s||(n.year="numeric"),e.toLocaleDateString([],n)}),Fu=new Intl.RelativeTimeFormat([],{style:"long",numeric:"auto"}),Iu=1e3*86400,Rt=new Date,Ru=t=>new Date(t).toDateString()===Rt.toDateString(),Pu=It((t,e,s)=>{const n=Math.round((new Date(t).getTime()-Rt.getTime())/Iu);return n<e||n>s?wn(t):Fu.format(n,"days")});function Ou(t){return new Uint8Array(t).reduce((s,n)=>s+n.toString(16).padStart(2,"0"),"")}const Pt=async(t,e)=>{e||(e=await be(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 be(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=Ou(c);e(r)})},n.readAsArrayBuffer(t)})}function vu(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 En(t,e){return new File([t],e,{type:t.type})}function wu(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 Eu=async t=>{const e={};for(const s of t){const n=await be(s);e[n]={sha1:n,extension:s.name.split(".").pop()||"",file_type:s.type,size:s.size}}return Object.values(e)},jn=async t=>(await fetch(t)).blob(),ju=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 qu(t){const e=new Blob([t]);du.saveAs(e,t.name)}const qn={};function Mu(t,e,s,...n){const a=qn[t];let c=!1;a?a[e]||(a[e]=!0,c=!0):(qn[t]={[e]:!0},c=!0),c&&console[s](...n)}function F(t){return{...t,offline_id:O.v4()}}function Mn(t){const e={};for(const s of t)e[s.offline_id]=s;return e}function ku(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 Du(t){return t.toLowerCase().replace(" ","-")}function zu(t,e=!1){return t.normalize("NFKD").toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/[-\s]+/g,e?"_":"-")}function Vu(t,e){if(t.length<=e)return t;const s=t.slice(0,e-1);return s.slice(0,s.lastIndexOf(" "))+"…"}const y=t=>e=>s=>t(s,e);function kn(t,e,s){return s.findIndex(n=>n.offline_id===t.offline_id)===e}function Cu(t,e,s){return s.findIndex(n=>n.file_sha1===t.file_sha1)===e}const Uu=/^.+@.+\..+$/,we=I(t=>t.offline_id),Dn=we.getInitialState({}),Ot=l.createSlice({name:"agents",initialState:Dn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dn)),reducers:{initializeConversations:we.initialize,addConversation:we.addOne,setConversation:we.setOne,updateConversation:we.updateOne}}),{initializeConversations:zn,addConversation:Vn,setConversation:Cn,updateConversation:Un}=Ot.actions,vt=t=>t.agentsReducer.instances,$u=l.createSelector([vt],t=>Object.values(t)),Bu=y(l.createSelector([vt,(t,e)=>e],(t,e)=>t[e])),$n=Ot.reducer,M=I(t=>t.offline_id),Bn=M.getInitialState({}),wt=l.createSlice({name:"assetAttachments",initialState:Bn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Bn)),reducers:{initializeAssetAttachments:M.initialize,addAssetAttachment:M.addOne,addAssetAttachments:M.addMany,setAssetAttachment:M.setOne,setAssetAttachments:M.setMany,updateAssetAttachment:M.updateOne,updateAssetAttachments:M.updateMany,deleteAssetAttachment:M.deleteOne,deleteAssetAttachments:M.deleteMany}}),{initializeAssetAttachments:Et,addAssetAttachment:Gu,addAssetAttachments:jt,setAssetAttachment:Gn,setAssetAttachments:Lu,updateAssetAttachment:Nu,updateAssetAttachments:Ln,deleteAssetAttachment:Nn,deleteAssetAttachments:qt}=wt.actions,Hn=t=>t.assetAttachmentReducer.instances,Mt=l.createSelector([Hn],t=>Object.values(t)),Wn=t=>e=>e.assetAttachmentReducer.instances[t],Kn=y(l.createSelector([Mt,(t,e)=>e],(t,e)=>S(t.filter(({asset:s})=>e===s)))),Hu=y(l.createSelector([Mt,(t,e)=>e],(t,e)=>{const s=t.filter(({asset:c})=>e===c),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),Yn=wt.reducer,k=I(t=>t.offline_id),Jn=k.getInitialState({}),kt=l.createSlice({name:"assetProcedureFieldsAttachments",initialState:Jn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Jn)),reducers:{initializeAssetProcedureFieldsAttachments:k.initialize,addAssetProcedureFieldsAttachment:k.addOne,addAssetProcedureFieldsAttachments:k.addMany,setAssetProcedureFieldsAttachment:k.setOne,setAssetProcedureFieldsAttachments:k.setMany,updateAssetProcedureFieldsAttachment:k.updateOne,updateAssetProcedureFieldsAttachments:k.updateMany,deleteAssetProcedureFieldsAttachment:k.deleteOne,deleteAssetProcedureFieldsAttachments:k.deleteMany}}),{initializeAssetProcedureFieldsAttachments:Xn,addAssetProcedureFieldsAttachment:Wu,addAssetProcedureFieldsAttachments:Zn,setAssetProcedureFieldsAttachment:Ku,setAssetProcedureFieldsAttachments:Yu,updateAssetProcedureFieldsAttachment:Ju,updateAssetProcedureFieldsAttachments:Qn,deleteAssetProcedureFieldsAttachment:Xu,deleteAssetProcedureFieldsAttachments:xn}=kt.actions,ea=t=>t.assetProcedureFieldsAttachmentReducer.instances,ta=l.createSelector([ea],t=>Object.values(t)),Zu=y(l.createSelector([ta,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),Qu=t=>e=>e.assetProcedureFieldsAttachmentReducer.instances[t],sa=kt.reducer,D=I(t=>t.offline_id),ia=D.getInitialState({}),Dt=l.createSlice({name:"assetProcedureFields",initialState:ia,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ia)),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:na,addAssetProcedureFields:aa,addAssetProcedureFieldsMany:xu,setAssetProcedureFields:eh,setAssetProcedureFieldsMany:th,updateAssetProcedureFields:ca,updateAssetProcedureFieldsMany:sh,deleteAssetProcedureFields:ra,deleteAssetProcedureFieldsMany:ih}=Dt.actions,oa=t=>t.assetProcedureFieldsReducer.instances,zt=l.createSelector([oa],t=>Object.values(t)),nh=y(l.createSelector([zt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),ah=y(l.createSelector([zt,(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],da=Dt.reducer,z=I(t=>t.offline_id),la=z.getInitialState({}),Vt=l.createSlice({name:"assetProcedureFieldValuesAttachments",initialState:la,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,la)),reducers:{initializeAssetProcedureFieldValuesAttachments:z.initialize,addAssetProcedureFieldValuesAttachment:z.addOne,addAssetProcedureFieldValuesAttachments:z.addMany,setAssetProcedureFieldValuesAttachment:z.setOne,setAssetProcedureFieldValuesAttachments:z.setMany,updateAssetProcedureFieldValuesAttachment:z.updateOne,updateAssetProcedureFieldValuesAttachments:z.updateMany,deleteAssetProcedureFieldValuesAttachment:z.deleteOne,deleteAssetProcedureFieldValuesAttachments:z.deleteMany}}),{initializeAssetProcedureFieldValuesAttachments:ua,addAssetProcedureFieldValuesAttachment:rh,addAssetProcedureFieldValuesAttachments:We,setAssetProcedureFieldValuesAttachment:oh,setAssetProcedureFieldValuesAttachments:dh,updateAssetProcedureFieldValuesAttachment:lh,updateAssetProcedureFieldValuesAttachments:ha,deleteAssetProcedureFieldValuesAttachment:uh,deleteAssetProcedureFieldValuesAttachments:Ke}=Vt.actions,Ct=t=>t.assetProcedureFieldValuesAttachmentReducer.instances,ma=l.createSelector([Ct],t=>Object.values(t)),hh=t=>e=>e.assetProcedureFieldValuesAttachmentReducer.instances[t],fa=y(l.createSelector([Ct,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),pa=y(l.createSelector([ma,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),Aa=Vt.reducer,V=I(t=>t.offline_id),ya=V.getInitialState({}),Ut=l.createSlice({name:"assetProcedureFieldValues",initialState:ya,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ya)),reducers:{initializeAssetProcedureFieldValues:V.initialize,addAssetProcedureFieldValues:V.addOne,addAssetProcedureFieldValuesMany:V.addMany,setAssetProcedureFieldValues:V.setOne,setAssetProcedureFieldValuesMany:V.setMany,updateAssetProcedureFieldValues:V.updateOne,updateAssetProcedureFieldValuesMany:V.updateMany,deleteAssetProcedureFieldValues:V.deleteOne,deleteAssetProcedureFieldValuesMany:V.deleteMany}}),{initializeAssetProcedureFieldValues:Sa,addAssetProcedureFieldValues:$t,addAssetProcedureFieldValuesMany:ga,setAssetProcedureFieldValues:mh,setAssetProcedureFieldValuesMany:fh,updateAssetProcedureFieldValues:Ee,updateAssetProcedureFieldValuesMany:ba,deleteAssetProcedureFieldValues:Bt,deleteAssetProcedureFieldValuesMany:_a}=Ut.actions,Ta=t=>t.assetProcedureFieldValuesReducer.instances,Gt=l.createSelector([Ta],t=>Object.values(t)),ph=y(l.createSelector([Gt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset===e)))),Ah=y(l.createSelector([Gt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure_instance===e)))),Lt=t=>e=>e.assetProcedureFieldValuesReducer.instances[t],Fa=Ut.reducer,C=I(t=>t.offline_id),Ia=C.getInitialState({}),Nt=l.createSlice({name:"assetProcedureInstances",initialState:Ia,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ia)),reducers:{initializeAssetProcedureInstances:C.initialize,addAssetProcedureInstance:C.addOne,addAssetProcedureInstances:C.addMany,setAssetProcedureInstance:C.setOne,setAssetProcedureInstances:C.setMany,updateAssetProcedureInstance:C.updateOne,updateAssetProcedureInstances:C.updateMany,deleteAssetProcedureInstance:C.deleteOne,deleteAssetProcedureInstances:C.deleteMany}}),{initializeAssetProcedureInstances:Ra,addAssetProcedureInstance:Ht,addAssetProcedureInstances:Pa,updateAssetProcedureInstance:je,updateAssetProcedureInstances:yh,deleteAssetProcedureInstance:Wt,deleteAssetProcedureInstances:Oa,setAssetProcedureInstance:Sh,setAssetProcedureInstances:gh}=Nt.actions,Kt=t=>t.assetProcedureInstanceReducer.instances,Yt=l.createSelector([Kt],t=>Object.values(t)),va=y(l.createSelector([Yt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),bh=y(l.createSelector([Yt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),Jt=t=>e=>e.assetProcedureInstanceReducer.instances[t],_h=y(l.createSelector([Kt,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return S(s)})),wa=Nt.reducer,U=I(t=>t.offline_id),Ea=U.getInitialState({}),Xt=l.createSlice({name:"assetProcedures",initialState:Ea,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ea)),reducers:{initializeAssetProcedures:U.initialize,addAssetProcedure:U.addOne,addAssetProcedures:U.addMany,setAssetProcedure:U.setOne,setAssetProcedures:U.setMany,updateAssetProcedure:U.updateOne,updateAssetProcedures:U.updateMany,deleteAssetProcedure:U.deleteOne,deleteAssetProcedures:U.deleteMany}}),{initializeAssetProcedures:ja,addAssetProcedure:Zt,addAssetProcedures:Th,updateAssetProcedure:qe,updateAssetProcedures:Fh,deleteAssetProcedure:Qt,deleteAssetProcedures:Ih,setAssetProcedure:Rh,setAssetProcedures:Ph}=Xt.actions,xt=t=>t.assetProcedureReducer.instances,qa=l.createSelector([xt],t=>Object.values(t)),Oh=y(l.createSelector([qa,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),es=t=>e=>e.assetProcedureReducer.instances[t],vh=y(l.createSelector([xt,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return S(s)})),Ma=Xt.reducer,$=I(t=>t.offline_id),ka=$.getInitialState({}),ts=l.createSlice({name:"assets",initialState:ka,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ka)),reducers:{initializeAssets:$.initialize,addAsset:$.addOne,addAssets:$.addMany,setAsset:$.setOne,setAssets:$.setMany,updateAsset:$.updateOne,updateAssets:$.updateMany,deleteAsset:$.deleteOne,deleteAssets:$.deleteMany}}),{initializeAssets:Da,addAsset:ss,addAssets:is,updateAsset:Me,updateAssets:wh,deleteAsset:ns,deleteAssets:za,setAsset:Eh,setAssets:jh}=ts.actions,as=t=>t.assetReducer.instances,Va=l.createSelector([as],t=>S(Object.values(t))),cs=y(l.createSelector([Va,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),rs=t=>e=>e.assetReducer.instances[t],qh=y(l.createSelector([as,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return S(s)})),Mh=t=>e=>cs(t)(e).length,Ca=ts.reducer,de=I(t=>t.offline_id),Ua=de.getInitialState({}),os=l.createSlice({name:"assetStageCompletions",initialState:Ua,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ua)),reducers:{initializeAssetStageCompletions:de.initialize,addAssetStageCompletion:de.addOne,addAssetStageCompletions:de.addMany,updateAssetStageCompletion:de.updateOne,updateAssetStageCompletions:de.updateMany,deleteAssetStageCompletion:de.deleteOne,deleteAssetStageCompletions:de.deleteMany}}),{initializeAssetStageCompletions:$a,addAssetStageCompletion:ds,addAssetStageCompletions:ls,updateAssetStageCompletion:Ba,updateAssetStageCompletions:Ga,deleteAssetStageCompletion:us,deleteAssetStageCompletions:hs}=os.actions,La=os.reducer,ms=t=>t.assetStageCompletionReducer.instances,kh=l.createSelector([ms],t=>Object.values(t)),Na=t=>e=>e.assetStageCompletionReducer.instances[t],Ha=y(l.createSelector([ms,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),B=I(t=>t.offline_id),Wa=B.getInitialState({}),fs=l.createSlice({name:"assetStages",initialState:Wa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Wa)),reducers:{initializeAssetStages:B.initialize,setAssetStage:B.setOne,setAssetStages:B.setMany,addAssetStage:B.addOne,addAssetStages:B.addMany,updateAssetStage:B.updateOne,updateAssetStages:B.updateMany,deleteAssetStage:B.deleteOne,deleteAssetStages:B.deleteMany}}),{initializeAssetStages:Ka,setAssetStage:Ya,setAssetStages:Dh,addAssetStage:zh,addAssetStages:ps,updateAssetStage:As,updateAssetStages:Ye,deleteAssetStage:Vh,deleteAssetStages:ys}=fs.actions,Ja=fs.reducer,Je=t=>t.assetStageReducer.instances,Xa=t=>e=>e.assetStageReducer.instances[t],Za=l.createSelector([Je],t=>Object.values(t)),Ch=y(l.createSelector([Je,(t,e)=>e],(t,e)=>{const s={};for(const[n,a]of Object.entries(t))a.asset_procedure===e&&(s[n]=a);return ge(s)})),Uh=y(l.createSelector([Za,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),Ss=y(l.createSelector([Je,(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 S(s)})),G=I(t=>t.offline_id),Qa=G.getInitialState({}),gs=l.createSlice({name:"assetTypeAttachments",initialState:Qa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Qa)),reducers:{initializeAssetTypeAttachments:G.initialize,addAssetTypeAttachment:G.addOne,addAssetTypeAttachments:G.addMany,setAssetTypeAttachment:G.setOne,setAssetTypeAttachments:G.setMany,updateAssetTypeAttachment:G.updateOne,updateAssetTypeAttachments:G.updateMany,deleteAssetTypeAttachment:G.deleteOne,deleteAssetTypeAttachments:G.deleteMany}}),{initializeAssetTypeAttachments:xa,addAssetTypeAttachment:$h,addAssetTypeAttachments:bs,setAssetTypeAttachment:ec,setAssetTypeAttachments:Bh,updateAssetTypeAttachment:Gh,updateAssetTypeAttachments:tc,deleteAssetTypeAttachment:sc,deleteAssetTypeAttachments:_s}=gs.actions,ic=t=>t.assetTypeAttachmentReducer.instances,Ts=l.createSelector([ic],t=>Object.values(t)),nc=t=>e=>e.assetTypeAttachmentReducer.instances[t],ac=y(l.createSelector([Ts,(t,e)=>e],(t,e)=>S(t.filter(({asset_type:s})=>e===s)))),Lh=y(l.createSelector([Ts,(t,e)=>e],(t,e)=>{const s=t.filter(({asset_type:c})=>c===e),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),cc=gs.reducer,L=I(t=>t.offline_id),rc=L.getInitialState({}),Fs=l.createSlice({name:"assetTypeFieldsAttachments",initialState:rc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,rc)),reducers:{initializeAssetTypeFieldsAttachments:L.initialize,addAssetTypeFieldsAttachment:L.addOne,addAssetTypeFieldsAttachments:L.addMany,setAssetTypeFieldsAttachment:L.setOne,setAssetTypeFieldsAttachments:L.setMany,updateAssetTypeFieldsAttachment:L.updateOne,updateAssetTypeFieldsAttachments:L.updateMany,deleteAssetTypeFieldsAttachment:L.deleteOne,deleteAssetTypeFieldsAttachments:L.deleteMany}}),{initializeAssetTypeFieldsAttachments:oc,addAssetTypeFieldsAttachment:Nh,addAssetTypeFieldsAttachments:dc,setAssetTypeFieldsAttachment:Hh,setAssetTypeFieldsAttachments:Wh,updateAssetTypeFieldsAttachment:Kh,updateAssetTypeFieldsAttachments:lc,deleteAssetTypeFieldsAttachment:Yh,deleteAssetTypeFieldsAttachments:uc}=Fs.actions,hc=t=>t.assetTypeFieldsAttachmentReducer.instances,mc=l.createSelector([hc],t=>Object.values(t)),Jh=y(l.createSelector([mc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),Xh=t=>e=>e.assetTypeFieldsAttachmentReducer.instances[t],fc=Fs.reducer,N=I(t=>t.offline_id),pc=N.getInitialState({}),Is=l.createSlice({name:"assetTypeFields",initialState:pc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,pc)),reducers:{initializeAssetTypeFields:N.initialize,addAssetTypeFields:N.addOne,addAssetTypeFieldsMany:N.addMany,setAssetTypeFields:N.setOne,setAssetTypeFieldsMany:N.setMany,updateAssetTypeFields:N.updateOne,updateAssetTypeFieldsMany:N.updateMany,deleteAssetTypeFields:N.deleteOne,deleteAssetTypeFieldsMany:N.deleteMany}}),{initializeAssetTypeFields:Ac,addAssetTypeFields:yc,addAssetTypeFieldsMany:Zh,setAssetTypeFields:Qh,setAssetTypeFieldsMany:xh,updateAssetTypeFields:Sc,updateAssetTypeFieldsMany:em,deleteAssetTypeFields:gc,deleteAssetTypeFieldsMany:tm}=Is.actions,bc=t=>t.assetTypeFieldsReducer.instances,Xe=l.createSelector([bc],t=>Object.values(t)),sm=y(l.createSelector([Xe,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),im=y(l.createSelector([Xe,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),nm=t=>e=>e.assetTypeFieldsReducer.instances[t],_c=Is.reducer,H=I(t=>t.offline_id),Tc=H.getInitialState({}),Rs=l.createSlice({name:"assetTypeFieldValuesAttachments",initialState:Tc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Tc)),reducers:{initializeAssetTypeFieldValuesAttachments:H.initialize,addAssetTypeFieldValuesAttachment:H.addOne,addAssetTypeFieldValuesAttachments:H.addMany,setAssetTypeFieldValuesAttachment:H.setOne,setAssetTypeFieldValuesAttachments:H.setMany,updateAssetTypeFieldValuesAttachment:H.updateOne,updateAssetTypeFieldValuesAttachments:H.updateMany,deleteAssetTypeFieldValuesAttachment:H.deleteOne,deleteAssetTypeFieldValuesAttachments:H.deleteMany}}),{initializeAssetTypeFieldValuesAttachments:Fc,addAssetTypeFieldValuesAttachment:am,addAssetTypeFieldValuesAttachments:Ze,setAssetTypeFieldValuesAttachment:cm,setAssetTypeFieldValuesAttachments:rm,updateAssetTypeFieldValuesAttachment:om,updateAssetTypeFieldValuesAttachments:Ic,deleteAssetTypeFieldValuesAttachment:dm,deleteAssetTypeFieldValuesAttachments:Qe}=Rs.actions,Ps=t=>t.assetTypeFieldValuesAttachmentReducer.instances,Rc=l.createSelector([Ps],t=>Object.values(t)),lm=t=>e=>e.assetTypeFieldValuesAttachmentReducer.instances[t],Pc=y(l.createSelector([Ps,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),Oc=y(l.createSelector([Rc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),vc=Rs.reducer,W=I(t=>t.offline_id),wc=W.getInitialState({}),Os=l.createSlice({name:"assetTypeFieldValues",initialState:wc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,wc)),reducers:{initializeAssetTypeFieldValues:W.initialize,addAssetTypeFieldValues:W.addOne,addAssetTypeFieldValuesMany:W.addMany,setAssetTypeFieldValues:W.setOne,setAssetTypeFieldValuesMany:W.setMany,updateAssetTypeFieldValues:W.updateOne,updateAssetTypeFieldValuesMany:W.updateMany,deleteAssetTypeFieldValues:W.deleteOne,deleteAssetTypeFieldValuesMany:W.deleteMany}}),{initializeAssetTypeFieldValues:Ec,addAssetTypeFieldValues:vs,addAssetTypeFieldValuesMany:jc,setAssetTypeFieldValues:um,setAssetTypeFieldValuesMany:hm,updateAssetTypeFieldValues:ke,updateAssetTypeFieldValuesMany:qc,deleteAssetTypeFieldValues:ws,deleteAssetTypeFieldValuesMany:Mc}=Os.actions,kc=t=>t.assetTypeFieldValuesReducer.instances,Es=l.createSelector([kc],t=>Object.values(t)),mm=y(l.createSelector([Es,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset===e)))),fm=y(l.createSelector([Xe,Es,(t,e)=>e],(t,e,s)=>{const n=new Set(t.filter(a=>a.asset_type===s).map(a=>a.offline_id));return S(e.filter(a=>n.has(a.fields_revision)))})),js=t=>e=>e.assetTypeFieldValuesReducer.instances[t],Dc=Os.reducer,K=I(t=>t.offline_id),zc=K.getInitialState({}),qs=l.createSlice({name:"assetTypes",initialState:zc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,zc)),reducers:{initializeAssetTypes:K.initialize,setAssetType:K.setOne,setAssetTypes:K.setMany,addAssetType:K.addOne,addAssetTypes:K.addMany,updateAssetType:K.updateOne,updateAssetTypes:K.updateMany,deleteAssetType:K.deleteOne,deleteAssetTypes:K.deleteMany}}),{initializeAssetTypes:Vc,setAssetType:pm,setAssetTypes:Am,addAssetType:Ms,addAssetTypes:ym,updateAssetType:De,updateAssetTypes:Sm,deleteAssetType:ks,deleteAssetTypes:gm}=qs.actions,Ds=t=>t.assetTypeReducer.instances,bm=l.createSelector([Ds],t=>Object.values(t)),zs=t=>e=>e.assetTypeReducer.instances[t],_m=y(l.createSelector([Ds,(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 S(s)})),Cc=qs.reducer,Uc={accessToken:"",refreshToken:"",isLoggedIn:!1},xe=l.createSlice({name:"auth",initialState:Uc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Uc)),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||xe.caseReducers.clearTokens(t),t.isLoggedIn=e.payload}}}),{setTokens:Tm,clearTokens:Fm,setLoggedIn:$c}=xe.actions,Im=t=>t.authReducer.accessToken,Rm=t=>t.authReducer.isLoggedIn,Bc=xe.reducer,ze=I(t=>t.offline_id),Gc=ze.getInitialState({}),Vs=l.createSlice({name:"categories",initialState:Gc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Gc)),reducers:{initializeCategories:ze.initialize,addCategory:ze.addOne,updateCategory:ze.updateOne,deleteCategory:ze.deleteOne}}),{initializeCategories:Lc,addCategory:Cs,updateCategory:Nc,deleteCategory:Hc}=Vs.actions,Us=t=>t.categoryReducer.instances,Pm=l.createSelector([Us],t=>Object.values(t)),$s=t=>e=>e.categoryReducer.instances[t],Om=y(l.createSelector([Us,(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 S(s)})),vm=t=>e=>Object.values(e.issueReducer.instances).filter(s=>s.category===t).length,Wc=Vs.reducer,Y=I(t=>t.offline_id),Kc=Y.getInitialState({}),Bs=l.createSlice({name:"documentAttachments",initialState:Kc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Kc)),reducers:{initializeDocumentAttachments:Y.initialize,addDocumentAttachment:Y.addOne,addDocumentAttachments:Y.addMany,setDocumentAttachment:Y.setOne,setDocumentAttachments:Y.setMany,updateDocumentAttachment:Y.updateOne,updateDocumentAttachments:Y.updateMany,deleteDocumentAttachment:Y.deleteOne,deleteDocumentAttachments:Y.deleteMany}}),{initializeDocumentAttachments:Yc,addDocumentAttachment:wm,addDocumentAttachments:Jc,setDocumentAttachment:Xc,setDocumentAttachments:Em,updateDocumentAttachment:jm,updateDocumentAttachments:Zc,deleteDocumentAttachment:Qc,deleteDocumentAttachments:xc}=Bs.actions,er=t=>t.documentAttachmentReducer.instances,Gs=l.createSelector([er],t=>Object.values(t)),tr=t=>e=>e.documentAttachmentReducer.instances[t],qm=y(l.createSelector([Gs,(t,e)=>e],(t,e)=>S(t.filter(({document:s})=>e===s)))),Mm=y(l.createSelector([Gs,(t,e)=>e],(t,e)=>{const s=t.filter(({document:c})=>e===c),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),sr=Bs.reducer,ir={documents:{}},Ls=l.createSlice({name:"documents",initialState:ir,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,ir)}),reducers:{setDocuments:(t,e)=>{if(e.payload.filter(kn).length!==e.payload.length)throw new Error("Tried to use setIssues reducer with duplicate ID's");t.documents=Mn(e.payload)},addDocuments:(t,e)=>{for(const s of e.payload)if(s.offline_id in t.documents)throw new Error(`attempting to add a document with offline_id ${s.offline_id} which already exists in state.documents.`);for(const s of e.payload){if(s.parent_document&&t.documents[s.parent_document]){const n=t.documents[s.parent_document];t.documents[s.parent_document]={...n,children_documents:[...n.children_documents,s.offline_id]}}t.documents[s.offline_id]=s}},updateDocuments:(t,e)=>{for(const s of e.payload)if(!(s.offline_id in t.documents))throw new Error(`attempting to update a document with offline_id ${s.offline_id} which doesn't exists in state.documents.`);for(const s of e.payload){const n=t.documents[s.offline_id];if(s.organization!==void 0&&s.organization!==n.organization)throw new Error("organization cannot be updated");if(s.project!==void 0&&s.project!==n.project)throw new Error("project cannot be updated");t.documents[s.offline_id]={...n,...s}}},moveDocument:(t,e)=>{const{documentId:s,targetDocumentId:n,position:a}=e.payload;if(!(s in t.documents))throw new Error(`attempting to move a document with offline_id ${s} which doesn't exist in state.documents`);const c=t.documents[s];if(c.parent_document&&t.documents[c.parent_document]){const{children_documents:r}=t.documents[c.parent_document];t.documents[c.parent_document].children_documents.splice(r.indexOf(c.offline_id),1)}if(n){const r=t.documents[n],d=r!=null&&r.parent_document?t.documents[r.parent_document]:null;switch(a){case"left":if(!d)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(d.children_documents.indexOf(r.offline_id),0,c.offline_id),t.documents[s].parent_document=d.offline_id;break;case"right":if(!d)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(d.children_documents.indexOf(r.offline_id)+1,0,c.offline_id),t.documents[s].parent_document=d.offline_id;break;case"left-child":if(!r)throw new Error("attempting to move a document to the left-child of a document that doesn't exist");t.documents[n].children_documents.unshift(c.offline_id),t.documents[s].parent_document=r.offline_id;break;case"right-child":if(!r)throw new Error("attempting to move a document to the left-child of a document that doesn't exist");t.documents[n].children_documents.push(c.offline_id),t.documents[s].parent_document=r.offline_id}}else t.documents[s].parent_document=null},removeDocuments:(t,e)=>{for(const s of e.payload)if(!(s in t.documents))throw new Error(`attempting to delete a document with offline_id ${s} which doesn't exists in state.documents.`);for(const s of e.payload){const n=t.documents[s];if(n.parent_document&&t.documents[n.parent_document]){const a=t.documents[n.parent_document];t.documents[n.parent_document]={...a,children_documents:a.children_documents.filter(c=>c!==n.offline_id)}}delete t.documents[s]}}}}),{setDocuments:nr,addDocuments:Ns,updateDocuments:le,moveDocument:ar,removeDocuments:Hs}=Ls.actions,_e=t=>t.documentsReducer.documents,cr=l.createSelector([_e],t=>Object.values(t)),rr=t=>e=>e.documentsReducer.documents[t],km=y(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 S(s)})),Dm=y(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.offline_id),a=t[a.parent_document??""];return S(s)})),zm=l.createSelector([cr],t=>S(t.filter(e=>!e.parent_document))),or=Ls.reducer,et=I(t=>t.offline_id),Vm=et.getInitialState({}),Ws=l.createSlice({name:"emailDomains",initialState:Vm,reducers:{initializeEmailDomains:et.initialize,addEmailDomain:et.addOne,deleteEmailDomain:et.deleteOne}}),{initializeEmailDomains:dr,addEmailDomain:lr,deleteEmailDomain:ur}=Ws.actions,hr=t=>t.emailDomainsReducer.instances,mr=l.createSelector([hr],t=>Object.values(t)),Cm=y(l.createSelector([mr,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),fr=Ws.reducer,pr={s3Urls:{}},Ar=1e3*60*60,Um=Ar*24*7,Ks=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()+Um);t.s3Urls[a]={url:s,fields:n,exp:r.getTime()}}}}),{setUploadUrl:yr}=Ks.actions,Sr=t=>e=>{const s=e.fileReducer.s3Urls[t];if(!s)return;const n=new Date().getTime();if(!((s.exp??n)-n<Ar))return s},gr=Ks.reducer,J=I(t=>t.offline_id),br=J.getInitialState({}),Ys=l.createSlice({name:"formRevisionAttachments",initialState:br,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,br)),reducers:{initializeFormRevisionAttachments:J.initialize,addFormRevisionAttachment:J.addOne,addFormRevisionAttachments:J.addMany,setFormRevisionAttachment:J.setOne,setFormRevisionAttachments:J.setMany,updateFormRevisionAttachment:J.updateOne,updateFormRevisionAttachments:J.updateMany,deleteFormRevisionAttachment:J.deleteOne,deleteFormRevisionAttachments:J.deleteMany}}),{initializeFormRevisionAttachments:_r,addFormRevisionAttachment:$m,addFormRevisionAttachments:Tr,setFormRevisionAttachment:Bm,setFormRevisionAttachments:Gm,updateFormRevisionAttachment:Lm,updateFormRevisionAttachments:Fr,deleteFormRevisionAttachment:Nm,deleteFormRevisionAttachments:Ir}=Ys.actions,Rr=t=>t.formRevisionAttachmentReducer.instances,Hm=y(l.createSelector([Rr,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.form_revision===e)))),Pr=Ys.reducer,Wm=(t,e)=>{const s=t.revision,n=e.revision;return s==="Pending"&&n==="Pending"?t.submitted_at<e.submitted_at?-1:1:s==="Pending"?1:n==="Pending"||s<n?-1:1},ue=I(t=>t.offline_id),Or=ue.getInitialState({}),Js=l.createSlice({name:"formRevisions",initialState:Or,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Or)),reducers:{initializeFormRevisions:ue.initialize,setFormRevision:ue.setOne,addFormRevision:ue.addOne,addFormRevisions:ue.addMany,deleteFormRevision:ue.deleteOne,deleteFormRevisions:ue.deleteMany}}),{setFormRevision:vr,initializeFormRevisions:wr,addFormRevision:Xs,addFormRevisions:Er,deleteFormRevision:Zs,deleteFormRevisions:jr}=Js.actions,tt=t=>t.formRevisionReducer.instances,qr=l.createSelector([tt],t=>Object.values(t)),Km=t=>e=>e.formRevisionReducer.instances[t],Mr=(t,e)=>{let s=null;for(const n of Object.values(t))n.form===e&&(!s||s.revision<n.revision)&&(s=n);if(!s)throw new Error("No form revision found for form "+e);return s},Ym=y(l.createSelector([tt,(t,e)=>e],(t,e)=>{const s=Object.values(t).filter(c=>c.form===e);if(s.length===0)return;const a=s.sort(Wm)[s.length-1];return t[a.offline_id]})),kr=y(l.createSelector([qr,(t,e)=>e],(t,e)=>S(t.filter(s=>s.form===e)))),Dr=Js.reducer,he=I(t=>t.offline_id),zr=he.getInitialState({}),Qs=l.createSlice({name:"forms",initialState:zr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,zr)),reducers:{initializeForms:he.initialize,setForm:he.setOne,addForm:he.addOne,addForms:he.addMany,updateForm:he.updateOne,deleteForm:he.deleteOne}}),{initializeForms:Vr,setForm:Jm,addForm:xs,addForms:Xm,updateForm:Zm,deleteForm:ei}=Qs.actions,Cr=Qs.reducer,Ur=t=>t.formReducer.instances,Qm=l.createSelector([Ur],t=>Object.values(t)),$r=t=>e=>e.formReducer.instances[t],xm=y(l.createSelector([t=>t.formReducer.instances,t=>t.formRevisionReducer.instances,(t,e)=>e],(t,e,s)=>{const{searchTerm:n,maxResults:a,organization:c}=s,r=[];for(const[d,m]of Object.entries(t)){if(Number.isInteger(c)&&c!==m.organization)continue;Mr(e,d).title.toLowerCase().includes(n.toLowerCase())&&r.push(m)}return[...r.slice(0,a)]},{memoizeOptions:{resultEqualityCheck:vn}})),X=I(t=>t.offline_id),Br=X.getInitialState({}),ti=l.createSlice({name:"formSubmissionAttachments",initialState:Br,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Br)),reducers:{initializeFormSubmissionAttachments:X.initialize,addFormSubmissionAttachment:X.addOne,addFormSubmissionAttachments:X.addMany,setFormSubmissionAttachment:X.setOne,setFormSubmissionAttachments:X.setMany,updateFormSubmissionAttachment:X.updateOne,updateFormSubmissionAttachments:X.updateMany,deleteFormSubmissionAttachment:X.deleteOne,deleteFormSubmissionAttachments:X.deleteMany}}),{initializeFormSubmissionAttachments:Gr,addFormSubmissionAttachment:ef,addFormSubmissionAttachments:st,setFormSubmissionAttachment:tf,setFormSubmissionAttachments:sf,updateFormSubmissionAttachment:nf,updateFormSubmissionAttachments:Lr,deleteFormSubmissionAttachment:af,deleteFormSubmissionAttachments:it}=ti.actions,si=t=>t.formSubmissionAttachmentReducer.instances,Nr=y(l.createSelector([si,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),Hr=y(l.createSelector([si,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.form_submission===e)))),Wr=ti.reducer,Z=I(t=>t.offline_id),Kr=Z.getInitialState({}),ii=l.createSlice({name:"formSubmissions",initialState:Kr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Kr)),reducers:{initializeFormSubmissions:Z.initialize,setFormSubmission:Z.setOne,setFormSubmissions:Z.setMany,addFormSubmission:Z.addOne,addFormSubmissions:Z.addMany,updateFormSubmission:Z.updateOne,updateFormSubmissions:Z.updateMany,deleteFormSubmission:Z.deleteOne,deleteFormSubmissions:Z.deleteMany}}),{initializeFormSubmissions:Yr,setFormSubmission:nt,setFormSubmissions:cf,addFormSubmission:ni,addFormSubmissions:at,updateFormSubmission:Jr,updateFormSubmissions:rf,deleteFormSubmission:ai,deleteFormSubmissions:ct}=ii.actions,ci=t=>t.formSubmissionReducer.instances,ri=l.createSelector([ci],t=>Object.values(t)),oi=t=>e=>e.formSubmissionReducer.instances[t],Xr=y(l.createSelector([ci,tt,(t,e)=>e],(t,e,s)=>{const n=new Set;for(const a of Object.values(e))a.form===s&&n.add(a.offline_id);return Object.values(t).filter(a=>n.has(a.form_revision))})),Zr=y(l.createSelector([ri,(t,e)=>e],(t,e)=>Object.values(t).filter(s=>s.issue===e))),Qr=y(l.createSelector([ri,(t,e)=>e],(t,e)=>t.filter(s=>s.asset===e))),xr=ii.reducer,Q=I(t=>t.offline_id),eo=Q.getInitialState({}),di=l.createSlice({name:"geoImages",initialState:eo,extraReducers:t=>{t.addCase("RESET",e=>{Object.assign(e,eo)})},reducers:{initializeGeoImages:Q.initialize,setGeoImage:Q.setOne,setGeoImages:Q.setMany,addGeoImage:Q.addOne,addGeoImages:Q.addMany,updateGeoImage:Q.updateOne,updateGeoImages:Q.updateMany,deleteGeoImage:Q.deleteOne,deleteGeoImages:Q.deleteMany}}),{initializeGeoImages:to,setGeoImage:Ve,setGeoImages:so,addGeoImage:io,addGeoImages:no,updateGeoImage:ao,updateGeoImages:of,deleteGeoImage:li,deleteGeoImages:co}=di.actions,ro=t=>t.geoImageReducer.instances,oo=l.createSelector([ro],t=>Object.values(t)),ui=t=>e=>e.geoImageReducer.instances[t],df=y(l.createSelector([oo,(t,e)=>e],(t,e)=>S(t.filter(s=>s.project===e)))),lo=di.reducer,x=I(t=>t.offline_id),uo=x.getInitialState({}),hi=l.createSlice({name:"issueAssociations",initialState:uo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,uo)),reducers:{initializeIssueAssociations:x.initialize,addIssueAssociation:x.addOne,addIssueAssociations:x.addMany,setIssueAssociation:x.setOne,setIssueAssociations:x.setMany,updateIssueAssociation:x.updateOne,updateIssueAssociations:x.updateMany,deleteIssueAssociation:x.deleteOne,deleteIssueAssociations:x.deleteMany}}),{initializeIssueAssociations:ho,setIssueAssociations:lf,setIssueAssociation:uf,updateIssueAssociation:mo,updateIssueAssociations:hf,addIssueAssociation:mi,addIssueAssociations:fi,deleteIssueAssociation:pi,deleteIssueAssociations:Ai}=hi.actions,Ce=t=>t.issueAssociationReducer.instances,mf=l.createSelector([Ce],t=>Object.values(t)),fo=t=>e=>e.issueAssociationReducer.instances[t],po=y(l.createSelector([Ce,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.associated_issue===e)))),Ao=y(l.createSelector([Ce,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),yo=y(l.createSelector([Ce,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.asset===e)))),So=hi.reducer,ee=I(t=>t.offline_id),go=ee.getInitialState({}),yi=l.createSlice({name:"issueAttachments",initialState:go,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,go)),reducers:{initializeIssueAttachments:ee.initialize,addIssueAttachment:ee.addOne,addIssueAttachments:ee.addMany,setIssueAttachment:ee.setOne,setIssueAttachments:ee.setMany,updateIssueAttachment:ee.updateOne,updateIssueAttachments:ee.updateMany,deleteIssueAttachment:ee.deleteOne,deleteIssueAttachments:ee.deleteMany}}),{initializeIssueAttachments:bo,addIssueAttachment:ff,addIssueAttachments:Si,setIssueAttachment:_o,setIssueAttachments:pf,updateIssueAttachment:Af,updateIssueAttachments:To,deleteIssueAttachment:Fo,deleteIssueAttachments:gi}=yi.actions,Io=t=>t.issueAttachmentReducer.instances,bi=l.createSelector([Io],t=>Object.values(t)),Ro=y(l.createSelector([bi,(t,e)=>e],(t,e)=>S(t.filter(({issue:s})=>e===s)))),Po=t=>e=>e.issueAttachmentReducer.instances[t],yf=y(l.createSelector([bi,(t,e)=>e],(t,e)=>{const s=t.filter(({issue:c})=>c===e),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),Oo=yi.reducer,me=I(t=>t.offline_id),vo=me.getInitialState({}),_i=l.createSlice({name:"issueComments",initialState:vo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,vo)),reducers:{addIssueComment:me.addOne,addIssueComments:me.addMany,setIssueComment:me.setOne,setIssueComments:me.setMany,deleteIssueComment:me.deleteOne,deleteIssueComments:me.deleteMany}}),{setIssueComments:wo,setIssueComment:Ti,addIssueComment:Fi,addIssueComments:Sf,deleteIssueComment:Ii,deleteIssueComments:gf}=_i.actions,Eo=t=>t.issueCommentReducer.instances,jo=t=>e=>e.issueCommentReducer.instances[t],bf=y(l.createSelector([Eo,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),qo=_i.reducer,fe=I(t=>t.offline_id),Mo=fe.getInitialState({}),Ri=l.createSlice({name:"issues",initialState:Mo,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Mo)}),reducers:{initializeIssues:fe.initialize,addIssue:fe.addOne,addIssues:fe.addMany,updateIssue:fe.updateOne,deleteIssue:fe.deleteOne,deleteIssues:fe.deleteMany}}),{initializeIssues:ko,addIssue:Pi,addIssues:Do,updateIssue:rt,deleteIssue:Oi,deleteIssues:zo}=Ri.actions,Vo=t=>t.issueReducer.instances,vi=t=>e=>e.issueReducer.instances[t],_f=y(l.createSelector([Vo,(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 S(s)})),Co=Ri.reducer,te=I(t=>t.offline_id),Uo=te.getInitialState({}),wi=l.createSlice({name:"issueTypeFieldsAttachments",initialState:Uo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Uo)),reducers:{initializeIssueTypeFieldsAttachments:te.initialize,addIssueTypeFieldsAttachment:te.addOne,addIssueTypeFieldsAttachments:te.addMany,setIssueTypeFieldsAttachment:te.setOne,setIssueTypeFieldsAttachments:te.setMany,updateIssueTypeFieldsAttachment:te.updateOne,updateIssueTypeFieldsAttachments:te.updateMany,deleteIssueTypeFieldsAttachment:te.deleteOne,deleteIssueTypeFieldsAttachments:te.deleteMany}}),{initializeIssueTypeFieldsAttachments:$o,addIssueTypeFieldsAttachment:Tf,addIssueTypeFieldsAttachments:Bo,setIssueTypeFieldsAttachment:Ff,setIssueTypeFieldsAttachments:If,updateIssueTypeFieldsAttachment:Rf,updateIssueTypeFieldsAttachments:Go,deleteIssueTypeFieldsAttachment:Pf,deleteIssueTypeFieldsAttachments:Lo}=wi.actions,No=t=>t.issueTypeFieldsAttachmentReducer.instances,Ho=l.createSelector([No],t=>Object.values(t)),Of=y(l.createSelector([Ho,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),vf=t=>e=>e.issueTypeFieldsAttachmentReducer.instances[t],Wo=wi.reducer,se=I(t=>t.offline_id),Ko=se.getInitialState({}),Ei=l.createSlice({name:"issueTypeFieldValues",initialState:Ko,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ko)),reducers:{initializeIssueTypeFieldValues:se.initialize,addIssueTypeFieldValues:se.addOne,addIssueTypeFieldValuesMany:se.addMany,setIssueTypeFieldValues:se.setOne,setIssueTypeFieldValuesMany:se.setMany,updateIssueTypeFieldValues:se.updateOne,updateIssueTypeFieldValuesMany:se.updateMany,deleteIssueTypeFieldValues:se.deleteOne,deleteIssueTypeFieldValuesMany:se.deleteMany}}),{initializeIssueTypeFieldValues:Yo,addIssueTypeFieldValues:ji,addIssueTypeFieldValuesMany:wf,setIssueTypeFieldValues:Ef,setIssueTypeFieldValuesMany:jf,updateIssueTypeFieldValues:Ue,updateIssueTypeFieldValuesMany:qf,deleteIssueTypeFieldValues:qi,deleteIssueTypeFieldValuesMany:Mf}=Ei.actions,Jo=t=>t.issueTypeFieldValuesReducer.instances,Mi=l.createSelector([Jo],t=>Object.values(t)),kf=y(l.createSelector([Mi,(t,e)=>e],(t,e)=>S(t.filter(s=>s.issue===e)))),ki=t=>e=>e.issueTypeFieldValuesReducer.instances[t],Xo=Ei.reducer,ie=I(t=>t.offline_id),Zo=ie.getInitialState({}),Di=l.createSlice({name:"issueTypeFields",initialState:Zo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Zo)),reducers:{initializeIssueTypeFields:ie.initialize,addIssueTypeFields:ie.addOne,addIssueTypeFieldsMany:ie.addMany,setIssueTypeFields:ie.setOne,setIssueTypeFieldsMany:ie.setMany,updateIssueTypeFields:ie.updateOne,updateIssueTypeFieldsMany:ie.updateMany,deleteIssueTypeFields:ie.deleteOne,deleteIssueTypeFieldsMany:ie.deleteMany}}),{initializeIssueTypeFields:Qo,addIssueTypeFields:xo,addIssueTypeFieldsMany:Df,setIssueTypeFields:zf,setIssueTypeFieldsMany:Vf,updateIssueTypeFields:ed,updateIssueTypeFieldsMany:Cf,deleteIssueTypeFields:td,deleteIssueTypeFieldsMany:Uf}=Di.actions,sd=t=>t.issueTypeFieldsReducer.instances,ot=l.createSelector([sd],t=>Object.values(t)),$f=y(l.createSelector([ot,(t,e)=>e],(t,e)=>S(t.filter(s=>s.issue_type===e)))),Bf=y(l.createSelector([ot,(t,e)=>e],(t,e)=>t.filter(s=>s.issue_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),Gf=y(l.createSelector([ot,Mi,(t,e)=>e],(t,e,s)=>{const n=new Set(t.filter(a=>a.issue_type===s).map(a=>a.offline_id));return S(e.filter(a=>n.has(a.fields_revision)))})),Lf=t=>e=>e.issueTypeFieldsReducer.instances[t],id=Di.reducer,ne=I(t=>t.offline_id),nd=ne.getInitialState({}),zi=l.createSlice({name:"issueTypeFieldValuesAttachments",initialState:nd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,nd)),reducers:{initializeIssueTypeFieldValuesAttachments:ne.initialize,addIssueTypeFieldValuesAttachment:ne.addOne,addIssueTypeFieldValuesAttachments:ne.addMany,setIssueTypeFieldValuesAttachment:ne.setOne,setIssueTypeFieldValuesAttachments:ne.setMany,updateIssueTypeFieldValuesAttachment:ne.updateOne,updateIssueTypeFieldValuesAttachments:ne.updateMany,deleteIssueTypeFieldValuesAttachment:ne.deleteOne,deleteIssueTypeFieldValuesAttachments:ne.deleteMany}}),{initializeIssueTypeFieldValuesAttachments:ad,addIssueTypeFieldValuesAttachment:Nf,addIssueTypeFieldValuesAttachments:dt,setIssueTypeFieldValuesAttachment:Hf,setIssueTypeFieldValuesAttachments:Wf,updateIssueTypeFieldValuesAttachment:Kf,updateIssueTypeFieldValuesAttachments:cd,deleteIssueTypeFieldValuesAttachment:Yf,deleteIssueTypeFieldValuesAttachments:lt}=zi.actions,Vi=t=>t.issueTypeFieldValuesAttachmentReducer.instances,rd=l.createSelector([Vi],t=>Object.values(t)),Jf=t=>e=>e.issueTypeFieldValuesAttachmentReducer.instances[t],od=y(l.createSelector([Vi,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),dd=y(l.createSelector([rd,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),ld=zi.reducer,Te=I(t=>t.offline_id),ud=Te.getInitialState({}),Ci=l.createSlice({name:"issueTypes",initialState:ud,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,ud)}),reducers:{initializeIssueTypes:Te.initialize,setIssueType:Te.setOne,addIssueType:Te.addOne,updateIssueType:Te.updateOne,removeIssueType:Te.deleteOne}}),{initializeIssueTypes:hd,setIssueType:$e,addIssueType:md,updateIssueType:fd,removeIssueType:Ui}=Ci.actions,pd=t=>t.issueTypeReducer.instances,Ad=l.createSelector(pd,t=>Object.values(t)),$i=t=>e=>e.issueTypeReducer.instances[t],Xf=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},Zf=y(l.createSelector([Ad,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),Bi=y(l.createSelector([t=>t.issueReducer.instances,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue_type===e)))),Qf=t=>e=>Bi(t)(e).length,yd=Ci.reducer,pe=I(t=>t.offline_id),Sd=pe.getInitialState({}),Gi=l.createSlice({name:"issueUpdates",initialState:Sd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Sd)),reducers:{initializeIssueUpdates:pe.setMany,setIssueUpdate:pe.setOne,addIssueUpdate:pe.addOne,addIssueUpdates:pe.addMany,deleteIssueUpdate:pe.deleteOne,deleteIssueUpdates:pe.deleteMany}}),{initializeIssueUpdates:gd,setIssueUpdate:xf,addIssueUpdate:bd,addIssueUpdates:_d,deleteIssueUpdate:Td,deleteIssueUpdates:Fd}=Gi.actions,Id=t=>t.issueUpdateReducer.instances,Rd=y(l.createSelector([Id,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),Pd=Gi.reducer,ut=I(t=>t.offline_id),Od=ut.getInitialState({}),Li=l.createSlice({name:"license",initialState:Od,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Od)),reducers:{initializeLicences:ut.initialize,addLicenses:ut.addMany,updateLicense:ut.updateOne}}),{initializeLicences:vd,addLicenses:ep,updateLicense:oe}=Li.actions,ht=t=>t.licenseReducer.instances,tp=t=>e=>e.licenseReducer.instances[t],wd=t=>e=>Object.values(e.licenseReducer.instances).find(s=>s.project===t),sp=l.createSelector([ht],t=>S(Object.values(t).filter(e=>e.is_active))),ip=l.createSelector([ht],t=>ge(Object.values(t).filter(e=>e.project).reduce((e,s)=>({...e,[s.project]:s}),{}))),Ed=Li.reducer,jd={users:{},currentUser:null},Ni=l.createSlice({name:"users",initialState:jd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,jd)),reducers:{setUsers:(t,e)=>{const s={};e.payload.forEach(n=>{s[n.id]=n}),t.users=s},addUsers:(t,e)=>{for(const s of e.payload)t.users[s.id]=s},setCurrentUser:(t,e)=>{t.currentUser=e.payload},setProfilePicture:(t,e)=>{if(!t.currentUser)return;t.currentUser.profile.file=e.payload.file??null,t.currentUser.profile.file_sha1=e.payload.file_sha1??null;const s=t.users[t.currentUser.id];if(!s)throw new Error("Unable to find current user in users slice");s.profile.file=e.payload.file??null,s.profile.file_sha1=e.payload.file_sha1??null},removeUser:(t,e)=>{delete t.users[e.payload]}}}),{setCurrentUser:np,setProfilePicture:ap,setUsers:qd,addUsers:cp,removeUser:Md}=Ni.actions,kd=Ni.reducer,mt=t=>t.userReducer.currentUser,ft=t=>t.userReducer.users,rp=t=>e=>e.userReducer.users[t],op=y(l.createSelector([ft,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectUsersByIds: No user exists with the id",n)}return S(s)})),pt=I(t=>t.offline_id),Dd=pt.getInitialState({}),Hi=l.createSlice({name:"organizationAccess",initialState:Dd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dd)),reducers:{initializeOrganizationAccesses:pt.initialize,updateOrganizationAccess:pt.updateOne,deleteOrganizationAccess:pt.deleteOne}}),{initializeOrganizationAccesses:zd,updateOrganizationAccess:Vd,deleteOrganizationAccess:Cd}=Hi.actions,Wi=t=>t.organizationAccessReducer.instances,dp=t=>e=>e.organizationAccessReducer.instances[t],lp=l.createSelector([mt,Wi],(t,e)=>Object.values(e).find(n=>n.user===(t==null?void 0:t.id))??null),up=t=>e=>Object.values(e.organizationAccessReducer.instances).find(s=>s.user===t.id),Ud=t=>{const e={};for(const s of Object.values(t.organizationAccessReducer.instances))e[s.user]=s;return ge(e)},$d=Hi.reducer,Be=I(t=>t.offline_id),Bd=Be.getInitialState({}),Ki=l.createSlice({name:"projectAccess",initialState:Bd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Bd)),reducers:{initializeProjectAccesses:Be.initialize,updateProjectAccess:Be.updateOne,deleteProjectAccess:Be.deleteOne,deleteProjectAccesses:Be.deleteMany}}),{initializeProjectAccesses:Yi,updateProjectAccess:Gd,deleteProjectAccess:Ld,deleteProjectAccesses:Nd}=Ki.actions,Ji=t=>t.projectAccessReducer.instances,Hd=l.createSelector(Ji,t=>Object.values(t)),hp=t=>e=>e.projectAccessReducer.instances[t],mp=t=>e=>Object.values(e.projectAccessReducer.instances).find(s=>s.user===t.id),Wd=t=>{const e={};for(const s of Object.values(t.projectAccessReducer.instances))e[s.user]=s;return ge(e)},Kd=Ki.reducer,Yd={projects:{}},Xi=l.createSlice({name:"projects",initialState:Yd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Yd)),reducers:{setProjects:(t,e)=>{const s={};e.payload.forEach(n=>{s[n.id]=n}),t.projects=s},updateProject:(t,e)=>{t.projects[e.payload.id]=e.payload},deleteProject:(t,e)=>{delete t.projects[e.payload.id]},acceptProjectInvite:(t,e)=>{if(e.payload in t.projects)t.projects[e.payload].invited=!1;else throw new Error("Accept project invite: user is not in this project")}}}),{setProjects:Jd,updateProject:Xd,deleteProject:Zd,acceptProjectInvite:Qd}=Xi.actions,xd=Xi.reducer,Zi=t=>t.projectReducer.projects,fp=t=>e=>e.projectReducer.projects[t],el=l.createSelector([Ji],t=>Object.values(t).map(e=>e.user)),tl=l.createSelector([el,ft],(t,e)=>t.reduce((s,n)=>({...s,[n]:e[n]}),{})),pp=l.createSelector([mt,tl,Wd],(t,e,s)=>S(Object.values(e).sort((n,a)=>{if(n.id===(t==null?void 0:t.id))return-1;if(a.id===(t==null?void 0:t.id))return 1;const c=s[n.id],r=s[a.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===gt.ADMIN?-1:1}))),sl={organizations:{}},Qi=l.createSlice({name:"organizations",initialState:sl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sl)),reducers:{setOrganizations:(t,e)=>{for(const s of e.payload)t.organizations[s.id]=s}}}),{setOrganizations:il}=Qi.actions,nl=t=>t.organizationReducer.organizations,al=l.createSelector([nl],t=>Object.values(t)),Ap=t=>e=>e.organizationReducer.organizations[t],yp=l.createSelector([al],t=>S(Object.values(t).filter(e=>e.has_access))),cl=l.createSelector([Wi],t=>Object.values(t).map(e=>e.user)),Sp=y(l.createSelector([Zi,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.organization_owner===e)))),gp=y(l.createSelector([ht,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.organization_owner===e)))),rl=l.createSelector([cl,ft],(t,e)=>ge(t.reduce((s,n)=>({...s,[n]:e[n]}),{}))),bp=l.createSelector([mt,rl,Ud],(t,e,s)=>S(Object.values(e).sort((n,a)=>{if(n.id===(t==null?void 0:t.id))return-1;if(a.id===(t==null?void 0:t.id))return 1;const c=s[n.id],r=s[a.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===bt.ADMIN?-1:1}))),ol=Qi.reducer,dl=(t,e,s)=>{const n=t.uuid?t:{...t,uuid:O.v4()};return{payload:n,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:n,BASE_URL:e,serviceName:s}}}}},ll={deletedRequests:[],latestRetryTime:0},xi=l.createSlice({name:"outbox",initialState:ll,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ll)),reducers:{enqueueRequest:{reducer:(t,e)=>t,prepare:t=>{console.debug("Preparing to enqueue request",t);const{BASE_URL:e,serviceName:s,...n}=t;return dl(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}}}),_p=t=>t.outboxReducer.deletedRequests,Tp=t=>t.outboxReducer.latestRetryTime,{enqueueRequest:ul,markForDeletion:Fp,markAsDeleted:hl,_setLatestRetryTime:ml}=xi.actions,fl=xi.reducer,ae=I(t=>t.offline_id),pl=ae.getInitialState({}),en=l.createSlice({name:"projectAttachments",initialState:pl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,pl)),reducers:{initializeProjectAttachments:ae.initialize,addProjectAttachment:ae.addOne,addProjectAttachments:ae.addMany,setProjectAttachment:ae.setOne,setProjectAttachments:ae.setMany,updateProjectAttachment:ae.updateOne,updateProjectAttachments:ae.updateMany,deleteProjectAttachment:ae.deleteOne,deleteProjectAttachments:ae.deleteMany}}),{initializeProjectAttachments:Al,addProjectAttachment:Ip,addProjectAttachments:yl,setProjectAttachment:Sl,setProjectAttachments:gl,updateProjectAttachment:Rp,updateProjectAttachments:bl,deleteProjectAttachment:_l,deleteProjectAttachments:tn}=en.actions,Tl=t=>t.projectAttachmentReducer.instances,sn=l.createSelector([Tl],t=>Object.values(t)),Fl=t=>e=>e.projectAttachmentReducer.instances[t],Il=y(l.createSelector([sn,(t,e)=>e],(t,e)=>S(t.filter(({project:s})=>e===s)))),Pp=y(l.createSelector([sn,(t,e)=>e],(t,e)=>{const s=t.filter(({project:c})=>e===c),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),Rl=en.reducer,ce=I(t=>t.offline_id),Pl=ce.getInitialState({activeProjectFileId:null,isImportingProjectFile:!1}),nn=l.createSlice({name:"projectFiles",initialState:Pl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Pl)),reducers:{initializeProjectFiles:ce.initialize,setProjectFile:ce.setOne,setProjectFiles:ce.setMany,addProjectFile:ce.addOne,addProjectFiles:ce.addMany,updateProjectFile:ce.updateOne,updateProjectFiles:ce.updateMany,deleteProjectFile:ce.deleteOne,deleteProjectFiles:ce.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:Ol,setProjectFile:Op,setProjectFiles:vp,addProjectFile:wp,addProjectFiles:vl,updateProjectFile:
|
|
1
|
+
(function(i,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("uuid"),require("@reduxjs/toolkit"),require("file-saver"),require("@redux-offline/redux-offline"),require("@redux-offline/redux-offline/lib/defaults"),require("localforage"),require("redux-persist-migrate"),require("superagent"),require("dependency-graph"),require("idb"),require("@redux-offline/redux-offline/lib/constants"),require("jwt-decode")):typeof define=="function"&&define.amd?define(["exports","uuid","@reduxjs/toolkit","file-saver","@redux-offline/redux-offline","@redux-offline/redux-offline/lib/defaults","localforage","redux-persist-migrate","superagent","dependency-graph","idb","@redux-offline/redux-offline/lib/constants","jwt-decode"],O):(i=typeof globalThis<"u"?globalThis:i||self,O(i["overmap-core"]={},i.uuid,i.toolkit,i.fileSaver,i.reduxOffline,i.offlineConfig,i.localforage,i.createMigration,i.request,i.dependencyGraph,i.idb,i.constants,i.jwtDecode))})(this,function(i,O,l,du,lu,Sn,uu,hu,Se,mu,fu,pu,Au){"use strict";var fy=Object.defineProperty;var py=(i,O,l)=>O in i?fy(i,O,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[O]=l;var g=(i,O,l)=>py(i,typeof O!="symbol"?O+"":O,l);var ou;const gn=Object.freeze([]),bn=Object.freeze({});var gt=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(gt||{}),bt=(t=>(t[t.GUEST=0]="GUEST",t[t.BASIC=2]="BASIC",t[t.ADMIN=4]="ADMIN",t))(bt||{}),u=(t=>(t.GET="GET",t.POST="POST",t.PATCH="PATCH",t.PUT="PUT",t.DELETE="DELETE",t))(u||{}),_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||{}),Tt=(t=>(t[t.BACKLOG=0]="BACKLOG",t[t.SELECTED=2]="SELECTED",t[t.DONE=4]="DONE",t))(Tt||{}),v=(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))(v||{}),Tn=(t=>(t.COMPLETED="checkout.completed",t.CLOSED="checkout.closed",t))(Tn||{}),Fn=(t=>(t[t.PRO=0]="PRO",t))(Fn||{}),In=(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))(In||{});const yu=Tt.BACKLOG,Su=_t.MEDIUM,Rn=6e4;function I(t){return{addOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},addMany:(f,p)=>{for(const A of p.payload){const _=t(A);f.instances[_]=A}},setOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},setMany:(f,p)=>{for(const A of p.payload){const _=t(A);f.instances[_]=A}},updateOne:(f,p)=>{const A=t(p.payload);f.instances[A]=p.payload},updateMany:(f,p)=>{for(const A of p.payload){const _=t(A);f.instances[_]=A}},deleteOne:(f,p)=>{delete f.instances[p.payload]},deleteMany:(f,p)=>{for(const A of p.payload)delete f.instances[A]},initialize:(f,p)=>{f.instances={};for(const A of p.payload){const _=t(A);f.instances[_]=A}},getInitialState:f=>({...f,instances:{}})}}ou=Symbol.toStringTag;class Pn{constructor(){g(this,ou,"Promise");g(this,"_promise");g(this,"_resolve");g(this,"_reject");g(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 gu=t=>({type:"Point",coordinates:t}),bu=t=>({type:"MultiPoint",coordinates:t}),_u=(t,e)=>t[0]===e[0]&&t[1]===e[1];let Ft=!1;["true","1"].includes("".toLowerCase())&&(Ft=!0);function On(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 It(t){const e={};return function(){const s=Array.prototype.slice.call(arguments);return s in e?(Ft&&console.debug(`Memoization debug: Using memorized return value for ${t.toString()}(`,s,")"),e[s]):(Ft&&console.debug(`Memoization debug: Cache miss! Memoizing ${t.toString()}(`,s,")"),e[s]=t.apply(this,s))}}function Tu(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 S=t=>t.length===0?gn:t,ge=t=>Object.keys(t).length===0?bn:t,vn=It(t=>{if(!t)return"";const e=new Date(t),s=e.getFullYear()===Rt.getFullYear(),n={day:"numeric",month:"short"};return s||(n.year="numeric"),e.toLocaleDateString([],n)}),Fu=new Intl.RelativeTimeFormat([],{style:"long",numeric:"auto"}),Iu=1e3*86400,Rt=new Date,Ru=t=>new Date(t).toDateString()===Rt.toDateString(),Pu=It((t,e,s)=>{const n=Math.round((new Date(t).getTime()-Rt.getTime())/Iu);return n<e||n>s?vn(t):Fu.format(n,"days")});function Ou(t){return new Uint8Array(t).reduce((s,n)=>s+n.toString(16).padStart(2,"0"),"")}const Pt=async(t,e)=>{e||(e=await be(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 be(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=Ou(c);e(r)})},n.readAsArrayBuffer(t)})}function vu(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 wn(t,e){return new File([t],e,{type:t.type})}function wu(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 Eu=async t=>{const e={};for(const s of t){const n=await be(s);e[n]={sha1:n,extension:s.name.split(".").pop()||"",file_type:s.type,size:s.size}}return Object.values(e)},En=async t=>(await fetch(t)).blob(),ju=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 qu(t){const e=new Blob([t]);du.saveAs(e,t.name)}const jn={};function Mu(t,e,s,...n){const a=jn[t];let c=!1;a?a[e]||(a[e]=!0,c=!0):(jn[t]={[e]:!0},c=!0),c&&console[s](...n)}function F(t){return{...t,offline_id:O.v4()}}function qn(t){const e={};for(const s of t)e[s.offline_id]=s;return e}function ku(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 Du(t){return t.toLowerCase().replace(" ","-")}function zu(t,e=!1){return t.normalize("NFKD").toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/[-\s]+/g,e?"_":"-")}function Vu(t,e){if(t.length<=e)return t;const s=t.slice(0,e-1);return s.slice(0,s.lastIndexOf(" "))+"…"}const y=t=>e=>s=>t(s,e);function Mn(t,e,s){return s.findIndex(n=>n.offline_id===t.offline_id)===e}function Cu(t,e,s){return s.findIndex(n=>n.file_sha1===t.file_sha1)===e}const Uu=/^.+@.+\..+$/,we=I(t=>t.offline_id),kn=we.getInitialState({}),Ot=l.createSlice({name:"agents",initialState:kn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,kn)),reducers:{initializeConversations:we.initialize,addConversation:we.addOne,setConversation:we.setOne,updateConversation:we.updateOne}}),{initializeConversations:Dn,addConversation:zn,setConversation:Vn,updateConversation:Cn}=Ot.actions,vt=t=>t.agentsReducer.instances,$u=l.createSelector([vt],t=>Object.values(t)),Bu=y(l.createSelector([vt,(t,e)=>e],(t,e)=>t[e])),Un=Ot.reducer,M=I(t=>t.offline_id),$n=M.getInitialState({}),wt=l.createSlice({name:"assetAttachments",initialState:$n,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,$n)),reducers:{initializeAssetAttachments:M.initialize,addAssetAttachment:M.addOne,addAssetAttachments:M.addMany,setAssetAttachment:M.setOne,setAssetAttachments:M.setMany,updateAssetAttachment:M.updateOne,updateAssetAttachments:M.updateMany,deleteAssetAttachment:M.deleteOne,deleteAssetAttachments:M.deleteMany}}),{initializeAssetAttachments:Et,addAssetAttachment:Gu,addAssetAttachments:jt,setAssetAttachment:Bn,setAssetAttachments:Lu,updateAssetAttachment:Nu,updateAssetAttachments:Gn,deleteAssetAttachment:Ln,deleteAssetAttachments:qt}=wt.actions,Nn=t=>t.assetAttachmentReducer.instances,Mt=l.createSelector([Nn],t=>Object.values(t)),Hn=t=>e=>e.assetAttachmentReducer.instances[t],Wn=y(l.createSelector([Mt,(t,e)=>e],(t,e)=>S(t.filter(({asset:s})=>e===s)))),Hu=y(l.createSelector([Mt,(t,e)=>e],(t,e)=>{const s=t.filter(({asset:c})=>e===c),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),Kn=wt.reducer,k=I(t=>t.offline_id),Yn=k.getInitialState({}),kt=l.createSlice({name:"assetProcedureFieldsAttachments",initialState:Yn,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Yn)),reducers:{initializeAssetProcedureFieldsAttachments:k.initialize,addAssetProcedureFieldsAttachment:k.addOne,addAssetProcedureFieldsAttachments:k.addMany,setAssetProcedureFieldsAttachment:k.setOne,setAssetProcedureFieldsAttachments:k.setMany,updateAssetProcedureFieldsAttachment:k.updateOne,updateAssetProcedureFieldsAttachments:k.updateMany,deleteAssetProcedureFieldsAttachment:k.deleteOne,deleteAssetProcedureFieldsAttachments:k.deleteMany}}),{initializeAssetProcedureFieldsAttachments:Jn,addAssetProcedureFieldsAttachment:Wu,addAssetProcedureFieldsAttachments:Xn,setAssetProcedureFieldsAttachment:Ku,setAssetProcedureFieldsAttachments:Yu,updateAssetProcedureFieldsAttachment:Ju,updateAssetProcedureFieldsAttachments:Zn,deleteAssetProcedureFieldsAttachment:Xu,deleteAssetProcedureFieldsAttachments:Qn}=kt.actions,xn=t=>t.assetProcedureFieldsAttachmentReducer.instances,ea=l.createSelector([xn],t=>Object.values(t)),Zu=y(l.createSelector([ea,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),Qu=t=>e=>e.assetProcedureFieldsAttachmentReducer.instances[t],ta=kt.reducer,D=I(t=>t.offline_id),sa=D.getInitialState({}),Dt=l.createSlice({name:"assetProcedureFields",initialState:sa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sa)),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:ia,addAssetProcedureFields:na,addAssetProcedureFieldsMany:xu,setAssetProcedureFields:eh,setAssetProcedureFieldsMany:th,updateAssetProcedureFields:aa,updateAssetProcedureFieldsMany:sh,deleteAssetProcedureFields:ca,deleteAssetProcedureFieldsMany:ih}=Dt.actions,ra=t=>t.assetProcedureFieldsReducer.instances,zt=l.createSelector([ra],t=>Object.values(t)),nh=y(l.createSelector([zt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),ah=y(l.createSelector([zt,(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],oa=Dt.reducer,z=I(t=>t.offline_id),da=z.getInitialState({}),Vt=l.createSlice({name:"assetProcedureFieldValuesAttachments",initialState:da,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,da)),reducers:{initializeAssetProcedureFieldValuesAttachments:z.initialize,addAssetProcedureFieldValuesAttachment:z.addOne,addAssetProcedureFieldValuesAttachments:z.addMany,setAssetProcedureFieldValuesAttachment:z.setOne,setAssetProcedureFieldValuesAttachments:z.setMany,updateAssetProcedureFieldValuesAttachment:z.updateOne,updateAssetProcedureFieldValuesAttachments:z.updateMany,deleteAssetProcedureFieldValuesAttachment:z.deleteOne,deleteAssetProcedureFieldValuesAttachments:z.deleteMany}}),{initializeAssetProcedureFieldValuesAttachments:la,addAssetProcedureFieldValuesAttachment:rh,addAssetProcedureFieldValuesAttachments:We,setAssetProcedureFieldValuesAttachment:oh,setAssetProcedureFieldValuesAttachments:dh,updateAssetProcedureFieldValuesAttachment:lh,updateAssetProcedureFieldValuesAttachments:ua,deleteAssetProcedureFieldValuesAttachment:uh,deleteAssetProcedureFieldValuesAttachments:Ke}=Vt.actions,Ct=t=>t.assetProcedureFieldValuesAttachmentReducer.instances,ha=l.createSelector([Ct],t=>Object.values(t)),hh=t=>e=>e.assetProcedureFieldValuesAttachmentReducer.instances[t],ma=y(l.createSelector([Ct,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),fa=y(l.createSelector([ha,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),pa=Vt.reducer,V=I(t=>t.offline_id),Aa=V.getInitialState({}),Ut=l.createSlice({name:"assetProcedureFieldValues",initialState:Aa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Aa)),reducers:{initializeAssetProcedureFieldValues:V.initialize,addAssetProcedureFieldValues:V.addOne,addAssetProcedureFieldValuesMany:V.addMany,setAssetProcedureFieldValues:V.setOne,setAssetProcedureFieldValuesMany:V.setMany,updateAssetProcedureFieldValues:V.updateOne,updateAssetProcedureFieldValuesMany:V.updateMany,deleteAssetProcedureFieldValues:V.deleteOne,deleteAssetProcedureFieldValuesMany:V.deleteMany}}),{initializeAssetProcedureFieldValues:ya,addAssetProcedureFieldValues:$t,addAssetProcedureFieldValuesMany:Sa,setAssetProcedureFieldValues:mh,setAssetProcedureFieldValuesMany:fh,updateAssetProcedureFieldValues:Ee,updateAssetProcedureFieldValuesMany:ga,deleteAssetProcedureFieldValues:Bt,deleteAssetProcedureFieldValuesMany:ba}=Ut.actions,_a=t=>t.assetProcedureFieldValuesReducer.instances,Gt=l.createSelector([_a],t=>Object.values(t)),ph=y(l.createSelector([Gt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset===e)))),Ah=y(l.createSelector([Gt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure_instance===e)))),Lt=t=>e=>e.assetProcedureFieldValuesReducer.instances[t],Ta=Ut.reducer,C=I(t=>t.offline_id),Fa=C.getInitialState({}),Nt=l.createSlice({name:"assetProcedureInstances",initialState:Fa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Fa)),reducers:{initializeAssetProcedureInstances:C.initialize,addAssetProcedureInstance:C.addOne,addAssetProcedureInstances:C.addMany,setAssetProcedureInstance:C.setOne,setAssetProcedureInstances:C.setMany,updateAssetProcedureInstance:C.updateOne,updateAssetProcedureInstances:C.updateMany,deleteAssetProcedureInstance:C.deleteOne,deleteAssetProcedureInstances:C.deleteMany}}),{initializeAssetProcedureInstances:Ia,addAssetProcedureInstance:Ht,addAssetProcedureInstances:Ra,updateAssetProcedureInstance:je,updateAssetProcedureInstances:yh,deleteAssetProcedureInstance:Wt,deleteAssetProcedureInstances:Pa,setAssetProcedureInstance:Sh,setAssetProcedureInstances:gh}=Nt.actions,Kt=t=>t.assetProcedureInstanceReducer.instances,Yt=l.createSelector([Kt],t=>Object.values(t)),Oa=y(l.createSelector([Yt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),bh=y(l.createSelector([Yt,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),Jt=t=>e=>e.assetProcedureInstanceReducer.instances[t],_h=y(l.createSelector([Kt,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return S(s)})),va=Nt.reducer,U=I(t=>t.offline_id),wa=U.getInitialState({}),Xt=l.createSlice({name:"assetProcedures",initialState:wa,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,wa)),reducers:{initializeAssetProcedures:U.initialize,addAssetProcedure:U.addOne,addAssetProcedures:U.addMany,setAssetProcedure:U.setOne,setAssetProcedures:U.setMany,updateAssetProcedure:U.updateOne,updateAssetProcedures:U.updateMany,deleteAssetProcedure:U.deleteOne,deleteAssetProcedures:U.deleteMany}}),{initializeAssetProcedures:Ea,addAssetProcedure:Zt,addAssetProcedures:Th,updateAssetProcedure:qe,updateAssetProcedures:Fh,deleteAssetProcedure:Qt,deleteAssetProcedures:Ih,setAssetProcedure:Rh,setAssetProcedures:Ph}=Xt.actions,xt=t=>t.assetProcedureReducer.instances,ja=l.createSelector([xt],t=>Object.values(t)),Oh=y(l.createSelector([ja,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),es=t=>e=>e.assetProcedureReducer.instances[t],vh=y(l.createSelector([xt,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return S(s)})),qa=Xt.reducer,$=I(t=>t.offline_id),Ma=$.getInitialState({}),ts=l.createSlice({name:"assets",initialState:Ma,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ma)),reducers:{initializeAssets:$.initialize,addAsset:$.addOne,addAssets:$.addMany,setAsset:$.setOne,setAssets:$.setMany,updateAsset:$.updateOne,updateAssets:$.updateMany,deleteAsset:$.deleteOne,deleteAssets:$.deleteMany}}),{initializeAssets:ka,addAsset:ss,addAssets:is,updateAsset:Me,updateAssets:wh,deleteAsset:ns,deleteAssets:Da,setAsset:Eh,setAssets:jh}=ts.actions,as=t=>t.assetReducer.instances,za=l.createSelector([as],t=>S(Object.values(t))),cs=y(l.createSelector([za,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),rs=t=>e=>e.assetReducer.instances[t],qh=y(l.createSelector([as,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a&&s.push(a)}return S(s)})),Mh=t=>e=>cs(t)(e).length,Va=ts.reducer,de=I(t=>t.offline_id),Ca=de.getInitialState({}),os=l.createSlice({name:"assetStageCompletions",initialState:Ca,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ca)),reducers:{initializeAssetStageCompletions:de.initialize,addAssetStageCompletion:de.addOne,addAssetStageCompletions:de.addMany,updateAssetStageCompletion:de.updateOne,updateAssetStageCompletions:de.updateMany,deleteAssetStageCompletion:de.deleteOne,deleteAssetStageCompletions:de.deleteMany}}),{initializeAssetStageCompletions:Ua,addAssetStageCompletion:ds,addAssetStageCompletions:ls,updateAssetStageCompletion:$a,updateAssetStageCompletions:Ba,deleteAssetStageCompletion:us,deleteAssetStageCompletions:hs}=os.actions,Ga=os.reducer,ms=t=>t.assetStageCompletionReducer.instances,kh=l.createSelector([ms],t=>Object.values(t)),La=t=>e=>e.assetStageCompletionReducer.instances[t],Na=y(l.createSelector([ms,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),B=I(t=>t.offline_id),Ha=B.getInitialState({}),fs=l.createSlice({name:"assetStages",initialState:Ha,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ha)),reducers:{initializeAssetStages:B.initialize,setAssetStage:B.setOne,setAssetStages:B.setMany,addAssetStage:B.addOne,addAssetStages:B.addMany,updateAssetStage:B.updateOne,updateAssetStages:B.updateMany,deleteAssetStage:B.deleteOne,deleteAssetStages:B.deleteMany}}),{initializeAssetStages:Wa,setAssetStage:Ka,setAssetStages:Dh,addAssetStage:zh,addAssetStages:ps,updateAssetStage:As,updateAssetStages:Ye,deleteAssetStage:Vh,deleteAssetStages:ys}=fs.actions,Ya=fs.reducer,Je=t=>t.assetStageReducer.instances,Ja=t=>e=>e.assetStageReducer.instances[t],Xa=l.createSelector([Je],t=>Object.values(t)),Ch=y(l.createSelector([Je,(t,e)=>e],(t,e)=>{const s={};for(const[n,a]of Object.entries(t))a.asset_procedure===e&&(s[n]=a);return ge(s)})),Uh=y(l.createSelector([Xa,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_procedure===e)))),Ss=y(l.createSelector([Je,(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 S(s)})),G=I(t=>t.offline_id),Za=G.getInitialState({}),gs=l.createSlice({name:"assetTypeAttachments",initialState:Za,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Za)),reducers:{initializeAssetTypeAttachments:G.initialize,addAssetTypeAttachment:G.addOne,addAssetTypeAttachments:G.addMany,setAssetTypeAttachment:G.setOne,setAssetTypeAttachments:G.setMany,updateAssetTypeAttachment:G.updateOne,updateAssetTypeAttachments:G.updateMany,deleteAssetTypeAttachment:G.deleteOne,deleteAssetTypeAttachments:G.deleteMany}}),{initializeAssetTypeAttachments:Qa,addAssetTypeAttachment:$h,addAssetTypeAttachments:bs,setAssetTypeAttachment:xa,setAssetTypeAttachments:Bh,updateAssetTypeAttachment:Gh,updateAssetTypeAttachments:ec,deleteAssetTypeAttachment:tc,deleteAssetTypeAttachments:_s}=gs.actions,sc=t=>t.assetTypeAttachmentReducer.instances,Ts=l.createSelector([sc],t=>Object.values(t)),ic=t=>e=>e.assetTypeAttachmentReducer.instances[t],nc=y(l.createSelector([Ts,(t,e)=>e],(t,e)=>S(t.filter(({asset_type:s})=>e===s)))),Lh=y(l.createSelector([Ts,(t,e)=>e],(t,e)=>{const s=t.filter(({asset_type:c})=>c===e),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),ac=gs.reducer,L=I(t=>t.offline_id),cc=L.getInitialState({}),Fs=l.createSlice({name:"assetTypeFieldsAttachments",initialState:cc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,cc)),reducers:{initializeAssetTypeFieldsAttachments:L.initialize,addAssetTypeFieldsAttachment:L.addOne,addAssetTypeFieldsAttachments:L.addMany,setAssetTypeFieldsAttachment:L.setOne,setAssetTypeFieldsAttachments:L.setMany,updateAssetTypeFieldsAttachment:L.updateOne,updateAssetTypeFieldsAttachments:L.updateMany,deleteAssetTypeFieldsAttachment:L.deleteOne,deleteAssetTypeFieldsAttachments:L.deleteMany}}),{initializeAssetTypeFieldsAttachments:rc,addAssetTypeFieldsAttachment:Nh,addAssetTypeFieldsAttachments:oc,setAssetTypeFieldsAttachment:Hh,setAssetTypeFieldsAttachments:Wh,updateAssetTypeFieldsAttachment:Kh,updateAssetTypeFieldsAttachments:dc,deleteAssetTypeFieldsAttachment:Yh,deleteAssetTypeFieldsAttachments:lc}=Fs.actions,uc=t=>t.assetTypeFieldsAttachmentReducer.instances,hc=l.createSelector([uc],t=>Object.values(t)),Jh=y(l.createSelector([hc,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),Xh=t=>e=>e.assetTypeFieldsAttachmentReducer.instances[t],mc=Fs.reducer,N=I(t=>t.offline_id),fc=N.getInitialState({}),Is=l.createSlice({name:"assetTypeFields",initialState:fc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,fc)),reducers:{initializeAssetTypeFields:N.initialize,addAssetTypeFields:N.addOne,addAssetTypeFieldsMany:N.addMany,setAssetTypeFields:N.setOne,setAssetTypeFieldsMany:N.setMany,updateAssetTypeFields:N.updateOne,updateAssetTypeFieldsMany:N.updateMany,deleteAssetTypeFields:N.deleteOne,deleteAssetTypeFieldsMany:N.deleteMany}}),{initializeAssetTypeFields:pc,addAssetTypeFields:Ac,addAssetTypeFieldsMany:Zh,setAssetTypeFields:Qh,setAssetTypeFieldsMany:xh,updateAssetTypeFields:yc,updateAssetTypeFieldsMany:em,deleteAssetTypeFields:Sc,deleteAssetTypeFieldsMany:tm}=Is.actions,gc=t=>t.assetTypeFieldsReducer.instances,Xe=l.createSelector([gc],t=>Object.values(t)),sm=y(l.createSelector([Xe,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset_type===e)))),im=y(l.createSelector([Xe,(t,e)=>e],(t,e)=>t.filter(s=>s.asset_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),nm=t=>e=>e.assetTypeFieldsReducer.instances[t],bc=Is.reducer,H=I(t=>t.offline_id),_c=H.getInitialState({}),Rs=l.createSlice({name:"assetTypeFieldValuesAttachments",initialState:_c,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,_c)),reducers:{initializeAssetTypeFieldValuesAttachments:H.initialize,addAssetTypeFieldValuesAttachment:H.addOne,addAssetTypeFieldValuesAttachments:H.addMany,setAssetTypeFieldValuesAttachment:H.setOne,setAssetTypeFieldValuesAttachments:H.setMany,updateAssetTypeFieldValuesAttachment:H.updateOne,updateAssetTypeFieldValuesAttachments:H.updateMany,deleteAssetTypeFieldValuesAttachment:H.deleteOne,deleteAssetTypeFieldValuesAttachments:H.deleteMany}}),{initializeAssetTypeFieldValuesAttachments:Tc,addAssetTypeFieldValuesAttachment:am,addAssetTypeFieldValuesAttachments:Ze,setAssetTypeFieldValuesAttachment:cm,setAssetTypeFieldValuesAttachments:rm,updateAssetTypeFieldValuesAttachment:om,updateAssetTypeFieldValuesAttachments:Fc,deleteAssetTypeFieldValuesAttachment:dm,deleteAssetTypeFieldValuesAttachments:Qe}=Rs.actions,Ps=t=>t.assetTypeFieldValuesAttachmentReducer.instances,Ic=l.createSelector([Ps],t=>Object.values(t)),lm=t=>e=>e.assetTypeFieldValuesAttachmentReducer.instances[t],Rc=y(l.createSelector([Ps,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),Pc=y(l.createSelector([Ic,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),Oc=Rs.reducer,W=I(t=>t.offline_id),vc=W.getInitialState({}),Os=l.createSlice({name:"assetTypeFieldValues",initialState:vc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,vc)),reducers:{initializeAssetTypeFieldValues:W.initialize,addAssetTypeFieldValues:W.addOne,addAssetTypeFieldValuesMany:W.addMany,setAssetTypeFieldValues:W.setOne,setAssetTypeFieldValuesMany:W.setMany,updateAssetTypeFieldValues:W.updateOne,updateAssetTypeFieldValuesMany:W.updateMany,deleteAssetTypeFieldValues:W.deleteOne,deleteAssetTypeFieldValuesMany:W.deleteMany}}),{initializeAssetTypeFieldValues:wc,addAssetTypeFieldValues:vs,addAssetTypeFieldValuesMany:Ec,setAssetTypeFieldValues:um,setAssetTypeFieldValuesMany:hm,updateAssetTypeFieldValues:ke,updateAssetTypeFieldValuesMany:jc,deleteAssetTypeFieldValues:ws,deleteAssetTypeFieldValuesMany:qc}=Os.actions,Mc=t=>t.assetTypeFieldValuesReducer.instances,Es=l.createSelector([Mc],t=>Object.values(t)),mm=y(l.createSelector([Es,(t,e)=>e],(t,e)=>S(t.filter(s=>s.asset===e)))),fm=y(l.createSelector([Xe,Es,(t,e)=>e],(t,e,s)=>{const n=new Set(t.filter(a=>a.asset_type===s).map(a=>a.offline_id));return S(e.filter(a=>n.has(a.fields_revision)))})),js=t=>e=>e.assetTypeFieldValuesReducer.instances[t],kc=Os.reducer,K=I(t=>t.offline_id),Dc=K.getInitialState({}),qs=l.createSlice({name:"assetTypes",initialState:Dc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dc)),reducers:{initializeAssetTypes:K.initialize,setAssetType:K.setOne,setAssetTypes:K.setMany,addAssetType:K.addOne,addAssetTypes:K.addMany,updateAssetType:K.updateOne,updateAssetTypes:K.updateMany,deleteAssetType:K.deleteOne,deleteAssetTypes:K.deleteMany}}),{initializeAssetTypes:zc,setAssetType:pm,setAssetTypes:Am,addAssetType:Ms,addAssetTypes:ym,updateAssetType:De,updateAssetTypes:Sm,deleteAssetType:ks,deleteAssetTypes:gm}=qs.actions,Ds=t=>t.assetTypeReducer.instances,bm=l.createSelector([Ds],t=>Object.values(t)),zs=t=>e=>e.assetTypeReducer.instances[t],_m=y(l.createSelector([Ds,(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 S(s)})),Vc=qs.reducer,Cc={accessToken:"",refreshToken:"",isLoggedIn:!1},xe=l.createSlice({name:"auth",initialState:Cc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Cc)),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||xe.caseReducers.clearTokens(t),t.isLoggedIn=e.payload}}}),{setTokens:Tm,clearTokens:Fm,setLoggedIn:Uc}=xe.actions,Im=t=>t.authReducer.accessToken,Rm=t=>t.authReducer.isLoggedIn,$c=xe.reducer,ze=I(t=>t.offline_id),Bc=ze.getInitialState({}),Vs=l.createSlice({name:"categories",initialState:Bc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Bc)),reducers:{initializeCategories:ze.initialize,addCategory:ze.addOne,updateCategory:ze.updateOne,deleteCategory:ze.deleteOne}}),{initializeCategories:Gc,addCategory:Cs,updateCategory:Lc,deleteCategory:Nc}=Vs.actions,Us=t=>t.categoryReducer.instances,Pm=l.createSelector([Us],t=>Object.values(t)),$s=t=>e=>e.categoryReducer.instances[t],Om=y(l.createSelector([Us,(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 S(s)})),vm=t=>e=>Object.values(e.issueReducer.instances).filter(s=>s.category===t).length,Hc=Vs.reducer,Y=I(t=>t.offline_id),Wc=Y.getInitialState({}),Bs=l.createSlice({name:"documentAttachments",initialState:Wc,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Wc)),reducers:{initializeDocumentAttachments:Y.initialize,addDocumentAttachment:Y.addOne,addDocumentAttachments:Y.addMany,setDocumentAttachment:Y.setOne,setDocumentAttachments:Y.setMany,updateDocumentAttachment:Y.updateOne,updateDocumentAttachments:Y.updateMany,deleteDocumentAttachment:Y.deleteOne,deleteDocumentAttachments:Y.deleteMany}}),{initializeDocumentAttachments:Kc,addDocumentAttachment:wm,addDocumentAttachments:Yc,setDocumentAttachment:Jc,setDocumentAttachments:Em,updateDocumentAttachment:jm,updateDocumentAttachments:Xc,deleteDocumentAttachment:Zc,deleteDocumentAttachments:Qc}=Bs.actions,xc=t=>t.documentAttachmentReducer.instances,Gs=l.createSelector([xc],t=>Object.values(t)),er=t=>e=>e.documentAttachmentReducer.instances[t],qm=y(l.createSelector([Gs,(t,e)=>e],(t,e)=>S(t.filter(({document:s})=>e===s)))),Mm=y(l.createSelector([Gs,(t,e)=>e],(t,e)=>{const s=t.filter(({document:c})=>e===c),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),tr=Bs.reducer,sr={documents:{}},Ls=l.createSlice({name:"documents",initialState:sr,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,sr)}),reducers:{setDocuments:(t,e)=>{if(e.payload.filter(Mn).length!==e.payload.length)throw new Error("Tried to use setIssues reducer with duplicate ID's");t.documents=qn(e.payload)},addDocuments:(t,e)=>{for(const s of e.payload)if(s.offline_id in t.documents)throw new Error(`attempting to add a document with offline_id ${s.offline_id} which already exists in state.documents.`);for(const s of e.payload){if(s.parent_document&&t.documents[s.parent_document]){const n=t.documents[s.parent_document];t.documents[s.parent_document]={...n,children_documents:[...n.children_documents,s.offline_id]}}t.documents[s.offline_id]=s}},updateDocuments:(t,e)=>{for(const s of e.payload)if(!(s.offline_id in t.documents))throw new Error(`attempting to update a document with offline_id ${s.offline_id} which doesn't exists in state.documents.`);for(const s of e.payload){const n=t.documents[s.offline_id];if(s.organization!==void 0&&s.organization!==n.organization)throw new Error("organization cannot be updated");if(s.project!==void 0&&s.project!==n.project)throw new Error("project cannot be updated");t.documents[s.offline_id]={...n,...s}}},moveDocument:(t,e)=>{const{documentId:s,targetDocumentId:n,position:a}=e.payload;if(!(s in t.documents))throw new Error(`attempting to move a document with offline_id ${s} which doesn't exist in state.documents`);const c=t.documents[s];if(c.parent_document&&t.documents[c.parent_document]){const{children_documents:r}=t.documents[c.parent_document];t.documents[c.parent_document].children_documents.splice(r.indexOf(c.offline_id),1)}if(n){const r=t.documents[n],d=r!=null&&r.parent_document?t.documents[r.parent_document]:null;switch(a){case"left":if(!d)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(d.children_documents.indexOf(r.offline_id),0,c.offline_id),t.documents[s].parent_document=d.offline_id;break;case"right":if(!d)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(d.children_documents.indexOf(r.offline_id)+1,0,c.offline_id),t.documents[s].parent_document=d.offline_id;break;case"left-child":if(!r)throw new Error("attempting to move a document to the left-child of a document that doesn't exist");t.documents[n].children_documents.unshift(c.offline_id),t.documents[s].parent_document=r.offline_id;break;case"right-child":if(!r)throw new Error("attempting to move a document to the left-child of a document that doesn't exist");t.documents[n].children_documents.push(c.offline_id),t.documents[s].parent_document=r.offline_id}}else t.documents[s].parent_document=null},removeDocuments:(t,e)=>{for(const s of e.payload)if(!(s in t.documents))throw new Error(`attempting to delete a document with offline_id ${s} which doesn't exists in state.documents.`);for(const s of e.payload){const n=t.documents[s];if(n.parent_document&&t.documents[n.parent_document]){const a=t.documents[n.parent_document];t.documents[n.parent_document]={...a,children_documents:a.children_documents.filter(c=>c!==n.offline_id)}}delete t.documents[s]}}}}),{setDocuments:ir,addDocuments:nr,updateDocuments:le,moveDocument:ar,removeDocuments:Ns}=Ls.actions,_e=t=>t.documentsReducer.documents,cr=l.createSelector([_e],t=>Object.values(t)),rr=t=>e=>e.documentsReducer.documents[t],km=y(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 S(s)})),Dm=y(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.offline_id),a=t[a.parent_document??""];return S(s)})),zm=l.createSelector([cr],t=>S(t.filter(e=>!e.parent_document))),or=Ls.reducer,et=I(t=>t.offline_id),Vm=et.getInitialState({}),Hs=l.createSlice({name:"emailDomains",initialState:Vm,reducers:{initializeEmailDomains:et.initialize,addEmailDomain:et.addOne,deleteEmailDomain:et.deleteOne}}),{initializeEmailDomains:dr,addEmailDomain:lr,deleteEmailDomain:ur}=Hs.actions,hr=t=>t.emailDomainsReducer.instances,mr=l.createSelector([hr],t=>Object.values(t)),Cm=y(l.createSelector([mr,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),fr=Hs.reducer,pr={s3Urls:{}},Ar=1e3*60*60,Um=Ar*24*7,Ws=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()+Um);t.s3Urls[a]={url:s,fields:n,exp:r.getTime()}}}}),{setUploadUrl:yr}=Ws.actions,Sr=t=>e=>{const s=e.fileReducer.s3Urls[t];if(!s)return;const n=new Date().getTime();if(!((s.exp??n)-n<Ar))return s},gr=Ws.reducer,J=I(t=>t.offline_id),br=J.getInitialState({}),Ks=l.createSlice({name:"formRevisionAttachments",initialState:br,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,br)),reducers:{initializeFormRevisionAttachments:J.initialize,addFormRevisionAttachment:J.addOne,addFormRevisionAttachments:J.addMany,setFormRevisionAttachment:J.setOne,setFormRevisionAttachments:J.setMany,updateFormRevisionAttachment:J.updateOne,updateFormRevisionAttachments:J.updateMany,deleteFormRevisionAttachment:J.deleteOne,deleteFormRevisionAttachments:J.deleteMany}}),{initializeFormRevisionAttachments:_r,addFormRevisionAttachment:$m,addFormRevisionAttachments:Tr,setFormRevisionAttachment:Bm,setFormRevisionAttachments:Gm,updateFormRevisionAttachment:Lm,updateFormRevisionAttachments:Fr,deleteFormRevisionAttachment:Nm,deleteFormRevisionAttachments:Ir}=Ks.actions,Rr=t=>t.formRevisionAttachmentReducer.instances,Hm=y(l.createSelector([Rr,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.form_revision===e)))),Pr=Ks.reducer,Wm=(t,e)=>{const s=t.revision,n=e.revision;return s==="Pending"&&n==="Pending"?t.submitted_at<e.submitted_at?-1:1:s==="Pending"?1:n==="Pending"||s<n?-1:1},ue=I(t=>t.offline_id),Or=ue.getInitialState({}),Ys=l.createSlice({name:"formRevisions",initialState:Or,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Or)),reducers:{initializeFormRevisions:ue.initialize,setFormRevision:ue.setOne,addFormRevision:ue.addOne,addFormRevisions:ue.addMany,deleteFormRevision:ue.deleteOne,deleteFormRevisions:ue.deleteMany}}),{setFormRevision:vr,initializeFormRevisions:wr,addFormRevision:Js,addFormRevisions:Er,deleteFormRevision:Xs,deleteFormRevisions:jr}=Ys.actions,tt=t=>t.formRevisionReducer.instances,qr=l.createSelector([tt],t=>Object.values(t)),Km=t=>e=>e.formRevisionReducer.instances[t],Mr=(t,e)=>{let s=null;for(const n of Object.values(t))n.form===e&&(!s||s.revision<n.revision)&&(s=n);if(!s)throw new Error("No form revision found for form "+e);return s},Ym=y(l.createSelector([tt,(t,e)=>e],(t,e)=>{const s=Object.values(t).filter(c=>c.form===e);if(s.length===0)return;const a=s.sort(Wm)[s.length-1];return t[a.offline_id]})),kr=y(l.createSelector([qr,(t,e)=>e],(t,e)=>S(t.filter(s=>s.form===e)))),Dr=Ys.reducer,he=I(t=>t.offline_id),zr=he.getInitialState({}),Zs=l.createSlice({name:"forms",initialState:zr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,zr)),reducers:{initializeForms:he.initialize,setForm:he.setOne,addForm:he.addOne,addForms:he.addMany,updateForm:he.updateOne,deleteForm:he.deleteOne}}),{initializeForms:Vr,setForm:Jm,addForm:Qs,addForms:Xm,updateForm:Zm,deleteForm:xs}=Zs.actions,Cr=Zs.reducer,Ur=t=>t.formReducer.instances,Qm=l.createSelector([Ur],t=>Object.values(t)),$r=t=>e=>e.formReducer.instances[t],xm=y(l.createSelector([t=>t.formReducer.instances,t=>t.formRevisionReducer.instances,(t,e)=>e],(t,e,s)=>{const{searchTerm:n,maxResults:a,organization:c}=s,r=[];for(const[d,m]of Object.entries(t)){if(Number.isInteger(c)&&c!==m.organization)continue;Mr(e,d).title.toLowerCase().includes(n.toLowerCase())&&r.push(m)}return[...r.slice(0,a)]},{memoizeOptions:{resultEqualityCheck:On}})),X=I(t=>t.offline_id),Br=X.getInitialState({}),ei=l.createSlice({name:"formSubmissionAttachments",initialState:Br,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Br)),reducers:{initializeFormSubmissionAttachments:X.initialize,addFormSubmissionAttachment:X.addOne,addFormSubmissionAttachments:X.addMany,setFormSubmissionAttachment:X.setOne,setFormSubmissionAttachments:X.setMany,updateFormSubmissionAttachment:X.updateOne,updateFormSubmissionAttachments:X.updateMany,deleteFormSubmissionAttachment:X.deleteOne,deleteFormSubmissionAttachments:X.deleteMany}}),{initializeFormSubmissionAttachments:Gr,addFormSubmissionAttachment:ef,addFormSubmissionAttachments:st,setFormSubmissionAttachment:tf,setFormSubmissionAttachments:sf,updateFormSubmissionAttachment:nf,updateFormSubmissionAttachments:Lr,deleteFormSubmissionAttachment:af,deleteFormSubmissionAttachments:it}=ei.actions,ti=t=>t.formSubmissionAttachmentReducer.instances,Nr=y(l.createSelector([ti,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),Hr=y(l.createSelector([ti,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.form_submission===e)))),Wr=ei.reducer,Z=I(t=>t.offline_id),Kr=Z.getInitialState({}),si=l.createSlice({name:"formSubmissions",initialState:Kr,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Kr)),reducers:{initializeFormSubmissions:Z.initialize,setFormSubmission:Z.setOne,setFormSubmissions:Z.setMany,addFormSubmission:Z.addOne,addFormSubmissions:Z.addMany,updateFormSubmission:Z.updateOne,updateFormSubmissions:Z.updateMany,deleteFormSubmission:Z.deleteOne,deleteFormSubmissions:Z.deleteMany}}),{initializeFormSubmissions:Yr,setFormSubmission:nt,setFormSubmissions:cf,addFormSubmission:ii,addFormSubmissions:at,updateFormSubmission:Jr,updateFormSubmissions:rf,deleteFormSubmission:ni,deleteFormSubmissions:ct}=si.actions,ai=t=>t.formSubmissionReducer.instances,ci=l.createSelector([ai],t=>Object.values(t)),ri=t=>e=>e.formSubmissionReducer.instances[t],Xr=y(l.createSelector([ai,tt,(t,e)=>e],(t,e,s)=>{const n=new Set;for(const a of Object.values(e))a.form===s&&n.add(a.offline_id);return Object.values(t).filter(a=>n.has(a.form_revision))})),Zr=y(l.createSelector([ci,(t,e)=>e],(t,e)=>Object.values(t).filter(s=>s.issue===e))),Qr=y(l.createSelector([ci,(t,e)=>e],(t,e)=>t.filter(s=>s.asset===e))),xr=si.reducer,Q=I(t=>t.offline_id),eo=Q.getInitialState({}),oi=l.createSlice({name:"geoImages",initialState:eo,extraReducers:t=>{t.addCase("RESET",e=>{Object.assign(e,eo)})},reducers:{initializeGeoImages:Q.initialize,setGeoImage:Q.setOne,setGeoImages:Q.setMany,addGeoImage:Q.addOne,addGeoImages:Q.addMany,updateGeoImage:Q.updateOne,updateGeoImages:Q.updateMany,deleteGeoImage:Q.deleteOne,deleteGeoImages:Q.deleteMany}}),{initializeGeoImages:to,setGeoImage:Ve,setGeoImages:so,addGeoImage:io,addGeoImages:no,updateGeoImage:ao,updateGeoImages:of,deleteGeoImage:di,deleteGeoImages:co}=oi.actions,ro=t=>t.geoImageReducer.instances,oo=l.createSelector([ro],t=>Object.values(t)),li=t=>e=>e.geoImageReducer.instances[t],df=y(l.createSelector([oo,(t,e)=>e],(t,e)=>S(t.filter(s=>s.project===e)))),lo=oi.reducer,x=I(t=>t.offline_id),uo=x.getInitialState({}),ui=l.createSlice({name:"issueAssociations",initialState:uo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,uo)),reducers:{initializeIssueAssociations:x.initialize,addIssueAssociation:x.addOne,addIssueAssociations:x.addMany,setIssueAssociation:x.setOne,setIssueAssociations:x.setMany,updateIssueAssociation:x.updateOne,updateIssueAssociations:x.updateMany,deleteIssueAssociation:x.deleteOne,deleteIssueAssociations:x.deleteMany}}),{initializeIssueAssociations:ho,setIssueAssociations:lf,setIssueAssociation:uf,updateIssueAssociation:mo,updateIssueAssociations:hf,addIssueAssociation:hi,addIssueAssociations:mi,deleteIssueAssociation:fi,deleteIssueAssociations:pi}=ui.actions,Ce=t=>t.issueAssociationReducer.instances,mf=l.createSelector([Ce],t=>Object.values(t)),fo=t=>e=>e.issueAssociationReducer.instances[t],po=y(l.createSelector([Ce,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.associated_issue===e)))),Ao=y(l.createSelector([Ce,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),yo=y(l.createSelector([Ce,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.asset===e)))),So=ui.reducer,ee=I(t=>t.offline_id),go=ee.getInitialState({}),Ai=l.createSlice({name:"issueAttachments",initialState:go,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,go)),reducers:{initializeIssueAttachments:ee.initialize,addIssueAttachment:ee.addOne,addIssueAttachments:ee.addMany,setIssueAttachment:ee.setOne,setIssueAttachments:ee.setMany,updateIssueAttachment:ee.updateOne,updateIssueAttachments:ee.updateMany,deleteIssueAttachment:ee.deleteOne,deleteIssueAttachments:ee.deleteMany}}),{initializeIssueAttachments:bo,addIssueAttachment:ff,addIssueAttachments:yi,setIssueAttachment:_o,setIssueAttachments:pf,updateIssueAttachment:Af,updateIssueAttachments:To,deleteIssueAttachment:Fo,deleteIssueAttachments:Si}=Ai.actions,Io=t=>t.issueAttachmentReducer.instances,gi=l.createSelector([Io],t=>Object.values(t)),Ro=y(l.createSelector([gi,(t,e)=>e],(t,e)=>S(t.filter(({issue:s})=>e===s)))),Po=t=>e=>e.issueAttachmentReducer.instances[t],yf=y(l.createSelector([gi,(t,e)=>e],(t,e)=>{const s=t.filter(({issue:c})=>c===e),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),Oo=Ai.reducer,me=I(t=>t.offline_id),vo=me.getInitialState({}),bi=l.createSlice({name:"issueComments",initialState:vo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,vo)),reducers:{addIssueComment:me.addOne,addIssueComments:me.addMany,setIssueComment:me.setOne,setIssueComments:me.setMany,deleteIssueComment:me.deleteOne,deleteIssueComments:me.deleteMany}}),{setIssueComments:wo,setIssueComment:_i,addIssueComment:Ti,addIssueComments:Sf,deleteIssueComment:Fi,deleteIssueComments:gf}=bi.actions,Eo=t=>t.issueCommentReducer.instances,jo=t=>e=>e.issueCommentReducer.instances[t],bf=y(l.createSelector([Eo,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),qo=bi.reducer,fe=I(t=>t.offline_id),Mo=fe.getInitialState({}),Ii=l.createSlice({name:"issues",initialState:Mo,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,Mo)}),reducers:{initializeIssues:fe.initialize,addIssue:fe.addOne,addIssues:fe.addMany,updateIssue:fe.updateOne,deleteIssue:fe.deleteOne,deleteIssues:fe.deleteMany}}),{initializeIssues:ko,addIssue:Ri,addIssues:Do,updateIssue:rt,deleteIssue:Pi,deleteIssues:zo}=Ii.actions,Vo=t=>t.issueReducer.instances,Oi=t=>e=>e.issueReducer.instances[t],_f=y(l.createSelector([Vo,(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 S(s)})),Co=Ii.reducer,te=I(t=>t.offline_id),Uo=te.getInitialState({}),vi=l.createSlice({name:"issueTypeFieldsAttachments",initialState:Uo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Uo)),reducers:{initializeIssueTypeFieldsAttachments:te.initialize,addIssueTypeFieldsAttachment:te.addOne,addIssueTypeFieldsAttachments:te.addMany,setIssueTypeFieldsAttachment:te.setOne,setIssueTypeFieldsAttachments:te.setMany,updateIssueTypeFieldsAttachment:te.updateOne,updateIssueTypeFieldsAttachments:te.updateMany,deleteIssueTypeFieldsAttachment:te.deleteOne,deleteIssueTypeFieldsAttachments:te.deleteMany}}),{initializeIssueTypeFieldsAttachments:$o,addIssueTypeFieldsAttachment:Tf,addIssueTypeFieldsAttachments:Bo,setIssueTypeFieldsAttachment:Ff,setIssueTypeFieldsAttachments:If,updateIssueTypeFieldsAttachment:Rf,updateIssueTypeFieldsAttachments:Go,deleteIssueTypeFieldsAttachment:Pf,deleteIssueTypeFieldsAttachments:Lo}=vi.actions,No=t=>t.issueTypeFieldsAttachmentReducer.instances,Ho=l.createSelector([No],t=>Object.values(t)),Of=y(l.createSelector([Ho,(t,e)=>e],(t,e)=>S(t.filter(s=>s.fields_revision===e)))),vf=t=>e=>e.issueTypeFieldsAttachmentReducer.instances[t],Wo=vi.reducer,se=I(t=>t.offline_id),Ko=se.getInitialState({}),wi=l.createSlice({name:"issueTypeFieldValues",initialState:Ko,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Ko)),reducers:{initializeIssueTypeFieldValues:se.initialize,addIssueTypeFieldValues:se.addOne,addIssueTypeFieldValuesMany:se.addMany,setIssueTypeFieldValues:se.setOne,setIssueTypeFieldValuesMany:se.setMany,updateIssueTypeFieldValues:se.updateOne,updateIssueTypeFieldValuesMany:se.updateMany,deleteIssueTypeFieldValues:se.deleteOne,deleteIssueTypeFieldValuesMany:se.deleteMany}}),{initializeIssueTypeFieldValues:Yo,addIssueTypeFieldValues:Ei,addIssueTypeFieldValuesMany:wf,setIssueTypeFieldValues:Ef,setIssueTypeFieldValuesMany:jf,updateIssueTypeFieldValues:Ue,updateIssueTypeFieldValuesMany:qf,deleteIssueTypeFieldValues:ji,deleteIssueTypeFieldValuesMany:Mf}=wi.actions,Jo=t=>t.issueTypeFieldValuesReducer.instances,qi=l.createSelector([Jo],t=>Object.values(t)),kf=y(l.createSelector([qi,(t,e)=>e],(t,e)=>S(t.filter(s=>s.issue===e)))),Mi=t=>e=>e.issueTypeFieldValuesReducer.instances[t],Xo=wi.reducer,ie=I(t=>t.offline_id),Zo=ie.getInitialState({}),ki=l.createSlice({name:"issueTypeFields",initialState:Zo,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Zo)),reducers:{initializeIssueTypeFields:ie.initialize,addIssueTypeFields:ie.addOne,addIssueTypeFieldsMany:ie.addMany,setIssueTypeFields:ie.setOne,setIssueTypeFieldsMany:ie.setMany,updateIssueTypeFields:ie.updateOne,updateIssueTypeFieldsMany:ie.updateMany,deleteIssueTypeFields:ie.deleteOne,deleteIssueTypeFieldsMany:ie.deleteMany}}),{initializeIssueTypeFields:Qo,addIssueTypeFields:xo,addIssueTypeFieldsMany:Df,setIssueTypeFields:zf,setIssueTypeFieldsMany:Vf,updateIssueTypeFields:ed,updateIssueTypeFieldsMany:Cf,deleteIssueTypeFields:td,deleteIssueTypeFieldsMany:Uf}=ki.actions,sd=t=>t.issueTypeFieldsReducer.instances,ot=l.createSelector([sd],t=>Object.values(t)),$f=y(l.createSelector([ot,(t,e)=>e],(t,e)=>S(t.filter(s=>s.issue_type===e)))),Bf=y(l.createSelector([ot,(t,e)=>e],(t,e)=>t.filter(s=>s.issue_type===e).sort((s,n)=>s.submitted_at>n.submitted_at?-1:1)[0])),Gf=y(l.createSelector([ot,qi,(t,e)=>e],(t,e,s)=>{const n=new Set(t.filter(a=>a.issue_type===s).map(a=>a.offline_id));return S(e.filter(a=>n.has(a.fields_revision)))})),Lf=t=>e=>e.issueTypeFieldsReducer.instances[t],id=ki.reducer,ne=I(t=>t.offline_id),nd=ne.getInitialState({}),Di=l.createSlice({name:"issueTypeFieldValuesAttachments",initialState:nd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,nd)),reducers:{initializeIssueTypeFieldValuesAttachments:ne.initialize,addIssueTypeFieldValuesAttachment:ne.addOne,addIssueTypeFieldValuesAttachments:ne.addMany,setIssueTypeFieldValuesAttachment:ne.setOne,setIssueTypeFieldValuesAttachments:ne.setMany,updateIssueTypeFieldValuesAttachment:ne.updateOne,updateIssueTypeFieldValuesAttachments:ne.updateMany,deleteIssueTypeFieldValuesAttachment:ne.deleteOne,deleteIssueTypeFieldValuesAttachments:ne.deleteMany}}),{initializeIssueTypeFieldValuesAttachments:ad,addIssueTypeFieldValuesAttachment:Nf,addIssueTypeFieldValuesAttachments:dt,setIssueTypeFieldValuesAttachment:Hf,setIssueTypeFieldValuesAttachments:Wf,updateIssueTypeFieldValuesAttachment:Kf,updateIssueTypeFieldValuesAttachments:cd,deleteIssueTypeFieldValuesAttachment:Yf,deleteIssueTypeFieldValuesAttachments:lt}=Di.actions,zi=t=>t.issueTypeFieldValuesAttachmentReducer.instances,rd=l.createSelector([zi],t=>Object.values(t)),Jf=t=>e=>e.issueTypeFieldValuesAttachmentReducer.instances[t],od=y(l.createSelector([zi,(t,e)=>e],(t,e)=>{const s=new Set(e);return S(Object.values(t).filter(n=>s.has(n.offline_id)))})),dd=y(l.createSelector([rd,(t,e)=>e],(t,e)=>S(t.filter(s=>s.field_values===e)))),ld=Di.reducer,Te=I(t=>t.offline_id),ud=Te.getInitialState({}),Vi=l.createSlice({name:"issueTypes",initialState:ud,extraReducers:t=>t.addCase("RESET",e=>{Object.assign(e,ud)}),reducers:{initializeIssueTypes:Te.initialize,setIssueType:Te.setOne,addIssueType:Te.addOne,updateIssueType:Te.updateOne,removeIssueType:Te.deleteOne}}),{initializeIssueTypes:hd,setIssueType:$e,addIssueType:md,updateIssueType:fd,removeIssueType:Ci}=Vi.actions,pd=t=>t.issueTypeReducer.instances,Ad=l.createSelector(pd,t=>Object.values(t)),Ui=t=>e=>e.issueTypeReducer.instances[t],Xf=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},Zf=y(l.createSelector([Ad,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),$i=y(l.createSelector([t=>t.issueReducer.instances,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue_type===e)))),Qf=t=>e=>$i(t)(e).length,yd=Vi.reducer,pe=I(t=>t.offline_id),Sd=pe.getInitialState({}),Bi=l.createSlice({name:"issueUpdates",initialState:Sd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Sd)),reducers:{initializeIssueUpdates:pe.setMany,setIssueUpdate:pe.setOne,addIssueUpdate:pe.addOne,addIssueUpdates:pe.addMany,deleteIssueUpdate:pe.deleteOne,deleteIssueUpdates:pe.deleteMany}}),{initializeIssueUpdates:gd,setIssueUpdate:xf,addIssueUpdate:bd,addIssueUpdates:_d,deleteIssueUpdate:Td,deleteIssueUpdates:Fd}=Bi.actions,Id=t=>t.issueUpdateReducer.instances,Rd=y(l.createSelector([Id,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.issue===e)))),Pd=Bi.reducer,ut=I(t=>t.offline_id),Od=ut.getInitialState({}),Gi=l.createSlice({name:"license",initialState:Od,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Od)),reducers:{initializeLicences:ut.initialize,addLicenses:ut.addMany,updateLicense:ut.updateOne}}),{initializeLicences:vd,addLicenses:ep,updateLicense:oe}=Gi.actions,ht=t=>t.licenseReducer.instances,tp=t=>e=>e.licenseReducer.instances[t],wd=t=>e=>Object.values(e.licenseReducer.instances).find(s=>s.project===t),sp=l.createSelector([ht],t=>S(Object.values(t).filter(e=>e.is_active))),ip=l.createSelector([ht],t=>ge(Object.values(t).filter(e=>e.project).reduce((e,s)=>({...e,[s.project]:s}),{}))),Ed=Gi.reducer,jd={users:{},currentUser:null},Li=l.createSlice({name:"users",initialState:jd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,jd)),reducers:{setUsers:(t,e)=>{const s={};e.payload.forEach(n=>{s[n.id]=n}),t.users=s},addUsers:(t,e)=>{for(const s of e.payload)t.users[s.id]=s},setCurrentUser:(t,e)=>{t.currentUser=e.payload},setProfilePicture:(t,e)=>{if(!t.currentUser)return;t.currentUser.profile.file=e.payload.file??null,t.currentUser.profile.file_sha1=e.payload.file_sha1??null;const s=t.users[t.currentUser.id];if(!s)throw new Error("Unable to find current user in users slice");s.profile.file=e.payload.file??null,s.profile.file_sha1=e.payload.file_sha1??null},removeUser:(t,e)=>{delete t.users[e.payload]}}}),{setCurrentUser:np,setProfilePicture:ap,setUsers:qd,addUsers:cp,removeUser:Md}=Li.actions,kd=Li.reducer,mt=t=>t.userReducer.currentUser,ft=t=>t.userReducer.users,rp=t=>e=>e.userReducer.users[t],op=y(l.createSelector([ft,(t,e)=>e],(t,e)=>{const s=[];for(const n of e){const a=t[n];a?s.push(a):console.warn("selectUsersByIds: No user exists with the id",n)}return S(s)})),pt=I(t=>t.offline_id),Dd=pt.getInitialState({}),Ni=l.createSlice({name:"organizationAccess",initialState:Dd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Dd)),reducers:{initializeOrganizationAccesses:pt.initialize,updateOrganizationAccess:pt.updateOne,deleteOrganizationAccess:pt.deleteOne}}),{initializeOrganizationAccesses:zd,updateOrganizationAccess:Vd,deleteOrganizationAccess:Cd}=Ni.actions,Hi=t=>t.organizationAccessReducer.instances,dp=t=>e=>e.organizationAccessReducer.instances[t],lp=l.createSelector([mt,Hi],(t,e)=>Object.values(e).find(n=>n.user===(t==null?void 0:t.id))??null),up=t=>e=>Object.values(e.organizationAccessReducer.instances).find(s=>s.user===t.id),Ud=t=>{const e={};for(const s of Object.values(t.organizationAccessReducer.instances))e[s.user]=s;return ge(e)},$d=Ni.reducer,Be=I(t=>t.offline_id),Bd=Be.getInitialState({}),Wi=l.createSlice({name:"projectAccess",initialState:Bd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Bd)),reducers:{initializeProjectAccesses:Be.initialize,updateProjectAccess:Be.updateOne,deleteProjectAccess:Be.deleteOne,deleteProjectAccesses:Be.deleteMany}}),{initializeProjectAccesses:Ki,updateProjectAccess:Gd,deleteProjectAccess:Ld,deleteProjectAccesses:Nd}=Wi.actions,Yi=t=>t.projectAccessReducer.instances,Hd=l.createSelector(Yi,t=>Object.values(t)),hp=t=>e=>e.projectAccessReducer.instances[t],mp=t=>e=>Object.values(e.projectAccessReducer.instances).find(s=>s.user===t.id),Wd=t=>{const e={};for(const s of Object.values(t.projectAccessReducer.instances))e[s.user]=s;return ge(e)},Kd=Wi.reducer,Yd={projects:{}},Ji=l.createSlice({name:"projects",initialState:Yd,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Yd)),reducers:{setProjects:(t,e)=>{const s={};e.payload.forEach(n=>{s[n.id]=n}),t.projects=s},updateProject:(t,e)=>{t.projects[e.payload.id]=e.payload},deleteProject:(t,e)=>{delete t.projects[e.payload.id]},acceptProjectInvite:(t,e)=>{if(e.payload in t.projects)t.projects[e.payload].invited=!1;else throw new Error("Accept project invite: user is not in this project")}}}),{setProjects:Jd,updateProject:Xd,deleteProject:Zd,acceptProjectInvite:Qd}=Ji.actions,xd=Ji.reducer,Xi=t=>t.projectReducer.projects,fp=t=>e=>e.projectReducer.projects[t],el=l.createSelector([Yi],t=>Object.values(t).map(e=>e.user)),tl=l.createSelector([el,ft],(t,e)=>t.reduce((s,n)=>({...s,[n]:e[n]}),{})),pp=l.createSelector([mt,tl,Wd],(t,e,s)=>S(Object.values(e).sort((n,a)=>{if(n.id===(t==null?void 0:t.id))return-1;if(a.id===(t==null?void 0:t.id))return 1;const c=s[n.id],r=s[a.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===gt.ADMIN?-1:1}))),sl={organizations:{}},Zi=l.createSlice({name:"organizations",initialState:sl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,sl)),reducers:{setOrganizations:(t,e)=>{for(const s of e.payload)t.organizations[s.id]=s}}}),{setOrganizations:il}=Zi.actions,nl=t=>t.organizationReducer.organizations,al=l.createSelector([nl],t=>Object.values(t)),Ap=t=>e=>e.organizationReducer.organizations[t],yp=l.createSelector([al],t=>S(Object.values(t).filter(e=>e.has_access))),cl=l.createSelector([Hi],t=>Object.values(t).map(e=>e.user)),Sp=y(l.createSelector([Xi,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.organization_owner===e)))),gp=y(l.createSelector([ht,(t,e)=>e],(t,e)=>S(Object.values(t).filter(s=>s.organization_owner===e)))),rl=l.createSelector([cl,ft],(t,e)=>ge(t.reduce((s,n)=>({...s,[n]:e[n]}),{}))),bp=l.createSelector([mt,rl,Ud],(t,e,s)=>S(Object.values(e).sort((n,a)=>{if(n.id===(t==null?void 0:t.id))return-1;if(a.id===(t==null?void 0:t.id))return 1;const c=s[n.id],r=s[a.id];return(c==null?void 0:c.access_level)===(r==null?void 0:r.access_level)?n.username.localeCompare(a.username):(c==null?void 0:c.access_level)===bt.ADMIN?-1:1}))),ol=Zi.reducer,dl=(t,e,s)=>{const n=t.uuid?t:{...t,uuid:O.v4()};return{payload:n,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:n,BASE_URL:e,serviceName:s}}}}},ll={deletedRequests:[],latestRetryTime:0},Qi=l.createSlice({name:"outbox",initialState:ll,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,ll)),reducers:{enqueueRequest:{reducer:(t,e)=>t,prepare:t=>{console.debug("Preparing to enqueue request",t);const{BASE_URL:e,serviceName:s,...n}=t;return dl(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}}}),_p=t=>t.outboxReducer.deletedRequests,Tp=t=>t.outboxReducer.latestRetryTime,{enqueueRequest:ul,markForDeletion:Fp,markAsDeleted:hl,_setLatestRetryTime:ml}=Qi.actions,fl=Qi.reducer,ae=I(t=>t.offline_id),pl=ae.getInitialState({}),xi=l.createSlice({name:"projectAttachments",initialState:pl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,pl)),reducers:{initializeProjectAttachments:ae.initialize,addProjectAttachment:ae.addOne,addProjectAttachments:ae.addMany,setProjectAttachment:ae.setOne,setProjectAttachments:ae.setMany,updateProjectAttachment:ae.updateOne,updateProjectAttachments:ae.updateMany,deleteProjectAttachment:ae.deleteOne,deleteProjectAttachments:ae.deleteMany}}),{initializeProjectAttachments:Al,addProjectAttachment:Ip,addProjectAttachments:yl,setProjectAttachment:Sl,setProjectAttachments:gl,updateProjectAttachment:Rp,updateProjectAttachments:bl,deleteProjectAttachment:_l,deleteProjectAttachments:en}=xi.actions,Tl=t=>t.projectAttachmentReducer.instances,tn=l.createSelector([Tl],t=>Object.values(t)),Fl=t=>e=>e.projectAttachmentReducer.instances[t],Il=y(l.createSelector([tn,(t,e)=>e],(t,e)=>S(t.filter(({project:s})=>e===s)))),Pp=y(l.createSelector([tn,(t,e)=>e],(t,e)=>{const s=t.filter(({project:c})=>e===c),n=s.filter(({file_type:c})=>!c.startsWith("image/")),a=s.filter(({file_type:c})=>c.startsWith("image/"));return{fileAttachments:n,imageAttachments:a}})),Rl=xi.reducer,ce=I(t=>t.offline_id),Pl=ce.getInitialState({activeProjectFileId:null,isImportingProjectFile:!1}),sn=l.createSlice({name:"projectFiles",initialState:Pl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Pl)),reducers:{initializeProjectFiles:ce.initialize,setProjectFile:ce.setOne,setProjectFiles:ce.setMany,addProjectFile:ce.addOne,addProjectFiles:ce.addMany,updateProjectFile:ce.updateOne,updateProjectFiles:ce.updateMany,deleteProjectFile:ce.deleteOne,deleteProjectFiles:ce.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:Ol,setProjectFile:Op,setProjectFiles:vp,addProjectFile:wp,addProjectFiles:vl,updateProjectFile:nn,updateProjectFiles:Ep,deleteProjectFile:wl,deleteProjectFiles:El,setIsImportingProjectFile:jl,setActiveProjectFileId:ql,saveActiveProjectFileBounds:Ml,resetProjectFileObjectUrls:jp}=sn.actions,kl=t=>t.projectFileReducer.instances,Dl=l.createSelector([kl],t=>S(Object.values(t).sort((e,s)=>e.z_index-s.z_index))),qp=t=>e=>e.projectFileReducer.instances[t],Mp=t=>t.projectFileReducer.activeProjectFileId,kp=t=>t.projectFileReducer.isImportingProjectFile,zl=sn.reducer,Dp={isRehydrated:!1},an=l.createSlice({name:"rehydrated",initialState:Dp,reducers:{setRehydrated:(t,e)=>{t.isRehydrated=e.payload}}}),{setRehydrated:zp}=an.actions,Vp=t=>t.rehydratedReducer.isRehydrated,Vl=an.reducer,Fe=I(t=>t.offline_id),Cl=Fe.getInitialState({}),cn=l.createSlice({name:"teams",initialState:Cl,extraReducers:t=>t.addCase("RESET",e=>Object.assign(e,Cl)),reducers:{setTeam:Fe.setOne,initializeTeams:Fe.initialize,addTeam:Fe.addOne,updateTeam:Fe.updateOne,deleteTeam:Fe.deleteOne}}),{setTeam:Ie,initializeTeams:Ul,addTeam:$l,updateTeam:rn,deleteTeam:on}=cn.actions,dn=t=>t.teamReducer.instances,ln=l.createSelector([dn],t=>Object.values(t)),Re=t=>e=>e.teamReducer.instances[t],Cp=y(l.createSelector([dn,(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 S(s)})),Up=y(l.createSelector([ln,(t,e)=>e],(t,e)=>S(t.filter(s=>s.organization===e)))),$p=y(l.createSelector([ln,(t,e)=>e],(t,e)=>S(t.filter(s=>s.members.includes(e))))),Bl=cn.reducer,Bp={version:0},Gl=l.createSlice({name:"versioning",initialState:Bp,reducers:{}}),Ll=Gl.reducer;let Nl;function Gp(t){Nl=t}function Ge(){return Nl}let Hl;function Lp(t){Hl=t}function Np(){return Hl}const Wl={};class Kl{constructor(e){g(this,"client");Wl[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 Yl="versioning",Jl=()=>Ql.length-1,Xl=t=>(t[Yl]={version:Jl()},t),Zl=()=>Xl({}),Hp=t=>(t.outboxReducer&&(t.outboxReducer.deletedRequests=[]),t),Wp=t=>e=>{var s;return e===void 0&&(e={}),((s=e[Yl])==null?void 0:s.version)===Jl()?e:t(e)},Ql=[Xl,Zl,Zl,Hp],Kp=Object.fromEntries(Ql.map((t,e)=>[e,Wp(t)])),un="versioning",xl={[un]:Ll,fileReducer:gr,authReducer:$c,categoryReducer:Hc,assetReducer:Va,assetAttachmentReducer:Kn,assetStageCompletionReducer:Ga,assetStageReducer:Ya,assetTypeReducer:Vc,assetTypeAttachmentReducer:ac,issueReducer:Co,issueAttachmentReducer:Oo,issueTypeReducer:yd,organizationReducer:ol,outboxReducer:fl,projectReducer:xd,projectAttachmentReducer:Rl,projectAccessReducer:Kd,organizationAccessReducer:$d,projectFileReducer:zl,rehydratedReducer:Vl,formReducer:Cr,formRevisionReducer:Dr,formRevisionAttachmentReducer:Pr,formSubmissionAttachmentReducer:Wr,formSubmissionReducer:xr,userReducer:kd,emailDomainsReducer:fr,licenseReducer:Ed,documentsReducer:or,documentAttachmentReducer:tr,teamReducer:Bl,agentsReducer:Un,issueCommentReducer:qo,issueUpdateReducer:Pd,geoImageReducer:lo,issueAssociationReducer:So,issueTypeFieldsReducer:id,issueTypeFieldValuesReducer:Xo,issueTypeFieldsAttachmentReducer:Wo,issueTypeFieldValuesAttachmentReducer:ld,assetTypeFieldsReducer:bc,assetTypeFieldValuesReducer:kc,assetTypeFieldsAttachmentReducer:mc,assetTypeFieldValuesAttachmentReducer:Oc,assetProcedureReducer:qa,assetProcedureInstanceReducer:va,assetProcedureFieldsReducer:oa,assetProcedureFieldValuesReducer:Ta,assetProcedureFieldsAttachmentReducer:ta,assetProcedureFieldValuesAttachmentReducer:pa},eu=l.combineReducers(xl),tu="RESET",Yp=(t,e)=>e.type==="auth/setLoggedIn"&&!e.payload?eu(void 0,e):eu(t,e);let hn=null;function Ae(){const t=Ge();if(!t)return console.warn("Client store not set; cannot get outbox coordinator yet."),null;if(hn)return hn;const e=t.getState().offline.outbox,s=Oe._fromOutbox(e);return hn=s,s}const Jp=t=>{if(t)throw t;const e=Ge();e?e.dispatch({type:"rehydrated/setRehydrated",payload:!0}):console.error("Client store not set")},su=(t,e,s)=>{const n=Ae();return n?(n.addRequest(e),n.getQueue()):(console.warn("Outbox coordinator not set; cannot enqueue request yet."),[])},iu=(t,e,s)=>{const n=Ae();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 Xp(t,e){if(!e.payload)throw new Error("Received empty payload");return aA(e)}const Zp={...Sn,effect:Xp,discard:fn,returnPromises:!0,persistCallback:Jp,retry:rA,persistOptions:{storage:uu},queue:{...Sn.queue,enqueue:su,dequeue:iu,peek:(...t)=>cA(...t)}},Qp=hu(Kp,un),xp=l.compose(lu.offline(Zp),Qp);function eA(t){function e(s){return typeof s=="object"&&s!==null&&["ok","redirect","clientError","serverError","error"].every(a=>a in s)}if(e(t))return t;if(typeof t=="object"&&t!==null){const s=t;if(e(s.response))return s.response;if(s.response&&e(s.response.response))return s.response.response}}async function mn(t,e){const s=Wl[t.meta.offline.effect.serviceName];if(!s)throw new Error(`Service ${t.meta.offline.effect.serviceName} not found`);const n=s instanceof R;if(e.store.getState().outboxReducer.deletedRequests.includes(t.payload.uuid))throw new Error("Request was marked for deletion");n&&t.payload.checkAuth!==!1&&await s.auth.prepareAuth();const c={queryParams:"",isAuthNeeded:!0},r=t.meta.offline.effect,{payload:d,headers:m,method:o,queryParams:h,attachmentHash:f,isExternalUrl:p,isAuthNeeded:A,isResponseBlob:_}={...c,...r.request},T=r.request;let b=T.url;const P=f?await e.files.fetchCache(f):void 0;if(f&&!P)throw new Error(`Cannot upload file ${f} because it's not cached.`);!p&&!b.startsWith("http")&&(!b.startsWith("/")&&!b.startsWith("blob:")&&(b="/"+b),b=t.meta.offline.effect.BASE_URL+b);const q=w=>{if(f){const re=T.s3url;if(!re)throw new Error(`No S3 URL for file ${f}`);if("warning"in re)throw new Error(`S3 URL warning for file ${f}`);if(!P)throw new Error(`No file for file ${f}`);const He=re.fields["x-amz-checksum-sha1"];if(!He)throw new Error(`No checksum for file ${f}`);return w.set("x-amz-checksum-sha1",He).field({...d,...re.fields}).attach("file",P)}return w.send(d)},my={[u.GET]:()=>_?Se.get(b.toString()).responseType("blob"):Se.get(b.toString()),[u.POST]:()=>{const w=Se.post(b.toString());return q(w)},[u.PATCH]:()=>{const w=Se.patch(b.toString());return q(w)},[u.PUT]:()=>{const w=Se.put(b.toString());return q(w)},[u.DELETE]:()=>{const w=Se.delete(b.toString());return q(w)}}[o];let ye=my();if(A&&n){const w=s.auth.getAuthHeader();ye=ye.set("Authorization",w)}m&&(ye=ye.set(m));try{return await ye.query(h)}catch(w){const re=eA(w),He=re==null?void 0:re.status;if(n&&He===401)return await s.auth.handleUnauthorized(ye,re),ye.query(h);throw new j({response:re,innerError:w,discard:au.includes(He)})}}class tA{constructor(e){g(this,"_all");g(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 nu{constructor(){g(this,"next");this.next=null}then(e){return new tA(this).then(e)}async run(e){if(this.next)return this.next.run(e);{if(console.debug("Middleware finished. Performing request:",e),!Ge())throw new Error("Client store not set");const n=Np();if(!n)throw new Error("Client SDK not set");return mn(e,n)}}}class sA extends nu{async run(e){return super.run(e)}}class iA extends nu{async run(e){return super.run(e)}}const nA=new sA().then(new iA).compile();function aA(t){var e;return(e=nA[0])==null?void 0:e.run(t)}const au=[400,409,403,404,405,500];function fn(t,e,s=0){var o;if(console.debug("Considering discarding request due to error:",t,`(${typeof t})`,`
|
|
3
3
|
Action:`,e,`
|
|
4
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=Ge(),c=n.getState().outboxReducer.deletedRequests,r=e.payload.uuid;function d(){n.dispatch(hl(r));const h=Ae();if(!h)throw new Error("Outbox coordinator not set");h.remove(e.payload.uuid);const f=e.meta.offline.rollback;throw f&&(console.warn("Rolling back request due to SDK error:",e),n.dispatch(f)),t}if(t instanceof j&&t.options.discard)return console.debug("Discarding request due to explicit discard:",e),d();if(c.includes(r))return console.debug("Discarding request due to deletion:",e),d();if(t instanceof j){const h=t.status||((o=t.response)==null?void 0:o.status);if(h||console.warn("Error has no status code:",t),h!==void 0&&au.includes(h)){console.warn("Discarding request due to error:",t,`
|
|
5
|
-
Action:`,e);const f=Ae();if(!f)throw new Error("Outbox coordinator not set");f.remove(e.payload.uuid),t.options.discard=!0,d()}}console.debug("Registering a retry for request:",e.payload.uuid);const m=Ae();if(!m)throw new Error("Outbox coordinator not set");return m.registerRetry(e.payload.uuid),!1}function cA(t,e,s){var n;return(n=Ae())==null?void 0:n.peek()}function rA(t,e){return Ge().dispatch(ml(new Date().getTime())),
|
|
5
|
+
Action:`,e);const f=Ae();if(!f)throw new Error("Outbox coordinator not set");f.remove(e.payload.uuid),t.options.discard=!0,d()}}console.debug("Registering a retry for request:",e.payload.uuid);const m=Ae();if(!m)throw new Error("Outbox coordinator not set");return m.registerRetry(e.payload.uuid),!1}function cA(t,e,s){var n;return(n=Ae())==null?void 0:n.peek()}function rA(t,e){return Ge().dispatch(ml(new Date().getTime())),Rn}const Pe="An unknown error occurred",oA=500,cu=["non_field_errors","detail"];function dA(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"?cu.includes(a)?c:`${a}: ${c}`:Array.isArray(c)?cu.includes(a)?c.join(`
|
|
6
6
|
`):c.map(r=>`${a}: ${r}`).join(`
|
|
7
7
|
`):`${a}: ${JSON.stringify(c)}`).join(`
|
|
8
|
-
`)}catch(a){console.error("Failed to extract error message from response body",a)}}else typeof t.body=="string"&&(s=t.body);else t!=null&&t.text?s=t.text:e instanceof Error&&(s=e.message);return!s||s.length>oA?Pe:s}class j extends Error{constructor(s){super(Pe);g(this,"status");g(this,"response");g(this,"message");g(this,"options");const{response:n,innerError:a}=s;this.message=s.message??dA(n,a)??Pe,this.status=(n==null?void 0:n.status)??0,this.response=n,s.discard=s.discard??!1,this.options=s}}class lA{constructor(e){g(this,"store");this.store=e}async enqueueRequest(e,s,n){return this._enqueueRequest(e,s,n).then(a=>{if(a instanceof j)throw a;return a})}_enqueueRequest(e,s,n){const a=new
|
|
9
|
-
Converting error to APIError and discarding.`),o=new j({message:"An error occurred while processing the request.",innerError:o,discard:!0})),a.reject(o)};r.then(d,m)}return a}}class Oe{constructor(){g(this,"graph");g(this,"requestAttemptCounter");this.graph=new mu.DepGraph,this.requestAttemptCounter={}}static _fromOutbox(e){const s=new Oe;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(d=>a.payload.blockers.includes(d))&&Oe._addDependency(a.payload.uuid,r.payload.uuid,s.graph)}}return s}_addDependency(e,s){Oe._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 uA=(t,e)=>{const s=new e(t);return Lp(s),Gp(t),s};class R extends Kl{constructor(s,n){super(s);g(this,"auth");this.auth=n}}class hA extends R{async startConversation(e,s){return this.enqueueRequest({description:"Start agent conversation",method:u.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:s},blockers:["prompt"],blocks:["prompt"]}).then(n=>(this.dispatch(Vn(n)),n))}async continueConversation(e,s,n){return this.enqueueRequest({description:"Prompt agent",method:u.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:n},blockers:["prompt"],blocks:["prompt"],queryParams:{conversation_id:s}}).then(a=>{this.dispatch(Un(a))})}async fetchDetails(e){return this.enqueueRequest({description:"Get agent conversation",method:u.GET,url:`/agents/conversations/${e}/`,blockers:["conversation"],blocks:["conversation"]}).then(s=>{this.dispatch(Cn(s))})}async rate(e,s){return this.enqueueRequest({description:"Rate agent response",method:u.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:u.GET,url:`/projects/${e}/agent-conversations/`,blockers:["agent-conversations"],blocks:["agent-conversations"]});this.dispatch(zn(s))}}class E extends R{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:n,assetTypeAttachmentReducer:a,documentAttachmentReducer:c,projectAttachmentReducer:r,formRevisionAttachmentReducer:d,formSubmissionAttachmentReducer:m,geoImageReducer:o,assetTypeFieldsAttachmentReducer:h,assetTypeFieldValuesAttachmentReducer:f,issueTypeFieldsAttachmentReducer:p,issueTypeFieldValuesAttachmentReducer:A}=this.client.store.getState();return[].concat(Object.values(s.instances),Object.values(n.instances),Object.values(a.instances),Object.values(c.instances),Object.values(r.instances),Object.values(d.instances),Object.values(m.instances),Object.values(o.instances),Object.values(h.instances),Object.values(f.instances),Object.values(p.instances),Object.values(A.instances)).filter(T=>T.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:u.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:n,blockers:[`s3-${a.fields.key}`],blocks:[n],s3url:a});return s}async getFilePayload(e){const s=await be(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 Le extends E{async _bulkAdd(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,a=new Date().toISOString(),c=[],r=[],d={};for(const h of e){const{modelId:f,file:p}=h,A=await this.getFilePayload(p);A.sha1 in d||(d[A.sha1]=A);const _=this.buildOfflineAttachment({file:p,file_sha1:A.sha1,submitted_at:a,created_by:n,description:"",modelId:f});c.push(_),r.push(this.buildAttachmentPayload({offline_id:_.offline_id,file_name:_.file_name,file_sha1:_.file_sha1,file_extension:A.extension,description:_.description,modelId:f}))}this.dispatch(this.addAttachments(c));const m=this.enqueueRequest({description:`Add ${this.name}`,method:u.POST,url:`${this.url}/bulk/`,payload:{submitted_at:a,attachments:r,files:Object.values(d)},blocks:c.map(h=>h.offline_id),blockers:c.map(h=>h.file_sha1)});return m.then(({attachments:h,presigned_urls:f})=>{this.dispatch(this.updateAttachments(h)),this.processPresignedUrls(f)}).catch(()=>{this.dispatch(this.removeAttachments(c.map(h=>h.offline_id)))}),[c,m.then(({attachments:h})=>h)]}async _delete(e){const{store:s}=this.client,n=this.selectAttachment(e)(s.getState());if(!n)throw new Error(`Attempting to delete attachment with offline_id ${e} that does not exist in the store`);this.dispatch(this.removeAttachment(n.offline_id));const a=this.enqueueRequest({description:`Delete ${this.name}`,method:u.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 mA extends Le{constructor(){super(...arguments);g(this,"name","Asset Attachment");g(this,"url","/asset-attachments");g(this,"initializeAttachments",Et);g(this,"addAttachments",jt);g(this,"updateAttachments",Ln);g(this,"removeAttachments",qt);g(this,"removeAttachment",Nn);g(this,"setAttachment",Gn);g(this,"selectAttachment",Wn)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset:s.modelId})}buildAttachmentPayload(s){return{...s,asset:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.assetId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get asset attachments",method:u.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blocks:[],blockers:[]});this.dispatch(Et(n))}}class fA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,fields_revision:h};r.push(T)}this.dispatch(Zn(c));const d=this.enqueueRequest({description:"Add asset procedure fields attachments",method:u.POST,url:"/asset-procedure-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.fields_revision),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(Qn(o.attachments))}).catch(()=>{this.dispatch(xn(c.map(o=>o.offline_id)))}),[c,d.then(({attachments:o})=>o)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure fields attachments",method:u.GET,url:"/asset-procedure-fields-attachments/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Xn(s))}}class pA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(aa(c));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:u.POST,url:"/asset-procedure-fields/",payload:c,blockers:[c.asset_procedure],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(ca(m))}).catch(m=>{throw this.dispatch(ra(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:u.GET,url:"/asset-procedure-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(na(s))}}function Ne(t,e){const s=[];let n=0;const a=t.length;for(;n<a;)s.push(t.slice(n,n+=e));return s}class AA extends E{async bulkAdd(e,s){var o;const n=new Date().toISOString(),a=(o=this.client.store.getState().userReducer.currentUser)==null?void 0:o.id,c=Ne(e,s??e.length),r=[],d=[];for(const h of c){const f={},p=[];for(const A of h){const{fieldValuesId:_,fieldIdentifier:T,file:b}=A,P=await this.getFilePayload(b);P.sha1 in f||(f[P.sha1]=P);const q=F({file:URL.createObjectURL(b),file_type:b.type,file_name:b.name,file_sha1:P.sha1,created_by:a,field_values:_,submitted_at:n,field_identifier:T});r.push(q);const St={offline_id:q.offline_id,file_name:b.name,file_sha1:P.sha1,file_extension:P.extension,field_identifier:T,field_values:_};p.push(St)}d.push({submitted_at:n,attachments:p,files:Object.values(f)})}this.dispatch(We(r));const m=d.map(h=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:u.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:h,blockers:h.attachments.map(f=>f.field_values),blocks:h.attachments.map(f=>f.offline_id)}));return Promise.all(m).then(h=>{for(const p of h)this.processPresignedUrls(p.presigned_urls);const f=h.flatMap(p=>p.attachments);this.dispatch(ha(f))}).catch(h=>{throw this.dispatch(Ke(r.map(f=>f.offline_id))),h}),[r,m.map(h=>h.then(({attachments:f})=>f))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=fa(e)(n);this.dispatch(Ke(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:u.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(We(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values attachments",method:u.GET,url:"/asset-procedure-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(ua(s))}}const yA=t=>Array.isArray(t)&&t[0]instanceof File,ve=t=>{const e={},s={};for(const n in t){const a=t[n];a instanceof File?e[n]=[a]:yA(a)?e[n]=a:a!==void 0&&(s[n]=a)}return{values:s,files:e}};class SA extends E{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add form submission",method:u.POST,url:"/form-submissions/",payload:a,blockers:["add-form-entry",e.form_revision,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[a.offline_id]});return this.dispatch(ni(a)),c.then(d=>(this.dispatch(nt(d)),d)).catch(()=>{this.dispatch(ai(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=oi(e.offline_id)(n);if(!a)throw new Error(`Expected submission with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(Jr(c));const r=this.enqueueRequest({description:"Delete user form submissions",method:u.PATCH,url:`/form-submissions/${c.offline_id}/`,payload:e,blockers:[c.offline_id],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(nt(d))}).catch(()=>{this.dispatch(nt(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=oi(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=Hr(e)(n);this.dispatch(ai(e)),this.dispatch(it(c.map(r=>r.offline_id)));try{return await this.enqueueRequest({description:"Delete user form submissions",method:u.DELETE,url:`/form-submissions/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ni(a)),this.dispatch(st(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch form submissions",method:u.GET,url:"/form-submissions/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Yr(s))}}class gA extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset procedure field values",method:u.POST,url:"/asset-procedure-field-values/",payload:a,blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[a.offline_id]});return this.dispatch($t(a)),c.then(d=>(this.dispatch(Ee(d)),d)).catch(()=>{this.dispatch(Bt(a.offline_id))}),[a,c]}bulkAdd(e,s){var o;const n=new Date().toISOString(),{values:a}=ve(e.values),c=[],r=Ne(e.payloads,s??e.payloads.length),d=[];for(const h of r){const f=[];for(const p of h){const A=F({...p,values:ve(p.values).values,created_by:(o=this.client.store.getState().userReducer.currentUser)==null?void 0:o.id,submitted_at:n});c.push(A),f.push({offline_id:A.offline_id,asset:p.asset,fields_revision:p.fields_revision,asset_procedure_instance:p.asset_procedure_instance,published_at:p.published_at,values:A.values})}d.push({submitted_at:n,values:a,field_values:f})}this.dispatch(ga(c));const m=[];for(const h of d){const f=h.field_values.map(b=>b.asset),p=h.field_values.map(b=>b.fields_revision),A=h.field_values.map(b=>b.asset_procedure_instance),_=h.field_values.map(b=>b.offline_id),T=this.enqueueRequest({description:"Bulk add asset procedure field values",method:u.POST,url:"/asset-procedure-field-values/bulk/",payload:h,blockers:[...f,...p,...A],blocks:_});m.push(T)}return Promise.all(m).then(h=>{this.dispatch(ba(h.flat()))}).catch(()=>{this.dispatch(_a(c.map(h=>h.offline_id)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=Lt(e.offline_id)(n);if(!a)throw new Error(`Expected AssetProcedureFieldValues with offline_id ${e.offline_id} to exist`);const{values:c}=ve(e.values??{}),r={...a,...e,values:{...a.values,...c}};this.dispatch(Ee(r));const d=this.enqueueRequest({description:"Update asset procedure field values",method:u.PATCH,url:`/asset-procedure-field-values/${e.offline_id}/`,payload:{...e,values:{...a.values,...c}},blockers:[r.fields_revision,r.asset,r.asset_procedure_instance],blocks:[r.offline_id]});return d.then(m=>{this.dispatch(Ee(m))}).catch(()=>{this.dispatch(Ee(a))}),[r,d]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Lt(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=pa(e)(n);this.dispatch(Bt(e)),this.dispatch(Ke(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete asset procedure field values",method:u.DELETE,url:`/asset-procedure-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch($t(a)),this.dispatch(We(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values",method:u.GET,url:"/asset-procedure-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Sa(s))}}class bA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Ht(c));const r=this.enqueueRequest({description:"Create asset procedure instance",method:u.POST,url:"/asset-procedure-instances/",payload:{...c},blockers:[e.asset_procedure,e.asset_type],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(je(d))}).catch(()=>{this.dispatch(Wt(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=Jt(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset procedure instance with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(je(a));const c=this.enqueueRequest({description:"Update asset procedure instance",method:u.PATCH,url:`/asset-procedure-instances/${e.offline_id}/`,payload:{asset_procedure:e.asset_procedure,asset_type:e.asset_type},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(je(r))}).catch(()=>{this.dispatch(je(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=Jt(e)(n);if(!a)throw new Error(`Expected asset procedure instance with offline_id ${e} to exist`);return this.dispatch(Wt(e)),this.enqueueRequest({description:"Delete asset procedure instance",method:u.DELETE,url:`/asset-procedure-instances/${e}/`,blockers:[e],blocks:[]}).catch(c=>{throw this.dispatch(Ht(a)),c})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure instances",method:u.GET,url:"/asset-procedure-instances/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Ra(s))}}class _A extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Zt(c));const r=this.enqueueRequest({description:"Create asset procedure",method:u.POST,url:"/asset-procedures/",queryParams:{organization_id:e.organization.toString()},payload:{...c},blockers:[],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(qe(d))}).catch(()=>{this.dispatch(Qt(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=es(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset procedure with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(qe(a));const c=this.enqueueRequest({description:"Update asset procedure",method:u.PATCH,url:`/asset-procedures/${e.offline_id}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(qe(r))}).catch(()=>{this.dispatch(qe(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=es(e)(n);if(!a)throw new Error(`Expected asset procedure with offline_id ${e} to exist`);const c=va(e)(n);return this.dispatch(Qt(e)),this.dispatch(Oa(c.map(r=>r.offline_id))),this.enqueueRequest({description:"Delete asset procedure",method:u.DELETE,url:`/asset-procedures/${e}/`,blockers:[e],blocks:[]}).catch(r=>{throw this.dispatch(Zt(a)),this.dispatch(Pa(c)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedures",method:u.GET,url:"/asset-procedures/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(ja(s))}}class TA extends R{add(e){const{store:s}=this.client;if(!e.canvas_marker&&!e.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");const n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(ss(c));const r=this.enqueueRequest({description:"Create asset",method:u.POST,url:"/assets/",payload:c,blockers:[c.asset_type],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(Me(d))}).catch(()=>{this.dispatch(ns(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=rs(e.offline_id)(s.getState());if(!n)throw new Error(`No asset with id ${e.offline_id} found in the store`);const a={...n,...e};if(!a.canvas_marker&&!a.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");this.dispatch(Me(a));const c=this.enqueueRequest({description:"Edit asset",method:u.PATCH,url:`/assets/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.then(r=>{this.dispatch(Me(r))}).catch(()=>{this.dispatch(Me(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=rs(e)(n);if(!a)throw new Error(`No asset with id ${e} found in the store`);const c=Kn(e)(n),r=Qr(e)(n),d=yo(e)(n);if(this.dispatch(ns(e)),c.length>0){const m=c.map(({offline_id:o})=>o);this.dispatch(qt(m))}if(r.length>0){const m=r.map(({offline_id:o})=>o);this.dispatch(ct(m))}if(d.length>0){const m=d.map(({offline_id:o})=>o);this.dispatch(Ai(m))}return this.enqueueRequest({description:"Delete asset",method:u.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(ss(a)),this.dispatch(jt(c)),this.dispatch(at(r)),this.dispatch(fi(d)),m})}bulkAdd(e,s,n,a){const c=new Date().toISOString(),r=O.v4(),d=Ne(e,a).map(h=>{const f=h.map(p=>F(p));return{batchId:O.v4(),payload:{transaction_id:r,submitted_at:c,asset_type:s,project:n,assets:f}}}),m=[];let o=null;for(const h of d){const{batchId:f,payload:p}=h,A=p.assets.map(P=>P.offline_id),_=[s];o&&_.push(o);const T=A;T.push(f);const b=this.enqueueRequest({description:"Batch create assets",method:u.POST,url:"/assets/bulk/",payload:p,blockers:_,blocks:T});o=h.batchId,m.push(b)}return Promise.all(m).then(h=>{const f=h.flat();this.dispatch(is(f))}),m}async refreshStore(e){const s=await this.enqueueRequest({description:"Get assets",method:u.GET,url:"/assets/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Da(s))}}class FA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(ds(c));const r=this.enqueueRequest({description:"Add asset stage completion",method:u.POST,url:"/asset-stage-completions/",payload:{offline_id:c.offline_id,submitted_at:a,asset_procedure_instance:e.asset_procedure_instance,asset:e.asset,stage:e.stage},blockers:[e.asset_procedure_instance,e.stage],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(Ba(d))}).catch(()=>{this.dispatch(us(c.offline_id))}),[c,r]}delete(e){const{store:s}=this.client,n=Na(e)(s.getState());if(!n)throw new Error(`Expected asset stage completion with id ${e} to exist`);this.dispatch(us(e));const a=this.enqueueRequest({description:"Delete asset stage completion",method:u.DELETE,url:`/asset-stage-completions/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(ds(n))}),a}bulkAdd(e){const{store:s}=this.client,n=new Date().toISOString(),a=s.getState().userReducer.currentUser.id,c=e.map(o=>F(o)),r=c.map(o=>({...o,created_by:a,submitted_at:n})),d=r.map(({offline_id:o})=>o);this.dispatch(ls(r));const m=this.enqueueRequest({description:"Bulk create asset stage completions",method:u.POST,url:"/asset-stage-completions/bulk/",payload:{submitted_at:n,completions:c},blockers:[...e.map(o=>o.asset_procedure_instance),...e.map(o=>o.stage),...e.map(o=>o.asset)],blocks:d});return m.then(o=>{this.dispatch(Ga(o))}).catch(()=>{this.dispatch(hs(d))}),[r,m]}bulkDelete(e){const{store:s}=this.client,n=Ha(e)(s.getState());this.dispatch(hs(e));const a=this.enqueueRequest({description:"Deleting asset stage completions",method:u.DELETE,url:"/asset-stage-completions/bulk/",payload:{completion_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(ls(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stage completions",method:u.GET,url:"/asset-stage-completions/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch($a(s))}}class IA extends R{bulkAdd(e,s){const n=new Date().toISOString(),a=this.client.store.getState().userReducer.currentUser.id,c=e.map(m=>F(m)),r=c.map(m=>({...m,asset_procedure:s,created_by:a,submitted_at:n}));this.dispatch(ps(r));const d=this.enqueueRequest({description:"Add asset stages",method:u.POST,url:"/asset-stages/bulk/",payload:{submitted_at:n,asset_procedure:s,stages:c},blockers:[s],blocks:c.map(({offline_id:m})=>m)});return d.then(m=>{this.dispatch(Ye(m))}).catch(()=>{this.dispatch(ys(r.map(({offline_id:m})=>m)))}),[r,d]}async bulkUpdate(e,s){const a=this.client.store.getState(),c=Ss(e.map(({offline_id:r})=>r))(a);return this.dispatch(Ye(e)),this.enqueueRequest({description:"Edit asset stages",method:u.PATCH,url:`/asset-procedures/${s}/bulk-update-stages/`,payload:{stages:e},blockers:[s],blocks:e.map(({offline_id:r})=>r)}).catch(r=>{throw this.dispatch(Ye(c)),r})}async bulkDelete(e){const{store:s}=this.client,n=Ss(e)(s.getState());this.dispatch(ys(e));const a=this.enqueueRequest({description:"Delete asset stages",method:u.DELETE,url:"/asset-stages/bulk/",payload:{stage_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(ps(n))}),a}update(e){const{store:s}=this.client,n=Xa(e.offline_id)(s.getState());if(!n)throw new Error(`No asset stage with id ${e.offline_id} found in the store`);const a={...n,...e};this.dispatch(As(a));const c=this.enqueueRequest({description:"Update asset stage",method:u.PATCH,url:`/asset-stages/${n.offline_id}/`,payload:{name:e.name,description:e.description,priority:e.priority,color:e.color},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(As(r))}).catch(()=>{this.dispatch(Ya(n))}),[a,c]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stages",method:u.GET,url:"/asset-stages/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Ka(s))}}class RA extends Le{constructor(){super(...arguments);g(this,"name","Asset Type Attachment");g(this,"url","/asset-type-attachments");g(this,"addAttachments",bs);g(this,"updateAttachments",tc);g(this,"removeAttachments",_s);g(this,"removeAttachment",sc);g(this,"setAttachment",ec);g(this,"selectAttachment",nc)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset_type:s.modelId})}buildAttachmentPayload(s){return{...s,asset_type:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.assetTypeId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get asset type attachments",method:u.GET,url:`${this.url}/`,queryParams:{organization:s.toString()},blocks:[],blockers:[]});this.dispatch(xa(n))}}class PA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,fields_revision:h};r.push(T)}this.dispatch(dc(c));const d=this.enqueueRequest({description:"Add asset type fields attachments",method:u.POST,url:"/asset-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.fields_revision),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(lc(o.attachments))}).catch(()=>{this.dispatch(uc(c.map(o=>o.offline_id)))}),[c,d.then(({attachments:o})=>o)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type fields attachments",method:u.GET,url:"/asset-type-fields-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(oc(s))}}class OA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(yc(c));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:u.POST,url:"/asset-type-fields/",payload:c,blockers:[c.asset_type],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(Sc(m))}).catch(m=>{throw this.dispatch(gc(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Type Fields",method:u.GET,url:"/asset-type-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Ac(s))}}class vA extends E{async bulkAdd(e,s){var o;const n=new Date().toISOString(),a=(o=this.client.store.getState().userReducer.currentUser)==null?void 0:o.id,c=Ne(e,s??e.length),r=[],d=[];for(const h of c){const f={},p=[];for(const A of h){const{fieldValuesId:_,fieldIdentifier:T,file:b}=A,P=await this.getFilePayload(b);P.sha1 in f||(f[P.sha1]=P);const q=F({file:URL.createObjectURL(b),file_type:b.type,file_name:b.name,file_sha1:P.sha1,created_by:a,field_values:_,submitted_at:n,field_identifier:T});r.push(q);const St={offline_id:q.offline_id,file_name:b.name,file_sha1:P.sha1,file_extension:P.extension,field_identifier:T,field_values:_};p.push(St)}d.push({submitted_at:n,attachments:p,files:Object.values(f)})}this.dispatch(Ze(r));const m=d.map(h=>this.enqueueRequest({description:"Add asset type field values attachments",method:u.POST,url:"/asset-type-field-values-attachments/bulk/",payload:h,blockers:h.attachments.map(f=>f.field_values),blocks:h.attachments.map(f=>f.offline_id)}));return Promise.all(m).then(h=>{for(const p of h)this.processPresignedUrls(p.presigned_urls);const f=h.flatMap(p=>p.attachments);this.dispatch(Ic(f))}).catch(h=>{throw this.dispatch(Qe(r.map(f=>f.offline_id))),h}),[r,m.map(h=>h.then(({attachments:f})=>f))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Pc(e)(n);this.dispatch(Qe(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:u.DELETE,url:"/asset-type-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 type field values attachments",method:u.GET,url:"/asset-type-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Fc(s))}}class wA extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset type field values",method:u.POST,url:"/asset-type-field-values/",payload:a,blockers:[e.asset,e.fields_revision],blocks:[a.offline_id]});return this.dispatch(vs(a)),c.then(d=>(this.dispatch(ke(d)),d)).catch(()=>{this.dispatch(ws(a.offline_id))}),[a,c]}bulkAdd(e,s){var o;const n=new Date().toISOString(),{values:a}=ve(e.values),c=[],r=Ne(e.payloads,s??e.payloads.length),d=[];for(const h of r){const f=[];for(const p of h){const A=F({...p,values:ve(p.values).values,created_by:(o=this.client.store.getState().userReducer.currentUser)==null?void 0:o.id,submitted_at:n});c.push(A),f.push({offline_id:A.offline_id,asset:p.asset,fields_revision:p.fields_revision,published_at:p.published_at,values:A.values})}d.push({submitted_at:n,values:a,field_values:f})}this.dispatch(jc(c));const m=[];for(const h of d){const f=h.field_values.map(T=>T.asset),p=h.field_values.map(T=>T.fields_revision),A=h.field_values.map(T=>T.offline_id),_=this.enqueueRequest({description:"Bulk add asset type field values",method:u.POST,url:"/asset-type-field-values/bulk/",payload:h,blockers:[...f,...p],blocks:A});m.push(_)}return Promise.all(m).then(h=>{this.dispatch(qc(h.flat()))}).catch(()=>{this.dispatch(Mc(c.map(h=>h.offline_id)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=js(e.offline_id)(n);if(!a)throw new Error(`Expected AssetTypeFieldValues with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(ke(c));const r=this.enqueueRequest({description:"Delete asset type field values",method:u.PATCH,url:`/asset-type-field-values/${e.offline_id}/`,payload:e,blockers:[c.offline_id,c.fields_revision,c.asset],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(ke(d))}).catch(()=>{this.dispatch(ke(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=js(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=Oc(e)(n);this.dispatch(ws(e)),this.dispatch(Qe(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete asset type field values",method:u.DELETE,url:`/asset-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(vs(a)),this.dispatch(Ze(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values",method:u.GET,url:"/asset-type-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Ec(s))}}class EA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Ms(c));const r=this.enqueueRequest({description:"Create asset type",method:u.POST,url:"/asset-types/",payload:c,blockers:[],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(De(d))}).catch(()=>{this.dispatch(ks(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=zs(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset type with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(De(a));const c=this.enqueueRequest({description:"Update asset type",method:u.PATCH,url:`/asset-types/${e.offline_id}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(De(r))}).catch(()=>{this.dispatch(De(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=zs(e)(n);if(!a)throw new Error(`Expected asset type with offline_id ${e} to exist`);const c=cs(e)(n),r=ac(e)(n);return this.dispatch(ks(e)),this.dispatch(za(c.map(d=>d.offline_id))),this.dispatch(_s(r.map(({offline_id:d})=>d))),this.enqueueRequest({description:"Delete asset type",method:u.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(d=>{throw this.dispatch(Ms(a)),this.dispatch(is(c)),this.dispatch(bs(r)),d})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset types",method:u.GET,url:"/asset-types/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Vc(s))}}class jA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Cs(c));const r=this.enqueueRequest({description:"Create Category",method:u.POST,url:"/categories/",payload:c,blockers:[e.project.toString()],blocks:[c.offline_id]});return[c,r]}update(e){const s=this.client.store.getState(),n=$s(e.offline_id)(s);if(!n)throw new Error(`Expected an existing category with offline_id ${e.offline_id}`);const a={...n,...e};this.dispatch(Nc(a));const c=this.enqueueRequest({description:"Edit Category",method:u.PATCH,url:`/categories/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return[a,c]}remove(e){const{store:s}=this.client,n=$s(e)(s.getState());if(!n)throw new Error(`No category with id ${e} found in the store`);this.dispatch(Hc(e));const a=this.enqueueRequest({description:"Delete Category",method:u.DELETE,url:`/categories/${n.offline_id}/`,blockers:[n.offline_id],blocks:[]});return a.catch(()=>{this.dispatch(Cs(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get categories",method:u.GET,url:"/categories/",queryParams:{project:e.toString()},blocks:[],blockers:[]});this.dispatch(Lc(s))}}class qA extends Le{constructor(){super(...arguments);g(this,"name","Document Attachment");g(this,"url","/document-attachments");g(this,"addAttachments",Jc);g(this,"updateAttachments",Zc);g(this,"removeAttachments",xc);g(this,"removeAttachment",Qc);g(this,"setAttachment",Xc);g(this,"selectAttachment",tr)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,document:s.modelId})}buildAttachmentPayload(s){return{...s,document:s.modelId}}async bulkAdd(s){var f;const{store:n}=this.client,a=(f=n.getState().userReducer.currentUser)==null?void 0:f.id,c=new Date().toISOString(),r=[],d=[],m={},o={};for(const p of s){const{documentId:A,file:_}=p,T=await this.getFilePayload(_);T.sha1 in m||(m[T.sha1]=T,o[T.sha1]=[]);const b=this.buildOfflineAttachment({file:_,file_sha1:T.sha1,submitted_at:c,created_by:a,description:"",modelId:A});r.push(b),d.push({offline_id:b.offline_id,file_name:b.file_name,file_sha1:b.file_sha1,file_extension:T.extension,description:b.description,document:A}),o[T.sha1].push(b.offline_id)}this.dispatch(this.addAttachments(r));const h=this.enqueueRequest({description:"Attach files to document",method:u.POST,url:"/document-attachments/bulk/",payload:{submitted_at:c,attachments:d,files:Object.values(m)},blocks:r.map(p=>p.offline_id),blockers:r.map(p=>p.file_sha1)});return h.then(({attachments:p,presigned_urls:A})=>{this.dispatch(this.updateAttachments(p));const _=this.processPresignedUrls(A);for(const[T,b]of Object.entries(_))b.then(()=>{const P=o[T];for(const q of P)this.makeReadable(q)})}).catch(()=>{this.dispatch(this.removeAttachments(r.map(p=>p.offline_id)))}),[r,h.then(({attachments:p})=>p)]}async delete(s){return this._delete(s)}makeReadable(s){this.enqueueRequest({description:"Add attachment to AI assistant",method:u.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:u.GET,url:`/projects/${s}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(Yc(a));const c=await this.enqueueRequest({description:"Get document attachments",method:u.GET,url:`/organizations/${n}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(this.addAttachments(c))}}class MA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Ns([c]));const r=this.enqueueRequest({description:"Create Document",method:u.POST,url:"/documents/",payload:c,queryParams:{parent_document:c.parent_document??void 0},blockers:c.parent_document?[c.parent_document]:[],blocks:[c.offline_id]});return r.catch(()=>{this.dispatch(Hs([c.offline_id]))}),[c,r]}update(e){const{store:s}=this.client,n=s.getState().documentsReducer.documents[e.offline_id];if(!n)throw new Error(`attempting to update a document with offline_id ${e.offline_id} that does not exist in store.documents`);const a={...n,...e};this.dispatch(le([a]));const c=this.enqueueRequest({description:"Update Document",method:u.PATCH,url:`/documents/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.catch(()=>{le([n])}),[a,c]}move(e,s,n){const{store:a}=this.client,c=_e(a.getState()),r=[],d=c[e];if(!d)throw new Error(`attempting to move a document with offline_id ${e} that does not exist in store.documents`);if(r.push(d),d.parent_document&&r.push(c[d.parent_document]),s){const o=c[s];if(!o)throw new Error(`attempting to move a document to target with offline_id ${s} that does not exist in store.documents`);r.push(o),o.parent_document&&r.push(c[o.parent_document])}this.dispatch(ar({documentId:e,targetDocumentId:s,position:n}));const m=this.enqueueRequest({description:"Move Document",method:u.PATCH,url:`/documents/${e}/move/`,queryParams:{target:s??void 0,position:n},blockers:[e],blocks:[]});return m.then(o=>{this.dispatch(le(o))}).catch(()=>{this.dispatch(le(r))}),m}delete(e){const{store:s}=this.client,n=_e(s.getState()),a=rr(e)(s.getState());if(!a)throw new Error(`attempting to delete a document with offline_id ${e} that does not exist in store.documents`);const c=a.parent_document?n[a.parent_document]:void 0;this.dispatch(Hs([e]));const r=this.enqueueRequest({description:"Delete Document",method:u.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return r.then(d=>{this.dispatch(le(d))}).catch(()=>{this.dispatch(le([a])),c&&this.dispatch(le([c]))}),r}async refreshStore(e,s){const n=this.enqueueRequest({description:"Get project documents",method:u.GET,url:`/projects/${e}/documents/`,blockers:[],blocks:[]}),a=this.enqueueRequest({description:"Get organization documents",method:u.GET,url:`/organizations/${s}/documents/`,blockers:[],blocks:[]});this.dispatch(nr(await n)),this.dispatch(Ns(await a))}}class kA extends R{async add(e,s){return this.enqueueRequest({description:"Add email domain to organization",method:u.POST,url:`/organizations/${e}/email-domains/`,payload:{email:s},blockers:[e.toString(),"create-org"],blocks:[]})}async remove(e){return this.dispatch(ur(e.offline_id)),this.enqueueRequest({description:"Remove email domain from organization",method:u.DELETE,url:`/organizations/${e.organization}/email-domains/${e.offline_id}/`,blockers:[e.domain],blocks:[]}).catch(s=>{throw this.dispatch(lr(e)),s})}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch email domains for organization",method:u.GET,url:`/organizations/${e}/email-domains/`,blockers:[e.toString()],blocks:[]});this.dispatch(dr(s))}}class DA extends R{async getVerificationCode(e){return this.enqueueRequest({description:"Get verification code",method:u.GET,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}validateVerificationCode(e,s=void 0){return this.enqueueRequest({description:"Validate verification code",method:u.POST,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,payload:s,blockers:[],blocks:[]})}}const At={},An=new Set;let yt=0,yn=0,Sn=0;const zA=20;class VA extends R{constructor(){super(...arguments);g(this,"host");g(this,"_dbPromise",fu.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 Pt(n,s),c=await this.enqueueRequest({description:"Get S3 URL",method:u.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await be(n),file_type:n.type,extension:n.name.split(".").pop(),size:n.size.toString()},blockers:[],blocks:[`s3-${a}`]});return"url"in c&&this.dispatch(yr({sha1:s,...c})),c}async addCache(s,n){if(An.has(n))return;if(!s.type){const r=s.name.split("."),d=r[r.length-1];s=new File([s],s.name,{type:d})}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),yt++):(await a.put("files",s,n),yn++),An.add(n),Sn++,Sn%zA===0&&console.debug(`File cache summary: ${yt} hits and ${yn} misses, ${yt/(yt+yn)*100}% hit rate over ${Sn} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),An.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const n=this.client.store.getState();return Sr(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 Pt(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 d=r.url,m=this.enqueueRequest({url:d,description:"Upload file",method:u.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 jn(s),f=new File([h],a??n,{type:h.type});return await this.addCache(f,n),f}let d=At[c],m=!0;d?m=!1:(d=new Promise(h=>{this.enqueueRequest({description:"Download file",method:u.GET,url:s,isExternalUrl:!0,isResponseBlob:!0,isAuthNeeded:!1,blockers:[n],blocks:[n]}).then(f=>{const p=new File([f],a??n,{type:f.type});h(p)})}),At[c]=d);let o;try{o=await d}catch(h){throw m&&h instanceof j&&delete At[c],h}if(m){const h=await be(o);if(h!==n){const A=`The hash of the file returned from the server (${h}) does not match the
|
|
8
|
+
`)}catch(a){console.error("Failed to extract error message from response body",a)}}else typeof t.body=="string"&&(s=t.body);else t!=null&&t.text?s=t.text:e instanceof Error&&(s=e.message);return!s||s.length>oA?Pe:s}class j extends Error{constructor(s){super(Pe);g(this,"status");g(this,"response");g(this,"message");g(this,"options");const{response:n,innerError:a}=s;this.message=s.message??dA(n,a)??Pe,this.status=(n==null?void 0:n.status)??0,this.response=n,s.discard=s.discard??!1,this.options=s}}class lA{constructor(e){g(this,"store");this.store=e}async enqueueRequest(e,s,n){return this._enqueueRequest(e,s,n).then(a=>{if(a instanceof j)throw a;return a})}_enqueueRequest(e,s,n){const a=new Pn,c={...e,BASE_URL:s,serviceName:n};if(e.immediate){const r={...c,uuid:e.uuid??O.v4()},d={payload:r,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:r,BASE_URL:s,serviceName:n}}}};mn(d,this).then(m=>{a.resolve(m.body)}).catch(m=>{fn(m,d),m instanceof Error?a.reject(m):a.reject(new Error((m??Pe).toString()))})}else{const r=this.store.dispatch(ul(c)),d=o=>{if(o)a.resolve(o.body);else{const h=new j({message:"Could not get a response from the server.",response:o,discard:!0});a.reject(h)}},m=o=>{o instanceof j?o.options.discard=!0:(console.error("Received an unexpected error while processing a request:",o,`
|
|
9
|
+
Converting error to APIError and discarding.`),o=new j({message:"An error occurred while processing the request.",innerError:o,discard:!0})),a.reject(o)};r.then(d,m)}return a}}class Oe{constructor(){g(this,"graph");g(this,"requestAttemptCounter");this.graph=new mu.DepGraph,this.requestAttemptCounter={}}static _fromOutbox(e){const s=new Oe;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(d=>a.payload.blockers.includes(d))&&Oe._addDependency(a.payload.uuid,r.payload.uuid,s.graph)}}return s}_addDependency(e,s){Oe._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 uA=(t,e)=>{const s=new e(t);return Lp(s),Gp(t),s};class R extends Kl{constructor(s,n){super(s);g(this,"auth");this.auth=n}}class hA extends R{async startConversation(e,s){return this.enqueueRequest({description:"Start agent conversation",method:u.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:s},blockers:["prompt"],blocks:["prompt"]}).then(n=>(this.dispatch(zn(n)),n))}async continueConversation(e,s,n){return this.enqueueRequest({description:"Prompt agent",method:u.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:n},blockers:["prompt"],blocks:["prompt"],queryParams:{conversation_id:s}}).then(a=>{this.dispatch(Cn(a))})}async fetchDetails(e){return this.enqueueRequest({description:"Get agent conversation",method:u.GET,url:`/agents/conversations/${e}/`,blockers:["conversation"],blocks:["conversation"]}).then(s=>{this.dispatch(Vn(s))})}async rate(e,s){return this.enqueueRequest({description:"Rate agent response",method:u.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:u.GET,url:`/projects/${e}/agent-conversations/`,blockers:["agent-conversations"],blocks:["agent-conversations"]});this.dispatch(Dn(s))}}class E extends R{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:n,assetTypeAttachmentReducer:a,documentAttachmentReducer:c,projectAttachmentReducer:r,formRevisionAttachmentReducer:d,formSubmissionAttachmentReducer:m,geoImageReducer:o,assetTypeFieldsAttachmentReducer:h,assetTypeFieldValuesAttachmentReducer:f,issueTypeFieldsAttachmentReducer:p,issueTypeFieldValuesAttachmentReducer:A}=this.client.store.getState();return[].concat(Object.values(s.instances),Object.values(n.instances),Object.values(a.instances),Object.values(c.instances),Object.values(r.instances),Object.values(d.instances),Object.values(m.instances),Object.values(o.instances),Object.values(h.instances),Object.values(f.instances),Object.values(p.instances),Object.values(A.instances)).filter(T=>T.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:u.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:n,blockers:[`s3-${a.fields.key}`],blocks:[n],s3url:a});return s}async getFilePayload(e){const s=await be(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 Le extends E{async _bulkAdd(e){var o;const{store:s}=this.client,n=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,a=new Date().toISOString(),c=[],r=[],d={};for(const h of e){const{modelId:f,file:p}=h,A=await this.getFilePayload(p);A.sha1 in d||(d[A.sha1]=A);const _=this.buildOfflineAttachment({file:p,file_sha1:A.sha1,submitted_at:a,created_by:n,description:"",modelId:f});c.push(_),r.push(this.buildAttachmentPayload({offline_id:_.offline_id,file_name:_.file_name,file_sha1:_.file_sha1,file_extension:A.extension,description:_.description,modelId:f}))}this.dispatch(this.addAttachments(c));const m=this.enqueueRequest({description:`Add ${this.name}`,method:u.POST,url:`${this.url}/bulk/`,payload:{submitted_at:a,attachments:r,files:Object.values(d)},blocks:c.map(h=>h.offline_id),blockers:c.map(h=>h.file_sha1)});return m.then(({attachments:h,presigned_urls:f})=>{this.dispatch(this.updateAttachments(h)),this.processPresignedUrls(f)}).catch(()=>{this.dispatch(this.removeAttachments(c.map(h=>h.offline_id)))}),[c,m.then(({attachments:h})=>h)]}async _delete(e){const{store:s}=this.client,n=this.selectAttachment(e)(s.getState());if(!n)throw new Error(`Attempting to delete attachment with offline_id ${e} that does not exist in the store`);this.dispatch(this.removeAttachment(n.offline_id));const a=this.enqueueRequest({description:`Delete ${this.name}`,method:u.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 mA extends Le{constructor(){super(...arguments);g(this,"name","Asset Attachment");g(this,"url","/asset-attachments");g(this,"initializeAttachments",Et);g(this,"addAttachments",jt);g(this,"updateAttachments",Gn);g(this,"removeAttachments",qt);g(this,"removeAttachment",Ln);g(this,"setAttachment",Bn);g(this,"selectAttachment",Hn)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset:s.modelId})}buildAttachmentPayload(s){return{...s,asset:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.assetId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get asset attachments",method:u.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blocks:[],blockers:[]});this.dispatch(Et(n))}}class fA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,fields_revision:h};r.push(T)}this.dispatch(Xn(c));const d=this.enqueueRequest({description:"Add asset procedure fields attachments",method:u.POST,url:"/asset-procedure-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.fields_revision),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(Zn(o.attachments))}).catch(()=>{this.dispatch(Qn(c.map(o=>o.offline_id)))}),[c,d.then(({attachments:o})=>o)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure fields attachments",method:u.GET,url:"/asset-procedure-fields-attachments/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Jn(s))}}class pA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(na(c));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:u.POST,url:"/asset-procedure-fields/",payload:c,blockers:[c.asset_procedure],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(aa(m))}).catch(m=>{throw this.dispatch(ca(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:u.GET,url:"/asset-procedure-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(ia(s))}}function Ne(t,e){const s=[];let n=0;const a=t.length;for(;n<a;)s.push(t.slice(n,n+=e));return s}class AA extends E{async bulkAdd(e,s){var o;const n=new Date().toISOString(),a=(o=this.client.store.getState().userReducer.currentUser)==null?void 0:o.id,c=Ne(e,s??e.length),r=[],d=[];for(const h of c){const f={},p=[];for(const A of h){const{fieldValuesId:_,fieldIdentifier:T,file:b}=A,P=await this.getFilePayload(b);P.sha1 in f||(f[P.sha1]=P);const q=F({file:URL.createObjectURL(b),file_type:b.type,file_name:b.name,file_sha1:P.sha1,created_by:a,field_values:_,submitted_at:n,field_identifier:T});r.push(q);const St={offline_id:q.offline_id,file_name:b.name,file_sha1:P.sha1,file_extension:P.extension,field_identifier:T,field_values:_};p.push(St)}d.push({submitted_at:n,attachments:p,files:Object.values(f)})}this.dispatch(We(r));const m=d.map(h=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:u.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:h,blockers:h.attachments.map(f=>f.field_values),blocks:h.attachments.map(f=>f.offline_id)}));return Promise.all(m).then(h=>{for(const p of h)this.processPresignedUrls(p.presigned_urls);const f=h.flatMap(p=>p.attachments);this.dispatch(ua(f))}).catch(h=>{throw this.dispatch(Ke(r.map(f=>f.offline_id))),h}),[r,m.map(h=>h.then(({attachments:f})=>f))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=ma(e)(n);this.dispatch(Ke(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:u.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(We(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values attachments",method:u.GET,url:"/asset-procedure-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(la(s))}}const yA=t=>Array.isArray(t)&&t[0]instanceof File,ve=t=>{const e={},s={};for(const n in t){const a=t[n];a instanceof File?e[n]=[a]:yA(a)?e[n]=a:a!==void 0&&(s[n]=a)}return{values:s,files:e}};class SA extends E{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,index:null,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add form submission",method:u.POST,url:"/form-submissions/",payload:a,blockers:["add-form-entry",e.form_revision,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[a.offline_id]});return this.dispatch(ii(a)),c.then(d=>(this.dispatch(nt(d)),d)).catch(()=>{this.dispatch(ni(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=ri(e.offline_id)(n);if(!a)throw new Error(`Expected submission with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(Jr(c));const r=this.enqueueRequest({description:"Delete user form submissions",method:u.PATCH,url:`/form-submissions/${c.offline_id}/`,payload:e,blockers:[c.offline_id],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(nt(d))}).catch(()=>{this.dispatch(nt(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=ri(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=Hr(e)(n);this.dispatch(ni(e)),this.dispatch(it(c.map(r=>r.offline_id)));try{return await this.enqueueRequest({description:"Delete user form submissions",method:u.DELETE,url:`/form-submissions/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ii(a)),this.dispatch(st(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch form submissions",method:u.GET,url:"/form-submissions/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Yr(s))}}class gA extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset procedure field values",method:u.POST,url:"/asset-procedure-field-values/",payload:a,blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[a.offline_id]});return this.dispatch($t(a)),c.then(d=>(this.dispatch(Ee(d)),d)).catch(()=>{this.dispatch(Bt(a.offline_id))}),[a,c]}bulkAdd(e,s){var o;const n=new Date().toISOString(),{values:a}=ve(e.values),c=[],r=Ne(e.payloads,s??e.payloads.length),d=[];for(const h of r){const f=[];for(const p of h){const A=F({...p,values:ve(p.values).values,created_by:(o=this.client.store.getState().userReducer.currentUser)==null?void 0:o.id,submitted_at:n});c.push(A),f.push({offline_id:A.offline_id,asset:p.asset,fields_revision:p.fields_revision,asset_procedure_instance:p.asset_procedure_instance,published_at:p.published_at,values:A.values})}d.push({submitted_at:n,values:a,field_values:f})}this.dispatch(Sa(c));const m=[];for(const h of d){const f=h.field_values.map(b=>b.asset),p=h.field_values.map(b=>b.fields_revision),A=h.field_values.map(b=>b.asset_procedure_instance),_=h.field_values.map(b=>b.offline_id),T=this.enqueueRequest({description:"Bulk add asset procedure field values",method:u.POST,url:"/asset-procedure-field-values/bulk/",payload:h,blockers:[...f,...p,...A],blocks:_});m.push(T)}return Promise.all(m).then(h=>{this.dispatch(ga(h.flat()))}).catch(()=>{this.dispatch(ba(c.map(h=>h.offline_id)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=Lt(e.offline_id)(n);if(!a)throw new Error(`Expected AssetProcedureFieldValues with offline_id ${e.offline_id} to exist`);const{values:c}=ve(e.values??{}),r={...a,...e,values:{...a.values,...c}};this.dispatch(Ee(r));const d=this.enqueueRequest({description:"Update asset procedure field values",method:u.PATCH,url:`/asset-procedure-field-values/${e.offline_id}/`,payload:{...e,values:{...a.values,...c}},blockers:[r.fields_revision,r.asset,r.asset_procedure_instance],blocks:[r.offline_id]});return d.then(m=>{this.dispatch(Ee(m))}).catch(()=>{this.dispatch(Ee(a))}),[r,d]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Lt(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=fa(e)(n);this.dispatch(Bt(e)),this.dispatch(Ke(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete asset procedure field values",method:u.DELETE,url:`/asset-procedure-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch($t(a)),this.dispatch(We(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values",method:u.GET,url:"/asset-procedure-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(ya(s))}}class bA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,index:null,created_by:n,submitted_at:a});this.dispatch(Ht(c));const r=this.enqueueRequest({description:"Create asset procedure instance",method:u.POST,url:"/asset-procedure-instances/",payload:{...c},blockers:[e.asset_procedure,e.asset_type],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(je(d))}).catch(()=>{this.dispatch(Wt(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=Jt(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset procedure instance with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(je(a));const c=this.enqueueRequest({description:"Update asset procedure instance",method:u.PATCH,url:`/asset-procedure-instances/${e.offline_id}/`,payload:{asset_procedure:e.asset_procedure,asset_type:e.asset_type},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(je(r))}).catch(()=>{this.dispatch(je(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=Jt(e)(n);if(!a)throw new Error(`Expected asset procedure instance with offline_id ${e} to exist`);return this.dispatch(Wt(e)),this.enqueueRequest({description:"Delete asset procedure instance",method:u.DELETE,url:`/asset-procedure-instances/${e}/`,blockers:[e],blocks:[]}).catch(c=>{throw this.dispatch(Ht(a)),c})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure instances",method:u.GET,url:"/asset-procedure-instances/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Ia(s))}}class _A extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Zt(c));const r=this.enqueueRequest({description:"Create asset procedure",method:u.POST,url:"/asset-procedures/",queryParams:{organization_id:e.organization.toString()},payload:{...c},blockers:[],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(qe(d))}).catch(()=>{this.dispatch(Qt(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=es(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset procedure with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(qe(a));const c=this.enqueueRequest({description:"Update asset procedure",method:u.PATCH,url:`/asset-procedures/${e.offline_id}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(qe(r))}).catch(()=>{this.dispatch(qe(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=es(e)(n);if(!a)throw new Error(`Expected asset procedure with offline_id ${e} to exist`);const c=Oa(e)(n);return this.dispatch(Qt(e)),this.dispatch(Pa(c.map(r=>r.offline_id))),this.enqueueRequest({description:"Delete asset procedure",method:u.DELETE,url:`/asset-procedures/${e}/`,blockers:[e],blocks:[]}).catch(r=>{throw this.dispatch(Zt(a)),this.dispatch(Ra(c)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedures",method:u.GET,url:"/asset-procedures/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Ea(s))}}class TA extends R{add(e){const{store:s}=this.client;if(!e.canvas_marker&&!e.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");const n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,index:null,created_by:n,submitted_at:a});this.dispatch(ss(c));const r=this.enqueueRequest({description:"Create asset",method:u.POST,url:"/assets/",payload:c,blockers:[c.asset_type],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(Me(d))}).catch(()=>{this.dispatch(ns(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=rs(e.offline_id)(s.getState());if(!n)throw new Error(`No asset with id ${e.offline_id} found in the store`);const a={...n,...e};if(!a.canvas_marker&&!a.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");this.dispatch(Me(a));const c=this.enqueueRequest({description:"Edit asset",method:u.PATCH,url:`/assets/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.then(r=>{this.dispatch(Me(r))}).catch(()=>{this.dispatch(Me(n))}),[a,c]}async remove(e){const{store:s}=this.client,n=s.getState(),a=rs(e)(n);if(!a)throw new Error(`No asset with id ${e} found in the store`);const c=Wn(e)(n),r=Qr(e)(n),d=yo(e)(n);if(this.dispatch(ns(e)),c.length>0){const m=c.map(({offline_id:o})=>o);this.dispatch(qt(m))}if(r.length>0){const m=r.map(({offline_id:o})=>o);this.dispatch(ct(m))}if(d.length>0){const m=d.map(({offline_id:o})=>o);this.dispatch(pi(m))}return this.enqueueRequest({description:"Delete asset",method:u.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(ss(a)),this.dispatch(jt(c)),this.dispatch(at(r)),this.dispatch(mi(d)),m})}bulkAdd(e,s,n,a){const c=new Date().toISOString(),r=O.v4(),d=Ne(e,a).map(h=>{const f=h.map(p=>F(p));return{batchId:O.v4(),payload:{transaction_id:r,submitted_at:c,asset_type:s,project:n,assets:f}}}),m=[];let o=null;for(const h of d){const{batchId:f,payload:p}=h,A=p.assets.map(P=>P.offline_id),_=[s];o&&_.push(o);const T=A;T.push(f);const b=this.enqueueRequest({description:"Batch create assets",method:u.POST,url:"/assets/bulk/",payload:p,blockers:_,blocks:T});o=h.batchId,m.push(b)}return Promise.all(m).then(h=>{const f=h.flat();this.dispatch(is(f))}),m}async refreshStore(e){const s=await this.enqueueRequest({description:"Get assets",method:u.GET,url:"/assets/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(ka(s))}}class FA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(ds(c));const r=this.enqueueRequest({description:"Add asset stage completion",method:u.POST,url:"/asset-stage-completions/",payload:{offline_id:c.offline_id,submitted_at:a,asset_procedure_instance:e.asset_procedure_instance,asset:e.asset,stage:e.stage},blockers:[e.asset_procedure_instance,e.stage],blocks:[c.offline_id]});return r.then(d=>{this.dispatch($a(d))}).catch(()=>{this.dispatch(us(c.offline_id))}),[c,r]}delete(e){const{store:s}=this.client,n=La(e)(s.getState());if(!n)throw new Error(`Expected asset stage completion with id ${e} to exist`);this.dispatch(us(e));const a=this.enqueueRequest({description:"Delete asset stage completion",method:u.DELETE,url:`/asset-stage-completions/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(ds(n))}),a}bulkAdd(e){const{store:s}=this.client,n=new Date().toISOString(),a=s.getState().userReducer.currentUser.id,c=e.map(o=>F(o)),r=c.map(o=>({...o,created_by:a,submitted_at:n})),d=r.map(({offline_id:o})=>o);this.dispatch(ls(r));const m=this.enqueueRequest({description:"Bulk create asset stage completions",method:u.POST,url:"/asset-stage-completions/bulk/",payload:{submitted_at:n,completions:c},blockers:[...e.map(o=>o.asset_procedure_instance),...e.map(o=>o.stage),...e.map(o=>o.asset)],blocks:d});return m.then(o=>{this.dispatch(Ba(o))}).catch(()=>{this.dispatch(hs(d))}),[r,m]}bulkDelete(e){const{store:s}=this.client,n=Na(e)(s.getState());this.dispatch(hs(e));const a=this.enqueueRequest({description:"Deleting asset stage completions",method:u.DELETE,url:"/asset-stage-completions/bulk/",payload:{completion_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(ls(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stage completions",method:u.GET,url:"/asset-stage-completions/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Ua(s))}}class IA extends R{bulkAdd(e,s){const n=new Date().toISOString(),a=this.client.store.getState().userReducer.currentUser.id,c=e.map(m=>F(m)),r=c.map(m=>({...m,asset_procedure:s,created_by:a,submitted_at:n}));this.dispatch(ps(r));const d=this.enqueueRequest({description:"Add asset stages",method:u.POST,url:"/asset-stages/bulk/",payload:{submitted_at:n,asset_procedure:s,stages:c},blockers:[s],blocks:c.map(({offline_id:m})=>m)});return d.then(m=>{this.dispatch(Ye(m))}).catch(()=>{this.dispatch(ys(r.map(({offline_id:m})=>m)))}),[r,d]}async bulkUpdate(e,s){const a=this.client.store.getState(),c=Ss(e.map(({offline_id:r})=>r))(a);return this.dispatch(Ye(e)),this.enqueueRequest({description:"Edit asset stages",method:u.PATCH,url:`/asset-procedures/${s}/bulk-update-stages/`,payload:{stages:e},blockers:[s],blocks:e.map(({offline_id:r})=>r)}).catch(r=>{throw this.dispatch(Ye(c)),r})}async bulkDelete(e){const{store:s}=this.client,n=Ss(e)(s.getState());this.dispatch(ys(e));const a=this.enqueueRequest({description:"Delete asset stages",method:u.DELETE,url:"/asset-stages/bulk/",payload:{stage_ids:e},blockers:e,blocks:[]});return a.catch(()=>{this.dispatch(ps(n))}),a}update(e){const{store:s}=this.client,n=Ja(e.offline_id)(s.getState());if(!n)throw new Error(`No asset stage with id ${e.offline_id} found in the store`);const a={...n,...e};this.dispatch(As(a));const c=this.enqueueRequest({description:"Update asset stage",method:u.PATCH,url:`/asset-stages/${n.offline_id}/`,payload:{name:e.name,description:e.description,priority:e.priority,color:e.color},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(As(r))}).catch(()=>{this.dispatch(Ka(n))}),[a,c]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stages",method:u.GET,url:"/asset-stages/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Wa(s))}}class RA extends Le{constructor(){super(...arguments);g(this,"name","Asset Type Attachment");g(this,"url","/asset-type-attachments");g(this,"addAttachments",bs);g(this,"updateAttachments",ec);g(this,"removeAttachments",_s);g(this,"removeAttachment",tc);g(this,"setAttachment",xa);g(this,"selectAttachment",ic)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset_type:s.modelId})}buildAttachmentPayload(s){return{...s,asset_type:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.assetTypeId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get asset type attachments",method:u.GET,url:`${this.url}/`,queryParams:{organization:s.toString()},blocks:[],blockers:[]});this.dispatch(Qa(n))}}class PA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,fields_revision:h};r.push(T)}this.dispatch(oc(c));const d=this.enqueueRequest({description:"Add asset type fields attachments",method:u.POST,url:"/asset-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.fields_revision),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(dc(o.attachments))}).catch(()=>{this.dispatch(lc(c.map(o=>o.offline_id)))}),[c,d.then(({attachments:o})=>o)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type fields attachments",method:u.GET,url:"/asset-type-fields-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(rc(s))}}class OA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Ac(c));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:u.POST,url:"/asset-type-fields/",payload:c,blockers:[c.asset_type],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(yc(m))}).catch(m=>{throw this.dispatch(Sc(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Type Fields",method:u.GET,url:"/asset-type-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(pc(s))}}class vA extends E{async bulkAdd(e,s){var o;const n=new Date().toISOString(),a=(o=this.client.store.getState().userReducer.currentUser)==null?void 0:o.id,c=Ne(e,s??e.length),r=[],d=[];for(const h of c){const f={},p=[];for(const A of h){const{fieldValuesId:_,fieldIdentifier:T,file:b}=A,P=await this.getFilePayload(b);P.sha1 in f||(f[P.sha1]=P);const q=F({file:URL.createObjectURL(b),file_type:b.type,file_name:b.name,file_sha1:P.sha1,created_by:a,field_values:_,submitted_at:n,field_identifier:T});r.push(q);const St={offline_id:q.offline_id,file_name:b.name,file_sha1:P.sha1,file_extension:P.extension,field_identifier:T,field_values:_};p.push(St)}d.push({submitted_at:n,attachments:p,files:Object.values(f)})}this.dispatch(Ze(r));const m=d.map(h=>this.enqueueRequest({description:"Add asset type field values attachments",method:u.POST,url:"/asset-type-field-values-attachments/bulk/",payload:h,blockers:h.attachments.map(f=>f.field_values),blocks:h.attachments.map(f=>f.offline_id)}));return Promise.all(m).then(h=>{for(const p of h)this.processPresignedUrls(p.presigned_urls);const f=h.flatMap(p=>p.attachments);this.dispatch(Fc(f))}).catch(h=>{throw this.dispatch(Qe(r.map(f=>f.offline_id))),h}),[r,m.map(h=>h.then(({attachments:f})=>f))]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Rc(e)(n);this.dispatch(Qe(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:u.DELETE,url:"/asset-type-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 type field values attachments",method:u.GET,url:"/asset-type-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Tc(s))}}class wA extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add asset type field values",method:u.POST,url:"/asset-type-field-values/",payload:a,blockers:[e.asset,e.fields_revision],blocks:[a.offline_id]});return this.dispatch(vs(a)),c.then(d=>(this.dispatch(ke(d)),d)).catch(()=>{this.dispatch(ws(a.offline_id))}),[a,c]}bulkAdd(e,s){var o;const n=new Date().toISOString(),{values:a}=ve(e.values),c=[],r=Ne(e.payloads,s??e.payloads.length),d=[];for(const h of r){const f=[];for(const p of h){const A=F({...p,values:ve(p.values).values,created_by:(o=this.client.store.getState().userReducer.currentUser)==null?void 0:o.id,submitted_at:n});c.push(A),f.push({offline_id:A.offline_id,asset:p.asset,fields_revision:p.fields_revision,published_at:p.published_at,values:A.values})}d.push({submitted_at:n,values:a,field_values:f})}this.dispatch(Ec(c));const m=[];for(const h of d){const f=h.field_values.map(T=>T.asset),p=h.field_values.map(T=>T.fields_revision),A=h.field_values.map(T=>T.offline_id),_=this.enqueueRequest({description:"Bulk add asset type field values",method:u.POST,url:"/asset-type-field-values/bulk/",payload:h,blockers:[...f,...p],blocks:A});m.push(_)}return Promise.all(m).then(h=>{this.dispatch(jc(h.flat()))}).catch(()=>{this.dispatch(qc(c.map(h=>h.offline_id)))}),[c,m]}update(e){const{store:s}=this.client,n=s.getState(),a=js(e.offline_id)(n);if(!a)throw new Error(`Expected AssetTypeFieldValues with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(ke(c));const r=this.enqueueRequest({description:"Delete asset type field values",method:u.PATCH,url:`/asset-type-field-values/${e.offline_id}/`,payload:e,blockers:[c.offline_id,c.fields_revision,c.asset],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(ke(d))}).catch(()=>{this.dispatch(ke(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=js(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=Pc(e)(n);this.dispatch(ws(e)),this.dispatch(Qe(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete asset type field values",method:u.DELETE,url:`/asset-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(vs(a)),this.dispatch(Ze(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values",method:u.GET,url:"/asset-type-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(wc(s))}}class EA extends R{add(e){const{store:s}=this.client,n=s.getState().userReducer.currentUser.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Ms(c));const r=this.enqueueRequest({description:"Create asset type",method:u.POST,url:"/asset-types/",payload:c,blockers:[],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(De(d))}).catch(()=>{this.dispatch(ks(c.offline_id))}),[c,r]}update(e){const{store:s}=this.client,n=zs(e.offline_id)(s.getState());if(!n)throw new Error(`Expected asset type with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(De(a));const c=this.enqueueRequest({description:"Update asset type",method:u.PATCH,url:`/asset-types/${e.offline_id}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[n.offline_id],blocks:[n.offline_id]});return c.then(r=>{this.dispatch(De(r))}).catch(()=>{this.dispatch(De(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=zs(e)(n);if(!a)throw new Error(`Expected asset type with offline_id ${e} to exist`);const c=cs(e)(n),r=nc(e)(n);return this.dispatch(ks(e)),this.dispatch(Da(c.map(d=>d.offline_id))),this.dispatch(_s(r.map(({offline_id:d})=>d))),this.enqueueRequest({description:"Delete asset type",method:u.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(d=>{throw this.dispatch(Ms(a)),this.dispatch(is(c)),this.dispatch(bs(r)),d})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset types",method:u.GET,url:"/asset-types/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(zc(s))}}class jA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(Cs(c));const r=this.enqueueRequest({description:"Create Category",method:u.POST,url:"/categories/",payload:c,blockers:[e.project.toString()],blocks:[c.offline_id]});return[c,r]}update(e){const s=this.client.store.getState(),n=$s(e.offline_id)(s);if(!n)throw new Error(`Expected an existing category with offline_id ${e.offline_id}`);const a={...n,...e};this.dispatch(Lc(a));const c=this.enqueueRequest({description:"Edit Category",method:u.PATCH,url:`/categories/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return[a,c]}remove(e){const{store:s}=this.client,n=$s(e)(s.getState());if(!n)throw new Error(`No category with id ${e} found in the store`);this.dispatch(Nc(e));const a=this.enqueueRequest({description:"Delete Category",method:u.DELETE,url:`/categories/${n.offline_id}/`,blockers:[n.offline_id],blocks:[]});return a.catch(()=>{this.dispatch(Cs(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Get categories",method:u.GET,url:"/categories/",queryParams:{project:e.toString()},blocks:[],blockers:[]});this.dispatch(Gc(s))}}class qA extends Le{constructor(){super(...arguments);g(this,"name","Document Attachment");g(this,"url","/document-attachments");g(this,"addAttachments",Yc);g(this,"updateAttachments",Xc);g(this,"removeAttachments",Qc);g(this,"removeAttachment",Zc);g(this,"setAttachment",Jc);g(this,"selectAttachment",er)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,document:s.modelId})}buildAttachmentPayload(s){return{...s,document:s.modelId}}async bulkAdd(s){var f;const{store:n}=this.client,a=(f=n.getState().userReducer.currentUser)==null?void 0:f.id,c=new Date().toISOString(),r=[],d=[],m={},o={};for(const p of s){const{documentId:A,file:_}=p,T=await this.getFilePayload(_);T.sha1 in m||(m[T.sha1]=T,o[T.sha1]=[]);const b=this.buildOfflineAttachment({file:_,file_sha1:T.sha1,submitted_at:c,created_by:a,description:"",modelId:A});r.push(b),d.push({offline_id:b.offline_id,file_name:b.file_name,file_sha1:b.file_sha1,file_extension:T.extension,description:b.description,document:A}),o[T.sha1].push(b.offline_id)}this.dispatch(this.addAttachments(r));const h=this.enqueueRequest({description:"Attach files to document",method:u.POST,url:"/document-attachments/bulk/",payload:{submitted_at:c,attachments:d,files:Object.values(m)},blocks:r.map(p=>p.offline_id),blockers:r.map(p=>p.file_sha1)});return h.then(({attachments:p,presigned_urls:A})=>{this.dispatch(this.updateAttachments(p));const _=this.processPresignedUrls(A);for(const[T,b]of Object.entries(_))b.then(()=>{const P=o[T];for(const q of P)this.makeReadable(q)})}).catch(()=>{this.dispatch(this.removeAttachments(r.map(p=>p.offline_id)))}),[r,h.then(({attachments:p})=>p)]}async delete(s){return this._delete(s)}makeReadable(s){this.enqueueRequest({description:"Add attachment to AI assistant",method:u.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:u.GET,url:`/projects/${s}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(Kc(a));const c=await this.enqueueRequest({description:"Get document attachments",method:u.GET,url:`/organizations/${n}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(this.addAttachments(c))}}class MA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(nr([c]));const r=this.enqueueRequest({description:"Create Document",method:u.POST,url:"/documents/",payload:c,queryParams:{parent_document:c.parent_document??void 0},blockers:c.parent_document?[c.parent_document]:[],blocks:[c.offline_id]});return r.catch(()=>{this.dispatch(Ns([c.offline_id]))}),[c,r]}update(e){const{store:s}=this.client,n=s.getState().documentsReducer.documents[e.offline_id];if(!n)throw new Error(`attempting to update a document with offline_id ${e.offline_id} that does not exist in store.documents`);const a={...n,...e};this.dispatch(le([a]));const c=this.enqueueRequest({description:"Update Document",method:u.PATCH,url:`/documents/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.catch(()=>{le([n])}),[a,c]}move(e,s,n){const{store:a}=this.client,c=_e(a.getState()),r=[],d=c[e];if(!d)throw new Error(`attempting to move a document with offline_id ${e} that does not exist in store.documents`);if(r.push(d),d.parent_document&&r.push(c[d.parent_document]),s){const o=c[s];if(!o)throw new Error(`attempting to move a document to target with offline_id ${s} that does not exist in store.documents`);r.push(o),o.parent_document&&r.push(c[o.parent_document])}this.dispatch(ar({documentId:e,targetDocumentId:s,position:n}));const m=this.enqueueRequest({description:"Move Document",method:u.PATCH,url:`/documents/${e}/move/`,queryParams:{target:s??void 0,position:n},blockers:[e],blocks:[]});return m.then(o=>{this.dispatch(le(o))}).catch(()=>{this.dispatch(le(r))}),m}delete(e){const{store:s}=this.client,n=_e(s.getState()),a=rr(e)(s.getState());if(!a)throw new Error(`attempting to delete a document with offline_id ${e} that does not exist in store.documents`);const c=a.parent_document?n[a.parent_document]:void 0;this.dispatch(Ns([e]));const r=this.enqueueRequest({description:"Delete Document",method:u.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return r.then(d=>{this.dispatch(le(d))}).catch(()=>{this.dispatch(le([a])),c&&this.dispatch(le([c]))}),r}async refreshStore(e,s){const n=this.enqueueRequest({description:"Get project documents",method:u.GET,url:`/projects/${e}/documents/`,blockers:[],blocks:[]}),a=this.enqueueRequest({description:"Get organization documents",method:u.GET,url:`/organizations/${s}/documents/`,blockers:[],blocks:[]});this.dispatch(ir([...await n,...await a]))}}class kA extends R{async add(e,s){return this.enqueueRequest({description:"Add email domain to organization",method:u.POST,url:`/organizations/${e}/email-domains/`,payload:{email:s},blockers:[e.toString(),"create-org"],blocks:[]})}async remove(e){return this.dispatch(ur(e.offline_id)),this.enqueueRequest({description:"Remove email domain from organization",method:u.DELETE,url:`/organizations/${e.organization}/email-domains/${e.offline_id}/`,blockers:[e.domain],blocks:[]}).catch(s=>{throw this.dispatch(lr(e)),s})}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch email domains for organization",method:u.GET,url:`/organizations/${e}/email-domains/`,blockers:[e.toString()],blocks:[]});this.dispatch(dr(s))}}class DA extends R{async getVerificationCode(e){return this.enqueueRequest({description:"Get verification code",method:u.GET,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}validateVerificationCode(e,s=void 0){return this.enqueueRequest({description:"Validate verification code",method:u.POST,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,payload:s,blockers:[],blocks:[]})}}const At={},pn=new Set;let yt=0,An=0,yn=0;const zA=20;class VA extends R{constructor(){super(...arguments);g(this,"host");g(this,"_dbPromise",fu.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 Pt(n,s),c=await this.enqueueRequest({description:"Get S3 URL",method:u.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await be(n),file_type:n.type,extension:n.name.split(".").pop(),size:n.size.toString()},blockers:[],blocks:[`s3-${a}`]});return"url"in c&&this.dispatch(yr({sha1:s,...c})),c}async addCache(s,n){if(pn.has(n))return;if(!s.type){const r=s.name.split("."),d=r[r.length-1];s=new File([s],s.name,{type:d})}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),yt++):(await a.put("files",s,n),An++),pn.add(n),yn++,yn%zA===0&&console.debug(`File cache summary: ${yt} hits and ${An} misses, ${yt/(yt+An)*100}% hit rate over ${yn} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),pn.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const n=this.client.store.getState();return Sr(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 Pt(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 d=r.url,m=this.enqueueRequest({url:d,description:"Upload file",method:u.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 En(s),f=new File([h],a??n,{type:h.type});return await this.addCache(f,n),f}let d=At[c],m=!0;d?m=!1:(d=new Promise(h=>{this.enqueueRequest({description:"Download file",method:u.GET,url:s,isExternalUrl:!0,isResponseBlob:!0,isAuthNeeded:!1,blockers:[n],blocks:[n]}).then(f=>{const p=new File([f],a??n,{type:f.type});h(p)})}),At[c]=d);let o;try{o=await d}catch(h){throw m&&h instanceof j&&delete At[c],h}if(m){const h=await be(o);if(h!==n){const A=`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 offline_id 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(A)}const f=o.type.split("/")[1];if(!f)throw new Error("File has no extension");const p=a??h+"."+f;if(o=En(o,p),!o.name)throw new Error("Failed to set file's name");await this.addCache(o,h),At[c]=new Promise(A=>{A(o)})}return o}}class CA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{revisionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,form_revision:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,form_revision:h};r.push(T)}this.dispatch(Tr(c));const d=this.enqueueRequest({description:"Attach files to form revision",method:u.POST,url:"/form-revision-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.form_revision),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(Fr(o.attachments))}).catch(()=>{this.dispatch(Ir(c.map(o=>o.offline_id)))}),[c,d.then(({attachments:o})=>o)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization form revision attachments",method:u.GET,url:"/form-revision-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(_r(s))}}class UA extends E{add(e){var d;const{store:s}=this.client,a=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,c=F({...e,created_by:a,revision:"Pending",submitted_at:new Date().toISOString()});this.dispatch(Xs(c));const r=this.enqueueRequest({description:"Create form revision",method:u.POST,url:"/form-revisions/",payload:c,blockers:[e.form],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(vr(m))}).catch(()=>{this.dispatch(Zs(c.offline_id))}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization form revisions",method:u.GET,url:"/form-revisions/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(wr(s))}}const $A=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(d){console.error("Failed to get image from promise",d)}else e[r.identifier]=r.image;delete r.image}c.push(r)}s.push({...n,fields:c})}return{fields:s,images:e}};class BA extends E{add(e,s){var o;const{store:n}=this.client,a=new Date().toISOString(),c=(o=n.getState().userReducer.currentUser)==null?void 0:o.id,r=F({...e,submitted_at:a,created_by:c}),d=F({...s,form:r.offline_id,revision:"Pending",submitted_at:a,created_by:c});this.dispatch(xs(r)),this.dispatch(Xs(d));const m=this.enqueueRequest({description:"Create form",method:u.POST,url:"/forms/",payload:{...r,initial_revision:{offline_id:d.offline_id,submitted_at:d.submitted_at,title:d.title,description:d.description,fields:d.fields}},blockers:[],blocks:[r.offline_id,d.offline_id]});return m.catch(h=>{throw this.dispatch(ei(r.offline_id)),this.dispatch(Zs(d.offline_id)),h}),[r,d,m]}async delete(e){const{store:s}=this.client,n=s.getState(),a=$r(e)(n);if(!a)throw new Error("Expected form to exist");const c=Xr(e)(n);c.length>0&&this.dispatch(ct(c.map(({offline_id:d})=>d)));const r=kr(e)(n);r.length>0&&this.dispatch(jr(r.map(({offline_id:d})=>d))),this.dispatch(ei(e));try{return await this.enqueueRequest({description:"Delete form",method:u.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(d){throw this.dispatch(xs(a)),r.length>0&&this.dispatch(Er(r)),c.length>0&&this.dispatch(at(c)),d}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization forms",method:u.GET,url:"/forms/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(Vr(s))}}class GA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{submissionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,form_submission:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,file_sha1:A.sha1,file_extension:A.extension,field_identifier:f,form_submission:h};r.push(T)}this.dispatch(st(c));const d=this.enqueueRequest({description:"Attach files to form submission",method:u.POST,url:"/form-submission-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.form_submission),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(Lr(o.attachments))}).catch(o=>{throw this.dispatch(it(c.map(h=>h.offline_id))),o}),[c,d.then(({attachments:o})=>o)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Nr(e)(n);this.dispatch(it(e));try{await this.enqueueRequest({description:"Delete form submission attachments",method:u.DELETE,url:"/form-submission-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(st(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get form submission attachments",method:u.GET,url:"/form-submission-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Gr(s))}}class LA extends E{async add(e){var f;const{store:s}=this.client,{file:n,...a}=e,c=new Date().toISOString(),r=(f=s.getState().userReducer.currentUser)==null?void 0:f.id,d=a.project,m=await this.getFilePayload(n),o=F({...a,file_name:n.name,file_sha1:m.sha1,file:URL.createObjectURL(n),submitted_at:c,created_by:r});this.dispatch(io(o));const h=this.enqueueRequest({description:"Add geo image",method:u.POST,url:"/geo-images/",payload:{offline_id:o.offline_id,submitted_at:c,title:o.title,description:o.description,geo_marker:o.geo_marker,canvas_marker:o.canvas_marker,sha1:o.file_sha1,project:o.project,file_name:o.file_name,direction:o.direction,original_date:o.original_date,file:m},blocks:[d.toString()],blockers:[d.toString()]});return h.then(p=>{this.processPresignedUrls(p.presigned_urls),this.dispatch(Ve(p.geo_image))}).catch(()=>{this.dispatch(li(o.offline_id))}),[o,h.then(p=>p.geo_image)]}async bulkAdd(e,s){var f;const{store:n}=this.client,a=new Date().toISOString(),c=(f=n.getState().userReducer.currentUser)==null?void 0:f.id,r=[],d=[],m=[],o={};for(const p of e){const{file:A,..._}=p,T=await this.getFilePayload(A);T.sha1 in o||(o[T.sha1]=T);const b=F({..._,file_name:A.name,file_sha1:T.sha1,file:URL.createObjectURL(A),submitted_at:a,created_by:c,project:s});r.push(b),d.push(b.offline_id),m.push({offline_id:b.offline_id,sha1:b.file_sha1,file_name:b.file_name,title:b.title,description:b.description,geo_marker:b.geo_marker,canvas_marker:b.canvas_marker,direction:b.direction,original_date:b.original_date})}this.dispatch(no(r));const h=this.enqueueRequest({description:"Bulk add geo images",method:u.POST,url:"/geo-images/bulk/",payload:{submitted_at:a,project:s,geo_images:m,files:Object.values(o)},blocks:[s.toString()],blockers:d});return h.then(p=>{this.processPresignedUrls(p.presigned_urls),this.dispatch(so(p.geo_images))}).catch(()=>{this.dispatch(co(d))}),[r,h.then(p=>p.geo_images)]}update(e){const{store:s}=this.client,n=s.getState(),a=ui(e.offline_id)(n);if(!a)throw new Error(`Map image with offline_id ${e.offline_id} does not exist in the store`);const c={...a,...e};this.dispatch(ao(c));const r=this.enqueueRequest({description:"Update geo image",method:u.PATCH,url:`/geo-images/${e.offline_id}/`,payload:e,blocks:[e.offline_id],blockers:[e.offline_id]});return r.then(d=>{this.dispatch(Ve(d))}).catch(()=>{this.dispatch(Ve(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=ui(e)(n);if(!a)throw new Error(`Map image with offline_id ${e} does not exist in the store`);this.dispatch(li(e));const c=this.enqueueRequest({description:"Delete geo image",method:u.DELETE,url:`/geo-images/${e}/`,blocks:[e],blockers:[e]});return c.catch(()=>{this.dispatch(Ve(a))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get geo images",method:u.GET,url:`/projects/${e}/geo-images/`,blocks:[e.toString()],blockers:[]});this.dispatch(to(s))}}class NA extends R{add(e){var d;const{store:s}=this.client,n=new Date().toISOString(),a=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,c=F({...e,submitted_at:n,created_by:a});this.dispatch(mi(c));const r=this.enqueueRequest({description:"Add issue association",method:u.POST,url:"/issue-associations/",payload:{offline_id:c.offline_id,submitted_at:n,...e},blockers:[e.associated_issue,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(mo(m))}).catch(()=>{this.dispatch(pi(c.offline_id))}),[c,r]}async delete(e){const{store:s}=this.client,n=fo(e)(s.getState());if(!n)throw new Error(`Issue association with id ${e} not found in store.`);this.dispatch(pi(e));const a=this.enqueueRequest({description:"Delete issue association",method:u.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(mi(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch issue associations",method:u.GET,url:"/issue-associations/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(ho(s))}}class HA extends Le{constructor(){super(...arguments);g(this,"name","Issue Attachment");g(this,"url","/issue-attachments");g(this,"addAttachments",Si);g(this,"updateAttachments",To);g(this,"removeAttachments",gi);g(this,"removeAttachment",Fo);g(this,"setAttachment",_o);g(this,"selectAttachment",Po)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue:s.modelId})}buildAttachmentPayload(s){return{...s,issue:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.issueId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get issue attachments",method:u.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blocks:[],blockers:[]});this.dispatch(bo(n))}}class WA extends R{add(e){var c;const{store:s}=this.client,n=F({...e,author:(c=s.getState().userReducer.currentUser)==null?void 0:c.id,submitted_at:new Date().toISOString()});this.dispatch(Fi(n));const a=this.enqueueRequest({description:"Add issue comment",method:u.POST,url:"/issue-comments/",payload:n,blockers:[e.issue],blocks:[n.offline_id]});return a.catch(()=>{this.dispatch(Ii(n.offline_id))}),[n,a]}update(e){const{store:s}=this.client,n=jo(e.offline_id)(s.getState());if(!n)throw new Error(`Comment with offline_id ${e.offline_id} not found in store`);const a={...n,...e};this.dispatch(Ti(a));const c=this.enqueueRequest({description:"Edit issue comment",method:u.PATCH,url:`/issue-comments/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.catch(()=>{this.dispatch(Ti(n))}),[a,c]}remove(e){const s=this.client.store.getState().issueCommentReducer.instances[e];if(!s)throw new Error(`Comment with offline_id ${e} not found in store`);this.dispatch(Ii(e));const n=this.enqueueRequest({description:"Delete comment",method:u.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return n.catch(()=>{this.dispatch(Fi(s))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Get comments",method:u.GET,url:"/issue-comments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(wo(s))}}class KA extends R{add(e){var m;const{store:s}=this.client,n=s.getState(),a=new Date().toISOString(),c=(m=n.userReducer.currentUser)==null?void 0:m.id,r=F({...e,submitted_at:a,created_by:c});this.dispatch(Pi(r));const d=this.enqueueRequest({description:"Create issue",method:u.POST,url:"/issues/",payload:r,blockers:["add-issue",r.project.toString()],blocks:[r.offline_id]});return d.then(o=>{this.dispatch(rt(o))}).catch(o=>{throw this.dispatch(Oi(r.offline_id)),o}),[r,d]}update(e){var m;const s=this.client.store.getState(),n=vi(e.offline_id)(s);if(!n)throw new Error(`Attempting to update an issue with offline_id ${e.offline_id} that doesn't exist in the store`);const a={...n,...e};this.dispatch(rt(a));const c={};for(const o of[v.TITLE,v.DESCRIPTION,v.STATUS,v.CATEGORY,v.PRIORITY,v.ASSIGNED_TO,v.DUE_DATE])if(o in e&&e[o]!==n[o])switch(o){case v.PRIORITY:case v.STATUS:{const h=e[o];c[o]=h!==void 0?Number(h):null;break}case v.DUE_DATE:case v.DESCRIPTION:case v.TITLE:c[o]=e[o]??null;break;case v.CATEGORY:{let h=null;const f=e[o];if(f&&(h=s.categoryReducer.instances[f]??null,!h))throw new Error(`Trying to update issue category to ${f} which does not exist in store`);c[o]=h?{name:h.name,color:h.color,offline_id:h.offline_id}:null;break}case v.ASSIGNED_TO:{let h=null;const f=e[o];if(f&&(h=s.userReducer.users[f]??null,!h))throw new Error(`Trying to update issue assigned_to to ${f} which does not exist in store`);c[o]=h?{full_name:h.username,id:h.id}:null;break}}const r=F({created_by:(m=s.userReducer.currentUser)==null?void 0:m.id,submitted_at:new Date().toISOString(),issue:n.offline_id,changes:c});this.dispatch(bd(r));const d=this.enqueueRequest({description:"Edit issue",method:u.PATCH,url:`/issues/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return d.catch(()=>{this.dispatch(rt(n)),this.dispatch(Td(r.offline_id))}),[a,d]}async remove(e){const{store:s}=this.client,n=s.getState(),a=vi(e)(n);if(!a)throw new Error(`No issue with id ${e} found in the store`);const c=Ro(e)(n),r=Rd(e)(n),d=Zr(e)(n),m={};for(const h of po(e)(n))m[h.offline_id]=h;for(const h of Ao(e)(n))m[h.offline_id]=h;const o=Object.values(m);this.dispatch(Oi(e)),c.length>0&&this.dispatch(gi(c.map(({offline_id:h})=>h))),r.length>0&&this.dispatch(Fd(r.map(({offline_id:h})=>h))),d.length>0&&this.dispatch(ct(d.map(({offline_id:h})=>h))),o.length>0&&this.dispatch(Ai(o.map(({offline_id:h})=>h)));try{return await this.enqueueRequest({description:"Delete issue",method:u.DELETE,url:`/issues/${e}/`,blockers:[e],blocks:[]})}catch(h){throw this.dispatch(Pi(a)),this.dispatch(Si(c)),this.dispatch(_d(r)),this.dispatch(at(d)),this.dispatch(fi(o)),h}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issues",method:u.GET,url:"/issues/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(ko(s))}}class YA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,file_extension:A.extension,field_identifier:f,file_sha1:A.sha1,fields_revision:h};r.push(T)}this.dispatch(Bo(c));const d=this.enqueueRequest({description:"Add issue type fields attachments",method:u.POST,url:"/issue-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.fields_revision),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(Go(o.attachments))}).catch(()=>{this.dispatch(Lo(c.map(o=>o.offline_id)))}),[c,d.then(({attachments:o})=>o)]}async refreshStore(e){const s=await this.enqueueRequest({description:"get issue type fields attachments",method:u.GET,url:"/issue-type-fields-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch($o(s))}}class JA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(xo(c));const r=this.enqueueRequest({description:"Add Issue Type Fields",method:u.POST,url:"/issue-type-fields/",payload:c,blockers:[c.issue_type],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(ed(m))}).catch(m=>{throw this.dispatch(td(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Issue Type Fields",method:u.GET,url:"/issue-type-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Qo(s))}}class XA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{fieldValuesId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,field_values:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,file_sha1:A.sha1,file_extension:A.extension,field_identifier:f,field_values:h};r.push(T)}this.dispatch(dt(c));const d=this.enqueueRequest({description:"Add issue type field values attachments",method:u.POST,url:"/issue-type-field-values-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.field_values),blocks:c.map(o=>o.offline_id)});return d.then(({presigned_urls:o,attachments:h})=>{this.processPresignedUrls(o),this.dispatch(cd(h))}).catch(o=>{throw this.dispatch(lt(c.map(h=>h.offline_id))),o}),[c,d.then(({attachments:o})=>o)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=od(e)(n);this.dispatch(lt(e));try{await this.enqueueRequest({description:"Delete issue type field values attachments",method:u.DELETE,url:"/issue-type-field-values-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 issue type field values attachments",method:u.GET,url:"/issue-type-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(ad(s))}}class ZA extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add issue type field values",method:u.POST,url:"/issue-type-field-values/",payload:a,blockers:[e.issue,e.fields_revision],blocks:[a.offline_id]});return this.dispatch(ji(a)),c.then(d=>(this.dispatch(Ue(d)),d)).catch(()=>{this.dispatch(qi(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=ki(e.offline_id)(n);if(!a)throw new Error(`Expected IssueTypeFieldValues with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(Ue(c));const r=this.enqueueRequest({description:"Update issue type field values",method:u.PATCH,url:`/issue-type-field-values/${e.offline_id}/`,payload:e,blockers:[c.offline_id,c.fields_revision,c.issue],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(Ue(d))}).catch(()=>{this.dispatch(Ue(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=ki(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=dd(e)(n);this.dispatch(qi(e)),this.dispatch(lt(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete issue type field values",method:u.DELETE,url:`/issue-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ji(a)),this.dispatch(dt(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values",method:u.GET,url:"/issue-type-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Yo(s))}}class QA extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,submitted_at:new Date().toISOString(),created_by:(r=n.userReducer.currentUser)==null?void 0:r.id});this.dispatch(md(a));const c=this.enqueueRequest({method:u.POST,url:"/issue-types/",payload:a,blockers:[],blocks:[a.offline_id]});return c.then(d=>{this.dispatch($e(d))}).catch(()=>{this.dispatch(Ui(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=$i(e.offline_id)(n);if(!a)throw new Error(`IssueType with offline_id ${e.offline_id} does not exist in the store.`);const c={...a,...e};this.dispatch(fd(c));const r=this.enqueueRequest({method:u.PATCH,url:`/issue-types/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return r.then(d=>{this.dispatch($e(d))}).catch(()=>{this.dispatch($e(a))}),[c,r]}delete(e){const{store:s}=this.client,n=s.getState(),a=$i(e)(n);if(!a)throw new Error(`IssueType with offline_id ${e} does not exist in the store.`);const c=Bi(e)(n);this.dispatch(Ui(e)),this.dispatch(zo(c.map(d=>d.offline_id)));const r=this.enqueueRequest({method:u.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return r.catch(()=>{this.dispatch($e(a)),this.dispatch(Do(c))}),r}async refreshStore(e){const s=await this.enqueueRequest({method:u.GET,url:"/issue-types/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(hd(s))}}class xA extends R{async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue updates",method:u.GET,url:"/issue-updates/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(gd(s))}}class ey extends Kl{constructor(e){super(e)}}const ty=1800;function sy(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 iy extends ey{constructor(){super(...arguments);g(this,"_getRenewedTokens",async s=>{const n=this.enqueueRequest({description:"Get renewed tokens",method:u.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($c(!1)),this.clearTokens(),this.dispatch({type:pu.RESET_STATE}),this.dispatch({type:tu})}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=Au(s).exp??n}catch{a=n}return a-n<ty}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 j&&this.clearAuth(),s instanceof Error?Promise.reject(s):Promise.reject(new Error((s??Pe).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 j({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 j({message:"Incorrect username or password.",response:n,discard:!0})}async initAuth(s){const n=O.v4();return console.debug(this.constructor.name,"Initiating auth"),this.enqueueRequest({uuid:n,description:"Get token pair",method:u.POST,url:this.initTokensUrl,payload:s,isAuthNeeded:!1,checkAuth:!1,immediate:!0,blockers:[],blocks:[]}).then(a=>{this.setTokens(sy(a))})}}class ny extends R{async getLicense(e){const s=await this.enqueueRequest({description:"Get license",method:u.GET,url:`/billing/${e.offline_id}/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(oe(s)),s}async pauseLicense(e){const s=await this.enqueueRequest({description:"Pause license",method:u.DELETE,url:`/billing/${e.offline_id}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(oe(s)),s}async resumeLicense(e){const s=await this.enqueueRequest({description:"Resume license",method:u.PATCH,url:`/billing/${e.offline_id}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(oe(s)),s}async cancelLicense(e){const s=await this.enqueueRequest({description:"Cancel license",method:u.DELETE,url:`/billing/${e.offline_id}/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(oe(s)),s}async attachLicenseToProject(e,s){const n=await this.enqueueRequest({description:"Attach license",method:u.PATCH,url:`/billing/${e.offline_id}/project/`,isAuthNeeded:!0,payload:{project:s.id},blockers:[e.organization_owner?e.organization_owner.toString():"",s.id?s.id.toString():""],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(oe(n)),n}async detachLicenseFromProject(e){const s=await this.enqueueRequest({description:"Detach license",method:u.DELETE,url:`/billing/${e.offline_id}/project/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(oe(s)),s}async getLatestTransaction(e){return await this.enqueueRequest({description:"Get latest transaction",method:u.GET,url:`/billing/${e.offline_id}/transaction/`,isAuthNeeded:!0,blockers:[e.offline_id],blocks:[e.offline_id]})}async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Get licenses",method:u.GET,url:`/organizations/${s}/licenses/`,isAuthNeeded:!0,blockers:[s.toString()],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of a)n[r.offline_id]=r;const c=await this.enqueueRequest({description:"Get licenses",method:u.GET,url:`/projects/${e}/licenses/`,isAuthNeeded:!0,blockers:[e.toString()],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of c)n[r.offline_id]=r;this.dispatch(vd(Object.values(n)))}}class ay extends R{async update(e){const s=this.enqueueRequest({description:"Edit organization access",method:u.PATCH,url:`/organizations/${e.organization}/access/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return s.then(()=>{this.dispatch(Vd(e))}),s}async remove(e){return this.dispatch(Cd(e.offline_id)),this.dispatch(Md(e.user)),this.enqueueRequest({description:"Remove organization access",method:u.DELETE,url:`/organizations/${e.organization}/access/${e.offline_id}/`,blockers:[e.offline_id],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization accesses",method:u.GET,url:`/organizations/${e}/access/`,blockers:[],blocks:[]});this.dispatch(zd(s))}}class cy extends R{create(e){return this.enqueueRequest({description:"Create organization",method:u.POST,url:"/organizations/",payload:{name:e},blockers:[],blocks:[`add-org-${e}`,"create-org"]})}async update(e){return this.enqueueRequest({description:"Edit organization",method:u.PATCH,url:`/organizations/${e.id}/`,payload:e,blockers:[`add-org-${e.name}`,e.id.toString()],blocks:[e.id.toString()]})}async invite(e,s){return this.enqueueRequest({description:"Invite user to organization",method:u.POST,url:`/organizations/${e}/invite/${s}/`,blockers:[],blocks:[]})}async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Get organizations",method:u.GET,url:`/projects/${e}/organizations/`,blockers:[],blocks:[]});for(const r of a)n[r.id]=r;const c=await this.enqueueRequest({description:"Get organization",method:u.GET,url:`/organizations/${s}/`,blockers:[],blocks:[]});n[c.id]=c,this.dispatch(il(Object.values(n)))}}class ry extends R{async update(e){return this.dispatch(Gd(e)),this.enqueueRequest({description:"Edit project access",method:u.PATCH,url:`/access/${e.offline_id}/`,payload:e,blockers:[e.offline_id,"change-access-level"],blocks:[e.offline_id]})}async remove(e){return this.dispatch(Ld(e)),this.enqueueRequest({description:"Delete project access",method:u.DELETE,url:`/access/${e}/`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project accesses",method:u.GET,url:`/projects/${e}/access/`,blockers:[],blocks:[]});this.dispatch(Yi(s))}}class oy extends Le{constructor(){super(...arguments);g(this,"name","Project Attachment");g(this,"url","/project-attachments");g(this,"addAttachments",yl);g(this,"updateAttachments",bl);g(this,"removeAttachments",tn);g(this,"removeAttachment",_l);g(this,"setAttachment",Sl);g(this,"selectAttachment",Fl)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,project:s.modelId})}buildAttachmentPayload(s){return{...s,project:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.projectId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get project attachments",method:u.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blockers:[],blocks:[]});this.dispatch(Al(n))}}class dy extends R{async saveExisting(e){if(!e.offline_id)throw new Error("You can only use this method to save existing project files. The one provided has no offline_id.");const s={...e};delete s.file;const n=this.enqueueRequest({method:u.PATCH,url:`/projects/files/${e.offline_id}/`,payload:s,blockers:[e.offline_id],blocks:[e.offline_id]});return n.then(a=>{this.dispatch(an(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:u.PATCH,url:`/projects/files/${n}/`,payload:m,blockers:[n],blocks:[n]}}else c=new Promise((m,o)=>{this.client.files.uploadFileToS3(a.file_sha1).then(([h])=>{m({method:u.POST,url:`/projects/${a.project}/files/`,payload:{...a,...h},blockers:[n],blocks:[n]})}).catch(o)});const d=Promise.resolve(c).then(m=>this.enqueueRequest(m));return d.then(m=>{this.dispatch(an(m))}),this.dispatch(Ml),this.dispatch(ql(null)),this.dispatch(jl(!1)),[a,d]}delete(e){return this.dispatch(wl(e)),this.enqueueRequest({method:u.DELETE,url:`/projects/files/${e}`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project files",method:u.GET,url:`/projects/${e}/files/`,blockers:[],blocks:[]});this.dispatch(Ol(s))}}class ly extends R{async add(e){if(!e.bounds&&!e.canvas_bounds)throw new Error("Project must either have bounds or canvas_bounds set");return await this.enqueueRequest({description:"Create project",method:u.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(Xd(e)),await this.enqueueRequest({description:"Update project",method:u.PATCH,url:`/projects/${e.id}/`,payload:{name:e.name,bounds:e.bounds},blockers:[e.id.toString()],blocks:[e.id.toString()]})}async delete(e){const{store:s}=this.client,n=s.getState(),a=Zi(n),c=a[e];if(!c)throw new Error("Expected project to exist");const r=Dl(n).filter(h=>h.project===e);this.dispatch(El(r.map(({offline_id:h})=>h)));const d=Il(c.id)(n);this.dispatch(tn(d.map(({offline_id:h})=>h)));const m=Hd(n);this.dispatch(Nd(m.map(({offline_id:h})=>h))),this.dispatch({type:"rehydrated/setRehydrated",payload:!1}),this.dispatch(Zd(c));const o=wd(c.id)(n);o&&this.dispatch(oe({...o,project:null}));try{await this.enqueueRequest({description:"Delete project",method:u.DELETE,url:`/projects/${e}/`,blockers:[e.toString()],blocks:[]}),this.dispatch({type:"rehydrated/setRehydrated",payload:!0})}catch(h){throw this.dispatch(Jd(Object.values(a))),this.dispatch(Yi(Object.values(m))),this.dispatch(vl(r)),this.dispatch(gl(d)),this.dispatch({type:"rehydrated/setRehydrated",payload:!0}),o&&this.dispatch(oe({...o,project:c.id})),h}}invite(e,s){const n=O.v4();return this.enqueueRequest({description:"Invite user to project",method:u.POST,url:`/projects/${e}/invite/${s}/`,payload:{offline_id:n},blockers:[],blocks:[n]})}joinProject(e,s,n){return this.enqueueRequest({description:"Join project",method:u.GET,url:`/projects/${e}/join-project/${s}/${n}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}async acceptInvite(e){return this.enqueueRequest({description:"Accept project invite",method:u.PATCH,url:`/projects/${e}/accept-invite/`,blockers:[e.toString()],blocks:[e.toString()]}).then(()=>{this.dispatch(Qd(e))})}}class uy extends R{add(e){const s=F({...e,submitted_at:new Date().toISOString()});this.dispatch($l(s));const n=this.enqueueRequest({description:"Create team",method:u.POST,url:`/organizations/${e.organization}/teams/`,payload:s,blockers:[],blocks:[s.offline_id]});return n.then(a=>{this.dispatch(Ie(a))}).catch(()=>{this.dispatch(dn(s.offline_id))}),[s,n]}update(e){const{store:s}=this.client,n=Re(e.offline_id)(s.getState());if(!n)throw new Error(`Expected team with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(on(a));const c=this.enqueueRequest({description:"Update team",method:u.PATCH,url:`/organizations/teams/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.then(r=>{this.dispatch(Ie(r))}).catch(()=>{this.dispatch(Ie(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Re(e)(n);if(!a)throw new Error(`Expected team with id ${e} to exist`);this.dispatch(dn(e));try{return await this.enqueueRequest({description:"Delete team",method:u.DELETE,url:`/organizations/teams/${e}/`,blockers:[e],blocks:[e]})}catch(c){throw this.dispatch(Ie(a)),c}}async setMembers(e,s){const{store:n}=this.client,a=Re(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);if(s.length!==new Set(s).size)throw new Error("Duplicate members found in the list");this.dispatch(on({...a,members:s}));const c=this.enqueueRequest({description:"Set team members",method:u.PUT,url:`/organizations/teams/${e}/set-members/`,payload:{users:s},blockers:[e],blocks:[e]});return c.catch(()=>{this.dispatch(Ie(a))}),c}async addMembers(e,s){const{store:n}=this.client,a=Re(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);const c=[...a.members,...s];return this.setMembers(e,c)}async removeMembers(e,s){const{store:n}=this.client,a=Re(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);const c=a.members.filter(r=>!s.includes(r));return this.setMembers(e,c)}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch teams",method:u.GET,url:`/organizations/${e}/teams/`,blockers:[],blocks:[]});this.dispatch(Ul(s))}}class hy extends R{async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Fetch organization users",method:u.GET,url:`/organizations/${s}/users/`,blockers:[],blocks:[]});for(const r of a)n[r.id]=r;const c=await this.enqueueRequest({description:"Fetch project users",method:u.GET,url:`/projects/${e}/users/`,blockers:[],blocks:[]});for(const r of c)n[r.id]=r;this.dispatch(qd(Object.values(n)))}}var ru=(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))(ru||{});i.APIError=j,i.AgentService=hA,i.AssetAttachmentService=mA,i.AssetProcedureFieldValuesAttachmentService=AA,i.AssetProcedureFieldValuesService=gA,i.AssetProcedureFieldsAttachmentService=fA,i.AssetProcedureFieldsService=pA,i.AssetProcedureInstanceService=bA,i.AssetProcedureService=_A,i.AssetService=TA,i.AssetStageCompletionService=FA,i.AssetStageService=IA,i.AssetTypeAttachmentService=RA,i.AssetTypeFieldValuesAttachmentService=vA,i.AssetTypeFieldValuesService=wA,i.AssetTypeFieldsAttachmentService=PA,i.AssetTypeFieldsService=OA,i.AssetTypeService=EA,i.AttachmentModel=Tn,i.BaseApiService=R,i.BaseSDK=lA,i.CategoryService=jA,i.DEFAULT_ISSUE_PRIORITY=Su,i.DEFAULT_ISSUE_STATUS=yu,i.DeferredPromise=On,i.DocumentAttachmentService=qA,i.DocumentService=MA,i.EMPTY_ARRAY=bn,i.EMPTY_OBJECT=_n,i.EmailDomainsService=kA,i.EmailVerificationService=DA,i.FileService=VA,i.FormRevisionAttachmentService=CA,i.FormRevisionService=UA,i.FormService=BA,i.FormSubmissionAttachmentService=GA,i.FormSubmissionService=SA,i.GeoImageService=LA,i.HttpMethod=u,i.IssueAssociationService=NA,i.IssueAttachmentService=HA,i.IssueCommentService=WA,i.IssuePriority=_t,i.IssueService=KA,i.IssueStatus=Tt,i.IssueTypeFieldValuesAttachmentService=XA,i.IssueTypeFieldValuesService=ZA,i.IssueTypeFieldsAttachmentService=YA,i.IssueTypeFieldsService=JA,i.IssueTypeService=QA,i.IssueUpdateChange=v,i.IssueUpdateService=xA,i.JWTService=iy,i.LicenseLevel=In,i.LicenseService=ny,i.LicenseStatus=Rn,i.OUTBOX_RETRY_DELAY=Pn,i.OrganizationAccessLevel=bt,i.OrganizationAccessService=ay,i.OrganizationService=cy,i.OutboxCoordinator=Oe,i.PaddleCheckoutEvent=Fn,i.ProjectAccessLevel=gt,i.ProjectAccessService=ry,i.ProjectAttachmentService=oy,i.ProjectFileService=dy,i.ProjectService=ly,i.TeamService=uy,i.UNKNOWN_ERROR_MESSAGE=Pe,i.UserService=hy,i.VERSION_REDUCER_KEY=hn,i.VerificationCodeType=ru,i._selectLatestFormRevision=Mr,i._setLatestRetryTime=ml,i.acceptProjectInvite=Qd,i.addAsset=ss,i.addAssetAttachment=Gu,i.addAssetAttachments=jt,i.addAssetProcedure=Zt,i.addAssetProcedureFieldValues=$t,i.addAssetProcedureFieldValuesAttachment=rh,i.addAssetProcedureFieldValuesAttachments=We,i.addAssetProcedureFieldValuesMany=ga,i.addAssetProcedureFields=aa,i.addAssetProcedureFieldsAttachment=Wu,i.addAssetProcedureFieldsAttachments=Zn,i.addAssetProcedureFieldsMany=xu,i.addAssetProcedureInstance=Ht,i.addAssetProcedureInstances=Pa,i.addAssetProcedures=Th,i.addAssetStage=zh,i.addAssetStageCompletion=ds,i.addAssetStageCompletions=ls,i.addAssetStages=ps,i.addAssetType=Ms,i.addAssetTypeAttachment=$h,i.addAssetTypeAttachments=bs,i.addAssetTypeFieldValues=vs,i.addAssetTypeFieldValuesAttachment=am,i.addAssetTypeFieldValuesAttachments=Ze,i.addAssetTypeFieldValuesMany=jc,i.addAssetTypeFields=yc,i.addAssetTypeFieldsAttachment=Nh,i.addAssetTypeFieldsAttachments=dc,i.addAssetTypeFieldsMany=Zh,i.addAssetTypes=ym,i.addAssets=is,i.addCategory=Cs,i.addConversation=Vn,i.addDocumentAttachment=wm,i.addDocumentAttachments=Jc,i.addDocuments=Ns,i.addEmailDomain=lr,i.addForm=xs,i.addFormRevision=Xs,i.addFormRevisionAttachment=$m,i.addFormRevisionAttachments=Tr,i.addFormRevisions=Er,i.addFormSubmission=ni,i.addFormSubmissionAttachment=ef,i.addFormSubmissionAttachments=st,i.addFormSubmissions=at,i.addForms=Xm,i.addGeoImage=io,i.addGeoImages=no,i.addIssue=Pi,i.addIssueAssociation=mi,i.addIssueAssociations=fi,i.addIssueAttachment=ff,i.addIssueAttachments=Si,i.addIssueComment=Fi,i.addIssueComments=Sf,i.addIssueType=md,i.addIssueTypeFieldValues=ji,i.addIssueTypeFieldValuesAttachment=Nf,i.addIssueTypeFieldValuesAttachments=dt,i.addIssueTypeFieldValuesMany=wf,i.addIssueTypeFields=xo,i.addIssueTypeFieldsAttachment=Tf,i.addIssueTypeFieldsAttachments=Bo,i.addIssueTypeFieldsMany=Df,i.addIssueUpdate=bd,i.addIssueUpdates=_d,i.addIssues=Do,i.addLicenses=ep,i.addProjectAttachment=Ip,i.addProjectAttachments=yl,i.addProjectFile=wp,i.addProjectFiles=vl,i.addTeam=$l,i.addUsers=cp,i.agentsReducer=$n,i.agentsSlice=Ot,i.areArraysEqual=Tu,i.assetAttachmentReducer=Yn,i.assetAttachmentSlice=wt,i.assetProcedureFieldValuesAttachmentReducer=Aa,i.assetProcedureFieldValuesAttachmentSlice=Vt,i.assetProcedureFieldValuesReducer=Fa,i.assetProcedureFieldValuesSlice=Ut,i.assetProcedureFieldsAttachmentReducer=sa,i.assetProcedureFieldsAttachmentSlice=kt,i.assetProcedureFieldsReducer=da,i.assetProcedureFieldsSlice=Dt,i.assetProcedureInstanceReducer=wa,i.assetProcedureInstanceSlice=Nt,i.assetProcedureReducer=Ma,i.assetProcedureSlice=Xt,i.assetReducer=Ca,i.assetSlice=ts,i.assetStageCompletionReducer=La,i.assetStageCompletionSlice=os,i.assetStageReducer=Ja,i.assetStageSlice=fs,i.assetTypeAttachmentReducer=cc,i.assetTypeAttachmentSlice=gs,i.assetTypeFieldValuesAttachmentReducer=vc,i.assetTypeFieldValuesAttachmentSlice=Rs,i.assetTypeFieldValuesReducer=Dc,i.assetTypeFieldValuesSlice=Os,i.assetTypeFieldsAttachmentReducer=fc,i.assetTypeFieldsAttachmentSlice=Fs,i.assetTypeFieldsReducer=_c,i.assetTypeFieldsSlice=Is,i.assetTypeReducer=Cc,i.assetTypeSlice=qs,i.authReducer=Bc,i.authSlice=xe,i.blobToBase64=ju,i.categoryReducer=Wc,i.categorySlice=Vs,i.clearTokens=Fm,i.constructUploadedFilePayloads=Eu,i.coordinatesAreEqual=_u,i.createModelAdapter=I,i.createMultiPointGeometry=bu,i.createOfflineAction=dl,i.createPointGeometry=gu,i.deleteAsset=ns,i.deleteAssetAttachment=Nn,i.deleteAssetAttachments=qt,i.deleteAssetProcedure=Qt,i.deleteAssetProcedureFieldValues=Bt,i.deleteAssetProcedureFieldValuesAttachment=uh,i.deleteAssetProcedureFieldValuesAttachments=Ke,i.deleteAssetProcedureFieldValuesMany=_a,i.deleteAssetProcedureFields=ra,i.deleteAssetProcedureFieldsAttachment=Xu,i.deleteAssetProcedureFieldsAttachments=xn,i.deleteAssetProcedureFieldsMany=ih,i.deleteAssetProcedureInstance=Wt,i.deleteAssetProcedureInstances=Oa,i.deleteAssetProcedures=Ih,i.deleteAssetStage=Vh,i.deleteAssetStageCompletion=us,i.deleteAssetStageCompletions=hs,i.deleteAssetStages=ys,i.deleteAssetType=ks,i.deleteAssetTypeAttachment=sc,i.deleteAssetTypeAttachments=_s,i.deleteAssetTypeFieldValues=ws,i.deleteAssetTypeFieldValuesAttachment=dm,i.deleteAssetTypeFieldValuesAttachments=Qe,i.deleteAssetTypeFieldValuesMany=Mc,i.deleteAssetTypeFields=gc,i.deleteAssetTypeFieldsAttachment=Yh,i.deleteAssetTypeFieldsAttachments=uc,i.deleteAssetTypeFieldsMany=tm,i.deleteAssetTypes=gm,i.deleteAssets=za,i.deleteCategory=Hc,i.deleteDocumentAttachment=Qc,i.deleteDocumentAttachments=xc,i.deleteEmailDomain=ur,i.deleteForm=ei,i.deleteFormRevision=Zs,i.deleteFormRevisionAttachment=Nm,i.deleteFormRevisionAttachments=Ir,i.deleteFormRevisions=jr,i.deleteFormSubmission=ai,i.deleteFormSubmissionAttachment=af,i.deleteFormSubmissionAttachments=it,i.deleteFormSubmissions=ct,i.deleteGeoImage=li,i.deleteGeoImages=co,i.deleteIssue=Oi,i.deleteIssueAssociation=pi,i.deleteIssueAssociations=Ai,i.deleteIssueAttachment=Fo,i.deleteIssueAttachments=gi,i.deleteIssueComment=Ii,i.deleteIssueComments=gf,i.deleteIssueTypeFieldValues=qi,i.deleteIssueTypeFieldValuesAttachment=Yf,i.deleteIssueTypeFieldValuesAttachments=lt,i.deleteIssueTypeFieldValuesMany=Mf,i.deleteIssueTypeFields=td,i.deleteIssueTypeFieldsAttachment=Pf,i.deleteIssueTypeFieldsAttachments=Lo,i.deleteIssueTypeFieldsMany=Uf,i.deleteIssueUpdate=Td,i.deleteIssueUpdates=Fd,i.deleteIssues=zo,i.deleteOrganizationAccess=Cd,i.deleteProject=Zd,i.deleteProjectAccess=Ld,i.deleteProjectAccesses=Nd,i.deleteProjectAttachment=_l,i.deleteProjectAttachments=tn,i.deleteProjectFile=wl,i.deleteProjectFiles=El,i.deleteTeam=dn,i.dequeue=iu,i.discard=pn,i.documentAttachmentReducer=sr,i.documentAttachmentSlice=Bs,i.documentSlice=Ls,i.documentsReducer=or,i.downloadFile=qu,i.downloadInMemoryFile=wu,i.emailDomainsReducer=fr,i.emailDomainsSlice=Ws,i.emailRegex=Uu,i.enqueue=su,i.enqueueRequest=ul,i.fallbackToEmptyArray=S,i.fallbackToEmptyObject=ge,i.fileReducer=gr,i.fileSlice=Ks,i.fileToBlob=jn,i.formReducer=Cr,i.formRevisionAttachmentReducer=Pr,i.formRevisionAttachmentSlice=Ys,i.formRevisionReducer=Dr,i.formRevisionsSlice=Js,i.formSlice=Qs,i.formSubmissionAttachmentReducer=Wr,i.formSubmissionAttachmentSlice=ti,i.formSubmissionReducer=xr,i.formSubmissionSlice=ii,i.geoImageReducer=lo,i.geoImageSlice=di,i.getFileIdentifier=vu,i.getFileS3Key=Pt,i.getLocalDateString=wn,i.getLocalRelativeDateString=Pu,i.getOutboxCoordinator=Ae,i.getRenamedFile=En,i.hashFile=be,i.initSDK=uA,i.initializeAssetAttachments=Et,i.initializeAssetProcedureFieldValues=Sa,i.initializeAssetProcedureFieldValuesAttachments=ua,i.initializeAssetProcedureFields=na,i.initializeAssetProcedureFieldsAttachments=Xn,i.initializeAssetProcedureInstances=Ra,i.initializeAssetProcedures=ja,i.initializeAssetStageCompletions=$a,i.initializeAssetStages=Ka,i.initializeAssetTypeAttachments=xa,i.initializeAssetTypeFieldValues=Ec,i.initializeAssetTypeFieldValuesAttachments=Fc,i.initializeAssetTypeFields=Ac,i.initializeAssetTypeFieldsAttachments=oc,i.initializeAssetTypes=Vc,i.initializeAssets=Da,i.initializeCategories=Lc,i.initializeConversations=zn,i.initializeDocumentAttachments=Yc,i.initializeEmailDomains=dr,i.initializeFormRevisionAttachments=_r,i.initializeFormRevisions=wr,i.initializeFormSubmissionAttachments=Gr,i.initializeFormSubmissions=Yr,i.initializeForms=Vr,i.initializeGeoImages=to,i.initializeIssueAssociations=ho,i.initializeIssueAttachments=bo,i.initializeIssueTypeFieldValues=Yo,i.initializeIssueTypeFieldValuesAttachments=ad,i.initializeIssueTypeFields=Qo,i.initializeIssueTypeFieldsAttachments=$o,i.initializeIssueTypes=hd,i.initializeIssueUpdates=gd,i.initializeIssues=ko,i.initializeLicences=vd,i.initializeOrganizationAccesses=zd,i.initializeProjectAccesses=Yi,i.initializeProjectAttachments=Al,i.initializeProjectFiles=Ol,i.initializeTeams=Ul,i.isToday=Ru,i.issueAssociationReducer=So,i.issueAssociationSlice=hi,i.issueAttachmentReducer=Oo,i.issueAttachmentSlice=yi,i.issueCommentReducer=qo,i.issueCommentSlice=_i,i.issueReducer=Co,i.issueSlice=Ri,i.issueTypeFieldValuesAttachmentReducer=ld,i.issueTypeFieldValuesAttachmentSlice=zi,i.issueTypeFieldValuesReducer=Xo,i.issueTypeFieldValuesSlice=Ei,i.issueTypeFieldsAttachmentReducer=Wo,i.issueTypeFieldsAttachmentSlice=wi,i.issueTypeFieldsReducer=id,i.issueTypeFieldsSlice=Di,i.issueTypeReducer=yd,i.issueTypeSlice=Ci,i.issueUpdateReducer=Pd,i.issueUpdateSlice=Gi,i.licenseReducer=Ed,i.licenseSlice=Li,i.logOnlyOnce=Mu,i.markAsDeleted=hl,i.markForDeletion=Fp,i.memoize=It,i.moveDocument=ar,i.offline=F,i.onlyUniqueHashes=Cu,i.onlyUniqueOfflineIds=kn,i.organizationAccessReducer=$d,i.organizationAccessSlice=Hi,i.organizationReducer=ol,i.organizationSlice=Qi,i.outboxReducer=fl,i.outboxSlice=xi,i.overmapEnhancer=xp,i.overmapReducers=xl,i.overmapRootReducer=Yp,i.performRequest=fn,i.projectAccessReducer=Kd,i.projectAccessSlice=Ki,i.projectAttachmentReducer=Rl,i.projectAttachmentSlice=en,i.projectFileReducer=zl,i.projectFileSlice=nn,i.projectReducer=xd,i.projectSlice=Xi,i.rehydratedReducer=Vl,i.rehydratedSlice=cn,i.removeDocuments=Hs,i.removeIssueType=Ui,i.removeUser=Md,i.resetProjectFileObjectUrls=jp,i.resetStore=tu,i.restructureCreateSelectorWithArgs=y,i.saveActiveProjectFileBounds=Ml,i.selectAccessToken=Im,i.selectActiveOrganizationAccess=lp,i.selectActiveProjectFileId=Mp,i.selectActiveStatusLicenses=sp,i.selectAllDocumentAttachments=Gs,i.selectAllProjectAttachments=sn,i.selectAncestorIdsOfDocument=Dm,i.selectAssetAttachmentById=Wn,i.selectAssetAttachmentMapping=Hn,i.selectAssetAttachments=Mt,i.selectAssetById=rs,i.selectAssetProcedureById=es,i.selectAssetProcedureFieldValues=Gt,i.selectAssetProcedureFieldValuesAttachmentById=hh,i.selectAssetProcedureFieldValuesAttachments=ma,i.selectAssetProcedureFieldValuesAttachmentsByIds=fa,i.selectAssetProcedureFieldValuesAttachmentsMapping=Ct,i.selectAssetProcedureFieldValuesById=Lt,i.selectAssetProcedureFieldValuesMapping=Ta,i.selectAssetProcedureFieldValuesOfAsset=ph,i.selectAssetProcedureFields=zt,i.selectAssetProcedureFieldsAttachmentById=Qu,i.selectAssetProcedureFieldsAttachments=ta,i.selectAssetProcedureFieldsAttachmentsMapping=ea,i.selectAssetProcedureFieldsById=ch,i.selectAssetProcedureFieldsMapping=oa,i.selectAssetProcedureFieldsOfAssetProcedure=nh,i.selectAssetProcedureInstanceById=Jt,i.selectAssetProcedureInstances=Yt,i.selectAssetProcedureInstancesByIds=_h,i.selectAssetProcedureInstancesMapping=Kt,i.selectAssetProcedureInstancesOfAssetProcedure=va,i.selectAssetProcedureInstancesOfAssetType=bh,i.selectAssetProcedures=qa,i.selectAssetProceduresByIds=vh,i.selectAssetProceduresMapping=xt,i.selectAssetProceduresOfOrganization=Oh,i.selectAssetStageById=Xa,i.selectAssetStageCompletionById=Na,i.selectAssetStageCompletionMapping=ms,i.selectAssetStageCompletions=kh,i.selectAssetStageCompletionsByIds=Ha,i.selectAssetStages=Za,i.selectAssetStagesByIds=Ss,i.selectAssetStagesMappingOfAssetProcedure=Ch,i.selectAssetStagesOfAssetProcedure=Uh,i.selectAssetTypeAttachmentById=nc,i.selectAssetTypeAttachmentMapping=ic,i.selectAssetTypeAttachments=Ts,i.selectAssetTypeById=zs,i.selectAssetTypeFieldValues=Es,i.selectAssetTypeFieldValuesAttachmentById=lm,i.selectAssetTypeFieldValuesAttachments=Rc,i.selectAssetTypeFieldValuesAttachmentsByIds=Pc,i.selectAssetTypeFieldValuesAttachmentsMapping=Ps,i.selectAssetTypeFieldValuesById=js,i.selectAssetTypeFieldValuesMapping=kc,i.selectAssetTypeFieldValuesOfAsset=mm,i.selectAssetTypeFields=Xe,i.selectAssetTypeFieldsAttachmentById=Xh,i.selectAssetTypeFieldsAttachments=mc,i.selectAssetTypeFieldsAttachmentsMapping=hc,i.selectAssetTypeFieldsById=nm,i.selectAssetTypeFieldsMapping=bc,i.selectAssetTypeFieldsOfAssetType=sm,i.selectAssetTypeValuesOfAssetType=fm,i.selectAssetTypes=bm,i.selectAssetTypesByIds=_m,i.selectAssetTypesMapping=Ds,i.selectAssets=Va,i.selectAssetsByIds=qh,i.selectAssetsMapping=as,i.selectAssetsOfAssetType=cs,i.selectAttachmentsOfAsset=Kn,i.selectAttachmentsOfAssetByType=Hu,i.selectAttachmentsOfAssetProcedureFieldValues=pa,i.selectAttachmentsOfAssetProcedureFields=Zu,i.selectAttachmentsOfAssetType=ac,i.selectAttachmentsOfAssetTypeByType=Lh,i.selectAttachmentsOfAssetTypeFieldValues=Oc,i.selectAttachmentsOfAssetTypeFields=Jh,i.selectAttachmentsOfDocument=qm,i.selectAttachmentsOfDocumentByType=Mm,i.selectAttachmentsOfFormRevision=Hm,i.selectAttachmentsOfFormSubmission=Hr,i.selectAttachmentsOfIssue=Ro,i.selectAttachmentsOfIssueByType=yf,i.selectAttachmentsOfIssueTypeFieldValues=dd,i.selectAttachmentsOfIssueTypeFields=Of,i.selectAttachmentsOfProject=Il,i.selectAttachmentsOfProjectByType=Pp,i.selectCategories=Pm,i.selectCategoriesByIds=Om,i.selectCategoryById=$s,i.selectCategoryMapping=Us,i.selectCommentsOfIssue=bf,i.selectConversation=Bu,i.selectConversationMapping=vt,i.selectConversations=$u,i.selectCurrentUser=mt,i.selectDeletedRequests=_p,i.selectDocumentAttachmentById=tr,i.selectDocumentAttachmentMapping=er,i.selectDocumentById=rr,i.selectDocuments=cr,i.selectDocumentsByIds=km,i.selectDocumentsMapping=_e,i.selectEmailDomains=mr,i.selectEmailDomainsAsMapping=hr,i.selectEmailDomainsOfOrganization=Cm,i.selectFieldValuesOfAssetProcedureInstance=Ah,i.selectFilteredForms=xm,i.selectFormById=$r,i.selectFormMapping=Ur,i.selectFormRevisionAttachmentsMapping=Rr,i.selectFormRevisionById=Km,i.selectFormRevisionMapping=tt,i.selectFormRevisions=qr,i.selectFormRevisionsOfForm=kr,i.selectFormSubmissionAttachemntsByIds=Nr,i.selectFormSubmissionAttachmentsMapping=si,i.selectFormSubmissionById=oi,i.selectFormSubmissions=ri,i.selectFormSubmissionsMapping=ci,i.selectFormSubmissionsOfAsset=Qr,i.selectFormSubmissionsOfForm=Xr,i.selectFormSubmissionsOfIssue=Zr,i.selectForms=Qm,i.selectGeoImageById=ui,i.selectGeoImageMapping=ro,i.selectGeoImages=oo,i.selectGeoImagesOfProject=df,i.selectIsImportingProjectFile=kp,i.selectIsLoggedIn=Rm,i.selectIssueAssociationById=fo,i.selectIssueAssociationMapping=Ce,i.selectIssueAssociations=mf,i.selectIssueAssociationsOfAsset=yo,i.selectIssueAssociationsOfIssue=Ao,i.selectIssueAssociationsToIssue=po,i.selectIssueAttachmentById=Po,i.selectIssueAttachmentMapping=Io,i.selectIssueAttachments=bi,i.selectIssueById=vi,i.selectIssueCommentById=jo,i.selectIssueCommentMapping=Eo,i.selectIssueCountOfCategory=vm,i.selectIssueMapping=Vo,i.selectIssueTypeById=$i,i.selectIssueTypeFieldValues=Mi,i.selectIssueTypeFieldValuesAttachmentById=Jf,i.selectIssueTypeFieldValuesAttachments=rd,i.selectIssueTypeFieldValuesAttachmentsByIds=od,i.selectIssueTypeFieldValuesAttachmentsMapping=Vi,i.selectIssueTypeFieldValuesById=ki,i.selectIssueTypeFieldValuesMapping=Jo,i.selectIssueTypeFieldValuesOfIssue=kf,i.selectIssueTypeFields=ot,i.selectIssueTypeFieldsAttachmentById=vf,i.selectIssueTypeFieldsAttachments=Ho,i.selectIssueTypeFieldsAttachmentsMapping=No,i.selectIssueTypeFieldsById=Lf,i.selectIssueTypeFieldsMapping=sd,i.selectIssueTypeFieldsOfIssueType=$f,i.selectIssueTypeMapping=pd,i.selectIssueTypeValuesOfIssueType=Gf,i.selectIssueTypes=Ad,i.selectIssueTypesByIds=Xf,i.selectIssueTypesOfOrganization=Zf,i.selectIssueUpdateMapping=Id,i.selectIssueUpdatesOfIssue=Rd,i.selectIssuesByIds=_f,i.selectIssuesOfIssueType=Bi,i.selectIssuesOfIssueTypeCount=Qf,i.selectLatestAssetProcedureFieldsOfAssetProcedure=ah,i.selectLatestAssetTypeFieldsOfAssetType=im,i.selectLatestFormRevisionOfForm=Ym,i.selectLatestIssueTypeFieldsOfIssueType=Bf,i.selectLatestRetryTime=Tp,i.selectLicense=tp,i.selectLicenseForProject=wd,i.selectLicenses=ht,i.selectLicensesForProjectsMapping=ip,i.selectLicensesOfOrganization=gp,i.selectNumberOfAssetsOfAssetType=Mh,i.selectOrganizationAccessById=dp,i.selectOrganizationAccessForUser=up,i.selectOrganizationAccessUserMapping=Ud,i.selectOrganizationAccesses=Wi,i.selectOrganizationById=Ap,i.selectOrganizationUsersAsMapping=rl,i.selectOrganizationUsersIds=cl,i.selectOrganizations=al,i.selectOrganizationsMapping=nl,i.selectOrganizationsWithAccess=yp,i.selectProjectAccessById=hp,i.selectProjectAccessForUser=mp,i.selectProjectAccessMapping=Ji,i.selectProjectAccessUserMapping=Wd,i.selectProjectAccesses=Hd,i.selectProjectAttachmentById=Fl,i.selectProjectAttachmentMapping=Tl,i.selectProjectById=fp,i.selectProjectFileById=qp,i.selectProjectFileMapping=kl,i.selectProjectFiles=Dl,i.selectProjectMapping=Zi,i.selectProjectUsersAsMapping=tl,i.selectProjectUsersIds=el,i.selectProjectsOfOrganization=Sp,i.selectRehydrated=Vp,i.selectRootDocuments=zm,i.selectSortedOrganizationUsers=bp,i.selectSortedProjectUsers=pp,i.selectStageMapping=Je,i.selectTeamById=Re,i.selectTeams=un,i.selectTeamsByIds=Cp,i.selectTeamsMapping=ln,i.selectTeamsOfOrganization=Up,i.selectTeamsOfUser=$p,i.selectUploadUrl=Sr,i.selectUserById=rp,i.selectUsersByIds=op,i.selectUsersMapping=ft,i.separateFilesFromValues=ve,i.separateImageFromFields=$A,i.setActiveProjectFileId=ql,i.setAsset=Eh,i.setAssetAttachment=Gn,i.setAssetAttachments=Lu,i.setAssetProcedure=Rh,i.setAssetProcedureFieldValues=mh,i.setAssetProcedureFieldValuesAttachment=oh,i.setAssetProcedureFieldValuesAttachments=dh,i.setAssetProcedureFieldValuesMany=fh,i.setAssetProcedureFields=eh,i.setAssetProcedureFieldsAttachment=Ku,i.setAssetProcedureFieldsAttachments=Yu,i.setAssetProcedureFieldsMany=th,i.setAssetProcedureInstance=Sh,i.setAssetProcedureInstances=gh,i.setAssetProcedures=Ph,i.setAssetStage=Ya,i.setAssetStages=Dh,i.setAssetType=pm,i.setAssetTypeAttachment=ec,i.setAssetTypeAttachments=Bh,i.setAssetTypeFieldValues=um,i.setAssetTypeFieldValuesAttachment=cm,i.setAssetTypeFieldValuesAttachments=rm,i.setAssetTypeFieldValuesMany=hm,i.setAssetTypeFields=Qh,i.setAssetTypeFieldsAttachment=Hh,i.setAssetTypeFieldsAttachments=Wh,i.setAssetTypeFieldsMany=xh,i.setAssetTypes=Am,i.setAssets=jh,i.setConversation=Cn,i.setCurrentUser=np,i.setDocumentAttachment=Xc,i.setDocumentAttachments=Em,i.setDocuments=nr,i.setForm=Jm,i.setFormRevision=vr,i.setFormRevisionAttachment=Bm,i.setFormRevisionAttachments=Gm,i.setFormSubmission=nt,i.setFormSubmissionAttachment=tf,i.setFormSubmissionAttachments=sf,i.setFormSubmissions=cf,i.setGeoImage=Ve,i.setGeoImages=so,i.setIsImportingProjectFile=jl,i.setIssueAssociation=uf,i.setIssueAssociations=lf,i.setIssueAttachment=_o,i.setIssueAttachments=pf,i.setIssueComment=Ti,i.setIssueComments=wo,i.setIssueType=$e,i.setIssueTypeFieldValues=Ef,i.setIssueTypeFieldValuesAttachment=Hf,i.setIssueTypeFieldValuesAttachments=Wf,i.setIssueTypeFieldValuesMany=jf,i.setIssueTypeFields=zf,i.setIssueTypeFieldsAttachment=Ff,i.setIssueTypeFieldsAttachments=If,i.setIssueTypeFieldsMany=Vf,i.setIssueUpdate=xf,i.setLoggedIn=$c,i.setOrganizations=il,i.setProfilePicture=ap,i.setProjectAttachment=Sl,i.setProjectAttachments=gl,i.setProjectFile=Op,i.setProjectFiles=vp,i.setProjects=Jd,i.setRehydrated=zp,i.setTeam=Ie,i.setTokens=Tm,i.setUploadUrl=yr,i.setUsers=qd,i.shallowEqual=vn,i.slugify=zu,i.spacesToDashesLower=Du,i.teamReducer=Bl,i.teamSlice=rn,i.toFileNameSafeString=ku,i.toOfflineIdRecord=Mn,i.truncate=Vu,i.updateAsset=Me,i.updateAssetAttachment=Nu,i.updateAssetAttachments=Ln,i.updateAssetProcedure=qe,i.updateAssetProcedureFieldValues=Ee,i.updateAssetProcedureFieldValuesAttachment=lh,i.updateAssetProcedureFieldValuesAttachments=ha,i.updateAssetProcedureFieldValuesMany=ba,i.updateAssetProcedureFields=ca,i.updateAssetProcedureFieldsAttachment=Ju,i.updateAssetProcedureFieldsAttachments=Qn,i.updateAssetProcedureFieldsMany=sh,i.updateAssetProcedureInstance=je,i.updateAssetProcedureInstances=yh,i.updateAssetProcedures=Fh,i.updateAssetStage=As,i.updateAssetStageCompletion=Ba,i.updateAssetStageCompletions=Ga,i.updateAssetStages=Ye,i.updateAssetType=De,i.updateAssetTypeAttachment=Gh,i.updateAssetTypeAttachments=tc,i.updateAssetTypeFieldValues=ke,i.updateAssetTypeFieldValuesAttachment=om,i.updateAssetTypeFieldValuesAttachments=Ic,i.updateAssetTypeFieldValuesMany=qc,i.updateAssetTypeFields=Sc,i.updateAssetTypeFieldsAttachment=Kh,i.updateAssetTypeFieldsAttachments=lc,i.updateAssetTypeFieldsMany=em,i.updateAssetTypes=Sm,i.updateAssets=wh,i.updateCategory=Nc,i.updateConversation=Un,i.updateDocumentAttachment=jm,i.updateDocumentAttachments=Zc,i.updateDocuments=le,i.updateForm=Zm,i.updateFormRevisionAttachment=Lm,i.updateFormRevisionAttachments=Fr,i.updateFormSubmission=Jr,i.updateFormSubmissionAttachment=nf,i.updateFormSubmissionAttachments=Lr,i.updateFormSubmissions=rf,i.updateGeoImage=ao,i.updateGeoImages=of,i.updateIssue=rt,i.updateIssueAssociation=mo,i.updateIssueAssociations=hf,i.updateIssueAttachment=Af,i.updateIssueAttachments=To,i.updateIssueType=fd,i.updateIssueTypeFieldValues=Ue,i.updateIssueTypeFieldValuesAttachment=Kf,i.updateIssueTypeFieldValuesAttachments=cd,i.updateIssueTypeFieldValuesMany=qf,i.updateIssueTypeFields=ed,i.updateIssueTypeFieldsAttachment=Rf,i.updateIssueTypeFieldsAttachments=Go,i.updateIssueTypeFieldsMany=Cf,i.updateLicense=oe,i.updateOrganizationAccess=Vd,i.updateProject=Xd,i.updateProjectAccess=Gd,i.updateProjectAttachment=Rp,i.updateProjectAttachments=bl,i.updateProjectFile=an,i.updateProjectFiles=Ep,i.updateTeam=on,i.userReducer=kd,i.userSlice=Ni,i.versioningReducer=Ll,i.versioningSlice=Gl,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
15
|
+
external URLs and therefore not prepended with VITE_API_URL.`;throw new Error(A)}const f=o.type.split("/")[1];if(!f)throw new Error("File has no extension");const p=a??h+"."+f;if(o=wn(o,p),!o.name)throw new Error("Failed to set file's name");await this.addCache(o,h),At[c]=new Promise(A=>{A(o)})}return o}}class CA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{revisionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,form_revision:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,field_identifier:f,file_extension:A.extension,file_sha1:A.sha1,form_revision:h};r.push(T)}this.dispatch(Tr(c));const d=this.enqueueRequest({description:"Attach files to form revision",method:u.POST,url:"/form-revision-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.form_revision),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(Fr(o.attachments))}).catch(()=>{this.dispatch(Ir(c.map(o=>o.offline_id)))}),[c,d.then(({attachments:o})=>o)]}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization form revision attachments",method:u.GET,url:"/form-revision-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(_r(s))}}class UA extends E{add(e){var d;const{store:s}=this.client,a=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,c=F({...e,created_by:a,revision:"Pending",submitted_at:new Date().toISOString()});this.dispatch(Js(c));const r=this.enqueueRequest({description:"Create form revision",method:u.POST,url:"/form-revisions/",payload:c,blockers:[e.form],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(vr(m))}).catch(()=>{this.dispatch(Xs(c.offline_id))}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization form revisions",method:u.GET,url:"/form-revisions/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(wr(s))}}const $A=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(d){console.error("Failed to get image from promise",d)}else e[r.identifier]=r.image;delete r.image}c.push(r)}s.push({...n,fields:c})}return{fields:s,images:e}};class BA extends E{add(e,s){var o;const{store:n}=this.client,a=new Date().toISOString(),c=(o=n.getState().userReducer.currentUser)==null?void 0:o.id,r=F({...e,submitted_at:a,created_by:c}),d=F({...s,form:r.offline_id,revision:"Pending",submitted_at:a,created_by:c});this.dispatch(Qs(r)),this.dispatch(Js(d));const m=this.enqueueRequest({description:"Create form",method:u.POST,url:"/forms/",payload:{...r,initial_revision:{offline_id:d.offline_id,submitted_at:d.submitted_at,title:d.title,description:d.description,fields:d.fields}},blockers:[],blocks:[r.offline_id,d.offline_id]});return m.catch(h=>{throw this.dispatch(xs(r.offline_id)),this.dispatch(Xs(d.offline_id)),h}),[r,d,m]}async delete(e){const{store:s}=this.client,n=s.getState(),a=$r(e)(n);if(!a)throw new Error("Expected form to exist");const c=Xr(e)(n);c.length>0&&this.dispatch(ct(c.map(({offline_id:d})=>d)));const r=kr(e)(n);r.length>0&&this.dispatch(jr(r.map(({offline_id:d})=>d))),this.dispatch(xs(e));try{return await this.enqueueRequest({description:"Delete form",method:u.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(d){throw this.dispatch(Qs(a)),r.length>0&&this.dispatch(Er(r)),c.length>0&&this.dispatch(at(c)),d}}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch organization forms",method:u.GET,url:"/forms/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch(Vr(s))}}class GA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{submissionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,form_submission:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,file_sha1:A.sha1,file_extension:A.extension,field_identifier:f,form_submission:h};r.push(T)}this.dispatch(st(c));const d=this.enqueueRequest({description:"Attach files to form submission",method:u.POST,url:"/form-submission-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.form_submission),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(Lr(o.attachments))}).catch(o=>{throw this.dispatch(it(c.map(h=>h.offline_id))),o}),[c,d.then(({attachments:o})=>o)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=Nr(e)(n);this.dispatch(it(e));try{await this.enqueueRequest({description:"Delete form submission attachments",method:u.DELETE,url:"/form-submission-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(c){throw this.dispatch(st(a)),c}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get form submission attachments",method:u.GET,url:"/form-submission-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Gr(s))}}class LA extends E{async add(e){var f;const{store:s}=this.client,{file:n,...a}=e,c=new Date().toISOString(),r=(f=s.getState().userReducer.currentUser)==null?void 0:f.id,d=a.project,m=await this.getFilePayload(n),o=F({...a,file_name:n.name,file_sha1:m.sha1,file:URL.createObjectURL(n),index:null,submitted_at:c,created_by:r});this.dispatch(io(o));const h=this.enqueueRequest({description:"Add geo image",method:u.POST,url:"/geo-images/",payload:{offline_id:o.offline_id,submitted_at:c,title:o.title,description:o.description,geo_marker:o.geo_marker,canvas_marker:o.canvas_marker,sha1:o.file_sha1,project:o.project,file_name:o.file_name,direction:o.direction,original_date:o.original_date,file:m},blocks:[d.toString()],blockers:[d.toString()]});return h.then(p=>{this.processPresignedUrls(p.presigned_urls),this.dispatch(Ve(p.geo_image))}).catch(()=>{this.dispatch(di(o.offline_id))}),[o,h.then(p=>p.geo_image)]}async bulkAdd(e,s){var f;const{store:n}=this.client,a=new Date().toISOString(),c=(f=n.getState().userReducer.currentUser)==null?void 0:f.id,r=[],d=[],m=[],o={};for(const p of e){const{file:A,..._}=p,T=await this.getFilePayload(A);T.sha1 in o||(o[T.sha1]=T);const b=F({..._,file_name:A.name,file_sha1:T.sha1,file:URL.createObjectURL(A),submitted_at:a,index:null,created_by:c,project:s});r.push(b),d.push(b.offline_id),m.push({offline_id:b.offline_id,sha1:b.file_sha1,file_name:b.file_name,title:b.title,description:b.description,geo_marker:b.geo_marker,canvas_marker:b.canvas_marker,direction:b.direction,original_date:b.original_date})}this.dispatch(no(r));const h=this.enqueueRequest({description:"Bulk add geo images",method:u.POST,url:"/geo-images/bulk/",payload:{submitted_at:a,project:s,geo_images:m,files:Object.values(o)},blocks:[s.toString()],blockers:d});return h.then(p=>{this.processPresignedUrls(p.presigned_urls),this.dispatch(so(p.geo_images))}).catch(()=>{this.dispatch(co(d))}),[r,h.then(p=>p.geo_images)]}update(e){const{store:s}=this.client,n=s.getState(),a=li(e.offline_id)(n);if(!a)throw new Error(`Map image with offline_id ${e.offline_id} does not exist in the store`);const c={...a,...e};this.dispatch(ao(c));const r=this.enqueueRequest({description:"Update geo image",method:u.PATCH,url:`/geo-images/${e.offline_id}/`,payload:e,blocks:[e.offline_id],blockers:[e.offline_id]});return r.then(d=>{this.dispatch(Ve(d))}).catch(()=>{this.dispatch(Ve(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=li(e)(n);if(!a)throw new Error(`Map image with offline_id ${e} does not exist in the store`);this.dispatch(di(e));const c=this.enqueueRequest({description:"Delete geo image",method:u.DELETE,url:`/geo-images/${e}/`,blocks:[e],blockers:[e]});return c.catch(()=>{this.dispatch(Ve(a))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get geo images",method:u.GET,url:`/projects/${e}/geo-images/`,blocks:[e.toString()],blockers:[]});this.dispatch(to(s))}}class NA extends R{add(e){var d;const{store:s}=this.client,n=new Date().toISOString(),a=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,c=F({...e,submitted_at:n,created_by:a});this.dispatch(hi(c));const r=this.enqueueRequest({description:"Add issue association",method:u.POST,url:"/issue-associations/",payload:{offline_id:c.offline_id,submitted_at:n,...e},blockers:[e.associated_issue,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(mo(m))}).catch(()=>{this.dispatch(fi(c.offline_id))}),[c,r]}async delete(e){const{store:s}=this.client,n=fo(e)(s.getState());if(!n)throw new Error(`Issue association with id ${e} not found in store.`);this.dispatch(fi(e));const a=this.enqueueRequest({description:"Delete issue association",method:u.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return a.catch(()=>{this.dispatch(hi(n))}),a}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch issue associations",method:u.GET,url:"/issue-associations/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(ho(s))}}class HA extends Le{constructor(){super(...arguments);g(this,"name","Issue Attachment");g(this,"url","/issue-attachments");g(this,"addAttachments",yi);g(this,"updateAttachments",To);g(this,"removeAttachments",Si);g(this,"removeAttachment",Fo);g(this,"setAttachment",_o);g(this,"selectAttachment",Po)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,issue:s.modelId})}buildAttachmentPayload(s){return{...s,issue:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.issueId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get issue attachments",method:u.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blocks:[],blockers:[]});this.dispatch(bo(n))}}class WA extends R{add(e){var c;const{store:s}=this.client,n=F({...e,author:(c=s.getState().userReducer.currentUser)==null?void 0:c.id,submitted_at:new Date().toISOString()});this.dispatch(Ti(n));const a=this.enqueueRequest({description:"Add issue comment",method:u.POST,url:"/issue-comments/",payload:n,blockers:[e.issue],blocks:[n.offline_id]});return a.catch(()=>{this.dispatch(Fi(n.offline_id))}),[n,a]}update(e){const{store:s}=this.client,n=jo(e.offline_id)(s.getState());if(!n)throw new Error(`Comment with offline_id ${e.offline_id} not found in store`);const a={...n,...e};this.dispatch(_i(a));const c=this.enqueueRequest({description:"Edit issue comment",method:u.PATCH,url:`/issue-comments/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.catch(()=>{this.dispatch(_i(n))}),[a,c]}remove(e){const s=this.client.store.getState().issueCommentReducer.instances[e];if(!s)throw new Error(`Comment with offline_id ${e} not found in store`);this.dispatch(Fi(e));const n=this.enqueueRequest({description:"Delete comment",method:u.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return n.catch(()=>{this.dispatch(Ti(s))}),n}async refreshStore(e){const s=await this.enqueueRequest({description:"Get comments",method:u.GET,url:"/issue-comments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(wo(s))}}class KA extends R{add(e){var m;const{store:s}=this.client,n=s.getState(),a=new Date().toISOString(),c=(m=n.userReducer.currentUser)==null?void 0:m.id,r=F({...e,index:null,submitted_at:a,created_by:c});this.dispatch(Ri(r));const d=this.enqueueRequest({description:"Create issue",method:u.POST,url:"/issues/",payload:r,blockers:["add-issue",r.project.toString(),r.issue_type,...r.category?[r.category]:[]],blocks:[r.offline_id]});return d.then(o=>{this.dispatch(rt(o))}).catch(o=>{throw this.dispatch(Pi(r.offline_id)),o}),[r,d]}update(e){var m;const s=this.client.store.getState(),n=Oi(e.offline_id)(s);if(!n)throw new Error(`Attempting to update an issue with offline_id ${e.offline_id} that doesn't exist in the store`);const a={...n,...e};this.dispatch(rt(a));const c={};for(const o of[v.TITLE,v.DESCRIPTION,v.STATUS,v.CATEGORY,v.PRIORITY,v.ASSIGNED_TO,v.DUE_DATE])if(o in e&&e[o]!==n[o])switch(o){case v.PRIORITY:case v.STATUS:{const h=e[o];c[o]=h!==void 0?Number(h):null;break}case v.DUE_DATE:case v.DESCRIPTION:case v.TITLE:c[o]=e[o]??null;break;case v.CATEGORY:{let h=null;const f=e[o];if(f&&(h=s.categoryReducer.instances[f]??null,!h))throw new Error(`Trying to update issue category to ${f} which does not exist in store`);c[o]=h?{name:h.name,color:h.color,offline_id:h.offline_id}:null;break}case v.ASSIGNED_TO:{let h=null;const f=e[o];if(f&&(h=s.userReducer.users[f]??null,!h))throw new Error(`Trying to update issue assigned_to to ${f} which does not exist in store`);c[o]=h?{full_name:h.username,id:h.id}:null;break}}const r=F({created_by:(m=s.userReducer.currentUser)==null?void 0:m.id,submitted_at:new Date().toISOString(),issue:n.offline_id,changes:c});this.dispatch(bd(r));const d=this.enqueueRequest({description:"Edit issue",method:u.PATCH,url:`/issues/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return d.catch(()=>{this.dispatch(rt(n)),this.dispatch(Td(r.offline_id))}),[a,d]}async remove(e){const{store:s}=this.client,n=s.getState(),a=Oi(e)(n);if(!a)throw new Error(`No issue with id ${e} found in the store`);const c=Ro(e)(n),r=Rd(e)(n),d=Zr(e)(n),m={};for(const h of po(e)(n))m[h.offline_id]=h;for(const h of Ao(e)(n))m[h.offline_id]=h;const o=Object.values(m);this.dispatch(Pi(e)),c.length>0&&this.dispatch(Si(c.map(({offline_id:h})=>h))),r.length>0&&this.dispatch(Fd(r.map(({offline_id:h})=>h))),d.length>0&&this.dispatch(ct(d.map(({offline_id:h})=>h))),o.length>0&&this.dispatch(pi(o.map(({offline_id:h})=>h)));try{return await this.enqueueRequest({description:"Delete issue",method:u.DELETE,url:`/issues/${e}/`,blockers:[e],blocks:[]})}catch(h){throw this.dispatch(Ri(a)),this.dispatch(yi(c)),this.dispatch(_d(r)),this.dispatch(at(d)),this.dispatch(mi(o)),h}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issues",method:u.GET,url:"/issues/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(ko(s))}}class YA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{fieldsRevisionId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,fields_revision:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,file_extension:A.extension,field_identifier:f,file_sha1:A.sha1,fields_revision:h};r.push(T)}this.dispatch(Bo(c));const d=this.enqueueRequest({description:"Add issue type fields attachments",method:u.POST,url:"/issue-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.fields_revision),blocks:c.map(o=>o.offline_id)});return d.then(o=>{this.processPresignedUrls(o.presigned_urls),this.dispatch(Go(o.attachments))}).catch(()=>{this.dispatch(Lo(c.map(o=>o.offline_id)))}),[c,d.then(({attachments:o})=>o)]}async refreshStore(e){const s=await this.enqueueRequest({description:"get issue type fields attachments",method:u.GET,url:"/issue-type-fields-attachments/",queryParams:{organization:e.toString()},blockers:[e.toString()],blocks:[]});this.dispatch($o(s))}}class JA extends R{add(e){var d;const{store:s}=this.client,n=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,a=new Date().toISOString(),c=F({...e,created_by:n,submitted_at:a});this.dispatch(xo(c));const r=this.enqueueRequest({description:"Add Issue Type Fields",method:u.POST,url:"/issue-type-fields/",payload:c,blockers:[c.issue_type],blocks:[c.offline_id]});return r.then(m=>{this.dispatch(ed(m))}).catch(m=>{throw this.dispatch(td(c.offline_id)),m}),[c,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Issue Type Fields",method:u.GET,url:"/issue-type-fields/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(Qo(s))}}class XA extends E{async bulkAdd(e){var m;const s=new Date().toISOString(),n=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,a={},c=[],r=[];for(const o of e){const{fieldValuesId:h,fieldIdentifier:f,file:p}=o,A=await this.getFilePayload(p);A.sha1 in a||(a[A.sha1]=A);const _=F({file:URL.createObjectURL(p),file_type:p.type,file_name:p.name,file_sha1:A.sha1,created_by:n,field_values:h,submitted_at:s,field_identifier:f});c.push(_);const T={offline_id:_.offline_id,file_name:p.name,file_sha1:A.sha1,file_extension:A.extension,field_identifier:f,field_values:h};r.push(T)}this.dispatch(dt(c));const d=this.enqueueRequest({description:"Add issue type field values attachments",method:u.POST,url:"/issue-type-field-values-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(a)},blockers:c.map(o=>o.field_values),blocks:c.map(o=>o.offline_id)});return d.then(({presigned_urls:o,attachments:h})=>{this.processPresignedUrls(o),this.dispatch(cd(h))}).catch(o=>{throw this.dispatch(lt(c.map(h=>h.offline_id))),o}),[c,d.then(({attachments:o})=>o)]}async bulkDelete(e){const{store:s}=this.client,n=s.getState(),a=od(e)(n);this.dispatch(lt(e));try{await this.enqueueRequest({description:"Delete issue type field values attachments",method:u.DELETE,url:"/issue-type-field-values-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 issue type field values attachments",method:u.GET,url:"/issue-type-field-values-attachments/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(ad(s))}}class ZA extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,created_by:(r=n.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),c=this.enqueueRequest({description:"Add issue type field values",method:u.POST,url:"/issue-type-field-values/",payload:a,blockers:[e.issue,e.fields_revision],blocks:[a.offline_id]});return this.dispatch(Ei(a)),c.then(d=>(this.dispatch(Ue(d)),d)).catch(()=>{this.dispatch(ji(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=Mi(e.offline_id)(n);if(!a)throw new Error(`Expected IssueTypeFieldValues with offline_id ${e.offline_id} to exist`);const c={...a,...e};this.dispatch(Ue(c));const r=this.enqueueRequest({description:"Update issue type field values",method:u.PATCH,url:`/issue-type-field-values/${e.offline_id}/`,payload:e,blockers:[c.offline_id,c.fields_revision,c.issue],blocks:[c.offline_id]});return r.then(d=>{this.dispatch(Ue(d))}).catch(()=>{this.dispatch(Ue(a))}),[c,r]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Mi(e)(n);if(!a)throw new Error(`Expected submission with offline_id ${e} to exist`);const c=dd(e)(n);this.dispatch(ji(e)),this.dispatch(lt(c.map(r=>r.offline_id)));try{await this.enqueueRequest({description:"Delete issue type field values",method:u.DELETE,url:`/issue-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Ei(a)),this.dispatch(dt(c)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue type field values",method:u.GET,url:"/issue-type-field-values/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(Yo(s))}}class QA extends R{add(e){var r;const{store:s}=this.client,n=s.getState(),a=F({...e,submitted_at:new Date().toISOString(),created_by:(r=n.userReducer.currentUser)==null?void 0:r.id});this.dispatch(md(a));const c=this.enqueueRequest({method:u.POST,url:"/issue-types/",payload:a,blockers:[],blocks:[a.offline_id]});return c.then(d=>{this.dispatch($e(d))}).catch(()=>{this.dispatch(Ci(a.offline_id))}),[a,c]}update(e){const{store:s}=this.client,n=s.getState(),a=Ui(e.offline_id)(n);if(!a)throw new Error(`IssueType with offline_id ${e.offline_id} does not exist in the store.`);const c={...a,...e};this.dispatch(fd(c));const r=this.enqueueRequest({method:u.PATCH,url:`/issue-types/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return r.then(d=>{this.dispatch($e(d))}).catch(()=>{this.dispatch($e(a))}),[c,r]}delete(e){const{store:s}=this.client,n=s.getState(),a=Ui(e)(n);if(!a)throw new Error(`IssueType with offline_id ${e} does not exist in the store.`);const c=$i(e)(n);this.dispatch(Ci(e)),this.dispatch(zo(c.map(d=>d.offline_id)));const r=this.enqueueRequest({method:u.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return r.catch(()=>{this.dispatch($e(a)),this.dispatch(Do(c))}),r}async refreshStore(e){const s=await this.enqueueRequest({method:u.GET,url:"/issue-types/",queryParams:{organization:e.toString()},blockers:[],blocks:[]});this.dispatch(hd(s))}}class xA extends R{async refreshStore(e){const s=await this.enqueueRequest({description:"Get issue updates",method:u.GET,url:"/issue-updates/",queryParams:{project:e.toString()},blockers:[],blocks:[]});this.dispatch(gd(s))}}class ey extends Kl{constructor(e){super(e)}}const ty=1800;function sy(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 iy extends ey{constructor(){super(...arguments);g(this,"_getRenewedTokens",async s=>{const n=this.enqueueRequest({description:"Get renewed tokens",method:u.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(Uc(!1)),this.clearTokens(),this.dispatch({type:pu.RESET_STATE}),this.dispatch({type:tu})}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=Au(s).exp??n}catch{a=n}return a-n<ty}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 j&&this.clearAuth(),s instanceof Error?Promise.reject(s):Promise.reject(new Error((s??Pe).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 j({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 j({message:"Incorrect username or password.",response:n,discard:!0})}async initAuth(s){const n=O.v4();return console.debug(this.constructor.name,"Initiating auth"),this.enqueueRequest({uuid:n,description:"Get token pair",method:u.POST,url:this.initTokensUrl,payload:s,isAuthNeeded:!1,checkAuth:!1,immediate:!0,blockers:[],blocks:[]}).then(a=>{this.setTokens(sy(a))})}}class ny extends R{async getLicense(e){const s=await this.enqueueRequest({description:"Get license",method:u.GET,url:`/billing/${e.offline_id}/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(oe(s)),s}async pauseLicense(e){const s=await this.enqueueRequest({description:"Pause license",method:u.DELETE,url:`/billing/${e.offline_id}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(oe(s)),s}async resumeLicense(e){const s=await this.enqueueRequest({description:"Resume license",method:u.PATCH,url:`/billing/${e.offline_id}/suspend/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(oe(s)),s}async cancelLicense(e){const s=await this.enqueueRequest({description:"Cancel license",method:u.DELETE,url:`/billing/${e.offline_id}/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:[]});return this.dispatch(oe(s)),s}async attachLicenseToProject(e,s){const n=await this.enqueueRequest({description:"Attach license",method:u.PATCH,url:`/billing/${e.offline_id}/project/`,isAuthNeeded:!0,payload:{project:s.id},blockers:[e.organization_owner?e.organization_owner.toString():"",s.id?s.id.toString():""],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(oe(n)),n}async detachLicenseFromProject(e){const s=await this.enqueueRequest({description:"Detach license",method:u.DELETE,url:`/billing/${e.offline_id}/project/`,isAuthNeeded:!0,blockers:[e.organization_owner?e.organization_owner.toString():""],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});return this.dispatch(oe(s)),s}async getLatestTransaction(e){return await this.enqueueRequest({description:"Get latest transaction",method:u.GET,url:`/billing/${e.offline_id}/transaction/`,isAuthNeeded:!0,blockers:[e.offline_id],blocks:[e.offline_id]})}async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Get licenses",method:u.GET,url:`/organizations/${s}/licenses/`,isAuthNeeded:!0,blockers:[s.toString()],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of a)n[r.offline_id]=r;const c=await this.enqueueRequest({description:"Get licenses",method:u.GET,url:`/projects/${e}/licenses/`,isAuthNeeded:!0,blockers:[e.toString()],blocks:["add-issue","add-form-entry","change-access-level","add-workspace"]});for(const r of c)n[r.offline_id]=r;this.dispatch(vd(Object.values(n)))}}class ay extends R{async update(e){const s=this.enqueueRequest({description:"Edit organization access",method:u.PATCH,url:`/organizations/${e.organization}/access/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return s.then(()=>{this.dispatch(Vd(e))}),s}async remove(e){return this.dispatch(Cd(e.offline_id)),this.dispatch(Md(e.user)),this.enqueueRequest({description:"Remove organization access",method:u.DELETE,url:`/organizations/${e.organization}/access/${e.offline_id}/`,blockers:[e.offline_id],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get organization accesses",method:u.GET,url:`/organizations/${e}/access/`,blockers:[],blocks:[]});this.dispatch(zd(s))}}class cy extends R{create(e){return this.enqueueRequest({description:"Create organization",method:u.POST,url:"/organizations/",payload:{name:e},blockers:[],blocks:[`add-org-${e}`,"create-org"]})}async update(e){return this.enqueueRequest({description:"Edit organization",method:u.PATCH,url:`/organizations/${e.id}/`,payload:e,blockers:[`add-org-${e.name}`,e.id.toString()],blocks:[e.id.toString()]})}async invite(e,s){return this.enqueueRequest({description:"Invite user to organization",method:u.POST,url:`/organizations/${e}/invite/${s}/`,blockers:[],blocks:[]})}async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Get organizations",method:u.GET,url:`/projects/${e}/organizations/`,blockers:[],blocks:[]});for(const r of a)n[r.id]=r;const c=await this.enqueueRequest({description:"Get organization",method:u.GET,url:`/organizations/${s}/`,blockers:[],blocks:[]});n[c.id]=c,this.dispatch(il(Object.values(n)))}}class ry extends R{async update(e){return this.dispatch(Gd(e)),this.enqueueRequest({description:"Edit project access",method:u.PATCH,url:`/access/${e.offline_id}/`,payload:e,blockers:[e.offline_id,"change-access-level"],blocks:[e.offline_id]})}async remove(e){return this.dispatch(Ld(e)),this.enqueueRequest({description:"Delete project access",method:u.DELETE,url:`/access/${e}/`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project accesses",method:u.GET,url:`/projects/${e}/access/`,blockers:[],blocks:[]});this.dispatch(Ki(s))}}class oy extends Le{constructor(){super(...arguments);g(this,"name","Project Attachment");g(this,"url","/project-attachments");g(this,"addAttachments",yl);g(this,"updateAttachments",bl);g(this,"removeAttachments",en);g(this,"removeAttachment",_l);g(this,"setAttachment",Sl);g(this,"selectAttachment",Fl)}buildOfflineAttachment(s){return F({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,project:s.modelId})}buildAttachmentPayload(s){return{...s,project:s.modelId}}async bulkAdd(s){return this._bulkAdd(s.map(n=>({modelId:n.projectId,file:n.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const n=await this.enqueueRequest({description:"Get project attachments",method:u.GET,url:`${this.url}/`,queryParams:{project:s.toString()},blockers:[],blocks:[]});this.dispatch(Al(n))}}class dy extends R{async saveExisting(e){if(!e.offline_id)throw new Error("You can only use this method to save existing project files. The one provided has no offline_id.");const s={...e};delete s.file;const n=this.enqueueRequest({method:u.PATCH,url:`/projects/files/${e.offline_id}/`,payload:s,blockers:[e.offline_id],blocks:[e.offline_id]});return n.then(a=>{this.dispatch(nn(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:u.PATCH,url:`/projects/files/${n}/`,payload:m,blockers:[n],blocks:[n]}}else c=new Promise((m,o)=>{this.client.files.uploadFileToS3(a.file_sha1).then(([h])=>{m({method:u.POST,url:`/projects/${a.project}/files/`,payload:{...a,...h},blockers:[n],blocks:[n]})}).catch(o)});const d=Promise.resolve(c).then(m=>this.enqueueRequest(m));return d.then(m=>{this.dispatch(nn(m))}),this.dispatch(Ml),this.dispatch(ql(null)),this.dispatch(jl(!1)),[a,d]}delete(e){return this.dispatch(wl(e)),this.enqueueRequest({method:u.DELETE,url:`/projects/files/${e}`,blockers:[e],blocks:[]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get project files",method:u.GET,url:`/projects/${e}/files/`,blockers:[],blocks:[]});this.dispatch(Ol(s))}}class ly extends R{async add(e){if(!e.bounds&&!e.canvas_bounds)throw new Error("Project must either have bounds or canvas_bounds set");return await this.enqueueRequest({description:"Create project",method:u.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(Xd(e)),await this.enqueueRequest({description:"Update project",method:u.PATCH,url:`/projects/${e.id}/`,payload:{name:e.name,bounds:e.bounds},blockers:[e.id.toString()],blocks:[e.id.toString()]})}async delete(e){const{store:s}=this.client,n=s.getState(),a=Xi(n),c=a[e];if(!c)throw new Error("Expected project to exist");const r=Dl(n).filter(h=>h.project===e);this.dispatch(El(r.map(({offline_id:h})=>h)));const d=Il(c.id)(n);this.dispatch(en(d.map(({offline_id:h})=>h)));const m=Hd(n);this.dispatch(Nd(m.map(({offline_id:h})=>h))),this.dispatch({type:"rehydrated/setRehydrated",payload:!1}),this.dispatch(Zd(c));const o=wd(c.id)(n);o&&this.dispatch(oe({...o,project:null}));try{await this.enqueueRequest({description:"Delete project",method:u.DELETE,url:`/projects/${e}/`,blockers:[e.toString()],blocks:[]}),this.dispatch({type:"rehydrated/setRehydrated",payload:!0})}catch(h){throw this.dispatch(Jd(Object.values(a))),this.dispatch(Ki(Object.values(m))),this.dispatch(vl(r)),this.dispatch(gl(d)),this.dispatch({type:"rehydrated/setRehydrated",payload:!0}),o&&this.dispatch(oe({...o,project:c.id})),h}}invite(e,s){const n=O.v4();return this.enqueueRequest({description:"Invite user to project",method:u.POST,url:`/projects/${e}/invite/${s}/`,payload:{offline_id:n},blockers:[],blocks:[n]})}joinProject(e,s,n){return this.enqueueRequest({description:"Join project",method:u.GET,url:`/projects/${e}/join-project/${s}/${n}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}async acceptInvite(e){return this.enqueueRequest({description:"Accept project invite",method:u.PATCH,url:`/projects/${e}/accept-invite/`,blockers:[e.toString()],blocks:[e.toString()]}).then(()=>{this.dispatch(Qd(e))})}}class uy extends R{add(e){const s=F({...e,submitted_at:new Date().toISOString()});this.dispatch($l(s));const n=this.enqueueRequest({description:"Create team",method:u.POST,url:`/organizations/${e.organization}/teams/`,payload:s,blockers:[],blocks:[s.offline_id]});return n.then(a=>{this.dispatch(Ie(a))}).catch(()=>{this.dispatch(on(s.offline_id))}),[s,n]}update(e){const{store:s}=this.client,n=Re(e.offline_id)(s.getState());if(!n)throw new Error(`Expected team with offline_id ${e.offline_id} to exist`);const a={...n,...e};this.dispatch(rn(a));const c=this.enqueueRequest({description:"Update team",method:u.PATCH,url:`/organizations/teams/${e.offline_id}/`,payload:e,blockers:[e.offline_id],blocks:[e.offline_id]});return c.then(r=>{this.dispatch(Ie(r))}).catch(()=>{this.dispatch(Ie(n))}),[a,c]}async delete(e){const{store:s}=this.client,n=s.getState(),a=Re(e)(n);if(!a)throw new Error(`Expected team with id ${e} to exist`);this.dispatch(on(e));try{return await this.enqueueRequest({description:"Delete team",method:u.DELETE,url:`/organizations/teams/${e}/`,blockers:[e],blocks:[e]})}catch(c){throw this.dispatch(Ie(a)),c}}async setMembers(e,s){const{store:n}=this.client,a=Re(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);if(s.length!==new Set(s).size)throw new Error("Duplicate members found in the list");this.dispatch(rn({...a,members:s}));const c=this.enqueueRequest({description:"Set team members",method:u.PUT,url:`/organizations/teams/${e}/set-members/`,payload:{users:s},blockers:[e],blocks:[e]});return c.catch(()=>{this.dispatch(Ie(a))}),c}async addMembers(e,s){const{store:n}=this.client,a=Re(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);const c=[...a.members,...s];return this.setMembers(e,c)}async removeMembers(e,s){const{store:n}=this.client,a=Re(e)(n.getState());if(!a)throw new Error(`Expected team with id ${e} to exist`);const c=a.members.filter(r=>!s.includes(r));return this.setMembers(e,c)}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch teams",method:u.GET,url:`/organizations/${e}/teams/`,blockers:[],blocks:[]});this.dispatch(Ul(s))}}class hy extends R{async refreshStore(e,s){const n={},a=await this.enqueueRequest({description:"Fetch organization users",method:u.GET,url:`/organizations/${s}/users/`,blockers:[],blocks:[]});for(const r of a)n[r.id]=r;const c=await this.enqueueRequest({description:"Fetch project users",method:u.GET,url:`/projects/${e}/users/`,blockers:[],blocks:[]});for(const r of c)n[r.id]=r;this.dispatch(qd(Object.values(n)))}}var ru=(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))(ru||{});i.APIError=j,i.AgentService=hA,i.AssetAttachmentService=mA,i.AssetProcedureFieldValuesAttachmentService=AA,i.AssetProcedureFieldValuesService=gA,i.AssetProcedureFieldsAttachmentService=fA,i.AssetProcedureFieldsService=pA,i.AssetProcedureInstanceService=bA,i.AssetProcedureService=_A,i.AssetService=TA,i.AssetStageCompletionService=FA,i.AssetStageService=IA,i.AssetTypeAttachmentService=RA,i.AssetTypeFieldValuesAttachmentService=vA,i.AssetTypeFieldValuesService=wA,i.AssetTypeFieldsAttachmentService=PA,i.AssetTypeFieldsService=OA,i.AssetTypeService=EA,i.AttachmentModel=_n,i.BaseApiService=R,i.BaseSDK=lA,i.CategoryService=jA,i.DEFAULT_ISSUE_PRIORITY=Su,i.DEFAULT_ISSUE_STATUS=yu,i.DeferredPromise=Pn,i.DocumentAttachmentService=qA,i.DocumentService=MA,i.EMPTY_ARRAY=gn,i.EMPTY_OBJECT=bn,i.EmailDomainsService=kA,i.EmailVerificationService=DA,i.FileService=VA,i.FormRevisionAttachmentService=CA,i.FormRevisionService=UA,i.FormService=BA,i.FormSubmissionAttachmentService=GA,i.FormSubmissionService=SA,i.GeoImageService=LA,i.HttpMethod=u,i.IssueAssociationService=NA,i.IssueAttachmentService=HA,i.IssueCommentService=WA,i.IssuePriority=_t,i.IssueService=KA,i.IssueStatus=Tt,i.IssueTypeFieldValuesAttachmentService=XA,i.IssueTypeFieldValuesService=ZA,i.IssueTypeFieldsAttachmentService=YA,i.IssueTypeFieldsService=JA,i.IssueTypeService=QA,i.IssueUpdateChange=v,i.IssueUpdateService=xA,i.JWTService=iy,i.LicenseLevel=Fn,i.LicenseService=ny,i.LicenseStatus=In,i.OUTBOX_RETRY_DELAY=Rn,i.OrganizationAccessLevel=bt,i.OrganizationAccessService=ay,i.OrganizationService=cy,i.OutboxCoordinator=Oe,i.PaddleCheckoutEvent=Tn,i.ProjectAccessLevel=gt,i.ProjectAccessService=ry,i.ProjectAttachmentService=oy,i.ProjectFileService=dy,i.ProjectService=ly,i.TeamService=uy,i.UNKNOWN_ERROR_MESSAGE=Pe,i.UserService=hy,i.VERSION_REDUCER_KEY=un,i.VerificationCodeType=ru,i._selectLatestFormRevision=Mr,i._setLatestRetryTime=ml,i.acceptProjectInvite=Qd,i.addAsset=ss,i.addAssetAttachment=Gu,i.addAssetAttachments=jt,i.addAssetProcedure=Zt,i.addAssetProcedureFieldValues=$t,i.addAssetProcedureFieldValuesAttachment=rh,i.addAssetProcedureFieldValuesAttachments=We,i.addAssetProcedureFieldValuesMany=Sa,i.addAssetProcedureFields=na,i.addAssetProcedureFieldsAttachment=Wu,i.addAssetProcedureFieldsAttachments=Xn,i.addAssetProcedureFieldsMany=xu,i.addAssetProcedureInstance=Ht,i.addAssetProcedureInstances=Ra,i.addAssetProcedures=Th,i.addAssetStage=zh,i.addAssetStageCompletion=ds,i.addAssetStageCompletions=ls,i.addAssetStages=ps,i.addAssetType=Ms,i.addAssetTypeAttachment=$h,i.addAssetTypeAttachments=bs,i.addAssetTypeFieldValues=vs,i.addAssetTypeFieldValuesAttachment=am,i.addAssetTypeFieldValuesAttachments=Ze,i.addAssetTypeFieldValuesMany=Ec,i.addAssetTypeFields=Ac,i.addAssetTypeFieldsAttachment=Nh,i.addAssetTypeFieldsAttachments=oc,i.addAssetTypeFieldsMany=Zh,i.addAssetTypes=ym,i.addAssets=is,i.addCategory=Cs,i.addConversation=zn,i.addDocumentAttachment=wm,i.addDocumentAttachments=Yc,i.addDocuments=nr,i.addEmailDomain=lr,i.addForm=Qs,i.addFormRevision=Js,i.addFormRevisionAttachment=$m,i.addFormRevisionAttachments=Tr,i.addFormRevisions=Er,i.addFormSubmission=ii,i.addFormSubmissionAttachment=ef,i.addFormSubmissionAttachments=st,i.addFormSubmissions=at,i.addForms=Xm,i.addGeoImage=io,i.addGeoImages=no,i.addIssue=Ri,i.addIssueAssociation=hi,i.addIssueAssociations=mi,i.addIssueAttachment=ff,i.addIssueAttachments=yi,i.addIssueComment=Ti,i.addIssueComments=Sf,i.addIssueType=md,i.addIssueTypeFieldValues=Ei,i.addIssueTypeFieldValuesAttachment=Nf,i.addIssueTypeFieldValuesAttachments=dt,i.addIssueTypeFieldValuesMany=wf,i.addIssueTypeFields=xo,i.addIssueTypeFieldsAttachment=Tf,i.addIssueTypeFieldsAttachments=Bo,i.addIssueTypeFieldsMany=Df,i.addIssueUpdate=bd,i.addIssueUpdates=_d,i.addIssues=Do,i.addLicenses=ep,i.addProjectAttachment=Ip,i.addProjectAttachments=yl,i.addProjectFile=wp,i.addProjectFiles=vl,i.addTeam=$l,i.addUsers=cp,i.agentsReducer=Un,i.agentsSlice=Ot,i.areArraysEqual=Tu,i.assetAttachmentReducer=Kn,i.assetAttachmentSlice=wt,i.assetProcedureFieldValuesAttachmentReducer=pa,i.assetProcedureFieldValuesAttachmentSlice=Vt,i.assetProcedureFieldValuesReducer=Ta,i.assetProcedureFieldValuesSlice=Ut,i.assetProcedureFieldsAttachmentReducer=ta,i.assetProcedureFieldsAttachmentSlice=kt,i.assetProcedureFieldsReducer=oa,i.assetProcedureFieldsSlice=Dt,i.assetProcedureInstanceReducer=va,i.assetProcedureInstanceSlice=Nt,i.assetProcedureReducer=qa,i.assetProcedureSlice=Xt,i.assetReducer=Va,i.assetSlice=ts,i.assetStageCompletionReducer=Ga,i.assetStageCompletionSlice=os,i.assetStageReducer=Ya,i.assetStageSlice=fs,i.assetTypeAttachmentReducer=ac,i.assetTypeAttachmentSlice=gs,i.assetTypeFieldValuesAttachmentReducer=Oc,i.assetTypeFieldValuesAttachmentSlice=Rs,i.assetTypeFieldValuesReducer=kc,i.assetTypeFieldValuesSlice=Os,i.assetTypeFieldsAttachmentReducer=mc,i.assetTypeFieldsAttachmentSlice=Fs,i.assetTypeFieldsReducer=bc,i.assetTypeFieldsSlice=Is,i.assetTypeReducer=Vc,i.assetTypeSlice=qs,i.authReducer=$c,i.authSlice=xe,i.blobToBase64=ju,i.categoryReducer=Hc,i.categorySlice=Vs,i.clearTokens=Fm,i.constructUploadedFilePayloads=Eu,i.coordinatesAreEqual=_u,i.createModelAdapter=I,i.createMultiPointGeometry=bu,i.createOfflineAction=dl,i.createPointGeometry=gu,i.deleteAsset=ns,i.deleteAssetAttachment=Ln,i.deleteAssetAttachments=qt,i.deleteAssetProcedure=Qt,i.deleteAssetProcedureFieldValues=Bt,i.deleteAssetProcedureFieldValuesAttachment=uh,i.deleteAssetProcedureFieldValuesAttachments=Ke,i.deleteAssetProcedureFieldValuesMany=ba,i.deleteAssetProcedureFields=ca,i.deleteAssetProcedureFieldsAttachment=Xu,i.deleteAssetProcedureFieldsAttachments=Qn,i.deleteAssetProcedureFieldsMany=ih,i.deleteAssetProcedureInstance=Wt,i.deleteAssetProcedureInstances=Pa,i.deleteAssetProcedures=Ih,i.deleteAssetStage=Vh,i.deleteAssetStageCompletion=us,i.deleteAssetStageCompletions=hs,i.deleteAssetStages=ys,i.deleteAssetType=ks,i.deleteAssetTypeAttachment=tc,i.deleteAssetTypeAttachments=_s,i.deleteAssetTypeFieldValues=ws,i.deleteAssetTypeFieldValuesAttachment=dm,i.deleteAssetTypeFieldValuesAttachments=Qe,i.deleteAssetTypeFieldValuesMany=qc,i.deleteAssetTypeFields=Sc,i.deleteAssetTypeFieldsAttachment=Yh,i.deleteAssetTypeFieldsAttachments=lc,i.deleteAssetTypeFieldsMany=tm,i.deleteAssetTypes=gm,i.deleteAssets=Da,i.deleteCategory=Nc,i.deleteDocumentAttachment=Zc,i.deleteDocumentAttachments=Qc,i.deleteEmailDomain=ur,i.deleteForm=xs,i.deleteFormRevision=Xs,i.deleteFormRevisionAttachment=Nm,i.deleteFormRevisionAttachments=Ir,i.deleteFormRevisions=jr,i.deleteFormSubmission=ni,i.deleteFormSubmissionAttachment=af,i.deleteFormSubmissionAttachments=it,i.deleteFormSubmissions=ct,i.deleteGeoImage=di,i.deleteGeoImages=co,i.deleteIssue=Pi,i.deleteIssueAssociation=fi,i.deleteIssueAssociations=pi,i.deleteIssueAttachment=Fo,i.deleteIssueAttachments=Si,i.deleteIssueComment=Fi,i.deleteIssueComments=gf,i.deleteIssueTypeFieldValues=ji,i.deleteIssueTypeFieldValuesAttachment=Yf,i.deleteIssueTypeFieldValuesAttachments=lt,i.deleteIssueTypeFieldValuesMany=Mf,i.deleteIssueTypeFields=td,i.deleteIssueTypeFieldsAttachment=Pf,i.deleteIssueTypeFieldsAttachments=Lo,i.deleteIssueTypeFieldsMany=Uf,i.deleteIssueUpdate=Td,i.deleteIssueUpdates=Fd,i.deleteIssues=zo,i.deleteOrganizationAccess=Cd,i.deleteProject=Zd,i.deleteProjectAccess=Ld,i.deleteProjectAccesses=Nd,i.deleteProjectAttachment=_l,i.deleteProjectAttachments=en,i.deleteProjectFile=wl,i.deleteProjectFiles=El,i.deleteTeam=on,i.dequeue=iu,i.discard=fn,i.documentAttachmentReducer=tr,i.documentAttachmentSlice=Bs,i.documentSlice=Ls,i.documentsReducer=or,i.downloadFile=qu,i.downloadInMemoryFile=wu,i.emailDomainsReducer=fr,i.emailDomainsSlice=Hs,i.emailRegex=Uu,i.enqueue=su,i.enqueueRequest=ul,i.fallbackToEmptyArray=S,i.fallbackToEmptyObject=ge,i.fileReducer=gr,i.fileSlice=Ws,i.fileToBlob=En,i.formReducer=Cr,i.formRevisionAttachmentReducer=Pr,i.formRevisionAttachmentSlice=Ks,i.formRevisionReducer=Dr,i.formRevisionsSlice=Ys,i.formSlice=Zs,i.formSubmissionAttachmentReducer=Wr,i.formSubmissionAttachmentSlice=ei,i.formSubmissionReducer=xr,i.formSubmissionSlice=si,i.geoImageReducer=lo,i.geoImageSlice=oi,i.getFileIdentifier=vu,i.getFileS3Key=Pt,i.getLocalDateString=vn,i.getLocalRelativeDateString=Pu,i.getOutboxCoordinator=Ae,i.getRenamedFile=wn,i.hashFile=be,i.initSDK=uA,i.initializeAssetAttachments=Et,i.initializeAssetProcedureFieldValues=ya,i.initializeAssetProcedureFieldValuesAttachments=la,i.initializeAssetProcedureFields=ia,i.initializeAssetProcedureFieldsAttachments=Jn,i.initializeAssetProcedureInstances=Ia,i.initializeAssetProcedures=Ea,i.initializeAssetStageCompletions=Ua,i.initializeAssetStages=Wa,i.initializeAssetTypeAttachments=Qa,i.initializeAssetTypeFieldValues=wc,i.initializeAssetTypeFieldValuesAttachments=Tc,i.initializeAssetTypeFields=pc,i.initializeAssetTypeFieldsAttachments=rc,i.initializeAssetTypes=zc,i.initializeAssets=ka,i.initializeCategories=Gc,i.initializeConversations=Dn,i.initializeDocumentAttachments=Kc,i.initializeEmailDomains=dr,i.initializeFormRevisionAttachments=_r,i.initializeFormRevisions=wr,i.initializeFormSubmissionAttachments=Gr,i.initializeFormSubmissions=Yr,i.initializeForms=Vr,i.initializeGeoImages=to,i.initializeIssueAssociations=ho,i.initializeIssueAttachments=bo,i.initializeIssueTypeFieldValues=Yo,i.initializeIssueTypeFieldValuesAttachments=ad,i.initializeIssueTypeFields=Qo,i.initializeIssueTypeFieldsAttachments=$o,i.initializeIssueTypes=hd,i.initializeIssueUpdates=gd,i.initializeIssues=ko,i.initializeLicences=vd,i.initializeOrganizationAccesses=zd,i.initializeProjectAccesses=Ki,i.initializeProjectAttachments=Al,i.initializeProjectFiles=Ol,i.initializeTeams=Ul,i.isToday=Ru,i.issueAssociationReducer=So,i.issueAssociationSlice=ui,i.issueAttachmentReducer=Oo,i.issueAttachmentSlice=Ai,i.issueCommentReducer=qo,i.issueCommentSlice=bi,i.issueReducer=Co,i.issueSlice=Ii,i.issueTypeFieldValuesAttachmentReducer=ld,i.issueTypeFieldValuesAttachmentSlice=Di,i.issueTypeFieldValuesReducer=Xo,i.issueTypeFieldValuesSlice=wi,i.issueTypeFieldsAttachmentReducer=Wo,i.issueTypeFieldsAttachmentSlice=vi,i.issueTypeFieldsReducer=id,i.issueTypeFieldsSlice=ki,i.issueTypeReducer=yd,i.issueTypeSlice=Vi,i.issueUpdateReducer=Pd,i.issueUpdateSlice=Bi,i.licenseReducer=Ed,i.licenseSlice=Gi,i.logOnlyOnce=Mu,i.markAsDeleted=hl,i.markForDeletion=Fp,i.memoize=It,i.moveDocument=ar,i.offline=F,i.onlyUniqueHashes=Cu,i.onlyUniqueOfflineIds=Mn,i.organizationAccessReducer=$d,i.organizationAccessSlice=Ni,i.organizationReducer=ol,i.organizationSlice=Zi,i.outboxReducer=fl,i.outboxSlice=Qi,i.overmapEnhancer=xp,i.overmapReducers=xl,i.overmapRootReducer=Yp,i.performRequest=mn,i.projectAccessReducer=Kd,i.projectAccessSlice=Wi,i.projectAttachmentReducer=Rl,i.projectAttachmentSlice=xi,i.projectFileReducer=zl,i.projectFileSlice=sn,i.projectReducer=xd,i.projectSlice=Ji,i.rehydratedReducer=Vl,i.rehydratedSlice=an,i.removeDocuments=Ns,i.removeIssueType=Ci,i.removeUser=Md,i.resetProjectFileObjectUrls=jp,i.resetStore=tu,i.restructureCreateSelectorWithArgs=y,i.saveActiveProjectFileBounds=Ml,i.selectAccessToken=Im,i.selectActiveOrganizationAccess=lp,i.selectActiveProjectFileId=Mp,i.selectActiveStatusLicenses=sp,i.selectAllDocumentAttachments=Gs,i.selectAllProjectAttachments=tn,i.selectAncestorIdsOfDocument=Dm,i.selectAssetAttachmentById=Hn,i.selectAssetAttachmentMapping=Nn,i.selectAssetAttachments=Mt,i.selectAssetById=rs,i.selectAssetProcedureById=es,i.selectAssetProcedureFieldValues=Gt,i.selectAssetProcedureFieldValuesAttachmentById=hh,i.selectAssetProcedureFieldValuesAttachments=ha,i.selectAssetProcedureFieldValuesAttachmentsByIds=ma,i.selectAssetProcedureFieldValuesAttachmentsMapping=Ct,i.selectAssetProcedureFieldValuesById=Lt,i.selectAssetProcedureFieldValuesMapping=_a,i.selectAssetProcedureFieldValuesOfAsset=ph,i.selectAssetProcedureFields=zt,i.selectAssetProcedureFieldsAttachmentById=Qu,i.selectAssetProcedureFieldsAttachments=ea,i.selectAssetProcedureFieldsAttachmentsMapping=xn,i.selectAssetProcedureFieldsById=ch,i.selectAssetProcedureFieldsMapping=ra,i.selectAssetProcedureFieldsOfAssetProcedure=nh,i.selectAssetProcedureInstanceById=Jt,i.selectAssetProcedureInstances=Yt,i.selectAssetProcedureInstancesByIds=_h,i.selectAssetProcedureInstancesMapping=Kt,i.selectAssetProcedureInstancesOfAssetProcedure=Oa,i.selectAssetProcedureInstancesOfAssetType=bh,i.selectAssetProcedures=ja,i.selectAssetProceduresByIds=vh,i.selectAssetProceduresMapping=xt,i.selectAssetProceduresOfOrganization=Oh,i.selectAssetStageById=Ja,i.selectAssetStageCompletionById=La,i.selectAssetStageCompletionMapping=ms,i.selectAssetStageCompletions=kh,i.selectAssetStageCompletionsByIds=Na,i.selectAssetStages=Xa,i.selectAssetStagesByIds=Ss,i.selectAssetStagesMappingOfAssetProcedure=Ch,i.selectAssetStagesOfAssetProcedure=Uh,i.selectAssetTypeAttachmentById=ic,i.selectAssetTypeAttachmentMapping=sc,i.selectAssetTypeAttachments=Ts,i.selectAssetTypeById=zs,i.selectAssetTypeFieldValues=Es,i.selectAssetTypeFieldValuesAttachmentById=lm,i.selectAssetTypeFieldValuesAttachments=Ic,i.selectAssetTypeFieldValuesAttachmentsByIds=Rc,i.selectAssetTypeFieldValuesAttachmentsMapping=Ps,i.selectAssetTypeFieldValuesById=js,i.selectAssetTypeFieldValuesMapping=Mc,i.selectAssetTypeFieldValuesOfAsset=mm,i.selectAssetTypeFields=Xe,i.selectAssetTypeFieldsAttachmentById=Xh,i.selectAssetTypeFieldsAttachments=hc,i.selectAssetTypeFieldsAttachmentsMapping=uc,i.selectAssetTypeFieldsById=nm,i.selectAssetTypeFieldsMapping=gc,i.selectAssetTypeFieldsOfAssetType=sm,i.selectAssetTypeValuesOfAssetType=fm,i.selectAssetTypes=bm,i.selectAssetTypesByIds=_m,i.selectAssetTypesMapping=Ds,i.selectAssets=za,i.selectAssetsByIds=qh,i.selectAssetsMapping=as,i.selectAssetsOfAssetType=cs,i.selectAttachmentsOfAsset=Wn,i.selectAttachmentsOfAssetByType=Hu,i.selectAttachmentsOfAssetProcedureFieldValues=fa,i.selectAttachmentsOfAssetProcedureFields=Zu,i.selectAttachmentsOfAssetType=nc,i.selectAttachmentsOfAssetTypeByType=Lh,i.selectAttachmentsOfAssetTypeFieldValues=Pc,i.selectAttachmentsOfAssetTypeFields=Jh,i.selectAttachmentsOfDocument=qm,i.selectAttachmentsOfDocumentByType=Mm,i.selectAttachmentsOfFormRevision=Hm,i.selectAttachmentsOfFormSubmission=Hr,i.selectAttachmentsOfIssue=Ro,i.selectAttachmentsOfIssueByType=yf,i.selectAttachmentsOfIssueTypeFieldValues=dd,i.selectAttachmentsOfIssueTypeFields=Of,i.selectAttachmentsOfProject=Il,i.selectAttachmentsOfProjectByType=Pp,i.selectCategories=Pm,i.selectCategoriesByIds=Om,i.selectCategoryById=$s,i.selectCategoryMapping=Us,i.selectCommentsOfIssue=bf,i.selectConversation=Bu,i.selectConversationMapping=vt,i.selectConversations=$u,i.selectCurrentUser=mt,i.selectDeletedRequests=_p,i.selectDocumentAttachmentById=er,i.selectDocumentAttachmentMapping=xc,i.selectDocumentById=rr,i.selectDocuments=cr,i.selectDocumentsByIds=km,i.selectDocumentsMapping=_e,i.selectEmailDomains=mr,i.selectEmailDomainsAsMapping=hr,i.selectEmailDomainsOfOrganization=Cm,i.selectFieldValuesOfAssetProcedureInstance=Ah,i.selectFilteredForms=xm,i.selectFormById=$r,i.selectFormMapping=Ur,i.selectFormRevisionAttachmentsMapping=Rr,i.selectFormRevisionById=Km,i.selectFormRevisionMapping=tt,i.selectFormRevisions=qr,i.selectFormRevisionsOfForm=kr,i.selectFormSubmissionAttachemntsByIds=Nr,i.selectFormSubmissionAttachmentsMapping=ti,i.selectFormSubmissionById=ri,i.selectFormSubmissions=ci,i.selectFormSubmissionsMapping=ai,i.selectFormSubmissionsOfAsset=Qr,i.selectFormSubmissionsOfForm=Xr,i.selectFormSubmissionsOfIssue=Zr,i.selectForms=Qm,i.selectGeoImageById=li,i.selectGeoImageMapping=ro,i.selectGeoImages=oo,i.selectGeoImagesOfProject=df,i.selectIsImportingProjectFile=kp,i.selectIsLoggedIn=Rm,i.selectIssueAssociationById=fo,i.selectIssueAssociationMapping=Ce,i.selectIssueAssociations=mf,i.selectIssueAssociationsOfAsset=yo,i.selectIssueAssociationsOfIssue=Ao,i.selectIssueAssociationsToIssue=po,i.selectIssueAttachmentById=Po,i.selectIssueAttachmentMapping=Io,i.selectIssueAttachments=gi,i.selectIssueById=Oi,i.selectIssueCommentById=jo,i.selectIssueCommentMapping=Eo,i.selectIssueCountOfCategory=vm,i.selectIssueMapping=Vo,i.selectIssueTypeById=Ui,i.selectIssueTypeFieldValues=qi,i.selectIssueTypeFieldValuesAttachmentById=Jf,i.selectIssueTypeFieldValuesAttachments=rd,i.selectIssueTypeFieldValuesAttachmentsByIds=od,i.selectIssueTypeFieldValuesAttachmentsMapping=zi,i.selectIssueTypeFieldValuesById=Mi,i.selectIssueTypeFieldValuesMapping=Jo,i.selectIssueTypeFieldValuesOfIssue=kf,i.selectIssueTypeFields=ot,i.selectIssueTypeFieldsAttachmentById=vf,i.selectIssueTypeFieldsAttachments=Ho,i.selectIssueTypeFieldsAttachmentsMapping=No,i.selectIssueTypeFieldsById=Lf,i.selectIssueTypeFieldsMapping=sd,i.selectIssueTypeFieldsOfIssueType=$f,i.selectIssueTypeMapping=pd,i.selectIssueTypeValuesOfIssueType=Gf,i.selectIssueTypes=Ad,i.selectIssueTypesByIds=Xf,i.selectIssueTypesOfOrganization=Zf,i.selectIssueUpdateMapping=Id,i.selectIssueUpdatesOfIssue=Rd,i.selectIssuesByIds=_f,i.selectIssuesOfIssueType=$i,i.selectIssuesOfIssueTypeCount=Qf,i.selectLatestAssetProcedureFieldsOfAssetProcedure=ah,i.selectLatestAssetTypeFieldsOfAssetType=im,i.selectLatestFormRevisionOfForm=Ym,i.selectLatestIssueTypeFieldsOfIssueType=Bf,i.selectLatestRetryTime=Tp,i.selectLicense=tp,i.selectLicenseForProject=wd,i.selectLicenses=ht,i.selectLicensesForProjectsMapping=ip,i.selectLicensesOfOrganization=gp,i.selectNumberOfAssetsOfAssetType=Mh,i.selectOrganizationAccessById=dp,i.selectOrganizationAccessForUser=up,i.selectOrganizationAccessUserMapping=Ud,i.selectOrganizationAccesses=Hi,i.selectOrganizationById=Ap,i.selectOrganizationUsersAsMapping=rl,i.selectOrganizationUsersIds=cl,i.selectOrganizations=al,i.selectOrganizationsMapping=nl,i.selectOrganizationsWithAccess=yp,i.selectProjectAccessById=hp,i.selectProjectAccessForUser=mp,i.selectProjectAccessMapping=Yi,i.selectProjectAccessUserMapping=Wd,i.selectProjectAccesses=Hd,i.selectProjectAttachmentById=Fl,i.selectProjectAttachmentMapping=Tl,i.selectProjectById=fp,i.selectProjectFileById=qp,i.selectProjectFileMapping=kl,i.selectProjectFiles=Dl,i.selectProjectMapping=Xi,i.selectProjectUsersAsMapping=tl,i.selectProjectUsersIds=el,i.selectProjectsOfOrganization=Sp,i.selectRehydrated=Vp,i.selectRootDocuments=zm,i.selectSortedOrganizationUsers=bp,i.selectSortedProjectUsers=pp,i.selectStageMapping=Je,i.selectTeamById=Re,i.selectTeams=ln,i.selectTeamsByIds=Cp,i.selectTeamsMapping=dn,i.selectTeamsOfOrganization=Up,i.selectTeamsOfUser=$p,i.selectUploadUrl=Sr,i.selectUserById=rp,i.selectUsersByIds=op,i.selectUsersMapping=ft,i.separateFilesFromValues=ve,i.separateImageFromFields=$A,i.setActiveProjectFileId=ql,i.setAsset=Eh,i.setAssetAttachment=Bn,i.setAssetAttachments=Lu,i.setAssetProcedure=Rh,i.setAssetProcedureFieldValues=mh,i.setAssetProcedureFieldValuesAttachment=oh,i.setAssetProcedureFieldValuesAttachments=dh,i.setAssetProcedureFieldValuesMany=fh,i.setAssetProcedureFields=eh,i.setAssetProcedureFieldsAttachment=Ku,i.setAssetProcedureFieldsAttachments=Yu,i.setAssetProcedureFieldsMany=th,i.setAssetProcedureInstance=Sh,i.setAssetProcedureInstances=gh,i.setAssetProcedures=Ph,i.setAssetStage=Ka,i.setAssetStages=Dh,i.setAssetType=pm,i.setAssetTypeAttachment=xa,i.setAssetTypeAttachments=Bh,i.setAssetTypeFieldValues=um,i.setAssetTypeFieldValuesAttachment=cm,i.setAssetTypeFieldValuesAttachments=rm,i.setAssetTypeFieldValuesMany=hm,i.setAssetTypeFields=Qh,i.setAssetTypeFieldsAttachment=Hh,i.setAssetTypeFieldsAttachments=Wh,i.setAssetTypeFieldsMany=xh,i.setAssetTypes=Am,i.setAssets=jh,i.setConversation=Vn,i.setCurrentUser=np,i.setDocumentAttachment=Jc,i.setDocumentAttachments=Em,i.setDocuments=ir,i.setForm=Jm,i.setFormRevision=vr,i.setFormRevisionAttachment=Bm,i.setFormRevisionAttachments=Gm,i.setFormSubmission=nt,i.setFormSubmissionAttachment=tf,i.setFormSubmissionAttachments=sf,i.setFormSubmissions=cf,i.setGeoImage=Ve,i.setGeoImages=so,i.setIsImportingProjectFile=jl,i.setIssueAssociation=uf,i.setIssueAssociations=lf,i.setIssueAttachment=_o,i.setIssueAttachments=pf,i.setIssueComment=_i,i.setIssueComments=wo,i.setIssueType=$e,i.setIssueTypeFieldValues=Ef,i.setIssueTypeFieldValuesAttachment=Hf,i.setIssueTypeFieldValuesAttachments=Wf,i.setIssueTypeFieldValuesMany=jf,i.setIssueTypeFields=zf,i.setIssueTypeFieldsAttachment=Ff,i.setIssueTypeFieldsAttachments=If,i.setIssueTypeFieldsMany=Vf,i.setIssueUpdate=xf,i.setLoggedIn=Uc,i.setOrganizations=il,i.setProfilePicture=ap,i.setProjectAttachment=Sl,i.setProjectAttachments=gl,i.setProjectFile=Op,i.setProjectFiles=vp,i.setProjects=Jd,i.setRehydrated=zp,i.setTeam=Ie,i.setTokens=Tm,i.setUploadUrl=yr,i.setUsers=qd,i.shallowEqual=On,i.slugify=zu,i.spacesToDashesLower=Du,i.teamReducer=Bl,i.teamSlice=cn,i.toFileNameSafeString=ku,i.toOfflineIdRecord=qn,i.truncate=Vu,i.updateAsset=Me,i.updateAssetAttachment=Nu,i.updateAssetAttachments=Gn,i.updateAssetProcedure=qe,i.updateAssetProcedureFieldValues=Ee,i.updateAssetProcedureFieldValuesAttachment=lh,i.updateAssetProcedureFieldValuesAttachments=ua,i.updateAssetProcedureFieldValuesMany=ga,i.updateAssetProcedureFields=aa,i.updateAssetProcedureFieldsAttachment=Ju,i.updateAssetProcedureFieldsAttachments=Zn,i.updateAssetProcedureFieldsMany=sh,i.updateAssetProcedureInstance=je,i.updateAssetProcedureInstances=yh,i.updateAssetProcedures=Fh,i.updateAssetStage=As,i.updateAssetStageCompletion=$a,i.updateAssetStageCompletions=Ba,i.updateAssetStages=Ye,i.updateAssetType=De,i.updateAssetTypeAttachment=Gh,i.updateAssetTypeAttachments=ec,i.updateAssetTypeFieldValues=ke,i.updateAssetTypeFieldValuesAttachment=om,i.updateAssetTypeFieldValuesAttachments=Fc,i.updateAssetTypeFieldValuesMany=jc,i.updateAssetTypeFields=yc,i.updateAssetTypeFieldsAttachment=Kh,i.updateAssetTypeFieldsAttachments=dc,i.updateAssetTypeFieldsMany=em,i.updateAssetTypes=Sm,i.updateAssets=wh,i.updateCategory=Lc,i.updateConversation=Cn,i.updateDocumentAttachment=jm,i.updateDocumentAttachments=Xc,i.updateDocuments=le,i.updateForm=Zm,i.updateFormRevisionAttachment=Lm,i.updateFormRevisionAttachments=Fr,i.updateFormSubmission=Jr,i.updateFormSubmissionAttachment=nf,i.updateFormSubmissionAttachments=Lr,i.updateFormSubmissions=rf,i.updateGeoImage=ao,i.updateGeoImages=of,i.updateIssue=rt,i.updateIssueAssociation=mo,i.updateIssueAssociations=hf,i.updateIssueAttachment=Af,i.updateIssueAttachments=To,i.updateIssueType=fd,i.updateIssueTypeFieldValues=Ue,i.updateIssueTypeFieldValuesAttachment=Kf,i.updateIssueTypeFieldValuesAttachments=cd,i.updateIssueTypeFieldValuesMany=qf,i.updateIssueTypeFields=ed,i.updateIssueTypeFieldsAttachment=Rf,i.updateIssueTypeFieldsAttachments=Go,i.updateIssueTypeFieldsMany=Cf,i.updateLicense=oe,i.updateOrganizationAccess=Vd,i.updateProject=Xd,i.updateProjectAccess=Gd,i.updateProjectAttachment=Rp,i.updateProjectAttachments=bl,i.updateProjectFile=nn,i.updateProjectFiles=Ep,i.updateTeam=rn,i.userReducer=kd,i.userSlice=Li,i.versioningReducer=Ll,i.versioningSlice=Gl,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|