(() => {
  'use strict';
  if (window.__APU_V636_TWO_PROJECT_FOOTER__) return;
  window.__APU_V636_TWO_PROJECT_FOOTER__ = true;
  const root = document.documentElement;
  const configNode = document.getElementById('apuProjectFooterConfig');
  let config = {};
  try { config = JSON.parse(configNode?.textContent || '{}'); } catch (_) {}
  const project = root.dataset.scrollTheme || config.slug || '';
  const PROJECT = {
    'computer-vision': {code:'P—01',line1:'COMPUTER VISION',line2:'IMAGE CLASSIFICATION',accent:'#FFD94D'},
    'incident-monitoring': {code:'P—02',line1:'INCIDENT MONITORING',line2:'OPERATIONS DASHBOARD',accent:'#48C7EF'}
  }[project] || config;
  if (!PROJECT || !PROJECT.line1) return;
  root.style.setProperty('--apu-v636-accent', PROJECT.accent || '#FFD94D');

  const words = {
    en:{copy:'A focused, responsive and Cloudflare Pages-ready standalone project.',privacy:'Privacy Policy',terms:'Terms of Service',cookies:'Cookie settings',label:'Project information'},
    id:{copy:'Proyek mandiri yang terfokus, responsif, dan siap untuk Cloudflare Pages.',privacy:'Kebijakan Privasi',terms:'Persyaratan Layanan',cookies:'Pengaturan cookie',label:'Informasi proyek'},
    ms:{copy:'Projek kendiri yang terfokus, responsif dan sedia untuk Cloudflare Pages.',privacy:'Dasar Privasi',terms:'Persyaratan Perkhidmatan',cookies:'Tetapan kuki',label:'Maklumat projek'},
    de:{copy:'Ein fokussiertes, responsives und für Cloudflare Pages vorbereitetes eigenständiges Projekt.',privacy:'Datenschutz',terms:'Nutzungsbedingungen',cookies:'Cookie-Einstellungen',label:'Projektinformationen'},
    vi:{copy:'Dự án độc lập, tập trung, đáp ứng và sẵn sàng cho Cloudflare Pages.',privacy:'Chính sách quyền riêng tư',terms:'Điều khoản dịch vụ',cookies:'Cài đặt cookie',label:'Thông tin dự án'},
    zh:{copy:'一个专注、响应式并适用于 Cloudflare Pages 的独立项目。',privacy:'隐私政策',terms:'服务条款',cookies:'Cookie 设置',label:'项目信息'},
    ja:{copy:'Cloudflare Pages対応の、集中型でレスポンシブな独立プロジェクトです。',privacy:'プライバシーポリシー',terms:'利用規約',cookies:'Cookie設定',label:'プロジェクト情報'}
  };
  function lang(){
    let value = root.dataset.apuLanguage || root.lang || '';
    try { value ||= localStorage.getItem('apu-ui-language') || ''; } catch (_) {}
    value = String(value || 'en').toLowerCase().split('-')[0];
    return words[value] ? value : 'en';
  }
  function esc(v){return String(v ?? '').replace(/[&<>"']/g,c=>({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#039;'}[c]));}
  function drawerContainers(){
    return [...document.querySelectorAll('.apu-v69-malaysia-menu,.apu-final-mobile-drawer,.apu-v5-mobile-nav-drawer,.apu-mobile-drawer-v65,.ai-architect-drawer')];
  }
  function createFooter(){
    const footer = document.createElement('div');
    footer.className = 'apu-v636-drawer-footer';
    footer.setAttribute('role','group');
    footer.style.setProperty('--apu-v636-local-accent',PROJECT.accent || '#FFD94D');
    footer.innerHTML = `<p class="apu-v636-drawer-footer__code">${esc(PROJECT.code || 'PROJECT')} · <span data-v636-label></span></p><p class="apu-v636-drawer-footer__brand"><span>${esc(PROJECT.line1)}</span><span>${esc(PROJECT.line2 || '')}</span></p><p class="apu-v636-drawer-footer__copy" data-v636-copy></p><nav class="apu-v636-drawer-footer__links" aria-label=""><a href="/privacy.html" data-v636-privacy></a><a href="/terms.html" data-v636-terms></a><button type="button" data-apu-v636-cookie data-v636-cookies></button></nav><div class="apu-v636-drawer-footer__symbols" aria-hidden="true"><span>★</span><span>∞</span><span>◉</span><span>✦</span></div>`;
    footer.querySelector('[data-apu-v636-cookie]')?.addEventListener('click',()=>{
      const existing = [...document.querySelectorAll('[data-cookie-settings]')].find(node => !node.closest('.apu-v636-drawer-footer'));
      if (existing) { existing.click(); return; }
      const panel = document.getElementById('apuCookiePanel');
      if (panel) { panel.hidden = false; panel.style.removeProperty('display'); }
    });
    return footer;
  }
  function updateFooter(footer){
    const dict = words[lang()];
    footer.querySelector('[data-v636-label]').textContent = dict.label;
    footer.querySelector('[data-v636-copy]').textContent = dict.copy;
    footer.querySelector('[data-v636-privacy]').textContent = dict.privacy;
    footer.querySelector('[data-v636-terms]').textContent = dict.terms;
    footer.querySelector('[data-v636-cookies]').textContent = dict.cookies;
    footer.querySelector('.apu-v636-drawer-footer__links')?.setAttribute('aria-label',dict.label);
  }
  function mountDrawerFooters(){
    drawerContainers().forEach(container => {
      let footer = container.querySelector(':scope > .apu-v636-drawer-footer');
      if (!footer) {
        footer = createFooter();
        container.appendChild(footer);
      }
      updateFooter(footer);
    });
    document.querySelectorAll('.apu-v636-drawer-footer').forEach(updateFooter);
    root.dataset.apuV636DrawerFooter = 'true';
  }
  function ensurePageFooter(){
    const footer = document.getElementById('apuProjectFooter');
    if (footer) {
      footer.hidden = false;
      footer.removeAttribute('aria-hidden');
      footer.style.setProperty('display','block','important');
      footer.style.setProperty('visibility','visible','important');
      footer.style.setProperty('opacity','1','important');
    }
  }
  let timer = 0;
  const schedule = () => { clearTimeout(timer); timer = setTimeout(()=>{mountDrawerFooters();ensurePageFooter();},24); };
  if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded',schedule,{once:true}); else schedule();
  addEventListener('load',schedule,{once:true});
  addEventListener('apu:languagechange',schedule);
  addEventListener('apu:viewer-language-change',schedule);
  addEventListener('storage',e=>{if(e.key==='apu-ui-language')schedule();});
  document.addEventListener('click',e=>{if(e.target.closest?.('.apu-v69-native-toggle,.apu-final-mobile-menu,[aria-controls*="Drawer" i]')) [0,50,160,420].forEach(d=>setTimeout(schedule,d));},true);
  const observer = new MutationObserver(schedule);
  observer.observe(document.documentElement,{subtree:true,childList:true,attributes:true,attributeFilter:['lang','data-apu-language','class','aria-expanded']});
  setTimeout(()=>observer.disconnect(),18000);
  [120,420,1100,2600,5200].forEach(d=>setTimeout(schedule,d));
})();
