PageSourceSearch

https://www.shahiin.com/_next/static/chunks/pages/product/[id]-6561963d05d8f9d8.js

js shahiin.com collected 2026-09-24 14:18:56 UTC 52,582 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1697],{5612:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(11713).A)("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]])},5830:(e,t,s)=>{"use strict";s.d(t,{w:()=>i});var a=s(37876),r=s(14232),l=s(76924),n=s(65870);let i=r.forwardRef((e,t)=>{let{className:s,orientation:r="horizontal",decorative:i=!0,...o}=e;return(0,a.jsx)(l.b,{ref:t,decorative:i,orientation:r,className:(0,n.cn)("shrink-0 bg-border","horizontal"===r?"h-[1px] w-full":"h-full w-[1px]",s),...o})});i.displayName=l.b.displayName},17739:(e,t,s)=>{"use strict";s.d(t,{T:()=>n});var a=s(37876),r=s(14232),l=s(65870);let n=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("textarea",{className:(0,l.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
1ing-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...r})});n.displayName="Textarea"},18465:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(11713).A)("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]])},20588:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(11713).A)("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]])},20710:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(11713).A)("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]])},21575:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(11713).A)("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]])},22963:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(11713).A)("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]])},26124:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(11713).A)("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]])},26257:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(11713).A)("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]])},27854:(e,t,s)=>{"use strict";s.r(t),s.d(t,{__N_SSP:()=>H,default:()=>et,dynamic:()=>ee});var a=s(37876),r=s(77328),l=s.n(r),n=s(14232),i=s(89099),o=s(77041),c=s(20727),d=s(65682),m=s(5830),x=s(22885),u=s(5612),p=s(760),h=s(84296),g=s(65104),v=s(96157),f=s(10797),b=s(99652),y=s(20588),j=s(20710),w=s(47333),N=s(35835),_=s(65084),F=s(3909),k=s(45682),A=s(74725),S=s(40587),E=s(41493),C=s(36552),z=s(53332);let I=e=>{var t;let{images:s,productName:r,selectedImageIndex:l,onImageSelect:n,onImageClick:i,className:o,thumbnailClassName:c}=e;return(0,a.jsxs)("div",{className:"space-y-3 ".concat(null!=o?o:""),children:[(0,a.jsx)("div",{className:"aspect-square bg-gray-50 rounded-xl overflow-hidden shadow-sm border border-gray-100 cursor-pointer hover:shadow-md transition-shadow",onClick:i,children:s.length>0?(0,a.jsx)(z.A,{src:null==(t=s[l])?void 0:t.image_url,alt:r,className:"w-full h-full rounded-lg",priority:!0,aspectRatio:"square"}):(0,a.jsx)(z.A,{src:"",alt:r,className:"w-full h-full rounded-lg",showFallbackIcon:!0,aspectRatio:"square"})}),s.length>1&&(0,a.jsx)("div",{className:"grid grid-cols-5 sm:grid-cols-4 gap-1.5 sm:gap-2",children:s.map((e,t)=>(0,a.jsx)("button",{onClick:()=>n(t),className:"aspect-square rounded-lg overflow-hidden border-2 transition-all duration-200 ".concat(null!=c?c:""," ").concat(l===t?"border-[#FF9933] ring-1 ring-[#FF9933]/25":"border-gray-200 hover:border-gray-300"),children:(0,a.jsx)(z.A,{src:e.image_url,alt:"".concat(r," ").concat(t+1),className:"w-full h-full object-cover",priority:t<=3,aspectRatio:"square"})},t))})]})};var P=s(18695),M=s(71587),L=s(31513),R=s(37113),O=s(26124),q=s(21575),D=s(30822),W=s(18465),$=s(40053),T=s(17739),Z=s(7446),G=s(70672),U=s(26257),B=s(97753);function J(e){let{productId:t,onReviewSubmitted:s,onCancel:r}=e,{user:l}=(0,w.A)(),{toast:i}=(0,A.dj)(),d=(0,n.useRef)(null),[m,x]=(0,n.useState)(0),[u,p]=(0,n.useState)(0),[h,g]=(0,n.useState)(""),[v,f]=(0,n.useState)([]),[b,y]=(0,n.useState)(""),[j,N]=(0,n.useState)([]),[_,k]=(0,n.useState)(!0),[S,E]=(0,n.use
1State)(!1),[C,z]=(0,n.useState)(!1);(0,n.useEffect)(()=>{(async()=>{if(null==l?void 0:l.id)try{k(!0);let{orders:e}=await F.Ek.getCustomerOrders(l.id),s=e.filter(e=>{var s;return"delivered"===e.status&&(null==(s=e.order_items)?void 0:s.some(e=>{var s;return e.product_id===t||(null==(s=e.product_snapshot)?void 0:s.id)===t}))});N(s),1===s.length&&y(s[0].id)}catch(e){console.error("Error fetching orders:",e),i({title:"خطأ",description:"فشل تحميل الطلبات",variant:"destructive"})}finally{k(!1)}})()},[null==l?void 0:l.id,t,i]);let I=async e=>{let t=e.target.files;if(t&&0!==t.length){if(v.length+t.length>3)return void i({title:"خطأ",description:"الحد الأقصى هو 3 صور",variant:"destructive"});E(!0);try{let e=[];for(let s=0;s<t.length;s++){let a=t[s];(0,B.Wl)(a);let r=await (0,B.w4)(a,2),l=await (0,B.QM)(r,"product-images","reviews/");e.push(l)}f([...v,...e]),i({title:"تم بنجاح",description:"تم رفع ".concat(e.length," صورة")})}catch(e){console.error("Image upload failed:",e),i({title:"خطأ",description:e.message||"فشل رفع الصور",variant:"destructive"})}finally{E(!1),d.current&&(d.current.value="")}}},P=async e=>{if(e.preventDefault(),!b)return void i({title:"خطأ",description:"يرجى اختيار الطلب",variant:"destructive"});if(0===m)return void i({title:"خطأ",description:"يرجى اختيار التقييم",variant:"destructive"});z(!0);try{await F.Ek.createProductReview({product_id:t,order_id:b,rating:m,review_text:h.trim()||void 0,review_images:v.length>0?v:void 0}),i({title:"تم بنجاح",description:"تم إرسال التقييم بنجاح"}),x(0),g(""),f([]),y(""),s&&s()}catch(e){console.error("Review submission failed:",e),i({title:"خطأ",description:e.message||"فشل إرسال التقييم",variant:"destructive"})}finally{z(!1)}};return _?(0,a.jsx)(c.Zp,{children:(0,a.jsx)(c.Wu,{className:"p-6",children:(0,a.jsxs)("div",{className:"flex items-center justify-center",children:[(0,a.jsx)(Z.A,{className:"h-6 w-6 animate-spin text-gray-400"}),(0,a.jsx)("span",{className:"mr-2 text-gray-600",children:"جاري التحميل..."})]})})}):0===j.length?(0,a.jsx)(c.Zp,{children:(0,a.jsx)(c.Wu,{className:"p-6 text-center",children:(0,a.jsx)("p",{className:"text-gray-600 mb-2",children:"يجب أن يكون لديك طلب تم تسليمه يحتوي على هذا المنتج لتتمكن من كتابة تقييم"})})}):(0,a.jsxs)(c.Zp,{children:[(0,a.jsx)(c.aR,{children:(0,a.jsx)(c.ZB,{className:"text-right",children:"اكتب تقييمك"})}),(0,a.jsx)(c.Wu,{children:(0,a.jsxs)("form",{onSubmit:P,className:"space-y-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)($.J,{className:"text-right block mb-2",children:"اختر الطلب"}),(0,a.jsxs)("select",{value:b,onChange:e=>y(e.target.value),className:"w-full p-2 border border-gray-300 rounded-lg text-right",required:!0,children:[(0,a.jsx)("option",{value:"",children:"-- اختر الطلب --"}),j.map(e=>(0,a.jsxs)("option",{value:e.id,children:["طلب #",e.id.slice(-8)," - ",new Date(e.created_at).toLocaleDateString("ar-SA")]},e.id))]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)($.J,{className:"text-right block mb-2",children:"التقييم"}),(0,a.jsx)("div",{className:"flex items-center justify-end gap-1",children:[1,2,3,4,5].map(e=>(0,a.jsx)("button",{type:"button",onClick:()=>x(e),onMouseEnter:()=>p(e),onMouseLeave:()=>p(0),className:"focus:outline-none",children:(0,a.jsx)(O.A,{className:"h-8 w-8 transition-colors ".concat(e<=(u||m)?"fill-yellow-400 text-yellow-400":"text-gray-300")})},e))})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)($.J,{htmlFor:"review-text",className:"text-right block mb-2",children:"نص التقييم (اختياري)"}),(0,a.jsx)(T.T,{id:"review-text",value:h,onChange:e=>g(e.target.value),placeholder:"شاركنا تجربتك مع هذا المنتج...",className:"min-h-[100px] text-right",maxLength:1e3}),(0,a.jsxs)("p",{className:"text-xs text-gray-500 mt-1 text-right",children:[h.length,"/1000"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)($.J,{className:"text-right block mb-2",children:"صور (اختياري - حد أقصى 3)"}),(0,a.jsxs)("div",{className:"space-y-4",children:[v.length>0&&(0,a.jsx)("div",{className:"grid grid-cols-3 gap-4",children:v.map((e,t)=>(0,a.jsxs)("div",{className:"relative group",children:[(0,a.jsx)("img",{src:e,alt:"Review ".concat(t+1),className:"w-full h-24 object-cover rounded-lg border border-gray-200"}),(0,a.jsx)("button",{type:"button",onClick:()=>{f(v.filter((e,s)=>s!==t))},className:"absolute top-1 left-1 bg-red-500 text-white rounded-full p-1 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,a.jsx)(G.A,{className:"h-4 w-4"})})]},t))}),v.length<3&&(0,a.jsxs)("div",{children:[(0,a.jsx)("input",{ref:d,type:"file",accept:"image/jpeg,image/jpg,image/png,image/webp",multiple:!0,onChange:I,className:"hidden",disabled:S}),(0,a.jsx)(o.$,{type:"button",variant:"outline",onClick:()=>{var e;
1return null==(e=d.current)?void 0:e.click()},disabled:S,className:"w-full",children:S?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Z.A,{className:"h-4 w-4 ml-2 animate-spin"}),"جاري الرفع..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(U.A,{className:"h-4 w-4 ml-2"}),"رفع صور"]})})]})]})]}),(0,a.jsxs)("div",{className:"flex gap-3 justify-end",children:[r&&(0,a.jsx)(o.$,{type:"button",variant:"outline",onClick:r,disabled:C,children:"إلغاء"}),(0,a.jsx)(o.$,{type:"submit",disabled:C||0===m||!b,className:"bg-[#FF9933] hover:bg-[#E6801A] text-white",children:C?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Z.A,{className:"h-4 w-4 ml-2 animate-spin"}),"جاري الإرسال..."]}):"إرسال التقييم"})]})]})})]})}function X(e){var t;let{productId:s}=e,{user:r}=(0,w.A)(),[l,i]=(0,n.useState)([]),[d,m]=(0,n.useState)(!0),[x,u]=(0,n.useState)(!1),[p,h]=(0,n.useState)(0),[g,v]=(0,n.useState)(0),[f,b]=(0,n.useState)(new Set),[y,j]=(0,n.useState)(null),N=async()=>{try{m(!0);let e=await F.Ek.getProductReviews(s,{limit:50,offset:0});i(e.reviews),h(e.meta.average_rating),v(e.meta.total_reviews)}catch(e){console.error("Error fetching reviews:",e)}finally{m(!1)}};(0,n.useEffect)(()=>{N()},[s]);let _=e=>(0,a.jsx)("div",{className:"flex items-center gap-1",children:[1,2,3,4,5].map(t=>(0,a.jsx)(O.A,{className:"h-4 w-4 ".concat(t<=e?"fill-yellow-400 text-yellow-400":"text-gray-300")},t))}),k=e=>{var t,s;return(null==(t=e.users)?void 0:t.name)?e.users.name:(null==(s=e.users)?void 0:s.email)?e.users.email.split("@")[0]:"مستخدم"};return d?(0,a.jsx)(c.Zp,{className:"border border-gray-100 shadow-sm",children:(0,a.jsx)(c.Wu,{className:"p-4",children:(0,a.jsx)("div",{className:"text-center text-sm text-gray-600",children:"جاري التحميل..."})})}):(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(c.Zp,{className:"border border-gray-100 shadow-sm",children:(0,a.jsxs)(c.Wu,{className:"p-3 sm:p-4",children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-lg sm:text-xl font-bold text-gray-900 mb-1.5",children:"التقييمات"}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"flex items-center",children:_(Math.round(p))}),(0,a.jsx)("span",{className:"text-base font-semibold text-gray-900",children:p.toFixed(1)})]}),(0,a.jsxs)("span",{className:"text-sm text-gray-600",children:["(",g," ","تقييم",")"]})]})]}),r&&"vendor"!==r.type&&(0,a.jsx)(o.$,{size:"sm",onClick:()=>u(!x),className:"bg-[#FF9933] hover:bg-[#E6801A] text-white shrink-0",children:x?"إلغاء":"اكتب تقييم"})]}),x&&(0,a.jsx)("div",{className:"mt-4",children:(0,a.jsx)(J,{productId:s,onReviewSubmitted:()=>{u(!1),N()},onCancel:()=>u(!1)})})]})}),0===l.length?(0,a.jsx)(c.Zp,{className:"border border-gray-100 shadow-sm",children:(0,a.jsx)(c.Wu,{className:"p-4 text-center",children:(0,a.jsx)("p",{className:"text-sm text-gray-600",children:"لا توجد تقييمات بعد. كن أول من يقيم هذا المنتج!"})})}):(0,a.jsx)("div",{className:"space-y-3",children:l.map(e=>{let t=f.has(e.id),s=e.review_text||"",r=s.length>200,l=r&&!t?s.substring(0,200)+"...":s;return(0,a.jsx)(c.Zp,{className:"border border-gray-100 shadow-sm",children:(0,a.jsx)(c.Wu,{className:"p-3 sm:p-4",children:(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("div",{className:"flex items-start justify-between",children:(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 mb-2",children:[(0,a.jsx)("div",{className:"w-10 h-10 bg-[#FF9933] rounded-full flex items-center justify-center text-white font-bold",children:k(e).charAt(0).toUpperCase()}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-semibold text-gray-900",children:k(e)}),(0,a.jsx)("p",{className:"text-sm text-gray-500",children:new Date(e.created_at).toLocaleDateString("ar-SA",{year:"numeric",month:"long",day:"numeric"})})]})]}),(0,a.jsx)("div",{className:"mr-14",children:_(e.rating)})]})}),s&&(0,a.jsxs)("div",{className:"text-gray-700",children:[(0,a.jsx)("p",{className:"text-right leading-relaxed",children:l}),r&&(0,a.jsx)(o.$,{variant:"ghost",size:"sm",onClick:()=>(e=>{let t=new Set(f);t.has(e)?t.delete(e):t.add(e),b(t)})(e.id),className:"mt-2 text-[#FF9933] hover:text-[#E6801A]",children:t?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(q.A,{className:"h-4 w-4 ml-1"}),"إخفاء"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(D.A,{className:"h-4 w-4 ml-1"}),"عرض المزيد"]})})]}),e.review_images&&e.review_images.length>0&&(0,a.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:e.review_images.map((t,s)=>(0,a.jsxs)("div",{className:"relative aspect-square cursor-pointer group",onClick:()=>j({reviewId:e.id,imageIndex:s}),children:[(0,a.jsx)("img",{src:t,alt:"Review image ".concat(s+1),className:"w-full h-full object-cover rounded-lg border border-gray-200 hover:opacity-90 transition-opacity"}),(0,a.jsx)("div",{className:"absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-10 transition-all rounded-lg flex items-center justify-center",children:(0,a.jsx)(W.A,{className:"h-6 w-6 text-white opacity-0 group-hover:opacity-100 transition-opacity"})})]},s))})]})})},e.id)})}),y&&(0,a.jsx)(C.A,{images:(null==(t=l.find(e=>e.id===y.reviewId))?void 0:t.review_images)||[],currentIndex:y.imageIndex,onClose:()=>j(null),onIndexChange:e=>j({reviewId:y.reviewId,imageIndex:e})})]})}let Y=e=>{let t={أحمر:"#ef4444",أزرق:"#3b82f6",أخضر:"#10b981",أصفر:"#f59e0b",أسود:"#000000",أبيض:"#ffffff",رمادي:"#6b7280",بني:"#8b4513",بنفسجي:"#8b5cf6",وردي:"#ec4899",برتقالي:"#f97316","أزرق داكن":"#1e3a8a","أحمر داكن":"#7f1d1d","أخضر فاتح":"#84cc16","أزرق فاتح":"#06b6d4","وردي داكن":"#d946ef",فضي:"#c0c0c0",ذهبي:"#fbbf24",بيج:"#f5f5dc",كاكي:"#f0e68c",جينز:"#5A7B8C","جينز أزرق":"#5A7B8C",كريمي:"#fef3c7",red:"#ef4444",blue:"#3b82f6",green:"#10b981",yellow:"#f59e0b",black:"#000000",white:"#ffffff",gray:"#6b7280",grey:"#6b7280",brown:"#8b4513",purple:"#8b5cf6",pink:"#ec4899",orange:"#f97316",navy:"#1e3a8a",maroon:"#7f1d1d",lime:"#84cc16",cyan:"#06b6d4",magenta:"#d946ef",silver:"#c0c0c0",gold:"#fbbf24",beige:"#f5f5dc",khaki:"#f0e68c","dark blue":"#1e3a8a","light blue":"#3b82f6","dark red":"#7f1d1d","light green":"#84cc16","dark green":"#059669","light pink":"#f9a8d4","dark pink":"#be185d","light gray":"#d1d5db","dark gray":"#374151",cream:"#fef3c7",creme:"#fef3c7",tan:"#d2b48c",jeans:"#5A7B8C",denim:"#5A7B8C",dar
1k:"#000000",light:"#ffffff",bright:"#fbbf24",muted:"#6b7280",vibrant:"#ec4899",pastel:"#fce7f3",neon:"#84cc16",metallic:"#c0c0c0"},s=e.toLowerCase().trim();if(t[s])return t[s];for(let[e,a]of Object.entries(t))if(s.includes(e)||e.includes(s))return a;for(let e of s.split(/\s+/))if(t[e])return t[e];if(/^#[0-9a-f]{6}$/i.test(e)||e.startsWith("rgb(")||e.startsWith("rgba("))return e;let a=Math.abs(e.split("").reduce((e,t)=>(e=(e<<5)-e+t.charCodeAt(0))&e,0))%360;return"hsl(".concat(a,", 70%, 50%)")},K=e=>{var t,s,r;let{productId:l,initialProduct:z}=e,O=(0,i.useRouter)(),{navigateToVendor:q}=(0,P.O)(),{setNavigationLoading:D}=(0,M.c)(),{user:W,userType:$}=(0,w.A)(),{addItem:T}=(0,N._)(),[Z,G]=(0,n.useState)(0),[U,B]=(0,n.useState)(""),[J,K]=(0,n.useState)(""),[Q,V]=(0,n.useState)(""),[H,ee]=(0,n.useState)(null),[et,es]=(0,n.useState)({}),[ea,er]=(0,n.useState)(1),[el,en]=(0,n.useState)(!1),[ei,eo]=(0,n.useState)(!1),{data:ec,isLoading:ed,error:em}=(0,_.Z)({queryKey:["product",l],queryFn:()=>F.Ek.getProducts({product_id:l}),enabled:!!l&&!z}),ex=z||(null==ec||null==(t=ec.data)?void 0:t[0]);(0,n.useEffect)(()=>{D(null)},[D,l]),(0,n.useEffect)(()=>{if(null==ex?void 0:ex.id){let e=(null==W?void 0:W.id)||null;"vendor"===$&&e&&ex.vendor_id===e||(0,R._D)(ex.id,e).catch(()=>{})}},[null==ex?void 0:ex.id,null==W?void 0:W.id,null==W?void 0:W.type,null==ex?void 0:ex.vendor_id]),(0,n.useEffect)(()=>{let e=()=>{D(null)};return O.events.on("routeChangeComplete",e),O.events.on("routeChangeError",e),()=>{O.events.off("routeChangeComplete",e),O.events.off("routeChangeError",e)}},[O,D]);let eu=(0,n.useMemo)(()=>(null==ex?void 0:ex.product_variants)&&Array.isArray(ex.product_variants)?(0,E.bv)(ex.product_variants,ex.base_price):[],[ex]),ep=eu.length>0,eh=(0,n.useMemo)(()=>(0,E.qQ)(eu),[eu]),eg=(0,n.useMemo)(()=>(0,E.P1)(eu),[eu]),ev=(0,n.useMemo)(()=>(0,E.ug)(eu),[eu]),ef=(0,n.useMemo)(()=>ev?Array.from(new Set(eu.map(e=>(0,E.qr)(e)))).sort(E.Tg):[],[ev,eu]),eb=(0,n.useMemo)(()=>(0,E.Kl)(eu),[eu]),ey=(0,n.useMemo)(()=>ex&&ep&&!eg?(0,E.rr)(ep,eu,ex):{mode:"none",colors:[],sizes:[],combinations:[]},[ep,eu,ex,eg]);(0,n.useEffect)(()=>{B(""),K(""),V("")},[l,null==ex?void 0:ex.id]),(0,n.useEffect)(()=>{if(!ep||!eg){ee(null),es({});return}let e=(0,E.JM)(eu);ee(e.selectedSize),es(e.facetSelections)},[ep,eg,null==ex?void 0:ex.id,eu]),(0,n.useEffect)(()=>{var e;if(eg||"options_only"!==ey.mode)return void V("");if(Q)return;let t=null!=(e=ey.combinations.find(e=>e.available))?e:ey.combinations[0];t&&V(t.id)},[ey.mode,ey.combinations,Q,eg]);let ej=(0,n.useMemo)(()=>{var e,t,s,a;if(!ep)return null;if(eg)return(0,E.TG)(eu,H,ev,et,eh);let{mode:r,combinations:l}=ey;if("matrix"===r&&U&&J){let t=l.find(e=>e.color===U&&e.size===J);return t&&null!=(e=eu.find(e=>e.id===t.id))?e:null}if("size_only"===r&&J){let e=l.find(e=>e.size===J);return e&&null!=(t=eu.find(t=>t.id===e.id))?t:null}if("color_only"===r&&U){let e=l.find(e=>e.color===U);return e&&null!=(s=eu.find(t=>t.id===e.id))?s:null}return"options_only"===r&&Q&&null!=(a=eu.find(e=>e.id===Q))?a:null},[ep,eg,eu,H,ev,et,eh,ey,U,J,Q]);if((0,n.useEffect)(()=>(ex&&(0,S.r3)(ex,ej),()=>{document.title="شاهين - تسوق بذكاء"}),[ex,ej]),ed&&!ex)return(0,a.jsx)("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-marketplace-primary"}),(0,a.jsx)("p",{className:"mt-4 text-gray-600",children:"جاري التحميل..."})]})});let ew=async()=>{if("vendor"===$)return void(0,A.oR)({title:"غير متاح للتاجر",description:"تسجيل الدخول كتاجر مخصص لإدارة المتجر وليس للشراء.",variant:"destructive"});if(!W){try{await O.push("/auth")}catch(e){console.error("router.push(/auth) failed, falling back to hard redirect",e)}window.location.assign("/auth");return}if(ex){if(ep&&!ej)return void(0,A.oR)({title:"اختر الخيارات",description:"يرجى اختيار جميع الخيارات المطلوبة قبل الإضافة للسلة",variant:"destructive"});en(!0),setTimeout(()=>{var e,t;T({productId:ex.id,name:ex.name,price:ej?ej.price:ex.base_price,currency:ex.currency,quantity:ea,imageUrl:ex.product_images&&Array.isArray(ex.product_images)?null==(e=ex.product_images[0])?void 0:e.image_url:null,variantId:null==ej?void 0:ej.id,variantName:null==ej?void 0:ej.name,vendorId:ex.vendor_profiles.id,vendorName:ex.vendor_profiles.vendor_name,deliveryPrice:ex.delivery_price,maxStock:ej?ej.stockCount:ex.stock_count,fulfillmentMethod:ex.fulfillment_method,vendorLatitude:ex.vendor_profiles.latitude,vendorLongitude:ex.vendor_profiles.longitude,availabilityMode:ex.availability_mode||"for_sale",pickupAvailable:ex.pickup_available||!1,deliveryAvailable:ex.delivery_available||!0,paymentCod:ex.payment_cash_on_delivery||!1,paymentShamcash:ex.payment_shamcash||!1,paymentGoldmasters:ex.payment_goldmasters||!1,paymentThika:ex.payment_thika||!1,paymentShamcashShahiin:ex.payment_shamcash_shahiin||!1,paymentThikaShahiin:ex.payment_thika_shahiin||!1,paymentGoldmasterShahiin:ex.payment_goldmaster_shahiin||!1,productSnapshot:{turbozone:null!=(t=ex.turbozone)?t:null,fulfillment_method:ex.fulfillment_method}}),(0,A.oR)({title:"✅ تم إضافة المنتج للسلة",description:"".concat(ex.name," - الكمية: ").concat(ea),duration:3e3}),en(!1)},800)}};if(em||!ex)return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(k.A,{}),(0,a.jsx)("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("h2",{className:"text-2xl font-bold text-gray-900 mb-4",children:"المنتج غير موجود"}),(0,a.jsx)(o.$,{onClick:()=>O.push("/products"),children:"العودة للمنتجات"})]})})]});if(ed)return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(k.A,{}),(0,a.jsx)("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:(0,a.jsx)("div",{className:"animate-spin rounded-full h-32 w-32 border-b-2 border-vendor-primary"})})]});let eN=ej?ej.price:ex.base_price,e_=ej?ej.stockCount:ep?(0,E.HR)(ex.product_variants,ex.stock_count):ex.total_stock||ex.stock_count,eF=0===e_,ek=!ep||eg&&!!ej||!eg&&("matrix"===ey.mode&&!!U&&!!J&&!!ej||"size_only"===ey.mode&&!!J&&!!ej||"color_only"===ey.mode&&!!U&&!!ej||"options_only"===ey.mode&&!!Q&&!!ej),eA=!eF&&ek;return"".concat(ex.name," - ").concat(ex.vendor_profiles.vendor_name),"تسوق ".concat(ex.name," بسعر ").concat(eN," ").concat(ex.currency," على شاهين"),ex.id,(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(k.A,{}),(0,a.jsxs)("div",{className:"min-h-screen bg-white product-details-page",children:[(0,a.jsx)("div",{className:"sticky top-0 z-50 bg-white/95 backdrop-blur-sm border-b border-gray-200",children:(0,a.jsx)("div",{className:"max-w-5xl mx-auto px-3 sm:px-4 lg:px-6 py-2.5 sm:py-3",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)(o.$,{variant:"ghost",size:"sm",onClick:()=>{D(null),window.history.length>1?O.back():O.push("/")},className:"w-10 h-10 rounded-full bg-white shadow-sm border border-gray-100 hover:bg-gray-50 active:scale-95 transition-transform","aria-label":"رجوع",children:(0,a.jsx)(x.A,{className:"h-4 w-4"})}),(0,a.jsxs)("div",{className:"flex items-center space-x-2 space-x-reverse",children:[(0,a.jsx)(o.$,{variant:"ghost",size:"sm",className:"w-10 h-10 rounded-full bg-white shadow-sm border border-gray-100 hover:bg-gray-50 active:scale-95 transition-transform","aria-label":"مشاركة",children:(0,a.jsx)(u.A,{className:"h-4 w-4"})}),(0,a.jsx)(o.$,{variant:"ghost",size:"sm",className:"w-10 h-10 rounded-full bg-white shadow-sm border border-gray-100 hover:bg-gray-50 active:scale-95 transition-transform","aria-label":"إضافة للمفضلة",children:(0,a.jsx)(p.A,{className:"h-4 w-4"})})]})]})})}),(0,a.jsx)("div",{className:"max-w-5xl mx-auto px-3 sm:px-4 lg:px-6 py-4 sm:py-5",children:(0,a.jsxs)("div",{className:"lg:grid lg:grid-cols-2 lg:gap-8 xl:gap-10 lg:items-start",children:[(0,a.jsx)("div",{className:"mb-5 lg:mb-0 lg:max-w-[min(100%,420p
1x)] xl:max-w-[min(100%,460px)] lg:mx-auto lg:w-full",children:(0,a.jsx)(I,{images:ex.product_images&&Array.isArray(ex.product_images)?ex.product_images:[],productName:ex.name,selectedImageIndex:Z,onImageSelect:G,onImageClick:()=>eo(!0),thumbnailClassName:"rounded-lg"})}),(0,a.jsxs)("div",{className:"space-y-3 sm:space-y-4 min-w-0",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h1",{className:"text-lg sm:text-xl md:text-2xl font-bold text-gray-900 mb-2 sm:mb-3 leading-snug pdp-title",children:ex.name}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3 mb-2 sm:mb-3",children:[(0,a.jsx)("span",{className:"text-xl sm:text-2xl font-bold text-teal-600 pdp-price",children:(0,L.vv)(eN,ex.currency)}),ex.is_discounted&&ex.discount_percentage>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-sm sm:text-base text-gray-400 line-through",children:(0,L.vv)(eN/(1-ex.discount_percentage/100),ex.currency)}),(0,a.jsxs)(d.E,{className:"bg-[#FF9933] text-white px-2 py-0.5 rounded-md text-xs font-bold",children:[ex.discount_percentage,"% Off"]})]})]})]}),ep&&(0,a.jsx)(c.Zp,{className:"border border-gray-100 shadow-sm",children:(0,a.jsxs)(c.Wu,{className:"p-3 sm:p-4",children:[(0,a.jsx)("h3",{className:"text-sm sm:text-base font-semibold mb-2 sm:mb-3",children:"اختر الخيارات"}),(0,a.jsxs)("div",{className:"space-y-3 sm:space-y-4",children:[eg&&(0,a.jsxs)("div",{className:"space-y-4",children:[ev&&ef.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2 sm:mb-3",children:(0,E.KG)(eu)}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2 sm:gap-3",children:ef.map(e=>{let t=H===e,s=eu.filter(t=>(0,E.qr)(t)===e).some(e=>e.stockCount>0);return(0,a.jsxs)("button",{type:"button",onClick:()=>s&&(e=>{ee(e),es((0,E.gA)(eu,e))})(e),disabled:!s,className:"\n                                            relative flex flex-col items-center justify-center gap-1 px-3 sm:px-4 py-2.5 sm:py-3 rounded-full border-2 transition-all duration-200 active:scale-95\n                                            ".concat(t?"border-[#FF9933] bg-[#FFF4EA] text-[#FF9933] shadow-sm":s?"border-gray-200 bg-white hover:border-[#FF9933]/60 hover:bg-[#FFF4EA]/60 text-gray-700":"border-gray-100 bg-gray-50 text-gray-400 cursor-not-allowed","\n                                            min-w-[52px] sm:min-w-[60px] min-h-[44px] sm:min-h-[48px]\n                                          "),children:[(0,a.jsx)("span",{className:"text-sm sm:text-base font-bold",children:e}),!s&&(0,a.jsx)("span",{className:"text-[10px] font-semibold text-red-600",children:"غير متوفر"})]},e)})})]}),eh.map((e,t)=>{let s=(0,E.h5)(eu,H,ev,et,eh,e);return 0===s.length?null:(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2 sm:mb-3",children:e}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2 sm:gap-3",children:s.map(s=>{let r=et[e]===s,l={};for(let e=0;e<t;e++){let t=eh[e],s=et[t];(null==s?void 0:s.trim())&&(l[t]=s)}let n={...l,[e]:s},i=(0,E.U)(eu,H,ev,n,eh),o=(0,E.u$)(e);return(0,a.jsxs)("button",{type:"button",onClick:()=>((e,t)=>{let s=eh.indexOf(e);if(s<0)return;let a={...et};for(let e=s+1;e<eh.length;e++)delete a[eh[e]];a[e]=t;let r=(0,E.Sv)(eu,H,ev,eh,a,s+1),l=(0,E.TG)(eu,H,ev,r,eh);ev&&l&&ee((0,E.qr)(l)),es(r)})(e,s),className:"\n                                              relative flex flex-col items-stretch gap-1 px-3 sm:px-4 py-2.5 sm:py-3 rounded-xl border-2 transition-all duration-200 text-start min-w-0 max-w-full sm:max-w-[280px]\n                                              ".concat(r?"border-[#FF9933] bg-[#FFF4EA] text-[#FF9933] shadow-sm":"border-gray-200 bg-white hover:border-[#FF9933]/60 hover:bg-[#FFF4EA]/60 text-gray-800","\n                                            "),children:[(0,a.jsxs)("span",{className:"flex items-start gap-2 min-w-0",children:[o&&(0,a.jsx)("span",{className:"mt-0.5 w-6 h-6 rounded-full border-2 border-gray-300 shrink-0",style:{backgroundColor:Y(s)}}),(0,a.jsx)("span",{className:"text-xs sm:text-sm font-semibold leading-snug break-words",children:s})]}),!i&&(0,a.jsx)("span",{className:"text-[11px] font-semibold text-red-600",children:"غير متوفر"})]},"".concat(e,"-").concat(s))})})]},"axis-".concat(e))})]}),!eg&&"options_only"===ey.mode&&(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2 sm:mb-3",children:eb.primaryOptionLabel}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2 sm:gap-3",children:ey.combinations.map(e=>{var t;let s=Q===e.id;return(0,a.jsxs)("button",{type:"button",onClick:()=>e.available&&V(e.id),disabled:!e.available,className:"\n                                        relative flex flex-col items-stretch gap-1 px-3 sm:px-4 py-2.5 sm:py-3 rounded-xl border-2 transition-all duration-200 text-start min-w-0 max-w-full sm:max-w-[280px]\n                                        ".concat(s?"border-[#FF9933] bg-[#FFF4EA] text-[#FF9933] shadow-sm":e.available?"border-gray-200 bg-white hover:border-[#FF9933]/60 hover:bg-[#FFF4EA]/60 text-gray-800":"border-gray-100 bg-gray-50 text-gray-400 cursor-not-allowed","\n                                      "),children:[(0,a.jsx)("span",{className:"text-xs sm:text-sm font-semibold leading-snug break-words",children:null!=(t=e.optionLabel)?t:e.id}),!e.available&&(0,a.jsx)("span",{className:"text-[11px] font-semibold text-red-600",children:"غير متوفر"})]},e.id)})})]}),!eg&&ey.colors.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2 sm:mb-3",children:eb.primaryOptionLabel}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2 sm:gap-3",children:ey.colors.map(e=>{let t=U===e,s=ey.combinations.filter(t=>t.color===e&&t.available).map(e=>e.size),r="color_only"===ey.mode?ey.combinations.some(t=>t.color===e&&t.available):s.length>0;return(0,a.jsxs)("button",{onClick:()=>{B(e),J&&!s.includes(J)&&K("")},disabled:!r,className:"\n                                        relative flex flex-col items-center justify-center gap-1 sm:gap-1.5 px-3 sm:px-4 py-2.5 sm:py-3 rounded-full border-2 transition-all duration-200 active:scale-95\n                                        ".concat(t?"border-[#FF9933] bg-[#FFF4EA] text-[#FF9933] shadow-sm":r?"border-gray-200 bg-white hover:border-[#FF9933]/60 hover:bg-[#FFF4EA]/60 text-gray-700":"border-gray-100 bg-gray-50 text-gray-400 cursor-not-allowed","\n                                        min-w-[72px] sm:min-w-[80px] min-h-[48px] sm:min-h-[52px]\n                                      "),children:[(0,a.jsx)("div",{className:"w-7 h-7 sm:w-6 sm:h-6 rounded-full border-2 ".concat(t?"border-[#FF9933]":"border-gray-300"),style:{backgroundColor:Y(e),boxShadow:t?"0 0 0 2px rgba(255, 153, 51, 0.2)":"none"}}),(0,a.jsx)("span",{className:"text-xs font-medium text-center",children:e}),t&&(0,a.jsx)("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-[#FF9933] rounded-full flex items-center justify-center",children:(0,a.jsx)("div",{className:"w-1.5 h-1.5 bg-white rounded-full"})})]},e)})})]}),!eg&&ey.sizes.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2 sm:mb-3",children:eb.sizeLabel}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2 sm:gap-3",children:ey.sizes.map(e=>{let t=J===e,s=ey.combinations.filter(t=>t.size===e&&t.available).map(e=>e.color),r="size_only"===ey.mode?ey.combinations.some(t=>t.size===e&&t.available):s.length>0;return(0,a.jsxs)("button",{onClick:()=>{K(e),U&&!s.includes(U)&&B("")},disabled:!r,className:"\n                                        relative flex flex-col items-center justify-center gap-1 px-3 sm:px-4 py-2.5 sm:py-3 rounded-full border-2 transition-all duration-200 active:scale-95\n                                        ".concat(t?"border-[#FF9933] bg-[#FFF4EA] text-[#FF9933] shadow-sm":r?"border-gray-200 bg-white hover:border-[#FF9933]/60 hover:bg-[#FFF4EA]/60 text-gray-700":"border-gray-100 bg-gray-50 text-gray-400 cursor-not-allowed","\n                                        min-w-[52px] sm:min-w-[60px] min-h-[44px] sm:min-h-[48px]\n                                      "),children:[(0,a.jsx)("span",{className:"text-sm sm:text-base font-bold",children:e}),t&&(0,a.jsx)("div",{className:"absolute -top-1 -right-1 w-4 h-4 sm:w-3 sm:h-3 bg-[#FF9933] rounded-full flex items-center justify-center",children:(0,a.jsx)("div",{className:"w-2 h-2 sm:w-1.5 sm:h-1.5 bg-white rounded-full"})})]},e)})})]}),ek&&ej&&(0,a.jsx)("div",{className:"bg-[#FFF4EA] border border-[#FFD8A6] rounded-xl p-3 sm:p-4",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm text-gray-600",children:"الخيار المحدد:"}),(0,a.jsx)("p",{className:"font-medium text-[#FF9933]",children:eg?null!=(s=null==ej?void 0:ej.name)?s:"":"options_only"===ey.mode?null!=(r=null==ej?void 0:ej.name)?r:"":"size_only"===ey.mode?J:"color_only"===ey.mode?U:"".concat(U," - ").concat(J)})]}),(0,a.jsxs)("div",{className:"text-right",children:[(0,a.jsx)("p",{className:"text-sm text-gray-600",children:"السعر:"}),(0,a.jsx)("p",{className:"font-bold text-[#FF9933]",children:(0,L.vv)(ej.price,ex.currency)})]})]})})]})]})}),(0,a.jsx)(c.Zp,{className:"border border-gray-100 shadow-sm",children:(0,a.jsx)(c.Wu,{className:"p-3 sm:p-4",children:(0,a.jsxs)("div",{className:"space-y-3 sm:space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-gray-700",children:"الكمية"}),(0,a.jsxs)("div",{className:"flex items-center space-x-2 space-x-reverse border-2 rounded-full px-1",children:[(0,a.jsx)(o.$,{variant:"ghost",size:"sm",onClick:()=>er(Math.max(1,ea-1)),disabled:ea<=1,className:"h-9 w-9 sm:h-10 sm:w-10 p-0 active:scale-95 transition-transform","aria-label":"تقليل الكمية",children:(0,a.jsx)(h.A,{className:"h-4 w-4"})}),(0,a.jsx)("span",{className:"px-2 sm:px-3 py-2 font-bold text-sm sm:text-base min-w-[36px] text-center",children:ea}),(0,a.jsx)(o.$,{variant:"ghost",size:"sm",onClick:()=>er(Math.min(e_,ea+1)),disabled:ea>=e_,className:"h-9 w-9 sm:h-10 sm:w-10 p-0 active:scale-95 transition-transform","aria-label":"زيادة الكمية",children:(0,a.jsx)(g.A,{className:"h-4 w-4"})})]})]}),(0,a.jsx)(o.$,{onClick:ew,disabled:!eA||el,className:"w-full pdp-add-to-cart bg-[#FF9933] hover:bg-[#
1E6801A] text-white py-2.5 sm:py-3 text-sm sm:text-base font-semibold min-h-[46px] sm:min-h-[48px] rounded-full active:scale-95 transition-all disabled:opacity-50 disabled:cursor-not-allowed",children:el?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white ml-2"}),(0,a.jsx)("span",{children:"جاري الإضافة..."})]}):ep&&!ek?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(v.A,{className:"h-4 w-4 ml-2"}),(0,a.jsx)("span",{children:eg?"اختر جميع الخيارات أولاً":"options_only"===ey.mode?"اختر ".concat(eb.primaryOptionLabel," أولاً"):"size_only"===ey.mode?"اختر ".concat(eb.sizeLabel," أولاً"):"color_only"===ey.mode?"اختر ".concat(eb.primaryOptionLabel," أولاً"):"اختر ".concat(eb.primaryOptionLabel," و ").concat(eb.sizeLabel," أولاً")})]}):eF?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(v.A,{className:"h-4 w-4 ml-2"}),(0,a.jsx)("span",{children:"نفد المخزون"})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(v.A,{className:"h-4 w-4 ml-2"}),(0,a.jsx)("span",{children:"أضف للسلة"})]})}),ep&&!ek&&(0,a.jsxs)("p",{className:"text-xs text-center text-[#FF9933] mt-2",children:[eg&&(0,a.jsx)(a.Fragment,{children:"⚠️ أكمل اختيار كل المحاور لإضافة المنتج للسلة"}),!eg&&"options_only"===ey.mode&&!Q&&"⚠️ اختر ".concat(eb.primaryOptionLabel," لإضافة المنتج للسلة"),!eg&&"size_only"===ey.mode&&!J&&"⚠️ اختر ".concat(eb.sizeLabel," لإضافة المنتج للسلة"),!eg&&"color_only"===ey.mode&&!U&&"⚠️ اختر ".concat(eb.primaryOptionLabel," لإضافة المنتج للسلة"),!eg&&"matrix"===ey.mode&&!U&&!J&&(0,a.jsxs)(a.Fragment,{children:["⚠️ اختر ",eb.primaryOptionLabel," و ",eb.sizeLabel," لإضافة المنتج للسلة"]}),!eg&&"matrix"===ey.mode&&U&&!J&&(0,a.jsxs)(a.Fragment,{children:["⚠️ اختر ",eb.sizeLabel," لإضافة المنتج للسلة"]}),!eg&&"matrix"===ey.mode&&!U&&J&&(0,a.jsxs)(a.Fragment,{children:["⚠️ اختر ",eb.primaryOptionLabel," لإضافة المنتج للسلة"]})]})]})})}),ex.description&&(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm sm:text-base font-bold text-gray-900 mb-1.5 sm:mb-2",children:"الوصف"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 leading-relaxed whitespace-pre-line",children:ex.description})]})]})]})}),(0,a.jsx)("div",{className:"max-w-5xl mx-auto px-3 sm:px-4 lg:px-6 py-4 sm:py-6",children:(0,a.jsx)(c.Zp,{className:"border border-gray-100 shadow-sm rounded-xl",children:(0,a.jsxs)(c.Wu,{className:"p-3 sm:p-4",children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-4 space-x-reverse",children:[(0,a.jsx)("div",{className:"w-10 h-10 bg-[#FFF4EA] rounded-full flex items-center justify-center shrink-0",children:(0,a.jsx)(f.A,{className:"h-5 w-5 text-[#FF9933]"})}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("h3",{className:"text-sm sm:text-base font-semibold text-gray-900",children:"يُباع بواسطة"}),(0,a.jsx)("p",{className:"text-[#FF9933] font-medium text-sm sm:text-base truncate",children:ex.vendor_profiles.vendor_name})]})]}),(0,a.jsxs)(o.$,{onClick:()=>{var e;(null==ex||null==(e=ex.vendor_profiles)?void 0:e.id)&&q(ex.vendor_profiles.id)},variant:"outline",className:"pdp-visit-store border-[#FF9933] text-[#FF9933] hover:bg-[#FF9933] hover:text-white rounded-full w-full sm:w-auto",children:[(0,a.jsx)(f.A,{className:"h-4 w-4 ml-2"}),"زيارة المتجر"]})]}),(0,a.jsx)(m.w,{className:"my-3"}),(0,a.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-2 sm:gap-3 text-xs text-gray-600",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2 space-x-reverse",children:[(0,a.jsx)(b.A,{className:"h-4 w-4 flex-shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:ex.vendor_profiles.formatted_address||"العنوان غير محدد"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2 space-x-reverse",children:[(0,a.jsx)(y.A,{className:"h-4 w-4 flex-shrink-0"}),(0,a.jsx)("span",{children:"متاح للتواصل"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2 space-x-reverse",children:[(0,a.jsx)(j.A,{className:"h-4 w-4 flex-shrink-0"}),(0,a.jsx)("span",{children:"متاح الآن"})]})]})]})})}),(0,a.jsx)("div",{className:"max-w-5xl mx-auto px-3 sm:px-4 lg:px-6 pb-8 sm:pb-10",children:(0,a.jsx)(X,{productId:ex.id})})]}),ei&&ex.product_images.length>0&&(0,a.jsx)(C.A,{images:ex.product_images,currentIndex:Z,onClose:()=>eo(!1),onIndexChange:e=>{G(e)}})]})},Q=e=>{let{productId:t,initialProduct:s}=e;return(0,a.jsx)(K,{productId:t,initialProduct:s})};var V=s(48085),H=!0;let ee="force-dynamic",et=e=>{let{product:t,error:s}=e;return console.log("\uD83D\uDECD️ [ProductPage] Component rendered with:",{product:!!t,error:s,productId:null==t?void 0:t.id}),console.log("\uD83D\uDECD️ [ProductPage] DEPLOYMENT TIMESTAMP:",new Date().toISOString()),console.log("\uD83D\uDECD️ [ProductPage] VERSION: 2024-01-15-NAVIGATION-FIX"),(0,a.jsxs)(a.Fragment,{children:[(()=>{var e,r,n,i,o,c,d,m,x,u,p,h,g,v,f,b,y,j,w,N,_,F,k,A,S,E,C;return s?(0,a.jsxs)(l(),{children:[(0,a.jsx)("title",{children:"Product Not Found - شاهين"}),(0,a.jsx)("meta",{name:"description",content:"Product not found"})]}):t?(0,a.jsxs)(l(),{children:[(0,a.jsx)("title",{children:"".concat(t.name," من ").concat((null==(e=t.vendors)?void 0:e.vendor_name)||(null==(r=t.vendor_profiles)?void 0:r.vendor_name)||"متجر"," على شاهين")}),(0,a.jsx)("meta",{name:"description",content:"تسوق ".concat(t.name," من ").concat((null==(n=t.vendors)?void 0:n.vendor_name)||(null==(i=t.vendor_profiles)?void 0:i.vendor_name)," على شاهين بسعر ").concat(t.base_price," ").concat(t.currency||"SYP"," - ").concat(t.description||"اكتشف منتجات مميزة",".")}),(0,a.jsx)("link",{rel:"icon",type:"image/png",href:"/lovable-uploads/icon.png"}),(0,a.jsx)("link",{rel:"apple-touch-icon",href:"/lovable-uploads/icon.png"}),(0,a.jsx)("meta",{property:"og:type",content:"product"}),(0,a.jsx)("meta",{property:"og:title",content:"".concat(t.name," من ").concat((null==(o=t.vendors)?void 0:o.vendor_name)||(null==(c=t.vendor_profiles)?void 0:c.vendor_name)||"متجر"," على شاهين")}),(0,a.jsx)("meta",{property:"og:description",content:"تسوق ".concat(t.name," من ").concat((null==(d=t.vendors)?void 0:d.vendor_name)||(null==(m=t.vendor_profiles)?void 0:m.vendor_name)," على شاهين بسعر ").concat(t.base_price," ").concat(t.currency||"SYP"," - ").concat(t.description||"اكتشف منتجات مميزة",".")}),(0,a.jsx)("meta",{property:"og:url",content:"https://shahiin.com/product/".concat(t.id)}),(0,a.jsx)("meta",{property:"og:site_name",content:"شاهين"}),(0,a.jsx)("meta",{property:"og:locale",content:"ar_SA"}),(0,a.jsx)("meta",{property:"og:image",content:t.product_images&&t.product_images.length>0?t.product_images[0].image_url:(null==(x=t.vendors)?void 0:x.brand_logo_url)||(null==(u=t.vendor_profiles)?void 0:u.brand_logo_url)||"https://shahiin.com/lovable-uploads/icon.png"}),(0,a.jsx)("meta",{property:"og:image:alt",content:"".concat(t.name," من ").concat((null==(p=t.vendors)?void 0:p.vendor_name)||(null==(h=t.vendor_profiles)?void 0:h.vendor_name)||"متجر"," على شاهين")}
1),(0,a.jsx)("meta",{property:"og:image:width",content:"1200"}),(0,a.jsx)("meta",{property:"og:image:height",content:"630"}),(0,a.jsx)("meta",{property:"og:image:type",content:"image/jpeg"}),(0,a.jsx)("meta",{property:"og:image:secure_url",content:t.product_images&&t.product_images.length>0?t.product_images[0].image_url:(null==(g=t.vendors)?void 0:g.brand_logo_url)||(null==(v=t.vendor_profiles)?void 0:v.brand_logo_url)||"https://shahiin.com/lovable-uploads/icon.png"}),(0,a.jsx)("meta",{property:"product:price:amount",content:(null==(f=t.base_price)?void 0:f.toString())||""}),(0,a.jsx)("meta",{property:"product:price:currency",content:t.currency||"SYP"}),(0,a.jsx)("meta",{property:"product:availability",content:(t.stock_count||0)>0?"متوفر":"غير متوفر"}),((null==(b=t.vendors)?void 0:b.vendor_name)||(null==(y=t.vendor_profiles)?void 0:y.vendor_name))&&(0,a.jsx)("meta",{property:"product:brand",content:(null==(j=t.vendors)?void 0:j.vendor_name)||(null==(w=t.vendor_profiles)?void 0:w.vendor_name)}),(0,a.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),(0,a.jsx)("meta",{name:"twitter:title",content:"".concat(t.name," من ").concat((null==(N=t.vendors)?void 0:N.vendor_name)||(null==(_=t.vendor_profiles)?void 0:_.vendor_name)||"متجر"," على شاهين")}),(0,a.jsx)("meta",{name:"twitter:description",content:"تسوق ".concat(t.name," من ").concat((null==(F=t.vendors)?void 0:F.vendor_name)||(null==(k=t.vendor_profiles)?void 0:k.vendor_name)," على شاهين بسعر ").concat(t.base_price," ").concat(t.currency||"SYP"," - ").concat(t.description||"اكتشف منتجات مميزة",".")}),(0,a.jsx)("meta",{name:"twitter:site",content:"@shaheenapp"}),(0,a.jsx)("meta",{name:"twitter:creator",content:"@shaheenapp"}),(0,a.jsx)("meta",{name:"twitter:image",content:t.product_images&&t.product_images.length>0?t.product_images[0].image_url:(null==(A=t.vendors)?void 0:A.brand_logo_url)||(null==(S=t.vendor_profiles)?void 0:S.brand_logo_url)||"https://shahiin.com/lovable-uploads/icon.png"}),(0,a.jsx)("meta",{name:"twitter:image:alt",content:"".concat(t.name," من ").concat((null==(E=t.vendors)?void 0:E.vendor_name)||(null==(C=t.vendor_profiles)?void 0:C.vendor_name)||"متجر"," على شاهين")}),(0,a.jsx)("link",{rel:"canonical",href:"https://shahiin.com/product/".concat(t.id)})]}):(0,a.jsxs)(l(),{children:[(0,a.jsx)("title",{children:"Product - شاهين"}),(0,a.jsx)("meta",{name:"description",content:"Product details on شاهين"})]})})(),(0,a.jsx)(V.y,{}),(0,a.jsx)(N.e,{children:s?(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)("h1",{className:"text-2xl font-bold mb-4",children:"Product Not Found"}),(0,a.jsx)("p",{className:"text-gray-600",children:s})]})}):(0,a.jsx)(Q,{productId:null==t?void 0:t.id,initialProduct:t})})]})}},28430:(e,t,s)=>{"use strict";s.d(t,{a:()=>r});var a=s(14232);function r(){let[e,t]=a.useState(void 0);return a.useEffect(()=>{{t(window.matchMedia("(max-width: 768px)").matches);let e=window.matchMedia("(max-width: 768px)"),s=()=>{t(e.matches)};return e.addEventListener("change",s),()=>{e.removeEventListener("change",s)}}},[]),!!e}},30822:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(11713).A)("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]])},36074:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/product/[id]",function(){return s(27854)}])},40053:(e,t,s)=>{"use strict";s.d(t,{J:()=>c});var a=s(37876),r=s(14232),l=s(59773),n=s(47137),i=s(65870);let o=(0,n.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),c=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(l.b,{ref:t,className:(0,i.cn)(o(),s),...r})});c.displayName=l.b.displayName},48085:(e,t,s)=>{"use strict";s.d(t,{y:()=>i});var a=s(37876),r=s(14232),l=s(89099),n=s(28430);let i=()=>{let e=(0,l.useRouter)(),{isMobile:t,isInApp:s}=(()=>{let e=(0,n.a)(),[t,s]=(0,r.useState)({isIOS:!1,isAndroid:!1,isInApp:!1,isInstallable:!1,canInstall:!1});return(0,r.useEffect)(()=>{let e=navigator.userAgent||navigator.vendor||"",t=!!(/shahiin/i.test(e)||/wv\)|.+(chrome).+mobile/i.test(e)&&!/chrome/i.test(e)||window.navigator.standalone||window.matchMedia("(display-mode: standalone)").matches),a=/iPad|iPhone|iPod/.test(e)&&!window.MSStream,r=/Android/.test(e),l=!1,n=!1,i=e=>{e.preventDefault(),l=!0,n=!0,s(e=>({...e,isInstallable:!0,canInstall:!0}))};
1return window.addEventListener("beforeinstallprompt",i),s({isIOS:a,isAndroid:r,isInApp:t,isInstallable:l,canInstall:n}),()=>{window.removeEventListener("beforeinstallprompt",i)}},[]),{isMobile:e,...t}})(),[i,o]=(0,r.useState)(!1);return((0,r.useEffect)(()=>{t&&!s&&o(!0)},[t,s]),!t||s||"/download-app"===e.pathname)?null:(0,a.jsxs)("button",{type:"button",onClick:()=>{e.push("/download-app")},className:"fixed z-[99999] flex items-center gap-2 rounded-full bg-marketplace-primary hover:bg-marketplace-primary/90 text-primary-foreground shadow-lg border-0 p-2 pr-3 transition-all duration-200 hover:scale-105 active:scale-95 ".concat(i?"opacity-100":"opacity-0 pointer-events-none"),style:{bottom:"calc(1rem + env(safe-area-inset-bottom))",left:"1rem"},"aria-label":"حمّل تطبيق شاهين",children:[(0,a.jsx)("img",{src:"/lovable-uploads/icon.png",alt:"شاهين",className:"h-10 w-10 rounded-full object-cover shadow-sm ring-2 ring-white/30"}),(0,a.jsx)("span",{className:"text-sm font-semibold text-white whitespace-nowrap",children:"حمّل التطبيق"})]})}},59773:(e,t,s)=>{"use strict";s.d(t,{b:()=>i});var a=s(14232),r=s(66326),l=s(37876),n=a.forwardRef((e,t)=>(0,l.jsx)(r.sG.label,{...e,ref:t,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));n.displayName="Label";var i=n},64589:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(11713).A)("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]])},65290:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(11713).A)("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]])},66326:(e,t,s)=>{"use strict";s.d(t,{hO:()=>o,sG:()=>i});var a=s(14232),r=s(98477),l=s(82987),n=s(37876),i=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((e,t)=>{let s=a.forwardRef((e,s)=>{let{asChild:a,...r}=e,i=a?l.DX:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,n.jsx)(i,{...r,ref:s})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function o(e,t){e&&r.flushSync(()=>e.dispatchEvent(t))}},70672:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(11713).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},96108:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(11713).A)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},97753:(e,t,s)=>{"use strict";s.d(t,{GW:()=>o,QM:()=>r,Wl:()=>i,Ww:()=>l,w4:()=>n});var a=s(12849);let r=async(e,t,s)=>{try{let r=Date.now(),l=e.name.replace(/[^a-zA-Z0-9.\-_]/g,"_").toLowerCase(),n="".concat(s).concat(r,"_").concat(l),{data:i,error:o}=await a.supabase.storage.from(t).upload(n,e,{cacheControl:"3600",upsert:!1});if(o)throw console.error("Upload error:",o),Error(o.message);let{data:c}=a.supabase.storage.from(t).getPublicUrl(n);return c.publicUrl}catch(e){throw console.error("File upload failed:",e),e}},l=async(e,t)=>{try{let s=e.split("/storage/v1/object/public/".concat(t,"/"));if(s.length<2)throw Error("Invalid file URL");let r=s[1],{error:l}=await a.supabase.storage.from(t).remove([r]);if(l)throw console.error("Delete error:",l),Error(l.message)}catch(e){throw console.error("File deletion failed:",e),e}},n=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6;return new Promise((s,a)=>{let r=new FileReader;r.onload=r=>{var l;let n=new Image;n.onload=()=>{let r=document.createElement("canvas"),l=n.width,i=n.height;l>i&&l>2e3?(i=2e3*i/l,l=2e3):i>2e3&&(l=2e3*l/i,i=2e3),r.width=l,r.height=i;let o=r.getContext("2d");if(!o)return void a(Error("Failed to get canvas context"));o.drawImage(n,0,0,l,i);let c=.9,d=()=>{r.toBlob(r=>{if(!r)return void a(Error("Failed to compress image"));r.size/1048576<=t||c<=.5?s(new File([r],e.name,{type:"image/jpeg",lastModified:Date.now()})):(c-=.1,d())},"image/jpeg",c)};d()},n.onerror=()=>a(Error("Failed to load image")),n.src=null==(l=r.target)?void 0:l.result},r.onerror=()=>
1a(Error("Failed to read file")),r.readAsDataURL(e)})},i=e=>{if(!["image/jpeg","image/jpg","image/png","image/webp"].includes(e.type))throw Error("Invalid file type. Please upload JPG, PNG, or WebP images.");if(e.size/1048576>10)throw Error("File too large. Maximum size is ".concat(10,"MB."));return!0},o=e=>{if(!["video/mp4","video/webm","video/quicktime"].includes(e.type))throw Error("Invalid file type. Please upload MP4, WebM, or MOV videos.");if(e.size/1048576>100)throw Error("File too large. Maximum size is ".concat(100,"MB."));return!0}}},e=>{e.O(0,[1987,633,3595,1196,1786,9341,3909,5682,970,2388,8004,636,6593,8792],()=>e(e.s=36074)),_N_E=e.O()}]);

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.