@overmap-ai/core 1.0.78-view-sets.36 → 1.0.78-view-sets.37

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.
@@ -3169,6 +3169,7 @@ class DS extends w {
3169
3169
  async refreshStore(e, s) {
3170
3170
  const i = await this.enqueueRequest(
3171
3171
  {
3172
+ immediate: !0,
3172
3173
  description: "Get agent conversation history",
3173
3174
  method: u.GET,
3174
3175
  url: "/agents/conversations/",
@@ -6258,6 +6259,7 @@ class g_ extends z {
6258
6259
  async refreshStore(e, s) {
6259
6260
  const i = await this.enqueueRequest(
6260
6261
  {
6262
+ immediate: !0,
6261
6263
  description: "Get geo images",
6262
6264
  method: u.GET,
6263
6265
  url: "/geo-images/",
@@ -6534,6 +6536,7 @@ class T_ extends w {
6534
6536
  async refreshStore(e, s) {
6535
6537
  const i = await this.enqueueRequest(
6536
6538
  {
6539
+ immediate: !0,
6537
6540
  description: "Get comments",
6538
6541
  method: u.GET,
6539
6542
  url: "/issue-comments/",
@@ -5,11 +5,11 @@ Retries:`,a),!(t instanceof Error))throw console.error("ENCOUNTERED NON-ERROR ER
5
5
  Action:`,e);const p=Ge();if(!p)throw new Error("Outbox coordinator not set");p.remove(e.payload.uuid),t.options.discard=!0,l()}}console.debug("Registering a retry for request:",e.payload.uuid);const m=Ge();if(!m)throw new Error("Outbox coordinator not set");return m.registerRetry(e.payload.uuid),!1}function cb(t,e,a){var i;return(i=Ge())==null?void 0:i.peek()}function nb(t,e){return ot().dispatch(Xl(new Date().getTime())),fc}const Ye="An unknown error occurred",rb=500,dm=["non_field_errors","detail"];function db(t,e){let a;if(t!=null&&t.body)if(typeof t.body=="object"){const i=t.body;if(typeof i.error=="string")a=i.error;else if(typeof i.message=="string")a=i.message;else try{a=Object.entries(i).map(([c,n])=>typeof n=="string"?dm.includes(c)?n:`${c}: ${n}`:Array.isArray(n)?dm.includes(c)?n.join(`
6
6
  `):n.map(r=>`${c}: ${r}`).join(`
7
7
  `):`${c}: ${JSON.stringify(n)}`).join(`
8
- `)}catch(c){console.error("Failed to extract error message from response body",c)}}else typeof t.body=="string"&&(a=t.body);else t!=null&&t.text?a=t.text:e instanceof Error&&(a=e.message);return!a||a.length>rb?Ye:a}class D extends Error{constructor(a){super(Ye);S(this,"status");S(this,"response");S(this,"message");S(this,"options");const{response:i,innerError:c}=a;this.message=a.message??db(i,c)??Ye,this.status=(i==null?void 0:i.status)??0,this.response=i,a.discard=a.discard??!1,this.options=a}}class ub extends xh{constructor(e){super(e)}}class v extends xh{constructor(a,i){super(a);S(this,"auth");this.auth=i}}class ob extends v{async startConversation(e,a){return this.enqueueRequest({description:"Start agent conversation",method:h.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:a},blockers:["prompt"],blocks:["prompt"]}).then(i=>(this.dispatch(vc(i)),i))}async continueConversation(e,a,i){return this.enqueueRequest({description:"Prompt agent",method:h.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:i},blockers:["prompt"],blocks:["prompt"],queryParams:{conversation_id:a}}).then(c=>{this.dispatch(Mc(c))})}async fetchDetails(e){return this.enqueueRequest({description:"Get agent conversation",method:h.GET,url:`/agents/conversations/${e}/`,blockers:["conversation"],blocks:["conversation"]}).then(a=>{this.dispatch(wc(a))})}async rate(e,a){return this.enqueueRequest({description:"Rate agent response",method:h.PUT,url:`/agents/responses/${e}/rate/`,payload:{rating:a},blockers:["rate"],blocks:["rate"]})}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get agent conversation history",method:h.GET,url:"/agents/conversations/",queryParams:{project:e},blockers:["agent-conversations"],blocks:["agent-conversations"]},a);return this.dispatch(Rc(i)),i}}const lb=5e4,E=1e3,hb="limit";class q extends v{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:a,assetAttachmentReducer:i,assetTypeAttachmentReducer:c,documentAttachmentReducer:n,projectAttachmentReducer:r,formRevisionAttachmentReducer:l,formSubmissionAttachmentReducer:m,geoImageReducer:u,assetTypeFieldsAttachmentReducer:o,assetTypeFieldValuesAttachmentReducer:p,issueTypeFieldsAttachmentReducer:A,issueTypeFieldValuesAttachmentReducer:y}=this.client.store.getState();return[].concat(Object.values(a.instances),Object.values(i.instances),Object.values(c.instances),Object.values(n.instances),Object.values(r.instances),Object.values(l.instances),Object.values(m.instances),Object.values(u.instances),Object.values(o.instances),Object.values(p.instances),Object.values(A.instances),Object.values(y.instances)).filter(P=>P.file_sha1===e).length}processPresignedUrls(e){const a={};for(const[i,c]of Object.entries(e))a[i]=this.enqueueRequest({url:c.url,description:"Upload file to S3",method:h.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:i,blockers:[`s3-${c.fields.key}`],blocks:[i],s3url:c});return a}async getFilePayload(e){const a=await He(e),i={sha1:a,file_type:e.type,extension:e.name.split(".").pop(),size:e.size};return await this.client.files.addCache(e,a),i}}class ke extends q{async _bulkAdd(e){var u;const{store:a}=this.client,i=(u=a.getState().userReducer.currentUser)==null?void 0:u.id,c=new Date().toISOString(),n=[],r=[],l={};for(const o of e){const{modelUuid:p,file:A}=o,y=await this.getFilePayload(A);y.sha1 in l||(l[y.sha1]=y);const b=this.buildOfflineAttachment({file:A,file_sha1:y.sha1,submitted_at:c,created_by:i,description:"",modelUuid:p});n.push(b),r.push(this.buildAttachmentPayload({uuid:b.uuid,file_name:b.file_name,file_sha1:b.file_sha1,file_extension:y.extension,description:b.description,modelUuid:p}))}this.dispatch(this.addAttachments(n));const m=this.enqueueRequest({description:`Add ${this.name}`,method:h.POST,url:`${this.url}/bulk/`,payload:{submitted_at:c,attachments:r,files:Object.values(l)},blocks:n.map(o=>o.uuid),blockers:n.map(o=>o.file_sha1)});return m.then(({attachments:o,presigned_urls:p})=>{this.dispatch(this.updateAttachments(o)),this.processPresignedUrls(p)}).catch(()=>{this.dispatch(this.removeAttachments(n.map(o=>o.uuid)))}),[n,m.then(({attachments:o})=>o)]}async _delete(e){const{store:a}=this.client,i=this.selectAttachment(e)(a.getState());if(!i)throw new Error(`Attempting to delete attachment with uuid ${e} that does not exist in the store`);this.dispatch(this.removeAttachment(i.uuid));const c=this.enqueueRequest({description:`Delete ${this.name}`,method:h.DELETE,url:`${this.url}/${e}/`,blockers:[e],blocks:[]});return c.then(()=>{this.getNumberOfAttachmentsWithSha1(i.file_sha1)===0&&this.client.files.removeCache(i.file_sha1)}).catch(()=>{this.dispatch(this.setAttachment(i))}),c}}class mb extends ke{constructor(){super(...arguments);S(this,"name","Asset Attachment");S(this,"url","/asset-attachments");S(this,"initializeAttachments",Qt);S(this,"addAttachments",xt);S(this,"updateAttachments",Vc);S(this,"removeAttachments",es);S(this,"removeAttachment",zc);S(this,"setAttachment",qc);S(this,"selectAttachment",Cc)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,asset:a.modelUuid})}buildAttachmentPayload(a){return{...a,asset:a.modelUuid}}async bulkAdd(a){return this._bulkAdd(a.map(i=>({modelUuid:i.assetUuid,file:i.file})))}async delete(a){return this._delete(a)}async refreshStore(a,i){const n=(await this.performPagination({immediate:!0,description:"Get asset attachments",method:h.GET,url:`${this.url}/`,queryParams:{limit:E,paginate:!0,asset__project:a},blocks:[],blockers:[]},r=>({immediate:!0,description:"Get asset attachments",method:h.GET,url:r,blockers:[],blocks:[]}),i)).flat();return this.dispatch(Qt(n)),n}}class pb extends ke{constructor(){super(...arguments);S(this,"name","Asset Procedure Attachment");S(this,"url","/asset-procedure-attachments");S(this,"addAttachments",Lc);S(this,"updateAttachments",Hc);S(this,"removeAttachments",Yc);S(this,"removeAttachment",Wc);S(this,"setAttachment",Nc);S(this,"selectAttachment",Jc)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,asset_procedure:a.modelUuid})}buildAttachmentPayload(a){return{...a,asset_procedure:a.modelUuid}}async bulkAdd(a){return this._bulkAdd(a.map(i=>({modelUuid:i.assetProcedureUuid,file:i.file})))}async delete(a){return this._delete(a)}async refreshStore(a,i){const c=await this.enqueueRequest({description:"Get asset procedure attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset_procedure__organization:a},blocks:[],blockers:[]},i);return this.dispatch($c(c)),c}}class Ab extends q{async bulkAdd(e){var m;const a=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldsRevisionUuid:o,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:o,submitted_at:a,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:o};r.push(P)}this.dispatch(en(n));const l=this.enqueueRequest({description:"Add asset procedure fields attachments",method:h.POST,url:"/asset-procedure-fields-attachments/bulk/",payload:{submitted_at:a,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.fields_revision),blocks:n.map(u=>u.uuid)});return l.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(tn(u.attachments))}).catch(()=>{this.dispatch(sn(n.map(u=>u.uuid)))}),[n,l.then(({attachments:u})=>u)]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get asset procedure fields attachments",method:h.GET,url:"/asset-procedure-fields-attachments/",queryParams:{fields_revision__asset_procedure__organization:e},blockers:[],blocks:[]},a);return this.dispatch(xc(i)),i}}class yb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(un(n));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:h.POST,url:"/asset-procedure-fields/",payload:w(n),blockers:[n.asset_procedure],blocks:[n.uuid]});return r.then(m=>{this.dispatch(on(m))}).catch(m=>{throw this.dispatch(ln(n.uuid)),m}),[n,r]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:h.GET,url:"/asset-procedure-fields/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]},a);return this.dispatch(dn(i)),i}}function $e(t,e){const a=[];let i=0;const c=t.length;for(;i<c;)a.push(t.slice(i,i+=e));return a}class fb extends q{async bulkAdd(e,a){var u;const i=new Date().toISOString(),c=(u=this.client.store.getState().userReducer.currentUser)==null?void 0:u.id,n=$e(e,a??e.length),r=[],l=[];for(const o of n){const p={},A=[];for(const y of o){const{fieldValuesUuid:b,fieldIdentifier:P,file:_}=y,R=await this.getFilePayload(_);R.sha1 in p||(p[R.sha1]=R);const z=T({file:URL.createObjectURL(_),file_type:_.type,file_name:_.name,file_sha1:R.sha1,created_by:c,field_values:b,submitted_at:i,field_identifier:P});r.push(z);const De={uuid:z.uuid,file_name:_.name,file_sha1:R.sha1,file_extension:R.extension,field_identifier:P,field_values:b};A.push(De)}l.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(mt(r));const m=l.map(o=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:h.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:o,blockers:o.attachments.map(p=>p.field_values),blocks:o.attachments.map(p=>p.uuid)}));return Promise.all(m).then(o=>{for(const A of o)this.processPresignedUrls(A.presigned_urls);const p=o.flatMap(A=>A.attachments);this.dispatch(yn(p))}).catch(o=>{throw this.dispatch(pt(r.map(p=>p.uuid))),o}),[r,m.map(o=>o.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:a}=this.client,i=a.getState(),c=Sn(e)(i);this.dispatch(pt(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:h.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(mt(c)),n}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset procedure field values attachments",method:h.GET,url:"/asset-procedure-field-values-attachments/",queryParams:{limit:E,paginate:!0,field_values__asset_procedure_instance__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset procedure field values attachments",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(An(c)),c}}class Sb extends v{add(e){var r;const{store:a}=this.client,i=a.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add asset procedure field values",method:h.POST,url:"/asset-procedure-field-values/",payload:w(c),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[c.uuid]});return this.dispatch(ds(c)),n.then(l=>(this.dispatch(Je(l)),l)).catch(()=>{this.dispatch(us(c.uuid))}),[c,n]}bulkAdd(e,a){var m;const i=new Date().toISOString(),c=[],n=$e(e.payloads,a??e.payloads.length),r=[];for(const u of n){const o=[];for(const p of u){const A=T({...p,values:p.values,created_by:(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,submitted_at:i});c.push(A),o.push({uuid:A.uuid,asset:p.asset,fields_revision:p.fields_revision,asset_procedure_instance:p.asset_procedure_instance,published_at:p.published_at,values:A.values})}r.push({submitted_at:i,values:e.values,field_values:o})}this.dispatch(Tn(c));const l=[];for(const u of r){const o=u.field_values.map(P=>P.asset),p=u.field_values.map(P=>P.fields_revision),A=u.field_values.map(P=>P.asset_procedure_instance),y=u.field_values.map(P=>P.uuid),b=this.enqueueRequest({description:"Bulk add asset procedure field values",method:h.POST,url:"/asset-procedure-field-values/bulk/",payload:u,blockers:[...o,...p,...A],blocks:y});l.push(b)}return Promise.all(l).then(u=>{this.dispatch(In(u.flat()))}).catch(()=>{this.dispatch(On(c.map(u=>u.uuid)))}),[c,l]}update(e){const{store:a}=this.client,i=a.getState(),c=ls(e.uuid)(i);if(!c)throw new Error(`Expected AssetProcedureFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(Je(n));const r=this.enqueueRequest({description:"Update asset procedure field values",method:h.PATCH,url:`/asset-procedure-field-values/${e.uuid}/`,payload:e,blockers:[n.fields_revision,n.asset,n.asset_procedure_instance],blocks:[n.uuid]});return r.then(l=>{this.dispatch(Je(l))}).catch(()=>{this.dispatch(Je(c))}),[n,r]}async delete(e){const{store:a}=this.client,i=a.getState(),c=ls(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=gn(e)(i);this.dispatch(us(e)),this.dispatch(pt(n.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset procedure field values",method:h.DELETE,url:`/asset-procedure-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ds(c)),this.dispatch(mt(n)),r}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset procedure field values",method:h.GET,url:"/asset-procedure-field-values/",queryParams:{limit:E,paginate:!0,asset_procedure_instance__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset procedure field values",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Fn(c)),c}}class gb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(ms(n));const r=this.enqueueRequest({description:"Create asset procedure instance",method:h.POST,url:"/asset-procedure-instances/",payload:w(n),blockers:[e.asset_procedure,e.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Xe(m))}).catch(()=>{this.dispatch(ps(n.uuid))}),[n,r]}update(e){const{store:a}=this.client,i=fs(e.uuid)(a.getState());if(!i)throw new Error(`Expected asset procedure instance with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(Xe(c));const n=this.enqueueRequest({description:"Update asset procedure instance",method:h.PATCH,url:`/asset-procedure-instances/${e.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(Xe(r))}).catch(()=>{this.dispatch(Xe(i))}),[c,n]}async remove(e){const{store:a}=this.client,i=a.getState(),c=fs(e)(i);if(!c)throw new Error(`Expected asset procedure instance with uuid ${e} to exist`);return this.dispatch(ps(e)),this.enqueueRequest({description:"Delete asset procedure instance",method:h.DELETE,url:`/asset-procedure-instances/${e}/`,blockers:[e],blocks:[]}).catch(n=>{throw this.dispatch(ms(c)),n})}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset procedure instances",method:h.GET,url:"/asset-procedure-instances/",queryParams:{limit:E,paginate:!0,project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset procedure instances",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(wn(c)),c}}class bb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(gs(n));const r=this.enqueueRequest({description:"Create asset procedure",method:h.POST,url:"/asset-procedures/",payload:w(n),blockers:[],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Qe(m))}).catch(()=>{this.dispatch(bs(n.uuid))}),[n,r]}update(e){const{store:a}=this.client,i=Fs(e.uuid)(a.getState());if(!i)throw new Error(`Expected asset procedure with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(Qe(c));const n=this.enqueueRequest({description:"Update asset procedure",method:h.PATCH,url:`/asset-procedures/${e.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(Qe(r))}).catch(()=>{this.dispatch(Qe(i))}),[c,n]}async remove(e){const{store:a}=this.client,i=a.getState(),c=Fs(e)(i);if(!c)throw new Error(`Expected asset procedure with uuid ${e} to exist`);const n=jn(e)(i);return this.dispatch(bs(e)),this.dispatch(En(n.map(r=>r.uuid))),this.enqueueRequest({description:"Delete asset procedure",method:h.DELETE,url:`/asset-procedures/${e}/`,blockers:[e],blocks:[]}).catch(r=>{throw this.dispatch(gs(c)),this.dispatch(Mn(n)),r})}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get asset procedures",method:h.GET,url:"/asset-procedures/",queryParams:{organization:e},blockers:[],blocks:[]},a);return this.dispatch(zn(i)),i}}class Pb extends q{async bulkAdd(e){var m;const a=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldsRevisionUuid:o,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:o,submitted_at:a,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:o};r.push(P)}this.dispatch(Bn(n));const l=this.enqueueRequest({description:"Add asset procedure step fields attachments",method:h.POST,url:"/asset-procedure-step-fields-attachments/bulk/",payload:{submitted_at:a,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.fields_revision),blocks:n.map(u=>u.uuid)});return l.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(Gn(u.attachments))}).catch(()=>{this.dispatch($n(n.map(u=>u.uuid)))}),[n,l.then(({attachments:u})=>u)]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get asset procedure step fields attachments",method:h.GET,url:"/asset-procedure-step-fields-attachments/",queryParams:{fields_revision__asset_procedure_step__organization:e},blockers:[],blocks:[]},a);return this.dispatch(kn(i)),i}}class Fb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Os(n));const r=this.enqueueRequest({description:"Add Asset Procedure Step Fields",method:h.POST,url:"/asset-procedure-step-fields/",payload:w(n),blockers:[n.asset_procedure_step],blocks:[n.uuid]});return r.then(m=>{this.dispatch(xe(m))}).catch(m=>{throw this.dispatch(_s(n.uuid)),m}),[n,r]}update(e){const{store:a}=this.client,i=a.getState().assetProcedureStepFieldsReducer.instances[e.uuid];if(!i)throw new Error(`AssetProcedureStepFields with uuid ${e.uuid} not found`);const c={...i,...e};this.dispatch(xe(c));const n=this.enqueueRequest({description:"Update Asset Procedure Step Fields",method:h.PATCH,url:`/asset-procedure-step-fields/${i.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(xe(r))}).catch(r=>{throw this.dispatch(xe(i)),r}),[c,n]}delete(e){const{store:a}=this.client,i=a.getState().assetProcedureStepFieldsReducer.instances[e];if(!i)throw new Error(`AssetProcedureStepFields with uuid ${e} not found`);this.dispatch(_s(e));const c=this.enqueueRequest({description:"Delete Asset Procedure Step Fields",method:h.DELETE,url:`/asset-procedure-step-fields/${e}/`,blockers:[e],blocks:[e]});return c.catch(n=>{throw this.dispatch(Os(i)),n}),c}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get Asset Procedure Step Fields",method:h.GET,url:"/asset-procedure-step-fields/",queryParams:{asset_procedure_step__asset_procedure__organization:e},blockers:[],blocks:[]},a);return this.dispatch(Yn(i)),i}}class Tb extends q{async bulkAdd(e,a){var u;const i=new Date().toISOString(),c=(u=this.client.store.getState().userReducer.currentUser)==null?void 0:u.id,n=$e(e,a??e.length),r=[],l=[];for(const o of n){const p={},A=[];for(const y of o){const{fieldValuesUuid:b,fieldIdentifier:P,file:_}=y,R=await this.getFilePayload(_);R.sha1 in p||(p[R.sha1]=R);const z=T({file:URL.createObjectURL(_),file_type:_.type,file_name:_.name,file_sha1:R.sha1,created_by:c,field_values:b,submitted_at:i,field_identifier:P});r.push(z);const De={uuid:z.uuid,file_name:_.name,file_sha1:R.sha1,file_extension:R.extension,field_identifier:P,field_values:b};A.push(De)}l.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(At(r));const m=l.map(o=>this.enqueueRequest({description:"Add asset procedure step field values attachments",method:h.POST,url:"/asset-procedure-step-field-values-attachments/bulk/",payload:o,blockers:o.attachments.map(p=>p.field_values),blocks:o.attachments.map(p=>p.uuid)}));return Promise.all(m).then(o=>{for(const A of o)this.processPresignedUrls(A.presigned_urls);const p=o.flatMap(A=>A.attachments);this.dispatch(Xn(p))}).catch(o=>{throw this.dispatch(yt(r.map(p=>p.uuid))),o}),[r,m.map(o=>o.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:a}=this.client,i=a.getState(),c=xn(e)(i);this.dispatch(yt(e));try{await this.enqueueRequest({description:"Delete asset procedure step field values attachments",method:h.DELETE,url:"/asset-procedure-step-field-values-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(At(c)),n}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset procedure step field values attachments",method:h.GET,url:"/asset-procedure-step-field-values-attachments/",queryParams:{limit:E,paginate:!0,field_values__asset_procedure_instance__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset procedure step field values attachments",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Jn(c)),c}}class Ib extends v{add(e){var r;const{store:a}=this.client,i=a.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add asset procedure step field values",method:h.POST,url:"/asset-procedure-step-field-values/",payload:w(c),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[c.uuid]});return this.dispatch(js(c)),n.then(l=>(this.dispatch(et(l)),l)).catch(()=>{this.dispatch(qs(c.uuid))}),[c,n]}bulkAdd(e,a){var m;const i=new Date().toISOString(),c=[],n=$e(e.payloads,a??e.payloads.length),r=[];for(const u of n){const o=[];for(const p of u){const A=T({...p,values:p.values,created_by:(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,submitted_at:i});c.push(A),o.push({uuid:A.uuid,asset:p.asset,fields_revision:p.fields_revision,asset_procedure_instance:p.asset_procedure_instance,asset_procedure_step:p.asset_procedure_step,published_at:p.published_at,values:A.values})}r.push({submitted_at:i,values:e.values,field_values:o})}this.dispatch(ir(c));const l=[];for(const u of r){const o=u.field_values.map(P=>P.asset),p=u.field_values.map(P=>P.fields_revision),A=u.field_values.map(P=>P.asset_procedure_instance),y=u.field_values.map(P=>P.uuid),b=this.enqueueRequest({description:"Bulk add asset procedure step field values",method:h.POST,url:"/asset-procedure-step-field-values/bulk/",payload:u,blockers:[...o,...p,...A],blocks:y});l.push(b)}return Promise.all(l).then(u=>{this.dispatch(cr(u.flat()))}).catch(()=>{this.dispatch(nr(c.map(u=>u.uuid)))}),[c,l]}update(e){const{store:a}=this.client,i=a.getState(),c=Vs(e.uuid)(i);if(!c)throw new Error(`Expected AssetProcedureStepFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(et(n));const r=this.enqueueRequest({description:"Update asset procedure step field values",method:h.PATCH,url:`/asset-procedure-step-field-values/${e.uuid}/`,payload:e,blockers:[n.fields_revision,n.asset,n.asset_procedure_instance],blocks:[n.uuid]});return r.then(l=>{this.dispatch(et(l))}).catch(()=>{this.dispatch(et(c))}),[n,r]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Vs(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=er(e)(i);this.dispatch(qs(e)),this.dispatch(yt(n.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset procedure step field values",method:h.DELETE,url:`/asset-procedure-step-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(js(c)),this.dispatch(At(n)),r}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset procedure step field values",method:h.GET,url:"/asset-procedure-step-field-values/",queryParams:{limit:E,paginate:!0,asset_procedure_instance__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset procedure step field values",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(ar(c)),c}}class Ob extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Us(n));const r=this.enqueueRequest({description:"Create asset procedure step",method:h.POST,url:"/asset-procedure-steps/",payload:w(n),blockers:[n.asset_procedure],blocks:[n.uuid]});return r.then(m=>{this.dispatch(St(m))}).catch(()=>{this.dispatch(Ds(n.uuid))}),[n,r]}update(e){const{store:a}=this.client,i=Cs(e.uuid)(a.getState());if(!i)throw new Error(`No asset procedure step with uuid ${e.uuid} found in the store`);const c={...i,...e};this.dispatch(St(c));const n=this.enqueueRequest({description:"Update asset procedure step",method:h.PATCH,url:`/asset-procedure-steps/${i.uuid}/`,payload:{name:e.name,description:e.description,priority:e.order,color:e.color},blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(St(r))}).catch(()=>{this.dispatch(lr(i))}),[c,n]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Cs(e)(i);if(!c)throw new Error(`No asset procedure step with uuid ${e} found in the store`);return this.dispatch(Ds(e)),this.enqueueRequest({description:"Delete asset stage",method:h.DELETE,url:`/asset-stages/${e}/`,blockers:[e],blocks:[]}).catch(n=>{throw this.dispatch(Us(c)),n})}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get asset procedure steps",method:h.GET,url:"/asset-procedure-steps/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]},a);return this.dispatch(or(i)),i}}class _b extends v{add(e){var l;const{store:a}=this.client;if(!e.canvas_marker&&!e.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");const i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Bs(n));const r=this.enqueueRequest({description:"Create asset",method:h.POST,url:"/assets/",payload:w(n),blockers:[n.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(tt(m))}).catch(()=>{this.dispatch(Gs(n.uuid))}),[n,r]}update(e){const{store:a}=this.client,i=Hs(e.uuid)(a.getState());if(!i)throw new Error(`No asset with uuid ${e.uuid} found in the store`);const c={...i,...e};if(!c.canvas_marker&&!c.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");this.dispatch(tt(c));const n=this.enqueueRequest({description:"Edit asset",method:h.PATCH,url:`/assets/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.then(r=>{this.dispatch(tt(r))}).catch(()=>{this.dispatch(tt(i))}),[c,n]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Hs(e)(i);if(!c)throw new Error(`No asset with uuid ${e} found in the store`);const n=kc(e)(i),r=zu(e)(i),l=xu(e)(i);if(this.dispatch(Gs(e)),n.length>0){const m=n.map(({uuid:u})=>u);this.dispatch(es(m))}if(r.length>0){const m=r.map(({uuid:u})=>u);this.dispatch(qt(m))}if(l.length>0){const m=l.map(({uuid:u})=>u);this.dispatch(Xa(m))}return this.enqueueRequest({description:"Delete asset",method:h.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(Bs(c)),this.dispatch(xt(n)),this.dispatch(jt(r)),this.dispatch(Za(l)),m})}bulkAdd(e,a,i,c){const n=new Date().toISOString(),r=Ne.v4(),l=$e(e,c).map(o=>{const p=o.map(A=>T(A));return{batchId:Ne.v4(),payload:{transaction_id:r,submitted_at:n,asset_type:a,project:i,assets:p}}}),m=[];let u=null;for(const o of l){const{batchId:p,payload:A}=o,y=A.assets.map(R=>R.uuid),b=[a];u&&b.push(u);const P=y;P.push(p);const _=this.enqueueRequest({description:"Batch create assets",method:h.POST,url:"/assets/bulk/",payload:A,blockers:b,blocks:P});u=o.batchId,m.push(_)}return Promise.all(m).then(o=>{const p=o.flat();this.dispatch(bt(p))}),m}async bulkDelete(e){const{store:a}=this.client,i=a.getState(),c=fr(e)(i);this.dispatch($s(e));try{await this.enqueueRequest({description:"Bulk delete assets",method:h.DELETE,url:"/assets/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(bt(c)),n}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get assets",method:h.GET,url:"/assets/",queryParams:{limit:E,paginate:!0,project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get assets",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Ar(c)),c}}class Rb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Ys(n));const r=this.enqueueRequest({description:"Add asset stage completion",method:h.POST,url:"/asset-stage-completions/",payload:w(n),blockers:[e.asset,e.stage],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Pr(m))}).catch(()=>{this.dispatch(Zs(n.uuid))}),[n,r]}delete(e){const{store:a}=this.client,i=Ir(e)(a.getState());if(!i)throw new Error(`Expected asset stage completion with uuid ${e} to exist`);this.dispatch(Zs(e));const c=this.enqueueRequest({description:"Delete asset stage completion",method:h.DELETE,url:`/asset-stage-completions/${e}/`,blockers:[e],blocks:[]});return c.catch(()=>{this.dispatch(Ys(i))}),c}bulkAdd(e){var u;const{store:a}=this.client,i=new Date().toISOString(),c=(u=a.getState().userReducer.currentUser)==null?void 0:u.id,n=e.map(o=>T(o)),r=n.map(o=>({...o,created_by:c,submitted_at:i})),l=r.map(({uuid:o})=>o);this.dispatch(Ks(r));const m=this.enqueueRequest({description:"Bulk create asset stage completions",method:h.POST,url:"/asset-stage-completions/bulk/",payload:{submitted_at:i,completions:n},blockers:[...e.map(o=>o.asset_procedure_instance),...e.map(o=>o.stage),...e.map(o=>o.asset)],blocks:l});return m.then(o=>{this.dispatch(Fr(o))}).catch(()=>{this.dispatch(Js(l))}),[r,m]}bulkDelete(e){const{store:a}=this.client,i=Or(e)(a.getState());this.dispatch(Js(e));const c=this.enqueueRequest({description:"Deleting asset stage completions",method:h.DELETE,url:"/asset-stage-completions/bulk/",payload:{uuids:e},blockers:e,blocks:[]});return c.catch(()=>{this.dispatch(Ks(i))}),c}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset stage completions",method:h.GET,url:"/asset-stage-completions/",queryParams:{limit:E,paginate:!0,asset_procedure_instance__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset stage completions",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(br(c)),c}}class vb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(xs(n));const r=this.enqueueRequest({description:"Create asset",method:h.POST,url:"/asset-stages/",payload:w(n),blockers:[n.asset_procedure],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Pt(m))}).catch(()=>{this.dispatch(ea(n.uuid))}),[n,r]}update(e){const{store:a}=this.client,i=ta(e.uuid)(a.getState());if(!i)throw new Error(`No asset stage with uuid ${e.uuid} found in the store`);const c={...i,...e};this.dispatch(Pt(c));const n=this.enqueueRequest({description:"Update asset stage",method:h.PATCH,url:`/asset-stages/${i.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(Pt(r))}).catch(()=>{this.dispatch(vr(i))}),[c,n]}async delete(e){const{store:a}=this.client,i=a.getState(),c=ta(e)(i);if(!c)throw new Error(`No asset stage with uuid ${e} found in the store`);return this.dispatch(ea(e)),this.enqueueRequest({description:"Delete asset stage",method:h.DELETE,url:`/asset-stages/${e}/`,blockers:[e],blocks:[]}).catch(n=>{throw this.dispatch(xs(c)),n})}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get asset stages",method:h.GET,url:"/asset-stages/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]},a);return this.dispatch(Rr(i)),i}}class wb extends ke{constructor(){super(...arguments);S(this,"name","Asset Type Attachment");S(this,"url","/asset-type-attachments");S(this,"addAttachments",aa);S(this,"updateAttachments",Vr);S(this,"removeAttachments",ia);S(this,"removeAttachment",zr);S(this,"setAttachment",qr);S(this,"selectAttachment",Cr)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,asset_type:a.modelUuid})}buildAttachmentPayload(a){return{...a,asset_type:a.modelUuid}}async bulkAdd(a){return this._bulkAdd(a.map(i=>({modelUuid:i.assetTypeUuid,file:i.file})))}async delete(a){return this._delete(a)}async refreshStore(a,i){const c=await this.enqueueRequest({description:"Get asset type attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset_type__organization:a},blocks:[],blockers:[]},i);return this.dispatch(jr(c)),c}}class Mb extends q{async bulkAdd(e){var m;const a=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldsRevisionUuid:o,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:o,submitted_at:a,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:o};r.push(P)}this.dispatch(Lr(n));const l=this.enqueueRequest({description:"Add asset type fields attachments",method:h.POST,url:"/asset-type-fields-attachments/bulk/",payload:{submitted_at:a,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.fields_revision),blocks:n.map(u=>u.uuid)});return l.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(Nr(u.attachments))}).catch(()=>{this.dispatch(Hr(n.map(u=>u.uuid)))}),[n,l.then(({attachments:u})=>u)]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get asset type fields attachments",method:h.GET,url:"/asset-type-fields-attachments/",queryParams:{fields_revision__asset_type__organization:e},blockers:[e],blocks:[]},a);return this.dispatch($r(i)),i}}class Eb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Xr(n));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:h.POST,url:"/asset-type-fields/",payload:w(n),blockers:[n.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Qr(m))}).catch(m=>{throw this.dispatch(xr(n.uuid)),m}),[n,r]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get Asset Type Fields",method:h.GET,url:"/asset-type-fields/",queryParams:{asset_type__organization:e},blockers:[],blocks:[]},a);return this.dispatch(Jr(i)),i}}class jb extends q{async bulkAdd(e,a){var u;const i=new Date().toISOString(),c=(u=this.client.store.getState().userReducer.currentUser)==null?void 0:u.id,n=$e(e,a??e.length),r=[],l=[];for(const o of n){const p={},A=[];for(const y of o){const{fieldValuesUuid:b,fieldIdentifier:P,file:_}=y,R=await this.getFilePayload(_);R.sha1 in p||(p[R.sha1]=R);const z=T({file:URL.createObjectURL(_),file_type:_.type,file_name:_.name,file_sha1:R.sha1,created_by:c,field_values:b,submitted_at:i,field_identifier:P});r.push(z);const De={uuid:z.uuid,file_name:_.name,file_sha1:R.sha1,file_extension:R.extension,field_identifier:P,field_values:b};A.push(De)}l.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(It(r));const m=l.map(o=>this.enqueueRequest({description:"Add asset type field values attachments",method:h.POST,url:"/asset-type-field-values-attachments/bulk/",payload:o,blockers:o.attachments.map(p=>p.field_values),blocks:o.attachments.map(p=>p.uuid)}));return Promise.all(m).then(o=>{for(const A of o)this.processPresignedUrls(A.presigned_urls);const p=o.flatMap(A=>A.attachments);this.dispatch(id(p))}).catch(o=>{throw this.dispatch(Ot(r.map(p=>p.uuid))),o}),[r,m.map(o=>o.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:a}=this.client,i=a.getState(),c=nd(e)(i);this.dispatch(Ot(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:h.DELETE,url:"/asset-type-field-values-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(It(c)),n}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset type field values attachments",method:h.GET,url:"/asset-type-field-values-attachments/",queryParams:{limit:E,paginate:!0,field_values__asset__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset type field values attachments",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(ad(c)),c}}class qb extends v{add(e){var r;const{store:a}=this.client,i=a.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add asset type field values",method:h.POST,url:"/asset-type-field-values/",payload:w(c),blockers:[e.asset,e.fields_revision],blocks:[c.uuid]});return this.dispatch(oa(c)),n.then(l=>(this.dispatch(st(l)),l)).catch(()=>{this.dispatch(la(c.uuid))}),[c,n]}bulkAdd(e,a){var m;const i=new Date().toISOString(),c=[],n=$e(e.payloads,a??e.payloads.length),r=[];for(const u of n){const o=[];for(const p of u){const A=T({...p,values:p.values,created_by:(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,submitted_at:i});c.push(A),o.push({uuid:A.uuid,asset:p.asset,fields_revision:p.fields_revision,published_at:p.published_at,values:A.values})}r.push({submitted_at:i,values:e.values,field_values:o})}this.dispatch(ld(c));const l=[];for(const u of r){const o=u.field_values.map(b=>b.asset),p=u.field_values.map(b=>b.fields_revision),A=u.field_values.map(b=>b.uuid),y=this.enqueueRequest({description:"Bulk add asset type field values",method:h.POST,url:"/asset-type-field-values/bulk/",payload:u,blockers:[...o,...p],blocks:A});l.push(y)}return Promise.all(l).then(u=>{this.dispatch(hd(u.flat()))}).catch(()=>{this.dispatch(md(c.map(u=>u.uuid)))}),[c,l]}update(e){const{store:a}=this.client,i=a.getState(),c=ma(e.uuid)(i);if(!c)throw new Error(`Expected AssetTypeFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(st(n));const r=this.enqueueRequest({description:"Delete asset type field values",method:h.PATCH,url:`/asset-type-field-values/${e.uuid}/`,payload:e,blockers:[n.uuid,n.fields_revision,n.asset],blocks:[n.uuid]});return r.then(l=>{this.dispatch(st(l))}).catch(()=>{this.dispatch(st(c))}),[n,r]}async delete(e){const{store:a}=this.client,i=a.getState(),c=ma(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=rd(e)(i);this.dispatch(la(e)),this.dispatch(Ot(n.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset type field values",method:h.DELETE,url:`/asset-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(oa(c)),this.dispatch(It(n)),r}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset type field values",method:h.GET,url:"/asset-type-field-values/",queryParams:{limit:E,paginate:!0,asset__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset type field values",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(od(c)),c}}class Vb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Aa(n));const r=this.enqueueRequest({description:"Create asset type",method:h.POST,url:"/asset-types/",payload:w(n),blockers:[],blocks:[n.uuid]});return r.then(m=>{this.dispatch(at(m))}).catch(()=>{this.dispatch(ya(n.uuid))}),[n,r]}update(e){const{store:a}=this.client,i=Sa(e.uuid)(a.getState());if(!i)throw new Error(`Expected asset type with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(at(c));const n=this.enqueueRequest({description:"Update asset type",method:h.PATCH,url:`/asset-types/${e.uuid}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(at(r))}).catch(()=>{this.dispatch(at(i))}),[c,n]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Sa(e)(i);if(!c)throw new Error(`Expected asset type with uuid ${e} to exist`);const n=Ns(e)(i),r=kr(e)(i);return this.dispatch(ya(e)),this.dispatch($s(n.map(l=>l.uuid))),this.dispatch(ia(r.map(({uuid:l})=>l))),this.enqueueRequest({description:"Delete asset type",method:h.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(l=>{throw this.dispatch(Aa(c)),this.dispatch(bt(n)),this.dispatch(aa(r)),l})}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get asset types",method:h.GET,url:"/asset-types/",queryParams:{organization:e},blockers:[],blocks:[]},a);return this.dispatch(fd(i)),i}}class zb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(ba(n));const r=this.enqueueRequest({description:"Create Category",method:h.POST,url:"/categories/",payload:w(n),blockers:[e.project],blocks:[n.uuid]});return[n,r]}update(e){const a=this.client.store.getState(),i=Fa(e.uuid)(a);if(!i)throw new Error(`Expected an existing category with uuid ${e.uuid}`);const c={...i,...e};this.dispatch(Od(c));const n=this.enqueueRequest({description:"Edit Category",method:h.PATCH,url:`/categories/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return[c,n]}remove(e){const{store:a}=this.client,i=Fa(e)(a.getState());if(!i)throw new Error(`No category with uuid ${e} found in the store`);this.dispatch(_d(e));const c=this.enqueueRequest({description:"Delete Category",method:h.DELETE,url:`/categories/${i.uuid}/`,blockers:[i.uuid],blocks:[]});return c.catch(()=>{this.dispatch(ba(i))}),c}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get categories",method:h.GET,url:"/categories/",queryParams:{project__organization_owner:e},blocks:[],blockers:[]},a);return this.dispatch(Id(i)),i}}class Ub extends ke{constructor(){super(...arguments);S(this,"name","Document Attachment");S(this,"url","/document-attachments");S(this,"addAttachments",Ed);S(this,"updateAttachments",qd);S(this,"removeAttachments",zd);S(this,"removeAttachment",Vd);S(this,"setAttachment",jd);S(this,"selectAttachment",Cd)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,document:a.modelUuid})}buildAttachmentPayload(a){return{...a,document:a.modelUuid}}async bulkAdd(a){var p;const{store:i}=this.client,c=(p=i.getState().userReducer.currentUser)==null?void 0:p.id,n=new Date().toISOString(),r=[],l=[],m={},u={};for(const A of a){const{documentUuid:y,file:b}=A,P=await this.getFilePayload(b);P.sha1 in m||(m[P.sha1]=P,u[P.sha1]=[]);const _=this.buildOfflineAttachment({file:b,file_sha1:P.sha1,submitted_at:n,created_by:c,description:"",modelUuid:y});r.push(_),l.push({uuid:_.uuid,file_name:_.file_name,file_sha1:_.file_sha1,file_extension:P.extension,description:_.description,document:y}),u[P.sha1].push(_.uuid)}this.dispatch(this.addAttachments(r));const o=this.enqueueRequest({description:"Attach files to document",method:h.POST,url:"/document-attachments/bulk/",payload:{submitted_at:n,attachments:l,files:Object.values(m)},blocks:r.map(A=>A.uuid),blockers:r.map(A=>A.file_sha1)});return o.then(({attachments:A,presigned_urls:y})=>{this.dispatch(this.updateAttachments(A));const b=this.processPresignedUrls(y);for(const[P,_]of Object.entries(b))_.then(()=>{const R=u[P];for(const z of R)this.makeReadable(z)})}).catch(()=>{this.dispatch(this.removeAttachments(r.map(A=>A.uuid)))}),[r,o.then(({attachments:A})=>A)]}async delete(a){return this._delete(a)}makeReadable(a){this.enqueueRequest({description:"Add attachment to AI assistant",method:h.PATCH,url:`/document-attachments/${a}/`,payload:{readable_to_assistant:!0},blockers:["index-document-attachment",a],blocks:["index-document-attachment"]})}async refreshStore(a,i){const c=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:"/document-attachments/",queryParams:{document__project__organization_owner:a},blocks:[],blockers:[]},i),n=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:"/document-attachments/",queryParams:{document__organization:a},blocks:[],blockers:[]},i),r=[...c,...n];return this.dispatch(Md(r)),r}}class Db extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch($d([n]));const r=this.enqueueRequest({description:"Create Document",method:h.POST,url:"/documents/",payload:w(n),queryParams:{parent_document:n.parent_document??void 0},blockers:n.parent_document?[n.parent_document]:[],blocks:[n.uuid]});return r.catch(()=>{this.dispatch(Oa([n.uuid]))}),[n,r]}update(e){const{store:a}=this.client,i=a.getState().documentsReducer.documents[e.uuid];if(!i)throw new Error(`attempting to update a document with uuid ${e.uuid} that does not exist in store.documents`);const c={...i,...e};this.dispatch(We([c]));const n=this.enqueueRequest({description:"Update Document",method:h.PATCH,url:`/documents/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.catch(()=>{We([i])}),[c,n]}delete(e){const{store:a}=this.client,i=Rt(a.getState()),c=Ld(e)(a.getState());if(!c)throw new Error(`attempting to delete a document with uuid ${e} that does not exist in store.documents`);const n=c.parent_document?i[c.parent_document]:void 0;this.dispatch(Oa([e]));const r=this.enqueueRequest({description:"Delete Document",method:h.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return r.then(l=>{this.dispatch(We(l))}).catch(()=>{this.dispatch(We([c])),n&&this.dispatch(We([n]))}),r}async refreshStore(e,a){const i=this.enqueueRequest({description:"Get project documents",method:h.GET,url:"/documents/",queryParams:{project__organization_owner:e},blockers:[],blocks:[]},a),c=this.enqueueRequest({description:"Get organization documents",method:h.GET,url:"/documents/",queryParams:{organization:e},blockers:[],blocks:[]},a),n=[...await i,...await c];return this.dispatch(Gd(n)),n}}class Cb extends v{async add(e,a){return this.enqueueRequest({description:"Add email domain to organization",method:h.POST,url:"/organization-email-domains/",payload:{email:a,organization:e},blockers:[e,"create-org"],blocks:[]})}async remove(e){return this.dispatch(Kd(e.uuid)),this.enqueueRequest({description:"Remove email domain from organization",method:h.DELETE,url:`/organization-email-domains/${e.uuid}/`,blockers:[e.domain],blocks:[]}).catch(a=>{throw this.dispatch(Yd(e)),a})}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Fetch email domains for organization",method:h.GET,url:"/organization-email-domains/",queryParams:{organization:e},blockers:[e],blocks:[]},a);return this.dispatch(Wd(i)),i}}class kb extends v{async getVerificationCode(e){return this.enqueueRequest({description:"Get verification code",method:h.GET,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}validateVerificationCode(e,a=void 0){return this.enqueueRequest({description:"Validate verification code",method:h.POST,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,payload:a,blockers:[],blocks:[]})}}const Gt={},uc=new Set;let $t=0,oc=0,lc=0;const Bb=20;class Gb extends v{constructor(){super(...arguments);S(this,"host");S(this,"_dbPromise",Am.openDB("fileCache",1,{upgrade(a){a.createObjectStore("files")}}))}async renewUploadUrl(a){const i=await this.fetchCache(a);if(!i)throw new Error(`File with sha1 ${a} not found in cache`);const c=await Kt(i,a),n=await this.enqueueRequest({description:"Get S3 URL",method:h.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await He(i),file_type:i.type,extension:i.name.split(".").pop(),size:i.size.toString()},blockers:[],blocks:[`s3-${c}`]});return"url"in n&&this.dispatch(eu({sha1:a,...n})),n}async addCache(a,i){if(uc.has(i))return;if(!a.type){const r=a.name.split("."),l=r[r.length-1];a=new File([a],a.name,{type:l})}if(!a.name||!a.size||!a.type)throw new Error("Cannot add files to cache that do not have a name, size and type.");const c=await this._dbPromise;!!await c.get("files",i)?(console.error("File already cached (this is unexpected at this point):",a.name,i),$t++):(await c.put("files",a,i),oc++),uc.add(i),lc++,lc%Bb===0&&console.debug(`File cache summary: ${$t} hits and ${oc} misses, ${$t/($t+oc)*100}% hit rate over ${lc} calls to addCache.`)}async removeCache(a){await(await this._dbPromise).delete("files",a),uc.delete(a)}async fetchCache(a){return(await this._dbPromise).get("files",a)}async getOrRenewUploadUrl(a){const i=this.client.store.getState();return tu(a)(i)??await this.renewUploadUrl(a)}async uploadFileToS3(a){const i=await this.fetchCache(a);if(!i)throw new Error(`File with sha1 ${a} not found in cache`);const c=await Kt(i,a),n={file_name:i.name,file_sha1:a,file:c},r=await this.getOrRenewUploadUrl(a);if("warning"in r){if(r.warning==="already_uploaded")return[n,Promise.resolve(void 0).then()];throw new Error(r.warning)}const l=r.url,m=this.enqueueRequest({url:l,description:"Upload file",method:h.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:a,blockers:[`s3-${c}`],blocks:[a],s3url:r});return[n,m]}async fetchFileFromUrl(a,i,c){const n=a.split("?")[0]??a,r=await this.fetchCache(i);if(r){if(!r.name)throw new Error("Cached file unexpectedly has no name.");return r}if(a.startsWith("blob:")){const o=await Pc(a),p=new File([o],c??i,{type:o.type});return await this.addCache(p,i),p}let l=Gt[n],m=!0;l?m=!1:(l=new Promise(o=>{this.enqueueRequest({description:"Download file",method:h.GET,url:a,isExternalUrl:!0,isResponseBlob:!0,isAuthNeeded:!1,blockers:[i],blocks:[i]}).then(p=>{const A=new File([p],c??i,{type:p.type});o(A)})}),Gt[n]=l);let u;try{u=await l}catch(o){throw m&&o instanceof D&&delete Gt[n],o}if(m){const o=await He(u);if(o!==i){const y=`The hash of the file returned from the server (${o}) does not match the
8
+ `)}catch(c){console.error("Failed to extract error message from response body",c)}}else typeof t.body=="string"&&(a=t.body);else t!=null&&t.text?a=t.text:e instanceof Error&&(a=e.message);return!a||a.length>rb?Ye:a}class D extends Error{constructor(a){super(Ye);S(this,"status");S(this,"response");S(this,"message");S(this,"options");const{response:i,innerError:c}=a;this.message=a.message??db(i,c)??Ye,this.status=(i==null?void 0:i.status)??0,this.response=i,a.discard=a.discard??!1,this.options=a}}class ub extends xh{constructor(e){super(e)}}class v extends xh{constructor(a,i){super(a);S(this,"auth");this.auth=i}}class ob extends v{async startConversation(e,a){return this.enqueueRequest({description:"Start agent conversation",method:h.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:a},blockers:["prompt"],blocks:["prompt"]}).then(i=>(this.dispatch(vc(i)),i))}async continueConversation(e,a,i){return this.enqueueRequest({description:"Prompt agent",method:h.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:i},blockers:["prompt"],blocks:["prompt"],queryParams:{conversation_id:a}}).then(c=>{this.dispatch(Mc(c))})}async fetchDetails(e){return this.enqueueRequest({description:"Get agent conversation",method:h.GET,url:`/agents/conversations/${e}/`,blockers:["conversation"],blocks:["conversation"]}).then(a=>{this.dispatch(wc(a))})}async rate(e,a){return this.enqueueRequest({description:"Rate agent response",method:h.PUT,url:`/agents/responses/${e}/rate/`,payload:{rating:a},blockers:["rate"],blocks:["rate"]})}async refreshStore(e,a){const i=await this.enqueueRequest({immediate:!0,description:"Get agent conversation history",method:h.GET,url:"/agents/conversations/",queryParams:{project:e},blockers:["agent-conversations"],blocks:["agent-conversations"]},a);return this.dispatch(Rc(i)),i}}const lb=5e4,E=1e3,hb="limit";class q extends v{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:a,assetAttachmentReducer:i,assetTypeAttachmentReducer:c,documentAttachmentReducer:n,projectAttachmentReducer:r,formRevisionAttachmentReducer:l,formSubmissionAttachmentReducer:m,geoImageReducer:u,assetTypeFieldsAttachmentReducer:o,assetTypeFieldValuesAttachmentReducer:p,issueTypeFieldsAttachmentReducer:A,issueTypeFieldValuesAttachmentReducer:y}=this.client.store.getState();return[].concat(Object.values(a.instances),Object.values(i.instances),Object.values(c.instances),Object.values(n.instances),Object.values(r.instances),Object.values(l.instances),Object.values(m.instances),Object.values(u.instances),Object.values(o.instances),Object.values(p.instances),Object.values(A.instances),Object.values(y.instances)).filter(P=>P.file_sha1===e).length}processPresignedUrls(e){const a={};for(const[i,c]of Object.entries(e))a[i]=this.enqueueRequest({url:c.url,description:"Upload file to S3",method:h.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:i,blockers:[`s3-${c.fields.key}`],blocks:[i],s3url:c});return a}async getFilePayload(e){const a=await He(e),i={sha1:a,file_type:e.type,extension:e.name.split(".").pop(),size:e.size};return await this.client.files.addCache(e,a),i}}class ke extends q{async _bulkAdd(e){var u;const{store:a}=this.client,i=(u=a.getState().userReducer.currentUser)==null?void 0:u.id,c=new Date().toISOString(),n=[],r=[],l={};for(const o of e){const{modelUuid:p,file:A}=o,y=await this.getFilePayload(A);y.sha1 in l||(l[y.sha1]=y);const b=this.buildOfflineAttachment({file:A,file_sha1:y.sha1,submitted_at:c,created_by:i,description:"",modelUuid:p});n.push(b),r.push(this.buildAttachmentPayload({uuid:b.uuid,file_name:b.file_name,file_sha1:b.file_sha1,file_extension:y.extension,description:b.description,modelUuid:p}))}this.dispatch(this.addAttachments(n));const m=this.enqueueRequest({description:`Add ${this.name}`,method:h.POST,url:`${this.url}/bulk/`,payload:{submitted_at:c,attachments:r,files:Object.values(l)},blocks:n.map(o=>o.uuid),blockers:n.map(o=>o.file_sha1)});return m.then(({attachments:o,presigned_urls:p})=>{this.dispatch(this.updateAttachments(o)),this.processPresignedUrls(p)}).catch(()=>{this.dispatch(this.removeAttachments(n.map(o=>o.uuid)))}),[n,m.then(({attachments:o})=>o)]}async _delete(e){const{store:a}=this.client,i=this.selectAttachment(e)(a.getState());if(!i)throw new Error(`Attempting to delete attachment with uuid ${e} that does not exist in the store`);this.dispatch(this.removeAttachment(i.uuid));const c=this.enqueueRequest({description:`Delete ${this.name}`,method:h.DELETE,url:`${this.url}/${e}/`,blockers:[e],blocks:[]});return c.then(()=>{this.getNumberOfAttachmentsWithSha1(i.file_sha1)===0&&this.client.files.removeCache(i.file_sha1)}).catch(()=>{this.dispatch(this.setAttachment(i))}),c}}class mb extends ke{constructor(){super(...arguments);S(this,"name","Asset Attachment");S(this,"url","/asset-attachments");S(this,"initializeAttachments",Qt);S(this,"addAttachments",xt);S(this,"updateAttachments",Vc);S(this,"removeAttachments",es);S(this,"removeAttachment",zc);S(this,"setAttachment",qc);S(this,"selectAttachment",Cc)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,asset:a.modelUuid})}buildAttachmentPayload(a){return{...a,asset:a.modelUuid}}async bulkAdd(a){return this._bulkAdd(a.map(i=>({modelUuid:i.assetUuid,file:i.file})))}async delete(a){return this._delete(a)}async refreshStore(a,i){const n=(await this.performPagination({immediate:!0,description:"Get asset attachments",method:h.GET,url:`${this.url}/`,queryParams:{limit:E,paginate:!0,asset__project:a},blocks:[],blockers:[]},r=>({immediate:!0,description:"Get asset attachments",method:h.GET,url:r,blockers:[],blocks:[]}),i)).flat();return this.dispatch(Qt(n)),n}}class pb extends ke{constructor(){super(...arguments);S(this,"name","Asset Procedure Attachment");S(this,"url","/asset-procedure-attachments");S(this,"addAttachments",Lc);S(this,"updateAttachments",Hc);S(this,"removeAttachments",Yc);S(this,"removeAttachment",Wc);S(this,"setAttachment",Nc);S(this,"selectAttachment",Jc)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,asset_procedure:a.modelUuid})}buildAttachmentPayload(a){return{...a,asset_procedure:a.modelUuid}}async bulkAdd(a){return this._bulkAdd(a.map(i=>({modelUuid:i.assetProcedureUuid,file:i.file})))}async delete(a){return this._delete(a)}async refreshStore(a,i){const c=await this.enqueueRequest({description:"Get asset procedure attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset_procedure__organization:a},blocks:[],blockers:[]},i);return this.dispatch($c(c)),c}}class Ab extends q{async bulkAdd(e){var m;const a=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldsRevisionUuid:o,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:o,submitted_at:a,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:o};r.push(P)}this.dispatch(en(n));const l=this.enqueueRequest({description:"Add asset procedure fields attachments",method:h.POST,url:"/asset-procedure-fields-attachments/bulk/",payload:{submitted_at:a,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.fields_revision),blocks:n.map(u=>u.uuid)});return l.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(tn(u.attachments))}).catch(()=>{this.dispatch(sn(n.map(u=>u.uuid)))}),[n,l.then(({attachments:u})=>u)]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get asset procedure fields attachments",method:h.GET,url:"/asset-procedure-fields-attachments/",queryParams:{fields_revision__asset_procedure__organization:e},blockers:[],blocks:[]},a);return this.dispatch(xc(i)),i}}class yb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(un(n));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:h.POST,url:"/asset-procedure-fields/",payload:w(n),blockers:[n.asset_procedure],blocks:[n.uuid]});return r.then(m=>{this.dispatch(on(m))}).catch(m=>{throw this.dispatch(ln(n.uuid)),m}),[n,r]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:h.GET,url:"/asset-procedure-fields/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]},a);return this.dispatch(dn(i)),i}}function $e(t,e){const a=[];let i=0;const c=t.length;for(;i<c;)a.push(t.slice(i,i+=e));return a}class fb extends q{async bulkAdd(e,a){var u;const i=new Date().toISOString(),c=(u=this.client.store.getState().userReducer.currentUser)==null?void 0:u.id,n=$e(e,a??e.length),r=[],l=[];for(const o of n){const p={},A=[];for(const y of o){const{fieldValuesUuid:b,fieldIdentifier:P,file:_}=y,R=await this.getFilePayload(_);R.sha1 in p||(p[R.sha1]=R);const z=T({file:URL.createObjectURL(_),file_type:_.type,file_name:_.name,file_sha1:R.sha1,created_by:c,field_values:b,submitted_at:i,field_identifier:P});r.push(z);const De={uuid:z.uuid,file_name:_.name,file_sha1:R.sha1,file_extension:R.extension,field_identifier:P,field_values:b};A.push(De)}l.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(mt(r));const m=l.map(o=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:h.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:o,blockers:o.attachments.map(p=>p.field_values),blocks:o.attachments.map(p=>p.uuid)}));return Promise.all(m).then(o=>{for(const A of o)this.processPresignedUrls(A.presigned_urls);const p=o.flatMap(A=>A.attachments);this.dispatch(yn(p))}).catch(o=>{throw this.dispatch(pt(r.map(p=>p.uuid))),o}),[r,m.map(o=>o.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:a}=this.client,i=a.getState(),c=Sn(e)(i);this.dispatch(pt(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:h.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(mt(c)),n}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset procedure field values attachments",method:h.GET,url:"/asset-procedure-field-values-attachments/",queryParams:{limit:E,paginate:!0,field_values__asset_procedure_instance__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset procedure field values attachments",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(An(c)),c}}class Sb extends v{add(e){var r;const{store:a}=this.client,i=a.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add asset procedure field values",method:h.POST,url:"/asset-procedure-field-values/",payload:w(c),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[c.uuid]});return this.dispatch(ds(c)),n.then(l=>(this.dispatch(Je(l)),l)).catch(()=>{this.dispatch(us(c.uuid))}),[c,n]}bulkAdd(e,a){var m;const i=new Date().toISOString(),c=[],n=$e(e.payloads,a??e.payloads.length),r=[];for(const u of n){const o=[];for(const p of u){const A=T({...p,values:p.values,created_by:(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,submitted_at:i});c.push(A),o.push({uuid:A.uuid,asset:p.asset,fields_revision:p.fields_revision,asset_procedure_instance:p.asset_procedure_instance,published_at:p.published_at,values:A.values})}r.push({submitted_at:i,values:e.values,field_values:o})}this.dispatch(Tn(c));const l=[];for(const u of r){const o=u.field_values.map(P=>P.asset),p=u.field_values.map(P=>P.fields_revision),A=u.field_values.map(P=>P.asset_procedure_instance),y=u.field_values.map(P=>P.uuid),b=this.enqueueRequest({description:"Bulk add asset procedure field values",method:h.POST,url:"/asset-procedure-field-values/bulk/",payload:u,blockers:[...o,...p,...A],blocks:y});l.push(b)}return Promise.all(l).then(u=>{this.dispatch(In(u.flat()))}).catch(()=>{this.dispatch(On(c.map(u=>u.uuid)))}),[c,l]}update(e){const{store:a}=this.client,i=a.getState(),c=ls(e.uuid)(i);if(!c)throw new Error(`Expected AssetProcedureFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(Je(n));const r=this.enqueueRequest({description:"Update asset procedure field values",method:h.PATCH,url:`/asset-procedure-field-values/${e.uuid}/`,payload:e,blockers:[n.fields_revision,n.asset,n.asset_procedure_instance],blocks:[n.uuid]});return r.then(l=>{this.dispatch(Je(l))}).catch(()=>{this.dispatch(Je(c))}),[n,r]}async delete(e){const{store:a}=this.client,i=a.getState(),c=ls(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=gn(e)(i);this.dispatch(us(e)),this.dispatch(pt(n.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset procedure field values",method:h.DELETE,url:`/asset-procedure-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ds(c)),this.dispatch(mt(n)),r}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset procedure field values",method:h.GET,url:"/asset-procedure-field-values/",queryParams:{limit:E,paginate:!0,asset_procedure_instance__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset procedure field values",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Fn(c)),c}}class gb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(ms(n));const r=this.enqueueRequest({description:"Create asset procedure instance",method:h.POST,url:"/asset-procedure-instances/",payload:w(n),blockers:[e.asset_procedure,e.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Xe(m))}).catch(()=>{this.dispatch(ps(n.uuid))}),[n,r]}update(e){const{store:a}=this.client,i=fs(e.uuid)(a.getState());if(!i)throw new Error(`Expected asset procedure instance with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(Xe(c));const n=this.enqueueRequest({description:"Update asset procedure instance",method:h.PATCH,url:`/asset-procedure-instances/${e.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(Xe(r))}).catch(()=>{this.dispatch(Xe(i))}),[c,n]}async remove(e){const{store:a}=this.client,i=a.getState(),c=fs(e)(i);if(!c)throw new Error(`Expected asset procedure instance with uuid ${e} to exist`);return this.dispatch(ps(e)),this.enqueueRequest({description:"Delete asset procedure instance",method:h.DELETE,url:`/asset-procedure-instances/${e}/`,blockers:[e],blocks:[]}).catch(n=>{throw this.dispatch(ms(c)),n})}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset procedure instances",method:h.GET,url:"/asset-procedure-instances/",queryParams:{limit:E,paginate:!0,project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset procedure instances",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(wn(c)),c}}class bb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(gs(n));const r=this.enqueueRequest({description:"Create asset procedure",method:h.POST,url:"/asset-procedures/",payload:w(n),blockers:[],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Qe(m))}).catch(()=>{this.dispatch(bs(n.uuid))}),[n,r]}update(e){const{store:a}=this.client,i=Fs(e.uuid)(a.getState());if(!i)throw new Error(`Expected asset procedure with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(Qe(c));const n=this.enqueueRequest({description:"Update asset procedure",method:h.PATCH,url:`/asset-procedures/${e.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(Qe(r))}).catch(()=>{this.dispatch(Qe(i))}),[c,n]}async remove(e){const{store:a}=this.client,i=a.getState(),c=Fs(e)(i);if(!c)throw new Error(`Expected asset procedure with uuid ${e} to exist`);const n=jn(e)(i);return this.dispatch(bs(e)),this.dispatch(En(n.map(r=>r.uuid))),this.enqueueRequest({description:"Delete asset procedure",method:h.DELETE,url:`/asset-procedures/${e}/`,blockers:[e],blocks:[]}).catch(r=>{throw this.dispatch(gs(c)),this.dispatch(Mn(n)),r})}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get asset procedures",method:h.GET,url:"/asset-procedures/",queryParams:{organization:e},blockers:[],blocks:[]},a);return this.dispatch(zn(i)),i}}class Pb extends q{async bulkAdd(e){var m;const a=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldsRevisionUuid:o,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:o,submitted_at:a,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:o};r.push(P)}this.dispatch(Bn(n));const l=this.enqueueRequest({description:"Add asset procedure step fields attachments",method:h.POST,url:"/asset-procedure-step-fields-attachments/bulk/",payload:{submitted_at:a,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.fields_revision),blocks:n.map(u=>u.uuid)});return l.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(Gn(u.attachments))}).catch(()=>{this.dispatch($n(n.map(u=>u.uuid)))}),[n,l.then(({attachments:u})=>u)]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get asset procedure step fields attachments",method:h.GET,url:"/asset-procedure-step-fields-attachments/",queryParams:{fields_revision__asset_procedure_step__organization:e},blockers:[],blocks:[]},a);return this.dispatch(kn(i)),i}}class Fb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Os(n));const r=this.enqueueRequest({description:"Add Asset Procedure Step Fields",method:h.POST,url:"/asset-procedure-step-fields/",payload:w(n),blockers:[n.asset_procedure_step],blocks:[n.uuid]});return r.then(m=>{this.dispatch(xe(m))}).catch(m=>{throw this.dispatch(_s(n.uuid)),m}),[n,r]}update(e){const{store:a}=this.client,i=a.getState().assetProcedureStepFieldsReducer.instances[e.uuid];if(!i)throw new Error(`AssetProcedureStepFields with uuid ${e.uuid} not found`);const c={...i,...e};this.dispatch(xe(c));const n=this.enqueueRequest({description:"Update Asset Procedure Step Fields",method:h.PATCH,url:`/asset-procedure-step-fields/${i.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(xe(r))}).catch(r=>{throw this.dispatch(xe(i)),r}),[c,n]}delete(e){const{store:a}=this.client,i=a.getState().assetProcedureStepFieldsReducer.instances[e];if(!i)throw new Error(`AssetProcedureStepFields with uuid ${e} not found`);this.dispatch(_s(e));const c=this.enqueueRequest({description:"Delete Asset Procedure Step Fields",method:h.DELETE,url:`/asset-procedure-step-fields/${e}/`,blockers:[e],blocks:[e]});return c.catch(n=>{throw this.dispatch(Os(i)),n}),c}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get Asset Procedure Step Fields",method:h.GET,url:"/asset-procedure-step-fields/",queryParams:{asset_procedure_step__asset_procedure__organization:e},blockers:[],blocks:[]},a);return this.dispatch(Yn(i)),i}}class Tb extends q{async bulkAdd(e,a){var u;const i=new Date().toISOString(),c=(u=this.client.store.getState().userReducer.currentUser)==null?void 0:u.id,n=$e(e,a??e.length),r=[],l=[];for(const o of n){const p={},A=[];for(const y of o){const{fieldValuesUuid:b,fieldIdentifier:P,file:_}=y,R=await this.getFilePayload(_);R.sha1 in p||(p[R.sha1]=R);const z=T({file:URL.createObjectURL(_),file_type:_.type,file_name:_.name,file_sha1:R.sha1,created_by:c,field_values:b,submitted_at:i,field_identifier:P});r.push(z);const De={uuid:z.uuid,file_name:_.name,file_sha1:R.sha1,file_extension:R.extension,field_identifier:P,field_values:b};A.push(De)}l.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(At(r));const m=l.map(o=>this.enqueueRequest({description:"Add asset procedure step field values attachments",method:h.POST,url:"/asset-procedure-step-field-values-attachments/bulk/",payload:o,blockers:o.attachments.map(p=>p.field_values),blocks:o.attachments.map(p=>p.uuid)}));return Promise.all(m).then(o=>{for(const A of o)this.processPresignedUrls(A.presigned_urls);const p=o.flatMap(A=>A.attachments);this.dispatch(Xn(p))}).catch(o=>{throw this.dispatch(yt(r.map(p=>p.uuid))),o}),[r,m.map(o=>o.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:a}=this.client,i=a.getState(),c=xn(e)(i);this.dispatch(yt(e));try{await this.enqueueRequest({description:"Delete asset procedure step field values attachments",method:h.DELETE,url:"/asset-procedure-step-field-values-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(At(c)),n}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset procedure step field values attachments",method:h.GET,url:"/asset-procedure-step-field-values-attachments/",queryParams:{limit:E,paginate:!0,field_values__asset_procedure_instance__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset procedure step field values attachments",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Jn(c)),c}}class Ib extends v{add(e){var r;const{store:a}=this.client,i=a.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add asset procedure step field values",method:h.POST,url:"/asset-procedure-step-field-values/",payload:w(c),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[c.uuid]});return this.dispatch(js(c)),n.then(l=>(this.dispatch(et(l)),l)).catch(()=>{this.dispatch(qs(c.uuid))}),[c,n]}bulkAdd(e,a){var m;const i=new Date().toISOString(),c=[],n=$e(e.payloads,a??e.payloads.length),r=[];for(const u of n){const o=[];for(const p of u){const A=T({...p,values:p.values,created_by:(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,submitted_at:i});c.push(A),o.push({uuid:A.uuid,asset:p.asset,fields_revision:p.fields_revision,asset_procedure_instance:p.asset_procedure_instance,asset_procedure_step:p.asset_procedure_step,published_at:p.published_at,values:A.values})}r.push({submitted_at:i,values:e.values,field_values:o})}this.dispatch(ir(c));const l=[];for(const u of r){const o=u.field_values.map(P=>P.asset),p=u.field_values.map(P=>P.fields_revision),A=u.field_values.map(P=>P.asset_procedure_instance),y=u.field_values.map(P=>P.uuid),b=this.enqueueRequest({description:"Bulk add asset procedure step field values",method:h.POST,url:"/asset-procedure-step-field-values/bulk/",payload:u,blockers:[...o,...p,...A],blocks:y});l.push(b)}return Promise.all(l).then(u=>{this.dispatch(cr(u.flat()))}).catch(()=>{this.dispatch(nr(c.map(u=>u.uuid)))}),[c,l]}update(e){const{store:a}=this.client,i=a.getState(),c=Vs(e.uuid)(i);if(!c)throw new Error(`Expected AssetProcedureStepFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(et(n));const r=this.enqueueRequest({description:"Update asset procedure step field values",method:h.PATCH,url:`/asset-procedure-step-field-values/${e.uuid}/`,payload:e,blockers:[n.fields_revision,n.asset,n.asset_procedure_instance],blocks:[n.uuid]});return r.then(l=>{this.dispatch(et(l))}).catch(()=>{this.dispatch(et(c))}),[n,r]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Vs(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=er(e)(i);this.dispatch(qs(e)),this.dispatch(yt(n.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset procedure step field values",method:h.DELETE,url:`/asset-procedure-step-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(js(c)),this.dispatch(At(n)),r}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset procedure step field values",method:h.GET,url:"/asset-procedure-step-field-values/",queryParams:{limit:E,paginate:!0,asset_procedure_instance__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset procedure step field values",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(ar(c)),c}}class Ob extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Us(n));const r=this.enqueueRequest({description:"Create asset procedure step",method:h.POST,url:"/asset-procedure-steps/",payload:w(n),blockers:[n.asset_procedure],blocks:[n.uuid]});return r.then(m=>{this.dispatch(St(m))}).catch(()=>{this.dispatch(Ds(n.uuid))}),[n,r]}update(e){const{store:a}=this.client,i=Cs(e.uuid)(a.getState());if(!i)throw new Error(`No asset procedure step with uuid ${e.uuid} found in the store`);const c={...i,...e};this.dispatch(St(c));const n=this.enqueueRequest({description:"Update asset procedure step",method:h.PATCH,url:`/asset-procedure-steps/${i.uuid}/`,payload:{name:e.name,description:e.description,priority:e.order,color:e.color},blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(St(r))}).catch(()=>{this.dispatch(lr(i))}),[c,n]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Cs(e)(i);if(!c)throw new Error(`No asset procedure step with uuid ${e} found in the store`);return this.dispatch(Ds(e)),this.enqueueRequest({description:"Delete asset stage",method:h.DELETE,url:`/asset-stages/${e}/`,blockers:[e],blocks:[]}).catch(n=>{throw this.dispatch(Us(c)),n})}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get asset procedure steps",method:h.GET,url:"/asset-procedure-steps/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]},a);return this.dispatch(or(i)),i}}class _b extends v{add(e){var l;const{store:a}=this.client;if(!e.canvas_marker&&!e.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");const i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Bs(n));const r=this.enqueueRequest({description:"Create asset",method:h.POST,url:"/assets/",payload:w(n),blockers:[n.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(tt(m))}).catch(()=>{this.dispatch(Gs(n.uuid))}),[n,r]}update(e){const{store:a}=this.client,i=Hs(e.uuid)(a.getState());if(!i)throw new Error(`No asset with uuid ${e.uuid} found in the store`);const c={...i,...e};if(!c.canvas_marker&&!c.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");this.dispatch(tt(c));const n=this.enqueueRequest({description:"Edit asset",method:h.PATCH,url:`/assets/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.then(r=>{this.dispatch(tt(r))}).catch(()=>{this.dispatch(tt(i))}),[c,n]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Hs(e)(i);if(!c)throw new Error(`No asset with uuid ${e} found in the store`);const n=kc(e)(i),r=zu(e)(i),l=xu(e)(i);if(this.dispatch(Gs(e)),n.length>0){const m=n.map(({uuid:u})=>u);this.dispatch(es(m))}if(r.length>0){const m=r.map(({uuid:u})=>u);this.dispatch(qt(m))}if(l.length>0){const m=l.map(({uuid:u})=>u);this.dispatch(Xa(m))}return this.enqueueRequest({description:"Delete asset",method:h.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch(Bs(c)),this.dispatch(xt(n)),this.dispatch(jt(r)),this.dispatch(Za(l)),m})}bulkAdd(e,a,i,c){const n=new Date().toISOString(),r=Ne.v4(),l=$e(e,c).map(o=>{const p=o.map(A=>T(A));return{batchId:Ne.v4(),payload:{transaction_id:r,submitted_at:n,asset_type:a,project:i,assets:p}}}),m=[];let u=null;for(const o of l){const{batchId:p,payload:A}=o,y=A.assets.map(R=>R.uuid),b=[a];u&&b.push(u);const P=y;P.push(p);const _=this.enqueueRequest({description:"Batch create assets",method:h.POST,url:"/assets/bulk/",payload:A,blockers:b,blocks:P});u=o.batchId,m.push(_)}return Promise.all(m).then(o=>{const p=o.flat();this.dispatch(bt(p))}),m}async bulkDelete(e){const{store:a}=this.client,i=a.getState(),c=fr(e)(i);this.dispatch($s(e));try{await this.enqueueRequest({description:"Bulk delete assets",method:h.DELETE,url:"/assets/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(bt(c)),n}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get assets",method:h.GET,url:"/assets/",queryParams:{limit:E,paginate:!0,project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get assets",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Ar(c)),c}}class Rb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Ys(n));const r=this.enqueueRequest({description:"Add asset stage completion",method:h.POST,url:"/asset-stage-completions/",payload:w(n),blockers:[e.asset,e.stage],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Pr(m))}).catch(()=>{this.dispatch(Zs(n.uuid))}),[n,r]}delete(e){const{store:a}=this.client,i=Ir(e)(a.getState());if(!i)throw new Error(`Expected asset stage completion with uuid ${e} to exist`);this.dispatch(Zs(e));const c=this.enqueueRequest({description:"Delete asset stage completion",method:h.DELETE,url:`/asset-stage-completions/${e}/`,blockers:[e],blocks:[]});return c.catch(()=>{this.dispatch(Ys(i))}),c}bulkAdd(e){var u;const{store:a}=this.client,i=new Date().toISOString(),c=(u=a.getState().userReducer.currentUser)==null?void 0:u.id,n=e.map(o=>T(o)),r=n.map(o=>({...o,created_by:c,submitted_at:i})),l=r.map(({uuid:o})=>o);this.dispatch(Ks(r));const m=this.enqueueRequest({description:"Bulk create asset stage completions",method:h.POST,url:"/asset-stage-completions/bulk/",payload:{submitted_at:i,completions:n},blockers:[...e.map(o=>o.asset_procedure_instance),...e.map(o=>o.stage),...e.map(o=>o.asset)],blocks:l});return m.then(o=>{this.dispatch(Fr(o))}).catch(()=>{this.dispatch(Js(l))}),[r,m]}bulkDelete(e){const{store:a}=this.client,i=Or(e)(a.getState());this.dispatch(Js(e));const c=this.enqueueRequest({description:"Deleting asset stage completions",method:h.DELETE,url:"/asset-stage-completions/bulk/",payload:{uuids:e},blockers:e,blocks:[]});return c.catch(()=>{this.dispatch(Ks(i))}),c}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset stage completions",method:h.GET,url:"/asset-stage-completions/",queryParams:{limit:E,paginate:!0,asset_procedure_instance__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset stage completions",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(br(c)),c}}class vb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(xs(n));const r=this.enqueueRequest({description:"Create asset",method:h.POST,url:"/asset-stages/",payload:w(n),blockers:[n.asset_procedure],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Pt(m))}).catch(()=>{this.dispatch(ea(n.uuid))}),[n,r]}update(e){const{store:a}=this.client,i=ta(e.uuid)(a.getState());if(!i)throw new Error(`No asset stage with uuid ${e.uuid} found in the store`);const c={...i,...e};this.dispatch(Pt(c));const n=this.enqueueRequest({description:"Update asset stage",method:h.PATCH,url:`/asset-stages/${i.uuid}/`,payload:e,blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(Pt(r))}).catch(()=>{this.dispatch(vr(i))}),[c,n]}async delete(e){const{store:a}=this.client,i=a.getState(),c=ta(e)(i);if(!c)throw new Error(`No asset stage with uuid ${e} found in the store`);return this.dispatch(ea(e)),this.enqueueRequest({description:"Delete asset stage",method:h.DELETE,url:`/asset-stages/${e}/`,blockers:[e],blocks:[]}).catch(n=>{throw this.dispatch(xs(c)),n})}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get asset stages",method:h.GET,url:"/asset-stages/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]},a);return this.dispatch(Rr(i)),i}}class wb extends ke{constructor(){super(...arguments);S(this,"name","Asset Type Attachment");S(this,"url","/asset-type-attachments");S(this,"addAttachments",aa);S(this,"updateAttachments",Vr);S(this,"removeAttachments",ia);S(this,"removeAttachment",zr);S(this,"setAttachment",qr);S(this,"selectAttachment",Cr)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,asset_type:a.modelUuid})}buildAttachmentPayload(a){return{...a,asset_type:a.modelUuid}}async bulkAdd(a){return this._bulkAdd(a.map(i=>({modelUuid:i.assetTypeUuid,file:i.file})))}async delete(a){return this._delete(a)}async refreshStore(a,i){const c=await this.enqueueRequest({description:"Get asset type attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset_type__organization:a},blocks:[],blockers:[]},i);return this.dispatch(jr(c)),c}}class Mb extends q{async bulkAdd(e){var m;const a=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldsRevisionUuid:o,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:o,submitted_at:a,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:o};r.push(P)}this.dispatch(Lr(n));const l=this.enqueueRequest({description:"Add asset type fields attachments",method:h.POST,url:"/asset-type-fields-attachments/bulk/",payload:{submitted_at:a,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.fields_revision),blocks:n.map(u=>u.uuid)});return l.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(Nr(u.attachments))}).catch(()=>{this.dispatch(Hr(n.map(u=>u.uuid)))}),[n,l.then(({attachments:u})=>u)]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get asset type fields attachments",method:h.GET,url:"/asset-type-fields-attachments/",queryParams:{fields_revision__asset_type__organization:e},blockers:[e],blocks:[]},a);return this.dispatch($r(i)),i}}class Eb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Xr(n));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:h.POST,url:"/asset-type-fields/",payload:w(n),blockers:[n.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Qr(m))}).catch(m=>{throw this.dispatch(xr(n.uuid)),m}),[n,r]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get Asset Type Fields",method:h.GET,url:"/asset-type-fields/",queryParams:{asset_type__organization:e},blockers:[],blocks:[]},a);return this.dispatch(Jr(i)),i}}class jb extends q{async bulkAdd(e,a){var u;const i=new Date().toISOString(),c=(u=this.client.store.getState().userReducer.currentUser)==null?void 0:u.id,n=$e(e,a??e.length),r=[],l=[];for(const o of n){const p={},A=[];for(const y of o){const{fieldValuesUuid:b,fieldIdentifier:P,file:_}=y,R=await this.getFilePayload(_);R.sha1 in p||(p[R.sha1]=R);const z=T({file:URL.createObjectURL(_),file_type:_.type,file_name:_.name,file_sha1:R.sha1,created_by:c,field_values:b,submitted_at:i,field_identifier:P});r.push(z);const De={uuid:z.uuid,file_name:_.name,file_sha1:R.sha1,file_extension:R.extension,field_identifier:P,field_values:b};A.push(De)}l.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(It(r));const m=l.map(o=>this.enqueueRequest({description:"Add asset type field values attachments",method:h.POST,url:"/asset-type-field-values-attachments/bulk/",payload:o,blockers:o.attachments.map(p=>p.field_values),blocks:o.attachments.map(p=>p.uuid)}));return Promise.all(m).then(o=>{for(const A of o)this.processPresignedUrls(A.presigned_urls);const p=o.flatMap(A=>A.attachments);this.dispatch(id(p))}).catch(o=>{throw this.dispatch(Ot(r.map(p=>p.uuid))),o}),[r,m.map(o=>o.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:a}=this.client,i=a.getState(),c=nd(e)(i);this.dispatch(Ot(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:h.DELETE,url:"/asset-type-field-values-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(It(c)),n}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset type field values attachments",method:h.GET,url:"/asset-type-field-values-attachments/",queryParams:{limit:E,paginate:!0,field_values__asset__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset type field values attachments",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(ad(c)),c}}class qb extends v{add(e){var r;const{store:a}=this.client,i=a.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add asset type field values",method:h.POST,url:"/asset-type-field-values/",payload:w(c),blockers:[e.asset,e.fields_revision],blocks:[c.uuid]});return this.dispatch(oa(c)),n.then(l=>(this.dispatch(st(l)),l)).catch(()=>{this.dispatch(la(c.uuid))}),[c,n]}bulkAdd(e,a){var m;const i=new Date().toISOString(),c=[],n=$e(e.payloads,a??e.payloads.length),r=[];for(const u of n){const o=[];for(const p of u){const A=T({...p,values:p.values,created_by:(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,submitted_at:i});c.push(A),o.push({uuid:A.uuid,asset:p.asset,fields_revision:p.fields_revision,published_at:p.published_at,values:A.values})}r.push({submitted_at:i,values:e.values,field_values:o})}this.dispatch(ld(c));const l=[];for(const u of r){const o=u.field_values.map(b=>b.asset),p=u.field_values.map(b=>b.fields_revision),A=u.field_values.map(b=>b.uuid),y=this.enqueueRequest({description:"Bulk add asset type field values",method:h.POST,url:"/asset-type-field-values/bulk/",payload:u,blockers:[...o,...p],blocks:A});l.push(y)}return Promise.all(l).then(u=>{this.dispatch(hd(u.flat()))}).catch(()=>{this.dispatch(md(c.map(u=>u.uuid)))}),[c,l]}update(e){const{store:a}=this.client,i=a.getState(),c=ma(e.uuid)(i);if(!c)throw new Error(`Expected AssetTypeFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(st(n));const r=this.enqueueRequest({description:"Delete asset type field values",method:h.PATCH,url:`/asset-type-field-values/${e.uuid}/`,payload:e,blockers:[n.uuid,n.fields_revision,n.asset],blocks:[n.uuid]});return r.then(l=>{this.dispatch(st(l))}).catch(()=>{this.dispatch(st(c))}),[n,r]}async delete(e){const{store:a}=this.client,i=a.getState(),c=ma(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=rd(e)(i);this.dispatch(la(e)),this.dispatch(Ot(n.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete asset type field values",method:h.DELETE,url:`/asset-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(oa(c)),this.dispatch(It(n)),r}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get asset type field values",method:h.GET,url:"/asset-type-field-values/",queryParams:{limit:E,paginate:!0,asset__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get asset type field values",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(od(c)),c}}class Vb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Aa(n));const r=this.enqueueRequest({description:"Create asset type",method:h.POST,url:"/asset-types/",payload:w(n),blockers:[],blocks:[n.uuid]});return r.then(m=>{this.dispatch(at(m))}).catch(()=>{this.dispatch(ya(n.uuid))}),[n,r]}update(e){const{store:a}=this.client,i=Sa(e.uuid)(a.getState());if(!i)throw new Error(`Expected asset type with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(at(c));const n=this.enqueueRequest({description:"Update asset type",method:h.PATCH,url:`/asset-types/${e.uuid}/`,payload:{icon:e.icon,color:e.color,name:e.name,description:e.description},blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(at(r))}).catch(()=>{this.dispatch(at(i))}),[c,n]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Sa(e)(i);if(!c)throw new Error(`Expected asset type with uuid ${e} to exist`);const n=Ns(e)(i),r=kr(e)(i);return this.dispatch(ya(e)),this.dispatch($s(n.map(l=>l.uuid))),this.dispatch(ia(r.map(({uuid:l})=>l))),this.enqueueRequest({description:"Delete asset type",method:h.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(l=>{throw this.dispatch(Aa(c)),this.dispatch(bt(n)),this.dispatch(aa(r)),l})}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get asset types",method:h.GET,url:"/asset-types/",queryParams:{organization:e},blockers:[],blocks:[]},a);return this.dispatch(fd(i)),i}}class zb extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(ba(n));const r=this.enqueueRequest({description:"Create Category",method:h.POST,url:"/categories/",payload:w(n),blockers:[e.project],blocks:[n.uuid]});return[n,r]}update(e){const a=this.client.store.getState(),i=Fa(e.uuid)(a);if(!i)throw new Error(`Expected an existing category with uuid ${e.uuid}`);const c={...i,...e};this.dispatch(Od(c));const n=this.enqueueRequest({description:"Edit Category",method:h.PATCH,url:`/categories/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return[c,n]}remove(e){const{store:a}=this.client,i=Fa(e)(a.getState());if(!i)throw new Error(`No category with uuid ${e} found in the store`);this.dispatch(_d(e));const c=this.enqueueRequest({description:"Delete Category",method:h.DELETE,url:`/categories/${i.uuid}/`,blockers:[i.uuid],blocks:[]});return c.catch(()=>{this.dispatch(ba(i))}),c}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get categories",method:h.GET,url:"/categories/",queryParams:{project__organization_owner:e},blocks:[],blockers:[]},a);return this.dispatch(Id(i)),i}}class Ub extends ke{constructor(){super(...arguments);S(this,"name","Document Attachment");S(this,"url","/document-attachments");S(this,"addAttachments",Ed);S(this,"updateAttachments",qd);S(this,"removeAttachments",zd);S(this,"removeAttachment",Vd);S(this,"setAttachment",jd);S(this,"selectAttachment",Cd)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,document:a.modelUuid})}buildAttachmentPayload(a){return{...a,document:a.modelUuid}}async bulkAdd(a){var p;const{store:i}=this.client,c=(p=i.getState().userReducer.currentUser)==null?void 0:p.id,n=new Date().toISOString(),r=[],l=[],m={},u={};for(const A of a){const{documentUuid:y,file:b}=A,P=await this.getFilePayload(b);P.sha1 in m||(m[P.sha1]=P,u[P.sha1]=[]);const _=this.buildOfflineAttachment({file:b,file_sha1:P.sha1,submitted_at:n,created_by:c,description:"",modelUuid:y});r.push(_),l.push({uuid:_.uuid,file_name:_.file_name,file_sha1:_.file_sha1,file_extension:P.extension,description:_.description,document:y}),u[P.sha1].push(_.uuid)}this.dispatch(this.addAttachments(r));const o=this.enqueueRequest({description:"Attach files to document",method:h.POST,url:"/document-attachments/bulk/",payload:{submitted_at:n,attachments:l,files:Object.values(m)},blocks:r.map(A=>A.uuid),blockers:r.map(A=>A.file_sha1)});return o.then(({attachments:A,presigned_urls:y})=>{this.dispatch(this.updateAttachments(A));const b=this.processPresignedUrls(y);for(const[P,_]of Object.entries(b))_.then(()=>{const R=u[P];for(const z of R)this.makeReadable(z)})}).catch(()=>{this.dispatch(this.removeAttachments(r.map(A=>A.uuid)))}),[r,o.then(({attachments:A})=>A)]}async delete(a){return this._delete(a)}makeReadable(a){this.enqueueRequest({description:"Add attachment to AI assistant",method:h.PATCH,url:`/document-attachments/${a}/`,payload:{readable_to_assistant:!0},blockers:["index-document-attachment",a],blocks:["index-document-attachment"]})}async refreshStore(a,i){const c=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:"/document-attachments/",queryParams:{document__project__organization_owner:a},blocks:[],blockers:[]},i),n=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:"/document-attachments/",queryParams:{document__organization:a},blocks:[],blockers:[]},i),r=[...c,...n];return this.dispatch(Md(r)),r}}class Db extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch($d([n]));const r=this.enqueueRequest({description:"Create Document",method:h.POST,url:"/documents/",payload:w(n),queryParams:{parent_document:n.parent_document??void 0},blockers:n.parent_document?[n.parent_document]:[],blocks:[n.uuid]});return r.catch(()=>{this.dispatch(Oa([n.uuid]))}),[n,r]}update(e){const{store:a}=this.client,i=a.getState().documentsReducer.documents[e.uuid];if(!i)throw new Error(`attempting to update a document with uuid ${e.uuid} that does not exist in store.documents`);const c={...i,...e};this.dispatch(We([c]));const n=this.enqueueRequest({description:"Update Document",method:h.PATCH,url:`/documents/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.catch(()=>{We([i])}),[c,n]}delete(e){const{store:a}=this.client,i=Rt(a.getState()),c=Ld(e)(a.getState());if(!c)throw new Error(`attempting to delete a document with uuid ${e} that does not exist in store.documents`);const n=c.parent_document?i[c.parent_document]:void 0;this.dispatch(Oa([e]));const r=this.enqueueRequest({description:"Delete Document",method:h.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return r.then(l=>{this.dispatch(We(l))}).catch(()=>{this.dispatch(We([c])),n&&this.dispatch(We([n]))}),r}async refreshStore(e,a){const i=this.enqueueRequest({description:"Get project documents",method:h.GET,url:"/documents/",queryParams:{project__organization_owner:e},blockers:[],blocks:[]},a),c=this.enqueueRequest({description:"Get organization documents",method:h.GET,url:"/documents/",queryParams:{organization:e},blockers:[],blocks:[]},a),n=[...await i,...await c];return this.dispatch(Gd(n)),n}}class Cb extends v{async add(e,a){return this.enqueueRequest({description:"Add email domain to organization",method:h.POST,url:"/organization-email-domains/",payload:{email:a,organization:e},blockers:[e,"create-org"],blocks:[]})}async remove(e){return this.dispatch(Kd(e.uuid)),this.enqueueRequest({description:"Remove email domain from organization",method:h.DELETE,url:`/organization-email-domains/${e.uuid}/`,blockers:[e.domain],blocks:[]}).catch(a=>{throw this.dispatch(Yd(e)),a})}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Fetch email domains for organization",method:h.GET,url:"/organization-email-domains/",queryParams:{organization:e},blockers:[e],blocks:[]},a);return this.dispatch(Wd(i)),i}}class kb extends v{async getVerificationCode(e){return this.enqueueRequest({description:"Get verification code",method:h.GET,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}validateVerificationCode(e,a=void 0){return this.enqueueRequest({description:"Validate verification code",method:h.POST,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,payload:a,blockers:[],blocks:[]})}}const Gt={},uc=new Set;let $t=0,oc=0,lc=0;const Bb=20;class Gb extends v{constructor(){super(...arguments);S(this,"host");S(this,"_dbPromise",Am.openDB("fileCache",1,{upgrade(a){a.createObjectStore("files")}}))}async renewUploadUrl(a){const i=await this.fetchCache(a);if(!i)throw new Error(`File with sha1 ${a} not found in cache`);const c=await Kt(i,a),n=await this.enqueueRequest({description:"Get S3 URL",method:h.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await He(i),file_type:i.type,extension:i.name.split(".").pop(),size:i.size.toString()},blockers:[],blocks:[`s3-${c}`]});return"url"in n&&this.dispatch(eu({sha1:a,...n})),n}async addCache(a,i){if(uc.has(i))return;if(!a.type){const r=a.name.split("."),l=r[r.length-1];a=new File([a],a.name,{type:l})}if(!a.name||!a.size||!a.type)throw new Error("Cannot add files to cache that do not have a name, size and type.");const c=await this._dbPromise;!!await c.get("files",i)?(console.error("File already cached (this is unexpected at this point):",a.name,i),$t++):(await c.put("files",a,i),oc++),uc.add(i),lc++,lc%Bb===0&&console.debug(`File cache summary: ${$t} hits and ${oc} misses, ${$t/($t+oc)*100}% hit rate over ${lc} calls to addCache.`)}async removeCache(a){await(await this._dbPromise).delete("files",a),uc.delete(a)}async fetchCache(a){return(await this._dbPromise).get("files",a)}async getOrRenewUploadUrl(a){const i=this.client.store.getState();return tu(a)(i)??await this.renewUploadUrl(a)}async uploadFileToS3(a){const i=await this.fetchCache(a);if(!i)throw new Error(`File with sha1 ${a} not found in cache`);const c=await Kt(i,a),n={file_name:i.name,file_sha1:a,file:c},r=await this.getOrRenewUploadUrl(a);if("warning"in r){if(r.warning==="already_uploaded")return[n,Promise.resolve(void 0).then()];throw new Error(r.warning)}const l=r.url,m=this.enqueueRequest({url:l,description:"Upload file",method:h.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:a,blockers:[`s3-${c}`],blocks:[a],s3url:r});return[n,m]}async fetchFileFromUrl(a,i,c){const n=a.split("?")[0]??a,r=await this.fetchCache(i);if(r){if(!r.name)throw new Error("Cached file unexpectedly has no name.");return r}if(a.startsWith("blob:")){const o=await Pc(a),p=new File([o],c??i,{type:o.type});return await this.addCache(p,i),p}let l=Gt[n],m=!0;l?m=!1:(l=new Promise(o=>{this.enqueueRequest({description:"Download file",method:h.GET,url:a,isExternalUrl:!0,isResponseBlob:!0,isAuthNeeded:!1,blockers:[i],blocks:[i]}).then(p=>{const A=new File([p],c??i,{type:p.type});o(A)})}),Gt[n]=l);let u;try{u=await l}catch(o){throw m&&o instanceof D&&delete Gt[n],o}if(m){const o=await He(u);if(o!==i){const y=`The hash of the file returned from the server (${o}) does not match the
9
9
  expected hash (${i}). This can happen if you're using a local development server and the
10
10
  isExternalUrl flag in the request details is set to true, because instead of requesting the local
11
11
  REST API, you will be requesting localhost:80 (where this app runs), resulting in a transformed blob
12
12
  (with an uuid attached) being returned. Alternatively, you may be running with
13
13
  import.meta.env.PROD, which will result in some file requests being treated as
14
- external URLs and therefore not prepended with VITE_API_URL.`;throw new Error(y)}const p=u.type.split("/")[1];if(!p)throw new Error("File has no extension");const A=c??o+"."+p;if(u=bc(u,A),!u.name)throw new Error("Failed to set file's name");await this.addCache(u,o),Gt[n]=new Promise(y=>{y(u)})}return u}}class $b extends q{async bulkAdd(e){var m;const a=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{revisionUuid:o,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,form_revision:o,submitted_at:a,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,form_revision:o};r.push(P)}this.dispatch(cu(n));const l=this.enqueueRequest({description:"Attach files to form revision",method:h.POST,url:"/form-revision-attachments/bulk/",payload:{submitted_at:a,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.form_revision),blocks:n.map(u=>u.uuid)});return l.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(nu(u.attachments))}).catch(()=>{this.dispatch(ru(n.map(u=>u.uuid)))}),[n,l.then(({attachments:u})=>u)]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Fetch organization form revision attachments",method:h.GET,url:"/form-revision-attachments/",queryParams:{form_revision__form__organization:e},blockers:[e],blocks:[]},a);return this.dispatch(iu(i)),i}}class Lb extends q{add(e){var l;const{store:a}=this.client,c=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,n=T({...e,created_by:c,submitted_at:new Date().toISOString()});this.dispatch(Ea(n));const r=this.enqueueRequest({description:"Create form revision",method:h.POST,url:"/form-revisions/",payload:w(n),blockers:[e.form],blocks:[n.uuid]});return r.then(m=>{this.dispatch(mu(m))}).catch(()=>{this.dispatch(ja(n.uuid))}),[n,r]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get organization form revisions",method:h.GET,url:"/form-revisions/",queryParams:{form__organization:e},blockers:[e],blocks:[]},a);return this.dispatch(lu(i)),i}}class Nb extends q{add(e,a){var u;const{store:i}=this.client,c=new Date().toISOString(),n=(u=i.getState().userReducer.currentUser)==null?void 0:u.id,r=T({...e,submitted_at:c,created_by:n}),l=T({...a,form:r.uuid,submitted_at:c,created_by:n});this.dispatch(Va(r)),this.dispatch(Ea(l));const m=this.enqueueRequest({description:"Create form",method:h.POST,url:"/forms/",payload:{...w(r),initial_revision:{uuid:l.uuid,submitted_at:l.submitted_at,title:l.title,description:l.description,fields:l.fields}},blockers:[],blocks:[r.uuid,l.uuid]});return m.catch(o=>{throw this.dispatch(za(r.uuid)),this.dispatch(ja(l.uuid)),o}),[r,l,m]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Tu(e)(i);if(!c)throw new Error("Expected form to exist");const n=qu(e)(i);n.length>0&&this.dispatch(qt(n.map(({uuid:l})=>l)));const r=yu(e)(i);r.length>0&&this.dispatch(pu(r.map(({uuid:l})=>l))),this.dispatch(za(e));try{return await this.enqueueRequest({description:"Delete form",method:h.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(l){throw this.dispatch(Va(c)),r.length>0&&this.dispatch(hu(r)),n.length>0&&this.dispatch(jt(n)),l}}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Fetch organization forms",method:h.GET,url:"/forms/",queryParams:{organization:e},blockers:[e],blocks:[]},a);return this.dispatch(gu(i)),i}}class Hb extends q{async bulkAdd(e){var m;const a=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{submissionUuid:o,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,form_submission:o,submitted_at:a,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,file_sha1:y.sha1,file_extension:y.extension,field_identifier:p,form_submission:o};r.push(P)}this.dispatch(wt(n));const l=this.enqueueRequest({description:"Attach files to form submission",method:h.POST,url:"/form-submission-attachments/bulk/",payload:{submitted_at:a,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.form_submission),blocks:n.map(u=>u.uuid)});return l.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(_u(u.attachments))}).catch(u=>{throw this.dispatch(Mt(n.map(o=>o.uuid))),u}),[n,l.then(({attachments:u})=>u)]}async bulkDelete(e){const{store:a}=this.client,i=a.getState(),c=Ru(e)(i);this.dispatch(Mt(e));try{await this.enqueueRequest({description:"Delete form submission attachments",method:h.DELETE,url:"/form-submission-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(wt(c)),n}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get form submission attachments",method:h.GET,url:"/form-submission-attachments/",queryParams:{limit:E,paginate:!0,form_submission__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get form submission attachments",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Ou(c)),c}}class Wb extends q{add(e){var r;const{store:a}=this.client,i=a.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add form submission",method:h.POST,url:"/form-submissions/",payload:w(c),blockers:[e.form_revision,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[c.uuid]});return this.dispatch(ka(c)),n.then(l=>(this.dispatch(Et(l)),l)).catch(()=>{this.dispatch(Ba(c.uuid))}),[c,n]}update(e){const{store:a}=this.client,i=a.getState(),c=La(e.uuid)(i);if(!c)throw new Error(`Expected submission with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(ju(n));const r=this.enqueueRequest({description:"Delete user form submissions",method:h.PATCH,url:`/form-submissions/${n.uuid}/`,payload:e,blockers:[n.uuid],blocks:[n.uuid]});return r.then(l=>{this.dispatch(Et(l))}).catch(()=>{this.dispatch(Et(c))}),[n,r]}async delete(e){const{store:a}=this.client,i=a.getState(),c=La(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=vu(e)(i);this.dispatch(Ba(e)),this.dispatch(Mt(n.map(r=>r.uuid)));try{return await this.enqueueRequest({description:"Delete user form submissions",method:h.DELETE,url:`/form-submissions/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ka(c)),this.dispatch(wt(n)),r}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Fetch form submissions",method:h.GET,url:"/form-submissions/",queryParams:{limit:E,paginate:!0,project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Fetch form submissions",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Eu(c)),c}}class Yb extends q{async add(e){var p;const{store:a}=this.client,{file:i,...c}=e,n=new Date().toISOString(),r=(p=a.getState().userReducer.currentUser)==null?void 0:p.id,l=c.project,m=await this.getFilePayload(i),u=T({...c,file_name:i.name,file_sha1:m.sha1,file:URL.createObjectURL(i),submitted_at:n,created_by:r});this.dispatch(Bu(u));const o=this.enqueueRequest({description:"Add geo image",method:h.POST,url:"/geo-images/",payload:{uuid:u.uuid,submitted_at:n,title:u.title,description:u.description,geo_marker:u.geo_marker,canvas_marker:u.canvas_marker,sha1:u.file_sha1,project:u.project,file_name:u.file_name,direction:u.direction,original_date:u.original_date,file:m},blocks:[l],blockers:[l]});return o.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(it(A.geo_image))}).catch(()=>{this.dispatch(Ha(u.uuid))}),[u,o.then(A=>A.geo_image)]}async bulkAdd(e,a){var p;const{store:i}=this.client,c=new Date().toISOString(),n=(p=i.getState().userReducer.currentUser)==null?void 0:p.id,r=[],l=[],m=[],u={};for(const A of e){const{file:y,...b}=A,P=await this.getFilePayload(y);P.sha1 in u||(u[P.sha1]=P);const _=T({...b,file_name:y.name,file_sha1:P.sha1,file:URL.createObjectURL(y),submitted_at:c,created_by:n,project:a});r.push(_),l.push(_.uuid),m.push({uuid:_.uuid,sha1:_.file_sha1,file_name:_.file_name,title:_.title,description:_.description,geo_marker:_.geo_marker,canvas_marker:_.canvas_marker,direction:_.direction,original_date:_.original_date})}this.dispatch(Gu(r));const o=this.enqueueRequest({description:"Bulk add geo images",method:h.POST,url:"/geo-images/bulk/",payload:{submitted_at:c,project:a,geo_images:m,files:Object.values(u)},blocks:[a],blockers:l});return o.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(ku(A.geo_images))}).catch(()=>{this.dispatch(Lu(l))}),[r,o.then(A=>A.geo_images)]}update(e){const{store:a}=this.client,i=a.getState(),c=Wa(e.uuid)(i);if(!c)throw new Error(`Map image with uuid ${e.uuid} does not exist in the store`);const n={...c,...e};this.dispatch($u(n));const r=this.enqueueRequest({description:"Update geo image",method:h.PATCH,url:`/geo-images/${e.uuid}/`,payload:e,blocks:[e.uuid],blockers:[e.uuid]});return r.then(l=>{this.dispatch(it(l))}).catch(()=>{this.dispatch(it(c))}),[n,r]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Wa(e)(i);if(!c)throw new Error(`Map image with uuid ${e} does not exist in the store`);this.dispatch(Ha(e));const n=this.enqueueRequest({description:"Delete geo image",method:h.DELETE,url:`/geo-images/${e}/`,blocks:[e],blockers:[e]});return n.catch(()=>{this.dispatch(it(c))}),n}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get geo images",method:h.GET,url:"/geo-images/",queryParams:{project:e},blocks:[e],blockers:[]},a);return this.dispatch(Cu(i)),i}}class Kb extends v{add(e){var l;const{store:a}=this.client,i=new Date().toISOString(),c=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,n=T({...e,submitted_at:i,created_by:c});this.dispatch(Ka(n));const r=this.enqueueRequest({description:"Add issue association",method:h.POST,url:"/issue-associations/",payload:w(n),blockers:[e.associated_issue,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Zu(m))}).catch(()=>{this.dispatch(Ja(n.uuid))}),[n,r]}async delete(e){const{store:a}=this.client,i=Ju(e)(a.getState());if(!i)throw new Error(`Issue association with uuid ${e} not found in store.`);this.dispatch(Ja(e));const c=this.enqueueRequest({description:"Delete issue association",method:h.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return c.catch(()=>{this.dispatch(Ka(i))}),c}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Fetch issue associations",method:h.GET,url:"/issue-associations/",queryParams:{limit:E,paginate:!0,associated_issue__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Fetch issue associations",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Ku(c)),c}}class Zb extends ke{constructor(){super(...arguments);S(this,"name","Issue Attachment");S(this,"url","/issue-attachments");S(this,"initializeAttachments",xa);S(this,"addAttachments",ei);S(this,"updateAttachments",ao);S(this,"removeAttachments",ti);S(this,"removeAttachment",io);S(this,"setAttachment",so);S(this,"selectAttachment",uo)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,issue:a.modelUuid})}buildAttachmentPayload(a){return{...a,issue:a.modelUuid}}async bulkAdd(a){return this._bulkAdd(a.map(i=>({modelUuid:i.issueUuid,file:i.file})))}async delete(a){return this._delete(a)}async refreshStore(a,i){const n=(await this.performPagination({immediate:!0,description:"Get issue attachments",method:h.GET,url:`${this.url}/`,queryParams:{limit:E,paginate:!0,issue__project:a},blocks:[],blockers:[]},r=>({immediate:!0,description:"Get issue attachments",method:h.GET,url:r,blockers:[],blocks:[]}),i)).flat();return this.dispatch(xa(n)),n}}class Jb extends ke{constructor(){super(...arguments);S(this,"name","Issue Comment Attachment");S(this,"url","/issue-comment-attachments");S(this,"initializeAttachments",ai);S(this,"addAttachments",ho);S(this,"updateAttachments",po);S(this,"removeAttachments",yo);S(this,"removeAttachment",Ao);S(this,"setAttachment",mo);S(this,"selectAttachment",go)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,issue_comment:a.modelUuid})}buildAttachmentPayload(a){return{...a,issue_comment:a.modelUuid}}async bulkAdd(a){return this._bulkAdd(a.map(i=>({modelUuid:i.issueCommentUuid,file:i.file})))}async delete(a){return this._delete(a)}async refreshStore(a,i){const n=(await this.performPagination({immediate:!0,description:"Get issue comment attachments",method:h.GET,url:`${this.url}/`,queryParams:{limit:E,paginate:!0,issue_comment__issue__project:a},blocks:[],blockers:[]},r=>({immediate:!0,description:"Get issue comment attachments",method:h.GET,url:r,blockers:[],blocks:[]}),i)).flat();return this.dispatch(ai(n)),n}}class Xb extends v{add(e){var n;const{store:a}=this.client,i=T({...e,author:(n=a.getState().userReducer.currentUser)==null?void 0:n.id,submitted_at:new Date().toISOString()});this.dispatch(ci(i));const c=this.enqueueRequest({description:"Add issue comment",method:h.POST,url:"/issue-comments/",payload:w(i),blockers:[e.issue],blocks:[i.uuid]});return c.catch(()=>{this.dispatch(ri(i.uuid))}),[i,c]}update(e){const{store:a}=this.client,i=di(e.uuid)(a.getState());if(!i)throw new Error(`Comment with uuid ${e.uuid} not found in store`);const c={...i,...e};this.dispatch(ni(c));const n=this.enqueueRequest({description:"Edit issue comment",method:h.PATCH,url:`/issue-comments/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.catch(()=>{this.dispatch(ni(i))}),[c,n]}remove(e){const{store:a}=this.client,i=di(e)(a.getState());if(!i)throw new Error(`Comment with uuid ${e} not found in store`);this.dispatch(ri(e));const c=this.enqueueRequest({description:"Delete comment",method:h.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return c.catch(()=>{this.dispatch(ci(i))}),c}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get comments",method:h.GET,url:"/issue-comments/",queryParams:{issue__project:e},blockers:[],blocks:[]},a);return this.dispatch(Fo(i)),i}}class Qb extends v{add(e){var m;const{store:a}=this.client,i=a.getState(),c=new Date().toISOString(),n=(m=i.userReducer.currentUser)==null?void 0:m.id,r=T({...e,submitted_at:c,created_by:n});this.dispatch(oi(r));const l=this.enqueueRequest({description:"Create issue",method:h.POST,url:"/issues/",payload:w(r),blockers:[r.project,r.issue_type,...r.category?[r.category]:[]],blocks:[r.uuid]});return l.then(u=>{this.dispatch(Vt(u))}).catch(u=>{throw this.dispatch(li(r.uuid)),u}),[r,l]}update(e){var m;const a=this.client.store.getState(),i=mi(e.uuid)(a);if(!i)throw new Error(`Attempting to update an issue with uuid ${e.uuid} that doesn't exist in the store`);const c={...i,...e};this.dispatch(Vt(c));const n={};for(const u of[j.TITLE,j.DESCRIPTION,j.STATUS,j.CATEGORY,j.PRIORITY,j.ASSIGNED_TO,j.DUE_DATE])if(u in e&&e[u]!==i[u])switch(u){case j.PRIORITY:case j.STATUS:{const o=e[u];n[u]=o!==void 0?Number(o):null;break}case j.DUE_DATE:case j.DESCRIPTION:case j.TITLE:n[u]=e[u]??null;break;case j.CATEGORY:{let o=null;const p=e[u];if(p&&(o=a.categoryReducer.instances[p]??null,!o))throw new Error(`Trying to update issue category to ${p} which does not exist in store`);n[u]=o?{name:o.name,color:o.color,uuid:o.uuid}:null;break}case j.ASSIGNED_TO:{let o=null;const p=e[u];if(p&&(o=a.userReducer.instances[p]??null,!o))throw new Error(`Trying to update issue assigned_to to ${p} which does not exist in store`);n[u]=o?{full_name:o.username,id:o.id}:null;break}}const r=T({created_by:(m=a.userReducer.currentUser)==null?void 0:m.id,submitted_at:new Date().toISOString(),issue:i.uuid,changes:n});this.dispatch(Pl(r));const l=this.enqueueRequest({description:"Edit issue",method:h.PATCH,url:`/issues/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return l.catch(()=>{this.dispatch(Vt(i)),this.dispatch(Tl(r.uuid))}),[c,l]}async remove(e){const{store:a}=this.client,i=a.getState(),c=mi(e)(i);if(!c)throw new Error(`No issue with uuid ${e} found in the store`);const n=ro(e)(i),r=_l(e)(i),l=Vu(e)(i),m={};for(const o of Xu(e)(i))m[o.uuid]=o;for(const o of Qu(e)(i))m[o.uuid]=o;const u=Object.values(m);this.dispatch(li(e)),n.length>0&&this.dispatch(ti(n.map(({uuid:o})=>o))),r.length>0&&this.dispatch(Il(r.map(({uuid:o})=>o))),l.length>0&&this.dispatch(qt(l.map(({uuid:o})=>o))),u.length>0&&this.dispatch(Xa(u.map(({uuid:o})=>o)));try{return await this.enqueueRequest({description:"Delete issue",method:h.DELETE,url:`/issues/${e}/`,blockers:[e],blocks:[]})}catch(o){throw this.dispatch(oi(c)),this.dispatch(ei(n)),this.dispatch(Fl(r)),this.dispatch(jt(l)),this.dispatch(Za(u)),o}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get issues",method:h.GET,url:"/issues/",queryParams:{limit:E,paginate:!0,project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get issues",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(_o(c)),c}}class xb extends ke{constructor(){super(...arguments);S(this,"name","Issue Type Attachment");S(this,"url","/issue-type-attachments");S(this,"initializeAttachments",Ai);S(this,"addAttachments",Eo);S(this,"updateAttachments",qo);S(this,"removeAttachments",zo);S(this,"removeAttachment",Vo);S(this,"setAttachment",jo);S(this,"selectAttachment",Co)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,issue_type:a.modelUuid})}buildAttachmentPayload(a){return{...a,issue_type:a.modelUuid}}async bulkAdd(a){return this._bulkAdd(a.map(i=>({modelUuid:i.issueTypeUuid,file:i.file})))}async delete(a){return this._delete(a)}async refreshStore(a,i){const c=await this.enqueueRequest({description:"Get issue type attachments",method:h.GET,url:`${this.url}/`,queryParams:{issue_type__organization:a},blocks:[],blockers:[]},i);return this.dispatch(Ai(c)),c}}class eP extends q{async bulkAdd(e){var m;const a=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldsRevisionUuid:o,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:o,submitted_at:a,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,file_extension:y.extension,field_identifier:p,file_sha1:y.sha1,fields_revision:o};r.push(P)}this.dispatch($o(n));const l=this.enqueueRequest({description:"Add issue type fields attachments",method:h.POST,url:"/issue-type-fields-attachments/bulk/",payload:{submitted_at:a,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.fields_revision),blocks:n.map(u=>u.uuid)});return l.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(Lo(u.attachments))}).catch(()=>{this.dispatch(No(n.map(u=>u.uuid)))}),[n,l.then(({attachments:u})=>u)]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"get issue type fields attachments",method:h.GET,url:"/issue-type-fields-attachments/",queryParams:{fields_revision__issue_type__organization:e},blockers:[e],blocks:[]},a);return this.dispatch(Go(i)),i}}class tP extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(el(n));const r=this.enqueueRequest({description:"Add Issue Type Fields",method:h.POST,url:"/issue-type-fields/",payload:w(n),blockers:[n.issue_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(tl(m))}).catch(m=>{throw this.dispatch(sl(n.uuid)),m}),[n,r]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get Issue Type Fields",method:h.GET,url:"/issue-type-fields/",queryParams:{issue_type__organization:e},blockers:[],blocks:[]},a);return this.dispatch(xo(i)),i}}class sP extends q{async bulkAdd(e){var m;const a=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldValuesUuid:o,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,field_values:o,submitted_at:a,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,file_sha1:y.sha1,file_extension:y.extension,field_identifier:p,field_values:o};r.push(P)}this.dispatch(Ut(n));const l=this.enqueueRequest({description:"Add issue type field values attachments",method:h.POST,url:"/issue-type-field-values-attachments/bulk/",payload:{submitted_at:a,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.field_values),blocks:n.map(u=>u.uuid)});return l.then(({presigned_urls:u,attachments:o})=>{this.processPresignedUrls(u),this.dispatch(rl(o))}).catch(u=>{throw this.dispatch(Dt(n.map(o=>o.uuid))),u}),[n,l.then(({attachments:u})=>u)]}async bulkDelete(e){const{store:a}=this.client,i=a.getState(),c=ul(e)(i);this.dispatch(Dt(e));try{await this.enqueueRequest({description:"Delete issue type field values attachments",method:h.DELETE,url:"/issue-type-field-values-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(Ut(c)),n}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get issue type field values attachments",method:h.GET,url:"/issue-type-field-values-attachments/",queryParams:{limit:E,paginate:!0,field_values__issue__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get issue type field values attachments",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(nl(c)),c}}class aP extends v{add(e){var r;const{store:a}=this.client,i=a.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add issue type field values",method:h.POST,url:"/issue-type-field-values/",payload:w(c),blockers:[e.issue,e.fields_revision],blocks:[c.uuid]});return this.dispatch(Si(c)),n.then(l=>(this.dispatch(nt(l)),l)).catch(()=>{this.dispatch(gi(c.uuid))}),[c,n]}update(e){const{store:a}=this.client,i=a.getState(),c=Pi(e.uuid)(i);if(!c)throw new Error(`Expected IssueTypeFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(nt(n));const r=this.enqueueRequest({description:"Update issue type field values",method:h.PATCH,url:`/issue-type-field-values/${e.uuid}/`,payload:e,blockers:[n.uuid,n.fields_revision,n.issue],blocks:[n.uuid]});return r.then(l=>{this.dispatch(nt(l))}).catch(()=>{this.dispatch(nt(c))}),[n,r]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Pi(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=ol(e)(i);this.dispatch(gi(e)),this.dispatch(Dt(n.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete issue type field values",method:h.DELETE,url:`/issue-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Si(c)),this.dispatch(Ut(n)),r}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get issue type field values",method:h.GET,url:"/issue-type-field-values/",queryParams:{limit:E,paginate:!0,issue__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get issue type field values",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Zo(c)),c}}class iP extends v{add(e){var r;const{store:a}=this.client,i=a.getState(),c=T({...e,submitted_at:new Date().toISOString(),created_by:(r=i.userReducer.currentUser)==null?void 0:r.id});this.dispatch(pl(c));const n=this.enqueueRequest({method:h.POST,url:"/issue-types/",payload:w(c),blockers:[],blocks:[c.uuid]});return n.then(l=>{this.dispatch(rt(l))}).catch(()=>{this.dispatch(_i(c.uuid))}),[c,n]}update(e){const{store:a}=this.client,i=a.getState(),c=Ri(e.uuid)(i);if(!c)throw new Error(`IssueType with uuid ${e.uuid} does not exist in the store.`);const n={...c,...e};this.dispatch(Al(n));const r=this.enqueueRequest({method:h.PATCH,url:`/issue-types/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return r.then(l=>{this.dispatch(rt(l))}).catch(()=>{this.dispatch(rt(c))}),[n,r]}delete(e){const{store:a}=this.client,i=a.getState(),c=Ri(e)(i);if(!c)throw new Error(`IssueType with uuid ${e} does not exist in the store.`);const n=vi(e)(i);this.dispatch(_i(e)),this.dispatch(vo(n.map(l=>l.uuid)));const r=this.enqueueRequest({method:h.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return r.catch(()=>{this.dispatch(rt(c)),this.dispatch(Ro(n))}),r}async refreshStore(e,a){const i=await this.enqueueRequest({method:h.GET,url:"/issue-types/",queryParams:{organization:e},blockers:[],blocks:[]},a);return this.dispatch(ml(i)),i}}class cP extends v{async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get issue updates",method:h.GET,url:"/issue-updates/",queryParams:{limit:E,paginate:!0,issue__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get issue updates",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(bl(c)),c}}const nP=1800;function rP(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 dP extends ub{constructor(){super(...arguments);S(this,"_getRenewedTokens",async a=>{const i=this.enqueueRequest({description:"Get renewed tokens",method:h.POST,url:this.refreshTokensUrl,payload:{refresh:a},isAuthNeeded:!1,blockers:[],blocks:[],checkAuth:!1,immediate:!0});let c;try{c=await i}catch(n){console.error("Could not renew tokens; clearing auth",n),this.clearAuth();return}if(!c.access)throw new Error("Missing access token");return{accessToken:c.access,refreshToken:c.refresh??this.getRefreshToken()}})}clearAuth(){console.debug(this.constructor.name,"clearing auth;"),this.dispatch(Pd(!1)),this.clearTokens(),this.dispatch(F()),this.dispatch(F())}async renewTokens(){const a=this.getRefreshToken();if(!a)throw new Error("No refresh token found");console.debug(this.constructor.name,"renewing tokens");try{const i=await this._getRenewedTokens(a);if(!i)return;console.log("Got renewed tokens"),this.setTokens(i)}catch(i){throw console.error("Could not renew tokens; clearing auth",i),this.clearAuth(),i}}tokenIsExpiringSoon(){const a=this.getAccessToken();if(!a)return!1;const i=Date.now()/1e3;let c;try{c=ym(a).exp??i}catch{c=i}return c-i<nP}getAuthHeader(){return`Bearer ${this.getAccessToken()}`}async prepareAuth(){if(this.tokenIsExpiringSoon()){console.debug(this.constructor.name,"preparing auth");try{await this.renewTokens()}catch(a){return a instanceof D&&this.clearAuth(),a instanceof Error?Promise.reject(a):Promise.reject(new Error((a??Ye).toString()))}}}async handleUnauthorized(a,i){const c=this.client.store.getState();if(a.url.endsWith("/token/refresh/"))throw c.authReducer.isLoggedIn&&console.warn("No signed-in user to sign out."),this.clearAuth(),new D({message:"You have been signed out due to inactivity.",response:i,discard:!0});if(c.authReducer.isLoggedIn)await this.renewTokens();else throw console.debug("Forbidden; user is not logged in."),new D({message:"Incorrect username or password.",response:i,discard:!0})}async initAuth(a){const i=Ne.v4();return console.debug(this.constructor.name,"Initiating auth"),this.enqueueRequest({uuid:i,description:"Get token pair",method:h.POST,url:this.initTokensUrl,payload:a,isAuthNeeded:!1,checkAuth:!1,immediate:!0,blockers:[],blocks:[]}).then(c=>{this.setTokens(rP(c))})}}class uP extends v{update(e){const{store:a}=this.client,i=Vi(e.uuid)(a.getState()),c={...i,...e};this.dispatch(kt(c));const n=this.enqueueRequest({description:"Edit organization access",method:h.PATCH,url:`/organization-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.then(r=>{this.dispatch(kt(r))}).catch(r=>{throw this.dispatch(kt(i)),r}),[c,n]}async remove(e){const{store:a}=this.client,i=a.getState(),c=Vi(e)(i),n=Vl(c.user)(i);this.dispatch(Cl(c.uuid)),this.dispatch(El(c.user));try{await this.enqueueRequest({description:"Remove organization access",method:h.DELETE,url:`/organization-accesses/${c.uuid}/`,blockers:[c.uuid],blocks:[]})}catch(r){throw this.dispatch(Dl(c)),this.dispatch(Ml(n)),r}}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get organization accesses",method:h.GET,url:"/organization-accesses/",queryParams:{organization:e},blockers:[],blocks:[]},a);return this.dispatch(Ul(i)),i}}class oP extends v{async add(e){const a=await this.enqueueRequest({description:"Create organization",method:h.POST,url:"/organizations/",payload:e,blockers:[],blocks:[]});return this.dispatch(Ll(a)),a}async update(e){const a=await this.enqueueRequest({description:"Edit organization",method:h.PATCH,url:`/organizations/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return this.dispatch(Nl(a)),a}async invite(e,a){return this.enqueueRequest({description:"Invite user to organization",method:h.POST,url:`/organizations/${e}/invite/${a}/`,blockers:[],blocks:[]})}async refreshStore(e){const a=await this.enqueueRequest({description:"Fetch organizations",method:h.GET,url:"/organizations/",blockers:[],blocks:[]},e);return this.dispatch($l(a)),a}}class lP extends v{add(e){const a=T(e);this.dispatch(Ci(a));const i=this.enqueueRequest({description:"Add project access",method:h.POST,url:"/project-accesses/",payload:w(a),blockers:[a.organization_access,a.project],blocks:[a.uuid]});return i.then(c=>{this.dispatch(dt(c))}).catch(c=>{throw this.dispatch(ki(a.uuid)),c}),[a,i]}update(e){const{store:a}=this.client,i=Gi(e.uuid)(a.getState()),c={...i,...e};this.dispatch(dt(c));const n=this.enqueueRequest({description:"Edit project access",method:h.PATCH,url:`/project-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[]});return n.then(r=>{this.dispatch(dt(r))}).catch(r=>{throw this.dispatch(dt(i)),r}),[c,n]}async remove(e){const{store:a}=this.client,i=Gi(e)(a.getState());this.dispatch(ki(e));try{await this.enqueueRequest({description:"Delete project access",method:h.DELETE,url:`/project-accesses/${e}/`,blockers:[e],blocks:[]})}catch(c){throw this.dispatch(Ci(i)),c}}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get project accesses",method:h.GET,url:"/project-accesses/",queryParams:{project__organization_owner:e},blockers:[],blocks:[]},a);return this.dispatch(eh(i)),i}}class hP extends ke{constructor(){super(...arguments);S(this,"name","Project Attachment");S(this,"url","/project-attachments");S(this,"addAttachments",rh);S(this,"updateAttachments",oh);S(this,"removeAttachments",Li);S(this,"removeAttachment",lh);S(this,"setAttachment",dh);S(this,"selectAttachment",ph)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,project:a.modelUuid})}buildAttachmentPayload(a){return{...a,project:a.modelUuid}}async bulkAdd(a){return this._bulkAdd(a.map(i=>({modelUuid:i.projectUuid,file:i.file})))}async delete(a){return this._delete(a)}async refreshStore(a,i){const c=await this.enqueueRequest({description:"Get project attachments",method:h.GET,url:`${this.url}/`,queryParams:{project__organization_owner:a},blockers:[],blocks:[]},i);return this.dispatch(nh(c)),c}}class mP extends v{async saveExisting(e){if(!e.uuid)throw new Error("You can only use this method to save existing project files. The one provided has no uuid.");const a={...e};delete a.file;const i=this.enqueueRequest({method:h.PATCH,url:`/project-files/${e.uuid}/`,payload:a,blockers:[e.uuid],blocks:[e.uuid]});return i.then(c=>{this.dispatch(Hi(c))}),i}saveActive(){const{store:e}=this.client,a=e.getState(),i=a.projectFileReducer.activeProjectFileId;if(!i)throw new Error("No active project file");const c=a.projectFileReducer.instances[i];if(!c)throw new Error("No active project file");if(!c.bounds&&!c.canvas_bounds)throw new Error("Project file must either have bounds or canvas_bounds set");let n;if(typeof c.file=="string"&&!c.file.startsWith("blob:")){const m={...c};delete m.file,n={method:h.PATCH,url:`/project-files/${i}/`,payload:m,blockers:[i],blocks:[i]}}else n=new Promise((m,u)=>{this.client.files.uploadFileToS3(c.file_sha1).then(([o])=>{m({method:h.POST,url:`/project-files${c.project}/`,payload:{...c,...o},blockers:[i],blocks:[i]})}).catch(u)});const l=Promise.resolve(n).then(m=>this.enqueueRequest(m));return l.then(m=>{this.dispatch(Hi(m))}),this.dispatch(Ih),this.dispatch(Th(null)),this.dispatch(Fh(!1)),[c,l]}delete(e){return this.dispatch(bh(e)),this.enqueueRequest({method:h.DELETE,url:`/project-files/${e}`,blockers:[e],blocks:[]})}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get project files",method:h.GET,url:"/project-files/",queryParams:{limit:E,paginate:!0,project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get project files",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Sh(c)),c}}class pP extends v{async add(e){const a=await this.enqueueRequest({description:"Create project",method:h.POST,url:"/projects/",payload:w(e),blockers:[],blocks:[]});return this.dispatch(Yi(a)),a}async update(e){if(!e.bounds&&!e.canvas_bounds)throw new Error("Project must either have bounds or canvas_bounds set");return this.dispatch(Mh(e)),await this.enqueueRequest({description:"Update project",method:h.PATCH,url:`/projects/${e.uuid}/`,payload:{name:e.name,bounds:e.bounds},blockers:[e.uuid],blocks:[e.uuid]})}async delete(e){const{store:a}=this.client,i=a.getState(),c=qh(e)(i);if(!c)throw new Error("Expected project to exist");const n=_h(i).filter(m=>m.project===e);this.dispatch(Ph(n.map(({uuid:m})=>m)));const r=Ah(c.uuid)(i);this.dispatch(Li(r.map(({uuid:m})=>m)));const l=ih(e)(i);this.dispatch(sh(l.map(({uuid:m})=>m))),this.dispatch(Ki(c.uuid));try{await this.enqueueRequest({description:"Delete project",method:h.DELETE,url:`/projects/${e}/`,blockers:[e],blocks:[]}),this.dispatch(Ki(c.uuid))}catch(m){throw this.dispatch(Yi(c)),this.dispatch(th(Object.values(l))),this.dispatch(gh(n)),this.dispatch(uh(r)),m}}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Fetch projects",method:h.GET,url:"/projects/",queryParams:{organization_owner:e},blockers:[],blocks:[]},a);return this.dispatch(wh(i)),i}}class AP extends v{add(e){const a=T(e);this.dispatch(Dh(a));const i=this.enqueueRequest({description:"Create team membership",method:h.POST,url:"/team-memberships/",payload:w(a),blockers:[e.team],blocks:[a.uuid]});return i.then(c=>{this.dispatch(Qi(c))}).catch(()=>{this.dispatch(xi(a.uuid))}),[a,i]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Bh(e)(i);if(!c)throw new Error(`Expected team membership with uuid ${e} to exist`);this.dispatch(xi(e));try{return await this.enqueueRequest({description:"Delete team membership",method:h.DELETE,url:`/team-memberships/${e}/`,blockers:[e],blocks:[e]})}catch(n){throw this.dispatch(Qi(c)),n}}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Fetch team memberships",method:h.GET,url:"/team-memberships/",queryParams:{team__organization:e},blockers:[],blocks:[]},a);return this.dispatch(Uh(i)),i}}class yP extends v{add(e){const a=T({...e,submitted_at:new Date().toISOString()});this.dispatch(Lh(a));const i=this.enqueueRequest({description:"Create team",method:h.POST,url:"/teams/",payload:w(a),blockers:[],blocks:[a.uuid]});return i.then(c=>{this.dispatch(ut(c))}).catch(()=>{this.dispatch(sc(a.uuid))}),[a,i]}update(e){const{store:a}=this.client,i=ic(e.uuid)(a.getState());if(!i)throw new Error(`Expected team with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(Nh(c));const n=this.enqueueRequest({description:"Update team",method:h.PATCH,url:`/teams/${e.uuid}/`,payload:w(e),blockers:[e.uuid],blocks:[e.uuid]});return n.then(r=>{this.dispatch(ut(r))}).catch(()=>{this.dispatch(ut(i))}),[c,n]}async delete(e){const{store:a}=this.client,i=a.getState(),c=ic(e)(i);if(!c)throw new Error(`Expected team with uuid ${e} to exist`);this.dispatch(sc(e));try{return await this.enqueueRequest({description:"Delete team",method:h.DELETE,url:`/teams/${e}/`,blockers:[e],blocks:[e]})}catch(n){throw this.dispatch(ut(c)),n}}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Fetch teams",method:h.GET,url:"/teams/",queryParams:{organization:e},blockers:[],blocks:[]},a);return this.dispatch($h(i)),i}}class fP extends v{async refreshStore(e,a){const i=await this.enqueueRequest({description:"Fetch organization users",method:h.GET,url:`/organizations/${e}/users/`,blockers:[],blocks:[]},a);return this.dispatch(wl(i)),i}}class SP{constructor(e){S(this,"store");this.store=e}async enqueueRequest(e,a,i,c){return this._enqueueRequest(e,a,i,c).then(n=>{if(n instanceof D)throw n;return n})}_enqueueRequest(e,a,i,c){const n=new Sc,r={...e,BASE_URL:a,serviceName:i};if(e.immediate){const l={...r,uuid:e.uuid??Ne.v4()},m={payload:l,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:l,BASE_URL:a,serviceName:i}}}};rc(m,this,c).then(u=>{n.resolve(u.body)}).catch(u=>{dc(u,m),u instanceof Error?n.reject(u):n.reject(new Error((u??Ye).toString()))})}else{const l=this.store.dispatch(Zl(r)),m=o=>{if(o)n.resolve(o.body);else{const p=new D({message:"Could not get a response from the server.",response:o,discard:!0});n.reject(p)}},u=o=>{o instanceof D?o.options.discard=!0:(console.error("Received an unexpected error while processing a request:",o,`
14
+ external URLs and therefore not prepended with VITE_API_URL.`;throw new Error(y)}const p=u.type.split("/")[1];if(!p)throw new Error("File has no extension");const A=c??o+"."+p;if(u=bc(u,A),!u.name)throw new Error("Failed to set file's name");await this.addCache(u,o),Gt[n]=new Promise(y=>{y(u)})}return u}}class $b extends q{async bulkAdd(e){var m;const a=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{revisionUuid:o,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,form_revision:o,submitted_at:a,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,form_revision:o};r.push(P)}this.dispatch(cu(n));const l=this.enqueueRequest({description:"Attach files to form revision",method:h.POST,url:"/form-revision-attachments/bulk/",payload:{submitted_at:a,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.form_revision),blocks:n.map(u=>u.uuid)});return l.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(nu(u.attachments))}).catch(()=>{this.dispatch(ru(n.map(u=>u.uuid)))}),[n,l.then(({attachments:u})=>u)]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Fetch organization form revision attachments",method:h.GET,url:"/form-revision-attachments/",queryParams:{form_revision__form__organization:e},blockers:[e],blocks:[]},a);return this.dispatch(iu(i)),i}}class Lb extends q{add(e){var l;const{store:a}=this.client,c=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,n=T({...e,created_by:c,submitted_at:new Date().toISOString()});this.dispatch(Ea(n));const r=this.enqueueRequest({description:"Create form revision",method:h.POST,url:"/form-revisions/",payload:w(n),blockers:[e.form],blocks:[n.uuid]});return r.then(m=>{this.dispatch(mu(m))}).catch(()=>{this.dispatch(ja(n.uuid))}),[n,r]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get organization form revisions",method:h.GET,url:"/form-revisions/",queryParams:{form__organization:e},blockers:[e],blocks:[]},a);return this.dispatch(lu(i)),i}}class Nb extends q{add(e,a){var u;const{store:i}=this.client,c=new Date().toISOString(),n=(u=i.getState().userReducer.currentUser)==null?void 0:u.id,r=T({...e,submitted_at:c,created_by:n}),l=T({...a,form:r.uuid,submitted_at:c,created_by:n});this.dispatch(Va(r)),this.dispatch(Ea(l));const m=this.enqueueRequest({description:"Create form",method:h.POST,url:"/forms/",payload:{...w(r),initial_revision:{uuid:l.uuid,submitted_at:l.submitted_at,title:l.title,description:l.description,fields:l.fields}},blockers:[],blocks:[r.uuid,l.uuid]});return m.catch(o=>{throw this.dispatch(za(r.uuid)),this.dispatch(ja(l.uuid)),o}),[r,l,m]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Tu(e)(i);if(!c)throw new Error("Expected form to exist");const n=qu(e)(i);n.length>0&&this.dispatch(qt(n.map(({uuid:l})=>l)));const r=yu(e)(i);r.length>0&&this.dispatch(pu(r.map(({uuid:l})=>l))),this.dispatch(za(e));try{return await this.enqueueRequest({description:"Delete form",method:h.DELETE,url:`/forms/${e}/`,blockers:[e],blocks:[]})}catch(l){throw this.dispatch(Va(c)),r.length>0&&this.dispatch(hu(r)),n.length>0&&this.dispatch(jt(n)),l}}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Fetch organization forms",method:h.GET,url:"/forms/",queryParams:{organization:e},blockers:[e],blocks:[]},a);return this.dispatch(gu(i)),i}}class Hb extends q{async bulkAdd(e){var m;const a=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{submissionUuid:o,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,form_submission:o,submitted_at:a,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,file_sha1:y.sha1,file_extension:y.extension,field_identifier:p,form_submission:o};r.push(P)}this.dispatch(wt(n));const l=this.enqueueRequest({description:"Attach files to form submission",method:h.POST,url:"/form-submission-attachments/bulk/",payload:{submitted_at:a,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.form_submission),blocks:n.map(u=>u.uuid)});return l.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(_u(u.attachments))}).catch(u=>{throw this.dispatch(Mt(n.map(o=>o.uuid))),u}),[n,l.then(({attachments:u})=>u)]}async bulkDelete(e){const{store:a}=this.client,i=a.getState(),c=Ru(e)(i);this.dispatch(Mt(e));try{await this.enqueueRequest({description:"Delete form submission attachments",method:h.DELETE,url:"/form-submission-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(wt(c)),n}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get form submission attachments",method:h.GET,url:"/form-submission-attachments/",queryParams:{limit:E,paginate:!0,form_submission__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get form submission attachments",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Ou(c)),c}}class Wb extends q{add(e){var r;const{store:a}=this.client,i=a.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add form submission",method:h.POST,url:"/form-submissions/",payload:w(c),blockers:[e.form_revision,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[c.uuid]});return this.dispatch(ka(c)),n.then(l=>(this.dispatch(Et(l)),l)).catch(()=>{this.dispatch(Ba(c.uuid))}),[c,n]}update(e){const{store:a}=this.client,i=a.getState(),c=La(e.uuid)(i);if(!c)throw new Error(`Expected submission with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(ju(n));const r=this.enqueueRequest({description:"Delete user form submissions",method:h.PATCH,url:`/form-submissions/${n.uuid}/`,payload:e,blockers:[n.uuid],blocks:[n.uuid]});return r.then(l=>{this.dispatch(Et(l))}).catch(()=>{this.dispatch(Et(c))}),[n,r]}async delete(e){const{store:a}=this.client,i=a.getState(),c=La(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=vu(e)(i);this.dispatch(Ba(e)),this.dispatch(Mt(n.map(r=>r.uuid)));try{return await this.enqueueRequest({description:"Delete user form submissions",method:h.DELETE,url:`/form-submissions/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(ka(c)),this.dispatch(wt(n)),r}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Fetch form submissions",method:h.GET,url:"/form-submissions/",queryParams:{limit:E,paginate:!0,project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Fetch form submissions",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Eu(c)),c}}class Yb extends q{async add(e){var p;const{store:a}=this.client,{file:i,...c}=e,n=new Date().toISOString(),r=(p=a.getState().userReducer.currentUser)==null?void 0:p.id,l=c.project,m=await this.getFilePayload(i),u=T({...c,file_name:i.name,file_sha1:m.sha1,file:URL.createObjectURL(i),submitted_at:n,created_by:r});this.dispatch(Bu(u));const o=this.enqueueRequest({description:"Add geo image",method:h.POST,url:"/geo-images/",payload:{uuid:u.uuid,submitted_at:n,title:u.title,description:u.description,geo_marker:u.geo_marker,canvas_marker:u.canvas_marker,sha1:u.file_sha1,project:u.project,file_name:u.file_name,direction:u.direction,original_date:u.original_date,file:m},blocks:[l],blockers:[l]});return o.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(it(A.geo_image))}).catch(()=>{this.dispatch(Ha(u.uuid))}),[u,o.then(A=>A.geo_image)]}async bulkAdd(e,a){var p;const{store:i}=this.client,c=new Date().toISOString(),n=(p=i.getState().userReducer.currentUser)==null?void 0:p.id,r=[],l=[],m=[],u={};for(const A of e){const{file:y,...b}=A,P=await this.getFilePayload(y);P.sha1 in u||(u[P.sha1]=P);const _=T({...b,file_name:y.name,file_sha1:P.sha1,file:URL.createObjectURL(y),submitted_at:c,created_by:n,project:a});r.push(_),l.push(_.uuid),m.push({uuid:_.uuid,sha1:_.file_sha1,file_name:_.file_name,title:_.title,description:_.description,geo_marker:_.geo_marker,canvas_marker:_.canvas_marker,direction:_.direction,original_date:_.original_date})}this.dispatch(Gu(r));const o=this.enqueueRequest({description:"Bulk add geo images",method:h.POST,url:"/geo-images/bulk/",payload:{submitted_at:c,project:a,geo_images:m,files:Object.values(u)},blocks:[a],blockers:l});return o.then(A=>{this.processPresignedUrls(A.presigned_urls),this.dispatch(ku(A.geo_images))}).catch(()=>{this.dispatch(Lu(l))}),[r,o.then(A=>A.geo_images)]}update(e){const{store:a}=this.client,i=a.getState(),c=Wa(e.uuid)(i);if(!c)throw new Error(`Map image with uuid ${e.uuid} does not exist in the store`);const n={...c,...e};this.dispatch($u(n));const r=this.enqueueRequest({description:"Update geo image",method:h.PATCH,url:`/geo-images/${e.uuid}/`,payload:e,blocks:[e.uuid],blockers:[e.uuid]});return r.then(l=>{this.dispatch(it(l))}).catch(()=>{this.dispatch(it(c))}),[n,r]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Wa(e)(i);if(!c)throw new Error(`Map image with uuid ${e} does not exist in the store`);this.dispatch(Ha(e));const n=this.enqueueRequest({description:"Delete geo image",method:h.DELETE,url:`/geo-images/${e}/`,blocks:[e],blockers:[e]});return n.catch(()=>{this.dispatch(it(c))}),n}async refreshStore(e,a){const i=await this.enqueueRequest({immediate:!0,description:"Get geo images",method:h.GET,url:"/geo-images/",queryParams:{project:e},blocks:[e],blockers:[]},a);return this.dispatch(Cu(i)),i}}class Kb extends v{add(e){var l;const{store:a}=this.client,i=new Date().toISOString(),c=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,n=T({...e,submitted_at:i,created_by:c});this.dispatch(Ka(n));const r=this.enqueueRequest({description:"Add issue association",method:h.POST,url:"/issue-associations/",payload:w(n),blockers:[e.associated_issue,...e.issue?[e.issue]:[],...e.asset?[e.asset]:[]],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Zu(m))}).catch(()=>{this.dispatch(Ja(n.uuid))}),[n,r]}async delete(e){const{store:a}=this.client,i=Ju(e)(a.getState());if(!i)throw new Error(`Issue association with uuid ${e} not found in store.`);this.dispatch(Ja(e));const c=this.enqueueRequest({description:"Delete issue association",method:h.DELETE,url:`/issue-associations/${e}/`,blockers:[e],blocks:[]});return c.catch(()=>{this.dispatch(Ka(i))}),c}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Fetch issue associations",method:h.GET,url:"/issue-associations/",queryParams:{limit:E,paginate:!0,associated_issue__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Fetch issue associations",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Ku(c)),c}}class Zb extends ke{constructor(){super(...arguments);S(this,"name","Issue Attachment");S(this,"url","/issue-attachments");S(this,"initializeAttachments",xa);S(this,"addAttachments",ei);S(this,"updateAttachments",ao);S(this,"removeAttachments",ti);S(this,"removeAttachment",io);S(this,"setAttachment",so);S(this,"selectAttachment",uo)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,issue:a.modelUuid})}buildAttachmentPayload(a){return{...a,issue:a.modelUuid}}async bulkAdd(a){return this._bulkAdd(a.map(i=>({modelUuid:i.issueUuid,file:i.file})))}async delete(a){return this._delete(a)}async refreshStore(a,i){const n=(await this.performPagination({immediate:!0,description:"Get issue attachments",method:h.GET,url:`${this.url}/`,queryParams:{limit:E,paginate:!0,issue__project:a},blocks:[],blockers:[]},r=>({immediate:!0,description:"Get issue attachments",method:h.GET,url:r,blockers:[],blocks:[]}),i)).flat();return this.dispatch(xa(n)),n}}class Jb extends ke{constructor(){super(...arguments);S(this,"name","Issue Comment Attachment");S(this,"url","/issue-comment-attachments");S(this,"initializeAttachments",ai);S(this,"addAttachments",ho);S(this,"updateAttachments",po);S(this,"removeAttachments",yo);S(this,"removeAttachment",Ao);S(this,"setAttachment",mo);S(this,"selectAttachment",go)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,issue_comment:a.modelUuid})}buildAttachmentPayload(a){return{...a,issue_comment:a.modelUuid}}async bulkAdd(a){return this._bulkAdd(a.map(i=>({modelUuid:i.issueCommentUuid,file:i.file})))}async delete(a){return this._delete(a)}async refreshStore(a,i){const n=(await this.performPagination({immediate:!0,description:"Get issue comment attachments",method:h.GET,url:`${this.url}/`,queryParams:{limit:E,paginate:!0,issue_comment__issue__project:a},blocks:[],blockers:[]},r=>({immediate:!0,description:"Get issue comment attachments",method:h.GET,url:r,blockers:[],blocks:[]}),i)).flat();return this.dispatch(ai(n)),n}}class Xb extends v{add(e){var n;const{store:a}=this.client,i=T({...e,author:(n=a.getState().userReducer.currentUser)==null?void 0:n.id,submitted_at:new Date().toISOString()});this.dispatch(ci(i));const c=this.enqueueRequest({description:"Add issue comment",method:h.POST,url:"/issue-comments/",payload:w(i),blockers:[e.issue],blocks:[i.uuid]});return c.catch(()=>{this.dispatch(ri(i.uuid))}),[i,c]}update(e){const{store:a}=this.client,i=di(e.uuid)(a.getState());if(!i)throw new Error(`Comment with uuid ${e.uuid} not found in store`);const c={...i,...e};this.dispatch(ni(c));const n=this.enqueueRequest({description:"Edit issue comment",method:h.PATCH,url:`/issue-comments/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.catch(()=>{this.dispatch(ni(i))}),[c,n]}remove(e){const{store:a}=this.client,i=di(e)(a.getState());if(!i)throw new Error(`Comment with uuid ${e} not found in store`);this.dispatch(ri(e));const c=this.enqueueRequest({description:"Delete comment",method:h.DELETE,url:`/issue-comments/${e}/`,blockers:[e],blocks:[]});return c.catch(()=>{this.dispatch(ci(i))}),c}async refreshStore(e,a){const i=await this.enqueueRequest({immediate:!0,description:"Get comments",method:h.GET,url:"/issue-comments/",queryParams:{issue__project:e},blockers:[],blocks:[]},a);return this.dispatch(Fo(i)),i}}class Qb extends v{add(e){var m;const{store:a}=this.client,i=a.getState(),c=new Date().toISOString(),n=(m=i.userReducer.currentUser)==null?void 0:m.id,r=T({...e,submitted_at:c,created_by:n});this.dispatch(oi(r));const l=this.enqueueRequest({description:"Create issue",method:h.POST,url:"/issues/",payload:w(r),blockers:[r.project,r.issue_type,...r.category?[r.category]:[]],blocks:[r.uuid]});return l.then(u=>{this.dispatch(Vt(u))}).catch(u=>{throw this.dispatch(li(r.uuid)),u}),[r,l]}update(e){var m;const a=this.client.store.getState(),i=mi(e.uuid)(a);if(!i)throw new Error(`Attempting to update an issue with uuid ${e.uuid} that doesn't exist in the store`);const c={...i,...e};this.dispatch(Vt(c));const n={};for(const u of[j.TITLE,j.DESCRIPTION,j.STATUS,j.CATEGORY,j.PRIORITY,j.ASSIGNED_TO,j.DUE_DATE])if(u in e&&e[u]!==i[u])switch(u){case j.PRIORITY:case j.STATUS:{const o=e[u];n[u]=o!==void 0?Number(o):null;break}case j.DUE_DATE:case j.DESCRIPTION:case j.TITLE:n[u]=e[u]??null;break;case j.CATEGORY:{let o=null;const p=e[u];if(p&&(o=a.categoryReducer.instances[p]??null,!o))throw new Error(`Trying to update issue category to ${p} which does not exist in store`);n[u]=o?{name:o.name,color:o.color,uuid:o.uuid}:null;break}case j.ASSIGNED_TO:{let o=null;const p=e[u];if(p&&(o=a.userReducer.instances[p]??null,!o))throw new Error(`Trying to update issue assigned_to to ${p} which does not exist in store`);n[u]=o?{full_name:o.username,id:o.id}:null;break}}const r=T({created_by:(m=a.userReducer.currentUser)==null?void 0:m.id,submitted_at:new Date().toISOString(),issue:i.uuid,changes:n});this.dispatch(Pl(r));const l=this.enqueueRequest({description:"Edit issue",method:h.PATCH,url:`/issues/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return l.catch(()=>{this.dispatch(Vt(i)),this.dispatch(Tl(r.uuid))}),[c,l]}async remove(e){const{store:a}=this.client,i=a.getState(),c=mi(e)(i);if(!c)throw new Error(`No issue with uuid ${e} found in the store`);const n=ro(e)(i),r=_l(e)(i),l=Vu(e)(i),m={};for(const o of Xu(e)(i))m[o.uuid]=o;for(const o of Qu(e)(i))m[o.uuid]=o;const u=Object.values(m);this.dispatch(li(e)),n.length>0&&this.dispatch(ti(n.map(({uuid:o})=>o))),r.length>0&&this.dispatch(Il(r.map(({uuid:o})=>o))),l.length>0&&this.dispatch(qt(l.map(({uuid:o})=>o))),u.length>0&&this.dispatch(Xa(u.map(({uuid:o})=>o)));try{return await this.enqueueRequest({description:"Delete issue",method:h.DELETE,url:`/issues/${e}/`,blockers:[e],blocks:[]})}catch(o){throw this.dispatch(oi(c)),this.dispatch(ei(n)),this.dispatch(Fl(r)),this.dispatch(jt(l)),this.dispatch(Za(u)),o}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get issues",method:h.GET,url:"/issues/",queryParams:{limit:E,paginate:!0,project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get issues",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(_o(c)),c}}class xb extends ke{constructor(){super(...arguments);S(this,"name","Issue Type Attachment");S(this,"url","/issue-type-attachments");S(this,"initializeAttachments",Ai);S(this,"addAttachments",Eo);S(this,"updateAttachments",qo);S(this,"removeAttachments",zo);S(this,"removeAttachment",Vo);S(this,"setAttachment",jo);S(this,"selectAttachment",Co)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,issue_type:a.modelUuid})}buildAttachmentPayload(a){return{...a,issue_type:a.modelUuid}}async bulkAdd(a){return this._bulkAdd(a.map(i=>({modelUuid:i.issueTypeUuid,file:i.file})))}async delete(a){return this._delete(a)}async refreshStore(a,i){const c=await this.enqueueRequest({description:"Get issue type attachments",method:h.GET,url:`${this.url}/`,queryParams:{issue_type__organization:a},blocks:[],blockers:[]},i);return this.dispatch(Ai(c)),c}}class eP extends q{async bulkAdd(e){var m;const a=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldsRevisionUuid:o,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:o,submitted_at:a,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,file_extension:y.extension,field_identifier:p,file_sha1:y.sha1,fields_revision:o};r.push(P)}this.dispatch($o(n));const l=this.enqueueRequest({description:"Add issue type fields attachments",method:h.POST,url:"/issue-type-fields-attachments/bulk/",payload:{submitted_at:a,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.fields_revision),blocks:n.map(u=>u.uuid)});return l.then(u=>{this.processPresignedUrls(u.presigned_urls),this.dispatch(Lo(u.attachments))}).catch(()=>{this.dispatch(No(n.map(u=>u.uuid)))}),[n,l.then(({attachments:u})=>u)]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"get issue type fields attachments",method:h.GET,url:"/issue-type-fields-attachments/",queryParams:{fields_revision__issue_type__organization:e},blockers:[e],blocks:[]},a);return this.dispatch(Go(i)),i}}class tP extends v{add(e){var l;const{store:a}=this.client,i=(l=a.getState().userReducer.currentUser)==null?void 0:l.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(el(n));const r=this.enqueueRequest({description:"Add Issue Type Fields",method:h.POST,url:"/issue-type-fields/",payload:w(n),blockers:[n.issue_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(tl(m))}).catch(m=>{throw this.dispatch(sl(n.uuid)),m}),[n,r]}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get Issue Type Fields",method:h.GET,url:"/issue-type-fields/",queryParams:{issue_type__organization:e},blockers:[],blocks:[]},a);return this.dispatch(xo(i)),i}}class sP extends q{async bulkAdd(e){var m;const a=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const u of e){const{fieldValuesUuid:o,fieldIdentifier:p,file:A}=u,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const b=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,field_values:o,submitted_at:a,field_identifier:p});n.push(b);const P={uuid:b.uuid,file_name:A.name,file_sha1:y.sha1,file_extension:y.extension,field_identifier:p,field_values:o};r.push(P)}this.dispatch(Ut(n));const l=this.enqueueRequest({description:"Add issue type field values attachments",method:h.POST,url:"/issue-type-field-values-attachments/bulk/",payload:{submitted_at:a,attachments:r,files:Object.values(c)},blockers:n.map(u=>u.field_values),blocks:n.map(u=>u.uuid)});return l.then(({presigned_urls:u,attachments:o})=>{this.processPresignedUrls(u),this.dispatch(rl(o))}).catch(u=>{throw this.dispatch(Dt(n.map(o=>o.uuid))),u}),[n,l.then(({attachments:u})=>u)]}async bulkDelete(e){const{store:a}=this.client,i=a.getState(),c=ul(e)(i);this.dispatch(Dt(e));try{await this.enqueueRequest({description:"Delete issue type field values attachments",method:h.DELETE,url:"/issue-type-field-values-attachments/bulk/",payload:{uuids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(Ut(c)),n}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get issue type field values attachments",method:h.GET,url:"/issue-type-field-values-attachments/",queryParams:{limit:E,paginate:!0,field_values__issue__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get issue type field values attachments",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(nl(c)),c}}class aP extends v{add(e){var r;const{store:a}=this.client,i=a.getState(),c=T({...e,created_by:(r=i.userReducer.currentUser)==null?void 0:r.id,submitted_at:new Date().toISOString()}),n=this.enqueueRequest({description:"Add issue type field values",method:h.POST,url:"/issue-type-field-values/",payload:w(c),blockers:[e.issue,e.fields_revision],blocks:[c.uuid]});return this.dispatch(Si(c)),n.then(l=>(this.dispatch(nt(l)),l)).catch(()=>{this.dispatch(gi(c.uuid))}),[c,n]}update(e){const{store:a}=this.client,i=a.getState(),c=Pi(e.uuid)(i);if(!c)throw new Error(`Expected IssueTypeFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(nt(n));const r=this.enqueueRequest({description:"Update issue type field values",method:h.PATCH,url:`/issue-type-field-values/${e.uuid}/`,payload:e,blockers:[n.uuid,n.fields_revision,n.issue],blocks:[n.uuid]});return r.then(l=>{this.dispatch(nt(l))}).catch(()=>{this.dispatch(nt(c))}),[n,r]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Pi(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=ol(e)(i);this.dispatch(gi(e)),this.dispatch(Dt(n.map(r=>r.uuid)));try{await this.enqueueRequest({description:"Delete issue type field values",method:h.DELETE,url:`/issue-type-field-values/${e}/`,blockers:[e],blocks:[]})}catch(r){throw this.dispatch(Si(c)),this.dispatch(Ut(n)),r}}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get issue type field values",method:h.GET,url:"/issue-type-field-values/",queryParams:{limit:E,paginate:!0,issue__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get issue type field values",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Zo(c)),c}}class iP extends v{add(e){var r;const{store:a}=this.client,i=a.getState(),c=T({...e,submitted_at:new Date().toISOString(),created_by:(r=i.userReducer.currentUser)==null?void 0:r.id});this.dispatch(pl(c));const n=this.enqueueRequest({method:h.POST,url:"/issue-types/",payload:w(c),blockers:[],blocks:[c.uuid]});return n.then(l=>{this.dispatch(rt(l))}).catch(()=>{this.dispatch(_i(c.uuid))}),[c,n]}update(e){const{store:a}=this.client,i=a.getState(),c=Ri(e.uuid)(i);if(!c)throw new Error(`IssueType with uuid ${e.uuid} does not exist in the store.`);const n={...c,...e};this.dispatch(Al(n));const r=this.enqueueRequest({method:h.PATCH,url:`/issue-types/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return r.then(l=>{this.dispatch(rt(l))}).catch(()=>{this.dispatch(rt(c))}),[n,r]}delete(e){const{store:a}=this.client,i=a.getState(),c=Ri(e)(i);if(!c)throw new Error(`IssueType with uuid ${e} does not exist in the store.`);const n=vi(e)(i);this.dispatch(_i(e)),this.dispatch(vo(n.map(l=>l.uuid)));const r=this.enqueueRequest({method:h.DELETE,url:`/issue-types/${e}/`,blockers:[e],blocks:[]});return r.catch(()=>{this.dispatch(rt(c)),this.dispatch(Ro(n))}),r}async refreshStore(e,a){const i=await this.enqueueRequest({method:h.GET,url:"/issue-types/",queryParams:{organization:e},blockers:[],blocks:[]},a);return this.dispatch(ml(i)),i}}class cP extends v{async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get issue updates",method:h.GET,url:"/issue-updates/",queryParams:{limit:E,paginate:!0,issue__project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get issue updates",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(bl(c)),c}}const nP=1800;function rP(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 dP extends ub{constructor(){super(...arguments);S(this,"_getRenewedTokens",async a=>{const i=this.enqueueRequest({description:"Get renewed tokens",method:h.POST,url:this.refreshTokensUrl,payload:{refresh:a},isAuthNeeded:!1,blockers:[],blocks:[],checkAuth:!1,immediate:!0});let c;try{c=await i}catch(n){console.error("Could not renew tokens; clearing auth",n),this.clearAuth();return}if(!c.access)throw new Error("Missing access token");return{accessToken:c.access,refreshToken:c.refresh??this.getRefreshToken()}})}clearAuth(){console.debug(this.constructor.name,"clearing auth;"),this.dispatch(Pd(!1)),this.clearTokens(),this.dispatch(F()),this.dispatch(F())}async renewTokens(){const a=this.getRefreshToken();if(!a)throw new Error("No refresh token found");console.debug(this.constructor.name,"renewing tokens");try{const i=await this._getRenewedTokens(a);if(!i)return;console.log("Got renewed tokens"),this.setTokens(i)}catch(i){throw console.error("Could not renew tokens; clearing auth",i),this.clearAuth(),i}}tokenIsExpiringSoon(){const a=this.getAccessToken();if(!a)return!1;const i=Date.now()/1e3;let c;try{c=ym(a).exp??i}catch{c=i}return c-i<nP}getAuthHeader(){return`Bearer ${this.getAccessToken()}`}async prepareAuth(){if(this.tokenIsExpiringSoon()){console.debug(this.constructor.name,"preparing auth");try{await this.renewTokens()}catch(a){return a instanceof D&&this.clearAuth(),a instanceof Error?Promise.reject(a):Promise.reject(new Error((a??Ye).toString()))}}}async handleUnauthorized(a,i){const c=this.client.store.getState();if(a.url.endsWith("/token/refresh/"))throw c.authReducer.isLoggedIn&&console.warn("No signed-in user to sign out."),this.clearAuth(),new D({message:"You have been signed out due to inactivity.",response:i,discard:!0});if(c.authReducer.isLoggedIn)await this.renewTokens();else throw console.debug("Forbidden; user is not logged in."),new D({message:"Incorrect username or password.",response:i,discard:!0})}async initAuth(a){const i=Ne.v4();return console.debug(this.constructor.name,"Initiating auth"),this.enqueueRequest({uuid:i,description:"Get token pair",method:h.POST,url:this.initTokensUrl,payload:a,isAuthNeeded:!1,checkAuth:!1,immediate:!0,blockers:[],blocks:[]}).then(c=>{this.setTokens(rP(c))})}}class uP extends v{update(e){const{store:a}=this.client,i=Vi(e.uuid)(a.getState()),c={...i,...e};this.dispatch(kt(c));const n=this.enqueueRequest({description:"Edit organization access",method:h.PATCH,url:`/organization-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return n.then(r=>{this.dispatch(kt(r))}).catch(r=>{throw this.dispatch(kt(i)),r}),[c,n]}async remove(e){const{store:a}=this.client,i=a.getState(),c=Vi(e)(i),n=Vl(c.user)(i);this.dispatch(Cl(c.uuid)),this.dispatch(El(c.user));try{await this.enqueueRequest({description:"Remove organization access",method:h.DELETE,url:`/organization-accesses/${c.uuid}/`,blockers:[c.uuid],blocks:[]})}catch(r){throw this.dispatch(Dl(c)),this.dispatch(Ml(n)),r}}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get organization accesses",method:h.GET,url:"/organization-accesses/",queryParams:{organization:e},blockers:[],blocks:[]},a);return this.dispatch(Ul(i)),i}}class oP extends v{async add(e){const a=await this.enqueueRequest({description:"Create organization",method:h.POST,url:"/organizations/",payload:e,blockers:[],blocks:[]});return this.dispatch(Ll(a)),a}async update(e){const a=await this.enqueueRequest({description:"Edit organization",method:h.PATCH,url:`/organizations/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[e.uuid]});return this.dispatch(Nl(a)),a}async invite(e,a){return this.enqueueRequest({description:"Invite user to organization",method:h.POST,url:`/organizations/${e}/invite/${a}/`,blockers:[],blocks:[]})}async refreshStore(e){const a=await this.enqueueRequest({description:"Fetch organizations",method:h.GET,url:"/organizations/",blockers:[],blocks:[]},e);return this.dispatch($l(a)),a}}class lP extends v{add(e){const a=T(e);this.dispatch(Ci(a));const i=this.enqueueRequest({description:"Add project access",method:h.POST,url:"/project-accesses/",payload:w(a),blockers:[a.organization_access,a.project],blocks:[a.uuid]});return i.then(c=>{this.dispatch(dt(c))}).catch(c=>{throw this.dispatch(ki(a.uuid)),c}),[a,i]}update(e){const{store:a}=this.client,i=Gi(e.uuid)(a.getState()),c={...i,...e};this.dispatch(dt(c));const n=this.enqueueRequest({description:"Edit project access",method:h.PATCH,url:`/project-accesses/${e.uuid}/`,payload:e,blockers:[e.uuid],blocks:[]});return n.then(r=>{this.dispatch(dt(r))}).catch(r=>{throw this.dispatch(dt(i)),r}),[c,n]}async remove(e){const{store:a}=this.client,i=Gi(e)(a.getState());this.dispatch(ki(e));try{await this.enqueueRequest({description:"Delete project access",method:h.DELETE,url:`/project-accesses/${e}/`,blockers:[e],blocks:[]})}catch(c){throw this.dispatch(Ci(i)),c}}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Get project accesses",method:h.GET,url:"/project-accesses/",queryParams:{project__organization_owner:e},blockers:[],blocks:[]},a);return this.dispatch(eh(i)),i}}class hP extends ke{constructor(){super(...arguments);S(this,"name","Project Attachment");S(this,"url","/project-attachments");S(this,"addAttachments",rh);S(this,"updateAttachments",oh);S(this,"removeAttachments",Li);S(this,"removeAttachment",lh);S(this,"setAttachment",dh);S(this,"selectAttachment",ph)}buildOfflineAttachment(a){return T({file:URL.createObjectURL(a.file),file_sha1:a.file_sha1,created_by:a.created_by,file_name:a.file.name,file_type:a.file.type,submitted_at:a.submitted_at,description:a.description,project:a.modelUuid})}buildAttachmentPayload(a){return{...a,project:a.modelUuid}}async bulkAdd(a){return this._bulkAdd(a.map(i=>({modelUuid:i.projectUuid,file:i.file})))}async delete(a){return this._delete(a)}async refreshStore(a,i){const c=await this.enqueueRequest({description:"Get project attachments",method:h.GET,url:`${this.url}/`,queryParams:{project__organization_owner:a},blockers:[],blocks:[]},i);return this.dispatch(nh(c)),c}}class mP extends v{async saveExisting(e){if(!e.uuid)throw new Error("You can only use this method to save existing project files. The one provided has no uuid.");const a={...e};delete a.file;const i=this.enqueueRequest({method:h.PATCH,url:`/project-files/${e.uuid}/`,payload:a,blockers:[e.uuid],blocks:[e.uuid]});return i.then(c=>{this.dispatch(Hi(c))}),i}saveActive(){const{store:e}=this.client,a=e.getState(),i=a.projectFileReducer.activeProjectFileId;if(!i)throw new Error("No active project file");const c=a.projectFileReducer.instances[i];if(!c)throw new Error("No active project file");if(!c.bounds&&!c.canvas_bounds)throw new Error("Project file must either have bounds or canvas_bounds set");let n;if(typeof c.file=="string"&&!c.file.startsWith("blob:")){const m={...c};delete m.file,n={method:h.PATCH,url:`/project-files/${i}/`,payload:m,blockers:[i],blocks:[i]}}else n=new Promise((m,u)=>{this.client.files.uploadFileToS3(c.file_sha1).then(([o])=>{m({method:h.POST,url:`/project-files${c.project}/`,payload:{...c,...o},blockers:[i],blocks:[i]})}).catch(u)});const l=Promise.resolve(n).then(m=>this.enqueueRequest(m));return l.then(m=>{this.dispatch(Hi(m))}),this.dispatch(Ih),this.dispatch(Th(null)),this.dispatch(Fh(!1)),[c,l]}delete(e){return this.dispatch(bh(e)),this.enqueueRequest({method:h.DELETE,url:`/project-files/${e}`,blockers:[e],blocks:[]})}async refreshStore(e,a){const c=(await this.performPagination({immediate:!0,description:"Get project files",method:h.GET,url:"/project-files/",queryParams:{limit:E,paginate:!0,project:e},blockers:[],blocks:[]},n=>({immediate:!0,description:"Get project files",method:h.GET,url:n,blockers:[],blocks:[]}),a)).flat();return this.dispatch(Sh(c)),c}}class pP extends v{async add(e){const a=await this.enqueueRequest({description:"Create project",method:h.POST,url:"/projects/",payload:w(e),blockers:[],blocks:[]});return this.dispatch(Yi(a)),a}async update(e){if(!e.bounds&&!e.canvas_bounds)throw new Error("Project must either have bounds or canvas_bounds set");return this.dispatch(Mh(e)),await this.enqueueRequest({description:"Update project",method:h.PATCH,url:`/projects/${e.uuid}/`,payload:{name:e.name,bounds:e.bounds},blockers:[e.uuid],blocks:[e.uuid]})}async delete(e){const{store:a}=this.client,i=a.getState(),c=qh(e)(i);if(!c)throw new Error("Expected project to exist");const n=_h(i).filter(m=>m.project===e);this.dispatch(Ph(n.map(({uuid:m})=>m)));const r=Ah(c.uuid)(i);this.dispatch(Li(r.map(({uuid:m})=>m)));const l=ih(e)(i);this.dispatch(sh(l.map(({uuid:m})=>m))),this.dispatch(Ki(c.uuid));try{await this.enqueueRequest({description:"Delete project",method:h.DELETE,url:`/projects/${e}/`,blockers:[e],blocks:[]}),this.dispatch(Ki(c.uuid))}catch(m){throw this.dispatch(Yi(c)),this.dispatch(th(Object.values(l))),this.dispatch(gh(n)),this.dispatch(uh(r)),m}}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Fetch projects",method:h.GET,url:"/projects/",queryParams:{organization_owner:e},blockers:[],blocks:[]},a);return this.dispatch(wh(i)),i}}class AP extends v{add(e){const a=T(e);this.dispatch(Dh(a));const i=this.enqueueRequest({description:"Create team membership",method:h.POST,url:"/team-memberships/",payload:w(a),blockers:[e.team],blocks:[a.uuid]});return i.then(c=>{this.dispatch(Qi(c))}).catch(()=>{this.dispatch(xi(a.uuid))}),[a,i]}async delete(e){const{store:a}=this.client,i=a.getState(),c=Bh(e)(i);if(!c)throw new Error(`Expected team membership with uuid ${e} to exist`);this.dispatch(xi(e));try{return await this.enqueueRequest({description:"Delete team membership",method:h.DELETE,url:`/team-memberships/${e}/`,blockers:[e],blocks:[e]})}catch(n){throw this.dispatch(Qi(c)),n}}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Fetch team memberships",method:h.GET,url:"/team-memberships/",queryParams:{team__organization:e},blockers:[],blocks:[]},a);return this.dispatch(Uh(i)),i}}class yP extends v{add(e){const a=T({...e,submitted_at:new Date().toISOString()});this.dispatch(Lh(a));const i=this.enqueueRequest({description:"Create team",method:h.POST,url:"/teams/",payload:w(a),blockers:[],blocks:[a.uuid]});return i.then(c=>{this.dispatch(ut(c))}).catch(()=>{this.dispatch(sc(a.uuid))}),[a,i]}update(e){const{store:a}=this.client,i=ic(e.uuid)(a.getState());if(!i)throw new Error(`Expected team with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(Nh(c));const n=this.enqueueRequest({description:"Update team",method:h.PATCH,url:`/teams/${e.uuid}/`,payload:w(e),blockers:[e.uuid],blocks:[e.uuid]});return n.then(r=>{this.dispatch(ut(r))}).catch(()=>{this.dispatch(ut(i))}),[c,n]}async delete(e){const{store:a}=this.client,i=a.getState(),c=ic(e)(i);if(!c)throw new Error(`Expected team with uuid ${e} to exist`);this.dispatch(sc(e));try{return await this.enqueueRequest({description:"Delete team",method:h.DELETE,url:`/teams/${e}/`,blockers:[e],blocks:[e]})}catch(n){throw this.dispatch(ut(c)),n}}async refreshStore(e,a){const i=await this.enqueueRequest({description:"Fetch teams",method:h.GET,url:"/teams/",queryParams:{organization:e},blockers:[],blocks:[]},a);return this.dispatch($h(i)),i}}class fP extends v{async refreshStore(e,a){const i=await this.enqueueRequest({description:"Fetch organization users",method:h.GET,url:`/organizations/${e}/users/`,blockers:[],blocks:[]},a);return this.dispatch(wl(i)),i}}class SP{constructor(e){S(this,"store");this.store=e}async enqueueRequest(e,a,i,c){return this._enqueueRequest(e,a,i,c).then(n=>{if(n instanceof D)throw n;return n})}_enqueueRequest(e,a,i,c){const n=new Sc,r={...e,BASE_URL:a,serviceName:i};if(e.immediate){const l={...r,uuid:e.uuid??Ne.v4()},m={payload:l,type:"",meta:{offline:{effect:{timestamp:new Date().toISOString(),request:l,BASE_URL:a,serviceName:i}}}};rc(m,this,c).then(u=>{n.resolve(u.body)}).catch(u=>{dc(u,m),u instanceof Error?n.reject(u):n.reject(new Error((u??Ye).toString()))})}else{const l=this.store.dispatch(Zl(r)),m=o=>{if(o)n.resolve(o.body);else{const p=new D({message:"Could not get a response from the server.",response:o,discard:!0});n.reject(p)}},u=o=>{o instanceof D?o.options.discard=!0:(console.error("Received an unexpected error while processing a request:",o,`
15
15
  Converting error to APIError and discarding.`),o=new D({message:"An error occurred while processing the request.",innerError:o,discard:!0})),n.reject(o)};l.then(m,u)}return n}}class Ke{constructor(){S(this,"graph");S(this,"requestAttemptCounter");this.graph=new fm.DepGraph,this.requestAttemptCounter={}}static _fromOutbox(e){const a=new Ke;for(let i=0;i<e.length;i++){const c=e[i];if(!c){console.error("Outbox item was undefined");continue}a.sneakRequest(c);for(let n=0;n<i;n++){const r=e[n];if(!r){console.error("Previous outbox item was undefined");continue}r.payload.uuid!==c.payload.uuid&&r.payload.blocks.some(l=>c.payload.blockers.includes(l))&&Ke._addDependency(c.payload.uuid,r.payload.uuid,a.graph)}}return a}_addDependency(e,a){Ke._addDependency(e,a,this.graph)}static _addDependency(e,a,i){if(e===a)throw new Error(`Tried to add dependency from node to itself: ${e}`);if(!i.hasNode(e))throw new Error(`Tried to add dependency from non-existent node: ${e} (to node: ${a})`);if(!i.hasNode(a))throw new Error(`Tried to add dependency to non-existent node: ${a} (from node: ${e})`);i.addDependency(e,a)}addRequest(e){if(this.graph.addNode(e.payload.uuid,e),!(e.payload.blockers.length===0||this.graph.size()===1))for(const a of this.graph.overallOrder()){if(a===e.payload.uuid)continue;const i=this.graph.getNodeData(a);e.payload.blockers.some(c=>i.payload.blocks.includes(c))&&this._addDependency(e.payload.uuid,a)}}insertRequest(e){this.graph.addNode(e.payload.uuid,e);for(const a of this.graph.overallOrder()){if(a===e.payload.uuid)continue;this.graph.getNodeData(a).payload.blockers.some(c=>e.payload.blocks.includes(c))&&this._addDependency(a,e.payload.uuid)}}sneakRequest(e){this.graph.addNode(e.payload.uuid,e)}_getNextNode(){const e=this.graph.overallOrder(!0);let a=1/0,i;for(const c of e){const n=this.requestAttemptCounter[c]||0;n<a&&(a=n,i=c)}return i}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(i=>this.graph.getNodeData(i)),a=this._getNextNode();if(a){const i=this.graph.getNodeData(a),c=e.findIndex(n=>n.payload.uuid===i.payload.uuid);c!==-1&&(e.splice(c,1),e.unshift(i))}return e}getReady(){let e=this.graph.overallOrder(!0).map(a=>this.graph.getNodeData(a));return e=e.sort((a,i)=>a.meta.offline.effect.timestamp.localeCompare(i.meta.offline.effect.timestamp)),e=e.sort((a,i)=>{const c=this.requestAttemptCounter[a.payload.uuid]||0,n=this.requestAttemptCounter[i.payload.uuid]||0;return c-n}),e}registerRetry(e){this.requestAttemptCounter[e]=(this.requestAttemptCounter[e]||0)+1}}const gP=(t,e)=>{const a=new e(t);return Lg(a),$g(t),a};var um=(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))(um||{});s.APIError=D,s.AgentService=ob,s.AssetAttachmentService=mb,s.AssetProcedureAttachmentService=pb,s.AssetProcedureFieldValuesAttachmentService=fb,s.AssetProcedureFieldValuesService=Sb,s.AssetProcedureFieldsAttachmentService=Ab,s.AssetProcedureFieldsService=yb,s.AssetProcedureInstanceService=gb,s.AssetProcedureService=bb,s.AssetProcedureStepFieldValuesAttachmentService=Tb,s.AssetProcedureStepFieldValuesService=Ib,s.AssetProcedureStepFieldsAttachmentService=Pb,s.AssetProcedureStepFieldsService=Fb,s.AssetProcedureStepService=Ob,s.AssetService=_b,s.AssetStageCompletionService=Rb,s.AssetStageService=vb,s.AssetTypeAttachmentService=wb,s.AssetTypeFieldValuesAttachmentService=jb,s.AssetTypeFieldValuesService=qb,s.AssetTypeFieldsAttachmentService=Mb,s.AssetTypeFieldsService=Eb,s.AssetTypeService=Vb,s.AttachmentModel=yc,s.BaseApiService=v,s.BaseSDK=SP,s.COMMON_AUTO_FIELDS=Tc,s.CategoryService=zb,s.DEFAULT_ISSUE_PRIORITY=gm,s.DEFAULT_ISSUE_STATUS=Sm,s.DEFAULT_PAGINATION_PAGE_SIZE=E,s.DeferredPromise=Sc,s.DocumentAttachmentService=Ub,s.DocumentService=Db,s.EMPTY_ARRAY=mc,s.EMPTY_OBJECT=pc,s.EmailDomainsService=Cb,s.EmailVerificationService=kb,s.FileService=Gb,s.FormRevisionAttachmentService=$b,s.FormRevisionService=Lb,s.FormService=Nb,s.FormSubmissionAttachmentService=Hb,s.FormSubmissionService=Wb,s.GeoImageService=Yb,s.HttpMethod=h,s.IssueAssociationService=Kb,s.IssueAttachmentService=Zb,s.IssueCommentAttachmentService=Jb,s.IssueCommentService=Xb,s.IssuePriority=Lt,s.IssueService=Qb,s.IssueStatus=Nt,s.IssueTypeAttachmentService=xb,s.IssueTypeFieldValuesAttachmentService=sP,s.IssueTypeFieldValuesService=aP,s.IssueTypeFieldsAttachmentService=eP,s.IssueTypeFieldsService=tP,s.IssueTypeService=iP,s.IssueUpdateChange=j,s.IssueUpdateService=cP,s.JWTService=dP,s.OUTBOX_RETRY_DELAY=fc,s.OrganizationAccessLevel=Ac,s.OrganizationAccessService=uP,s.OrganizationService=oP,s.OutboxCoordinator=Ke,s.PAGINATION_MAX_PAGE_SIZE=lb,s.PAGINATION_PAGE_SIZE_QUERY_PARAM=hb,s.ProjectAccessService=lP,s.ProjectAttachmentService=hP,s.ProjectFileService=mP,s.ProjectService=pP,s.RESET_ORGANIZATION_STATE=O,s.RESET_PROJECT_STATE=M,s.RESET_STATE=F,s.TeamMembershipService=AP,s.TeamService=yP,s.UNKNOWN_ERROR_MESSAGE=Ye,s.UserService=fP,s.VERSION_REDUCER_KEY=Ze,s.VerificationCodeType=um,s._setLatestRetryTime=Xl,s.addAsset=Bs,s.addAssetAttachment=Jm,s.addAssetAttachments=xt,s.addAssetProcedure=gs,s.addAssetProcedureAttachment=xm,s.addAssetProcedureAttachments=Lc,s.addAssetProcedureFieldValues=ds,s.addAssetProcedureFieldValuesAttachment=Sp,s.addAssetProcedureFieldValuesAttachments=mt,s.addAssetProcedureFieldValuesMany=Tn,s.addAssetProcedureFields=un,s.addAssetProcedureFieldsAttachment=ap,s.addAssetProcedureFieldsAttachments=en,s.addAssetProcedureFieldsMany=op,s.addAssetProcedureInstance=ms,s.addAssetProcedureInstances=Mn,s.addAssetProcedureStep=Us,s.addAssetProcedureStepFieldValues=js,s.addAssetProcedureStepFieldValuesAttachment=sA,s.addAssetProcedureStepFieldValuesAttachments=At,s.addAssetProcedureStepFieldValuesMany=ir,s.addAssetProcedureStepFields=Os,s.addAssetProcedureStepFieldsAttachment=Bp,s.addAssetProcedureStepFieldsAttachments=Bn,s.addAssetProcedureStepFieldsMany=Yp,s.addAssetProcedureSteps=pA,s.addAssetProcedures=qp,s.addAssetStage=xs,s.addAssetStageCompletion=Ys,s.addAssetStageCompletions=Ks,s.addAssetStages=vA,s.addAssetType=Aa,s.addAssetTypeAttachment=VA,s.addAssetTypeAttachments=aa,s.addAssetTypeFieldValues=oa,s.addAssetTypeFieldValuesAttachment=QA,s.addAssetTypeFieldValuesAttachments=It,s.addAssetTypeFieldValuesMany=ld,s.addAssetTypeFields=Xr,s.addAssetTypeFieldsAttachment=DA,s.addAssetTypeFieldsAttachments=Lr,s.addAssetTypeFieldsMany=NA,s.addAssetTypes=oy,s.addAssets=bt,s.addCategories=gy,s.addCategory=ba,s.addConversation=vc,s.addConversations=Lm,s.addDocumentAttachment=_y,s.addDocumentAttachments=Ed,s.addDocuments=$d,s.addEmailDomain=Yd,s.addEmailDomains=qy,s.addForm=Va,s.addFormRevision=Ea,s.addFormRevisionAttachment=Gy,s.addFormRevisionAttachments=cu,s.addFormRevisions=hu,s.addFormSubmission=ka,s.addFormSubmissionAttachment=rf,s.addFormSubmissionAttachments=wt,s.addFormSubmissions=jt,s.addForms=xy,s.addGeoImage=Bu,s.addGeoImages=Gu,s.addIssue=oi,s.addIssueAssociation=Ka,s.addIssueAssociations=Za,s.addIssueAttachment=bf,s.addIssueAttachments=ei,s.addIssueComment=ci,s.addIssueCommentAttachment=Tf,s.addIssueCommentAttachments=ho,s.addIssueComments=vf,s.addIssueType=pl,s.addIssueTypeAttachment=Cf,s.addIssueTypeAttachments=Eo,s.addIssueTypeFieldValues=Si,s.addIssueTypeFieldValuesAttachment=oS,s.addIssueTypeFieldValuesAttachments=Ut,s.addIssueTypeFieldValuesMany=Zf,s.addIssueTypeFields=el,s.addIssueTypeFieldsAttachment=$f,s.addIssueTypeFieldsAttachments=$o,s.addIssueTypeFieldsMany=tS,s.addIssueTypes=yS,s.addIssueUpdate=Pl,s.addIssueUpdates=Fl,s.addIssues=Ro,s.addOrganization=Ll,s.addOrganizationAccess=Dl,s.addOrganizationAccesses=DS,s.addOrganizations=WS,s.addProject=Yi,s.addProjectAccess=Ci,s.addProjectAccesses=th,s.addProjectAttachment=ng,s.addProjectAttachments=rh,s.addProjectFile=og,s.addProjectFiles=gh,s.addProjects=Sg,s.addTeam=Lh,s.addTeamMembership=Dh,s.addTeamMemberships=_g,s.addTeams=qg,s.addUser=Ml,s.addUsers=MS,s.agentsReducer=Ec,s.agentsSlice=Zt,s.areArraysEqual=Om,s.assetAttachmentReducer=Bc,s.assetAttachmentSlice=Xt,s.assetProcedureAttachmentReducer=Xc,s.assetProcedureAttachmentSlice=ts,s.assetProcedureFieldValuesAttachmentReducer=bn,s.assetProcedureFieldValuesAttachmentSlice=cs,s.assetProcedureFieldValuesReducer=Rn,s.assetProcedureFieldValuesSlice=rs,s.assetProcedureFieldsAttachmentReducer=nn,s.assetProcedureFieldsAttachmentSlice=ss,s.assetProcedureFieldsReducer=mn,s.assetProcedureFieldsSlice=as,s.assetProcedureInstanceReducer=qn,s.assetProcedureInstanceSlice=hs,s.assetProcedureReducer=Dn,s.assetProcedureSlice=Ss,s.assetProcedureStepFieldValuesAttachmentReducer=tr,s.assetProcedureStepFieldValuesAttachmentSlice=ws,s.assetProcedureStepFieldValuesReducer=dr,s.assetProcedureStepFieldValuesSlice=Es,s.assetProcedureStepFieldsAttachmentReducer=Hn,s.assetProcedureStepFieldsAttachmentSlice=Ts,s.assetProcedureStepFieldsReducer=Kn,s.assetProcedureStepFieldsSlice=Is,s.assetProcedureStepReducer=hr,s.assetProcedureStepSlice=zs,s.assetReducer=Sr,s.assetSlice=ks,s.assetStageCompletionReducer=Tr,s.assetStageCompletionSlice=Ws,s.assetStageReducer=wr,s.assetStageSlice=Qs,s.assetTypeAttachmentReducer=Br,s.assetTypeAttachmentSlice=sa,s.assetTypeFieldValuesAttachmentReducer=dd,s.assetTypeFieldValuesAttachmentSlice=ra,s.assetTypeFieldValuesReducer=Ad,s.assetTypeFieldValuesSlice=ua,s.assetTypeFieldsAttachmentReducer=Kr,s.assetTypeFieldsAttachmentSlice=ca,s.assetTypeFieldsReducer=td,s.assetTypeFieldsSlice=na,s.assetTypeReducer=gd,s.assetTypeSlice=pa,s.authReducer=Fd,s.authSlice=_t,s.baseReducer=Bg,s.baseReducers=cc,s.blobToBase64=Vm,s.categoryReducer=vd,s.categorySlice=ga,s.clearTokens=yy,s.constructUploadedFilePayloads=qm,s.coordinatesAreEqual=Tm,s.createModelAdapter=I,s.createMultiPointGeometry=Fm,s.createOfflineAction=Yl,s.createPayload=w,s.createPointGeometry=Pm,s.createSelectionAdapter=bm,s.deleteAsset=Gs,s.deleteAssetAttachment=zc,s.deleteAssetAttachments=es,s.deleteAssetProcedure=bs,s.deleteAssetProcedureAttachment=Wc,s.deleteAssetProcedureAttachments=Yc,s.deleteAssetProcedureFieldValues=us,s.deleteAssetProcedureFieldValuesAttachment=Fp,s.deleteAssetProcedureFieldValuesAttachments=pt,s.deleteAssetProcedureFieldValuesMany=On,s.deleteAssetProcedureFields=ln,s.deleteAssetProcedureFieldsAttachment=rp,s.deleteAssetProcedureFieldsAttachments=sn,s.deleteAssetProcedureFieldsMany=pp,s.deleteAssetProcedureInstance=ps,s.deleteAssetProcedureInstances=En,s.deleteAssetProcedureStep=Ds,s.deleteAssetProcedureStepFieldValues=qs,s.deleteAssetProcedureStepFieldValuesAttachment=nA,s.deleteAssetProcedureStepFieldValuesAttachments=yt,s.deleteAssetProcedureStepFieldValuesMany=nr,s.deleteAssetProcedureStepFields=_s,s.deleteAssetProcedureStepFieldsAttachment=Np,s.deleteAssetProcedureStepFieldsAttachments=$n,s.deleteAssetProcedureStepFieldsMany=Xp,s.deleteAssetProcedureSteps=yA,s.deleteAssetProcedures=zp,s.deleteAssetStage=ea,s.deleteAssetStageCompletion=Zs,s.deleteAssetStageCompletions=Js,s.deleteAssetStages=MA,s.deleteAssetType=ya,s.deleteAssetTypeAttachment=zr,s.deleteAssetTypeAttachments=ia,s.deleteAssetTypeFieldValues=la,s.deleteAssetTypeFieldValuesAttachment=sy,s.deleteAssetTypeFieldValuesAttachments=Ot,s.deleteAssetTypeFieldValuesMany=md,s.deleteAssetTypeFields=xr,s.deleteAssetTypeFieldsAttachment=GA,s.deleteAssetTypeFieldsAttachments=Hr,s.deleteAssetTypeFieldsMany=KA,s.deleteAssetTypes=hy,s.deleteAssets=$s,s.deleteCategories=Ty,s.deleteCategory=_d,s.deleteConversation=Wm,s.deleteConversations=Ym,s.deleteDocumentAttachment=Vd,s.deleteDocumentAttachments=zd,s.deleteEmailDomain=Kd,s.deleteEmailDomains=Cy,s.deleteForm=za,s.deleteFormRevision=ja,s.deleteFormRevisionAttachment=Hy,s.deleteFormRevisionAttachments=ru,s.deleteFormRevisions=pu,s.deleteFormSubmission=Ba,s.deleteFormSubmissionAttachment=lf,s.deleteFormSubmissionAttachments=Mt,s.deleteFormSubmissions=qt,s.deleteForms=cf,s.deleteGeoImage=Ha,s.deleteGeoImages=Lu,s.deleteIssue=li,s.deleteIssueAssociation=Ja,s.deleteIssueAssociations=Xa,s.deleteIssueAttachment=io,s.deleteIssueAttachments=ti,s.deleteIssueComment=ri,s.deleteIssueCommentAttachment=Ao,s.deleteIssueCommentAttachments=yo,s.deleteIssueComments=Ef,s.deleteIssueType=gS,s.deleteIssueTypeAttachment=Vo,s.deleteIssueTypeAttachments=zo,s.deleteIssueTypeFieldValues=gi,s.deleteIssueTypeFieldValuesAttachment=pS,s.deleteIssueTypeFieldValuesAttachments=Dt,s.deleteIssueTypeFieldValuesMany=xf,s.deleteIssueTypeFields=sl,s.deleteIssueTypeFieldsAttachment=Wf,s.deleteIssueTypeFieldsAttachments=No,s.deleteIssueTypeFieldsMany=cS,s.deleteIssueTypes=bS,s.deleteIssueUpdate=Tl,s.deleteIssueUpdates=Il,s.deleteIssues=vo,s.deleteOrganization=KS,s.deleteOrganizationAccess=Cl,s.deleteOrganizationAccesses=GS,s.deleteOrganizations=ZS,s.deleteProject=Ki,s.deleteProjectAccess=ki,s.deleteProjectAccesses=sh,s.deleteProjectAttachment=lh,s.deleteProjectAttachments=Li,s.deleteProjectFile=bh,s.deleteProjectFiles=Ph,s.deleteProjects=bg,s.deleteTeam=sc,s.deleteTeamMembership=xi,s.deleteTeamMemberships=Mg,s.deleteTeams=Ug,s.deleteUser=El,s.deleteUsers=qS,s.dequeue=cm,s.discard=dc,s.documentAttachmentReducer=kd,s.documentAttachmentSlice=Ta,s.documentSlice=Ia,s.documentsReducer=Nd,s.downloadFile=zm,s.downloadInMemoryFile=jm,s.emailDomainsReducer=Xd,s.emailDomainsSlice=Ra,s.emailRegex=$m,s.enqueue=im,s.enqueueRequest=Zl,s.fallbackToEmptyArray=g,s.fallbackToEmptyObject=ht,s.fileReducer=su,s.fileSlice=va,s.fileToBlob=Pc,s.formReducer=bu,s.formRevisionAttachmentReducer=uu,s.formRevisionAttachmentSlice=wa,s.formRevisionReducer=fu,s.formRevisionsSlice=Ma,s.formSlice=qa,s.formSubmissionAttachmentReducer=wu,s.formSubmissionAttachmentSlice=Ua,s.formSubmissionReducer=Uu,s.formSubmissionSlice=Ca,s.geoImageReducer=Wu,s.geoImageSlice=Na,s.getFileIdentifier=Em,s.getFileS3Key=Kt,s.getLocalDateString=gc,s.getLocalRelativeDateString=wm,s.getOutboxCoordinator=Ge,s.getRenamedFile=bc,s.hashFile=He,s.initSDK=gP,s.initializeAssetAttachments=Qt,s.initializeAssetProcedureAttachments=$c,s.initializeAssetProcedureFieldValues=Fn,s.initializeAssetProcedureFieldValuesAttachments=An,s.initializeAssetProcedureFields=dn,s.initializeAssetProcedureFieldsAttachments=xc,s.initializeAssetProcedureInstances=wn,s.initializeAssetProcedureStepFieldValues=ar,s.initializeAssetProcedureStepFieldValuesAttachments=Jn,s.initializeAssetProcedureStepFields=Yn,s.initializeAssetProcedureStepFieldsAttachments=kn,s.initializeAssetProcedureSteps=or,s.initializeAssetProcedures=zn,s.initializeAssetStageCompletions=br,s.initializeAssetStages=Rr,s.initializeAssetTypeAttachments=jr,s.initializeAssetTypeFieldValues=od,s.initializeAssetTypeFieldValuesAttachments=ad,s.initializeAssetTypeFields=Jr,s.initializeAssetTypeFieldsAttachments=$r,s.initializeAssetTypes=fd,s.initializeAssets=Ar,s.initializeCategories=Id,s.initializeConversations=Rc,s.initializeDocumentAttachments=Md,s.initializeEmailDomains=Wd,s.initializeFormRevisionAttachments=iu,s.initializeFormRevisions=lu,s.initializeFormSubmissionAttachments=Ou,s.initializeFormSubmissions=Eu,s.initializeForms=gu,s.initializeGeoImages=Cu,s.initializeIssueAssociations=Ku,s.initializeIssueAttachments=xa,s.initializeIssueCommentAttachments=ai,s.initializeIssueComments=Rf,s.initializeIssueTypeAttachments=Ai,s.initializeIssueTypeFieldValues=Zo,s.initializeIssueTypeFieldValuesAttachments=nl,s.initializeIssueTypeFields=xo,s.initializeIssueTypeFieldsAttachments=Go,s.initializeIssueTypes=ml,s.initializeIssueUpdates=bl,s.initializeIssues=_o,s.initializeOrganizationAccesses=Ul,s.initializeOrganizations=$l,s.initializeProjectAccesses=eh,s.initializeProjectAttachments=nh,s.initializeProjectFiles=Sh,s.initializeProjects=wh,s.initializeTeamMemberships=Uh,s.initializeTeams=$h,s.initializeUsers=wl,s.isToday=vm,s.issueAssociationReducer=eo,s.issueAssociationSlice=Ya,s.issueAttachmentReducer=oo,s.issueAttachmentSlice=Qa,s.issueCommentAttachmentReducer=bo,s.issueCommentAttachmentSlice=si,s.issueCommentReducer=Io,s.issueCommentSlice=ii,s.issueReducer=wo,s.issueSlice=ui,s.issueTypeAttachmentReducer=ko,s.issueTypeAttachmentSlice=pi,s.issueTypeFieldValuesAttachmentReducer=ll,s.issueTypeFieldValuesAttachmentSlice=Ti,s.issueTypeFieldValuesReducer=Xo,s.issueTypeFieldValuesSlice=fi,s.issueTypeFieldsAttachmentReducer=Yo,s.issueTypeFieldsAttachmentSlice=yi,s.issueTypeFieldsReducer=il,s.issueTypeFieldsSlice=Fi,s.issueTypeReducer=Sl,s.issueTypeSlice=Oi,s.issueUpdateReducer=Rl,s.issueUpdateSlice=wi,s.logOnlyOnce=Um,s.markAsDeleted=Jl,s.markForDeletion=eg,s.memoize=Wt,s.offline=T,s.onlyUniqueHashes=Gm,s.onlyUniqueOfflineIds=Oc,s.organizationAccessReducer=kl,s.organizationAccessSlice=ji,s.organizationReducer=Wl,s.organizationSlice=zi,s.outboxReducer=Ql,s.outboxSlice=Ui,s.overmapEnhancer=Qg,s.overmapReducer=Gg,s.overmapReducers=Zh,s.performRequest=rc,s.projectAccessReducer=ah,s.projectAccessSlice=Di,s.projectAttachmentReducer=yh,s.projectAttachmentSlice=$i,s.projectFileReducer=Rh,s.projectFileSlice=Ni,s.projectReducer=Eh,s.projectSlice=Wi,s.rehydratedReducer=Vh,s.rehydratedSlice=Ji,s.removeDocuments=Oa,s.removeIssueType=_i,s.resetProjectFileObjectUrls=hg,s.restructureCreateSelectorWithArgs=f,s.saveActiveProjectFileBounds=Ih,s.selectAccessToken=fy,s.selectAccessesByUserOfProject=ig,s.selectAccessibleProjects=Pg,s.selectActiveOrganizationAccess=$S,s.selectActiveProjectFileId=pg,s.selectAllDocumentAttachments=Dd,s.selectAllProjectAttachments=mh,s.selectAssetAttachmentById=Cc,s.selectAssetAttachmentMapping=Uc,s.selectAssetAttachments=Dc,s.selectAssetById=Hs,s.selectAssetProcedureAttachmentById=Jc,s.selectAssetProcedureAttachmentMapping=Kc,s.selectAssetProcedureAttachments=Zc,s.selectAssetProcedureById=Fs,s.selectAssetProcedureFieldValues=os,s.selectAssetProcedureFieldValuesAttachmentById=Tp,s.selectAssetProcedureFieldValuesAttachments=fn,s.selectAssetProcedureFieldValuesAttachmentsByIds=Sn,s.selectAssetProcedureFieldValuesAttachmentsMapping=ns,s.selectAssetProcedureFieldValuesById=ls,s.selectAssetProcedureFieldValuesMapping=_n,s.selectAssetProcedureFieldValuesOfAsset=_p,s.selectAssetProcedureFields=is,s.selectAssetProcedureFieldsAttachmentById=up,s.selectAssetProcedureFieldsAttachments=cn,s.selectAssetProcedureFieldsAttachmentsMapping=an,s.selectAssetProcedureFieldsById=fp,s.selectAssetProcedureFieldsMapping=hn,s.selectAssetProcedureFieldsOfAssetProcedure=Ap,s.selectAssetProcedureInstanceById=fs,s.selectAssetProcedureInstances=ys,s.selectAssetProcedureInstancesByIds=jp,s.selectAssetProcedureInstancesMapping=As,s.selectAssetProcedureInstancesOfAssetProcedure=jn,s.selectAssetProcedureInstancesOfAssetType=Ep,s.selectAssetProcedureStepById=Cs,s.selectAssetProcedureStepFieldValues=ft,s.selectAssetProcedureStepFieldValuesAttachmentById=rA,s.selectAssetProcedureStepFieldValuesAttachments=Qn,s.selectAssetProcedureStepFieldValuesAttachmentsByIds=xn,s.selectAssetProcedureStepFieldValuesAttachmentsMapping=Ms,s.selectAssetProcedureStepFieldValuesById=Vs,s.selectAssetProcedureStepFieldValuesMapping=rr,s.selectAssetProcedureStepFieldValuesOfAsset=oA,s.selectAssetProcedureStepFieldValuesOfAssetProcedureInstance=lA,s.selectAssetProcedureStepFieldValuesOfAssetProcedureStep=hA,s.selectAssetProcedureStepFields=vs,s.selectAssetProcedureStepFieldsAttachmentById=Wp,s.selectAssetProcedureStepFieldsAttachments=Nn,s.selectAssetProcedureStepFieldsAttachmentsMapping=Ln,s.selectAssetProcedureStepFieldsById=tA,s.selectAssetProcedureStepFieldsMapping=Rs,s.selectAssetProcedureStepFieldsOfAssetProcedureStep=Qp,s.selectAssetProcedureStepMapping=gt,s.selectAssetProcedureSteps=mr,s.selectAssetProcedureStepsByIds=gA,s.selectAssetProcedureStepsMappingOfAssetProcedure=fA,s.selectAssetProcedureStepsOfAssetProcedure=SA,s.selectAssetProcedures=Un,s.selectAssetProceduresByIds=Cp,s.selectAssetProceduresMapping=Ps,s.selectAssetProceduresOfOrganization=kp,s.selectAssetStageById=ta,s.selectAssetStageCompletionById=Ir,s.selectAssetStageCompletionMapping=Xs,s.selectAssetStageCompletions=_A,s.selectAssetStageCompletionsByIds=Or,s.selectAssetStages=Mr,s.selectAssetStagesByIds=qA,s.selectAssetStagesMappingOfAssetProcedure=EA,s.selectAssetStagesOfAssetProcedure=jA,s.selectAssetTypeAttachmentById=Cr,s.selectAssetTypeAttachmentMapping=Ur,s.selectAssetTypeAttachments=Dr,s.selectAssetTypeById=Sa,s.selectAssetTypeFieldValues=ha,s.selectAssetTypeFieldValuesAttachmentById=ay,s.selectAssetTypeFieldValuesAttachments=cd,s.selectAssetTypeFieldValuesAttachmentsByIds=nd,s.selectAssetTypeFieldValuesAttachmentsMapping=da,s.selectAssetTypeFieldValuesById=ma,s.selectAssetTypeFieldValuesMapping=pd,s.selectAssetTypeFieldValuesOfAsset=ny,s.selectAssetTypeFields=Tt,s.selectAssetTypeFieldsAttachmentById=LA,s.selectAssetTypeFieldsAttachments=Yr,s.selectAssetTypeFieldsAttachmentsMapping=Wr,s.selectAssetTypeFieldsById=XA,s.selectAssetTypeFieldsMapping=ed,s.selectAssetTypeFieldsOfAssetType=ZA,s.selectAssetTypeValuesOfAssetType=ry,s.selectAssetTypes=Sd,s.selectAssetTypesByIds=my,s.selectAssetTypesMapping=fa,s.selectAssetTypesOfOrganization=py,s.selectAssets=yr,s.selectAssetsByIds=fr,s.selectAssetsMapping=Ls,s.selectAssetsOfAssetType=Ns,s.selectAttachmentsOfAsset=kc,s.selectAttachmentsOfAssetProcedure=sp,s.selectAttachmentsOfAssetProcedureFieldValues=gn,s.selectAttachmentsOfAssetProcedureFields=dp,s.selectAttachmentsOfAssetProcedureStepFieldValues=er,s.selectAttachmentsOfAssetProcedureStepFields=Hp,s.selectAttachmentsOfAssetType=kr,s.selectAttachmentsOfAssetTypeFieldValues=rd,s.selectAttachmentsOfAssetTypeFields=$A,s.selectAttachmentsOfDocument=wy,s.selectAttachmentsOfFormRevision=Wy,s.selectAttachmentsOfFormSubmission=vu,s.selectAttachmentsOfIssue=ro,s.selectAttachmentsOfIssueComment=_f,s.selectAttachmentsOfIssueType=Gf,s.selectAttachmentsOfIssueTypeFieldValues=ol,s.selectAttachmentsOfIssueTypeFields=Yf,s.selectAttachmentsOfProject=Ah,s.selectCategories=Rd,s.selectCategoriesByIds=Iy,s.selectCategoriesOfProject=Oy,s.selectCategoryById=Fa,s.selectCategoryMapping=Pa,s.selectCommentsOfIssue=jf,s.selectConversation=Zm,s.selectConversationMapping=Jt,s.selectConversations=Km,s.selectCurrentUser=ql,s.selectDeletedRequests=QS,s.selectDocumentAttachmentById=Cd,s.selectDocumentAttachmentMapping=Ud,s.selectDocumentById=Ld,s.selectDocuments=_a,s.selectDocumentsByIds=My,s.selectDocumentsMapping=Rt,s.selectEmailDomains=Jd,s.selectEmailDomainsAsMapping=Zd,s.selectEmailDomainsOfOrganization=ky,s.selectFieldValuesOfAssetProcedureInstance=Rp,s.selectFormById=Tu,s.selectFormMapping=Pu,s.selectFormRevisionAttachmentsMapping=du,s.selectFormRevisionById=Xy,s.selectFormRevisionMapping=vt,s.selectFormRevisions=Au,s.selectFormRevisionsOfForm=yu,s.selectFormSubmissionAttachemntsByIds=Ru,s.selectFormSubmissionAttachmentsMapping=Da,s.selectFormSubmissionById=La,s.selectFormSubmissions=$a,s.selectFormSubmissionsMapping=Ga,s.selectFormSubmissionsOfAsset=zu,s.selectFormSubmissionsOfForm=qu,s.selectFormSubmissionsOfIssue=Vu,s.selectForms=Fu,s.selectFormsOfOrganization=nf,s.selectGeoImageById=Wa,s.selectGeoImageMapping=Nu,s.selectGeoImages=Hu,s.selectGeoImagesOfProject=Af,s.selectIsImportingProjectFile=Ag,s.selectIsLoggedIn=Sy,s.selectIssueAssociationById=Ju,s.selectIssueAssociationMapping=ct,s.selectIssueAssociations=gf,s.selectIssueAssociationsOfAsset=xu,s.selectIssueAssociationsOfIssue=Qu,s.selectIssueAssociationsToIssue=Xu,s.selectIssueAttachmentById=uo,s.selectIssueAttachmentMapping=co,s.selectIssueAttachments=no,s.selectIssueById=mi,s.selectIssueCommentAttachmentById=go,s.selectIssueCommentAttachmentMapping=fo,s.selectIssueCommentAttachments=So,s.selectIssueCommentById=di,s.selectIssueCommentMapping=To,s.selectIssueMapping=hi,s.selectIssueTypeAttachmentById=Co,s.selectIssueTypeAttachmentMapping=Uo,s.selectIssueTypeAttachments=Do,s.selectIssueTypeById=Ri,s.selectIssueTypeFieldValues=bi,s.selectIssueTypeFieldValuesAttachmentById=AS,s.selectIssueTypeFieldValuesAttachments=dl,s.selectIssueTypeFieldValuesAttachmentsByIds=ul,s.selectIssueTypeFieldValuesAttachmentsMapping=Ii,s.selectIssueTypeFieldValuesById=Pi,s.selectIssueTypeFieldValuesMapping=Jo,s.selectIssueTypeFieldValuesOfIssue=eS,s.selectIssueTypeFields=zt,s.selectIssueTypeFieldsAttachmentById=Kf,s.selectIssueTypeFieldsAttachments=Wo,s.selectIssueTypeFieldsAttachmentsMapping=Ho,s.selectIssueTypeFieldsById=uS,s.selectIssueTypeFieldsMapping=al,s.selectIssueTypeFieldsOfIssueType=nS,s.selectIssueTypeMapping=yl,s.selectIssueTypeValuesOfIssueType=dS,s.selectIssueTypes=fl,s.selectIssueTypesByIds=PS,s.selectIssueTypesOfOrganization=FS,s.selectIssueUpdateMapping=Ol,s.selectIssueUpdatesOfIssue=_l,s.selectIssues=Uf,s.selectIssuesByIds=Df,s.selectIssuesOfIssueType=vi,s.selectIssuesOfIssueTypeCount=TS,s.selectLatestAssetProcedureFieldsOfAssetProcedure=yp,s.selectLatestAssetProcedureStepFieldsOfAssetProcedureStep=xp,s.selectLatestAssetTypeFieldsOfAssetType=JA,s.selectLatestFieldsByAssetProcedureStep=eA,s.selectLatestFormRevisionOfForm=Qy,s.selectLatestIssueTypeFieldsOfIssueType=rS,s.selectLatestRetryTime=xS,s.selectMembershipsByUserOfTeam=Eg,s.selectNumberOfAssetsOfAssetType=TA,s.selectOrganizationAccessById=Vi,s.selectOrganizationAccessMapping=qi,s.selectOrganizationAccessUserMapping=Bl,s.selectOrganizationById=XS,s.selectOrganizationDocuments=jy,s.selectOrganizations=JS,s.selectOrganizationsMapping=Hl,s.selectProjectAccessById=Gi,s.selectProjectAccessMapping=Bi,s.selectProjectAccesses=Bt,s.selectProjectAccessesOfProject=ih,s.selectProjectAttachmentById=ph,s.selectProjectAttachmentMapping=hh,s.selectProjectById=qh,s.selectProjectDocuments=Ey,s.selectProjectFileById=mg,s.selectProjectFileMapping=Oh,s.selectProjectFiles=_h,s.selectProjectMapping=jh,s.selectProjects=Zi,s.selectProjectsOfOrganization=Fg,s.selectRehydrated=Og,s.selectStageMapping=Ft,s.selectTeamById=ic,s.selectTeamMembershipById=Bh,s.selectTeamMemberships=ec,s.selectTeamMembershipsMapping=kh,s.selectTeams=Hh,s.selectTeamsByIds=Dg,s.selectTeamsMapping=ac,s.selectTeamsOfOrganization=Cg,s.selectUploadUrl=tu,s.selectUserById=Vl,s.selectUsers=Ei,s.selectUsersByIds=US,s.selectUsersMapping=Ct,s.selectUsersOfOrganization=LS,s.selectUsersOfProject=cg,s.selectUsersOfTeam=jg,s.setActiveProjectFileId=Th,s.setAsset=PA,s.setAssetAttachment=qc,s.setAssetAttachments=Xm,s.setAssetProcedure=Up,s.setAssetProcedureAttachment=Nc,s.setAssetProcedureAttachments=ep,s.setAssetProcedureFieldValues=Ip,s.setAssetProcedureFieldValuesAttachment=gp,s.setAssetProcedureFieldValuesAttachments=bp,s.setAssetProcedureFieldValuesMany=Op,s.setAssetProcedureFields=lp,s.setAssetProcedureFieldsAttachment=ip,s.setAssetProcedureFieldsAttachments=cp,s.setAssetProcedureFieldsMany=hp,s.setAssetProcedureInstance=wp,s.setAssetProcedureInstances=Mp,s.setAssetProcedureStep=lr,s.setAssetProcedureStepFieldValues=dA,s.setAssetProcedureStepFieldValuesAttachment=aA,s.setAssetProcedureStepFieldValuesAttachments=iA,s.setAssetProcedureStepFieldValuesMany=uA,s.setAssetProcedureStepFields=Kp,s.setAssetProcedureStepFieldsAttachment=Gp,s.setAssetProcedureStepFieldsAttachments=$p,s.setAssetProcedureStepFieldsMany=Zp,s.setAssetProcedureSteps=mA,s.setAssetProcedures=Dp,s.setAssetStage=vr,s.setAssetStageCompletion=IA,s.setAssetStageCompletions=OA,s.setAssetStages=RA,s.setAssetType=dy,s.setAssetTypeAttachment=qr,s.setAssetTypeAttachments=zA,s.setAssetTypeFieldValues=iy,s.setAssetTypeFieldValuesAttachment=xA,s.setAssetTypeFieldValuesAttachments=ey,s.setAssetTypeFieldValuesMany=cy,s.setAssetTypeFields=HA,s.setAssetTypeFieldsAttachment=CA,s.setAssetTypeFieldsAttachments=kA,s.setAssetTypeFieldsMany=WA,s.setAssetTypes=uy,s.setAssets=FA,s.setCategories=Py,s.setCategory=by,s.setConversation=wc,s.setConversations=Nm,s.setCurrentUser=VS,s.setDocumentAttachment=jd,s.setDocumentAttachments=Ry,s.setDocuments=Gd,s.setEmailDomain=Vy,s.setEmailDomains=zy,s.setForm=ef,s.setFormRevision=mu,s.setFormRevisionAttachment=$y,s.setFormRevisionAttachments=Ly,s.setFormRevisions=Ky,s.setFormSubmission=Et,s.setFormSubmissionAttachment=df,s.setFormSubmissionAttachments=uf,s.setFormSubmissions=hf,s.setForms=tf,s.setGeoImage=it,s.setGeoImages=ku,s.setIsImportingProjectFile=Fh,s.setIssue=qf,s.setIssueAssociation=ff,s.setIssueAssociations=yf,s.setIssueAttachment=so,s.setIssueAttachments=Pf,s.setIssueComment=ni,s.setIssueCommentAttachment=mo,s.setIssueCommentAttachments=If,s.setIssueComments=Fo,s.setIssueType=rt,s.setIssueTypeAttachment=jo,s.setIssueTypeAttachments=kf,s.setIssueTypeFieldValues=Jf,s.setIssueTypeFieldValuesAttachment=lS,s.setIssueTypeFieldValuesAttachments=hS,s.setIssueTypeFieldValuesMany=Xf,s.setIssueTypeFields=sS,s.setIssueTypeFieldsAttachment=Lf,s.setIssueTypeFieldsAttachments=Nf,s.setIssueTypeFieldsMany=aS,s.setIssueTypes=fS,s.setIssueUpdate=IS,s.setIssueUpdates=OS,s.setIssues=Vf,s.setLoggedIn=Pd,s.setOrganization=HS,s.setOrganizationAccess=CS,s.setOrganizationAccesses=kS,s.setOrganizations=NS,s.setProfilePicture=zS,s.setProject=fg,s.setProjectAccess=tg,s.setProjectAccesses=sg,s.setProjectAttachment=dh,s.setProjectAttachments=uh,s.setProjectFile=dg,s.setProjectFiles=ug,s.setProjects=yg,s.setRehydrated=Ig,s.setTeam=ut,s.setTeamMembership=Qi,s.setTeamMemberships=Rg,s.setTeams=Vg,s.setTokens=Ay,s.setUploadUrl=eu,s.setUser=wS,s.setUsers=vS,s.shallowEqual=Im,s.slugify=km,s.spacesToDashesLower=Cm,s.teamMembershipReducer=Ch,s.teamMembershipSlice=Xi,s.teamReducer=Wh,s.teamSlice=tc,s.toFileNameSafeString=Dm,s.toOfflineIdRecord=Ic,s.truncate=Bm,s.updateAsset=tt,s.updateAssetAttachment=Qm,s.updateAssetAttachments=Vc,s.updateAssetProcedure=Qe,s.updateAssetProcedureAttachment=tp,s.updateAssetProcedureAttachments=Hc,s.updateAssetProcedureFieldValues=Je,s.updateAssetProcedureFieldValuesAttachment=Pp,s.updateAssetProcedureFieldValuesAttachments=yn,s.updateAssetProcedureFieldValuesMany=In,s.updateAssetProcedureFields=on,s.updateAssetProcedureFieldsAttachment=np,s.updateAssetProcedureFieldsAttachments=tn,s.updateAssetProcedureFieldsMany=mp,s.updateAssetProcedureInstance=Xe,s.updateAssetProcedureInstances=vp,s.updateAssetProcedureStep=St,s.updateAssetProcedureStepFieldValues=et,s.updateAssetProcedureStepFieldValuesAttachment=cA,s.updateAssetProcedureStepFieldValuesAttachments=Xn,s.updateAssetProcedureStepFieldValuesMany=cr,s.updateAssetProcedureStepFields=xe,s.updateAssetProcedureStepFieldsAttachment=Lp,s.updateAssetProcedureStepFieldsAttachments=Gn,s.updateAssetProcedureStepFieldsMany=Jp,s.updateAssetProcedureSteps=AA,s.updateAssetProcedures=Vp,s.updateAssetStage=Pt,s.updateAssetStageCompletion=Pr,s.updateAssetStageCompletions=Fr,s.updateAssetStages=wA,s.updateAssetType=at,s.updateAssetTypeAttachment=UA,s.updateAssetTypeAttachments=Vr,s.updateAssetTypeFieldValues=st,s.updateAssetTypeFieldValuesAttachment=ty,s.updateAssetTypeFieldValuesAttachments=id,s.updateAssetTypeFieldValuesMany=hd,s.updateAssetTypeFields=Qr,s.updateAssetTypeFieldsAttachment=BA,s.updateAssetTypeFieldsAttachments=Nr,s.updateAssetTypeFieldsMany=YA,s.updateAssetTypes=ly,s.updateAssets=bA,s.updateCategories=Fy,s.updateCategory=Od,s.updateConversation=Mc,s.updateConversations=Hm,s.updateDocumentAttachment=vy,s.updateDocumentAttachments=qd,s.updateDocuments=We,s.updateEmailDomain=Uy,s.updateEmailDomains=Dy,s.updateForm=sf,s.updateFormRevision=Zy,s.updateFormRevisionAttachment=Ny,s.updateFormRevisionAttachments=nu,s.updateFormRevisions=Jy,s.updateFormSubmission=ju,s.updateFormSubmissionAttachment=of,s.updateFormSubmissionAttachments=_u,s.updateFormSubmissions=mf,s.updateForms=af,s.updateGeoImage=$u,s.updateGeoImages=pf,s.updateIssue=Vt,s.updateIssueAssociation=Zu,s.updateIssueAssociations=Sf,s.updateIssueAttachment=Ff,s.updateIssueAttachments=ao,s.updateIssueComment=wf,s.updateIssueCommentAttachment=Of,s.updateIssueCommentAttachments=po,s.updateIssueComments=Mf,s.updateIssueType=Al,s.updateIssueTypeAttachment=Bf,s.updateIssueTypeAttachments=qo,s.updateIssueTypeFieldValues=nt,s.updateIssueTypeFieldValuesAttachment=mS,s.updateIssueTypeFieldValuesAttachments=rl,s.updateIssueTypeFieldValuesMany=Qf,s.updateIssueTypeFields=tl,s.updateIssueTypeFieldsAttachment=Hf,s.updateIssueTypeFieldsAttachments=Lo,s.updateIssueTypeFieldsMany=iS,s.updateIssueTypes=SS,s.updateIssueUpdate=_S,s.updateIssueUpdates=RS,s.updateIssues=zf,s.updateOrganization=Nl,s.updateOrganizationAccess=kt,s.updateOrganizationAccesses=BS,s.updateOrganizations=YS,s.updateProject=Mh,s.updateProjectAccess=dt,s.updateProjectAccesses=ag,s.updateProjectAttachment=rg,s.updateProjectAttachments=oh,s.updateProjectFile=Hi,s.updateProjectFiles=lg,s.updateProjects=gg,s.updateTeam=Nh,s.updateTeamMembership=vg,s.updateTeamMemberships=wg,s.updateTeams=zg,s.updateUser=jS,s.updateUsers=ES,s.userReducer=jl,s.userSlice=Mi,s.versioningReducer=Kh,s.versioningSlice=Yh,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Core functionality for Overmap",
4
4
  "author": "Wôrdn Inc.",
5
5
  "license": "UNLICENSED",
6
- "version": "1.0.78-view-sets.36",
6
+ "version": "1.0.78-view-sets.37",
7
7
  "type": "module",
8
8
  "main": "dist/overmap-core.umd.cjs",
9
9
  "module": "dist/overmap-core.js",