import{ALL_LOCALES as e}from"@intlayer/types/allLocales";const t=e=>{let t=e.split(`.`);if(t.length<=2)return e;let n=t.slice(-2).join(`.`);return[`co.uk`,`com.au`,`com.br`,`com.tr`,`co.jp`,`com.cn`,`com.mx`,`com.ar`,`com.co`].includes(n)&&t.length>=3?t.slice(-3).join(`.`):t.slice(-2).join(`.`)},n=async(n,r)=>{let i=new URL(r).hostname,a=t(i),o=await n.$$eval(`a[href]`,e=>e.map(e=>({href:e.getAttribute(`href`),text:e.innerText?.trim()||``}))),s=0,c=0,l=[],u=[],d=[];for(let{href:n,text:i}of o)if(!(!n||n.startsWith(`#`)||n.startsWith(`javascript:`)))try{let o=new URL(n,r),f=o.hostname;if(t(f)===a){c++;let t=o.pathname;t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1));let r=o.origin+t+o.search;d.push(r);let a=o.pathname.toLowerCase(),f=o.hostname.toLowerCase(),p=Object.values(e).some(e=>{let t=e.toLowerCase();return a.startsWith(`/${t}/`)||a===`/${t}`||a.includes(`/${t}/`)}),m=Object.values(e).some(e=>{let t=e.toLowerCase();return f.startsWith(`${t}.`)||f.includes(`.${t}.`)}),h=`\`\`\`\`html\n<a href='${n}'>${i||`Link`}</a>\n\`\`\``;p||m?(s++,l.push(h)):u.push(h)}}catch{}let f=s>0,p=c===0||s===c,m=`none`;return f&&(m=`path-based`),{urlStructureLocalized:m,hasLocalizedLinks:f,allAnchorsLocalized:p,totalInternalCount:c,localizedCount:s,localizedLinks:l,nonLocalizedLinks:u,internalUrls:Array.from(new Set(d))}};export{n as analyzeUrlStructure};
//# sourceMappingURL=analyzeUrlStructure.mjs.map