@overmap-ai/core 1.0.78-view-sets.4 → 1.0.78-view-sets.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/overmap-core.js
CHANGED
|
@@ -3200,7 +3200,7 @@ class _S extends v {
|
|
|
3200
3200
|
const s = await this.enqueueRequest({
|
|
3201
3201
|
description: "Get agent conversation history",
|
|
3202
3202
|
method: u.GET,
|
|
3203
|
-
url: "/
|
|
3203
|
+
url: "/agents/conversations/",
|
|
3204
3204
|
queryParams: { project: e },
|
|
3205
3205
|
blockers: ["agent-conversations"],
|
|
3206
3206
|
blocks: ["agent-conversations"]
|
|
@@ -5,7 +5,7 @@ Retries:`,s),!(t instanceof Error))throw console.error("ENCOUNTERED NON-ERROR ER
|
|
|
5
5
|
Action:`,e);const p=Ue();if(!p)throw new Error("Outbox coordinator not set");p.remove(e.payload.uuid),t.options.discard=!0,o()}}console.debug("Registering a retry for request:",e.payload.uuid);const m=Ue();if(!m)throw new Error("Outbox coordinator not set");return m.registerRetry(e.payload.uuid),!1}function Ng(t,e,s){var i;return(i=Ue())==null?void 0:i.peek()}function Hg(t,e){return pt().dispatch(nh(new Date().getTime())),oc}const Ze="An unknown error occurred",Wg=500,Xh=["non_field_errors","detail"];function Kg(t,e){let s;if(t!=null&&t.body)if(typeof t.body=="object"){const i=t.body;if(typeof i.error=="string")s=i.error;else if(typeof i.message=="string")s=i.message;else try{s=Object.entries(i).map(([c,n])=>typeof n=="string"?Xh.includes(c)?n:`${c}: ${n}`:Array.isArray(n)?Xh.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"&&(s=t.body);else t!=null&&t.text?s=t.text:e instanceof Error&&(s=e.message);return!s||s.length>Wg?Ze:s}class D extends Error{constructor(s){super(Ze);f(this,"status");f(this,"response");f(this,"message");f(this,"options");const{response:i,innerError:c}=s;this.message=s.message??Kg(i,c)??Ze,this.status=(i==null?void 0:i.status)??0,this.response=i,s.discard=s.discard??!1,this.options=s}}class Yg extends Gh{constructor(e){super(e)}}class R extends Gh{constructor(s,i){super(s);f(this,"auth");this.auth=i}}class Jg extends R{async startConversation(e,s){return this.enqueueRequest({description:"Start agent conversation",method:h.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:s},blockers:["prompt"],blocks:["prompt"]}).then(i=>(this.dispatch(Pc(i)),i))}async continueConversation(e,s,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:s}}).then(c=>{this.dispatch(Tc(c))})}async fetchDetails(e){return this.enqueueRequest({description:"Get agent conversation",method:h.GET,url:`/agents/conversations/${e}/`,blockers:["conversation"],blocks:["conversation"]}).then(s=>{this.dispatch(bc(s))})}async rate(e,s){return this.enqueueRequest({description:"Rate agent response",method:h.PUT,url:`/agents/responses/${e}/rate/`,payload:{rating:s},blockers:["rate"],blocks:["rate"]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get agent conversation history",method:h.GET,url:"/agent-conversations/",queryParams:{project:e},blockers:["agent-conversations"],blocks:["agent-conversations"]});return this.dispatch(Fc(s)),s}}class j extends R{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:i,assetTypeAttachmentReducer:c,documentAttachmentReducer:n,projectAttachmentReducer:r,formRevisionAttachmentReducer:o,formSubmissionAttachmentReducer:m,geoImageReducer:d,assetTypeFieldsAttachmentReducer:l,assetTypeFieldValuesAttachmentReducer:p,issueTypeFieldsAttachmentReducer:A,issueTypeFieldValuesAttachmentReducer:y}=this.client.store.getState();return[].concat(Object.values(s.instances),Object.values(i.instances),Object.values(c.instances),Object.values(n.instances),Object.values(r.instances),Object.values(o.instances),Object.values(m.instances),Object.values(d.instances),Object.values(l.instances),Object.values(p.instances),Object.values(A.instances),Object.values(y.instances)).filter(P=>P.file_sha1===e).length}processPresignedUrls(e){const s={};for(const[i,c]of Object.entries(e))s[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 s}async getFilePayload(e){const s=await Ne(e),i={sha1:s,file_type:e.type,extension:e.name.split(".").pop(),size:e.size};return await this.client.files.addCache(e,s),i}}class Ce extends j{async _bulkAdd(e){var d;const{store:s}=this.client,i=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,c=new Date().toISOString(),n=[],r=[],o={};for(const l of e){const{modelUuid:p,file:A}=l,y=await this.getFilePayload(A);y.sha1 in o||(o[y.sha1]=y);const F=this.buildOfflineAttachment({file:A,file_sha1:y.sha1,submitted_at:c,created_by:i,description:"",modelUuid:p});n.push(F),r.push(this.buildAttachmentPayload({uuid:F.uuid,file_name:F.file_name,file_sha1:F.file_sha1,file_extension:y.extension,description:F.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(o)},blocks:n.map(l=>l.uuid),blockers:n.map(l=>l.file_sha1)});return m.then(({attachments:l,presigned_urls:p})=>{this.dispatch(this.updateAttachments(l)),this.processPresignedUrls(p)}).catch(()=>{this.dispatch(this.removeAttachments(n.map(l=>l.uuid)))}),[n,m.then(({attachments:l})=>l)]}async _delete(e){const{store:s}=this.client,i=this.selectAttachment(e)(s.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 Zg extends Ce{constructor(){super(...arguments);f(this,"name","Asset Attachment");f(this,"url","/asset-attachments");f(this,"initializeAttachments",Qt);f(this,"addAttachments",xt);f(this,"updateAttachments",Rc);f(this,"removeAttachments",es);f(this,"removeAttachment",vc);f(this,"setAttachment",Oc);f(this,"selectAttachment",Ec)}buildOfflineAttachment(s){return T({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset:s.modelUuid})}buildAttachmentPayload(s){return{...s,asset:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(i=>({modelUuid:i.assetUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get asset attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset__project:s},blocks:[],blockers:[]});return this.dispatch(Qt(i)),i}}class Xg extends Ce{constructor(){super(...arguments);f(this,"name","Asset Procedure Attachment");f(this,"url","/asset-procedure-attachments");f(this,"addAttachments",Dc);f(this,"updateAttachments",Uc);f(this,"removeAttachments",Bc);f(this,"removeAttachment",kc);f(this,"setAttachment",Cc);f(this,"selectAttachment",Lc)}buildOfflineAttachment(s){return T({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset_procedure:s.modelUuid})}buildAttachmentPayload(s){return{...s,asset_procedure:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(i=>({modelUuid:i.assetProcedureUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get asset procedure attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset_procedure__organization:s},blocks:[],blockers:[]});return this.dispatch(zc(i)),i}}class Qg extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const d of e){const{fieldsRevisionUuid:l,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const F=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:l,submitted_at:s,field_identifier:p});n.push(F);const P={uuid:F.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:l};r.push(P)}this.dispatch(Kc(n));const o=this.enqueueRequest({description:"Add asset procedure fields attachments",method:h.POST,url:"/asset-procedure-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(c)},blockers:n.map(d=>d.fields_revision),blocks:n.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(Yc(d.attachments))}).catch(()=>{this.dispatch(Jc(n.map(d=>d.uuid)))}),[n,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=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:[]});return this.dispatch(Wc(s)),s}}class xg extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(tn(n));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:h.POST,url:"/asset-procedure-fields/",payload:n,blockers:[n.asset_procedure],blocks:[n.uuid]});return r.then(m=>{this.dispatch(sn(m))}).catch(m=>{throw this.dispatch(an(n.uuid)),m}),[n,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:h.GET,url:"/asset-procedure-fields/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(en(s)),s}}function ke(t,e){const s=[];let i=0;const c=t.length;for(;i<c;)s.push(t.slice(i,i+=e));return s}class eF extends j{async bulkAdd(e,s){var d;const i=new Date().toISOString(),c=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,n=ke(e,s??e.length),r=[],o=[];for(const l of n){const p={},A=[];for(const y of l){const{fieldValuesUuid:F,fieldIdentifier:P,file:I}=y,v=await this.getFilePayload(I);v.sha1 in p||(p[v.sha1]=v);const q=T({file:URL.createObjectURL(I),file_type:I.type,file_name:I.name,file_sha1:v.sha1,created_by:c,field_values:F,submitted_at:i,field_identifier:P});r.push(q);const Qe={uuid:q.uuid,file_name:I.name,file_sha1:v.sha1,file_extension:v.extension,field_identifier:P,field_values:F};A.push(Qe)}o.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(yt(r));const m=o.map(l=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:h.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:l,blockers:l.attachments.map(p=>p.field_values),blocks:l.attachments.map(p=>p.uuid)}));return Promise.all(m).then(l=>{for(const A of l)this.processPresignedUrls(A.presigned_urls);const p=l.flatMap(A=>A.attachments);this.dispatch(un(p))}).catch(l=>{throw this.dispatch(ft(r.map(p=>p.uuid))),l}),[r,m.map(l=>l.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=ln(e)(i);this.dispatch(ft(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:h.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(yt(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values attachments",method:h.GET,url:"/asset-procedure-field-values-attachments/",queryParams:{field_values__asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(dn(s)),s}}class tF extends R{add(e){var r;const{store:s}=this.client,i=s.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:M(c),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[c.uuid]});return this.dispatch(ds(c)),n.then(o=>(this.dispatch(et(o)),o)).catch(()=>{this.dispatch(us(c.uuid))}),[c,n]}bulkAdd(e,s){var m;const i=new Date().toISOString(),c=[],n=ke(e.payloads,s??e.payloads.length),r=[];for(const d of n){const l=[];for(const p of d){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),l.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:l})}this.dispatch(yn(c));const o=[];for(const d of r){const l=d.field_values.map(P=>P.asset),p=d.field_values.map(P=>P.fields_revision),A=d.field_values.map(P=>P.asset_procedure_instance),y=d.field_values.map(P=>P.uuid),F=this.enqueueRequest({description:"Bulk add asset procedure field values",method:h.POST,url:"/asset-procedure-field-values/bulk/",payload:d,blockers:[...l,...p,...A],blocks:y});o.push(F)}return Promise.all(o).then(d=>{this.dispatch(fn(d.flat()))}).catch(()=>{this.dispatch(Sn(c.map(d=>d.uuid)))}),[c,o]}update(e){const{store:s}=this.client,i=s.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(et(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(o=>{this.dispatch(et(o))}).catch(()=>{this.dispatch(et(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=ls(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=hn(e)(i);this.dispatch(us(e)),this.dispatch(ft(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(yt(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values",method:h.GET,url:"/asset-procedure-field-values/",queryParams:{asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(An(s)),s}}class sF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.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:M(n),blockers:[e.asset_procedure,e.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(tt(m))}).catch(()=>{this.dispatch(ps(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=fs(e.uuid)(s.getState());if(!i)throw new Error(`Expected asset procedure instance with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(tt(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(tt(r))}).catch(()=>{this.dispatch(tt(i))}),[c,n]}async remove(e){const{store:s}=this.client,i=s.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){const s=await this.enqueueRequest({description:"Get asset procedure instances",method:h.GET,url:"/asset-procedure-instances/",queryParams:{project:e},blockers:[],blocks:[]});return this.dispatch(bn(s)),s}}class aF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.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:M(n),blockers:[],blocks:[n.uuid]});return r.then(m=>{this.dispatch(st(m))}).catch(()=>{this.dispatch(Fs(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=bs(e.uuid)(s.getState());if(!i)throw new Error(`Expected asset procedure with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(st(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(st(r))}).catch(()=>{this.dispatch(st(i))}),[c,n]}async remove(e){const{store:s}=this.client,i=s.getState(),c=bs(e)(i);if(!c)throw new Error(`Expected asset procedure with uuid ${e} to exist`);const n=_n(e)(i);return this.dispatch(Fs(e)),this.dispatch(In(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(Tn(n)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedures",method:h.GET,url:"/asset-procedures/",queryParams:{organization:e},blockers:[],blocks:[]});return this.dispatch(vn(s)),s}}class iF extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const d of e){const{fieldsRevisionUuid:l,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const F=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:l,submitted_at:s,field_identifier:p});n.push(F);const P={uuid:F.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:l};r.push(P)}this.dispatch(qn(n));const o=this.enqueueRequest({description:"Add asset procedure step fields attachments",method:h.POST,url:"/asset-procedure-step-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(c)},blockers:n.map(d=>d.fields_revision),blocks:n.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(Vn(d.attachments))}).catch(()=>{this.dispatch(zn(n.map(d=>d.uuid)))}),[n,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=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:[]});return this.dispatch(jn(s)),s}}class cF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(_s(n));const r=this.enqueueRequest({description:"Add Asset Procedure Step Fields",method:h.POST,url:"/asset-procedure-step-fields/",payload:n,blockers:[n.asset_procedure_step],blocks:[n.uuid]});return r.then(m=>{this.dispatch(at(m))}).catch(m=>{throw this.dispatch(Os(n.uuid)),m}),[n,r]}update(e){const{store:s}=this.client,i=s.getState().assetProcedureStepFieldsReducer.instances[e.uuid];if(!i)throw new Error(`AssetProcedureStepFields with uuid ${e.uuid} not found`);const c={...i,...e};this.dispatch(at(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(at(r))}).catch(r=>{throw this.dispatch(at(i)),r}),[c,n]}delete(e){const{store:s}=this.client,i=s.getState().assetProcedureStepFieldsReducer.instances[e];if(!i)throw new Error(`AssetProcedureStepFields with uuid ${e} not found`);this.dispatch(Os(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(_s(i)),n}),c}async refreshStore(e){const s=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:[]});return this.dispatch(Bn(s)),s}}class nF extends j{async bulkAdd(e,s){var d;const i=new Date().toISOString(),c=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,n=ke(e,s??e.length),r=[],o=[];for(const l of n){const p={},A=[];for(const y of l){const{fieldValuesUuid:F,fieldIdentifier:P,file:I}=y,v=await this.getFilePayload(I);v.sha1 in p||(p[v.sha1]=v);const q=T({file:URL.createObjectURL(I),file_type:I.type,file_name:I.name,file_sha1:v.sha1,created_by:c,field_values:F,submitted_at:i,field_identifier:P});r.push(q);const Qe={uuid:q.uuid,file_name:I.name,file_sha1:v.sha1,file_extension:v.extension,field_identifier:P,field_values:F};A.push(Qe)}o.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(St(r));const m=o.map(l=>this.enqueueRequest({description:"Add asset procedure step field values attachments",method:h.POST,url:"/asset-procedure-step-field-values-attachments/bulk/",payload:l,blockers:l.attachments.map(p=>p.field_values),blocks:l.attachments.map(p=>p.uuid)}));return Promise.all(m).then(l=>{for(const A of l)this.processPresignedUrls(A.presigned_urls);const p=l.flatMap(A=>A.attachments);this.dispatch(Nn(p))}).catch(l=>{throw this.dispatch(gt(r.map(p=>p.uuid))),l}),[r,m.map(l=>l.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=Wn(e)(i);this.dispatch(gt(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:{attachment_ids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(St(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure step field values attachments",method:h.GET,url:"/asset-procedure-step-field-values-attachments/",queryParams:{field_values__asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(Ln(s)),s}}class rF extends R{add(e){var r;const{store:s}=this.client,i=s.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:M(c),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[c.uuid]});return this.dispatch(js(c)),n.then(o=>(this.dispatch(it(o)),o)).catch(()=>{this.dispatch(qs(c.uuid))}),[c,n]}bulkAdd(e,s){var m;const i=new Date().toISOString(),c=[],n=ke(e.payloads,s??e.payloads.length),r=[];for(const d of n){const l=[];for(const p of d){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),l.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:l})}this.dispatch(Xn(c));const o=[];for(const d of r){const l=d.field_values.map(P=>P.asset),p=d.field_values.map(P=>P.fields_revision),A=d.field_values.map(P=>P.asset_procedure_instance),y=d.field_values.map(P=>P.uuid),F=this.enqueueRequest({description:"Bulk add asset procedure step field values",method:h.POST,url:"/asset-procedure-step-field-values/bulk/",payload:d,blockers:[...l,...p,...A],blocks:y});o.push(F)}return Promise.all(o).then(d=>{this.dispatch(Qn(d.flat()))}).catch(()=>{this.dispatch(xn(c.map(d=>d.uuid)))}),[c,o]}update(e){const{store:s}=this.client,i=s.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(it(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(o=>{this.dispatch(it(o))}).catch(()=>{this.dispatch(it(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Vs(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=Kn(e)(i);this.dispatch(qs(e)),this.dispatch(gt(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(St(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure step field values",method:h.GET,url:"/asset-procedure-step-field-values/",queryParams:{asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(Zn(s)),s}}class dF extends R{bulkAdd(e,s){var m;const i=new Date().toISOString(),c=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,n=e.map(d=>T(d)),r=n.map(d=>({...d,asset_procedure:s,created_by:c,submitted_at:i}));this.dispatch(Ds(r));const o=this.enqueueRequest({description:"Add asset procedure steps",method:h.POST,url:"/asset-procedure-steps/bulk/",payload:{submitted_at:i,asset_procedure:s,steps:n},blockers:[s],blocks:n.map(({uuid:d})=>d)});return o.then(d=>{this.dispatch(Pt(d))}).catch(()=>{this.dispatch(Us(r.map(({uuid:d})=>d)))}),[r,o]}async bulkUpdate(e,s){const c=this.client.store.getState(),n=ks(e.map(({uuid:r})=>r))(c);return this.dispatch(Pt(e)),this.enqueueRequest({description:"Edit asset procedure steps",method:h.PATCH,url:`/asset-procedures/${s}/bulk-update-steps/`,payload:{steps:e},blockers:[s],blocks:e.map(({uuid:r})=>r)}).catch(r=>{throw this.dispatch(Pt(n)),r})}async bulkDelete(e){const{store:s}=this.client,i=ks(e)(s.getState());this.dispatch(Us(e));const c=this.enqueueRequest({description:"Delete asset procedure steps",method:h.DELETE,url:"/asset-procedure-steps/bulk/",payload:{step_ids:e},blockers:e,blocks:[]});return c.catch(()=>{this.dispatch(Ds(i))}),c}update(e){const{store:s}=this.client,i=nr(e.uuid)(s.getState());if(!i)throw new Error(`No asset procedure step with uuid ${e.uuid} found in the store`);const c={...i,...e};this.dispatch(Cs(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(Cs(r))}).catch(()=>{this.dispatch(ir(i))}),[c,n]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure steps",method:h.GET,url:"/asset-procedure-steps/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(ar(s)),s}}class uF extends R{add(e){var o;const{store:s}=this.client;if(!e.canvas_marker&&!e.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");const i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch($s(n));const r=this.enqueueRequest({description:"Create asset",method:h.POST,url:"/assets/",payload:M(n),blockers:[n.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(ct(m))}).catch(()=>{this.dispatch(Gs(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=Ws(e.uuid)(s.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(ct(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(ct(r))}).catch(()=>{this.dispatch(ct(i))}),[c,n]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Ws(e)(i);if(!c)throw new Error(`No asset with uuid ${e} found in the store`);const n=jc(e)(i),r=wu(e)(i),o=Ku(e)(i);if(this.dispatch(Gs(e)),n.length>0){const m=n.map(({uuid:d})=>d);this.dispatch(es(m))}if(r.length>0){const m=r.map(({uuid:d})=>d);this.dispatch(zt(m))}if(o.length>0){const m=o.map(({uuid:d})=>d);this.dispatch(Qa(m))}return this.enqueueRequest({description:"Delete asset",method:h.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch($s(c)),this.dispatch(xt(n)),this.dispatch(Vt(r)),this.dispatch(Za(o)),m})}bulkAdd(e,s,i,c){const n=new Date().toISOString(),r=Ge.v4(),o=ke(e,c).map(l=>{const p=l.map(A=>T(A));return{batchId:Ge.v4(),payload:{transaction_id:r,submitted_at:n,asset_type:s,project:i,assets:p}}}),m=[];let d=null;for(const l of o){const{batchId:p,payload:A}=l,y=A.assets.map(v=>v.uuid),F=[s];d&&F.push(d);const P=y;P.push(p);const I=this.enqueueRequest({description:"Batch create assets",method:h.POST,url:"/assets/bulk/",payload:A,blockers:F,blocks:P});d=l.batchId,m.push(I)}return Promise.all(m).then(l=>{const p=l.flat();this.dispatch(Tt(p))}),m}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=lr(e)(i);this.dispatch(Ls(e));try{await this.enqueueRequest({description:"Bulk delete assets",method:h.DELETE,url:"/assets/bulk/",payload:{asset_ids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(Tt(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get assets",method:h.GET,url:"/assets/",queryParams:{project:e},blockers:[],blocks:[]});return this.dispatch(ur(s)),s}}class oF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.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:M(n),blockers:[e.asset,e.stage],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Ar(m))}).catch(()=>{this.dispatch(Zs(n.uuid))}),[n,r]}delete(e){const{store:s}=this.client,i=Sr(e)(s.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 d;const{store:s}=this.client,i=new Date().toISOString(),c=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,n=e.map(l=>T(l)),r=n.map(l=>({...l,created_by:c,submitted_at:i})),o=r.map(({uuid:l})=>l);this.dispatch(Js(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(l=>l.asset_procedure_instance),...e.map(l=>l.stage),...e.map(l=>l.asset)],blocks:o});return m.then(l=>{this.dispatch(yr(l))}).catch(()=>{this.dispatch(Xs(o))}),[r,m]}bulkDelete(e){const{store:s}=this.client,i=gr(e)(s.getState());this.dispatch(Xs(e));const c=this.enqueueRequest({description:"Deleting asset stage completions",method:h.DELETE,url:"/asset-stage-completions/bulk/",payload:{completion_ids:e},blockers:e,blocks:[]});return c.catch(()=>{this.dispatch(Js(i))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stage completions",method:h.GET,url:"/asset-stage-completions/",queryParams:{asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(pr(s)),s}}class lF extends R{bulkAdd(e,s){var m;const i=new Date().toISOString(),c=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,n=e.map(d=>T(d)),r=n.map(d=>({...d,asset_procedure:s,created_by:c,submitted_at:i}));this.dispatch(ea(r));const o=this.enqueueRequest({description:"Add asset stages",method:h.POST,url:"/asset-stages/bulk/",payload:{submitted_at:i,asset_procedure:s,stages:n},blockers:[s],blocks:n.map(({uuid:d})=>d)});return o.then(d=>{this.dispatch(It(d))}).catch(()=>{this.dispatch(sa(r.map(({uuid:d})=>d)))}),[r,o]}async bulkUpdate(e,s){const c=this.client.store.getState(),n=aa(e.map(({uuid:r})=>r))(c);return this.dispatch(It(e)),this.enqueueRequest({description:"Edit asset stages",method:h.PATCH,url:`/asset-procedures/${s}/bulk-update-stages/`,payload:{stages:e},blockers:[s],blocks:e.map(({uuid:r})=>r)}).catch(r=>{throw this.dispatch(It(n)),r})}async bulkDelete(e){const{store:s}=this.client,i=aa(e)(s.getState());this.dispatch(sa(e));const c=this.enqueueRequest({description:"Delete asset stages",method:h.DELETE,url:"/asset-stages/bulk/",payload:{stage_ids:e},blockers:e,blocks:[]});return c.catch(()=>{this.dispatch(ea(i))}),c}update(e){const{store:s}=this.client,i=Ir(e.uuid)(s.getState());if(!i)throw new Error(`No asset stage with uuid ${e.uuid} found in the store`);const c={...i,...e};this.dispatch(ta(c));const n=this.enqueueRequest({description:"Update asset stage",method:h.PATCH,url:`/asset-stages/${i.uuid}/`,payload:{name:e.name,description:e.description,priority:e.priority,color:e.color},blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(ta(r))}).catch(()=>{this.dispatch(br(i))}),[c,n]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stages",method:h.GET,url:"/asset-stages/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(Pr(s)),s}}class hF extends Ce{constructor(){super(...arguments);f(this,"name","Asset Type Attachment");f(this,"url","/asset-type-attachments");f(this,"addAttachments",ca);f(this,"updateAttachments",wr);f(this,"removeAttachments",na);f(this,"removeAttachment",Mr);f(this,"setAttachment",vr);f(this,"selectAttachment",qr)}buildOfflineAttachment(s){return T({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset_type:s.modelUuid})}buildAttachmentPayload(s){return{...s,asset_type:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(i=>({modelUuid:i.assetTypeUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get asset type attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset_type__organization:s},blocks:[],blockers:[]});return this.dispatch(Rr(i)),i}}class mF extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const d of e){const{fieldsRevisionUuid:l,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const F=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:l,submitted_at:s,field_identifier:p});n.push(F);const P={uuid:F.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:l};r.push(P)}this.dispatch(Ur(n));const o=this.enqueueRequest({description:"Add asset type fields attachments",method:h.POST,url:"/asset-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(c)},blockers:n.map(d=>d.fields_revision),blocks:n.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(kr(d.attachments))}).catch(()=>{this.dispatch(Br(n.map(d=>d.uuid)))}),[n,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=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:[]});return this.dispatch(Cr(s)),s}}class pF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Wr(n));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:h.POST,url:"/asset-type-fields/",payload:n,blockers:[n.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Kr(m))}).catch(m=>{throw this.dispatch(Yr(n.uuid)),m}),[n,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Type Fields",method:h.GET,url:"/asset-type-fields/",queryParams:{asset_type__organization:e},blockers:[],blocks:[]});return this.dispatch(Hr(s)),s}}class AF extends j{async bulkAdd(e,s){var d;const i=new Date().toISOString(),c=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,n=ke(e,s??e.length),r=[],o=[];for(const l of n){const p={},A=[];for(const y of l){const{fieldValuesUuid:F,fieldIdentifier:P,file:I}=y,v=await this.getFilePayload(I);v.sha1 in p||(p[v.sha1]=v);const q=T({file:URL.createObjectURL(I),file_type:I.type,file_name:I.name,file_sha1:v.sha1,created_by:c,field_values:F,submitted_at:i,field_identifier:P});r.push(q);const Qe={uuid:q.uuid,file_name:I.name,file_sha1:v.sha1,file_extension:v.extension,field_identifier:P,field_values:F};A.push(Qe)}o.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(Rt(r));const m=o.map(l=>this.enqueueRequest({description:"Add asset type field values attachments",method:h.POST,url:"/asset-type-field-values-attachments/bulk/",payload:l,blockers:l.attachments.map(p=>p.field_values),blocks:l.attachments.map(p=>p.uuid)}));return Promise.all(m).then(l=>{for(const A of l)this.processPresignedUrls(A.presigned_urls);const p=l.flatMap(A=>A.attachments);this.dispatch(xr(p))}).catch(l=>{throw this.dispatch(vt(r.map(p=>p.uuid))),l}),[r,m.map(l=>l.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=td(e)(i);this.dispatch(vt(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:h.DELETE,url:"/asset-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(Rt(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values attachments",method:h.GET,url:"/asset-type-field-values-attachments/",queryParams:{field_values__asset__project:e},blockers:[],blocks:[]});return this.dispatch(Qr(s)),s}}class yF extends R{add(e){var r;const{store:s}=this.client,i=s.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:M(c),blockers:[e.asset,e.fields_revision],blocks:[c.uuid]});return this.dispatch(ha(c)),n.then(o=>(this.dispatch(nt(o)),o)).catch(()=>{this.dispatch(ma(c.uuid))}),[c,n]}bulkAdd(e,s){var m;const i=new Date().toISOString(),c=[],n=ke(e.payloads,s??e.payloads.length),r=[];for(const d of n){const l=[];for(const p of d){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),l.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:l})}this.dispatch(nd(c));const o=[];for(const d of r){const l=d.field_values.map(F=>F.asset),p=d.field_values.map(F=>F.fields_revision),A=d.field_values.map(F=>F.uuid),y=this.enqueueRequest({description:"Bulk add asset type field values",method:h.POST,url:"/asset-type-field-values/bulk/",payload:d,blockers:[...l,...p],blocks:A});o.push(y)}return Promise.all(o).then(d=>{this.dispatch(rd(d.flat()))}).catch(()=>{this.dispatch(dd(c.map(d=>d.uuid)))}),[c,o]}update(e){const{store:s}=this.client,i=s.getState(),c=Aa(e.uuid)(i);if(!c)throw new Error(`Expected AssetTypeFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(nt(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(o=>{this.dispatch(nt(o))}).catch(()=>{this.dispatch(nt(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Aa(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=sd(e)(i);this.dispatch(ma(e)),this.dispatch(vt(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(ha(c)),this.dispatch(Rt(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values",method:h.GET,url:"/asset-type-field-values/",queryParams:{asset__project:e},blockers:[],blocks:[]});return this.dispatch(cd(s)),s}}class fF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(fa(n));const r=this.enqueueRequest({description:"Create asset type",method:h.POST,url:"/asset-types/",payload:M(n),blockers:[],blocks:[n.uuid]});return r.then(m=>{this.dispatch(rt(m))}).catch(()=>{this.dispatch(Sa(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=Fa(e.uuid)(s.getState());if(!i)throw new Error(`Expected asset type with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(rt(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(rt(r))}).catch(()=>{this.dispatch(rt(i))}),[c,n]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Fa(e)(i);if(!c)throw new Error(`Expected asset type with uuid ${e} to exist`);const n=Hs(e)(i),r=Vr(e)(i);return this.dispatch(Sa(e)),this.dispatch(Ls(n.map(o=>o.uuid))),this.dispatch(na(r.map(({uuid:o})=>o))),this.enqueueRequest({description:"Delete asset type",method:h.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(o=>{throw this.dispatch(fa(c)),this.dispatch(Tt(n)),this.dispatch(ca(r)),o})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset types",method:h.GET,url:"/asset-types/",queryParams:{organization:e},blockers:[],blocks:[]});return this.dispatch(hd(s)),s}}class SF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.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:M(n),blockers:[e.project],blocks:[n.uuid]});return[n,r]}update(e){const s=this.client.store.getState(),i=Ia(e.uuid)(s);if(!i)throw new Error(`Expected an existing category with uuid ${e.uuid}`);const c={...i,...e};this.dispatch(gd(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:s}=this.client,i=Ia(e)(s.getState());if(!i)throw new Error(`No category with uuid ${e} found in the store`);this.dispatch(Fd(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){const s=await this.enqueueRequest({description:"Get categories",method:h.GET,url:"/categories/",queryParams:{project__organization_owner:e},blocks:[],blockers:[]});return this.dispatch(Sd(s)),s}}class gF extends Ce{constructor(){super(...arguments);f(this,"name","Document Attachment");f(this,"url","/document-attachments");f(this,"addAttachments",Id);f(this,"updateAttachments",Od);f(this,"removeAttachments",vd);f(this,"removeAttachment",Rd);f(this,"setAttachment",_d);f(this,"selectAttachment",Ed)}buildOfflineAttachment(s){return T({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,document:s.modelUuid})}buildAttachmentPayload(s){return{...s,document:s.modelUuid}}async bulkAdd(s){var p;const{store:i}=this.client,c=(p=i.getState().userReducer.currentUser)==null?void 0:p.id,n=new Date().toISOString(),r=[],o=[],m={},d={};for(const A of s){const{documentUuid:y,file:F}=A,P=await this.getFilePayload(F);P.sha1 in m||(m[P.sha1]=P,d[P.sha1]=[]);const I=this.buildOfflineAttachment({file:F,file_sha1:P.sha1,submitted_at:n,created_by:c,description:"",modelUuid:y});r.push(I),o.push({uuid:I.uuid,file_name:I.file_name,file_sha1:I.file_sha1,file_extension:P.extension,description:I.description,document:y}),d[P.sha1].push(I.uuid)}this.dispatch(this.addAttachments(r));const l=this.enqueueRequest({description:"Attach files to document",method:h.POST,url:"/document-attachments/bulk/",payload:{submitted_at:n,attachments:o,files:Object.values(m)},blocks:r.map(A=>A.uuid),blockers:r.map(A=>A.file_sha1)});return l.then(({attachments:A,presigned_urls:y})=>{this.dispatch(this.updateAttachments(A));const F=this.processPresignedUrls(y);for(const[P,I]of Object.entries(F))I.then(()=>{const v=d[P];for(const q of v)this.makeReadable(q)})}).catch(()=>{this.dispatch(this.removeAttachments(r.map(A=>A.uuid)))}),[r,l.then(({attachments:A})=>A)]}async delete(s){return this._delete(s)}makeReadable(s){this.enqueueRequest({description:"Add attachment to AI assistant",method:h.PATCH,url:`/document-attachments/${s}/`,payload:{readable_to_assistant:!0},blockers:["index-document-attachment",s],blocks:["index-document-attachment"]})}async refreshStore(s,i){const c=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:`/projects/${s}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(Td(c));const n=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:`/organizations/${i}/document-attachments/`,blocks:[],blockers:[]});return this.dispatch(this.addAttachments(n)),[...c,...n]}}class FF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(zd([n]));const r=this.enqueueRequest({description:"Create Document",method:h.POST,url:"/documents/",payload:M(n),queryParams:{parent_document:n.parent_document??void 0},blockers:n.parent_document?[n.parent_document]:[],blocks:[n.uuid]});return r.catch(()=>{this.dispatch(Ra([n.uuid]))}),[n,r]}update(e){const{store:s}=this.client,i=s.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(De([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(()=>{De([i])}),[c,n]}move(e,s,i){const{store:c}=this.client,n=He(c.getState()),r=[],o=n[e];if(!o)throw new Error(`attempting to move a document with uuid ${e} that does not exist in store.documents`);if(r.push(o),o.parent_document&&r.push(n[o.parent_document]),s){const d=n[s];if(!d)throw new Error(`attempting to move a document to target with uuid ${s} that does not exist in store.documents`);r.push(d),d.parent_document&&r.push(n[d.parent_document])}this.dispatch(Dd({documentId:e,targetDocumentId:s,position:i}));const m=this.enqueueRequest({description:"Move Document",method:h.PATCH,url:`/documents/${e}/move/`,queryParams:{target:s??void 0,position:i},blockers:[e],blocks:[]});return m.then(d=>{this.dispatch(De(d))}).catch(()=>{this.dispatch(De(r))}),m}delete(e){const{store:s}=this.client,i=He(s.getState()),c=Ud(e)(s.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(Ra([e]));const r=this.enqueueRequest({description:"Delete Document",method:h.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return r.then(o=>{this.dispatch(De(o))}).catch(()=>{this.dispatch(De([c])),n&&this.dispatch(De([n]))}),r}async refreshStore(e,s){const i=this.enqueueRequest({description:"Get project documents",method:h.GET,url:`/projects/${e}/documents/`,blockers:[],blocks:[]}),c=this.enqueueRequest({description:"Get organization documents",method:h.GET,url:`/organizations/${s}/documents/`,blockers:[],blocks:[]}),n=[...await i,...await c];return this.dispatch(Vd(n)),n}}class PF extends R{async add(e,s){return this.enqueueRequest({description:"Add email domain to organization",method:h.POST,url:"/organization-email-domains/",payload:{email:s,organization:e},blockers:[e,"create-org"],blocks:[]})}async remove(e){return this.dispatch(Ld(e.uuid)),this.enqueueRequest({description:"Remove email domain from organization",method:h.DELETE,url:`/organization-email-domains/${e.uuid}/`,blockers:[e.domain],blocks:[]}).catch(s=>{throw this.dispatch(Gd(e)),s})}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch email domains for organization",method:h.GET,url:"/organization-email-domains/",queryParams:{organization:e},blockers:[e],blocks:[]});return this.dispatch($d(s)),s}}class bF extends R{async getVerificationCode(e){return this.enqueueRequest({description:"Get verification code",method:h.GET,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}validateVerificationCode(e,s=void 0){return this.enqueueRequest({description:"Validate verification code",method:h.POST,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,payload:s,blockers:[],blocks:[]})}}const $t={},sc=new Set;let Gt=0,ac=0,ic=0;const TF=20;class IF extends R{constructor(){super(...arguments);f(this,"host");f(this,"_dbPromise",im.openDB("fileCache",1,{upgrade(s){s.createObjectStore("files")}}))}async renewUploadUrl(s){const i=await this.fetchCache(s);if(!i)throw new Error(`File with sha1 ${s} not found in cache`);const c=await Yt(i,s),n=await this.enqueueRequest({description:"Get S3 URL",method:h.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await Ne(i),file_type:i.type,extension:i.name.split(".").pop(),size:i.size.toString()},blockers:[],blocks:[`s3-${c}`]});return"url"in n&&this.dispatch(Jd({sha1:s,...n})),n}async addCache(s,i){if(sc.has(i))return;if(!s.type){const r=s.name.split("."),o=r[r.length-1];s=new File([s],s.name,{type:o})}if(!s.name||!s.size||!s.type)throw new Error("Cannot add files to cache that do not have a name, size and type.");const c=await this._dbPromise;!!await c.get("files",i)?(console.error("File already cached (this is unexpected at this point):",s.name,i),Gt++):(await c.put("files",s,i),ac++),sc.add(i),ic++,ic%TF===0&&console.debug(`File cache summary: ${Gt} hits and ${ac} misses, ${Gt/(Gt+ac)*100}% hit rate over ${ic} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),sc.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const i=this.client.store.getState();return Zd(s)(i)??await this.renewUploadUrl(s)}async uploadFileToS3(s){const i=await this.fetchCache(s);if(!i)throw new Error(`File with sha1 ${s} not found in cache`);const c=await Yt(i,s),n={file_name:i.name,file_sha1:s,file:c},r=await this.getOrRenewUploadUrl(s);if("warning"in r){if(r.warning==="already_uploaded")return[n,Promise.resolve(void 0).then()];throw new Error(r.warning)}const o=r.url,m=this.enqueueRequest({url:o,description:"Upload file",method:h.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:s,blockers:[`s3-${c}`],blocks:[s],s3url:r});return[n,m]}async fetchFileFromUrl(s,i,c){const n=s.split("?")[0]??s,r=await this.fetchCache(i);if(r){if(!r.name)throw new Error("Cached file unexpectedly has no name.");return r}if(s.startsWith("blob:")){const l=await pc(s),p=new File([l],c??i,{type:l.type});return await this.addCache(p,i),p}let o=$t[n],m=!0;o?m=!1:(o=new Promise(l=>{this.enqueueRequest({description:"Download file",method:h.GET,url:s,isExternalUrl:!0,isResponseBlob:!0,isAuthNeeded:!1,blockers:[i],blocks:[i]}).then(p=>{const A=new File([p],c??i,{type:p.type});l(A)})}),$t[n]=o);let d;try{d=await o}catch(l){throw m&&l instanceof D&&delete $t[n],l}if(m){const l=await Ne(d);if(l!==i){const y=`The hash of the file returned from the server (${l}) does not match the
|
|
8
|
+
`)}catch(c){console.error("Failed to extract error message from response body",c)}}else typeof t.body=="string"&&(s=t.body);else t!=null&&t.text?s=t.text:e instanceof Error&&(s=e.message);return!s||s.length>Wg?Ze:s}class D extends Error{constructor(s){super(Ze);f(this,"status");f(this,"response");f(this,"message");f(this,"options");const{response:i,innerError:c}=s;this.message=s.message??Kg(i,c)??Ze,this.status=(i==null?void 0:i.status)??0,this.response=i,s.discard=s.discard??!1,this.options=s}}class Yg extends Gh{constructor(e){super(e)}}class R extends Gh{constructor(s,i){super(s);f(this,"auth");this.auth=i}}class Jg extends R{async startConversation(e,s){return this.enqueueRequest({description:"Start agent conversation",method:h.POST,url:"/agents/prompt/",payload:{prompt:e,active_project:s},blockers:["prompt"],blocks:["prompt"]}).then(i=>(this.dispatch(Pc(i)),i))}async continueConversation(e,s,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:s}}).then(c=>{this.dispatch(Tc(c))})}async fetchDetails(e){return this.enqueueRequest({description:"Get agent conversation",method:h.GET,url:`/agents/conversations/${e}/`,blockers:["conversation"],blocks:["conversation"]}).then(s=>{this.dispatch(bc(s))})}async rate(e,s){return this.enqueueRequest({description:"Rate agent response",method:h.PUT,url:`/agents/responses/${e}/rate/`,payload:{rating:s},blockers:["rate"],blocks:["rate"]})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get agent conversation history",method:h.GET,url:"/agents/conversations/",queryParams:{project:e},blockers:["agent-conversations"],blocks:["agent-conversations"]});return this.dispatch(Fc(s)),s}}class j extends R{getNumberOfAttachmentsWithSha1(e){const{issueAttachmentReducer:s,assetAttachmentReducer:i,assetTypeAttachmentReducer:c,documentAttachmentReducer:n,projectAttachmentReducer:r,formRevisionAttachmentReducer:o,formSubmissionAttachmentReducer:m,geoImageReducer:d,assetTypeFieldsAttachmentReducer:l,assetTypeFieldValuesAttachmentReducer:p,issueTypeFieldsAttachmentReducer:A,issueTypeFieldValuesAttachmentReducer:y}=this.client.store.getState();return[].concat(Object.values(s.instances),Object.values(i.instances),Object.values(c.instances),Object.values(n.instances),Object.values(r.instances),Object.values(o.instances),Object.values(m.instances),Object.values(d.instances),Object.values(l.instances),Object.values(p.instances),Object.values(A.instances),Object.values(y.instances)).filter(P=>P.file_sha1===e).length}processPresignedUrls(e){const s={};for(const[i,c]of Object.entries(e))s[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 s}async getFilePayload(e){const s=await Ne(e),i={sha1:s,file_type:e.type,extension:e.name.split(".").pop(),size:e.size};return await this.client.files.addCache(e,s),i}}class Ce extends j{async _bulkAdd(e){var d;const{store:s}=this.client,i=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,c=new Date().toISOString(),n=[],r=[],o={};for(const l of e){const{modelUuid:p,file:A}=l,y=await this.getFilePayload(A);y.sha1 in o||(o[y.sha1]=y);const F=this.buildOfflineAttachment({file:A,file_sha1:y.sha1,submitted_at:c,created_by:i,description:"",modelUuid:p});n.push(F),r.push(this.buildAttachmentPayload({uuid:F.uuid,file_name:F.file_name,file_sha1:F.file_sha1,file_extension:y.extension,description:F.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(o)},blocks:n.map(l=>l.uuid),blockers:n.map(l=>l.file_sha1)});return m.then(({attachments:l,presigned_urls:p})=>{this.dispatch(this.updateAttachments(l)),this.processPresignedUrls(p)}).catch(()=>{this.dispatch(this.removeAttachments(n.map(l=>l.uuid)))}),[n,m.then(({attachments:l})=>l)]}async _delete(e){const{store:s}=this.client,i=this.selectAttachment(e)(s.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 Zg extends Ce{constructor(){super(...arguments);f(this,"name","Asset Attachment");f(this,"url","/asset-attachments");f(this,"initializeAttachments",Qt);f(this,"addAttachments",xt);f(this,"updateAttachments",Rc);f(this,"removeAttachments",es);f(this,"removeAttachment",vc);f(this,"setAttachment",Oc);f(this,"selectAttachment",Ec)}buildOfflineAttachment(s){return T({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset:s.modelUuid})}buildAttachmentPayload(s){return{...s,asset:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(i=>({modelUuid:i.assetUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get asset attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset__project:s},blocks:[],blockers:[]});return this.dispatch(Qt(i)),i}}class Xg extends Ce{constructor(){super(...arguments);f(this,"name","Asset Procedure Attachment");f(this,"url","/asset-procedure-attachments");f(this,"addAttachments",Dc);f(this,"updateAttachments",Uc);f(this,"removeAttachments",Bc);f(this,"removeAttachment",kc);f(this,"setAttachment",Cc);f(this,"selectAttachment",Lc)}buildOfflineAttachment(s){return T({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset_procedure:s.modelUuid})}buildAttachmentPayload(s){return{...s,asset_procedure:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(i=>({modelUuid:i.assetProcedureUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get asset procedure attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset_procedure__organization:s},blocks:[],blockers:[]});return this.dispatch(zc(i)),i}}class Qg extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const d of e){const{fieldsRevisionUuid:l,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const F=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:l,submitted_at:s,field_identifier:p});n.push(F);const P={uuid:F.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:l};r.push(P)}this.dispatch(Kc(n));const o=this.enqueueRequest({description:"Add asset procedure fields attachments",method:h.POST,url:"/asset-procedure-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(c)},blockers:n.map(d=>d.fields_revision),blocks:n.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(Yc(d.attachments))}).catch(()=>{this.dispatch(Jc(n.map(d=>d.uuid)))}),[n,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=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:[]});return this.dispatch(Wc(s)),s}}class xg extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(tn(n));const r=this.enqueueRequest({description:"Add Asset Procedure Fields",method:h.POST,url:"/asset-procedure-fields/",payload:n,blockers:[n.asset_procedure],blocks:[n.uuid]});return r.then(m=>{this.dispatch(sn(m))}).catch(m=>{throw this.dispatch(an(n.uuid)),m}),[n,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Procedure Fields",method:h.GET,url:"/asset-procedure-fields/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(en(s)),s}}function ke(t,e){const s=[];let i=0;const c=t.length;for(;i<c;)s.push(t.slice(i,i+=e));return s}class eF extends j{async bulkAdd(e,s){var d;const i=new Date().toISOString(),c=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,n=ke(e,s??e.length),r=[],o=[];for(const l of n){const p={},A=[];for(const y of l){const{fieldValuesUuid:F,fieldIdentifier:P,file:I}=y,v=await this.getFilePayload(I);v.sha1 in p||(p[v.sha1]=v);const q=T({file:URL.createObjectURL(I),file_type:I.type,file_name:I.name,file_sha1:v.sha1,created_by:c,field_values:F,submitted_at:i,field_identifier:P});r.push(q);const Qe={uuid:q.uuid,file_name:I.name,file_sha1:v.sha1,file_extension:v.extension,field_identifier:P,field_values:F};A.push(Qe)}o.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(yt(r));const m=o.map(l=>this.enqueueRequest({description:"Add asset procedure field values attachments",method:h.POST,url:"/asset-procedure-field-values-attachments/bulk/",payload:l,blockers:l.attachments.map(p=>p.field_values),blocks:l.attachments.map(p=>p.uuid)}));return Promise.all(m).then(l=>{for(const A of l)this.processPresignedUrls(A.presigned_urls);const p=l.flatMap(A=>A.attachments);this.dispatch(un(p))}).catch(l=>{throw this.dispatch(ft(r.map(p=>p.uuid))),l}),[r,m.map(l=>l.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=ln(e)(i);this.dispatch(ft(e));try{await this.enqueueRequest({description:"Delete asset procedure field values attachments",method:h.DELETE,url:"/asset-procedure-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(yt(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values attachments",method:h.GET,url:"/asset-procedure-field-values-attachments/",queryParams:{field_values__asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(dn(s)),s}}class tF extends R{add(e){var r;const{store:s}=this.client,i=s.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:M(c),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[c.uuid]});return this.dispatch(ds(c)),n.then(o=>(this.dispatch(et(o)),o)).catch(()=>{this.dispatch(us(c.uuid))}),[c,n]}bulkAdd(e,s){var m;const i=new Date().toISOString(),c=[],n=ke(e.payloads,s??e.payloads.length),r=[];for(const d of n){const l=[];for(const p of d){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),l.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:l})}this.dispatch(yn(c));const o=[];for(const d of r){const l=d.field_values.map(P=>P.asset),p=d.field_values.map(P=>P.fields_revision),A=d.field_values.map(P=>P.asset_procedure_instance),y=d.field_values.map(P=>P.uuid),F=this.enqueueRequest({description:"Bulk add asset procedure field values",method:h.POST,url:"/asset-procedure-field-values/bulk/",payload:d,blockers:[...l,...p,...A],blocks:y});o.push(F)}return Promise.all(o).then(d=>{this.dispatch(fn(d.flat()))}).catch(()=>{this.dispatch(Sn(c.map(d=>d.uuid)))}),[c,o]}update(e){const{store:s}=this.client,i=s.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(et(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(o=>{this.dispatch(et(o))}).catch(()=>{this.dispatch(et(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=ls(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=hn(e)(i);this.dispatch(us(e)),this.dispatch(ft(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(yt(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure field values",method:h.GET,url:"/asset-procedure-field-values/",queryParams:{asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(An(s)),s}}class sF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.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:M(n),blockers:[e.asset_procedure,e.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(tt(m))}).catch(()=>{this.dispatch(ps(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=fs(e.uuid)(s.getState());if(!i)throw new Error(`Expected asset procedure instance with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(tt(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(tt(r))}).catch(()=>{this.dispatch(tt(i))}),[c,n]}async remove(e){const{store:s}=this.client,i=s.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){const s=await this.enqueueRequest({description:"Get asset procedure instances",method:h.GET,url:"/asset-procedure-instances/",queryParams:{project:e},blockers:[],blocks:[]});return this.dispatch(bn(s)),s}}class aF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.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:M(n),blockers:[],blocks:[n.uuid]});return r.then(m=>{this.dispatch(st(m))}).catch(()=>{this.dispatch(Fs(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=bs(e.uuid)(s.getState());if(!i)throw new Error(`Expected asset procedure with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(st(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(st(r))}).catch(()=>{this.dispatch(st(i))}),[c,n]}async remove(e){const{store:s}=this.client,i=s.getState(),c=bs(e)(i);if(!c)throw new Error(`Expected asset procedure with uuid ${e} to exist`);const n=_n(e)(i);return this.dispatch(Fs(e)),this.dispatch(In(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(Tn(n)),r})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedures",method:h.GET,url:"/asset-procedures/",queryParams:{organization:e},blockers:[],blocks:[]});return this.dispatch(vn(s)),s}}class iF extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const d of e){const{fieldsRevisionUuid:l,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const F=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:l,submitted_at:s,field_identifier:p});n.push(F);const P={uuid:F.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:l};r.push(P)}this.dispatch(qn(n));const o=this.enqueueRequest({description:"Add asset procedure step fields attachments",method:h.POST,url:"/asset-procedure-step-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(c)},blockers:n.map(d=>d.fields_revision),blocks:n.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(Vn(d.attachments))}).catch(()=>{this.dispatch(zn(n.map(d=>d.uuid)))}),[n,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=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:[]});return this.dispatch(jn(s)),s}}class cF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(_s(n));const r=this.enqueueRequest({description:"Add Asset Procedure Step Fields",method:h.POST,url:"/asset-procedure-step-fields/",payload:n,blockers:[n.asset_procedure_step],blocks:[n.uuid]});return r.then(m=>{this.dispatch(at(m))}).catch(m=>{throw this.dispatch(Os(n.uuid)),m}),[n,r]}update(e){const{store:s}=this.client,i=s.getState().assetProcedureStepFieldsReducer.instances[e.uuid];if(!i)throw new Error(`AssetProcedureStepFields with uuid ${e.uuid} not found`);const c={...i,...e};this.dispatch(at(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(at(r))}).catch(r=>{throw this.dispatch(at(i)),r}),[c,n]}delete(e){const{store:s}=this.client,i=s.getState().assetProcedureStepFieldsReducer.instances[e];if(!i)throw new Error(`AssetProcedureStepFields with uuid ${e} not found`);this.dispatch(Os(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(_s(i)),n}),c}async refreshStore(e){const s=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:[]});return this.dispatch(Bn(s)),s}}class nF extends j{async bulkAdd(e,s){var d;const i=new Date().toISOString(),c=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,n=ke(e,s??e.length),r=[],o=[];for(const l of n){const p={},A=[];for(const y of l){const{fieldValuesUuid:F,fieldIdentifier:P,file:I}=y,v=await this.getFilePayload(I);v.sha1 in p||(p[v.sha1]=v);const q=T({file:URL.createObjectURL(I),file_type:I.type,file_name:I.name,file_sha1:v.sha1,created_by:c,field_values:F,submitted_at:i,field_identifier:P});r.push(q);const Qe={uuid:q.uuid,file_name:I.name,file_sha1:v.sha1,file_extension:v.extension,field_identifier:P,field_values:F};A.push(Qe)}o.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(St(r));const m=o.map(l=>this.enqueueRequest({description:"Add asset procedure step field values attachments",method:h.POST,url:"/asset-procedure-step-field-values-attachments/bulk/",payload:l,blockers:l.attachments.map(p=>p.field_values),blocks:l.attachments.map(p=>p.uuid)}));return Promise.all(m).then(l=>{for(const A of l)this.processPresignedUrls(A.presigned_urls);const p=l.flatMap(A=>A.attachments);this.dispatch(Nn(p))}).catch(l=>{throw this.dispatch(gt(r.map(p=>p.uuid))),l}),[r,m.map(l=>l.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=Wn(e)(i);this.dispatch(gt(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:{attachment_ids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(St(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure step field values attachments",method:h.GET,url:"/asset-procedure-step-field-values-attachments/",queryParams:{field_values__asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(Ln(s)),s}}class rF extends R{add(e){var r;const{store:s}=this.client,i=s.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:M(c),blockers:[e.asset,e.fields_revision,e.asset_procedure_instance],blocks:[c.uuid]});return this.dispatch(js(c)),n.then(o=>(this.dispatch(it(o)),o)).catch(()=>{this.dispatch(qs(c.uuid))}),[c,n]}bulkAdd(e,s){var m;const i=new Date().toISOString(),c=[],n=ke(e.payloads,s??e.payloads.length),r=[];for(const d of n){const l=[];for(const p of d){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),l.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:l})}this.dispatch(Xn(c));const o=[];for(const d of r){const l=d.field_values.map(P=>P.asset),p=d.field_values.map(P=>P.fields_revision),A=d.field_values.map(P=>P.asset_procedure_instance),y=d.field_values.map(P=>P.uuid),F=this.enqueueRequest({description:"Bulk add asset procedure step field values",method:h.POST,url:"/asset-procedure-step-field-values/bulk/",payload:d,blockers:[...l,...p,...A],blocks:y});o.push(F)}return Promise.all(o).then(d=>{this.dispatch(Qn(d.flat()))}).catch(()=>{this.dispatch(xn(c.map(d=>d.uuid)))}),[c,o]}update(e){const{store:s}=this.client,i=s.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(it(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(o=>{this.dispatch(it(o))}).catch(()=>{this.dispatch(it(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Vs(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=Kn(e)(i);this.dispatch(qs(e)),this.dispatch(gt(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(St(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure step field values",method:h.GET,url:"/asset-procedure-step-field-values/",queryParams:{asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(Zn(s)),s}}class dF extends R{bulkAdd(e,s){var m;const i=new Date().toISOString(),c=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,n=e.map(d=>T(d)),r=n.map(d=>({...d,asset_procedure:s,created_by:c,submitted_at:i}));this.dispatch(Ds(r));const o=this.enqueueRequest({description:"Add asset procedure steps",method:h.POST,url:"/asset-procedure-steps/bulk/",payload:{submitted_at:i,asset_procedure:s,steps:n},blockers:[s],blocks:n.map(({uuid:d})=>d)});return o.then(d=>{this.dispatch(Pt(d))}).catch(()=>{this.dispatch(Us(r.map(({uuid:d})=>d)))}),[r,o]}async bulkUpdate(e,s){const c=this.client.store.getState(),n=ks(e.map(({uuid:r})=>r))(c);return this.dispatch(Pt(e)),this.enqueueRequest({description:"Edit asset procedure steps",method:h.PATCH,url:`/asset-procedures/${s}/bulk-update-steps/`,payload:{steps:e},blockers:[s],blocks:e.map(({uuid:r})=>r)}).catch(r=>{throw this.dispatch(Pt(n)),r})}async bulkDelete(e){const{store:s}=this.client,i=ks(e)(s.getState());this.dispatch(Us(e));const c=this.enqueueRequest({description:"Delete asset procedure steps",method:h.DELETE,url:"/asset-procedure-steps/bulk/",payload:{step_ids:e},blockers:e,blocks:[]});return c.catch(()=>{this.dispatch(Ds(i))}),c}update(e){const{store:s}=this.client,i=nr(e.uuid)(s.getState());if(!i)throw new Error(`No asset procedure step with uuid ${e.uuid} found in the store`);const c={...i,...e};this.dispatch(Cs(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(Cs(r))}).catch(()=>{this.dispatch(ir(i))}),[c,n]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset procedure steps",method:h.GET,url:"/asset-procedure-steps/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(ar(s)),s}}class uF extends R{add(e){var o;const{store:s}=this.client;if(!e.canvas_marker&&!e.geo_marker)throw new Error("Asset must have either a canvas_marker or geo_marker");const i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch($s(n));const r=this.enqueueRequest({description:"Create asset",method:h.POST,url:"/assets/",payload:M(n),blockers:[n.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(ct(m))}).catch(()=>{this.dispatch(Gs(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=Ws(e.uuid)(s.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(ct(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(ct(r))}).catch(()=>{this.dispatch(ct(i))}),[c,n]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Ws(e)(i);if(!c)throw new Error(`No asset with uuid ${e} found in the store`);const n=jc(e)(i),r=wu(e)(i),o=Ku(e)(i);if(this.dispatch(Gs(e)),n.length>0){const m=n.map(({uuid:d})=>d);this.dispatch(es(m))}if(r.length>0){const m=r.map(({uuid:d})=>d);this.dispatch(zt(m))}if(o.length>0){const m=o.map(({uuid:d})=>d);this.dispatch(Qa(m))}return this.enqueueRequest({description:"Delete asset",method:h.DELETE,url:`/assets/${e}/`,blockers:[e],blocks:[]}).catch(m=>{throw this.dispatch($s(c)),this.dispatch(xt(n)),this.dispatch(Vt(r)),this.dispatch(Za(o)),m})}bulkAdd(e,s,i,c){const n=new Date().toISOString(),r=Ge.v4(),o=ke(e,c).map(l=>{const p=l.map(A=>T(A));return{batchId:Ge.v4(),payload:{transaction_id:r,submitted_at:n,asset_type:s,project:i,assets:p}}}),m=[];let d=null;for(const l of o){const{batchId:p,payload:A}=l,y=A.assets.map(v=>v.uuid),F=[s];d&&F.push(d);const P=y;P.push(p);const I=this.enqueueRequest({description:"Batch create assets",method:h.POST,url:"/assets/bulk/",payload:A,blockers:F,blocks:P});d=l.batchId,m.push(I)}return Promise.all(m).then(l=>{const p=l.flat();this.dispatch(Tt(p))}),m}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=lr(e)(i);this.dispatch(Ls(e));try{await this.enqueueRequest({description:"Bulk delete assets",method:h.DELETE,url:"/assets/bulk/",payload:{asset_ids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(Tt(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get assets",method:h.GET,url:"/assets/",queryParams:{project:e},blockers:[],blocks:[]});return this.dispatch(ur(s)),s}}class oF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.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:M(n),blockers:[e.asset,e.stage],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Ar(m))}).catch(()=>{this.dispatch(Zs(n.uuid))}),[n,r]}delete(e){const{store:s}=this.client,i=Sr(e)(s.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 d;const{store:s}=this.client,i=new Date().toISOString(),c=(d=s.getState().userReducer.currentUser)==null?void 0:d.id,n=e.map(l=>T(l)),r=n.map(l=>({...l,created_by:c,submitted_at:i})),o=r.map(({uuid:l})=>l);this.dispatch(Js(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(l=>l.asset_procedure_instance),...e.map(l=>l.stage),...e.map(l=>l.asset)],blocks:o});return m.then(l=>{this.dispatch(yr(l))}).catch(()=>{this.dispatch(Xs(o))}),[r,m]}bulkDelete(e){const{store:s}=this.client,i=gr(e)(s.getState());this.dispatch(Xs(e));const c=this.enqueueRequest({description:"Deleting asset stage completions",method:h.DELETE,url:"/asset-stage-completions/bulk/",payload:{completion_ids:e},blockers:e,blocks:[]});return c.catch(()=>{this.dispatch(Js(i))}),c}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stage completions",method:h.GET,url:"/asset-stage-completions/",queryParams:{asset_procedure_instance__project:e},blockers:[],blocks:[]});return this.dispatch(pr(s)),s}}class lF extends R{bulkAdd(e,s){var m;const i=new Date().toISOString(),c=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,n=e.map(d=>T(d)),r=n.map(d=>({...d,asset_procedure:s,created_by:c,submitted_at:i}));this.dispatch(ea(r));const o=this.enqueueRequest({description:"Add asset stages",method:h.POST,url:"/asset-stages/bulk/",payload:{submitted_at:i,asset_procedure:s,stages:n},blockers:[s],blocks:n.map(({uuid:d})=>d)});return o.then(d=>{this.dispatch(It(d))}).catch(()=>{this.dispatch(sa(r.map(({uuid:d})=>d)))}),[r,o]}async bulkUpdate(e,s){const c=this.client.store.getState(),n=aa(e.map(({uuid:r})=>r))(c);return this.dispatch(It(e)),this.enqueueRequest({description:"Edit asset stages",method:h.PATCH,url:`/asset-procedures/${s}/bulk-update-stages/`,payload:{stages:e},blockers:[s],blocks:e.map(({uuid:r})=>r)}).catch(r=>{throw this.dispatch(It(n)),r})}async bulkDelete(e){const{store:s}=this.client,i=aa(e)(s.getState());this.dispatch(sa(e));const c=this.enqueueRequest({description:"Delete asset stages",method:h.DELETE,url:"/asset-stages/bulk/",payload:{stage_ids:e},blockers:e,blocks:[]});return c.catch(()=>{this.dispatch(ea(i))}),c}update(e){const{store:s}=this.client,i=Ir(e.uuid)(s.getState());if(!i)throw new Error(`No asset stage with uuid ${e.uuid} found in the store`);const c={...i,...e};this.dispatch(ta(c));const n=this.enqueueRequest({description:"Update asset stage",method:h.PATCH,url:`/asset-stages/${i.uuid}/`,payload:{name:e.name,description:e.description,priority:e.priority,color:e.color},blockers:[i.uuid],blocks:[i.uuid]});return n.then(r=>{this.dispatch(ta(r))}).catch(()=>{this.dispatch(br(i))}),[c,n]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset stages",method:h.GET,url:"/asset-stages/",queryParams:{asset_procedure__organization:e},blockers:[],blocks:[]});return this.dispatch(Pr(s)),s}}class hF extends Ce{constructor(){super(...arguments);f(this,"name","Asset Type Attachment");f(this,"url","/asset-type-attachments");f(this,"addAttachments",ca);f(this,"updateAttachments",wr);f(this,"removeAttachments",na);f(this,"removeAttachment",Mr);f(this,"setAttachment",vr);f(this,"selectAttachment",qr)}buildOfflineAttachment(s){return T({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,asset_type:s.modelUuid})}buildAttachmentPayload(s){return{...s,asset_type:s.modelUuid}}async bulkAdd(s){return this._bulkAdd(s.map(i=>({modelUuid:i.assetTypeUuid,file:i.file})))}async delete(s){return this._delete(s)}async refreshStore(s){const i=await this.enqueueRequest({description:"Get asset type attachments",method:h.GET,url:`${this.url}/`,queryParams:{asset_type__organization:s},blocks:[],blockers:[]});return this.dispatch(Rr(i)),i}}class mF extends j{async bulkAdd(e){var m;const s=new Date().toISOString(),i=(m=this.client.store.getState().userReducer.currentUser)==null?void 0:m.id,c={},n=[],r=[];for(const d of e){const{fieldsRevisionUuid:l,fieldIdentifier:p,file:A}=d,y=await this.getFilePayload(A);y.sha1 in c||(c[y.sha1]=y);const F=T({file:URL.createObjectURL(A),file_type:A.type,file_name:A.name,file_sha1:y.sha1,created_by:i,fields_revision:l,submitted_at:s,field_identifier:p});n.push(F);const P={uuid:F.uuid,file_name:A.name,field_identifier:p,file_extension:y.extension,file_sha1:y.sha1,fields_revision:l};r.push(P)}this.dispatch(Ur(n));const o=this.enqueueRequest({description:"Add asset type fields attachments",method:h.POST,url:"/asset-type-fields-attachments/bulk/",payload:{submitted_at:s,attachments:r,files:Object.values(c)},blockers:n.map(d=>d.fields_revision),blocks:n.map(d=>d.uuid)});return o.then(d=>{this.processPresignedUrls(d.presigned_urls),this.dispatch(kr(d.attachments))}).catch(()=>{this.dispatch(Br(n.map(d=>d.uuid)))}),[n,o.then(({attachments:d})=>d)]}async refreshStore(e){const s=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:[]});return this.dispatch(Cr(s)),s}}class pF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(Wr(n));const r=this.enqueueRequest({description:"Add Asset Type Fields",method:h.POST,url:"/asset-type-fields/",payload:n,blockers:[n.asset_type],blocks:[n.uuid]});return r.then(m=>{this.dispatch(Kr(m))}).catch(m=>{throw this.dispatch(Yr(n.uuid)),m}),[n,r]}async refreshStore(e){const s=await this.enqueueRequest({description:"Get Asset Type Fields",method:h.GET,url:"/asset-type-fields/",queryParams:{asset_type__organization:e},blockers:[],blocks:[]});return this.dispatch(Hr(s)),s}}class AF extends j{async bulkAdd(e,s){var d;const i=new Date().toISOString(),c=(d=this.client.store.getState().userReducer.currentUser)==null?void 0:d.id,n=ke(e,s??e.length),r=[],o=[];for(const l of n){const p={},A=[];for(const y of l){const{fieldValuesUuid:F,fieldIdentifier:P,file:I}=y,v=await this.getFilePayload(I);v.sha1 in p||(p[v.sha1]=v);const q=T({file:URL.createObjectURL(I),file_type:I.type,file_name:I.name,file_sha1:v.sha1,created_by:c,field_values:F,submitted_at:i,field_identifier:P});r.push(q);const Qe={uuid:q.uuid,file_name:I.name,file_sha1:v.sha1,file_extension:v.extension,field_identifier:P,field_values:F};A.push(Qe)}o.push({submitted_at:i,attachments:A,files:Object.values(p)})}this.dispatch(Rt(r));const m=o.map(l=>this.enqueueRequest({description:"Add asset type field values attachments",method:h.POST,url:"/asset-type-field-values-attachments/bulk/",payload:l,blockers:l.attachments.map(p=>p.field_values),blocks:l.attachments.map(p=>p.uuid)}));return Promise.all(m).then(l=>{for(const A of l)this.processPresignedUrls(A.presigned_urls);const p=l.flatMap(A=>A.attachments);this.dispatch(xr(p))}).catch(l=>{throw this.dispatch(vt(r.map(p=>p.uuid))),l}),[r,m.map(l=>l.then(({attachments:p})=>p))]}async bulkDelete(e){const{store:s}=this.client,i=s.getState(),c=td(e)(i);this.dispatch(vt(e));try{await this.enqueueRequest({description:"Delete asset type field values attachments",method:h.DELETE,url:"/asset-type-field-values-attachments/bulk/",payload:{attachment_ids:e},blockers:e,blocks:[]})}catch(n){throw this.dispatch(Rt(c)),n}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values attachments",method:h.GET,url:"/asset-type-field-values-attachments/",queryParams:{field_values__asset__project:e},blockers:[],blocks:[]});return this.dispatch(Qr(s)),s}}class yF extends R{add(e){var r;const{store:s}=this.client,i=s.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:M(c),blockers:[e.asset,e.fields_revision],blocks:[c.uuid]});return this.dispatch(ha(c)),n.then(o=>(this.dispatch(nt(o)),o)).catch(()=>{this.dispatch(ma(c.uuid))}),[c,n]}bulkAdd(e,s){var m;const i=new Date().toISOString(),c=[],n=ke(e.payloads,s??e.payloads.length),r=[];for(const d of n){const l=[];for(const p of d){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),l.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:l})}this.dispatch(nd(c));const o=[];for(const d of r){const l=d.field_values.map(F=>F.asset),p=d.field_values.map(F=>F.fields_revision),A=d.field_values.map(F=>F.uuid),y=this.enqueueRequest({description:"Bulk add asset type field values",method:h.POST,url:"/asset-type-field-values/bulk/",payload:d,blockers:[...l,...p],blocks:A});o.push(y)}return Promise.all(o).then(d=>{this.dispatch(rd(d.flat()))}).catch(()=>{this.dispatch(dd(c.map(d=>d.uuid)))}),[c,o]}update(e){const{store:s}=this.client,i=s.getState(),c=Aa(e.uuid)(i);if(!c)throw new Error(`Expected AssetTypeFieldValues with uuid ${e.uuid} to exist`);const n={...c,...e};this.dispatch(nt(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(o=>{this.dispatch(nt(o))}).catch(()=>{this.dispatch(nt(c))}),[n,r]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Aa(e)(i);if(!c)throw new Error(`Expected submission with uuid ${e} to exist`);const n=sd(e)(i);this.dispatch(ma(e)),this.dispatch(vt(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(ha(c)),this.dispatch(Rt(n)),r}}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset type field values",method:h.GET,url:"/asset-type-field-values/",queryParams:{asset__project:e},blockers:[],blocks:[]});return this.dispatch(cd(s)),s}}class fF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(fa(n));const r=this.enqueueRequest({description:"Create asset type",method:h.POST,url:"/asset-types/",payload:M(n),blockers:[],blocks:[n.uuid]});return r.then(m=>{this.dispatch(rt(m))}).catch(()=>{this.dispatch(Sa(n.uuid))}),[n,r]}update(e){const{store:s}=this.client,i=Fa(e.uuid)(s.getState());if(!i)throw new Error(`Expected asset type with uuid ${e.uuid} to exist`);const c={...i,...e};this.dispatch(rt(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(rt(r))}).catch(()=>{this.dispatch(rt(i))}),[c,n]}async delete(e){const{store:s}=this.client,i=s.getState(),c=Fa(e)(i);if(!c)throw new Error(`Expected asset type with uuid ${e} to exist`);const n=Hs(e)(i),r=Vr(e)(i);return this.dispatch(Sa(e)),this.dispatch(Ls(n.map(o=>o.uuid))),this.dispatch(na(r.map(({uuid:o})=>o))),this.enqueueRequest({description:"Delete asset type",method:h.DELETE,url:`/asset-types/${e}/`,blockers:[e],blocks:[]}).catch(o=>{throw this.dispatch(fa(c)),this.dispatch(Tt(n)),this.dispatch(ca(r)),o})}async refreshStore(e){const s=await this.enqueueRequest({description:"Get asset types",method:h.GET,url:"/asset-types/",queryParams:{organization:e},blockers:[],blocks:[]});return this.dispatch(hd(s)),s}}class SF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.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:M(n),blockers:[e.project],blocks:[n.uuid]});return[n,r]}update(e){const s=this.client.store.getState(),i=Ia(e.uuid)(s);if(!i)throw new Error(`Expected an existing category with uuid ${e.uuid}`);const c={...i,...e};this.dispatch(gd(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:s}=this.client,i=Ia(e)(s.getState());if(!i)throw new Error(`No category with uuid ${e} found in the store`);this.dispatch(Fd(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){const s=await this.enqueueRequest({description:"Get categories",method:h.GET,url:"/categories/",queryParams:{project__organization_owner:e},blocks:[],blockers:[]});return this.dispatch(Sd(s)),s}}class gF extends Ce{constructor(){super(...arguments);f(this,"name","Document Attachment");f(this,"url","/document-attachments");f(this,"addAttachments",Id);f(this,"updateAttachments",Od);f(this,"removeAttachments",vd);f(this,"removeAttachment",Rd);f(this,"setAttachment",_d);f(this,"selectAttachment",Ed)}buildOfflineAttachment(s){return T({file:URL.createObjectURL(s.file),file_sha1:s.file_sha1,created_by:s.created_by,file_name:s.file.name,file_type:s.file.type,submitted_at:s.submitted_at,description:s.description,document:s.modelUuid})}buildAttachmentPayload(s){return{...s,document:s.modelUuid}}async bulkAdd(s){var p;const{store:i}=this.client,c=(p=i.getState().userReducer.currentUser)==null?void 0:p.id,n=new Date().toISOString(),r=[],o=[],m={},d={};for(const A of s){const{documentUuid:y,file:F}=A,P=await this.getFilePayload(F);P.sha1 in m||(m[P.sha1]=P,d[P.sha1]=[]);const I=this.buildOfflineAttachment({file:F,file_sha1:P.sha1,submitted_at:n,created_by:c,description:"",modelUuid:y});r.push(I),o.push({uuid:I.uuid,file_name:I.file_name,file_sha1:I.file_sha1,file_extension:P.extension,description:I.description,document:y}),d[P.sha1].push(I.uuid)}this.dispatch(this.addAttachments(r));const l=this.enqueueRequest({description:"Attach files to document",method:h.POST,url:"/document-attachments/bulk/",payload:{submitted_at:n,attachments:o,files:Object.values(m)},blocks:r.map(A=>A.uuid),blockers:r.map(A=>A.file_sha1)});return l.then(({attachments:A,presigned_urls:y})=>{this.dispatch(this.updateAttachments(A));const F=this.processPresignedUrls(y);for(const[P,I]of Object.entries(F))I.then(()=>{const v=d[P];for(const q of v)this.makeReadable(q)})}).catch(()=>{this.dispatch(this.removeAttachments(r.map(A=>A.uuid)))}),[r,l.then(({attachments:A})=>A)]}async delete(s){return this._delete(s)}makeReadable(s){this.enqueueRequest({description:"Add attachment to AI assistant",method:h.PATCH,url:`/document-attachments/${s}/`,payload:{readable_to_assistant:!0},blockers:["index-document-attachment",s],blocks:["index-document-attachment"]})}async refreshStore(s,i){const c=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:`/projects/${s}/document-attachments/`,blocks:[],blockers:[]});this.dispatch(Td(c));const n=await this.enqueueRequest({description:"Get document attachments",method:h.GET,url:`/organizations/${i}/document-attachments/`,blocks:[],blockers:[]});return this.dispatch(this.addAttachments(n)),[...c,...n]}}class FF extends R{add(e){var o;const{store:s}=this.client,i=(o=s.getState().userReducer.currentUser)==null?void 0:o.id,c=new Date().toISOString(),n=T({...e,created_by:i,submitted_at:c});this.dispatch(zd([n]));const r=this.enqueueRequest({description:"Create Document",method:h.POST,url:"/documents/",payload:M(n),queryParams:{parent_document:n.parent_document??void 0},blockers:n.parent_document?[n.parent_document]:[],blocks:[n.uuid]});return r.catch(()=>{this.dispatch(Ra([n.uuid]))}),[n,r]}update(e){const{store:s}=this.client,i=s.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(De([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(()=>{De([i])}),[c,n]}move(e,s,i){const{store:c}=this.client,n=He(c.getState()),r=[],o=n[e];if(!o)throw new Error(`attempting to move a document with uuid ${e} that does not exist in store.documents`);if(r.push(o),o.parent_document&&r.push(n[o.parent_document]),s){const d=n[s];if(!d)throw new Error(`attempting to move a document to target with uuid ${s} that does not exist in store.documents`);r.push(d),d.parent_document&&r.push(n[d.parent_document])}this.dispatch(Dd({documentId:e,targetDocumentId:s,position:i}));const m=this.enqueueRequest({description:"Move Document",method:h.PATCH,url:`/documents/${e}/move/`,queryParams:{target:s??void 0,position:i},blockers:[e],blocks:[]});return m.then(d=>{this.dispatch(De(d))}).catch(()=>{this.dispatch(De(r))}),m}delete(e){const{store:s}=this.client,i=He(s.getState()),c=Ud(e)(s.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(Ra([e]));const r=this.enqueueRequest({description:"Delete Document",method:h.DELETE,url:`/documents/${e}/`,blockers:[e],blocks:[]});return r.then(o=>{this.dispatch(De(o))}).catch(()=>{this.dispatch(De([c])),n&&this.dispatch(De([n]))}),r}async refreshStore(e,s){const i=this.enqueueRequest({description:"Get project documents",method:h.GET,url:`/projects/${e}/documents/`,blockers:[],blocks:[]}),c=this.enqueueRequest({description:"Get organization documents",method:h.GET,url:`/organizations/${s}/documents/`,blockers:[],blocks:[]}),n=[...await i,...await c];return this.dispatch(Vd(n)),n}}class PF extends R{async add(e,s){return this.enqueueRequest({description:"Add email domain to organization",method:h.POST,url:"/organization-email-domains/",payload:{email:s,organization:e},blockers:[e,"create-org"],blocks:[]})}async remove(e){return this.dispatch(Ld(e.uuid)),this.enqueueRequest({description:"Remove email domain from organization",method:h.DELETE,url:`/organization-email-domains/${e.uuid}/`,blockers:[e.domain],blocks:[]}).catch(s=>{throw this.dispatch(Gd(e)),s})}async refreshStore(e){const s=await this.enqueueRequest({description:"Fetch email domains for organization",method:h.GET,url:"/organization-email-domains/",queryParams:{organization:e},blockers:[e],blocks:[]});return this.dispatch($d(s)),s}}class bF extends R{async getVerificationCode(e){return this.enqueueRequest({description:"Get verification code",method:h.GET,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,blockers:[],blocks:[]})}validateVerificationCode(e,s=void 0){return this.enqueueRequest({description:"Validate verification code",method:h.POST,url:`/verification/email-verification/${e}/`,isAuthNeeded:!1,payload:s,blockers:[],blocks:[]})}}const $t={},sc=new Set;let Gt=0,ac=0,ic=0;const TF=20;class IF extends R{constructor(){super(...arguments);f(this,"host");f(this,"_dbPromise",im.openDB("fileCache",1,{upgrade(s){s.createObjectStore("files")}}))}async renewUploadUrl(s){const i=await this.fetchCache(s);if(!i)throw new Error(`File with sha1 ${s} not found in cache`);const c=await Yt(i,s),n=await this.enqueueRequest({description:"Get S3 URL",method:h.GET,url:"/authentication/files/presigned-upload-url/",queryParams:{sha1:await Ne(i),file_type:i.type,extension:i.name.split(".").pop(),size:i.size.toString()},blockers:[],blocks:[`s3-${c}`]});return"url"in n&&this.dispatch(Jd({sha1:s,...n})),n}async addCache(s,i){if(sc.has(i))return;if(!s.type){const r=s.name.split("."),o=r[r.length-1];s=new File([s],s.name,{type:o})}if(!s.name||!s.size||!s.type)throw new Error("Cannot add files to cache that do not have a name, size and type.");const c=await this._dbPromise;!!await c.get("files",i)?(console.error("File already cached (this is unexpected at this point):",s.name,i),Gt++):(await c.put("files",s,i),ac++),sc.add(i),ic++,ic%TF===0&&console.debug(`File cache summary: ${Gt} hits and ${ac} misses, ${Gt/(Gt+ac)*100}% hit rate over ${ic} calls to addCache.`)}async removeCache(s){await(await this._dbPromise).delete("files",s),sc.delete(s)}async fetchCache(s){return(await this._dbPromise).get("files",s)}async getOrRenewUploadUrl(s){const i=this.client.store.getState();return Zd(s)(i)??await this.renewUploadUrl(s)}async uploadFileToS3(s){const i=await this.fetchCache(s);if(!i)throw new Error(`File with sha1 ${s} not found in cache`);const c=await Yt(i,s),n={file_name:i.name,file_sha1:s,file:c},r=await this.getOrRenewUploadUrl(s);if("warning"in r){if(r.warning==="already_uploaded")return[n,Promise.resolve(void 0).then()];throw new Error(r.warning)}const o=r.url,m=this.enqueueRequest({url:o,description:"Upload file",method:h.POST,isExternalUrl:!0,isAuthNeeded:!1,attachmentHash:s,blockers:[`s3-${c}`],blocks:[s],s3url:r});return[n,m]}async fetchFileFromUrl(s,i,c){const n=s.split("?")[0]??s,r=await this.fetchCache(i);if(r){if(!r.name)throw new Error("Cached file unexpectedly has no name.");return r}if(s.startsWith("blob:")){const l=await pc(s),p=new File([l],c??i,{type:l.type});return await this.addCache(p,i),p}let o=$t[n],m=!0;o?m=!1:(o=new Promise(l=>{this.enqueueRequest({description:"Download file",method:h.GET,url:s,isExternalUrl:!0,isResponseBlob:!0,isAuthNeeded:!1,blockers:[i],blocks:[i]}).then(p=>{const A=new File([p],c??i,{type:p.type});l(A)})}),$t[n]=o);let d;try{d=await o}catch(l){throw m&&l instanceof D&&delete $t[n],l}if(m){const l=await Ne(d);if(l!==i){const y=`The hash of the file returned from the server (${l}) 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
|
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.
|
|
6
|
+
"version": "1.0.78-view-sets.5",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/overmap-core.umd.cjs",
|
|
9
9
|
"module": "dist/overmap-core.js",
|