(function () {
const CM_IMG = "https://cdn.salla.sa/WlApNA/products/wfseFvgokGt2Zhs8f7GaFpFMWPdoBPJF11rH8XQM.png";
const INCHES_IMG = "https://cdn.salla.sa/WlApNA/products/IZZipSjsYIoH7W9ObSjyr7jwellovRBMJcGTJoKU.png";
const RETURN_URL = "https://quueen.com/return-policy/page-1702475190";
const isProductPage =
window.location.pathname.includes("/p") ||
document.querySelector("salla-product-options") !== null;
if (!isProductPage) return;
function buildWidget() {
const wrapper = document.createElement("div");
wrapper.id = "qqn-size-guide";
wrapper.style.cssText = "margin-top: 12px; margin-bottom: 16px; font-family: inherit; direction: rtl;";
wrapper.innerHTML = `
استرجاع مجاني خلال 7 أيام — بدون أسئلة، بدون تعقيد
سياسة الاستبدال والاسترجاع ←
`;
return wrapper;
}
window.qqnSecToggle = function (id) {
const body = document.getElementById("qqn-body-" + id);
const arrow = document.getElementById("qqn-arrow-" + id);
if (!body) return;
const isOpen = body.classList.contains("open");
body.classList.toggle("open", !isOpen);
arrow.classList.toggle("open", !isOpen);
};
window.qqnShowUnit = function (unit) {
["inches", "cm"].forEach(function (u) {
document.getElementById("qqn-img-" + u)?.classList.toggle("active", u === unit);
document.getElementById("qqn-tab-" + u)?.classList.toggle("active", u === unit);
});
};
function inject() {
if (document.getElementById("qqn-size-guide")) return;
const target = document.querySelector("salla-product-options");
if (!target) return;
target.insertAdjacentElement("afterend", buildWidget());
}
function tryInject(retries = 10) {
if (document.querySelector("salla-product-options")) {
inject();
} else if (retries > 0) {
setTimeout(function () { tryInject(retries - 1); }, 400);
}
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", function () { tryInject(); });
} else {
tryInject();
}
const _pushState = history.pushState;
history.pushState = function () {
_pushState.apply(this, arguments);
setTimeout(tryInject, 800);
};
window.addEventListener("popstate", function () { setTimeout(tryInject, 800); });
})();
(function () {
"use strict";
var SUPABASE_URL = "https://aqgjdquhpmzryrmnqfzl.supabase.co";
var SUPABASE_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImFxZ2pkcXVocG16cnlybW5xZnpsIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Nzk1NTMyNDEsImV4cCI6MjA5NTEyOTI0MX0.oA7dKrK0QujzntLMVpNc_9t60Nufn77Uh8LABTMhaAk";
/* camera SVG icon */
var CAMERA_SVG =
'' +
'
' +
'' +
'' +
'
' +
'
' +
'
' +
'
' +
[5,4,3,2,1].map(function(i){
return '' +
'';
}).join("") +
'
' +
'
' +
'
' +
'' +
'' +
'
' +
'
' +
'
' +
'
' +
'
' +
/* progress bar — hidden until upload starts */
'
' +
'
' +
'
جاري رفع الصور...
' +
'
' +
'
' +
'
' +
'
' +
'
';
openDialog(html);
document.getElementById("rvqDlgClose").onclick = closeDialog;
var pickedFiles = [];
var addBtn = document.getElementById("rvqImgAddBtn");
var fileInput = document.getElementById("rvqFileInput");
var imgWrap = document.getElementById("rvqImgWrap");
addBtn.onclick = function () { fileInput.click(); };
fileInput.onchange = function () {
var files = Array.prototype.slice.call(fileInput.files || []);
files.forEach(function (f) {
if (pickedFiles.length >= 5) return;
pickedFiles.push(f);
var reader = new FileReader();
reader.onload = function (e) {
var thumb = el("div", "rvq-img-thumb");
var idx = pickedFiles.length - 1;
thumb.innerHTML =
'' +
'
' +
'' +
'' +
'
' +
'
' +
'' +
'' +
'
' +
'
' +
'
' +
'
';
openDialog(html);
document.getElementById("rvqDlgClose2").onclick = closeDialog;
document.getElementById("rvqQSubmit").onclick = function () {
var name = (document.getElementById("rvqQName").value || "").trim();
var text = (document.getElementById("rvqQText").value || "").trim();
var msg = document.getElementById("rvqQMsg");
if (!name) { msg.style.color = "#e44"; msg.textContent = "الرجاء إدخال اسمك"; return; }
if (!text) { msg.style.color = "#e44"; msg.textContent = "الرجاء كتابة سؤالك"; return; }
var btn = document.getElementById("rvqQSubmit");
btn.disabled = true;
btn.textContent = "جاري الإرسال...";
msg.textContent = "";
var today = new Date().toISOString().slice(0, 10);
var payload = {
product_id: productIdGlobal,
user_name: name,
question: text,
question_date: today,
answer: null,
answered_by: null
};
sbInsert("questions", payload).then(function () {
btn.textContent = "تم الإرسال ✓";
msg.style.color = "#22a";
msg.textContent = "شكراً! سيتم الرد على سؤالك قريباً.";
setTimeout(closeDialog, 2000);
}).catch(function (err) {
btn.disabled = false;
btn.textContent = "إرسال السؤال";
msg.style.color = "#e44";
msg.textContent = "حدث خطأ، يرجى المحاولة مجدداً.";
console.error("[Reviews] insert error:", err);
});
};
}
/* ══════════════════════════════════════════════
BUILD REVIEWS SECTION
══════════════════════════════════════════════ */
function buildReviewsSection(reviews, stats) {
var sec = el("div", "rvq-section");
sec.id = "rvqReviewsSection";
sec.appendChild(el("div", "rvq-sec-title", "التعليقات على المنتج"));
if (!reviews || reviews.length === 0) {
sec.appendChild(makeEmpty("💬", "لا توجد تعليقات بعد", "كن أول من يشارك رأيه في هذا المنتج"));
return sec;
}
var avg = parseFloat(stats.avg_rating || 0).toFixed(1);
var total = Number(stats.total_reviews || 0);
var sumBar = el("div", "rvq-sum-bar");
sumBar.innerHTML =
'' +
'
' +
'
' + stars(Math.round(stats.avg_rating), 19) + '
' +
parseFloat(stats.avg_rating).toFixed(1) +
'
' +
'
' +
'
' + buildBreakdown(stats) + '
' +
'
' +
'