import{D as t}from"./p-7737f905.js";class s{constructor(i,h,o=!1,e){this.beforeFetch=()=>new s(this.data,this.meta,!0,void 0),this.afterFetch=(i,h=!0)=>{var o;const e=this.data&&h?[...this.data,...t.decodeList(i.results)]:t.decodeList(i.results);let n=this.meta;return(null===(o=i.meta)||void 0===o?void 0:o.total)?n=i.meta:n||0!==i.results.length||(n={total:e.length}),new s(e,n,!1,void 0)},this.afterFetchError=t=>new s(this.data,this.meta,!1,t),this.afterUpdateItem=(t,i)=>new s(this.data?[...this.data].map((s=>s._id===t?Object.assign(Object.assign({},s),i):s)):this.data,this.meta,!1,void 0),this.isEndReached=()=>!(!this.data||!this.meta)&&this.data.length>=this.meta.total,this.data=i,this.error=e,this.isPending=o,this.meta=h}}s.init=()=>new s;export{s as L}