@leabankab/component-library 8.1.0 → 8.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.
@@ -6,6 +6,7 @@ export type GlobalAlertProps = AlertProps & {
6
6
  * @default false
7
7
  */
8
8
  fluid?: boolean;
9
+ innerClassName?: string;
9
10
  };
10
11
  /**
11
12
  * An `Alert` that spans the whole page width, for messages about the whole
@@ -21,4 +22,4 @@ export type GlobalAlertProps = AlertProps & {
21
22
  * </GlobalAlert>
22
23
  * ```
23
24
  */
24
- export declare function GlobalAlert({ fluid, className, ...props }: GlobalAlertProps): import("react").JSX.Element;
25
+ export declare function GlobalAlert({ fluid, className, innerClassName, ...props }: GlobalAlertProps): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("vanilla-cookieconsent");c=s(c);var l=3,u=[`necessary`,`preferences`,`analytics`,`marketing`],d={se:`leabank.se`,fi:`leabank.fi`,no:`leabank.no`,es:`leabank.es`},f=`cc_cookie`;function p(e,t){let n=d[t],r=e.toLowerCase();return r===n||r.endsWith(`.${n}`)?n:void 0}function m(){document.cookie=`${f}=; path=/; max-age=0`}var h={consent:null,settingsOpen:!1,ready:!1},g=!1,_=h,v=new Set;function y(e){_={..._,...e},v.forEach(e=>e())}function b(){if(typeof window>`u`||!c.validConsent())return null;let e=new Set(c.getUserPreferences().acceptedCategories);return Object.fromEntries(u.map(t=>[t,e.has(t)]))}function x({market:e,onConsentChange:t}){if(typeof window>`u`||g)return;g=!0;let n=p(window.location.hostname,e);n&&m();let r=()=>{let e=b();y({consent:e}),e&&t?.(e)};c.run({root:document.createElement(`div`),autoShow:!1,hideFromBots:!1,language:{default:`en`,translations:{en:{consentModal:{},preferencesModal:{sections:[]}}}},revision:3,cookie:{name:f,sameSite:`Lax`,secure:!0,...n&&{domain:n}},categories:{necessary:{enabled:!0,readOnly:!0},preferences:{enabled:!1,readOnly:!1},analytics:{enabled:!1,readOnly:!1,autoClear:{cookies:[{name:/^(_ga|_gid|_gat)/}]}},marketing:{enabled:!1,readOnly:!1,autoClear:{cookies:[{name:/^(_fbp|_fbc)/},{name:/^(_gcl_)/}]}}},onFirstConsent:r,onChange:r}).then(()=>{let e=b();y({consent:e,ready:!0,settingsOpen:_.settingsOpen||e===null}),e&&t?.(e)})}function S(e){_.ready&&(c.acceptCategory(e===`all`?`all`:[`necessary`,...e.filter(e=>e!==`necessary`)]),y({consent:b(),settingsOpen:!1}))}function C(){typeof window>`u`||y({settingsOpen:!0})}function w(){_.consent!==null&&y({settingsOpen:!1})}function T(e){return v.add(e),()=>{v.delete(e)}}function E(){return _}function D(){return h}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return l}});
2
+ //# sourceMappingURL=cookie-consent-core-fntGUdFt.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookie-consent-core-fntGUdFt.cjs","names":[],"sources":["../src/cookie-consent/constants.ts","../src/cookie-consent/domain.ts","../src/cookie-consent/core.ts"],"sourcesContent":["/**\n * Bumping the revision invalidates every visitor's consent on every Lea Bank\n * app at once. Only change it here, then release all apps together.\n */\nexport const COOKIE_CONSENT_REVISION = 3;\n\nexport const COOKIE_CONSENT_CATEGORIES = [\n \"necessary\",\n \"preferences\",\n \"analytics\",\n \"marketing\",\n] as const;\n\nexport type CookieConsentCategory = (typeof COOKIE_CONSENT_CATEGORIES)[number];\n\nexport type ConsentState = Record<CookieConsentCategory, boolean>;\n\nexport type Market = \"se\" | \"fi\" | \"no\" | \"es\";\n\nexport const MARKET_DOMAINS: Record<Market, string> = {\n se: \"leabank.se\",\n fi: \"leabank.fi\",\n no: \"leabank.no\",\n es: \"leabank.es\",\n};\n\nexport const COOKIE_NAME = \"cc_cookie\";\n","import { COOKIE_NAME, MARKET_DOMAINS, type Market } from \"./constants\";\n\n/**\n * Returns the market's registrable domain when the page is served from it or\n * one of its subdomains. Anywhere else (localhost, `*.azurewebsites.net`,\n * which is on the Public Suffix List) the browser would reject the cookie, so\n * it stays host-only.\n */\nexport function resolveCookieDomain(\n hostname: string,\n market: Market,\n): string | undefined {\n const domain = MARKET_DOMAINS[market];\n const host = hostname.toLowerCase();\n\n return host === domain || host.endsWith(`.${domain}`) ? domain : undefined;\n}\n\n/**\n * Erases a host-only consent cookie left by an earlier, domain-less setup.\n * Without this it coexists with the domain cookie under the same name and a\n * stale value can win. A cookie written without `domain` only matches the\n * host-only one, so the shared cookie is kept.\n */\nexport function clearHostOnlyCookie(): void {\n document.cookie = `${COOKIE_NAME}=; path=/; max-age=0`;\n}\n","import * as CookieConsent from \"vanilla-cookieconsent\";\n\nimport {\n COOKIE_CONSENT_CATEGORIES,\n COOKIE_CONSENT_REVISION,\n COOKIE_NAME,\n type ConsentState,\n type CookieConsentCategory,\n type Market,\n} from \"./constants\";\nimport { clearHostOnlyCookie, resolveCookieDomain } from \"./domain\";\n\nexport interface InitCookieConsentOptions {\n market: Market;\n /**\n * Called with the visitor's choice once the library has loaded, when there\n * is a valid consent, and again whenever the choice changes.\n */\n onConsentChange?: (state: ConsentState) => void;\n}\n\nexport interface ConsentSnapshot {\n consent: ConsentState | null;\n /** Whether the settings dialog should be shown. */\n settingsOpen: boolean;\n /** The stored consent has been read and the choice can be changed. */\n ready: boolean;\n}\n\nconst serverSnapshot: ConsentSnapshot = {\n consent: null,\n settingsOpen: false,\n ready: false,\n};\n\nlet started = false;\nlet snapshot = serverSnapshot;\nconst listeners = new Set<() => void>();\n\nfunction update(patch: Partial<ConsentSnapshot>) {\n snapshot = { ...snapshot, ...patch };\n listeners.forEach((listener) => listener());\n}\n\n/** `null` on the server, before the visitor has chosen, or after a revision bump. */\nexport function getConsentState(): ConsentState | null {\n if (typeof window === \"undefined\" || !CookieConsent.validConsent()) {\n return null;\n }\n\n const accepted = new Set(CookieConsent.getUserPreferences().acceptedCategories);\n return Object.fromEntries(\n COOKIE_CONSENT_CATEGORIES.map((category) => [category, accepted.has(category)]),\n ) as ConsentState;\n}\n\n/**\n * Reads the shared consent and keeps it up to date. Only the first call has an\n * effect, and it is a no-op on the server. It shows nothing by itself: the\n * settings dialog is rendered by `CookieConsentProvider`.\n */\nexport function initCookieConsent({\n market,\n onConsentChange,\n}: InitCookieConsentOptions): void {\n if (typeof window === \"undefined\" || started) return;\n started = true;\n\n const domain = resolveCookieDomain(window.location.hostname, market);\n if (domain) clearHostOnlyCookie();\n\n const applyConsent = () => {\n const consent = getConsentState();\n update({ consent });\n if (consent) onConsentChange?.(consent);\n };\n\n // The full build with its UI unused: `run` still builds an empty consent\n // modal when consent is missing, so it goes into a detached `root` that never\n // reaches the page. The UI-less core build of 3.1.0 can't be used, because\n // its `run` throws. `hideFromBots` is off because its check stops `run`\n // before the stored cookie is read, so browser automation such as Playwright\n // could never see a stored consent. With the UI unused, it hides nothing.\n void CookieConsent.run({\n root: document.createElement(\"div\"),\n autoShow: false,\n hideFromBots: false,\n language: {\n default: \"en\",\n translations: { en: { consentModal: {}, preferencesModal: { sections: [] } } },\n },\n revision: COOKIE_CONSENT_REVISION,\n cookie: {\n name: COOKIE_NAME,\n sameSite: \"Lax\",\n secure: true,\n ...(domain && { domain }),\n },\n categories: {\n necessary: { enabled: true, readOnly: true },\n preferences: { enabled: false, readOnly: false },\n analytics: {\n enabled: false,\n readOnly: false,\n autoClear: { cookies: [{ name: /^(_ga|_gid|_gat)/ }] },\n },\n marketing: {\n enabled: false,\n readOnly: false,\n autoClear: {\n cookies: [{ name: /^(_fbp|_fbc)/ }, { name: /^(_gcl_)/ }],\n },\n },\n },\n onFirstConsent: applyConsent,\n onChange: applyConsent,\n }).then(() => {\n const consent = getConsentState();\n update({\n consent,\n ready: true,\n settingsOpen: snapshot.settingsOpen || consent === null,\n });\n if (consent) onConsentChange?.(consent);\n });\n}\n\n/**\n * Stores the visitor's choice. `necessary` is always kept. Does nothing until\n * `initCookieConsent` has read the stored consent.\n */\nexport function setConsent(\n categories: readonly CookieConsentCategory[] | \"all\",\n): void {\n if (!snapshot.ready) return;\n\n CookieConsent.acceptCategory(\n categories === \"all\"\n ? \"all\"\n : [\"necessary\", ...categories.filter((category) => category !== \"necessary\")],\n );\n update({ consent: getConsentState(), settingsOpen: false });\n}\n\n/** Opens the settings dialog of the mounted `CookieConsentProvider`. */\nexport function openCookieSettings(): void {\n if (typeof window === \"undefined\") return;\n update({ settingsOpen: true });\n}\n\n/** Closes the settings dialog, unless the visitor has yet to choose. */\nexport function closeCookieSettings(): void {\n if (snapshot.consent === null) return;\n update({ settingsOpen: false });\n}\n\nexport function subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nexport function getSnapshot(): ConsentSnapshot {\n return snapshot;\n}\n\nexport function getServerSnapshot(): ConsentSnapshot {\n return serverSnapshot;\n}\n"],"mappings":"kiBAIA,IAAa,EAA0B,EAE1B,E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E,EACA,SAAA,EACA,OAAQ,CACN,KAAM,EACN,SAAU,MACV,OAAQ,GACR,GAAI,GAAU,CAAE,QAAO,CACzB,EACA,WAAY,CACV,UAAW,CAAE,QAAS,GAAM,SAAU,EAAK,EAC3C,YAAa,CAAE,QAAS,GAAO,SAAU,EAAM,EAC/C,UAAW,CACT,QAAS,GACT,SAAU,GACV,UAAW,CAAE,QAAS,CAAC,CAAE,KAAM,kBAAmB,CAAC,CAAE,CACvD,EACA,UAAW,CACT,QAAS,GACT,SAAU,GACV,UAAW,CACT,QAAS,CAAC,CAAE,KAAM,cAAe,EAAG,CAAE,KAAM,UAAW,CAAC,CAC1D,CACF,CACF,EACA,eAAgB,EAChB,SAAU,CACZ,CAAC,CAAC,CAAC,SAAW,CACZ,IAAM,EAAU,EAAgB,EAChC,EAAO,CACL,UACA,MAAO,GACP,aAAc,EAAS,cAAgB,IAAY,IACrD,CAAC,EACG,GAAS,IAAkB,CAAO,CACxC,CAAC,CACH,CAMA,SAAgB,EACd,EACM,CACD,EAAS,QAEd,EAAc,eACZ,IAAe,MACX,MACA,CAAC,YAAa,GAAG,EAAW,OAAQ,GAAa,IAAa,WAAW,CAAC,CAChF,EACA,EAAO,CAAE,QAAS,EAAgB,EAAG,aAAc,EAAM,CAAC,EAC5D,CAGA,SAAgB,GAA2B,CACrC,OAAO,OAAW,KACtB,EAAO,CAAE,aAAc,EAAK,CAAC,CAC/B,CAGA,SAAgB,GAA4B,CACtC,EAAS,UAAY,MACzB,EAAO,CAAE,aAAc,EAAM,CAAC,CAChC,CAEA,SAAgB,EAAU,EAAkC,CAE1D,OADA,EAAU,IAAI,CAAQ,MACT,CACX,EAAU,OAAO,CAAQ,CAC3B,CACF,CAEA,SAAgB,GAA+B,CAC7C,OAAO,CACT,CAEA,SAAgB,GAAqC,CACnD,OAAO,CACT"}
@@ -50,6 +50,7 @@ function p({ market: t, onConsentChange: n }) {
50
50
  e.run({
51
51
  root: document.createElement("div"),
52
52
  autoShow: !1,
53
+ hideFromBots: !1,
53
54
  language: {
54
55
  default: "en",
55
56
  translations: { en: {
@@ -121,4 +122,4 @@ function y() {
121
122
  //#endregion
122
123
  export { p as a, _ as c, v as i, n as l, f as n, h as o, y as r, m as s, g as t, t as u };
123
124
 
124
- //# sourceMappingURL=cookie-consent-core-mwVmy5nZ.mjs.map
125
+ //# sourceMappingURL=cookie-consent-core-lX0QAEAo.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookie-consent-core-lX0QAEAo.mjs","names":[],"sources":["../src/cookie-consent/constants.ts","../src/cookie-consent/domain.ts","../src/cookie-consent/core.ts"],"sourcesContent":["/**\n * Bumping the revision invalidates every visitor's consent on every Lea Bank\n * app at once. Only change it here, then release all apps together.\n */\nexport const COOKIE_CONSENT_REVISION = 3;\n\nexport const COOKIE_CONSENT_CATEGORIES = [\n \"necessary\",\n \"preferences\",\n \"analytics\",\n \"marketing\",\n] as const;\n\nexport type CookieConsentCategory = (typeof COOKIE_CONSENT_CATEGORIES)[number];\n\nexport type ConsentState = Record<CookieConsentCategory, boolean>;\n\nexport type Market = \"se\" | \"fi\" | \"no\" | \"es\";\n\nexport const MARKET_DOMAINS: Record<Market, string> = {\n se: \"leabank.se\",\n fi: \"leabank.fi\",\n no: \"leabank.no\",\n es: \"leabank.es\",\n};\n\nexport const COOKIE_NAME = \"cc_cookie\";\n","import { COOKIE_NAME, MARKET_DOMAINS, type Market } from \"./constants\";\n\n/**\n * Returns the market's registrable domain when the page is served from it or\n * one of its subdomains. Anywhere else (localhost, `*.azurewebsites.net`,\n * which is on the Public Suffix List) the browser would reject the cookie, so\n * it stays host-only.\n */\nexport function resolveCookieDomain(\n hostname: string,\n market: Market,\n): string | undefined {\n const domain = MARKET_DOMAINS[market];\n const host = hostname.toLowerCase();\n\n return host === domain || host.endsWith(`.${domain}`) ? domain : undefined;\n}\n\n/**\n * Erases a host-only consent cookie left by an earlier, domain-less setup.\n * Without this it coexists with the domain cookie under the same name and a\n * stale value can win. A cookie written without `domain` only matches the\n * host-only one, so the shared cookie is kept.\n */\nexport function clearHostOnlyCookie(): void {\n document.cookie = `${COOKIE_NAME}=; path=/; max-age=0`;\n}\n","import * as CookieConsent from \"vanilla-cookieconsent\";\n\nimport {\n COOKIE_CONSENT_CATEGORIES,\n COOKIE_CONSENT_REVISION,\n COOKIE_NAME,\n type ConsentState,\n type CookieConsentCategory,\n type Market,\n} from \"./constants\";\nimport { clearHostOnlyCookie, resolveCookieDomain } from \"./domain\";\n\nexport interface InitCookieConsentOptions {\n market: Market;\n /**\n * Called with the visitor's choice once the library has loaded, when there\n * is a valid consent, and again whenever the choice changes.\n */\n onConsentChange?: (state: ConsentState) => void;\n}\n\nexport interface ConsentSnapshot {\n consent: ConsentState | null;\n /** Whether the settings dialog should be shown. */\n settingsOpen: boolean;\n /** The stored consent has been read and the choice can be changed. */\n ready: boolean;\n}\n\nconst serverSnapshot: ConsentSnapshot = {\n consent: null,\n settingsOpen: false,\n ready: false,\n};\n\nlet started = false;\nlet snapshot = serverSnapshot;\nconst listeners = new Set<() => void>();\n\nfunction update(patch: Partial<ConsentSnapshot>) {\n snapshot = { ...snapshot, ...patch };\n listeners.forEach((listener) => listener());\n}\n\n/** `null` on the server, before the visitor has chosen, or after a revision bump. */\nexport function getConsentState(): ConsentState | null {\n if (typeof window === \"undefined\" || !CookieConsent.validConsent()) {\n return null;\n }\n\n const accepted = new Set(CookieConsent.getUserPreferences().acceptedCategories);\n return Object.fromEntries(\n COOKIE_CONSENT_CATEGORIES.map((category) => [category, accepted.has(category)]),\n ) as ConsentState;\n}\n\n/**\n * Reads the shared consent and keeps it up to date. Only the first call has an\n * effect, and it is a no-op on the server. It shows nothing by itself: the\n * settings dialog is rendered by `CookieConsentProvider`.\n */\nexport function initCookieConsent({\n market,\n onConsentChange,\n}: InitCookieConsentOptions): void {\n if (typeof window === \"undefined\" || started) return;\n started = true;\n\n const domain = resolveCookieDomain(window.location.hostname, market);\n if (domain) clearHostOnlyCookie();\n\n const applyConsent = () => {\n const consent = getConsentState();\n update({ consent });\n if (consent) onConsentChange?.(consent);\n };\n\n // The full build with its UI unused: `run` still builds an empty consent\n // modal when consent is missing, so it goes into a detached `root` that never\n // reaches the page. The UI-less core build of 3.1.0 can't be used, because\n // its `run` throws. `hideFromBots` is off because its check stops `run`\n // before the stored cookie is read, so browser automation such as Playwright\n // could never see a stored consent. With the UI unused, it hides nothing.\n void CookieConsent.run({\n root: document.createElement(\"div\"),\n autoShow: false,\n hideFromBots: false,\n language: {\n default: \"en\",\n translations: { en: { consentModal: {}, preferencesModal: { sections: [] } } },\n },\n revision: COOKIE_CONSENT_REVISION,\n cookie: {\n name: COOKIE_NAME,\n sameSite: \"Lax\",\n secure: true,\n ...(domain && { domain }),\n },\n categories: {\n necessary: { enabled: true, readOnly: true },\n preferences: { enabled: false, readOnly: false },\n analytics: {\n enabled: false,\n readOnly: false,\n autoClear: { cookies: [{ name: /^(_ga|_gid|_gat)/ }] },\n },\n marketing: {\n enabled: false,\n readOnly: false,\n autoClear: {\n cookies: [{ name: /^(_fbp|_fbc)/ }, { name: /^(_gcl_)/ }],\n },\n },\n },\n onFirstConsent: applyConsent,\n onChange: applyConsent,\n }).then(() => {\n const consent = getConsentState();\n update({\n consent,\n ready: true,\n settingsOpen: snapshot.settingsOpen || consent === null,\n });\n if (consent) onConsentChange?.(consent);\n });\n}\n\n/**\n * Stores the visitor's choice. `necessary` is always kept. Does nothing until\n * `initCookieConsent` has read the stored consent.\n */\nexport function setConsent(\n categories: readonly CookieConsentCategory[] | \"all\",\n): void {\n if (!snapshot.ready) return;\n\n CookieConsent.acceptCategory(\n categories === \"all\"\n ? \"all\"\n : [\"necessary\", ...categories.filter((category) => category !== \"necessary\")],\n );\n update({ consent: getConsentState(), settingsOpen: false });\n}\n\n/** Opens the settings dialog of the mounted `CookieConsentProvider`. */\nexport function openCookieSettings(): void {\n if (typeof window === \"undefined\") return;\n update({ settingsOpen: true });\n}\n\n/** Closes the settings dialog, unless the visitor has yet to choose. */\nexport function closeCookieSettings(): void {\n if (snapshot.consent === null) return;\n update({ settingsOpen: false });\n}\n\nexport function subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nexport function getSnapshot(): ConsentSnapshot {\n return snapshot;\n}\n\nexport function getServerSnapshot(): ConsentSnapshot {\n return serverSnapshot;\n}\n"],"mappings":";;AAIA,IAAa,IAA0B,GAE1B,IAA4B;CACvC;CACA;CACA;CACA;AACF,GAQa,IAAyC;CACpD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN,GAEa,IAAc;;;AClB3B,SAAgB,EACd,GACA,GACoB;CACpB,IAAM,IAAS,EAAe,IACxB,IAAO,EAAS,YAAY;CAElC,OAAO,MAAS,KAAU,EAAK,SAAS,IAAI,GAAQ,IAAI,IAAS,KAAA;AACnE;AAQA,SAAgB,IAA4B;CAC1C,SAAS,SAAS,GAAG,EAAY;AACnC;;;ACGA,IAAM,IAAkC;CACtC,SAAS;CACT,cAAc;CACd,OAAO;AACT,GAEI,IAAU,IACV,IAAW,GACT,oBAAY,IAAI,IAAgB;AAEtC,SAAS,EAAO,GAAiC;CAE/C,AADA,IAAW;EAAE,GAAG;EAAU,GAAG;CAAM,GACnC,EAAU,SAAS,MAAa,EAAS,CAAC;AAC5C;AAGA,SAAgB,IAAuC;CACrD,IAAI,OAAO,SAAW,OAAe,CAAC,EAAc,aAAa,GAC/D,OAAO;CAGT,IAAM,IAAW,IAAI,IAAI,EAAc,mBAAmB,CAAC,CAAC,kBAAkB;CAC9E,OAAO,OAAO,YACZ,EAA0B,KAAK,MAAa,CAAC,GAAU,EAAS,IAAI,CAAQ,CAAC,CAAC,CAChF;AACF;AAOA,SAAgB,EAAkB,EAChC,WACA,sBACiC;CACjC,IAAI,OAAO,SAAW,OAAe,GAAS;CAC9C,IAAU;CAEV,IAAM,IAAS,EAAoB,OAAO,SAAS,UAAU,CAAM;CACnE,AAAI,KAAQ,EAAoB;CAEhC,IAA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AE,cAAc,GAAM,CAAC;AAChC;AAEA,SAAgB,EAAU,GAAkC;CAE1D,OADA,EAAU,IAAI,CAAQ,SACT;EACX,EAAU,OAAO,CAAQ;CAC3B;AACF;AAEA,SAAgB,IAA+B;CAC7C,OAAO;AACT;AAEA,SAAgB,IAAqC;CACnD,OAAO;AACT"}
@@ -1,2 +1,2 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});require('./cookie-consent.css');const e=require("./cookie-consent-core-C4MP7GlV.cjs");let t=require("react"),n=require("@base-ui/react/button"),r=require("@base-ui/react/use-render"),i=require("react/jsx-runtime"),a=require("@base-ui/react/dialog"),o=require("lucide-react"),s=require("@base-ui/react/switch"),c=require("@base-ui/react/accordion");var l=(e,t)=>n=>[e,typeof t==`function`?t(n):t].filter(Boolean).join(` `),u={Button:`_Button_1d72q_1`,IconButton:`_IconButton_1d72q_125`,Spinner:`_Spinner_1d72q_150`,"button-spin":`_button-spin_1d72q_1`,SrOnly:`_SrOnly_1d72q_168`},d=e=>(0,t.isValidElement)(e)&&(e.props.href!=null||e.props.to!=null),f=e=>e.preventDefault();function p({loading:e=!1,disabled:t,className:a,render:o,nativeButton:s,focusableWhenDisabled:c,ref:l,...u}){let p=!!(t||e),m=d(o),h={"aria-busy":e||void 0,"data-loading":e||void 0};return(0,r.useRender)({enabled:m,render:m?o:void 0,ref:l,defaultTagName:`a`,props:{...u,...h,"aria-disabled":p||void 0,"data-disabled":p?``:void 0,className:typeof a==`function`?a({disabled:p}):a,onClick:p?f:u.onClick}})||(0,i.jsx)(n.Button,{...u,...h,ref:l,render:o,nativeButton:s,focusableWhenDisabled:c,disabled:p,className:a})}function m({variant:e=`solid`,color:t=`primary`,size:n=`md`,className:r,...a}){return(0,i.jsx)(p,{...a,"data-variant":e,"data-color":t,"data-size":n,className:l(u.Button,r)})}function h({startIcon:e,endIcon:t,loading:n=!1,loadingLabel:r,children:a,...o}){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(m,{...o,loading:n,"data-start-icon":n||e!=null||void 0,"data-end-icon":t!=null||void 0,children:[n?(0,i.jsx)(`span`,{className:u.Spinner,"aria-hidden":!0}):e,a,t]}),r!=null&&(0,i.jsx)(`span`,{role:`status`,className:u.SrOnly,children:n?r:null})]})}var g={Backdrop:`_Backdrop_1mady_8`,Viewport:`_Viewport_1mady_22`,Popup:`_Popup_1mady_38`,Header:`_Header_1mady_78`,Title:`_Title_1mady_88`,Description:`_Description_1mady_97`,Content:`_Content_1mady_111`,Footer:`_Footer_1mady_119`,CloseButton:`_CloseButton_1mady_135`},_=(0,t.createContext)(`no`),v=()=>(0,t.useContext)(_);function y(e){return function(){let t=v(),n={};return Object.keys(e).forEach(r=>{let i=e[r];n[r]=i[t]??i.no}),n}}var b=y({close:{no:`Lukk`,se:`Stäng`,fi:`Sulje`,es:`Cerrar`}}),x=a.Dialog.Root;a.Dialog.Trigger;var S=a.Dialog.Portal;function C({className:e,...t}){return(0,i.jsx)(a.Dialog.Backdrop,{...t,className:l(g.Backdrop,e)})}function w({className:e,...t}){return(0,i.jsx)(a.Dialog.Viewport,{...t,className:l(g.Viewport,e)})}function T({size:e=`sm`,fullScreenOnMobile:t,className:n,...r}){return(0,i.jsx)(a.Dialog.Popup,{...r,"data-size":e,"data-full-screen-on-mobile":t||void 0,className:l(g.Popup,n)})}function E({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Header,e].filter(Boolean).join(` `)})}function D({className:e,...t}){return(0,i.jsx)(a.Dialog.Title,{...t,className:l(g.Title,e)})}function O({className:e,...t}){return(0,i.jsx)(a.Dialog.Description,{...t,className:l(g.Description,e)})}function k({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Content,e].filter(Boolean).join(` `)})}function A({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Footer,e].filter(Boolean).join(` `)})}a.Dialog.Close;function j({label:e,className:t,...n}){let r=b();return(0,i.jsx)(a.Dialog.Close,{...n,"aria-label":e??r.close,className:l(g.CloseButton,t),children:(0,i.jsx)(o.X,{size:20,"aria-hidden":!0})})}var M={Switch:`_Switch_9c9ji_7`,Thumb:`_Thumb_9c9ji_36`};function N({className:e,...t}){return(0,i.jsx)(s.Switch.Root,{...t,className:l(M.Switch,e),children:(0,i.jsx)(s.Switch.Thumb,{className:M.Thumb})})}var P={Root:`_Root_18gqk_13`,Item:`_Item_18gqk_10`,Header:`_Header_18gqk_10`,Trigger:`_Trigger_18gqk_95`,Label:`_Label_18gqk_136`,Icon:`_Icon_18gqk_140`,Panel:`_Panel_18gqk_158`,Content:`_Content_18gqk_169`};function F({variant:e=`outline`,iconPosition:t=`end`,className:n,...r}){return(0,i.jsx)(c.Accordion.Root,{...r,"data-variant":e,"data-icon-position":t,className:l(P.Root,n)})}function I({className:e,...t}){return(0,i.jsx)(c.Accordion.Item,{...t,className:l(P.Item,e)})}function L({className:e,...t}){return(0,i.jsx)(c.Accordion.Header,{...t,className:l(P.Header,e)})}function R({children:e,className:t,...n}){return(0,i.jsxs)(c.Accordion.Trigger,{...n,className:l(P.Trigger,t),children:[(0,i.jsx)(`span`,{className:P.Label,children:e}),(0,i.jsx)(o.ChevronDown,{className:P.Icon,size:20,"aria-hidden":!0})]})}function z({children:e,className:t,...n}){return(0,i.jsx)(c.Accordion.Panel,{...n,className:l(P.Panel,t),children:(0,i.jsx)(`div`,{className:P.Content,children:e})})}var B={Intro:`_Intro_nxwj4_7`,Categories:`_Categories_nxwj4_39`,CategoryDescription:`_CategoryDescription_nxwj4_43`,Actions:`_Actions_nxwj4_52`,Save:`_Save_nxwj4_63`},V=`https://relative.invalid`;function H(e,t){try{return new URL(e,t)}catch{return null}}function U(e){let t=e.trim();if(!t)return!1;let n=H(t);return n?n.protocol===`https:`||n.protocol===`mailto:`:H(t,V)?.origin===V}function W({href:e,resolveHref:t=e=>e,children:n}){let r=t(e);return!r||!U(r)?(0,i.jsx)(i.Fragment,{children:n}):(0,i.jsx)(`a`,{href:r.trim(),target:`_blank`,rel:`noopener noreferrer`,children:n})}function G({node:e}){let t=e.text;return e.underline&&(t=(0,i.jsx)(`u`,{children:t})),e.italic&&(t=(0,i.jsx)(`em`,{children:t})),e.bold&&(t=(0,i.jsx)(`strong`,{children:t})),(0,i.jsx)(i.Fragment,{children:t})}function K({nodes:e,resolveHref:t}){return(0,i.jsx)(i.Fragment,{children:(e??[]).map((e,n)=>e.type===`text`?(0,i.jsx)(G,{node:e},n):e.type===`link`?(0,i.jsx)(W,{href:e.url??``,resolveHref:t,children:(e.children??[]).filter(e=>e.type===`text`).map((e,t)=>(0,i.jsx)(G,{node:e},t))},n):null)})}function q({node:e,resolveHref:t}){let n=e.format===`ordered`?`ol`:`ul`;return(0,i.jsx)(n,{children:(e.children??[]).map((e,n)=>e.type===`list`?(0,i.jsx)(`li`,{children:(0,i.jsx)(q,{node:e,resolveHref:t})},n):e.type===`list-item`?(0,i.jsx)(`li`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})},n):null)})}function J({nodes:e,resolveHref:t}){return(0,i.jsx)(i.Fragment,{children:e.map((e,n)=>{switch(e.type){case`paragraph`:return(0,i.jsx)(`p`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})},n);case`heading`:return(0,i.jsx)(`p`,{children:(0,i.jsx)(`strong`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})})},n);case`list`:return(0,i.jsx)(q,{node:e,resolveHref:t},n);default:return null}})})}function Y(e){return{necessary:!0,preferences:e?.preferences??!1,analytics:e?.analytics??!1,marketing:e?.marketing??!1}}function X({category:e,copy:n,checked:r,onCheckedChange:a}){let o=(0,t.useId)(),s=(0,t.useId)(),{title:c,description:l}=n.categories[e];return(0,i.jsxs)(I,{value:e,children:[(0,i.jsxs)(L,{children:[(0,i.jsx)(R,{children:(0,i.jsx)(`span`,{id:o,children:c})}),(0,i.jsx)(N,{"aria-labelledby":o,"aria-describedby":l?s:void 0,checked:r,disabled:e===`necessary`,onCheckedChange:a})]}),(0,i.jsx)(z,{keepMounted:!0,children:l&&(0,i.jsx)(`p`,{id:s,className:B.CategoryDescription,children:l})})]})}function Z({open:n,consent:r,copy:a,resolveHref:o,onAcceptAll:s,onAcceptNecessary:c,onSave:l,onClose:u}){let d=r!==null,[f,p]=(0,t.useState)(()=>Y(r)),[m,g]=(0,t.useState)(n);return n!==m&&(g(n),n&&p(Y(r))),(0,i.jsx)(x,{open:n,onOpenChange:e=>{!e&&d&&u()},disablePointerDismissal:!d,children:(0,i.jsxs)(S,{children:[(0,i.jsx)(C,{}),(0,i.jsx)(w,{children:(0,i.jsxs)(T,{fullScreenOnMobile:!0,size:`md`,children:[(0,i.jsxs)(E,{children:[(0,i.jsx)(D,{children:a.modalTitle}),d&&(0,i.jsx)(j,{label:a.closeIconLabel})]}),(0,i.jsxs)(k,{children:[(0,i.jsx)(O,{render:(0,i.jsx)(`div`,{}),className:B.Intro,children:(0,i.jsx)(J,{nodes:a.intro,resolveHref:o})}),(0,i.jsx)(F,{variant:`solid`,iconPosition:`start`,multiple:!0,className:B.Categories,children:e.l.map(e=>(0,i.jsx)(X,{category:e,copy:a,checked:f[e],onCheckedChange:t=>p(n=>({...n,[e]:t}))},e))})]}),(0,i.jsxs)(A,{className:B.Actions,children:[(0,i.jsx)(h,{onClick:s,color:`secondary`,size:`sm`,children:a.btnAcceptAll}),(0,i.jsx)(h,{onClick:c,color:`secondary`,size:`sm`,children:a.btnAcceptNecessary}),(0,i.jsx)(h,{variant:`outline`,color:`secondary`,size:`sm`,className:B.Save,onClick:()=>l(e.l.filter(e=>f[e])),children:a.btnSaveSettings})]})]})})]})})}var Q=(0,t.createContext)(null);function $({market:n,copy:r,resolveHref:a,children:o}){let{consent:s,settingsOpen:c,ready:l}=(0,t.useSyncExternalStore)(e.c,e.i,e.r);(0,t.useEffect)(()=>{e.a({market:n})},[]);let u=(0,t.useMemo)(()=>({consent:s,openSettings:e.o}),[s]);return(0,i.jsxs)(Q.Provider,{value:u,children:[o,l&&(0,i.jsx)(Z,{open:c,consent:s,copy:r,resolveHref:a,onAcceptAll:()=>e.s(`all`),onAcceptNecessary:()=>e.s([]),onSave:e.s,onClose:e.t})]})}function ee(){let e=(0,t.useContext)(Q);if(!e)throw Error(`useCookieConsent must be used inside a CookieConsentProvider.`);return e}exports.CookieConsentProvider=$,exports.useCookieConsent=ee;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});require('./cookie-consent.css');const e=require("./cookie-consent-core-fntGUdFt.cjs");let t=require("react"),n=require("@base-ui/react/button"),r=require("@base-ui/react/use-render"),i=require("react/jsx-runtime"),a=require("@base-ui/react/dialog"),o=require("lucide-react"),s=require("@base-ui/react/switch"),c=require("@base-ui/react/accordion");var l=(e,t)=>n=>[e,typeof t==`function`?t(n):t].filter(Boolean).join(` `),u={Button:`_Button_1d72q_1`,IconButton:`_IconButton_1d72q_125`,Spinner:`_Spinner_1d72q_150`,"button-spin":`_button-spin_1d72q_1`,SrOnly:`_SrOnly_1d72q_168`},d=e=>(0,t.isValidElement)(e)&&(e.props.href!=null||e.props.to!=null),f=e=>e.preventDefault();function p({loading:e=!1,disabled:t,className:a,render:o,nativeButton:s,focusableWhenDisabled:c,ref:l,...u}){let p=!!(t||e),m=d(o),h={"aria-busy":e||void 0,"data-loading":e||void 0};return(0,r.useRender)({enabled:m,render:m?o:void 0,ref:l,defaultTagName:`a`,props:{...u,...h,"aria-disabled":p||void 0,"data-disabled":p?``:void 0,className:typeof a==`function`?a({disabled:p}):a,onClick:p?f:u.onClick}})||(0,i.jsx)(n.Button,{...u,...h,ref:l,render:o,nativeButton:s,focusableWhenDisabled:c,disabled:p,className:a})}function m({variant:e=`solid`,color:t=`primary`,size:n=`md`,className:r,...a}){return(0,i.jsx)(p,{...a,"data-variant":e,"data-color":t,"data-size":n,className:l(u.Button,r)})}function h({startIcon:e,endIcon:t,loading:n=!1,loadingLabel:r,children:a,...o}){return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(m,{...o,loading:n,"data-start-icon":n||e!=null||void 0,"data-end-icon":t!=null||void 0,children:[n?(0,i.jsx)(`span`,{className:u.Spinner,"aria-hidden":!0}):e,a,t]}),r!=null&&(0,i.jsx)(`span`,{role:`status`,className:u.SrOnly,children:n?r:null})]})}var g={Backdrop:`_Backdrop_1mady_8`,Viewport:`_Viewport_1mady_22`,Popup:`_Popup_1mady_38`,Header:`_Header_1mady_78`,Title:`_Title_1mady_88`,Description:`_Description_1mady_97`,Content:`_Content_1mady_111`,Footer:`_Footer_1mady_119`,CloseButton:`_CloseButton_1mady_135`},_=(0,t.createContext)(`no`),v=()=>(0,t.useContext)(_);function y(e){return function(){let t=v(),n={};return Object.keys(e).forEach(r=>{let i=e[r];n[r]=i[t]??i.no}),n}}var b=y({close:{no:`Lukk`,se:`Stäng`,fi:`Sulje`,es:`Cerrar`}}),x=a.Dialog.Root;a.Dialog.Trigger;var S=a.Dialog.Portal;function C({className:e,...t}){return(0,i.jsx)(a.Dialog.Backdrop,{...t,className:l(g.Backdrop,e)})}function w({className:e,...t}){return(0,i.jsx)(a.Dialog.Viewport,{...t,className:l(g.Viewport,e)})}function T({size:e=`sm`,fullScreenOnMobile:t,className:n,...r}){return(0,i.jsx)(a.Dialog.Popup,{...r,"data-size":e,"data-full-screen-on-mobile":t||void 0,className:l(g.Popup,n)})}function E({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Header,e].filter(Boolean).join(` `)})}function D({className:e,...t}){return(0,i.jsx)(a.Dialog.Title,{...t,className:l(g.Title,e)})}function O({className:e,...t}){return(0,i.jsx)(a.Dialog.Description,{...t,className:l(g.Description,e)})}function k({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Content,e].filter(Boolean).join(` `)})}function A({className:e,...t}){return(0,i.jsx)(`div`,{...t,className:[g.Footer,e].filter(Boolean).join(` `)})}a.Dialog.Close;function j({label:e,className:t,...n}){let r=b();return(0,i.jsx)(a.Dialog.Close,{...n,"aria-label":e??r.close,className:l(g.CloseButton,t),children:(0,i.jsx)(o.X,{size:20,"aria-hidden":!0})})}var M={Switch:`_Switch_9c9ji_7`,Thumb:`_Thumb_9c9ji_36`};function N({className:e,...t}){return(0,i.jsx)(s.Switch.Root,{...t,className:l(M.Switch,e),children:(0,i.jsx)(s.Switch.Thumb,{className:M.Thumb})})}var P={Root:`_Root_18gqk_13`,Item:`_Item_18gqk_10`,Header:`_Header_18gqk_10`,Trigger:`_Trigger_18gqk_95`,Label:`_Label_18gqk_136`,Icon:`_Icon_18gqk_140`,Panel:`_Panel_18gqk_158`,Content:`_Content_18gqk_169`};function F({variant:e=`outline`,iconPosition:t=`end`,className:n,...r}){return(0,i.jsx)(c.Accordion.Root,{...r,"data-variant":e,"data-icon-position":t,className:l(P.Root,n)})}function I({className:e,...t}){return(0,i.jsx)(c.Accordion.Item,{...t,className:l(P.Item,e)})}function L({className:e,...t}){return(0,i.jsx)(c.Accordion.Header,{...t,className:l(P.Header,e)})}function R({children:e,className:t,...n}){return(0,i.jsxs)(c.Accordion.Trigger,{...n,className:l(P.Trigger,t),children:[(0,i.jsx)(`span`,{className:P.Label,children:e}),(0,i.jsx)(o.ChevronDown,{className:P.Icon,size:20,"aria-hidden":!0})]})}function z({children:e,className:t,...n}){return(0,i.jsx)(c.Accordion.Panel,{...n,className:l(P.Panel,t),children:(0,i.jsx)(`div`,{className:P.Content,children:e})})}var B={Intro:`_Intro_nxwj4_7`,Categories:`_Categories_nxwj4_39`,CategoryDescription:`_CategoryDescription_nxwj4_43`,Actions:`_Actions_nxwj4_52`,Save:`_Save_nxwj4_63`},V=`https://relative.invalid`;function H(e,t){try{return new URL(e,t)}catch{return null}}function U(e){let t=e.trim();if(!t)return!1;let n=H(t);return n?n.protocol===`https:`||n.protocol===`mailto:`:H(t,V)?.origin===V}function W({href:e,resolveHref:t=e=>e,children:n}){let r=t(e);return!r||!U(r)?(0,i.jsx)(i.Fragment,{children:n}):(0,i.jsx)(`a`,{href:r.trim(),target:`_blank`,rel:`noopener noreferrer`,children:n})}function G({node:e}){let t=e.text;return e.underline&&(t=(0,i.jsx)(`u`,{children:t})),e.italic&&(t=(0,i.jsx)(`em`,{children:t})),e.bold&&(t=(0,i.jsx)(`strong`,{children:t})),(0,i.jsx)(i.Fragment,{children:t})}function K({nodes:e,resolveHref:t}){return(0,i.jsx)(i.Fragment,{children:(e??[]).map((e,n)=>e.type===`text`?(0,i.jsx)(G,{node:e},n):e.type===`link`?(0,i.jsx)(W,{href:e.url??``,resolveHref:t,children:(e.children??[]).filter(e=>e.type===`text`).map((e,t)=>(0,i.jsx)(G,{node:e},t))},n):null)})}function q({node:e,resolveHref:t}){let n=e.format===`ordered`?`ol`:`ul`;return(0,i.jsx)(n,{children:(e.children??[]).map((e,n)=>e.type===`list`?(0,i.jsx)(`li`,{children:(0,i.jsx)(q,{node:e,resolveHref:t})},n):e.type===`list-item`?(0,i.jsx)(`li`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})},n):null)})}function J({nodes:e,resolveHref:t}){return(0,i.jsx)(i.Fragment,{children:e.map((e,n)=>{switch(e.type){case`paragraph`:return(0,i.jsx)(`p`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})},n);case`heading`:return(0,i.jsx)(`p`,{children:(0,i.jsx)(`strong`,{children:(0,i.jsx)(K,{nodes:e.children,resolveHref:t})})},n);case`list`:return(0,i.jsx)(q,{node:e,resolveHref:t},n);default:return null}})})}function Y(e){return{necessary:!0,preferences:e?.preferences??!1,analytics:e?.analytics??!1,marketing:e?.marketing??!1}}function X({category:e,copy:n,checked:r,onCheckedChange:a}){let o=(0,t.useId)(),s=(0,t.useId)(),{title:c,description:l}=n.categories[e];return(0,i.jsxs)(I,{value:e,children:[(0,i.jsxs)(L,{children:[(0,i.jsx)(R,{children:(0,i.jsx)(`span`,{id:o,children:c})}),(0,i.jsx)(N,{"aria-labelledby":o,"aria-describedby":l?s:void 0,checked:r,disabled:e===`necessary`,onCheckedChange:a})]}),(0,i.jsx)(z,{keepMounted:!0,children:l&&(0,i.jsx)(`p`,{id:s,className:B.CategoryDescription,children:l})})]})}function Z({open:n,consent:r,copy:a,resolveHref:o,onAcceptAll:s,onAcceptNecessary:c,onSave:l,onClose:u}){let d=r!==null,[f,p]=(0,t.useState)(()=>Y(r)),[m,g]=(0,t.useState)(n);return n!==m&&(g(n),n&&p(Y(r))),(0,i.jsx)(x,{open:n,onOpenChange:e=>{!e&&d&&u()},disablePointerDismissal:!d,children:(0,i.jsxs)(S,{children:[(0,i.jsx)(C,{}),(0,i.jsx)(w,{children:(0,i.jsxs)(T,{fullScreenOnMobile:!0,size:`md`,children:[(0,i.jsxs)(E,{children:[(0,i.jsx)(D,{children:a.modalTitle}),d&&(0,i.jsx)(j,{label:a.closeIconLabel})]}),(0,i.jsxs)(k,{children:[(0,i.jsx)(O,{render:(0,i.jsx)(`div`,{}),className:B.Intro,children:(0,i.jsx)(J,{nodes:a.intro,resolveHref:o})}),(0,i.jsx)(F,{variant:`solid`,iconPosition:`start`,multiple:!0,className:B.Categories,children:e.l.map(e=>(0,i.jsx)(X,{category:e,copy:a,checked:f[e],onCheckedChange:t=>p(n=>({...n,[e]:t}))},e))})]}),(0,i.jsxs)(A,{className:B.Actions,children:[(0,i.jsx)(h,{onClick:s,color:`secondary`,size:`sm`,children:a.btnAcceptAll}),(0,i.jsx)(h,{onClick:c,color:`secondary`,size:`sm`,children:a.btnAcceptNecessary}),(0,i.jsx)(h,{variant:`outline`,color:`secondary`,size:`sm`,className:B.Save,onClick:()=>l(e.l.filter(e=>f[e])),children:a.btnSaveSettings})]})]})})]})})}var Q=(0,t.createContext)(null);function $({market:n,copy:r,resolveHref:a,children:o}){let{consent:s,settingsOpen:c,ready:l}=(0,t.useSyncExternalStore)(e.c,e.i,e.r);(0,t.useEffect)(()=>{e.a({market:n})},[]);let u=(0,t.useMemo)(()=>({consent:s,openSettings:e.o}),[s]);return(0,i.jsxs)(Q.Provider,{value:u,children:[o,l&&(0,i.jsx)(Z,{open:c,consent:s,copy:r,resolveHref:a,onAcceptAll:()=>e.s(`all`),onAcceptNecessary:()=>e.s([]),onSave:e.s,onClose:e.t})]})}function ee(){let e=(0,t.useContext)(Q);if(!e)throw Error(`useCookieConsent must be used inside a CookieConsentProvider.`);return e}exports.CookieConsentProvider=$,exports.useCookieConsent=ee;
2
2
  //# sourceMappingURL=cookie-consent-react.cjs.map
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { a as e, c as t, i as n, l as r, o as i, r as a, s as o, t as s } from "./cookie-consent-core-mwVmy5nZ.mjs";
2
+ import { a as e, c as t, i as n, l as r, o as i, r as a, s as o, t as s } from "./cookie-consent-core-lX0QAEAo.mjs";
3
3
  import { createContext as c, isValidElement as l, useContext as u, useEffect as d, useId as f, useMemo as p, useState as m, useSyncExternalStore as h } from "react";
