/* OK ITHAKI V249485 - SINGLE CANONICAL / SAFE MEMBER FEED EXIT / STORY CONFIRM / 7 VIDEOS */
(function(){'use strict';
if(window.__ITHAKI_V249485__)return;window.__ITHAKI_V249485__=true;
const $=id=>document.getElementById(id);
function addCss(){if($('ithV249485Css'))return;const s=document.createElement('style');s.id='ithV249485Css';s.textContent=`
#ith477StorySelectionV249485{margin-top:10px;padding:12px;border-radius:16px;border:1px solid rgba(255,215,110,.34);background:rgba(4,20,34,.96)}
#ith477StorySelectionV249485 .preview{width:100%;max-height:46dvh;display:grid;place-items:center;overflow:hidden;border-radius:14px;background:#000;margin-bottom:10px}
#ith477StorySelectionV249485 img,#ith477StorySelectionV249485 video{display:block;max-width:100%;max-height:46dvh;object-fit:contain}
#ith477StorySelectionV249485 .actions{display:grid;grid-template-columns:1fr 1fr;gap:9px}
#ith477StorySelectionV249485 .actions button{min-height:46px;border-radius:13px;border:1px solid rgba(255,255,255,.24);font-weight:900;color:#fff;background:#075b42}
#ith477StorySelectionV249485 .actions button.cancel{background:#6d1820}
html[data-ithaki-v249485] body.memberFeedV249485 #feedPage{display:block!important;height:100dvh!important;max-height:100dvh!important;overflow:hidden!important;overflow-x:hidden!important;padding:0!important;background:#000!important}
html[data-ithaki-v249485] body.memberFeedV249485 #feedPage .feedList.memberTikTokFeedV249494{height:100dvh!important;max-height:100dvh!important;overflow-y:auto!important;overflow-x:hidden!important;touch-action:pan-y!important;pointer-events:auto!important;scroll-snap-type:y mandatory!important;scroll-padding:0!important;padding:0!important;margin:0!important;overscroll-behavior-y:contain!important;-webkit-overflow-scrolling:touch!important;background:#000!important}html[data-ithaki-v249485] body.memberFeedV249485 #feedPage .feedList.memberTikTokFeedV249494>.post{width:100%!important;max-width:none!important;min-height:100dvh!important;height:100dvh!important;margin:0!important;padding:0!important;border:0!important;border-radius:0!important;scroll-snap-align:start!important;scroll-snap-stop:always!important;background:#000!important}html[data-ithaki-v249485] body.memberFeedV249485 #feedPage .memberPostPicker,html[data-ithaki-v249485] body.memberFeedV249485 #feedPage .memberThumbGrid{height:auto!important;max-height:none!important;overflow:visible!important;touch-action:pan-y!important;pointer-events:auto!important;scroll-snap-type:none!important}
#ithMemberFeedExitV249485{position:fixed!important;top:calc(env(safe-area-inset-top) + 10px)!important;left:10px!important;z-index:2147483000!important;width:48px!important;height:48px!important;border-radius:50%!important;border:1px solid rgba(255,255,255,.48)!important;background:rgba(3,14,24,.86)!important;color:#fff!important;font-size:34px!important;line-height:42px!important;font-weight:900!important;display:none;align-items:center;justify-content:center;box-shadow:0 8px 26px rgba(0,0,0,.55)!important;backdrop-filter:blur(10px)!important;-webkit-backdrop-filter:blur(10px)!important}
body.memberFeedV249485 #ithMemberFeedExitV249485{display:flex!important}
body.memberFeedV249485 #feedPage>.feedBackOnly{display:none!important}
`;document.head.appendChild(s)}
/* V249494: Story selection is owned only by the canonical V249477 Story core. */
function isMemberFeed(){const fp=$('feedPage');return window.__ITHAKI_MEMBER_FEED_MODE_V249483__===true||window.__ITHAKI_MEMBER_FEED_MODE_V249481__===true||!!(fp&&(fp.querySelector('.feedMemberLabel')||fp.querySelector('.memberPostPicker')||fp.dataset.memberFeedV249483==='1'))}
function ensureExitButton(){let b=$('ithMemberFeedExitV249485');if(!b){b=document.createElement('button');b.id='ithMemberFeedExitV249485';b.type='button';b.setAttribute('aria-label','Έξοδος από τις δημοσιεύσεις μέλους');b.title='Πίσω στη γενική Ροή';b.textContent='‹';document.body.appendChild(b);b.onclick=async function(e){e.preventDefault();e.stopPropagation();b.disabled=true;try{const f=window.__ITHAKI_EXIT_MEMBER_FEED_V249485__;if(typeof f==='function')await f();else{window.__ITHAKI_MEMBER_FEED_MODE_V249483__=false;window.__ITHAKI_MEMBER_FEED_MODE_V249481__=false;const I=window.ITH||{};if(typeof I.loadFeed==='function')await I.loadFeed();else if(typeof I.page==='function')await I.page('feed')}}finally{b.disabled=false;document.body.classList.remove('memberFeedV249485')}}}return b}
function fixMemberScroll(){const active=isMemberFeed();document.body.classList.toggle('memberFeedV249485',active);ensureExitButton();const fp=$('feedPage');if(!fp)return;if(active){const list=fp.querySelector('.feedList');if(list&&list.classList.contains('memberTikTokFeedV249494')){fp.style.overflow='hidden';list.style.height='100dvh';list.style.maxHeight='100dvh';list.style.overflowY='auto';list.style.overflowX='hidden';list.style.scrollSnapType='y mandatory';list.style.touchAction='pan-y'}else{fp.style.overflowY='auto';fp.style.touchAction='pan-y';fp.style.webkitOverflowScrolling='touch';if(list){list.style.height='auto';list.style.maxHeight='none';list.style.overflow='visible';list.style.touchAction='pan-y'}}}}
function isVideoCard(el){return !!el.querySelector('video')&&!el.classList.contains('ithakiOfficialInsertedV249485')}
function isIthakiCard(el){const t=((el.getAttribute('data-nickname')||'')+' '+(el.textContent||'')).toLowerCase();return /ok\s*ithaki|ithaki|ιθάκη|ιθακη/.test(t)&&!el.closest('#ith477StoryBarWrap')}
function interleaveIthaki(){const list=document.querySelector('#feedPage .feedList');if(!list||isMemberFeed())return;const children=[...list.children].filter(x=>x.matches('article,.post,.card'));const sig=children.map(x=>x.getAttribute('data-post')||x.id||x.className).join('|')+'|'+children.length;if(list.dataset.v249485Sig===sig)return;list.dataset.v249485Sig=sig;const official=children.filter(isIthakiCard);if(!official.length)return;official.forEach(x=>x.remove());let videoCount=0,oi=0;const current=[...list.children];for(const el of current){if(isVideoCard(el))videoCount++;if(videoCount>0&&videoCount%7===0){const src=official[oi%official.length];const node=oi<official.length?src:src.cloneNode(true);node.classList.add('ithakiOfficialInsertedV249485');el.after(node);oi++;}}for(let i=oi;i<official.length;i++)list.appendChild(official[i])}
function canonical(){/* V249487 is the only version owner */}
function maintain(){addCss();canonical();fixMemberScroll();interleaveIthaki();document.documentElement.setAttribute('data-ithaki-v249485','single-canonical-safe-feed-exit')}
function boot(){maintain();setInterval(maintain,1200);new MutationObserver(()=>{clearTimeout(window.__ith485m);window.__ith485m=setTimeout(maintain,60)}).observe(document.body,{childList:true,subtree:true})}
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',boot,{once:true});else boot();
})();
