You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
542 lines
21 KiB
542 lines
21 KiB
<!doctype html>
|
|
<html lang="en" dir="ltr">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
<meta
|
|
name="viewport"
|
|
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover, interactive-widget=overlays-content"
|
|
/>
|
|
<title>Habib Shop</title>
|
|
<style id="habib-boot-shimmer-styles">
|
|
html,
|
|
body {
|
|
margin: 0;
|
|
padding: 0;
|
|
background-color: #f3f1ef;
|
|
-webkit-tap-highlight-color: transparent;
|
|
}
|
|
@media (min-width: 1024px) {
|
|
html,
|
|
body {
|
|
background-color: #1e2229;
|
|
}
|
|
}
|
|
@keyframes habib-boot-sweep {
|
|
0% {
|
|
transform: translate3d(-100%, 0, 0);
|
|
}
|
|
100% {
|
|
transform: translate3d(100%, 0, 0);
|
|
}
|
|
}
|
|
.habib-boot-shell {
|
|
width: 100%;
|
|
min-height: 100vh;
|
|
min-height: 100dvh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
background-color: #f3f1ef;
|
|
}
|
|
@media (min-width: 1024px) {
|
|
.habib-boot-shell {
|
|
padding: 0 16px;
|
|
background-color: #1e2229;
|
|
}
|
|
}
|
|
.habib-boot-viewport {
|
|
width: 100%;
|
|
max-width: 100%;
|
|
min-height: 100vh;
|
|
min-height: 100dvh;
|
|
background-color: #f3f1ef;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: space-between;
|
|
box-sizing: border-box;
|
|
overflow: hidden;
|
|
}
|
|
@media (min-width: 1024px) {
|
|
.habib-boot-viewport {
|
|
width: 375px;
|
|
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
|
|
}
|
|
}
|
|
.habib-boot-bone {
|
|
position: relative;
|
|
overflow: hidden;
|
|
background-color: #f8f8f8;
|
|
flex-shrink: 0;
|
|
}
|
|
.habib-boot-bone::after {
|
|
content: '';
|
|
position: absolute;
|
|
inset: 0;
|
|
transform: translate3d(-100%, 0, 0);
|
|
background-image: linear-gradient(
|
|
90deg,
|
|
rgba(248, 248, 248, 0) 0%,
|
|
rgba(229, 225, 220, 0.85) 50%,
|
|
rgba(248, 248, 248, 0) 100%
|
|
);
|
|
animation: habib-boot-sweep 1.5s cubic-bezier(0.4, 0, 0.2, 1) 1s infinite;
|
|
pointer-events: none;
|
|
}
|
|
html.is-bare-boot .habib-boot-shell {
|
|
display: none !important;
|
|
}
|
|
</style>
|
|
<script>
|
|
try {
|
|
if (
|
|
window.location.search.indexOf('bare=1') !== -1 ||
|
|
window.location.search.indexOf('embed=1') !== -1 ||
|
|
window.location.pathname.indexOf('/node/') === 0 ||
|
|
window.location.pathname === '/test'
|
|
) {
|
|
document.documentElement.classList.add('is-bare-boot');
|
|
}
|
|
} catch (_eBoot) {}
|
|
</script>
|
|
<script id="habib-core-bootstrap">
|
|
(function () {
|
|
var listeners = new Set();
|
|
|
|
function readCookie(name) {
|
|
var match = document.cookie.match(
|
|
new RegExp('(?:^|;\\s*)' + name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '=([^;]*)')
|
|
);
|
|
return match ? decodeURIComponent(match[1]) : '';
|
|
}
|
|
|
|
function sanitizeToken(raw) {
|
|
if (typeof raw !== 'string') return '';
|
|
var trimmed = raw.trim().replace(/^["']|["']$/g, '');
|
|
if (!trimmed || trimmed === 'NO_TOKEN' || trimmed === 'null' || trimmed === 'undefined') {
|
|
return '';
|
|
}
|
|
return trimmed;
|
|
}
|
|
|
|
function resolveInitialToken() {
|
|
var urlTok = '';
|
|
try {
|
|
if (window.location && window.location.search) {
|
|
var sp = new URLSearchParams(window.location.search);
|
|
urlTok = sanitizeToken(
|
|
sp.get('token') ||
|
|
sp.get('auth_token') ||
|
|
sp.get('habib_token') ||
|
|
sp.get('HABIB_TOKEN') ||
|
|
''
|
|
);
|
|
}
|
|
} catch (_eUrl) {}
|
|
|
|
var ssTok = '';
|
|
try {
|
|
ssTok = sanitizeToken(window.sessionStorage.getItem('HABIB_TOKEN') || '');
|
|
} catch (_eSs) {}
|
|
|
|
return (
|
|
sanitizeToken(window.HABIB_TOKEN) ||
|
|
urlTok ||
|
|
sanitizeToken(readCookie('HABIB_TOKEN')) ||
|
|
sanitizeToken(readCookie('habib_token')) ||
|
|
ssTok
|
|
);
|
|
}
|
|
|
|
var currentToken = resolveInitialToken();
|
|
if (currentToken) {
|
|
document.cookie = 'HABIB_TOKEN=' + encodeURIComponent(currentToken) + '; path=/; SameSite=Lax';
|
|
try {
|
|
window.sessionStorage.setItem('HABIB_TOKEN', currentToken);
|
|
} catch (_eInitSs) {}
|
|
}
|
|
var rawCoinsCookie = readCookie('HABIB_COINS');
|
|
var currentCoins = rawCoinsCookie !== '' ? Number(rawCoinsCookie) : 21;
|
|
if (!Number.isFinite(currentCoins) || currentCoins < 0) {
|
|
currentCoins = 21;
|
|
}
|
|
|
|
function normalizeBootLang(raw) {
|
|
if (typeof raw !== 'string') return '';
|
|
var clean = raw.trim().toLowerCase();
|
|
if (!clean) return '';
|
|
if (clean.indexOf('fa') === 0 || clean === 'persian' || clean === 'farsi') return 'fa';
|
|
if (clean.indexOf('ar') === 0 || clean === 'arabic') return 'ar';
|
|
if (clean.indexOf('en') === 0 || clean === 'english') return 'en';
|
|
return '';
|
|
}
|
|
|
|
function applyBootLanguage(langCode) {
|
|
var norm = normalizeBootLang(langCode) || 'en';
|
|
var dir = norm === 'fa' || norm === 'ar' ? 'rtl' : 'ltr';
|
|
if (document.documentElement) {
|
|
document.documentElement.lang = norm;
|
|
document.documentElement.dir = dir;
|
|
}
|
|
if (document.body) {
|
|
document.body.dir = dir;
|
|
}
|
|
}
|
|
|
|
function resolveInitialLanguage() {
|
|
var urlLang = '';
|
|
try {
|
|
if (window.location && window.location.search) {
|
|
var sp = new URLSearchParams(window.location.search);
|
|
urlLang = normalizeBootLang(sp.get('lang') || sp.get('locale') || sp.get('language') || '');
|
|
}
|
|
} catch (_eLangUrl) {}
|
|
var cookieLang = normalizeBootLang(
|
|
readCookie('HABIB_LANGUAGE') || readCookie('HABIB_USER_LANGUAGE') || readCookie('habib_language')
|
|
);
|
|
var lsLang = '';
|
|
try {
|
|
lsLang = normalizeBootLang(
|
|
window.localStorage.getItem('habib_shop_language') ||
|
|
window.localStorage.getItem('HABIB_LANGUAGE') ||
|
|
''
|
|
);
|
|
} catch (_eLangLs) {}
|
|
var chosen = urlLang || cookieLang || lsLang || 'en';
|
|
if (urlLang) {
|
|
document.cookie = 'HABIB_LANGUAGE=' + encodeURIComponent(chosen) + '; path=/; SameSite=Lax';
|
|
document.cookie = 'HABIB_USER_LANGUAGE=' + encodeURIComponent(chosen) + '; path=/; SameSite=Lax';
|
|
try {
|
|
window.localStorage.setItem('habib_shop_language', chosen);
|
|
} catch (_eSaveUrlLang) {}
|
|
}
|
|
return chosen;
|
|
}
|
|
|
|
applyBootLanguage(resolveInitialLanguage());
|
|
|
|
function getFlutterBridge() {
|
|
var ch = window.HabibApp || window.FlutterChannel;
|
|
if (ch && typeof ch.postMessage === 'function') {
|
|
if (!window.FlutterChannel) window.FlutterChannel = ch;
|
|
if (!window.HabibApp) window.HabibApp = ch;
|
|
return ch;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
try {
|
|
Object.defineProperty(window, 'HABIB_TOKEN', {
|
|
configurable: true,
|
|
enumerable: true,
|
|
get: function () {
|
|
var ssVal = '';
|
|
try {
|
|
ssVal = sanitizeToken(window.sessionStorage.getItem('HABIB_TOKEN') || '');
|
|
} catch (_eGetSs) {}
|
|
return (
|
|
currentToken ||
|
|
sanitizeToken(readCookie('HABIB_TOKEN')) ||
|
|
sanitizeToken(readCookie('habib_token')) ||
|
|
ssVal
|
|
);
|
|
},
|
|
set: function (nextValue) {
|
|
var clean = sanitizeToken(typeof nextValue === 'string' ? nextValue : String(nextValue || ''));
|
|
var prev = currentToken;
|
|
currentToken = clean;
|
|
if (clean) {
|
|
document.cookie = 'HABIB_TOKEN=' + encodeURIComponent(clean) + '; path=/; SameSite=Lax';
|
|
try {
|
|
window.sessionStorage.setItem('HABIB_TOKEN', clean);
|
|
} catch (_eSetSs) {}
|
|
} else {
|
|
document.cookie = 'HABIB_TOKEN=; path=/; max-age=0; SameSite=Lax';
|
|
document.cookie = 'habib_token=; path=/; max-age=0; SameSite=Lax';
|
|
try {
|
|
window.sessionStorage.removeItem('HABIB_TOKEN');
|
|
} catch (_eRmSs) {}
|
|
}
|
|
if (clean !== prev) {
|
|
window.dispatchEvent(
|
|
new CustomEvent('habib:auth-token-changed', {
|
|
detail: { token: clean, previousToken: prev },
|
|
})
|
|
);
|
|
}
|
|
},
|
|
});
|
|
} catch (_err) {
|
|
window.HABIB_TOKEN = currentToken;
|
|
}
|
|
|
|
try {
|
|
Object.defineProperty(window, 'HABIB_COINS', {
|
|
configurable: true,
|
|
enumerable: true,
|
|
get: function () {
|
|
return currentCoins;
|
|
},
|
|
set: function (nextCoins) {
|
|
var parsed = Number(nextCoins);
|
|
if (!Number.isFinite(parsed) || parsed < 0) return;
|
|
if (parsed !== currentCoins) {
|
|
currentCoins = parsed;
|
|
window.dispatchEvent(
|
|
new CustomEvent('habib:coins-changed', {
|
|
detail: { coins: currentCoins },
|
|
})
|
|
);
|
|
}
|
|
},
|
|
});
|
|
} catch (_err2) {
|
|
window.HABIB_COINS = currentCoins;
|
|
}
|
|
|
|
window.addFlutterResponseListener = function (fn) {
|
|
if (typeof fn !== 'function') {
|
|
return function () {};
|
|
}
|
|
listeners.add(fn);
|
|
return function () {
|
|
listeners.delete(fn);
|
|
};
|
|
};
|
|
|
|
window.onFlutterResponse = function (rawPayload) {
|
|
var payload = rawPayload;
|
|
if (typeof rawPayload === 'string') {
|
|
try {
|
|
payload = JSON.parse(rawPayload);
|
|
} catch (_e) {
|
|
payload = { raw: rawPayload };
|
|
}
|
|
}
|
|
if (payload && typeof payload === 'object') {
|
|
var action = String(payload.action || payload.type || '').toLowerCase();
|
|
var data = payload.data || payload.payload || payload;
|
|
var explicitToken =
|
|
typeof data.token === 'string'
|
|
? data.token
|
|
: typeof data.auth_token === 'string'
|
|
? data.auth_token
|
|
: typeof data.authToken === 'string'
|
|
? data.authToken
|
|
: '';
|
|
|
|
if (data && data.user && typeof data.user === 'object') {
|
|
window.__HABIB_BOOTSTRAP__ = Object.assign(
|
|
{},
|
|
window.__HABIB_BOOTSTRAP__ || {},
|
|
{ user: data.user }
|
|
);
|
|
}
|
|
|
|
var incomingLang = normalizeBootLang(
|
|
data.language ||
|
|
data.locale ||
|
|
(data.user && (data.user.preferred_language || data.user.language)) ||
|
|
''
|
|
);
|
|
if (incomingLang) {
|
|
var prevBootLang = resolveBootLang();
|
|
document.cookie = 'HABIB_LANGUAGE=' + encodeURIComponent(incomingLang) + '; path=/; SameSite=Lax';
|
|
document.cookie = 'HABIB_USER_LANGUAGE=' + encodeURIComponent(incomingLang) + '; path=/; SameSite=Lax';
|
|
try {
|
|
window.localStorage.setItem('habib_shop_language', incomingLang);
|
|
} catch (_eBridgeLang) {}
|
|
applyBootLanguage(incomingLang);
|
|
if (incomingLang !== prevBootLang) {
|
|
window.dispatchEvent(
|
|
new CustomEvent('habib:language-changed', {
|
|
detail: { language: incomingLang },
|
|
})
|
|
);
|
|
}
|
|
}
|
|
|
|
if (explicitToken) {
|
|
window.HABIB_TOKEN = explicitToken;
|
|
} else if (action === 'login' && payload.success !== false) {
|
|
var cookieTokAfterLogin =
|
|
sanitizeToken(readCookie('HABIB_TOKEN')) ||
|
|
sanitizeToken(readCookie('habib_token'));
|
|
if (cookieTokAfterLogin) {
|
|
window.HABIB_TOKEN = cookieTokAfterLogin;
|
|
}
|
|
} else if (action === 'initial_config' || action === 'initialconfig') {
|
|
window.__HABIB_BOOTSTRAP__ = data;
|
|
var cookieTokFromBootstrap =
|
|
sanitizeToken(readCookie('HABIB_TOKEN')) ||
|
|
sanitizeToken(readCookie('habib_token'));
|
|
if (cookieTokFromBootstrap) {
|
|
window.HABIB_TOKEN = cookieTokFromBootstrap;
|
|
}
|
|
}
|
|
|
|
var nextCoinVal =
|
|
data.coinsBalance !== undefined
|
|
? data.coinsBalance
|
|
: data.coin_balance !== undefined
|
|
? data.coin_balance
|
|
: undefined;
|
|
if (nextCoinVal !== undefined) {
|
|
window.HABIB_COINS = Number(nextCoinVal);
|
|
}
|
|
}
|
|
listeners.forEach(function (listener) {
|
|
try {
|
|
listener(payload);
|
|
} catch (_listenerErr) {
|
|
// ignore individual listener errors
|
|
}
|
|
});
|
|
};
|
|
|
|
var webReadySent = false;
|
|
window.HABIB_WEB_READY_SENT = false;
|
|
|
|
function tryPostWebReady() {
|
|
if (webReadySent) return true;
|
|
var bridge = getFlutterBridge();
|
|
if (bridge) {
|
|
webReadySent = true;
|
|
window.HABIB_WEB_READY_SENT = true;
|
|
try {
|
|
bridge.postMessage(
|
|
JSON.stringify({
|
|
action: 'web_ready',
|
|
service: 'shop',
|
|
timestamp: Date.now(),
|
|
})
|
|
);
|
|
} catch (_postErr) {
|
|
// ignore channel error
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
window.__announceHabibWebReady = function () {
|
|
if (tryPostWebReady()) return;
|
|
var attempts = 0;
|
|
var timer = window.setInterval(function () {
|
|
attempts += 1;
|
|
if (tryPostWebReady() || attempts >= 25) {
|
|
window.clearInterval(timer);
|
|
}
|
|
}, 120);
|
|
};
|
|
|
|
// Emergency fallback only if React bundle fails to mount
|
|
window.setTimeout(function () {
|
|
if (!webReadySent && !document.querySelector('.habib-mobile-viewport')) {
|
|
tryPostWebReady();
|
|
}
|
|
}, 10000);
|
|
|
|
function postClientLog(level, message, details) {
|
|
var bridge = getFlutterBridge();
|
|
if (!bridge) {
|
|
return;
|
|
}
|
|
try {
|
|
bridge.postMessage(
|
|
JSON.stringify({
|
|
action: 'client_log',
|
|
level: level,
|
|
message: String(message || 'Shop web error'),
|
|
details: details || {},
|
|
})
|
|
);
|
|
} catch (_logErr) {
|
|
// ignore logging errors
|
|
}
|
|
}
|
|
|
|
window.addEventListener('error', function (event) {
|
|
postClientLog('error', event.message || 'Unhandled error', {
|
|
filename: event.filename,
|
|
lineno: event.lineno,
|
|
colno: event.colno,
|
|
});
|
|
});
|
|
|
|
window.addEventListener('unhandledrejection', function (event) {
|
|
var reason = event.reason;
|
|
postClientLog(
|
|
'error',
|
|
reason && reason.message ? reason.message : String(reason || 'Unhandled promise rejection'),
|
|
{}
|
|
);
|
|
});
|
|
})();
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="root">
|
|
<div class="habib-boot-shell" aria-hidden="true">
|
|
<div class="habib-boot-viewport">
|
|
<div style="padding: 37px 16px 22px; display: flex; flex-direction: column; gap: 20px;">
|
|
<div style="display: flex; align-items: center; justify-content: space-between; min-height: 40px; margin-bottom: 11px;">
|
|
<div class="habib-boot-bone" style="width: 40px; height: 40px; border-radius: 15px;"></div>
|
|
<div class="habib-boot-bone" style="width: 68px; height: 22px; border-radius: 8px;"></div>
|
|
<div class="habib-boot-bone" style="width: 40px; height: 40px; border-radius: 15px;"></div>
|
|
</div>
|
|
<div style="display: flex; gap: 10px; align-items: center;">
|
|
<div class="habib-boot-bone" style="flex: 1; height: 44px; border-radius: 14px;"></div>
|
|
<div class="habib-boot-bone" style="width: 44px; height: 44px; border-radius: 14px;"></div>
|
|
</div>
|
|
<div class="habib-boot-bone" style="width: 100%; height: 164px; border-radius: 15px;"></div>
|
|
<div style="display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px;">
|
|
<div style="display: flex; flex-direction: column; align-items: center; gap: 6px;">
|
|
<div class="habib-boot-bone" style="width: 43px; height: 43px; border-radius: 50%;"></div>
|
|
<div class="habib-boot-bone" style="width: 36px; height: 9px; border-radius: 4px;"></div>
|
|
</div>
|
|
<div style="display: flex; flex-direction: column; align-items: center; gap: 6px;">
|
|
<div class="habib-boot-bone" style="width: 43px; height: 43px; border-radius: 50%;"></div>
|
|
<div class="habib-boot-bone" style="width: 36px; height: 9px; border-radius: 4px;"></div>
|
|
</div>
|
|
<div style="display: flex; flex-direction: column; align-items: center; gap: 6px;">
|
|
<div class="habib-boot-bone" style="width: 43px; height: 43px; border-radius: 50%;"></div>
|
|
<div class="habib-boot-bone" style="width: 36px; height: 9px; border-radius: 4px;"></div>
|
|
</div>
|
|
<div style="display: flex; flex-direction: column; align-items: center; align-items: center; gap: 6px;">
|
|
<div class="habib-boot-bone" style="width: 43px; height: 43px; border-radius: 50%;"></div>
|
|
<div class="habib-boot-bone" style="width: 36px; height: 9px; border-radius: 4px;"></div>
|
|
</div>
|
|
<div style="display: flex; flex-direction: column; align-items: center; gap: 6px;">
|
|
<div class="habib-boot-bone" style="width: 43px; height: 43px; border-radius: 50%;"></div>
|
|
<div class="habib-boot-bone" style="width: 36px; height: 9px; border-radius: 4px;"></div>
|
|
</div>
|
|
</div>
|
|
<div style="display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;">
|
|
<div style="padding: 12px; border-radius: 15px; background: #ffffff; display: flex; flex-direction: column; gap: 8px;">
|
|
<div class="habib-boot-bone" style="width: 100%; height: 112px; border-radius: 10px;"></div>
|
|
<div class="habib-boot-bone" style="width: 62%; height: 10px; border-radius: 5px;"></div>
|
|
<div class="habib-boot-bone" style="width: 90%; height: 13px; border-radius: 6px;"></div>
|
|
<div class="habib-boot-bone" style="width: 54px; height: 15px; border-radius: 6px;"></div>
|
|
</div>
|
|
<div style="padding: 12px; border-radius: 15px; background: #ffffff; display: flex; flex-direction: column; gap: 8px;">
|
|
<div class="habib-boot-bone" style="width: 100%; height: 112px; border-radius: 10px;"></div>
|
|
<div class="habib-boot-bone" style="width: 62%; height: 10px; border-radius: 5px;"></div>
|
|
<div class="habib-boot-bone" style="width: 90%; height: 13px; border-radius: 6px;"></div>
|
|
<div class="habib-boot-bone" style="width: 54px; height: 15px; border-radius: 6px;"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div style="height: 78px; border-radius: 17px 17px 0 0; background: #ffffff; display: flex; align-items: center; justify-content: space-around; padding: 0 16px;">
|
|
<div class="habib-boot-bone" style="width: 36px; height: 36px; border-radius: 10px;"></div>
|
|
<div class="habib-boot-bone" style="width: 36px; height: 36px; border-radius: 10px;"></div>
|
|
<div class="habib-boot-bone" style="width: 54px; height: 48px; border-radius: 24px;"></div>
|
|
<div class="habib-boot-bone" style="width: 36px; height: 36px; border-radius: 10px;"></div>
|
|
<div class="habib-boot-bone" style="width: 36px; height: 36px; border-radius: 10px;"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script type="module" src="/src/main.tsx"></script>
|
|
</body>
|
|
</html>
|