var y=Object.defineProperty;var l=(s,t,e)=>t in s?y(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var n=(s,t,e)=>(l(s,typeof t!="symbol"?t+"":t,e),e);import{A as f}from"./record.7835c07e.js";import"./outputWidgets.6d6b4a37.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]="c127f3a3-d125-4bfb-a55b-c2e60419fb80",s._sentryDebugIdIdentifier="sentry-dbid-c127f3a3-d125-4bfb-a55b-c2e60419fb80")}catch{}})();class w{async list(){return await(await fetch("/_editor/api/hooks")).json()}async create(){return await(await fetch("/_editor/api/hooks",{method:"POST",headers:{"Content-Type":"application/json"}})).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 r=e?"?remove_file=true":"",o=`/_editor/api/hooks/${t}`+r;await fetch(o,{method:"DELETE",headers:{"Content-Type":"application/json"}})}async test(t,e){const r=new URLSearchParams(e.query),o=await fetch(`/_editor/api/hooks/${t}/test?${r.toString()}`,{method:e.method,headers:{"Content-Type":"application/json",...e.headers},body:e.method==="GET"?void 0:e.body}),{status:c,headers:d,body:h,stderr:p,stdout:u}=await o.json();return{status:c,headers:d,body:h,stderr:p,stdout:u}}}const a=new w;class i{constructor(t){n(this,"record");this.record=f.create(a,t)}static async list(){return(await a.list()).map(e=>new i(e))}static async create(){const t=await a.create();return new i(t)}static async get(t){const e=await a.get(t);return new i(e)}async delete(t){await a.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 a.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{i as H};
//# sourceMappingURL=hooks.e5458cf8.js.map
