var f=Object.defineProperty;var u=(s,t,e)=>t in s?f(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 l}from"./record.fe2d13ca.js";import"./outputWidgets.e33755f8.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[t]="c0623d67-ae6f-4f7d-af7f-a4b6829619b1",s._sentryDebugIdIdentifier="sentry-dbid-c0623d67-ae6f-4f7d-af7f-a4b6829619b1")}catch{}})();class w{async list(){return await(await fetch("/_editor/api/hooks")).json()}async create(t,e){return await(await fetch("/_editor/api/hooks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t,file:e})})).json()}async get(t){return await(await fetch(`/_editor/api/hooks/${t}`)).json()}async update(t,e){return await(await fetch(`/_editor/api/hooks/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json()}async delete(t,e){const a=e?"?remove_file=true":"",i=`/_editor/api/hooks/${t}`+a;await fetch(i,{method:"DELETE",headers:{"Content-Type":"application/json"}})}async test(t,e){const a=new URLSearchParams(e.query),i=await fetch(`/_editor/api/hooks/${t}/test?${a.toString()}`,{method:e.method,headers:{"Content-Type":"application/json",...e.headers},body:e.method==="GET"?void 0:e.body}),{status:d,headers:c,body:h,stderr:p,stdout:y}=await i.json();return{status:d,headers:c,body:h,stderr:p,stdout:y}}}const r=new w;class o{constructor(t){n(this,"record");this.record=l.create(r,t)}static async list(){return(await r.list()).map(e=>new o(e))}static async create(t,e){const a=await r.create(t,e);return new o(a)}static async get(t){const e=await r.get(t);return new o(e)}async delete(t){await r.delete(this.id,t)}async duplicate(){return this}async save(){await this.record.save()}onUpdate(t){this.record.pubsub.subscribe("update",t)}hasChanges(t){return this.record.hasChanges(t)}get id(){return this.record.get("id")}get path(){return this.record.get("path")}set path(t){this.record.set("path",t)}get title(){return this.record.get("title")}set title(t){this.record.set("title",t)}get file(){return this.record.get("file")}set file(t){this.record.set("file",t)}async test(t){return r.test(this.id,t)}get position(){const[t,e]=this.record.get("workflow_position");return{x:t,y:e,referential:"world"}}get isInitial(){return this.record.get("is_initial")}}export{o as H};
//# sourceMappingURL=hooks.c8b87772.js.map
