function n(n){if(!n?.languages?.length){return[]}const e=Array.from(document.querySelectorAll('link[rel="alternate"][hreflang]'));const r=e.map((n=>{let e=n.getAttribute("hreflang")??"";if(e.indexOf("en-")!==-1||e.indexOf("en_")!==-1){e=e.substring(0,2)}return e}));if(!r.length){return[...n.languages]}return n.languages.filter((n=>r.includes(n.twoLetterISOLanguageName)))}function e(n,e,r){if(r){return null}const t=document.querySelector(`link[rel="alternate"][hreflang="${n.twoLetterISOLanguageName}"]`);if(t){return t.getAttribute("href")}const u=e?.url??"/";return u+(u.lastIndexOf("/")!==u.length-1?"/":"")+n.twoLetterISOLanguageName}function r(n,e,r,t){if(t){return n}if(n[0]?.name===e.menuHomeButton){return n}return[{href:r,name:e.menuHomeButton,id:"homelink",open:false,selected:false,children:[]},...n]}function t(n){return"promo-"+n.linkText.replace(/[^A-Za-z0-9.\\\/]/gim,"")}function u(n){return n.length>0?n[n.length-1]:null}function s(n){if(n.length<=1){return[]}return n.slice(0,-1)}function i(n){const e=u(n);const r=s(n);const t=r.map(((n,e)=>({index:e,label:n.name,href:n.href||undefined,root:n})));return{hasMenuSwitching:t.length>0,modeRoots:r,menuModeOptions:t,sharedRoot:e,sharedItems:e?.children??[]}}function a(n,e){return n.modeRoots[e]??n.modeRoots[0]??null}function o(n,e){const r=i(n);return a(r,e)}function c(n,e){const r=a(n,e);if(!r){return{primaryItems:n.sharedItems,sharedItems:[]}}return{primaryItems:r?.children??[],sharedItems:n.sharedItems}}function f(n,e){const r=i(n);return c(r,e)}function l(n,e){const r=c(n,e);return[...r.primaryItems,...r.sharedItems]}function h(n){switch(n?.toLowerCase()){case"business":return"business";case"private":return"private";default:return"private"}}function d(n){switch(h(n)){case"private":return"light";case"business":return"dark";default:return"light"}}function m(n,e){if(n){try{const e=JSON.parse(n);if(Array.isArray(e)){const n=e.filter((n=>typeof n==="string")).map((n=>h(n)));if(n.length>0){return n}}}catch(n){console.warn("[pn-marketweb-header] Invalid menu-themes value",n)}}if(!Array.isArray(e)){return[]}return e.map((n=>n?.root?.toggleTheme)).filter((n=>typeof n==="string")).map((n=>h(n)))}export{o as a,l as b,f as c,e as d,i as e,t as f,n as g,d as h,r as p,m as r};
//# sourceMappingURL=p-04f51418.js.map