Spaces:
Running
Running
Delete ui.py
Browse files
ui.py
DELETED
|
@@ -1,540 +0,0 @@
|
|
| 1 |
-
from __future__ import annotations
|
| 2 |
-
|
| 3 |
-
import html
|
| 4 |
-
from typing import List, Optional
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
_e = html.escape
|
| 8 |
-
|
| 9 |
-
APP_TITLE = "Amanah AI"
|
| 10 |
-
APP_TAGLINE = "نظام ذكي للتحقق من الاقتباسات القرآنية والحديثية"
|
| 11 |
-
ENGLISH_TITLE = "AI-Powered Verification and Correction of Quranic and Prophetic Quotations"
|
| 12 |
-
COPIED_MESSAGE = "تم نسخ النص بنجاح"
|
| 13 |
-
|
| 14 |
-
GROUP_LABEL = {"verified": "موثّق", "mismatch": "غير مطابق", "review": "تحتاج مراجعة بشرية"}
|
| 15 |
-
TYPE_LABEL = {"Ayah": "آية قرآنية", "Hadith": "حديث نبوي"}
|
| 16 |
-
INDICATORS = [
|
| 17 |
-
("composite", "الدرجة المركبة"),
|
| 18 |
-
("coverage", "تغطية الكلمات"),
|
| 19 |
-
("lcs_ratio", "التسلسل النصي"),
|
| 20 |
-
("token_overlap", "تداخل الكلمات"),
|
| 21 |
-
("edit_sim", "تشابه الحروف"),
|
| 22 |
-
("diacritic_sim", "التشكيل"),
|
| 23 |
-
]
|
| 24 |
-
METHODS = {
|
| 25 |
-
"substring_match": "الاقتباس واردٌ كاملًا في المصدر",
|
| 26 |
-
"threshold_pass": "تجاوز عتبة التطابق",
|
| 27 |
-
"threshold_fail": "دون عتبة التطابق",
|
| 28 |
-
"borderline_multi_cov": "حالة حدّية: عدة مصادر متقاربة",
|
| 29 |
-
"borderline_default": "حالة حدّية",
|
| 30 |
-
"borderline_low_retrieval": "حالة حدّية: استرجاع ضعيف",
|
| 31 |
-
"no_candidates": "لا توجد مصادر مرشحة",
|
| 32 |
-
"empty_span": "نص فارغ",
|
| 33 |
-
"error": "تعذّرت المعالجة",
|
| 34 |
-
}
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
def _pct(value: float) -> str:
|
| 38 |
-
return f"{round(value * 100)}%"
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
def source_label(source: dict) -> str:
|
| 42 |
-
if source["type"] == "Quran":
|
| 43 |
-
start, end = source["ayah_start"], source["ayah_end"]
|
| 44 |
-
verses = f"{start}" if start == end else f"{start}–{end}"
|
| 45 |
-
return f"سورة {source['surah_name']} — الآية {verses}"
|
| 46 |
-
return f"حديث رقم {source['hadithID']} — {source['title']}"
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
def reason_text(reason: dict) -> str:
|
| 50 |
-
code = reason["code"]
|
| 51 |
-
src = reason.get("source", "")
|
| 52 |
-
if code == "exact_match":
|
| 53 |
-
return f"تطابق تام مع {src} بعد تجاهل اختلافات الرسم والتشكيل."
|
| 54 |
-
if code == "close_match":
|
| 55 |
-
return f"تطابق شبه كامل مع {src}."
|
| 56 |
-
if code == "altered_passage":
|
| 57 |
-
n = reason.get("n", 0)
|
| 58 |
-
how = "تغيّر ترتيب الكلمات" if reason.get("reordered") else f"{n} موضع مختلف"
|
| 59 |
-
return f"النص يخالف {src} ({how}). التصحيح المقترح هو نص المصدر حرفيًا ولم يُولَّد."
|
| 60 |
-
if code == "weak_match":
|
| 61 |
-
return "وُجد مصدر قريب لكن التطابق غير كافٍ للحكم الآلي."
|
| 62 |
-
if code == "ungrounded":
|
| 63 |
-
return "تعذّر التثبّت من المرجع المقترح داخل المراجع المضمّنة، فأُسقط الاقتراح ولم يُعرض أي تصحيح؛ يلزم الرجوع إلى مختص."
|
| 64 |
-
if code == "too_short":
|
| 65 |
-
return "الاقتباس قصير جدًا (كلمتان فقط) فلا يمكن تحديد مصدره بيقين؛ يلزم الرجوع إلى مختص."
|
| 66 |
-
if code == "no_source":
|
| 67 |
-
return "لا يوجد في المراجع المضمّنة نصٌّ يشبه هذا الاقتباس، وقد يكون مختلَقًا."
|
| 68 |
-
if code == "insufficient_evidence":
|
| 69 |
-
return "الأدلة غير كافية: لا مصدر واضح، ودرجة اليقين منخفضة."
|
| 70 |
-
if code == "candidate_not_strong":
|
| 71 |
-
return f"وُجد مرشح ({src}، قوة المطابقة {round(reason.get('strength', 0) * 100)}%) لكن الدليل لا يكفي للتصحيح الآلي."
|
| 72 |
-
if code == "hadith_altered":
|
| 73 |
-
return (f"النص قريب جدًا من {src} لكن يختلف عنه في {reason.get('n', 1)} موضع (زيادة أو نقص أو استبدال كلمة)، وقد يغيّر ذلك المعنى؛ "
|
| 74 |
-
"لا يُوثَّق الحديث إلا إذا طابق النص حرفيًا، ولا يُصحَّح آليًا فتلزم مراجعة مختص.")
|
| 75 |
-
if code == "hadith_candidate":
|
| 76 |
-
return f"وُجدت رواية مشابهة ({src}) لكن لا يُصحَّح الحديث آليًا لاختلاف الروايات؛ يلزم الرجوع إلى مختص."
|
| 77 |
-
return "تعذّرت معالجة هذا الاقتباس آليًا."
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
def note_text(note: dict) -> str:
|
| 81 |
-
n = note.get("n", 0)
|
| 82 |
-
code = note["code"]
|
| 83 |
-
if code == "diacritic_conflict":
|
| 84 |
-
return f"تنبيه: تشكيل {n} كلمة يخالف المصحف (الكلمات صحيحة لكن الحركات مختلفة)."
|
| 85 |
-
if code == "orthographic_variant":
|
| 86 |
-
return f"ملاحظة: {n} اختلاف إملائي (رسم أو مسافات) لا يغيّر الكلمة."
|
| 87 |
-
if note.get("misattributed"):
|
| 88 |
-
if code == "is_ayah":
|
| 89 |
-
return f"تنبيه: النص قرآني ({note['source']}) لكن عبارة التقديم تنسبه إلى الحديث."
|
| 90 |
-
return f"تنبيه: النص حديث ({note['source']}) لكن عبارة التقديم تنسبه إلى القرآن."
|
| 91 |
-
if code == "is_hadith":
|
| 92 |
-
return f"تنبيه: هذا النص وارد في الحديث ({note['source']}) وليس في القرآن؛ ربما نُسب إلى الله تعالى خطأً."
|
| 93 |
-
if code == "is_ayah":
|
| 94 |
-
return f"تنبيه: هذا النص وارد في القرآن ({note['source']}) وليس في الحديث؛ ربما نُسب إلى النبي ﷺ خطأً."
|
| 95 |
-
if code == "hadith_minor_diffs":
|
| 96 |
-
return f"ملاحظة: {n} اختلاف طفيف عن أقرب رواية في المراجع."
|
| 97 |
-
return ""
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
def _diff_html(comparison: dict) -> str:
|
| 101 |
-
parts = []
|
| 102 |
-
for op in comparison["word_diff"]:
|
| 103 |
-
if op["op"] == "equal":
|
| 104 |
-
parts.append(f'<span class="w-eq">{_e(op["span"])}</span>')
|
| 105 |
-
continue
|
| 106 |
-
if op["span"]:
|
| 107 |
-
parts.append(f'<span class="w-extra">{_e(op["span"])}</span>')
|
| 108 |
-
if op["source"]:
|
| 109 |
-
parts.append(f'<span class="w-missing">{_e(op["source"])}</span>')
|
| 110 |
-
return " ".join(parts)
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
def _legend(group: str, comparison: Optional[dict]) -> str:
|
| 114 |
-
if group == "verified" or not comparison or all(op["op"] == "equal" for op in comparison["word_diff"]):
|
| 115 |
-
return ""
|
| 116 |
-
return '<p class="legend"><span class="w-extra">كلمات في الاقتباس تخالف المصدر</span> <span class="w-missing">الصواب من المصدر</span></p>'
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
def _indicator_table(signals: Optional[dict]) -> str:
|
| 120 |
-
if not signals:
|
| 121 |
-
return ""
|
| 122 |
-
rows = []
|
| 123 |
-
for key, label in INDICATORS:
|
| 124 |
-
value = float(signals.get(key, 0.0))
|
| 125 |
-
rows.append(
|
| 126 |
-
f'<div class="ind"><div class="ind-name">{label}</div>'
|
| 127 |
-
f'<div class="bar"><span style="width:{_pct(value)}"></span></div><div class="ind-val">{_pct(value)}</div></div>'
|
| 128 |
-
)
|
| 129 |
-
rows.append(f'<div class="ind"><div class="ind-name">وروده كاملًا في المصدر</div><div class="ind-val wide">{"نعم" if signals.get("is_substring") else "لا"}</div></div>')
|
| 130 |
-
return '<div class="indicators">' + "".join(rows) + "</div>"
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
def _match_percent(span: dict) -> int:
|
| 134 |
-
evidence = span["evidence"]
|
| 135 |
-
if evidence and evidence.get("comparison"):
|
| 136 |
-
return round(evidence["comparison"]["word_similarity"] * 100)
|
| 137 |
-
if evidence and evidence.get("signals"):
|
| 138 |
-
return round(evidence["signals"]["composite"] * 100)
|
| 139 |
-
return 0
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
def _evidence_panel(span: dict) -> str:
|
| 143 |
-
evidence, verification = span["evidence"], span["verification"]
|
| 144 |
-
rows = [
|
| 145 |
-
f'<div class="ev-row"><b>الاقتباس المكتشف</b><p class="quote">{_e(span["text"])}</p></div>',
|
| 146 |
-
f'<div class="ev-row"><b>النوع</b><p>{TYPE_LABEL[span["type"]]}</p></div>',
|
| 147 |
-
]
|
| 148 |
-
if evidence:
|
| 149 |
-
comparison = evidence["comparison"]
|
| 150 |
-
rows += [
|
| 151 |
-
f'<div class="ev-row"><b>المصدر المرشح</b><p>{_e(source_label(evidence["source"]))}</p></div>',
|
| 152 |
-
f'<div class="ev-row"><b>نص المصدر الأصلي</b><p class="quote">{_e(comparison["source_excerpt"])}</p></div>',
|
| 153 |
-
f'<div class="ev-row"><b>المقارنة كلمةً بكلمة</b><p class="diff">{_diff_html(comparison)}</p>{_legend(span["group"], comparison)}</div>',
|
| 154 |
-
f'<div class="ev-row"><b>مؤشرات التحقق</b>{_indicator_table(evidence.get("signals"))}</div>',
|
| 155 |
-
]
|
| 156 |
-
if comparison["diacritic_notes"]:
|
| 157 |
-
items = "، ".join(f"{_e(n['word'])} ← {_e(n['source_word'])}" for n in comparison["diacritic_notes"])
|
| 158 |
-
rows.append(f'<div class="ev-row"><b>اختلافات التشكيل</b><p>{items}</p></div>')
|
| 159 |
-
else:
|
| 160 |
-
rows.append('<div class="ev-row"><b>المصدر المرشح</b><p>لم يُسترجع أي مصدر.</p></div>')
|
| 161 |
-
rows += [
|
| 162 |
-
f'<div class="ev-row"><b>درجة اليقين في الحكم</b><p>{_pct(verification["confidence"])} · {METHODS.get(verification["method"], "")}</p></div>',
|
| 163 |
-
f'<div class="ev-row"><b>القرار</b><p>{_e(span["status_ar"])}</p></div>',
|
| 164 |
-
f'<div class="ev-row"><b>سبب القرار</b><p>{_e(reason_text(span["reason"]))}</p></div>',
|
| 165 |
-
]
|
| 166 |
-
return "".join(rows)
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
def _card(span: dict) -> str:
|
| 170 |
-
group, evidence = span["group"], span["evidence"]
|
| 171 |
-
label = GROUP_LABEL[group]
|
| 172 |
-
chip = f'<span class="conf">نسبة المطابقة <b>{_match_percent(span)}%</b></span>'
|
| 173 |
-
scan_badge = ('<span class="badge scan" title="اكتُشف بمطابقة النص مع المراجع دون علامات تنصيص">اقتباس غير معلَن</span>'
|
| 174 |
-
if span["detection"]["backend"] == "scan" else "")
|
| 175 |
-
|
| 176 |
-
fields = [f'<div class="field"><label>الاقتباس المكتشف</label><p class="quote">{_e(span["text"])}</p></div>']
|
| 177 |
-
if evidence:
|
| 178 |
-
comparison = evidence["comparison"]
|
| 179 |
-
fields.append(f'<div class="field"><label>المصدر المرشح</label><p>{_e(source_label(evidence["source"]))}</p></div>')
|
| 180 |
-
if group != "verified":
|
| 181 |
-
fields.append(
|
| 182 |
-
f'<div class="field"><label>المقارنة بالمصدر</label><p class="diff">{_diff_html(comparison)}</p>{_legend(group, comparison)}</div>'
|
| 183 |
-
)
|
| 184 |
-
else:
|
| 185 |
-
fields.append('<div class="field"><label>المصدر المرشح</label><p>لا يوجد</p></div>')
|
| 186 |
-
fields.append(f'<p class="reason">{_e(reason_text(span["reason"]))}</p>')
|
| 187 |
-
|
| 188 |
-
notes = "".join(f'<p class="note">{_e(note_text(n))}</p>' for n in span["notes"] if note_text(n))
|
| 189 |
-
action = ""
|
| 190 |
-
correction, suggestion = span["correction"], span["suggestion"]
|
| 191 |
-
if correction:
|
| 192 |
-
action = (
|
| 193 |
-
'<div class="action ok"><b>التصحيح المقترح من المصدر</b>'
|
| 194 |
-
f'<p class="quote">{_e(correction["display_text"])}</p>'
|
| 195 |
-
f'<p class="legend">{_e(source_label(correction["source"]))}</p></div>'
|
| 196 |
-
)
|
| 197 |
-
elif group == "review":
|
| 198 |
-
closest = ""
|
| 199 |
-
if suggestion:
|
| 200 |
-
closest = (f'<p class="legend">أقرب مصدر وُجد للمراجِع، وليس تصحيحًا آليًا: {_e(source_label(suggestion["source"]))}</p>'
|
| 201 |
-
f'<p class="quote small">{_e(suggestion["display_text"][:420])}</p>')
|
| 202 |
-
action = ('<div class="action warn"><b>الأدلة غير كافية للتصحيح الآلي.</b> يُوصى بالمراجعة البشرية.' + closest + "</div>")
|
| 203 |
-
elif span["status"] == "UNSUPPORTED":
|
| 204 |
-
action = '<div class="action bad"><b>لا يوجد مصدر مطابق في المراجع المتاحة.</b> لم يُقترح أي نص بديل.</div>'
|
| 205 |
-
|
| 206 |
-
return f"""
|
| 207 |
-
<div class="qcard {group}">
|
| 208 |
-
<div class="qhead">
|
| 209 |
-
<span class="idx">{span["id"]}</span>
|
| 210 |
-
<span class="badge type">{TYPE_LABEL[span["type"]]}</span>{scan_badge}
|
| 211 |
-
<span class="badge st {group}">{label}</span>
|
| 212 |
-
{chip}
|
| 213 |
-
</div>
|
| 214 |
-
{"".join(fields)}
|
| 215 |
-
{notes}
|
| 216 |
-
{action}
|
| 217 |
-
<details class="evidence"><summary>عرض الدليل</summary><div class="ev-body">{_evidence_panel(span)}</div></details>
|
| 218 |
-
</div>"""
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
def _summary(summary: dict) -> str:
|
| 222 |
-
tiles = [
|
| 223 |
-
(summary["n_spans"], "إجمالي الاقتباسات", ""),
|
| 224 |
-
(summary["n_ayah"], "آيات قرآنية", ""),
|
| 225 |
-
(summary["n_hadith"], "أحاديث نبوية", ""),
|
| 226 |
-
(summary["VERIFIED"], "موثّق", "verified"),
|
| 227 |
-
(summary["CORRECTED"] + summary["UNSUPPORTED"], "غير مطابق", "mismatch"),
|
| 228 |
-
(summary["HUMAN_REVIEW"], "تحتاج مراجعة", "review"),
|
| 229 |
-
]
|
| 230 |
-
return '<div class="summary">' + "".join(
|
| 231 |
-
f'<div class="tile {cls}{" zero" if value == 0 and cls else ""}"><b>{value}</b><span>{label}</span></div>'
|
| 232 |
-
for value, label, cls in tiles
|
| 233 |
-
) + "</div>"
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
def _highlighted_text(result: dict, title: str) -> str:
|
| 237 |
-
text, pieces, cursor = result["input_text"], [], 0
|
| 238 |
-
for span in result["spans"]:
|
| 239 |
-
pieces.append(_e(text[cursor:span["start"]]))
|
| 240 |
-
pieces.append(f'<mark class="{span["group"]}">{_e(text[span["start"]:span["end"]])}</mark>')
|
| 241 |
-
cursor = span["end"]
|
| 242 |
-
pieces.append(_e(text[cursor:]))
|
| 243 |
-
legend = ('<div class="hl-legend"><mark class="verified">موثّق</mark><mark class="mismatch">غير مطابق</mark>'
|
| 244 |
-
'<mark class="review">مراجعة بشرية</mark></div>')
|
| 245 |
-
return f'<div class="highlight"><label>{title}</label><p>' + "".join(pieces) + "</p>" + legend + "</div>"
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
def final_text(result: dict) -> str:
|
| 249 |
-
text, reports = result["input_text"], result["spans"]
|
| 250 |
-
for report in sorted(reports, key=lambda r: r["start"], reverse=True):
|
| 251 |
-
if report["status"] == "CORRECTED" and report["correction"]:
|
| 252 |
-
text = text[: report["start"]] + report["correction"]["display_text"] + text[report["end"]:]
|
| 253 |
-
elif report["status"] == "UNSUPPORTED":
|
| 254 |
-
text = text[: report["end"]] + " [⚠ لا يوجد مصدر مطابق]" + text[report["end"]:]
|
| 255 |
-
elif report["status"] == "HUMAN_REVIEW":
|
| 256 |
-
text = text[: report["end"]] + " [⚠ يحتاج مراجعة بشرية]" + text[report["end"]:]
|
| 257 |
-
return text
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
def _final_block(result: dict) -> str:
|
| 261 |
-
summary = result["summary"]
|
| 262 |
-
fixed = summary["CORRECTED"]
|
| 263 |
-
open_items = summary["UNSUPPORTED"] + summary["HUMAN_REVIEW"]
|
| 264 |
-
if fixed == 0 and open_items == 0:
|
| 265 |
-
headline = "كل الاقتباسات المكتشفة مطابقة للمصادر."
|
| 266 |
-
else:
|
| 267 |
-
headline = f"صُحِّح {fixed} اقتباس من نص المصدر، وبقي {open_items} اقتباس يحتاج مراجعة بشرية ومعلَّم بعلامة تنبيه."
|
| 268 |
-
text = final_text(result)
|
| 269 |
-
return (
|
| 270 |
-
'<div class="final"><div class="final-head"><b>النسخة المصحّحة</b>'
|
| 271 |
-
f'<button class="copy" type="button" data-text="{_e(text, quote=True)}" '
|
| 272 |
-
'onclick="window.icvCopy&&window.icvCopy(this)">نسخ النص</button></div>'
|
| 273 |
-
f'<p class="legend">{headline}</p><p class="final-text">{_e(text)}</p></div>'
|
| 274 |
-
)
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
def render_results(result: dict, generated_answer: Optional[str] = None) -> str:
|
| 278 |
-
header = render_generated_header(generated_answer) if generated_answer is not None else ""
|
| 279 |
-
if not result["spans"]:
|
| 280 |
-
body = (
|
| 281 |
-
'<div class="notice">لم يُعثر على اقتباسات قرآنية أو حديثية في هذا النص. يتعرّف النظام على الاقتباسات بمطابقتها مع المراجع، '
|
| 282 |
-
'سواء وُضعت بين علامات تنصيص أو أقواس أو وردت داخل الكلام دون أي عبارة تمهيدية.</div>'
|
| 283 |
-
)
|
| 284 |
-
return f'<div class="icv">{header}{body}</div>'
|
| 285 |
-
generated = generated_answer is not None
|
| 286 |
-
title = "إجابة النموذج مع الاقتباسات المكتشفة" if generated else "النص مع الاقتباسات المكتشفة"
|
| 287 |
-
parts = [_summary(result["summary"]), _highlighted_text(result, title), "".join(_card(s) for s in result["spans"])]
|
| 288 |
-
summary = result["summary"]
|
| 289 |
-
if generated or summary["CORRECTED"] or summary["UNSUPPORTED"] or summary["HUMAN_REVIEW"]:
|
| 290 |
-
parts.append(_final_block(result))
|
| 291 |
-
return f'<div class="icv">{header}{"".join(parts)}</div>'
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
def render_generated_header(answer: str) -> str:
|
| 295 |
-
return f'<div class="generated"><label>إجابة النموذج اللغوي كما وصلت</label><p>{_e(answer)}</p></div>'
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
def render_message(message: str, kind: str = "info") -> str:
|
| 299 |
-
return f'<div class="icv"><div class="notice {kind}">{_e(message)}</div></div>'
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
STAR = (
|
| 304 |
-
'<svg class="mark" viewBox="0 0 64 64" fill="none" stroke="#E2C06E" stroke-width="1.8" aria-hidden="true">'
|
| 305 |
-
'<rect x="14" y="14" width="36" height="36"/><rect x="14" y="14" width="36" height="36" transform="rotate(45 32 32)"/>'
|
| 306 |
-
'<circle cx="32" cy="32" r="7" fill="#E2C06E" stroke="none"/></svg>'
|
| 307 |
-
)
|
| 308 |
-
|
| 309 |
-
HERO = f"""
|
| 310 |
-
<div class="icv"><header class="hero">
|
| 311 |
-
{STAR}
|
| 312 |
-
<h1 class="brand">{APP_TITLE}</h1>
|
| 313 |
-
<p class="tagline">{APP_TAGLINE}</p>
|
| 314 |
-
<p class="sub">يكتشف الاقتباسات القرآنية والحديثية داخل أي نص، ويطابقها كلمةً بكلمة مع نصوص المراجع، ويصحّح الخطأ من المصدر نفسه.
|
| 315 |
-
وحين لا يجد دليلًا كافيًا لا يخمّن أبدًا، بل يعلن أن الاقتباس غير مطابق أو يحيله إلى المراجعة البشرية.</p>
|
| 316 |
-
<ul class="trust"><li><b>من المصدر</b> كل مرجع وتصحيح من نص المراجع حرفيًا</li><li><b>٣ قرارات</b> موثّق · غير مطابق · مراجعة بشرية</li><li><b>داخل المتصفح</b> التحقق لا يرسل نصك إلى أي خادم</li></ul>
|
| 317 |
-
</header></div>
|
| 318 |
-
"""
|
| 319 |
-
|
| 320 |
-
DISCLAIMER = """<div class="icv"><div class="disclaimer">أداة مساعدة للتدقيق النصي وليست فتوى ولا بديلًا عن المراجعة المتخصصة.
|
| 321 |
-
النتائج مبنية على مراجع القرآن الكريم والكتب الستة المضمّنة فقط.
|
| 322 |
-
<br>نص القرآن: <a href="https://tanzil.net" target="_blank" rel="noopener">مشروع Tanzil</a> (CC BY 3.0) · بيانات IslamicEval 2025.</div></div>"""
|
| 323 |
-
|
| 324 |
-
PLACEHOLDER = "الصق هنا النص الذي ولّده نموذج لغوي. يكتشف النظام الآيات والأحاديث الواردة فيه، بعلامات تنصيص أو بدونها…"
|
| 325 |
-
PROMPT_PLACEHOLDER = "اكتب سؤالك، مثل: اشرح لي فضل الصبر في القرآن والسنة مع ذكر الأدلة."
|
| 326 |
-
|
| 327 |
-
_PATTERN = (
|
| 328 |
-
"url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='88' viewBox='0 0 88 88'%3E"
|
| 329 |
-
"%3Cg fill='none' stroke='%230F4C3A' stroke-opacity='0.07' stroke-width='1'%3E"
|
| 330 |
-
"%3Crect x='22' y='22' width='44' height='44'/%3E%3Crect x='22' y='22' width='44' height='44' transform='rotate(45 44 44)'/%3E"
|
| 331 |
-
"%3C/g%3E%3C/svg%3E\")"
|
| 332 |
-
)
|
| 333 |
-
|
| 334 |
-
CSS = """
|
| 335 |
-
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&family=Amiri:wght@400;700&display=swap');
|
| 336 |
-
:root { --green:#0F4C3A; --green-2:#17694F; --gold:#B8912F; --gold-2:#E2C06E; --cream:#FBF6EA; --paper:#FFFFFF;
|
| 337 |
-
--ink:#1F2933; --muted:#55626D; --line:#E6DCC3; --ok:#1B7A4B; --ok-bg:#EAF6EF; --ok-line:#BFE3CD;
|
| 338 |
-
--bad:#B3261E; --bad-bg:#FDECEA; --bad-line:#F4B8B3; --warn:#7A5B0C; --warn-bg:#FFF6DA; --warn-line:#EBD28A; }
|
| 339 |
-
.gradio-container, body.icv-page { background:var(--cream) PATTERN !important; font-family:'Cairo','Segoe UI',Tahoma,sans-serif; color:var(--ink); }
|
| 340 |
-
.gradio-container { max-width:1060px !important; --body-text-color:#1F2933; --block-background-fill:#FFFFFF; --block-border-color:#E6DCC3;
|
| 341 |
-
--input-background-fill:#FFFFFF; --block-label-text-color:#55626D; --button-primary-background-fill:#0F4C3A;
|
| 342 |
-
--button-primary-background-fill-hover:#17694F; --button-primary-text-color:#FFFFFF; --button-secondary-background-fill:#FFFFFF;
|
| 343 |
-
--button-secondary-text-color:#0F4C3A; --button-secondary-border-color:#B8912F; --color-accent:#B8912F; }
|
| 344 |
-
.icv { direction:rtl; text-align:right; color:var(--ink); line-height:1.9; }
|
| 345 |
-
.icv .hero { background:linear-gradient(135deg,#0F4C3A,#17694F); border-radius:20px; padding:30px 22px 26px; margin:10px 0 18px; text-align:center;
|
| 346 |
-
box-shadow:0 6px 22px rgba(15,76,58,.18); border-bottom:4px solid var(--gold); }
|
| 347 |
-
.icv .hero .mark { width:54px; height:54px; display:block; margin:0 auto 4px; }
|
| 348 |
-
.icv .hero h1 { font-size:2.3rem; margin:.1rem 0; color:#FFFFFF; font-weight:700; }
|
| 349 |
-
.icv .hero .tagline { color:var(--gold-2); font-size:1.2rem; font-weight:600; margin:.1rem 0 .6rem; }
|
| 350 |
-
.icv .hero .sub { max-width:720px; margin:0 auto; color:#E9F2EE; font-size:1rem; }
|
| 351 |
-
.icv .flow { display:flex; flex-wrap:wrap; justify-content:center; align-items:center; gap:8px; margin-top:16px; }
|
| 352 |
-
.icv .flow span { background:rgba(255,255,255,.12); border:1px solid rgba(226,192,110,.55); color:#FFF; border-radius:999px; padding:3px 16px; font-size:.9rem; }
|
| 353 |
-
.icv .flow i { color:var(--gold-2); font-style:normal; font-size:1.2rem; }
|
| 354 |
-
.icv .disclaimer { font-size:.85rem; color:var(--muted); text-align:center; padding:14px 8px; }
|
| 355 |
-
.icv .en-free { direction:rtl; }
|
| 356 |
-
.input-area textarea { direction:rtl; text-align:right; font-family:'Amiri','Cairo',serif !important; font-size:1.25rem !important; line-height:2.1 !important; background:#FFFFFF !important; color:#1F2933 !important; }
|
| 357 |
-
.llm-row label, .gradio-container label span { font-family:'Cairo',sans-serif; }
|
| 358 |
-
.results { direction:rtl; }
|
| 359 |
-
.icv .summary { display:grid; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); gap:10px; margin:8px 0 14px; }
|
| 360 |
-
.icv .tile { background:var(--paper); border:1px solid var(--line); border-radius:14px; padding:12px 8px; text-align:center; }
|
| 361 |
-
.icv .tile b { display:block; font-size:1.8rem; color:var(--green); line-height:1.3; } .icv .tile span { font-size:.92rem; color:var(--muted); }
|
| 362 |
-
.icv .tile.verified { background:var(--ok-bg); border-color:var(--ok-line); } .icv .tile.verified b { color:var(--ok); }
|
| 363 |
-
.icv .tile.mismatch { background:var(--bad-bg); border-color:var(--bad-line); } .icv .tile.mismatch b { color:var(--bad); }
|
| 364 |
-
.icv .tile.review { background:var(--warn-bg); border-color:var(--warn-line); } .icv .tile.review b { color:var(--warn); }
|
| 365 |
-
.icv .tile.zero { background:var(--paper); border-color:var(--line); opacity:.6; } .icv .tile.zero b { color:var(--muted); }
|
| 366 |
-
.icv .highlight, .icv .generated, .icv .final { background:var(--paper); border:1px solid var(--line); border-radius:14px; padding:14px 18px; margin-bottom:14px; }
|
| 367 |
-
.icv label { display:block; color:var(--muted); font-size:.82rem; font-weight:600; margin-bottom:4px; }
|
| 368 |
-
.icv .highlight p, .icv .generated p, .icv .final-text { font-family:'Amiri','Cairo',serif; font-size:1.2rem; line-height:2.2; margin:0; white-space:pre-wrap; }
|
| 369 |
-
.icv mark { color:var(--ink); border-radius:6px; padding:1px 5px; }
|
| 370 |
-
.icv mark.verified { background:#D5EEDF; } .icv mark.mismatch { background:#F8CFCB; } .icv mark.review { background:#F7E3A6; }
|
| 371 |
-
.icv .hl-legend { display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; font-size:.78rem; }
|
| 372 |
-
.icv .qcard { background:var(--paper); border:1px solid var(--line); border-inline-start:6px solid var(--line); border-radius:16px; padding:16px 18px; margin:12px 0; }
|
| 373 |
-
.icv .qcard.verified { border-inline-start-color:var(--ok); } .icv .qcard.mismatch { border-inline-start-color:var(--bad); } .icv .qcard.review { border-inline-start-color:var(--gold); }
|
| 374 |
-
.icv .qhead { display:flex; flex-wrap:wrap; gap:8px; align-items:center; margin-bottom:8px; }
|
| 375 |
-
.icv .idx { background:var(--green); color:#FFF; border-radius:50%; width:28px; height:28px; display:inline-flex; align-items:center; justify-content:center; font-weight:700; font-size:.9rem; }
|
| 376 |
-
.icv .badge { padding:2px 14px; border-radius:999px; font-size:.84rem; background:#F3EEDD; border:1px solid var(--line); color:var(--ink); }
|
| 377 |
-
.icv .badge.st.verified { background:var(--ok-bg); border-color:var(--ok-line); color:var(--ok); font-weight:600; }
|
| 378 |
-
.icv .badge.st.mismatch { background:var(--bad-bg); border-color:var(--bad-line); color:var(--bad); font-weight:600; }
|
| 379 |
-
.icv .badge.st.review { background:var(--warn-bg); border-color:var(--warn-line); color:var(--warn); font-weight:600; }
|
| 380 |
-
.icv .badge.scan { background:#EEF3FB; border-color:#C9D8EE; color:#2F4F7F; }
|
| 381 |
-
.icv .conf { margin-inline-start:auto; color:var(--muted); font-size:.88rem; } .icv .conf b { color:var(--green); }
|
| 382 |
-
.icv .field { margin:8px 0; } .icv .field p { margin:0; }
|
| 383 |
-
.icv .quote { font-family:'Amiri','Cairo',serif; font-size:1.25rem; line-height:2.2; color:var(--ink); } .icv .quote.small { font-size:1.05rem; color:#3a4651; }
|
| 384 |
-
.icv .diff { font-family:'Amiri','Cairo',serif; font-size:1.2rem; line-height:2.2; }
|
| 385 |
-
.icv .w-extra { background:var(--bad-bg); color:var(--bad); border-radius:4px; padding:0 4px; text-decoration:line-through; }
|
| 386 |
-
.icv .w-missing { background:var(--ok-bg); color:var(--ok); border-radius:4px; padding:0 4px; font-weight:700; }
|
| 387 |
-
.icv .legend { color:var(--muted); font-size:.82rem; margin:4px 0 0; } .icv .legend span { text-decoration:none; font-size:.8rem; }
|
| 388 |
-
.icv .reason { color:var(--muted); font-size:.92rem; margin:6px 0 0; }
|
| 389 |
-
.icv .note { color:var(--warn); background:var(--warn-bg); border:1px solid var(--warn-line); border-radius:10px; padding:5px 12px; font-size:.88rem; margin:8px 0 0; }
|
| 390 |
-
.icv .action { border-radius:12px; padding:10px 14px; margin-top:10px; }
|
| 391 |
-
.icv .action.ok { background:var(--ok-bg); border:1px solid var(--ok-line); } .icv .action.ok b { color:var(--ok); }
|
| 392 |
-
.icv .action.warn { background:var(--warn-bg); border:1px solid var(--warn-line); } .icv .action.warn b { color:var(--warn); }
|
| 393 |
-
.icv .action.bad { background:var(--bad-bg); border:1px solid var(--bad-line); } .icv .action.bad b { color:var(--bad); }
|
| 394 |
-
.icv .evidence { margin-top:12px; border-top:1px dashed var(--line); padding-top:8px; }
|
| 395 |
-
.icv .evidence summary { cursor:pointer; color:var(--green); font-weight:700; }
|
| 396 |
-
.icv .ev-row { margin:10px 0; } .icv .ev-row b { color:var(--gold); font-size:.88rem; } .icv .ev-row p { margin:2px 0; }
|
| 397 |
-
.icv .indicators { display:grid; gap:6px; margin-top:6px; }
|
| 398 |
-
.icv .ind { display:grid; grid-template-columns:150px 1fr 48px; gap:10px; align-items:center; font-size:.88rem; }
|
| 399 |
-
.icv .bar { background:#EFE8D3; border-radius:999px; height:9px; overflow:hidden; direction:rtl; } .icv .bar span { display:block; height:100%; background:linear-gradient(270deg,var(--green),var(--gold)); }
|
| 400 |
-
.icv .ind-val { text-align:left; direction:ltr; color:var(--ink); } .icv .ind-val.wide { grid-column:2 / span 2; text-align:right; direction:rtl; }
|
| 401 |
-
.icv .final { border-color:var(--gold); background:#FFFDF6; }
|
| 402 |
-
.icv .final-head { display:flex; justify-content:space-between; align-items:center; } .icv .final-head b { color:var(--green); font-size:1.05rem; }
|
| 403 |
-
.icv .copy { background:var(--green); color:#FFF; border:0; border-radius:10px; padding:5px 16px; font-family:inherit; cursor:pointer; }
|
| 404 |
-
.icv .notice { background:var(--paper); border:1px solid var(--line); border-radius:14px; padding:16px; }
|
| 405 |
-
.icv .notice.warn { background:var(--warn-bg); border-color:var(--warn-line); color:var(--warn); } .icv .notice.bad { background:var(--bad-bg); border-color:var(--bad-line); color:var(--bad); }
|
| 406 |
-
@media (max-width:640px){ .icv .hero h1{font-size:1.7rem;} .icv .ind{grid-template-columns:104px 1fr 40px;} }
|
| 407 |
-
""".replace("PATTERN", _PATTERN)
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
GLASS_CSS = """
|
| 411 |
-
:root { --glass:rgba(255,255,255,.62); --glass-strong:rgba(255,255,255,.82); --glass-line:rgba(255,255,255,.75);
|
| 412 |
-
--shadow-1:0 1px 2px rgba(15,76,58,.06), 0 8px 24px rgba(15,76,58,.08); --shadow-2:0 2px 4px rgba(15,76,58,.08), 0 18px 44px rgba(15,76,58,.16); }
|
| 413 |
-
.gradio-container, body.icv-page { background:
|
| 414 |
-
radial-gradient(900px 520px at 88% -8%, rgba(226,192,110,.34), transparent 60%),
|
| 415 |
-
radial-gradient(760px 520px at 6% 4%, rgba(23,105,79,.20), transparent 62%),
|
| 416 |
-
linear-gradient(180deg,#FBF6EA 0%,#F3EBD3 100%) !important; background-attachment:fixed !important; }
|
| 417 |
-
/* RTL safety: long words, URLs and mixed Latin/digit runs wrap inside their box instead of spilling out */
|
| 418 |
-
.icv, .icv * { box-sizing:border-box; min-width:0; }
|
| 419 |
-
.icv p, .icv span, .icv b, .icv label, .icv summary, .icv button, .icv .badge, .icv .tile { overflow-wrap:anywhere; }
|
| 420 |
-
.icv .quote, .icv .diff, .icv .final-text, .icv .highlight p, .icv .generated p { unicode-bidi:plaintext; text-align:start; }
|
| 421 |
-
.icv .hero { position:relative; overflow:hidden; border-bottom:0; border:1px solid rgba(226,192,110,.45);
|
| 422 |
-
background:linear-gradient(120deg,#0B3B2D,#17694F 45%,#0F4C3A 70%,#1d7a5c); background-size:240% 240%; animation:icv-flow 16s ease-in-out infinite;
|
| 423 |
-
box-shadow:var(--shadow-2); }
|
| 424 |
-
.icv .hero::before { content:""; position:absolute; inset:-40% -10% auto auto; width:60%; aspect-ratio:1; border-radius:50%;
|
| 425 |
-
background:radial-gradient(circle, rgba(226,192,110,.38), transparent 65%); pointer-events:none; }
|
| 426 |
-
.icv .hero::after { content:""; position:absolute; inset:auto auto 0 0; width:100%; height:4px; background:linear-gradient(90deg,transparent,var(--gold-2),transparent); }
|
| 427 |
-
.icv .hero h1 { font-size:clamp(1.45rem,4.2vw,2.3rem); line-height:1.5; text-wrap:balance; position:relative; }
|
| 428 |
-
.icv .hero .tagline, .icv .hero .sub, .icv .flow { position:relative; }
|
| 429 |
-
.icv .flow span { backdrop-filter:blur(6px); -webkit-backdrop-filter:blur(6px); }
|
| 430 |
-
@keyframes icv-flow { 0%,100%{background-position:0% 50%} 50%{background-position:100% 50%} }
|
| 431 |
-
.icv .tile, .icv .highlight, .icv .generated, .icv .final, .icv .qcard, .icv .notice, .icv .export {
|
| 432 |
-
background:var(--glass); border:1px solid var(--glass-line); box-shadow:var(--shadow-1);
|
| 433 |
-
backdrop-filter:blur(14px) saturate(150%); -webkit-backdrop-filter:blur(14px) saturate(150%); transition:transform .25s ease, box-shadow .25s ease; }
|
| 434 |
-
.icv .qcard { border-inline-start:6px solid var(--line); }
|
| 435 |
-
.icv .qcard:hover, .icv .tile:hover { transform:translateY(-2px); box-shadow:var(--shadow-2); }
|
| 436 |
-
.icv .tile.verified { background:linear-gradient(160deg,rgba(234,246,239,.92),rgba(255,255,255,.6)); }
|
| 437 |
-
.icv .tile.mismatch { background:linear-gradient(160deg,rgba(253,236,234,.92),rgba(255,255,255,.6)); }
|
| 438 |
-
.icv .tile.review { background:linear-gradient(160deg,rgba(255,246,218,.95),rgba(255,255,255,.6)); }
|
| 439 |
-
.icv .final { background:linear-gradient(160deg,rgba(255,253,246,.92),rgba(250,240,208,.55)); border-color:rgba(184,145,47,.55); }
|
| 440 |
-
.icv .final-head { flex-wrap:wrap; gap:10px; }
|
| 441 |
-
.icv .qhead .badge { max-width:100%; white-space:normal; }
|
| 442 |
-
.icv .ind { grid-template-columns:minmax(96px,150px) minmax(0,1fr) 48px; }
|
| 443 |
-
.icv .bar span { background:linear-gradient(270deg,var(--green),var(--gold-2)); transition:width .6s ease; }
|
| 444 |
-
.icv .copy, .icv .dl { background:linear-gradient(135deg,var(--green),var(--green-2)); color:#FFF; border:0; border-radius:12px; padding:7px 18px;
|
| 445 |
-
font-family:inherit; font-weight:600; cursor:pointer; box-shadow:0 4px 12px rgba(15,76,58,.25); transition:transform .15s ease, box-shadow .15s ease, filter .15s ease; }
|
| 446 |
-
.icv .copy:hover, .icv .dl:hover { transform:translateY(-1px); filter:brightness(1.08); box-shadow:0 8px 18px rgba(15,76,58,.3); }
|
| 447 |
-
.icv .copy:active, .icv .dl:active { transform:translateY(0); }
|
| 448 |
-
.icv .copy:focus-visible, .icv .dl:focus-visible { outline:3px solid rgba(184,145,47,.55); outline-offset:2px; }
|
| 449 |
-
.icv .copy.done { background:linear-gradient(135deg,#1B7A4B,#2a9d66); }
|
| 450 |
-
.icv .export { border-radius:16px; padding:12px 18px; margin:12px 0; }
|
| 451 |
-
.icv .export summary { cursor:pointer; color:var(--green); font-weight:700; }
|
| 452 |
-
.icv .dls { display:flex; flex-wrap:wrap; gap:10px; margin-top:10px; }
|
| 453 |
-
/* toast */
|
| 454 |
-
#icv-toast { position:fixed; inset-inline:0; bottom:28px; margin-inline:auto; width:max-content; max-width:calc(100vw - 32px); z-index:99999;
|
| 455 |
-
direction:rtl; text-align:center; font:600 1rem 'Cairo','Segoe UI',Tahoma,sans-serif; color:#FFF; padding:12px 24px; border-radius:999px;
|
| 456 |
-
background:linear-gradient(135deg,rgba(15,76,58,.94),rgba(23,105,79,.94)); border:1px solid rgba(226,192,110,.6);
|
| 457 |
-
box-shadow:0 14px 40px rgba(15,76,58,.35); backdrop-filter:blur(10px); -webkit-backdrop-filter:blur(10px);
|
| 458 |
-
opacity:0; transform:translateY(18px) scale(.97); pointer-events:none; transition:opacity .28s ease, transform .28s cubic-bezier(.2,.9,.3,1.2); }
|
| 459 |
-
#icv-toast.show { opacity:1; transform:none; } #icv-toast.bad { background:linear-gradient(135deg,rgba(179,38,30,.95),rgba(214,69,58,.95)); }
|
| 460 |
-
/* skeleton loaders */
|
| 461 |
-
.skel { position:relative; overflow:hidden; background:rgba(15,76,58,.08); border-radius:10px; }
|
| 462 |
-
.skel::after { content:""; position:absolute; inset:0; transform:translateX(100%); animation:icv-shimmer 1.4s infinite;
|
| 463 |
-
background:linear-gradient(90deg,transparent,rgba(255,255,255,.75),transparent); }
|
| 464 |
-
@keyframes icv-shimmer { 100% { transform:translateX(-100%); } }
|
| 465 |
-
.skel-card { background:var(--glass); border:1px solid var(--glass-line); border-radius:16px; padding:16px 18px; margin:12px 0; box-shadow:var(--shadow-1); }
|
| 466 |
-
.skel-line { height:14px; margin:10px 0; } .skel-line.w60 { width:60%; } .skel-line.w85 { width:85%; } .skel-line.w40 { width:40%; }
|
| 467 |
-
.skel-tiles { display:grid; grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:10px; margin:8px 0 14px; } .skel-tile { height:78px; border-radius:14px; }
|
| 468 |
-
.icv-spinner { width:18px; height:18px; border-radius:50%; border:3px solid rgba(15,76,58,.18); border-top-color:var(--gold); display:inline-block;
|
| 469 |
-
vertical-align:middle; margin-inline-end:10px; animation:icv-spin .8s linear infinite; }
|
| 470 |
-
@keyframes icv-spin { to { transform:rotate(360deg); } }
|
| 471 |
-
@media (prefers-reduced-motion: reduce) { .icv .hero, .skel::after, .icv-spinner { animation:none; } .icv .qcard, .icv .tile, #icv-toast { transition:none; } }
|
| 472 |
-
@media (max-width:640px){ .icv .ind{grid-template-columns:minmax(84px,104px) minmax(0,1fr) 40px;} .icv .final-head{flex-direction:column; align-items:stretch;} .icv .copy{width:100%;} }
|
| 473 |
-
/* layout polish: centred, compact, professional */
|
| 474 |
-
.icv .notice, .icv .disclaimer, .icv .export { text-align:center; }
|
| 475 |
-
.icv .export .legend { max-width:640px; margin:8px auto 0; font-size:.9rem; line-height:1.9; color:var(--muted); }
|
| 476 |
-
.icv .dls { justify-content:center; }
|
| 477 |
-
.icv .dl { display:inline-flex; flex-direction:column; align-items:center; gap:2px; min-width:170px; }
|
| 478 |
-
.icv .dl .t { font-weight:700; } .icv .dl .s { font-size:.78rem; font-weight:500; opacity:.85; }
|
| 479 |
-
.icv .hero .flow { display:flex; justify-content:center; flex-wrap:wrap; gap:8px; }
|
| 480 |
-
|
| 481 |
-
/* ---- Amanah AI visual identity ---- */
|
| 482 |
-
.icv .hero { padding:38px 24px 30px; border-radius:26px; background:
|
| 483 |
-
radial-gradient(900px 300px at 85% -10%, rgba(226,192,110,.28), transparent 60%),
|
| 484 |
-
radial-gradient(700px 320px at 0% 110%, rgba(23,105,79,.9), transparent 70%),
|
| 485 |
-
linear-gradient(135deg,#0A3B2C 0%,#0F4C3A 45%,#17694F 100%); box-shadow:0 18px 50px rgba(10,59,44,.28); }
|
| 486 |
-
.icv .hero .mark { width:60px; height:60px; margin-bottom:6px; filter:drop-shadow(0 4px 10px rgba(226,192,110,.45)); }
|
| 487 |
-
.icv .hero h1.brand { font-family:'Cairo','Segoe UI',sans-serif; font-weight:800; font-size:clamp(2.4rem,7vw,3.9rem); letter-spacing:.02em; direction:ltr;
|
| 488 |
-
line-height:1.15; margin:.1rem 0 .2rem; background:linear-gradient(180deg,#FFFFFF 30%,#F3DFA6 100%); -webkit-background-clip:text; background-clip:text; color:transparent; }
|
| 489 |
-
.icv .hero .tagline { font-size:clamp(1.05rem,2.6vw,1.45rem); font-weight:700; color:var(--gold-2); margin:.2rem 0 .8rem; }
|
| 490 |
-
.icv .hero .sub { max-width:760px; font-size:1.02rem; line-height:2; color:#E4EFEA; }
|
| 491 |
-
.icv .trust { list-style:none; display:flex; flex-wrap:wrap; justify-content:center; gap:10px; margin:20px 0 0; padding:0; position:relative; }
|
| 492 |
-
.icv .trust li { background:rgba(255,255,255,.1); border:1px solid rgba(226,192,110,.5); border-radius:14px; padding:8px 16px; color:#FFF; font-size:.92rem; backdrop-filter:blur(6px); }
|
| 493 |
-
.icv .trust li b { color:var(--gold-2); font-size:1.05rem; margin-inline-end:6px; }
|
| 494 |
-
.icv .tile { box-shadow:0 6px 18px rgba(15,76,58,.07); transition:transform .2s; } .icv .tile:hover { transform:translateY(-2px); }
|
| 495 |
-
.icv .qcard { box-shadow:0 8px 26px rgba(15,76,58,.09); }
|
| 496 |
-
"""
|
| 497 |
-
CSS += GLASS_CSS
|
| 498 |
-
|
| 499 |
-
SKELETON = (
|
| 500 |
-
'<div class="icv" aria-busy="true" aria-label="جارٍ التحقق">'
|
| 501 |
-
'<div class="skel-tiles">' + '<div class="skel skel-tile"></div>' * 4 + '</div>'
|
| 502 |
-
+ ('<div class="skel-card"><div class="skel skel-line w40"></div><div class="skel skel-line w85"></div>'
|
| 503 |
-
'<div class="skel skel-line"></div><div class="skel skel-line w60"></div></div>') * 2
|
| 504 |
-
+ '</div>'
|
| 505 |
-
)
|
| 506 |
-
|
| 507 |
-
COPY_JS = r"""
|
| 508 |
-
(function () {
|
| 509 |
-
if (window.icvCopy) return;
|
| 510 |
-
function toast(message, bad) {
|
| 511 |
-
var t = document.getElementById('icv-toast');
|
| 512 |
-
if (!t) { t = document.createElement('div'); t.id = 'icv-toast'; t.setAttribute('role', 'status'); t.setAttribute('aria-live', 'polite'); document.body.appendChild(t); }
|
| 513 |
-
t.textContent = message; t.className = 'show' + (bad ? ' bad' : '');
|
| 514 |
-
clearTimeout(window.__icvToast); window.__icvToast = setTimeout(function () { t.className = bad ? 'bad' : ''; }, 2400);
|
| 515 |
-
}
|
| 516 |
-
function legacyCopy(text) {
|
| 517 |
-
var area = document.createElement('textarea'); area.value = text; area.setAttribute('readonly', '');
|
| 518 |
-
area.style.cssText = 'position:fixed;top:0;left:0;opacity:0;pointer-events:none'; document.body.appendChild(area);
|
| 519 |
-
area.select(); area.setSelectionRange(0, text.length); var ok = false;
|
| 520 |
-
try { ok = document.execCommand('copy'); } catch (e) { ok = false; }
|
| 521 |
-
document.body.removeChild(area); return ok;
|
| 522 |
-
}
|
| 523 |
-
window.icvToast = toast;
|
| 524 |
-
window.icvCopy = function (button) {
|
| 525 |
-
var text = button.getAttribute('data-text') || '';
|
| 526 |
-
function finish(ok) {
|
| 527 |
-
toast(ok ? '__COPIED__' : 'تعذّر النسخ، حدّد النص وانسخه يدويًا', !ok);
|
| 528 |
-
if (ok) { button.classList.add('done'); setTimeout(function () { button.classList.remove('done'); }, 1600); }
|
| 529 |
-
}
|
| 530 |
-
if (navigator.clipboard && window.isSecureContext) {
|
| 531 |
-
navigator.clipboard.writeText(text).then(function () { finish(true); }, function () { finish(legacyCopy(text)); });
|
| 532 |
-
} else { finish(legacyCopy(text)); }
|
| 533 |
-
};
|
| 534 |
-
window.icvDownload = function (button) {
|
| 535 |
-
var blob = new Blob([button.getAttribute('data-text') || ''], { type: 'text/tab-separated-values;charset=utf-8' });
|
| 536 |
-
var link = document.createElement('a'); link.href = URL.createObjectURL(blob); link.download = button.getAttribute('data-name') || 'results.tsv';
|
| 537 |
-
document.body.appendChild(link); link.click(); document.body.removeChild(link); setTimeout(function () { URL.revokeObjectURL(link.href); }, 1000);
|
| 538 |
-
};
|
| 539 |
-
})();
|
| 540 |
-
""".replace("__COPIED__", COPIED_MESSAGE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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