(()=>{'use strict';
window.ITHAKI_R10F32_PRO_PROFILE_DIRECT_CREATOR=true;
const $=id=>document.getElementById(id);
const esc=s=>String(s??'').replace(/[&<>"']/g,m=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[m]));
const I=()=>window.ITH||{};
function uiLang(){try{return String(localStorage.getItem('ith_ui_lang_v249141')||localStorage.getItem('ith_ui_lang')||'el').startsWith('en')?'en':'el'}catch(_){return'el'}}
function tr(el,en){return uiLang()==='en'?en:el}
function nickname(){try{return String((window.state&&state.name)||localStorage.getItem('ith_name')||tr('Μέλος','Member'))}catch(_){return tr('Μέλος','Member')}}
function avatar(){try{if(typeof window.avatarHtml==='function')return window.avatarHtml({nickname:nickname(),avatar:window.avatarValue?window.avatarValue():''})}catch(_){}return `<span class="r32FallbackAvatar">${esc((nickname()[0]||'Μ').toUpperCase())}</span>`}
function addCss(){if($('ithR32Css'))return;const s=document.createElement('style');s.id='ithR32Css';s.textContent=`
#profilePage .r32Profile{width:min(780px,calc(100% - 20px));margin:12px auto 120px;display:grid;gap:14px;color:#edf7ff}
.r32Card{border:1px solid rgba(91,197,255,.24);border-radius:22px;background:linear-gradient(155deg,rgba(6,27,48,.98),rgba(7,49,68,.95));box-shadow:0 18px 52px rgba(0,0,0,.34);padding:18px}
.r32Head{display:flex;align-items:center;gap:14px}.r32Head h2{margin:0;color:#f7d975;text-align:left}.r32Sub{font-size:13px;color:#a9c7d8}.r32Back{width:42px;height:42px;border-radius:14px;border:1px solid rgba(255,255,255,.22);background:#0b314d;color:white;font-size:25px}.r32Identity{display:grid;grid-template-columns:auto 1fr;gap:16px;align-items:center;margin-top:16px}.r32AvatarBox{display:grid;justify-items:center;gap:9px}.r32AvatarBox .avatar,.r32FallbackAvatar{width:92px!important;height:92px!important;border-radius:50%;display:grid!important;place-items:center;font-size:38px;background:linear-gradient(135deg,#19bdf3,#634eea,#f3c452);border:3px solid #f0cf6b;box-shadow:0 0 0 5px rgba(240,207,107,.12)}
.r32Field{display:grid;gap:6px;margin-top:12px}.r32Field label{font-weight:800;color:#d8eaf4}.r32Field input,.r32Field textarea,.r32Field select{width:100%;border:1px solid rgba(255,255,255,.18);border-radius:14px;background:#061f34;color:#fff;padding:12px 13px;font:inherit}.r32Field textarea{min-height:66px;resize:vertical}.r32Row{display:flex;gap:8px;flex-wrap:wrap}.r32Btn{border:1px solid rgba(111,213,255,.35);border-radius:13px;background:#0b3857;color:#fff;padding:11px 14px;font-weight:800;cursor:pointer}.r32Btn:hover{transform:translateY(-1px);border-color:#f0cf6b}.r32Gold{background:linear-gradient(135deg,#b98420,#f5dc83)!important;color:#142031!important;border-color:#ffe9a8!important}.r32LangMenu{margin-top:12px}.r32LangMenu>summary{list-style:none;cursor:pointer;display:flex;justify-content:space-between;align-items:center;padding:13px 15px;border:1px solid rgba(240,207,107,.48);border-radius:15px;background:linear-gradient(135deg,#0b3555,#104f66);font-weight:900;color:#f4dc87}.r32LangMenu>summary::-webkit-details-marker{display:none}.r32LangBody{display:grid;gap:12px;margin-top:9px;padding:14px;border-radius:16px;background:#061c30;border:1px solid rgba(255,255,255,.09)}.r32Mode button.on{background:linear-gradient(135deg,#b98420,#f5dc83);color:#142031}.r32Checks{display:grid;gap:9px;margin-top:12px}.r32Check{display:flex;align-items:center;gap:10px;padding:11px;border-radius:14px;background:rgba(255,255,255,.045)}.r32Actions{display:grid;grid-template-columns:1fr 1fr;gap:10px}.r32Actions .r32Btn{min-height:52px}.r32Note{font-size:12px;color:#9fc2d5}.r32Admin{position:fixed;inset:0;z-index:2147483000;background:rgba(0,0,0,.78);display:grid;place-items:center;padding:14px}.r32Modal{width:min(680px,100%);max-height:92vh;overflow:auto;background:#06182b;border:1px solid rgba(240,207,107,.58);border-radius:22px;padding:17px}.r32Msg{padding:11px;border-radius:13px;background:rgba(255,255,255,.055);margin-top:8px}.r32Reply{margin-top:7px;border-left:3px solid #efc958;padding:8px;background:rgba(239,201,88,.09)}
#ithProCenterV249477 .ith477Header h3,#ithProCenterV249477 .ith477Top h3{color:#f5d97b!important}
@media(max-width:640px){#profilePage .r32Profile{width:calc(100% - 12px);margin-top:6px}.r32Card{padding:14px;border-radius:18px}.r32Identity{grid-template-columns:1fr}.r32AvatarBox{justify-items:start}.r32Actions{grid-template-columns:1fr}.r32Head{align-items:flex-start}.r32Head h2{font-size:22px}}
`;document.head.appendChild(s)}
function mode(){try{return localStorage.getItem('ith_translation_mode_r10f32')||'manual'}catch(_){return'manual'}}
function target(){try{return localStorage.getItem('ith_translation_target_lang')||'en'}catch(_){return'en'}}
function setMode(v){localStorage.setItem('ith_translation_mode_r10f32',v);localStorage.setItem('ith_auto_translate_content_r10f8',v==='auto'?'1':'0');renderProfileR32()}
function setTarget(v){localStorage.setItem('ith_translation_target_lang',v)}
function setMenu(v){try{if(typeof I().setUiLang==='function')I().setUiLang(v);else{localStorage.setItem('ith_ui_lang_v249141',v);localStorage.setItem('ith_ui_lang',v);location.reload()}}catch(_){}}
function saveAbout(){const x=$('r32About');if(x)localStorage.setItem('ith_profile_about_r10f32',String(x.value||'').slice(0,180))}
function renderProfileR32(){const p=$('profilePage');if(!p)return false;const about=localStorage.getItem('ith_profile_about_r10f32')||localStorage.getItem('ith_profile_about_r10f31f7')||'';const m=mode(),t=target();p.innerHTML=`<main class="r32Profile" data-r10f32-profile="1"><section class="r32Card"><div class="r32Head"><button class="r32Back" id="r32Back">‹</button><div><h2>${tr('Επαγγελματικό προφίλ','Professional profile')}</h2><div class="r32Sub">${tr('Καθαρό, απλό και ολοκληρωμένο με μία ματιά.','Clean, simple and complete at a glance.')}</div></div></div><div class="r32Identity"><div class="r32AvatarBox">${avatar()}<div class="r32Row"><button class="r32Btn" id="r32Camera">📷</button><button class="r32Btn" id="r32Photo">🖼️</button><button class="r32Btn" id="r32Animal">🐾</button></div></div><div><div class="r32Field"><label>${tr('Όνομα / ψευδώνυμο','Name / nickname')}</label><input id="profName" value="${esc(nickname())}" autocomplete="nickname"></div><div id="animalBox" class="r32Row" style="display:none;margin-top:8px"></div><details class="r32LangMenu"><summary><span>🌐 ${tr('Γλώσσα και μετάφραση','Language and translation')}</span><span>⌄</span></summary><div class="r32LangBody"><div><b>${tr('Γλώσσα μενού','Menu language')}</b><div class="r32Row" style="margin-top:7px"><button class="r32Btn ${uiLang()==='el'?'r32Gold':''}" data-ui="el">Ελληνικά</button><button class="r32Btn ${uiLang()==='en'?'r32Gold':''}" data-ui="en">English</button></div></div><div><b>${tr('Τρόπος μετάφρασης','Translation mode')}</b><div class="r32Row r32Mode" style="margin-top:7px"><button class="r32Btn ${m==='auto'?'on':''}" data-mode="auto">${tr('Αυτόματη','Automatic')}</button><button class="r32Btn ${m==='manual'?'on':''}" data-mode="manual">${tr('Χειροκίνητη','Manual')}</button></div></div><div class="r32Field"><label>${tr('Γλώσσα μετάφρασης','Translation language')}</label><select id="r32Target"><option value="el" ${t==='el'?'selected':''}>Ελληνικά</option><option value="en" ${t==='en'?'selected':''}>English</option></select></div><div class="r32Note">${tr('Εσωτερικό λεξικό Ελληνικά ↔ Αγγλικά.','Internal Greek ↔ English dictionary.')}</div></div></details><div class="r32Field"><label>${tr('Λίγα λόγια για εσένα — προαιρετικά','A few words about you — optional')}</label><textarea id="r32About" maxlength="180" placeholder="${tr('Μία σύντομη σειρά που σε περιγράφει…','One short line about you…')}">${esc(about)}</textarea></div></div></div><div class="r32Checks"><label class="r32Check"><input id="age16" type="checkbox" ${(window.state&&state.age16)?'checked':''}><span>${tr('Είμαι άνω των 16 ετών.','I am over 16 years old.')}</span></label><label class="r32Check"><input id="policyOk" type="checkbox" ${(window.state&&state.policyOk)?'checked':''}><span>${tr('Συμφωνώ με την πολιτική και τους όρους χρήσης.','I agree to the policy and terms of use.')}</span></label></div><div class="r32Row" style="margin-top:12px"><button class="r32Btn r32Gold" id="r32Save">💾 ${tr('Αποθήκευση προφίλ','Save profile')}</button></div></section><section class="r32Card"><div class="r32Actions"><button class="r32Btn" id="r32Admin">💬 ${tr('Άμεση επαφή διαχειριστή','Direct administrator contact')}</button><button class="r32Btn r32Gold" id="r32Creator">🛠️ ${tr('Εργαλεία δημιουργού','Creator tools')}</button></div></section></main>`;
$('r32Back').onclick=()=>I().page?.('home');$('r32Camera').onclick=()=>I().avatarPick?.('camera');$('r32Photo').onclick=()=>I().avatarPick?.('file');$('r32Animal').onclick=()=>I().showAnimals?.();$('r32About').oninput=saveAbout;$('r32Save').onclick=()=>{saveAbout();return I().saveProfile?.()};$('r32Admin').onclick=openAdmin;$('r32Creator').onclick=openCreatorTools;p.querySelectorAll('[data-ui]').forEach(b=>b.onclick=()=>setMenu(b.dataset.ui));p.querySelectorAll('[data-mode]').forEach(b=>b.onclick=()=>setMode(b.dataset.mode));$('r32Target').onchange=e=>setTarget(e.target.value);return true}
function apiBase(){try{return String((window.state&&state.api)||localStorage.getItem('ith_server_base')||location.origin).replace(/\/$/,'')}catch(_){return location.origin}}
function room(){try{return String((window.state&&state.room)||localStorage.getItem('ith_room')||'ithaki-phone-test')}catch(_){return'ithaki-phone-test'}}
function device(){try{return String((window.state&&state.device)||localStorage.getItem('ith_device')||'')}catch(_){return''}}
async function request(path,opt={}){const r=await fetch(apiBase()+path,{credentials:'same-origin',headers:{'Content-Type':'application/json'},...opt}),tx=await r.text();let d={};try{d=JSON.parse(tx)}catch(_){d={message:tx}}if(!r.ok)throw Error(d.detail||d.error||d.message||('HTTP '+r.status));return d}
async function loadThread(){const b=$('r32Thread');if(!b)return;b.innerHTML=tr('Φόρτωση…','Loading…');try{const d=await request(`/api/feedback/status?room_id=${encodeURIComponent(room())}&device_id=${encodeURIComponent(device())}&limit=80&_v=${Date.now()}`),a=Array.isArray(d.feedback)?d.feedback:[];b.innerHTML=a.length?a.map(x=>`<div class="r32Msg"><b>${esc(x.subject||tr('Μήνυμα','Message'))}</b><div>${esc(x.message||'')}</div>${x.admin_reply?`<div class="r32Reply"><b>${tr('Απάντηση διαχειριστή','Administrator reply')}</b><div>${esc(x.admin_reply)}</div></div>`:`<small>${tr('Αναμονή απάντησης','Waiting for reply')}</small>`}</div>`).join(''):`<div class="r32Note">${tr('Δεν υπάρχει ακόμη επικοινωνία.','No contact yet.')}</div>`}catch(e){b.innerHTML=`<div class="r32Note">${esc(e.message)}</div>`}}
async function sendAdmin(){const ta=$('r32AdminText'),sub=$('r32AdminSubject'),txt=String(ta?.value||'').trim();if(!txt)return;const b=$('r32AdminSend');b.disabled=true;try{await request('/api/feedback/send',{method:'POST',body:JSON.stringify({room_id:room(),device_id:device(),nickname:nickname(),subject:String(sub?.value||'').trim()||tr('Άμεση επαφή','Direct contact'),contact_kind:'professional',screen:'profile-r10f32',message:txt,user_agent:navigator.userAgent||'',professional_member:true})});ta.value='';await loadThread()}catch(e){alert(e.message)}finally{b.disabled=false}}
function openAdmin(){document.getElementById('r32AdminModal')?.remove();const x=document.createElement('section');x.id='r32AdminModal';x.className='r32Admin';x.innerHTML=`<div class="r32Modal"><div class="r32Head"><div><h2>${tr('Άμεση επαφή διαχειριστή','Direct administrator contact')}</h2><div class="r32Sub">${tr('Το μήνυμα και η απάντηση μένουν στο ίδιο σημείο.','Message and reply stay in the same place.')}</div></div><button class="r32Back" id="r32AdminClose">×</button></div><div class="r32Field"><label>${tr('Θέμα','Subject')}</label><input id="r32AdminSubject" maxlength="120"></div><div class="r32Field"><label>${tr('Μήνυμα','Message')}</label><textarea id="r32AdminText" maxlength="2500"></textarea></div><div class="r32Row"><button class="r32Btn r32Gold" id="r32AdminSend">${tr('Αποστολή','Send')}</button><button class="r32Btn" id="r32AdminRefresh">${tr('Ανανέωση','Refresh')}</button></div><div id="r32Thread"></div></div>`;document.body.appendChild(x);$('r32AdminClose').onclick=()=>x.remove();$('r32AdminSend').onclick=sendAdmin;$('r32AdminRefresh').onclick=loadThread;x.onclick=e=>{if(e.target===x)x.remove()};loadThread()}
function openCreatorTools(){const f=I().openProfessionalCreatorToolsV249496||I().openProfessionalCreatorToolsV249477;if(typeof f==='function')return f();const open=I().openProfessionalCenterV249477||I().openProfessionalCenterFastV249392;if(typeof open==='function'){open();setTimeout(()=>{const tile=[...document.querySelectorAll('#ithProCenterV249477 button,[data-tab]')].find(e=>/εργαλεία δημιουργού|creator tools/i.test(e.textContent||''));tile?.click()},80);return false}alert(tr('Τα Εργαλεία Δημιουργού δεν φορτώθηκαν.','Creator tools did not load.'));return false}
function installHooks(){const ith=I();if(!ith.__r32PageWrapped&&typeof ith.page==='function'){const old=ith.page.bind(ith);ith.page=function(name,...a){const r=old(name,...a);if(String(name)==='profile')setTimeout(renderProfileR32,0);return r};ith.__r32PageWrapped=true}ith.renderProfessionalProfileR10F32=renderProfileR32;ith.openAdministratorContactR10F32=openAdmin;ith.openCreatorToolsDirectR10F32=openCreatorTools}
function maintain(){addCss();installHooks();if(String(document.body?.dataset?.page||'')==='profile'){const p=$('profilePage');if(p&&!p.querySelector('[data-r10f32-profile="1"]'))renderProfileR32()}document.documentElement.dataset.ithakiR10f32='professional-profile-direct-creator'}
new MutationObserver(()=>requestAnimationFrame(maintain)).observe(document.documentElement,{subtree:true,childList:true});addEventListener('DOMContentLoaded',maintain);addEventListener('load',maintain);setInterval(maintain,700);maintain();
})();