/* SAN AVELIO - PROFILE PHOTO CARD - CLEAN BASE v21
FULL REPLACEMENT CONTENT FOR 89779.txt.
Rebuilt from the last user-supplied working photo-card base.
Does not touch 12993 / 70119 / HTML-bottom / map.
*/
(function(){
'use strict';
function isView(){
if(!/\/profile\.php$/i.test(location.pathname)) return false;
var p=new URLSearchParams(location.search);
return !p.has('section')&&!p.has('action')&&!p.has('edit')&&!p.has('p')&&!p.has('page')&&!p.has('mode')&&!p.has('form');
}
function install(){
if(!isView() || document.getElementById('sa-photo-clean-v21')) return;
var root=document.getElementById('sa-dossier-clean');
if(!root) return;
var portrait=root.querySelector('.portrait');
if(!portrait) return;
var deco=document.createElement('div');
deco.className='sa-id-decor-work';
deco.innerHTML=
'
ARCHIVIO CIVICO0002
'+
'RESIDENTE / SAN AVELIO'+
'REGISTRO CIVICO · IDENTITA
';
portrait.appendChild(deco);
var st=document.createElement('style');
st.id='sa-photo-clean-v21';
st.textContent=`
#sa-dossier-clean .head{grid-template-columns:290px minmax(0,1fr)!important}
#sa-dossier-clean .identity{padding-left:38px!important;padding-right:38px!important}
#sa-dossier-clean .portrait{
position:relative!important;display:block!important;box-sizing:border-box!important;
width:auto!important;min-height:0!important;height:500px!important;padding:0!important;overflow:hidden!important;
border-right:1px solid rgba(199,154,79,.34)!important;
}
#sa-dossier-clean .portrait:before{
content:""!important;display:block!important;position:absolute!important;
left:36px!important;right:24px!important;top:26px!important;bottom:26px!important;
width:auto!important;height:auto!important;transform:none!important;box-sizing:border-box!important;
border:1px solid rgba(205,158,70,.30)!important;
background:
linear-gradient(rgba(205,158,70,.09),rgba(205,158,70,.09)) 20px 52px/calc(100% - 40px) 1px no-repeat,
linear-gradient(rgba(205,158,70,.07),rgba(205,158,70,.07)) 20px calc(100% - 76px)/calc(100% - 40px) 1px no-repeat!important;
box-shadow:none!important;opacity:1!important;z-index:1!important;
}
#sa-dossier-clean .portrait:after{
content:"IDENTITY / CIVIC RECORD / 0002"!important;display:block!important;position:absolute!important;
left:-14px!important;top:50%!important;right:auto!important;bottom:auto!important;width:auto!important;
transform:translateY(-50%) rotate(-90deg)!important;transform-origin:center!important;color:#d3a24b!important;
font:500 9px/1 Georgia,"Times New Roman",serif!important;letter-spacing:2.4px!important;
white-space:nowrap!important;opacity:.82!important;z-index:4!important;
}
#sa-dossier-clean .portrait img,
#sa-dossier-clean .portrait img.sa-avatar-native{
position:absolute!important;z-index:5!important;left:calc(50% + 6px)!important;top:50%!important;
right:auto!important;bottom:auto!important;transform:translate(-50%,-50%)!important;
max-width:180px!important;max-height:250px!important;min-width:0!important;min-height:0!important;
object-fit:contain!important;filter:none!important;margin:0!important;padding:4px!important;box-sizing:content-box!important;
background:#071b1e!important;border:1px solid rgba(222,174,84,.72)!important;
box-shadow:0 0 0 7px #092327,0 0 0 8px rgba(205,158,70,.28),0 13px 26px rgba(0,0,0,.30)!important;
}
#sa-dossier-clean .sa-id-decor-work{
position:absolute!important;inset:0!important;z-index:3!important;pointer-events:none!important;
color:#d8a94f!important;font-family:Georgia,"Times New Roman",serif!important;
}
#sa-dossier-clean .sa-id-top-work{
position:absolute!important;top:39px!important;left:58px!important;right:46px!important;height:32px!important;
display:grid!important;grid-template-columns:1fr auto!important;align-items:start!important;
font-size:10px!important;font-weight:600!important;letter-spacing:2.2px!important;
}
#sa-dossier-clean .sa-id-top-work b{font-size:10px!important;font-weight:600!important;letter-spacing:2px!important}
#sa-dossier-clean .sa-id-top-work i{
grid-column:1/-1!important;display:block!important;height:1px!important;margin-top:11px!important;
background:linear-gradient(90deg,rgba(205,158,70,.55),rgba(205,158,70,.08))!important;opacity:.55!important;
}
#sa-dossier-clean .sa-id-bottom-work{
position:absolute!important;left:58px!important;right:46px!important;bottom:35px!important;min-height:42px!important;
font-size:9px!important;font-weight:600!important;letter-spacing:1.8px!important;line-height:1.25!important;
}
#sa-dossier-clean .sa-id-bottom-work>span{display:block!important;white-space:nowrap!important;opacity:.88!important}
#sa-dossier-clean .sa-id-bottom-work>i{
display:block!important;width:72px!important;height:7px!important;margin:11px 0 9px!important;opacity:.42!important;
background:repeating-linear-gradient(90deg,rgba(210,164,78,.85) 0 1px,transparent 1px 5px)!important;
}
#sa-dossier-clean .sa-id-bottom-work small{
display:block!important;font-size:7px!important;font-weight:400!important;letter-spacing:1.35px!important;line-height:1.2!important;opacity:.72!important;
}
@media(max-width:760px){
#sa-dossier-clean .head{grid-template-columns:1fr!important}
#sa-dossier-clean .portrait{height:500px!important}
#sa-dossier-clean .identity{padding-left:24px!important;padding-right:24px!important}
}
`;
document.head.appendChild(st);
}
function start(){
install();
new MutationObserver(install).observe(document.documentElement,{childList:true,subtree:true});
setTimeout(install,250);setTimeout(install,800);
}
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',start,{once:true});else start();
})();
/* SAN AVELIO — PROFILE DATA v40 / SHARED STORAGE
Public read + owner-only write through the same Rusff storage API already used
by SAN AVELIO shared map storage. No navigation, no profile form POST.
*/
(function(){
'use strict';
var APP_ID=1887506;
var API=location.origin+'/api.php';
var PREFIX='san_avelio_profile_v1_';
var data=null, uid='', saving=false;
function q(){return new URLSearchParams(location.search)}
function blank(){return {fullName:'',age:'',occupation:'',residence:'',status:'',dossier:'',relations:'',chronicle:'',places:''}}
function norm(o){
var d=blank();o=o&&typeof o==='object'?o:{};
Object.keys(d).forEach(function(k){d[k]=o[k]==null?'':String(o[k])});
return d;
}
function parseSA(v){
var m=String(v||'').trim().match(/^SA\d+:([\s\S]*)$/);
if(!m)return null;
try{return norm(JSON.parse(m[1]))}catch(e){return null}
}
function key(){return PREFIX+String(uid)}
function jq(){return window.jQuery||window.$||null}
function token(){
try{if(window.ForumAPITicket)return String(window.ForumAPITicket)}catch(e){}
try{if(typeof ForumAPITicket!=='undefined'&&ForumAPITicket)return String(ForumAPITicket)}catch(e){}
return '';
}
function serverValue(j,k){
try{
var v=j&&j.response&&j.response.storage&&j.response.storage.data&&j.response.storage.data[k];
if(v==null||v==='')return null;
if(typeof v==='string')return norm(JSON.parse(v));
return v&&typeof v==='object'?norm(v):null;
}catch(e){return null}
}
function serverGet(){
var $=jq(),k=key();
if(!$||!$.ajax)return Promise.reject(new Error('jQuery unavailable'));
return new Promise(function(resolve,reject){
$.ajax({
url:API,type:'GET',dataType:'json',cache:false,
data:{method:'storage.get',app_id:APP_ID,key:[k],_:Date.now()},
success:function(j){
if(j&&(j.error||j.errors))return reject(new Error('storage.get'));
resolve(serverValue(j,k));
},
error:function(x){reject(new Error('storage.get HTTP '+x.status))}
});
});
}
function serverSet(obj){
var $=jq(),t=token();
if(!$||!$.ajax)return Promise.reject(new Error('jQuery unavailable'));
if(!t)return Promise.reject(new Error('ForumAPITicket unavailable'));
return new Promise(function(resolve,reject){
$.ajax({
url:API,type:'POST',dataType:'json',cache:false,
data:{method:'storage.set',app_id:APP_ID,key:key(),value:JSON.stringify(norm(obj)),token:t},
success:function(j){
if(j&&(j.error||j.errors))return reject(new Error('storage.set'));
resolve(j);
},
error:function(x){reject(new Error('storage.set HTTP '+x.status))}
});
});
}
/* One-time source for an owner whose shared profile has not yet been published. */
async function nativeData(){
try{
var r=await fetch('/profile.php?section=fields&id='+encodeURIComponent(uid)+'&_sa40='+Date.now(),
{credentials:'same-origin',cache:'no-store'});
if(!r.ok)return null;
var doc=new DOMParser().parseFromString(await r.text(),'text/html');
var f=doc.getElementById('fld1');
if(f){var d=parseSA(f.value||'');if(d)return d}
var a=doc.querySelectorAll('textarea,input');
for(var i=0;i