import {branches,branchContactSeed,contactEdit} from './core.mjs' import {maps} from './maps.mjs' import {socials} from './social.mjs' const preview=new URLSearchParams(location.search).get('mode')==='preview' const $=id=>document.getElementById(id) if(preview)for(const id of ['home','back'])$(id).href='./index.html?mode=preview' function node(tag,text,cls){const e=document.createElement(tag);e.textContent=text;if(cls)e.className=cls;return e} function link(label,href,cls='outline',external=true){const a=node('a',label,cls);a.href=href;if(external){a.target='_blank';a.rel='noopener noreferrer'}return a} let saved={} if(preview){try{saved=JSON.parse(localStorage.getItem('noor-local-admin-workbench-v2')||'{}')?.contacts||{}}catch{}} for(const b of branches){ const card=node('article','','card') let phone=branchContactSeed[b.id]?.phone||'' if(preview&&saved[b.id])try{phone=contactEdit(b.id,saved[b.id].phone,'').phone}catch{} card.append(node('span','فرع النور الشامي','eyebrow'),node('h3',b.name),node('p',maps[b.id].address)) const actions=node('div','','controls') actions.append(link('خرائط Google',maps[b.id].map)) if(phone){ const tel=link('اتصل بفرع '+b.name,'tel:'+phone,'btn',false) card.append(node('span',phone,'branchNumber'));actions.append(tel) } card.append(actions);$('contactBranches').append(card) } for(const x of socials)$('social').append(link(x.label,x.url))