var __generator=this&&this.__generator||function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,c;return c={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(c[Symbol.iterator]=function(){return this}),c;function a(t){return function(e){return u([t,e])}}function u(c){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,i&&(o=c[0]&2?i["return"]:c[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;if(i=0,o)c=[c[0]&2,o.value];switch(c[0]){case 0:case 1:o=c;break;case 4:n.label++;return{value:c[1],done:false};case 5:n.label++;i=c[1];c=[0];continue;case 7:c=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1];o=c;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(c);break}if(o[2])n.ops.pop();n.trys.pop();continue}c=e.call(t,n)}catch(t){c=[6,t];i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:true}}};import{a as Connection}from"./Item-f4cbd6f4.js";import"./_commonjsHelpers-9943807e.js";import"./index-1f953d81.js";var __awaiter=undefined&&undefined.__awaiter||function(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function c(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r["throw"](t))}catch(t){o(t)}}function u(t){t.done?n(t.value):i(t.value).then(c,a)}u((r=r.apply(t,e||[])).next())}))};var Order=function(){function t(t){this.connection=t}t.prototype.create=function(t,e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:return[4,this.connection.post("order",t,{accept:e?"application/jwt":"application/json"})];case 1:return[2,n.sent()]}}))}))};t.prototype.update=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,this.connection.patch("order",t)];case 1:return[2,e.sent()]}}))}))};t.prototype.list=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:return[4,this.connection.get("order")];case 1:return[2,t.sent()]}}))}))};t.prototype.get=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4,this.connection.get("order/"+t)];case 1:return[2,e.sent()]}}))}))};t.prototype.receipt=function(t,e,n){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(r){switch(r.label){case 0:return[4,this.connection.get("order/"+t+"/receipt"+(n?"?email=true":""),{accept:{pdf:"application/pdf",html:"text/html"}[e]})];case 1:return[2,r.sent()]}}))}))};t.prototype.setPayment=function(t,e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:return[4,this.connection.put("order/"+e+"/payment",t)];case 1:return[2,n.sent()]}}))}))};t.prototype.createEvent=function(t,e){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(n){switch(n.label){case 0:return[4,this.connection.post("order/"+e+"/event",t)];case 1:return[2,n.sent()]}}))}))};t.prototype.load=function(t){var e=this;var n=Object.assign(Object.assign({},typeof t=="string"?{id:t}:t),{cancel:function(t){return __awaiter(e,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.createEvent(t,n.id)]}))}))},charge:function(t){return __awaiter(e,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.createEvent(t,n.id)]}))}))},refund:function(t){return __awaiter(e,void 0,void 0,(function(){return __generator(this,(function(e){return[2,this.createEvent(t,n.id)]}))}))}});return n};t.open=function(e,n){var r=Connection.open(e,n);return r&&new t(r)};return t}();export{Order};