/* OK ITHAKI V249499 - RUNTIME TRUTH OWNER */
(function(){'use strict';if(window.__ITHAKI_V249499_RUNTIME_OWNER__)return;window.__ITHAKI_V249499_RUNTIME_OWNER__={ownAvatarPosts:true,professionalAdminContact:true,storyAvatarPhoto:true,serverInbox:true};
const $=id=>document.getElementById(id),I=()=>window.ITH||{},S=()=>window.state||I().state||{};
const norm=v=>String(v||'').trim().toLowerCase();
function ownIds(){const s=S(),a=[s.device,s.device_id];try{a.push(localStorage.getItem('ith_device'),localStorage.getItem('ith_account_device_v249384'),localStorage.getItem('ith_professional_device_v249383'))}catch(e){}return new Set(a.map(norm).filter(Boolean))}
function ownNames(){const s=S(),a=[s.name,s.nickname];try{a.push(localStorage.getItem('ith_name'),localStorage.getItem('ith_profile_name'))}catch(e){}return new Set(a.map(norm).filter(x=>x&&x!=='μέλος'&&x!=='member'))}
function postInfo(el){const p=el&&el.closest?el.closest('#feedPage article[data-post],#feedPage [data-post][data-sender],#feedPage .mediaPost[data-post]'):null;if(!p)return null;const sender=String(p.dataset.sender||p.getAttribute('data-sender')||'');const pid=String(p.dataset.post||p.getAttribute('data-post')||'');let label='';const sm=p.querySelector('.feedAvatarOverlay small,.postHead b,.postAvatar+small');if(sm)label=sm.textContent||'';return{p,sender,pid,label}}
function isOwn(info,clicked){if(!info)return false;if(info.p.dataset.ownPost==='1')return true;if(ownIds().has(norm(info.sender)))return true;if(clicked&&/δημοσιεύσεις μου|my posts/i.test(clicked.getAttribute('title')||''))return true;if(info.label&&ownNames().has(norm(info.label)))return true;return false}
function openOwn(info){const ith=I(),id=info.sender||String(S().device||S().device_id||'');if(typeof ith.openMemberFeed==='function')return ith.openMemberFeed(id,info.pid||'');if(typeof window.openMemberFeed==='function')return window.openMemberFeed(id,info.pid||'');return false}
function avatarTarget(t){if(!t||!t.closest)return null;return t.closest('#feedPage .feedAvatarOverlay,#feedPage .leftActions .avatarDotWrap,#feedPage .leftActions .avatar,#feedPage .leftActions button,#feedPage .postHead .avatar,#feedPage .postHead button,#feedPage .postAvatar,#feedPage [class*="feedAvatar"]')}
document.addEventListener('click',function(e){const q=avatarTarget(e.target);if(!q)return;const info=postInfo(q);if(!isOwn(info,q))return;e.preventDefault();e.stopPropagation();if(e.stopImmediatePropagation)e.stopImmediatePropagation();openOwn(info);return false},true);
function forceProfessional(){const ith=I(),open=ith.openProfessionalCenterV249499||ith.openProfessionalCenterV249477,admin=ith.openDirectAdminContactV249499;if(typeof open==='function'){['openProfessionalCenterV249383','openProfessionalCenterV249384','openProfessionalCenterV249386','openProfessionalCenterFastV249392','openProfessionalCenterV249477','openProfessionalCenterV249499'].forEach(k=>ith[k]=open);document.querySelectorAll('#ithProQuick384,#ithOpenProfessional383,[data-open-professional]').forEach(b=>{b.onclick=open;b.removeAttribute('onclick')})}const profileBtn=$('ithOpenProfessional383');if(profileBtn&&typeof admin==='function'&&!$('ith499DirectAdminProfile')){const b=document.createElement('button');b.id='ith499DirectAdminProfile';b.type='button';b.textContent=(document.documentElement.lang||'el').toLowerCase().startsWith('en')?'💬 Direct administrator contact':'💬 Άμεση επαφή διαχειριστή';b.onclick=admin;profileBtn.insertAdjacentElement('afterend',b)}const grid=document.querySelector('#ithProCenterV249477 .ith477Grid');if(grid&&typeof admin==='function'&&!grid.querySelector('[data-pro477="admin"],#ith499AdminTile')){const b=document.createElement('button');b.id='ith499AdminTile';b.className='ith477Tile';b.innerHTML='<b>💬 Άμεση επαφή διαχειριστή</b><small>Μήνυμα και απάντηση στο ειδικό server inbox.</small>';b.onclick=admin;grid.appendChild(b)}}
document.addEventListener('click',function(e){const q=e.target&&e.target.closest?e.target.closest('#ithProQuick384,#ithOpenProfessional383,[data-open-professional]'):null;if(!q)return;const f=I().openProfessionalCenterV249499||I().openProfessionalCenterV249477;if(typeof f!=='function')return;e.preventDefault();e.stopPropagation();if(e.stopImmediatePropagation)e.stopImmediatePropagation();f()},true);
function repairStoryAvatars(){document.querySelectorAll('#ith477StoryBarWrap .ith499StoryAvatar').forEach(r=>{const img=r.querySelector('img');if(img){img.style.filter='none';img.style.opacity='1';img.style.visibility='visible';img.style.background='transparent';if(img.complete&&img.naturalWidth>0)r.classList.add('hasPhoto');else if(img.complete&&img.naturalWidth===0)img.remove()}})}
function canonical(){return false}
function run(){forceProfessional();repairStoryAvatars();canonical();document.documentElement.setAttribute('data-ithaki-v249499-runtime','own-feed-admin-inbox-story-avatar-photo')}
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',run,{once:true});else run();new MutationObserver(()=>{clearTimeout(window.__ith499mo);window.__ith499mo=setTimeout(run,60)}).observe(document.documentElement,{subtree:true,childList:true});setInterval(run,1200);
})();
