var c=Object.defineProperty;var d=(r,e,t)=>e in r?c(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var o=(r,e,t)=>(d(r,typeof e!="symbol"?e+"":e,t),t);import{C as s}from"./gateway.5aa82c5f.js";import{A as u}from"./activeRecord.8939db5d.js";import"./outputWidgets.b9aa154a.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="920c3e60-052b-4aae-986f-577ee6601825",r._sentryDebugIdIdentifier="sentry-dbid-920c3e60-052b-4aae-986f-577ee6601825")}catch{}})();class h extends Error{constructor(){super("Subdomain already in use")}}class l{constructor(){o(this,"urlPath","projects")}async create({name:e,organizationId:t}){return s.post(`organizations/${t}/${this.urlPath}`,{name:e})}async delete(e){await s.delete(`/${this.urlPath}/${e}`)}async list(e){return s.get(`organizations/${e}/${this.urlPath}`)}async get(e){return s.get(`${this.urlPath}/${e}`)}async update(e,t){const a=await s.patch(`${this.urlPath}/${e}`,t);if("error"in a&&a.error==="subdomain-already-in-use")throw new h;if("error"in a)throw new Error("Unknown error");return a}async duplicate(e){return s.post(`${this.urlPath}/${e}/duplicate`,{})}async checkSubdomain(e,t){return s.get(`${this.urlPath}/${e}/check-subdomain/${t}`)}}const n=new l;class i{constructor(e){o(this,"record");this.record=u.create(n,e,"id")}static async list(e){return(await n.list(e)).map(a=>new i(a))}static async create({name:e,organizationId:t}){const a=await n.create({organizationId:t,name:e});return new i(a)}static async get(e){const t=await n.get(e);return new i(t)}async delete(){await n.delete(this.id)}async save(){return this.record.save()}resetChanges(){this.record.resetChanges()}hasChanges(){return this.record.hasChanges()}get id(){return this.record.get("id")}set id(e){this.record.set("id",e)}async duplicate(){return await n.duplicate(this.id)}get name(){return this.record.get("name")}set name(e){this.record.set("name",e)}get organizationId(){return this.record.get("organizationId")}get subdomain(){return this.record.get("subdomain")}set subdomain(e){this.record.set("subdomain",e)}async checkSubdomain(){return await n.checkSubdomain(this.id,this.subdomain)}}export{i as P};
//# sourceMappingURL=project.c2b2df99.js.map
