var __awaiter=this&&this.__awaiter||function(e,t,n,i){function r(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function s(e){try{c(i.next(e))}catch(e){o(e)}}function a(e){try{c(i["throw"](e))}catch(e){o(e)}}function c(e){e.done?n(e.value):r(e.value).then(s,a)}c((i=i.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,r,o,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(e){return function(t){return c([e,t])}}function c(s){if(i)throw new TypeError("Generator is already executing.");while(n)try{if(i=1,r&&(o=s[0]&2?r["return"]:s[0]?r["throw"]||((o=r["return"])&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;if(r=0,o)s=[s[0]&2,o.value];switch(s[0]){case 0:case 1:o=s;break;case 4:n.label++;return{value:s[1],done:false};case 5:n.label++;r=s[1];s=[0];continue;case 7:s=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){n.label=s[1];break}if(s[0]===6&&n.label<o[1]){n.label=o[1];o=s;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(s);break}if(o[2])n.ops.pop();n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e];r=0}finally{i=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{r as registerInstance,h,g as getElement}from"./index-08b73e9e.js";import{d as dist$1}from"./index-8ba22472.js";import{a as PaymentOptionInvoiceIs}from"./model-23a8b6a7.js";import{p as paymentDetailsAdd}from"./PaymentDetails-c0a6f6c4.js";import{d as dist}from"./index-a0a71287.js";var sv={"The selected invoice choice costs $0.":"Avgiften för den valda fakturan är $0.","Due within $0 days":"Betalas inom $0 dagar.","Due before $0.":"Betalas före $0"};function create(e){return dist.create({sv:sv},e)}var styleCss=".sc-ig-invoice-details-h>p.sc-ig-invoice-details{padding-left:0.4em;padding-right:0.4em}smoothly-radio.sc-ig-invoice-details{width:calc(100% - 2px)}";var IntergiroInvoiceDetails=function(){function e(e){registerInstance(this,e)}e.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(e){this.t=create(this.element);return[2]}))}))};e.prototype.getPayment=function(e,t){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(n){if(this.option&&this.selected){if(!e.items||!e.currency||!e.customer)console.log("Error: must have items, currency, customer");else{t={type:this.option.type,terms:this.selected,verify:{mode:"iframe",parent:window.location.origin}}}}return[2,t]}))}))};e.prototype.render=function(){var e=this;var t=this.t;if(!this.selected&&this.option)this.selected=this.option.terms[0];return[this.option?this.option.terms.map((function(n){return h("smoothly-radio",{onSmoothlySelected:function(){return e.selected=n},checked:e.selected==n,name:"invoice-terms",value:n.due.toString()},typeof n.due=="number"?t("Due within $0 days",n.due):t("Due before $0.",n.due))})):[],this.selected?h("p",null,t("The selected invoice choice costs $0.",dist$1.format(this.selected.fee,"price",this.currency))):[]]};Object.defineProperty(e.prototype,"element",{get:function(){return getElement(this)},enumerable:false,configurable:true});return e}();paymentDetailsAdd("invoice",(function(e){var t={type:"invoice",name:"Invoice",brand:e.service,component:h("ig-invoice-details",{option:PaymentOptionInvoiceIs(e)?e:undefined,currency:e.currency,ref:function(e){return t.element=e}})};return t}));IntergiroInvoiceDetails.style=styleCss;export{IntergiroInvoiceDetails as I};