{"version":3,"sources":["webpack:///./LeLab.Web/src/js/locale-cookie.entry.js","webpack:///./LeLab.Web/src/utils/cookies.js"],"names":["BarbaLocaleCookie","PageHooks","afterEnter","name","value","options","newCookie","expireSeconds","sameSite","Date","now","document","cookie","setCookie","documentElement","lang"],"mappings":"8GAMA,MAAMA,UAA0BC,IAC5BC,cCHG,SAAmBC,EAAMC,EAAOC,GACnC,IAAIC,EAAY,GAAH,OAAMH,EAAN,YAAcC,GAE3B,MAAM,cAAEG,EAAF,SAAiBC,GAAaH,EAEhCE,IACAD,GAAa,aAAe,IAAIG,KAAKA,KAAKC,MAAwB,IAAhBH,IAGlDC,IACAF,GAAa,cAAJ,OAAkBE,IAG/BF,GAAa,WAEbK,SAASC,OAASN,EDTdO,CANiB,eAKJF,SAASG,gBAAgBC,KACJ,CAC9BR,cARiB,QASjBC,SAAU,YAKtB,IAAIR,I","file":"locale-cookie.js","sourcesContent":["import { setCookie } from \"../utils/cookies.js\";\r\nimport { PageHooks } from \"barba\";\r\n\r\nconst localeCookieDuration = 365 * 24 * 60 * 60; // 1 an\r\nconst localeCookieName = \"localecookie\";\r\n\r\nclass BarbaLocaleCookie extends PageHooks {\r\n afterEnter() {\r\n // Set document language in cookie\r\n const lang = document.documentElement.lang;\r\n setCookie(localeCookieName, lang, {\r\n expireSeconds: localeCookieDuration,\r\n sameSite: \"Strict\"\r\n });\r\n }\r\n}\r\n\r\nnew BarbaLocaleCookie();\r\n","export function readCookie(name) {\r\n return document.cookie.replace(new RegExp(`(?:(?:^|.*;\\\\s*)${name}\\\\s*\\\\=\\\\s*([^;]*).*$)|^.*$`), \"$1\");\r\n}\r\n\r\nexport function setCookie(name, value, options) {\r\n let newCookie = `${name}=${value}`;\r\n\r\n const { expireSeconds, sameSite } = options;\r\n\r\n if (expireSeconds) {\r\n newCookie += `; expires=` + new Date(Date.now() + expireSeconds * 1000);\r\n }\r\n\r\n if (sameSite) {\r\n newCookie += `; SameSite=${sameSite}`;\r\n }\r\n\r\n newCookie += `; path=/`;\r\n\r\n document.cookie = newCookie;\r\n}\r\n"],"sourceRoot":""}