1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[640],{8471:(e,l,t)=>{"use strict";t.r(l),t.d(l,{__N_SSP:()=>eb,default:()=>ey});var n=t(37876),s=t(46572),i=t(14232),a=t(96715),d=t(24719),r=t(89902),o=t(37006),u=t(37427),c=t(89130),m=t(61825),x=t(90974);function v(e){let{language:l,bundleProducts:t,setBundleProducts:s,product:i,product:{product_name:a,product_image:d,product_price:r,sku:o}}=e,u=(null==t?void 0:t.find(e=>e.sku==o))!=void 0;return(0,n.jsxs)("div",{className:"relative flex items-center gap-4 border min-w-36 sm:min-w-48",children:[(0,n.jsx)("span",{className:"z-30 size-5 rounded-sm absolute top-2 ".concat("en"===l?"left-2":"right-2"," bg-red-600 text-white flex items-center justify-center cursor-pointer max-sm:size-[12px]"),onClick:()=>u?void s(e=>e.filter(e=>e.sku!=o)):void s(e=>[...e,i]),children:u&&(0,n.jsx)(m.A,{className:"size-3 max-sm:size-[10px]"})}),(0,n.jsxs)("div",{className:"relative w-full p-3 bg-white rounded-md max-sm:text-xs",children:[(0,n.jsx)(c.A,{src:"".concat("https://media.backcomfort.com.sa/media","/catalog/product/").concat(d),alt:a,title:a,className:"object-contain h-40 size-full max-sm:w-[89px] mx-auto max-sm:h-[73px]"}),(0,n.jsx)("p",{className:"sm:text-[15px] my-1 sm:my-2 font-semibold line-clamp-2",children:a}),(0,n.jsxs)("p",{className:"flex items-center gap-1 font-bold text-red-600",children:[r," ",(0,n.jsx)(x.A,{className:"size-3.5"})]})]})]})}var p=t(38490),h=t(96169),g=t(61559),f=t(71114);let j=e=>(0,g.OM)(null==e?void 0:e.bundle_child_default_stock),b=e=>{let l=Number(null==e?void 0:e.quantity);return(null==e?void 0:e.quantity)==null||(null==e?void 0:e.quantity)===""||Number.isNaN(l)?(null==e?void 0:e.is_salable)==null||(0,g.r2)(null==e?void 0:e.is_salable):l>0},y=e=>(0,g.r2)(null==e?void 0:e.can_change_quantity),N=(e,l)=>((null==e?void 0:e.product_links)||[]).filter(e=>l.includes(null==e?void 0:e.id)),_=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return(e||[]).reduce((e,l)=>{let t=(null==l?void 0:l.product_links)||[];return{...e,[null==l?void 0:l.option_id]:{selectionIds:t.filter(e=>(0,g.r2)(null==e?void 0:e.is_default)&&b(e)).map(e=>null==e?void 0:e.id),qty:t.reduce((e,l)=>({...e,[null==l?void 0:l.id]:j(l)}),{})}}},{})},w=(e,l)=>{var t,n;let s=N(e,(null==l?void 0:l.selectionIds)||[]),i=s.find(y);return i?(0,g.OM)(null!=(n=null==l||null==(t=l.qty)?void 0:t[null==i?void 0:i.id])?n:j(i)):j(s.at(0))},k=(e,l)=>((null==e?void 0:e.bundle_product_options)||[]).every(e=>{var t;let n=(null==l||null==(t=l[null==e?void 0:e.option_id])?void 0:t.selectionIds)||[];return!!N(e,n).every(b)&&(!(0,g.r2)(null==e?void 0:e.required)||n.length>0)});var A=t(73464),C=t(38248),z=t(97685);let q=async(e,l,t,n,s,i)=>{var a;let d=null==n?void 0:n.map(e=>e.sku),{data:r,error:o}=await (0,p.k7)(e,l,t,d);if(o)return z.default.error((null==o||null==(a=o.error)?void 0:a.message)||"The product that was requested doesn't exist. Verify the product and try again.");t!==(null==r?void 0:r.quoteId)&&(s({type:"clear"}),(0,C.setCookie)("quote",null==r?void 0:r.quoteId)),null==i||i.dispatch({type:"cartInfo",productInfo:[],payloadRelatedProducts:[]}),await (0,h.rG)(e,l,(null==r?void 0:r.quoteId)||t,s),(null==r?void 0:r.message)&&z.default.success(null==r?void 0:r.message)},P=async(e,l,t,n)=>{l(!0);let{handshake:s,quote:i,mage:a}=(0,C.getCookies)();if(!i){let{data:i}=await (0,p.zA)(s,a);return(null==i?void 0:i.cart_id)?((0,C.setCookie)("quote",null==i?void 0:i.cart_id),await q(s,a,null==i?void 0:i.cart_id,e,t,n)):z.default.error("Could not start a cart. Please try again."),l(!1)}return await q(s,a,i,e,t,n),l(!1)},S=async(e,l,t,n,s,i)=>{var a,d;let{data:r,error:o}=await (0,p.lu)(e,l,t,n);if(o)return z.default.error((null==o||null==(a=o.error)?void 0:a.message)||"The product that was requested doesn't exist. Verify the product and try again.");t!==(null==r?void 0:r.quoteId)&&(s({type:"clear"}),(0,C.setCookie)("quote",null==r?void 0:r.quoteId));let u=(null==r?void 0:r.quoteId)||t,c=await (0,p.Xl)(e,l,u);null==i||i.dispatch({type:"cartInfo",productInfo:[],payloadRelatedProducts:[]}),(0,h.A6)(null==c||null==(d=c.data)?void 0:d.data,s),(null==r?void 0:r.message)&&z.default.success(null==r?void 0:r.message)},I=async(e,l,t,n,s,i)=>{let a=(0,A.Nv)(e,l);if(0===a.length)return z.default.error("ar"===i?"اختر Ù
ÙØªØ¬Ùا ÙØ§ØØ¯Ùا عÙÙ Ø§ÙØ£ÙÙ":"Please select at least one product");t(!0);let{handshake:d,quote:r,mage:o}=(0,C.getCookies)();if(!r){let{data:e}=await (0,p.zA)(d,o);
1return(null==e?void 0:e.cart_id)?((0,C.setCookie)("quote",null==e?void 0:e.cart_id),await S(d,o,null==e?void 0:e.cart_id,a,n,s)):z.default.error("Could not start a cart. Please try again."),t(!1)}return await S(d,o,r,a,n,s),t(!1)},R=async(e,l,t,n,s,i,a)=>{var d,r;let{data:o,error:u}=await (0,p.QJ)(e,l,t,n,1,s);if(u)return z.default.error((null==u||null==(d=u.error)?void 0:d.message)||"The product that was requested doesn't exist. Verify the product and try again.");t!==(null==o?void 0:o.quoteId)&&(i({type:"clear"}),(0,C.setCookie)("quote",null==o?void 0:o.quoteId));let c=(null==o?void 0:o.quoteId)||t,m=await (0,p.Xl)(e,l,c);null==a||a.dispatch({type:"cartInfo",productInfo:[],payloadRelatedProducts:[]}),(0,h.A6)(null==m||null==(r=m.data)?void 0:r.data,i),(null==o?void 0:o.message)&&z.default.success(null==o?void 0:o.message)},B=async(e,l,t,n,s,i)=>{if(!k(e,l))return z.default.error("ar"===i?"ÙØ±Ø¬Ù Ø§Ø®ØªÙØ§Ø± جÙ
ÙØ¹ Ø§ÙØ®Ùارات اÙÙ
Ø·ÙÙØ¨Ø©":"Please select all required options");let a=(0,g.DR)(null==e?void 0:e.sku),d=((e,l)=>((null==e?void 0:e.bundle_product_options)||[]).map(e=>{let t=null==l?void 0:l[null==e?void 0:e.option_id],n=(null==t?void 0:t.selectionIds)||[];return 0===n.length?null:{option_id:null==e?void 0:e.option_id,option_qty:w(e,t),option_selections:n}}).filter(Boolean))(e,l);t(!0);let{handshake:r,quote:o,mage:u}=(0,C.getCookies)();if(!o){let{data:e}=await (0,p.zA)(r,u);return(null==e?void 0:e.cart_id)?((0,C.setCookie)("quote",null==e?void 0:e.cart_id),await R(r,u,null==e?void 0:e.cart_id,a,d,n,s)):z.default.error("Could not start a cart. Please try again."),t(!1)}return await R(r,u,o,a,d,n,s),t(!1)};t(88220).Buffer;var O=t(99842),M=t(66342);let T=e=>{let{t:l,language:t,bundle:s}=e,{date_from:a,date_to:d,child_details:r}=s,[o,c]=(0,i.useState)(r&&Array.isArray(r)?r:[]),[m,p]=(0,i.useState)(!1),{dispatch:h}=(0,u._)(),g=(0,i.useContext)(O.ModalContext);async function f(){await P(o,p,h,g)}return function(e,l){let t=new Date,n=new Date(e),s=new Date(l);return t>n&&t<s}(a,d)&&(0,n.jsxs)("div",{className:"p-3 border rounded-md bg-zinc-100",children:[(0,n.jsx)("h3",{className:"mb-2 text-sm font-bold sm:text-lg",children:l("It is also sold with it")}),(0,n.jsx)("div",{className:"flex items-center gap-4 overflow-auto",children:null==r?void 0:r.map((e,s)=>(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)(v,{product:e,t:l,setBundleProducts:c,bundleProducts:o,language:t}),s!==(null==r?void 0:r.length)-1&&(0,n.jsxs)("span",{className:"flex items-center justify-center border border-red-600 rounded-md ms-2 size-4 sm:size-6",children:[(0,n.jsx)(M.A,{className:"text-red-600 size-2"})," "]})]},e.sku))}),(null==o?void 0:o.length)>0?(0,n.jsx)("button",{disabled:(null==o?void 0:o.length)==0,className:"bg-red-600 text-white w-full font-semibold p-1.5 sm:p-2 mt-3 max-sm:text-xs rounded-md",onClick:()=>f(),children:m?l("Buying..."):(0,n.jsxs)("span",{className:"flex flex-wrap items-center gap-1",children:[(0,n.jsx)("span",{children:l("Buy all")})," ",(0,n.jsx)("span",{children:null==o?void 0:o.length})," ",(0,n.jsx)("span",{children:l("products at a price of")}),(0,n.jsx)("span",{children:null==o?void 0:o.reduce((e,l)=>e+ +(null==l?void 0:l.product_price),0)}),(0,n.jsx)(x.A,{className:"size-3.5"})]})}):null]})};var D=t(42656),E=t(32304),F=t(24301),Q=t(28408),L=t(89099),U=t(92808),V=t(99329);function X(e){var l,t;let{availableStores:a}=e,[d,r]=(0,i.useState)(null),{t:o}=(0,s.Bd)(["product"]),u=null==a?void 0:a.map(e=>{var l,t;return{value:e,label:(0,n.jsx)("div",{className:"flex items-center justify-between",children:(0,n.jsxs)("p",{children:[null==e||null==(l=e.location)?void 0:l.name," - ",null==e||null==(t=e.location)?void 0:t.address]})})}});return(null==a?void 0:a.length)>0&&(0,n.jsxs)("div",{className:"p-4 space-y-2 border rounded-md border-primary",children:[(0,n.jsx)("h2",{className:"max-sm:text-sm",children:o("Show available stores")}),(0,n.jsx)(V.Ay,{placeholder:o("Show available stores"),options:u,onChange:e=>r(e.value),className:"max-sm:text-sm"}),d&&(0,n.jsxs)("div",{className:"p-2 border-gray-300 border-1 max-sm:text-sm",children:[(0,n.jsxs)("p",{children:[o("branchName")," : ",null==d||null==(l=d.location)?void 0:l.name]}),(0,n.jsxs)("p",{children:[o("Address")," : ",null==d||null==(t=d.location)?void 0:t.address]})]})]})}var G=t(84821),H=t(42518),J=t(69100),W=t(79489);let Z=e=>{let{prices:l}=e,t=(0,J.cp)(l);return(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1 font-bold text-red-600",children:[(0,W.g)((null==t?void 0:t.specialPrice)||(null==t?void 0:t.originalPrice)),(0,n.jsx)(x.A,{className:"size-3"})]}),(null==t?void 0:t.specialPrice)?(0,n.jsxs)("span",{className:"flex items-center gap-1 text-xs line-through text-zinc-400",children:[(0,W.g)(null==t?void 0:t.originalPrice),(0,n.jsx)(x.A,{className:"size-2.5"})]}):null]})},K=e=>{let{t:l,product:t,quantities:s,onChangeQty:i}=e,a=(null==t?void 0:t.grouped_products)||[];if(0===a.length)return null;let d=a.reduce((e,l)=>{var t,n;return(0,A.lv)(l)?e+(null!=(n=null==s?void 0:s[(0,g.DR)(null==l?void 0:l.sku)])?n:0)*(Number(null==l||null==(t=l.prices_with_tax)?void 0:t.final_price)||0):e},0);return(0,n.jsx)("div",{className:"overflow-hidden border rounded-md",children:(0,n.jsxs)("table",{className:"w-full text-sm",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{className:"bg-zinc-50 text-zinc-500",children:[(0,n.jsx)("th",{className:"px-3 py-2 font-bold text-start",children:l("Product")}),(0,n.jsx)("th",{className:"px-3 py-2 font-bold text-start",children:l("Price")}),(0,n.jsx)("th",{className:"px-3 py-2 font-bold text-end",children:l("Quantity")})]})}),(0,n.jsx)("tbody",{className:"divide-y",children:a.map(e=>{var t;let a=(0,A.lv)(e),d=(0,g.DR)(null==e?void 0:e.sku);return(0,n.jsxs)("tr",{className:a?"":"opacity-60",children:[(0,n.jsx)("td",{className:"px-3 py-3",children:(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)(c.A,{src:(e=>{if(e){if(!Array.isArray(e)&&Array.isArray(null==e?void 0:e.image)){var l,t;return null==(t=e.image)||null==(l=t.at(0))?void 0:l.image}if(Array.isArray(e)&&e.length){let l=e.at(0);return"string"==typeof l?l:(null==l?void 0:l.image)||(null==l?void 0:l.url)}}})(null==e?void 0:e._media_),alt:(null==e?void 0:e.name)||"",width:48,height:48,className:"object-contain rounded-sm size-12 shrink-0 bg-zinc-50"}),(0,n.jsx)("span",{className:"font-semibold",children:null==e?void 0:e.name})]})}),(0,n.jsx)("td",{className:"px-3 py-3",children:a?(0,n.jsx)(Z,{prices:null==e?void 0:e.prices_with_tax}):(0,n.jsx)("span",{className:"text-xs font-semibold text-red-600",children:l("Out of stock")})}),(0,n.jsx)("td",{className:"px-3 py-3 text-end",children:(0,n.jsx)("input",{type:"number",min:0,inputMode:"numeric",disabled:!a,value:null!=(t=null==s?void 0:s[d])?t:0,onChange:e=>i(d,(0,g.WG)(e.target.value)),"aria-label":"".concat(l("Quantity")," ").concat((null==e?void 0:e.name)||""),className:"h-9 px-2 text-center border rounded-md w-14 disabled:opacity-40 disabled:cursor-not-allowed"})})]},d)})}),(0,n.jsx)("tfoot",{children:(0,n.jsxs)("tr",{className:"font-bold bg-zinc-50",children:[(0,n.jsx)("td",{className:"px-3 py-3",colSpan:2,children:l("Subtotal")}),(0,n.jsx)("td",{className:"px-3 py-3 text-end",children:(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 text-lg text-red-600",children:[(0,W.g)(d),(0,n.jsx)(x.A,{className:"size-3.5"})]})})]})})]})})},Y=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return[...e].sort((e,l)=>Number((null==e?void 0:e.position)||0)-Number((null==l?void 0:l.position)||0))},$=e=>{let{prices:l}=e,t=(0,J.cp)(l);return(0,n.jsxs)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,n.jsxs)("span",{className:"flex items-center gap-1 font-bold text-red-600",children:[(0,W.g)((null==t?void 0:t.specialPrice)||(null==t?void 0:t.originalPrice)),(0,n.jsx)(x.A,{className:"size-3"})]}),(null==t?void 0:t.specialPrice)?(0,n.jsxs)("span",{className:"flex items-center gap-1 text-xs line-through text-zinc-400",children:[(0,W.g)(null==t?void 0:t.originalPrice),(0,n.jsx)(x.A,{className:"size-2.5"})]}):null]})},ee=e=>{let{t:l,isMulti:t,link:s,checked:i,name:a,onSelect:d,onToggle:r}=e,o=(0,g.r2)(null==s?void 0:s.can_change_quantity),u=j(s),m=b(s);return(0,n.jsxs)("div",{className:"flex items-center gap-3 p-3 border rounded-md transition-colors ".concat(i?"border-red-600 bg-red-50":"border-zinc-200 hover:border-zinc-300"," ").concat(m?"":"op
1acity-50"),children:[(0,n.jsxs)("label",{className:"flex items-center flex-1 min-w-0 gap-3 ".concat(m?"cursor-pointer":"cursor-not-allowed"),children:[(0,n.jsx)("input",{type:t?"checkbox":"radio",name:a,checked:i,disabled:!m&&!i,onChange:()=>t?r(null==s?void 0:s.id):d(null==s?void 0:s.id),className:"accent-red-600 size-4 shrink-0"}),(0,n.jsx)(c.A,{src:(e=>{var l,t;if(e){if(!Array.isArray(e)&&Array.isArray(null==e?void 0:e.image))return null==(t=e.image)||null==(l=t.at(0))?void 0:l.image;if(Array.isArray(e)&&e.length){let l=e.at(0);return"string"==typeof l?l:(null==l?void 0:l.image)||(null==l?void 0:l.url)}}})(null==s?void 0:s._media_),alt:(null==s?void 0:s.name)||"",width:48,height:48,className:"object-contain rounded-sm size-12 shrink-0 bg-zinc-50"}),(0,n.jsxs)("span",{className:"flex-1 min-w-0",children:[(0,n.jsx)("span",{className:"block font-semibold truncate",children:null==s?void 0:s.name}),(0,n.jsx)($,{prices:null==s?void 0:s.prices_with_tax}),m?null:(0,n.jsx)("span",{className:"block text-xs font-semibold text-red-600",children:l("Out of stock")})]})]}),i&&!o?(0,n.jsxs)("span",{className:"text-sm shrink-0 text-zinc-500",children:[l("Quantity"),": ",u]}):null]})},el=e=>{let{t:l,option:t,parentBase:s,selectionIds:i,onSelect:a}=e;return(0,n.jsxs)("select",{value:(null==i?void 0:i[0])||"",onChange:e=>a(e.target.value),className:"w-full h-11 px-3 bg-white border rounded-md",children:[(0,n.jsx)("option",{value:"",children:l("Choose an option")}),Y(null==t?void 0:t.product_links).map(e=>(0,n.jsx)("option",{value:null==e?void 0:e.id,disabled:!b(e),children:b(e)?"".concat(null==e?void 0:e.name," (+").concat((0,W.g)((0,f.e)(e,s)),")"):"".concat(null==e?void 0:e.name," (").concat(l("Out of stock"),")")},null==e?void 0:e.id))]})},et=e=>{var l,t;let{t:s,option:i,parentBase:a,selection:d,onSelectSingle:r,onToggleMulti:o,onChangeQty:u}=e,c=null==i?void 0:i.type,m="checkbox"===c||"multi"===c,x=(0,g.r2)(null==i?void 0:i.required),v=(null==d?void 0:d.selectionIds)||[],p=x&&0===v.length,h="bundle-option-".concat(null==i?void 0:i.option_id),f=((e,l)=>N(e,(null==l?void 0:l.selectionIds)||[]).some(y))(i,d),j=w(i,d),b=((null==i?void 0:i.product_links)||[]).find(e=>v.includes(null==e?void 0:e.id)&&(0,g.r2)(null==e?void 0:e.can_change_quantity)),_=null!=(t=null==d||null==(l=d.qty)?void 0:l[null==b?void 0:b.id])?t:j;return(0,n.jsxs)("fieldset",{children:[(0,n.jsxs)("legend",{className:"flex items-center gap-2 mb-2 font-bold",children:[null==i?void 0:i.title,(0,n.jsx)("span",{className:"text-xs font-semibold ".concat(x?"text-red-600":"text-zinc-400"),children:x?s("Required"):s("Optional")})]}),"select"===c?(0,n.jsx)(el,{t:s,option:i,parentBase:a,selectionIds:v,onSelect:e=>r(null==i?void 0:i.option_id,e)}):(0,n.jsx)("div",{className:"grid gap-2",children:Y(null==i?void 0:i.product_links).map(e=>(0,n.jsx)(ee,{t:s,isMulti:m,link:e,name:h,checked:v.includes(null==e?void 0:e.id),onSelect:e=>r(null==i?void 0:i.option_id,e),onToggle:e=>o(null==i?void 0:i.option_id,e)},null==e?void 0:e.id))}),f?(0,n.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,n.jsx)("label",{htmlFor:"".concat(h,"-qty"),className:"text-sm font-semibold",children:s("Quantity")}),(0,n.jsx)("input",{id:"".concat(h,"-qty"),type:"number",min:1,inputMode:"numeric",value:_,onChange:e=>u(null==i?void 0:i.option_id,e.target.value),className:"h-9 px-2 text-center border rounded-md w-14"})]}):null,p?(0,n.jsx)("p",{className:"mt-2 text-xs font-semibold text-red-600",children:s("Select at least one")}):null]})},en=e=>{let{t:l,product:t,selections:s,onSelectSingle:i,onToggleMulti:a,onChangeQty:d}=e,r=(null==t?void 0:t.bundle_product_options)||[];if(0===r.length)return null;let o=(0,f.R)(t),u=((e,l)=>{let t=(0,f.R)(e);return((null==e?void 0:e.bundle_product_options)||[]).reduce((e,n)=>e+((e,l)=>{let t=(null==l?void 0:l.selectionIds)||[],n=w(e,l);return N(e,t).map(e=>({link:e,qty:y(e)?n:j(e)}))})(n,null==l?void 0:l[null==n?void 0:n.option_id]).reduce((e,l)=>{let{link:n,qty:s}=l;return e+(0,f.e)(n,t)*s},0),0)})(t,s),c=k(t,s);return(0,n.jsxs)("div",{className:"space-y-5",children:[(0,n.jsx)("h2",{className:"font-bold sm:text-lg",children:l("Options")}),Y(r).map(e=>(0,n.jsx)(et,{t:l,option:e,parentBase:o,selection:null==s?void 0:s[null==e?void 0:e.option_id],onSelectSingle:i,onToggleMulti:a,onChangeQty:d},null==e?void 0:e.option_id)),(0,n.jsxs)("div",{className:"flex items-center justify-between p-4 border rounded-md bg-zinc-50",children:[(0,n.jsx)("span",{className:"font-bold",children:l("Total")}),(0,n.jsxs)("span",{className:"inline-flex items-center gap-1 text-xl font-extrabold text-red-600",children:[(0,W.g)(u),(0,n.jsx)(x.A,{className:"size-4"})]})]}),c?null:(0,n.jsx)("p",{className:"text-sm font-semibold text-red-600",children:l("Select all required options")})]})},es=e=>{var l,t,s,a,d,r,c,m;let{t:x,language:v,product:p,availableStores:h,productReviews:g,onChangeConfigurableProduct:f}=e,[j,b]=(0,i.useState)(1),{push:y}=(0,L.useRouter)(),[N,w]=(0,i.useState)(!1),{dispatch:C}=(0,u._)(),z=(0,i.useContext)(O.ModalContext),q=(null==p?void 0:p.type_id)==="grouped",P=(null==p?void 0:p.type_id)==="bundle",S=Array.isArray(null==p?void 0:p.sku)?null==p||null==(l=p.sku)?void 0:l.at(0):null==p?void 0:p.sku,[R,M]=(0,i.useState)(()=>(0,A.sU)(null==p?void 0:p.grouped_products)),[V,J]=(0,i.useState)(()=>_(null==p?void 0:p.bundle_product_options));(0,i.useEffect)(()=>{M((0,A.sU)(null==p?void 0:p.grouped_products)),J(_(null==p?void 0:p.bundle_product_options))},[S]);let W=(0,i.useCallback)((e,l)=>{M(t=>({...t,[e]:l}))},[]),Z=(0,i.useCallback)((e,l)=>{J(t=>({...t,[e]:{...null==t?void 0:t[e],selectionIds:l?[l]:[]}}))},[]),Y=(0,i.useCallback)((e,l)=>{J(t=>{var n;let s=(null==t||null==(n=t[e])?void 0:n.selectionIds)||[],i=s.includes(l)?s.filter(e=>e!==l):[...s,l];return{...t,[e]:{...null==t?void 0:t[e],selectionIds:i}}})},[]),$=(0,i.useCallback)((e,l)=>{J(t=>{let n=null==t?void 0:t[e];if(!n)return t;let s=Object.keys((null==n?void 0:n.qty)||{}).reduce((e,t)=>
1({...e,[t]:l}),{});return{...t,[e]:{...n,qty:s}}})},[]),ee=q&&(0,A.RB)(p,R),el=P&&k(p,V),et=async e=>{var l,t,n;return q?void await I(p,R,w,C,z,v):P?void await B(p,V,w,C,z,v):(w(!0),void((null==p||null==(l=p.stock)?void 0:l.qty)>0&&(null==p||null==(t=p.stock)?void 0:t.is_in_stock)&&await (0,U.Q)(x,p,j,w,C,(null==p||null==(n=p._configurables)?void 0:n.length)>0?null==p?void 0:p.current_option:null,z,[],e,y),w(!1)))},es=(null==g?void 0:g.length)?((null==g?void 0:g.map(e=>{var l,t;return(null==e||null==(t=e.ratings)||null==(l=t[0])?void 0:l.value)||5}).reduce((e,l)=>e+l))/(null==g?void 0:g.length)).toFixed(2):0;return(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"*:mb-4 max-sm:*:mb-3",children:[(0,n.jsx)("h1",{className:"sm:text-lg font-[700] text-justify md:text-xl ",children:(null==p?void 0:p.name)||""}),(0,n.jsx)(o.A,{sku:(null==p?void 0:p.viewedSku)||(null==p?void 0:p.sku)}),(0,n.jsx)(F.A,{reviews_count:Math.floor(es)}),!q&&!P&&(0,n.jsx)(D.A,{prices:null==p?void 0:p.prices_with_tax,price:null==p||null==(t=p.price)?void 0:t.at(0),productType:null==p?void 0:p.type_id}),P&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(en,{t:x,product:p,selections:V,onSelectSingle:Z,onToggleMulti:Y,onChangeQty:$}),(0,n.jsx)("button",{type:"button",disabled:N||!el,onClick:()=>et("bundle"),className:"w-full h-11 p-2 text-sm font-bold text-white bg-black rounded-md disabled:opacity-40 disabled:cursor-not-allowed max-sm:h-9 max-sm:text-xs",children:N?x("Adding"):x("Add to cart")})]}),q&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(K,{t:x,product:p,quantities:R,onChangeQty:W}),(0,n.jsx)("button",{type:"button",disabled:N||!ee,onClick:()=>et("grouped"),className:"w-full h-11 p-2 text-sm font-bold text-white bg-black rounded-md disabled:opacity-40 disabled:cursor-not-allowed max-sm:h-9 max-sm:text-xs",children:N?x("Adding"):x("Add to cart")})]}),(null==p||null==(s=p.configurable_options)?void 0:s.length)>0&&(0,n.jsx)(H.A,{t:x,product:p,onChangeConfigurableProduct:f}),!!(null==p||null==(a=p.stock)?void 0:a.qty)&&5>=+(null==p||null==(d=p.stock)?void 0:d.qty)&&(0,n.jsxs)("div",{className:"sm:text-lg md:text-xl",children:[x("available"),(0,n.jsx)("span",{className:"mx-1 font-extrabold sm:text-lg md:text-xl",children:null==p||null==(r=p.stock)?void 0:r.qty}),x("only_in_stock")]}),(0,n.jsx)("div",{className:"flex items-center gap-4 mb-10 sm:justify-end sm:gap-5",children:(0,n.jsx)(Q.A,{product:p,fromPDP:!0})}),(0,n.jsx)("div",{className:"hidden max-sm:block",children:(0,n.jsx)(G.A,{product:p,t:x,fromPDP:!0})}),!q&&!P&&(0,n.jsx)(E.A,{product:p,qty:j,setQty:b}),!q&&!P&&(0,n.jsx)("div",{className:"w-full max-sm:-mt-3 col-span-full lg:col-span-4 md:hidden",onClick:()=>et("fast"),children:(0,n.jsx)("button",{disabled:N,className:"w-full h-10 p-2 text-sm font-bold text-white bg-black rounded-md max-sm:text-xs max-sm:h-8 max-sm:p-1",children:"en"===v?"Buy Fast":"شراء Ø³Ø±ÙØ¹"})}),(0,n.jsx)(X,{availableStores:h}),(0,n.jsx)("div",{className:"max-sm:hidden",children:(0,n.jsx)(G.A,{product:p,t:x,fromPDP:!0})}),(null==p||null==(c=p.bundle_discount_products)?void 0:c.length)>0&&(0,n.jsx)(T,{t:x,language:v,parentProduct:p,bundle:(null==p||null==(m
1=p.bundle_discount_products)?void 0:m.at(0))||{}})]})})};var ei=t(65250),ea=t(42344),ed=t(4964);let er=e=>{var l;let{album:t,currentImg:s,setCurrentImg:a,name:d,setZoom:r,language:o}=e;(0,ei.y)();let u=(0,i.useRef)();return(0,ed.A)(u,()=>r(!1)),(0,n.jsxs)("div",{ref:u,className:"relative w-11/12 bg-white rounded-md md:w-1/2",children:[t.length>1&&(0,n.jsx)(ea.A,{onClick:()=>a(s+1),className:"absolute z-30 ".concat("en"===o?"rotate-90":"-rotate-90"," -translate-y-1/2 cursor-pointer md:text-white size-5 max-sm:rounded-full md:size-7 top-1/2 start-1 md:-start-16")}),(0,n.jsx)(c.A,{src:null==(l=t[s%t.length])?void 0:l.image,className:"object-cover w-full h-[65vh] sm:h-[85vh] rounded-t-md",alt:"Album Imgs"}),t.length>1&&(0,n.jsx)(ea.A,{onClick:()=>a(s-1),className:"absolute z-30 ".concat("ar"===o?"rotate-90":"-rotate-90"," -translate-y-1/2 cursor-pointer md:text-white size-5 max-sm:rounded-full md:size-7 top-1/2 end-1 md:-end-16")}),(0,n.jsxs)("div",{className:"flex items-center justify-between gap-5 px-4 py-3",children:[(0,n.jsx)("h2",{className:"text-lg font-bold max-sm:text-sm",children:d||"Unknown"}),(0,n.jsxs)("div",{className:"flex items-center gap-1",children:[(0,n.jsx)("span",{children:s%t.length+1}),(0,n.jsx)("span",{children:" / "}),(0,n.jsx)("span",{children:t.length})]})]})]})};var eo=t(80336),eu=t(90924),ec=t(57018);let em=e=>{let{title:l="",relatedProducts:t}=e,{t:a,i18n:{language:d}}=(0,s.Bd)("product"),[r,o]=(0,i.useState)({});return(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"mx-auto flex items-center justify-between mb-3 sm:mb-4",children:[(0,n.jsx)("div",{className:"flex flex-wrap items-center gap-4",children:(0,n.jsx)("span",{className:"text-lg sm:text-xl font-extrabold",children:a(l||"Related Products")})}),(0,n.jsx)(eu.A,{swiper:r,language:d})]}),(0,n.jsx)("section",{className:"",children:(0,n.jsx)(ec.A,{products:t,set_swiper:o})})]})};var ex=t(52333),ev=t(98791);let ep=async(e,l)=>{let t=Array.isArray(l)?null==l?void 0:l.at(0):l;try{return await (0,ev.A)({method:"get",url:"/product/reviews/".concat(t),headers:{Authorization:"Bearer ".concat(e)}})}catch(e){return e}};var eh=t(48805);let eg=async(e,l,t,n)=>{var s,i,a,d,r,o,u;let c=t.length>0?t:null==(d=await (0,eh.o8)(e,Array.isArray(null==l?void 0:l.sku)?null==l?void 0:l.sku[0]:null==l?void 0:l.sku))||null==(a=d.data)||null==(i=a.data)||null==(s=i.at(0))?void 0:s[n],m=(null==c?void 0:c.length)>0?null==(u=await (0,eh.En)(e,c,!1))||null==(o=u.data)||null==(r=o.data)?void 0:r.products:[];return(null==m?void 0:m.filter(e=>null==e?void 0:e.stock.is_in_stock))||[]};var ef=t(2601);let ej=e=>{var l,t,s;let{t:a,product:d,errorReviews:r,productReviews:o}=e,{locale:u}=(0,L.useRouter)(),c=!!(null==d?void 0:d.short_description),m=(null==d||null==(l=d.product_attributes)?void 0:l.length)>0,x=(null==o?void 0:o.length)>0,[v,p]=(0,i.useState)(c?"detail":m?"specifications":x?"review":""),h=(null==d?void 0:d._configurables)?null==d||null==(s=d._configurables)||null==(t=s.find(e=>(null==e?void 0:e.sku)===(null==d?void 0:d.viewedSku)))?void 0:t.product_attributes:null==d?void 0:d.product_attributes;return(0,n.jsxs)("section",{children:[(0,n.jsxs)("div",{className:"flex items-center overflow-auto",children:[c&&(0,n.jsx)("button",{className:"py-3 max-sm:pe-4 max-sm:text-sm sm:max-w-44 sm:min-w-44 text-start ".concat("detail"===v?"font-extrabold":""),onClick:()=>p("detail"),children:a("Details")}),m&&(0,n.jsx)("button",{className:"py-3 max-sm:pe-4 max-sm:text-sm sm:max-w-44 sm:min-w-44 text-start ".concat("specifications"===v?"font-extrabold":""),onClick:()=>p("specifications"),children:a("Specifications")}),x&&(0,n.jsx)("button",{className:"py-3 max-sm:pe-4 max-sm:text-sm sm:max-w-44 sm:min-w-44 text-start ".concat("review"===v?"font-extrabold":""),onClick:()=>p("review"),children:a("User Reviews")})]}),"specifications"===v&&(()=>{var e;return m?(0,n.jsx)("div",{className:"p-3 bg-zinc-100 max-sm:text-sm",children:null==h||null==(e=h.filter(e=>{var l,t;return(null==e||null==(l=e["en"===u?"1":"2"])?void 0:l.value)&&(null==e||null==(t=e["en"===u?"1":"2"])?void 0:t.value)!=="null"}))?void 0:e.map((e,l)=>{var t,s;let i="en"===u?"1":"2",a=null==e||null==(t=e[i])?void 0:t.label,d=null==e||null==(s=e[i])?void 0:s.value;return d?(0,n.jsxs)("div",{className:"flex gap-1",children:[(0,n.jsxs)("span",{children:[a,":"]}),(0,n.jsx)("span",{children:d})]},l):null})}):(0,n.jsx)("p",{className:"p-3 bg-zinc-100 max-sm:text-sm",children:"ar"===u?"عÙÙØ§Ù ÙØ§ ØªÙØ¬Ø¯ Ù
ÙØ§ØµÙات ÙÙØ°Ø§ اÙÙ
ÙØªØ¬":"There are no specifications for this product"})})(),"detail"===v&&c&&(0,n.jsx)("p",{className:"p-3 bg-zinc-100",dangerouslySetInnerHTML:{__html:(null==d?void 0:d.short_description)||a("There is no description")}}),"review"===v&&(r||!o?null:(0,n.jsx)("div",{className:"grid grid-cols-1 gap-4 p-5 bg-zinc-100 lg:grid-cols-2 max-sm:text-sm",children:null==o?void 0:o.map((e,l)=>{var t,s;return(0,n.jsxs)("div",{className:"flex justify-between gap-5",children:[(0,n.jsxs)("div",{className:"flex flex-col flex-1 max-sm:gap-1",children:[(0,n.jsx)("h4",{className:"font-bold sm:text-lg",children:null==e?void 0:e.nickname}),(0,n.jsx)("p",{className:"text-zinc-500 max-sm:text-xs whitespace-nowrap",children:null==e||null==(s=e.created_at)||null==(t=s.split(" "))?void 0:t[0]})]}),(0,n.jsx)("p",{className:"flex flex-col w-3/4 max-sm:text-xs text-zinc-500",children:(0,n.jsx)("span",{children:null==e?void 0:e.detail})})]},l)})}))]})};var eb=!0;let ey=e=>{var l,t,o,u,c,m,x;let{product:v,availableStores:p}=e,{t:h,i18n:{language:g}}=(0,s.Bd)("product");(0,i.useEffect)(()=>{v&&(0,ef.Fg)(v)},[]);let[f,j]=(0,i.useState)(!1),[b,y]=(0,i.useState)(0),N=(0,C.getCookie)("handshake"),[_,w]=(0,i.useState)([]),{relatedProducts:k,upsellProducts:A}=((e,l,t)=>
1{let[n,s]=(0,i.useState)([]),[a,d]=(0,i.useState)([]);return(0,ex.u)(()=>"related-products-".concat(null==e?void 0:e.sku,"-").concat(t),()=>eg(l,e,null==e?void 0:e.custom_related_products,"related"),{revalidateOnFocus:!1,refreshInterval:18e5,onSuccess:s,onError:e=>console.error("error fetching related products:",e)}),(0,ex.u)(()=>"up-sell-products-".concat(null==e?void 0:e.sku,"-").concat(t),()=>eg(l,e,null==e?void 0:e.up_sell_products,"upsell"),{revalidateOnFocus:!1,refreshInterval:18e5,onSuccess:d,onError:e=>console.error("error fetching up sell products:",e)}),{relatedProducts:n,upsellProducts:a}})(v,N,g);(0,ex.u)(()=>"product-reviews-".concat(null==v?void 0:v.sku,"-").concat(g),async()=>await ep(N,null==v?void 0:v.sku),{revalidateOnFocus:!1,refreshInterval:18e5,onSuccess:e=>{var l;w(null==e||null==(l=e.data)?void 0:l.data)}});let[z,q]=(0,i.useState)(v),P=(null==z||null==(l=z._media_)?void 0:l.image)||[];(0,i.useEffect)(()=>{q(v)},[v]);let S=(0,i.useCallback)(e=>{var l;let t=null==v||null==(l=v._configurables)?void 0:l.find(l=>Object.keys(e).every(t=>{var n,s;return(null==l||null==(n=l.options)?void 0:n[t])===(null==e||null==(s=e[t])?void 0:s.option_value)}));q((0,J.lo)(t,v))},[v]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(a.A,{title:(null==v?void 0:v.name)||"",description:null==v?void 0:v.meta_description,image:null==v||null==(u=v._media_)||null==(o=u.image)||null==(t=o.at(0))?void 0:t.image}),(0,n.jsx)(eo.A,{current:(null==z?void 0:z.name)||("en"===g?"Product Detail":"ØªÙØ§ØµÙ٠اÙÙ ÙØªØ¬"),categoryName:(null==z||null==(m=z.category)||null==(c=m.at(1))?void 0:c.name)||null}),(0,n.jsxs)("section",{className:"subMainSize mx-auto my-4 sm:my-8 sm:*:mb-4 ",children:[(0,n.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[(0,n.jsx)(r.A,{album:P,setZoom:j}),(0,n.jsx)(es,{t:h,language:g,product:z,onChangeConfigurableProduct:S,availableStores:p,productReviews:_})]}),(0,n.jsx)(ej,{product:z,productReviews:_,t:h}),(null==k?void 0:k.length)>0&&(0,n.jsx)(em,{title:"Related Products",relatedProducts:k}),(null==A?void 0:A.length)>0&&(0,n.jsx)(em,{title:"Upsell Products",relatedProducts:A})]}),(0,n.jsx)(d.A,{isCenter:!0,show:f,children:(0,n.jsx)(er,{album:P,currentImg:b,setCurrentImg:y,name:null==v||null==(x=v.name)?void 0:x.at(0),setZoom:j,language:g})})]})}},44604:(e,l,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/product/[rewrite_url]",function(){return t(8471)}])},57018:(e,l,t)=>{"use strict";t.d(l,{A:()=>r});var n=t(37876),s=t(56029),i=t(78579),a=t(89099),d=t(27888);let r=e=>{let{set_swiper:l,products:t}=e,{locale:r}=(0,a.useRouter)(),{screenWidth:o}=(0,i.A)(),u=o<600;return(0,n.jsx)(d.RC,{dir:"en"===r?"ltr":"rtl",onInit:e=>l(e),autoplay:{delay:2500,disableOnInteraction:!1},loop:!0,spaceBetween:u?3:16,slidesPerView:u?2.5:o<=768?3.5:5,className:"h-full w-[".concat(o,"px]"),children:t.map(e=>{var l;return(0,n.jsx)(d.qr,{className:"sm:max-w-[230px]",children:(0,n.jsx)(s.A,{product:e})},"object"==typeof(null==e?void 0:e.sku)?null==e||null==(l=e.sku)?void 0:l.at(0):null==e?void 0:e.sku)})},r)}},61825:(e,l,t)=>{"use strict";t.d(l,{A:()=>s});var n=t(37876);let s=e=>(0,n.jsx)("svg",{width:50,height:36,viewBox:"0 0 50 36",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,n.jsx)("path",{d:"M17.8964 36C16.8959 36 15.9455 35.5982 15.2451 34.895L1.08804 20.6808C-0.362681 19.2243 -0.362681 16.8134 1.08804 15.3568C2.53877 13.9002 4.93997 13.9002 6.39069 15.3568L17.8964 26.909L43.6093 1.09243C45.06 -0.364144 47.4612 -0.364144 48.912 1.09243C50.3627 2.54901 50.3627 4.95989 48.912 6.41646L20.5478 34.895C19.8474 35.5982 18.8969 36 17.8964 36Z",fill:"currentColor"})})}},e=>{e.O(0,[131,329,895,636,593,792],()=>e(e.s=44604)),_N_E=e.O()}]); 2//# sourceMappingURL=[rewrite_url]-b3b6143a823cdc2c.js.map
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.