/* OK ITHAKI V249526R10 — NOTIFICATIONS / CALLS / DEDUP / FORM BACK ARROWS */
(function(){
'use strict';
if(window.__ITHAKI_V249526R10_OWNER__)return;
window.__ITHAKI_V249526R10_OWNER__={version:'V249526R10',singleOpenClosedNotificationOwner:true,callSessionDedup:true,criticalRuntimeDedup:true,canonicalFormBackArrows:true,at:Date.now()};
const SINGLE_OPEN_CLOSED_NOTIFICATION_OWNER_R10=true,CALL_SESSION_NOTIFICATION_DEDUP_R10=true,FULL_RUNTIME_DUPLICATE_AUDIT_R10=true,CANONICAL_FORM_BACK_ARROWS_R10=true;
const I=()=>window.ITH=window.ITH||{},$=id=>document.getElementById(id),norm=s=>String(s||'').normalize('NFD').replace(/[\u0300-\u036f]/g,'').replace(/\s+/g,' ').trim().toLocaleLowerCase('el');
function visible(x){if(!x||!x.isConnected)return false;const s=getComputedStyle(x);return !x.hidden&&s.display!=='none'&&s.visibility!=='hidden'&&s.opacity!=='0'}
function clickFirst(root,selectors){for(const q of selectors){const b=root&&root.querySelector(q);if(b&&b!==root.querySelector('.ithR10BackArrow')){try{b.click();return true}catch(e){}}}return false}
function closeRoot(root){if(!root)return false;const id=root.id||'';try{if(id==='previewModal'&&window.state?.call&&typeof I().callBackArrowV249531==='function')return I().callBackArrowV249531();if(id==='memberMenu'&&typeof I().closeMember==='function')return I().closeMember();if(id==='plusSheet'){root.classList.remove('show');return false}if(id==='ith527ExternalOrganizer'&&typeof I().openExternalMessageCenterV249529==='function'){root.remove();document.body.classList.remove('ith527ExternalOpen');return false}if(clickFirst(root,['[data-r3-close]','[data-close]','[data-back]','.localCloseBtn','.closeBtn','button[aria-label="Κλείσιμο"]','button[title="Κλείσιμο"]']))return false;root.classList.remove('show','open','active');if(root.matches('[role="dialog"],.previewModal,.memberMenu'))root.removeAttribute('aria-modal')}catch(e){}return false}
function ensureBack(root){if(!root||!visible(root))return;const arrows=[...root.querySelectorAll(':scope > .ithR10BackArrow,:scope > header .ithR10BackArrow,:scope > .row .ithR10BackArrow')];arrows.slice(1).forEach(x=>x.remove());if(arrows.length)return;const existing=[...root.querySelectorAll('button')].find(b=>/^(←|‹|⬅|🔙)$/.test(String(b.textContent||'').trim()));if(existing){existing.classList.add('ithR10BackArrow');existing.setAttribute('aria-label','Επιστροφή');return}const b=document.createElement('button');b.type='button';b.className='icon ithR10BackArrow';b.textContent='←';b.setAttribute('aria-label','Επιστροφή');b.title='Επιστροφή';b.addEventListener('click',e=>{e.preventDefault();e.stopImmediatePropagation();closeRoot(root)},true);root.insertBefore(b,root.firstChild)}
function formRoots(){return [...document.querySelectorAll('#memberMenu.show,#previewModal.show,#plusSheet.show,#ith526NotificationCenter,#ith526NotificationSettings,#ith527ExternalOrganizer,#ithShareR3,[role="dialog"][aria-modal="true"],.commentPanel.show,.mediaViewer.show')].filter(visible)}
function dedupeButtons(root){if(!root)return;const groups=root.id==='plusSheet'?[root]:[...root.querySelectorAll(':scope > header,:scope > .row:first-child,.ith526Tabs,.ith517ToolGrid,.ith516PanelList,#ith519CommunityCommandBar')];for(const g of groups){const seen=new Set();[...g.querySelectorAll(':scope > button')].forEach(b=>{if(b.classList.contains('ithR10BackArrow'))return;const action=String(b.dataset.action||b.dataset.act||b.dataset.tab||b.dataset.r9plus||b.dataset.r8plus||b.getAttribute('onclick')||'').replace(/\s+/g,'');const key=action||norm(b.getAttribute('aria-label')||b.title||b.textContent);if(!key)return;if(seen.has(key))b.remove();else seen.add(key)})}}
function notificationKey(x){const explicit=String(x.dataset.notificationId||x.dataset.eventId||x.dataset.messageId||x.dataset.key||'').trim();if(explicit)return'exp:'+explicit;const app=norm(x.dataset.package||x.dataset.app||x.querySelector('[data-app],.appName')?.textContent);const title=norm(x.querySelector('b,strong,h3,.title')?.textContent);const body=norm(x.querySelector('p,.body,.message')?.textContent||x.textContent).slice(0,180);const t=String(x.dataset.createdAt||x.querySelector('time')?.getAttribute('datetime')||'').slice(0,16);return'app:'+app+'|'+title+'|'+body+'|'+t}
function dedupeNotifications(){const roots=[...document.querySelectorAll('#ith526NotificationCenter,#ith527ExternalOrganizer,[data-external-notification-list]')];for(const root of roots){const seen=new Set();const rows=[...root.querySelectorAll('.ith526Notice,[data-notification-id],[data-external-id],.externalNotice,.notificationRow')];for(const x of rows){const k=notificationKey(x);if(seen.has(k))x.remove();else seen.add(k)}}const bells=[...document.querySelectorAll('#ithNotifyFabV249238,.ithNotifyFabV249238,[data-notifications-fab]')];const keep=bells.find(x=>x.id==='ithNotifyFabV249238')||bells.find(visible)||bells[0];bells.forEach(x=>{if(x!==keep)x.remove()});if(keep)[...keep.querySelectorAll('.badge')].slice(1).forEach(x=>x.remove())}
function dedupeCriticalIds(){for(const id of ['ith526BilDock','ithNotifyFabV249238','ith527ExternalOrganizer','ithShareR3']){const a=[...document.querySelectorAll('#'+id)];if(a.length<2)continue;const keep=a.find(visible)||a[a.length-1];a.forEach(x=>{if(x!==keep)x.remove()})}const pm=$('previewModal');if(pm){[...pm.querySelectorAll('#callRemote')].slice(1).forEach(x=>x.remove());[...pm.querySelectorAll('#callLocal')].slice(1).forEach(x=>x.remove())}}
function audit(){dedupeCriticalIds();dedupeNotifications();for(const r of formRoots()){dedupeButtons(r);ensureBack(r)}document.documentElement.setAttribute('data-r10-runtime-audit','ok');window.__ITHAKI_R10_AUDIT__={bells:document.querySelectorAll('#ithNotifyFabV249238,.ithNotifyFabV249238,[data-notifications-fab]').length,bil:document.querySelectorAll('#ith526BilDock').length,externalCenters:document.querySelectorAll('#ith527ExternalOrganizer').length,arrows:document.querySelectorAll('.ithR10BackArrow').length,at:Date.now()}}
function install(){const st=document.createElement('style');st.id='ith531R10Css';st.textContent=`.ithR10BackArrow{position:relative!important;z-index:2147483600!important;min-width:40px!important;width:40px!important;height:40px!important;border-radius:13px!important;font-size:23px!important;font-weight:1000!important;background:rgba(5,25,39,.94)!important;color:#ffe39a!important;border:1px solid rgba(255,227,154,.45)!important;box-shadow:0 7px 20px rgba(0,0,0,.28)!important}#memberMenu>.ithR10BackArrow,#previewModal>.ithR10BackArrow,[role=dialog]>.ithR10BackArrow{position:absolute!important;top:10px!important;left:10px!important}`;if(!$('ith531R10Css'))document.head.appendChild(st);audit();new MutationObserver(()=>{clearTimeout(install.m);install.m=setTimeout(audit,55)}).observe(document.body,{childList:true,subtree:true});window.addEventListener('ithaki:page-changed',()=>setTimeout(audit,40));window.addEventListener('pageshow',audit);setInterval(audit,2500);document.documentElement.setAttribute('data-ithaki-v249526r10','notifications-calls-dedup-back-arrows');try{localStorage.setItem('ith_frontend_build','V249526R10-notifications-calls-dedup-back-arrows')}catch(e){}}
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',install,{once:true});else install();
})();