4
4
  import { Button as g } from "@base-ui/react/button";
5
5
  import { useRender as _ } from "@base-ui/react/use-render";
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./cookie-consent-core-C4MP7GlV.cjs");exports.COOKIE_CONSENT_CATEGORIES=e.l,exports.COOKIE_CONSENT_REVISION=e.u,exports.getConsentState=e.n,exports.initCookieConsent=e.a,exports.openCookieSettings=e.o,exports.setConsent=e.s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./cookie-consent-core-fntGUdFt.cjs");exports.COOKIE_CONSENT_CATEGORIES=e.l,exports.COOKIE_CONSENT_REVISION=e.u,exports.getConsentState=e.n,exports.initCookieConsent=e.a,exports.openCookieSettings=e.o,exports.setConsent=e.s;
@@ -1,2 +1,2 @@
1
- import { a as e, l as t, n, o as r, s as i, u as a } from "./cookie-consent-core-mwVmy5nZ.mjs";
1
+ import { a as e, l as t, n, o as r, s as i, u as a } from "./cookie-consent-core-lX0QAEAo.mjs";
2
2
  export { t as COOKIE_CONSENT_CATEGORIES, a as COOKIE_CONSENT_REVISION, n as getConsentState, e as initCookieConsent, r as openCookieSettings, i as setConsent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leabankab/component-library",
3
- "version": "8.1.0",
3
+ "version": "8.2.0",
4
4
  "description": "@leabankab/component-library — Lea Bank's React component library.",
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -106,7 +106,6 @@
106
106
  "devDependencies": {
107
107
  "@changesets/changelog-git": "^0.2.1",
108
108
  "@changesets/cli": "^2.31.1",
109
- "@chromatic-com/storybook": "^5.2.1",
110
109
  "@emotion/react": "^11.14.0",
111
110
  "@emotion/styled": "^11.14.1",
112
111
  "@eslint/js": "^9.39.5",
@@ -1,2 +0,0 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));let c=require("vanilla-cookieconsent");c=s(c);var l=3,u=[`necessary`,`preferences`,`analytics`,`marketing`],d={se:`leabank.se`,fi:`leabank.fi`,no:`leabank.no`,es:`leabank.es`},f=`cc_cookie`;function p(e,t){let n=d[t],r=e.toLowerCase();return r===n||r.endsWith(`.${n}`)?n:void 0}function m(){document.cookie=`${f}=; path=/; max-age=0`}var h={consent:null,settingsOpen:!1,ready:!1},g=!1,_=h,v=new Set;function y(e){_={..._,...e},v.forEach(e=>e())}function b(){if(typeof window>`u`||!c.validConsent())return null;let e=new Set(c.getUserPreferences().acceptedCategories);return Object.fromEntries(u.map(t=>[t,e.has(t)]))}function x({market:e,onConsentChange:t}){if(typeof window>`u`||g)return;g=!0;let n=p(window.location.hostname,e);n&&m();let r=()=>{let e=b();y({consent:e}),e&&t?.(e)};c.run({root:document.createElement(`div`),autoShow:!1,language:{default:`en`,translations:{en:{consentModal:{},preferencesModal:{sections:[]}}}},revision:3,cookie:{name:f,sameSite:`Lax`,secure:!0,...n&&{domain:n}},categories:{necessary:{enabled:!0,readOnly:!0},preferences:{enabled:!1,readOnly:!1},analytics:{enabled:!1,readOnly:!1,autoClear:{cookies:[{name:/^(_ga|_gid|_gat)/}]}},marketing:{enabled:!1,readOnly:!1,autoClear:{cookies:[{name:/^(_fbp|_fbc)/},{name:/^(_gcl_)/}]}}},onFirstConsent:r,onChange:r}).then(()=>{let e=b();y({consent:e,ready:!0,settingsOpen:_.settingsOpen||e===null}),e&&t?.(e)})}function S(e){_.ready&&(c.acceptCategory(e===`all`?`all`:[`necessary`,...e.filter(e=>e!==`necessary`)]),y({consent:b(),settingsOpen:!1}))}function C(){typeof window>`u`||y({settingsOpen:!0})}function w(){_.consent!==null&&y({settingsOpen:!1})}function T(e){return v.add(e),()=>{v.delete(e)}}function E(){return _}function D(){return h}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return l}});
2
- //# sourceMappingURL=cookie-consent-core-C4MP7GlV.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cookie-consent-core-C4MP7GlV.cjs","names":[],"sources":["../src/cookie-consent/constants.ts","../src/cookie-consent/domain.ts","../src/cookie-consent/core.ts"],"sourcesContent":["/**\n * Bumping the revision invalidates every visitor's consent on every Lea Bank\n * app at once. Only change it here, then release all apps together.\n */\nexport const COOKIE_CONSENT_REVISION = 3;\n\nexport const COOKIE_CONSENT_CATEGORIES = [\n \"necessary\",\n \"preferences\",\n \"analytics\",\n \"marketing\",\n] as const;\n\nexport type CookieConsentCategory = (typeof COOKIE_CONSENT_CATEGORIES)[number];\n\nexport type ConsentState = Record<CookieConsentCategory, boolean>;\n\nexport type Market = \"se\" | \"fi\" | \"no\" | \"es\";\n\nexport const MARKET_DOMAINS: Record<Market, string> = {\n se: \"leabank.se\",\n fi: \"leabank.fi\",\n no: \"leabank.no\",\n es: \"leabank.es\",\n};\n\nexport const COOKIE_NAME = \"cc_cookie\";\n","import { COOKIE_NAME, MARKET_DOMAINS, type Market } from \"./constants\";\n\n/**\n * Returns the market's registrable domain when the page is served from it or\n * one of its subdomains. Anywhere else (localhost, `*.azurewebsites.net`,\n * which is on the Public Suffix List) the browser would reject the cookie, so\n * it stays host-only.\n */\nexport function resolveCookieDomain(\n hostname: string,\n market: Market,\n): string | undefined {\n const domain = MARKET_DOMAINS[market];\n const host = hostname.toLowerCase();\n\n return host === domain || host.endsWith(`.${domain}`) ? domain : undefined;\n}\n\n/**\n * Erases a host-only consent cookie left by an earlier, domain-less setup.\n * Without this it coexists with the domain cookie under the same name and a\n * stale value can win. A cookie written without `domain` only matches the\n * host-only one, so the shared cookie is kept.\n */\nexport function clearHostOnlyCookie(): void {\n document.cookie = `${COOKIE_NAME}=; path=/; max-age=0`;\n}\n","import * as CookieConsent from \"vanilla-cookieconsent\";\n\nimport {\n COOKIE_CONSENT_CATEGORIES,\n COOKIE_CONSENT_REVISION,\n COOKIE_NAME,\n type ConsentState,\n type CookieConsentCategory,\n type Market,\n} from \"./constants\";\nimport { clearHostOnlyCookie, resolveCookieDomain } from \"./domain\";\n\nexport interface InitCookieConsentOptions {\n market: Market;\n /**\n * Called with the visitor's choice once the library has loaded, when there\n * is a valid consent, and again whenever the choice changes.\n */\n onConsentChange?: (state: ConsentState) => void;\n}\n\nexport interface ConsentSnapshot {\n consent: ConsentState | null;\n /** Whether the settings dialog should be shown. */\n settingsOpen: boolean;\n /** The stored consent has been read and the choice can be changed. */\n ready: boolean;\n}\n\nconst serverSnapshot: ConsentSnapshot = {\n consent: null,\n settingsOpen: false,\n ready: false,\n};\n\nlet started = false;\nlet snapshot = serverSnapshot;\nconst listeners = new Set<() => void>();\n\nfunction update(patch: Partial<ConsentSnapshot>) {\n snapshot = { ...snapshot, ...patch };\n listeners.forEach((listener) => listener());\n}\n\n/** `null` on the server, before the visitor has chosen, or after a revision bump. */\nexport function getConsentState(): ConsentState | null {\n if (typeof window === \"undefined\" || !CookieConsent.validConsent()) {\n return null;\n }\n\n const accepted = new Set(CookieConsent.getUserPreferences().acceptedCategories);\n return Object.fromEntries(\n COOKIE_CONSENT_CATEGORIES.map((category) => [category, accepted.has(category)]),\n ) as ConsentState;\n}\n\n/**\n * Reads the shared consent and keeps it up to date. Only the first call has an\n * effect, and it is a no-op on the server. It shows nothing by itself: the\n * settings dialog is rendered by `CookieConsentProvider`.\n */\nexport function initCookieConsent({\n market,\n onConsentChange,\n}: InitCookieConsentOptions): void {\n if (typeof window === \"undefined\" || started) return;\n started = true;\n\n const domain = resolveCookieDomain(window.location.hostname, market);\n if (domain) clearHostOnlyCookie();\n\n const applyConsent = () => {\n const consent = getConsentState();\n update({ consent });\n if (consent) onConsentChange?.(consent);\n };\n\n // The full build with its UI unused: `run` still builds an empty consent\n // modal when consent is missing, so it goes into a detached `root` that never\n // reaches the page. The UI-less core build of 3.1.0 can't be used, because\n // its `run` throws.\n void CookieConsent.run({\n root: document.createElement(\"div\"),\n autoShow: false,\n language: {\n default: \"en\",\n translations: { en: { consentModal: {}, preferencesModal: { sections: [] } } },\n },\n revision: COOKIE_CONSENT_REVISION,\n cookie: {\n name: COOKIE_NAME,\n sameSite: \"Lax\",\n secure: true,\n ...(domain && { domain }),\n },\n categories: {\n necessary: { enabled: true, readOnly: true },\n preferences: { enabled: false, readOnly: false },\n analytics: {\n enabled: false,\n readOnly: false,\n autoClear: { cookies: [{ name: /^(_ga|_gid|_gat)/ }] },\n },\n marketing: {\n enabled: false,\n readOnly: false,\n autoClear: {\n cookies: [{ name: /^(_fbp|_fbc)/ }, { name: /^(_gcl_)/ }],\n },\n },\n },\n onFirstConsent: applyConsent,\n onChange: applyConsent,\n }).then(() => {\n const consent = getConsentState();\n update({\n consent,\n ready: true,\n settingsOpen: snapshot.settingsOpen || consent === null,\n });\n if (consent) onConsentChange?.(consent);\n });\n}\n\n/**\n * Stores the visitor's choice. `necessary` is always kept. Does nothing until\n * `initCookieConsent` has read the stored consent.\n */\nexport function setConsent(\n categories: readonly CookieConsentCategory[] | \"all\",\n): void {\n if (!snapshot.ready) return;\n\n CookieConsent.acceptCategory(\n categories === \"all\"\n ? \"all\"\n : [\"necessary\", ...categories.filter((category) => category !== \"necessary\")],\n );\n update({ consent: getConsentState(), settingsOpen: false });\n}\n\n/** Opens the settings dialog of the mounted `CookieConsentProvider`. */\nexport function openCookieSettings(): void {\n if (typeof window === \"undefined\") return;\n update({ settingsOpen: true });\n}\n\n/** Closes the settings dialog, unless the visitor has yet to choose. */\nexport function closeCookieSettings(): void {\n if (snapshot.consent === null) return;\n update({ settingsOpen: false });\n}\n\nexport function subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nexport function getSnapshot(): ConsentSnapshot {\n return snapshot;\n}\n\nexport function getServerSnapshot(): ConsentSnapshot {\n return serverSnapshot;\n}\n"],"mappings":"kiBAIA,IAAa,EAA0B,EAE1B,EAA4B,CACvC,YACA,cACA,YACA,WACF,EAQa,EAAyC,CACpD,GAAI,aACJ,GAAI,aACJ,GAAI,aACJ,GAAI,YACN,EAEa,EAAc,YClB3B,SAAgB,EACd,EACA,EACoB,CACpB,IAAM,EAAS,EAAe,GACxB,EAAO,EAAS,YAAY,EAElC,OAAO,IAAS,GAAU,EAAK,SAAS,IAAI,G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AAS,CAAC,CAAE,KAAM,kBAAmB,CAAC,CAAE,CACvD,EACA,UAAW,CACT,QAAS,GACT,SAAU,GACV,UAAW,CACT,QAAS,CAAC,CAAE,KAAM,cAAe,EAAG,CAAE,KAAM,UAAW,CAAC,CAC1D,CACF,CACF,EACA,eAAgB,EAChB,SAAU,CACZ,CAAC,CAAC,CAAC,SAAW,CACZ,IAAM,EAAU,EAAgB,EAChC,EAAO,CACL,UACA,MAAO,GACP,aAAc,EAAS,cAAgB,IAAY,IACrD,CAAC,EACG,GAAS,IAAkB,CAAO,CACxC,CAAC,CACH,CAMA,SAAgB,EACd,EACM,CACD,EAAS,QAEd,EAAc,eACZ,IAAe,MACX,MACA,CAAC,YAAa,GAAG,EAAW,OAAQ,GAAa,IAAa,WAAW,CAAC,CAChF,EACA,EAAO,CAAE,QAAS,EAAgB,EAAG,aAAc,EAAM,CAAC,EAC5D,CAGA,SAAgB,GAA2B,CACrC,OAAO,OAAW,KACtB,EAAO,CAAE,aAAc,EAAK,CAAC,CAC/B,CAGA,SAAgB,GAA4B,CACtC,EAAS,UAAY,MACzB,EAAO,CAAE,aAAc,EAAM,CAAC,CAChC,CAEA,SAAgB,EAAU,EAAkC,CAE1D,OADA,EAAU,IAAI,CAAQ,MACT,CACX,EAAU,OAAO,CAAQ,CAC3B,CACF,CAEA,SAAgB,GAA+B,CAC7C,OAAO,CACT,CAEA,SAAgB,GAAqC,CACnD,OAAO,CACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"cookie-consent-core-mwVmy5nZ.mjs","names":[],"sources":["../src/cookie-consent/constants.ts","../src/cookie-consent/domain.ts","../src/cookie-consent/core.ts"],"sourcesContent":["/**\n * Bumping the revision invalidates every visitor's consent on every Lea Bank\n * app at once. Only change it here, then release all apps together.\n */\nexport const COOKIE_CONSENT_REVISION = 3;\n\nexport const COOKIE_CONSENT_CATEGORIES = [\n \"necessary\",\n \"preferences\",\n \"analytics\",\n \"marketing\",\n] as const;\n\nexport type CookieConsentCategory = (typeof COOKIE_CONSENT_CATEGORIES)[number];\n\nexport type ConsentState = Record<CookieConsentCategory, boolean>;\n\nexport type Market = \"se\" | \"fi\" | \"no\" | \"es\";\n\nexport const MARKET_DOMAINS: Record<Market, string> = {\n se: \"leabank.se\",\n fi: \"leabank.fi\",\n no: \"leabank.no\",\n es: \"leabank.es\",\n};\n\nexport const COOKIE_NAME = \"cc_cookie\";\n","import { COOKIE_NAME, MARKET_DOMAINS, type Market } from \"./constants\";\n\n/**\n * Returns the market's registrable domain when the page is served from it or\n * one of its subdomains. Anywhere else (localhost, `*.azurewebsites.net`,\n * which is on the Public Suffix List) the browser would reject the cookie, so\n * it stays host-only.\n */\nexport function resolveCookieDomain(\n hostname: string,\n market: Market,\n): string | undefined {\n const domain = MARKET_DOMAINS[market];\n const host = hostname.toLowerCase();\n\n return host === domain || host.endsWith(`.${domain}`) ? domain : undefined;\n}\n\n/**\n * Erases a host-only consent cookie left by an earlier, domain-less setup.\n * Without this it coexists with the domain cookie under the same name and a\n * stale value can win. A cookie written without `domain` only matches the\n * host-only one, so the shared cookie is kept.\n */\nexport function clearHostOnlyCookie(): void {\n document.cookie = `${COOKIE_NAME}=; path=/; max-age=0`;\n}\n","import * as CookieConsent from \"vanilla-cookieconsent\";\n\nimport {\n COOKIE_CONSENT_CATEGORIES,\n COOKIE_CONSENT_REVISION,\n COOKIE_NAME,\n type ConsentState,\n type CookieConsentCategory,\n type Market,\n} from \"./constants\";\nimport { clearHostOnlyCookie, resolveCookieDomain } from \"./domain\";\n\nexport interface InitCookieConsentOptions {\n market: Market;\n /**\n * Called with the visitor's choice once the library has loaded, when there\n * is a valid consent, and again whenever the choice changes.\n */\n onConsentChange?: (state: ConsentState) => void;\n}\n\nexport interface ConsentSnapshot {\n consent: ConsentState | null;\n /** Whether the settings dialog should be shown. */\n settingsOpen: boolean;\n /** The stored consent has been read and the choice can be changed. */\n ready: boolean;\n}\n\nconst serverSnapshot: ConsentSnapshot = {\n consent: null,\n settingsOpen: false,\n ready: false,\n};\n\nlet started = false;\nlet snapshot = serverSnapshot;\nconst listeners = new Set<() => void>();\n\nfunction update(patch: Partial<ConsentSnapshot>) {\n snapshot = { ...snapshot, ...patch };\n listeners.forEach((listener) => listener());\n}\n\n/** `null` on the server, before the visitor has chosen, or after a revision bump. */\nexport function getConsentState(): ConsentState | null {\n if (typeof window === \"undefined\" || !CookieConsent.validConsent()) {\n return null;\n }\n\n const accepted = new Set(CookieConsent.getUserPreferences().acceptedCategories);\n return Object.fromEntries(\n COOKIE_CONSENT_CATEGORIES.map((category) => [category, accepted.has(category)]),\n ) as ConsentState;\n}\n\n/**\n * Reads the shared consent and keeps it up to date. Only the first call has an\n * effect, and it is a no-op on the server. It shows nothing by itself: the\n * settings dialog is rendered by `CookieConsentProvider`.\n */\nexport function initCookieConsent({\n market,\n onConsentChange,\n}: InitCookieConsentOptions): void {\n if (typeof window === \"undefined\" || started) return;\n started = true;\n\n const domain = resolveCookieDomain(window.location.hostname, market);\n if (domain) clearHostOnlyCookie();\n\n const applyConsent = () => {\n const consent = getConsentState();\n update({ consent });\n if (consent) onConsentChange?.(consent);\n };\n\n // The full build with its UI unused: `run` still builds an empty consent\n // modal when consent is missing, so it goes into a detached `root` that never\n // reaches the page. The UI-less core build of 3.1.0 can't be used, because\n // its `run` throws.\n void CookieConsent.run({\n root: document.createElement(\"div\"),\n autoShow: false,\n language: {\n default: \"en\",\n translations: { en: { consentModal: {}, preferencesModal: { sections: [] } } },\n },\n revision: COOKIE_CONSENT_REVISION,\n cookie: {\n name: COOKIE_NAME,\n sameSite: \"Lax\",\n secure: true,\n ...(domain && { domain }),\n },\n categories: {\n necessary: { enabled: true, readOnly: true },\n preferences: { enabled: false, readOnly: false },\n analytics: {\n enabled: false,\n readOnly: false,\n autoClear: { cookies: [{ name: /^(_ga|_gid|_gat)/ }] },\n },\n marketing: {\n enabled: false,\n readOnly: false,\n autoClear: {\n cookies: [{ name: /^(_fbp|_fbc)/ }, { name: /^(_gcl_)/ }],\n },\n },\n },\n onFirstConsent: applyConsent,\n onChange: applyConsent,\n }).then(() => {\n const consent = getConsentState();\n update({\n consent,\n ready: true,\n settingsOpen: snapshot.settingsOpen || consent === null,\n });\n if (consent) onConsentChange?.(consent);\n });\n}\n\n/**\n * Stores the visitor's choice. `necessary` is always kept. Does nothing until\n * `initCookieConsent` has read the stored consent.\n */\nexport function setConsent(\n categories: readonly CookieConsentCategory[] | \"all\",\n): void {\n if (!snapshot.ready) return;\n\n CookieConsent.acceptCategory(\n categories === \"all\"\n ? \"all\"\n : [\"necessary\", ...categories.filter((category) => category !== \"necessary\")],\n );\n update({ consent: getConsentState(), settingsOpen: false });\n}\n\n/** Opens the settings dialog of the mounted `CookieConsentProvider`. */\nexport function openCookieSettings(): void {\n if (typeof window === \"undefined\") return;\n update({ settingsOpen: true });\n}\n\n/** Closes the settings dialog, unless the visitor has yet to choose. */\nexport function closeCookieSettings(): void {\n if (snapshot.consent === null) return;\n update({ settingsOpen: false });\n}\n\nexport function subscribe(listener: () => void): () => void {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n}\n\nexport function getSnapshot(): ConsentSnapshot {\n return snapshot;\n}\n\nexport function getServerSnapshot(): ConsentSnapshot {\n return serverSnapshot;\n}\n"],"mappings":";;AAIA,IAAa,IAA0B,GAE1B,IAA4B;CACvC;CACA;CACA;CACA;AACF,GAQa,IAAyC;CACpD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN,GAEa,IAAc;;;AClB3B,SAAgB,EACd,GACA,GACoB;CACpB,IAAM,IAAS,EAAe,IACxB,IAAO,EAAS,YAAY;CAElC,OAAO,MAAS,KAAU,EAAK,SAAS,IAAI,GAAQ,IAAI,IAAS,KAAA;AACnE;AAQA,SAAgB,IAA4B;CAC1C,SAAS,SAAS,GAAG,EAAY;AACnC;;;ACGA,IAAM,IAAkC;CACtC,SAAS;CACT,cAAc;CACd,OAAO;AACT,GAEI,IAAU,IACV,IAAW,GACT,oBAAY,IAAI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