var __assign=this&&this.__assign||function(){__assign=Object.assign||function(t){for(var n,r=1,e=arguments.length;r<e;r++){n=arguments[r];for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o))t[o]=n[o]}return t};return __assign.apply(this,arguments)};var __awaiter=this&&this.__awaiter||function(t,n,r,e){function o(t){return t instanceof r?t:new r((function(n){n(t)}))}return new(r||(r=Promise))((function(r,i){function a(t){try{c(e.next(t))}catch(t){i(t)}}function u(t){try{c(e["throw"](t))}catch(t){i(t)}}function c(t){t.done?r(t.value):o(t.value).then(a,u)}c((e=e.apply(t,n||[])).next())}))};var __generator=this&&this.__generator||function(t,n){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},e,o,i,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(t){return function(n){return c([t,n])}}function c(a){if(e)throw new TypeError("Generator is already executing.");while(r)try{if(e=1,o&&(i=a[0]&2?o["return"]:a[0]?o["throw"]||((i=o["return"])&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;if(o=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:r.label++;return{value:a[1],done:false};case 5:r.label++;o=a[1];a=[0];continue;case 7:a=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){r.label=a[1];break}if(a[0]===6&&r.label<i[1]){r.label=i[1];i=a;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(a);break}if(i[2])r.ops.pop();r.trys.pop();continue}a=n.call(t,r)}catch(t){a=[6,t];o=0}finally{e=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};import{E as Error}from"./ok-c9833bf3.js";import{a as Connection}from"./Item-f4cbd6f4.js";import"./_commonjsHelpers-9943807e.js";import"./index-1f953d81.js";var Authorization=function(){function t(t){this.connection=t}t.prototype.create=function(t){return __awaiter(this,void 0,void 0,(function(){var n;return __generator(this,(function(r){switch(r.label){case 0:return[4,this.connection.post("authorization",t)];case 1:n=r.sent();return[2,Error.is(n)?n:this.load(n)]}}))}))};t.prototype.update=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:return[4,this.connection.patch("authorization/",t)];case 1:return[2,n.sent()]}}))}))};t.prototype.list=function(t,n,r,e){return __awaiter(this,void 0,void 0,(function(){var o,i;return __generator(this,(function(a){switch(a.label){case 0:o=t?["state=true"]:[];r&&o.push("start="+r);e&&o.push("end="+e);n&&o.push("merchants="+n);i=o.join("&");return[4,this.connection.get("authorization"+(i?"?"+i:""))];case 1:return[2,a.sent()]}}))}))};t.prototype.get=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){return[2,this.connection.get("authorization/"+t)]}))}))};t.prototype.load=function(t){var n=this;var r=__assign(__assign({},typeof t=="string"?{id:t}:t),{cancel:function(){return n.connection.delete("authorization/"+r.id)},capture:function(t){return n.connection.post("authorization/"+r.id+"/capture",t)},refund:function(t){return n.connection.post("authorization/"+r.id+"/refund",t)}});return r};t.open=function(n,r){var e=Connection.open(n,r);return e&&new t(e)};return t}();export{Authorization};