@wayke-se/components-react 5.2.0-beta.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -5164,7 +5164,7 @@ https://www.w3ctech.com/topic/2226`));let a=r(...s);return a.postcssPlugin=t,a.p
5164
5164
  `,zt=od.div`
5165
5165
  flex: 1 0 50%;
5166
5166
  padding: ${m(1)};
5167
- `;var Rk=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],HD=(e,t)=>{switch(t){case"monday":return e("common.mondayShort");case"tuesday":return e("common.tuesdayShort");case"wednesday":return e("common.wednesdayShort");case"thursday":return e("common.thursdayShort");case"friday":return e("common.fridayShort");case"saturday":return e("common.saturdayShort");case"sunday":return e("common.sundayShort")}},$D=[],UD=(e,t)=>Rk.reduce((r,i)=>{let n=HD(e,i),o=t[i],s=r?.[r.length-1];return s&&s.from==o?.from&&s.until===o?.until?r[r.length-1].titleTo=n:r.push({titleFrom:n,from:o?.from,until:o?.until}),r},$D.slice()),jD=(e,t)=>{let r=new Date().getDay(),i=Rk[r===0?6:r-1],n=t[i];return{title:e(n?"item.openingHoursToday":"item.closedToday"),from:n?.from,until:n?.until}},Lk=e=>{let t=e.split(":").map(r=>parseInt(r,10));return new Date().setHours(t[0],t[1]).valueOf()},GD=({openingHours:e})=>{let{t}=_D(),r=sd(()=>e?jD(t,e):null,[e]),i=sd(()=>{try{if(r?.from&&r?.until){let o=new Date().valueOf(),s=Lk(r.from),a=Lk(r.until);return o>=s&&o<=a}}catch{return!1}},[r]),n=sd(()=>e?UD(t,e):null,[e]);return n?ft.createElement(ft.Fragment,null,ft.createElement(Fe,null,ft.createElement(Ok,{label:t(i?"item.open":"item.closed"),severity:i?"positive":"negative"})),ft.createElement(Fe,null,ft.createElement(Aa,null,ft.createElement(Si,null,ft.createElement(zt,null,ft.createElement(pi,null,r?.title)),ft.createElement(zt,null,ft.createElement(pi,null,r?.from?`${r.from} - ${r.until}`:t("item.closed")))),n.map(o=>ft.createElement(Si,{key:o.titleFrom},ft.createElement(zt,null,o.titleTo?`${o.titleFrom} - ${o.titleTo}`:o.titleFrom),ft.createElement(zt,null,o.from?`${o.from} - ${o.until}`:t("item.closed"))))))):null},Bk=GD;import Ci,{useCallback as VD,useState as zD}from"react";import{useTranslation as qD}from"react-i18next";var JD=({phoneNumber:e})=>{let{t}=qD(),[r,i]=zD(!1),n=VD(()=>!r&&i(!0),[r]);return Ci.createElement(Si,null,Ci.createElement(zt,null,t("other.phoneNumber")),Ci.createElement(zt,null,r?Ci.createElement(Hn,{as:"a",href:`tel:${e}`,title:t("other.callPhoneNumber",{phoneNumber:e})||""},Ci.createElement(se,null,e)):Ci.createElement(Hn,{onClick:n,title:t("other.showPhoneNumber")||""},Ci.createElement(se,null,t("other.showPhoneNumber")))))},Fk=JD;import{parsePhoneNumberFromString as YD}from"libphonenumber-js/core";var _k={version:4,country_calling_codes:{"46":["SE"],"47":["NO"]},countries:{NO:["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]",[["(?:2[1-4]|3[1-3578]|5[1-35-7]|6[1-4679]|7[0-8])\\d{6}",[8]],["(?:4[015-8]|9\\d)\\d{6}",[8]],["80[01]\\d{5}",[8]],["82[09]\\d{5}",[8]],["880\\d{5}",[8]],0,["(?:0[2-9]|81(?:0(?:0[7-9]|1\\d)|5\\d\\d))\\d{3}"],0,["85[0-5]\\d{5}",[8]],["810(?:0[0-6]|[2-8]\\d)\\d{3}",[8]]]],SE:["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44|9)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0",0,0,0,0,0,[["(?:(?:[12][136]|3[356]|4[0246]|6[03]|8\\d)\\d|90[1-9])\\d{4,6}|(?:1(?:2[0-35]|4[0-4]|5[0-25-9]|7[13-6]|[89]\\d)|2(?:2[0-7]|4[0136-8]|5[0138]|7[018]|8[01]|9[0-57])|3(?:0[0-4]|1\\d|2[0-25]|4[056]|7[0-2]|8[0-3]|9[023])|4(?:1[013-8]|3[0135]|5[14-79]|7[0-246-9]|8[0156]|9[0-689])|5(?:0[0-6]|[15][0-5]|2[0-68]|3[0-4]|4\\d|6[03-5]|7[013]|8[0-79]|9[01])|6(?:1[1-3]|2[0-4]|4[02-57]|5[0-37]|6[0-3]|7[0-2]|8[0247]|9[0-356])|9(?:1[0-68]|2\\d|3[02-5]|4[0-3]|5[0-4]|[68][01]|7[0135-8]))\\d{5,6}",[7,8,9]],["7[02369]\\d{7}",[9]],["20\\d{4,7}",[6,7,8,9]],["649\\d{6}|99[1-59]\\d{4}(?:\\d{3})?|9(?:00|39|44)[1-8]\\d{3,6}",[7,8,9,10]],["75[1-8]\\d{6}",[9]],0,["10[1-8]\\d{6}",[9]],["74[02-9]\\d{6}",[9]],0,["77[0-7]\\d{6}",[9]]]]},nonGeographic:{}};var QD=_k,KD=QD,va=e=>{try{return YD(e.replace("-","").replace(/ /g,""),KD)?.formatNational()||e}catch{return e}};import qt,{useCallback as Hk,useContext as ZD,useState as XD}from"react";import{useTranslation as eM}from"react-i18next";var tM=({loading:e,connections:t,onClose:r})=>{let{t:i}=eM(),{centralStorageId:n,setCentralStorageId:o}=ZD(un),[s,a]=XD(n),l=Hk(u=>{u&&o(u)},[]),d=Hk(u=>a(u.currentTarget.value),[]);return s?qt.createElement(Te,{title:i("item.switchBranch"),onClose:r},qt.createElement(O,null,qt.createElement(pe,null,qt.createElement(ae,null,qt.createElement("p",null,i("item.switchBranchDescription")))),qt.createElement(pe,null,qt.createElement(Yr,null,i("item.chooseBranch")),qt.createElement(ca,{value:s,onChange:d,options:t?.map(u=>({value:u.id,displayName:u.name})),title:i("item.chooseBranch")}))),qt.createElement(O,null,qt.createElement(nt,{disabled:e,fullWidth:!0,onClick:()=>l(s),title:i("item.chooseSelectedBranch")||""},qt.createElement(se,null,i("common.choose"))))):null},wa=tM;var oM=({branch:e,loading:t,displayBranchName:r})=>{let{t:i}=nM(),[n,o]=iM(!1),s=$k(()=>o(!0),[]),a=$k(()=>o(!1),[]);return rM(()=>{e&&n&&o(!1)},[e]),e?Be.createElement(Be.Fragment,null,n&&Be.createElement(wa,{loading:t,connections:e?.connections,onClose:a}),Be.createElement(O,null,Be.createElement(ze,{noMargin:!0},r?`${i("item.thisCarsIsLocatedAt")} ${e.name}`:e?.location?.city?i("item.thisCarIsAvailableAtOurBranch",{location:e?.location?.city}):i("item.contact"))),Be.createElement(O,null,Be.createElement(Mk,{position:e?.location?.position})),(e?.connections?.length||0)>1&&Be.createElement(O,null,Be.createElement(ae,null,Be.createElement("p",null,i("item.centralWarehouseCarDescriptionShort")," ",Be.createElement(Se,{as:"span",role:"button",onClick:s,inline:!0,title:i("item.clickHereToShowContactToAnotherBranch")||""},i("item.clickHereToShowContactToAnotherBranch")),"."))),Be.createElement(O,null,Be.createElement(Jy,null,Be.createElement(O,null,Be.createElement(Aa,null,e?.location?.streetAddress&&e?.location?.city&&Be.createElement(Si,null,Be.createElement(zt,null,i("common.address")),Be.createElement(zt,null,Be.createElement(Hn,null,Be.createElement(se,null,`${e?.location?.streetAddress}, ${e?.location?.city}`)))),e?.contact?.phonenumber&&Be.createElement(Fk,{phoneNumber:va(e.contact.phonenumber)}))),e?.openingHours&&Be.createElement(O,null,Be.createElement(Bk,{openingHours:e.openingHours}))))):null},Uk=oM;import{format as FM}from"date-fns";import{nb as _M,sv as HM}from"date-fns/locale";import ke,{useCallback as Ta,useEffect as $M,useState as AA}from"react";import{useTranslation as UM}from"react-i18next";import Qr,{useCallback as Ti,useMemo as eA,useState as IM}from"react";import{useTranslation as SM}from"react-i18next";import ye,{useCallback as ld,useId as hM,useMemo as fM,useState as ba}from"react";import{useTranslation as gM}from"react-i18next";import{useCallback as aM,useState as jk}from"react";var fn={name:"@wayke-se/components-react",version:"5.2.0-beta.0",description:"",module:"dist/index.mjs",main:"dist/index.js",types:"dist/index.d.ts",type:"module",files:["dist"],scripts:{prebuild:"npm run clean",test:"npm run lint && npm run typecheck",lint:"npx @biomejs/biome check","lint:fix":"npx @biomejs/biome check --write",typecheck:"tsc --noEmit --skipLibCheck",gen:"graphql-codegen --config ./codegen.yml","generate-libphonenumber-metadata":"libphonenumber-metadata-generator src/utils/metadata.min.json --countries SE,NO --extended",prepare:"husky",start:"node ./esbuild/start.js",build:"npm run clean && node ./esbuild/lib.js && node ./esbuild/cdn.js",clean:"rimraf build && rimraf dist && rimraf dist-cdn","build:types":"tsc --project tsconfig.build.json"},repository:{type:"git",url:"git+https://github.com/wayke-se/components-react.git"},author:"Ourstudio",license:"MIT",peerDependencies:{react:"^18 || ^19","react-dom":"^18 || ^19","styled-components":"^6"},devDependencies:{"@biomejs/biome":"2.5.15","@graphql-codegen/cli":"^7.4.5","@graphql-codegen/typescript":"^6.1.1","@types/googlemaps":"^3.43.3","@types/node":"^24.19.1","@types/react":"^19.3.0","@types/react-dom":"^19.3.0","@types/react-slick":"^0.23.13","@wayke-se/ecom-web":"^2.1.1",dotenv:"^18.0.6",esbuild:"^0.28.2","esbuild-plugin-copy":"^2.1.1",husky:"^9.1.7","libphonenumber-metadata-generator":"^2.0.6","lint-staged":"^17.6.0",react:"^19.3.0","react-dom":"^19.3.0","react-router-dom":"^7.18.4",rimraf:"^6.1.3","styled-components":"^6.5.3",typescript:"^7.0.2"},dependencies:{"@apollo/client":"^4.3.3","@emotion/is-prop-valid":"^1.4.0","@photo-sphere-viewer/core":"^5.15.1","date-fns":"^4.4.0",graphql:"^16.0.0 || ^17.0.0",i18next:"^26.4.2","libphonenumber-js":"^1.13.15",marked:"^18.1.0","react-compound-slider":"^3.4.0","react-i18next":"^17.0.16","react-slick":"^0.31.0","scroll-into-view-if-needed":"^3.1.0"},allowScripts:{esbuild:!0,fsevents:!1}};var lM=(e,t="SE")=>{let[r,i]=jk(!1),[n,o]=jk(null),s=aM(async({itemId:a,branchId:l,communication:d,firstName:u,lastName:h,phoneNumber:p,email:f,message:v,tradeInCarRegNo:A,tradeInCarMileage:g})=>{if(!e)throw new Error("Missing apiUrl, cannot submit lead");i(!0),o(null);let y={firstName:u,lastName:h,phoneNumber:p,email:f,branchId:l,type:"registrationOfInterestToBuy",metaData:[{key:"source",value:window.location.hostname.replace(/^www\./,"")},{key:"sourceMechanism",value:`cta.${d}`},{key:"client",value:"components-react"},{key:"clientVersion",value:fn.version},{key:"itemForSaleId",value:a},...A?[{key:"registrationNumber",value:A}]:[],...g?[{key:"tradeInCarMileage",value:g},{key:"readingUnit",value:t==="NO"?"Kilometer":"ScandinavianMile"}]:[],{key:"message",value:v||""}]};try{let k=`${new URL(e).origin}/lead`,w=await fetch(k,{method:"POST",body:JSON.stringify(y),headers:{"Content-Type":"application/json; charset=UTF-8"}});if(!w.ok)throw new Error(`Request failed with status ${w.status}`);return await w.json()}catch(k){throw o(k instanceof Error?k.message:"Something went wrong"),k}finally{i(!1)}},[e,t]);return{isLoading:r,error:n,submitLead:s}},Gk=lM;import dM from"react";import cM from"styled-components";var Vk=cM.div`
5167
+ `;var Rk=["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],HD=(e,t)=>{switch(t){case"monday":return e("common.mondayShort");case"tuesday":return e("common.tuesdayShort");case"wednesday":return e("common.wednesdayShort");case"thursday":return e("common.thursdayShort");case"friday":return e("common.fridayShort");case"saturday":return e("common.saturdayShort");case"sunday":return e("common.sundayShort")}},$D=[],UD=(e,t)=>Rk.reduce((r,i)=>{let n=HD(e,i),o=t[i],s=r?.[r.length-1];return s&&s.from==o?.from&&s.until===o?.until?r[r.length-1].titleTo=n:r.push({titleFrom:n,from:o?.from,until:o?.until}),r},$D.slice()),jD=(e,t)=>{let r=new Date().getDay(),i=Rk[r===0?6:r-1],n=t[i];return{title:e(n?"item.openingHoursToday":"item.closedToday"),from:n?.from,until:n?.until}},Lk=e=>{let t=e.split(":").map(r=>parseInt(r,10));return new Date().setHours(t[0],t[1]).valueOf()},GD=({openingHours:e})=>{let{t}=_D(),r=sd(()=>e?jD(t,e):null,[e]),i=sd(()=>{try{if(r?.from&&r?.until){let o=new Date().valueOf(),s=Lk(r.from),a=Lk(r.until);return o>=s&&o<=a}}catch{return!1}},[r]),n=sd(()=>e?UD(t,e):null,[e]);return n?ft.createElement(ft.Fragment,null,ft.createElement(Fe,null,ft.createElement(Ok,{label:t(i?"item.open":"item.closed"),severity:i?"positive":"negative"})),ft.createElement(Fe,null,ft.createElement(Aa,null,ft.createElement(Si,null,ft.createElement(zt,null,ft.createElement(pi,null,r?.title)),ft.createElement(zt,null,ft.createElement(pi,null,r?.from?`${r.from} - ${r.until}`:t("item.closed")))),n.map(o=>ft.createElement(Si,{key:o.titleFrom},ft.createElement(zt,null,o.titleTo?`${o.titleFrom} - ${o.titleTo}`:o.titleFrom),ft.createElement(zt,null,o.from?`${o.from} - ${o.until}`:t("item.closed"))))))):null},Bk=GD;import Ci,{useCallback as VD,useState as zD}from"react";import{useTranslation as qD}from"react-i18next";var JD=({phoneNumber:e})=>{let{t}=qD(),[r,i]=zD(!1),n=VD(()=>!r&&i(!0),[r]);return Ci.createElement(Si,null,Ci.createElement(zt,null,t("other.phoneNumber")),Ci.createElement(zt,null,r?Ci.createElement(Hn,{as:"a",href:`tel:${e}`,title:t("other.callPhoneNumber",{phoneNumber:e})||""},Ci.createElement(se,null,e)):Ci.createElement(Hn,{onClick:n,title:t("other.showPhoneNumber")||""},Ci.createElement(se,null,t("other.showPhoneNumber")))))},Fk=JD;import{parsePhoneNumberFromString as YD}from"libphonenumber-js/core";var _k={version:4,country_calling_codes:{"46":["SE"],"47":["NO"]},countries:{NO:["47","00","(?:0|[2-9]\\d{3})\\d{4}",[5,8],[["(\\d{3})(\\d{2})(\\d{3})","$1 $2 $3",["8"]],["(\\d{2})(\\d{2})(\\d{2})(\\d{2})","$1 $2 $3 $4",["[2-79]"]]],0,0,0,0,0,"[02-689]|7[0-8]",[["(?:2[1-4]|3[1-3578]|5[1-35-7]|6[1-4679]|7[0-8])\\d{6}",[8]],["(?:4[015-8]|9\\d)\\d{6}",[8]],["80[01]\\d{5}",[8]],["82[09]\\d{5}",[8]],["880\\d{5}",[8]],0,["(?:0[2-9]|81(?:0(?:0[7-9]|1\\d)|5\\d\\d))\\d{3}"],0,["85[0-5]\\d{5}",[8]],["810(?:0[0-6]|[2-8]\\d)\\d{3}",[8]]]],SE:["46","00","(?:[26]\\d\\d|9)\\d{9}|[1-9]\\d{8}|[1-689]\\d{7}|[1-4689]\\d{6}|2\\d{5}",[6,7,8,9,10],[["(\\d{2})(\\d{2,3})(\\d{2})","$1-$2 $3",["20"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{4})","$1-$2",["9(?:00|39|44|9)"],"0$1",0,"$1 $2"],["(\\d{2})(\\d{3})(\\d{2})","$1-$2 $3",["[12][136]|3[356]|4[0246]|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3"],["(\\d)(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2,3})(\\d{2})","$1-$2 $3",["1[2457]|2(?:[247-9]|5[0138])|3[0247-9]|4[1357-9]|5[0-35-9]|6(?:[125689]|4[02-57]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3"],["(\\d{3})(\\d{2,3})(\\d{3})","$1-$2 $3",["9(?:00|39|44)"],"0$1",0,"$1 $2 $3"],["(\\d{2})(\\d{2,3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["1[13689]|2[0136]|3[1356]|4[0246]|54|6[03]|90[1-9]"],"0$1",0,"$1 $2 $3 $4"],["(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4",["10|7"],"0$1",0,"$1 $2 $3 $4"],["(\\d)(\\d{3})(\\d{3})(\\d{2})","$1-$2 $3 $4",["8"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{2})","$1-$2 $3 $4",["[13-5]|2(?:[247-9]|5[0138])|6(?:[124-689]|7[0-2])|9(?:[125-8]|3[02-5]|4[0-3])"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{2})(\\d{3})","$1-$2 $3 $4",["9"],"0$1",0,"$1 $2 $3 $4"],["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})","$1-$2 $3 $4 $5",["[26]"],"0$1",0,"$1 $2 $3 $4 $5"]],"0",0,0,0,0,0,[["(?:(?:[12][136]|3[356]|4[0246]|6[03]|8\\d)\\d|90[1-9])\\d{4,6}|(?:1(?:2[0-35]|4[0-4]|5[0-25-9]|7[13-6]|[89]\\d)|2(?:2[0-7]|4[0136-8]|5[0138]|7[018]|8[01]|9[0-57])|3(?:0[0-4]|1\\d|2[0-25]|4[056]|7[0-2]|8[0-3]|9[023])|4(?:1[013-8]|3[0135]|5[14-79]|7[0-246-9]|8[0156]|9[0-689])|5(?:0[0-6]|[15][0-5]|2[0-68]|3[0-4]|4\\d|6[03-5]|7[013]|8[0-79]|9[01])|6(?:1[1-3]|2[0-4]|4[02-57]|5[0-37]|6[0-3]|7[0-2]|8[0247]|9[0-356])|9(?:1[0-68]|2\\d|3[02-5]|4[0-3]|5[0-4]|[68][01]|7[0135-8]))\\d{5,6}",[7,8,9]],["7[02369]\\d{7}",[9]],["20\\d{4,7}",[6,7,8,9]],["649\\d{6}|99[1-59]\\d{4}(?:\\d{3})?|9(?:00|39|44)[1-8]\\d{3,6}",[7,8,9,10]],["75[1-8]\\d{6}",[9]],0,["10[1-8]\\d{6}",[9]],["74[02-9]\\d{6}",[9]],0,["77[0-7]\\d{6}",[9]]]]},nonGeographic:{}};var QD=_k,KD=QD,va=e=>{try{return YD(e.replace("-","").replace(/ /g,""),KD)?.formatNational()||e}catch{return e}};import qt,{useCallback as Hk,useContext as ZD,useState as XD}from"react";import{useTranslation as eM}from"react-i18next";var tM=({loading:e,connections:t,onClose:r})=>{let{t:i}=eM(),{centralStorageId:n,setCentralStorageId:o}=ZD(un),[s,a]=XD(n),l=Hk(u=>{u&&o(u)},[]),d=Hk(u=>a(u.currentTarget.value),[]);return s?qt.createElement(Te,{title:i("item.switchBranch"),onClose:r},qt.createElement(O,null,qt.createElement(pe,null,qt.createElement(ae,null,qt.createElement("p",null,i("item.switchBranchDescription")))),qt.createElement(pe,null,qt.createElement(Yr,null,i("item.chooseBranch")),qt.createElement(ca,{value:s,onChange:d,options:t?.map(u=>({value:u.id,displayName:u.name})),title:i("item.chooseBranch")}))),qt.createElement(O,null,qt.createElement(nt,{disabled:e,fullWidth:!0,onClick:()=>l(s),title:i("item.chooseSelectedBranch")||""},qt.createElement(se,null,i("common.choose"))))):null},wa=tM;var oM=({branch:e,loading:t,displayBranchName:r})=>{let{t:i}=nM(),[n,o]=iM(!1),s=$k(()=>o(!0),[]),a=$k(()=>o(!1),[]);return rM(()=>{e&&n&&o(!1)},[e]),e?Be.createElement(Be.Fragment,null,n&&Be.createElement(wa,{loading:t,connections:e?.connections,onClose:a}),Be.createElement(O,null,Be.createElement(ze,{noMargin:!0},r?`${i("item.thisCarsIsLocatedAt")} ${e.name}`:e?.location?.city?i("item.thisCarIsAvailableAtOurBranch",{location:e?.location?.city}):i("item.contact"))),Be.createElement(O,null,Be.createElement(Mk,{position:e?.location?.position})),(e?.connections?.length||0)>1&&Be.createElement(O,null,Be.createElement(ae,null,Be.createElement("p",null,i("item.centralWarehouseCarDescriptionShort")," ",Be.createElement(Se,{as:"span",role:"button",onClick:s,inline:!0,title:i("item.clickHereToShowContactToAnotherBranch")||""},i("item.clickHereToShowContactToAnotherBranch")),"."))),Be.createElement(O,null,Be.createElement(Jy,null,Be.createElement(O,null,Be.createElement(Aa,null,e?.location?.streetAddress&&e?.location?.city&&Be.createElement(Si,null,Be.createElement(zt,null,i("common.address")),Be.createElement(zt,null,Be.createElement(Hn,null,Be.createElement(se,null,`${e?.location?.streetAddress}, ${e?.location?.city}`)))),e?.contact?.phonenumber&&Be.createElement(Fk,{phoneNumber:va(e.contact.phonenumber)}))),e?.openingHours&&Be.createElement(O,null,Be.createElement(Bk,{openingHours:e.openingHours}))))):null},Uk=oM;import{format as FM}from"date-fns";import{nb as _M,sv as HM}from"date-fns/locale";import ke,{useCallback as Ta,useEffect as $M,useState as AA}from"react";import{useTranslation as UM}from"react-i18next";import Qr,{useCallback as Ti,useMemo as eA,useState as IM}from"react";import{useTranslation as SM}from"react-i18next";import ye,{useCallback as ld,useId as hM,useMemo as fM,useState as ba}from"react";import{useTranslation as gM}from"react-i18next";import{useCallback as aM,useState as jk}from"react";var fn={name:"@wayke-se/components-react",version:"5.2.0",description:"",module:"dist/index.mjs",main:"dist/index.js",types:"dist/index.d.ts",type:"module",files:["dist"],scripts:{prebuild:"npm run clean",test:"npm run lint && npm run typecheck",lint:"npx @biomejs/biome check","lint:fix":"npx @biomejs/biome check --write",typecheck:"tsc --noEmit --skipLibCheck",gen:"graphql-codegen --config ./codegen.yml","generate-libphonenumber-metadata":"libphonenumber-metadata-generator src/utils/metadata.min.json --countries SE,NO --extended",prepare:"husky",start:"node ./esbuild/start.js",build:"npm run clean && node ./esbuild/lib.js && node ./esbuild/cdn.js",clean:"rimraf build && rimraf dist && rimraf dist-cdn","build:types":"tsc --project tsconfig.build.json"},repository:{type:"git",url:"git+https://github.com/wayke-se/components-react.git"},author:"Ourstudio",license:"MIT",peerDependencies:{react:"^18 || ^19","react-dom":"^18 || ^19","styled-components":"^6"},devDependencies:{"@biomejs/biome":"2.5.15","@graphql-codegen/cli":"^7.4.5","@graphql-codegen/typescript":"^6.1.1","@types/googlemaps":"^3.43.3","@types/node":"^24.19.1","@types/react":"^19.3.0","@types/react-dom":"^19.3.0","@types/react-slick":"^0.23.13","@wayke-se/ecom-web":"^2.1.1",dotenv:"^18.0.6",esbuild:"^0.28.2","esbuild-plugin-copy":"^2.1.1",husky:"^9.1.7","libphonenumber-metadata-generator":"^2.0.6","lint-staged":"^17.6.0",react:"^19.3.0","react-dom":"^19.3.0","react-router-dom":"^7.18.4",rimraf:"^6.1.3","styled-components":"^6.5.3",typescript:"^7.0.2"},dependencies:{"@apollo/client":"^4.3.3","@emotion/is-prop-valid":"^1.4.0","@photo-sphere-viewer/core":"^5.15.1","date-fns":"^4.4.0",graphql:"^16.0.0 || ^17.0.0",i18next:"^26.4.2","libphonenumber-js":"^1.13.15",marked:"^18.1.0","react-compound-slider":"^3.4.0","react-i18next":"^17.0.16","react-slick":"^0.31.0","scroll-into-view-if-needed":"^3.1.0"},allowScripts:{esbuild:!0,fsevents:!1}};var lM=(e,t="SE")=>{let[r,i]=jk(!1),[n,o]=jk(null),s=aM(async({itemId:a,branchId:l,communication:d,firstName:u,lastName:h,phoneNumber:p,email:f,message:v,tradeInCarRegNo:A,tradeInCarMileage:g})=>{if(!e)throw new Error("Missing apiUrl, cannot submit lead");i(!0),o(null);let y={firstName:u,lastName:h,phoneNumber:p,email:f,branchId:l,type:"registrationOfInterestToBuy",metaData:[{key:"source",value:window.location.hostname.replace(/^www\./,"")},{key:"sourceMechanism",value:`cta.${d}`},{key:"client",value:"components-react"},{key:"clientVersion",value:fn.version},{key:"itemForSaleId",value:a},...A?[{key:"registrationNumber",value:A}]:[],...g?[{key:"tradeInCarMileage",value:g},{key:"readingUnit",value:t==="NO"?"Kilometer":"ScandinavianMile"}]:[],{key:"message",value:v||""}]};try{let k=`${new URL(e).origin}/lead`,w=await fetch(k,{method:"POST",body:JSON.stringify(y),headers:{"Content-Type":"application/json; charset=UTF-8"}});if(!w.ok)throw new Error(`Request failed with status ${w.status}`);return await w.json()}catch(k){throw o(k instanceof Error?k.message:"Something went wrong"),k}finally{i(!1)}},[e,t]);return{isLoading:r,error:n,submitLead:s}},Gk=lM;import dM from"react";import cM from"styled-components";var Vk=cM.div`
5168
5168
  margin-top: ${m(.5)};
5169
5169
  font-size: 0.875rem;
5170
5170
  color: ${e=>e.theme.color.ui.negative};