import{r as t,c as s,h as e,g as i}from"./p-890a2f7e.js";import{d as o}from"./p-7dfab099.js";import"./p-d6eb762b.js";import{c as r,S as a,U as l}from"./p-d30b6245.js";import"./p-888f7794.js";import"./p-be8a42cb.js";import{d as n}from"./p-9f421a09.js";import"./p-d0c8864c.js";import{C as h}from"./p-2b2884a0.js";import{s as d}from"./p-ce08e4b7.js";import{E as c}from"./p-c9a42c5a.js";import{N as m}from"./p-363dca49.js";import{P as p}from"./p-700bd59f.js";import"./p-112455b1.js";import"./p-1ae2b158.js";import"./p-a96ec623.js";import"./p-c5e6713f.js";import"./p-87741a18.js";const g=class{constructor(e){t(this,e),this.updateCustomers=s(this,"updateCustomers",7),this.selected={}}componentWillLoad(){this.customersFiltered||this.filterCustomers()}handleFilterChanged(t){this.filter=t.detail,t.stopPropagation()}filterCustomers(){const t=this.customers&&(this.filter?o.filter(this.filter,this.customers):[...this.customers]);this.customersFiltered=t}handleSelectedChanged(t){this.selected=t.detail}onCreate(t){this.updateCustomers.emit(t.detail)}render(){return[e("ig-filter",{template:r.template,filter:this.filter}),e("ig-customer-actions",{whitelist:this.whitelist,selected:this.selected}),e("ig-customers-table",{client:this.client,customers:this.customersFiltered,orders:this.orders,selected:this.selected,whitelist:this.whitelist}),e("ig-customer-create-popup",{hidden:!0,onCreate:t=>this.onCreate(t)}),e("ig-customers-footer",{customers:this.customersFiltered})]}static get watchers(){return{customers:["filterCustomers"],filter:["filterCustomers"]}}};g.style=".sc-ig-customers-h{display:block;width:100%;max-width:90em;margin:auto}ig-customer-create-popup.sc-ig-customers{bottom:3.5em;margin-right:2.5em}";const u=class{constructor(s){t(this,s),this.selected={}}componentWillLoad(){this.settlementsChanged()}settlementsChanged(){var t;this.settlementsFiltered||(this.settlementsFiltered=null===(t=this.settlements)||void 0===t?void 0:t.sort(((t,s)=>t.period.start<s.period.start?1:-1)))}handleFilterChanged(t){this.settlementsFiltered=t.detail,t.stopPropagation()}handleSelectedChanged(t){this.selected=t.detail}render(){return[e("ig-filter",{value:this.settlements,template:a.template}),e("ig-portal-settlement-table",{settlements:this.settlementsFiltered,interchange:this.interchange}),e("ig-portal-settlement-footer",{color:"light",selected:this.selected,interchange:this.interchange,settlements:this.settlementsFiltered})]}static get watchers(){return{settlements:["settlementsChanged"]}}};u.style="";const f=class{constructor(s){t(this,s),this.filter={client:o.is(h.value),status:o.some(o.or("created","ordered","denied","pending"))},this.deferFilter={client:o.is(h.value),status:o.some(o.or("deferred"))}}componentWillLoad(){const t=this.orders&&o.filter(o.and(o.parse("deferred")).generalize(),this.orders);this.filteredOrders=t&&d(t,"created")}render(){return[e("portal-create-order",{orders:this.orders,emailOption:this.emailOption,currency:this.currency}),e("portal-display-defer-list",{orders:this.orders,filter:this.deferFilter}),e("ig-orders",{orders:this.filteredOrders})]}};f.style=".sc-portal-defer-view-h{display:block;width:100%;max-width:90em;margin:auto}[hidden].sc-portal-defer-view-h{display:none}";const b={"Login failed. Make sure email and password are correct.":"Inloggning misslyckades. Kontrollera e-post och lösenord.",Email:"E-post",Password:"Lösenord","Log in":"Logga in"},y=class{constructor(e){t(this,e),this.notice=s(this,"notice",7),this.userChanged=s(this,"userChanged",7)}componentWillLoad(){var t;this.t=n.create({sv:b},this.element),this.done=!!(null===(t=p.client)||void 0===t?void 0:t.me.user)}async attemptLogin(t){p.client&&(p.client.me.onUnauthorized=async()=>{var s,e,i;const o=await(null===(s=p.client)||void 0===s?void 0:s.me.login(null!==(e=t.detail.user)&&void 0!==e?e:"",null!==(i=t.detail.password)&&void 0!==i?i:""));return l.is(o)?(this.userChanged.emit({user:o}),this.done=!0):this.notice.emit(m.failed(this.t("Login failed. Make sure email and password are correct."))),!c.is(o)})}render(){const t=this.t;return[e("smoothly-dialog",{open:1!=this.done,header:"PayFunc Portal"},e("form",null,e("smoothly-input",{style:{borderBottom:"none"},type:"email",name:"user"},t("Email")),e("smoothly-input",{type:"password",name:"password"},t("Password")),e("smoothly-submit",{color:"success",prevent:!0,expand:"block",onSubmit:t=>this.attemptLogin(t)},t("Log in")))),e("slot",null)]}get element(){return i(this)}};y.style=".sc-portal-login-h{display:block}[hidden].sc-portal-login-h{display:none}.sc-portal-login-h>smoothly-dialog.sc-portal-login{top:60px;z-index:2}*.sc-portal-login{z-index:0}header.sc-portal-login{background-color:rgb(var(--smoothly-default-shade))}form.sc-portal-login{position:relative}smoothly-input.sc-portal-login{border:1px solid rgb(var(--smoothly-medium-color))}smoothly-submit.sc-portal-login{margin-top:0.4em}";export{g as ig_customers,u as ig_portal_settlements,f as portal_defer_view,y as portal_login}