var __awaiter=this&&this.__awaiter||function(t,e,n,i){function r(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function s(t){try{l(i.next(t))}catch(t){o(t)}}function a(t){try{l(i["throw"](t))}catch(t){o(t)}}function l(t){t.done?n(t.value):r(t.value).then(s,a)}l((i=i.apply(t,e||[])).next())}))};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:[]},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(t){return function(e){return l([t,e])}}function l(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=e.call(t,n)}catch(t){s=[6,t];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{P as PaymentOptionInstallmentIs}from"./model-23a8b6a7.js";import{p as paymentDetailsAdd}from"./PaymentDetails-c0a6f6c4.js";import{d as dist}from"./index-a0a71287.js";var sv={"$0 $1 / month in $2 months":"$0 $1 / månad i $2 månader","$0 $1 in initial fee and $2 $3 reccuring. Total cost is $4 $5 and the effective rate is $6%":"$0 $1 i uppläggningsavgift och $2 $3 i månadsavgift. Total kostnad är $4 $5 och den effektiva räntan är $6%"};function create(t){return dist.create({sv:sv},t)}var styleCss=".sc-ig-installment-details-h{display:block;margin:1em}[hidden].sc-ig-installment-details-h{display:none}smoothly-radio.sc-ig-installment-details{text-align:center;border-left:solid 1px rgb(var(--smoothly-medium-color));border-right:solid 1px rgb(var(--smoothly-medium-color))}smoothly-radio.sc-ig-installment-details:first-of-type{border-top:solid 1px rgb(var(--smoothly-medium-color));border-top-left-radius:4px;border-top-right-radius:4px}smoothly-radio.sc-ig-installment-details:last-of-type{border-bottom:solid 1px rgb(var(--smoothly-medium-color));border-bottom-left-radius:4px;border-bottom-right-radius:4px}p.sc-ig-installment-details{color:rgb(var(--smoothly-medium-color))}";var IntergiroInstallmentDetails=function(){function t(t){registerInstance(this,t)}t.prototype.componentWillLoad=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.t=create(this.element);return[2]}))}))};t.prototype.getPayment=function(t,e){return __awaiter(this,void 0,void 0,(function(){var e;return __generator(this,(function(n){if(this.option&&this.selected){if(!t.items||!t.currency||!t.customer)console.log("Error: must have items, currency, customer");else{e={type:this.option.type,plan:this.selected,verify:{mode:"iframe",parent:window.location.origin}}}}return[2,e]}))}))};t.prototype.onSelected=function(t){if(typeof t.detail=="object"&&typeof t.detail.value=="string"&&this.option)this.selected=this.option.plans.find((function(e){return e.length.toString()==t.detail.value}))};t.prototype.limit=function(t,e){var n=e==0?1:100;return Math.round((t+Number.EPSILON)*n)/n};t.prototype.render=function(){var t=this;var e=this.t;if(!this.selected&&Array.isArray(this.option)&&this.option.length>0)this.selected=this.option.plans[0];var n=this.selected&&this.selected.effectiveRate?this.selected.effectiveRate*100:"-";return[this.option?this.option.plans.map((function(n){return h("smoothly-radio",{checked:t.selected==n,name:"invoice-plan",value:n.length.toString()},e("$0 $1 / month in $2 months",t.currency,t.limit(n.amount,0),n.length))})):[],this.selected?h("p",null,e("$0 $1 in initial fee and $2 $3 reccuring. Total cost is $4 $5 and the effective rate is $6%",this.currency,this.selected.fees.initial,this.currency,this.selected.fees.reaccuring,this.currency,this.limit(this.selected.total,0),typeof n=="number"?this.limit(n,2).toString():n)):[]]};Object.defineProperty(t.prototype,"element",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();paymentDetailsAdd("installment",(function(t){var e={type:"installment",name:"Installment Plan",brand:t.service,component:h("ig-installment-details",{ref:function(t){return e.element=t},option:PaymentOptionInstallmentIs(t)?t:undefined,currency:t.currency})};return e}));IntergiroInstallmentDetails.style=styleCss;export{IntergiroInstallmentDetails as I};