PageSourceSearch

https://eqwecare.se/assets/index-tnBIv3OM.js

js eqwecare.se collected 2026-09-24 15:12:34 UTC 214,566 bytes, 1 lines download raw bytes

1import{c as ks,d as be,b9 as ha,i as Xe,o as ga,u as ee,j as e,n as c,S as W,B,x as Be,ba as r,U as as,r as l,f as Q,b3 as Ns,z as V,h as re,eV as ws,eW as pa,eX as xa,b0 as ba,bd as ja,M as J,eY as fa,eZ as Sa,e_ as ya,e$ as va,f0 as ka,f1 as Na,f2 as wa,f3 as Ca,f4 as Pa,f5 as Fa,f6 as Ea,f7 as Ba,s as on,a as ln,b$ as Aa,T as La,P as Da,K as Ta,b as js,f8 as Ra,dZ as za,dT as Ma,f9 as Ia,W as hs,X as Oa,au as Ys,fa as Ka,fb as Va,fc as qa,fd as $a,d_ as Ua,fe as Ga}from"./index-Dqf2uGiv.js";import{L as Ha}from"./index-CVxMFDrh.js";import{p as es}from"./profile1-DzAaSgAn.js";import{D as fs}from"./invoiceDefaults-CH0acUo_.js";import{P as Qe,D as Ss}from"./paymentMethods-Cr5pcJfE.js";import{l as _a,i as Ja,m as cn}from"./luhnAlgo-B8z0oDmV.js";import{s as Wa}from"./phoneFormatter-De6zYIGY.js";import{R as Ya}from"./index-C6kNBKWf.js";import{u as dn,m as Za}from"./postalCodeFormatter-DXRa8iGI.js";import{a as Xa,i as Qa}from"./personId-CUZKRZuv.js";import{V as ye}from"./validationRules-Eb6EGYXU.js";import{S as ss,c as et}from"./constants-BTqeRRYw.js";import{S as st}from"./index-Cf53BUZN.js";import{U as nt}from"./UseMyLocationButton-CXVSOOM8.js";import{R as Te}from"./Row-DjU35VzF.js";import{I as _e}from"./Image-DVq8Svz6.js";import{C as T}from"./Card-C4TaYy-S.js";import{A as H}from"./Alert-DBcbpOMK.js";import{I as at}from"./InputGroup-BWxGwk85.js";import{A as Ie}from"./Accordion-B-AB2uCT.js";import{getFortnoxAccounts as mn,getFortnoxConnectionStatus as un,getFortnoxSettings as hn,verifyFortnoxModules as tt,completeFortnoxOnboarding as rt,getFortnoxAuthUrl as gn,updateFortnoxSettings as it,getSpirisConnectionStatus as pn,getSpirisSettings as xn,verifySpirisModules as Zs,updateSpirisSettings as ot,completeSpirisOnboarding as lt,getSpirisAuthUrl as bn,disconnectSpiris as ct,disconnectFortnox as dt,requestSpirisAccess as mt,getAccountSettings as ut,updateAccountSettings as ht}from"./accountingService-27G0zzPQ.js";import{B as ge}from"./NavbarContext-D_AGnKGB.js";import{P as jn}from"./ProgressBar-CoKxh3me.js";import{T as Xs}from"./Table-BL_fR-if.js";import{T as Ee}from"./Tab-DihlPGNu.js";import{N as Ke}from"./Nav-Bv7u2qzG.js";import{u as gt,W as pt}from"./WebGuide-whWyrb_O.js";import"./index-BwrYomd3.js";import"./navigationConfig-C6RebKK7.js";import"./NavIcon-D8xmWKow.js";import"./index-D2g9Z2GZ.js";import"./Anchor-BThcAKIt.js";import"./useAiChatStore-BJeZABSB.js";import"./ListGroup-Bie7cDl2.js";import"./CardHeaderContext-z8TY24XU.js";import"./Collapse-CwefKhif.js";const xt=s=>ks({firstName:be().required(s("profileSchema.firstName.required")).trim().min(ye.name.min,s("validation.tooShort",{min:ye.name.min})).max(ye.name.max,s("validation.tooLong",{max:ye.name.max})).matches(ye.name.pattern,s("profileSchema.firstName.invalid")),lastName:be().required(s("profileSchema.lastName.required")).trim().min(ye.name.min,s("validation.tooShort",{min:ye.name.min})).max(ye.name.max,s("validation.tooLong",{max:ye.name.max})).matches(ye.name.pattern,s("profileSchema.lastName.invalid")),title:be().required(s("profileSchema.title.required")).max(ye.title.max,s("profileSchema.title.max")).trim(),phone:be().required(s("profileSchema.phone.required")).test("is-valid-length",s("profileSchema.phone.length"),n=>{const i=n==null?void 0:n.replace(/[^\d]/g,"");return(i==null?void 0:i.length)>=7&&(i==null?void 0:i.length)<=15}).test("is-valid-phone",s("profileSchema.phone.valid"),n=>Ja(n)),address:be().nullable().test("address-required-if-postal-info",s("profileSchema.address.dependentRequired"),function(n){if(!this.parent)return!0;const{postNumber:i,postPlace:a}=this.parent,t=i&&typeof i=="string"&&i.trim()!=="",o=a&&typeof a=="string"&&a.trim()!=="",d=n&&typeof n=="string"&&n.trim()!=="";return t||o?d:!0}),postNumber:be().transform(n=>n?n.replace(/\s/g,""):"").trim().nullable().test("postNumber-matches",s("profileSchema.postNumber.matches"),function(n){return!n||n.trim()===""?!0:/^\d{5}$/.test(n)}).test("postNumber-required-if-address-or-postPlace",s("profileSchema.postNumber.required"),function(n){if(!this.parent)return!0;const{address:i,postPlace:a}=this.parent,t=i&&typeof i=="string"&&i.trim()!=="",o=a&&typeof a=="str
1ing"&&a.trim()!=="",d=n&&typeof n=="string"&&n.trim()!=="";return t||o?d:!0}),postPlace:be().trim().nullable().max(ye.city.max,s("validation.tooLong",{max:ye.city.max})).test("postPlace-pattern",s("profileSchema.postPlace.invalid"),function(n){return!n||n.trim()===""?!0:ye.city.pattern.test(n)}).test("postPlace-required-if-address-or-postNumber",s("profileSchema.postPlace.required"),function(n){if(!this.parent)return!0;const{address:i,postNumber:a}=this.parent,t=i&&typeof i=="string"&&i.trim()!=="",o=a&&typeof a=="string"&&a.trim()!=="",d=n&&typeof n=="string"&&n.trim()!=="";return t||o?d:!0}),email:be().trim().lowercase().email(s("profileSchema.email.invalid")).max(ye.email.max,s("validation.tooLong",{max:ye.email.max})).required(s("profileSchema.email.required")),organizationName:be().required(s("profileSchema.organizationName.required")).max(100,s("profileSchema.organizationName.max")),organizationNumber:be().required(s("profileSchema.organizationNumber.required")).test("is-valid-identification",s("profileSchema.organizationNumber.luhn"),n=>{if(!n)return!1;const i=n.replace(/\D/g,"");return i.length===10?Xa(n)?!0:_a(i):i.length===12?Qa(n):!1})}),bt=s=>ks({swishNumberCheck:Xe(),bankgiroCheck:Xe(),plusgiroCheck:Xe(),bankAccountCheck:Xe(),swishNumber:be().test("swish-conditional",s("profileSchema.phone.valid"),function(n){const{swishNumberCheck:i}=this.parent;return i?n?/^\d+$/.test(n)?n.length<7||n.length>15?this.createError({message:s("paymentSchema.swishNumber.length")}):!0:this.createError({message:s("paymentSchema.common.digitsOnly")}):this.createError({message:s("paymentSchema.swishNumber.required")}):!0}),bankgiro:be().test("bankgiro-conditional",s("paymentSchema.bankgiro.format"),function(n){const{bankgiroCheck:i}=this.parent;return i?n?/^\d+$/.test(n)?n.length===7||n.length===8?!0:this.createError({message:s("paymentSchema.bankgiro.format")}):this.createError({message:s("paymentSchema.bankgiro.digitsOnly")}):this.createError({message:s("paymentSchema.bankgiro.required")}):!0}),plusgiro:be().test("plusgiro-conditional",s("paymentSchema.plusgiro.format"),function(n){const{plusgiroCheck:i}=this.parent;return i?n?/^\d+$/.test(n)?n.length<2||n.length>10?this.createError({message:s("paymentSchema.plusgiro.format")}):!0:this.createError({message:s("paymentSchema.plusgiro.digitsOnly")}):this.createError({message:s("paymentSchema.plusgiro.required")}):!0}),bankAccount:be().test("bankAccount-conditional",s("paymentSchema.bankAccount.format"),function(n){const{bankAccountCheck:i}=this.parent;if(!i)return!0;if(!n)return this.createError({message:s("paymentSchema.bankAccount.required")});if(!/^\d+$/.test(n))return this.createError({message:s("paymentSchema.bankAccount.digitsOnly")});if(n.length<5||n.length>15)return this.createError({message:s("paymentSchema.bankAccount.format")});const a=n.startsWith("8")?5:4;if(n.length<=a)return this.createError({message:s("paymentSchema.bankAccount.format")});const t=n.length-a;return t<1||t>12?this.createError({message:s("paymentSchema.bankAccount.format")}):!0}),ibanCheck:Xe(),iban:be().test("iban-conditional",s("paymentSchema.iban.format"),function(n){const{ibanCheck:i}=this.parent;return i?n?/^[A-Z]{2}[0-9]{2}[A-Z0-9]{10,30}$/.test(n)?!0:this.createError({message:s("paymentSchema.iban.format")}):this.createError({message:s("paymentSchema.iban.required")}):!0}),bicCheck:Xe(),bic:be().test("bic-conditional",s("paymentSchema.bic.format"),function(n){const{bicCheck:i}=this.parent;return i?n?/^[A-Z]{4}[A-Z]{2}[A-Z0-9]{2}([A-Z0-9]{3})?$/.test(n)?!0:this.createError({message:s("paymentSchema.bic.format")}):this.createError({message:s("paymentSchema.bic.required")}):!0}),enabledPaymentMethods:ha().of(be()).min(1,s("paymentSchema.enabledPaymentMethods.min")),defaultPaymentMethod:be().test("default-in-enabled",s("paymentSchema.defaultPaymentMethod.notEnabled"),function(n){const i=this.parent.enabledPaymentMethods;return!Array.isArray(i)||i.length===0?!0:i.includes(n)})}),jt=s=>ks({oldPassword:be().required(s("passwordSchema.oldPassword.required")).min(8,s("passwordSchema.oldPassword.min")).matches(/[0-9]/,s("passwordSchema.oldPassword.number")).matches(/[A-Z]/,s("passwordSchema.oldPassword.uppercase")).matches(/[a-z]/,s("passwordSchema.oldPassword.lowercase")).matches(/[^a-zA-Z0-9]/,s("passwordSchema.oldPassword.special")),newPassword:be().required(s("passwordSchema.newPassword.required")).min(8,s("passwordSchema.newPassword.min")).matches(/[0-9]/,s("passwordSchema.newPassword.number")).matches(/[A-Z]/,s("passwordSchema.newPassword.uppercase")).matches(/[a-z]/,s("passwordSchema.newPassword.lowercase")).matches(/[^a-zA-Z0-9]/,s("passwordSchema.newPassword.special")).notOneOf([ga("oldPassword")],s("passwordSchema.newPassword.notSame"))}),Se={normalizeSwish(s){return s?String(s).replace(/\D/g,"").slice(0,15):""},formatSwishNumber(s,n=!1){const i=String(s||"").replace(/\D/g,""),t=i.length>=3&&i.slice(0,3)==="123"?i.slice(0,10):i;let o="";return t.length<=3?o=t:t.length<=6?o=`${t.slice(0,3)} ${t.slice(3)}`:t.length<=8?o=`${t.slice(0,3)} ${t.slice(3,6)} ${t.slice(6)}`:t.length<=10?o=`${t.slice(0,3)} ${t.slice(3,6)} ${t.slice(6,8)} ${t.slice(8,10)}
1`:o=t.replace(/(\d{3})(?=\d)/g,"$1 ").trim(),(n?"+":"")+o},normalizeBankgiro(s){return s?String(s).replace(/\D/g,"").slice(0,8):""},formatBankgiroNumber(s){const n=String(s||"").replace(/\D/g,"");return n.length<=4?n:`${n.slice(0,n.length-4)}-${n.slice(-4)}`},normalizePlusgiro(s){return s?String(s).replace(/\D/g,"").slice(0,10):""},formatPlusgiroNumber(s){const n=String(s||"").replace(/\D/g,"");return n.length<=1?n:`${n.slice(0,-1)}-${n.slice(-1)}`},normalizeBankAccount(s){return s?String(s).replace(/\D/g,"").slice(0,15):""},formatBankAccountNumber(s){const n=String(s||"").replace(/\D/g,"");if(!n)return"";let i=0;if(n[0]==="8"&&n.length>=5)i=5;else if(n.length>=4)i=4;else return n;const a=n.slice(0,i),t=n.slice(i),o=i===5?`${a.slice(0,4)}-${a.slice(4,5)}`:a;let d=t;return t.length>6?d=`${t.slice(0,3)} ${t.slice(3,6)} ${t.slice(6)}`:t.length>3&&(d=`${t.slice(0,3)} ${t.slice(3)}`),i===5?`${o}${t?" "+d:""}`:`${o}${t?" - "+d:""}`},normalizeIban(s){return s?String(s).toUpperCase().replace(/[^A-Z0-9]/g,"").slice(0,34):""},formatIban(s){const n=String(s||"").toUpperCase().replace(/[^A-Z0-9]/g,"");return n?n.replace(/(.{4})/g,"$1 ").trim():""},normalizeBic(s){return s?String(s).toUpperCase().replace(/[^A-Z0-9]/g,"").slice(0,11):""},formatBic(s){return String(s||"").toUpperCase().replace(/[^A-Z0-9]/g,"")}},ft=s=>{if(!s)return"";const n=s.replace(/\D/g,"").slice(0,10);return n.length>6?`${n.slice(0,6)}-${n.slice(6)}`:n},fn=({loading:s,profilePic:n,isCompanyLogo:i,formikProfile:a,handleProfilePicChange:t,handleLogoChange:o,onPlaceSelected:d})=>{const{t:h}=ee();return e.jsx(c,{onSubmit:a.handleSubmit,children:e.jsxs("div",{className:"from_des_block",children:[e.jsxs(Te,{children:[e.jsx(c.Group,{className:"mb-3 col-lg-12",children:e.jsxs("div",{className:"d-flex gap-3",children:[e.jsxs("div",{className:"user-profile-pic",children:[s?e.jsx("div",{className:"d-flex justify-content-center align-items-center h-100",children:e.jsx(W,{variant:"success"})}):e.jsx(_e,{src:n||es,alt:"Profile",onError:u=>u.target.src=es}),e.jsx(c.Control,{type:"file",accept:"image/*",onChange:t}),e.jsx(B,{className:"btn",children:h("ProfilePage.Profile-Picture")})]}),e.jsxs("div",{className:"user-profile-pic companylogo",children:[s?e.jsx("div",{className:"d-flex justify-content-center align-items-center h-100",children:e.jsx(W,{variant:"success"})}):e.jsx(_e,{src:i||es,alt:"Profile",onError:u=>u.target.src=es}),e.jsx(c.Control,{accept:"image/*",type:"file",onChange:o}),e.jsx(B,{className:"btn",children:h("ProfilePage.Company-Logo")})]})]})}),e.jsxs(c.Group,{className:"mb-3 col-lg-6",children:[e.jsx(c.Label,{children:h("ProfilePage.First-Name")}),e.jsx(c.Control,{type:"text",name:"firstName",maxLength:50,value:a.values.firstName,onChange:a.handleChange,onBlur:a.handleBlur,isInvalid:a.touched.firstName&&!!a.errors.firstName}),e.jsx(c.Control.Feedback,{type:"invalid",children:a.errors.firstName})]}),e.jsxs(c.Group,{className:"mb-3 col-lg-6",children:[e.jsx(c.Label,{children:h("ProfilePage.Last-Name")}),e.jsx(c.Control,{type:"text",maxLength:50,name:"lastName",value:a.values.lastName,onChange:a.handleChange,onBlur:a.handleBlur,isInvalid:a.touched.lastName&&!!a.errors.lastName}),e.jsx(c.Control.Feedback,{type:"invalid",children:a.errors.lastName})]}),e.jsxs(c.Group,{className:"mb-3",children:[e.jsx(c.Label,{children:h("ProfilePage.Title")}),e.jsx(c.Control,{type:"text",name:"title",max:50,value:a.values.title,onChange:a.handleChange,onBlur:a.handleBlur,isInvalid:!!a.errors.title&&a.touched.title}),e.jsx(c.Control.Feedback,{type:"invalid",children:a.errors.title})]}),e.jsxs(Te,{children:[e.jsx(Be,{lg:12,className:"mb-2",children:e.jsx(nt,{existingValues:{address:a.values.address,postalCode:a.values.postNumber,city:a.values.postPlace},onAddressResolved:d,disabled:a.isSubmitting})}),e.jsxs(c.Group,{className:"mb-4 col-lg-6",children:[e.jsx(st,{name:"Address",onChange:u=>a.setFieldValue("address",u.target.value),value:a.values.address,onPlaceSelected:d}),e.jsx("small",{className:"text-danger",children:a.errors.address})]}),e.jsxs(c.Group,{className:"mb-4 col-lg-3",children:[e.jsx(c.Label,{children:h("CommonText.Postal-Code")}),e.jsx(c.Control,{type:"text",name:"postNumber",value:Za(a.values.postNumber),onChange:u=>{const m=dn(u.target.value);a.setFieldValue("postNumber",m)},maxLength:5,onBlur:a.handleBlur,isInvalid:a.touched.postNumber&&!!a.errors.postNumber}),e.jsx(c.Control.Feedback,{type:"invalid",children:a.errors.postNumber})]}),e.jsxs(c.Group,{className:"mb-4 col-lg-3",children:[e.jsx(c.Label,{children:h("CommonText.City")}),e.jsx(c.Control,{type:"text",name:"postPlace",value:a.values.postPlace,onChange:a.handleChange,onBlur:a.handleBlur,isInvalid:a.touched.postPlace&&!!a.errors.postPlace}),e.jsx(c.Control.Feedback,{type:"invalid",children:a.errors.postPlace})]})]}),e.jsxs(c.Group,{className:"mb-3 col-lg-6",children:[e.jsx(c.Label,{children:h("ProfilePage.Email")}),e.jsx(c.Control,{type:"email",name:"email",value:a.values.email,onChange:a.handleChange,readOnly:!0,isInvalid:a.touched.email&&!!a.errors.email}),e.jsx(c.Control.Feedback,{type:"invalid",children:a.errors.email})]}),e.jsxs(c.Group,{className:"mb-3 col-lg-6",children:[e.jsx(c.Label,{children:h("ProfilePage.Phone-No")}),e.jsx(c.Control,{type:"text",name:"phone",value:a.values.phone,onChange:u=>a.setFieldValue("phone",cn(u.target.value)),onBlur:a.handleBlur,isInvalid:a.touched.phone&&!!a.errors.phone}),e.jsx(c.Control.Feedback,{type:"invalid",children:a.errors.phone})]}),e.jsxs(c.Group,{className:"mb-3 col-lg-6",children:[e.jsx(c.Label,{children:h("ProfilePage.Organization-Name")}),e.jsx(c.Control,{type:"text",name:"organizationName",max:50,value:a.values.organizationName,onChange:a.handleChange,onBlur:a.handleBlur,isInvalid:a.touched.organizationName&&!!a.errors.organizationName}),e.jsx(c.Control.Feedback,{type:"invalid",children:a.errors.organizationName})]}),e.jsxs(c.Group,{className:"mb-3 col-lg-6",children:[e.jsx(c.Label,{children:h("ProfilePage.Organization-Number")}),e.jsx(c.Control,{type:"text",name:"organizationNumber",max:50,value:ft(a.values.organizationNumber),onChange:u=>{const m=u.target.value.replace(/\D/g,"").slice(0,10);a.setFieldValue("organizationNumber",m,!0)},onBlur:u=>{a.setTouched({...a.touched,organizationNumber:!0},!0),a.handleBlur(u)},isInvalid:a.touched.organizationNumber&&!!a.errors.organizationNumber}),e.jsx(c.Control.Feedback,{type:"invalid",children:a.errors.organizationNumber})]})]}),e.jsx(B,{className:"form-action-btn-primary mb-5",onClick:a.handleSubmit,disabled:a.isSubmitting||s,children:h("ProfilePage.Update")})]})})};
1fn.propTypes={user:r.object,loading:r.bool,profilePic:r.string,isCompanyLogo:r.string,formikProfile:r.object.isRequired,handleProfilePicChange:r.func.isRequired,handleLogoChange:r.func.isRequired,onPlaceSelected:r.func.isRequired};const St=()=>{const{t:s}=ee(),{user:n}=as(),[i,a]=l.useState(!1),[t,o]=l.useState(!1),[d,h]=l.useState(!0),[u,m]=l.useState(""),[g,p]=l.useState(null),[y,x]=l.useState(!1),[k,P]=l.useState(!1);l.useEffect(()=>{n!=null&&n.id&&w()},[n]),l.useEffect(()=>{if(g){const b=d!==g.bookingConfirmationEnabled||u!==g.bookingConfirmationCustomText;x(b)}},[d,u,g]);const w=async()=>{a(!0);try{const{data:b}=await Q.get(Ns.endPoint(n.id));b!=null&&b.result&&(h(b.result.bookingConfirmationEnabled??!0),m(b.result.bookingConfirmationCustomText||""),p(b.result))}catch(b){V.error(re(b))}finally{a(!1)}},D=async()=>{o(!0);try{const b={bookingConfirmationEnabled:d,bookingConfirmationCustomText:u.trim()},{data:F}=await Q.put(ws.endPoint(n.id),b);F!=null&&F.result&&(p(F.result),x(!1),V.success(s("BookingSettings.SaveSuccess")||"Inställningar sparade!"))}catch(b){V.error(re(b))}finally{o(!1)}},O=()=>{g&&(h(g.bookingConfirmationEnabled??!0),m(g.bookingConfirmationCustomText||""))};return i?e.jsx(T,{className:"mb-4",children:e.jsxs(T.Body,{className:"text-center",children:[e.jsx(W,{animation:"border",size:"sm"}),e.jsx("p",{className:"mt-2 mb-0",children:s("BookingSettings.Loading")||"Laddar inställningar..."})]})}):e.jsxs(T,{className:"mb-4",children:[e.jsx(T.Header,{style:{cursor:"pointer"},onClick:()=>P(!k),children:e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("h5",{className:"mb-0",children:[e.jsx("i",{className:"bi bi-envelope-check me-2"}),s("BookingSettings.Title")||"Bokningsbekräftelser"]}),e.jsxs("div",{className:"d-flex align-items-center gap-2",children:[!k&&e.jsx("span",{className:`badge ${d?"bg-success":"bg-secondary"}`,children:d?s("BookingSettings.StatusEnabled")||"Aktiverad":s("BookingSettings.StatusDisabled")||"Inaktiverad"}),e.jsx("i",{className:`bi ${k?"bi-chevron-up":"bi-chevron-down"}`})]})]})}),k&&e.jsx(T.Body,{children:e.jsxs(c,{children:[e.jsx(c.Group,{className:"mb-4",children:e.jsx(c.Check,{type:"switch",id:"booking-confirmation-enabled",label:e.jsxs("span",{children:[e.jsx("strong",{children:s("BookingSettings.EnableLabel")||"Aktivera bokningsbekräftelser"}),e.jsx("p",{className:"text-muted mb-0 small",children:s("BookingSettings.EnableDescription")||"När aktiverat skickas automatiskt en bekräftelse via email till kunden när en ny bokning skapas."})]}),checked:d,onChange:b=>h(b.target.checked)})}),d&&e.jsxs(e.Fragment,{children:[e.jsxs(c.Group,{className:"mb-4",children:[e.jsx(c.Label,{children:e.jsx("strong",{children:s("BookingSettings.CustomTextLabel")||"Anpassat meddelande (valfritt)"})}),e.jsx(c.Control,{as:"textarea",rows:6,placeholder:s("BookingSettings.CustomTextPlaceholder")||"Ange ett personligt meddelande som inkluderas i bekräftelsen. Lämna tomt för standardtext.",value:u,onChange:b=>m(b.target.value),maxLength:1e3}),e.jsxs(c.Text,{className:"text-muted",children:[u.length,"/1000 ",s("BookingSettings.Characters")||"tecken"]}),e.jsxs(H,{variant:"light",className:"mt-3 mb-0 border",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("strong",{children:[e.jsx("i",{className:"bi bi-lightbulb me-2"}),"Använd platshållare för dynamisk text"]})}),e.jsx("p",{className:"small mb-2",children:"Skriv platshållare inom hakparenteser så ersätts de automatiskt med rätt värde:"}),e.jsxs("div",{className:"d-flex flex-wrap gap-2 small",children:[e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"[djurnamn]"}),e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"[kundnamn]"}),e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"[datum]"}),e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"[tid]"}),e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"[sluttid]"}),e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"[tjänster]"}),e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"[adress]"})]}),e.jsx("p",{className:"small text-muted mt-2 mb-0",children:'Exempel: "Vi ses [datum] för att ta hand om [djurnamn]!"'})]}),!u.trim()&&e.jsxs(H,{variant:"info",className:"mt-2 small mb-0",children:[e.jsx("i",{className:"bi bi-info-circle me-2"}),s("BookingSettings.DefaultTextInfo")||"När inget anpassat meddelande anges används en standardbekräftelse med bokningsdetaljer."]})]}),e.jsxs(c.Group,{className:"mb-4",children:[e.jsx(c.Label,{children:e.jsx("strong",{children:s("BookingSettings.PreviewLabel")||"Förhandsvisning"})}),e.jsx(T,{bg:"light",children:e.jsxs(T.Body,{className:"small",children:[e.jsx("p",{className:"mb-2",children:e.jsx("strong",{children:"Hej Anna Andersson,"})}),e.jsx("p",{className:"mb-2",children:s("BookingSettings.PreviewIntro")||"Din bokning är nu bekräftad!"}),e.jsxs("div",{className:"mb-2 p-2 bg-white rounded",children:[e.jsxs("p",{className:"mb-1",children:[e.jsxs("strong",{children:[s("BookingSettings.PreviewDate")||"Datum",":"]})," onsdag, 5 februari 2025"]}),e.jsxs("p",{className:"mb-1",children:[e.jsxs("strong",{children:[s("BookingSettings.PreviewTime")||"Tid",":"]})," 10:00 - 11:30"]}),e.jsxs("p",{className:"mb-1",children:[e.jsxs("strong",{children:[s("BookingSettings.PreviewAnimal
1s")||"Djur",":"]})," Mirre, Storm"]}),e.jsxs("p",{className:"mb-0",children:[e.jsxs("strong",{children:[s("BookingSettings.PreviewServices")||"Tjänster",":"]})," Verkning, Skoning"]})]}),u.trim()&&e.jsx("div",{className:"mb-2 p-2 border-start border-primary border-3 bg-white",children:e.jsx("p",{className:"mb-0 font-italic",style:{whiteSpace:"pre-line"},children:u.replace(/\[djurnamn\]/gi,"Mirre, Storm").replace(/\[kundnamn\]/gi,"Anna Andersson").replace(/\[datum\]/gi,"onsdag, 5 februari 2025").replace(/\[tid\]/gi,"10:00").replace(/\[starttid\]/gi,"10:00").replace(/\[sluttid\]/gi,"11:30").replace(/\[tjänster\]/gi,"Verkning, Skoning").replace(/\[tjanster\]/gi,"Verkning, Skoning").replace(/\[adress\]/gi,"Storgatan 1, 12345 Stockholm").replace(/\[plats\]/gi,"Storgatan 1, 12345 Stockholm")})}),e.jsx("p",{className:"mb-0 text-muted",children:s("BookingSettings.PreviewFooter")||"Tips: Kom ihåg att meddela om det blir några ändringar i god tid innan besöket."})]})})]})]}),e.jsxs("div",{className:"d-flex gap-2",children:[e.jsx(B,{variant:"primary",onClick:D,disabled:t||!y,children:t?e.jsxs(e.Fragment,{children:[e.jsx(W,{animation:"border",size:"sm",className:"me-2"}),s("CommonText.Saving")||"Sparar..."]}):e.jsx(e.Fragment,{children:s("commonButton.Save")||"Spara"})}),y&&e.jsx(B,{variant:"outline-secondary",onClick:O,disabled:t,children:s("commonButton.Cancel")||"Avbryt"})]})]})})]})},Qs=[{value:30,label:"30 min"},{value:45,label:"45 min"},{value:60,label:"60 min"},{value:90,label:"90 min"},{value:120,label:"120 min"}],yt=()=>{var O;const{t:s}=ee(),{user:n}=as(),[i,a]=l.useState(!1),[t,o]=l.useState(!1),[d,h]=l.useState(60),[u,m]=l.useState(60),[g,p]=l.useState(!1),[y,x]=l.useState(!1);l.useEffect(()=>{n!=null&&n.id&&k()},[n]),l.useEffect(()=>{p(d!==u)},[d,u]);const k=async()=>{a(!0);try{const{data:b}=await Q.get(Ns.endPoint(n.id));if(b!=null&&b.result){const F=b.result.defaultBookingDuration??60;h(F),m(F)}}catch(b){V.error(re(b))}finally{a(!1)}},P=async()=>{o(!0);try{const{data:b}=await Q.put(ws.endPoint(n.id),{defaultBookingDuration:d});if(b!=null&&b.result){const F=b.result.defaultBookingDuration??60;m(F),p(!1),V.success(s("BookingSettings.SaveSuccess")||"Inställningar sparade!")}}catch(b){V.error(re(b))}finally{o(!1)}},w=()=>{h(u)};if(i)return e.jsx(T,{className:"mb-4",children:e.jsxs(T.Body,{className:"text-center",children:[e.jsx(W,{animation:"border",size:"sm"}),e.jsx("p",{className:"mt-2 mb-0",children:s("BookingSettings.Loading")||"Laddar inställningar..."})]})});const D=((O=Qs.find(b=>b.value===d))==null?void 0:O.label)||`${d} min`;return e.jsxs(T,{className:"mb-4",children:[e.jsx(T.Header,{style:{cursor:"pointer"},onClick:()=>x(!y),children:e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("h5",{className:"mb-0",children:[e.jsx("i",{className:"bi bi-clock me-2"}),s("BookingSettings.DefaultDuration")||"Standard bokningslängd"]}),e.jsxs("div",{className:"d-flex align-items-center gap-2",children:[!y&&e.jsx("span",{className:"badge bg-primary",children:D}),e.jsx("i",{className:`bi ${y?"bi-chevron-up":"bi-chevron-down"}`})]})]})}),y&&e.jsx(T.Body,{children:e.jsxs(c,{children:[e.jsxs(c.Group,{className:"mb-4",children:[e.jsx(c.Label,{children:e.jsx("strong",{children:s("BookingSettings.DefaultDuration")||"Standard bokningslängd"})}),e.jsx("p",{className:"text-muted small mb-2",children:s("BookingSettings.DefaultDurationDescription")||"Standardlängd för nya bokningar. Sluttid beräknas automatiskt utifrån denna inställning."}),e.jsx(c.Select,{value:d,onChange:b=>h(Number(b.target.value)),style:{maxWidth:"200px"},children:Qs.map(b=>e.jsx("option",{value:b.value,children:b.label},b.value))})]}),e.jsxs("div",{className:"d-flex gap-2",children:[e.jsx(B,{variant:"primary",onClick:P,disabled:t||!g,children:t?e.jsxs(e.Fragment,{children:[e.jsx(W,{animation:"border",size:"sm",className:"me-2"}),s("CommonText.Saving")||"Sparar..."]}):e.jsx(e.Fragment,{children:s("commonButton.Save")||"Spara"})}),g&&e.jsx(B,{variant:"outline-secondary",onClick:w,disabled:t,children:s("commonButton.Cancel")||"Avbryt"})]})]})})]})},vt=()=>{const{t:s}=ee(),{user:n}=as(),[i,a]=l.useState(!1),[t,o]=l.useState(!1),[d,h]=l.useState(!1),[u,m]=l.useState(""),[g,p]=l.useState(null),[y,x]=l.useState(!1),[k,P]=l.useState(!1);l.useEffect(()=>{n!=null&&n.id&&w()},[n]),l.useEffect(()=>{if(g){const b=d!==(g.bookingReminderEnabled??!1)||u!==(g.bookingReminderCustomText||"");x(b)}},[d,u,g]);const w=async()=>{a(!0);try{const{data:b}=await Q.get(Ns.endPoint(n.id));b!=null&&b.result&&(h(b.result.bookingReminderEnabled??!1),m(b.result.bookingReminderCustomText||""),p(b.result))}catch(b){V.error(re(b))}finally{a(!1)}},D=async()=>{o(!0);try{const b={bookingReminderEnabled:d,bookingReminderCustomText:u.trim()},{data:F}=await Q.put(ws.endPoint(n.id),b);F!=null&&F.result&&(p(F.result),x(!1),V.success(s("success.settingsSaved")))}catch(b){V.error(re(b))}finally{o(!1)}},O=()=>{g&&(h(g.bookingReminderEnabled??!1),m(g.bookingReminderCustomText||""))};return i?e.jsx(T,{className:"mb-4",children:e.jsxs(T.Body,{className:"text-center",children:[e.jsx(W,{animation:"border",size:"sm"}),e.jsx("p",{className:"mt-2 mb-0",children:"Laddar inställningar..."})]})}):e.jsxs(T,{className:"mb-4",children:[e.jsx(T.Header,{style:{cursor:"pointer"},onClick:()=>P(!k),children:e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("h5",{className:"mb-0",children:[e.jsx("i",{className:"bi bi-bell me-2"}),s("ReminderSettings.Title")||"Inställningar för bokningspåminnelse"]}),e.jsxs("div",{className:"d-flex align-items-center gap-2",children:[!k&&e.jsx("span",{className:`badge ${d?"bg-success":"bg-secondary"}`,children:d?s("ReminderSettings.StatusEnabled")||"Aktiverad":s("ReminderSettings.StatusDisabled")||"Inaktiverad"}),e.jsx("i",{className:`bi ${k?"bi-chevron-up":"bi-chevron-down"}`})]})]})}),k&&e.jsx(T.Body,{children:e.jsxs(c,{children:[e.jsx(c.Group,{className:"mb-4",children:e.jsx(c.Check,{type:"switch",id:"booking-reminder-enabled",label:e.jsxs("span",{children:[e.jsx("strong",{children:s("ReminderSettings.EnableLabel")||"Aktivera bokningspåminnelser"}),e.jsx("p",{className:"text-muted mb-0 small",children:s("ReminderSettings.EnableDescription")||"När aktiverat skickas automatiskt en påminnelse via email till kunden en dag innan bokningen."})]}),checked:d,onChange:b=>h(b.target.checked)})}),d&&e.jsxs(e.Fragment,{children:[e.jsxs(c.Group,{className:"mb-4",children:[e.jsx(c.Label,{children:e.jsx("strong",{children:s("ReminderSettings.CustomTextLabel")||"Anpassat meddelande (valfritt)"})}),e.jsx(c.Control,{as:"textarea",rows:6,placeholder:s("ReminderSettings.CustomTextPlaceholder")||"Ange ett personligt meddelande som inkluderas i påminnelsen. Lämna tomt för standardtext.",value:u,onChange:b=>m(b.target.value),maxLength:1e3}),e.jsxs(c.Text,{className:"text-muted",children:[u.length,"/1000 ",s("ReminderSettings.Characters")||"tecken"]}),e.jsxs(H,{variant:"light",className:"mt-3 mb-0 border",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("strong",{children:[e.jsx("i",{className:"bi bi-lightbulb me-2"}),"Använd platshållare för dynamisk text"]})}),e.jsx("p",{className:"small mb-2",children:"Skriv platshållare inom hakparenteser så ersätts de automatiskt med rätt värde:"}),e.jsxs("div",{className:"d-flex flex-wrap gap-2 small",children:[e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"[djurnamn]"}),e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"[kundnamn]"}),e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"[datum]"}),e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"[tid]"}),e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"[sluttid]"}),e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"[tjänster]"}),e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"[adress]"})]}),e.jsx("p",{className:"small text-muted mt-2 mb-0",children:'Exempel: "Glöm inte att ha [djurnamn] redo imorgon kl [tid]!"'})]}),!u.trim()&&e.jsxs(H,{variant:"info",className:"mt-2 small mb-0",children:[e.jsx("i",{className:"bi bi-info-circle me-2"}),s("ReminderSettings.DefaultTextInfo")||"När inget anpassat meddelande anges används en standardpåminnelse med bokningsdetaljer."]})]}),e.jsxs(c.Group,{className:"mb-4",children:[e.jsx(c.Label,{children:e.jsx("strong",{children:s("ReminderSettings.PreviewLabel")||"Förhandsvisning"})}),e.jsx(T,{bg:"light",children:e.jsxs(T.Body,{className:"small",children:[e.jsx("p",{className:"mb-2",children:e.jsx("strong",{children:"Hej Anna Andersson,"})}),e.jsx("p",{className:"mb-2",children:s("ReminderSettings.PreviewIntro")||"Detta är en påminnelse om din bokning som är planerad imorgon!"}),e.jsx("div",{className:"mb-2 p-2 bg-warning bg-opacity-10 rounded border border-warning",children:e.jsx("p",{className:"mb-0 fw-bold text-center",children:"Din bokning är imorgon onsdag, 5 februari 2025 kl 10:00"})}),e.jsxs("div",{className:"mb-2 p-2 bg-white rounded",children:[e.jsxs("p",{className:"mb-1",children:[e.jsxs("strong",{children:[s("ReminderSettings.PreviewDate")||"Datum",":"]})," onsdag, 5 februari 2025"]}),e.jsxs("p",{className:"mb-1",children:[e.jsxs("strong",{children:[s("ReminderSettings.PreviewTime")||"Tid",":"]})," 10:00 - 11:30"]}),e.jsxs("p",{className:"mb-1",children:[e.jsxs("strong",{children:[s("ReminderSettings.PreviewAnimal
1s")||"Djur",":"]})," Mirre, Storm"]}),e.jsxs("p",{className:"mb-0",children:[e.jsxs("strong",{children:[s("ReminderSettings.PreviewServices")||"Tjänster",":"]})," Verkning, Skoning"]})]}),u.trim()&&e.jsx("div",{className:"mb-2 p-2 border-start border-primary border-3 bg-white",children:e.jsx("p",{className:"mb-0 font-italic",style:{whiteSpace:"pre-line"},children:u.replace(/\[djurnamn\]/gi,"Mirre, Storm").replace(/\[kundnamn\]/gi,"Anna Andersson").replace(/\[datum\]/gi,"onsdag, 5 februari 2025").replace(/\[tid\]/gi,"10:00").replace(/\[starttid\]/gi,"10:00").replace(/\[sluttid\]/gi,"11:30").replace(/\[tjänster\]/gi,"Verkning, Skoning").replace(/\[tjanster\]/gi,"Verkning, Skoning").replace(/\[adress\]/gi,"Storgatan 1, 12345 Stockholm").replace(/\[plats\]/gi,"Storgatan 1, 12345 Stockholm")})}),e.jsx("p",{className:"mb-0 text-muted",children:s("ReminderSettings.PreviewFooter")||"Observera: Om du behöver göra ändringar eller avboka, vänligen kontakta oss så snart som möjligt."})]})})]})]}),e.jsxs("div",{className:"d-flex gap-2",children:[e.jsx(B,{variant:"primary",onClick:D,disabled:t||!y,children:t?e.jsxs(e.Fragment,{children:[e.jsx(W,{animation:"border",size:"sm",className:"me-2"}),s("CommonText.Saving")||"Sparar..."]}):e.jsx(e.Fragment,{children:s("commonButton.Save")||"Spara"})}),y&&e.jsx(B,{variant:"outline-secondary",onClick:O,disabled:t,children:s("commonButton.Cancel")||"Avbryt"})]})]})})]})},Sn=({language:s,handleLanguageChange:n,handleLanguageUpdate:i})=>{const{t:a}=ee();return e.jsxs(e.Fragment,{children:[e.jsx(yt,{}),e.jsx(St,{}),e.jsx(vt,{}),e.jsxs("div",{className:"from_des_block",children:[e.jsxs("h2",{children:[e.jsx("i",{className:"bi bi-globe me-2"}),a("ProfilePage.Language-Settings")]}),e.jsxs(c,{children:[e.jsx(Te,{children:e.jsxs("div",{className:"mb-3",children:[e.jsx(c.Check,{inline:!0,label:a("English"),name:"language",type:"radio",value:"en",checked:s==="en",onChange:n,id:"lang-en"}),e.jsx(c.Check,{inline:!0,label:a("Swedish"),name:"language",type:"radio",value:"sv",checked:s==="sv",onChange:n,id:"lang-sv"})]})}),e.jsx(B,{className:"form-action-btn-primary mb-5",onClick:i,children:a("ProfilePage.Update")})]})]})]})};Sn.propTypes={language:r.string,handleLanguageChange:r.func.isRequired,handleLanguageUpdate:r.func.isRequired};const kt=()=>{const{t:s}=ee(),[n,i]=l.useState(""),[a,t]=l.useState(!1),[o,d]=l.useState(!1);l.useEffect(()=>{h()},[]);const h=async()=>{try{t(!0);const g=await Q.get(pa.endPoint());g.data.status===!0&&i(g.data.result.icalUrl)}catch(g){console.error("Error fetching iCal token:",g),V.error(re(g)||s("CalendarSync.FetchError"))}finally{t(!1)}},u=async()=>{if(window.confirm(s("CalendarSync.ConfirmRegenerate")))try{d(!0);const g=await Q.post(xa.endPoint());g.data.status===!0&&(i(g.data.result.icalUrl),V.success(s("CalendarSync.Regenerated")))}catch(g){console.error("Error regenerating iCal token:",g),V.error(re(g)||s("CalendarSync.RegenerateError"))}finally{d(!1)}},m=()=>{navigator.clipboard.writeText(n),V.success(s("CalendarSync.Copied"))};return e.jsxs("div",{className:"mb-4",children:[e.jsxs(c.Label,{className:"fw-semibold",children:[e.jsx("i",{className:"bi bi-calendar-check me-2"}),s("CalendarSync.Title")]}),e.jsxs(H,{variant:"info",className:"mt-2",children:[e.jsx("i",{className:"bi bi-info-circle me-2"}),e.jsx("strong",{children:s("CalendarSync.InfoTitle")})," ",s("CalendarSync.InfoBody")]}),a?e.jsx("div",{className:"text-center py-4",children:e.jsx("div",{className:"spinner-border text-success",role:"status",children:e.jsx("span",{className:"visually-hidden",children:s("CommonText.Loading")})})}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"ms-2",children:[e.jsx(c.Label,{className:"fw-semibold mb-2",children:s("CalendarSync.YourLink")}),e.jsxs(at,{className:"mb-3",children:[e.jsx(c.Control,{type:"text",value:n,readOnly:!0,placeholder:s("CalendarSync.LinkPlaceholder")}),e.jsxs(B,{variant:"outline-success",onClick:m,children:[e.jsx("i",{className:"bi bi-clipboard me-1"}),s("CalendarSync.CopyLink")]})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx(B,{variant:"warning",size:"sm",onClick:u,disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner-border spinner-border-sm me-2",role:"status"}),s("CalendarSync.Regenerating")]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-arrow-clockwise me-1"}),s("CalendarSync.Regenerate")]})}),e.jsx("small",{className:"text-muted ms-2",children:s("CalendarSync.RegenerateHint")})]}),e.jsx(c.Label,{className:"fw-semibold mb-2",children:s("CalendarSync.Instructions")}),e.jsxs(Ie,{children:[e.jsxs(Ie.Item,{eventKey:"0",children:[e.jsxs(Ie.Header,{children:[e.jsx("i",{className:"bi bi-google me-2 text-danger"}),"Google Calendar"]}),e.jsxs(Ie.Body,{children:[e.jsxs("ol",{children:[e.jsxs("li",{children:[s("CalendarSync.Google.Step1")," ",e.jsx("a",{href:"https://calendar.google.com",target:"_blank",rel:"noopener noreferrer",children:"Google Calendar"})]}),e.jsx("li",{children:s("CalendarSync.Google.Step2")}),e.jsx("li",{children:s("CalendarSync.Google.Step3")}),e.jsx("li",{children:s("CalendarSync.Google.Step4")}),e.jsx("li",{children:s("CalendarSync.Google.Step5")}),e.jsx("li",{children:s("CalendarSync.Google.Step6")})]}),e.jsx(H,{variant:"secondary",className:"mb-0",children:e.jsxs("small",{children:[e.jsx("strong",{children:s("CalendarSync.Google.NoteLabel")})," ",s("CalendarSync.Google.Note")]})})]})]}),e.jsxs(Ie.Item,{eventKey:"1",children:[e.jsxs(Ie.Header,{children:[e.jsx("i",{className:"bi bi-apple me-2"}),s("CalendarSync.ICloud.Header")]}),e.jsxs(Ie.Body,{children:[e.jsx("h6",{children:s("CalendarSync.ICloud.OnMac")}),e.jsxs("ol",{children:[e.jsx("li",{children:s("CalendarSync.ICloud.MacStep1")}),e.jsx("li",{children:s("CalendarSync.ICloud.MacStep2")}),e.jsx("li",{children:s("CalendarSync.ICloud.MacStep3")}),e.jsx("li",{children:s("CalendarSync.ICloud.MacStep4")}),e.jsx("li",{children:s("CalendarSync.ICloud.MacStep5")})]}),e.jsx("h6",{children:s("CalendarSync.ICloud.OnIphone")}),e.jsxs("ol",{children:[e.jsx("li",{children:s("CalendarSync.ICloud.IosStep1")}),e.jsx("li",{children:s("CalendarSync.ICloud.IosStep2")}),e.jsx("li",{children:s("CalendarSync.ICloud.IosStep3")}),e.jsx("li",{children:s("CalendarSync.ICloud.IosStep4")}),e.jsx("li",{children:s("CalendarSync.ICloud.IosStep5")})]})]})]}),e.jsxs(Ie.Item,{eventKey:"2",children:[e.jsxs(Ie.Header,{children:[e.jsx("i",{className:"bi bi-microsoft me-2 text-primary"}),"Outlook Calendar"]}),e.jsx(Ie.Body,{children:e.jsxs("ol",{children:[e.jsx("li",{children:s("CalendarSync.Outlook.Step1")}),e.jsx("li",{children:s("CalendarSync.Outlook.Step2")}),e.jsx("li",{children:s("CalendarSync.Outlook.Step3")}),e.jsx("li",{children:s("CalendarSync.Outlook.Step4")}),e.jsx("li",{children:s("CalendarSync.Outlook.Step5")}),e.jsx("li",{children:s("CalendarSync.Outlook.Step6")})]})})]})]}),e.jsxs(H,{variant:"warning",className:"mt-3 mb-0",children:[e.jsx("i",{className:"bi bi-shield-exclamation me-2"}),e.jsx("strong",{children:s("CalendarSync.SecurityLabel")}
1)," ",s("CalendarSync.SecurityBody")]})]})})]})},yn=()=>{const{t:s}=ee(),{user:n}=as(),[i,a]=l.useState(!0),[t,o]=l.useState(!1),[d,h]=l.useState({showPharmaceuticals:!0,showDiagnosis:!0,journalTemplate:"standard",askOnDragDrop:!0,jobStartMode:"booked",autoSendServiceReport:!1,requireFacilityNumber:!0,autoSignOnStartJob:!1}),[u,m]=l.useState({showPharmaceuticals:!0,showDiagnosis:!0,journalTemplate:"standard",askOnDragDrop:!0,jobStartMode:"booked",autoSendServiceReport:!1,requireFacilityNumber:!0,autoSignOnStartJob:!1});l.useEffect(()=>{(async()=>{if(n!=null&&n.id)try{const{data:w}=await Q.get(ba.endPoint(n.id));if(w!=null&&w.result){const D={showPharmaceuticals:w.result.showPharmaceuticals??!0,showDiagnosis:w.result.showDiagnosis??!0,journalTemplate:w.result.journalTemplate??"standard",askOnDragDrop:w.result.askOnDragDrop??!0,jobStartMode:w.result.jobStartMode??"booked",requireFacilityNumber:w.result.requireFacilityNumber??!0,autoSendServiceReport:w.result.autoSendServiceReport??!1,autoSignOnStartJob:w.result.autoSignOnStartJob??!1};h(D),m(D)}}catch(w){console.error("Failed to fetch journal settings:",w),V.error(re(w))}finally{a(!1)}})()},[n==null?void 0:n.id]);const g=P=>{h(w=>({...w,[P]:!w[P]}))},p=(P,w)=>{h(D=>({...D,[P]:w}))},y=async()=>{if(n!=null&&n.id){o(!0);try{const{data:P}=await Q.put(ja.endPoint(n.id),d);P!=null&&P.status&&(m(d),V.success(s("JournalSettings.SaveSuccess")))}catch(P){console.error("Failed to save journal settings:",P),V.error(re(P))}finally{o(!1)}}},x=d.showPharmaceuticals!==u.showPharmaceuticals||d.showDiagnosis!==u.showDiagnosis||d.journalTemplate!==u.journalTemplate||d.askOnDragDrop!==u.askOnDragDrop||d.jobStartMode!==u.jobStartMode||d.requireFacilityNumber!==u.requireFacilityNumber||d.autoSendServiceReport!==u.autoSendServiceReport||d.autoSignOnStartJob!==u.autoSignOnStartJob,k=!d.showPharmaceuticals||!d.showDiagnosis;return i?e.jsx("div",{className:"text-center py-4",children:e.jsx(W,{animation:"border",size:"sm"})}):e.jsxs("div",{className:"from_des_block",children:[e.jsxs("h2",{children:[e.jsx("i",{className:"bi bi-journal-medical me-2"}),s("JournalSettings.Title")]}),e.jsx("p",{className:"text-muted mb-4",children:s("JournalSettings.Description")}),e.jsxs(c,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx(c.Label,{className:"fw-semibold",children:s("JournalSettings.TemplateSelection")}),e.jsxs("div",{className:"ms-2",children:[e.jsx(c.Check,{type:"radio",id:"template-standard",name:"journalTemplate",label:e.jsxs("div",{children:[e.jsx("span",{children:s("JournalSettings.StandardTemplate")}),e.jsx("small",{className:"d-block text-muted",children:s("JournalSettings.StandardTemplateDesc")})]}),value:"standard",checked:d.journalTemplate==="standard",onChange:()=>p("journalTemplate","standard"),className:"mb-2"}),e.jsx(c.Check,{type:"radio",id:"template-hovslagare",name:"journalTemplate",label:e.jsxs("div",{children:[e.jsx("span",{children:s("JournalSettings.HovslagareTemplate")}),e.jsx("small",{className:"d-block text-muted",children:s("JournalSettings.HovslagareTemplateDesc")})]}),value:"hovslagare",checked:d.journalTemplate==="hovslagare",onChange:()=>p("journalTemplate","hovslagare")})]})]}),e.jsx("hr",{className:"my-4"}),d.journalTemplate==="standard"&&e.jsxs("div",{className:"mb-4",children:[e.jsx(c.Label,{className:"fw-semibold",children:s("JournalSettings.SectionVisibility")}),e.jsxs("div",{className:"ms-2",children:[e.jsx(c.Check,{type:"switch",id:"showPharmaceuticals",label:s("JournalSettings.ShowPharmaceuticals"),checked:d.showPharmaceuticals,onChange:()=>g("showPharmaceuticals"),className:"mb-3"}),e.jsx(c.Check,{type:"switch",id:"showDiagnosis",label:s("JournalSettings.ShowDiagnosis"),checked:d.showDiagnosis,onChange:()=>g("showDiagnosis")})]})]}),d.journalTemplate==="standard"&&k&&e.jsxs(H,{variant:"info",className:"mb-4",children:[e.jsx("i",{className:"bi bi-info-circle me-2"}),s("JournalSettings.HiddenSectionsInfo")]}),e.jsx("hr",{className:"my-4"}),e.jsxs("div",{className:"mb-4",children:[e.jsxs(c.Label,{className:"fw-semibold",children:[e.jsx("i",{className:"bi bi-calendar3 me-2"}
1),s("JournalSettings.CalendarSettings")]}),e.jsx("div",{className:"ms-2 mb-3",children:e.jsx(c.Check,{type:"switch",id:"askOnDragDrop",label:e.jsxs("div",{children:[e.jsx("span",{children:s("JournalSettings.AskOnDragDrop")}),e.jsx("small",{className:"d-block text-muted",children:s("JournalSettings.AskOnDragDropDesc")})]}),checked:d.askOnDragDrop,onChange:()=>g("askOnDragDrop")})}),e.jsxs("div",{className:"ms-2",children:[e.jsx(c.Label,{className:"fw-semibold mb-2",children:s("JournalSettings.JobStartMode")}),e.jsx(c.Check,{type:"radio",id:"jobStartMode-current",name:"jobStartMode",label:e.jsxs("div",{children:[e.jsx("span",{children:s("JournalSettings.JobStartModeCurrent")}),e.jsx("small",{className:"d-block text-muted",children:s("JournalSettings.JobStartModeCurrentDesc")})]}),value:"current",checked:d.jobStartMode==="current",onChange:()=>p("jobStartMode","current"),className:"mb-2"}),e.jsx(c.Check,{type:"radio",id:"jobStartMode-booked",name:"jobStartMode",label:e.jsxs("div",{children:[e.jsx("span",{children:s("JournalSettings.JobStartModeBooked")}),e.jsx("small",{className:"d-block text-muted",children:s("JournalSettings.JobStartModeBookedDesc")})]}),value:"booked",checked:d.jobStartMode==="booked",onChange:()=>p("jobStartMode","booked")})]})]}),e.jsx("hr",{className:"my-4"}),e.jsxs("div",{className:"mb-4",children:[e.jsxs(c.Label,{className:"fw-semibold",children:[e.jsx("i",{className:"bi bi-pen me-2"}),s("JournalSettings.SigningSettings")]}),e.jsxs("div",{className:"ms-2",children:[e.jsx(c.Check,{type:"switch",id:"requireFacilityNumber",label:e.jsxs("div",{children:[e.jsx("span",{children:s("JournalSettings.RequireFacilityNumber")}),e.jsx("small",{className:"d-block text-muted",children:s("JournalSettings.RequireFacilityNumberDesc")})]}),checked:d.requireFacilityNumber,onChange:()=>g("requireFacilityNumber"),className:"mb-3"}),e.jsx(c.Check,{type:"switch",id:"autoSignOnStartJob",label:e.jsxs("div",{children:[e.jsx("span",{children:s("JournalSettings.AutoSignOnStartJob")}),e.jsx("small",{className:"d-block text-muted",children:s("JournalSettings.AutoSignOnStartJobDesc")})]}),checked:d.autoSignOnStartJob,onChange:()=>g("autoSignOnStartJob")})]})]}),e.jsx("hr",{className:"my-4"}),e.jsxs("div",{className:"mb-4",children:[e.jsxs(c.Label,{className:"fw-semibold",children:[e.jsx("i",{className:"bi bi-send me-2"}),s("JournalSettings.AutoSendTitle")]}),e.jsx("div",{className:"ms-2",children:e.jsx(c.Check,{type:"switch",id:"autoSendServiceReport",label:e.jsxs("div",{children:[e.jsx("span",{children:s("JournalSettings.AutoSendServiceReport")}),e.jsx("small",{className:"d-block text-muted",children:s("JournalSettings.AutoSendServiceReportDesc")})]}),checked:d.autoSendServiceReport,onChange:()=>g("autoSendServiceReport")})})]}),e.jsx(kt,{}),e.jsx(B,{className:"form-action-btn-primary",onClick:y,disabled:t||!x,children:t?e.jsxs(e.Fragment,{children:[e.jsx(W,{animation:"border",size:"sm",className:"me-2"}),s("CommonText.Saving")]}):s("ProfilePage.Update")})]})]})};yn.propTypes={};const vn=({settings:s,onSettingsChange:n,verifiedModules:i})=>{const{t:a}=ee(),t=s.integrationFeatures||{vouchers:!1,invoices:!1,inventory:!1,swishCommerce:!1},o=[{key:"vouchers",name:a("fortnox.features.vouchers.name","Bokföringsverifikat"),description:a("fortnox.features.vouchers.description","Skapa bokföringsverifikat för dagsavslut, intäkter och betalsätt."),license:a("fortnox.features.vouchers.license","Kräver: Fortnox Bokföring"),requires:null},{key:"invoices",name:a("fortnox.features.invoices.name","Kundfakturor"),description:a("fortnox.features.invoices.description","Skapa och skicka kundfakturor. Inkluderar kundregister och kundreskontra."),license:a("fortnox.features.invoices.license","Kräver: Fortnox Fakturering"),requires:null,recommended:!0},{key:"inventory",name:a("fortnox.features.inventory.name","Lagerhantering"),description:a("fortnox.features.inventory.description","Synka artiklar och hantera lagersaldo automatiskt vid försäljning."),license:a("fortnox.features.inventory.license","Kräver: Fortnox Lager + Fakturering"),requires:"invoices",requiresLabel:a("fortnox.features.inventory.requires","Kräver att Kundfakturor är aktiverat"),comingSoon:!0},{key:"swishCommerce",name:a("fortnox.features.swishCommerce.name","Swish Commerce"),description:a("fortnox.features.swishCommerce.description","Integrera Swish-betalningar direkt med Fortnox för automatisk bokföring."),license:a("fortnox.features.swishCommerce.license","Kräver: Swish Commerce-avtal"),requires:null,comingSoon:!0}],d=(p,y)=>{const x={...t,[p]:y};p==="invoices"&&!y&&(x.inventory=!1),n({integrationFeatures:x})},h=p=>(i==null?void 0:i[p])===!0,u=p=>(i==null?void 0:i[p])===!1,m=p=>!!(p.comingSoon||!h(p.key)&&!t[p.key]||p.requires&&!t[p.requires]),g=Object.values(t).some(p=>p);return e.jsxs("div",{children:[e.jsx("h5",{className:"mb-3",children:a("fortnox.wizard.step1Title","Välj integrationsmoduler")}),e.jsx("p",{className:"text-muted mb-4",children:a("fortnox.wizard.step1Description","Välj vilka funktioner du vill aktivera. Du kan välja flera beroende på vilka Fortnox-licenser du har.")}),e.jsx("div",{className:"d-flex flex-column gap-3",children:o.map(p=>{const y=m(p),x=t[p.key]||!1;return e.jsx(T,{className:`${x?"border-primary":""} ${y?"opacity-50":""}`,style:{cursor:y?"not-allowed":"pointer"},onClick:()=>!y&&d(p.key,!x),children:e.jsxs(T.Body,{className:"d-flex align-items-start",children:[e.jsx(c.Check,{type:"checkbox",id:`feature-${p.key}`,checked:x,disabled:y,onChange:k=>d(p.key,k.target.checked),className:"me-3 mt-1",onClick:k=>k.stopPropagation()}),e.jsxs("div",{className:"flex-grow-1",children:[e.jsxs("div",{className:"d-flex align-items-center gap-2 mb-1 flex-wrap",children:[e.jsx("strong",{children:p.name}),p.recommended&&e.jsx(ge,{bg:"success",children:a("fortnox.wizard.recommended","Rekommenderas")}),p.comingSoon&&e.jsx(ge,{bg:"secondary",children:a("fortnox.wizard.comingSoon","Kommer snart")})]}),e.jsx("p",{className:"text-muted mb-1 small",children:p.description}),e.jsx("small",{className:"text-secondary",children:p.license}),!p.comingSoon&&u(p.key)&&e.jsx("div",{className:"mt-1",children:e.jsxs("small",{className:"text-danger",children:[e.jsx("i",{className:"bi bi-x-circle me-1"}),x?a("fortnox.wizard.licenseRevoked","Påslagen här, men Fortnox svarar att kontot saknar modulen. Stäng av den eller återaktivera den i Fortnox."):a("fortnox.wizard.noLicense","Du saknar licens för denna modul i Fortnox")]})}
1),!p.comingSoon&&!h(p.key)&&!u(p.key)&&e.jsx("div",{className:"mt-1",children:e.jsxs("small",{className:"text-secondary",children:[e.jsx("i",{className:"bi bi-question-circle me-1"}),a("fortnox.wizard.notVerified","Inte kontrollerad ännu — anslut till Fortnox så verifieras modulen")]})}),p.requiresLabel&&y&&h(p.key)&&e.jsx("div",{className:"mt-1",children:e.jsxs("small",{className:"text-warning",children:[e.jsx("i",{className:"bi bi-exclamation-triangle me-1"}),p.requiresLabel]})})]})]})},p.key)})}),!g&&e.jsx(H,{variant:"warning",className:"mt-3",children:a("fortnox.wizard.noFeatureSelected","Välj minst en modul för att fortsätta.")})]})};vn.propTypes={settings:r.shape({integrationFeatures:r.shape({vouchers:r.bool,invoices:r.bool,inventory:r.bool,swishCommerce:r.bool})}).isRequired,onSettingsChange:r.func.isRequired,verifiedModules:r.shape({invoices:r.bool,vouchers:r.bool,inventory:r.bool,articles:r.bool})};const kn=({isConnected:s,isConnecting:n,onConnect:i,needsReconnection:a})=>{const{t}=ee();return e.jsxs("div",{children:[e.jsx("h5",{className:"mb-3",children:t("fortnox.wizard.step2Title","Koppla Fortnox")}),e.jsx("p",{className:"text-muted mb-4",children:t("fortnox.wizard.step2Description","Logga in i ditt Fortnox-konto och godkänn att eqwecare får hantera dina fakturor.")}),s&&!a?e.jsxs(H,{variant:"success",className:"d-flex align-items-center",children:[e.jsx("i",{className:"bi bi-check-circle-fill me-2 fs-4"}),e.jsxs("div",{children:[e.jsx("strong",{children:t("fortnox.wizard.connected","Kopplad!")}),e.jsx("p",{className:"mb-0 small",children:t("fortnox.wizard.connectedDescription","Ditt Fortnox-konto är kopplat. Du kan fortsätta till nästa steg.")})]})]}):a?e.jsxs(H,{variant:"warning",className:"d-flex align-items-center",children:[e.jsx("i",{className:"bi bi-exclamation-triangle-fill me-2 fs-4"}),e.jsxs("div",{children:[e.jsx("strong",{children:t("fortnox.wizard.needsReconnection","Koppling behöver förnyas")}),e.jsx("p",{className:"mb-0 small",children:t("fortnox.wizard.needsReconnectionDescription","Din Fortnox-koppling har gått ut. Klicka på knappen nedan för att förnya.")})]})]}):e.jsxs(H,{variant:"info",className:"d-flex align-items-center",children:[e.jsx("i",{className:"bi bi-info-circle-fill me-2 fs-4"}),e.jsxs("div",{children:[e.jsx("strong",{children:t("fortnox.wizard.notConnected","Inte kopplad")}),e.jsx("p",{className:"mb-0 small",children:t("fortnox.wizard.notConnectedDescription","Klicka på knappen nedan för att koppla ditt Fortnox-konto.")})]})]}),e.jsx("div",{className:"mt-4",children:!s||a?e.jsx(B,{variant:"primary",size:"lg",onClick:i,disabled:n,className:"d-flex align-items-center gap-2",children:n?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true"}),t("fortnox.wizard.connecting","Kopplar...")]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-box-arrow-up-right"}),a?t("fortnox.wizard.renewConnection","Förnya koppling"):t("fortnox.wizard.connectFortnox","Koppla Fortnox")]})}):null}),e.jsx("div",{className:"mt-4",children:e.jsxs("p",{className:"text-muted small",children:[e.jsx("i",{className:"bi bi-shield-check me-1"}),t("fortnox.wizard.securityNote","Din data skyddas av Fortnox säkra OAuth-koppling. Vi sparar aldrig ditt Fortnox-lösenord.")]})})]})};kn.propTypes={isConnected:r.bool.isRequired,isConnecting:r.bool,onConnect:r.func.isRequired,needsReconnection:r.bool};const ns=({label:s,description:n,value:i,onChange:a,options:t,layout:o="row",labelCols:d=4,className:h})=>{const u=t&&t.length>0?e.jsx(c.Select,{value:i??"",onChange:m=>a(m.target.value),children:t.map(m=>e.jsxs("option",{value:m.number,children:[m.number," - ",m.description]},m.number))}):e.jsx(c.Control,{type:"number",min:1e3,max:9999,value:i??"",onChange:m=>a(m.target.value)});return o==="stacked"?e.jsxs(c.Group,{className:h,children:[e.jsx(c.Label,{className:"small",children:s}),u]}):e.jsxs(c.Group,{as:Te,className:h??"mb-3",children:[e.jsxs(c.Label,{column:!0,sm:d,children:[s,n&&e.jsx("p",{className:"text-muted small mb-0 fw-normal",children:n})]}),e.jsx(Be,{sm:12-d,children:u})]})};ns.propTypes={label:r.node.isRequired,description:r.node,value:r.oneOfType([r.number,r.string]),onChange:r.func.isRequired,options:r.arrayOf(r.shape({number:r.oneOfType([r.number,r.string]),description:r.string})),layout:r.oneOf(["row","stacked"]),labelCols:r.number,className:r.string};const Nn=({settings:s,onSettingsChange:n,ferrierId:i})=>{var x;const{t:a}
1=ee(),[t,o]=l.useState([]),[d,h]=l.useState(!0),[u,m]=l.useState(null),g=!((x=s.integrationFeatures)!=null&&x.invoices);l.useEffect(()=>{(async()=>{if(i){h(!0),m(null);try{const P=await mn(i,"income");o(P)}catch(P){console.error("Error fetching Fortnox accounts:",P),m(a("fortnox.wizard.accountsFetchError","Kunde inte hämta konton från Fortnox"))}finally{h(!1)}}})()},[i,a]);const p=(k,P)=>{const w=parseInt(P,10);isNaN(w)||n({accountMappings:{...s.accountMappings,[k]:w}})},y=[{key:"productSales",label:a("fortnox.accounts.productSales","Varuförsäljning"),description:a("fortnox.accounts.productSalesDesc","Konto för försäljning av produkter"),defaultValue:3001},{key:"serviceSales",label:a("fortnox.accounts.serviceSales","Tjänsteförsäljning"),description:a("fortnox.accounts.serviceSalesDesc","Konto för försäljning av tjänster"),defaultValue:3002},{key:"groupSales",label:a("fortnox.accounts.groupSales","Paketförsäljning"),description:a("fortnox.accounts.groupSalesDesc","Konto för försäljning av paket/grupper"),defaultValue:3002}];return d?e.jsxs("div",{className:"text-center py-5",children:[e.jsx(W,{animation:"border",role:"status",children:e.jsx("span",{className:"visually-hidden",children:a("common.loading","Laddar...")})}),e.jsx("p",{className:"mt-3 text-muted",children:a("fortnox.wizard.loadingAccounts","Hämtar konton från Fortnox...")})]}):e.jsxs("div",{children:[e.jsx("h5",{className:"mb-3",children:a("fortnox.wizard.step3Title","Kontoinställningar")}),e.jsx("p",{className:"text-muted mb-4",children:a("fortnox.wizard.step3Description","Välj vilka Fortnox-konton som ska användas för olika intäktstyper. Standardvärden följer BAS-kontoplanen.")}),u&&e.jsxs(H,{variant:"warning",className:"mb-4",children:[e.jsx("i",{className:"bi bi-exclamation-triangle me-2"}),u,e.jsx("p",{className:"mb-0 small mt-2",children:a("fortnox.wizard.usingDefaults","Standardkonton används. Du kan ändra dessa manuellt.")})]}),e.jsx(c,{children:y.map(k=>{var P;return e.jsx(ns,{label:k.label,description:k.description,value:((P=s.accountMappings)==null?void 0:P[k.key])||k.defaultValue,onChange:w=>p(k.key,w),options:t},k.key)})}),g&&e.jsxs(e.Fragment,{children:[e.jsx("hr",{className:"my-4"}),e.jsx("h6",{className:"mb-3",children:a("fortnox.wizard.accountingMethodTitle","Bokföringsmetod")}),e.jsx("p",{className:"text-muted small mb-3",children:a("fortnox.wizard.accountingMethodDescription","Välj vilken bokföringsmetod din verksamhet använder. Detta styr när verifikat skapas i Fortnox.")}),e.jsxs(c,{children:[e.jsx(c.Check,{type:"radio",id:"accountingMethod-accrual",name:"accountingMethod",label:e.jsxs("span",{children:[e.jsx("strong",{children:a("fortnox.wizard.accrual","Faktureringsmetoden")}),e.jsx("p",{className:"text-muted small mb-0 fw-normal",children:a("fortnox.wizard.accrualDesc","Verifikat skapas när fakturan låses (DEBIT kundfordringar / CREDIT försäljning + moms). Standard.")})]}),checked:(s.accountingMethod||"accrual")==="accrual",onChange:()=>n({accountingMethod:"accrual"}),className:"mb-3"}),e.jsx(c.Check,{type:"radio",id:"accountingMethod-cash",name:"accountingMethod",label:e.jsxs("span",{children:[e.jsx("strong",{children:a("fortnox.wizard.cash","Kontantmetoden")}),e.jsx("p",{className:"text-muted small mb-0 fw-normal",children:a("fortnox.wizard.cashDesc","Inget verifikat skapas vid låsning. Verifikat skapas proportionellt vid varje betalning (DEBIT bank / CREDIT försäljning + moms).")})]}),checked:s.accountingMethod==="cash",onChange:()=>n({accountingMethod:"cash"})})]}),e.jsxs(H,{variant:"info",className:"mt-3 mb-0 small",children:[e.jsx("i",{className:"bi bi-info-circle me-2"}),a("fortnox.wizard.accountingMethodAutoNote","Denna inställning påverkar enbart voucher-pathen (ferriers med enbart Bokföringslicens). För ferriers med Faktureringslicens hanterar Fortnox själv metoden. Värdet synkas automatiskt från ditt Fortnox-konto vid verifiering.")]})]}),e.jsxs(H,{variant:"info",className:"mt-4",children:[e.jsx("i",{className:"bi bi-info-circle me-2"}),a("fortnox.wizard.accountsNote","Dessa konton används när fakturor skapas i Fortnox. Se till att kontona finns i din kontoplan.")]})]})};Nn.propTypes={settings:r.shape({accountMappings:r.shape({productSales:r.number,serviceSales:r.number,groupSales:r.number}),accountingMethod:r.oneOf(["accrual","cash"])}).isRequired,onSettingsChange:r.func.isRequired,ferrierId:r.string.isRequired};const wn=({settings:s,onSettingsChange:n,ferrierId:i})=>{const{t:a}
1=ee(),[t,o]=l.useState([]),[d,h]=l.useState(!0),[u,m]=l.useState(null);l.useEffect(()=>{(async()=>{if(i){h(!0),m(null);try{const k=await mn(i,"asset");o(k)}catch(k){console.error("Error fetching Fortnox accounts:",k),m(a("fortnox.wizard.accountsFetchError","Kunde inte hämta konton från Fortnox"))}finally{h(!1)}}})()},[i,a]);const g=(x,k)=>{const P=parseInt(k,10);isNaN(P)||n({accountMappings:{...s.accountMappings,[x]:P}})},p=(x,k)=>{n({paymentModes:{...s.paymentModes,[x]:k}})},y=[{key:"swish",label:"Swish",accountKey:"swishReceivables",defaultAccount:1580,defaultMode:"SWISH"},{key:"card",label:a("fortnox.paymentMethods.card","Kortbetalning"),accountKey:"cardReceivables",defaultAccount:1581,defaultMode:"CARD"},{key:"cash",label:a("fortnox.paymentMethods.cash","Kontant"),accountKey:"cashReceivables",defaultAccount:1910,defaultMode:"CASH"},{key:"bankgiro",label:"Bankgiro",accountKey:"bankAccount",defaultAccount:1920,defaultMode:"BG"}];return d?e.jsxs("div",{className:"text-center py-5",children:[e.jsx(W,{animation:"border",role:"status",children:e.jsx("span",{className:"visually-hidden",children:a("common.loading","Laddar...")})}),e.jsx("p",{className:"mt-3 text-muted",children:a("fortnox.wizard.loadingAccounts","Hämtar konton från Fortnox...")})]}):e.jsxs("div",{children:[e.jsx("h5",{className:"mb-3",children:a("fortnox.wizard.step4Title","Betalningsmetoder")}),e.jsx("p",{className:"text-muted mb-4",children:a("fortnox.wizard.step4Description","Konfigurera vilka konton som ska användas för olika betalningsmetoder.")}),u&&e.jsxs(H,{variant:"warning",className:"mb-4",children:[e.jsx("i",{className:"bi bi-exclamation-triangle me-2"}),u,e.jsx("p",{className:"mb-0 small mt-2",children:a("fortnox.wizard.usingDefaults","Standardkonton används. Du kan ändra dessa manuellt.")})]}),e.jsx(c,{children:y.map(x=>{var k,P;return e.jsxs("div",{className:"border rounded p-3 mb-3",children:[e.jsxs("h6",{className:"mb-3",children:[e.jsx("i",{className:`bi ${x.key==="swish"?"bi-phone":x.key==="card"?"bi-credit-card":x.key==="cash"?"bi-cash":"bi-bank"} me-2`}),x.label]}),e.jsx(ns,{className:"mb-2",label:a("fortnox.paymentMethods.accountLabel","Mottagarkonto"),value:((k=s.accountMappings)==null?void 0:k[x.accountKey])||x.defaultAccount,onChange:w=>g(x.accountKey,w),options:t}),e.jsxs(c.Group,{as:Te,children:[e.jsx(c.Label,{column:!0,sm:4,children:a("fortnox.paymentMethods.modeLabel","Betalsättskod")}),e.jsxs(Be,{sm:8,children:[e.jsx(c.Control,{type:"text",value:((P=s.paymentModes)==null?void 0:P[x.key])||x.defaultMode,onChange:w=>p(x.key,w.target.value),placeholder:x.defaultMode,maxLength:20}),e.jsx(c.Text,{className:"text-muted",children:a("fortnox.paymentMethods.modeDescription","Kod som används i Fortnox för denna betalningsmetod")})]})]})]},x.key)})}),e.jsxs(H,{variant:"info",className:"mt-4",children:[e.jsx("i",{className:"bi bi-info-circle me-2"}),a("fortnox.wizard.paymentNote","Se till att betalsättskoderna matchar de som är konfigurerade i ditt Fortnox-konto under Inställningar > Betalsätt.")]})]})};wn.propTypes={settings:r.shape({accountMappings:r.shape({swishReceivables:r.number,cardReceivables:r.number,cashReceivables:r.number,bankAccount:r.number}),paymentModes:r.shape({swish:r.string,card:r.string,cash:r.string,bankgiro:r.string})}).isRequired,onSettingsChange:r.func.isRequired,ferrierId:r.string.isRequired};const Cn=({settings:s,onComplete:n,isCompleting:i,testResult:a})=>{var u,m,g,p,y,x,k,P,w,D,O;const{t}=ee(),o={vouchers:t("fortnox.features.vouchers.name","Bokföringsverifikat"),invoices:t("fortnox.features.invoices.name","Kundfakturor"),inventory:t("fortnox.features.inventory.name","Lagerhantering"),swishCommerce:t("fortnox.features.swishCommerce.name","Swish Commerce")},d=s.integrationFeatures||{},h=Object.entries(d).filter(([,b])=>b).map(([b])=>b);return e.jsxs("div",{children:[e.jsx("h5",{className:"mb-3",children:t("fortnox.wizard.step5Title","Bekräfta inställningar")}),e.jsx("p",{className:"text-muted mb-4",children:t("fortnox.wizard.step5Description","Granska dina inställningar och slutför konfigurationen.")}),e.jsxs(T,{className:"mb-4",children:[e.jsx(T.Header,{children:e.jsx("strong",{children:t("fortnox.wizard.summary","Sammanfattning")})}),e.jsx(T.Body,{children:e.jsxs(Te,{children:[e.jsxs(Be,{md:6,children:[e.jsx("h6",{className:"text-muted mb-2",children:t("fortnox.wizard.activeFeatures","Aktiva moduler")}),e.jsx("div",{className:"mb-3",children:h.length>0?h.map(b=>e.jsxs(ge,{bg:"primary",className:"me-1 mb-1",children:[e.jsx("i",{className:"bi bi-check me-1"}),o[b]||b]},b)):e.jsx("span",{className:"text-muted",children:t("fortnox.wizard.noFeaturesEnabled","Inga moduler valda")})}),e.jsx("h6",{className:"text-muted mb-2",children:t("fortnox.wizard.incomeAccounts","Intäktskonton")}),e.jsxs("ul",{className:"list-unstyled small",children:[e.jsxs("li",{children:[e.jsxs("strong",{children:[t("fortnox.accounts.productSales","Varuförsäljning"),":"]})," ",((u=s.accountMappings)==null?void 0:u.productSales)||3001]}),e.jsxs("li",{children:[e.jsxs("strong",{children:[t("fortnox.accounts.serviceSales","Tjänsteförsäljning"),":"]})," ",((m=s.accountMappings)==null?void 0:m.serviceSales)||3002]}),e.jsxs("li",{children:[e.jsxs("strong",{children:[t("fortnox.accounts.groupSales","Paketförsäljning"),":"]})," ",((g=s.accountMappings)==null?void 0:g.groupSales)||3002]})]})]}),e.jsxs(Be,{md:6,children:[e.jsx("h6",{className:"text-muted mb-2",children:t("fortnox.wizard.paymentAccounts","Betalningskonton")}),e.jsxs("ul",{className:"list-unstyled small",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Swish:"})," ",((p=s.accountMappings)==null?void 0:p.swishReceivables)||1580," (",((y=s.paymentModes)==null?void 0:y.swish)||"SWISH",")"]}),e.jsxs("li",{children:[e.jsxs("strong",{children:[t("fortnox.paymentMethods.card","Kort"),":"]})," ",((x=s.accountMappings)==null?void 0:x.cardReceivables)||1581," (",((k=s.paymentModes)==null?void 0:k.card)||"CARD",")"]}),e.jsxs("li",{children:[e.jsxs("strong",{children:[t("fortnox.paymentMethods.cash","Kontant"),":"]})," ",((P=s.accountMappings)==null?void 0:P.cashReceivables)||1910," (",((w=s.paymentModes)==null?void 0:w.cash)||"CASH",")"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Bankgiro:"})," ",((D=s.accountMappings)==null?void 0:D.bankAccount)||1920," (",((O=s.paymentModes)==null?void 0:O.bankgiro)||"BG",")"]})]}),e.jsx("h6",{className:"text-muted mb-2 mt-3",children:t("fortnox.wizard.autoSettings","Automatiska inställningar")}),e.jsxs("ul",{className:"list-unstyled small",children:[e.jsxs("li",{children:[e.jsx("i",{className:`bi ${s.autoSyncInvoices!==!1?"bi-check-circle text-success":"bi-x-circle text-danger"} me-1`}),t("fortnox.wizard.autoSyncInvoices","Synka fakturor automatiskt")]}),e.jsxs("li",{children:[e.jsx("i",{className:`bi ${s.autoBookkeepInvoices!==!1?"bi-check-circle text-success":"bi-x-circle text-danger"} me-1`}),t("fortnox.wizard.autoBookkeep","Bokför fakturor automatiskt")]}),!d.invoices&&e.jsxs("li",{children:[e.jsx("i",{className:"bi bi-journal-bookmark-fill text-primary me-1"}),t("fortnox.wizard.accountingMethodLabel","Bokföringsmetod"),":"," ",e.jsx("strong",{children:s.accountingMethod==="cash"?t("fortnox.wizard.cash","Kontantmetoden"):t("fortnox.wizard.accrual","Faktureringsmetoden")})]})]})]})]})})]}),a&&e.jsx(H,{variant:a.success?"success":"danger",className:"mb-4",children:a.success?e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-check-circle-fill me-2"}),e.jsx("strong",{children:t("fortnox.wizard.testSuccess","Anslutningstest lyckat!")}),e.jsxs("p",{className:"mb-0 mt-2",children:[t("fortnox.wizard.connectedTo","Kopplad till"),": ",e.jsx("strong",{children:a.companyName}),e.jsx("br",{}),t("fortnox.wizard.orgNumber","Organisationsnummer"),": ",a.organizationNumber]})]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-x-circle-fill me-2"}),e.jsx("strong",{children:t("fortnox.wizard.testFailed","Anslutningstest misslyckades")}),e.jsx("p",{className:"mb-0 mt-2",children:a.error})]})}),e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("small",{className:"text-muted",children:[e.jsx("i",{className:"bi bi-info-circle me-1"}),t("fortnox.wizard.canEditLater","Du kan ändra dessa inställningar senare under Profil > Ekonomisystem.")]}),e.jsx(B,{variant:"success",size:"lg",onClick:()=>n(!0),disabled:i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true",className:"me-2"}),t("fortnox.wizard.completing","Slutför...")]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-check2-circle me-2"}),t("fortnox.wizard.completeSetup","Slutför konfiguration")]})})]})]})};Cn.propTypes={settings:r.shape({integrationFeatures:r.shape({vouchers:r.bool,invoices:r.bool,inventory:r.bool,swishCommerce:r.bool}),accountMappings:r.object,paymentModes:r.object,autoSyncInvoices:r.bool,autoBookkeepInvoices:r.bool,accountingMethod:r.oneOf(["accrual","cash"])}).isRequired,onComplete:r.func.isRequired,isCompleting:r.bool,testResult:r.shape({success:r.bool,companyName:r.string,organizationNumber:r.string,error:r.string})};const Pn=({show:s,onHide:n,ferrierId:i,onComplete:a})=>{const{t}=ee(),[o,d]=l.useState(1),[h,u]=l.useState({integrationFeatures:{vouchers:!1,invoices:!1,inventory:!1,swishCommerce:!1},accountMappings:{productSales:3001,serviceSales:3002,groupSales:3002,swishReceivables:1580,cardReceivables:1581,c
1ashReceivables:1910,bankAccount:1920},paymentModes:{swish:"SWISH",card:"CARD",cash:"CASH",bankgiro:"BG"},autoSyncInvoices:!0,autoBookkeepInvoices:!0,accountingMethod:"accrual"}),[m,g]=l.useState(!1),[p,y]=l.useState(!1),[x,k]=l.useState(!1),[P,w]=l.useState(null),[D,O]=l.useState(!1),[b,F]=l.useState(!0),[K,U]=l.useState(!1),[I,Y]=l.useState(null),[Z,je]=l.useState(null),le=5;l.useEffect(()=>{s&&i&&fe()},[s,i]);const fe=async()=>{F(!0),Y(null);try{const C=await un(i);g(C.connected),y(C.needsReconnection||!1);const j=await hn(i);j&&(u(se=>({...se,...j,integrationFeatures:{...se.integrationFeatures,...j.integrationFeatures},accountMappings:{...se.accountMappings,...j.accountMappings},paymentModes:{...se.paymentModes,...j.paymentModes}})),j.verifiedModules&&w(j.verifiedModules),!j.onboardingCompleted&&j.onboardingStep&&d(C.connected?j.onboardingStep:1))}catch(C){console.error("Error loading Fortnox data:",C),Y(t("fortnox.wizard.loadError","Kunde inte ladda inställningar"))}finally{F(!1)}},oe=C=>{u(j=>({...j,...C,integrationFeatures:C.integrationFeatures?{...j.integrationFeatures,...C.integrationFeatures}:j.integrationFeatures,accountMappings:C.accountMappings?{...j.accountMappings,...C.accountMappings}:j.accountMappings,paymentModes:C.paymentModes?{...j.paymentModes,...C.paymentModes}:j.paymentModes}))},G=async()=>{k(!0);try{const C=!!window.ReactNativeWebView,j=await gn(i,C?"app":"web");C?window.ReactNativeWebView.postMessage(JSON.stringify({type:"fortnoxAuth",authUrl:j})):window.location.href=j}catch(C){console.error("Error connecting to Fortnox:",C),Y(t("fortnox.wizard.connectError","Kunde inte starta Fortnox-koppling")),k(!1)}},q=async()=>{var C,j;U(!0);try{return await it(i,{...h,onboardingStep:o}),!0}catch(se){return console.error("Error saving settings:",se),((j=(C=se==null?void 0:se.response)==null?void 0:C.data)==null?void 0:j.errorCode)==="MODULE_NOT_VERIFIED"?(Y(se.response.data.message||t("fortnox.wizard.moduleNotVerified","Modulen kan inte aktiveras eftersom Fortnox inte har bekräftat att kontot har den.")),!1):!0}finally{U(!1)}},ce=async()=>{if(await q()){if(o===1&&m){O(!0),Y(null);try{const j=await tt(i);j.modules&&w({invoices:j.modules.invoices,vouchers:j.modules.vouchers,inventory:j.modules.inventory,articles:j.modules.articles})}catch(j){console.error("Module verification failed:",j),Y(t("fortnox.wizard.verifyError","Kunde inte kontrollera vilka moduler ditt Fortnox-konto har. Försök igen — moduler som inte är bekräftade går inte att aktivera."))}finally{O(!1)}}o<le&&d(j=>j+1)}},ae=()=>{o>1&&d(C=>C-1)},de=async(C=!1)=>{var j;U(!0),Y(null);try{const se=await rt(i,C);se.testResult&&je(se.testResult),a&&a(se),(!C||(j=se.testResult)!=null&&j.success)&&n()}catch(se){console.error("Error completing onboarding:",se),Y(t("fortnox.wizard.completeError","Kunde inte slutföra konfigurationen"))}finally{U(!1)}},me=()=>{switch(o){case 1:return m&&!p;case 2:{const C=h.integrationFeatures||{};return Object.values(C).some(j=>j===!0)}case 3:return!0;case 4:return!0;case 5:return!0;default:return!1}},ue=()=>{switch(o){case 1:return e.jsx(kn,{isConnected:m,isConnecting:x,needsReconnection:p,onConnect:G});case 2:return e.jsx(vn,{settings:h,onSettingsChange:oe,verifiedModules:P});case 3:return e.jsx(Nn,{settings:h,onSettingsChange:oe,ferrierId:i});case 4:return e.jsx(wn,{settings:h,onSettingsChange:oe,ferrierId:i});case 5:return e.jsx(Cn,{settings:h,onComplete:de,isCompleting:K,testResult:Z});default:return null}},R=[t("fortnox.wizard.step1Label","Koppla"),t("fortnox.wizard.step2Label","Moduler"),t("fortnox.wizard.step3Label","Konton"),t("fortnox.wizard.step4Label","Betalning"),t("fortnox.wizard.step5Label","Bekräfta")];return e.jsxs(J,{show:s,onHide:n,size:"lg",centered:!0,backdrop:"static",children:[e.jsx(J.Header,{closeButton:!0,children:e.jsxs(J.Title,{children:[e.jsx("i",{className:"bi bi-gear me-2"}),t("fortnox.wizard.title","Konfigurera Fortnox")]})}),e.jsxs(J.Body,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"d-flex justify-content-between mb-2",children:R.map((C,j)=>e.jsxs("span",{className:`small ${o===j+1?"fw-bold text-primary":o>j+1?"text-success":"text-muted"}`,children:[o>j+1&&e.jsx("i",{className:"bi bi-check-circle-fill me-1"}),C]},j))}),e.jsx(jn,{now:o/le*100,variant:"primary",style:{height:"4px"}})]}),I&&e.jsxs(H,{variant:"danger",dismissible:!0,onClose:()=>Y(null),children:[e.jsx("i",{className:"bi bi-exclamation-triangle me-2"}),I]}),b?e.jsxs("div",{className:"text-center py-5",children:[e.jsx(W,{animation:"border",role:"status",children:e.jsx("span",{className:"visually-hidden",children:t("common.loading","Laddar...")})}),e.jsx("p",{className:"mt-3 text-muted",children:t("fortnox.wizard.loading","Laddar inställningar...")})]}):ue()]}),e.jsxs(J.Footer,{children:[o>1&&o<5&&e.jsxs(B,{variant:"outline-secondary",onClick:ae,disabled:K,children:[e.jsx("i",{className:"bi bi-arrow-left me-1"}),t("common.back","Tillbaka")]}),e.jsx(B,{variant:"outline-secondary",onClick:n,disabled:K,children:t("common.cancel","Avbryt")}),o<5&&e.jsx(B,{variant:"primary",onClick:ce,disabled:!me()||K||D,children:K||D?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true",className:"me-2"}),D?t("fortnox.wizard.verifying","Kontrollerar moduler..."):t("common.saving","Sparar...")]}):e.jsxs(e.Fragment,{children:[t("common.next","Nästa"),e.jsx("i",{className:"bi bi-arrow-right ms-1"})]})})]})]})};Pn.propTypes={show:r.bool.isRequired,onHide:r.func.isRequired,ferrierId:r.string.isRequired,onComplete:r.func};const Fn=({settings:s,onSettingsChange:n,verifiedModules:i,availableModules:a})=>{const{t}=ee(),o=s.integrationFeatures||{invoices:!0,payments:!0,eInvoice:!1,articleSync:!1},d=[{key:"invoices",name:t("spiris.features.invoices.name","Kundfakturor"),description:t("spiris.features.invoices.description","Skapa och skicka kundfakturor via Visma eAccounting. Inkluderar kundregister och automatisk bokföring."),license:t("spiris.features.invoices.license","Ingår i Visma eAccounting"),requires:null,recommended:!0},{key:"payments",name:t("spiris.features.payments.name","Betalningsbevakning"),description:t("spiris.features.payments.description","Automatisk bevakning av betalningsstatus. Betalningar i Visma uppdateras i eqwecare var 15:e minut."),license:t("spiris.features.payments.license","Ingår i Visma eAccounting"),requires:"invoices",requiresLabel:t("spiris.features.payments.requires","Kräver att Kundfakturor är aktiverat")},{key:"eInvoice",name:t("spiris.features.eInvoice.name","E-faktura (Peppol)"),description:t("spiris.features.eInvoice.description","Skicka e-fakturor via Peppol-nätverket direkt från eqwecare."),license:t("spiris.features.eInvoice.license","Kräver: Peppol-registrering i Visma"),requires:"invoices",requiresLabel:t("spiris.features.eInvoice.requires","Kräver att Kundfakturor är aktiverat"),hidden:!0},{key:"articleSync",name:t("spiris.features.articleSync.name","Artikelsynkronisering"),description:t("spiris.features.articleSync.description","Synka tjänster och produkter automatiskt till Visma eAccounting."),license:t("spiris.features.articleSync.license","Ingår i Visma eAccounting"),requires:null,hidden:!0}],h=(x,k)=>{const P={...o,[x]:k};x==="invoices"&&!k&&(P.payments=!1,P.eInvoice=!1),n({integrationFeatures:P})},u=x=>a?a[x]===!1:!1,m=x=>i?i[x==="articleSync"?"articles":x]===!1:!1,g=x=>u(x)||m(x),p=x=>!!(g(x.key)||x.requires&&!o[x.requires]);l.useEffect(()=>{if(!i&&!a)return;const x={};for(const k of Object.keys(o))o[k]&&g(k)&&(x[k]=!1);Object.keys(x).length>0&&n({integrationFeatures:{...o,...x}})},[i,a]),l.useEffect(()=>{const x={};for(const k of d)k.hidden&&o[k.key]&&(x[k.key]=!1);Object.keys(x).length>0&&n({integrationFeatures:{...o,...x}})},[]);const y=Object.values(o).some(x=>x);return e.jsxs("div",{children:[e.jsx("h5",{className:"mb-3",children:t("spiris.wizard.step1Title","Välj integrationsmoduler")}),e.jsx("p",{className:"text-muted mb-4",children:t("spiris.wizard.step1Description","Välj vilka funktioner du vill aktivera i din Visma eAccounting-integration.")}),e.jsx("div",{className:"d-flex flex-column gap-3",children:d.filter(x=>!x.hidden).map(x=>{const k=p(x),P=o[x.key]||!1;return e.jsx(T,{className:`${P?"border-primary":""} ${k?"opacity-50":""}`,style:{cursor:k?"not-allowed":"pointer"},onClick:()=>!k&&h(x.key,!P),children:e.jsxs(T.Body,{className:"d-flex align-items-start",children:[e.jsx(c.Check,{type:"checkbox",id:`feature-${x.key}`,checked:P,disabled:k,onChange:w=>h(x.key,w.target.checked),className:"me-3 mt-1",onClick:w=>w.stopPropagation()}),e.jsxs("div",{className:"flex-grow-1",children:[e.jsxs("div",{className:"d-flex align-items-center gap-2 mb-1 flex-wrap",children:[e.jsx("strong",{children:x.name}),x.recommended&&e.jsx(ge,{bg:"success",children:t("spiris.wizard.recommended","Rekommenderas")})]}),e.jsx("p",{className:"text-muted mb-1 small",children:x.description}),e.jsx("small",{className:"text-secondary",children:x.license}),u(x.key)&&e.jsx("div",{className:"mt-1",children:e.jsxs("small",{className:"text-danger",children:[e.jsx("i",{className:"bi bi-x-circle me-1"}),t("spiris.wizard.scopeMissing","Du nekade denna behörighet vid kopplingen — koppla om för att ändra")]})}),!u(x.key)&&m(x.key)&&e.jsx("div",{className:"mt-1",children:e.jsxs("small",{className:"text-danger",children:[e.jsx("i",{className:"bi bi-x-circle me-1"}),t("spiris.wizard.noLicense","Du saknar tillgång till denna funktion i Visma eAccounting")]})}),x.requiresLabel&&k&&!g(x.key)&&e.jsx("div",{className:"mt-1",children:e.jsxs("small",{className:"text-warning",children:[e.jsx("i",{className:"bi bi-exclamation-triangle me-1"}),x.requiresLabel]})})]})]})},x.key)})}),!y&&e.jsx(H,{variant:"warning",className:"mt-3",children:t("spiris.wizard.noFeatureSelected","Välj minst en modul för att fortsätta.")})]})};Fn.propTypes={settings:r.shape({integrationFeatures:r.shape({invoices:r.bool,payments:r.bool,eInvoice:r.bool,articleSync:r.bool})}).isRequired,onSettingsChange:r.func.isRequired,verifiedModules:r.shape({invoices:r.bool,payments:r.bool,customers:r.bool,articles:r.bool}),availableModules:r.shape({invoices:r.bool,payments:r.bool,articleSync:r.bool,eInvoice:r.bool})};const En=({isConnected:s,isConnecting:n,onConnect:i,needsReconnection:a})=>{const{t}=ee();return e.jsxs("div",{children:[e.jsx("h5",{className:"mb-3",children:t("spiris.wizard.step2Title","Koppla Spiris")}),e.jsx("p",{className:"text-muted mb-4",children:t("spiris.wizard.step2Description","
1Logga in i ditt Visma eAccounting-konto och godkänn att eqwecare får hantera dina fakturor.")}),s&&!a?e.jsxs(H,{variant:"success",className:"d-flex align-items-center",children:[e.jsx("i",{className:"bi bi-check-circle-fill me-2 fs-4"}),e.jsxs("div",{children:[e.jsx("strong",{children:t("spiris.wizard.connected","Kopplad!")}),e.jsx("p",{className:"mb-0 small",children:t("spiris.wizard.connectedDescription","Ditt Visma eAccounting-konto är kopplat. Du kan fortsätta till nästa steg.")})]})]}):a?e.jsxs(H,{variant:"warning",className:"d-flex align-items-center",children:[e.jsx("i",{className:"bi bi-exclamation-triangle-fill me-2 fs-4"}),e.jsxs("div",{children:[e.jsx("strong",{children:t("spiris.wizard.needsReconnection","Koppling behöver förnyas")}),e.jsx("p",{className:"mb-0 small",children:t("spiris.wizard.needsReconnectionDescription","Din Spiris-koppling har gått ut. Klicka på knappen nedan för att förnya.")})]})]}):e.jsxs(H,{variant:"info",className:"d-flex align-items-center",children:[e.jsx("i",{className:"bi bi-info-circle-fill me-2 fs-4"}),e.jsxs("div",{children:[e.jsx("strong",{children:t("spiris.wizard.notConnected","Inte kopplad")}),e.jsx("p",{className:"mb-0 small",children:t("spiris.wizard.notConnectedDescription","Klicka på knappen nedan för att koppla ditt Visma eAccounting-konto.")})]})]}),e.jsx("div",{className:"mt-4",children:!s||a?e.jsx(B,{variant:"primary",size:"lg",onClick:i,disabled:n,className:"d-flex align-items-center gap-2",children:n?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true"}),t("spiris.wizard.connecting","Kopplar...")]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-box-arrow-up-right"}),a?t("spiris.wizard.renewConnection","Förnya koppling"):t("spiris.wizard.connectSpiris","Koppla Spiris")]})}):null}),e.jsx("div",{className:"mt-4",children:e.jsxs("p",{className:"text-muted small",children:[e.jsx("i",{className:"bi bi-shield-check me-1"}),t("spiris.wizard.securityNote","Din data skyddas av Vismas säkra OAuth-koppling. Vi sparar aldrig ditt lösenord.")]})})]})};En.propTypes={isConnected:r.bool.isRequired,isConnecting:r.bool,onConnect:r.func.isRequired,needsReconnection:r.bool};const Bn=({settings:s,onSettingsChange:n,ferrierId:i})=>{const{t:a}=ee(),t=(h,u)=>{const m=parseInt(u,10);isNaN(m)||n({accountMappings:{...s.accountMappings,[h]:m}})},o=[{key:"productSales",label:a("spiris.accounts.productSales","Varuförsäljning"),description:a("spiris.accounts.productSalesDesc","Konto för försäljning av produkter"),defaultValue:3011},{key:"serviceSales",label:a("spiris.accounts.serviceSales","Tjänsteförsäljning"),description:a("spiris.accounts.serviceSalesDesc","Konto för försäljning av tjänster"),defaultValue:3010},{key:"groupSales",label:a("spiris.accounts.groupSales","Paketförsäljning"),description:a("spiris.accounts.groupSalesDesc","Konto för försäljning av paket/grupper"),defaultValue:3010}],d=[{key:"outputVat25",label:a("spiris.accounts.vat25","Utgående moms 25%"),defaultValue:2610},{key:"outputVat12",label:a("spiris.accounts.vat12","Utgående moms 12%"),defaultValue:2620},{key:"outputVat6",label:a("spiris.accounts.vat6","Utgående moms 6%"),defaultValue:2630}];return e.jsxs("div",{children:[e.jsx("h5",{className:"mb-3",children:a("spiris.wizard.step3Title","Kontoinställningar")}),e.jsx("p",{className:"text-muted mb-4",children:a("spiris.wizard.step3Description","Välj vilka konton som ska användas för olika intäktstyper och moms. Standardvärden följer BAS-kontoplanen.")}),e.jsxs(c,{children:[e.jsx("h6",{className:"mb-3",children:a("spiris.wizard.incomeAccounts","Intäktskonton")}),o.map(h=>{var u;return e.jsx(ns,{label:h.label,description:h.description,value:((u=s.accountMappings)==null?void 0:u[h.key])||h.defaultValue,onChange:m=>t(h.key,m)},h.key)}),e.jsx("h6",{className:"mb-3 mt-4",children:a("spiris.wizard.vatAccounts","Momskonton")}),d.map(h=>{var u;return e.jsx(ns,{label:h.label,value:((u=s.accountMappings)==null?void 0:u[h.key])||h.defaultValue,onChange:m=>t(h.key,m)},h.key)})]}),e.jsxs(H,{variant:"info",className:"mt-4",children:[e.jsx("i",{className:"bi bi-info-circle me-2"}),a("spiris.wizard.accountsNote","Dessa konton används som referens vid SIE-export och bokföring. Visma eAccounting hanterar kontomappning automatiskt.")]})]})};Bn.propTypes={settings:r.shape({accountMappings:r.shape({productSales:r.number,serviceSales:r.number,groupSales:r.number,outputVat25:r.number,outputVat12:r.number,outputVat6:r.number})}).isRequired,onSettingsChange:r.func.isRequired,ferrierId:r.string.isRequired};const An=({settings:s,onSettingsChange:n,ferrierId:i})=>{const{t:a}=ee(),t=(d,h)=>{const u=parseInt(h,10);isNaN(u)||n({accountMappings:{...s.accountMappings,[d]:u}})},o=[{key:"swish",label:"Swish",accountKey:"swishAccount",defaultAccount:1920,icon:"bi-phone"},{key:"card",label:a("spiris.paymentMethods.card","Kortbetalning"),accountKey:"cardAccount",defaultAccount:1920,icon:"bi-credit-card"},{key:"cash",label:a("spiris.paymentMethods.cash","Kontant"),accountKey:"cashAccount",defaultAccount:1910,icon:"bi-cash"},{key:"bankgiro",label:"Bankgiro",accountKey:"bankAccount",defaultAccount:1920,icon:"bi-bank"}];return e.jsxs("div",{children:[e.jsx("h5",{className:"mb-3",children:a("spiris.wizard.step4Title","Betalningsmetoder")}),e.jsx("p",{className:"text-muted mb-4",children:a("spiris.wizard.step4Description","Konfigurera vilka konton som ska användas för olika betalningsmetoder.")}),e.jsx(c,{children:o.map(d=>{var h;return e.jsxs("div",{className:"border rounded p-3 mb-3",children:[e.jsxs("h6",{className:"mb-3",children:[e.jsx("i",{className:`bi ${d.icon} me-2`}),d.label]}),e.jsxs(c.Group,{as:Te,children:[e.jsx(c.Label,{column:!0,sm:4,children:a("spiris.paymentMethods.accountLabel","Mottagarkonto")}),e.jsx(Be,{sm:8,children:e.jsx(c.Control,{type:"number",value:((h=s.accountMappings)==null?void 0:h[d.accountKey])||d.defaultAccount,onChange:u=>t(d.accountKey,u.target.value),min:1e3,max:9999})})]})]},d.key)})}),e.jsxs(H,{variant:"info",className:"mt-4",children:[e.jsx("i",{className:"bi bi-info-circle me-2"}),a("spiris.wizard.paymentNote","Dessa konton används som referens vid SIE-export. Betalningar i Visma hanteras automatiskt.")]})]})};An.propTypes={settings:r.shape({accountMappings:r.shape({swishAccount:r.number,cardAccount:r.number,cashAccount:r.number,bankAccount:r.number})}).isRequired,onSettingsChange:r.func.isRequired,ferrierId:r.string.isRequired};const Ln=({settings:s,onComplete:n,isCompleting:i,testResult:a})=>{var u,m,g,p,y,x,k,P,w,D;const{t}=ee(),o={invoices:t("spiris.features.invoices.name","Kundfakturor"),payments:t("spiris.features.payments.name","Betalningsbevakning"),eInvoice:t("spiris.features.eInvoice.name","E-faktura (Peppol)"),articleSync:t("spiris.features.articleSync.name","Artikelsynkronisering")},d=s.integrationFeatures||{},h=Object.entries(d).filter(([,O])=>O).map(([O])=>O);return e.jsxs("div",{children:[e.jsx("h5",{className:"mb-3",children:t("spiris.wizard.step5Title","Bekräfta inställningar")}),e.jsx("p",{className:"text-muted mb-4",children:t("spiris.wizard.step5Description","Granska dina inställningar och slutför konfigurationen.")}),e.jsxs(T,{className:"mb-4",children:[e.jsx(T.Header,{children:e.jsx("strong",{children:t("spiris.wizard.summary","Sammanfattning")})}),e.jsx(T.Body,{children:e.jsxs(Te,{children:[e.jsxs(Be,{md:6,children:[e.jsx("h6",{className:"text-muted mb-2",children:t("spiris.wizard.activeFeatures","Aktiva moduler")}),e.jsx("div",{className:"mb-3",children:h.length>0?h.map(O=>e.jsxs(ge,{bg:"primary",className:"me-1 mb-1",children:[e.jsx("i",{className:"bi bi-check me-1"}),o[O]||O]},O)):e.jsx("span",{className:"text-muted",children:t("spiris.wizard.noFeaturesEnabled","Inga moduler valda")})}),e.jsx("h6",{className:"text-muted mb-2",children:t("spiris.wizard.incomeAccounts","Intäktskonton")}),e.jsxs("ul",{className:"list-unstyled small",children:[e.jsxs("li",{children:[e.jsxs("strong",{children:[t("spiris.accounts.productSales","Varuförsäljning"),":"]})," ",((u=s.accountMappings)==null?void 0:u.productSales)||3011]}),e.jsxs("li",{children:[e.jsxs("strong",{children:[t("spiris.accounts.serviceSales","Tjänsteförsäljning"),":"]})," ",((m=s.accountMappings)==null?void 0:m.serviceSales)||3010]}),e.jsxs("li",{children:[e.jsxs("strong",{children:[t("spiris.accounts.groupSales","Paketförsäljning"),":"]})," ",((g=s.accountMappings)==null?void 0:g.groupSales)||3010]})]}),e.jsx("h6",{className:"text-muted mb-2 mt-3",children:t("spiris.wizard.vatAccounts","Momskonton")}),e.jsxs("ul",{className:"list-unstyled small",children:[e.jsxs("li",{children:[e.jsxs("strong",{children:[t("spiris.accounts.vat25","Utgående moms 25%"),":"]})," ",((p=s.accountMappings)==null?void 0:p.outputVat25)||2610]}),e.jsxs("li",{children:[e.jsxs("strong",{children:[t("spiris.accounts.vat12","Utgående moms 12%"),":"]})," ",((y=s.accountMappings)==null?void 0:y.outputVat12)||2620]}),e.jsxs("li",{children:[e.jsxs("strong",{children:[t("spiris.accounts.vat6","Utgående moms 6%"),":"]})," ",((x=s.accountMappings)==null?void 0:x.outputVat6)||2630]})]})]}),e.jsxs(Be,{md:6,children:[e.jsx("h6",{className:"text-muted mb-2",children:t("spiris.wizard.paymentAccounts","Betalningskonton")}),e.jsxs("ul",{className:"list-unstyled small",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Swish:"})," ",((k=s.accountMappings)==null?void 0:k.swishAccount)||1920]}),e.jsxs("li",{children:[e.jsxs("strong",{children:[t("spiris.paymentMethods.card","Kortbetalning"),":"]})," ",((P=s.accountMappings)==null?void 0:P.cardAccount)||1920]}),e.jsxs("li",{children:[e.jsxs("strong",{children:[t("spiris.paymentMethods.cash","Kontant"),":"]})," ",((w=s.accountMappings)==null?void 0:w.cashAccount)||1910]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Bankgiro:"})," ",((D=s.accountMappings)==null?void 0:D.bankAccount)||1920]})]}),e.jsx("h6",{className:"text-muted mb-2 mt-3",children:t("spiris.wizard.autoSettings","Automatiska inställningar")}),e.jsxs("ul",{className:"list-unstyled small",children:[e.jsxs("li",{children:[e.jsx("i",{className:`bi ${s.autoSyncInvoices!==!1?"bi-check-circle text-success":"bi-x-circle text-danger"} me-1`}),t("spiris.wizard.autoSyncInvoices","Synka fakturor automatiskt")]}),e.jsxs("li",{children:[e.jsx("i",{className:`bi ${s.autoSyncPayments!==!1?"bi-check-circle text-success":"bi-x-circle text-danger"} me-1`}),t("spiris.wizard.autoSyncPayments","Synka betalningar automatiskt")]})]})]})]})})]}),a&&e.jsx(H,{variant:a.success?"success":"danger",className:"mb-4",children:a.success?e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-check-circle-fill me-2"}),e.jsx("strong",{children:t("spiris.wizard.testSuccess","Anslutningstest lyckat!")}),e.jsxs("p",{className:"mb-0 mt-2",children:[t("spiris.wizard.connectedTo","Kopplad till"),": ",e.jsx("strong",{children:a.companyName}),e.jsx("br",{}),t("spiris.wizard.orgNumber","Organisationsnummer"),": ",a.organizationNumber]})]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-x-circle-fill me-2"}),e.jsx("strong",{children:t("spiris.wizard.testFailed","Anslutningstest misslyckades")}),e.jsx("p",{className:"mb-0 mt-2",children:a.error})]})}),e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("small",{className:"text-muted",children:[e.jsx("i",{className:"bi bi-info-circle me-1"}),t("spiris.wizard.canEditLater","Du kan ändra dessa inställningar senare under Profil > Ekonomisystem.")]}),e.jsx(B,{variant:"success",size:"lg",onClick:()=>n(!0),disabled:i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true",className:"me-2"}),t("spiris.wizard.completing","Slutför...")]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-check2-circle me-2"}),t("spiris.wizard.completeSetup","Slutför konfiguration")]})})]})]})};Ln.propTypes={settings:r.shape({integrationFeatures:r.shape({invoices:r.bool,payments:r.bool,eInvoice:r.bool,articleSync:r.bool}),accountMappings:r.object,paymentModes:r.object,autoSyncInvoices:r.bool,autoSyncPayments:r.bool}).isRequired,onComplete:r.func.isRequired,isCompleting:r.bool,testResult:r.shape({success:r.bool,companyName:r.string,organizationNumber:r.string,error:r.string})};const Dn=({show:s,onHide:n,ferrierId:i,onComplete:a})=>{const{t}=ee(),[o,d]=l.useState(1),[h,u]=l.useState({integrationFeatures:{invoices:!0,payments:!0,eInvoice:!1,articleSync:!1},accountMappings:{productSales:3011,serviceSales:3010,groupSales:3010,bankAccount:1920,cashAccount:1910,swishAccount:1920,cardAccount:1920,outputVat25:2610,outputVat12:2620,outputVat6:2630},paymentModes:{swish:1920,card:1920,cash:1910,bankgiro:1920},autoSyncInvoices:!0,autoSyncPayments:!0}),[m,g]=l.useState(!1),[p,y]=l.useState(!1),[x,k]=l.useState(!1),[P,w]=l.useState(null),[D,O]=l.useState(null),[b,F]=l.useState(!0),[K,U]=l.useState(!1),[I,Y]=l.useState(null),[Z,je]=l.useState(null),le=5;l.useEffect(()=>{s&&i&&fe()},[s,i]);const fe=async()=>{F(!0),Y(null);try{const R=await pn(i);g(R.connected),y(R.needsReconnection||!1),R.availableModules&&O(R.availableModules);const C=await xn(i);if(C&&(u(j=>({...j,...C,integrationFeatures:{...j.integrationFeatures,...C.integrationFeatures},accountMappings:{...j.accountMappings,...C.accountMappings},paymentModes:{...j.paymentModes,...C.paymentModes}})),C.verifiedModules&&w(C.verifiedModules),C.availableModules&&O(C.availableModules),!C.onboardingCompleted&&C.onboardingStep?d(C.onboardingStep):d(1)),R.connected&&!R.needsReconnection)try{const j=await Zs(i);j!=null&&j.modules&&w({invoices:j.modules.invoices,payments:j.modules.payments,customers:j.modules.customers,articles:j.modules.articles}),j!=null&&j.availableModules&&O(j.availableModules)}catch(j){console.error("Early module verification failed:",j)}}catch(R){console.error("Error loading Spiris data:",R),Y(t("spiris.wizard.loadError","Kunde inte ladda inställningar"))}finally{F(!1)}},oe=R=>{u(C=>({...C,...R,integrationFeatures:R.integrationFeatures?{...C.integrationFeatures,...R.integrationFeatures}:C.integrationFeatures,accountMappings:R.accountMappings?{...C.accountMappings,...R.accountMappings}:C.accountMappings,paymentModes:R.paymentModes?{...C.paymentModes,...R.paymentModes}:C.paymentModes}))},G=async()=>{k(!0);try{const R=!!window.ReactNativeWebView,C=await bn(i);R?window.ReactNativeWebView.postMessage(JSON.stringify({type:"spirisAuth",authUrl:C})):window.location.href=C}catch(R){console.error("Error connecting to Spiris:",R),Y(t("spiris.wizard.connectError","Kunde inte starta Spiris-koppling")),k(!1)}},q=async()=>{U(!0);try{try{await ot(i,{...h,onboardingStep:o})}catch(R){console.error("Error saving settings:",R)}if(o===2&&m)try{const R=await Zs(i);R.modules&&w({invoices:R.modules.invoices,payments:R.modules.payments,customers:R.modules.customers,articles:R.modules.articles}),R.availableModules&&O(R.availableModules)}catch(R){console.error("Module verification failed:",R)}o<le&&d(R=>R+1)}finally{U(!1)}},ce=()=>{o>1&&d(R=>R-1)},ae=async(R=!1)=>{var C;U(!0),Y(null);try{const j=await lt(i,R);j.testResult&&je(j.testResult),a&&a(j),(!R||(C=j.testResult)!=null&&C.success)&&n()}catch(j){console.error("Error completing onboarding:",j),Y(t("spiris.wizard.completeError","Kunde inte slutföra konfigurationen"))}finally{U(!1)}},de=()=>{switch(o){case 1:const R=h.integrationFeatures||{};return Object.values(R).some(C=>C===!0);case 2:return m&&!p;case 3:return!0;case 4:return!0;case 5:return!0;default:return!1}},me=()=>{switch(o){case 1:return e.jsx(Fn,{settings:h,onSettingsChange:oe,verifiedModules:P,availableModules:D});case 2:return e.jsx(En,{isConnected:m,isConnecting:x,needsReconnection:p,onConnect:G});case 3:return e.jsx(Bn,{settings:h,onSettingsChange:oe,ferrierId:i});case 4:return e.jsx(An,{settings:h,onSettingsChange:oe,ferrierId:i});case 5:return e.jsx(Ln,{settings:h,onComplete:ae,isCompleting:K,testResult:Z});default:return null}},ue=[t("spiris.wizard.step1Label","Moduler"),t("spiris.wizard.step2Label","Koppla"),t("spiris.wizard.step3Label","Konton"),t("spiris.wizard.step4Label","Betalning"),t("spiris.wizard.step5Label","Bekräfta")];return e.jsxs(J,{show:s,onHide:n,size:"lg",centered:!0,backdrop:"static",children:[e.jsx(J.Header,{closeButton:!0,children:e.jsxs(J.Title,{children:[e.jsx("i",{
1className:"bi bi-gear me-2"}),t("spiris.wizard.title","Konfigurera Spiris")]})}),e.jsxs(J.Body,{children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"d-flex justify-content-between mb-2",children:ue.map((R,C)=>e.jsxs("span",{className:`small ${o===C+1?"fw-bold text-primary":o>C+1?"text-success":"text-muted"}`,children:[o>C+1&&e.jsx("i",{className:"bi bi-check-circle-fill me-1"}),R]},C))}),e.jsx(jn,{now:o/le*100,variant:"primary",style:{height:"4px"}})]}),I&&e.jsxs(H,{variant:"danger",dismissible:!0,onClose:()=>Y(null),children:[e.jsx("i",{className:"bi bi-exclamation-triangle me-2"}),I]}),b?e.jsxs("div",{className:"text-center py-5",children:[e.jsx(W,{animation:"border",role:"status",children:e.jsx("span",{className:"visually-hidden",children:t("common.loading","Laddar...")})}),e.jsx("p",{className:"mt-3 text-muted",children:t("spiris.wizard.loading","Laddar inställningar...")})]}):me()]}),e.jsxs(J.Footer,{children:[o>1&&o<5&&e.jsxs(B,{variant:"outline-secondary",onClick:ce,disabled:K,children:[e.jsx("i",{className:"bi bi-arrow-left me-1"}),t("common.back","Tillbaka")]}),e.jsx(B,{variant:"outline-secondary",onClick:n,disabled:K,children:t("common.cancel","Avbryt")}),o<5&&e.jsx(B,{variant:"primary",onClick:q,disabled:!de()||K,children:K?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true",className:"me-2"}),t("common.saving","Sparar...")]}):e.jsxs(e.Fragment,{children:[t("common.next","Nästa"),e.jsx("i",{className:"bi bi-arrow-right ms-1"})]})})]})]})};Dn.propTypes={show:r.bool.isRequired,onHide:r.func.isRequired,ferrierId:r.string.isRequired,onComplete:r.func};const en=[{key:"vouchers",label:"Bokföring"},{key:"invoices",label:"Fakturor"}],Tn=({ferrierId:s})=>{const[n,i]=l.useState(!1),[a,t]=l.useState(!1),[o,d]=l.useState(!0),[h,u]=l.useState(!1),[m,g]=l.useState(!1),[p,y]=l.useState(!1),[x,k]=l.useState(null),[P,w]=l.useState(!0),[D,O]=l.useState(!1),[b,F]=l.useState(!1),[K,U]=l.useState(!1),[I,Y]=l.useState(!1),[Z,je]=l.useState(!1),[le,fe]=l.useState(!1),[oe,G]=l.useState(!1),[q,ce]=l.useState(!1),[ae,de]=l.useState(!0),[me,ue]=l.useState(null),[R,C]=l.useState(null),[j,se]=l.useState(null),[Pe,Ae]=l.useState([]),[pe,xe]=l.useState(!1),[Re,te]=l.useState(!1),[Le,E]=l.useState(""),[M,S]=l.useState("success"),[$,z]=l.useState(!1),[ie,ve]=l.useState(null),ke=(A,_)=>{if(A==="success")rs().then(()=>{xe(!0)});else if(A==="error"){let X;switch(_){case"forbidden":X="Fortnox avvisade kopplingen. Kontrollera att ditt Fortnox-konto har API-åtkomst och att du har administratörsrättigheter i Fortnox.";break;
1case"access_denied":X="Du nekade åtkomst till Fortnox. Försök igen och godkänn åtkomsten.";break;case"auth_failed":X="Autentiseringen mot Fortnox misslyckades. Försök igen.";break;case"csrf_invalid":X="Säkerhetstoken har gått ut. Börja om kopplingen.";break;case"missing_params":X="Kopplingen avbröts på grund av saknade parametrar. Försök igen.";break;case"spiris_connected":X="Du har redan kopplat Spiris. Koppla bort Spiris först om du vill byta till Fortnox.";break;default:X="Kunde inte koppla Fortnox. Försök igen."}E(X),S("error"),te(!0)}ce(!1)},Ne=(A,_)=>{if(A==="success")Ue().then(X=>{const we=X==null?void 0:X.availableModules;(we?Object.values(we).some(He=>He===!0):!0)?(E("Ditt EQWECARE-konto är nu kopplat mot Spiris."),S("success"),te(!0),y(!0)):(E('Du är tekniskt kopplad mot Spiris, men nekade de behörigheter som krävs för att integrera mot eqwecare. Koppla om och godkänn minst "Försäljning" i Visma-dialogen, eller koppla bort Spiris.'),S("error"),te(!0))});else if(A==="error"){let X;
1switch(_){case"access_denied":X="Du avbröt kopplingen till Spiris. Försök igen och godkänn åtkomsten.";break;case"oauth_error":X="Visma avvisade kopplingen. Försök igen.";break;case"auth_failed":X="Autentiseringen mot Spiris misslyckades. Försök igen.";break;case"csrf_invalid":X="Säkerhetstoken har gått ut. Börja om kopplingen.";break;case"missing_params":X="Kopplingen avbröts på grund av saknade parametrar. Försök igen.";break;case"fortnox_connected":X="Du har redan kopplat Fortnox. Koppla bort Fortnox först om du vill byta till Spiris.";break;default:X="Kunde inte koppla Spiris. Försök igen."}E(X),S("error"),te(!0)}t(!1)};l.useEffect(()=>{let A=!1;return(async()=>{var _;try{const{data:X}=await Q.get(fa.endPoint());A||w(!!((_=X==null?void 0:X.result)!=null&&_.spirisNewConnectionsEnabled))}catch(X){console.warn("Failed to fetch integration availability:",X)}})(),()=>{A=!0}},[]),l.useEffect(()=>{Ue(),rs();const A=new URLSearchParams(window.location.search);A.get("spiris")==="success"?(Ne("success"),window.history.replaceState({},document.title,window.location.pathname)):A.get("spiris")==="error"?(Ne("error",A.get("reason")),window.history.replaceState({},document.title,window.location.pathname)):A.get("fortnox")==="success"?(ke("success"),window.history.replaceState({},document.title,window.location.pathname)):A.get("fortnox")==="error"&&(ke("error",A.get("reason")),window.history.replaceState({},document.title,window.location.pathname));const _=we=>{const{fortnoxResult:Ye,reason:He}=we.detail||{};ke(Ye,He)};window.addEventListener("fortnox-oauth-result",_);const X=we=>{const{spirisResult:Ye,reason:He}=we.detail||{};Ne(Ye,He)};return window.addEventListener("spiris-oauth-result",X),()=>{window.removeEventListener("fortnox-oauth-result",_),window.removeEventListener("spiris-oauth-result",X)}},[s]);const Ue=async()=>{if(!s)return null;d(!0);try{const A=await pn(s);if(i(A.connected),u(A.needsReconnection||!1),k(A.availableModules||null),A.connected)try{const _=await xn(s);g((_==null?void 0:_.onboardingCompleted)||!1)}catch(_){console.error("Error checking Spiris settings:",_),g(!1)}return A}catch(A){return console.error("Error checking Spiris status:",A),i(!1),k(null),null}finally{d(!1)}},ze=async()=>{t(!0);try{const A=!!window.ReactNativeWebView,_=await bn(s,A?"app":"web");A?window.ReactNativeWebView.postMessage(JSON.stringify({type:"spirisAuth",authUrl:_})):window.location.href=_}catch(A){console.error("Error connecting to Spiris:",A),E("Kunde inte starta Spiris-koppling. Försök igen."),S("error"),te(!0),t(!1)}},he=()=>{ve("spiris"),z(!0)},Ve=async()=>{z(!1),d(!0);try{await ct(s),i(!1),E("Spiris har kopplats bort!"),S("success"),te(!0)}catch(A){console.error("Error disconnecting Spiris:",A),E("Kunde inte koppla bort Spiris. Försök igen."),S("error"),te(!0)}finally{d(!1)}},Me=()=>{O(!1),F(!1)},ts=async()=>{if(b){U(!0);try{await mt(s),O(!1),F(!1),Y(!0),E("Din ansökan är skickad! Vi hör av oss så snart du får åtkomst till Spiris."),S("success"),te(!0)}catch(A){console.error("Error requesting Spiris access:",A),E("Kunde inte skicka ansökan just nu. Försök igen om en stund."),S("error"),te(!0)}finally{U(!1)}}},rs=async()=>{if(s){de(!0);try{const A=await un(s);if(je(A.connected),fe(A.needsReconnection||!1),Ae(A.revokedModules||[]),A.connected)try{const _=await hn(s);G((_==null?void 0:_.onboardingCompleted)||!1),ue((_==null?void 0:_.integrationFeatures)||null),C((_==null?void 0:_.verifiedModules)||null),se((_==null?void 0:_.lastModuleVerification)||null)}catch(_){console.error("Error checking Fortnox settings:",_),G(!1),ue(null),C(null),se(null)}else ue(null),C(null),se(null)}catch(A){console.error("Error checking Fortnox status:",A),je(!1),fe(!1),G(!1),ue(null),C(null),se(null),Ae([])}finally{de(!1)}}},xs=()=>{G(!0),xe(!1),E("Fortnox-konfigurationen har sparats!"),S("success"),te(!0)},ms=()=>{g(!0),y(!1),E("Spiris-konfigurationen har sparats!"),S("success"),te(!0)},We=async()=>{ce(!0);try{const A=!!window.ReactNativeWebView,_=await gn(s,A?"app":"web");A?window.ReactNativeWebView.postMessage(JSON.stringify({type:"fortnoxAuth",authUrl:_})):window.location.href=_}catch(A){console.error("Error connecting to Fortnox:",A),E("Kunde inte starta Fortnox-koppling. Försök igen."),S("error"),te(!0),ce(!1)}},is=()=>{ve("fortnox"),z(!0)},bs=async()=>{z(!1),de(!0);try{await dt(s),je(!1),E("Fortnox har kopplats bort!"),S("success"),te(!0)}catch(A){console.error("Error disconnecting Fortnox:",A),E("Kunde inte koppla bort Fortnox. Försök igen."),S("error"),te(!0)}finally{de(!1)}},os=en.map(({key:A,label:_})=>{const X=(me==null?void 0:me[A])===!0,we=R==null?void 0:R[A];return we===!0&&X?{key:A,label:_,text:"aktiv",icon:"bi-check-circle-fill",className:"text-success"}:we===!0&&!X?{key:A,label:_,text:"tillgänglig i Fortnox, avstängd i eqwecare",icon:"bi-dash-circle",className:"text-muted"}:we===!1&&X?{key:A,label:_,text:"påslagen i eqwecare, men saknas i Fortnox",icon:"bi-exclamation-triangle-fill",className:"text-warning"}:we===!1?{key:A,label:_,text:"saknas i Fortnox",icon:"bi-x-circle",className:"text-muted"}:{key:A,label:_,text:"inte kontrollerad ännu",icon:"bi-question-circle",className:"text-secondary"}}),Ge=en.filter(({key:A})=>Pe.includes(A)),ls=Ge.length>0;return e.jsxs(T,{className:"mt-4 mb-4",children:[e.jsxs(T.Body,{children:[e.jsxs(T.Title,{children:[e.jsx("i",{className:"bi bi-calculator me-2"}),"Ekonomisystem"]}),e.jsxs(T.Text,{className:"text-muted",children:["Koppla ditt ekonomisystem för automatisk synkronisering av fakturor och kunder du skapar i ",e.jsx("span",{style:{fontFamily:"Outfit, sans-serif"},children:"eqwecare"}),"."]}),(n||P)&&(()=>{const A=x==null?!0:Object.values(x).some(X=>X===!0),_=n&&!h&&!A;return e.jsx(T,{className:"mb-3 border mt-3",children:e.jsxs(T.Body,{children:[e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("div",{children:[e.jsxs("h5",{className:"mb-1",children:["Spiris (Visma eAccounting)",o?e.jsx(W,{animation:"border",size:"sm",className:"ms-2",role:"status",children:e.jsx("span",{className:"visually-hidden",children:"Laddar..."})}):n&&h?e.jsx(ge,{bg:"warning",className:"ms-2",children:"⚠️ Behöver förnyas"}):_?e.jsx(ge,{bg:"warning",className:"ms-2",children:"⚠️ Behörigheter saknas"}):n?e.jsx(ge,{bg:"success",className:"ms-2",children:"✓ Kopplad"}):e.jsx(ge,{bg:"secondary",className:"ms-2",children:"Ej kopplad"})]}),e.jsx("p",{className:"text-muted small mb-0",children:"Internationellt ekonomisystem från Visma"})]}),e.jsx("div",{children:n&&h?e.jsxs("div",{className:"d-flex gap-2",children:[e.jsx(B,{variant:"primary",size:"sm",onClick:ze,disabled:a||o,children:a?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true",className:"me-2"}),"Förnyar..."]}):"Förnya koppling"}),e.jsx(B,{variant:"outline-danger",size:"sm",onClick:he,disabled:o,children:"Koppla bort"})]}):_?e.jsxs("div",{className:"d-flex gap-2",children:[e.jsx(B,{variant:"primary",size:"sm",onClick:ze,disabled:a||o,children:a?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true",className:"me-2"}),"Kopplar om..."]}):"Koppla om"}),e.jsx(B,{variant:"outline-danger",size:"sm",onClick:he,disabled:o,children:"Koppla bort"})]}
1):n?e.jsxs("div",{className:"d-flex gap-2",children:[m?e.jsxs(B,{variant:"outline-primary",size:"sm",onClick:()=>y(!0),disabled:o,children:[e.jsx("i",{className:"bi bi-pencil me-1"}),"Redigera"]}):e.jsxs(B,{variant:"primary",size:"sm",onClick:()=>y(!0),disabled:o,children:[e.jsx("i",{className:"bi bi-gear me-1"}),"Konfigurera"]}),e.jsx(B,{variant:"outline-danger",size:"sm",onClick:he,disabled:o,children:o?"Kopplar bort...":"Koppla bort"})]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{variant:"primary",size:"sm",onClick:ze,disabled:a||!s||Z,children:a?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true",className:"me-2"}),"Kopplar..."]}):"Koppla Spiris"}),Z&&e.jsx("small",{className:"text-muted d-block mt-1",children:"Koppla bort Fortnox först"})]})})]}),n&&h&&e.jsxs(H,{variant:"warning",className:"mt-3 mb-0",children:[e.jsx(H.Heading,{className:"h6",children:"⚠️ Åtgärd krävs"}),e.jsx("p",{className:"mb-2",children:"Din Spiris-koppling behöver förnyas eftersom säkerhetstoken har gått ut."}),e.jsxs("p",{className:"mb-2",children:[e.jsx("strong",{children:"Du kan inte låsa eller skicka fakturor"})," förrän du väljer något av följande:"]}),e.jsxs("ul",{className:"mb-2",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Förnya koppling:"})," Fortsätt synka fakturor till Visma (rekommenderas om du använder Visma aktivt)"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Koppla bort:"})," Ta bort Spiris-integrationen permanent"]})]}),e.jsxs("small",{className:"text-muted",children:[e.jsx("strong",{children:"Varför?"})," För att skydda dina fakturor från att missas i Visma blockerar vi operationer tills du aktivt väljer."]})]}),_&&e.jsxs(H,{variant:"warning",className:"mt-3 mb-0",children:[e.jsx(H.Heading,{className:"h6",children:"⚠️ Behörigheter saknas"}),e.jsxs("p",{className:"mb-2",children:["Du är tekniskt kopplad mot Spiris, men ",e.jsx("strong",{children:"nekade de behörigheter som krävs"})," för att integrera mot eqwecare. Inga moduler kan användas just nu."]}),e.jsx("p",{className:"mb-2",children:"Välj något av följande:"}),e.jsxs("ul",{className:"mb-2",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Koppla om:"})," Logga in mot Visma igen och godkänn minst ",e.jsx("em",{children:"Försäljning"})," i samtyckesdialogen"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Koppla bort:"})," Ta bort Spiris-integrationen"]})]}),e.jsxs("small",{className:"text-muted",children:[e.jsx("strong",{children:"Varför?"})," Vi behöver tillgång till försäljningsmodulen i Visma för att kunna skapa kunder, artiklar och fakturor åt dig."]})]})]})})})(),!n&&!P&&e.jsx(T,{className:"mb-3 border mt-3",children:e.jsx(T.Body,{children:e.jsxs("div",{className:"d-flex justify-content-between align-items-center flex-wrap gap-2",children:[e.jsxs("div",{children:[e.jsxs("h5",{className:"mb-1",children:["Spiris (Visma eAccounting)",e.jsx(ge,{bg:"secondary",className:"ms-2",children:"Beta"})]}),e.jsx("p",{className:"text-muted small mb-0",children:"Spiris är just nu öppet för ett begränsat antal användare i beta. Kontakta oss så hjälper vi dig komma igång."})]}),e.jsx("div",{children:e.jsx(B,{variant:"outline-primary",size:"sm",onClick:()=>O(!0),disabled:I,children:I?"Ansökan skickad":"Ansök om åtkomst"})})]})})}),e.jsx(T,{className:"mb-3 border",children:e.jsxs(T.Body,{children:[e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("div",{children:[e.jsxs("h5",{className:"mb-1",children:["Fortnox",ae?e.jsx(W,{animation:"border",size:"sm",className:"ms-2",role:"status",children:e.jsx("span",{className:"visually-hidden",children:"Laddar..."})}):Z&&le?e.jsx(ge,{bg:"warning",className:"ms-2",children:"⚠️ Behöver förnyas"}):Z&&ls?e.jsx(ge,{bg:"warning",className:"ms-2",children:"⚠️ Konfigurationen stämmer inte"}):Z?e.jsx(ge,{bg:"success",className:"ms-2",children:"✓ Kopplad"}):e.jsx(ge,{bg:"secondary",className:"ms-2",children:"Ej kopplad"})]}),e.jsx("p",{className:"text-muted small mb-0",children:"Sveriges mest använda ekonomisystem"}),Z&&!ae&&os.length>0&&e.jsxs("div",{className:"mt-2",children:[os.map(A=>e.jsxs("div",{className:`small ${A.className}`,children:[e.jsx("i",{className:`bi ${A.icon} me-1`}),e.jsx("strong",{children:A.label})," — ",A.text]},A.key)),j&&e.jsxs("div",{className:"text-muted small mt-1",children:["Modulerna kontrollerades"," ",new Date(j).toLocaleStr
1ing("sv-SE",{dateStyle:"short",timeStyle:"short"})]})]})]}),e.jsx("div",{children:Z&&le?e.jsxs("div",{className:"d-flex gap-2",children:[e.jsx(B,{variant:"primary",size:"sm",onClick:We,disabled:q||ae,children:q?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true",className:"me-2"}),"Förnyar..."]}):"Förnya koppling"}),e.jsx(B,{variant:"outline-danger",size:"sm",onClick:is,disabled:ae,children:"Koppla bort"})]}):Z?e.jsxs("div",{className:"d-flex gap-2",children:[oe?e.jsxs(B,{variant:"outline-primary",size:"sm",onClick:()=>xe(!0),disabled:ae,children:[e.jsx("i",{className:"bi bi-pencil me-1"}),"Redigera"]}):e.jsxs(B,{variant:"primary",size:"sm",onClick:()=>xe(!0),disabled:ae,children:[e.jsx("i",{className:"bi bi-gear me-1"}),"Konfigurera"]}),e.jsx(B,{variant:"outline-danger",size:"sm",onClick:is,disabled:ae,children:ae?"Kopplar bort...":"Koppla bort"})]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{variant:"primary",size:"sm",onClick:We,disabled:q||!s||n,children:q?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true",className:"me-2"}),"Kopplar..."]}):"Koppla Fortnox"}),n&&e.jsx("small",{className:"text-muted d-block mt-1",children:"Koppla bort Spiris först"})]})})]}),Z&&le&&e.jsxs(H,{variant:"warning",className:"mt-3 mb-0",children:[e.jsx(H.Heading,{className:"h6",children:"⚠️ Åtgärd krävs"}),e.jsx("p",{className:"mb-2",children:"Din Fortnox-koppling behöver förnyas eftersom säkerhetstoken har gått ut (gäller i 30 dagar)."}),e.jsxs("p",{className:"mb-2",children:[e.jsx("strong",{children:"Du kan inte låsa eller skicka fakturor"})," förrän du väljer något av följande:"]}),e.jsxs("ul",{className:"mb-2",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Förnya koppling:"})," Fortsätt synka fakturor till Fortnox (rekommenderas om du använder Fortnox aktivt)"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Koppla bort:"})," Ta bort Fortnox-integrationen permanent"]})]}),e.jsxs("small",{className:"text-muted",children:[e.jsx("strong",{children:"Varför?"})," För att skydda dina fakturor från att missas i Fortnox blockerar vi operationer tills du aktivt väljer. Detta säkerställer att alla fakturor antingen synkas till Fortnox ELLER att du medvetet valt att inte använda Fortnox."]})]}),Z&&!le&&ls&&e.jsxs(H,{variant:"warning",className:"mt-3 mb-0",children:[e.jsx(H.Heading,{className:"h6",children:"⚠️ Konfigurationen stämmer inte med Fortnox"}),e.jsxs("p",{className:"mb-2",children:[Ge.map(A=>A.label).join(" och ")," ",Ge.length>1?"är påslagna":"är påslagen"," i eqwecare, men Fortnox svarar att kontot inte har"," ",Ge.length>1?"modulerna":"modulen",". Det händer om en modul sagts upp eller ändrats i Fortnox."]}),e.jsxs("p",{className:"mb-2",children:[e.jsx("strong",{children:"Vi ändrar inte din konfiguration åt dig."})," Fakturor som kräver"," ",Ge.length>1?"modulerna":"modulen"," kommer inte att synkas förrän du valt hur du vill ha det."]}),e.jsx("small",{className:"text-muted",children:"Kontrollera modulen i Fortnox. Har du den kvar räcker det att konfigurera om här. Har du sagt upp den, stäng av den i konfigurationen så slutar eqwecare försöka."})]})]})}),Z&&e.jsxs(H,{variant:"info",className:"mt-3",children:[e.jsx("i",{className:"bi bi-info-circle me-2"}),"Bokföringsunderlag skapas nu automatiskt i ditt ekonomisystem när du skapar fakturor i ",e.jsx("span",{style:{fontFamily:"Outfit, sans-serif"},children:"eqwecare"}),"."]}),!Z&&e.jsx("div",{className:"mt-3",children:e.jsxs("small",{className:"text-muted",children:[e.jsx("strong",{children:"Vad händer när jag gör kopplingen?"}),e.jsxs("ul",{className:"mt-2 mb-0",children:[e.jsx("li",{children:"Du omdirigeras till ditt konto i Fortnox för att godkänna åtkomst"}),e.jsxs("li",{children:[e.jsx("span",{style:{fontFamily:"Outfit, sans-serif"},children:"eqwecare"})," kan sedan skapa bokföringsunderlag och kunder automatiskt"]}),e.jsx("li",{children:"Du kan när som helst koppla bort integrationen"})]})]})})]}),e.jsxs(J,{show:Re,onHide:()=>te(!1),centered:!0,children:[e.jsx(J.Header,{closeButton:!0,children:e.jsx(J.Title,{children:M==="success"?e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-check-circle-fill text-success me-2"}),"Lyckades!"]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-x-circle-fill text-danger me-2"}),"Något gick fel"]})})}),e.jsx(J.Body,{children:e.jsx("p",{className:"mb-0",children:Le})}),e.jsx(J.Footer,{children:e.jsx(B,{variant:M==="success"?"success":"secondary",onClick:()=>te(!1),children:"OK"})})]}),e.jsxs(J,{show:$,onHide:()=>z(!1),centered:!0,children:[e.jsx(J.Header,{closeButton:!0,children:e.jsxs(J.Title,{children:[e.jsx("i",{className:"bi bi-exclamation-triangle-fill text-warning me-2"}),"Bekräfta bortkoppling"]})}),e.jsx(J.Body,{children:e.jsxs("p",{className:"mb-0",children:["Är du säker på att du vill koppla bort ",ie==="spiris"?"
1Spiris":"Fortnox","?"]})}),e.jsxs(J.Footer,{children:[e.jsx(B,{variant:"secondary",onClick:()=>z(!1),children:"Avbryt"}),e.jsx(B,{variant:"danger",onClick:ie==="spiris"?Ve:bs,children:"Koppla bort"})]})]}),e.jsxs(J,{show:D,onHide:Me,centered:!0,children:[e.jsx(J.Header,{closeButton:!0,children:e.jsxs(J.Title,{children:[e.jsx("i",{className:"bi bi-info-circle-fill text-primary me-2"}),"Ansök om åtkomst till Spiris"]})}),e.jsxs(J.Body,{children:[e.jsxs("p",{children:["Spiris (Visma eAccounting) är just nu i ",e.jsx("strong",{children:"beta"})," hos"," ",e.jsx("span",{style:{fontFamily:"Outfit, sans-serif"},children:"eqwecare"})," och öppet för ett begränsat antal användare."]}),e.jsx("p",{className:"mb-3",children:"Innan du ansöker vill vi att du bekräftar att du förstår följande:"}),e.jsxs("ul",{className:"mb-3",children:[e.jsx("li",{children:"Integrationen är fortfarande under utveckling och fel kan uppstå"}),e.jsx("li",{children:"Det är viktigt att du kontaktar oss direkt om ett problem uppstår"})]}),e.jsx(c.Check,{type:"checkbox",id:"spiris-access-confirm",label:"Jag förstår att Spiris är i beta och att fel kan uppstå, och att jag ska kontakta eqwecare-supporten direkt om ett problem uppstår.",checked:b,onChange:A=>F(A.target.checked)})]}),e.jsxs(J.Footer,{children:[e.jsx(B,{variant:"secondary",onClick:Me,disabled:K,children:"Avbryt"}),e.jsx(B,{variant:"primary",onClick:ts,disabled:!b||K,children:K?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",role:"status","aria-hidden":"true",className:"me-2"}),"Skickar..."]}):"Skicka ansökan"})]})]}),e.jsx(Pn,{show:pe,onHide:()=>xe(!1),ferrierId:s,onComplete:xs}),e.jsx(Dn,{show:p,onHide:()=>y(!1),ferrierId:s,onComplete:ms})]})};Tn.propTypes={ferrierId:r.string.isRequired};const Nt=[{titleKey:"accountSettings.groupIncome",fields:[{key:"serviceSales",labelKey:"accountSettings.serviceSales"},{key:"productSales",labelKey:"accountSettings.productSales"},{key:"groupSales",labelKey:"accountSettings.groupSales"},{key:"reminderFeeIncome",labelKey:"accountSettings.reminderFeeIncome"}]},{titleKey:"accountSettings.groupReceivables",fields:[{key:"customerReceivables",labelKey:"accountSettings.customerReceivables"}]},{titleKey:"accountSettings.groupPayment",fields:[{key:"swishReceivables",labelKey:"accountSettings.swish"},{key:"cardReceivables",labelKey:"accountSettings.card"},{key:"cashReceivables",labelKey:"accountSettings.cash"},{key:"bankAccount",labelKey:"accountSettings.bank"},{key:"plusgiroAccount",labelKey:"accountSettings.plusgiro"}]},{titleKey:"accountSettings.groupVat",fields:[{key:"outputVat25",labelKey:"accountSettings.outputVat25"},{key:"outputVat12",labelKey:"accountSettings.outputVat12"},{key:"outputVat6",labelKey:"accountSettings.outputVat6"}]}],ys=[{month:1,labelKey:"accountSettings.fiscalYearJan"},{month:5,labelKey:"accountSettings.fiscalYearMay"},{month:7,labelKey:"accountSettings.fiscalYearJul"},{month:9,labelKey:"accountSettings.fiscalYearSep"}],wt=[{key:"invoice",labelKey:"accountSettings.seriesInvoice"},{key:"payment",labelKey:"accountSettings.seriesPayment"},{key:"credit",labelKey:"accountSettings.seriesCredit"},{key:"reminderFee",labelKey:"accountSettings.seriesReminderFee"}],Rn=({ferrierId:s})=>{const{t:n}=ee(),[i,a]=l.useState(null),[t,o]=l.useState(1),[d,h]=l.useState({}),[u,m]=l.useState(!0),[g,p]=l.useState(!1),[y,x]=l.useState(""),[k,P]=l.useState("");l.useEffect(()=>{if(!s)return;let F=!0;return(async()=>{var K,U;m(!0);try{const I=await ut(s);if(!F)return;a((I==null?void 0:I.accountMappings)||{}),o(((K=I==null?void 0:I.sieSettings)==null?void 0:K.fiscalYearStartMonth)||1),h(((U=I==null?void 0:I.sieSettings)==null?void 0:U.sieSeries)||{})}catch(I){console.error("Error loading account settings:",I),F&&x(n("accountSettings.loadError"))}finally{F&&m(!1)}})(),()=>{F=!1}},[s,n]);const w=(F,K)=>{a(U=>({...U,[F]:K===""?"":Number(K)}))},D=(F,K)=>{const U=K.replace(/[^A-Za-z0-9]/g,"").toUpperCase().slice(0,6);h(I=>({...I,[F]:U}))},O=async()=>{p(!0),x(""),P("");try{const F={};for(const[K,U]of Object.entries(i)){const I=Number(U);U!==""&&U!==null&&U!==void 0&&!Number.isNaN(I)&&(F[K]=I)}await ht(s,F,{fiscalYearStartMonth:Number(t)||1,sieSeries:d}),P(n("accountSettings.saveSuccess"))}catch(F){console.error("Error saving account settings:",F),x(n("accountSettings.saveError"))}finally{p(!1)}},b=ys.some(F=>F.month===Number(t))?ys:[...ys,{month:Number(t),labelKey:null}];return e.jsx(T,{className:"mt-4 mb-4",children:e.jsxs(T.Body,{children:[e.jsxs(T.Title,{children:[e.jsx("i",{className:"bi bi-diagram-3 me-2"}),n("accountSettings.title")]}),e.jsx(T.Text,{className:"text-muted",children:n("accountSettings.intro")}),y&&e.jsx(H,{variant:"danger",onClose:()=>x(""),dismissible:!0,children:y}),k&&e.jsx(H,{variant:"success",onClose:()=>P(""),dismissible:!0,children:k}),u||!i?e.jsx("div",{className:"text-center py-3",children:e.jsx(W,{animation:"border",size:"sm"})}):e.jsxs(e.Fragment,{children:[Nt.map(F=>e.jsxs("div",{className:"mb-3",children:[e.jsx("h6",{className:"text-muted",children:n(F.titleKey)}),e.jsx("div",{className:"row",children:F.fields.map(K=>e.jsx("div",{className:"col-md-4 mb-2",children:e.jsx(ns,{layout:"stacked",label:n(K.labelKey),value:i[K.key]??"",onChange:U=>w(K.key,U)})},K.key))})]},F.titleKey)),e.jsxs("div",{className:"mb-3",children:[e.jsx("h6",{className:"text-muted",children:n("accountSettings.groupFiscalYear")}),e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col-md-4 mb-2",children:e.jsxs(c.Group,{children:[e.jsx(c.Label,{className:"small mb-1",children:n("accountSettings.fiscalYearStart")}),e.jsx(c.Select,{value:t,onChange:F=>o(Number(F.target.value)),children:b.map(F=>e.jsx("option",{value:F.month,children:F.labelKey?n(F.labelKey):n("accountSettings.fiscalYearMonth",{month:F.month})},F.month))})]})}),e.jsx("div",{className:"col-md-8 d-flex align-items-end",children:e.jsx("p",{className:"text-muted small mb-2",children:n("accountSettings.fiscalYearHelp")})})]})]}),e.jsxs("div",{className:"mb-3",children:[e.jsx("h6",{className:"text-muted",children:n("accountSettings.groupSeries")}),e.jsx("p",{className:"text-muted small mb-2",children:n("accountSettings.seriesHelp")}),e.jsx("div",{className:"row",children:wt.map(F=>e.jsx("div",{className:"col-md-3 col-6 mb-2",children:e.jsxs(c.Group,{children:[e.jsx(c.Label,{className:"small mb-1",children:n(F.labelKey)}),e.jsx(c.Control,{type:"text",maxLength:6,value:d[F.key]??"",onChange:K=>D(F.key,K.target.value)})]})},F.key))})]}),e.jsx(B,{variant:"primary",onClick:O,disabled:g,children:g?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",className:"me-2"}),n("accountSettings.saving")]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-save me-2"}),n("accountSettings.save")]})})]})]})})};Rn.propTypes={ferrierId:r.string.isRequired};const Ct=async(s,n,i,a=!0)=>{try{return(await Q.get(va.endPoint(s,n,i,a))).data.result}catch(t){throw console.error("Error previewing SIE export:",t),t}},Pt=async(s,n,i,a="cp437",t=!0,o=null)=>{try{const d=await Q.get(ka.endPoint(s,n,i,a,t,o),{responseType:"blob"}),h=d.headers["content-disposition"];let u=`SIE_export_${n}_${i}.se`;if(h){const y=h.match(/filename="?([^";\n]+)"?/);y&&y[1]&&(u=y[1])}const m=window.URL.createObjectURL(new Blob([d.data])),g=document.createElement("a");g.href=m,g.setAttribute("download",u),document.body.appendChild(g),g.click(),g.remove(),window.URL.revokeObjectURL(m);let p=[];try{p=JSON.parse(d.headers["x-series-numbers"]||"[]")}catch{p=[]}return{success:!0,fileName:u,verificationCount:d.headers["x-verification-count"],invoiceCount:d.headers["x-invoice-count"],checksum:d.headers["x-checksum"],seriesNumbers:p}}catch(d){throw console.error("Error downloading SIE file:",d),d}},Ft=async(s,n=10)=>{try{return(await Q.get(Sa.endPoint(s,n))).data.result}catch(i){throw console.error("Error getting SIE export history:",i),i}},Et=async(s,n,i)=>{try{return(await Q.get(ya.endPoint(s,n,i))).data.result}catch(a){throw console.error("Error getting next voucher numbers:",a),a}},gs=[{key:"invoice",labelKey:"sieExport.seriesInvoice"},{key:"payment",labelKey:"sieExport.seriesPayment"},{key:"credit",labelKey:"sieExport.seriesCredit"},{key:"reminderFee",labelKey:"sieExport.seriesReminderFee"}],ps={invoice:"",payment:"",credit:"",reminderFee:""},sn=s=>{const n=s.getFullYear(),i=String(s.getMonth()+1).padStart(2,"0"),a=String(s.getDate()).padStart(2,"0");return`${n}-${i}-${a}`},zn=({ferrierId:s})=>{var M;const{t:n}=ee(),[i,a]=l.useState(""),[t,o]=l.useState(""),[d,h]=l.useState("cp437"),[u,m]=l.useState(!0),[g,p]=l.useState(ps),[y,x]=l.useState(null),[k,P]=l.useState(!1),[w,D]=l.useState(null),[O,b]=l.useState(!1),[F,K]=l.useState(!1),[U,I]=l.useState(!1),[Y,Z]=l.useState([]),[je,le]=l.useState(!1),[fe,oe]=l.useState(!1),[G,q]=l.useState(""),[ce,ae]=l.useState("");l.useEffect(()=>{const S=new Date,$=new Date(S.getFullYear(),S.getMonth(),1),z=new Date(S.getFullYear(),S.getMonth()+1,0);a(sn($)),o(sn(z))},[]);const de=l.useCallback(async()=>{le(!0);try{const S=await Ft(s,10);Z(S||[])}catch(S){console.error("Error loading history:",S)}finally{le(!1)}},[s]);l.useEffect(()=>{s&&de()},[s,de]);const me=l.useCallback(async()=>
1{if(!(!s||!i||!t)){P(!0);try{const S=await Et(s,i,t);x(S);const $={...ps};((S==null?void 0:S.series)||[]).forEach(z=>{$[z.key]=String(z.suggested)}),p($)}catch(S){console.error("Error loading suggested voucher numbers:",S),x(null),p(ps)}finally{P(!1)}}},[s,i,t]);l.useEffect(()=>{me()},[me]);const ue=S=>{if(S===""||S===null||S===void 0)return!0;const $=Number(S);return Number.isInteger($)&&$>0},R=gs.every(({key:S})=>ue(g[S])),C=()=>{const S={};return gs.forEach(({key:$})=>{const z=Number(g[$]);g[$]!==""&&Number.isInteger(z)&&z>0&&(S[$]=z)}),Object.keys(S).length>0?S:null},j=(S,$)=>{p(z=>({...z,[S]:$}))},se=S=>{const $={...ps};((S==null?void 0:S.seriesNumbers)||[]).forEach(z=>{z!=null&&z.key&&(z!=null&&z.start)&&($[z.key]=String(z.start))}),p($),oe(!1)},Pe=async()=>{if(!i||!t){q(n("sieExport.missingPeriod"));return}b(!0),q("");try{const S=await Ct(s,i,t,u);D(S),K(!0)}catch(S){console.error("Error previewing:",S),q(n("sieExport.previewError"))}finally{b(!1)}},Ae=async()=>{if(!i||!t){q(n("sieExport.missingPeriod"));return}I(!0),q(""),ae("");try{const S=await Pt(s,i,t,d,u,C());if(S.success){const $=(S.seriesNumbers||[]).map(z=>`${z.code} ${z.start}–${z.end}`).join(", ");ae($?n("sieExport.exportedWithNumbers",{fileName:S.fileName,numbers:$}):n("sieExport.exported",{fileName:S.fileName})),K(!1),de(),me()}}catch(S){console.error("Error downloading:",S),q(n("sieExport.downloadError"))}finally{I(!1)}},pe=S=>S?new Date(S).toLocaleDateString("sv-SE"):"-",xe=S=>S==null?"-":new Intl.NumberFormat("sv-SE",{style:"currency",currency:"SEK"}).format(S),Re=S=>{switch(S){case"success":return e.jsx(ge,{bg:"success",children:n("sieExport.statusOk")});case"warning":return e.jsx(ge,{bg:"warning",children:n("sieExport.statusWarning")});case"error":return e.jsx(ge,{bg:"danger",children:n("sieExport.statusError")});default:return e.jsx(ge,{bg:"secondary",children:S})}},te=()=>{var z,ie;const S=(z=y==null?void 0:y.series)==null?void 0:z.find(ve=>ve.key==="invoice");if(!S)return null;const $=S.reference;switch(S.source){case"same-period":return n("sieExport.suggestSamePeriod",{exportedAt:pe($==null?void 0:$.exportedAt)});case"previous-period":return n("sieExport.suggestPrevious",{periodStart:pe($==null?void 0:$.periodStart),periodEnd:pe($==null?void 0:$.periodEnd)});case"overlap":return n("sieExport.suggestOverlap");default:return n("sieExport.suggestFirst",{fiscalYear:((ie=y==null?void 0:y.fiscalYear)==null?void 0:ie.label)||""})}},Le=()=>{const S=(y==null?void 0:y.series)||[];if(S.some(ie=>ie.warning==="overlap"))return n("sieExport.suggestOverlap");const $=S.filter(ie=>ie.warning==="unknown-history");if($.length===0)return null;const z=$.map(ie=>{var ve;return n(((ve=gs.find(ke=>ke.key===ie.key))==null?void 0:ve.labelKey)||ie.key)}).join(", ");return n("sieExport.suggestUnknownHistory",{series:z})},E=S=>((S==null?void 0:S.seriesNumbers)||[]).map($=>`${$.code} ${$.start}–${$.end}`).join(", ");return e.jsxs(T,{className:"mt-4 mb-4",children:[e.jsxs(T.Body,{children:[e.jsxs(T.Title,{children:[e.jsx("i",{className:"bi bi-file-earmark-code me-2"}),n("sieExport.title")]}),e.jsx(T.Text,{className:"text-muted",children:n("sieExport.intro")}),G&&e.jsx(H,{variant:"danger",onClose:()=>q(""),dismissible:!0,children:G}),ce&&e.jsx(H,{variant:"success",onClose:()=>ae(""),dismissible:!0,children:ce}),e.jsxs("div",{className:"row mb-3",children:[e.jsx("div",{className:"col-md-6",children:e.jsxs(c.Group,{children:[e.jsx(c.Label,{children:n("sieExport.periodFrom")}),e.jsx(c.Control,{type:"date",value:i,onChange:S=>a(S.target.value)})]})}),e.jsx("div",{className:"col-md-6",children:e.jsxs(c.Group,{children:[e.jsx(c.Label,{children:n("sieExport.periodTo")}),e.jsx(c.Control,{type:"date",value:t,onChange:S=>o(S.target.value)})]})})]}),e.jsx(T,{className:"border mb-3",children:e.jsxs(T.Body,{className:"py-3",children:[e.jsxs("div",{className:"d-flex align-items-center mb-1",children:[e.jsxs("h6",{className:"mb-0",children:[e.jsx("i",{className:"bi bi-123 me-2"}),n("sieExport.voucherNumbers")]}),k&&e.jsx(W,{animation:"border",size:"sm",className:"ms-2"}),((M=y==null?void 0:y.fiscalYear)==null?void 0:M.label)&&e.jsx(ge,{bg:"light",text:"dark",className:"ms-2",children:n("sieExport.fiscalYear",{label:y.fiscalYear.label})})]}),e.jsx("p",{className:"text-muted small mb-2",children:n("sieExport.voucherNumbersHelp")}),te()&&e.jsx("p",{className:"text-muted small mb-2",children:te()}),Le()&&e.jsxs(H,{variant:"warning",className:"py-2 small mb-3",children:[e.jsx("i",{className:"bi bi-exclamation-triangle me-2"}),Le()]}),e.jsx("div",{className:"row",children:gs.map(({key:S,labelKey:$})=>{var ve,ke;const z=(ve=y==null?void 0:y.series)==null?void 0:ve.find(Ne=>Ne.key===S),ie=ue(g[S]);return e.jsx("div",{className:"col-md-3 col-6 mb-2",children:e.jsxs(c.Group,{children:[e.jsxs(c.Label,{className:"small mb-1",children:[n($),(z==null?void 0:z.code)&&e.jsxs("span",{className:"text-muted ms-1",children:["(",z.code,")"]})]}),e.jsx(c.Control,{type:"number",min:"1",step:"1",inputMode:"numeric",value:g[S],isInvalid:!ie,onChange:Ne=>j(S,Ne.target.value)}),e.jsx(c.Control.Feedback,{type:"invalid",children:n("sieExport.invalidNumber")}),(ke=z==null?void 0:z.reference)!=null&&ke.end?e.jsx(c.Text,{className:"text-muted",children:n("sieExport.previousRange",{start:z.reference.start,end:z.reference.end})}):null]})},S)})})]})}),e.jsxs("div",{className:"row mb-3",children:[e.jsx("div",{className:"col-md-6",children:e.jsxs(c.Group,{children:[e.jsx(c.Label,{children:n("sieExport.encoding")}),e.jsxs(c.Select,{value:d,onChange:S=>h(S.target.value),children:[e.jsx("option",{value:"cp437",children:n("sieExport.encodingCp437")}),e.jsx("option",{value:"utf8",children:n("sieExport.encodingUtf8")})]}),e.jsx(c.Text,{className:"text-muted",children:n("sieExport.encodingHelp")})]})}),e.jsx("div",{className:"col-md-6",children:e.jsxs(c.Group,{className:"mt-4",children:[e.jsx(c.Check,{type:"checkbox",id:"includePayments",label:n("sieExport.includePayments"),checked:u,onChange:S=>m(S.target.checked)}),e.jsx(c.Text,{className:"text-muted",children:n("sieExport.includePaymentsHelp")})]})})]}),e.jsxs("div",{className:"d-flex gap-2 mb-3 flex-wrap",children:[e.jsx(B,{variant:"outline-primary",onClick:Pe,disabled:O||!i||!t,children:O?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",className:"me-2"}),n("sieExport.loading")]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-eye me-2"}),n("sieExport.preview")]})}),e.jsx(B,{variant:"primary",onClick:Ae,disabled:U||!i||!t||!R,children:U?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",className:"me-2"}),n("sieExport.downloading")]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-download me-2"}),n("sieExport.download")]})}),e.jsxs(B,{variant:"outline-secondary",onClick:()=>oe(!fe),children:[e.jsx("i",{className:"bi bi-clock-history me-2"}),n("sieExport.history")]})]}),fe&&e.jsx(T,{className:"border mt-3",children:e.jsxs(T.Body,{children:[e.jsx("h6",{children:n("sieExport.historyTitle")}),je?e.jsx("div",{className:"text-center py-3",children:e.jsx(W,{animation:"border",size:"sm"})}):Y.length===0?e.jsx("p",{className:"text-muted mb-0",children:n("sieExport.historyEmpty")}):e.jsxs(Xs,{size:"sm",responsive:!0,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:n("sieExport.colDate")}
1),e.jsx("th",{children:n("sieExport.colPeriod")}),e.jsx("th",{children:n("sieExport.colInvoices")}),e.jsx("th",{children:n("sieExport.colVerifications")}),e.jsx("th",{children:n("sieExport.colVoucherNumbers")}),e.jsx("th",{children:n("sieExport.colStatus")}),e.jsx("th",{})]})}),e.jsx("tbody",{children:Y.map(S=>{var $,z;return e.jsxs("tr",{children:[e.jsx("td",{children:pe(S.createdAt)}),e.jsxs("td",{children:[pe(S.periodStart)," - ",pe(S.periodEnd)]}),e.jsx("td",{children:(($=S.invoiceIds)==null?void 0:$.length)||0}),e.jsx("td",{children:S.verificationCount||0}),e.jsx("td",{children:E(S)||"-"}),e.jsx("td",{children:Re(S.status)}),e.jsx("td",{children:((z=S.seriesNumbers)==null?void 0:z.length)>0&&e.jsx(B,{variant:"link",size:"sm",className:"p-0",onClick:()=>se(S),children:n("sieExport.useTheseNumbers")})})]},S._id)})})]})]})}),e.jsxs(H,{variant:"info",className:"mt-3 mb-0",children:[e.jsx("i",{className:"bi bi-info-circle me-2"}),e.jsx("strong",{children:n("sieExport.infoTitle")})," ",n("sieExport.info")]})]}),e.jsxs(J,{show:F,onHide:()=>K(!1),size:"lg",centered:!0,children:[e.jsx(J.Header,{closeButton:!0,children:e.jsxs(J.Title,{children:[e.jsx("i",{className:"bi bi-file-earmark-code me-2"}),n("sieExport.previewTitle")]})}),e.jsx(J.Body,{children:w&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"row mb-4",children:[e.jsx("div",{className:"col-md-6",children:e.jsxs("div",{className:"border rounded p-3",children:[e.jsx("h6",{className:"text-muted mb-3",children:n("sieExport.periodLabel")}),e.jsxs("p",{className:"mb-1",children:[e.jsxs("strong",{children:[n("sieExport.from"),":"]})," ",pe(w.periodStart)]}),e.jsxs("p",{className:"mb-0",children:[e.jsxs("strong",{children:[n("sieExport.to"),":"]})," ",pe(w.periodEnd)]})]})}),e.jsx("div",{className:"col-md-6",children:e.jsxs("div",{className:"border rounded p-3",children:[e.jsx("h6",{className:"text-muted mb-3",children:n("sieExport.summary")}),e.jsxs("p",{className:"mb-1",children:[e.jsxs("strong",{children:[n("sieExport.invoiceCount"),":"]})," ",w.invoiceCount||0]}),e.jsxs("p",{className:"mb-1",children:[e.jsxs("strong",{children:[n("sieExport.verificationCount"),":"]})," ",w.verificationCount||0]}),e.jsxs("p",{className:"mb-0",children:[e.jsxs("strong",{children:[n("sieExport.paidCount"),":"]})," ",w.paidCount||0]})]})})]}),e.jsxs("div",{className:"row mb-4",children:[e.jsx("div",{className:"col-md-4",children:e.jsxs("div",{className:"border rounded p-3 text-center",children:[e.jsx("small",{className:"text-muted d-block",children:n("sieExport.netAmount")}),e.jsx("h5",{className:"mb-0",children:xe(w.netAmount)})]})}),e.jsx("div",{className:"col-md-4",children:e.jsxs("div",{className:"border rounded p-3 text-center",children:[e.jsx("small",{className:"text-muted d-block",children:n("sieExport.vat")}),e.jsx("h5",{className:"mb-0",children:xe(w.totalTax)})]})}),e.jsx("div",{className:"col-md-4",children:e.jsxs("div",{className:"border rounded p-3 text-center bg-light",children:[e.jsx("small",{className:"text-muted d-block",children:n("sieExport.totalAmount")}),e.jsx("h5",{className:"mb-0 text-primary",children:xe(w.totalAmount)})]})})]}),w.creditCount>0&&e.jsxs(H,{variant:"warning",children:[e.jsx("i",{className:"bi bi-exclamation-triangle me-2"}),n("sieExport.creditNotice",{creditCount:w.creditCount})]}),w.invoices&&w.invoices.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h6",{children:n("sieExport.includedInvoices")}),e.jsx("div",{style:{maxHeight:"200px",overflowY:"auto"},children:e.jsxs(Xs,{size:"sm",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:n("sieExport.colInvoiceNumber")}),e.jsx("th",{children:n("sieExport.colCustomer")}),e.jsx("th",{children:n("sieExport.colDate")}),e.jsx("th",{children:n("sieExport.colAmount")}),e.jsx("th",{children:n("sieExport.colStatus")})]})}),e.jsx("tbody",{children:w.invoices.map(S=>e.jsxs("tr",{children:[e.jsx("td",{children:S.invoiceNumber||S._id.slice(-6)}),e.jsx("td",{children:S.customerName}),e.jsx("td",{children:pe(S.invoiceDate)}),e.jsx("td",{children:xe(S.totalCost)}),e.jsx("td",{children:S.invoiceType==="credit"?e.jsx(ge,{bg:"info",children:n("sieExport.badgeCredit")}):S.status===3?e.jsx(ge,{bg:"success",children:n("sieExport.badgePaid")}):e.jsx(ge,{bg:"warning",children:n("sieExport.badgeSent")})})]},S._id))})]})})]})]})}),e.jsxs(J.Footer,{children:[e.jsx(B,{variant:"secondary",onClick:()=>K(!1),children:n("sieExport.close")}),e.jsx(B,{variant:"primary",onClick:Ae,disabled:U||!R,children:U?e.jsxs(e.Fragment,{children:[e.jsx(W,{as:"span",animation:"border",size:"sm",className:"me-2"}),n("sieExport.downloading")]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-download me-2"}),n("sieExport.download")]})})]})]})]})};zn.propTypes={ferrierId:r.string.isRequired};r.oneOf(["qr","api"]),r.shape({uploadedAt:r.string,expiresAt:r.string,originalFilename:r.string}),r.func.isRequired,r.func.isRequired,r.func.isRequired,r.bool,r.bool;const nn=Qe,Mn=({user:s,loading:n,deviceType:i,subscriptionInfo:a,subscriptionSyncing:t,formikPaymentMethods:o,swishEnabled:d,setSwishEnabled:h,swishLeadingPlus:u,setSwishLeadingPlus:m,swishIntegrationType:g,swishCertificateInfo:p,handleSwishIntegrationTypeChange:y,handleSwishCertificateUpload:x,handleSwishCertificateDelete:k,swishCertificateLoading:P,swishCertificateUploading:w,bankgiroEnabled:D,setBankgiroEnabled:O,plusgiroEnabled:b,setPlusgiroEnabled:F,bankAccountEnabled:K,setBankAccountEnabled:U,ibanEnabled:I,setIbanEnabled:Y,bicEnabled:Z,setBicEnabled:je,openStripePortal:le,openSubscriptionModal:fe,portalLoading:oe,pricingTableError:G,defaultPaymentTerms:q,setDefaultPaymentTerms:ce,onSaveDefaultPaymentTerms:ae,savingPaymentTerms:de,defaultReminderFee:me,setDefaultReminderFee:ue,onSaveDefaultReminderFee:R,savingReminderFee:C})=>{const{t:j}=ee(),se=(E,M)=>{const S=o.values.enabledPaymentMethods||[],$=M?[...S,E]:S.filter(ie=>ie!==E),z=nn.filter(ie=>$.includes(ie));o.setFieldValue("enabledPaymentMethods",z,!0),z.length>0&&!z.includes(o.values.defaultPaymentMethod)&&o.setFieldValue("defaultPaymentMethod",z[0],!0)},Pe=E=>{if(!E)return null;const M=new Date(E);return Number.isNaN(M.getTime())?null:M.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})},Ae=E=>{switch(E){case"active":return j("ProfilePage.Subscription-Status-Active");case"trialing":return j("ProfilePage.Subscription-Status-Trialing");case"past_due":return j("ProfilePage.Subscription-Status-PastDue");case"canceled":return j("ProfilePage.Subscription-Status-Canceled");case"unpaid":return j("ProfilePage.Subscription-Status-Unpaid");case"incomplete":return j("ProfilePage.Subscription-Status-Incomplete");case"incomplete_expired":return j("ProfilePage.Subscription-Status-IncompleteExpired");case"paused":return j("ProfilePage.Subscription-Status-Paused");case null:case void 0:return j("ProfilePage.Subscription-Status-Unknown");default:return j("ProfilePage.Subscription-Status-Unknown")}},xe=(()=>{const E=a==null?void 0:a.subscriptionTier;if(!E)return"none";if(E==="trial"&&(a!=null&&a.trialStartDate)){const M=new Date(a.trialStartDate);if(M.setDate(M.getDate()+14),new Date>=M)return"none"}return a!=null&&a.subscriptionExpiryDate&&new Date>=new Date(a.subscriptionExpiryDate)?"none":E})(),Re=["trial","bas","pro"].includes(xe),te=Pe(a==null?void 0:a.subscriptionCurrentPeriodEnd),Le=Ae(a==null?void 0:a.stripeSubscriptionStatus);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"from_des_block",children:e.jsxs(c.Group,{children:[e.jsxs("h2",{children:[e.jsx("i",{className:"bi bi-credit-card me-2"}),j("ProfilePage.Subscription-Section")]}),t&&e.jsxs("div",{className:"d-flex align-items-center text-muted mb-3",children:[e.jsx(W,{animation:"border",size:"sm",className:"me-2"}),j("ProfilePage.Subscription-Loading")]}),Re?e.jsxs("div",{className:"mb-3",children:[e.jsxs("p",{className:"mb-1",children:[e.jsxs("strong",{children:[j("ProfilePage.Subscription-Plan"),": "]}),(a==null?void 0:a.subscriptionPlanName)||j(`ProfilePage.Subscription-Tier-${xe}`)]}),te?e.jsxs("p",{className:"mb-1",children:[e.jsxs("strong",{children:[(a==null?void 0:a.stripeSubscriptionStatus)==="canceled"||a!=null&&a.subscriptionCancelAtPeriodEnd?j("ProfilePage.Subscription-ValidUntil"):j("ProfilePage.Subscription-Expires"),":"," "]}),te]}):null,(a==null?void 0:a.stripeSubscriptionStatus)&&e.jsxs("p",{className:"mb-0",children:[e.jsxs("strong",{children:[j("ProfilePage.Subscription-Status"),": "]}),Le]})]}):e.jsx("p",{className:"text-muted mb-3",children:j("ProfilePage.Subscription-None")}),(G||!ss)&&e.jsx("p",{className:"text-danger mb-3",children:j(G?"ProfilePage.Subscription-TableLoadError":"ProfilePage.Subscription-TableMissing")}),i!=="ios"&&e.jsx("div",{className:"d-flex flex-wrap gap-2 mb-2",children:xe==="bas"||xe==="pro"?e.jsxs(B,{className:"form-action-btn-primary",onClick:le,disabled:oe||!(s!=null&&s.id),children:[oe&&e.jsx(W,{animation:"border",size:"sm",className:"me-2"}),j("ProfilePage.Subscription-Manage")]}):xe==="trial"?e.jsx(B,{className:"form-action-btn-primary",onClick:fe,disabled:G||!ss||!(s!=null&&s.id),children:j("ProfilePage.Subscription-Upgrade")}):e.jsx(B,{className:"form-action-btn-primary",onClick:fe,disabled:G||!ss||!(s!=null&&s.id),children:j("ProfilePage.Subscription-Start")})})]})}),e.jsxs("div",{className:"from_des_block",children:[e.jsxs("h2",{children:[e.jsx("i",{className:"bi bi-wallet2 me-2"}),j("ProfilePage.Payment-Methods-Settings")]}),e.jsxs(c,{onSubmit:o.handleSubmit,noValidate:!0,children:[e.jsxs("div",{className:"payment-table",children:[e.jsxs("div",{className:"payment-row",children:[e.jsx("div",{className:"label-cell",children:e.jsx(c.Check,{type:"checkbox",label:"Swish",id:"swishNumberCheck",name:"swishNumberCheck",checked:d,onChange:E=>{const M=E.currentTarget.checked;h(M),o.setFieldValue("swishNumberCheck",M)}})}),e.jsx("div",{className:"input-cell",children:e.jsxs(c.Group,{children:[e.jsx(c.Control,{name:"swishNumber",type:"text",inputMode:"tel",autoComplete:"tel",className:"text-control",value:Se.formatSwishNumber(o.values.swishNumber,u),onChange:E=>{m(/^\s*\+/.test(E.target.value));const M=Se.normalizeSwish(E.target.value);o.setFieldValue("swishNumber",M,!0)},onBlur:E=>{o.setTouched({...o.touched,swishNumberNumber:!0},!0),o.handleBlur(E)},disabled:!o.values.swishNumberCheck,isInvalid:o.touched.swishNumber&&!!o.errors.swishNumber}),e.jsx(c.Control.Feedback,{type:"invalid",children:o.errors.swishNumber})]})})]}),e.jsxs("div",{className:"payment-row",children:[e.jsx("div",{className:"label-cell",children:e.jsx(c.Check,{type:"checkbox",label:"Bankgiro",i
1d:"bankgiroCheck",name:"bankgiroCheck",checked:D,onChange:E=>{const M=E.currentTarget.checked;O(M),o.setFieldValue("bankgiroCheck",M)}})}),e.jsxs("div",{className:"input-cell",children:[e.jsx(c.Control,{name:"bankgiro",type:"text",inputMode:"numeric",autoComplete:"off",className:"text-control",value:Se.formatBankgiroNumber(o.values.bankgiro),onChange:E=>{const M=Se.normalizeBankgiro(E.target.value);o.setFieldValue("bankgiro",M,!0)},onBlur:o.handleBlur,disabled:!o.values.bankgiroCheck,isInvalid:o.touched.bankgiro&&!!o.errors.bankgiro}),e.jsx(c.Control.Feedback,{type:"invalid",children:o.errors.bankgiro})]})]}),e.jsxs("div",{className:"payment-row",children:[e.jsx("div",{className:"label-cell",children:e.jsx(c.Check,{type:"checkbox",label:"Plusgiro",id:"plusgiroCheck",name:"plusgiroCheck",checked:b,onChange:E=>{const M=E.currentTarget.checked;F(M),o.setFieldValue("plusgiroCheck",M)}})}),e.jsxs("div",{className:"input-cell",children:[e.jsx(c.Control,{name:"plusgiro",type:"text",inputMode:"numeric",autoComplete:"off",className:"text-control",value:Se.formatPlusgiroNumber(o.values.plusgiro),onChange:E=>{const M=Se.normalizePlusgiro(E.target.value);o.setFieldValue("plusgiro",M,!0)},onBlur:o.handleBlur,disabled:!o.values.plusgiroCheck,isInvalid:o.touched.plusgiro&&!!o.errors.plusgiro}),e.jsx(c.Control.Feedback,{type:"invalid",children:o.errors.plusgiro})]})]}),e.jsxs("div",{className:"payment-row",children:[e.jsx("div",{className:"label-cell",children:e.jsx(c.Check,{type:"checkbox",label:"Bankkonto",id:"bankAccountCheck",name:"bankAccountCheck",checked:K,onChange:E=>{const M=E.currentTarget.checked;U(M),o.setFieldValue("bankAccountCheck",M)}})}),e.jsxs("div",{className:"input-cell",children:[e.jsx(c.Control,{name:"bankAccount",type:"text",inputMode:"numeric",autoComplete:"off",className:"text-control",value:Se.formatBankAccountNumber(o.values.bankAccount),onChange:E=>{const M=Se.normalizeBankAccount(E.target.value);o.setFieldValue("bankAccount",M,!0)},onBlur:o.handleBlur,disabled:!o.values.bankAccountCheck,isInvalid:o.touched.bankAccount&&!!o.errors.bankAccount}),e.jsx(c.Control.Feedback,{type:"invalid",children:o.errors.bankAccount})]})]}),e.jsxs("div",{className:"payment-row",children:[e.jsx("div",{className:"label-cell",children:e.jsx(c.Check,{type:"checkbox",label:"IBAN",id:"ibanCheck",name:"ibanCheck",checked:I,onChange:E=>{const M=E.currentTarget.checked;Y(M),o.setFieldValue("ibanCheck",M)}})}),e.jsxs("div",{className:"input-cell",children:[e.jsx(c.Control,{name:"iban",type:"text",autoComplete:"off",className:"text-control",placeholder:"SE45 5000 0000 0583 9825 7466",value:Se.formatIban(o.values.iban),onChange:E=>{const M=Se.normalizeIban(E.target.value);o.setFieldValue("iban",M,!0)},onBlur:o.handleBlur,disabled:!o.values.ibanCheck,isInvalid:o.touched.iban&&!!o.errors.iban}),e.jsx(c.Control.Feedback,{type:"invalid",children:o.errors.iban})]})]}),e.jsxs("div",{className:"payment-row",children:[e.jsx("div",{className:"label-cell",children:e.jsx(c.Check,{type:"checkbox",label:"BIC/SWIFT",id:"bicCheck",name:"bicCheck",checked:Z,onChange:E=>{const M=E.currentTarget.checked;je(M),o.setFieldValue("bicCheck",M)}})}),e.jsxs("div",{className:"input-cell",children:[e.jsx(c.Control,{name:"bic",type:"text",autoComplete:"off",className:"text-control",placeholder:"ESSESESS",value:Se.formatBic(o.values.bic),onChange:E=>{const M=Se.normalizeBic(E.target.value);o.setFieldValue("bic",M,!0)},onBlur:o.handleBlur,disabled:!o.values.bicCheck,isInvalid:o.touched.bic&&!!o.errors.bic}),e.jsx(c.Control.Feedback,{type:"invalid",children:o.errors.bic})]})]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsxs("h2",{children:[e.jsx("i",{className:"bi bi-cash-coin me-2"}),j("ProfilePage.RegisterPayment-Settings")]}),e.jsx("p",{className:"text-muted mb-3",children:j("ProfilePage.RegisterPayment-Settings-Description")}),e.jsxs(c.Group,{className:"mb-3",children:[e.jsx(c.Label,{children:j("ProfilePage.RegisterPayment-EnabledMethods")}),nn.map(E=>e.jsx(c.Check,{type:"checkbox",id:`register-payment-method-${E}`,label:j(`Payments.${E}`),checked:(o.values.enabledPaymentMethods||[]).includes(E),onChange:M=>se(E,M.currentTarget.checked)},E)),o.errors.enabledPaymentMethods&&e.jsx("div",{className:"text-danger small mt-1",children:o.errors.enabledPaymentMethods})]}),e.jsxs(c.Group,{className:"mb-3",style:{maxWidth:"300px"},children:[e.jsx(c.Label,{children:j("ProfilePage.RegisterPayment-DefaultMethod")}),e.jsx(c.Select,{name:"defaultPaymentMethod",value:o.values.defaultPaymentMethod||"",onChange:E=>o.setFieldValue("defaultPaymentMethod",E.target.value,!0),isInvalid:!!o.errors.defaultPaymentMethod,children:(o.values.enabledPaymentMethods||[]).map(E=>e.jsx("option",{value:E,children:j(`Payments.${E}`)},E))}),e.jsx(c.Control.Feedback,{type:"invalid",children:o.errors.defaultPaymentMethod})]})]}
1),e.jsx(B,{type:"submit",className:"form-action-btn-primary mb-5 mt-3",disabled:o.isSubmitting||n,children:j("ProfilePage.Update")})]})]}),e.jsxs("div",{className:"from_des_block",children:[e.jsxs("h2",{children:[e.jsx("i",{className:"bi bi-calendar-check me-2"}),j("ProfilePage.Default-Payment-Terms")]}),e.jsx("p",{className:"text-muted mb-3",children:j("ProfilePage.Default-Payment-Terms-Description")}),e.jsxs(c.Group,{className:"mb-3",style:{maxWidth:"200px"},children:[e.jsx(c.Label,{children:j("ProfilePage.Payment-Terms-Days")}),e.jsx(c.Control,{type:"number",min:"0",max:"90",value:q,onChange:E=>{const M=E.target.value;(M===""||parseInt(M,10)>=0&&parseInt(M,10)<=90)&&ce(M===""?"":parseInt(M,10))}}),e.jsx(c.Text,{className:"text-muted",children:j("ProfilePage.Payment-Terms-Range")})]}),e.jsxs(B,{className:"form-action-btn-primary mb-5",onClick:ae,disabled:de||n,children:[de?e.jsx(W,{animation:"border",size:"sm",className:"me-2"}):null,j("ProfilePage.Update")]})]}),e.jsxs("div",{className:"from_des_block",children:[e.jsxs("h2",{children:[e.jsx("i",{className:"bi bi-bell me-2"}),j("ProfilePage.Default-Reminder-Fee")]}),e.jsx("p",{className:"text-muted mb-3",children:j("ProfilePage.Default-Reminder-Fee-Description")}),e.jsxs(c.Group,{className:"mb-3",style:{maxWidth:"200px"},children:[e.jsxs(c.Label,{children:[j("Reminders.DefaultFee")," (kr)"]}),e.jsx(c.Control,{type:"number",min:"0",value:me,onChange:E=>{const M=E.target.value;(M===""||parseInt(M,10)>=0)&&ue(M===""?"":parseInt(M,10))}})]}),e.jsxs(B,{className:"form-action-btn-primary mb-5",onClick:R,disabled:C||n,children:[C?e.jsx(W,{animation:"border",size:"sm",className:"me-2"}):null,j("ProfilePage.Update")]})]}),e.jsx(Rn,{ferrierId:s==null?void 0:s._id}),e.jsx(Tn,{ferrierId:s==null?void 0:s._id}),e.jsx(zn,{ferrierId:s==null?void 0:s._id})]})};Mn.propTypes={user:r.object,loading:r.bool,deviceType:r.string,subscriptionInfo:r.object,subscriptionSyncing:r.bool,formikPaymentMethods:r.object.isRequired,swishEnabled:r.bool,setSwishEnabled:r.func,swishLeadingPlus:r.bool,setSwishLeadingPlus:r.func,swishIntegrationType:r.string,swishCertificateInfo:r.object,handleSwishIntegrationTypeChange:r.func,handleSwishCertificateUpload:r.func,handleSwishCertificateDelete:r.func,swishCertificateLoading:r.bool,swishCertificateUploading:r.bool,bankgiroEnabled:r.bool,setBankgiroEnabled:r.func,plusgiroEnabled:r.bool,setPlusgiroEnabled:r.func,bankAccountEnabled:r.bool,setBankAccountEnabled:r.func,ibanEnabled:r.bool,setIbanEnabled:r.func,bicEnabled:r.bool,setBicEnabled:r.func,openStripePortal:r.func.isRequired,openSubscriptionModal:r.func.isRequired,portalLoading:r.bool,pricingTableError:r.bool,defaultPaymentTerms:r.oneOfType([r.number,r.string]),setDefaultPaymentTerms:r.func,onSaveDefaultPaymentTerms:r.func,savingPaymentTerms:r.bool,defaultReminderFee:r.oneOfType([r.number,r.string]),setDefaultReminderFee:r.func,onSaveDefaultReminderFee:r.func,savingReminderFee:r.bool};const Bt=({ferrierId:s})=>{const{t:n}=ee(),[i,a]=l.useState(null),[t,o]=l.useState(null),[d,h]=l.useState(!0),[u,m]=l.useState(!1),[g,p]=l.useState(!1);l.useEffect(()=>{s&&(y(),x())},[s]);const y=async()=>{try{const{data:D}=await Q.get(Na.endPoint(s));a((D==null?void 0:D.result)||null)}catch(D){console.error("Error loading share code:",D),a(null)}finally{h(!1)}},x=async()=>{try{const{data:D}=await Q.get(wa.endPoint(s));o((D==null?void 0:D.result)||null)}catch(D){console.error("Error loading stats:",D),o(null)}},k=async()=>{m(!0);try{const{data:D}=await Q.post(Ca.endPoint(s));V.success(n("shareCode.generated")),a(D.result),x()}catch(D){V.error(re(D))}finally{m(!1)}},P=D=>{if(navigator.clipboard)navigator.clipboard.writeText(D).then(()=>{V.success(n("shareCode.copied"))});else{const O=document.createElement("textarea");O.value=D,document.body.appendChild(O),O.focus(),O.select();try{document.execCommand("copy"),V.success(n("shareCode.copied"))}catch{V.error(n("shareCode.copyFailed"))}document.body.removeChild(O)}},w=D=>D?new Date(D).toLocaleDateString("sv-SE",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"Aldrig";
1return d?e.jsx(T,{className:"mb-4",children:e.jsx(T.Body,{className:"text-center",children:e.jsx("div",{className:"spinner-border text-primary",role:"status",children:e.jsx("span",{className:"sr-only",children:"Laddar..."})})})}):e.jsxs(e.Fragment,{children:[e.jsxs(T,{className:"mb-4",children:[e.jsx(T.Header,{children:e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("h5",{className:"mb-0",children:[e.jsx("i",{className:"bi bi-share me-2"}),"Delningskod för kundapp"]}),e.jsxs(B,{variant:"outline-info",size:"sm",onClick:()=>p(!0),children:[e.jsx("i",{className:"bi bi-info-circle"})," Hur fungerar det?"]})]})}),e.jsx(T.Body,{children:i&&i.hasActiveCode?e.jsxs(Te,{children:[e.jsx(Be,{md:6,children:e.jsxs("div",{className:"text-center mb-3",children:[e.jsx("h6",{className:"text-muted mb-2",children:"Din aktiva delningskod"}),e.jsx("div",{className:"bg-light p-4 rounded border",style:{fontSize:"1.8rem",fontFamily:"monospace",fontWeight:"bold"},children:i.shareCode}),e.jsxs("div",{className:"mt-3",children:[e.jsxs(B,{variant:"primary",size:"sm",className:"me-2",onClick:()=>P(i.shareCode),children:[e.jsx("i",{className:"bi bi-clipboard"})," Kopiera kod"]}),e.jsx(B,{variant:"outline-secondary",size:"sm",onClick:k,disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner-border spinner-border-sm me-2"}),"Genererar..."]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-arrow-clockwise"})," Generera ny"]})})]})]})}),e.jsx(Be,{md:6,children:e.jsxs("div",{className:"border-start ps-4",children:[e.jsx("h6",{className:"text-muted mb-3",children:"Statistik"}),e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h4 text-primary mb-1",children:i.usageCount||0}),e.jsx("small",{className:"text-muted",children:"Gånger använd"})]})}),e.jsx("div",{className:"col-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"h4 text-success mb-1",children:(t==null?void 0:t.importedCustomers)||0}),e.jsx("small",{className:"text-muted",children:"Importerade kunder"})]})})]}),e.jsx("hr",{className:"my-3"}),e.jsxs("small",{className:"text-muted",children:[e.jsx("strong",{children:"Skapad:"})," ",w(i.createdAt),e.jsx("br",{}),e.jsx("strong",{children:"Senast använd:"})," ",w(i.lastUsedAt)]})]})})]}):e.jsxs("div",{className:"text-center py-4",children:[e.jsx("h6",{className:"text-muted mb-3",children:"Du har ingen aktiv delningskod"}),e.jsx("p",{className:"text-muted mb-4",children:"Skapa en delningskod så att kunder kan dela sina uppgifter med dig"}),e.jsx(B,{variant:"primary",onClick:k,disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner-border spinner-border-sm me-2"}),"Genererar..."]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"bi bi-plus-circle"})," Skapa delningskod"]})})]})})]}),e.jsxs(J,{show:g,onHide:()=>p(!1),size:"lg",children:[e.jsx(J.Header,{closeButton:!0,children:e.jsx(J.Title,{children:"Hur fungerar delningskoder?"})}),e.jsxs(J.Body,{children:[e.jsxs("div",{className:"row",children:[e.jsxs("div",{className:"col-md-6",children:[e.jsxs("h6",{className:"text-primary mb-3",children:[e.jsx("i",{className:"bi bi-1-circle"})," Skapa delningskod"]}),e.jsx("p",{className:"small",children:"Generera en unik kod som kunder kan använda för att dela sina uppgifter med dig."}),e.jsxs("h6",{className:"text-primary mb-3 mt-4",children:[e.jsx("i",{className:"bi bi-2-circle"})," Dela koden"]}),e.jsx("p",{className:"small",children:"Ge koden till nya kunder som ska registrera sig i kundappen."})]}),e.jsxs("div",{className:"col-md-6",children:[e.jsxs("h6",{className:"text-primary mb-3",children:[e.jsx("i",{className:"bi bi-3-circle"})," Kund använder koden"]}),e.jsx("p",{className:"small",children:"Kunden anger koden i sin app och delar sina uppgifter och djur med dig."}),e.jsxs("h6",{className:"text-primary mb-3 mt-4",children:[e.jsx("i",{className:"bi bi-4-circle"})," Automatisk import"]}),e.jsx("p",{className:"small",children:"Kundens uppgifter importeras automatiskt till ditt system och du kan börja hantera dem."})]})]}),e.jsxs(H,{variant:"info",className:"mt-4",children:[e.jsxs(H.Heading,{className:"h6",children:[e.jsx("i",{className:"bi bi-info-circle"})," Tips"]}),e.jsxs("ul",{className:"small mb-0",children:[e.jsx("li",{children:"Du kan generera en ny kod när som helst"}),e.jsx("li",{children:"Den gamla koden slutar fungera när du skapar en ny"}),e.jsx("li",{children:"Kunder kan bara använda koden en gång"}),e.jsx("li",{children:"All data importeras säkert och krypterat"})]})]})]}),e.jsx(J.Footer,{children:e.jsx(B,{variant:"secondary",onClick:()=>p(!1),children:"Stäng"})})]})]})},In=({currentLogo:s,onLogoChange:n,onLogoDelete:i,uploading:a=!1,imageBaseUrl:t=""})=>{const{t:o}=ee(),d=l.useRef(null),[h,u]=l.useState(!1),[m,g]=l.useState(null),[p,y]=l.useState(""),x=2*1024*1024,k=["image/png","image/jpeg","image/jpg","image/svg+xml"],P=I=>I?k.includes(I.type)?I.size>x?(y(o("BrandSettings.Logo.FileTooLarge")),!1):(y(""),!0):(y(o("BrandSettings.Logo.InvalidFormat")),!1):!1,w=I=>{if(!P(I))return;const Y=URL.createObjectURL(I);g(Y),n(I)},D=I=>{var Z;const Y=(Z=I.target.files)==null?void 0:Z[0];Y&&w(Y)},O=I=>{I.preventDefault(),I.stopPropagation(),I.type==="dragenter"||I.type==="dragover"?u(!0):I.type==="dragleave"&&u(!1)},b=I=>{var Z;I.preventDefault(),I.stopPropagation(),u(!1);const Y=(Z=I.dataTransfer.files)==null?void 0:Z[0];Y&&w(Y)},F=()=>{var I;(I=d.current)==null||I.click()},K=()=>{g(null),y(""),d.current&&(d.current.value=""),i==null||i()},U=m||(s?`${t}${s}`:null);return e.jsxs("div",{className:"brand-logo-upload",children:[e.jsx(c.Label,{children:e.jsx("strong",{children:o("BrandSettings.Logo.Label")})}),e.jsx("p",{className:"text-muted small mb-3",children:o("BrandSettings.Logo.Description")}),p&&e.jsxs(H,{variant:"danger",className:"mb-3",dismissible:!0,onClose:()=>y(""),children:[e.jsx("i",{className:"bi bi-exclamation-triangle me-2"}),p]}),e.jsxs("div",{className:`brand-logo-dropzone ${h?"drag-active":""} ${U?"has-logo":""}`,onDragEnter:O,onDragOver:O,onDragLeave:O,onDrop:b,onClick:F,children:[a?e.jsxs("div",{className:"text-center py-4",children:[e.jsx(W,{animation:"border",size:"sm",className:"me-2"}),e.jsx("span",{children:o("BrandSettings.Logo.Uploading")})]}):U?e.jsx("div",{className:"logo-preview-container",children:e.jsx(_e,{src:U,alt:o("BrandSettings.Logo.PreviewAlt"),className:"logo-preview"})}):e.jsxs("div",{className:"dropzone-content",children:[e.jsx("i",{className:"bi bi-cloud-arrow-up display-6 text-muted mb-2"}),e.jsx("p",{className:"mb-1",children:o("BrandSettings.Logo.DragDropText")}),e.jsx("p",{className:"text-muted small mb-0",children:o("BrandSettings.Logo.SupportedFormats")})]}),e.jsx(c.Control,{ref:d,type:"file",accept:".png,.jpg,.jpeg,.svg",onChange:D,className:"d-none"})]}),e.jsxs("div",{className:"d-flex gap-2 mt-3",children:[e.jsxs(B,{variant:"outline-primary",size:"sm",onClick:F,disabled:a,children:[e.jsx("i",{className:"bi bi-upload me-1"}),o(U?"BrandSettings.Logo.ChangeButton":"BrandSettings.Logo.UploadButton")]}),U&&e.jsxs(B,{variant:"outline-danger",size:"sm",onClick:I=>{I.stopPropagation(),K()},disabled:a,children:[e.jsx("i",{className:"bi bi-trash me-1"}),o("BrandSettings.Logo.DeleteButton")]})]}),e.jsx(c.Text,{className:"text-muted d-block mt-2",children:e.jsx("small",{children:o("BrandSettings.Logo.MaxSize")})})]})};In.propTypes={currentLogo:r.string,onLogoChange:r.func.isRequired,onLogoDelete:r.func,uploading:r.bool,imageBaseUrl:r.string};const On=({showLogoOnInvoice:s=!0,showLogoOnJournal:n=!0,showLogoOnBookingConf:i=!0,showLogoOnBookingReminder:a=!0,onChange:t,disabled:o=!1})=>{const{t:d}=ee(),h=(m,g)=>{t==null||t({[m]:g})},u=[{field:"showLogoOnInvoice",value:s,label:d("BrandSettings.Placement.Invoice"),description:d("BrandSettings.Placement.InvoiceDescription"),icon:"bi-receipt"},{field:"showLogoOnJournal",value:n,label:d("BrandSettings.Placement.Journal"),description:d("BrandSettings.Placement.JournalDescription"),icon:"bi-journal-medical"},{field:"showLogoOnBookingConf",value:i,label:d("BrandSettings.Placement.BookingConfirmation"),description:d("BrandSettings.Placement.BookingConfirmationDescription"),icon:"bi-envelope-check"},{field:"showLogoOnBookingReminder",value:a,label:d("BrandSettings.Placement.BookingReminder"),description:d("BrandSettings.Placement.BookingReminderDescription"),icon:"bi-bell"}];return e.jsxs("div",{className:"brand-logo-placement",children:[e.jsx(c.Label,{children:e.jsx("strong",{children:d("BrandSettings.Placement.Label")})}),e.jsx("p",{className:"text-muted small mb-3",children:d("BrandSettings.Placement.Description")}),e.jsx("div",{className:"placement-options",children:u.map(m=>e.jsx("div",{className:"placement-option mb-3",children:e.jsx(c.Check,{type:"switch",id:`placement-${m.field}`,checked:m.value,onChange:g=>h(m.field,g.target.checked),disabled:o,label:e.jsxs("div",{className:"placement-label",children:[e.jsxs("div",{className:"d-flex align-items-center",children:[e.jsx("i",{className:`bi ${m.icon} me-2`}),e.jsx("strong",{children:m.label})]}),e.jsx("p",{className:"text-muted small mb-0 mt-1",children:m.description})]})})},m.field))})]})};On.propTypes={showLogoOnInvoice:r.bool,showLogoOnJournal:r.bool,showLogoOnBookingConf:r.bool,showLogoOnBookingReminder:r.bool,onCh
1ange:r.func,disabled:r.bool};const Kn=s=>{const n=s.replace(/^#/,""),i=parseInt(n,16);return{r:i>>16&255,g:i>>8&255,b:i&255}},At=(s,n,i)=>{const a=t=>{const o=Math.max(0,Math.min(255,Math.round(t))).toString(16);return o.length===1?"0"+o:o};return`#${a(s)}${a(n)}${a(i)}`.toUpperCase()},Lt=s=>{const{r:n,g:i,b:a}=Kn(s),t=n/255,o=i/255,d=a/255,h=Math.max(t,o,d),u=Math.min(t,o,d),m=(h+u)/2;let g=0,p=0;if(h!==u){const y=h-u;switch(p=m>.5?y/(2-h-u):y/(h+u),h){case t:g=((o-d)/y+(o<d?6:0))/6;break;case o:g=((d-t)/y+2)/6;break;case d:g=((t-o)/y+4)/6;break}}return{h:Math.round(g*360),s:Math.round(p*100),l:Math.round(m*100)}},Dt=(s,n,i)=>{const a=n/100,t=i/100,o=(1-Math.abs(2*t-1))*a,d=o*(1-Math.abs(s/60%2-1)),h=t-o/2;let u=0,m=0,g=0;return s>=0&&s<60?(u=o,m=d,g=0):s>=60&&s<120?(u=d,m=o,g=0):s>=120&&s<180?(u=0,m=o,g=d):s>=180&&s<240?(u=0,m=d,g=o):s>=240&&s<300?(u=d,m=0,g=o):(u=o,m=0,g=d),At(Math.round((u+h)*255),Math.round((m+h)*255),Math.round((g+h)*255))},an=s=>{if(!s||!Je(s))return"#E8F5E9";const n=Lt(s),i=Math.min(95,n.l+35),a=Math.max(20,n.s-30);return Dt(n.h,a,i)},vs=s=>{const{r:n,g:i,b:a}=Kn(s),t=o=>{const d=o/255;return d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4)};return .2126*t(n)+.7152*t(i)+.0722*t(a)},Vn=(s,n)=>{if(!Je(s)||!Je(n))return 1;const i=vs(s),a=vs(n),t=Math.max(i,a),o=Math.min(i,a);return(t+.05)/(o+.05)},Tt=s=>Je(s)&&vs(s)>.179?"#000000":"#FFFFFF",Rt=(s,n,i=!1)=>{const a=Vn(s,n);return i?a>=3:a>=4.5},Je=s=>!s||typeof s!="string"?!1:/^#[0-9A-Fa-f]{6}$/.test(s),qe={primary:"#2E7D32",secondary:"#E8F5E9",textOnColor:"#FFFFFF"},zt=["#2E7D32","#1B5E20","#388E3C","#4CAF50","#1565C0","#0D47A1","#1976D2","#42A5F5","#37474F","#263238","#455A64","#607D8B","#4E342E","#3E2723","#5D4037","#795548","#AD1457","#880E4F","#C2185B","#E91E63","#E65100","#BF360C","#F4511E","#FF7043","#F9A825","#F57F17","#FBC02D","#FFCA28","#6A1B9A","#4A148C","#7B1FA2","#AB47BC","#212121","#424242","#616161","#9E9E9E","#B71C1C","#C62828","#D32F2F","#EF5350"],tn=({value:s,onChange:n,disabled:i})=>{const[a,t]=l.useState(!1),o=l.useRef(null);return l.useEffect(()=>{const d=h=>{o.current&&!o.current.contains(h.target)&&t(!1)};return a&&(document.addEventListener("mousedown",d),document.addEventListener("touchstart",d)),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("touchstart",d)}},[a]),e.jsxs("div",{className:"color-swatch-picker",ref:o,style:{position:"relative"},children:[e.jsx("div",{className:"color-swatch-trigger",onClick:()=>!i&&t(!a),style:{width:50,height:38,backgroundColor:s,borderRadius:4,border:"1px solid #dee2e6",cursor:i?"not-allowed":"pointer",opacity:i?.6:1,flexShrink:0}}),a&&e.jsx("div",{className:"color-swatch-popover",style:{position:"absolute",top:"calc(100% + 4px)",left:0,zIndex:1050,backgroundColor:"#fff",border:"1px solid #dee2e6",borderRadius:8,padding:12,boxShadow:"0 4px 16px rgba(0,0,0,0.15)",width:240},children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(8, 1fr)",gap:4},children:zt.map(d=>e.jsx("div",{onClick:()=>{n(d),t(!1)},style:{width:24,height:24,backgroundColor:d,borderRadius:4,cursor:"pointer",border:s===d?"2px solid #000":"1px solid #dee2e6",transition:"transform 0.1s"},onMouseEnter:h=>h.target.style.transform="scale(1.2)",onMouseLeave:h=>h.target.style.transform="scale(1)"},d))})})]})},qn=({primaryColor:s=qe.primary,secondaryColor:n=qe.secondary,textOnColor:i=qe.textOnColor,onChange:a,disabled:t=!1})=>{const{t:o}=ee(),d=()=>{const b=an(s);return n===b||n===qe.secondary},[h,u]=l.useState(d),[m,g]=l.useState(s),[p,y]=l.useState(n);l.useEffect(()=>{g(s)},[s]),l.useEffect(()=>{y(n)},[n]),l.useEffect(()=>{if(h&&s){const b=an(s),F=Tt(s);a==null||a({brandSecondaryColor:b,brandTextOnColor:F}),y(b)}},[s,h]);const x=b=>{Je(b)&&(a==null||a({brandPrimaryColor:b})),g(b)},k=b=>{u(!1),Je(b)&&(a==null||a({brandSecondaryColor:b})),y(b)},P=(b,F)=>{const K=F.startsWith("#")?F:`#${F}`;Je(K)?b==="primary"?x(K.toUpperCase()):k(K.toUpperCase()):b==="primary"?g(s):y(n)},w=()=>{u(!0),a==null||a({brandPrimaryColor:qe.primary,brandSecondaryColor:qe.secondary,brandTextOnColor:qe.textOnColor}),g(qe.primary),y(qe.secondary)},D=Vn(i,s),O=Rt(i,s);return e.jsxs("div",{className:"brand-color-picker",children:[e.jsx(c.Label,{children:e.jsx("strong",{children:o("BrandSettings.Colors.Label")})}),e.jsx("p",{className:"text-muted small mb-3",children:o("BrandSettings.Colors.Description")}
1),e.jsxs(Te,{className:"g-3",children:[e.jsx(Be,{xs:12,md:6,children:e.jsxs("div",{className:"color-picker-group",children:[e.jsx(c.Label,{className:"small fw-semibold",children:o("BrandSettings.Colors.PrimaryLabel")}),e.jsxs("div",{className:"d-flex align-items-center gap-2",children:[e.jsx(tn,{value:s,onChange:x,disabled:t}),e.jsx(c.Control,{type:"text",value:m,onChange:b=>g(b.target.value.toUpperCase()),onBlur:b=>P("primary",b.target.value),disabled:t,maxLength:7,className:"hex-input",placeholder:"#2E7D32"})]}),e.jsx(c.Text,{className:"text-muted small",children:o("BrandSettings.Colors.PrimaryDescription")})]})}),e.jsx(Be,{xs:12,md:6,children:e.jsxs("div",{className:"color-picker-group",children:[e.jsxs(c.Label,{className:"small fw-semibold d-flex align-items-center justify-content-between",children:[e.jsx("span",{children:o("BrandSettings.Colors.SecondaryLabel")}),h&&e.jsx("span",{className:"badge bg-secondary small",children:o("BrandSettings.Colors.AutoGenerated")})]}),e.jsxs("div",{className:"d-flex align-items-center gap-2",children:[e.jsx(tn,{value:n,onChange:k,disabled:t}),e.jsx(c.Control,{type:"text",value:p,onChange:b=>{u(!1),y(b.target.value.toUpperCase())},onBlur:b=>P("secondary",b.target.value),disabled:t,maxLength:7,className:"hex-input",placeholder:"#E8F5E9"})]}),e.jsx(c.Text,{className:"text-muted small",children:o("BrandSettings.Colors.SecondaryDescription")})]})})]}),e.jsxs("div",{className:"color-preview mt-4 mb-3",children:[e.jsx(c.Label,{className:"small fw-semibold mb-2",children:o("BrandSettings.Colors.Preview")}),e.jsxs("div",{className:"preview-container d-flex gap-2",children:[e.jsx("div",{className:"preview-box primary-preview",style:{backgroundColor:s,color:i},children:o("BrandSettings.Colors.PreviewPrimary")}),e.jsx("div",{className:"preview-box secondary-preview",style:{backgroundColor:n},children:o("BrandSettings.Colors.PreviewSecondary")})]})]}),!O&&e.jsxs(H,{variant:"warning",className:"mb-3",children:[e.jsx("i",{className:"bi bi-exclamation-triangle me-2"}),e.jsx("strong",{children:o("BrandSettings.Colors.ContrastWarningTitle")}),e.jsx("p",{className:"mb-0 small mt-1",children:o("BrandSettings.Colors.ContrastWarning",{ratio:D.toFixed(1)})})]}),e.jsxs(B,{variant:"outline-secondary",size:"sm",onClick:w,disabled:t,className:"mt-2",children:[e.jsx("i",{className:"bi bi-arrow-counterclockwise me-1"}),o("BrandSettings.Colors.ResetButton")]})]})};qn.propTypes={primaryColor:r.string,secondaryColor:r.string,textOnColor:r.string,onChange:r.func,disabled:r.bool};const $n=({greetingInvoice:s="",greetingReceipt:n="",greetingBookingConf:i="",greetingBookingReminder:a="",onChange:t,disabled:o=!1})=>{const{t:d}=ee(),h=100,u=(p,y)=>{y.length<=h&&(t==null||t({[p]:y}))},m=p=>p?p.replace(/\{kundnamn\}/gi,"Anna Andersson").replace(/\{customername\}/gi,"Anna Andersson").replace(/\{företagsnamn\}/gi,"Hovslagare AB").replace(/\{companyname\}/gi,"Hovslagare AB").replace(/\{datum\}/gi,new Date().toLocaleDateString("sv-SE")):"",g=[{field:"greetingInvoice",value:s,label:d("BrandSettings.Greetings.InvoiceLabel"),placeholder:d("BrandSettings.Greetings.InvoicePlaceholder"),icon:"bi-receipt"},{field:"greetingReceipt",value:n,label:d("BrandSettings.Greetings.ReceiptLabel"),placeholder:d("BrandSettings.Greetings.ReceiptPlaceholder"),icon:"bi-receipt-cutoff"},{field:"greetingBookingConf",value:i,label:d("BrandSettings.Greetings.BookingConfLabel"),placeholder:d("BrandSettings.Greetings.BookingConfPlaceholder"),icon:"bi-envelope-check"},{field:"greetingBookingReminder",value:a,label:d("BrandSettings.Greetings.BookingReminderLabel"),placeholder:d("BrandSettings.Greetings.BookingReminderPlaceholder"),icon:"bi-bell"}];return e.jsxs("div",{className:"brand-greeting-text",children:[e.jsx(c.Label,{children:e.jsx("strong",{children:d("BrandSettings.Greetings.Label")})}),e.jsx("p",{className:"text-muted small mb-3",children:d("BrandSettings.Greetings.Description")}),e.jsxs(H,{variant:"light",className:"border mb-4",children:[e.jsx("div",{className:"mb-2",children:e.jsxs("strong",{children:[e.jsx("i",{className:"bi bi-lightbulb me-2"}),d("BrandSettings.Greetings.VariablesTitle")]})}),e.jsx("p",{className:"small mb-2",children:d("BrandSettings.Greetings.VariablesDescription")}),e.jsxs("div",{className:"d-flex flex-wrap gap-2 small",children:[e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"{kundnamn}"}),e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"{företagsnamn}"}),e.jsx("code",{className:"bg-white px-2 py-1 rounded border",children:"{datum}"})]})]}),e.jsx("div",{className:"greeting-fields",children:g.map(p=>e.jsx(T,{className:"mb-3",children:e.jsx(T.Body,{className:"py-3",children:e.jsxs(c.Group,{children:[e.jsxs(c.Label,{className:"d-flex align-items-center mb-2",children:[e.jsx("i",{className:`bi ${p.icon} me-2`}),e.jsx("strong",{className:"small",children:p.label})]}),e.jsx(c.Control,{type:"text",value:p.value,onChange:y=>u(p.field,y.target.value),placeholder:p.placeholder,disabled:o,maxLength:h}),e.jsx("div",{className:"d-flex justify-content-between align-items-center mt-1",children:e.jsxs(c.Text,{className:"text-muted",children:[(p.value||"").length,"/",h," ",d("BrandSettings.Greetings.Characters")]})}),p.value&&p.value.length>0&&e.jsxs("div",{className:"greeting-preview mt-2 p-2 bg-light rounded border-start border-primary border-3",children:[e.jsxs("small",{className:"text-muted d-block mb-1",children:[d("BrandSettings.Greetings.Preview"),":"]}),e.jsx("span",{className:"small fst-italic",children:m(p.value)})]})]})})},p.field))})]})};$n.propTypes={greetingInvoice:r.string,greetingReceipt:r.string,greetingBookingConf:r.string,greetingBookingReminder:r.string,onChange:r.func,disabled:r.bool};const Un=({show:s,onHide:n,settings:i,logoUrl:a,invoiceTemplate:t="minimal"})=>{const{t:o}=ee(),[d,h]=l.useState("invoice"),{brandPrimaryColor:u="#2E7D32",brandSecondaryColor:m="#E8F5E9",brandTextOnColor:g="#FFFFFF",greetingInvoice:p="",greetingBookingConf:y=""}=i||{},x=b=>b?b.replace(/\{kundnamn\}
1/gi,"Anna Andersson").replace(/\{customername\}/gi,"Anna Andersson").replace(/\{företagsnamn\}/gi,"Hovslagare AB").replace(/\{companyname\}/gi,"Hovslagare AB").replace(/\{datum\}/gi,new Date().toLocaleDateString("sv-SE")):"",k=()=>e.jsxs("div",{className:"preview-document invoice-preview",children:[e.jsxs("div",{className:"preview-header d-flex justify-content-between align-items-start",style:{backgroundColor:"#fff",padding:"16px"},children:[e.jsx("div",{children:a?e.jsx(_e,{src:a,alt:"Logo",className:"preview-logo"}):e.jsx("div",{className:"preview-logo-placeholder",children:e.jsx("i",{className:"bi bi-building"})})}),e.jsxs("div",{className:"text-end",children:[e.jsx("span",{className:"px-3 py-1 fw-bold rounded",style:{backgroundColor:u,color:g,fontSize:"1.1rem"},children:"FAKTURA"}),e.jsx("div",{className:"mt-2",children:e.jsxs("small",{className:"text-muted",children:["#2024-001 · ",new Date().toLocaleDateString("sv-SE")]})})]})]}),p&&e.jsx("div",{className:"px-3 py-2 mb-3",style:{backgroundColor:m,borderLeft:`4px solid ${u}`},children:e.jsx("small",{children:x(p)})}),e.jsxs("div",{className:"preview-body",children:[e.jsxs("div",{className:"row mb-3",children:[e.jsxs("div",{className:"col-6",children:[e.jsx("small",{className:"text-muted",children:o("BrandSettings.Preview.Customer")}),e.jsx("p",{className:"mb-0 small fw-semibold",children:"Anna Andersson"})]}),e.jsxs("div",{className:"col-6 text-end",children:[e.jsx("small",{className:"text-muted",children:o("BrandSettings.Preview.Date")}),e.jsx("p",{className:"mb-0 small",children:new Date().toLocaleDateString("sv-SE")})]})]}),e.jsxs("div",{className:"preview-items mt-3 p-2 rounded",style:{backgroundColor:m},children:[e.jsxs("div",{className:"d-flex justify-content-between small",children:[e.jsx("span",{children:o("BrandSettings.Preview.Service")}),e.jsx("span",{children:"500 kr"})]}),e.jsx("hr",{className:"my-2"}),e.jsxs("div",{className:"d-flex justify-content-between small fw-bold",children:[e.jsx("span",{children:o("BrandSettings.Preview.Total")}),e.jsx("span",{children:"500 kr"})]})]})]}),e.jsxs("div",{className:"mt-3 p-2 rounded-bottom d-flex justify-content-between",style:{backgroundColor:u,color:g,fontSize:"0.7rem"},children:[e.jsx("span",{children:"Hovslagare AB"}),e.jsx("span",{children:"Org.nr: 556677-8899"}),e.jsx("span",{children:"[email protected]"})]})]}),P=()=>e.jsxs("div",{className:"preview-document invoice-preview",children:[e.jsx("div",{style:{height:5,background:`linear-gradient(90deg, ${u}, ${m})`}}),e.jsxs("div",{className:"d-flex justify-content-between align-items-start p-3",style:{backgroundColor:"#fff"},children:[e.jsx("div",{style:{flex:1},children:a?e.jsx(_e,{src:a,alt:"Logo",className:"preview-logo"}):e.jsx("div",{className:"preview-logo-placeholder",children:e.jsx("i",{className:"bi bi-building"})})}),e.jsx("div",{style:{flex:1,textAlign:"center"},children:p&&e.jsx("div",{className:"px-2 py-1 rounded",style:{border:`2px solid ${u}`,display:"inline-block"},children:e.jsx("small",{className:"fst-italic",children:x(p)})})}),e.jsxs("div",{className:"px-3 py-2 rounded text-end",style:{backgroundColor:u,color:g,flex:"0 0 auto"},children:[e.jsx("div",{className:"fw-bold",style:{fontSize:"0.9rem"},children:"FAKTURA"}),e.jsx("small",{children:"#2024-001"}),e.jsx("br",{}),e.jsx("small",{children:new Date().toLocaleDateString("sv-SE")})]})]}),e.jsxs("div",{className:"preview-body",children:[e.jsxs("div",{className:"row mb-3",children:[e.jsxs("div",{className:"col-6",children:[e.jsx("small",{className:"fw-bold",style:{color:m!=="#E8F5E9"?m:u},children:"Mottagare"}),e.jsx("p",{className:"mb-0 small",children:"Anna Andersson"})]}),e.jsxs("div",{className:"col-6",children:[e.jsx("small",{className:"fw-bold",style:{color:m!=="#E8F5E9"?m:u},children:"Avsändare"}),e.jsx("p",{className:"mb-0 small",children:"Hovslagare AB"})]})]}),e.jsxs("div",{className:"preview-items mt-3 p-2 rounded",style:{backgroundColor:m},children:[e.jsxs("div",{className:"d-flex justify-content-between small",children:[e.jsx("span",{children:o("BrandSettings.Preview.Service")}),e.jsx("span",{children:"500 kr"})]}),e.jsx("hr",{className:"my-2"}),e.jsxs("div",{className:"d-flex justify-content-between small fw-bold",children:[e.jsx("span",{children:o("BrandSettings.Preview.Total")}),e.jsx("span",{children:"500 kr"})]})]})]}),e.jsxs("div",{className:"mt-3 p-2 rounded-bottom d-flex justify-content-between",style:{backgroundColor:u,color:g,fontSize:"0.7rem"},children:[e.jsx("span",{children:"Hovslagare AB"}),e.jsx("span",{children:"Org.nr: 556677-8899"}),e.jsx("span",{children:"[email protected]"})]})]}),w=()=>t==="premium"?P():k(),D=()=>e.jsxs("div",{className:"preview-document journal-preview",children:[e.jsx("div",{className:"preview-header",style:{backgroundColor:u,color:g},children:e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[a?e.jsx(_e,{src:a,alt:"Logo",className:"preview-logo"}):e.jsx("div",{className:"preview-logo-placeholder",children:e.jsx("i",{className:"bi bi-building"})}),e.jsx("div",{className:"text-end",children:e.jsx("h5",{className:"mb-0",style:{color:g}
1,children:o("BrandSettings.Preview.JournalTitle")})})]})}),e.jsxs("div",{className:"preview-body",children:[e.jsxs("div",{className:"row mb-3",children:[e.jsxs("div",{className:"col-6",children:[e.jsx("small",{className:"text-muted",children:o("BrandSettings.Preview.Animal")}),e.jsx("p",{className:"mb-0 small fw-semibold",children:"Mirre"})]}),e.jsxs("div",{className:"col-6",children:[e.jsx("small",{className:"text-muted",children:o("BrandSettings.Preview.Date")}),e.jsx("p",{className:"mb-0 small",children:new Date().toLocaleDateString("sv-SE")})]})]}),e.jsxs("div",{className:"preview-section p-2 rounded mb-2",style:{backgroundColor:m},children:[e.jsx("small",{className:"fw-semibold",children:o("BrandSettings.Preview.Notes")}),e.jsx("p",{className:"mb-0 small mt-1",children:o("BrandSettings.Preview.JournalNoteExample")})]})]})]}),O=()=>e.jsxs("div",{className:"preview-document email-preview",children:[e.jsx("div",{className:"preview-header",style:{backgroundColor:u,color:g},children:e.jsxs("div",{className:"d-flex align-items-center",children:[a?e.jsx(_e,{src:a,alt:"Logo",className:"preview-logo me-3"}):e.jsx("div",{className:"preview-logo-placeholder me-3",children:e.jsx("i",{className:"bi bi-building"})}),e.jsx("h5",{className:"mb-0",style:{color:g},children:o("BrandSettings.Preview.BookingConfirmationTitle")})]})}),e.jsxs("div",{className:"preview-body",children:[e.jsx("p",{className:"small mb-2",children:e.jsx("strong",{children:o("BrandSettings.Preview.EmailGreeting")})}),e.jsx("p",{className:"small mb-3",children:o("BrandSettings.Preview.BookingConfirmed")}),y&&e.jsx("div",{className:"preview-greeting p-2 mb-3 rounded border-start border-3",style:{backgroundColor:m,borderColor:u},children:e.jsx("small",{className:"fst-italic",children:x(y)})}),e.jsx("div",{className:"preview-details p-2 rounded",style:{backgroundColor:m},children:e.jsxs("div",{className:"small",children:[e.jsxs("p",{className:"mb-1",children:[e.jsxs("strong",{children:[o("BrandSettings.Preview.Date"),":"]})," ",new Date().toLocaleDateString("sv-SE")]}),e.jsxs("p",{className:"mb-1",children:[e.jsxs("strong",{children:[o("BrandSettings.Preview.Time"),":"]})," 10:00 - 11:00"]}),e.jsxs("p",{className:"mb-0",children:[e.jsxs("strong",{children:[o("BrandSettings.Preview.Animal"),":"]})," Mirre"]})]})})]})]});return e.jsxs(J,{show:s,onHide:n,size:"lg",centered:!0,children:[e.jsx(J.Header,{closeButton:!0,children:e.jsxs(J.Title,{children:[e.jsx("i",{className:"bi bi-eye me-2"}),o("BrandSettings.Preview.ModalTitle")]})}),e.jsx(J.Body,{children:e.jsxs(Ee.Container,{activeKey:d,onSelect:h,children:[e.jsxs(Ke,{variant:"tabs",className:"mb-4",children:[e.jsx(Ke.Item,{children:e.jsxs(Ke.Link,{eventKey:"invoice",children:[e.jsx("i",{className:"bi bi-receipt me-1"}),o("BrandSettings.Preview.TabInvoice")]})}),e.jsx(Ke.Item,{children:e.jsxs(Ke.Link,{eventKey:"journal",children:[e.jsx("i",{className:"bi bi-journal-medical me-1"}),o("BrandSettings.Preview.TabJournal")]})}),e.jsx(Ke.Item,{children:e.jsxs(Ke.Link,{eventKey:"booking",children:[e.jsx("i",{className:"bi bi-envelope-check me-1"}),o("BrandSettings.Preview.TabBooking")]})})]}),e.jsxs(Ee.Content,{children:[e.jsx(Ee.Pane,{eventKey:"invoice",children:w()}),e.jsx(Ee.Pane,{eventKey:"journal",children:D()}),e.jsx(Ee.Pane,{eventKey:"booking",children:O()})]})]})}),e.jsx(J.Footer,{children:e.jsx(B,{variant:"secondary",onClick:n,children:o("commonButton.Close")})})]})};Un.propTypes={show:r.bool.isRequired,onHide:r.func.isRequired,settings:r.shape({brandPrimaryColor:r.string,brandSecondaryColor:r.string,brandTextOnColor:r.string,greetingInvoice:r.string,greetingBookingConf:r.string}),logoUrl:r.string,invoiceTemplate:r.oneOf(["minimal","premium"])};const Oe={brandPrimaryColor:"#2E7D32",brandSecondaryColor:"#E8F5E9",brandTextOnColor:"#FFFFFF",showLogoOnInvoice:!0,showLogoOnJournal:!0,showLogoOnBookingConf:!0,showLogoOnBookingReminder:!0,greetingInvoice:"",greetingReceipt:"",greetingBookingConf:"",greetingBookingReminder:"",brandLogo:null,invoiceTemplate:"minimal"},Mt=()=>{const{t:s}=ee(),{user:n}=as(),i="https://ewq-ferrier.s3.eu-north-1.amazonaws.com/",[a,t]=l.useState(!1),[o,d]=l.useState(!1),[h,u]=l.useState(!1),[m,g]=l.useState(Oe),[p,y]=l.useState(null),[x,k]=l.useState(!1),[P,w]=l.useState(!1),[D,O]=l.useState(!1),[b,F]=l.useState(null),[K,U]=l.useState(null);l.useEffect(()=>{n!=null&&n.id&&I()},[n]),l.useEffect(()=>{if(p){const G=JSON.stringify(m)!==JSON.stringify(p)||b!==null;k(G)}},[m,p,b]);const I=async()=>{var G;t(!0);try{const{data:q}=await Q.get(Pa.endPoint(n.id));if(q!=null&&q.result){const ce={brandPrimaryColor:q.result.brandPrimaryColor||Oe.brandPrimaryColor,brandSecondaryColor:q.result.brandSecondaryColor||Oe.brandSecondaryColor,brandTextOnColor:q.result.brandTextOnColor||Oe.brandTextOnColor,showLogoOnInvoice:q.result.showLogoOnInvoice??Oe.showLogoOnInvoice,showLogoOnJournal:q.result.showLogoOnJournal??Oe.showLogoOnJournal,showLogoOnBookingConf:q.result.showLogoOnBookingConf??Oe.showLogoOnBookingConf,showLogoOnBookingReminder:q.result.showLogoOnBookingReminder??Oe.showLogoOnBookingReminder,greetingInvoice:q.result.greetingInvoice||"",greetingReceipt:q.result.greetingReceipt||"",greetingBookingConf:q.result.greetingBookingConf||"",greetingBookingReminder:q.result.greetingBookingReminder||"",brandLogo:q.result.brandLogo||null,invoiceTemplate:q.result.invoiceTemplate||"minimal"};g(ce),y(ce)}}catch(q){((G=q==null?void 0:q.response)==null?void 0:G.status)!==404&&V.error(re(q)),g(Oe),y(Oe)}finally{t(!1)}},Y=G=>{g(q=>({...q,...G}))},Z=G=>{F(G);const q=URL.createObjectURL(G);U(q)},je=async()=>
1{if(b){F(null),U(null);return}if(m.brandLogo)try{await Q.delete(Fa.endPoint(n.id)),g(G=>({...G,brandLogo:null})),y(G=>({...G,brandLogo:null})),V.success(s("BrandSettings.Logo.DeleteSuccess"))}catch(G){V.error(re(G))}},le=async()=>{var G,q,ce,ae,de;d(!0);try{if(b){u(!0);const R=new FormData;R.append("logo",b);try{const{data:C}=await Q.post(Ea.endPoint(n.id),R,{headers:{"Content-Type":"multipart/form-data"}});(G=C==null?void 0:C.result)!=null&&G.brandLogo&&g(j=>({...j,brandLogo:C.result.brandLogo}))}catch(C){V.error(re(C)),u(!1),d(!1);return}u(!1),F(null),U(null)}const me={brandPrimaryColor:m.brandPrimaryColor,brandSecondaryColor:m.brandSecondaryColor,brandTextOnColor:m.brandTextOnColor,showLogoOnInvoice:m.showLogoOnInvoice,showLogoOnJournal:m.showLogoOnJournal,showLogoOnBookingConf:m.showLogoOnBookingConf,showLogoOnBookingReminder:m.showLogoOnBookingReminder,greetingInvoice:((q=m.greetingInvoice)==null?void 0:q.trim())||null,greetingReceipt:((ce=m.greetingReceipt)==null?void 0:ce.trim())||null,greetingBookingConf:((ae=m.greetingBookingConf)==null?void 0:ae.trim())||null,greetingBookingReminder:((de=m.greetingBookingReminder)==null?void 0:de.trim())||null,invoiceTemplate:m.invoiceTemplate},{data:ue}=await Q.put(Ba.endPoint(n.id),me);if(ue!=null&&ue.result){const R={...m,...ue.result};y(R),g(R),k(!1),V.success(s("BrandSettings.SaveSuccess"))}}catch(me){V.error(re(me))}finally{d(!1)}},fe=()=>{p&&(g(p),F(null),U(null))},oe=()=>K||(m.brandLogo?`${i}${m.brandLogo}`:null);return a?e.jsx(T,{className:"mb-4 brand-customization-card",children:e.jsxs(T.Body,{className:"text-center",children:[e.jsx(W,{animation:"border",size:"sm"}),e.jsx("p",{className:"mt-2 mb-0",children:s("BrandSettings.Loading")})]})}):e.jsxs(e.Fragment,{children:[e.jsxs(T,{className:"mb-4 brand-customization-card",children:[e.jsx(T.Header,{style:{cursor:"pointer"},onClick:()=>w(!P),children:e.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("h5",{className:"mb-0",children:[e.jsx("i",{className:"bi bi-palette me-2"}),s("BrandSettings.Title")]}),e.jsxs("div",{className:"d-flex align-items-center gap-2",children:[!P&&m.brandPrimaryColor&&e.jsx("div",{className:"rounded",style:{width:24,height:24,backgroundColor:m.brandPrimaryColor,border:"1px solid #dee2e6"}}),e.jsx("i",{className:`bi ${P?"bi-chevron-up":"bi-chevron-down"}`})]})]})}),P&&e.jsxs(T.Body,{children:[e.jsxs(H,{variant:"info",className:"mb-4",children:[e.jsx("i",{className:"bi bi-info-circle me-2"}),s("BrandSettings.Description")]}),e.jsxs(c,{children:[e.jsx("div",{className:"brand-section",children:e.jsx(In,{currentLogo:m.brandLogo,onLogoChange:Z,onLogoDelete:je,uploading:h,imageBaseUrl:i})}),e.jsx("div",{className:"brand-section",children:e.jsx(On,{showLogoOnInvoice:m.showLogoOnInvoice,showLogoOnJournal:m.showLogoOnJournal,showLogoOnBookingConf:m.showLogoOnBookingConf,showLogoOnBookingReminder:m.showLogoOnBookingReminder,onChange:Y,disabled:o})}),e.jsx("div",{className:"brand-section",children:e.jsx(qn,{primaryColor:m.brandPrimaryColor,secondaryColor:m.brandSecondaryColor,textOnColor:m.brandTextOnColor,onChange:Y,disabled:o})}),e.jsx("div",{className:"brand-section",children:e.jsx($n,{greetingInvoice:m.greetingInvoice,greetingReceipt:m.greetingReceipt,greetingBookingConf:m.greetingBookingConf,greetingBookingReminder:m.greetingBookingReminder,onChange:Y,disabled:o})}),e.jsxs("div",{className:"brand-section",children:[e.jsxs("h6",{className:"brand-section-title",children:[e.jsx("i",{className:"bi bi-file-earmark-text me-2"}),s("BrandSettings.Template.Label")]}),e.jsx("p",{className:"text-muted small mb-3",children:s("BrandSettings.Template.Description")}),e.jsx("div",{className:"d-flex gap-3 flex-wrap",children:["minimal","premium"].map(G=>e.jsx(T,{className:`template-select-card ${m.invoiceTemplate===G?"selected":""}`,style:{cursor:o?"not-allowed":"pointer",flex:"1 1 200px",maxWidth:"280px",border:m.invoiceTemplate===G?`2px solid ${m.brandPrimaryColor}`:"2px solid #dee2e6",opacity:o?.6:1},onClick:()=>!o&&Y({invoiceTemplate:G}),children:e.jsxs(T.Body,{className:"text-center py-3",children:[e.jsx("div",{className:"mb-2 mx-auto",style:{width:60,height:80,border:`2px solid ${m.invoiceTemplate===G?m.brandPrimaryColor:"#dee2e6"}`,borderRadius:4,display:"flex",flexDirection:"column",overflow:"hidden"},children:G==="minimal"?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{height:6,backgroundColor:m.brandPrimaryColor}}),e.jsx("div",{style:{height:4,backgroundColor:m.brandSecondaryColor,margin:"3px 4px 0"}}),e.jsxs("div",{style:{flex:1,padding:"3px 4px"},children:[e.jsx("div",{style:{height:2,backgroundColor:"#ddd",marginBottom:2}}),e.jsx("div",{style:{height:2,backgroundColor:"#ddd",marginBottom:2}}),e.jsx("div",{style:{height:2,backgroundColor:"#ddd",width:"60%"}})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{height:3,background:`linear-gradient(90deg, ${m.brandPrimaryColor}, ${m.brandSecondaryColor})`}}),e.jsxs("div",{style:{display:"flex",padding:"3px 4px 0",gap:3},children:[e.jsx("div",{style:{width:12,height:12,backgroundColor:"#eee",borderRadius:2}}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{height:2,backgroundColor:"#ddd",marginBottom:2}}),e.jsx("div",{style:{height:2,backgroundColor:"#ddd",width:"60%"}})]}),e.jsx("div",{style:{width:16,height:14,backgroundColor:m.brandPrimaryColor,borderRadius:2}})]}),e.jsxs("div",{style:{flex:1,padding:"3px 4px"},children:[e.jsx("div",{style:{height:2,backgroundColor:"#ddd",marginBottom:2}}),e.jsx("div",{style:{height:2,backgroundColor:"#ddd",marginBottom:2}}),e.jsx("div",{style:{height:2,backgroundColor:"#ddd",width:"60%"}})]})]})}),e.jsx("div",{className:"fw-semibold",children:s(`BrandSettings.Template.${G==="minimal"?"Minimal":"Premium"}`)}),e.jsx("small",{className:"text-muted",children:s(`BrandSettings.Template.${G==="minimal"?"MinimalDescription":"PremiumDescription"}`)}),m.invoiceTemplate===G&&e.jsx("div",{className:"mt-1",children:e.jsx("i",{className:"bi bi-check-circle-fill",style:{color:m.brandPrimaryColor}})})]})},G))})]}),e.jsxs("div",{className:"brand-action-buttons",children:[e.jsx(B,{variant:"primary",onClick:le,disabled:o||!x,children:o?e.jsxs(e.Fragment,{children:[e.jsx(W,{animation:"border",size:"sm",className:"me-2"}),s("BrandSettings.Saving")]}):e.jsx(e.Fragment,{children:s("commonButton.Save")})}),x&&e.jsx(B,{variant:"outline-secondary",onClick:fe,disabled:o,children:s("commonButton.Cancel")}),e.jsxs(B,{variant:"outline-primary",onClick:()=>O(!0),disabled:o,children:[e.jsx("i",{className:"bi bi-eye me-1"}),s("BrandSettings.PreviewButton")]})]})]})]})]}),e.jsx(Un,{show:D,onHide:()=>O(!1),settings:m,logoUrl:oe(),invoiceTemplate:m.invoiceTemplate})]})},Gn=({user:s,formikPassword:n,handleLogout:i,setShowAccountDeleteModal:a})=>{const{t}=ee(),[o,d]=l.useState(!1),[h,u]=l.useState(!1),m=()=>d(p=>!p),g=()=>u(p=>!p);return e.jsxs(e.Fragment,{children:[e.jsx(Mt,{}),e.jsx(Bt,{ferrierId:s==null?void 0:s.id}),e.jsxs("div",{className:"from_des_block",children:[e.jsxs("h2",{children:[e.jsx("i",{className:"bi bi-lock me-2"}),t("ProfilePage.Change-Password")]}),e.jsxs(c,{onSubmit:n.handleSubmit,children:[e.jsxs(Te,{children:[e.jsxs(c.Group,{className:"mb-3 col-lg-6",children:[e.jsx(c.Label,{children:t("ProfilePage.Current-Password")}),e.jsxs("div",{className:"password-input password",children:[e.jsx(c.Control,{type:o?"text":"password",name:"oldPassword",autoComplete:"current-password",value:n.values.oldPassword,onChange:n.handleChange,onBlur:n.handleBlur,isInvalid:n.touched.oldPassword&&!!n.errors.oldPassword}),e.jsx(c.Control.Feedback,{type:"invalid",children:n.errors.oldPassword}),e.jsx("i",{className:`bi ${o?"bi-eye-slash":"bi-eye"}`,onClick:m,style:{cursor:"pointer",marginLeft:"10px"}})]})]}),e.jsxs(c.Group,{className:"mb-3 col-lg-6",children:[e.jsx(c.Label,{children:t("ProfilePage.New-Password")}),e.jsxs("div",{className:"password-input password",children:[e.jsx(c.Control,{type:h?"text":"password",name:"newPassword",autoComplete:"new-password",value:n.values.newPassword,onChange:n.handleChange,onBlur:n.handleBlur,isInvalid:n.touched.newPassword&&!!n.errors.newPassword}),e.jsx(c.Control.Feedback,{type:"invalid",children:n.errors.newPassword}),e.jsx("i",{className:`bi ${h?"bi-eye-slash":"bi-eye"}`,onClick:g,style:{cursor:"pointer",marginLeft:"10px"}})]})]})]}),e.jsx(B,{className:"form-action-btn-primary mb-5",type:"submit",disabled:n.isSubmitting,children:n.isSubmitting?t("ProfilePage.Updating"):t("ProfilePage.Update")})]})]}),e.jsxs("div",{className:"form-action-buttons-container mt-4",children:[e.jsx("div",{className:"form-action-buttons-left",children:e.jsx(B,{className:"form-action-btn-secondary",onClick:()=>i(),children:t("ProfilePage.Logout")})}),e.jsx("div",{className:"form-action-buttons-right",children:e.jsx(B,{className:"form-action-btn-danger",onClick:()=>a(!0),children:t("ProfilePage.Delete-Account")}
1)})]})]})};Gn.propTypes={user:r.object,formikPassword:r.object.isRequired,handleLogout:r.func.isRequired,setShowAccountDeleteModal:r.func.isRequired};const rn=[{key:"grunduppgifter",icon:"bi-person",labelKey:"ProfilePage.Tab.BasicInfo"},{key:"ekonomi",icon:"bi-calculator",labelKey:"ProfilePage.Tab.Accounting"},{key:"kommunikation",icon:"bi-envelope",labelKey:"ProfilePage.Tab.Communication"},{key:"journal",icon:"bi-journal-medical",labelKey:"ProfilePage.Tab.Journal"},{key:"konto",icon:"bi-gear",labelKey:"ProfilePage.Tab.Account"}],Hn=({user:s,loading:n,deviceType:i,subscriptionInfo:a,subscriptionSyncing:t,profilePic:o,isCompanyLogo:d,formikProfile:h,formikPaymentMethods:u,formikPassword:m,swishEnabled:g,setSwishEnabled:p,swishLeadingPlus:y,setSwishLeadingPlus:x,swishIntegrationType:k,swishCertificateInfo:P,handleSwishIntegrationTypeChange:w,handleSwishCertificateUpload:D,handleSwishCertificateDelete:O,swishCertificateLoading:b,swishCertificateUploading:F,bankgiroEnabled:K,setBankgiroEnabled:U,plusgiroEnabled:I,setPlusgiroEnabled:Y,bankAccountEnabled:Z,setBankAccountEnabled:je,ibanEnabled:le,setIbanEnabled:fe,bicEnabled:oe,setBicEnabled:G,handleProfilePicChange:q,handleLogoChange:ce,onPlaceSelected:ae,language:de,handleLanguageChange:me,handleLanguageUpdate:ue,openStripePortal:R,openSubscriptionModal:C,portalLoading:j,pricingTableError:se,handleLogout:Pe,setShowAccountDeleteModal:Ae,defaultPaymentTerms:pe,setDefaultPaymentTerms:xe,onSaveDefaultPaymentTerms:Re,savingPaymentTerms:te,defaultReminderFee:Le,setDefaultReminderFee:E,onSaveDefaultReminderFee:M,savingReminderFee:S})=>{const{t:$}=ee(),[z,ie]=on(),ve=ln(),ke=()=>{const he=z.get("tab"),Ve=z.get("scrollTo");return z.get("fortnox")||Ve==="ekonomisystem"||he==="betalning"?"ekonomi":he==="utseende"?"konto":he&&rn.some(ts=>ts.key===he)?he:"grunduppgifter"},[Ne,Ue]=l.useState(ke);l.useEffect(()=>{const he=ke();he!==Ne&&Ue(he)},[z]),l.useEffect(()=>{z.get("scrollTo")==="ekonomisystem"&&ve("/profile?tab=ekonomi",{replace:!0})},[z,ve]);const ze=he=>{Ue(he),ie({tab:he},{replace:!0})};return e.jsxs(Ee.Container,{activeKey:Ne,onSelect:ze,children:[e.jsx(Ke,{variant:"tabs",className:"profile-tabs-nav mb-4",children:rn.map(({key:he,icon:Ve,labelKey:Me})=>e.jsx(Ke.Item,{"data-guide":`settings-tab-${he}`,children:e.jsxs(Ke.Link,{eventKey:he,children:[e.jsx("i",{className:`bi ${Ve} me-2`}),e.jsx("span",{className:"d-none d-md-inline",children:$(Me)})]})},he))}),e.jsxs(Ee.Content,{children:[e.jsx(Ee.Pane,{eventKey:"grunduppgifter",mountOnEnter:!1,unmountOnExit:!1,children:e.jsx(fn,{user:s,loading:n,profilePic:o,isCompanyLogo:d,formikProfile:h,handleProfilePicChange:q,handleLogoChange:ce,onPlaceSelected:ae})}),e.jsx(Ee.Pane,{eventKey:"ekonomi",mountOnEnter:!1,unmountOnExit:!1,children:e.jsx(Mn,{user:s,loading:n,deviceType:i,subscriptionInfo:a,subscriptionSyncing:t,formikPaymentMethods:u,swishEnabled:g,setSwishEnabled:p,swishLeadingPlus:y,setSwishLeadingPlus:x,swishIntegrationType:k,swishCertificateInfo:P,handleSwishIntegrationTypeChange:w,handleSwishCertificateUpload:D,handleSwishCertificateDelete:O,swishCertificateLoading:b,swishCertificateUploading:F,bankgiroEnabled:K,setBankgiroEnabled:U,plusgiroEnabled:I,setPlusgiroEnabled:Y,bankAccountEnabled:Z,setBankAccountEnabled:je,ibanEnabled:le,setIbanEnabled:fe,bicEnabled:oe,setBicEnabled:G,openStripePortal:R,openSubscriptionModal:C,portalLoading:j,pricingTableError:se,defaultPaymentTerms:pe,setDefaultPaymentTerms:xe,onSaveDefaultPaymentTerms:Re,savingPaymentTerms:te,defaultReminderFee:Le,setDefaultReminderFee:E,onSaveDefaultReminderFee:M,savingReminderFee:S})}),e.jsx(Ee.Pane,{eventKey:"kommunikation",mountOnEnter:!1,unmountOnExit:!1,children:e.jsx(Sn,{language:de,handleLanguageChange:me,handleLanguageUpdate:ue})}),e.jsx(Ee.Pane,{eventKey:"journal",mountOnEnter:!1,unmountOnExit:!1,children:e.jsx(yn,{})}),e.jsx(Ee.Pane,{eventKey:"konto",mountOnEnter:!1,unmountOnExit:!1,children:e.jsx(Gn,{user:s,formikPassword:m,handleLogout:Pe,setShowAccountDeleteModal:Ae})})]})]})};Hn.propTypes={user:r.object,loading:r.bool,deviceType:r.string,subscriptionInfo:r.object,subscriptionSyncing:r.bool,profilePic:r.
1string,isCompanyLogo:r.string,formikProfile:r.object.isRequired,formikPaymentMethods:r.object.isRequired,formikPassword:r.object.isRequired,swishEnabled:r.bool,setSwishEnabled:r.func,swishLeadingPlus:r.bool,setSwishLeadingPlus:r.func,swishIntegrationType:r.string,swishCertificateInfo:r.object,handleSwishIntegrationTypeChange:r.func,handleSwishCertificateUpload:r.func,handleSwishCertificateDelete:r.func,swishCertificateLoading:r.bool,swishCertificateUploading:r.bool,bankgiroEnabled:r.bool,setBankgiroEnabled:r.func,plusgiroEnabled:r.bool,setPlusgiroEnabled:r.func,bankAccountEnabled:r.bool,setBankAccountEnabled:r.func,ibanEnabled:r.bool,setIbanEnabled:r.func,bicEnabled:r.bool,setBicEnabled:r.func,handleProfilePicChange:r.func.isRequired,handleLogoChange:r.func.isRequired,onPlaceSelected:r.func.isRequired,language:r.string,handleLanguageChange:r.func.isRequired,handleLanguageUpdate:r.func.isRequired,openStripePortal:r.func.isRequired,openSubscriptionModal:r.func.isRequired,portalLoading:r.bool,pricingTableError:r.bool,handleLogout:r.func.isRequired,setShowAccountDeleteModal:r.func.isRequired,defaultPaymentTerms:r.oneOfType([r.number,r.string]),setDefaultPaymentTerms:r.func,onSaveDefaultPaymentTerms:r.func,savingPaymentTerms:r.bool,defaultReminderFee:r.oneOfType([r.number,r.string]),setDefaultReminderFee:r.func,onSaveDefaultReminderFee:r.func,savingReminderFee:r.bool};const It=({onClose:s,onCleared:n})=>{const{t:i}=ee(),[a,t]=l.useState(!1);return a?e.jsx(Aa,{onClose:()=>t(!1),onCleared:o=>{t(!1),n==null||n(o)}}):e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"demo-sub-blocker-title",style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",padding:16,zIndex:1100},children:e.jsxs("div",{style:{background:"#fff",borderRadius:8,maxWidth:480,width:"100%",padding:20,boxShadow:"0 12px 32px rgba(0,0,0,0.18)"},children:[e.jsxs("h3",{id:"demo-sub-blocker-title",style:{fontSize:18,marginTop:0,color:"#222",display:"flex",gap:8},children:[e.jsx("span",{"aria-hidden":!0,children:"📋"}),i("demoSubscriptionBlocker.title","Du är i demoläge")]}),e.jsx("div",{style:{fontSize:14,color:"#444",lineHeight:1.55},children:i("demoSubscriptionBlocker.body","För att skaffa en prenumeration måste du först rensa exempeldatan och börja på riktigt med ett eget tomt konto.")}),e.jsx("div",{style:{background:"#fff3e0",border:"1px solid #ffb74d",color:"#e65100",padding:"10px 12px",borderRadius:6,fontSize:13,marginTop:14,marginBottom:16,lineHeight:1.5},children:i("demoSubscriptionBlocker.hint","När du klickar på knappen nedan visas en bekräftelseruta innan något raderas.")}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"1px solid #ccc",color:"#444",padding:"8px 14px",borderRadius:6,fontSize:13,cursor:"pointer"},children:i("demoSubscriptionBlocker.cancel","Avbryt")}),e.jsx("button",{type:"button",onClick:()=>t(!0),style:{background:"#e65100",border:"none",color:"#fff",padding:"8px 14px",borderRadius:6,fontSize:13,fontWeight:600,cursor:"pointer"},children:i("demoSubscriptionBlocker.clearCta","Rensa & börja på riktigt")})]})]})})},yr=()=>{const{t:s}=ee(),n=gt("settings"),{user:i,setUser:a,clearUser:t}=as(),{clearToken:o,token:d}=La(),{unregister:h}=Da(),[u,m]=l.useState(null),[g,p]=l.useState(null),[y,x]=l.useState(!1),[k,P]=l.useState("en"),w="https://ewq-ferrier.s3.eu-north-1.amazonaws.com/",D=ln(),[O,b]=l.useState(!1),[F,K]=l.useState(""),[U,I]=l.useState(!1),[Y,Z]=l.useState(""),[je,le]=l.useState(!1),[fe,oe]=l.useState(!1),[G,q]=l.useState(!1),[ce,ae]=l.useState(!1),[de,me]=l.useState(!1),[ue,R]=l.useState(!1),[C,j]=l.useState(!1),[se,Pe]=l.useState("qr"),[Ae,pe]=l.useState(null),[xe,Re]=l.useState(!1),[te,Le]=l.useState(!1),[E,M]=l.useState(fs),[S,$]=l.useState(!1),[z,ie]=l.useState(60),[ve,ke]=l.useState(!1),[Ne]=on(),[Ue,ze]=l.useState(!1),[he,Ve]=l.useState(!1),Me=Ta(),[ts,rs]=l.useState(!1),[xs,ms]=l.useState(!1),[We,is]=l.useState(!1),[bs,os]=l.useState(null),[Ge,ls]=l.useState(!1),[A,_]=l.useState("web"),X=(f="")=>/^\d{7,15}$/.test(f),we=(f="")=>/^\d{7,8}$/.test(f),Ye=(f="")=>/^\d{2,10}$/.test(f),He=(f="")=>{if(!/^\d{5,15}$/.test(f))return!1;const L=f.startsWith("8")?5:4;if(f.length<=L)return!1;const N=f.length-L;return N>=1&&N<=12},_n=(f="")=>/^[A-Z]{2}[0-9]{2}[A-Z0-9]{10,30}$/.test(f),Jn=(f="")=>/^[A-Z]{4}[A-Z]{2}[A-Z0-9]{2}([A-Z0-9]{3})?$/.test(f),Ze=(f,L,N)=>L||N(f)?f:"",$e=js({initialValues:{firstName:"",lastName:"",title:"",phone:"",email:"",profileImage:null,companyLogo:null,organizationName:"",organizationNumber:"",address:"",postNumber:"",postPlace:""},validationSchema:xt(s),onSubmit:async(f,{setSubmitting:L})=>
1{try{L(!0);const N=new FormData;N.append("firstName",f.firstName),N.append("lastName",f.lastName),N.append("title",f.title),N.append("address",f.address),N.append("postNumber",dn(f.postNumber)),N.append("postPlace",f.postPlace),N.append("phoneNumber",Wa(f.phone)),f.profileImage&&N.append("profileImage",f.profileImage),f.companyLogo&&N.append("organizationLogo",f.companyLogo),N.append("organizationName",f.organizationName),N.append("identificationNumber",f.organizationNumber),N.append("organizationNumber",f.organizationNumber);const{data:ne}=await Q.put(hs.endPoint(i==null?void 0:i.id),N);a(ne==null?void 0:ne.result),V.success((ne==null?void 0:ne.message)||s("ProfilePage.Profile-Updated"))}catch(N){V.error(re(N))}finally{L(!1)}}}),Cs=js({initialValues:{swishNumberCheck:!1,swishNumber:"",bankgiroCheck:!1,bankgiro:"",plusgiroCheck:!1,plusgiro:"",bankAccountCheck:!1,bankAccount:"",ibanCheck:!1,iban:"",bicCheck:!1,bic:"",defaultPaymentMethod:Ss,enabledPaymentMethods:[...Qe]},validationSchema:bt(s),onSubmit:async(f,{setSubmitting:L})=>{var N,ne,Fe;try{L(!0);const Ce={swishNumberCheck:f.swishNumberCheck,bankgiroCheck:f.bankgiroCheck,plusgiroCheck:f.plusgiroCheck,bankAccountCheck:f.bankAccountCheck,ibanCheck:f.ibanCheck,bicCheck:f.bicCheck,swishNumber:Ze(f.swishNumber,f.swishNumberCheck,X),bankgiro:Ze(f.bankgiro,f.bankgiroCheck,we),plusgiro:Ze(f.plusgiro,f.plusgiroCheck,Ye),bankAccount:Ze(f.bankAccount,f.bankAccountCheck,He),iban:Ze(f.iban,f.ibanCheck,_n),bic:Ze(f.bic,f.bicCheck,Jn),enabledPaymentMethods:((N=f.enabledPaymentMethods)==null?void 0:N.length)>0?f.enabledPaymentMethods:[...Qe],defaultPaymentMethod:(ne=f.enabledPaymentMethods)!=null&&ne.includes(f.defaultPaymentMethod)?f.defaultPaymentMethod:((Fe=f.enabledPaymentMethods)==null?void 0:Fe[0])||Ss},{data:De}=await Q.put(Ua.endPoint(i==null?void 0:i.id),Ce);V.success((De==null?void 0:De.message)||s("ProfilePage.Profile-Updated"))}catch(Ce){V.error(re(Ce))}finally{L(!1)}}}),Ps=js({initialValues:{oldPassword:"",newPassword:""},validationSchema:jt(s),onSubmit:async(f,{setSubmitting:L})=>{try{L(!0);const{data:N}=await Q.put($a.endPoint(i==null?void 0:i.id),{oldPassword:f.oldPassword,newPassword:f.newPassword});V.success((N==null?void 0:N.message)||s("ProfilePage.Password-Changed")),Ps.resetForm()}catch(N){V.error(re(N))}finally{L(!1)}}}),Fs=async()=>{var f,L,N,ne,Fe,Ce,De,cs,ds,us,Es,Bs,As,Ls,Ds,Ts,Rs,zs,Ms,Is,Os,Ks,Vs,qs,$s,Us,Gs,Hs,_s,Js,Ws;x(!0);try{const{data:v}=await Q.get(za.endPoint(i==null?void 0:i.id)),ua=((f=v==null?void 0:v.result)==null?void 0:f.phoneNumber)||"";$e.setValues({firstName:((L=v==null?void 0:v.result)==null?void 0:L.firstName)||"",lastName:((N=v==null?void 0:v.result)==null?void 0:N.lastName)||"",title:((ne=v==null?void 0:v.result)==null?void 0:ne.title)||"",email:((Fe=v==null?void 0:v.result)==null?void 0:Fe.email)||"",address:((Ce=v==null?void 0:v.result)==null?void 0:Ce.address)||"",postNumber:((De=v==null?void 0:v.result)==null?void 0:De.postNumber)||"",postPlace:((cs=v==null?void 0:v.result)==null?void 0:cs.postPlace)||"",phone:cn(ua),profileImage:null,companyLogo:null,organizationName:((ds=v==null?void 0:v.result)==null?void 0:ds.organizationName)||"",organizationNumber:((us=v==null?void 0:v.result)==null?void 0:us.identificationNumber)||((Es=v==null?void 0:v.result)==null?void 0:Es.organizationNumber)||""}),os({stripeSubscriptionId:((Bs=v==null?void 0:v.result)==null?void 0:Bs.stripeSubscriptionId)??null,stripeSubscriptionStatus:((As=v==null?void 0:v.result)==null?void 0:As.stripeSubscriptionStatus)??null,subscriptionStatus:((Ls=v==null?void 0:v.result)==null?void 0:Ls.subscriptionStatus)??null,subscriptionTier:((Ds=v==null?void 0:v.result)==null?void 0:Ds.subscriptionTier)??null,trialStartDate:((Ts=v==null?void 0:v.result)==null?void 0:Ts.trialStartDate)??null,subscriptionPlanName:((Rs=v==null?void 0:v.result)==null?void 0:Rs.subscriptionPlanName)??null,subscriptionPlanInterval:((zs=v==null?void 0:v.result)==null?void 0:zs.subscriptionPlanInterval)??null,subscriptionPriceId:((Ms=v==null?void 0:v.result)==null?void 0:Ms.subscriptionPriceId)??null,subscriptionPriceAmount:((Is=v==null?void 0:v.result)==null?void 0:Is.subscriptionPriceAmount)??null,subscriptionPriceCurrency:((Os=v==null?void 0:v.result)==null?void 0:Os.subscriptionPriceCurrency)??null,subscriptionCurrentPeriodStart:((Ks=v==null?void 0:v.result)==null?void 0:Ks.subscriptionCurrentPeriodStart)??null,subscriptionCurrentPeriodEnd:((Vs=v==null?void 0:v.result)==null?void 0:Vs.subscriptionCurrentPeriodEnd)??null,subscriptionCancelAt:((qs=v==null?void 0:v.result)==null?void 0:qs.subscriptionCancelAt)??null,subscriptionCancelAtPeriodEnd:(($s=v==null?void 0:v.result)==null?void 0:$s.subscriptionCancelAtPeriodEnd)??null,subscriptionExpiryDate:((Us=v==null?void 0:v.result)==null?void 0:Us.subscriptionExpiryDate)??null}),v!=null&&v.result&&a({...i,...v.result}),_(((Gs=v==null?void 0:v.result)==null?void 0:Gs.deviceType)||"web"),M(((Hs=v==null?void 0:v.result)==null?void 0:Hs.defaultPaymentTerms)??fs),ie(((_s=v==null?void 0:v.result)==null?void 0:_s.defaultReminderFee)??60),(Js=v==null?void 0:v.result)!=null&&Js.profileImage?m(`${w}${v.result.profileImage}`):m(es),(Ws=v==null?void 0:v.result)!=null&&Ws.organizationLogo?p(`${w}${v.result.organizationLogo}`):p(es)}catch(v){V.error(re(v))}finally{x(!1)}},Wn=async()=>{var f;x(!0);try{const{data:L}=await Q.get(Ma.endPoint(i==null?void 0:i.id)),N=((f=L==null?void 0:L.result)==null?void 0:f.paymentMethods)??(L==null?void 0:L.result)??{},ne=Se.normalizeSwish(N.swishNumber??N.swish??""),Fe=Se.normalizeBankgiro(N.bankgiro??N.bankGiro??""),Ce=Se.normalizePlusgiro(N.plusgiro??N.plusgiro??N.plusGiro??""),De=Se.normalizeBankAccount(N.bankAccount??N.bankAccount??""),cs=Se.normalizeIban(N.iban??""),ds=Se.normalizeBic(N.bic??"");Cs.setValues({swishNumberCheck:N.swishNumberCheck??N.swishCheck??!!ne,swishNumber:ne,bankgiroCheck:N.bankgiroCheck??!!Fe,bankgiro:Fe,plusgiroCheck:N.plusgiroCheck??N.plusgiroCheck??!!Ce,plusgiro:Ce,bankAccountCheck:N.bankAccountCheck??!!De,bankAccount:De,ibanCheck:N.ibanCheck??!!cs,iban:cs,bicCheck:N.bicCheck??!!ds,bic:ds,enabledPaymentMethods:Array.isArray(N.enabledPaymentMethods)&&N.enabledPaymentMethods.length>0?Qe.filter(us=>N.enabledPaymentMethods.includes(us)):[...Qe],defaultPaymentMethod:Qe.includes(N.defaultPaymentMethod)?N.defaultPaymentMethod:Ss}),le(N.swishNumberCheck),q(N.bankgiroCheck),ae(N.plusgiroCheck),me(N.bankAccountCheck),R(N.ibanCheck),j(N.bicCheck),typeof oe=="function"&&oe(!1)}catch(L){V.error(re(L))}finally{x(!1)}},Yn=async f=>{const L=f.target.files[0];if(L)try{const N=await Ys(L,300,300,2);N&&($e.setFieldValue("profileImage",N),m(URL.createObjectURL(N)))}catch{V.error(s("ProfilePage.ImageResizeError"))}},Zn=async f=>{const L=f.target.files[0];if(L)try{const N=await Ys(L,600,200,2);N&&($e.setFieldValue("companyLogo",N),p(URL.createObjectURL(N)))}catch{V.error(s("ProfilePage.ImageResizeError"))}},Xn=()=>
1{if(!F.trim()){Z(s("ProfilePage.Password-Required"));return}Z(""),ea(F)},Qn=async()=>{await h();try{await Q.post(Oa.endPoint(),{accessToken:d}),o(),t(),window.ReactNativeWebView?window.ReactNativeWebView.postMessage("logout"):D("/login")}catch{o(),t(),window.ReactNativeWebView?window.ReactNativeWebView.postMessage("logout"):D("/login")}},ea=async f=>{try{const{data:L}=await Q.delete(Ga.endPoint(i==null?void 0:i.id),{data:{password:f}});V.success((L==null?void 0:L.message)||s("ProfilePage.Account-Deleted")),o(null),t(null),b(!1),K(""),D("/login")}catch(L){const N=re(L);Z(N),V.error(N)}},sa=async()=>{try{$(!0);const f=E===""?fs:parseInt(E,10);await Q.patch(hs.endPoint(i.id),{defaultPaymentTerms:f}),M(f),V.success(s("ProfilePage.Default-Payment-Terms-Saved"))}catch(f){V.error(re(f))}finally{$(!1)}},na=async()=>{try{ke(!0);const f=z===""?60:parseInt(z,10);await Q.patch(hs.endPoint(i.id),{defaultReminderFee:f}),ie(f),V.success(s("ProfilePage.Default-Reminder-Fee-Saved"))}catch(f){V.error(re(f))}finally{ke(!1)}},aa=async()=>{var f;if(i!=null&&i.id){Re(!0);try{const{data:L}=await Q.get(Ia.endPoint(i.id));if(L!=null&&L.result){const{hasCertificate:N,integrationType:ne,uploadedAt:Fe,expiresAt:Ce,originalFilename:De}=L.result;pe(N?{uploadedAt:Fe,expiresAt:Ce,originalFilename:De}:null),Pe(ne||"qr")}}catch(L){((f=L==null?void 0:L.response)==null?void 0:f.status)!==404&&console.error("Error fetching certificate info:",L),pe(null)}finally{Re(!1)}}},ta=async(f,L)=>{if(i!=null&&i.id){Le(!0);try{const N=new FormData;N.append("certificate",f),N.append("passphrase",L);const{data:ne}=await Q.post(Va.endPoint(i.id),N,{headers:{"Content-Type":"multipart/form-data"}});if(ne!=null&&ne.result){const{uploadedAt:Fe,originalFilename:Ce}=ne.result;pe({uploadedAt:Fe,originalFilename:Ce}),Pe("api"),V.success(s("SwishSettings.uploadSuccess")||"Certifikat uppladdat!")}}catch(N){V.error(re(N))}finally{Le(!1)}}},ra=async()=>{if(i!=null&&i.id)try{await Q.delete(Ka.endPoint(i.id)),pe(null),V.success(s("SwishSettings.deleteSuccess")||"Certifikat borttaget!")}catch(f){V.error(re(f))}},ia=async f=>{if(!(i!=null&&i.id))return;const L=se;Pe(f);try{await Q.put(qa.endPoint(i.id),{integrationType:f})}catch(N){Pe(L),V.error(re(N))}},oa=f=>{P(f.target.value)},la=async()=>{if(localStorage.setItem("language",k),i!=null&&i.id)try{await Q.patch(hs.endPoint(i.id),{language:k})}catch(f){console.error("Failed to update language in database:",f)}window.ReactNativeWebView?(window.ReactNativeWebView.postMessage(`languageChanged:${k}`),V.success(s("ProfilePage.Language-Updated",{lng:k})),setTimeout(()=>window.location.reload(),100)):(V.success(s("ProfilePage.Language-Updated",{lng:k})),window.location.reload())},ca=f=>{if(f){if($e.setFieldValue("address",f.address||""),f.postalCode){const L=f.postalCode.replace(/\s/g,"");$e.setFieldValue("postNumber",L)}f.city&&$e.setFieldValue("postPlace",f.city)}},da=async()=>{var f;try{rs(!0);const{data:L}=await Q.post(`/stripe/create-portal-session/${i==null?void 0:i.id}`),N=(f=L==null?void 0:L.result)==null?void 0:f.url;if(!N)throw new Error("Missing portal URL");sessionStorage.setItem("returnFromStripe","true"),window.location.assign(N)}catch(L){V.error((L==null?void 0:L.message)||s("ProfilePage.Subscription-PortalFailed"))}finally{rs(!1)}},ma=()=>{if(We){V.error(s("ProfilePage.Subscription-TableLoadError"));return}if(Me.hasSampleData){Ve(!0);return}ze(!0)};return l.useEffect(()=>{const f="stripe-pricing-table-js";if(document.getElementById(f)){ms(!0);return}const L=document.createElement("script");return L.id=f,L.src="https://js.stripe.com/v3/pricing-table.js",L.async=!0,L.onload=()=>{ms(!0),is(!1)},L.onerror=()=>{is(!0),V.error(s("ProfilePage.Subscription-TableLoadError"))},document.body.appendChild(L),()=>{L.onload=null,L.onerror=null}},[s]),l.useEffect(()=>{const f=Ne.get("session_id");if(!f)return;(async()=>{var N;try{ls(!0);const{data:ne}=await Q.post(Ra.endPoint(i==null?void 0:i.id),{session_id:f});(N=ne==null?void 0:ne.result)!=null&&N.subscription&&(os(ne.result.subscription),a({...i,...ne.result.subscription})),V.success(s("ProfilePage.Subscription-Updated")),await Fs()}catch(ne){console.log(ne),V.error(s("ProfilePage.Subscription-Failed"))}finally{ls(!1),ze(!1),D("/profile",{replace:!0})}})()},[Ne,s,D]),l.useEffect(()=>{const f=localStorage.getItem("language");f&&P(f)},[]),l.useEffect(()=>{i!=null&&i.id&&Fs()},[i==null?void 0:i.id]),l.useEffect(()=>{i!=null&&i.id&&Wn()},[i==null?void 0:i.id]),l.useEffect(()=>{i!=null&&i.id&&je&&aa()},[i==null?void 0:i.id,je]),l.useEffect(()=>{O||(K(""),Z(""),I(!1))},[O]),e.jsxs(e.Fragment,{children:[e.jsxs(Ha,{pageTitle:"Profile",onRestartTour:n.startManually,children:[n.shouldShow&&e.jsx(pt,{steps:n.steps,onComplete:n.complete,onSkip:n.skip}),e.jsxs("div",{className:"from_wrap","data-guide":"settings-overview",children:[A!=="web"&&e.jsx(T,{className:"mb-4",children:e.jsxs(T.Body,{children:[e.jsx("h5",{className:"mb-3",children:s("ProfilePage.Support-Section-Title")}),e.jsxs("p",{className:"mb-0",children:[s("ProfilePage.Support-Section-Text")," ",e.jsx("a",{href:"https://eqwecare.se",target:"_blank",rel:"noopener noreferrer",className:"text-primary",style:{textDecoration:"underline",cursor:"pointer"},children:s("ProfilePage.Support-Section-Link")})," ",s("ProfilePage.Support-Section-Text-End")]})]})}),e.jsx(Hn,{user:i,loading:y,deviceType:A,subscriptionInfo:bs,subscriptionSyncing:Ge,profilePic:u,isCompanyLogo:g,formikProfile:$e,formikPaymentMethods:Cs,formikPassword:Ps,swishEnabled:je,setSwishEnabled:le,swishLeadingPlus:fe,setSwishLeadingPlus:oe,swishIntegrationType:se,swishCertificateInfo:Ae,handleSwishIntegrationTypeChange:ia,handleSwishCertificateUpload:ta,handleSwishCertificateDelete:ra,swishCertificateLoading:xe,swishCertificateUploading:te,bankgiroEnabled:G,setBankgiroEnabled:q,plusgiroEnabled:ce,setPlusgiroEnabled:ae,bankAccountEnabled:de,setBankAccountEnabled:me,ibanEnabled:ue,setIbanEnabled:R,bicEnabled:C,setBicEnabled:j,handleProfilePicChange:Yn,handleLogoChange:Zn,onPlaceSelected:ca,language:k,handleLanguageChange:oa,handleLanguageUpdate:la,openStripePortal:da,openSubscriptionModal:ma,portalLoading:ts,pricingTableError:We,handleLogout:Qn,setShowAccountDeleteModal:b,defaultPaymentTerms:E,setDefaultPaymentTerms:M,onSaveDefaultPaymentTerms:sa,savingPaymentTerms:S,defaultReminderFee:z,setDefaultReminderFee:ie,onSaveDefaultReminderFee:na,savingReminderFee:ve})]})]}),e.jsxs(Ya,{id:"deleteConfirmModal",title:s("DeletePopup.Confirm-Delete"),isOpen:O,onClose:()=>{b(!1),K(""),Z("")},footerButtons:e.jsxs(e.Fragment,{children:[e.jsx(B,{variant:"secondary",onClick:()=>{b(!1),K(""),Z("")},children:s("DeletePopup.Cancel")}),e.jsx(B,{variant:"danger",onClick:Xn,children:s("DeletePopup.Confirm-Delete")})]}),children:[e.jsx("p",{className:"mb-3",children:s("ProfilePage.Account-Delete-Text")}),e.jsx("input",{type:"text",name:"dummy-username",autoComplete:"username",style:{position:"absolute",top:"-9999px",left:"-9999px"},tabIndex:"-1"}),e.jsx("input",{type:"password",name:"dummy-password",autoComplete:"new-password",style:{position:"absolute",top:"-9999px",left:"-9999px"},tabIndex:"-1"}),e.jsxs(c.Group,{className:"mb-3",children:[e.jsx(c.Label,{children:s("ProfilePage.Password")}),e.jsxs("div",{className:"position-relative",children:[e.jsx(c.Control,{type:U?"text":"password",name:"delete-account-password",placeholder:s("ProfilePage.Enter-Password"),value:F,onChange:f=>{K(f.target.value),Z("")},isInvalid:!!Y,autoComplete:"new-password",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false","data-lpignore":"true","data-form-type":"other"}),e.jsx("i",{className:`bi ${U?"bi-eye-slash":"bi-eye"} position-absolute`,style:{right:"10px",top:"50%",transform:"translateY(-50%)",cursor:"pointer"},onClick:()=>I(!U)}),e.jsx(c.Control.Feedback,{type:"invalid",children:Y})]})]})]}),he&&e.jsx(It,{onClose:()=>Ve(!1),onCleared:()=>{var f;Ve(!1),(f=Me.refetch)==null||f.call(Me),ze(!0)}}),e.jsxs(J,{show:Ue,onHide:()=>ze(!1),size:"lg",centered:!0,children:[e.jsx(J.Header,{closeButton:!0,children:e.jsx(J.Title,{children:s("ProfilePage.Subscription-ModalTitle")})}),e.jsxs(J.Body,{children:[We?e.jsx("p",{className:"text-danger mb-0",children:s("ProfilePage.Subscription-TableLoadError")}):xs?e.jsx("div",{className:"w-100",children:e.jsx("stripe-pricing-table",{"pricing-table-id":ss,"publishable-key":et,"client-reference-id":String((i==null?void 0:i.id)??""),"customer-email":$e.values.email||""},ss)}):e.jsx("div",{className:"d-flex justify-content-center py-4",children:e.jsx(W,{})}),!ss]})]})]})};export{yr as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.