var h=Object.defineProperty;var r=(e,t,s)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var a=(e,t,s)=>(r(e,typeof t!="symbol"?t+"":t,s),s);import{p as i}from"./passwordlessManager.d8088db9.js";import{P as c}from"./pubsub.a0411919.js";const n={}.VITE_CLOUD_API_URL||"http://localhost:3001";class d{static async get(t){return await(await fetch(`${n}/console/${t}`,{headers:{...i.getUserHeaders("Author-Authorization")}})).json()}static async post(t,s){return await(await fetch(`${n}/console/${t}`,{method:"POST",headers:{"Content-Type":"application/json",...i.getUserHeaders("Author-Authorization")},body:JSON.stringify(s)})).json()}static async put(t,s){return await(await fetch(`${n}/console/${t}`,{method:"PUT",headers:{"Content-Type":"application/json",...i.getUserHeaders("Author-Authorization")},body:JSON.stringify(s)})).json()}static async delete(t){await fetch(`${n}/console/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json",...i.getUserHeaders("Author-Authorization")}})}}class g{constructor(t,s,o){a(this,"initialState");a(this,"changes");a(this,"api");a(this,"idKey");a(this,"pubsub");this.initialState=s,this.changes={},this.api=t,this.idKey=o,this.pubsub=new c}get(t){var s;return(s=this.changes[t])!=null?s:this.initialState[t]}set(t,s){this.changes[t]=s}async save(){Object.keys(this.changes).length!==0&&(this.initialState=await this.api.update(this.initialState[this.idKey],this.changes),this.changes={},this.pubsub.publish("update"))}hasChanges(){return Object.keys(this.changes).length>0}get state(){return{...this.initialState,...this.changes}}}export{g as A,d as C};
//# sourceMappingURL=utils.ac5c1175.js.map
