/* OK ITHAKI V249526R10F16 — PLUS CLEANUP / EL-EN ONLY / PROFILE BACKUP WARNING / COMMUNITY SHARE DEDUP AUDIT */
(function(){
'use strict';
if(window.__ITHAKI_V249526R10F16_OWNER__)return;
window.__ITHAKI_V249526R10F16_OWNER__={version:'V249526R10F16',plusCleanup:true,elEnOnly:true,noFirstRunMemberWindow:true,profileBackupWarning:true,communityShareDedupeAudit:true,at:Date.now()};
window.PLUS_LIGHTHOUSE_REMOVED_R10F16=true;
window.PLUS_SINGLE_ANONYMOUS_WALL_R10F16=true;
window.ONLY_EL_EN_LANGUAGES_R10F16=true;
window.FIRST_RUN_MEMBER_WINDOW_REMOVED_R10F16=true;
window.PROFILE_BACKUP_EXPLICIT_WARNING_R10F16=true;
window.COMMUNITY_SHARE_DEDUP_AUDIT_R10F16=true;
window.COMMUNITY_NO_PERIODIC_AUDIT_R10F16=true;
window.COMMUNITY_DOM_AUDIT_DISABLED_R10F18=true;
const $=id=>document.getElementById(id), I=()=>window.ITH=window.ITH||{};
const norm=v=>String(v||'').normalize('NFD').replace(/[\u0300-\u036f]/g,'').replace(/\s+/g,' ').trim().toLocaleLowerCase('el');
function forceElEn(){
 let c='el';try{c=String(localStorage.getItem('ith_global_language_r10f7')||localStorage.getItem('ith_ui_lang_v249141')||localStorage.getItem('ith_ui_lang')||'el').toLowerCase().split('-')[0]}catch(_e){}
 if(c!=='el'&&c!=='en')c='el';
 try{for(const k of ['ith_global_language_r10f7','ith_ui_lang_v249141','ith_ui_lang','ith_target_lang'])localStorage.setItem(k,c);localStorage.setItem('ith_global_language_selected_r10f7','1');localStorage.setItem('ith_r10f9_classic_entry_done','1')}catch(_e){}
 document.documentElement.lang=c;
 document.querySelectorAll('#ith537LanguageModal [data-r10f7-lang],#ithR10F9Profile #ithR10F9Lang option,#ith537FullProfileModal #ith537ProfileLanguage option,#ithLexicon1R10F8 #lexR8Other option').forEach(x=>{const v=String(x.dataset.r10f7Lang||x.value||'');if(v&&v!=='el'&&v!=='en')x.remove()});
}
function removeStartup(){
 document.querySelectorAll('#ithR10F9Entry,#ith537LanguageModal[data-first-run="1"]').forEach(x=>x.remove());
 try{localStorage.setItem('ith_r10f9_classic_entry_done','1');localStorage.setItem('ith_global_language_selected_r10f7','1')}catch(_e){}
}
function cleanPlus(){
 const p=$('plusSheet');if(!p)return;
 p.querySelectorAll('[data-r9plus="lighthouse"],[data-r8plus="lighthouse"],[data-act="light"],[data-act="lighthouse"]').forEach(x=>x.remove());
 p.querySelectorAll('button').forEach(x=>{const t=norm((x.textContent||'')+' '+(x.title||''));if(/(^| )φαρος($| )|lighthouse|φως \/ φαρος/.test(t))x.remove()});
 const candidates=[...p.querySelectorAll('[data-r9plus="anon_wall"],[data-r8plus="anon_wall"],[data-act="anon_wall"]')];
 const textual=[...p.querySelectorAll('button')].filter(x=>/ανωνυμος τοιχος|anonymous wall/.test(norm(x.textContent||'')));
 const all=[...new Set([...candidates,...textual])];
 if(all.length>1){const keep=all.find(x=>x.matches('[data-r9plus="anon_wall"]'))||all[0];all.forEach(x=>{if(x!==keep)x.remove()})}
 p.dataset.r10f16Clean='1';
}
function communityKey(card){
 const id=String(card.dataset.spaceId||card.dataset.subroomId||card.getAttribute('data-id')||'').trim();
 const title=norm(card.querySelector('h1,h2,h3,h4,.who b,strong,b')?.textContent||card.textContent||'');
 return title?'title:'+title:(id?'id:'+id:'');
}
function dedupeCommunityDom(){
 const root=$('ith516List')||document.querySelector('#spacesPage [data-community-list],#spacesPage .ith516List');if(!root)return 0;
 const seen=new Set();let removed=0;
 root.querySelectorAll(':scope > [data-space-id],:scope > [data-subroom-id],:scope > .ith516Row,:scope > .communityCard,:scope > .spaceCard,:scope > .roomCard').forEach(card=>{const k=communityKey(card);if(!k)return;if(seen.has(k)){card.remove();removed++}else seen.add(k)});
 root.dataset.r10f16Dedupe=String(removed);return removed;
}
const SHARE_IDS=['ith526R3ShareChoice','ith526R2ShareChoice','ith524ShareChoice','ith523ShareChoice','ith509ShareChoice','ithShareChoice'];
function dedupeSharePanels(){
 const panels=[];for(const id of SHARE_IDS)document.querySelectorAll('#'+id).forEach(x=>panels.push(x));
 if(panels.length<2)return 0;const keep=document.getElementById('ith526R3ShareChoice')||panels[panels.length-1];let n=0;panels.forEach(x=>{if(x!==keep){x.remove();n++}});document.documentElement.dataset.r10f16SharePanels=String(n);return n;
}
let lastShareButton=null,lastShareAt=0;
function shareClickGuard(e){
 const b=e.target.closest?.('#spacesPage button,#memberMenu button');if(!b)return;
 const t=norm((b.textContent||'')+' '+(b.title||'')+' '+(b.getAttribute('aria-label')||''));
 if(!/κοινοποι|share|📤/.test(t))return;
 const now=Date.now();if(lastShareButton===b&&now-lastShareAt<900){e.preventDefault();e.stopImmediatePropagation();return false}lastShareButton=b;lastShareAt=now;
}
function audit(){forceElEn();removeStartup();cleanPlus();dedupeSharePanels();document.documentElement.setAttribute('data-ithaki-r10f16','plus-el-en-profile-backup-no-community-dom')}
function install(){document.addEventListener('click',shareClickGuard,true);const mo=new MutationObserver(()=>{clearTimeout(mo._t);mo._t=setTimeout(audit,40)});mo.observe(document.documentElement,{subtree:true,childList:true});audit();I().auditCommunitiesR10F16=audit;try{localStorage.setItem('ith_frontend_build','V249526R10F16-plus-el-en-profile-backup-community-audit')}catch(_e){}}
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',install,{once:true});else install();
})();
