(function() {
var fontLink = document.createElement('link');
fontLink.rel = 'stylesheet';
fontLink.href = 'https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&family=Inter:wght@400;600;700&display=swap';
document.head.appendChild(fontLink);
var style = document.createElement('style');
style.innerHTML = `
body {
font-family: 'Cairo', sans-serif;
}
[dir="ltr"] {
font-family: 'Inter', sans-serif;
}
`;
document.head.appendChild(style);
})();
(function () {
function applyNewFooterLayout() {
var appsColumn = document.querySelector('.store-footer__apps');
var contactsRow = document.querySelector('.store-footer__contacts-row');
if (!appsColumn || !contactsRow) return false;
if (contactsRow.parentElement !== appsColumn) {
appsColumn.appendChild(contactsRow);
}
return true;
}
if (!applyNewFooterLayout()) {
var attempts = 0;
var interval = setInterval(function () {
attempts++;
if (applyNewFooterLayout() || attempts > 40) clearInterval(interval);
}, 250);
}
var observer = new MutationObserver(function () { applyNewFooterLayout(); });
observer.observe(document.documentElement, { childList: true, subtree: true });
})();
document.addEventListener('DOMContentLoaded', function () {
var sections = document.querySelectorAll('.s-block--enhanced-features');
if (sections.length > 0) {
sections[0].classList.add('target-first-block');
}
});
(function() {
const wheelImageUrl = 'https://i.ibb.co/4RCprztf/1-Copy-2.png';
const AUTO_SHOWN_KEY = 'salla_wheel_auto_shown_v3';
// رابط صفحة عروض اليوم الوطني
const nationalCategoryUrl = 'https://sa.pectiv.com/ar/%D8%B9%D8%B1%D9%88%D8%B6-%D8%A7%D9%8D%D9%8A%D9%88%D9%85-%D8%A7%D9%84%D9%88%D8%B7%D9%86%D9%8A/c1088349138';
// رابط صفحة المنتج الهدية (المحفظة النسائية)
const giftProductUrl = 'https://sa.pectiv.com/ar/%D8%A7%D9%84%D9%85%D8%AD%D9%81%D8%B8%D8%A9-%D8%A7%D9%84%D9%86%D8%B3%D8%A7%D8%A6%D9%8A%D8%A9/p798190773';
const prizes = [
{ name: "خصم 10%", code: "PT10", targetAngle: 30, type: "coupon" },
{ name: "شحن مجاني", code: "PTFREESHIP", targetAngle: 330, type: "coupon" },
{ name: "خصم على الباقات الوطنية", code: "NAT2026", targetAngle: 270, type: "link" },
{ name: "هدية مجانية مع الطلب", code: "PTGIFTFREE", targetAngle: 210, type: "gift" },
{ name: "خصم 20%", code: "PT20", targetAngle: 150, type: "coupon" },
{ name: "خصم 15%", code: "PT15", targetAngle: 90, type: "coupon" }
];
const widgetHTML = `
أدر العجلة واكسب جائزتك! 🎁
حسّك أخضر! أدر العجلة واكسب 🎁
`;
window.addEventListener('load', function() {
document.body.insertAdjacentHTML('beforeend', widgetHTML);
const modal = document.getElementById('js-wheel-modal');
const floatBtn = document.getElementById('js-wheel-floating-btn');
function openModal() {
modal.style.display = 'flex';
setTimeout(function() { modal.style.opacity = '1'; }, 50);
}
function closeModal() {
modal.style.opacity = '0';
setTimeout(function() { modal.style.display = 'none'; }, 400);
}
if (!sessionStorage.getItem(AUTO_SHOWN_KEY)) {
setTimeout(function() { openModal(); sessionStorage.setItem(AUTO_SHOWN_KEY, 'true'); }, 2000);
}
floatBtn.onclick = openModal;
document.getElementById('close-wheel-btn').onclick = closeModal;
document.getElementById('js-spin-btn').onclick = runSpinLogic;
document.getElementById('js-copy-btn').onclick = function() {
const input = document.getElementById('js-coupon-code');
input.select();
document.execCommand('copy');
this.innerText = 'تم النسخ! ✓';
this.style.background = '#985b67';
};
});
function runSpinLogic() {
const spinBtn = document.getElementById('js-spin-btn');
const img = document.getElementById('js-wheel-img');
const pointer = document.getElementById('js-wheel-pointer');
spinBtn.disabled = true;
spinBtn.style.opacity = '0.6';
spinBtn.innerText = 'جاري التدوير...';
pointer.classList.add('wheel-spinning-pointer');
const prize = prizes[Math.floor(Math.random() * prizes.length)];
const totalRotation = (360 * 6) + prize.targetAngle;
img.style.transform = `rotate(${totalRotation}deg)`;
setTimeout(function() {
pointer.classList.remove('wheel-spinning-pointer');
spinBtn.style.display = 'none';
const couponBox = document.getElementById('js-coupon-box');
const linkBox = document.getElementById('js-link-box');
const prizeText = document.getElementById('js-prize-text');
const catBtn = document.getElementById('js-cat-btn');
if (prize.type === 'link') {
prizeText.innerHTML = '🎉 استمتع بأقوى عروض اليوم الوطني!';
couponBox.style.display = 'none';
linkBox.style.display = 'block';
catBtn.innerText = 'تصفح عروض اليوم الوطني الآن 🇸🇦';
catBtn.href = nationalCategoryUrl;
} else if (prize.type === 'gift') {
prizeText.innerHTML = `
🎉 مبروك! حصلت على: ${prize.name}
انسخي الكود، اضغطي الزر واختاري اللون المفضل لإضافته للسلة!
`;
document.getElementById('js-coupon-code').value = prize.code;
couponBox.style.display = 'flex';
linkBox.style.display = 'block';
catBtn.innerText = 'اختر لون المحفظة واطلب الهدية 🎁';
catBtn.href = giftProductUrl;
} else {
prizeText.innerHTML = '🎉 مبروك! حصلت على: ' + prize.name + '';
document.getElementById('js-coupon-code').value = prize.code;
couponBox.style.display = 'flex';
linkBox.style.display = 'none';
}
document.getElementById('js-wheel-result').style.display = 'block';
}, 5100);
}
})();
(function () {
var TAG_BADGES = [
{
match: ['best seller'],
label: { en: 'Best Seller', ar: 'الأكثر مبيعاً' }
},
{
match: ['الاكثر مبيعا', 'الأكثر مبيعاً', 'الأكثر مبيعا'],
label: { en: 'Best Seller', ar: 'الأكثر مبيعاً' }
}
];
var fetchCache = new Map();
function getCurrentLocale() {
var htmlLang = document.documentElement.lang || '';
if (htmlLang.toLowerCase().startsWith('en')) return 'en';
return 'ar'; // افتراضي عربي
}
function normalize(str) {
return (str || '').trim().toLowerCase();
}
function findMatchedBadge(pageText) {
var normalizedPage = normalize(pageText);
for (var i = 0; i < TAG_BADGES.length; i++) {
var badge = TAG_BADGES[i];
for (var j = 0; j < badge.match.length; j++) {
if (normalizedPage.indexOf(normalize(badge.match[j])) !== -1) {
return badge;
}
}
}
return null;
}
function extractTagsTextFromDoc(doc) {
// بناخد كل النصوص اللي جوه روابط (a) في صفحة المنتج
// لأن الوسوم بتترندر كـ {{ tag.name }} حسب توثيق ثيمات سلة
var links = doc.querySelectorAll('a');
var combined = '';
links.forEach(function (a) {
combined += ' ' + (a.textContent || '');
});
return combined;
}
function injectBadge(card, badge) {
if (!card || card.querySelector('.custom-tag-badge')) return;
var imageWrap = card.querySelector('.product-card__image');
if (!imageWrap) return;
var locale = getCurrentLocale();
var span = document.createElement('span');
span.className = 'custom-tag-badge';
span.textContent = badge.label[locale] || badge.label.ar;
imageWrap.style.position = imageWrap.style.position || 'relative';
imageWrap.appendChild(span);
}
function getProductLink(card) {
var titleLink = card.querySelector('.product-card__title a');
if (titleLink && titleLink.href) return titleLink.href;
var imgLink = card.querySelector('.product-card__image a');
if (imgLink && imgLink.href) return imgLink.href;
return null;
}
function processCard(card) {
if (card.dataset.tagBadgeChecked === '1') return;
card.dataset.tagBadgeChecked = '1';
var url = getProductLink(card);
if (!url) return;
if (fetchCache.has(url)) {
fetchCache.get(url).then(function (badge) {
if (badge) injectBadge(card, badge);
});
return;
}
var promise = fetch(url, { credentials: 'same-origin' })
.then(function (res) {
return res.text();
})
.then(function (html) {
var doc = new DOMParser().parseFromString(html, 'text/html');
var tagsText = extractTagsTextFromDoc(doc);
return findMatchedBadge(tagsText);
})
.catch(function () {
return null;
});
fetchCache.set(url, promise);
promise.then(function (badge) {
if (badge) injectBadge(card, badge);
});
}
function scanAllCards() {
document
.querySelectorAll('custom-salla-product-card')
.forEach(processCard);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', scanAllCards);
} else {
scanAllCards();
}
var observer = new MutationObserver(function () {
scanAllCards();
});
observer.observe(document.body, { childList: true, subtree: true });
if (!document.getElementById('custom-tag-badge-style')) {
var style = document.createElement('style');
style.id = 'custom-tag-badge-style';
style.innerHTML = `
.custom-tag-badge {
position: absolute;
top: 10px;
inset-inline-start: 10px;
background: #985b67;
color: #ffffff;
font-size: 12px;
font-weight: 700;
padding: 4px 10px;
border-radius: 20px;
z-index: 5;
white-space: nowrap;
}
`;
document.head.appendChild(style);
}
})();
(function () {
var currentUrl = decodeURIComponent(window.location.href);
var isCustomBundlePage =
currentUrl.indexOf("صممي-باقتك") !== -1 ||
currentUrl.indexOf("Customise-your-Bundle") !== -1 ||
currentUrl.indexOf("page-2030586741") !== -1 ||
currentUrl.indexOf("page-1476492491") !== -1;
if (!isCustomBundlePage) {
return;
}
function detectLang() {
var path = (window.location.pathname || "").toLowerCase();
var pathSegments = path.split("/").filter(Boolean);
if (pathSegments[0] === "en") return "en";
if (pathSegments[0] === "ar") return "ar";
var htmlLang = (document.documentElement.getAttribute("lang") || "").toLowerCase();
if (htmlLang.indexOf("en") === 0) return "en";
if (htmlLang.indexOf("ar") === 0) return "ar";
try {
if (window.salla && salla.config && typeof salla.config.get === "function") {
var sallaLang = salla.config.get("language") || salla.config.get("store.locale");
if (sallaLang) return sallaLang.toLowerCase().indexOf("en") === 0 ? "en" : "ar";
}
} catch (e) {}
var navLang = (navigator.language || "ar").toLowerCase();
return navLang.indexOf("en") === 0 ? "en" : "ar";
}
var LANG = detectLang();
var DIR = LANG === "ar" ? "rtl" : "ltr";
var BANNERS = {
ar: "https://pub-1bc5afce57514c38b9c1ba5ebc27c031.r2.dev/image/w970--x-h250%20(1).jpg",
en: "https://pub-1bc5afce57514c38b9c1ba5ebc27c031.r2.dev/image/w970--x-h250%20(1).jpg"
};
var SECOND_BANNERS = {
ar: "https://pub-1bc5afce57514c38b9c1ba5ebc27c031.r2.dev/image/w1400-x-h497.jpg",
en: "https://pub-1bc5afce57514c38b9c1ba5ebc27c031.r2.dev/image/w1400-x-h497---en.jpg"
};
var SVG_ICONS = {
feather: '',
comfort: '',
absorb: '',
bacteria: '',
shield: '',
star: '',
heart: ''
};
var AR_SLIDES = [
[
{ title: "مناسبة للجلد الحساس", desc: "تمنع الطفح الجلدي، الحكة والحساسية", icon: SVG_ICONS.feather },
{ title: "راحة مطلقة", desc: "تمنع الرطوبة والرائحة الممزوجة", icon: SVG_ICONS.comfort },
{ title: "امتصاص ممتاز", desc: "قدرة امتصاص أعلى بـ 4 مرات - لا تسريب", icon: SVG_ICONS.absorb }
],
[
{ title: "حماية فائقة", desc: "تمنع نمو البكتيريا", icon: SVG_ICONS.bacteria },
{ title: "مناسبة للجلد الحساس", desc: "تمنع الطفح الجلدي، الحكة والحساسية", icon: SVG_ICONS.feather },
{ title: "راحة مطلقة", desc: "تمنع الرطوبة والرائحة الممزوجة", icon: SVG_ICONS.comfort }
]
];
var UI = {
ar: {
title: "صممي باقتك",
subtitle: "اختاري احتياجك من فوط PECTIV وكوّني باقتك الخاصة",
totalUnit: "عدد القطع",
totalPrice: "الإجمالي",
currency: "ريال",
addToCart: "أضيفي إلى السلة",
adding: "جارِ الإضافة...",
success: "تمت إضافة المنتجات للسلة بنجاح",
error: "حدث خطأ أثناء الإضافة للسلة",
empty: "اختاري قطعة واحدة على الأقل",
visionTitle: "أنوثة وثقة كبيرة",
visionDesc: "رؤية بكتيف: نؤمن بقوة أن كل امرأة تستحق العناية والاهتمام الفائق لتتمتع بصحتها النسائية على أكمل وجه. مهمتنا تقديم المنتجات النسائية الاستثنائية التي تفوق التوقعات. بكتيف تستحق ثقتك.",
featsTitle: "ميزات منتجاتنا"
},
en: {
title: "Customise your Bundle",
subtitle: "Pick what you need from PECTIV and build your own bundle",
totalUnit: "Items",
totalPrice: "Total",
currency: "SAR",
addToCart: "ADD TO CART",
adding: "ADDING...",
success: "Products added to cart successfully",
error: "An error occurred while adding to cart",
empty: "Pick at least one item",
visionTitle: "BOLD FEMININITY - CONFIDENCE BEYOND LIMITS",
visionDesc: "Crafting Exceptional Feminine Products That Exceed Expectations, Offering Ultimate Comfort & Convenience. Because You Deserve More Than Standard Care. As a leading brand dedicated to premium feminine care, we set out to redefine your daily routine, transforming it from a basic necessity into an elevated experience rooted in comfort, wellness, and luxury",
featsTitle: ""
}
};
var T = UI[LANG];
var products = [
{ id: 1514271525, price: 28.50, img: "https://cdn.files.salla.network/products/953599628/f3e3f493-5a04-4ce7-9edd-f5490cc88a31-original.webp", name: { ar: "الفوط النهارية", en: "The Regular" }, slugAr: "الفوط-النهارية" },
{ id: 2039737564, price: 28.50, img: "https://cdn.files.salla.network/products/953599628/fea5808e-6115-41e4-a64f-0d831c6f5862-original.webp", name: { ar: "الفوط الليلية", en: "The Night" }, slugAr: "الفوط-الليلية" },
{ id: 485344715, price: 28.50, img: "https://cdn.files.salla.network/products/953599628/f8edcfa6-0507-4269-8eeb-513e0dfec8f2-original.webp", name: { ar: "الفوط الليلية ماكسي", en: "The Overnight" }, slugAr: "الفوط-الليلية-ماكسي" },
{ id: 107869048, price: 26.50, img: "https://cdn.files.salla.network/products/953599628/90993253-cdd4-4c67-9562-70c5eebc47dd-original.webp", name: { ar: "فوط المراهقات", en: "The Teens" }, slugAr: "فوط-المراهقات" },
{ id: 581270208, price: 30.50, img: "https://cdn.files.salla.network/products/953599628/90993253-cdd4-4c67-9562-70c5eebc47dd-original.webp", name: { ar: "الفوط اليومية", en: "The Liners" }, slugAr: "الفوط-اليومية" },
{ id: 2085321862, price: 32.50, img: "https://cdn.files.salla.network/products/953599628/91c628f1-220c-4e29-9ad2-580e575ab7ed-original.webp", name: { ar: "الفوط اليومية الطويلة", en: "The Long Liners" }, slugAr: "الفوط-اليومية-الطويلة" },
{ id: 811160536, price: 32.50, img: "https://cdn.files.salla.network/products/953599628/7f197a3c-6c94-4e47-9d76-c5849bcf11b3-original.webp", name: { ar: "الفوط اليومية سترينج", en: "The Thongs" }, slugAr: "الفوط-اليومية-سترينج" }
];
function buildProductUrl(p) {
return window.location.origin + "/ar/" + encodeURIComponent(p.slugAr) + "/p" + p.id;
}
var styleTag = document.createElement("style");
styleTag.textContent = [
":root { --cb-primary:#985b67; --cb-primary-dark:#7a4a54; --cb-gold:#c9a876; --cb-ink:#2b2622; }",
".cb-native-title-hidden { display:none !important; }",
".cb-wrap { max-width:1200px; margin:0 auto; padding:30px 16px 40px; font-family: inherit; }",
".cb-head { text-align:center; margin-bottom:36px; }",
".cb-title { font-size:30px; font-weight:700; color:var(--cb-ink); margin-bottom:10px; }",
".cb-title:after { content:''; display:block; width:46px; height:2px; background:var(--cb-gold); margin:14px auto 0; }",
".cb-subtitle { font-size:14.5px; color:#9a9088; }",
".cb-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:26px; }",
"@media (max-width:1024px){ .cb-grid{ grid-template-columns:repeat(3,1fr);} }",
"@media (max-width:700px){ .cb-grid{ grid-template-columns:repeat(2,1fr); gap:16px;} }",
"@media (max-width:380px){ .cb-grid{ grid-template-columns:1fr; max-width:280px; margin:0 auto;} }",
".cb-card { background:#fff; border:1px solid #f1ebe7; border-radius:20px; padding:22px 18px; text-align:center; transition:all .3s ease; position:relative; }",
".cb-card:hover { box-shadow:0 16px 32px rgba(122,59,82,.14); transform:translateY(-5px); }",
".cb-card.is-active { border-color:var(--cb-primary); box-shadow:0 12px 28px rgba(122,59,82,.18); }",
".cb-img-box { background:none; border-radius:16px; aspect-ratio:1/1; display:flex; align-items:center; justify-content:center; overflow:hidden; margin-bottom:18px; position:relative; }",
".cb-img-box img { width:78%; height:78%; object-fit:contain; transition:transform .4s ease; }",
".cb-card:hover .cb-img-box img { transform:scale(1.07); }",
".cb-qty-pill { position:absolute; top:10px; inset-inline-end:10px; background:var(--cb-primary); color:#fff; font-size:11.5px; font-weight:700; min-width:22px; height:22px; padding:0 6px; border-radius:999px; display:flex; align-items:center; justify-content:center; opacity:0; transform:scale(.6); transition:all .2s ease; }",
".cb-card.is-active .cb-qty-pill { opacity:1; transform:scale(1); }",
".cb-name { font-weight:600; color:var(--cb-ink); margin-bottom:6px; font-size:15px; min-height:21px; }",
".cb-price { color:var(--cb-primary); font-size:15px; font-weight:700; margin-bottom:14px; position:relative; padding-bottom:14px; }",
".cb-price:after { content:''; position:absolute; bottom:0; left:50%; transform:translateX(-50%); width:26px; height:1.5px; background:var(--cb-gold); opacity:.7; }",
".cb-qty-row { display:flex; align-items:center; justify-content:space-between; direction:ltr; background:#fff; border:1px solid #ece7e5; border-radius:999px; padding:3px; max-width:150px; margin:0 auto; }",
".cb-btn { width:32px; height:32px; border-radius:50%; border:none; background:var(--cb-primary); color:#fff; font-size:17px; font-weight:600; cursor:pointer; display:flex; align-items:center; justify-content:center; }",
".cb-qty-input { width:36px; height:32px; text-align:center; border:none; background:transparent; font-size:15px; font-weight:700; color:var(--cb-ink); }",
".cb-inline-action { margin-top:40px; background:#faf7f5; border:1px solid #f1ebe7; border-radius:20px; padding:20px 30px; display:flex; align-items:center; justify-content:space-between; gap:20px; }",
".cb-summary { display:flex; gap:28px; font-size:13px; color:#a89b8f; }",
".cb-summary b { display:block; font-size:18px; color:var(--cb-ink); font-weight:700; }",
".cb-summary .cb-price-value { color:var(--cb-primary); }",
".cb-add-btn { flex:1; max-width:320px; background:linear-gradient(135deg,var(--cb-primary),var(--cb-primary-dark)); color:#fff; border:none; padding:16px 24px; font-size:15px; font-weight:700; cursor:pointer; border-radius:12px; }",
".cb-add-btn:disabled { background:#e3dcd8; cursor:not-allowed; }",
".cb-features-sec { max-width:1200px; margin:50px auto 30px; padding:0 16px; text-align:center; }",
".cb-sec-title { font-size:26px; font-weight:700; color:#4a423d; margin-bottom:30px; }",
".cb-features { display:grid; grid-template-columns:repeat(3,1fr); gap:24px; min-height:160px; transition:opacity .3s ease; }",
"html[lang='ar'] .cb-feat-card, body[dir='rtl'] .cb-feat-card { text-align:center; padding:10px; }",
"html[lang='ar'] .cb-feat-icon, body[dir='rtl'] .cb-feat-icon { width:65px; height:65px; margin:0 auto 16px; color:#4a423d; display:flex; align-items:center; justify-content:center; }",
"html[lang='ar'] .cb-feat-icon svg, body[dir='rtl'] .cb-feat-icon svg { width:52px; height:52px; }",
"html[lang='en'] .cb-feat-card, body[dir='ltr'] .cb-feat-card { text-align:center; background:#fff; border-radius:16px; padding:32px 20px; border:1px solid #f3ece8; }",
"html[lang='en'] .cb-feat-icon, body[dir='ltr'] .cb-feat-icon { width:56px; height:56px; margin:0 auto 18px; background:#fbf2ee; color:#7a4a54; border-radius:50%; display:flex; align-items:center; justify-content:center; }",
"html[lang='en'] .cb-feat-icon svg, body[dir='ltr'] .cb-feat-icon svg { width:26px; height:26px; }",
".cb-feat-title { font-size:16px; font-weight:700; color:var(--cb-ink); margin-bottom:8px; }",
".cb-feat-desc { font-size:13.5px; color:#857971; line-height:1.6; }",
".cb-dots { display:flex; justify-content:center; gap:8px; margin-top:24px; }",
".cb-dot { width:32px; height:4px; background:#ccc; border:none; border-radius:2px; cursor:pointer; transition:all .3s ease; padding:0; }",
".cb-dot.active { background:#000; width:40px; }",
".cb-full-banner { width:100vw; position:relative; left:50%; right:50%; margin-left:-50vw; margin-right:-50vw; line-height:0; overflow:hidden; }",
".cb-full-banner.middle-banner { margin-top:40px; margin-bottom:40px; }",
".cb-full-banner img { width:100%; height:auto; display:block; }",
".cb-vision-sec { width:100vw; position:relative; left:50%; right:50%; margin-left:-50vw; margin-right:-50vw; background:#f5f2f0; padding:60px 20px; text-align:center; }",
".cb-vision-inner { max-width:850px; margin:0 auto; }",
".cb-vision-title { font-size:28px; font-weight:700; color:#b07f89; margin-bottom:20px; text-transform:uppercase; }",
".cb-vision-desc { font-size:15px; color:#5c544e; line-height:1.9; }",
".cb-toast { position:fixed; bottom:30px; left:50%; transform:translateX(-50%); background:#2e7d32; color:#fff; padding:12px 26px; border-radius:8px; font-size:14px; font-weight:600; opacity:0; transition:opacity .3s; pointer-events:none; z-index:999; max-width:90vw; text-align:center; line-height:1.7; }",
".cb-toast.cb-toast-warning { background:#b25c1f; pointer-events:auto; }",
".cb-toast.show { opacity:1; }"
].join("\n");
document.head.appendChild(styleTag);
function hideNativeTitle(container) {
if (!container) return;
var headings = container.querySelectorAll("h1");
headings.forEach(function (h) {
if (h.closest(".cb-wrap") || h.closest(".cb-vision-sec")) return;
h.classList.add("cb-native-title-hidden");
});
}
function renderFeatures(slideIndex) {
var featsContainer = document.getElementById("cbFeaturesGrid");
if (!featsContainer) return;
var items = (LANG === "ar") ? AR_SLIDES[slideIndex] : [
{ title: "Ultimate Protection", desc: "Advanced design for complete leak prevention.", icon: SVG_ICONS.shield },
{ title: "Nano Technology", desc: "Inbuilt layer to eliminate bacteria and odors.", icon: SVG_ICONS.star },
{ title: "Supreme Softness", desc: "Cottony soft touch gentle on the skin.", icon: SVG_ICONS.heart }
];
featsContainer.style.opacity = "0";
setTimeout(function () {
featsContainer.innerHTML = items.map(function (item) {
return '' +
'
' + item.icon + '
' +
'
' + item.title + '
' +
'
' + item.desc + '
' +
'
';
}).join('');
featsContainer.style.opacity = "1";
}, 150);
}
function injectMarkup() {
var container = document.querySelector(".s-page-content, .page-content, main") || document.body;
hideNativeTitle(container);
var wrap = document.createElement("div");
wrap.className = "cb-wrap";
wrap.setAttribute("dir", DIR);
wrap.innerHTML =
'' +
'
' + T.title + '
' +
'
' + T.subtitle + '
' +
'
' +
'' +
'' +
'
' +
'
' + T.totalUnit + '0
' +
'
' + T.totalPrice + '0.00 ' + T.currency + '
' +
'
' +
'
' +
'
';
container.appendChild(wrap);
var featuresSec = document.createElement("div");
featuresSec.className = "cb-features-sec";
featuresSec.setAttribute("dir", DIR);
var titleHtml = T.featsTitle ? '' + T.featsTitle + '
' : '';
var dotsHtml = '';
if (LANG === "ar") {
dotsHtml = '' +
'' +
'' +
'' +
'' +
'
';
}
featuresSec.innerHTML = titleHtml + '' + dotsHtml;
container.appendChild(featuresSec);
var secondBannerSrc = SECOND_BANNERS[LANG] || SECOND_BANNERS.ar;
var middleBanner = document.createElement("div");
middleBanner.className = "cb-full-banner middle-banner";
middleBanner.innerHTML = '
';
container.appendChild(middleBanner);
var visionSec = document.createElement("div");
visionSec.className = "cb-vision-sec";
visionSec.setAttribute("dir", DIR);
visionSec.innerHTML =
'' +
'
' + T.visionTitle + '
' +
'
' + T.visionDesc + '
' +
'
';
container.appendChild(visionSec);
var bannerSrc = BANNERS[LANG] || BANNERS.ar;
var fullBanner = document.createElement("div");
fullBanner.className = "cb-full-banner";
fullBanner.innerHTML = '
';
container.appendChild(fullBanner);
var toast = document.createElement("div");
toast.className = "cb-toast";
toast.id = "cbToast";
toast.setAttribute("dir", DIR);
document.body.appendChild(toast);
renderFeatures(0);
if (LANG === "ar") {
var dots = featuresSec.querySelectorAll(".cb-dot");
dots.forEach(function (dot) {
dot.addEventListener("click", function () {
dots.forEach(function (d) { d.classList.remove("active"); });
this.classList.add("active");
var index = parseInt(this.getAttribute("data-slide")) % AR_SLIDES.length;
renderFeatures(index);
});
});
}
}
async function fetchProductOptionsData(productId) {
try {
if (window.salla && salla.product && salla.product.api &&
typeof salla.product.api.fetchOptions === "function") {
var res1 = await salla.product.api.fetchOptions([productId]);
var d1 = res1 && res1.data && res1.data[0];
console.log("[CB] fetchOptions() نتيجة للمنتج " + productId, d1);
if (d1) {
console.log(
"[CB] كل المفاتيح المتاحة في بيانات المنتج " + productId + ": " +
JSON.stringify(Object.keys(d1))
);
console.log(
"[CB] قيمة d1.options للمنتج " + productId + ": " + JSON.stringify(d1.options)
);
}
if (d1 && d1.options && d1.options.length) return d1;
} else {
console.warn("[CB] salla.product.api.fetchOptions غير متوفرة في هذا الإصدار من القالب");
}
} catch (e) {
console.warn("[CB] فشلت fetchOptions للمنتج " + productId, e);
}
try {
if (window.salla && salla.product && salla.product.api &&
typeof salla.product.api.fetch === "function") {
var res2 = await salla.product.api.fetch({
source: "selected",
source_value: [productId],
includes: ["options"]
});
var list2 = (res2 && res2.data && res2.data.data) || (res2 && res2.data) || [];
var d2 = Array.isArray(list2) ? list2[0] : list2;
console.log("[CB] product.fetch() (احتياطي) نتيجة للمنتج " + productId, d2);
if (d2 && d2.options) return d2;
}
} catch (e) {
console.warn("[CB] فشلت product.fetch() الاحتياطية للمنتج " + productId, e);
}
console.warn("[CB] تعذر جلب بيانات الاختيارات للمنتج " + productId + " من أي مصدر");
return null;
}
function getOptionValues(opt) {
return opt.details || opt.values || [];
}
function pickPreferredValue(opt) {
var vals = getOptionValues(opt);
if (!vals.length) return null;
var oneTimeKeywords = ["لمرة واحدة", "مرة واحدة", "one time", "once", "single"];
var oneTime = vals.find(function (v) {
var name = (v.name || v.display_value || v.option_value || "").toString().toLowerCase();
return oneTimeKeywords.some(function (kw) { return name.indexOf(kw.toLowerCase()) !== -1; });
});
if (oneTime) return oneTime;
var isDefault = vals.find(function (v) { return v.is_default; });
if (isDefault) return isDefault;
return vals[0];
}
async function buildDefaultOptionsPayload(productId) {
var optionsPayload = {};
var productData = await fetchProductOptionsData(productId);
if (!productData || !productData.options || !productData.options.length) {
return optionsPayload;
}
productData.options.forEach(function (opt) {
var chosen = pickPreferredValue(opt);
if (chosen) optionsPayload[opt.id] = chosen.id;
});
if (productData.skus && productData.skus.length) {
var chosenIds = Object.keys(optionsPayload).map(function (k) { return optionsPayload[k]; });
var validCombo = productData.skus.some(function (sku) {
return (sku.related_option_values || []).every(function (id) {
return chosenIds.indexOf(id) !== -1;
});
});
if (!validCombo) {
console.warn("[CB] التركيبة الافتراضية للمنتج " + productId + " غير موجودة كـ SKU، سيتم استخدام أول SKU متاح");
optionsPayload = {};
var firstSku = productData.skus[0];
(firstSku.related_option_values || []).forEach(function (valId) {
productData.options.forEach(function (opt) {
getOptionValues(opt).forEach(function (v) {
if (v.id === valId) optionsPayload[opt.id] = valId;
});
});
});
}
}
console.log("[CB] optionsPayload النهائي للمنتج " + productId, optionsPayload);
return optionsPayload;
}
function initBundle() {
var grid = document.getElementById("cbGrid");
var totalUnitEl = document.getElementById("cbTotalUnit");
var totalPriceEl = document.getElementById("cbTotalPrice");
var addBtn = document.getElementById("cbAddBtn");
var toast = document.getElementById("cbToast");
if (!grid || !addBtn) return;
var qtyMap = {};
products.forEach(function (p) {
qtyMap[p.id] = 0;
var displayName = p.name[LANG] || p.name.ar;
var card = document.createElement("div");
card.className = "cb-card";
card.dataset.id = p.id;
card.innerHTML =
'' +
'

' +
'
0' +
'
' +
'' + displayName + '
' +
'' + p.price.toFixed(2) + ' ' + T.currency + '
' +
'' +
'' +
'' +
'' +
'
';
grid.appendChild(card);
});
function updateSummary() {
var totalUnit = 0;
var totalPrice = 0;
products.forEach(function (p) {
totalUnit += qtyMap[p.id];
totalPrice += qtyMap[p.id] * p.price;
});
totalUnitEl.textContent = totalUnit;
totalPriceEl.textContent = totalPrice.toFixed(2) + ' ' + T.currency;
addBtn.disabled = totalUnit === 0;
}
function updateCardState(id) {
var card = grid.querySelector('.cb-card[data-id="' + id + '"]');
var pill = grid.querySelector('.cb-qty-pill[data-pill="' + id + '"]');
var qty = qtyMap[id];
if (card) card.classList.toggle('is-active', qty > 0);
if (pill) pill.textContent = qty;
}
grid.addEventListener("click", function (e) {
var id = e.target.getAttribute("data-id");
if (!id) return;
id = Number(id);
if (e.target.classList.contains("cb-plus")) {
qtyMap[id]++;
} else if (e.target.classList.contains("cb-minus")) {
if (qtyMap[id] > 0) qtyMap[id]--;
} else {
return;
}
var input = grid.querySelector('.cb-qty-input[data-id="' + id + '"]');
if (input) input.value = qtyMap[id];
updateCardState(id);
updateSummary();
});
function showToast(msg, isHtml) {
if (isHtml) {
toast.innerHTML = msg;
toast.style.pointerEvents = "auto";
toast.classList.add("cb-toast-warning");
} else {
toast.textContent = msg;
toast.style.pointerEvents = "none";
toast.classList.remove("cb-toast-warning");
}
toast.classList.add("show");
var hideDelay = isHtml ? 8000 : 2500;
setTimeout(function () { toast.classList.remove("show"); }, hideDelay);
}
addBtn.addEventListener("click", async function () {
var itemsToAdd = products.filter(function (p) { return qtyMap[p.id] > 0; });
if (itemsToAdd.length === 0) return;
addBtn.disabled = true;
addBtn.textContent = T.adding;
var failedItems = []; // { name, url }
for (var i = 0; i < itemsToAdd.length; i++) {
var p = itemsToAdd[i];
var quantity = qtyMap[p.id];
var displayName = p.name[LANG] || p.name.ar;
try {
var optionsPayload = await buildDefaultOptionsPayload(p.id);
var addItemData = {
id: p.id,
quantity: quantity
};
if (Object.keys(optionsPayload).length > 0) {
addItemData.options = optionsPayload;
}
await salla.cart.addItem(addItemData);
qtyMap[p.id] = 0;
var input = grid.querySelector('.cb-qty-input[data-id="' + p.id + '"]');
if (input) input.value = 0;
updateCardState(p.id);
} catch (err) {
var serverDetails = (err && err.response && err.response.data) ? err.response.data : err;
console.error(
"[CB] فشلت إضافة المنتج \"" + displayName + "\" (id: " + p.id + ") - تفاصيل رد السيرفر:",
JSON.stringify(serverDetails, null, 2)
);
failedItems.push({ name: displayName, url: buildProductUrl(p) });
}
}
updateSummary();
addBtn.disabled = false;
addBtn.textContent = T.addToCart;
if (failedItems.length === 0) {
showToast(T.success);
} else {
var introText = (LANG === "ar")
? "المنتجات دي تحتاج اختيار يدوي، دوسي عليها لإضافتها مباشرة: "
: "These items need a manual choice — tap to add them directly: ";
var linksHtml = failedItems.map(function (item) {
return '' +
item.name + '';
}).join(LANG === "ar" ? "،" : ",");
showToast(introText + linksHtml, true);
}
});
updateSummary();
}
function start() {
injectMarkup();
initBundle();
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", start);
} else {
start();
}
})();
// logo
(function () {
const newLogoUrl = 'https://pub-1bc5afce57514c38b9c1ba5ebc27c031.r2.dev/image/260x260%20logo.png';
function setLogo() {
document.querySelectorAll('header .logo-normal').forEach(function (logo) {
if (logo.src !== newLogoUrl) {
logo.src = newLogoUrl;
logo.removeAttribute('srcset');
}
});
}
setLogo();
const headerEl = document.querySelector('header.store-header');
if (headerEl) {
const observer = new MutationObserver(setLogo);
observer.observe(headerEl, { childList: true, subtree: true, attributes: true, attributeFilter: ['src', 'srcset'] });
}
})();
(function () {
var isEn = location.pathname.indexOf('/en/') > -1;
var unwanted = isEn ? 'ar' : 'en'; // الصور اللي هتتشال
var log = function () { console.log.apply(console, ['[lang-images]'].concat([].slice.call(arguments))); };
log('page lang =', isEn ? 'en' : 'ar', '| removing alt =', unwanted);
function removeByAlt(swiper) {
for (var i = swiper.slides.length - 1; i >= 0; i--) {
var img = swiper.slides[i].querySelector('img');
if (img && img.getAttribute('alt') === unwanted) swiper.removeSlide(i);
}
swiper.update();
swiper.slideTo(0, 0);
}
var tries = 0;
var t = setInterval(function () {
var slider = document.querySelector('salla-slider.details-slider');
var main = slider && slider.querySelector('.s-slider-container');
var thumbs = slider && slider.querySelector('.s-slider-thumbs-container');
if (main && thumbs && main.swiper && thumbs.swiper && !slider.dataset.langCleaned) {
removeByAlt(main.swiper);
removeByAlt(thumbs.swiper);
main.querySelectorAll('a[data-slid-index]').forEach(function (a, i) {
a.setAttribute('data-slid-index', i);
});
if (window.refreshFsLightbox) window.refreshFsLightbox();
slider.dataset.langCleaned = '1';
log('done');
clearInterval(t);
} else if (++tries > 60) {
log('gave up: slider not ready');
clearInterval(t);
}
}, 250);
})();