import{r as t,c,h as o,g as e}from"./p-bf76c688.js";import"./p-14076c1b.js";import"./p-2094943b.js";import"./p-335d4224.js";import{N as a}from"./p-363dca49.js";import{C as s}from"./p-c87b74f2.js";import{d as n}from"./p-07ea43bc.js";import{d as r}from"./p-c2cf0935.js";import{d as i}from"./p-05fa5cbf.js";const u={"Account number":"Kontonummer",Name:"Namn",Email:"E-post","Create account":"Skapa konto","Failed to create account.":"Kunde inte skapa konto.","Account was created.":"Kontot skapades.","Creating account...":"Skapar konto..."},m=class{constructor(o){t(this,o),this.createAccount=c(this,"createAccount",7),this.notice=c(this,"notice",7),this.close=c(this,"close",7)}componentWillLoad(){this.accountNumber=r.Identifier.generate(12),this.t=n.create({sv:u},this.element)}async submitAccount(t){const c={number:t.detail.accountNumber,customer:{name:""==t.detail.name?void 0:t.detail.name,email:""==t.detail.email?void 0:t.detail.email},method:[]};this.notice.emit(a.execute(this.t("Creating account..."),async()=>{let t;this.close.emit();const o=await s.post("account/",c);if(i.Error.is(o))t=[!1,this.t("Failed to create account.")];else{t=[!0,this.t("Account was created.")];const c=await s.get("account/");this.createAccount.emit(c)}return t}))}render(){return[o("form",null,o("section",null,o("smoothly-input",{name:"accountNumber",type:"text",value:this.accountNumber},this.t("Account number")),o("smoothly-input",{name:"name",type:"text"},this.t("Name"))),o("section",null,o("smoothly-input",{name:"email",type:"text"},this.t("Email")),o("smoothly-submit",{fill:"clear",prevent:!0,onSubmit:t=>this.submitAccount(t)},o("smoothly-icon",{toolTip:this.t("Create account"),name:"add-circle",fill:"clear",size:"medium",color:"success"}))))]}get element(){return e(this)}};m.style=".sc-payfunc-account-create-h>form.sc-payfunc-account-create{width:100%;flex-wrap:wrap;display:flex}section.sc-payfunc-account-create{display:flex;flex-grow:1}section.sc-payfunc-account-create:last-of-type{flex-grow:2;min-width:calc(100% - 45px)}section.sc-payfunc-account-create>smoothly-input.sc-payfunc-account-create{border:1px solid rgb(var(--smoothly-medium-color));margin-bottom:0.5em;margin-left:-1px;flex-grow:1}section.sc-payfunc-account-create:last-of-type>smoothly-submit.sc-payfunc-account-create{float:right;margin-bottom:.5em;border:none}section.sc-payfunc-account-create:first-of-type{flex-wrap:wrap}section.sc-payfunc-account-create:first-of-type>*.sc-payfunc-account-create:first-of-type{flex-grow:1;flex-basis:8em}section.sc-payfunc-account-create:first-of-type>*.sc-payfunc-account-create:last-of-type{flex-grow:3}smoothly-icon.sc-payfunc-account-create{cursor:pointer;float:right}";export{m as payfunc_account_create}