import{A as d}from"./tables-BHu5fUrG.js";import{b as a}from"./router-C-Pd0gHD.js";import"./jwt-decode.esm-CuqABuF0.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[t]="de46a10d-8ee9-42ac-93db-befa7e936e8a",o._sentryDebugIdIdentifier="sentry-dbid-de46a10d-8ee9-42ac-93db-befa7e936e8a")}catch{}})();class l extends Error{constructor(){super("Subdomain already in use")}}class h{urlPath="projects";async create({name:t,organizationId:e,folderId:r}){return a.post(`organizations/${e}/${this.urlPath}`,{name:t,folderId:r})}async delete(t){await a.delete(`/${this.urlPath}/${t}`)}async duplicate(t){return await new Promise(e=>setTimeout(e,5e3)),a.post(`/${this.urlPath}/${t}/duplicate`,{})}async getWorkflowStatistics(t){return a.get(`projects/${t}/workflow-statistics`)}async list(t){return a.get(`organizations/${t}/${this.urlPath}`)}async get(t){return a.get(`${this.urlPath}/${t}`)}async update(t,e){const r=await a.patch(`${this.urlPath}/${t}`,e);if("error"in r&&r.error==="subdomain-already-in-use")throw new l;if("error"in r)throw new Error("Unknown error");return r}async checkSubdomain(t,e){return a.get(`${this.urlPath}/${t}/check-subdomain/${e}`)}async getStatus(t){return a.get(`${this.urlPath}/${t}/deploy-status`)}async startWebEditor(t){return a.post(`${this.urlPath}/${t}/web-editor/start`,{})}async executeQuery(t,e,r){return a.post(`projects/${t}/execute`,{query:e,params:r})}async runJob(t,e){await a.post(`projects/${t}/jobs/${e}/execute`,{})}async runTasklet(t,e,r,n){await a.post(`projects/${t}/tasklets/${e}/execute`,{type:r,payload:n})}}const s=new h;class i{static formatSubdomain(t){const r=t.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,""),n=/[a-z0-9]+/g,c=r.matchAll(n);return Array.from(c).map(u=>u[0]).join("-")}record;constructor(t){this.record=d.create(s,t)}static fromDTO(t){return new i(t)}static async list(t){return(await s.list(t)).map(n=>new i(n)).sort((n,c)=>n.name.localeCompare(c.name))}static async create(t){const e=await s.create(t);return new i(e)}get folderId(){return this.record.get("folderId")}set folderId(t){this.record.set("folderId",t)}static async get(t){const e=await s.get(t);return new i(e)}static async getStatus(t){return await s.getStatus(t)}async delete(){await s.delete(this.id)}async duplicate(){const t=await s.duplicate(this.id);return new i(t)}static async executeQuery(t,e,r){return s.executeQuery(t,e,r)}async save(){return this.record.save()}resetChanges(){this.record.resetChanges()}hasChanges(t){return this.record.hasChanges(t)}get id(){return this.record.get("id")}get name(){return this.record.get("name")}set name(t){this.record.set("name",t)}get organizationId(){return this.record.get("organizationId")}get subdomain(){return this.record.get("subdomain")}set subdomain(t){this.record.set("subdomain",t)}async checkSubdomain(){return await s.checkSubdomain(this.id,this.subdomain)}static async startWebEditor(t){return await s.startWebEditor(t)}getUrl(t=""){const e=t.startsWith("/")?t.slice(1):t;return`https://${this.subdomain}.abstra.app/${e}`}}export{h as P,i as a};
//# sourceMappingURL=project-D3XwUmzI.js.map
