import{E as t}from"./p-9b3f323d.js";import{a}from"./p-d6eb762b.js";import"./p-112455b1.js";import"./p-1ae2b158.js";class r{constructor(t){this.connection=t}async create(a){const r=await this.connection.post("authorization",a);return t.is(r)?r:this.load(r)}async update(t){return await this.connection.patch("authorization/",t)}async list(t,a,r,i){const s=t?["state=true"]:[];r&&s.push(`start=${r}`),i&&s.push(`end=${i}`),a&&s.push(`merchants=${a}`);const n=s.join("&");return await this.connection.get("authorization"+(n?"?"+n:""))}async get(t){return this.connection.get("authorization/"+t)}load(t){const a={..."string"==typeof t?{id:t}:t,cancel:()=>this.connection.delete("authorization/"+a.id),capture:t=>this.connection.post("authorization/"+a.id+"/capture",t),refund:t=>this.connection.post("authorization/"+a.id+"/refund",t)};return a}static open(t,i){const s=a.open(t,i);return s&&new r(s)}}export{r as Authorization}