var h=Object.defineProperty;var u=(s,t,e)=>t in s?h(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var n=(s,t,e)=>(u(s,typeof t!="symbol"?t+"":t,e),e);import{A as d,C as i}from"./utils.7963b0ba.js";class o{constructor(){n(this,"urlPath","projects")}async create({name:t,organizationId:e}){return i.post(`organizations/${e}/${this.urlPath}`,{name:t})}async delete(t){await i.delete(`/${this.urlPath}/${t}`)}async list(t){return i.get(`organizations/${t}/${this.urlPath}`)}async get(t){return i.get(`${this.urlPath}/${t}`)}async update(t,e){return i.put(`${this.urlPath}/${t}`,e)}async duplicate(t){return i.post(`${this.urlPath}/${t}/duplicate`,{})}}const a=new o;class r{constructor(t){n(this,"initialState");n(this,"changes");n(this,"record");this.record=new d(a,t,"id"),this.initialState=t,this.changes={}}static async list(t){return(await a.list(t)).map(c=>new r(c))}static async create({name:t,organizationId:e}){const c=await a.create({organizationId:e,name:t});return new r(c)}static async get(t){const e=await a.get(t);return new r(e)}async delete(){await a.delete(this.id)}async save(){Object.keys(this.changes).length!==0&&(this.initialState=await a.update(this.id,this.changes),this.changes={})}get(t){var e;return(e=this.changes[t])!=null?e:this.initialState[t]}set(t,e){this.changes[t]=e}hasChanges(){return Object.keys(this.changes).length>0}get id(){return this.record.get("id")}set id(t){this.record.set("id",t)}async duplicate(){return await a.duplicate(this.id)}get name(){return this.record.get("name")}set name(t){this.record.set("name",t)}get organizationId(){return this.record.get("organizationId")}}export{r as P};
//# sourceMappingURL=project.73d49dff.js.map
