1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4063],{8172:(e,t,s)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/profile",function(){return s(37970)}])},37970:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>ev,dynamic:()=>ej});var a=s(37876),r=s(68229),l=s(86382),n=s(45770),i=s(35835),c=s(34121),d=s(18076),o=s(14232),x=s(89099),m=s(45682),h=s(68605),u=s(20727),p=s(65682),g=s(47333),j=s(65084),v=s(3909),f=s(77041),b=s(48971),y=s(40053),N=s(74725),w=s(72671),E=s(71416),F=s(10345),A=s(81193),S=s(53656),C=s(96575),B=s(89155),k=s(94108),_=s(48230),T=s.n(_);let q=()=>{var e,t,s;let r=(0,g.A)(),{toast:l}=(0,N.dj)();if(!r)return(0,a.jsxs)("div",{className:"text-center py-16",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-2 border-[#FF9933] border-t-transparent mx-auto mb-4"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Ø¬Ø§Ø±Ù Ø§ÙØªØÙ
ÙÙ..."})]});let{user:n,refreshAuthState:i}=r,[c,d]=(0,o.useState)(!1),[x,m]=(0,o.useState)({name:"",phone:""}),[h,p]=(0,o.useState)(!1),[j,v]=(0,o.useState)(!1),[_,q]=(0,o.useState)(null),[U,J]=(0,o.useState)(!1),[O,W]=(0,o.useState)(!1),[P,R]=(0,o.useState)(!1),[M,Z]=(0,o.useState)(!1),$=async()=>{if(null==n?void 0:n.id)try{let e=await (0,A.f)(n.id);p(e.phoneVerified),v(e.emailVerified),q(e.pendingEmail)}catch(e){p(!1),v(!1),q(null)}};(0,o.useEffect)(()=>{(null==n?void 0:n.id)&&$()},[null==n?void 0:n.id]),(0,o.useEffect)(()=>{n&&m({name:n.name||"",phone:n.phone||""})},[n]);let z=async e=>{if(e.preventDefault(),n){d(!0);try{var t;let e=C.AuthService.getJwt();if(!e)throw Error("No authentication token");let s=null!=(t=n.preferences)?t:{},a=await fetch("".concat((0,k.getEdgeFunctionsUrl)(),"/clients"),{method:"PUT",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e),apikey:(0,k.getSupabaseAnonKey)()},body:JSON.stringify({name:x.name,phone:x.phone,preferences:s})}),r=await a.json().catch(()=>({}));if(!a.ok||!0!==r.success)throw Error(r.error||"Failed to update profile");let c={id:n.id,email:n.email,name:x.name,phone:x.phone,role:n.role||"client",preferences:s,created_at:n.created_at,updated_at:new Date().toISOString()};localStorage.setItem("user_data",JSON.stringify(c)),await i(),l({title:"تÙ
ØÙظ Ø§ÙØªØºÙÙØ±Ø§Øª",description:"تÙ
ØªØØ¯ÙØ« Ù
عÙÙÙ
ات Ù
ÙÙÙ Ø§ÙØ´Ø®ØµÙ Ø¨ÙØ¬Ø§Ø"})}catch(e){console.error("Profile update error:",e),l({title:"خطأ",description:e instanceof Error?e.message:"ØØ¯Ø« خطأ Ø£Ø«ÙØ§Ø¡ ØÙظ Ø§ÙØªØºÙÙØ±Ø§Øª",variant:"destructive"})}finally{d(!1)}}};return n?(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)(u.Zp,{className:"rounded-2xl shadow-lg border-[#
1E5E7EB] overflow-hidden",children:[(0,a.jsx)(u.aR,{className:"pb-2",children:(0,a.jsxs)(u.ZB,{className:"flex items-center gap-3 text-right",children:[(0,a.jsx)("div",{className:"w-12 h-12 rounded-xl bg-[#FFF4EA] flex items-center justify-center",children:(0,a.jsx)(w.A,{className:"h-6 w-6 text-[#FF9933]"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("span",{className:"block",children:"اÙÙ
عÙÙÙ
ات Ø§ÙØ£Ø³Ø§Ø³ÙØ©"}),(0,a.jsx)("p",{className:"text-sm font-normal text-gray-500 mt-0.5",children:"إدارة Ù
عÙÙÙ
ات ØØ³Ø§Ø¨Ù Ø§ÙØ´Ø®ØµÙ"})]})]})}),(0,a.jsx)(u.Wu,{className:"pt-4",children:(0,a.jsxs)("form",{onSubmit:z,className:"space-y-5",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(y.J,{htmlFor:"name",className:"text-right block",children:"Ø§ÙØ§Ø³Ù
اÙÙØ§Ù
Ù"}),(0,a.jsx)(b.p,{id:"name",value:x.name,onChange:e=>m({...x,name:e.target.value}),required:!0,className:"rounded-xl border-[#E5E7EB]"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(y.J,{htmlFor:"phone",className:"text-right block",children:"رÙÙ
اÙÙØ§ØªÙ"}),(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)(b.p,{id:"phone",type:"tel",value:x.phone,onChange:e=>m({...x,phone:e.target.value}),className:"rounded-xl border-[#E5E7EB] flex-1 min-w-0",placeholder:"أدخ٠رÙÙ
اÙÙØ§ØªÙ"}),h&&(null!=(t=null==(e=x.phone)?void 0:e.trim())?t:"").length>0?(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-sm font-medium bg-green-100 text-green-800",children:[(0,a.jsx)(E.A,{className:"h-4 w-4"}),"Ù
ÙØ«ÙÙ"]}):(0,a.jsx)(f.$,{type:"button",variant:"outline",size:"sm",disabled:!x.phone||U,className:"rounded-xl border-[#E5E7EB]",onClick:async()=>{if(x.phone){J(!0);try{let e=C.AuthService.getJwt();await S.d.sendWhatsAppCode(x.phone,"verify_phone","client",e),R(!0)}catch(e){l({title:"خطأ",description:(null==e?void 0:e.message)||"ÙØ´Ù إرسا٠رÙ
ز Ø§ÙØªØÙÙ",variant:"destructive"})}finally{J(!1)}}},children:U?"Ø¬Ø§Ø±Ù Ø§ÙØ¥Ø±Ø³Ø§Ù...":"ØªÙØ«Ù٠اÙÙØ§ØªÙ"})]}),!h&&(0,a.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"ØªÙØ«Ù٠اÙÙØ§ØªÙ ÙØ¶Ù
٠أÙ
Ø§Ù ØØ³Ø§Ø¨Ù. Ø³ÙØ±Ø³Ù Ù٠رÙ
زا٠عبر ÙØ§ØªØ³Ø§Ø¨."})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(y.J,{htmlFor:"email",className:"text-right block",children:"Ø§ÙØ¨Ø±Ùد Ø§ÙØ¥ÙÙØªØ±ÙÙÙ"}),(0,a.jsxs)("div",{className:"flex items-center gap-3 flex-wrap",children:[(0,a.jsx)(b.p,{id:"email",type:"email",value:(null==_?void 0:_.trim())?_:null!=(s=n.email)?s:"",disabled:!0,className:"bg-[#F9FAFB] rounded-xl border-[#E5E7EB] flex-1 min-w-0"}),(0,a.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-sm font-medium ".concat((null==_?void 0:_.trim())?"bg-amber-100 text-amber-800":j?"bg-green-100 text-green-800":"bg-gray-100 text-gray-600"),children:[(0,a.jsx)(E.A,{className:"h-4 w-4"}),(null==_?void 0:_.trim())?"Ø¨Ø§ÙØªØ¸Ø§Ø± Ø§ÙØªØÙÙ":j?"Ù
ÙØ«ÙÙ":"ØºÙØ± Ù
ÙØ«ÙÙ"]})]}),(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"ÙØ§ ÙÙ
Ù٠تغÙÙØ± Ø§ÙØ¨Ø±Ùد Ø§ÙØ¥ÙÙØªØ±ÙÙÙ"}),!j&&(0,a.jsx)(f.$,{type:"button",variant:"outline",size:"sm",disabled:O||!n.email,className:"rounded-xl border-[#E5E7EB] mt-2",onClick:async()=>{var e;let t=null!=(e=(null==_?void 0:_.trim())||n.email)?e:"";if(t){W(!0);try{let e=C.AuthService.getJwt();await S.d.sendEmailCode(t,"verify_email","client",e),Z(!0)}catch(e){l({title:"خطأ",description:(null==e?void 0:e.message)||"ÙØ´Ù إرسا٠رÙ
ز Ø§ÙØªØÙÙ",variant:"destructive"})}finally{W(!1)}}},children:O?"Ø¬Ø§Ø±Ù Ø§ÙØ¥Ø±Ø³Ø§Ù...":"ØªÙØ«ÙÙ Ø§ÙØ¨Ø±Ùد"})]}),(0,a.jsxs)("p",{className:"text-sm text-gray-600 text-right rounded-xl border border-gray-200 bg-[#F9FAFB] px-4 py-3",children:["Ø¹ÙØ§ÙÙÙ Ø§ÙØªÙصÙÙ ÙØ®Ø±Ø§Ø¦Ø· Ø§ÙØ§Ø³ØªÙاÙ
ØªÙØ¯Ø§Ø± Ù
٠تبÙÙØ¨"," ",(0,a.jsx)(T(),{href:"/profile?tab=addresses",className:"font-semibold text-[#FF8524] hover:underline",children:"Ø§ÙØ¹ÙاÙÙÙ"}),"â Ù
Ø«Ù Ø§ÙØªØ·Ø¨ÙÙ (جدÙÙ Ø§ÙØ¹ÙاÙÙÙ ÙÙÙØ³ ØµÙØØ© Ø§ÙØ¹Ù
ÙÙ)."]}),(0,a.jsxs)(f.$,{type:"submit",className:"w-full bg-[#FF9933] hover:bg-[#
1E6801A] text-white rounded-xl font-semibold py-6 flex items-center justify-center gap-2",disabled:c,children:[(0,a.jsx)(F.A,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:c?"Ø¬Ø§Ø±Ù Ø§ÙØÙØ¸...":"ØÙظ Ø§ÙØªØºÙÙØ±Ø§Øª"})]})]})})]}),(0,a.jsx)(B.l,{open:P,onOpenChange:R,title:"أدخ٠رÙ
ز Ø§ÙØªØÙÙ",description:"Ø£Ø¯Ø®Ù Ø§ÙØ±Ù
ز اÙÙ
رس٠إÙÙ٠عبر ÙØ§ØªØ³Ø§Ø¨",onVerify:async e=>{let t=C.AuthService.getJwt();await S.d.verifyWhatsAppCode(x.phone,e,"verify_phone",void 0,"client",t),await $(),null==i||i(),l({title:"تÙ
Ø§ÙØªÙØ«ÙÙ",description:"تÙ
ØªÙØ«Ù٠رÙÙ
ÙØ§ØªÙÙ Ø¨ÙØ¬Ø§Ø"})}}),(0,a.jsx)(B.l,{open:M,onOpenChange:Z,title:"أدخ٠رÙ
ز Ø§ÙØªØÙÙ",description:"Ø£Ø¯Ø®Ù Ø§ÙØ±Ù
ز اÙÙ
رس٠إÙÙ Ø¨Ø±ÙØ¯Ù Ø§ÙØ¥ÙÙØªØ±ÙÙÙ",onVerify:async e=>{var t;let s=null!=(t=(null==_?void 0:_.trim())||(null==n?void 0:n.email))?t:"";if(!s)return;let a=C.AuthService.getJwt();await S.d.verifyEmailCode(s,e,"verify_email",void 0,"client",a),await $(),null==i||i(),Z(!1),l({title:"تÙ
Ø§ÙØªÙØ«ÙÙ",description:"تÙ
ØªÙØ«ÙÙ Ø¨Ø±ÙØ¯Ù Ø§ÙØ¥ÙÙØªØ±ÙÙÙ Ø¨ÙØ¬Ø§Ø"})}})]}):(0,a.jsx)("div",{children:"ØºÙØ± Ù
سÙ
ÙØ"})};var U=s(10456),J=s(17739),O=s(92161),W=s(89774),P=s(87966),R=s(86739),M=s(95167),Z=s(6973),$=s(23834),z=s(91220),L=s(2466),D=s(46961),I=s(25666),X=s(43846);let K=(e,t)=>{if("SYP"===t){let t=Math.round(e);return"".concat(t.toLocaleString("en-US")," Ù.س")}return"USD"===t?"$".concat(e.toFixed(2)):"".concat(e.toFixed(2)," ").concat(t)},V=e=>{switch(null==e?void 0:e.toLowerCase()){case"approved":case"completed":return"bg-green-100 text-green-800";
1case"pending":return"bg-amber-100 text-amber-800";case"rejected":case"cancelled":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}},Y=()=>{var e,t,s,r;let[l,n]=(0,o.useState)(null),[i,c]=(0,o.useState)([]),[d,x]=(0,o.useState)([]),[m,p]=(0,o.useState)(null),[g,j]=(0,o.useState)(null),[v,N]=(0,o.useState)(!0),[w,F]=(0,o.useState)(!1),[A,S]=(0,o.useState)(!1),[C,B]=(0,o.useState)(!1),[k,_]=(0,o.useState)(!1),[T,q]=(0,o.useState)(null),[U,Y]=(0,o.useState)("manual"),[G,Q]=(0,o.useState)(null),[H,ee]=(0,o.useState)(null),[et,es]=(0,o.useState)({amount:"",currency:"SYP",paymentMethod:"shamcash",confirmationCode:"",receiptUrl:"",notes:""}),[ea,er]=(0,o.useState)({amount:"",currency:"SYP",paymentMethod:"shamcash",recipientAccount:"",notes:""}),el=async()=>{try{N(!0);let e=await W.F.getWalletBalance();n(e)}catch(e){q(e instanceof Error?e.message:"ØØ¯Ø« خطأ Ø£Ø«ÙØ§Ø¡ تØÙ
Ù٠اÙÙ
ØÙظة")}finally{N(!1)}},en=async()=>{try{F(!0);let[e,t]=await Promise.all([W.F.getChargeRequests(),W.F.getWithdrawRequests()]);c(e),x(t)}catch(e){q(e instanceof Error?e.message:"ØØ¯Ø« خطأ Ø£Ø«ÙØ§Ø¡ تØÙ
ÙÙ Ø§ÙØ·Ùبات")}finally{F(!1)}},ei=async()=>{try{S(!0);let[e,t]=await Promise.all([P.J.generateReferralLink(),P.J.getReferralStats()]);p(e),j(t)}catch(e){q(e instanceof Error?e.message:"ØØ¯Ø« خطأ Ø£Ø«ÙØ§Ø¡ تØÙ
ÙÙ Ø¨ÙØ§Ùات Ø§ÙØ¯Ø¹Ùات")}finally{S(!1)}};(0,o.useEffect)(()=>{el(),en(),ei()},[]);let ec=async()=>{let e=Number(et.amount);e&&!(e<=0)&&et.confirmationCode.trim()&&(await W.F.createChargeRequest({amount:e,currency:et.currency,paymentMethod:et.paymentMethod,confirmationCode:et.confirmationCode.trim(),receiptUrl:et.receiptUrl||void 0,notes:et.notes||void 0}),B(!1),es({amount:"",currency:et.currency,paymentMethod:et.paymentMethod,confirmationCode:"",receiptUrl:"",notes:""}),en(),el())},ed=async e=>{try{ee(null),Q(e);let t=await W.F.getStripeWalletPaymentUrl(e);window.location.href=t}catch(e){ee(e instanceof Error?e.message:"ØªØ¹Ø°ÙØ± بدء عÙ
ÙÙØ© Ø§ÙØ¯Ùع Ø¨Ø§ÙØ¨Ø·Ø§ÙØ©"),Q(null)}},eo=async()=>{let e=Number(ea.amount);e&&!(e<=0)&&ea.recipientAccount.trim()&&(await W.F.createWithdrawRequest({amount:e,currency:ea.currency,paymentMethod:ea.paymentMethod,recipientAccount:ea.recipientAccount.trim(),notes:ea.notes||void 0}),_(!1),er({amount:"",currency:ea.currency,paymentMethod:ea.paymentMethod,recipientAccount:"",notes:""}),en(),el())},ex=(0,o.useMemo)(()=>l?(l.wallet.syp_balance||0)+(l.wallet.usd_balance||0):0,[l]);if(v)return(0,a.jsxs)("div",{className:"text-center py-16",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-2 border-[#FF9933] border-t-transparent mx-auto mb-4"}),(0,a.jsx)("p",{className:"text-gray-600",children:"جار٠تØÙ
Ù٠اÙÙ
ØÙظة..."})]});if(T)return(0,a.jsx)(u.Zp,{className:"rounded-2xl shadow-lg border-[#
1E5E7EB] overflow-hidden",children:(0,a.jsx)(u.Wu,{className:"p-6 text-center text-red-600",children:T})});if(!l)return(0,a.jsx)(u.Zp,{className:"rounded-2xl shadow-lg border-[#E5E7EB] overflow-hidden",children:(0,a.jsx)(u.Wu,{className:"p-6 text-center text-gray-600",children:"ÙØ§ ØªÙØ¬Ø¯ Ø¨ÙØ§Ùات ÙÙÙ
ØÙظة"})});let em=0===(l.wallet.syp_balance||0)&&0===(l.wallet.usd_balance||0);return(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)(h.tU,{defaultValue:"balance",className:"w-full",children:[(0,a.jsxs)(h.j7,{className:"w-full justify-between flex-wrap h-auto p-1.5 rounded-xl bg-[#F3F4F6] gap-1",children:[(0,a.jsx)(h.Xi,{value:"balance",className:"rounded-lg px-4 py-2.5 data-[state=active]:bg-white data-[state=active]:text-[#FF9933] data-[state=active]:shadow-sm",children:"Ø§ÙØ±ØµÙد"}),(0,a.jsx)(h.Xi,{value:"transactions",className:"rounded-lg px-4 py-2.5 data-[state=active]:bg-white data-[state=active]:text-[#FF9933] data-[state=active]:shadow-sm",children:"اÙÙ
عاÙ
ÙØ§Øª"}),(0,a.jsx)(h.Xi,{value:"rewards",className:"rounded-lg px-4 py-2.5 data-[state=active]:bg-white data-[state=active]:text-[#FF9933] data-[state=active]:shadow-sm",children:"اÙÙ
ÙØ§Ùآت"}),(0,a.jsx)(h.Xi,{value:"requests",className:"rounded-lg px-4 py-2.5 data-[state=active]:bg-white data-[state=active]:text-[#FF9933] data-[state=active]:shadow-sm",children:"Ø§ÙØ·Ùبات"})]}),(0,a.jsxs)(h.av,{value:"balance",className:"mt-6",children:[em&&(0,a.jsxs)("div",{className:"rounded-2xl border border-[#FF9933]/30 bg-[#FFF4EA] p-5 mb-6 flex items-start gap-4",children:[(0,a.jsx)("div",{className:"w-12 h-12 rounded-xl bg-[#FF9933]/20 flex items-center justify-center flex-shrink-0",children:(0,a.jsx)(R.A,{className:"h-6 w-6 text-[#FF9933]"})}),(0,a.jsxs)("div",{className:"flex-1 text-right",children:[(0,a.jsx)("p",{className:"font-semibold text-gray-900",children:"Ø±ØµÙØ¯Ù ÙØ§Ø±Øº"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:"Ø´ØÙ اÙÙ
ØÙظة ÙÙØ¯Ùع Ù
Ù Ø®ÙØ§ÙÙØ§ Ø¹ÙØ¯ Ø§ÙØ·Ùب"}),(0,a.jsxs)("button",{type:"button",onClick:()=>B(!0),className:"inline-flex items-center gap-2 mt-3 text-sm font-semibold text-[#FF9933] hover:text-[#E6801A] transition-colors",children:[(0,a.jsx)(M.A,{className:"h-4 w-4"}),"Ø´ØÙ اÙÙ
ØÙظة Ø§ÙØ¢Ù"]})]})]}
1),(0,a.jsxs)(u.Zp,{className:"rounded-2xl shadow-lg border-[#E5E7EB] overflow-hidden",children:[(0,a.jsx)(u.aR,{className:"pb-2",children:(0,a.jsxs)(u.ZB,{className:"flex items-center gap-2 text-right",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-xl bg-[#FFF4EA] flex items-center justify-center",children:(0,a.jsx)(Z.A,{className:"h-5 w-5 text-[#FF9933]"})}),(0,a.jsx)("span",{children:"Ø±ØµÙØ¯ اÙÙ
ØÙظة"})]})}),(0,a.jsxs)(u.Wu,{className:"space-y-5",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{className:"bg-[#F9FAFB] rounded-2xl p-5 border border-[#E5E7EB] text-center",children:[(0,a.jsx)("div",{className:"text-sm text-gray-500 mb-1",children:"SYP"}),(0,a.jsx)("div",{className:"text-xl font-bold text-[#111827]",children:K(l.wallet.syp_balance||0,"SYP")})]}),(0,a.jsxs)("div",{className:"bg-[#F9FAFB] rounded-2xl p-5 border border-[#E5E7EB] text-center",children:[(0,a.jsx)("div",{className:"text-sm text-gray-500 mb-1",children:"USD"}),(0,a.jsx)("div",{className:"text-xl font-bold text-[#111827]",children:K(l.wallet.usd_balance||0,"USD")})]})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between text-sm py-3 px-4 bg-[#F9FAFB] rounded-xl",children:[(0,a.jsx)("span",{className:"text-gray-600",children:"Ø§ÙØ¹Ù
ÙØ© اÙÙ
ÙØ¶ÙØ©"}),(0,a.jsx)("span",{className:"font-semibold text-gray-900 px-3 py-1 rounded-full bg-white border border-[#E5E7EB]",children:l.preferredCurrency})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between text-sm py-3 px-4 bg-[#FFF4EA] rounded-xl border border-[#FF9933]/20",children:[(0,a.jsx)("span",{className:"text-gray-600",children:"إجÙ
اÙÙ Ø§ÙØ±ØµÙد"}),(0,a.jsx)("span",{className:"font-bold text-lg text-[#FF9933]",children:K(ex,l.preferredCurrency)})]}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3 pt-2",children:[(0,a.jsxs)(f.$,{className:"bg-[#FF9933] hover:bg-[#E6801A] text-white rounded-xl font-semibold px-6",onClick:()=>B(!0),children:[(0,a.jsx)(M.A,{className:"h-4 w-4 ml-2"}),"Ø´ØÙ اÙÙ
ØÙظة"]}),(0,a.jsxs)(f.$,{variant:"outline",className:"rounded-xl border-[#E5E7EB] hover:bg-gray-50 font-semibold px-6",onClick:()=>_(!0),children:[(0,a.jsx)($.A,{className:"h-4 w-4 ml-2"}),"Ø³ØØ¨ Ø§ÙØ±ØµÙد"]})]})]})]})]}),(0,a.jsx)(h.av,{value:"transactions",className:"mt-6",children:(0,a.jsxs)(u.Zp,{className:"rounded-2xl shadow-lg border-[#
1E5E7EB] overflow-hidden",children:[(0,a.jsx)(u.aR,{className:"pb-2",children:(0,a.jsxs)(u.ZB,{className:"flex items-center gap-2 text-right",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-xl bg-[#FFF4EA] flex items-center justify-center",children:(0,a.jsx)(z.A,{className:"h-5 w-5 text-[#FF9933]"})}),(0,a.jsx)("span",{children:"اÙÙ
عاÙ
ÙØ§Øª Ø§ÙØ£Ø®Ùرة"})]})}),(0,a.jsx)(u.Wu,{children:0===l.recentTransactions.length?(0,a.jsxs)("div",{className:"text-center py-12 text-gray-500",children:[(0,a.jsx)(z.A,{className:"h-12 w-12 mx-auto mb-3 opacity-40"}),(0,a.jsx)("p",{children:"ÙØ§ ØªÙØ¬Ø¯ Ù
عاÙ
ÙØ§Øª بعد"})]}):(0,a.jsx)("div",{className:"space-y-2",children:l.recentTransactions.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between py-4 px-4 rounded-xl hover:bg-[#F9FAFB] transition-colors border-b border-gray-100 last:border-0",children:[(0,a.jsxs)("div",{className:"text-right",children:[(0,a.jsx)("div",{className:"text-sm font-medium text-gray-900",children:function(e){let t=String(e.type||"").toLowerCase().trim(),s=String(e.reason||"").toLowerCase(),a=function(e){if(e.order_id&&String(e.order_id).length>0)return String(e.order_id);let t=e.source_id?String(e.source_id):"";return t.toLowerCase().startsWith("order:")?t.slice(6).trim():null}(e),r=a?" \xb7 #".concat(function(e){let t=e.trim();return t.length<=8?t:t.slice(-8)}(a)):"",l=s.includes("order payment")||s.includes("order:")||!!a,n=s.includes("order cancelled")||s.includes("order canceled")||s.includes("wallet refund")||s.includes("refund:")||!!a;return"redeem"===t?l?"Ø¯ÙØ¹ Ø·ÙØ¨ باÙÙ
ØÙظة".concat(r):"استخداÙ
Ø±ØµÙØ¯":"refund"===t?n||s.includes("cancel")?"استرداد Ù
Ø¨ÙØº Ø§ÙØ·Ùب".concat(r):"استرداد Ø¥Ù٠اÙÙ
ØÙظة":"reward"===t?"Ø¥Ø¶Ø§ÙØ© Ø±ØµÙØ¯":"revoke"===t?"Ø¥ÙØºØ§Ø¡ Ø±ØµÙØ¯":"withdraw"===t?"Ø³ØØ¨ Ø±ØµÙØ¯":e.type||"Ù
عاÙ
ÙØ©"}(e)}),(0,a.jsx)("div",{className:"text-xs text-gray-500 mt-0.5",children:new Date(e.created_at).toLocaleString("ar-SA")})]}),(0,a.jsxs)("div",{className:"text-sm font-bold ".concat(e.amount>=0?"text-green-600":"text-red-600"),children:[e.amount>=0?"+":"-"," ",K(Math.abs(e.amount),e.currency)]})]},e.id))})})]})}),(0,a.jsx)(h.av,{value:"rewards",className:"mt-6",children:(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)(u.Zp,{className:"rounded-2xl shadow-lg border-[#
1E5E7EB] overflow-hidden",children:[(0,a.jsx)(u.aR,{className:"pb-2",children:(0,a.jsxs)(u.ZB,{className:"flex items-center gap-2 text-right",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-xl bg-[#FFF4EA] flex items-center justify-center",children:(0,a.jsx)(L.A,{className:"h-5 w-5 text-[#FF9933]"})}),(0,a.jsx)("span",{children:"Ø¹Ø¬ÙØ© Ø§ÙØØ¸ اÙÙÙÙ
ÙØ©"})]})}),(0,a.jsx)(u.Wu,{className:"text-sm text-gray-600",children:"ÙØ±ÙباÙ: Ù
ÙØ²Ø© Ø¹Ø¬ÙØ© Ø§ÙØØ¸ اÙÙÙÙ
ÙØ© ÙÙØ³Ø¨ Ø±ØµÙØ¯ Ù
جاÙÙ."})]}),(0,a.jsxs)(u.Zp,{className:"rounded-2xl shadow-lg border-[#E5E7EB] overflow-hidden",children:[(0,a.jsx)(u.aR,{className:"pb-2",children:(0,a.jsxs)(u.ZB,{className:"flex items-center gap-2 text-right",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-xl bg-[#FFF4EA] flex items-center justify-center",children:(0,a.jsx)(L.A,{className:"h-5 w-5 text-[#FF9933]"})}),(0,a.jsx)("span",{children:"Ø¯Ø¹ÙØ© Ø§ÙØ£ØµØ¯Ùاء"})]})}),(0,a.jsxs)(u.Wu,{className:"space-y-4",children:[A?(0,a.jsxs)("div",{className:"text-center py-8",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-[#FF9933] border-t-transparent mx-auto"}),(0,a.jsx)("p",{className:"text-sm text-gray-500 mt-2",children:"جار٠تØÙ
Ù٠رابط Ø§ÙØ¯Ø¹ÙØ©..."})]}):m?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"bg-[#F9FAFB] p-4 rounded-xl text-sm break-all border border-[#E5E7EB] font-mono",children:m}),(0,a.jsxs)("div",{className:"flex gap-3 flex-wrap",children:[(0,a.jsx)(f.$,{className:"bg-[#FF9933] hover:bg-[#E6801A] text-white rounded-xl",onClick:()=>P.J.shareReferralLink(m),children:"Ù
Ø´Ø§Ø±ÙØ© Ø§ÙØ±Ø§Ø¨Ø·"}),(0,a.jsxs)(f.$,{variant:"outline",className:"rounded-xl border-[#E5E7EB]",onClick:ei,children:[(0,a.jsx)(D.A,{className:"h-4 w-4 ml-2"}),"ØªØØ¯ÙØ«"]})]})]}):(0,a.jsx)(f.$,{className:"bg-[#FF9933] hover:bg-[#E6801A] text-white rounded-xl",onClick:ei,children:"تØÙ
Ù٠رابط Ø§ÙØ¯Ø¹ÙØ©"}),g&&(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-4 pt-4 border-t border-[#E5E7EB]",children:[(0,a.jsxs)("div",{className:"bg-[#F9FAFB] p-4 rounded-xl border border-[#E5E7EB]",children:[(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-1",children:"اÙÙÙØ±Ø§Øª"}),(0,a.jsx)("p",{className:"text-lg font-bold text-[#111827]",children:null!=(e=g.totalClicks)?e:0})]}),(0,a.jsxs)("div",{className:"bg-[#F9FAFB] p-4 rounded-xl border border-[#E5E7EB]",children:[(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-1",children:"Ø§ÙØªØ³Ø¬ÙÙØ§Øª"}),(0,a.jsx)("p",{className:"text-lg font-bold text-[#111827]",children:null!=(t=g.totalSignups)?t:0})]}),(0,a.jsxs)("div",{className:"bg-[#F9FAFB] p-4 rounded-xl border border-[#E5E7EB]",children:[(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-1",children:"Ø§ÙØ±ØµÙد اÙÙ
ÙØªØ³Ø¨"}),(0,a.jsx)("p",{className:"text-lg font-bold text-[#FF9933]",children:null!=(s=g.totalEarned)?s:0})]}),(0,a.jsxs)("div",{className:"bg-[#F9FAFB] p-4 rounded-xl border border-[#E5E7EB]",children:[(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-1",children:"Ù
Ø¹Ø¯Ù Ø§ÙØªØÙÙÙ"}),(0,a.jsxs)("p",{className:"text-lg font-bold text-[#111827]",children:[null!=(r=g.conversionRate)?r:0,"%"]})]})]})]})]})]})}),(0,a.jsx)(h.av,{value:"requests",className:"mt-6",children:(0,a.jsxs)(u.Zp,{className:"rounded-2xl shadow-lg border-[#
1E5E7EB] overflow-hidden",children:[(0,a.jsx)(u.aR,{className:"pb-2",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)(u.ZB,{className:"flex items-center gap-2 text-right",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-xl bg-[#FFF4EA] flex items-center justify-center",children:(0,a.jsx)(I.A,{className:"h-5 w-5 text-[#FF9933]"})}),(0,a.jsx)("span",{children:"Ø·ÙØ¨Ø§Øª اÙÙ
ØÙظة"})]}),(0,a.jsxs)(f.$,{variant:"ghost",size:"sm",onClick:en,className:"rounded-xl text-gray-600 hover:bg-gray-100",children:[(0,a.jsx)(D.A,{className:"h-4 w-4 ml-2"}),"ØªØØ¯ÙØ«"]})]})}),(0,a.jsx)(u.Wu,{className:"space-y-6",children:w?(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-[#FF9933] border-t-transparent mx-auto"}),(0,a.jsx)("p",{className:"text-sm text-gray-500 mt-2",children:"جار٠تØÙ
ÙÙ Ø§ÙØ·Ùبات..."})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("div",{className:"font-semibold text-sm text-gray-700",children:"Ø·ÙØ¨Ø§Øª Ø§ÙØ´ØÙ"}),0===i.length?(0,a.jsx)("div",{className:"text-sm text-gray-500 py-4 px-4 bg-[#F9FAFB] rounded-xl",children:"ÙØ§ ØªÙØ¬Ø¯ Ø·ÙØ¨Ø§Øª Ø´ØÙ"}):(0,a.jsx)("div",{className:"space-y-2",children:i.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between p-4 rounded-xl border border-[#E5E7EB] bg-white hover:shadow-sm transition-shadow",children:[(0,a.jsxs)("div",{className:"text-right",children:[(0,a.jsx)("div",{className:"font-semibold text-[#111827]",children:K(e.amount,e.currency)}),(0,a.jsx)("div",{className:"text-xs text-gray-500 mt-0.5",children:new Date(e.created_at).toLocaleString("ar-SA")})]}),(0,a.jsx)("span",{className:"px-3 py-1 rounded-full text-xs font-medium ".concat(V(e.status)),children:e.status})]},e.id))})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("div",{className:"font-semibold text-sm text-gray-700",children:"Ø·ÙØ¨Ø§Øª Ø§ÙØ³ØØ¨"}),0===d.length?(0,a.jsx)("div",{className:"text-sm text-gray-500 py-4 px-4 bg-[#F9FAFB] rounded-xl",children:"ÙØ§ ØªÙØ¬Ø¯ Ø·ÙØ¨Ø§Øª Ø³ØØ¨"}):(0,a.jsx)("div",{className:"space-y-2",children:d.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between p-4 rounded-xl border border-[#E5E7EB] bg-white hover:shadow-sm transition-shadow",children:[(0,a.jsxs)("div",{className:"text-right",children:[(0,a.jsx)("div",{className:"font-semibold text-[#111827]",children:K(e.amount,e.currency)}),(0,a.jsx)("div",{className:"text-xs text-gray-500 mt-0.5",children:new Date(e.created_at).toLocaleString("ar-SA")})]}),(0,a.jsx)("span",{className:"px-3 py-1 rounded-full text-xs font-medium ".concat(V(e.status)),children:e.status})]},e.id))})]})]})})]})})]}),(0,a.jsx)(O.lG,{open:C,onOpenChange:e=>{B(e),e||(Y("manual"),ee(null),Q(null))},children:(0,a.jsxs)(O.Cf,{className:"max-w-md rounded-2xl border-[#
1E5E7EB]",children:[(0,a.jsx)(O.c7,{className:"text-right",children:(0,a.jsx)(O.L3,{children:"Ø´ØÙ اÙÙ
ØÙظة"})}),(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-2 p-1 rounded-xl bg-[#F3F4F6]",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>Y("manual"),className:"flex items-center justify-center gap-2 rounded-lg py-2.5 text-sm font-semibold transition-colors ".concat("manual"===U?"bg-white text-[#FF9933] shadow-sm":"text-gray-600 hover:text-gray-900"),children:[(0,a.jsx)($.A,{className:"h-4 w-4"}),"تØÙÙÙ ÙØ¯ÙÙ"]}),(0,a.jsxs)("button",{type:"button",onClick:()=>Y("card"),className:"flex items-center justify-center gap-2 rounded-lg py-2.5 text-sm font-semibold transition-colors ".concat("card"===U?"bg-white text-[#FF9933] shadow-sm":"text-gray-600 hover:text-gray-900"),children:[(0,a.jsx)(X.A,{className:"h-4 w-4"}),"Ø§ÙØ¯Ùع Ø¨Ø§ÙØ¨Ø·Ø§ÙØ© (Visa)"]})]}),"card"===U?(0,a.jsxs)("div",{className:"space-y-4 mt-4",children:[(0,a.jsxs)("div",{className:"rounded-2xl border border-[#FF9933]/30 bg-[#FFF4EA] p-4 text-right",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 justify-end",children:[(0,a.jsx)("span",{className:"font-semibold text-[#2B241F]",children:"Ø§ÙØ¯Ùع ب٠ÙÙØ²Ø§ Ø£Ù Ù
Ø§Ø³ØªØ±ÙØ§Ø±Ø¯"}),(0,a.jsx)(E.A,{className:"h-5 w-5 text-[#FF9933]"})]}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-2",children:"اختر اÙÙ
Ø¨ÙØº Ø£Ø¯ÙØ§Ù. Ø³ÙØªÙ
تØÙÙÙ٠إÙÙ ØµÙØØ© Ø¯ÙØ¹ Ø¢Ù
ÙØ© (Stripe)Ø ÙÙÙØ¶Ø§Ù Ø§ÙØ±ØµÙد Ø¥ÙÙ Ù
ØÙظت٠ÙÙØ± إتÙ
اÙ
Ø§ÙØ¯Ùع."}),(0,a.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Ø§ÙØ¯Ùع Ø¨Ø§ÙØ¨Ø·Ø§ÙØ© Ø¨Ø§ÙØ¯ÙÙØ§Ø± Ø§ÙØ£Ù
رÙÙÙ (USD) ÙÙØ·."})]}),H&&(0,a.jsx)("div",{className:"text-sm text-red-600 text-right bg-red-50 rounded-xl px-4 py-3",children:H}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-3",children:[10,20,50,100].map(e=>(0,a.jsx)(f.$,{disabled:null!==G,onClick:()=>ed(e),className:"bg-[#FF9933] hover:bg-[#E6801A] text-white rounded-xl font-semibold py-6 text-base disabled:opacity-60",children:G===e?(0,a.jsx)("span",{className:"animate-spin rounded-full h-5 w-5 border-2 border-white border-t-transparent"}):"$".concat(e," USD")},e))})]}):(0,a.jsxs)("div",{className:"space-y-4 mt-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(y.J,{className:"text-right block mb-2",children:"اÙÙ
Ø¨ÙØº"}),(0,a.jsx)(b.p,{type:"number",value:et.amount,onChange:e=>es({...et,amount:e.target.value}),className:"rounded-xl border-[#E5E7EB]"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(y.J,{className:"text-right block mb-2",children:"Ø§ÙØ¹Ù
ÙØ©"}),(0,a.jsx)(b.p,{value:et.currency,onChange:e=>es({...et,currency:e.target.value}),className:"rounded-xl border-[#E5E7EB]"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(y.J,{className:"text-right block mb-2",children:"طرÙÙØ© Ø§ÙØ¯Ùع"}),(0,a.jsx)(b.p,{value:et.paymentMethod,onChange:e=>es({...et,paymentMethod:e.target.value}),className:"rounded-xl border-[#E5E7EB]"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(y.J,{className:"text-right block mb-2",children:"رÙÙ
Ø§ÙØªØ£ÙÙØ¯"}),(0,a.jsx)(b.p,{value:et.confirmationCode,onChange:e=>es({...et,confirmationCode:e.target.value}),className:"rounded-xl border-[#E5E7EB]"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(y.J,{className:"text-right block mb-2",children:"رابط Ø§ÙØ¥Ùصا٠(Ø§Ø®ØªÙØ§Ø±Ù)"}),(0,a.jsx)(b.p,{value:et.receiptUrl,onChange:e=>es({...et,receiptUrl:e.target.value}),className:"rounded-xl border-[#E5E7EB]"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(y.J,{className:"text-right block mb-2",children:"Ù
ÙØ§ØØ¸Ø§Øª (Ø§Ø®ØªÙØ§Ø±Ù)"}),(0,a.jsx)(J.T,{value:et.notes,onChange:e=>es({...et,notes:e.target.value}),className:"rounded-xl border-[#E5E7EB]"})]}),(0,a.jsx)(f.$,{className:"w-full bg-[#FF9933] hover:bg-[#E6801A] text-white rounded-xl font-semibold py-6",onClick:ec,children:"Ø¥Ø±Ø³Ø§Ù Ø§ÙØ·Ùب"})]})]})}),(0,a.jsx)(O.lG,{open:k,onOpenChange:_,children:(0,a.jsxs)(O.Cf,{className:"max-w-md rounded-2xl border-[#
1E5E7EB]",children:[(0,a.jsx)(O.c7,{className:"text-right",children:(0,a.jsx)(O.L3,{children:"Ø·ÙØ¨ Ø³ØØ¨ Ø§ÙØ±ØµÙد"})}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(y.J,{className:"text-right block mb-2",children:"اÙÙ
Ø¨ÙØº"}),(0,a.jsx)(b.p,{type:"number",value:ea.amount,onChange:e=>er({...ea,amount:e.target.value}),className:"rounded-xl border-[#E5E7EB]"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(y.J,{className:"text-right block mb-2",children:"Ø§ÙØ¹Ù
ÙØ©"}),(0,a.jsx)(b.p,{value:ea.currency,onChange:e=>er({...ea,currency:e.target.value}),className:"rounded-xl border-[#E5E7EB]"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(y.J,{className:"text-right block mb-2",children:"طرÙÙØ© Ø§ÙØ§Ø³ØªÙاÙ
"}),(0,a.jsx)(b.p,{value:ea.paymentMethod,onChange:e=>er({...ea,paymentMethod:e.target.value}),className:"rounded-xl border-[#E5E7EB]"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(y.J,{className:"text-right block mb-2",children:"Ø§ÙØØ³Ø§Ø¨ اÙÙ
ستÙÙ
"}),(0,a.jsx)(b.p,{value:ea.recipientAccount,onChange:e=>er({...ea,recipientAccount:e.target.value}),className:"rounded-xl border-[#E5E7EB]"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(y.J,{className:"text-right block mb-2",children:"Ù
ÙØ§ØØ¸Ø§Øª (Ø§Ø®ØªÙØ§Ø±Ù)"}),(0,a.jsx)(J.T,{value:ea.notes,onChange:e=>er({...ea,notes:e.target.value}),className:"rounded-xl border-[#E5E7EB]"})]}),(0,a.jsx)(f.$,{className:"w-full bg-[#FF9933] hover:bg-[#E6801A] text-white rounded-xl font-semibold py-6",onClick:eo,children:"Ø¥Ø±Ø³Ø§Ù Ø§ÙØ·Ùب"})]})]})})]})};var G=s(91978),Q=s(62910),H=s(20710),ee=s(498),et=s(45884),es=s(99652),ea=s(11711),er=s(3609),el=s(5612),en=s(70801),ei=s(96108),ec=s(69518),ed=s(48100),eo=s(71449),ex=s(50526);let em=()=>{var e,t,s,r;let l=(0,x.useRouter)(),n=(0,g.A)(),[i,c]=(0,o.useState)(!1),[d,y]=(0,o.useState)(null),[w,E]=(0,o.useState)(null),[F,A]=(0,o.useState)(!1);if(!n)return null;let{user:S,isAuthenticated:C,userType:B,loading:k}=n;if(!k&&!C)return l.push("/auth"),null;if(!k&&C&&"vendor"===B)return l.push("/vendor-portal/dashboard"),null;let _=(0,o.useMemo)(()=>{let e=l.query.tab;return"orders"===e||"addresses"===e||"wallet"===e||"settings"===e?e:"profile"},[l.query.tab]),{data:T,isLoading:J,error:O,refetch:W}=(0,j.Z)({queryKey:["customer-orders",null==S?void 0:S.id],queryFn:()=>v.Ek.getCustomerOrders((null==S?void 0:S.id)||""),enabled:!!(null==S?void 0:S.id)}),R=(null==T?void 0:T.orders)||[],[M,Z]=(0,o.useState)("all"),$="all"===M?R:R.filter(e=>e.status===M),z=e=>{switch(e){case"pending":return"ÙÙØ¯ Ø§ÙØ§Ùتظار";case"confirmed":return"Ù
Ø¤ÙØ¯";case"preparing":return"ÙÙØ¯ Ø§ÙØªØØ¶Ùر";case"ready_for_pickup":return"Ø¬Ø§ÙØ² ÙÙØ§Ø³ØªÙاÙ
";case"out_for_delivery":return"ÙÙ Ø§ÙØ·Ø±ÙÙ";case"delivered":return"تÙ
Ø§ÙØªØ³ÙÙÙ
";case"cancelled":return"Ù
ÙØºÙ";case"refunded":return"Ù
سترد";default:return e}},L=async(e,t)=>{if(window.confirm((0,ex.ak)(t)))try{await v.Ek.cancelOrder(e),(0,N.oR)({title:"تÙ
Ø¥ÙØºØ§Ø¡ Ø§ÙØ·Ùب",description:"تÙ
Ø§ÙØ¥Ùغاء Ø¨ÙØ¬Ø§Ø. Ø¥Ù Ø¯ÙØ¹Øª باÙÙ
ØÙØ¸Ø©Ø Ø±Ø§Ø¬Ø¹ سج٠اÙÙ
ØÙظة."}),W()}catch(e){(0,N.oR)({title:"ØªØ¹Ø°ÙØ± Ø§ÙØ¥Ùغاء",description:e instanceof Error?e.message:"ØØ§ÙÙ Ù
رة أخرÙ",variant:"destructive"})}},D=async()=>{if(null==S?void 0:S.id)try{A(!0);let[e,t]=await Promise.all([P.J.generateReferralLink(),P.J.getReferralStats()]);y(e),E(t)}catch(e){console.error("Error loading referral:",e)}finally{A(!1)}},I=async()=>{if(d)try{await navigator.clipboard.writeText(d),(0,N.oR)({title:"تÙ
اÙÙØ³Ø®",description:"تÙ
ÙØ³Ø® رابط Ø§ÙØ¯Ø¹ÙØ© Ø¥ÙÙ Ø§ÙØØ§ÙØ¸Ø©"})}catch(e){(0,N.oR)({title:"خطأ",description:"ÙØ´Ù ÙØ³Ø® Ø§ÙØ±Ø§Ø¨Ø·",variant:"destructive"})}};return(0,o.useEffect)(()=>{(null==S?void 0:S.id)&&D()},[null==S?void 0:S.id]),(0,a.jsxs)("div",{className:"min-h-screen bg-[#F9FAFB]",children:[(0,a.jsx)(m.A,{}),(0,a.jsxs)("div",{className:"container mx-auto px-4 py-8 max-w-4xl",children:[(0,a.jsxs)("div",{className:"mb-6 text-right",children:[(0,a.jsx)("h1",{className:"text-2xl sm:text-3xl font-bold text-gray-900",children:"ØØ³Ø§Ø¨Ù"}),(0,a.jsx)("p",{className:"text-gray-600 mt-1",children:"إدارة ØØ³Ø§Ø¨Ù ÙØ§ÙØ·ÙØ¨Ø§Øª ÙØ§ÙØ¹ÙØ§ÙÙÙ"})]}),(0,a.jsxs)(h.tU,{defaultValue:_,className:"w-full",children:[(0,a.jsxs)(h.j7,{className:"w-full justify-between flex-wrap h-auto p-1.5 rounded-xl bg-[#F3F4F6] gap-1 mb-6",children:[(0,a.jsx)(h.Xi,{value:"profile",className:"rounded-lg px-4 py-2.5 data-[state=active]:bg-white data-[state=active]:text-[#FF9933] data-[state=active]:shadow-sm",children:"اÙÙ
ÙÙ Ø§ÙØ´Ø®ØµÙ"}),(0,a.jsx)(h.Xi,{value:"orders",className:"rounded-lg px-4 py-2.5 data-[state=active]:bg-white data-[state=active]:text-[#FF9933] data-[state=active]:shadow-sm",children:"Ø·ÙØ¨Ø§ØªÙ"}),(0,a.jsx)(h.Xi,{value:"addresses",className:"rounded-lg px-4 py-2.5 data-[state=active]:bg-white data-[state=active]:text-[#FF9933] data-[state=active]:shadow-sm",children:"Ø§ÙØ¹ÙاÙÙÙ"}),(0,a.jsx)(h.Xi,{value:"wallet",className:"rounded-lg px-4 py-2.5 data-[state=active]:bg-white data-[state=active]:text-[#FF9933] data-[state=active]:shadow-sm",children:"اÙÙ
ØÙظة"}),(0,a.jsx)(h.Xi,{value:"settings",className:"rounded-lg px-4 py-2.5 data-[state=active]:bg-white data-[state=active]:text-[#FF9933] data-[state=active]:shadow-sm",children:"Ø§ÙØ¥Ø¹Ø¯Ø§Ø¯Ø§Øª"})]}),(0,a.jsx)(h.av,{value:"profile",children:(0,a.jsx)(q,{})}),(0,a.jsxs)(h.av,{value:"orders",children:[(0,a.jsx)("div",{className:"flex flex-wrap gap-2 mb-6",children:["all","pending","confirmed","preparing","ready_for_pickup","out_for_delivery","delivered","cancelled"].map(e=>(0,a.jsx)(f.$,{variant:M===e?"default":"outline",size:"sm",onClick:()=>
1Z(e),className:M===e?"bg-[#FF9933] hover:bg-[#E6801A] rounded-xl":"rounded-xl border-[#E5E7EB]",children:"all"===e?"اÙÙÙ":z(e)},e))}),J?(0,a.jsxs)("div",{className:"text-center py-16",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-2 border-[#FF9933] border-t-transparent mx-auto mb-4"}),(0,a.jsx)("p",{className:"text-gray-600",children:"جار٠تØÙ
ÙÙ Ø§ÙØ·Ùبات..."})]}):O?(0,a.jsx)(u.Zp,{className:"rounded-2xl shadow-lg border-[#E5E7EB]",children:(0,a.jsx)(u.Wu,{className:"p-6 text-center text-red-600",children:"ØØ¯Ø« خطأ Ø£Ø«ÙØ§Ø¡ تØÙ
ÙÙ Ø§ÙØ·Ùبات"})}):0===$.length?(0,a.jsx)(u.Zp,{className:"rounded-2xl shadow-lg border-[#E5E7EB] overflow-hidden",children:(0,a.jsxs)(u.Wu,{className:"p-12 text-center",children:[(0,a.jsx)("div",{className:"w-20 h-20 rounded-2xl bg-[#F3F4F6] flex items-center justify-center mx-auto mb-4",children:(0,a.jsx)(et.A,{className:"h-10 w-10 text-gray-400"})}),(0,a.jsx)("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"ÙØ§ ØªÙØ¬Ø¯ Ø·ÙØ¨Ø§Øª"}),(0,a.jsx)("p",{className:"text-gray-600",children:"ÙÙ
تÙÙ
Ø¨Ø£Ù Ø·ÙØ¨Ø§Øª بعد."})]})}):(0,a.jsx)("div",{className:"space-y-6",children:$.map(e=>{var t,s,r,n;return(0,a.jsxs)(u.Zp,{className:"overflow-hidden cursor-pointer rounded-2xl shadow-lg border-[#
1E5E7EB] hover:shadow-xl transition-all duration-200",onClick:()=>l.push("/orders/".concat(e.id)),children:[(0,a.jsxs)("div",{className:"bg-white border-b border-[#E5E7EB] p-4 sm:p-5 flex justify-between items-start",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"font-semibold",children:["Ø·ÙØ¨ رÙÙ
#",e.id.slice(-8)]}),(0,a.jsx)("div",{className:"text-sm text-gray-500",children:new Date(e.created_at).toLocaleDateString("ar-SA",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),(0,a.jsxs)("div",{className:"flex flex-col items-end gap-2",children:[(0,a.jsxs)(p.E,{className:"".concat((e=>{switch(e){case"pending":return"bg-yellow-100 text-yellow-800";case"confirmed":return"bg-blue-100 text-blue-800";case"preparing":return"bg-orange-100 text-orange-800";case"ready_for_pickup":return"bg-purple-100 text-purple-800";case"out_for_delivery":return"bg-indigo-100 text-indigo-800";case"delivered":return"bg-green-100 text-green-800";case"cancelled":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}})(e.status)," flex items-center gap-1"),children:[(e=>{switch(e){case"pending":return(0,a.jsx)(H.A,{className:"h-4 w-4"});case"confirmed":case"delivered":return(0,a.jsx)(ee.A,{className:"h-4 w-4"});case"preparing":default:return(0,a.jsx)(et.A,{className:"h-4 w-4"});case"ready_for_pickup":return(0,a.jsx)(es.A,{className:"h-4 w-4"});case"out_for_delivery":return(0,a.jsx)(ea.A,{className:"h-4 w-4"});case"cancelled":case"refunded":return(0,a.jsx)(er.A,{className:"h-4 w-4"})}})(e.status),z(e.status)]}),"delivered"===e.status&&e.delivery_proof_url&&(0,a.jsx)(Q.A,{deliveryProofUrl:e.delivery_proof_url,orderId:e.id})]})]}),(0,a.jsx)(u.Wu,{className:"p-6",children:(0,a.jsxs)("div",{className:"grid md:grid-cols-2 gap-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"font-semibold text-gray-900 mb-3",children:"اÙÙ
ÙØªØ¬Ø§Øª"}),(0,a.jsx)("div",{className:"space-y-3",children:null==(t=e.order_items)?void 0:t.map((t,s)=>{var r,l;return(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(null==(r=t.product_snapshot)?void 0:r.image_url)&&(0,a.jsx)("img",{src:t.product_snapshot.image_url,alt:t.product_snapshot.name,className:"w-12 h-12 object-cover rounded-xl"}),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("p",{className:"font-medium text-sm",children:null==(l=t.product_snapshot)?void 0:l.name}),(0,a.jsxs)("p",{className:"text-xs text-gray-500",children:["اÙÙÙ
ÙØ©: ",t.quantity," \xd7 ",t.unit_price," ",e.currency]})]}),(0,a.jsxs)("p",{className:"font-semibold text-sm",children:[t.total_price," ",e.currency]})]},s)})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"font-semibold text-gray-900 mb-3",children:"ØªÙØ§ØµÙÙ Ø§ÙØ·Ùب"}),(0,a.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"text-gray-600",children:"اÙÙ
جÙ
ÙØ¹:"}),(0,a.jsxs)("span",{className:"font-semibold",children:[e.total_amount," ",e.currency]})]}),(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"text-gray-600",children:"طرÙÙØ© Ø§ÙØ¯Ùع:"}),(0,a.jsx)("span",{children:e.payment_method})]}),e.payment_receipt&&(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"text-gray-600",children:"رÙÙ
Ø§ÙØ¥ÙصاÙ:"}),(0,a.jsx)("span",{className:"font-mono text-xs",children:e.payment_receipt})]}),e.delivery_requested&&(0,a.jsxs)("div",{className:"mt-3 pt-3 border-t",children:[(0,a.jsx)("p",{className:"text-gray-600 mb-1",children:"عÙÙØ§Ù Ø§ÙØªØ³ÙÙÙ
:"}),(0,a.jsxs)("p",{className:"text-sm",children:[null==(s=e.delivery_address)?void 0:s.street,", ",null==(r=e.delivery_address)?void 0:r.city,", ",null==(n=e.delivery_address)?void 0:n.country]})]}),(0,ex.bh)(e.status)&&(0,a.jsx)("div",{className:"mt-3 pt-3 border-t border-[#E5E7EB]",children:(0,a.jsx)(f.$,{variant:"destructive",className:"rounded-xl",onClick:()=>L(e.id,e.payment_method),children:"Ø¥ÙØºØ§Ø¡ Ø§ÙØ·Ùب"})})]})]})]})})]},e.id)})})]}),(0,a.jsx)(h.av,{value:"addresses",children:(0,a.jsx)(U.A,{})}),(0,a.jsx)(h.av,{value:"wallet",children:(0,a.jsx)(Y,{})}),(0,a.jsxs)(h.av,{value:"settings",children:[(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsx)(u.Zp,{className:"rounded-2xl shadow-lg border-[#
1E5E7EB] overflow-hidden",children:(0,a.jsxs)(u.Wu,{className:"p-6 space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-full bg-[#16A34A]/20 flex items-center justify-center",children:(0,a.jsx)(el.A,{className:"h-5 w-5 text-[#16A34A]"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-semibold text-[#111827]",children:"Ø¯Ø¹ÙØ© Ø§ÙØ£ØµØ¯Ùاء"}),(0,a.jsx)("p",{className:"text-sm text-gray-600",children:"Ø´Ø§Ø±Ù Ø±Ø§Ø¨Ø·Ù ÙØ§ØØµÙ عÙÙ Ø±ØµÙØ¯ Ù
جاÙÙ Ø¹ÙØ¯ تسجÙÙ Ø£ØµØ¯ÙØ§Ø¦Ù"})]})]}),F?(0,a.jsx)("div",{className:"text-center py-4",children:(0,a.jsx)("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-[#FF8524] mx-auto"})}):d?(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-sm font-medium text-[#374151] mb-2",children:"رابط Ø§ÙØ¯Ø¹ÙØ© Ø§ÙØ®Ø§Øµ بÙ:"}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(b.p,{value:d,readOnly:!0,className:"flex-1 bg-[#F9FAFB] text-sm border-[#
1E5E7EB] rounded-xl"}),(0,a.jsx)(f.$,{variant:"outline",size:"icon",onClick:I,title:"ÙØ³Ø® Ø§ÙØ±Ø§Ø¨Ø·",className:"border-[#E5E7EB] rounded-xl",children:(0,a.jsx)(en.A,{className:"h-4 w-4"})}),(0,a.jsxs)(f.$,{onClick:()=>P.J.shareReferralLink(d),className:"bg-[#FF9933] hover:bg-[#E6801A] text-white rounded-xl",children:[(0,a.jsx)(el.A,{className:"h-4 w-4 ml-2"}),"Ù
Ø´Ø§Ø±ÙØ© Ø§ÙØ±Ø§Ø¨Ø·"]})]})]}),w&&(0,a.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 pt-4 border-t border-[#E5E7EB]",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-1",children:"اÙÙÙØ±Ø§Øª"}),(0,a.jsx)("p",{className:"text-lg font-semibold text-[#111827]",children:null!=(e=w.totalClicks)?e:0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-1",children:"Ø§ÙØªØ³Ø¬ÙÙØ§Øª"}),(0,a.jsx)("p",{className:"text-lg font-semibold text-[#111827]",children:null!=(t=w.totalSignups)?t:0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-1",children:"Ø§ÙØ±ØµÙد اÙÙ
ÙØªØ³Ø¨"}),(0,a.jsx)("p",{className:"text-lg font-semibold text-[#16A34A]",children:null!=(s=w.totalEarned)?s:0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-xs text-gray-500 mb-1",children:"Ù
Ø¹Ø¯Ù Ø§ÙØªØÙÙÙ"}),(0,a.jsxs)("p",{className:"text-lg font-semibold text-[#111827]",children:[null!=(r=w.conversionRate)?r:0,"%"]})]})]}),(0,a.jsxs)("div",{className:"rounded-xl bg-[#EFF6FF] border border-[#BFDBFE] p-4 space-y-3",children:[(0,a.jsx)("p",{className:"font-semibold text-[#2563EB] text-center",children:"ÙÙÙÙØ© Ø§ÙØØµÙ٠عÙÙ Ø±ØµÙØ¯ Ù
جاÙÙ"}),(0,a.jsxs)("ol",{className:"text-sm text-[#374151] space-y-2 list-decimal list-inside",children:[(0,a.jsx)("li",{children:"شار٠رابط٠Ù
ع Ø§ÙØ£ØµØ¯Ùاء"}),(0,a.jsx)("li",{children:"Ø§Ø·ÙØ¨ Ù
ÙÙÙ
Ø§ÙØªØ³ÙÙ Ù
٠اÙÙ
ÙÙØ¹ أ٠تØÙ
ÙÙ Ø§ÙØªØ·Ø¨ÙÙ"}),(0,a.jsx)("li",{children:"Ø§Ø·ÙØ¨ Ù
ÙÙÙ
Ø¥ÙØ´Ø§Ø¡ ØØ³Ø§Ø¨ Ø¬Ø¯ÙØ¯"}),(0,a.jsx)("li",{children:"Ø§ØØµÙ عÙÙ Ø±ØµÙØ¯ Ù
جاÙÙ ÙÙ Ù
ØÙظتÙ!"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 rounded-lg bg-[#DCFCE7] border border-[#86EFAC] p-3",children:[(0,a.jsx)("span",{className:"text-[#16A34A] text-lg",children:"â"}),(0,a.jsx)("p",{className:"text-sm font-medium text-[#166534]",children:"Ø§ÙØ±ØµÙد Ø³ÙØ¸Ùر ÙÙ Ù
ØÙظت٠ÙÙØ± تسجÙ٠صدÙÙÙ"})]})]})]}):(0,a.jsx)(f.$,{onClick:D,className:"bg-[#FF9933] hover:bg-[#E6801A] text-white rounded-xl",children:"تØÙ
Ù٠رابط Ø§ÙØ¯Ø¹ÙØ©"})]})}
1),(0,a.jsx)(u.Zp,{className:"rounded-2xl shadow-lg border-[#E5E7EB] overflow-hidden cursor-pointer hover:shadow-xl transition-shadow",onClick:()=>l.push("/affiliate"),children:(0,a.jsxs)(u.Wu,{className:"p-6 flex items-center justify-between",children:[(0,a.jsx)(ei.A,{className:"h-5 w-5 text-gray-400 flex-shrink-0"}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsxs)("div",{className:"text-right",children:[(0,a.jsx)("h3",{className:"font-semibold text-gray-900",children:"Ø¨Ø±ÙØ§Ù
ج اÙÙ
سÙÙÙÙÙ"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-0.5",children:"Ø§ÙØ¶Ù
ÙØ´Ø§Ø±Ù Ø±ÙØ§Ø¨Ø· ÙØ§Ùسب عÙ
ÙÙØ© عÙÙ ÙÙ Ø·ÙØ¨"})]}),(0,a.jsx)("div",{className:"w-10 h-10 rounded-xl bg-[#FFF4EA] flex items-center justify-center flex-shrink-0",children:(0,a.jsx)(ec.A,{className:"h-5 w-5 text-[#FF9933]"})})]})]})}),(0,a.jsx)(u.Zp,{className:"rounded-2xl shadow-lg border-[#E5E7EB] overflow-hidden cursor-pointer hover:shadow-xl transition-shadow",onClick:()=>l.push("/affiliate/commissions"),children:(0,a.jsxs)(u.Wu,{className:"p-6 flex items-center justify-between",children:[(0,a.jsx)(ei.A,{className:"h-5 w-5 text-gray-400 flex-shrink-0"}),(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsxs)("div",{className:"text-right",children:[(0,a.jsx)("h3",{className:"font-semibold text-gray-900",children:"سج٠عÙ
ÙÙØ§ØªÙ"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-0.5",children:"تابع عÙ
ÙÙØ§ØªÙ ÙØ±ØµÙØ¯ÙØ§ Ù٠اÙÙ
ØÙظة"})]}),(0,a.jsx)("div",{className:"w-10 h-10 rounded-xl bg-[#FFF4EA] flex items-center justify-center flex-shrink-0",children:(0,a.jsx)(ed.A,{className:"h-5 w-5 text-[#FF9933]"})})]})]})}
1),(0,a.jsx)(u.Zp,{className:"rounded-2xl shadow-lg border-[#E5E7EB] overflow-hidden",children:(0,a.jsxs)(u.Wu,{className:"p-6 space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"w-10 h-10 rounded-xl bg-[#FFF4EA] flex items-center justify-center",children:(0,a.jsx)(eo.A,{className:"h-5 w-5 text-[#FF9933]"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"font-semibold text-gray-900",children:"إعدادات Ø§ÙØØ³Ø§Ø¨"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-0.5",children:"ÙÙ
ÙÙÙ ØØ°Ù ØØ³Ø§Ø¨Ù ÙÙØ§Ø¦Ùا٠Ù
Ù ÙÙØ§. ÙØ°Ø§ Ø§ÙØ¥Ø¬Ø±Ø§Ø¡ ÙØ§ ÙÙ
ÙÙ Ø§ÙØªØ±Ø§Ø¬Ø¹ عÙÙ."})]})]}),(0,a.jsx)(f.$,{variant:"destructive",className:"rounded-xl",onClick:()=>c(!0),children:"ØØ°Ù Ø§ÙØØ³Ø§Ø¨"})]})})]}),(0,a.jsx)(G.A,{isOpen:i,onOpenChange:c})]})]})]})]})};var eh=s(48085),eu=s(39094),ep=s(77328),eg=s.n(ep);let ej="force-dynamic";function ev(){return(0,a.jsxs)(d.t,{children:[(0,a.jsxs)(eg(),{children:[(0,a.jsx)("title",{children:"ØØ³Ø§Ø¨Ù - شاÙÙÙ"}),(0,a.jsx)("meta",{name:"description",content:"إدارة ØØ³Ø§Ø¨Ù عÙÙ Ù
ÙØµØ© شاÙÙÙ"}),(0,a.jsx)("meta",{property:"og:title",content:"ØØ³Ø§Ø¨Ù - شاÙÙÙ"}),(0,a.jsx)("meta",{property:"og:description",content:"إدارة ØØ³Ø§Ø¨Ù عÙÙ Ù
ÙØµØ© شاÙÙÙ"}),(0,a.jsx)("meta",{property:"og:type",content:"website"}),(0,a.jsx)("meta",{property:"og:image",content:"/lovable-uploads/icon.png"}),(0,a.jsx)("meta",{name:"twitter:card",content:"summary_large_image"}),(0,a.jsx)("meta",{name:"twitter:title",content:"ØØ³Ø§Ø¨Ù - شاÙÙÙ"}),(0,a.jsx)("meta",{name:"twitter:description",content:"إدارة ØØ³Ø§Ø¨Ù عÙÙ Ù
ÙØµØ© شاÙÙÙ"}),(0,a.jsx)("meta",{name:"twitter:image",content:"/lovable-uploads/icon.png"})]}),(0,a.jsx)(n.Bc,{children:(0,a.jsxs)(i.e,{children:[(0,a.jsx)(eh.y,{}),(0,a.jsx)(r.l,{}),(0,a.jsx)(l.l,{}),(0,a.jsx)(c.t,{children:(0,a.jsx)(eu.M,{children:(0,a.jsx)(em,{})})})]})})]})}},50526:(e,t,s)=>{"use strict";function a(e){return String(null!=e?e:"").toLowerCase().trim()}function r(e){return"pending"===a(e)}function l(e){let t="ÙÙ Ø£ÙØª Ù
ØªØ£ÙØ¯ Ù
Ù Ø¥ÙØºØ§Ø¡ ÙØ°Ø§ Ø§ÙØ·ÙبØ";return"wallet"===a(e)?"".concat(t,"\n\n")+"إذا ÙÙØ¬Ø¯ خصÙ
Ù
٠اÙÙ
ØÙظة ÙÙØ°Ø§ Ø§ÙØ·ÙØ¨Ø ÙÙØ¹Ø§Ø¯ اÙÙ
Ø¨ÙØº عادة٠إÙÙ Ù
ØÙظت٠بعد ÙØ¬Ø§Ø Ø§ÙØ¥Ùغاء. راجع تبÙÙØ¨ \xabاÙÙ
ØÙظة\xbb ÙØ³Ø¬Ù Ø§ÙØ¹Ù
ÙÙØ§Øª ÙÙØªØ£Ùد.":t}s.d(t,{ak:()=>l,bh:()=>r})},62910:(e,t,s)=>{"use strict";s.d(t,{A:()=>x});var a=s(37876),r=s(14232),l=s(92161),n=s(77041),i=s(65682),c=s(42341),d=s(18465),o=s(98737);let x=e=>{let{deliveryProofUrl:t,orderId:s}=e,[x,m]=(0,r.useState)(!0),[h,u]=(0,r.useState)(!1),[p,g]=(0,r.useState)(!1),j=(0,o.pk)(t,"full");return(0,a.jsxs)(l.lG,{open:p,onOpenChange:g,children:[(0,a.jsx)(l.zM,{asChild:!0,children:(0,a.jsxs)(n.$,{variant:"outline",size:"sm",className:"flex items-center gap-2",children:[(0,a.jsx)(c.A,{className:"h-4 w-4"}),"عرض إثبات Ø§ÙØªØ³ÙÙÙ
"]})}),(0,a.jsxs)(l.Cf,{className:"max-w-3xl",children:[(0,a.jsx)(l.c7,{children:(0,a.jsxs)(l.L3,{className:"flex items-center justify-between",children:[(0,a.jsxs)("span",{children:["إثبات Ø§ÙØªØ³ÙÙÙ
- Ø·ÙØ¨ #",s.slice(-8)]}),(0,a.jsxs)(i.E,{variant:"secondary",className:"bg-green-100 text-green-800",children:[(0,a.jsx)(d.A,{className:"h-3 w-3 mr-1"}),"تÙ
Ø§ÙØªØ³ÙÙÙ
"]})]})}),(0,a.jsxs)("div",{className:"relative",children:[x&&(0,a.jsx)("div",{className:"aspect-video bg-gray-100 rounded-lg flex items-center justify-center",children:(0,a.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-marketplace-primary"})}),h?(0,a.jsxs)("div",{className:"aspect-video bg-gray-100 rounded-lg flex flex-col items-center justify-center text-gray-500",children:[(0,a.jsx)(d.A,{className:"h-12 w-12 mb-2"}),(0,a.jsx)("p",{children:"تعذر تØÙ
ÙÙ ØµÙØ±Ø© إثبات Ø§ÙØªØ³ÙÙÙ
"})]}):(0,a.jsx)("img",{src:j,alt:"إثبات Ø§ÙØªØ³ÙÙÙ
- Ø·ÙØ¨ ".concat(s),className:"w-full rounded-lg shadow-lg transition-opacity duration-300 ".concat(x?"opacity-0":"opacity-100"),onLoad:()=>{m(!1)},onError:()=>{m(!1),u(!0)},loading:"lazy"})]}),(0,a.jsx)("div",{className:"text-sm text-gray-600 text-center",children:"ÙØ°Ù Ø§ÙØµÙرة تÙ
Ø§ÙØªÙØ§Ø·ÙØ§ Ø¹ÙØ¯ تسÙÙÙ
Ø§ÙØ·Ùب ÙØ¥Ø«Ø¨Ø§Øª عÙÙ ÙØµÙ٠اÙÙ
ÙØªØ¬Ø§Øª Ø¨ØØ§ÙØ© Ø¬ÙØ¯Ø©"})]})]})}},65084:(e,t,s)=>{"use strict";s.d(t,{Z:()=>n});var a=s(91196);let r={products:{staleTime:3e5,gcTime:9e5},categories:{staleTime:6e5,gcTime:18e5},vendors:{staleTime:3e5,gcTime:9e5},specialOffers:{staleTime:12e4,gcTime:6e5},favorites:{staleTime:6e4,gcTime:3e5},userData:{staleTime:3e4,gcTime:12e4},videoMetadata:{staleTime:6e5,gcTime:18e5},default:{staleTime:3e5,gcTime:9e5}},l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default";return r[e]||r.default},n=e=>{var t,s;let r={staleTime:3e5,gcTime:9e5};try{let t=e.cacheType||"default";r=l(t)}catch(e){console.warn("Error getting cache config, using default:",e)}let n=!1===e.enabled,{cacheType:i,...c}=e;return(0,a.I)({...c,staleTime:null!=(t=e.staleTime)?t:r.staleTime,gcTime:null!=(s=e.gcTime)?s:r.gcTime,retry:(e,t)=>t instanceof Error&&(t.message.includes("CORS")||t.message.includes("401")||t.message.includes("preflight"))?e<2:e<3,retryDelay:e=>Math.min(1e3*2**e,3e4),refetchOnWindowFocus:!1,refetchOnReconnect:!1,enabled:!n})}},89774:(e,t,s)=>{"use strict";s.d(t,{F:()=>l});var a=s(96575),r=s(94108);class l{static async getWalletBalance(){var e,t,s;let l=a.AuthService.getJwt();if(!l)throw Error("Authentication required. Please sign in to view wallet.");let n=await a.AuthService.getCurrentUserId();if(!n)throw Error("User not authenticated.");let i=await fetch("".concat((0,r.getEdgeFunctionsUrl)(),"/wallet-balance"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(l),apikey:(0,r.getSupabaseAnonKey)()},body:JSON.stringify({userId:n})});if(!i.ok){let e=await i.text();throw Error("Failed to fetch wallet balance: ".concat(i.status," ").concat(e))}let c=await i.json();if(!(null==c?void 0:c.success))throw Error((null==c?void 0:c.error)||"Failed to fetch wallet balance");return{wallet:c.wallet||(null==(e=c.data)?void 0:e.wallet)||{syp_balance:0,usd_balance:0,try_balance:0},preferredCurrency:c.preferredCurrency||(null==(t=c.data)?void 0:t.preferredCurrency)||"SYP",recentTransactions:c.recentTransactions||(null==(s=c.data)?void 0:s.recentTransactions)||[]}}static async createChargeRequest(e){let t=a.AuthService.getJwt();if(!t)throw Error("Authentication required. Please sign in to create a charge request.");let s=await a.AuthService.getCurrentUserId();if(!s)throw Error("User not authenticated.");let l=await fetch("".concat((0,r.getEdgeFunctionsUrl)(),"/wallet-charge-request"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t),apikey:(0,r.getSupabaseAnonKey)()},body:JSON.stringify({userId:s,amount:e.amount,currency:e.currency,paymentMethod:e.paymentMethod,receiptUrl:e.receiptUrl,notes:e.notes,confirmationCode:e.confirmationCode})});if(!l.ok){let e=await l.text();throw Error("Failed to create charge request: ".concat(l.status," ").concat(e))}let n=await l.json();if(!(null==n?void 0:n.success))throw Error((null==n?void 0:n.error)||"Failed to create charge request");return n.request}static async createWithdrawRequest(e){let t=a.AuthService.getJwt();if(!t)throw Error("Authentication required. Please sign in to create a withdrawal request.");let s=await a.AuthService.getCurrentUserId();if(!s)throw Error("User not authenticated.");let l=await fetch("".concat((0,r.getEdgeFunctionsUrl)(),"/wallet-withdraw-request"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t),apikey:(0,r.getSupabaseAnonKey)()},body:JSON.stringify({userId:s,amount:e.amount,currency:e.currency,paymentMethod:e.paymentMethod,recipientAccount:e.recipientAccount,notes:e.notes})});if(!l.ok){let e=await l.text();throw Error("Failed to create withdraw request: ".concat(l.status," ").concat(e))}let n=await l.json();if(!(null==n?void 0:n.success))throw Error((null==n?void 0:n.error)||"Failed to create withdraw request");return n.request}static async getChargeRequests(){let e=a.AuthService.getJwt();if(!e)throw Error("Authentication required. Please sign in to view charge requests.");let t=await a.AuthService.getCurrentUserId();if(!t)throw Error("User not authenticated.");let s=await fetch("".concat((0,r.getEdgeFunctionsUrl)(),"/wallet-charge-requests"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e),apikey:(0,r.getSupabaseAnonKey)()},body:JSON.stringify({userId:t})});if(!s.ok){let e=await s.text();throw Error("Failed to fetch charge requests: ".concat(s.status," ").concat(e))}let l=await s.json();if(!(null==l?void 0:l.success))throw Error((null==l?void 0:l.error)||"Failed to fetch charge requests");return l.data||[]}static async applyWalletToOrder(e){var t,s,l,n;let i=a.AuthService.getJwt();if(!i)throw Error("Authentication required.");let c=await a.AuthService.getCurrentUserId();if(!c)throw Error("User not authenticated.");let d=await fetch("".concat((0,r.getEdgeFunctionsUrl)(),"/wallet-apply"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(i),apikey:(0,r.getSupabaseAnonKey)()},body:JSON.stringify({userId:c,orderId:e.orderId,currency:e.currency,subtotal:e.subtotal,deliveryFee:null!=(t=e.deliveryFee)?t:0,couponsAppliedTotal:null!=(s=e.couponsAppliedTotal)?s:0,ruleCode:null!=(l=e.ruleCode)?l:"default",requestAmount:e.requestAmount})});if(!d.ok){let e=await d.text();throw Error("Wallet apply failed: ".concat(d.status," ").concat(e))}let o=await d.json();return(null==o?void 0:o.success)?{amount:null!=(n=o.amount)?n:0,success:!0}:null}static async applyWalletMulti(e){if(0===e.deductions.length)return!1;let t=a.AuthService.getJwt();if(!t)throw Error("Authentication required.");let s=await a.AuthService.getCurrentUserId();if(!s)throw Error("User not authenticated.");let l=e.deductions.filter(e=>e.amount>0);if(0===l.length)return!1;let n=await fetch("".concat((0,r.getEdgeFunctionsUrl)(),"/wallet-apply-multi"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t),apikey:(0,r.getSupabaseAnonKey)()},body:JSON.stringify({userId:s,orderId:e.orderId,deductions:l})});if(!n.ok){let e=await n.text();throw Error("Wallet apply-multi failed: ".concat(n.status," ").concat(e))}let i=await n.json();return(null==i?void 0:i.success)===!0}static async getStripeWalletPaymentUrl(e){if(![10,20,50,100].includes(e))throw Error("اÙÙ
Ø¨ÙØº ØºÙØ± ØµØ§ÙØ. اختر Ø£ØØ¯ اÙÙ
Ø¨Ø§ÙØº: 10Ø 20Ø 50Ø 100");let t=a.AuthService.getJwt();if(!t)throw Error("ÙØ¬Ø¨ تسجÙÙ Ø§ÙØ¯Ø®ÙÙ ÙØ§Ø³ØªØ®Ø¯Ø§Ù
Ø§ÙØ¯Ùع Ø¨Ø§ÙØ¨Ø·Ø§ÙØ©.");let s=await fetch("".concat((0,r.getEdgeFunctionsUrl)(),"/wallet-payment-links?amount=").concat(e),{method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t),apikey:(0,r.getSupabaseAnonKey)()}});if(!s.ok){let e=await s.text();throw Error("Failed to fetch payment link: ".concat(s.status," ").concat(e))}let l=await s.json(),n=null==l?void 0:l.url;if(!n||"string"!=typeof n)throw Error("ØªØ¹Ø°ÙØ± Ø§ÙØØµÙ٠عÙ٠رابط Ø§ÙØ¯Ùع. ØØ§ÙÙ Ù
رة أخرÙ.");return n}static async getWithdrawRequests(){let e=a.AuthService.getJwt();if(!e)throw Error("Authentication required. Please sign in to view withdraw requests.");let t=await a.AuthService.getCurrentUserId();if(!t)throw Error("User not authenticated.");let s=await fetch("".concat((0,r.getEdgeFunctionsUrl)(),"/wallet-withdraw-requests"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(e),apikey:(0,r.getSupabaseAnonKey)()},body:JSON.stringify({userId:t})});if(!s.ok){let e=await s.text();throw Error("Failed to fetch withdraw requests: ".concat(s.status," ").concat(e))}let l=await s.json();if(!(null==l?void 0:l.success))throw Error((null==l?void 0:l.error)||"Failed to fetch withdraw requests");return l.data||[]}}},98737:(e,t,s)=>{"use strict";s.d(t,{DD:()=>l,NN:()=>i,QC:()=>r,U$:()=>n,pk:()=>c,ue:()=>a});let a=()=>"/lovable-uploads/a321abf8-1dfc-42a4-8901-db2b1d1a203c.png",r=()=>"/lovable-uploads/a321abf8-1dfc-42a4-8901-db2b1d1a203c.png",l=()=>"/lovable-uploads/storelogo.png",n=()=>"https://images.unsplash.com/photo-1560472354-b33ff0c44a43?w=400&h=400&fit=crop&crop=center&auto=format",i=e=>
1new Promise(t=>{let s=new Image;s.onload=()=>t(!0),s.onerror=()=>t(!1),s.src=e}),c=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"medium";return e?e.includes("supabase.co/storage/v1/object/public/")?e+({thumbnail:"?width=300&height=200&resize=cover",medium:"?width=800&height=600&resize=contain",full:""})[t]:e:""}}},e=>{e.O(0,[1987,681,3740,633,7224,3595,6514,3058,1196,1144,445,5910,9958,5462,3909,5682,4894,2013,345,9398,636,6593,8792],()=>e(e.s=8172)),_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.