/* OK ITHAKI V249485 - BASE OWNER WITHOUT VERSION TIMER */
(function(){
'use strict';
if(window.__ITHAKI_V249483__)return;
window.__ITHAKI_V249483__={cleanSingleOwner:true,canonicalOwner:249485,installedAt:Date.now()};
const $=id=>document.getElementById(id);
function isMemberView(){const fp=$('feedPage');return !!(window.__ITHAKI_MEMBER_FEED_MODE_V249483__&&fp&&(fp.querySelector('.feedMemberLabel')||fp.querySelector('.memberPostPicker')||fp.dataset.memberFeedV249483==='1'))}
let snapshot='';let restoring=false;
function saveMemberSnapshot(){const fp=$('feedPage');if(!fp)return;fp.dataset.memberFeedV249483='1';snapshot=fp.innerHTML}
function protectMemberView(){const fp=$('feedPage');if(!fp||!window.__ITHAKI_MEMBER_FEED_MODE_V249483__||restoring)return;if((fp.querySelector('.feedMemberLabel')||fp.querySelector('.memberPostPicker'))){snapshot=fp.innerHTML;fp.dataset.memberFeedV249483='1';return}if(snapshot){restoring=true;fp.innerHTML=snapshot;fp.dataset.memberFeedV249483='1';setTimeout(()=>{restoring=false},0)}}
function unlockMemberFeed(){window.__ITHAKI_MEMBER_FEED_MODE_V249483__=false;window.__ITHAKI_MEMBER_FEED_MODE_V249481__=false;snapshot='';const fp=$('feedPage');if(fp)delete fp.dataset.memberFeedV249483;document.body.classList.remove('memberFeedV249485')}
function installFeedOwner(){const I=window.ITH||{};if(I.__v249485FeedOwner)return;I.__v249485FeedOwner=true;
 const oldPicker=I.openMemberPostPicker,oldMember=I.openMemberFeed,oldLoad=I.loadFeed;
 if(typeof oldPicker==='function')I.openMemberPostPicker=async function(){window.__ITHAKI_MEMBER_FEED_MODE_V249483__=true;window.__ITHAKI_MEMBER_FEED_MODE_V249481__=true;const r=await oldPicker.apply(this,arguments);setTimeout(saveMemberSnapshot,30);setTimeout(saveMemberSnapshot,350);return r};
 if(typeof oldMember==='function')I.openMemberFeed=async function(){window.__ITHAKI_MEMBER_FEED_MODE_V249483__=true;window.__ITHAKI_MEMBER_FEED_MODE_V249481__=true;const r=await oldMember.apply(this,arguments);setTimeout(saveMemberSnapshot,30);setTimeout(saveMemberSnapshot,350);return r};
 if(typeof oldLoad==='function')I.loadFeed=function(){if(isMemberView()||window.__ITHAKI_MEMBER_FEED_MODE_V249483__===true)return Promise.resolve(false);unlockMemberFeed();return oldLoad.apply(this,arguments)};
 window.__ITHAKI_EXIT_MEMBER_FEED_V249485__=async function(){if(typeof I.closeMemberFeedV249494==='function')return I.closeMemberFeedV249494();unlockMemberFeed();try{return await oldLoad.call(I)}catch(e){try{return await I.page('feed')}catch(_){return false}}};
 ['openProfessionalFeedV249430','openProfessionalFeedV249429','openProfessionalFeedV249475','openProfessionalFeed'].forEach(k=>{const f=I[k];if(typeof f==='function'&&!f.__v249485){const w=function(){if(isMemberView()||window.__ITHAKI_MEMBER_FEED_MODE_V249483__===true)return false;return f.apply(this,arguments)};w.__v249485=true;I[k]=w}});
 document.addEventListener('click',e=>{const b=e.target.closest('.feedBackOnly,#ithMemberFeedExitV249485');if(b&&isMemberView()){e.preventDefault();e.stopImmediatePropagation();window.__ITHAKI_EXIT_MEMBER_FEED_V249485__()}},true);
}
function oneExternalCenterButton(){if(window.__ITHAKI_V249500_HOME_OWNER__)return true;const home=$('homePage');if(!home)return;const candidates=[...home.querySelectorAll('button')].filter(b=>b.id==='ithExternalCenterHomeV249483'||b.id==='ithExternalCenterHomeV249486'||b.getAttribute('data-v249461-action')==='external'||/Εξωτερικ|External Message/i.test(b.textContent||''));let keep=candidates.find(b=>b.getAttribute('data-v249461-action')==='external')||candidates.find(b=>b.id==='ithExternalCenterHomeV249483'||b.id==='ithExternalCenterHomeV249486')||candidates[0];candidates.filter(b=>b!==keep).forEach(b=>b.remove());if(!keep){keep=document.createElement('button');keep.className='btn card';(home.querySelector('.ithActionsV249461,.homeGrid,.homeActions')||home).appendChild(keep)}keep.id='ithExternalCenterHomeV249483';keep.innerHTML='<span class="ithActionIconV249461" aria-hidden="true">✉</span><b>Κέντρο Μηνυμάτων</b>';keep.title='Email, Viber, ημερολόγιο και εργασίες';keep.onclick=()=>{const f=(window.ITH||{}).openExternalMessageCenterV249477;if(typeof f==='function')return f(false,'calendar')}}
function storyAvatars(){document.querySelectorAll('.storyItem,.professionalStoryItem,.storyAvatarButton').forEach(b=>{const img=b.querySelector('img');if(img){img.loading='lazy';img.alt=img.alt||'Story avatar'}})}
function maintain(){installFeedOwner();oneExternalCenterButton();storyAvatars();protectMemberView();document.querySelectorAll('.proFooter').forEach(x=>x.textContent='OK ITHAKI · Ιδιωτικότητα · Ανθρώπινη επικοινωνία')}
function boot(){maintain();setInterval(maintain,1500);const mo=new MutationObserver(()=>{clearTimeout(window.__ith483m);window.__ith483m=setTimeout(maintain,80)});mo.observe(document.body,{childList:true,subtree:true});document.documentElement.setAttribute('data-ithaki-v249483','base-owner-no-version-timer')}
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',boot,{once:true});else boot();
})();
