(function () { "use strict"; // جميع الأوقات بتوقيت مكة المكرمة var START_MS = Date.parse("2026-11-09T08:00:00+03:00"); var END_MS = Date.parse("2026-11-18T15:00:00+03:00"); var root = document.getElementById("taatheem-tender"); if (!root) return; function get(id) { return root.querySelector("#" + id); } var status = get("tt-status"); var heading = get("tt-timer-heading"); var note = get("tt-countdown-note"); var fields = [ get("tt-days"), get("tt-hours"), get("tt-minutes"), get("tt-seconds") ]; if ( !status || !heading || !note || fields.some(function (x) { return !x; }) ) return; function pad(number) { return String(number).padStart(2, "0"); } function update() { var now = Date.now(); var target; if (now < START_MS) { // المرحلة الأولى: قبل بدء المنافسة target = START_MS; status.textContent = "● المنافسة لم تبدأ بعد"; status.style.background = "#fff1d6"; status.style.color = "#875a17"; heading.textContent = "الوقت المتبقي لبدء المنافسة"; note.textContent = "تبدأ يوم الاثنين 9 نوفمبر 2026م، " + "الساعة 8:00 صباحًا بتوقيت مكة المكرمة"; } else if (now < END_MS) { // المرحلة الثانية: المنافسة مفتوحة target = END_MS; status.textContent = "● بدأت المنافسة – استقبال العروض مفتوح"; status.style.background = "#d8f7e5"; status.style.color = "#126b39"; heading.textContent = "الوقت المتبقي لإغلاق استقبال العروض"; note.textContent = "تُغلق يوم الأربعاء 18 نوفمبر 2026م، " + "الساعة 3:00 مساءً بتوقيت مكة المكرمة"; } else { // المرحلة الثالثة: انتهاء المنافسة target = now; status.textContent = "● انتهت المنافسة – استقبال العروض مغلق"; status.style.background = "#e5ebec"; status.style.color = "#455c63"; heading.textContent = "انتهى الوقت المخصص لتقديم العروض"; note.textContent = "أُغلق استقبال العروض يوم الأربعاء " + "18 نوفمبر 2026م، الساعة 3:00 مساءً " + "بتوقيت مكة المكرمة"; } var total = Math.max( 0, Math.floor((target - now) / 1000) ); var values = [ Math.floor(total / 86400), Math.floor((total % 86400) / 3600), Math.floor((total % 3600) / 60), total % 60 ]; values.forEach(function (value, index) { fields[index].textContent = pad(value); }); } update(); var timer = setInterval(function () { update(); if (Date.now() >= END_MS) { clearInterval(timer); } }, 1000); })();