import{r as t,c as e,h as o,g as c}from"./p-e964d29c.js";import{E as a}from"./p-121de483.js";import{d as s}from"./p-2e91fa88.js";import"./p-d636f04c.js";import"./p-a5a65406.js";import{N as i}from"./p-363dca49.js";import{C as r}from"./p-578eb6e9.js";import{d as n}from"./p-4052fee2.js";import"./p-112455b1.js";const m={"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..."},l=class{constructor(o){t(this,o),this.createAccount=e(this,"createAccount",7),this.notice=e(this,"notice",7),this.close=e(this,"close",7)}componentWillLoad(){this.accountNumber=s.Identifier.generate(12),this.t=n.create({sv:m},this.element)}async submitAccount(t){const e={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(i.execute(this.t("Creating account..."),(async()=>{let t;this.close.emit();const o=await r.post("account/",e);if(a.is(o))t=[!1,this.t("Failed to create account.")];else{t=[!0,this.t("Account was created.")];const e=await r.get("account/");this.createAccount.emit(e)}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 c(this)}};l.style=".sc-ig-account-create-h>form.sc-ig-account-create{width:100%;flex-wrap:wrap;display:flex}section.sc-ig-account-create{display:flex;flex-grow:1}section.sc-ig-account-create:last-of-type{flex-grow:2;min-width:calc(100% - 45px)}section.sc-ig-account-create>smoothly-input.sc-ig-account-create{border:1px solid rgb(var(--smoothly-medium-color));margin-bottom:0.5em;margin-left:-1px;flex-grow:1}section.sc-ig-account-create:last-of-type>smoothly-submit.sc-ig-account-create{float:right;margin-bottom:.5em;border:none}section.sc-ig-account-create:first-of-type{flex-wrap:wrap}section.sc-ig-account-create:first-of-type>*.sc-ig-account-create:first-of-type{flex-grow:1;flex-basis:8em}section.sc-ig-account-create:first-of-type>*.sc-ig-account-create:last-of-type{flex-grow:3}smoothly-icon.sc-ig-account-create{cursor:pointer;float:right}";export{l as ig_account_create}