1import{aa as J,ab as W,bo as E,r as d,j as e,a9 as H,a6 as $,x as O,aA as X,ag as D,bK as Z,_ as ee,aL as T,av as se,bz as Y,bL as te,bI as z,bn as L,bM as ae,au as le,aQ as re,q as B,n as ne,bN as V,bs as ie,bt as ce,aN as _,bO as oe,aK as de,aJ as q,X as G,T as K,D as xe,aM as me,A as he,N as be,bE as fe}from"./index-aQkVUlMC.js";import{P as ue}from"./PrescriptionDetailsModal-BlWbcUDm.js";import{p as pe}from"./payment.service-DSYw8qoj.js";import{f as je}from"./helpers-BjPMjhCy.js";import"./index-D-SuB-5T.js";import"./doctor.service-xNdIyfxJ.js";const ge=J(W(h=>({nearbyPharmacies:[],loading:!1,error:null,fetchNearbyPharmacies:async()=>{console.log("ðª [PharmacyStore] Fetching nearby pharmacies..."),h({loading:!0,error:null});try{const n=await E.getNearbyPharmacies();console.log("â
[PharmacyStore] Nearby pharmacies fetched:",n),console.log("â
[PharmacyStore] Type check - is array:",Array.isArray(n));const s=Array.isArray(n)?n:[];return h({nearbyPharmacies:s,loading:!1,error:null}),{success:!0,data:s}}catch(n){console.error("â [PharmacyStore] Error fetching pharmacies:",n);const s=n.response?.data?.message||"ÙØ´Ù ÙÙ Ø¬ÙØ¨ Ø§ÙØµÙدÙÙØ§Øª اÙÙØ±Ùبة";return h({nearbyPharmacies:[],loading:!1,error:s}),{success:!1,error:s}}},clearPharmacies:()=>{console.log("ð§¹ [PharmacyStore] Clearing pharmacies data"),h({nearbyPharmacies:[],loading:!1,error:null})},sendPrescriptionToPharmacy:async(n,s)=>{console.log(`ð¤ [PharmacyStore] Sending prescription ${n} to pharmacy ${s}...`);try{const i=await E.sendPrescriptionToPharmacy(n,s);return console.log("â
[PharmacyStore] Prescription sent successfully:",i),{success:!0,data:i}}catch(i){return console.error("â [PharmacyStore] Error sending prescription:",i),{success:!1,error:i.response?.data?.message||"ÙØ´Ù ÙÙ Ø¥Ø±Ø³Ø§Ù Ø§ÙØ±Ùشتة"}}},clearError:()=>{h({error:null})}}),{name:"pharmacy-store",partialize:h=>({nearbyPharmacies:h.nearbyPharmacies})})),Q=({autoFetch:h=!1}={})=>{const{nearbyPharmacies:n,loading:s,error:i,fetchNearbyPharmacies:o,sendPrescriptionToPharmacy:l,clearPharmacies:x,clearError:j}=ge();d.useEffect(()=>{h&&(console.log("ð [usePharmacy] Auto-fetching nearby pharmacies..."),o())},[h,o]),d.useEffect(()=>()=>{},[]);const g=n&&n.length>0;return{nearbyPharmacies:n,loading:s,error:i,hasPharmacies:g,isEmpty:!s&&!g,fetchNearbyPharmacies:o,sendPrescriptionToPharmacy:l,clearPharmacies:x,clearError:j}},Ne=({pharmacies:h=[],loading:n,onClose:s,onSelectPharmacy:i,prescription:o})=>{const[l,x]=d.useState(new Set),[j,g]=d.useState(null),[v,y]=d.useState(!1),{sendPrescriptionToPharmacy:F}=Q(),c=Array.isArray(h)?h:[],P=async a=>{if(!o?.id)return console.error("â No prescription ID provided"),{success:!1,pharmacyName:a.name,error:"ÙØ§ ÙÙØ¬Ø¯ Ù
عر٠ÙÙØ±Ùشتة"};g(a.id),console.log("ð¤ Sending prescription to pharmacy:",a.name,"Prescription ID:",o.id);try{const p=await F(o.id,a.id);if(!p.success){const b=p.error||"ÙØ´Ù ÙÙ Ø¥Ø±Ø³Ø§Ù Ø§ÙØ±Ùشتة";return console.error("â API returned error:",b),{success:!1,pharmacyName:a.name,error:b}}return x(b=>new Set([...b,a.id])),console.log("â
Prescription sent successfully to:",a.name),{success:!0,pharmacyName:a.name}}catch(p){console.error("â Unexpected error sending prescription:",p);const b=p?.message||"ØØ¯Ø« خطأ ØºÙØ± Ù
تÙÙØ¹";return{success:!1,pharmacyName:a.name,error:b}}finally{g(null)}},M=async()=>{if(!o?.id){console.error("â No prescription ID provided"),alert("خطأ: ÙØ§ ÙÙØ¬Ø¯ Ù
عر٠ÙÙØ±Ùشتة");return}y(!0),console.log("ð¤ Sending prescription to all pharmacies");const a=[];
1for(const N of c)if(!l.has(N.id)){g(N.id);const C=await P(N);a.push(C),await new Promise(R=>setTimeout(R,300))}y(!1),g(null);const p=a.filter(N=>N.success).length,b=a.filter(N=>!N.success).length,A=a.filter(N=>!N.success);if(b===0&&p>0)alert(`â ØªÙ Ø¥Ø±Ø³Ø§Ù Ø§ÙØ±Ùشتة Ø¨ÙØ¬Ø§Ø Ø¥ÙÙ Ø¬Ù ÙØ¹ Ø§ÙØµÙدÙÙØ§Øª (${p})`);else if(p===0&&b>0){const N=A.map(C=>`- ${C.pharmacyName}: ${C.error}`).join(` 2`);alert(`â ÙØ´Ù Ø¥Ø±Ø³Ø§Ù Ø§ÙØ±Ùشتة ÙØ¬Ù ÙØ¹ Ø§ÙØµÙدÙÙØ§Øª: 3 4${N}`)}else if(p>0&&b>0){const N=A.map(C=>`- ${C.pharmacyName}: ${C.error}`).join(` 5`);alert(`â ï¸ ÙØªØ§Ø¦Ø¬ Ù ØªÙØ§Ùتة: 6 7â ØªÙ Ø§ÙØ¥Ø±Ø³Ø§Ù Ø¨ÙØ¬Ø§Ø: ${p} 8â ÙØ´Ù Ø§ÙØ¥Ø±Ø³Ø§Ù: ${b} 9 10ØªÙØ§ØµÙÙ Ø§ÙØ£Ø®Ø·Ø§Ø¡: 11${N}`)}else alert("ÙØ§ ØªÙØ¬Ø¯ ØµÙØ¯ÙÙØ§Øª ÙÙØ¥Ø±Ø³Ø§Ù Ø¥ÙÙÙØ§")},k=a=>{console.log("ð Viewing report from pharmacy:",a.name),i&&i(a)};return n?e.jsx("div",{className:"p-8",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"inline-block w-16 h-16 border-4 border-teal-500 border-t-transparent rounded-full animate-spin mb-4"}),e.jsx("p",{className:"text-slate-600 font-semibold text-lg",children:"Ø¬Ø§Ø±Ù Ø§ÙØ¨ØØ« Ø¹Ù Ø£ÙØ±Ø¨ Ø§ÙØµÙدÙÙØ§Øª..."})]})})}):e.jsxs("div",{className:"p-8 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-black text-slate-800",children:"Ø£ÙØ±Ø¨ Ø§ÙØµÙدÙÙØ§Øª"}),e.jsx("p",{className:"text-slate-600 font-semibold mt-1",children:"اختر Ø§ÙØµÙدÙÙØ© اÙÙ ÙØ§Ø³Ø¨Ø© ÙÙ"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[c.length>0&&l.size<c.length&&e.jsx("button",{onClick:M,disabled:v||j!==null,className:"px-5 py-2.5 bg-gradient-to-r from-teal-500 to-emerald-600 hover:from-teal-600 hover:to-emerald-700 text-white font-bold rounded-xl transition-all shadow-md hover:shadow-lg disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:v?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),e.jsx("span",{children:"Ø¬Ø§Ø±Ù Ø§ÙØ¥Ø±Ø³Ø§Ù..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"text-sm"}),e.jsxs("span",{children:["إرسا٠ÙÙØ¬Ù ÙØ¹ (",c.length-l.size,")"]})]})}),e.jsx("button",{onClick:s,className:"w-10 h-10 bg-slate-100 hover:bg-slate-200 rounded-full flex items-center justify-center transition-all",children:e.jsx($,{className:"text-slate-600"})})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:c.map((a,p)=>e.jsxs("div",{className:"bg-white border-2 border-slate-200 rounded-2xl p-5 hover:border-teal-400 hover:shadow-lg transition-all duration-200 cursor-pointer group",onClick:()=>i&&i(a),children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-teal-500 to-emerald-600 rounded-lg flex items-center justify-center",children:e.jsxs("span",{className:"text-white font-black text-sm",children:["#",p+1]})}),l.has(a.id)&&e.jsxs("div",{className:"flex items-center gap-1 bg-green-100 px-2 py-1 rounded-lg",children:[e.jsx(O,{className:"text-green-600 text-xs"}),e.jsx("span",{className:"text-green-700 font-bold text-xs",children:"ØªÙ Ø§ÙØ¥Ø±Ø³Ø§Ù"})]})]}),a.rating&&e.jsxs("div",{className:"flex items-center gap-1 bg-amber-50 px-2 py-1 rounded-lg",children:[e.jsx(X,{className:"text-amber-500 text-xs"}),e.jsx("span",{className:"text-amber-700 font-bold text-xs",children:a.rating})]})]}),e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"w-20 h-20 rounded-full overflow-hidden border-4 border-teal-100 group-hover:border-teal-300 transition-all",children:e.jsx("img",{src:a.profileImageUrl,alt:a.name,className:"w-full h-full object-cover",onError:b=>{b.target.src="https://via.placeholder.com/150/00b19f/ffffff?text=ØµÙØ¯ÙÙØ©"}})})}),e.jsx("h4",{className:"text-lg font-black text-slate-800 text-center mb-3 group-hover:text-teal-600 transition-colors",children:a.name}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-3 bg-slate-50 rounded-lg py-2 px-3",children:[e.jsx(D,{className:"text-teal-600 text-sm"}),e.jsxs("span",{className:"text-slate-700 font-bold text-sm",children:[a.distanceInKm||a.distanceKm," ÙÙ "]})]}),e.jsx("div",{className:"mt-3 pt-3 border-t border-slate-200",children:a.offersDelivery||a.hasDelivery?e.jsxs("div",{className:"flex items-center justify-between bg-teal-50 rounded-lg py-2 px-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"text-teal-600 text-sm"}),e.jsx("span",{className:"text-teal-700 font-bold text-xs",children:"ØªÙØµÙ٠٠تاØ"})]}),e.jsx("span",{className:"text-teal-700 font-black text-sm",children:a.deliveryFee===0?"Ù Ø¬Ø§ÙØ§Ù":`${a.deliveryFee} ج.Ù `})]}):e.jsxs("div",{className:"flex items-center justify-center gap-2 bg-slate-100 rounded-lg py-2 px-3",children:[e.jsx($,{className:"text-slate-500 text-xs"}),e.jsx("span",{className:"text-slate-600 font-bold text-xs",children:"ÙØ§ ÙÙØ¬Ø¯ ØªÙØµÙÙ"})]})}),a.phoneNumber&&e.jsx("div",{className:"mt-3 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsxs("div",{className:"flex items-center justify-center gap-2 text-slate-600",children:[e.jsx(ee,{className:"text-xs"}),e.jsx("span",{className:"text-xs font-semibold",children:a.phoneNumber})]})}),l.has(a.id)?e.jsxs("button",{onClick:b=>{b.stopPropagation(),k(a)},className:"w-full mt-4 px-4 py-2.5 bg-gradient-to-r from-blue-500 to-blue-600 hover:from-blue-600 hover:to-blue-700 text-white font-bold rounded-xl transition-all shadow-md hover:shadow-lg flex items-center justify-center gap-2",children:[e.jsx(T,{className:"text-sm"}),"عرض Ø§ÙØªÙØ±ÙØ±"]}):e.jsx("button",{onClick:b=>{b.stopPropagation(),P(a)},disabled:j===a.id,className:"w-full mt-4 px-4 py-2.5 bg-gradient-to-r from-teal-500 to-emerald-600 hover:from-teal-600 hover:to-emerald-700 text-white font-bold rounded-xl transition-all shadow-md hover:shadow-lg disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:j===a.id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
11ded-full animate-spin"}),e.jsx("span",{children:"Ø¬Ø§Ø±Ù Ø§ÙØ¥Ø±Ø³Ø§Ù..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(H,{className:"text-sm"}),"Ø¥Ø±Ø³Ø§Ù Ø§ÙØ±Ùشتة"]})})]},a.id))}),c.length===0&&!n&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-24 h-24 bg-slate-100 rounded-2xl flex items-center justify-center mx-auto mb-4",children:e.jsx(D,{className:"text-4xl text-slate-400"})}),e.jsx("h3",{className:"text-xl font-bold text-slate-700 mb-2",children:"ÙØ§ ØªÙØ¬Ø¯ ØµÙØ¯ÙÙØ§Øª ÙØ±Ùبة"}),e.jsx("p",{className:"text-slate-500",children:"ÙÙ ÙØªÙ ÙÙ Ù Ù Ø§ÙØ¹Ø«Ùر عÙÙ ØµÙØ¯ÙÙØ§Øª ÙÙ Ù ÙØ·ÙتÙ"})]})]})},ve={available:{label:"٠تÙÙØ±",color:"green",bgColor:"bg-green-50",borderColor:"border-green-200",textColor:"text-green-700",iconColor:"text-green-600"},unavailable:{label:"ØºÙØ± ٠تÙÙØ±",color:"red",bgColor:"bg-red-50",borderColor:"border-red-200",textColor:"text-red-700",iconColor:"text-red-600"},has_alternative:{label:"بدÙ٠٠تÙÙØ±",color:"amber",bgColor:"bg-amber-50",borderColor:"border-amber-200",textColor:"text-amber-700",iconColor:"text-amber-600"}},ye=({isOpen:h,onClose:n,pharmacy:s,report:i})=>{if(!h)return null;const o=i&&i.status!=="pending";return e.jsxs("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4 animate-fadeIn",children:[e.jsxs("div",{className:"bg-white rounded-3xl shadow-2xl max-w-3xl w-full overflow-hidden animate-slideUp max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"relative bg-gradient-to-br from-blue-500 via-blue-600 to-indigo-600 p-8",children:[e.jsx("button",{onClick:n,className:"absolute top-4 left-4 w-10 h-10 bg-white/20 hover:bg-white/30 rounded-full flex items-center justify-center transition-all duration-200 hover:rotate-90",children:e.jsx($,{className:"text-white text-lg"})}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-16 h-16 rounded-full overflow-hidden border-4 border-white/30 flex-shrink-0",children:e.jsx("img",{src:s?.profileImageUrl,alt:s?.name,className:"w-full h-full object-cover",onError:l=>{l.target.src="https://via.placeholder.com/150/00b19f/ffffff?text=ØµÙØ¯ÙÙØ©"}})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-black text-white mb-1",children:"ØªÙØ±Ùر Ø§ÙØµÙدÙÙØ©"}),e.jsx("p",{className:"text-sm text-white/80 font-semibold",children:s?.name})]})]})]}),e.jsxs("div",{className:"p-8",children:[o?e.jsxs("div",{className:"space-y-6",children:[i.summary&&e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"bg-green-50 rounded-xl p-4 border-2 border-green-200 text-center",children:[e.jsx("div",{className:"text-2xl font-black text-green-700",children:i.summary.availableItems}),e.jsx("div",{className:"text-xs font-semibold text-green-600 mt-1",children:"٠تÙÙØ±"})]}),e.jsxs("div",{className:"bg-amber-50 rounded-xl p-4 border-2 border-amber-200 text-center",children:[e.jsx("div",{className:"text-2xl font-black text-amber-700",children:i.summary.alternativeItems}),e.jsx("div",{className:"text-xs font-semibold text-amber-600 mt-1",children:"بدÙ٠٠تÙÙØ±"})]}),e.jsxs("div",{className:"bg-red-50 rounded-xl p-4 border-2 border-red-200 text-center",children:[e.jsx("div",{className:"text-2xl font-black text-red-700",children:i.summary.unavailableItems}),e.jsx("div",{className:"text-xs font-semibold text-red-600 mt-1",children:"ØºÙØ± ٠تÙÙØ±"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h4",{className:"text-lg font-black text-slate-800 flex items-center gap-2",children:[e.jsx(Y,{className:"text-teal-600"}),"ØªÙØ§ØµÙÙ Ø§ÙØ£Ø¯ÙÙØ©"]}),i.medications&&i.medications.map(l=>{const x=ve[l.availability];return e.jsx("div",{className:`${x.bgColor} border-2 ${x.borderColor} rounded-xl p-4`,children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h5",{className:"font-black text-slate-800",children:l.name}),e.jsx("span",{className:`px-2 py-1 ${x.bgColor} ${x.textColor} text-xs font-bold rounded-lg border ${x.borderColor}`,children:x.label})]}),l.availability==="has_alternative"&&e.jsxs("div",{className:"flex items-start gap-2 mt-2 bg-white/50 rounded-lg p-2",children:[e.jsx(te,{className:"text-amber-600 text-sm mt-1 flex-shrink-0"}),e.jsxs("div",{className:"text-xs",children:[e.jsxs("p",{className:"font-semibold text-slate-700",children:[e.jsx("span",{className:"text-amber-700 font-black",children:"Ø§ÙØ¨Ø¯ÙÙ:"})," ",l.alternativeName]}),l.alternativeReason&&e.jsx("p",{className:"text-slate-600 mt-1",children:l.alternativeReason})]})]}),l.availability==="unavailable"&&l.reason&&e.jsxs("p",{className:"text-xs text-red-600 font-semibold mt-1",children:[e.jsx(z,{className:"inline mr-1"}),l.reason]})]}),e.jsx("div",{className:"text-left flex-shrink-0",children:l.unitPrice!==null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-xs text-slate-600 font-semibold mb-1",children:[l.unit," à ",l.quantity]}),e.jsxs("div",{className:"text-sm font-bold text-slate-700",children:[l.unitPrice.toFixed(2)," ج.Ù / ",l.unit]}),e.jsxs("div",{className:"text-lg font-black text-teal-700 mt-1",children:[l.totalPrice.toFixed(2)," ج.Ù "]})]}):e.jsx("div",{className:"text-sm font-bold text-red-600",children:"-"})})]})},l.id)})]}),i.notes&&e.jsxs("div",{className:"bg-blue-50 rounded-xl p-4 border-2 border-blue-200",children:[e.jsx("h5",{className:"font-black text-blue-800 text-sm mb-2",children:"Ù ÙØ§ØØ¸Ø§Øª Ø§ÙØµÙدÙÙØ©:"}),e.jsx("p",{className:"text-blue-700 text-sm font-semibold",children:i.notes})]}),i.summary&&e.jsxs("div",{className:"bg-gradient-to-br from-teal-50 to-emerald-50 rounded-2xl p-6 border-2 border-teal-200",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(L,{className:"text-teal-600 text-xl"}),e.jsx("h4",{className:"text-lg font-black text-slate-800",children:"Ù ÙØ®Øµ Ø§ÙØªÙÙÙØ©"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-700 font-semibold",children:"إج٠اÙÙ Ø§ÙØ£Ø¯ÙÙØ©:"}),e.jsxs("span",{className:"text-slate-800 font-bold",children:[i.summary.subtotal.toFixed(2)," ج.Ù "]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-700 font-semibold",children:"رسÙÙ Ø§ÙØªÙصÙÙ:"}),e.jsxs("span",{className:"text-slate-800 font-bold",children:[i.summary.deliveryFee.toFixed(2)," ج.Ù "]})]}),e.jsx("div",{className:"h-px bg-teal-300 my-2"}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-teal-800 font-black text-lg",children:"Ø§ÙØ¥Ø¬Ù اÙÙ:"}),e.jsxs("span",{className:"text-teal-700 font-black text-2xl",children:[i.summary.total.toFixed(2)," ج.Ù "]})]})]}),e.jsx("button",{className:"w-full mt-4 px-6 py-3 bg-gradient-to-r from-teal-500 to-emerald-600 hover:from-teal-600 hover:to-emerald-700 text-white font-black rounded-xl transition-all shadow-md hover:shadow-lg",children:"تأÙÙØ¯ Ø§ÙØ·Ùب"})]})]}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"w-24 h-24 bg-amber-100 rounded-2xl flex items-center justify-center mx-auto mb-6",children:e.jsx(se,{className:"text-5xl text-amber-500 animate-pulse"})}),e.jsx("h3",{className:"text-2xl font-black text-slate-800 mb-3",children:"ÙÙ Ø§ÙØªØ¸Ø§Ø± Ø§ÙØ±Ø¯"}),e.jsx("p",{className:"text-slate-600 font-semibold text-lg mb-6",children:"Ù٠ترد Ø§ÙØµÙدÙÙØ© ØØªÙ Ø§ÙØ¢Ù"}),e.jsx("p",{className:"text-slate-500 text-sm",children:"Ø³ÙØªÙ إشعار٠ÙÙØ± Ø§Ø³ØªÙØ§Ù رد Ø§ÙØµÙدÙÙØ© عÙÙ Ø§ÙØ±Ùشتة"}),e.jsx("div",{className:"mt-8 bg-blue-50 rounded-2xl p-6 border-2 border-blue-200",children:e.jsx("p",{className:"text-blue-700 font-semibold text-sm",children:"ð¡ Ø¹Ø§Ø¯Ø©Ù ٠ا ØªØ³ØªØºØ±Ù Ø§ÙØµÙدÙÙØ§Øª Ù Ù 15-30 دÙÙÙØ© ÙÙØ±Ø¯ عÙÙ Ø§ÙØ·Ùبات"})})]}),e.jsx("div",{className:"mt-8 pt-6 border-t border-slate-200",children:e.jsx("button",{onClick:n,className:"w-full px-6 py-4 bg-slate-100 hover:bg-slate-200 text-slate-700 font-bold rounded-xl transition-all",children:"Ø¥ØºÙØ§Ù"})})]})]}),e.jsx("style",{jsx:!0,children:` 12 @keyframes fadeIn { 13 from { opacity: 0; } 14 to { opacity: 1; } 15 } 16 @keyframes slideUp { 17 from { transform: translateY(20px); opacity: 0; } 18 to { transform: translateY(0); opacity: 1; } 19 } 20 .animate-fadeIn { 21 animation: fadeIn 0.2s ease-out; 22 } 23 .animate-slideUp { 24 animation: slideUp 0.3s ease-out; 25 } 26 `})]})},we=({isOpen:h,onClose:n,prescription:s})=>{const[i,o]=d.useState(!1),[l,x]=d.useState(null),[j,g]=d.useState(!1),[v,y]=d.use
26State(null),[F,c]=d.useState(!1),[P,M]=d.useState([]),{nearbyPharmacies:k,loading:a,fetchNearbyPharmacies:p,clearError:b}=Q(),A=async()=>{try{const r=["order-1","order-2"],t=[];for(const w of r)try{const u=await E.getPharmacyResponse(w);u&&t.push({orderId:u.orderId,pharmacyId:u.orderId,pharmacyName:u.pharmacyName,pharmacyAddress:"",pharmacyPhone:u.pharmacyPhone,rating:4.5,hasReport:!0,reportStatus:"completed",totalAmount:u.totalAmount,deliveryAvailable:u.deliveryAvailable,deliveryFee:u.deliveryFee,responseTime:u.respondedAt,apiResponse:u})}catch{console.log(`No response found for order ${w}`)}return t}catch(r){return console.error("Error checking existing reports:",r),[]}},N=async()=>{console.log("ð Searching for nearby pharmacies for prescription:",s?.id);const r=await A();if(r.length>0){M(r),c(!0);return}b(),(await p()).success?o(!0):alert("ØØ¯Ø« خطأ Ø£Ø«ÙØ§Ø¡ Ø§ÙØ¨ØØ« Ø¹Ù Ø§ÙØµÙدÙÙØ§Øª. ÙØ±Ø¬Ù اÙÙ
ØØ§ÙÙØ© Ù
رة أخرÙ.")},C=async r=>{console.log("â
Opening report for pharmacy:",r),x(r);const t={pharmacyName:r.name,medications:s?.medications||[],totalAmount:0,deliveryAvailable:!0,deliveryFee:10};y(t),g(!0)},R=()=>{o(!1),P.length>0&&c(!0)},f=()=>{g(!1),y(null),x(null)},m=async r=>{console.log("ð Viewing report for pharmacy:",r.pharmacyName);try{if(r.apiResponse)y(r.apiResponse),x(r),g(!0);else{const t=await E.getPharmacyResponse(r.orderId);t?(y(t),x(r),g(!0)):alert("ÙØ§ ÙÙ
ÙÙ Ø¬ÙØ¨ ØªÙØ§ØµÙÙ Ø§ÙØªÙØ±ÙØ± Ù٠اÙÙÙØª Ø§ÙØØ§ÙÙ")}}catch(t){console.error("Error fetching pharmacy report:",t),alert("ØØ¯Ø« خطأ Ø£Ø«ÙØ§Ø¡ Ø¬ÙØ¨ ØªÙØ§ØµÙÙ Ø§ÙØªÙØ±ÙØ±")}},I=()=>{c(!1),o(!1),M([]),x(null),y(null),g(!1)};return h?e.jsxs("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4 animate-fadeIn",children:[e.jsxs("div",{className:"bg-white rounded-3xl shadow-2xl max-w-6xl w-full overflow-hidden animate-slideUp max-h-[90vh] overflow-y-auto",children:[e.jsxs("div",{className:"relative bg-gradient-to-br from-teal-500 via-teal-600 to-emerald-600 p-8",children:[e.jsx("button",{onClick:n,className:"absolute top-4 left-4 w-10 h-10 bg-white/20 hover:bg-white/30 rounded-full flex items-center justify-center transition-all duration-200 hover:rotate-90",children:e.jsx($,{className:"text-white text-lg"})}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-16 h-16 bg-white/20 backdrop-blur-sm rounded-2xl flex items-center justify-center flex-shrink-0",children:e.jsx(Y,{className:"text-4xl text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-3xl font-black text-white mb-1",children:"Ø·ÙØ¨ Ø±ÙØ´ØªØ©"}),e.jsxs("p",{className:"text-sm text-white/80 font-semibold",children:["رÙÙ
Ø§ÙØ±Ùشتة: ",s?.prescriptionNumber||"N/A"]})]})]})]}),F?e.jsxs("div",{className:"p-8 space-y-6",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h3",{className:"text-2xl font-black text-slate-800 mb-2",children:"Ø§ÙØªÙØ§Ø±ÙØ± اÙÙØ§Ø±Ø¯Ø©"}),e.jsxs("p",{className:"text-slate-600 font-semibold",children:["تÙ
Ø§Ø³ØªÙØ§Ù
",P.length," ØªÙØ±Ùر Ù
Ù Ø§ÙØµÙدÙÙØ§Øª"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:P.map(r=>e.jsxs("div",{className:"bg-white border-2 border-slate-200 rounded-2xl p-6 hover:border-teal-300 hover:shadow-lg transition-all duration-200",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-br from-teal-500 to-emerald-600 rounded-xl flex items-center justify-center flex-shrink-0",children:e.jsx(ae,{className:"text-white text-xl"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-black text-slate-800 text-lg mb-1",children:r.pharmacyName}),e.jsx("p",{className:"text-slate-500 text-sm",children:r.pharmacyAddress}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("div",{className:"flex items-center gap-1",children:[...Array(5)].map((t,w)=>e.jsx(O,{className:`text-xs ${w<Math.floor(r.rating)?"text-amber-400":"text-slate-300"}`},w))}),e.jsx("span",{className:"text-xs text-slate-600 font-semibold",children:r.rating})]})]})]}),e.jsxs("div",{className:"space-y-3 mb-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600 font-semibold",children:"إجÙ
اÙ٠اÙÙ
Ø¨ÙØº:"}),e.jsxs("span",{className:"font-black text-teal-600",children:[r.totalAmount," جÙ
26ÙÙ"]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600 font-semibold",children:"Ø§ÙØªÙصÙÙ:"}),e.jsx("span",{className:`font-semibold ${r.deliveryAvailable?"text-green-600":"text-red-600"}`,children:r.deliveryAvailable?`Ù
ØªØ§Ø (${r.deliveryFee} جÙÙÙ)`:"ØºÙØ± Ù
تاØ"})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-slate-600 font-semibold",children:"ÙÙØª Ø§ÙØ±Ø¯:"}),e.jsx("span",{className:"text-slate-500 text-sm",children:new Date(r.responseTime).toLocaleTimeString("ar-EG",{hour:"2-digit",minute:"2-digit"})})]})]}),e.jsxs("button",{onClick:()=>m(r),className:"w-full px-4 py-3 bg-gradient-to-r from-teal-500 to-emerald-600 hover:from-teal-600 hover:to-emerald-700 text-white font-bold rounded-xl transition-all shadow-sm hover:shadow-md flex items-center justify-center gap-2",children:[e.jsx(T,{className:"text-sm"}),e.jsx("span",{children:"عرض Ø§ÙØªÙØ±ÙØ±"})]})]},r.pharmacyId))}),e.jsxs("div",{className:"flex items-center gap-3 pt-4",children:[e.jsxs("button",{onClick:I,className:"flex-1 px-6 py-4 bg-gradient-to-r from-emerald-500 to-teal-600 hover:from-emerald-600 hover:to-teal-700 text-white font-black rounded-xl transition-all shadow-lg hover:shadow-xl flex items-center justify-center gap-3",children:[e.jsx(le,{className:"text-xl"}),e.jsx("span",{children:"Ø·ÙØ¨ Ø¬Ø¯ÙØ¯"})]}),e.jsx("button",{onClick:n,className:"px-6 py-4 bg-white hover:bg-slate-100 text-slate-700 font-bold rounded-xl border-2 border-slate-200 transition-all",children:"Ø¥ØºÙØ§Ù"})]})]}):i?e.jsx(Ne,{pharmacies:k,loading:a,onClose:R,onSelectPharmacy:C,prescription:s}):e.jsxs("div",{className:"p-8 space-y-6",children:[e.jsx("div",{className:"bg-gradient-to-br from-teal-50 to-emerald-50 rounded-2xl p-6 border-2 border-teal-200",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-br from-teal-500 to-emerald-600 rounded-xl flex items-center justify-center flex-shrink-0",children:e.jsx(D,{className:"text-white text-xl"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-black text-slate-800 mb-2",children:"ÙÙÙ ÙØ¹Ù
٠اÙÙØ¸Ø§Ù
Ø"}),e.jsxs("p",{className:"text-slate-600 leading-relaxed font-semibold",children:["سÙÙÙÙ
اÙÙØ¸Ø§Ù
Ø¨Ø§ÙØ¨ØØ« ع٠",e.jsx("span",{className:"text-teal-600 font-black",children:"Ø£ÙØ±Ø¨ 3 ØµÙØ¯ÙÙØ§Øª"})," Ù
Ù Ù
ÙÙØ¹Ù Ø§ÙØØ§ÙÙ ÙØ¥Ø±Ø³Ø§Ù Ø§ÙØ±Ùشتة ÙÙÙ
ÙÙØªØ£Ùد Ù
٠تÙÙØ± جÙ
ÙØ¹ Ø§ÙØ£Ø¯ÙÙØ©. ستتÙÙÙ Ø±Ø¯ÙØ¯ÙÙ
Ù
ع Ø§ÙØ£Ø³Ø¹Ø§Ø± ÙØ§Ùبدائ٠اÙÙ
ØªØ§ØØ© ÙØªØ®ØªØ§Ø± Ø§ÙØ£Ùسب ÙÙ."]})]})]})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-teal-100 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(O,{className:"text-teal-600"})}),e.jsx("p",{className:"text-slate-700 font-semibold",children:"Ù
ÙØ§Ø±ÙØ© Ø§ÙØ£Ø³Ø¹Ø§Ø± بÙÙ Ø§ÙØµÙدÙÙØ§Øª"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-teal-100 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(O,{className:"text-teal-600"})}),e.jsx("p",{className:"text-slate-700 font-semibold",children:"Ù
Ø¹Ø±ÙØ© Ø§ÙØ¨Ø¯Ø§Ø¦Ù اÙÙ
ØªØ§ØØ© ÙÙØ£Ø¯ÙÙØ©"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-teal-100 rounded-lg flex items-center justify-center flex-shrink-0",children:e.jsx(O,{className:"text-teal-600"})}),e.jsx("p",{className:"text-slate-700 font-semibold",children:"ØªÙØµÙÙ Ø³Ø±ÙØ¹ ÙØ¨Ø§Ø¨ اÙÙ
ÙØ²Ù"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-4",children:[e.jsx("button",{onClick:N,disabled:a,className:"flex-1 px-6 py-4 bg-gradient-to-r from-teal-500 to-emerald-600 hover:from-teal-600 hover:to-emerald-700 text-white font-black rounded-xl transition-all shadow-lg hover:shadow-xl disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-3",children:a?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-5 h-5 border-3 border-white border-t-transparent roun
26ded-full animate-spin"}),e.jsx("span",{children:"Ø¬Ø§Ø±Ù Ø§ÙØ¨ØØ«..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"text-xl"}),e.jsx("span",{children:"Ø§Ø¨ØØ« Ø§ÙØ¢Ù"})]})}),e.jsx("button",{onClick:n,className:"px-6 py-4 bg-white hover:bg-slate-100 text-slate-700 font-bold rounded-xl border-2 border-slate-200 transition-all",children:"Ø¥ÙØºØ§Ø¡"})]})]})]}),e.jsx("style",{jsx:!0,children:` 27 @keyframes fadeIn { 28 from { opacity: 0; } 29 to { opacity: 1; } 30 } 31 @keyframes slideUp { 32 from { transform: translateY(20px); opacity: 0; } 33 to { transform: translateY(0); opacity: 1; } 34 } 35 .animate-fadeIn { 36 animation: fadeIn 0.2s ease-out; 37 } 38 .animate-slideUp { 39 animation: slideUp 0.3s ease-out; 40 } 41 `}),e.jsx(ye,{isOpen:j,onClose:f,pharmacy:l,report:v})]}):null},Pe=({isOpen:h,onClose:n,orderData:s,onPaymentConfirm:i})=>{const[o,l]=d.useState(""),[x,j]=d.useState(!1),[g,v]=d.useState(null),y=[{id:"card",name:"Ø¨Ø·Ø§ÙØ© ائت٠اÙ",icon:e.jsx(ie,{className:"text-3xl"}),description:"Visa ⢠Mastercard ⢠Amex",bgGradient:"from-blue-50 to-indigo-50",borderColor:"border-blue-300",iconBg:"bg-blue-500"},{id:"vodafone",name:"ÙÙØ¯Ø§ÙÙÙ ÙØ§Ø´",icon:e.jsx(ce,{className:"text-3xl"}),description:"Ø§Ø¯ÙØ¹ Ù Ù Ù ØÙØ¸ØªÙ Ø§ÙØ¥ÙÙØªØ±ÙÙÙØ©",bgGradient:"from-red-50 to-orange-50",borderColor:"border-red-300",iconBg:"bg-red-500"},{id:"cash",name:"ÙØ§Ø´ Ø¹ÙØ¯ Ø§ÙØ§Ø³ØªÙا٠",icon:e.jsx(L,{className:"text-3xl"}),description:"Ø§Ø¯ÙØ¹ ÙÙØ¯Ø§Ù Ø¹ÙØ¯ Ø§Ø³ØªÙØ§Ù Ø§ÙØ·Ùب",bgGradient:"from-green-50 to-emerald-50",borderColor:"border-green-300",iconBg:"bg-green-500"}],F=async()=>{if(!o){v("ÙØ±Ø¬Ù Ø§Ø®ØªÙØ§Ø± طرÙÙØ© Ø§ÙØ¯Ùع");return}j(!0),v(null);try{const c=s?.orderId;if(!c){v("ÙØ§ ÙÙ Ù٠تأÙÙØ¯ Ø§ÙØ·Ùب: رÙÙ Ø§ÙØ·Ùب ØºÙØ± Ù ÙØ¬Ùد"),j(!1);return}if(o==="cash"){console.log("ðµ Cash on delivery selected for order:",c);const p=await E.confirmPharmacyOrder(c,{method:"cash",orderData:s});console.log("â Order confirmed for cash:",p),i({method:"cash",status:"confirmed"});return}const P=1,M=o==="vodafone"?1:0;console.log("ð³ Initiating Paymob payment for pharmacy order:",c);const k=await pe.initiatePharmacyOrderPayment(c,P,M);console.log("ð³ API Response:",JSON.stringify(k,null,2));const a=k?.data;if(a?.paymentUrl){console.log("ð Redirecting to Paymob:",a.paymentUrl),window.location.href=a.paymentUrl;return}console.error("â No paymentUrl in response:",k),v(k?.message||a?.message||"ÙÙ ÙØªÙ Ù٠٠٠تÙÙÙØ¯ رابط Ø§ÙØ¯Ùع. ÙØ±Ø¬Ù اÙÙ ØØ§ÙÙØ© ٠رة أخرÙ."),j(!1)}catch(c){console.error("â Payment failed:",c);const P=c?.response?.data?.message;v(P||"ØØ¯Ø« خطأ Ù٠ع٠ÙÙØ© Ø§ÙØ¯Ùع. ÙØ±Ø¬Ù اÙÙ ØØ§ÙÙØ© ٠رة أخرÙ."),j(!1)}};return h?e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",dir:"rtl",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl w-full max-w-2xl max-h-[90vh] overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-teal-500 to-emerald-600 p-6 relative",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-black text-white mb-2",children:"اختر طرÙÙØ© Ø§ÙØ¯Ùع"}),e.jsxs("p",{className:"text-teal-100 font-medium",children:["إج٠اÙ٠اÙÙ Ø¨ÙØº: ",s?.totalAmount||0," ج.Ù ",s?.deliveryFee&&` + ${s.deliveryFee} ج.٠رسÙÙ ØªÙØµÙÙ`]})]}),e.jsx("button",{onClick:n,className:"w-10 h-10 bg-white/20 hover:bg-white/30 rounded-xl flex items-center justify-center transition-colors",children:e.jsx($,{className:"w-5 h-5 text-white"})})]})}),e.jsxs("div",{className:"p-6 max-h-[calc(90vh-200px)] overflow-y-auto",children:[g&&e.jsxs("div",{className:"mb-4 p-4 bg-red-50 border border-red-200 rounded-xl flex items-start gap-3",children:[e.jsx(B,{className:"text-red-500 mt-1 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-red-800 mb
41-1",children:"ØØ¯Ø« خطأ"}),e.jsx("p",{className:"text-xs text-red-700",children:g})]})]}),e.jsxs("div",{className:"space-y-4 mb-6",children:[e.jsx("h3",{className:"text-lg font-bold text-slate-800 mb-4",children:"Ø·Ø±Ù Ø§ÙØ¯Ùع اÙÙ
ØªØ§ØØ©"}),y.map(c=>e.jsx("div",{onClick:()=>{l(c.id),v(null)},className:`p-4 rounded-xl border-2 cursor-pointer transition-all ${o===c.id?`${c.borderColor} bg-gradient-to-r ${c.bgGradient}`:"border-slate-200 hover:border-slate-300"}`,children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`w-12 h-12 ${c.iconBg} rounded-xl flex items-center justify-center text-white`,children:c.icon}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-bold text-slate-800",children:c.name}),e.jsx("p",{className:"text-sm text-slate-600",children:c.description})]}),e.jsx("div",{className:`w-6 h-6 rounded-full border-2 ${o===c.id?"bg-teal-500 border-teal-500":"border-slate-300"}`,children:o===c.id&&e.jsx("div",{className:"w-full h-full rounded-full bg-white scale-50"})})]})},c.id))]}),(o==="card"||o==="vodafone")&&e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-5 mb-6 text-center",children:[e.jsx("div",{className:"bg-blue-100 w-14 h-14 mx-auto flex items-center justify-center rounded-full mb-3",children:e.jsx(ne,{className:"text-2xl text-blue-600"})}),e.jsx("h4",{className:"font-bold text-slate-800 mb-2",children:"Ø§ÙØ¯Ùع Ø§ÙØ¢Ù
٠باستخداÙ
Paymob"}),e.jsx("p",{className:"text-sm text-slate-600",children:"Ø³ÙØªÙ
ØªÙØ¬ÙÙ٠إÙÙ Ø¨ÙØ§Ø¨Ø© Ø§ÙØ¯Ùع Ø§ÙØ¢Ù
ÙØ© ÙØ¥ØªÙ
اÙ
Ø§ÙØ¹Ù
ÙÙØ©. جÙ
ÙØ¹ اÙÙ
عاÙ
ÙØ§Øª Ù
Ø´ÙØ±Ø© ÙØ¢Ù
ÙØ© 100%."})]}),o==="cash"&&e.jsx("div",{className:"bg-green-50 rounded-xl p-5 mb-6",children:e.jsxs("div",{className:"flex items-center gap-3 text-green-700",children:[e.jsx(L,{className:"text-2xl"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:"Ø³ÙØªÙ
Ø§ÙØ¯Ùع ÙÙØ¯Ø§Ù Ø¹ÙØ¯ Ø§Ø³ØªÙØ§Ù
Ø§ÙØ·Ùب"}),e.jsx("p",{className:"text-sm",children:"ØªØ£ÙØ¯ Ù
٠تÙÙØ± اÙÙ
Ø¨ÙØº اÙÙ
Ø·ÙÙØ¨ Ø¹ÙØ¯ Ø§ÙØªØ³ÙÙÙ
"})]})]})})]}),e.jsxs("div",{className:"bg-slate-50 px-6 py-4 flex items-center justify-between",children:[e.jsx("button",{onClick:n,className:"px-6 py-3 bg-slate-500 text-white rounded-xl hover:bg-slate-600 transition-colors font-bold",children:"Ø¥ÙØºØ§Ø¡"}),e.jsx("button",{onClick:F,disabled:!o||x,className:`px-8 py-3 rounded-xl font-bold flex items-center gap-2 transition-all ${!o||x?"bg-slate-300 text-slate-500 cursor-not-allowed":"bg-gradient-to-r from-teal-500 to-emerald-600 text-white hover:from-teal-600 hover:to-emerald-700"}`,children:x?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-5 h-5 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Ø¬Ø§Ø±Ù Ø§ÙØªØÙÙÙ..."]}):e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"w-5 h-5"}),o==="cash"?"تأÙÙØ¯ Ø§ÙØ·Ùب":"تأÙÙØ¯ ÙØ§ÙØ°ÙØ§Ø¨ ÙÙØ¯Ùع"]})})]})]})}):null},ke=({isOpen:h,onClose:n,prescription:s,onNewOrder:i})=>{const[o,l]=d.useState([]),[x,j]=d.useState(null),[g,v]=d.useState(!1),[y,F]=d.useState(null),[c,P]=d.useState(null),[M,k]=d.useState(!1),[a,p]=d.useState(!1),[b,A]=d.useState(null);d.useEffect(()=>{const f=async()=>{v(!0),F(null);try{console.log("ð Fetching pharmacy reports for prescription:",s.id),console.log("ð Full prescription object:",s);const m=await E.getPharmacyReports(s.id);if(console.log("â
Raw API response:",m),console.log("â
Response structure check:",{hasData:!!m,hasPrescriptionId:!!m?.prescriptionId,hasPharmacyResponses:!!m?.pharmacyResponses,pharmacyResponsesLength:m?.pharmacyResponses?.length||0,responseKeys:m?Object.keys(m):[]}),m&&m.prescriptionId){console.log("â
Valid prescription pharmacy response found"),console.log("ð Raw pharmacyResponses:",m.pharmacyResponses),m.pharmacyResponses&&m.pharmacyResponses.length>0&&(console.log("ð First pharmacy response structure:",m.pharmacyResponses[0]),console.log("ð Available medications in first response:",m.pharmacyResponses[0]?.availableMedications),console.log("ð Alternative medications in first response:",m.pharmacyResponses[0]?.alternativeMedications));const I=m.pharmacyResponses?.map((r,t)=>{console.log(`ð Processing pharmacy response ${t+1}:`,r),console.log("ð Medications array:",r.medications);let w=[],u=[],U=[];return r.medications&&Array.isArray(r.medications)&&r.medications.forEach(S=>{console.log("ð Processing medication:",S),S.isAvailable&&S.availableQuantity>0?w.push({medicationName:S.medicationName,quantity:S.availableQuantity,unitPrice:S.unitPrice,isAvailable:!0}):!S.isAvailable&&S.alternativeOne?u.push({medicationName:S.alternativeOne.medicationName,unitPrice:S.alternativeOne.unitPrice,originalMedication:S.medicationName,quantity:1}):!S.isAvailable&&!S.alternativeOne&&U.push({medicationName:S.medicationName,isAvailable:!1})}
41),console.log(`ð Final medication counts for pharmacy ${t+1}:`,{available:w.length,alternative:u.length,unavailable:U.length}),{orderId:r.orderId,pharmacyId:r.pharmacyId,pharmacyName:r.pharmacyName,pharmacyPhone:r.pharmacyPhone,pharmacyAddress:r.pharmacyAddress,totalAmount:r.totalAmount,deliveryFee:r.deliveryFee,availableMedications:w,alternativeMedications:u,unavailableMedications:U,pharmacyNotes:r.pharmacyNotes,sentAt:r.sentAt,respondedAt:r.respondedAt,status:r.status||"responded"}})||[];console.log("ð Converted reports array:",I),console.log("ð First report medications check:",{available:I[0]?.availableMedications?.length||0,alternative:I[0]?.alternativeMedications?.length||0,unavailable:I[0]?.unavailableMedications?.length||0}),l(I),j({prescriptionId:m.prescriptionId,prescriptionNumber:m.prescriptionNumber,totalPharmacyResponses:m.totalPharmacyResponses})}else console.log("â ï¸ No valid pharmacy response data found"),F("ÙØ§ ØªÙØ¬Ø¯ ØªÙØ§Ø±Ùر Ù
ØªØ§ØØ© ÙÙØ°Ù Ø§ÙØ±Ùشتة")}catch(m){console.error("â Error fetching pharmacy reports:",m),F("ØØ¯Ø« خطأ Ù٠تØÙ
ÙÙ ØªÙØ§Ø±Ùر Ø§ÙØµÙدÙÙØ§Øª")}finally{v(!1)}};h&&s?.id&&f()},[h,s?.id]);const N=f=>{console.log("ð Viewing detailed report for pharmacy:",f.pharmacyName),P(f),k(!0)},C=f=>{console.log("ð Opening payment modal for pharmacy:",f.pharmacyName),A(f),p(!0)},R=async f=>{try{console.log("ð³ Payment confirmed:",f),p(!1),A(null),alert(`تÙ
تأÙÙØ¯ Ø§ÙØ·Ùب Ù
Ù ${b.pharmacyName} Ø¨ÙØ¬Ø§Ø! Ø³ÙØªÙ
Ø§ÙØªÙاص٠Ù
Ø¹Ù ÙØ±ÙباÙ.`),n()}catch(m){console.error("â Order confirmation failed:",m),alert("ØØ¯Ø« خطأ Ù٠تأÙÙØ¯ Ø§ÙØ·Ùب. ÙØ±Ø¬Ù اÙÙ
ØØ§ÙÙØ© Ù
رة أخرÙ.")}};return h?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",dir:"rtl",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl w-full max-w-4xl max-h-[90vh] overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-teal-500 to-emerald-600 p-6 text-white",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 rounded-xl flex items-center justify-center",children:e.jsx(T,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-black",children:"ØªÙØ§Ø±Ùر Ø§ÙØµÙدÙÙØ§Øª"}),e.jsxs("p",{className:"text-teal-100 font-medium",children:["Ø±ÙØ´ØªØ© رÙÙ
: ",x?.prescriptionNumber||s?.prescriptionNumber||"ØºÙØ± Ù
ØØ¯Ø¯"]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>{n(),i?i(s):window.location.href="/patient/prescriptions"},className:"px-4 py-2 bg-white/20 hover:bg-white/30 rounded-xl flex items-center gap-2 transition-colors font-bold text-sm",children:[e.jsx(V,{className:"w-4 h-4"}),e.jsx("span",{children:"Ø·ÙØ¨ Ø¬Ø¯ÙØ¯"})]}),e.jsx("button",{onClick:n,className:"w-10 h-10 bg-white/20 hover:bg-white/30 rounded-xl flex items-center justify-center transition-colors",children:e.jsx($,{className:"w-5 h-5"})})]})]})}),e.jsx("div",{className:"p-6 max-h-[calc(90vh-200px)] overflow-y-auto",children:g?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 border-4 border-teal-200 border-t-teal-600 rounded-full animate-spin mx-auto mb-4"}),e.jsx("p",{className:"text-slate-600 font-medium",children:"جار٠تØÙ
ÙÙ Ø§ÙØªÙØ§Ø±ÙØ±..."})]})}):y?e.jsxs("div",{className:"text-center py-20",children:[e.jsx("div",{className:"w-24 h-24 bg-red-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(B,{className:"text-red-500 text-4xl"})}),e.jsx("h3",{className:"text-xl font-bold text-slate-800 mb-2",children:"ØØ¯Ø« خطأ"}),e.jsx("p",{className:"text-slate-600 font-medium mb-4",children:y}),e.jsx("button",{onClick:()=>window.location.reload(),className:"px-6 py-2.5 bg-gradient-to-r from-teal-500 to-emerald-600 text-white rounded-xl hover:from-teal-600 hover:to-emerald-700 transition-all font-bold text-sm shadow-lg",children:"إعادة اÙÙ
ØØ§ÙÙØ©"})]}):o.length===0?e.jsxs("div",{className:"text-center py-20",children:[e.jsx("div",{className:"w-24 h-24 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(T,{className:"text-slate-400 text-4xl"})}),e.jsx("h3",{className:"text-xl font-bold text-slate-800 mb-2",children:"ÙØ§ ØªÙØ¬Ø¯ ØªÙØ§Ø±Ùر"}),e.jsx("p",{className:"text-slate-600 font-medium",children:"ÙÙ
ترد Ø£Ù ØµÙØ¯ÙÙØ© عÙÙ ÙØ°Ù Ø§ÙØ±Ùشتة بعد"})]}):e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:o.map((f,m)=>e.jsxs("div",{className:"bg-white rounded-2xl border-2 border-slate-200 hover:border-teal-400 transition-all shadow-sm hover:shadow-lg p-6",children:[e.jsx("div",{className:"flex items-center justify-between mb-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-12 h-12 bg-gradient-to-br from-emerald-500 to-teal-600 rounded-xl flex items-center justify-center text-white font-black text-lg",children:m+1}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-black text-slate-800",children:f.pharmacyName}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-slate-600",children:[e.jsx(D,{className:"text-teal-500"}),e.jsx("span",{children:f.pharmacyAddress})]})]})]})}),e.jsx("div",{className:"bg-gradient-to-r from-slate-50 to-slate-100/50 rounded-xl p-4 mb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-slate-600",children:"إجÙ
اÙÙ Ø§ÙØ³Ø¹Ø±"}),e.jsxs("p",{className:"text-2xl font-black text-slate-800",children:[f.totalAmount," ج.Ù
"]})]}),f.deliveryFee>0&&e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-600",children:"رسÙÙ
Ø§ÙØªÙصÙÙ"}),e.jsxs("p",{className:"text-lg font-bold text-emerald-600",children:[f.deliveryFee," ج.Ù
"]})]})]})}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-slate-600",children:"Ø§ÙØ£Ø¯ÙÙØ© اÙÙ
تÙÙØ±Ø©:"}),e.jsx("span",{className:"font-bold text-green-600",children:f.availableMedications?.length||0})]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-slate-600",children:"Ø§ÙØ¨Ø¯Ø§Ø¦Ù اÙÙ
ÙØªØ±ØØ©:"}),e.jsx("span",{className:"font-bold text-blue-600",children:f.alternativeMedications?.length||0})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>N(f),className:"flex-1 px-4 py-2.5 bg-gradient-to-r from-slate-500 to-slate-600 text-white rounded-xl hover:from-slate-600 hover:to-slate-700 transition-all font-bold text-sm shadow-md hover:shadow-lg flex items-center justify-center gap-2",children:[e.jsx(_,{className:"w-4 h-4"}),"عرض Ø§ÙØªÙاصÙÙ"]}),e.jsxs("button",{onClick:()=>C(f),className:"flex-1 px-4 py-2.5 bg-gradient-to-r from-teal-500 to-emerald-600 text-white rounded-xl hover:from-teal-600 hover:to-emerald-700 transition-all font-bold text-sm shadow-md hover:shadow-lg flex items-center justify-center gap-2",children:[e.jsx(V,{className:"w-4 h-4"}),"Ø§Ø·ÙØ¨ Ø§ÙØ¢Ù"]})]})]},f.orderId||m))})})]})}),M&&c&&e.jsx(Ce,{isOpen:M,onClose:()=>k(!1),report:c,onOrderNow:()=>{k(!1),C(c)}}),e.jsx(Pe,{isOpen:a,onClose:()=>p(!1),orderData:b,onPaymentConfirm:R})]}):null},Ce=({isOpen:h,onClose:n,report:s,onOrderNow:i})=>{if(!h||!s)return null;const o=l=>new Date(l).toLocaleDateString("ar-EG",{day:"numeric",month:"long",year:"numeric",hour:"2-digit",minute:"2-digit"});return e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",dir:"rtl",children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl w-full max-w-4xl max-h-[90vh] overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-emerald-500 to-teal-600 p-6 text-white",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 bg-white/20 rounded-xl flex items-center justify-center",children:e.jsx(T,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-black",children:s.pharmacyName}),e.jsx("p",{className:"text-emerald-100 font-medium",children:"ØªÙØ§ØµÙÙ Ø§ÙØ¹Ø±Ø¶ ÙØ§ÙأدÙÙØ©"})]})]}),e.jsx("button",{onClick:n,className:"w-10 h-10 bg-white/20 hover:bg-white/30 rounded-xl flex items-center justify-center transition-colors",children:e.jsx($,{className:"w-5 h-5"})})]})}
41),e.jsxs("div",{className:"p-6 max-h-[calc(90vh-200px)] overflow-y-auto",children:[e.jsxs("div",{className:"bg-slate-50 rounded-xl p-4 mb-6",children:[e.jsx("h3",{className:"text-lg font-black text-slate-800 mb-3",children:"Ù
عÙÙÙ
ات Ø§ÙØµÙدÙÙØ©"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{className:"text-teal-500"}),e.jsx("span",{className:"text-sm font-semibold text-slate-700",children:s.pharmacyAddress})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"text-teal-500"}),e.jsx("span",{className:"text-sm font-semibold text-slate-700",children:s.pharmacyPhone})]})]})]}),e.jsxs("div",{className:"bg-gradient-to-r from-emerald-50 to-teal-50 rounded-xl p-4 mb-6",children:[e.jsx("h3",{className:"text-lg font-black text-slate-800 mb-3",children:"ØªÙØ§ØµÙÙ Ø§ÙØ³Ø¹Ø±"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-slate-600",children:"إجÙ
اÙÙ Ø§ÙØ£Ø¯ÙÙØ©"}),e.jsxs("p",{className:"text-2xl font-black text-slate-800",children:[s.totalAmount," ج.Ù
"]})]}),s.deliveryFee>0&&e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-600",children:"رسÙÙ
Ø§ÙØªÙصÙÙ"}),e.jsxs("p",{className:"text-xl font-bold text-emerald-600",children:[s.deliveryFee," ج.Ù
"]})]}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-600",children:"اÙÙ
جÙ
ÙØ¹ اÙÙÙÙ"}),e.jsxs("p",{className:"text-2xl font-black text-emerald-600",children:[s.totalAmount+(s.deliveryFee||0)," ج.Ù
"]})]})]})]}),s.availableMedications&&s.availableMedications.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("h3",{className:"text-lg font-black text-slate-800 mb-4 flex items-center gap-2",children:[e.jsx(O,{className:"text-green-500"}),"Ø§ÙØ£Ø¯ÙÙØ© اÙÙ
تÙÙØ±Ø© (",s.availableMedications.length,")"]}),e.jsx("div",{className:"space-y-3",children:s.availableMedications.map((l,x)=>e.jsx("div",{className:"bg-green-50 rounded-xl p-4 border border-green-200",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-slate-800",children:l.medicationName}),e.jsx("p",{className:"text-sm text-green-600 font-semibold",children:"Ù
تÙÙØ±"})]}),e.jsxs("div",{className:"text-left",children:[e.jsxs("p",{className:"text-lg font-black text-green-600",children:[l.unitPrice," ج.Ù
"]}),e.jsxs("p",{className:"text-sm text-slate-600",children:["اÙÙÙ
ÙØ©: ",l.quantity]})]})]})},x))})]}),s.alternativeMedications&&s.alternativeMedications.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("h3",{className:"text-lg font-black text-slate-800 mb-4 flex items-center gap-2",children:[e.jsx(B,{className:"text-amber-500"}),"Ø§ÙØ¨Ø¯Ø§Ø¦Ù اÙÙ
ÙØªØ±ØØ© (",s.alternativeMedications.length,")"]}),e.jsx("div",{className:"space-y-3",children:s.alternativeMedications.map((l,x)=>e.jsxs("div",{className:"bg-amber-50 rounded-xl p-4 border-2 border-amber-300",children:[e.jsx("div",{className:"mb-3 pb-3 border-b border-amber-200",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(z,{className:"text-red-500 text-sm"}),e.jsx("span",{className:"text-sm text-slate-600 font-semibold",children:"ØºÙØ± Ù
تÙÙØ±:"}),e.jsx("span",{className:"text-sm text-slate-800 font-bold",children:l.originalMedication})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(O,{className:"text-amber-500 text-sm"}),e.jsx("span",{className:"text-xs text-amber-700 font-semibold",children:"Ø§ÙØ¨Ø¯Ù٠اÙÙ
ÙØªØ±Ø:"})]}),e.jsx("h4",{className:"font-black text-slate-800 text-lg",children:l.medicationName})]}),e.jsxs("div",{className:"text-left",children:[e.jsxs("p",{className:"text-lg font-black text-amber-600",children:[l.unitPrice," ج.Ù
"]}),e.jsxs("p",{className:"text-sm text-slate-600",children:["اÙÙÙ
ÙØ©: ",l.quantity]})]})]})]},x))})]}),s.unavailableMedications&&s.unavailableMedications.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("h3",{className:"text-lg font-black text-slate-800 mb-4 flex items-center gap-2",children:[e.jsx(z,{className:"text-red-500"}),"Ø§ÙØ£Ø¯ÙÙØ© ØºÙØ± اÙÙ
تÙÙØ±Ø© (",s.unavailableMedications.length,")"]}),e.jsx("div",{className:"space-y-3",children:s.unavailableMedications.map((l,x)=>e.jsx("div",{className:"bg-red-50 rounded-xl p-4 border border-red-200",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-bold text-slate-800",children:l.medicationName}),e.jsx("p",{className:"text-sm text-red-600 font-semibold",children:"ØºÙØ± Ù
تÙÙØ± ÙÙØ§ ÙÙØ¬Ø¯ بدÙÙ"})]}),e.jsx("div",{className:"text-left",children:e.jsx("span",{className:"text-sm font-bold text-red-600 bg-red-100 px-3 py-1.5 rounded-full",children:"ØºÙØ± Ù
تÙÙØ±"})})]})},x))})]}),s.pharmacyNotes&&e.jsxs("div",{className:"bg-yellow-50 rounded-xl p-4 mb-6",children:[e.jsx("h3",{className:"text-lg font-black text-slate-800 mb-2",children:"Ù
ÙØ§ØØ¸Ø§Øª Ø§ÙØµÙدÙÙØ©"}),e.jsx("p",{className:"text-slate-700",children:s.pharmacyNotes})]}),e.jsx("div",{className:"bg-slate-50 rounded-xl p-4 text-sm text-slate-600",children:e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:"ØªØ§Ø±ÙØ® Ø§ÙØ±Ø¯: "}),o(s.respondedAt)]})})})]}),e.jsx("div",{className:"bg-slate-50 p-6 border-t",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("button",{onClick:n,className:"px-6 py-3 bg-slate-500 text-white rounded-xl hover:bg-slate-600 transition-colors font-bold",children:"Ø¥ØºÙØ§Ù"}),e.jsxs("button",{onClick:()=>i(s),className:"px-8 py-3 bg-gradient-to-r from-teal-500 to-emerald-600 text-white rounded-xl hover:from-teal-600 hover:to-emerald-700 transition-all font-bold flex items-center gap-2",children:[e.jsx(V,{className:"w-5 h-5"}),"تأÙÙØ¯ Ø§ÙØ·Ùب Ø§ÙØ¢Ù"]})]})})]})})},Oe=()=>{const{user:h}
41=de(),[n,s]=d.useState([]),[i,o]=d.useState(!0),[l,x]=d.useState(null),[j,g]=d.useState(null),[v,y]=d.useState(!1),[F,c]=d.useState(!1),[P,M]=d.useState(null),[k,a]=d.useState(!1),[p,b]=d.useState(null),A=async()=>{o(!0),x(null);try{console.log("ð Fetching prescriptions for patient:",h?.id);const t=await E.getMyPrescriptions();console.log("â
Prescriptions response:",t);const w=t.map(u=>({...u,consultationType:u.appointmentType==="regular"?"ÙØ´Ù Ø¬Ø¯ÙØ¯":"إعادة ÙØ´Ù",patientId:h?.id}));console.log("ð Prescription statuses:",w.map(u=>({id:u.id,prescriptionNumber:u.prescriptionNumber,status:u.status,statusName:u.statusName,statusText:I(u.status),hasReports:u.status===5}))),s(w),o(!1)}catch(t){console.error("â Error fetching prescriptions:",t),x("ØØ¯Ø« خطأ Ù٠تØÙ
ÙÙ Ø§ÙØ±Ùشتات"),o(!1)}};d.useEffect(()=>{h?.id&&A()},[h?.id]);const N=t=>{console.log("ðï¸ Viewing prescription:",t),g(t),y(!0)},C=t=>{console.log("ð Ordering prescription:",t),M(t),c(!0)},R=t=>{console.log("ð Viewing reports for prescription:",t),b(t),a(!0)},f=t=>(console.log("ð Checking prescription status:",{id:t.id,status:t.status,statusName:t.statusName,hasReports:t.status===5}),t.status===5),m=t=>{if(!t)return"ØºÙØ± Ù
ØØ¯Ø¯";try{return je(t)}catch{return t}},I=t=>({1:"ÙØ´Ø·Ø©",2:"Ù
ÙØºÙØ©",3:"تÙ
صرÙÙØ§",4:"Ù
ÙØªÙÙØ© Ø§ÙØµÙاØÙØ©",5:"تÙ
Ø§ÙØ±Ø¯ عÙÙÙØ§"})[t]||"ØºÙØ± Ù
ØØ¯Ø¯",r=t=>({1:"text-blue-600 bg-blue-50",2:"text-red-600 bg-red-50",3:"text-green-600 bg-green-50",4:"text-gray-600 bg-gray-50",5:"text-emerald-600 bg-emerald-50"})[t]||"text-gray-600 bg-gray-50";return e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-teal-50/30 to-emerald-50/30",dir:"rtl",children:[e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[e.jsxs("div",{className:"bg-gradient-to-r from-teal-500 to-emerald-600 rounded-2xl p-8 mb-8 relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 opacity-10",children:e.jsx("div",{className:"absolute inset-0",style:{backgroundImage:`url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")`}})}),e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-white/10 rounded-full -mr-32 -mt-32"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-48 h-48 bg-emerald-400/20 rounded-full -ml-24 -mb-24"}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx("div",{className:"w-16 h-16 bg-white/20 backdrop-blur-sm rounded-2xl flex items-center justify-center shadow-lg",children:e.jsx(q,{className:"text-white text-3xl"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-4xl font-black text-white mb-2",children:"Ø§ÙØ±Ùشتات Ø§ÙØ·Ø¨ÙØ©"}),e.jsx("p",{className:"text-white/90 text-lg font-medium",children:"جÙ
ÙØ¹ Ø§ÙØ±Ùشتات Ø§ÙØ®Ø§ØµØ© ب٠Ù
Ù ÙÙ Ø§ÙØ£Ø·Ø¨Ø§Ø¡"})]})]}),!i&&!l&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mt-6",children:[e.jsx("div",{className:"bg-white/20 backdrop-blur-sm rounded-xl p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-white/30 rounded-lg flex items-center justify-center",children:e.jsx(q,{className:"text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-white/80",children:"إجÙ
اÙÙ Ø§ÙØ±Ùشتات"}),e.jsx("p",{className:"text-2xl font-black text-white",children:n.length})]})]})}),e.jsx("div",{className:"bg-white/20 backdrop-blur-sm rounded-xl p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-white/30 rounded-lg flex items-center justify-center",children:e.jsx(G,{className:"text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-white/80",children:"عدد Ø§ÙØ£Ø·Ø¨Ø§Ø¡"}),e.jsx("p",{className:"text-2xl font-black text-white",children:new Set(n.map(t=>t.doctorId)).size})]})]})}),e.jsx("div",{className:"bg-white/20 backdrop-blur-sm rounded-xl p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-white/30 rounded-lg flex items-center justify-center",children:e.jsx(K,{className:"text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-white/80",children:"آخر Ø±ÙØ´ØªØ©"}),e.jsx("p",{className:"text-sm font-bold text-white",children:n.length>0?m(n[0].createdAt):"-"})]})]})})]})]})]}),e.jsx("div",{className:"bg-white rounded-2xl shadow-lg p-6",children:i?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 border-4 border-teal-200 border-t-teal-600 rounded-full animate-spin mx-auto mb-4"}),e.jsx("p",{className:"text-slate-600 font-medium",children:"جار٠تØÙ
ÙÙ Ø§ÙØ±Ùشتات..."})]})}):l?e.jsxs("div",{className:"text-center py-20",children:[e.jsx("div",{className:"w-24 h-24 bg-red-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(xe,{className:"text-red-500 text-4xl"})}),e.jsx("h3",{className:"text-xl font-bold text-slate-800 mb-2",children:"ØØ¯Ø« خطأ"}),e.jsx("p",{className:"text-slate-600 font-medium mb-4",children:l}),e.jsx("button",{onClick:A,className:"px-6 py-2.5 bg-gradient-to-r from-teal-500 to-emerald-600 text-white rounded-xl hover:from-teal-600 hover:to-emerald-700 transition-all font-bold text-sm shadow-lg",children:"إعادة اÙÙ
ØØ§ÙÙØ©"})]}):n.length===0?e.jsxs("div",{className:"text-center py-20",children:[e.jsx("div",{className:"w-24 h-24 bg-slate-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(T,{className:"text-slate-400 text-4xl"})}),e.jsx("h3",{className:"text-xl font-bold text-slate-800 mb-2",children:"ÙØ§ ØªÙØ¬Ø¯ Ø±ÙØ´ØªØ§Øª"}),e.jsx("p",{className:"text-slate-600 font-medium",children:"ÙÙ
ÙØªÙ
Ø¥ÙØ´Ø§Ø¡ Ø£Ù Ø±ÙØ´ØªØ§Øª Ù٠بعد"})]}):e.jsx("div",{className:"space-y-4",children:n.map((t,w)=>e.jsx("div",{className:"bg-white rounded-2xl border-2 border-slate-200 hover:border-teal-400 transition-all shadow-sm hover:shadow-lg p-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-14 h-14 bg-gradient-to-br from-teal-500 to-emerald-600 rounded-xl flex items-center justify-center text-white font-black text-lg flex-shrink-0",children:w+1}),e.jsxs("div",{className:"flex-1 grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{className:"text-teal-600 text-sm"}),e.jsx("span",{className:"text-xs font-semibold text-teal-700",children:"رÙÙ
Ø§ÙØ±Ùشتة:"}),e.jsx("span",{className:"text-sm font-black text-slate-900",children:t.prescriptionNumber})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"text-teal-600 text-sm"}),e.jsx("span",{className:"text-xs font-semibold text-teal-700",children:"Ø§ÙØ·Ø¨Ùب:"}),e.jsx("span",{className:"text-sm font-bold text-slate-900",children:t.doctorName})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{className:"text-teal-600 text-sm"}),e.jsx("span",{className:"text-xs font-semibold text-teal-700",children:"ØªØ§Ø±ÙØ® Ø§ÙØ¥Ùشاء:"}),e.jsx("span",{className:"text-sm font-bold text-slate-700",children:m(t.createdAt)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{className:"text-teal-600 text-sm"}),e.jsx("span",{className:"text-xs font-semibold text-teal-700",children:"Ø§ÙØØ§ÙØ©:"}),e.jsx("span",{className:`text-xs font-bold px-2 py-1 rounded-full ${r(t.status)}`,children:I(t.status)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"text-teal-600 text-sm"}),e.jsx("span",{className:"text-xs font-semibold text-teal-700",children:"Ø§ÙØªØ®ØµØµ:"}),e.jsx("span",{className:"text-sm font-bold text-slate-700",children:t.doctorSpecialty})]})]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-teal-50 px-3 py-1.5 rounded-lg border border-teal-200",children:[e.jsx(fe,{className:"text-teal-600 text-xs"}),e.jsx("span",{className:"text-xs font-bold text-teal-700",children:t.consultationType})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>N(t),className:"px-4 py-2.5 bg-gradient-to-r from-slate-500 to-slate-600 text-white rounded-xl hover:from-slate-600 hover:to-slate-700 transition-all font-bold text-sm shadow-md hover:shadow-lg flex items-center gap-2 whitespace-nowrap",children:[e.jsx(_,{className:"w-4 h-4"}),"عرض Ø§ÙØ±Ùشتة"]}),(t.status===1||t.status===5)&&(f(t)?e.jsxs("button",{onClick:()=>R(t),className:"px-4 py-2.5 bg-gradient-to-r from-emerald-500 to-teal-600 text-white rounded-xl hover:from-emerald-600 hover:to-teal-700 transition-all font-bold text-sm shadow-md hover:shadow-lg flex items-center gap-2 whitespace-nowrap",children:[e.jsx(T,{className:"w-4 h-4"}),"Ø§ÙØªÙØ§Ø±ÙØ±"]}):t.status===1?e.jsxs("button",{onClick:()=>C(t),className:"px-4 py-2.5 bg-gradient-to-r from-teal-500 to-emerald-600 text-white rounded-xl hover:from-teal-600 hover:to-emerald-700 transition-all font-bold text-sm shadow-md hover:shadow-lg flex items-center gap-2 whitespace-nowrap",children:[e.jsx(V,{className:"w-4 h-4"}),"Ø§Ø·ÙØ¨ Ø§ÙØ¢Ù"]}):null)]})]})]})},t.id))})})]}),j&&e.jsx(ue,{isOpen:v,onClose:()=>{y(!1),g(null)},prescriptionId:j.id,patientId:j.patientId,doctorId:j.doctorId,doctorName:j.doctorName,doctorSpecialty:j.doctorSpecialty}),e.jsx(we,{isOpen:F,onClose:()=>{c(!1),M(null)},prescription:P}),e.jsx(ke,{isOpen:k,onClose:()=>{a(!1),b(null)},prescription:p,onNewOrder:t=>{a(!1),M(t),c(!0)}})]})};export{Oe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.