/* OK ITHAKI V249526 — STABLE REQUESTS / SINGLE NOTIFICATION OWNER / MODERN ANONYMOUS WALL */
(function(){
'use strict';
if(window.__ITHAKI_V249526_FINAL_OWNER__)return;
window.__ITHAKI_V249526_FINAL_OWNER__={version:'V249526',stableRequests:true,singleNotificationOwner:true,modernAnonymousWall:true,canonical:true,exclusiveAnonymousWallOwnerR10F3:true,wallFallbackChainStoppedR10F3:true,at:Date.now()};
const I=()=>window.ITH=window.ITH||{}; const S=()=>window.state||I().state||{}; const $=id=>document.getElementById(id);
const esc=s=>String(s==null?'':s).replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[c]));
const LS={master:'ith525_notifications_enabled',sound:'ith525_notification_sound',bil:'ith525_bil_enabled',opened:'ith526_notifications_opened_at',seen:'ith526_notification_seen_keys',syncEnabled:'ith525_external_sync_enabled',syncSecret:'ith525_external_sync_secret'};
const center={open:false,tab:'all',items:[],loading:false,seq:0,html:'',restoreQueued:false};
const wall={open:false,items:[],filter:'all',socket:null,retry:1600};
let pollTimer=0,hideTimer=0,syncTimer=0,lastBilAction=null,lastBilVoiceText='',lastBilVoiceAt=0;
function bool(k,d=true){try{const v=localStorage.getItem(k);return v==null?d:v==='1'}catch(e){return d}}
function setBool(k,v){try{localStorage.setItem(k,v?'1':'0')}catch(e){}return !!v}
function room(){return String(S().room||localStorage.getItem('ith_room')||'ithaki-phone-test')}
function device(){return String(S().device||localStorage.getItem('ith_device')||'')}
function api(path){if(/^https?:/i.test(path))return path;let b=String(S().api||'').replace(/\/+$/,'');if(!b||/appassets\.androidplatform\.net/i.test(b))b='https://ok-ithaki.gr';return b+path}
function nativeObj(){return window.OKITHAKI_ANDROID||window.AndroidBridge||null}
function nativeCall(name,...args){try{const n=nativeObj();if(n&&typeof n[name]==='function')return n[name](...args)}catch(e){}return null}
function toast(m,ms=4200){try{if(typeof I().toast==='function')return I().toast(String(m),ms)}catch(e){}const t=$('toast');if(t){t.textContent=String(m);t.classList.add('show');clearTimeout(toast._t);toast._t=setTimeout(()=>t.classList.remove('show'),ms)}}
async function getJson(path){const r=await fetch(api(path),{cache:'no-store',credentials:'include'});if(!r.ok)throw new Error('HTTP '+r.status);return r.json()}
async function postJson(path,data){const r=await fetch(api(path),{method:'POST',headers:{'Content-Type':'application/json'},credentials:'include',body:JSON.stringify(data)});if(!r.ok)throw new Error('HTTP '+r.status);return r.json()}
function masterOn(){return bool(LS.master,true)} function soundOn(){return bool(LS.sound,true)} function bilOn(){return bool(LS.bil,true)}
function createdMs(x){let v=Number(x.created_at||x.updated_at||x.time||x.ts||0);if(v>0&&v<2e10)v*=1000;return v||Date.now()}
function noticeType(x){return String(x.type||x.kind||x.event_type||x.item_type||'notification').toLowerCase()}
function noticeName(x){return String(x.from_name||x.sender_name||x.peer_name||x.nickname||x.title||'Μέλος').trim()||'Μέλος'}
function noticeKey(x,p='n'){let t=noticeType(x);if(/friend|contact|request/.test(t))t='friend_request';else if(/message|dm|chat|secure/.test(t))t='message';else if(/like|reaction/.test(t))t='reaction';else if(/comment/.test(t))t='comment';else if(/reply/.test(t))t='reply';else if(/follow/.test(t))t='follow';const actor=String(x.from_id||x.sender_id||x.actor_id||x.peer_id||'');const recipient=String(x.to_id||x.recipient_id||device()||'');const target=String(x.message_id||x.post_id||x.publication_id||x.comment_id||x.reply_id||x.request_id||x.external_id||'');if(/^external/.test(String(p)))return 'external|'+String(x.id||x.notification_id||x.key||x.package_name||x.source||'')+'|'+Math.floor(createdMs(x)/30000);const bucket=Math.floor(createdMs(x)/15000);const semantic=String(x.body||x.text||x.message||x.from_name||x.sender_name||x.peer_name||x.status||target||'').trim().toLocaleLowerCase('el').replace(/\s+/g,' ').slice(0,120);return [t,actor,recipient,semantic||target,bucket].join('|')}
function normalize(x,source){const y=Object.assign({},x);y.__source=source;y.__key=noticeKey(y,source);y.__created=createdMs(y);y.__external=/^external/.test(source);return y}
function dedupe(a){const m=new Map();(a||[]).forEach(x=>{if(!x||!x.__key)return;const old=m.get(x.__key);if(!old||x.__created>old.__created)m.set(x.__key,x)});return [...m.values()].sort((a,b)=>b.__created-a.__created)}
function localNotices(){try{return (JSON.parse(localStorage.getItem('ith_notifications')||'[]')||[]).map(x=>normalize(x,'local'))}catch(e){return[]}}
function externalNativeItems(){try{return JSON.parse(String(nativeCall('getExternalMessageCenterItemsV249477')||'[]'))||[]}catch(e){return[]}}
function externalItems(){const a=externalNativeItems().map(x=>normalize(x,'external-phone'));const b=(window.__ITHAKI_EXTERNAL_SYNC_ITEMS_V249525__||[]).map(x=>normalize(Object.assign({synced_from_phone:true},x),'external-sync'));return dedupe([...a,...b])}
async function fetchInternal(){const out=[...localNotices()];if(!device())return dedupe(out);const urls=[['/api/notifications/social/v249247?room_id='+encodeURIComponent(room())+'&device_id='+encodeURIComponent(device())+'&limit=160','social'],['/api/notifications/light/v249242?room_id='+encodeURIComponent(room())+'&device_id='+encodeURIComponent(device())+'&limit=160','light'],['/api/notifications?room_id='+encodeURIComponent(room())+'&device_id='+encodeURIComponent(device())+'&limit=250','friend']];for(const [u,p] of urls){try{const d=await getJson(u);(d.items||[]).forEach(x=>out.push(normalize(x,p)))}catch(e){}}return dedupe(out)}
async function allNotices(){await syncExternal(false).catch(()=>{});return dedupe([...(await fetchInternal()),...externalItems()])}
function isRequest(x){return /friend|contact|request/.test(noticeType(x)) && String(x.status||'pending')==='pending'}
function isMessage(x){return /message|dm|chat|secure/.test(noticeType(x))}
function textFor(x){if(x.__external)return (x.title?x.title+': ':'')+String(x.body||'');const t=noticeType(x),n=noticeName(x);if(isMessage(x))return 'Έχεις μήνυμα από '+n+'.';if(/like|reaction/.test(t))return 'Έχεις like από '+n+' στη δημοσίευσή σου.';if(/follow/.test(t))return 'Σε ακολουθεί ο/η '+n+'.';if(/profile.*view|view.*profile/.test(t))return 'Ο/Η '+n+' είδε το προφίλ σου.';if(/post.*view|view.*post/.test(t))return 'Ο/Η '+n+' είδε τη δημοσίευσή σου.';if(/comment/.test(t))return 'Ο/Η '+n+' σχολίασε τη δημοσίευσή σου.';if(/reply/.test(t))return 'Ο/Η '+n+' σου απάντησε.';if(isRequest(x))return 'Έχεις αίτημα φιλίας από '+n+'.';return String(x.text||x.body||x.title||'Νέα ειδοποίηση.')}
function playSound(){if(!masterOn()||!soundOn())return;const r=nativeCall('playNotificationSoundV249525');if(r!==null)return;try{if(typeof I().playAppAlert==='function')return I().playAppAlert('message')}catch(e){}try{const C=window.AudioContext||window.webkitAudioContext,a=new C(),o=a.createOscillator(),g=a.createGain();o.frequency.value=820;g.gain.setValueAtTime(.12,a.currentTime);g.gain.exponentialRampToValueAtTime(.001,a.currentTime+.22);o.connect(g);g.connect(a.destination);o.start();o.stop(a.currentTime+.23)}catch(e){}}
function bilFace(){return '<span class="ith526BilFace"><i class="shell"></i><i class="head"><i class="eye l"></i><i class="eye r"></i><i class="mouth"></i></i><i class="foot l"></i><i class="foot r"></i></span>'}
function pageName(){return String(document.body?.dataset.page||S().page||'home')}
function ensureBil(){cleanupOld();let d=$('ith526BilDock');if(!d){d=document.createElement('button');d.id='ith526BilDock';d.type='button';d.innerHTML=bilFace()+'<span id="ith526BilSpeech"></span>';d.onclick=()=>{lastBilAction=null;openSettings()};document.body.appendChild(d)}d.hidden=!bilOn()||!(pageName()==='home'||center.open);return d}
function speakBil(text){if(window.__ITHAKI_R10F40_NOTIFICATION_EXCLUSIVE__)return false;const v=String(text||'').trim();if(!v||!bilOn()||!masterOn()||!soundOn())return false;const now=Date.now();if(v===lastBilVoiceText&&now-lastBilVoiceAt<10000)return false;lastBilVoiceText=v;lastBilVoiceAt=now;const d=$('ith526BilDock');try{if(!('speechSynthesis' in window)||typeof SpeechSynthesisUtterance==='undefined')return false;window.speechSynthesis.cancel();const u=new SpeechSynthesisUtterance(v);u.lang=String(document.documentElement.lang||localStorage.getItem('ith_ui_lang')||'el').toLowerCase().startsWith('en')?'en-US':'el-GR';u.rate=.94;u.pitch=1;u.volume=1;if(d)d.classList.add('talking');u.onend=u.onerror=()=>d&&d.classList.remove('talking');window.speechSynthesis.speak(u);return true}catch(e){if(d)d.classList.remove('talking');return false}} function showBil(text,action){if(window.__ITHAKI_R10F40_NOTIFICATION_EXCLUSIVE__)return false;if(!bilOn()||!masterOn())return;const d=ensureBil(),s=$('ith526BilSpeech');if(!d||!s)return;lastBilAction=action||null;d.hidden=false;s.textContent=String(text||'');s.classList.add('show');speakBil(text);clearTimeout(hideTimer);hideTimer=setTimeout(()=>s.classList.remove('show'),6500)}
function cleanupOld(){const ids=['ith523HomeBilCard','ith523BilNotificationCard','ith524BilDock','ith525BilDock','ith477BilNotificationCard','ith509BilNotificationCard','ithBilGreenTurtleV249461','ithBilMenuV249461','ithBilPopV249461','ithBilStableV249475','ithBilStableMenuV249475','ithProfileBilCardV249476'];ids.forEach(id=>$(id)?.remove());document.querySelectorAll('[data-bil-notification-card],.bil473Preview,.bil475Preview,.ithBilHomeCardV249472').forEach(x=>{if(!x.closest('#ith526BilDock')&&!x.closest('#ith526NotificationSettings'))x.remove()})}
function applyNativeSettings(){nativeCall('setNotificationMasterEnabledV249525',masterOn());nativeCall('setNotificationSoundEnabledV249525',soundOn())}
function bell(){return $('ithNotifyFabV249238')||document.querySelector('.ithNotifyFabV249238,[data-notifications-fab]')}
function setBadge(n){const b=bell();if(!b)return;let x=b.querySelector('.badge');if(!x){x=document.createElement('span');x.className='badge';b.appendChild(x)}x.textContent=n>99?'99+':String(n);x.style.display=n>0&&masterOn()?'grid':'none'}
function openedAt(){return Number(localStorage.getItem(LS.opened)||0)}
async function updateBadge(){if(!masterOn()){setBadge(0);return 0}const a=await allNotices();const n=a.filter(x=>x.__created>openedAt()&&x.unread!==false&&String(x.status||'unread')!=='read').length;setBadge(n);return n}
function seenSet(){try{return new Set(JSON.parse(localStorage.getItem(LS.seen)||'[]'))}catch(e){return new Set()}}
function saveSeen(s){try{localStorage.setItem(LS.seen,JSON.stringify([...s].slice(-500)))}catch(e){}}
async function poll(){if(window.__ITHAKI_R10F40_NOTIFICATION_EXCLUSIVE__)return;cleanupOld();ensureBil();applyNativeSettings();let a=[];try{a=await allNotices()}catch(e){}const seen=seenSet(),fresh=a.filter(x=>!seen.has(x.__key));a.forEach(x=>seen.add(x.__key));saveSeen(seen);if(masterOn()&&fresh.length){const newest=fresh[0];if(!(newest.__external&&nativeObj()))playSound();showBil(textFor(newest),()=>routeNotice(newest))}await updateBadge().catch(()=>{})}
function routeNotice(x){if(x.__external)return openExternalCenter(x);const peer=String(x.from_id||x.sender_id||x.peer_id||'');if(isMessage(x)&&peer){const f=I().startDM||I().openDMWith;if(typeof f==='function')return f.call(I(),peer)}return openCenter(isRequest(x)?'requests':'all')}
function closeMenu(){center.open=false;document.body.classList.remove('ith526NotificationsOpen');const m=$('memberMenu');if(m){delete m.dataset.ith526Owner;m.classList.remove('show');m.innerHTML=''}ensureBil()}
function tabButton(tab,label,count){return '<button class="ith526Tab '+(center.tab===tab?'active':'')+'" data-tab="'+tab+'">'+label+(count!=null?'<i>'+count+'</i>':'')+'</button>'}
function internalCard(x){const peer=String(x.from_id||x.sender_id||x.peer_id||''),pending=isRequest(x),inbound=String(x.to_id||device())===device();return '<article class="ith526Notice" data-key="'+esc(x.__key)+'"><header><b>'+esc(textFor(x))+'</b><small>'+esc(new Date(x.__created).toLocaleString('el-GR'))+'</small></header><div class="ith526Actions">'+(isMessage(x)&&peer?'<button data-a="dm" data-peer="'+esc(peer)+'">💬 Μηνύματα</button>':'<button data-a="detail">Άνοιγμα</button>')+(pending&&inbound?'<button class="green" data-a="accept" data-peer="'+esc(peer)+'" data-id="'+esc(x.id||x.event_id||'')+'">✓ Αποδοχή</button><button class="danger" data-a="reject" data-peer="'+esc(peer)+'" data-id="'+esc(x.id||x.event_id||'')+'">× Απόρριψη</button>':'')+'</div></article>'}
function externalCard(x){return '<article class="ith526Notice external"><header><span class="ith526Source">'+esc(String(x.source||'APP').toUpperCase())+'</span><b>'+esc(x.title||'Εξωτερικό μήνυμα')+'</b><small>'+esc(new Date(x.__created).toLocaleString('el-GR'))+'</small></header><p>'+esc(x.body||'')+'</p><div class="ith526Actions"><button data-a="external-center">📨 Κέντρο</button><button data-a="external-open" data-id="'+esc(x.id||'')+'" data-source="'+esc(x.source||'')+'">↗ Εφαρμογή</button></div></article>'}
function renderCenter(){const root=$('ith526NotificationCenter');if(!root||!center.open)return;const requests=center.items.filter(isRequest),external=center.items.filter(x=>x.__external),internal=center.items.filter(x=>!x.__external);let shown=center.items;if(center.tab==='requests')shown=requests;if(center.tab==='external')shown=external;const cards=shown.map(x=>x.__external?externalCard(x):internalCard(x)).join('')||'<section class="ith526Empty">Δεν υπάρχουν στοιχεία σε αυτή την κατηγορία.</section>';root.innerHTML='<div class="ith526Head"><button data-top="close">‹</button><div><b>Κέντρο Ειδοποιήσεων</b><small>Ένας σταθερός μηχανισμός · χωρίς αναβόσβημα</small></div><button data-top="settings">⚙️</button><button data-top="close">×</button></div><div class="ith526Tabs">'+tabButton('all','Όλες',center.items.length)+tabButton('requests','Αιτήματα',requests.length)+tabButton('external','Άλλες εφαρμογές',external.length)+'</div><section class="ith526Summary"><span>Το καμπανάκι μηδενίστηκε. Η νέα μέτρηση ξεκινά από εδώ.</span></section><main class="ith526List">'+cards+'</main>';center.html=root.outerHTML;bindCenter(root)}
function bindCenter(root){root.onclick=async e=>{const top=e.target.closest('[data-top]');if(top){if(top.dataset.top==='close')return closeMenu();if(top.dataset.top==='settings')return openSettings()}const tab=e.target.closest('[data-tab]');if(tab){center.tab=tab.dataset.tab;return renderCenter()}const b=e.target.closest('[data-a]');if(!b)return;const act=b.dataset.a;if(act==='dm'){const f=I().startDM||I().openDMWith;if(typeof f==='function')f.call(I(),b.dataset.peer);return}if(act==='accept'||act==='reject'){b.disabled=true;const fn=I().respondFriendProposalV249233||I().respondFriendProposalV249223;try{if(typeof fn==='function')await fn.call(I(),b.dataset.id,act==='accept',b.dataset.peer,b.closest('[data-key]')?.dataset.key||'')}catch(err){toast('Δεν ολοκληρώθηκε: '+(err.message||err))}await refreshCenter();return}if(act==='external-center')return openExternalCenter();if(act==='external-open'){if(!nativeCall('openExternalNotificationV249477',b.dataset.id)&&!nativeCall('openExternalSourceAppV249477',b.dataset.source))toast('Η εφαρμογή ανοίγει μόνο στο κινητό που συνέλεξε την ειδοποίηση.')}}}
async function markViewed(a){const now=Date.now();localStorage.setItem(LS.opened,String(now));setBadge(0);nativeCall('resetNotificationBadgeV249525');const ids=(a||[]).filter(x=>x.__source==='social'&&x.id).map(x=>x.id);if(ids.length)postJson('/api/notifications/read/v249247',{room_id:room(),device_id:device(),ids:ids.slice(0,120)}).catch(()=>{})}
async function refreshCenter(){if(center.loading)return;center.loading=true;const seq=++center.seq;try{const items=await allNotices();if(seq!==center.seq)return;center.items=items;await markViewed(items);renderCenter()}finally{center.loading=false}}
async function openCenter(tab='all'){const m=$('memberMenu');if(!m)return false;center.open=true;center.tab=tab;document.body.classList.add('ith526NotificationsOpen');m.dataset.ith526Owner='notifications';m.classList.add('show','fullAvatarMenuV249231');m.innerHTML='<div id="ith526NotificationCenter" class="ith526Panel"><div class="ith526Loading">Φόρτωση σταθερής λίστας…</div></div>';ensureBil();await refreshCenter();return false}
function toggleRow(key,label,desc,on){return '<button class="ith526Toggle" data-setting="'+key+'"><span><b>'+esc(label)+'</b><small>'+esc(desc)+'</small></span><i class="'+(on?'on':'')+'">'+(on?'ON':'OFF')+'</i></button>'}
function openSettings(){const m=$('memberMenu');if(!m)return false;center.open=true;m.dataset.ith526Owner='notifications';m.classList.add('show','fullAvatarMenuV249231');m.innerHTML='<div id="ith526NotificationSettings" class="ith526Panel"><div class="ith526Head"><button data-top="center">‹</button><div><b>Ρυθμίσεις ειδοποιήσεων</b><small>Μία εγγραφή για κάθε επιλογή</small></div><button data-top="close">×</button></div>'+toggleRow('master','Ειδοποιήσεις','Γενική ενεργοποίηση ή απενεργοποίηση.',masterOn())+toggleRow('sound','Ήχος','Ηχητική ειδοποίηση για νέα γεγονότα.',soundOn())+toggleRow('bil','Bil','Ένας Bil που ανοίγει το σχετικό μήνυμα.',bilOn())+'<section class="ith526Settings"><b>Άλλες εφαρμογές</b><div class="ith526Grid"><button data-action="external">📨 Κέντρο Μηνυμάτων</button><button data-action="calendar">📅 Ημερολόγιο</button><button data-action="access">🔐 Άδεια Android</button></div></section><section class="ith526Settings"><b>Κρυπτογραφημένος συγχρονισμός</b>'+toggleRow('sync','Κινητό ↔ Υπολογιστής','Ο server κρατά μόνο κρυπτογραφημένο snapshot.',bool(LS.syncEnabled,false))+'<div class="ith526Grid"><button data-action="sync-code">🗝️ Κωδικός</button><button data-action="sync-import">📥 Εισαγωγή</button><button data-action="sync-now">↻ Συγχρονισμός</button></div></section></div>';const root=$('ith526NotificationSettings');root.onclick=async e=>{const top=e.target.closest('[data-top]');if(top){if(top.dataset.top==='center')return openCenter(center.tab);return closeMenu()}const s=e.target.closest('[data-setting]');if(s){const k=s.dataset.setting;if(k==='master')setBool(LS.master,!masterOn());if(k==='sound')setBool(LS.sound,!soundOn());if(k==='bil')setBool(LS.bil,!bilOn());if(k==='sync')setBool(LS.syncEnabled,!bool(LS.syncEnabled,false));applyNativeSettings();if(!masterOn()){setBadge(0);nativeCall('resetNotificationBadgeV249525')}return openSettings()}const a=e.target.closest('[data-action]');if(!a)return;if(a.dataset.action==='external')return openExternalCenter();if(a.dataset.action==='calendar')return openCalendar();if(a.dataset.action==='access')return nativeCall('openNotificationAccessSettingsV249477');if(a.dataset.action==='sync-code')return showSyncCode();if(a.dataset.action==='sync-import')return importSyncCode();if(a.dataset.action==='sync-now')return syncExternal(true)};return false}
function openExternalCenter(){const f=I().openExternalMessageCenterV249477||I().openExternalCenterV249508;if(typeof f==='function')return f.call(I());toast('Το Κέντρο Μηνυμάτων δεν είναι διαθέσιμο.');return false}
function openCalendar(){const f=I().openExternalMessageCenterV249477||I().renderLocalProfessionalCalendarV249477;if(typeof f==='function')return f.call(I(),true,'calendar');return false}
function bytesToB64u(bytes){let s='';bytes.forEach(b=>s+=String.fromCharCode(b));return btoa(s).replace(/\+/g,'-').replace(/\//g,'_').replace(/=+$/,'')}
function b64uToBytes(s){s=String(s||'').replace(/^ITH525-/,'').replace(/-/g,'+').replace(/_/g,'/');while(s.length%4)s+='=';const r=atob(s),a=new Uint8Array(r.length);for(let i=0;i<r.length;i++)a[i]=r.charCodeAt(i);return a}
function getSecret(){try{return localStorage.getItem(LS.syncSecret)||''}catch(e){return''}}
function ensureSecret(){let s=getSecret();if(!s){s='ITH525-'+bytesToB64u(crypto.getRandomValues(new Uint8Array(32)));localStorage.setItem(LS.syncSecret,s)}return s}
async function keyAndId(){const raw=b64uToBytes(ensureSecret());if(raw.length!==32)throw new Error('Μη έγκυρος κωδικός');const hash=new Uint8Array(await crypto.subtle.digest('SHA-256',raw));const id=[...hash].slice(0,20).map(b=>b.toString(16).padStart(2,'0')).join('');const key=await crypto.subtle.importKey('raw',raw,'AES-GCM',false,['encrypt','decrypt']);return{key,id}}
async function encryptItems(items){const {key,id}=await keyAndId(),iv=crypto.getRandomValues(new Uint8Array(12)),plain=new TextEncoder().encode(JSON.stringify(items));const ct=new Uint8Array(await crypto.subtle.encrypt({name:'AES-GCM',iv},key,plain));return{id,payload:JSON.stringify({v:1,alg:'AES-256-GCM',iv:bytesToB64u(iv),ct:bytesToB64u(ct)})}}
async function decryptItems(payload){const {key}=await keyAndId(),b=JSON.parse(payload),plain=await crypto.subtle.decrypt({name:'AES-GCM',iv:b64uToBytes(b.iv)},key,b64uToBytes(b.ct));return JSON.parse(new TextDecoder().decode(plain))}
async function showSyncCode(){const c=ensureSecret();try{await navigator.clipboard.writeText(c);toast('Ο κωδικός αντιγράφηκε.')}catch(e){prompt('Κωδικός συγχρονισμού',c)}}
async function importSyncCode(){const c=prompt('Επικόλλησε τον κωδικό ITH525-…',getSecret());if(c===null)return;try{if(b64uToBytes(c.trim()).length!==32)throw 0;localStorage.setItem(LS.syncSecret,c.trim().startsWith('ITH525-')?c.trim():'ITH525-'+c.trim());setBool(LS.syncEnabled,true);await syncExternal(true);openSettings()}catch(e){toast('Ο κωδικός δεν είναι έγκυρος.')}}
async function syncExternal(show){if(!bool(LS.syncEnabled,false)||!getSecret()||!crypto?.subtle)return false;try{const native=externalNativeItems(),{id}=await keyAndId();if(nativeObj()&&native.length){const box=await encryptItems(native);await postJson('/api/external-center/sync/v249525',{sync_id:box.id,encrypted_payload:box.payload,item_count:native.length,updated_at:Date.now()});window.__ITHAKI_EXTERNAL_SYNC_ITEMS_V249525__=native;if(show)toast('Η λίστα συγχρονίστηκε κρυπτογραφημένα.');return true}const d=await getJson('/api/external-center/sync/v249525?sync_id='+encodeURIComponent(id));if(d.encrypted_payload){window.__ITHAKI_EXTERNAL_SYNC_ITEMS_V249525__=await decryptItems(d.encrypted_payload);if(show)toast('Η λίστα φορτώθηκε στον υπολογιστή.');return true}if(show)toast('Δεν υπάρχει ακόμη λίστα από κινητό.')}catch(e){if(show)toast('Ο συγχρονισμός απέτυχε: '+String(e.message||e))}return false}

/* Modern anonymous wall */
const REACTIONS=[['🤍','στήριξη'],['✨','ελπίδα'],['🤝','μαζί'],['🌿','ηρεμία']];
function wallCategory(t){t=String(t||'').toLowerCase();if(/[?？]|πώς|γιατί|τι να/.test(t))return'question';if(/στήρι|βοήθ|δύσκολ|μόνος|μόνη/.test(t))return'support';if(/ιδέα|πρόταση|μπορούμε/.test(t))return'idea';return'thought'}
function normalizeWall(d){const a=(d&&(d.posts||d.items||d.wall))||[];return Array.isArray(a)?a.map((p,i)=>({id:String(p.post_id||p.id||p.wall_id||'w'+i),text:String(p.text||p.message||p.body||''),created:Number(p.created_at||p.timestamp||0),category:wallCategory(p.text||p.message||p.body||'')})).filter(x=>x.id&&x.text):[]}
async function loadWall(){let err;for(const u of ['/api/wall/list_v249345?room_id='+encodeURIComponent(room())+'&limit=100','/api/wall/list_v249344?room_id='+encodeURIComponent(room())+'&limit=100','/api/wall/list_v249339?room_id='+encodeURIComponent(room())+'&limit=100','/api/wall/list?room_id='+encodeURIComponent(room())+'&limit=100']){try{wall.items=normalizeWall(await getJson(u));renderWallList();hydrateWall();return}catch(e){err=e}}throw err||new Error('Ο Τοίχος δεν απάντησε')}
function fmtWall(t){try{return new Date((Number(t)||Date.now()/1000)*1000).toLocaleString('el-GR',{day:'2-digit',month:'short',hour:'2-digit',minute:'2-digit'})}catch(e){return'τώρα'}}
function wallCard(p){return '<article class="ith526WallCard" data-wall="'+esc(p.id)+'"><header><span class="ith526AnonAvatar">◌</span><div><b>Ανώνυμη φωνή</b><small>'+esc(fmtWall(p.created))+'</small></div><button data-report="'+esc(p.id)+'">⚑</button></header><p>'+esc(p.text)+'</p><footer>'+REACTIONS.map(r=>'<button data-react="'+esc(r[0])+'" data-post="'+esc(p.id)+'" title="'+esc(r[1])+'"><span>'+r[0]+'</span><i>0</i></button>').join('')+'</footer></article>'}
function renderWallList(){const list=$('ith526WallList');if(!list)return;const a=wall.filter==='all'?wall.items:wall.items.filter(x=>x.category===wall.filter);list.innerHTML=a.map(wallCard).join('')||'<section class="ith526WallEmpty"><span>◌</span><b>Ο χώρος περιμένει την πρώτη ανώνυμη φωνή.</b><small>Χωρίς όνομα. Χωρίς προφίλ. Με σεβασμό.</small></section>'}
async function hydrateWall(){const ids=wall.items.map(x=>x.id).slice(0,100);if(!ids.length)return;try{const d=await getJson('/api/v411/wall/reactions?room_id='+encodeURIComponent(room())+'&post_ids='+encodeURIComponent(ids.join(','))+'&device_id='+encodeURIComponent(device()));$('ith526WallLive')?.replaceChildren(document.createTextNode(String(d.live_now||0)));(d.items||[]).forEach(it=>{const c=document.querySelector('[data-wall="'+CSS.escape(String(it.post_id))+'"]');if(!c)return;c.querySelectorAll('[data-react]').forEach(b=>{const e=b.dataset.react;b.querySelector('i').textContent=String((it.counts||{})[e]||0);b.classList.toggle('active',Array.isArray(it.mine)&&it.mine.includes(e))})})}catch(e){}}
async function reactWall(b){if(b.disabled)return;b.disabled=true;try{const d=await postJson('/api/v411/wall/reaction',{room_id:room(),post_id:b.dataset.post,device_id:device(),emoji:b.dataset.react});const c=b.closest('[data-wall]');c?.querySelectorAll('[data-react]').forEach(x=>{const e=x.dataset.react;x.querySelector('i').textContent=String((d.counts||{})[e]||0);x.classList.toggle('active',Array.isArray(d.mine)&&d.mine.includes(e))})}catch(e){toast('Η αντίδραση δεν καταχωρήθηκε.')}finally{setTimeout(()=>b.disabled=false,250)}}
async function sendWall(){const f=$('ith526WallText'),b=$('ith526WallSend');if(!f||!b)return;const text=f.value.trim();if(!text)return toast('Γράψε πρώτα τη σκέψη σου.');b.disabled=true;let err;for(const u of ['/api/wall/post_v249345','/api/wall/post_v249344','/api/wall/post_v249339','/api/wall/post']){try{await postJson(u,{room_id:room(),owner_token:device(),text});f.value='';$('ith526WallCount').textContent='0/500';await loadWall();b.disabled=false;return}catch(e){err=e}}b.disabled=false;toast('Δεν στάλθηκε: '+(err?.message||err||'σφάλμα'))}
async function reportWall(id){for(const [u,p] of [['/api/wall/report_v249344',{room_id:room(),owner_token:device(),post_id:id,reason:'user_report'}],['/api/report',{room_id:room(),reporter_id:device(),target_type:'wall',target_id:id,reason:'user_report'}]]){try{await postJson(u,p);toast('Η αναφορά καταχωρήθηκε.');return}catch(e){}}toast('Η αναφορά δεν καταχωρήθηκε.')}
function closeWall(){wall.open=false;try{wall.socket?.close()}catch(e){}wall.socket=null;$('ith526AnonymousWall')?.remove()}
function connectWall(){try{const base=api('').replace(/^http:/,'ws:').replace(/^https:/,'wss:');wall.socket=new WebSocket(base+'/ws/v411/wall/'+encodeURIComponent(room())+'?device_id='+encodeURIComponent(device()));wall.socket.onmessage=e=>{try{const m=JSON.parse(e.data);if(m.live_now!=null)$('ith526WallLive').textContent=String(m.live_now);if(m.type==='v411_reaction')hydrateWall();if(/^wall_/.test(m.type||''))setTimeout(loadWall,120)}catch(_){}};wall.socket.onclose=()=>{if(wall.open)setTimeout(connectWall,Math.min(15000,wall.retry*=1.5))}}catch(e){}}
function openWall(){closeWall();document.querySelectorAll('#ithUnifiedWall397,#ithV411Wall,#ithWall357,#v411Overlay,.v411Overlay').forEach(x=>x.remove());wall.open=true;const d=document.createElement('div');d.id='ith526AnonymousWall';d.innerHTML='<div class="ith526WallAurora"></div><header class="ith526WallHead"><button data-wall-close>‹</button><div><small>OK ITHAKI · ΑΣΦΑΛΗΣ ΧΩΡΟΣ</small><h1>Ανώνυμος Τοίχος</h1><p>Μοιράσου μια σκέψη χωρίς όνομα και χωρίς προφίλ.</p></div><span class="ith526Live"><i></i><b id="ith526WallLive">0</b> τώρα</span><button data-wall-close>×</button></header><nav class="ith526WallFilters"><button class="active" data-filter="all">Όλα</button><button data-filter="thought">Σκέψεις</button><button data-filter="support">Στήριξη</button><button data-filter="question">Ερωτήσεις</button><button data-filter="idea">Ιδέες</button></nav><main id="ith526WallList" class="ith526WallList"><section class="ith526WallEmpty">Φόρτωση…</section></main><footer class="ith526WallComposer"><div class="ith526Privacy"><span>◌</span><div><b>Γράφεις ανώνυμα</b><small>Δεν εμφανίζεται avatar, όνομα ή προφίλ.</small></div></div><div class="ith526ComposeRow"><textarea id="ith526WallText" maxlength="500" placeholder="Μια σκέψη, μια ερώτηση ή λίγα λόγια στήριξης…"></textarea><button id="ith526WallSend">➤</button></div><div class="ith526ComposeMeta"><span>Σεβασμός · χωρίς προσωπικά στοιχεία</span><b id="ith526WallCount">0/500</b></div></footer>';document.body.appendChild(d);d.onclick=e=>{if(e.target.closest('[data-wall-close]'))return closeWall();const f=e.target.closest('[data-filter]');if(f){wall.filter=f.dataset.filter;d.querySelectorAll('[data-filter]').forEach(x=>x.classList.toggle('active',x===f));return renderWallList()}const r=e.target.closest('[data-react]');if(r)return reactWall(r);const rep=e.target.closest('[data-report]');if(rep)return reportWall(rep.dataset.report)};$('ith526WallText').oninput=e=>$('ith526WallCount').textContent=e.target.value.length+'/500';$('ith526WallSend').onclick=sendWall;loadWall().catch(e=>{$('ith526WallList').innerHTML='<section class="ith526WallEmpty"><b>Ο Τοίχος δεν φορτώθηκε.</b><small>'+esc(e.message||e)+'</small></section>'});connectWall();return true}
function ensurePlusWall(){const s=$('plusSheet');if(!s)return;const old=[...s.querySelectorAll('[data-act="anon_wall"],#ith526PlusWall')];old.slice(1).forEach(x=>x.remove());let b=old[0];if(!b){b=document.createElement('button');b.id='ith526PlusWall';b.className='tile ith526WallTile';b.dataset.act='anon_wall';s.appendChild(b)}b.innerHTML='<b>◌</b><span>Ανώνυμος Τοίχος</span><small>Μίλα χωρίς όνομα</small>';b.onclick=e=>{e.preventDefault();e.stopPropagation();s.classList.remove('show');openWall()}}
function captureWall(e){const b=e.target&&e.target.closest&&e.target.closest('#plusSheet [data-r9plus="anon_wall"],#plusSheet [data-r8plus="anon_wall"],#plusSheet [data-act="anon_wall"],#ith526PlusWall,[data-bil-action="wall"],[data-a="wall"],#ithHomeWall378');if(!b)return;e.preventDefault();e.stopPropagation();e.stopImmediatePropagation();$('plusSheet')?.classList.remove('show');openWall()}

function installOwners(){const o=I();if(!window.__ITHAKI_R10F40_NOTIFICATION_EXCLUSIVE__){o.openMessageCenterFromNotificationSettingsV249526=openExternalCenter;window.openMessageCenterFromNotificationSettingsV249526=openExternalCenter;o.notifyCenter=openCenter;window.notifyCenter=openCenter;o.openNotificationSettingsV249238=openSettings;window.openNotificationSettingsV249238=openSettings;o.renderNotificationModeSettingsV249258=openSettings;window.renderNotificationModeSettingsV249258=openSettings;o.refreshNotificationBadgeV249238=updateBadge;window.refreshNotificationBadgeV249238=updateBadge;o.showBilNotificationV249526=showBil;window.showBilNotificationV249526=showBil;o.openFriendRequestsV249526=()=>openCenter('requests')}const wallAliases=['openAnonymousWallV249526','openAnonymousWallV249526R10F3','openAnonymousWallV249283','openZeroSupportWallV249270','openUnifiedWallV249397','openWallV249357','openCurrentWallV249440','openWallV411','openAnonymousWallV411','openProfessionalAnonymousWallV249378','openDirectWallV249434'];wallAliases.forEach(k=>{o[k]=openWall;window[k]=openWall})}
function canonical(){try{const u=new URL(location.href);if(u.searchParams.get('v')!=='249526'){u.searchParams.set('v',(window.ITHAKI_ACTIVE_VERSION||'249526r10f37f1f2'));history.replaceState(null,'',u.pathname+'?'+u.searchParams.toString()+u.hash)}}catch(e){}document.querySelectorAll('.proFooter').forEach(x=>x.textContent='OK ITHAKI · Ιδιωτικότητα · Ανθρώπινη επικοινωνία');try{localStorage.setItem('ith_frontend_build','V249526-stable-requests-modern-anonymous-wall');document.documentElement.setAttribute('data-ithaki-v249526','stable-requests-modern-anonymous-wall')}catch(e){}}
function css(){if($('ith526Style'))return;const s=document.createElement('style');s.id='ith526Style';s.textContent=`
#ith526BilDock{position:fixed;left:12px;bottom:calc(var(--bar,72px) + 28px);z-index:2147483500;width:58px;height:58px;border:0;background:transparent;padding:0;overflow:visible;filter:drop-shadow(0 8px 15px #0008)}#ith526BilDock[hidden]{display:none!important}.ith526BilFace{position:relative;display:block;width:58px;height:54px}.ith526BilFace .shell{position:absolute;left:5px;top:23px;width:43px;height:28px;border-radius:55%;background:radial-gradient(circle at 44% 23%,#ffe49c 0 18%,#62bf89 19% 55%,#246b50 56% 100%);border:1px solid #ffffff80}.ith526BilFace .head{position:absolute;left:23px;top:2px;width:27px;height:27px;border-radius:50%;background:#7bdaa0;border:1px solid #ffffff80}.ith526BilFace .eye{position:absolute;top:8px;width:4px;height:6px;border-radius:50%;background:#10231e}.ith526BilFace .eye.l{left:6px}.ith526BilFace .eye.r{right:6px}.ith526BilFace .mouth{position:absolute;left:8px;top:17px;width:10px;height:4px;border-bottom:2px solid #17392e;border-radius:0 0 9px 9px}.ith526BilFace .foot{position:absolute;top:47px;width:11px;height:6px;border-radius:99px;background:#62bf89}.ith526BilFace .foot.l{left:7px}.ith526BilFace .foot.r{right:8px}#ith526BilSpeech{position:absolute;left:50px;bottom:34px;width:min(300px,calc(100vw - 78px));padding:10px 12px;border-radius:16px 16px 16px 4px;background:#07131ff5;border:1px solid #7eebae60;color:#fff;font-size:13px;line-height:1.4;text-align:left;opacity:0;visibility:hidden;transform:translateY(5px);transition:.2s;box-shadow:0 13px 32px #0007;pointer-events:none}#ith526BilSpeech.show{opacity:1;visibility:visible;transform:none}#ith526BilDock.talking .ith526BilFace .mouth{animation:ith526BilTalk .18s infinite alternate}@keyframes ith526BilTalk{from{height:3px;border-bottom-width:2px}to{height:8px;border-bottom-width:3px}}
.ith526Panel{height:100%;overflow:auto;padding:10px 10px calc(var(--bar,72px) + 26px);box-sizing:border-box;background:linear-gradient(180deg,#06101b,#0b1826)}.ith526Head{position:sticky;top:0;z-index:30;display:flex;align-items:center;gap:8px;padding:10px;border-radius:18px;background:#081522ee;border:1px solid #ffffff1d;backdrop-filter:blur(16px);box-shadow:0 12px 30px #0005}.ith526Head>div{flex:1;display:flex;flex-direction:column}.ith526Head small{opacity:.65}.ith526Head button,.ith526Actions button,.ith526Grid button{border:1px solid #ffffff24;background:#ffffff0e;color:#fff;border-radius:13px;padding:9px 11px}.ith526Tabs{display:flex;gap:7px;overflow:auto;padding:12px 2px 4px}.ith526Tab{display:flex;align-items:center;gap:7px;white-space:nowrap;border:1px solid #ffffff1e;background:#ffffff0b;color:#dce9f5;border-radius:999px;padding:9px 12px}.ith526Tab.active{background:linear-gradient(135deg,#27d79433,#58a8ff2b);border-color:#70e6b174}.ith526Tab i{font-style:normal;background:#ffffff16;border-radius:99px;padding:2px 7px}.ith526Summary,.ith526Notice,.ith526Empty,.ith526Settings{margin-top:10px;padding:13px;border-radius:18px;background:#ffffff0b;border:1px solid #ffffff16}.ith526Notice header{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.ith526Notice header b{flex:1;min-width:180px}.ith526Notice small,.ith526Settings small{opacity:.65}.ith526Actions{display:flex;gap:7px;flex-wrap:wrap;margin-top:10px}.ith526Actions .green{background:#36ef9f28;border-color:#36ef9f70}.ith526Actions .danger{background:#ff67671f;border-color:#ff67676b}.ith526Source{font-size:10px;font-weight:900;color:#ffdc7b;background:#ffdc7b18;border-radius:99px;padding:4px 7px}.ith526Toggle{width:100%;display:flex;align-items:center;gap:10px;text-align:left;padding:13px;margin-top:9px;border:1px solid #ffffff1f;background:#ffffff0c;color:#fff;border-radius:16px}.ith526Toggle span{display:flex;flex-direction:column;gap:4px;flex:1}.ith526Toggle i{font-style:normal;padding:7px 10px;border-radius:99px;background:#ffffff10}.ith526Toggle i.on{background:#35efa02a;color:#68efad}.ith526Grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:10px}
#ith526AnonymousWall{position:fixed;inset:0;z-index:2147483645;background:#050912;color:#f5f8fb;display:grid;grid-template-rows:auto auto 1fr auto;overflow:hidden;font-family:system-ui,-apple-system,sans-serif}#ith526AnonymousWall *{box-sizing:border-box}.ith526WallAurora{position:absolute;inset:-30%;pointer-events:none;background:radial-gradient(circle at 18% 12%,#665cff32,transparent 28%),radial-gradient(circle at 85% 23%,#00d3a42b,transparent 30%),radial-gradient(circle at 58% 82%,#ffbd5930,transparent 28%);filter:blur(34px)}.ith526WallHead{position:relative;z-index:2;display:flex;align-items:center;gap:12px;padding:max(15px,env(safe-area-inset-top)) 15px 13px;background:#07101bd9;border-bottom:1px solid #ffffff14;backdrop-filter:blur(22px)}.ith526WallHead>div{flex:1}.ith526WallHead h1{margin:2px 0;font-size:clamp(23px,5vw,36px);letter-spacing:-.7px}.ith526WallHead p,.ith526WallHead small{margin:0;opacity:.7}.ith526WallHead button{width:42px;height:42px;border-radius:14px;border:1px solid #ffffff20;background:#ffffff0c;color:#fff;font-size:24px}.ith526Live{display:flex;gap:6px;align-items:center;padding:8px 10px;border-radius:99px;background:#31e3a21b;border:1px solid #31e3a24d;font-size:12px}.ith526Live i{width:8px;height:8px;border-radius:50%;background:#38edac;box-shadow:0 0 0 5px #38edac20;animation:ith526Pulse 1.7s infinite}@keyframes ith526Pulse{50%{box-shadow:0 0 0 9px transparent}}.ith526WallFilters{position:relative;z-index:2;display:flex;gap:8px;overflow:auto;padding:11px 14px;background:#07101bbd}.ith526WallFilters button{white-space:nowrap;border:1px solid #ffffff19;background:#ffffff0a;color:#dbe6ef;border-radius:999px;padding:9px 13px}.ith526WallFilters button.active{background:linear-gradient(135deg,#6a5cff45,#24d5a238);border-color:#8d83ff82}.ith526WallList{position:relative;z-index:2;overflow:auto;padding:14px 14px 180px;display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,310px),1fr));gap:12px;align-content:start}.ith526WallCard{padding:16px;border-radius:23px;background:linear-gradient(145deg,#ffffff0f,#ffffff06);border:1px solid #ffffff18;box-shadow:0 16px 34px #0005;backdrop-filter:blur(12px)}.ith526WallCard header{display:flex;align-items:center;gap:10px}.ith526WallCard header>div{flex:1;display:flex;flex-direction:column}.ith526WallCard header small{opacity:.55}.ith526WallCard header button{border:0;background:transparent;color:#99a8b8;font-size:19px}.ith526AnonAvatar{width:42px;height:42px;border-radius:50%;display:grid;place-items:center;font-size:24px;background:linear-gradient(145deg,#806cff55,#20cda43c);border:1px solid #ffffff30}.ith526WallCard p{font-size:16px;line-height:1.55;white-space:pre-wrap}.ith526WallCard footer{display:flex;gap:7px}.ith526WallCard footer button{display:flex;align-items:center;gap:5px;border:1px solid #ffffff16;background:#ffffff08;color:#fff;border-radius:99px;padding:7px 9px}.ith526WallCard footer button.active{background:#7e6cff32;border-color:#9c91ff75}.ith526WallCard footer i{font-style:normal;font-size:11px;opacity:.75}.ith526WallEmpty{grid-column:1/-1;min-height:240px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:8px;border:1px dashed #ffffff22;border-radius:24px;background:#ffffff05}.ith526WallEmpty>span{font-size:52px}.ith526WallEmpty small{opacity:.65}.ith526WallComposer{position:absolute;z-index:5;left:0;right:0;bottom:0;padding:12px 14px calc(12px + env(safe-area-inset-bottom));background:#07101bf2;border-top:1px solid #ffffff16;backdrop-filter:blur(22px)}.ith526Privacy{display:flex;align-items:center;gap:9px;margin-bottom:8px}.ith526Privacy>span{width:34px;height:34px;display:grid;place-items:center;border-radius:50%;background:#ffffff0d}.ith526Privacy>div{display:flex;flex-direction:column}.ith526Privacy small{opacity:.58}.ith526ComposeRow{display:flex;gap:9px}.ith526ComposeRow textarea{flex:1;min-height:52px;max-height:110px;resize:none;border:1px solid #ffffff1f;border-radius:18px;background:#ffffff0b;color:#fff;padding:13px;font:inherit}.ith526ComposeRow button{width:54px;border:0;border-radius:18px;background:linear-gradient(145deg,#70e8b4,#8a79ff);color:#071017;font-size:23px;font-weight:900}.ith526ComposeMeta{display:flex;justify-content:space-between;margin-top:6px;font-size:11px;opacity:.58}.ith526WallTile{background:linear-gradient(145deg,#4b3bbf33,#00a57d25)!important}.ith526WallTile small{display:block;opacity:.65;font-size:10px}
@media(max-width:520px){.ith526Grid{grid-template-columns:1fr}.ith526WallHead p{display:none}.ith526Live{display:none}.ith526WallList{grid-template-columns:1fr;padding-inline:10px}.ith526WallHead{gap:8px}.ith526WallHead h1{font-size:24px}}
`;document.head.appendChild(s)}
function maintain(){css();installOwners();cleanupOld();ensureBil();ensurePlusWall();canonical();applyNativeSettings();const m=$('memberMenu');if(center.open&&m&&m.dataset.ith526Owner==='notifications'&&!m.querySelector('#ith526NotificationCenter,#ith526NotificationSettings')){if(!center.restoreQueued){center.restoreQueued=true;queueMicrotask(()=>{center.restoreQueued=false;if(center.open){m.innerHTML='<div id="ith526NotificationCenter" class="ith526Panel"></div>';renderCenter()}})}}}
function patchBell(){const b=bell();if(b&&!b.dataset.ith526){b.dataset.ith526='1';b.onclick=e=>{e.preventDefault();e.stopPropagation();openCenter('all')}}}
function primeBilVoice(){if(primeBilVoice.done)return;primeBilVoice.done=true;try{if('speechSynthesis' in window)window.speechSynthesis.getVoices()}catch(e){}try{if(bilOn()&&masterOn()&&localStorage.getItem('ith526_bil_voice_ready_r5')!=='1'){localStorage.setItem('ith526_bil_voice_ready_r5','1');setTimeout(()=>showBil('Ο Bil είναι ενεργός και θα σε ενημερώνει για νέες ειδοποιήσεις.'),80)}}catch(e){}}
function install(){I().openExactNotificationMessageCenterButtonV249526=openExternalCenter;window.openExactNotificationMessageCenterButtonV249526=openExternalCenter;css();installOwners();canonical();document.addEventListener('click',primeBilVoice,{capture:true,once:true});document.addEventListener('click',captureWall,true);maintain();patchBell();clearInterval(pollTimer);pollTimer=setInterval(poll,8000);setTimeout(poll,1200);clearInterval(syncTimer);syncTimer=setInterval(()=>syncExternal(false),60000);setTimeout(()=>syncExternal(false),3200);new MutationObserver(()=>{clearTimeout(install._m);install._m=setTimeout(()=>{maintain();patchBell()},60)}).observe(document.body,{subtree:true,childList:true});window.addEventListener('ithaki:page-changed',()=>setTimeout(maintain,60));['focus','pageshow'].forEach(n=>window.addEventListener(n,()=>{maintain();updateBadge()}));setInterval(maintain,1200)}
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',install,{once:true});else install();
})();
