1 line
31 KiB
JavaScript
1 line
31 KiB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,78740,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.SEVERITY_COLORS=a.DAMAGE_ZONE_COORDS=void 0,a.DAMAGE_ZONE_COORDS={hood:{x:48,y:8,w:64,h:28},roof:{x:48,y:52,w:64,h:56},trunk:{x:48,y:124,w:64,h:28},"front-bumper":{x:48,y:0,w:64,h:10},"rear-bumper":{x:48,y:150,w:64,h:10},"front-left-fender":{x:20,y:10,w:30,h:35},"front-right-fender":{x:110,y:10,w:30,h:35},"front-left-door":{x:20,y:52,w:30,h:30},"front-right-door":{x:110,y:52,w:30,h:30},"rear-left-door":{x:20,y:82,w:30,h:30},"rear-right-door":{x:110,y:82,w:30,h:30},"rear-left-fender":{x:20,y:112,w:30,h:35},"rear-right-fender":{x:110,y:112,w:30,h:35},windshield:{x:52,y:38,w:56,h:18},"rear-window":{x:52,y:104,w:56,h:18},"left-mirror":{x:8,y:50,w:14,h:10},"right-mirror":{x:138,y:50,w:14,h:10},"front-left-wheel":{x:10,y:24,w:22,h:26},"front-right-wheel":{x:128,y:24,w:22,h:26},"rear-left-wheel":{x:10,y:110,w:22,h:26},"rear-right-wheel":{x:128,y:110,w:22,h:26},interior:{x:55,y:58,w:50,h:44},"under-hood":{x:52,y:10,w:56,h:20},undercarriage:{x:52,y:130,w:56,h:20}},a.SEVERITY_COLORS={SCRATCH:"#F59E0B",DENT:"#EF4444",CRACK:"#8B5CF6",MISSING:"#374151",OTHER:"#6B7280"}},33556,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.FUEL_POLICY_LABELS=void 0,a.FUEL_POLICY_LABELS={FULL_TO_FULL:{en:"Full-to-Full: Return vehicle with a full tank. A refueling fee applies if returned with less fuel.",fr:"Plein à plein : retournez le véhicule avec le plein. Des frais de ravitaillement s'appliquent sinon.",ar:"ممتلئ إلى ممتلئ: يجب إعادة السيارة بخزان ممتلئ. رسوم إضافية في حال الإعادة بمستوى أقل."},FULL_TO_EMPTY:{en:"Full-to-Empty: Vehicle is provided with a full tank. No refund for unused fuel upon return.",fr:"Plein à vide : le véhicule est livré avec le plein. Aucun remboursement n'est accordé pour le carburant non utilisé.",ar:"ممتلئ إلى فارغ: تُسلَّم السيارة بخزان ممتلئ. لا استرداد للوقود غير المستخدم."},SAME_TO_SAME:{en:"Same-to-Same: Return vehicle with the same fuel level as at pickup.",fr:"Même niveau : retournez le véhicule avec le même niveau de carburant qu'au départ.",ar:"نفس المستوى: أعد السيارة بنفس مستوى الوقود عند الاستلام."},PREPAID:{en:"Prepaid Fuel: You pre-purchase a full tank at a fixed rate. Return at any fuel level.",fr:"Carburant prépayé : vous achetez un plein à tarif fixe à l'avance. Retour possible avec n'importe quel niveau.",ar:"الوقود المدفوع مسبقاً: تدفع مقدماً ثمن خزان كامل بسعر ثابت. يمكن إعادة السيارة بأي مستوى."},FREE:{en:"Fuel Included: Fuel cost is included in the rental price.",fr:"Carburant inclus : le coût du carburant est inclus dans le tarif de location.",ar:"الوقود مشمول: تكلفة الوقود مشمولة في سعر الإيجار."}}},89456,(e,t,a)=>{"use strict";function r(e){if(e)return e;let t="object"==typeof globalThis&&"document"in globalThis?globalThis.document?.documentElement?.lang:void 0;return"en"===t||"fr"===t||"ar"===t?t:"en"}function n(e,t="MAD"){return"ar"===r(e)?"درهم":"MAD"}Object.defineProperty(a,"__esModule",{value:!0}),a.PLAN_FEATURES=a.PLAN_PRICES=void 0,a.getCurrencyLabel=n,a.formatCurrency=function(e,t="MAD",a){let s=r(a),i=new Intl.NumberFormat({en:"en-US",fr:"fr-FR",ar:"ar-MA"}[s],{minimumFractionDigits:2,maximumFractionDigits:2}).format(e/100),l=n(s,t);return"en"===s?`${l} ${i}`:`${i} ${l}`},a.PLAN_PRICES={STARTER:{MONTHLY:{MAD:2990},ANNUAL:{MAD:29900}},GROWTH:{MONTHLY:{MAD:3990},ANNUAL:{MAD:39900}},PRO:{MONTHLY:{MAD:99900},ANNUAL:{MAD:999e3}}},a.PLAN_FEATURES={STARTER:["Up to 10 vehicles","1 user account","Basic analytics","Marketplace listing"],GROWTH:["Up to 50 vehicles","5 user accounts","Full analytics","Priority marketplace placement","Custom branding"],PRO:["Unlimited vehicles","Unlimited user accounts","Advanced reports","API access","Dedicated support"]}},82110,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a.defaultMarketplaceHomepageContent=a.defaultMarketplaceHomepageSections=void 0,a.cloneMarketplaceHomepageContent=function(){return JSON.parse(JSON.stringify(a.defaultMarketplaceHomepageContent))},a.resolveMarketplaceHomepageSections=function(e){let t=e?.length?e:a.defaultMarketplaceHomepageSections;return t.filter((e,a)=>t.indexOf(e)===a)},a.defaultMarketplaceHomepageSections=["hero","surface","pillars","audiences","features","steps","closing"],a.defaultMarketplaceHomepageContent={en:{sections:a.defaultMarketplaceHomepageSections,heroKicker:"RentalDriveGo",heroTitle:"Marketplace discovery with a sharper front door.",heroBody:"Rental companies run private operations, renters browse a shared marketplace, and every booking ends on the company’s own branded checkout.",startTrial:"Start free trial",exploreVehicles:"Explore vehicles",surfaceLabel:"Marketplace surface",surfaceTitle:"Designed for two audiences at once.",surfaceBody:"Operators need control, renters need confidence. The marketplace should show both without feeling like a template.",liveLabel:"Live network",trustedFleets:"Trusted fleets",brandedFlows:"Branded booking flows",multiTenant:"Multi-tenant operations",companyKicker:"Operator workflow",companyTitle:"Manage inventory, offers, billing, and staff from one control layer.",companyBody:"Publish inventory once, decide what appears publicly, and keep contracts, payments, and reporting isolated per company.",renterKicker:"Renter experience",renterTitle:"Let renters compare quickly, then hand them off to the right company site.",renterBody:"The marketplace works as a discovery engine, not a dead-end aggregator. Search here, reserve there, and pay direct.",pillars:[["Unified publishing","Vehicle photos, pricing, and offers flow from one admin workflow into marketplace discovery and branded booking pages."],["Qualified discovery","Featured offers, location-aware browsing, and company reputation signals help renters narrow options fast."],["Direct revenue path","Bookings move into the company’s own payment flow, so customer ownership and cash collection stay with the business."]].map(([e,t])=>({title:e,body:t})),metrics:[["01","Shared marketplace visibility"],["02","Direct company checkout"],["03","Company-owned payments"]].map(([e,t])=>({value:e,label:t})),featureLabel:"What the product covers",features:["Fleet management with multi-photo uploads","Marketplace offers and redirect booking flow","Branded public booking site per company","Customer CRM, analytics, and billing controls"],stepsTitle:"How companies launch",steps:[["1","Create your company workspace","Pick a plan, launch your 90-day trial, and verify the owner account."],["2","Publish vehicles and offers","Upload photos once and control what appears on the marketplace and branded site."],["3","Accept bookings on your own site","Renters discover your fleet on RentalDriveGo, then pay you directly on your branded booking flow."]].map(([e,t,a])=>({step:e,title:t,body:a})),stepLabel:"Step",readyKicker:"Ready to launch",readyTitle:"The marketplace homepage should explain the product in seconds.",readyBody:"Use the marketplace to attract demand, then move renters into a branded experience that keeps pricing, payments, and trust tied to your company.",viewPricing:"View pricing",createWorkspace:"Create workspace"},fr:{sections:a.defaultMarketplaceHomepageSections,heroKicker:"RentalDriveGo",heroTitle:"Une vitrine marketplace plus claire et plus percutante.",heroBody:"Les entreprises de location gèrent leurs opérations en privé, les clients parcourent une marketplace commune et chaque réservation se finalise sur le parcours de paiement aux couleurs de l'entreprise.",startTrial:"Commencer l’essai gratuit",exploreVehicles:"Explorer les véhicules",surfaceLabel:"Vitrine marketplace",surfaceTitle:"Pensée pour deux audiences à la fois.",surfaceBody:"Les opérateurs veulent du contrôle, les clients veulent de la confiance. La marketplace doit montrer les deux sans ressembler à un modèle générique.",liveLabel:"Réseau actif",trustedFleets:"Flottes fiables",brandedFlows:"Parcours de marque",multiTenant:"Opérations multi-tenant",companyKicker:"Flux opérateur",companyTitle:"Pilotez l’inventaire, les offres, la facturation et l’équipe depuis un seul centre de contrôle.",companyBody:"Publiez une seule fois, choisissez ce qui apparaît publiquement, et gardez contrats, paiements et rapports isolés par entreprise.",renterKicker:"Expérience client",renterTitle:"Laissez les clients comparer rapidement, puis redirigez-les vers le bon site d’entreprise.",renterBody:"La marketplace sert de moteur de découverte, pas d’agrégateur sans suite. Recherche ici, réservation là-bas, paiement direct.",pillars:[["Publication unifiée","Les photos, tarifs et offres circulent depuis un seul flux d’administration vers la découverte marketplace et les pages de réservation de marque."],["Découverte qualifiée","Offres mises en avant, navigation par localisation et signaux de réputation aident les clients à filtrer rapidement."],["Revenus en direct","Les réservations basculent vers le paiement propre à l’entreprise afin de préserver la relation client et l’encaissement."]].map(([e,t])=>({title:e,body:t})),metrics:[["01","Visibilité marketplace partagée"],["02","Paiement direct entreprise"],["03","Paiements gérés par l’entreprise"]].map(([e,t])=>({value:e,label:t})),featureLabel:"Ce que couvre le produit",features:["Gestion de flotte avec téléversement de plusieurs photos","Offres marketplace et redirection vers la réservation","Site public de réservation par entreprise","CRM client, analytics et contrôle de facturation"],stepsTitle:"Comment les entreprises démarrent",steps:[["1","Créez votre espace entreprise","Choisissez un plan, lancez votre essai de 90 jours et vérifiez le compte propriétaire."],["2","Publiez véhicules et offres","Téléversez une seule fois et contrôlez ce qui apparaît sur la marketplace et le site de marque."],["3","Acceptez les réservations sur votre site","Les clients découvrent votre flotte sur RentalDriveGo puis paient directement via votre parcours de réservation."]].map(([e,t,a])=>({step:e,title:t,body:a})),stepLabel:"Étape",readyKicker:"Prêt à démarrer",readyTitle:"La page d’accueil marketplace doit présenter le produit en quelques secondes.",readyBody:"Utilisez la marketplace pour capter la demande, puis orientez les clients vers une expérience de marque où les prix, les paiements et la confiance restent attachés à votre entreprise.",viewPricing:"Voir les tarifs",createWorkspace:"Créer l’espace"},ar:{sections:a.defaultMarketplaceHomepageSections,heroKicker:"RentalDriveGo",heroTitle:"واجهة سوق أكثر وضوحاً وتأثيراً.",heroBody:"شركات التأجير تدير عملياتها بشكل خاص، والمستأجرون يتصفحون سوقاً مشتركاً، وكل حجز ينتهي في صفحة دفع تحمل هوية الشركة ذاتها.",startTrial:"ابدأ التجربة المجانية",exploreVehicles:"استكشف السيارات",surfaceLabel:"واجهة السوق",surfaceTitle:"مصممة لجمهورين في الوقت نفسه.",surfaceBody:"المشغلون يريدون التحكم، والمستأجرون يريدون الثقة. يجب أن تُظهر المنصة الأمرين معاً من دون أن تبدو كقالب عادي.",liveLabel:"شبكة نشطة",trustedFleets:"أساطيل موثوقة",brandedFlows:"مسارات حجز مخصصة",multiTenant:"عمليات متعددة الشركات",companyKicker:"سير عمل المشغل",companyTitle:"تحكم في المخزون والعروض والفوترة والفريق من طبقة تشغيل واحدة.",companyBody:"انشر المخزون مرة واحدة، وحدد ما يظهر للعامة، واحتفظ بالعقود والمدفوعات والتقارير معزولة لكل شركة.",renterKicker:"تجربة المستأجر",renterTitle:"دع المستأجرين يقارنون بسرعة ثم وجّههم إلى موقع الشركة المناسب.",renterBody:"هذه المنصة محرك لاكتشاف الخيارات، وليست مُجمِّعاً بلا مسار واضح. ابحث هنا، احجز هناك، وادفع مباشرة للشركة.",pillars:[["نشر موحد","صور السيارات والأسعار والعروض تنتقل من سير إدارة واحد إلى السوق وصفحات الحجز ذات الهوية الخاصة."],["اكتشاف مؤهل","تساعد العروض المميزة، والتصفح حسب الموقع، وإشارات السمعة المستأجرين على تحديد خياراتهم بسرعة."],["مسار إيراد مباشر","تنتقل الحجوزات إلى صفحة الدفع الخاصة بالشركة حتى تبقى علاقة العميل والتحصيل المالي بيد الشركة نفسها."]].map(([e,t])=>({title:e,body:t})),metrics:[["01","ظهور مشترك في السوق"],["02","دفع مباشر للشركة"],["03","مدفوعات مملوكة للشركة"]].map(([e,t])=>({value:e,label:t})),featureLabel:"ما الذي يقدمه المنتج",features:["إدارة الأسطول مع رفع عدة صور","عروض السوق والتحويل إلى مسار الحجز","موقع حجز عام مخصص لكل شركة","إدارة العملاء والتحليلات والفوترة"],stepsTitle:"كيف تبدأ الشركات",steps:[["1","أنشئ مساحة عمل شركتك","اختر الخطة وابدأ تجربتك لمدة 14 يوماً ثم فعّل حساب المالك."],["2","انشر السيارات والعروض","ارفع الصور مرة واحدة وتحكم فيما يظهر في السوق وفي الموقع المخصص."],["3","استقبل الحجوزات على موقعك","يكتشف المستأجرون أسطولك على RentalDriveGo ثم يدفعون مباشرة عبر مسار الحجز الخاص بك."]].map(([e,t,a])=>({step:e,title:t,body:a})),stepLabel:"الخطوة",readyKicker:"جاهز للانطلاق",readyTitle:"يجب أن تشرح الصفحة الرئيسية قيمة المنصة خلال ثوانٍ.",readyBody:"استخدم السوق لجذب الطلب، ثم انقل المستأجرين إلى تجربة تحمل هوية شركتك، بحيث تبقى الأسعار والمدفوعات والثقة مرتبطة بنشاطك.",viewPricing:"عرض الأسعار",createWorkspace:"إنشاء المساحة"}}},64712,(e,t,a)=>{"use strict";var r=e.e&&e.e.__createBinding||(Object.create?function(e,t,a,r){void 0===r&&(r=a);var n=Object.getOwnPropertyDescriptor(t,a);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,r,n)}:function(e,t,a,r){void 0===r&&(r=a),e[r]=t[a]}),n=e.e&&e.e.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||r(t,e,a)};Object.defineProperty(a,"__esModule",{value:!0}),n(e.r(78740),a),n(e.r(33556),a),n(e.r(89456),a),n(e.r(82110),a)},290,e=>{"use strict";var t=e.i(43476),a=e.i(18566),r=e.i(71645),n=e.i(64712),s=e.i(94327),i=e.i(56322);let l={TRIALING:"bg-sky-100 text-sky-700",ACTIVE:"bg-green-100 text-green-700",PAST_DUE:"bg-orange-100 text-orange-700",CANCELLED:"bg-slate-100 text-slate-600",UNPAID:"bg-red-100 text-red-700"},o={PAID:"bg-green-100 text-green-700",PENDING:"bg-orange-100 text-orange-700",FAILED:"bg-red-100 text-red-700",REFUNDED:"bg-slate-100 text-slate-600"},c=["STARTER","GROWTH","PRO"];e.s(["default",0,function(){let e=(0,a.useRouter)(),{language:d}=(0,i.useDashboardI18n)(),[u,p]=(0,r.useState)(null),[m,h]=(0,r.useState)([]),[x,f]=(0,r.useState)(!0),[b,y]=(0,r.useState)(null),[v,g]=(0,r.useState)(null),[P,A]=(0,r.useState)("STARTER"),[N,w]=(0,r.useState)("MONTHLY"),[E,S]=(0,r.useState)("AMANPAY"),[k,L]=(0,r.useState)({amanpay:!1,paypal:!1}),[T,j]=(0,r.useState)(n.PLAN_PRICES),[R,D]=(0,r.useState)([]),[C,M]=(0,r.useState)(!1),[O,I]=(0,r.useState)(!1),F={en:{title:"Subscription",subtitle:"Manage your plan, payment provider, and subscription invoices.",trial:"Free trial",remaining:"remaining. Subscribe before it ends to keep access.",currentPlan:"Current plan",renews:"renews",cancelScheduled:"Cancellation scheduled at end of billing period.",undo:"Undo",cancelling:"Cancelling…",cancelPlan:"Cancel plan",changePlan:"Change plan",subscribe:"Subscribe",selectPlan:"Select a plan and payment provider to proceed.",monthly:"Monthly",annual:"Annual (save ~17%)",active:"Active",perMonthShort:"mo",perYearShort:"yr",paymentProvider:"Payment provider",total:"Total",perMonth:"month",perYear:"year",redirecting:"Redirecting…",subscribeNow:"Subscribe now",invoiceHistory:"Invoice history",date:"Date",provider:"Provider",status:"Status",paid:"Paid",amount:"Amount",loading:"Loading…",noInvoices:"No invoices yet.",noProviderConfigured:"No payment provider is configured. Contact support to enable AmanPay or PayPal.",providerUnavailable:"This payment provider is not configured.",statusLabels:{TRIALING:"Trialing",ACTIVE:"Active",PAST_DUE:"Past due",CANCELLED:"Cancelled",UNPAID:"Unpaid"},invoiceStatusLabels:{PAID:"Paid",PENDING:"Pending",FAILED:"Failed",REFUNDED:"Refunded"},planFeatures:{STARTER:["Up to 10 vehicles","1 user seat","Basic analytics","Marketplace listing"],GROWTH:["Up to 50 vehicles","5 user seats","Full analytics","Priority listing","Custom branding"],PRO:["Unlimited vehicles","Unlimited seats","Advanced reports","API access","Dedicated support"]}},fr:{title:"Abonnement",subtitle:"Gérez votre plan, le prestataire de paiement et les factures d’abonnement.",trial:"Essai gratuit",remaining:"restants. Abonnez-vous avant la fin pour garder l’accès.",currentPlan:"Plan actuel",renews:"renouvelle le",cancelScheduled:"Annulation programmée à la fin de la période.",undo:"Annuler",cancelling:"Annulation…",cancelPlan:"Annuler le plan",changePlan:"Changer de plan",subscribe:"S’abonner",selectPlan:"Sélectionnez un plan et un prestataire de paiement.",monthly:"Mensuel",annual:"Annuel (économie ~17%)",active:"Actif",perMonthShort:"mois",perYearShort:"an",paymentProvider:"Prestataire de paiement",total:"Total",perMonth:"mois",perYear:"an",redirecting:"Redirection…",subscribeNow:"S’abonner maintenant",invoiceHistory:"Historique des factures",date:"Date",provider:"Prestataire",status:"Statut",paid:"Payé",amount:"Montant",loading:"Chargement…",noInvoices:"Aucune facture pour le moment.",noProviderConfigured:"Aucun prestataire de paiement n’est configuré. Contactez le support pour activer AmanPay ou PayPal.",providerUnavailable:"Ce prestataire de paiement n’est pas configuré.",statusLabels:{TRIALING:"Essai",ACTIVE:"Actif",PAST_DUE:"En retard",CANCELLED:"Annulé",UNPAID:"Impayé"},invoiceStatusLabels:{PAID:"Payé",PENDING:"En attente",FAILED:"Échec",REFUNDED:"Remboursé"},planFeatures:{STARTER:["Jusqu’à 10 véhicules","1 utilisateur","Analyses de base","Présence marketplace"],GROWTH:["Jusqu’à 50 véhicules","5 utilisateurs","Analyses complètes","Mise en avant prioritaire","Personnalisation"],PRO:["Véhicules illimités","Utilisateurs illimités","Rapports avancés","Accès API","Support dédié"]}},ar:{title:"الاشتراك",subtitle:"إدارة الخطة ومزوّد الدفع وفواتير الاشتراك.",trial:"تجربة مجانية",remaining:"متبقية. اشترك قبل انتهائها للحفاظ على الوصول.",currentPlan:"الخطة الحالية",renews:"يتجدد في",cancelScheduled:"تمت جدولة الإلغاء عند نهاية فترة الفوترة.",undo:"تراجع",cancelling:"جارٍ الإلغاء…",cancelPlan:"إلغاء الخطة",changePlan:"تغيير الخطة",subscribe:"اشتراك",selectPlan:"اختر خطة ومزوّد دفع للمتابعة.",monthly:"شهري",annual:"سنوي (توفير ~17%)",active:"نشط",perMonthShort:"شهر",perYearShort:"سنة",paymentProvider:"مزوّد الدفع",total:"الإجمالي",perMonth:"شهر",perYear:"سنة",redirecting:"جارٍ التحويل…",subscribeNow:"اشترك الآن",invoiceHistory:"سجل الفواتير",date:"التاريخ",provider:"المزوّد",status:"الحالة",paid:"مدفوع",amount:"المبلغ",loading:"جارٍ التحميل…",noInvoices:"لا توجد فواتير حتى الآن.",noProviderConfigured:"لا يوجد مزوّد دفع مهيأ. تواصل مع الدعم لتفعيل AmanPay أو PayPal.",providerUnavailable:"مزوّد الدفع هذا غير مهيأ.",statusLabels:{TRIALING:"تجريبي",ACTIVE:"نشط",PAST_DUE:"متأخر",CANCELLED:"ملغى",UNPAID:"غير مدفوع"},invoiceStatusLabels:{PAID:"مدفوع",PENDING:"قيد الانتظار",FAILED:"فشل",REFUNDED:"مسترد"},planFeatures:{STARTER:["حتى 10 مركبات","مستخدم واحد","تحليلات أساسية","إدراج في السوق"],GROWTH:["حتى 50 مركبة","5 مستخدمين","تحليلات كاملة","إدراج ذو أولوية","تخصيص العلامة"],PRO:["مركبات غير محدودة","مقاعد غير محدودة","تقارير متقدمة","وصول API","دعم مخصص"]}}}[d];(0,r.useEffect)(()=>{let t=window.localStorage.getItem(s.EMPLOYEE_PROFILE_KEY);if(t)try{let a=JSON.parse(t),r="OWNER"===a.role;g(r),r||e.replace("/");return}catch{}(0,s.apiFetch)("/auth/employee/me").then(({employee:t})=>{window.localStorage.setItem(s.EMPLOYEE_PROFILE_KEY,JSON.stringify(t));let a="OWNER"===t.role;g(a),a||e.replace("/")}).catch(()=>{g(!1),e.replace("/")})},[e]);let U=(0,r.useCallback)(async()=>{let[e,t]=await Promise.all([(0,s.apiFetch)("/subscriptions/plans"),(0,s.apiFetch)("/subscriptions/features")]);e&&Object.keys(e).length>0&&j(e),t&&D(t)},[]);if((0,r.useEffect)(()=>{!0===v&&Promise.all([(0,s.apiFetch)("/subscriptions/me"),(0,s.apiFetch)("/subscriptions/invoices"),(0,s.apiFetch)("/subscriptions/providers"),U()]).then(([e,t,a])=>{L(a),a.amanpay?S("AMANPAY"):a.paypal&&S("PAYPAL"),e&&(p(e),A(e.plan),w(e.billingPeriod)),h(t??[])}).catch(e=>y(e.message)).finally(()=>f(!1))},[v,U]),(0,r.useEffect)(()=>{if(!0!==v)return;let e=()=>{U().catch(()=>{})},t=()=>{"visible"===document.visibilityState&&U().catch(()=>{})};return window.addEventListener("focus",e),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("focus",e),document.removeEventListener("visibilitychange",t)}},[v,U]),!0!==v)return null;async function _(){M(!0),y(null);try{if("AMANPAY"===E&&!k.amanpay||"PAYPAL"===E&&!k.paypal)throw Error(F.providerUnavailable);let e=new URL(window.location.href);e.search="",e.hash="";let t=await (0,s.apiFetch)("/subscriptions/checkout",{method:"POST",body:JSON.stringify({plan:P,billingPeriod:N,currency:"MAD",provider:E,successUrl:`${e.toString()}?payment=success`,failureUrl:`${e.toString()}?payment=failed`})});window.location.href=t.checkoutUrl}catch(e){y(e.message),M(!1)}}async function Y(){I(!0),y(null);try{let e=await (0,s.apiFetch)("/subscriptions/cancel",{method:"POST"});p(e)}catch(e){y(e.message)}finally{I(!1)}}async function H(){I(!0),y(null);try{let e=await (0,s.apiFetch)("/subscriptions/resume",{method:"POST"});p(e)}catch(e){y(e.message)}finally{I(!1)}}let B=T[P]?.[N]?.MAD,G=u?.trialEndAt?Math.ceil((new Date(u.trialEndAt).getTime()-Date.now())/864e5):null;return(0,t.jsxs)("div",{className:"space-y-8",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-xl font-semibold text-slate-900",children:F.title}),(0,t.jsx)("p",{className:"text-sm text-slate-500 mt-1",children:F.subtitle})]}),b&&(0,t.jsx)("div",{className:"card p-4 border-red-200 bg-red-50 text-sm text-red-700",children:b}),u?.status==="TRIALING"&&null!==G&&G>0&&(0,t.jsx)("div",{className:"card p-4 border-sky-200 bg-sky-50 flex items-center justify-between",children:(0,t.jsxs)("p",{className:"text-sm font-medium text-sky-800",children:[F.trial," — ",(0,t.jsxs)("strong",{children:[G," days"]})," ",F.remaining]})}),u&&(0,t.jsx)("div",{className:"card p-6",children:(0,t.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-xs font-medium text-slate-500 uppercase tracking-wide",children:F.currentPlan}),(0,t.jsxs)("div",{className:"mt-1 flex items-center gap-3",children:[(0,t.jsx)("h3",{className:"text-2xl font-bold text-slate-900",children:u.plan}),(0,t.jsx)("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${l[u.status]??"bg-slate-100 text-slate-600"}`,children:F.statusLabels[u.status]??u.status})]}),(0,t.jsxs)("p",{className:"mt-1 text-sm text-slate-500",children:[u.billingPeriod," · ",u.currency,u.currentPeriodEnd&&` \xb7 ${F.renews} ${new Date(u.currentPeriodEnd).toLocaleDateString()}`]}),u.cancelAtPeriodEnd&&(0,t.jsxs)("p",{className:"mt-2 text-sm font-medium text-orange-700",children:[F.cancelScheduled," ",(0,t.jsx)("button",{onClick:H,disabled:O,className:"underline",children:F.undo})]})]}),!u.cancelAtPeriodEnd&&(0,t.jsx)("button",{onClick:Y,disabled:O,className:"btn-secondary text-red-600 border-red-200 hover:bg-red-50 text-sm",children:O?F.cancelling:F.cancelPlan})]})}),(0,t.jsxs)("div",{className:"card p-6 space-y-6",children:[k.amanpay||k.paypal?null:(0,t.jsx)("div",{className:"rounded-xl border border-orange-200 bg-orange-50 px-4 py-3 text-sm text-orange-700",children:F.noProviderConfigured}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-base font-semibold text-slate-900",children:u?.status==="ACTIVE"?F.changePlan:F.subscribe}),(0,t.jsx)("p",{className:"mt-1 text-sm text-slate-500",children:F.selectPlan})]}),(0,t.jsx)("div",{className:"flex items-center gap-2",children:["MONTHLY","ANNUAL"].map(e=>(0,t.jsx)("button",{onClick:()=>w(e),className:`px-4 py-1.5 rounded-full text-sm font-medium transition-colors ${N===e?"bg-blue-900 text-white":"bg-slate-100 text-slate-600 hover:bg-slate-200"}`,children:"MONTHLY"===e?F.monthly:F.annual},e))}),(0,t.jsx)("div",{className:"grid gap-4 md:grid-cols-3",children:c.map(e=>{let a=T[e]?.[N]?.MAD,r=u?.plan===e&&u?.status==="ACTIVE",s=R.filter(t=>t.plan===e);return(0,t.jsxs)("button",{onClick:()=>A(e),className:`text-left p-5 rounded-xl border-2 transition-all ${P===e?"border-blue-500 bg-blue-50/50":"border-slate-200 hover:border-slate-300 bg-white"} ${r?"ring-2 ring-green-200":""}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("p",{className:"font-semibold text-slate-900",children:e}),r&&(0,t.jsx)("span",{className:"badge-green",children:F.active})]}),(0,t.jsxs)("p",{className:"mt-2 text-2xl font-black text-slate-900",children:[a?(0,n.formatCurrency)(a,"MAD"):"—",(0,t.jsxs)("span",{className:"text-sm font-normal text-slate-500",children:["/","MONTHLY"===N?F.perMonthShort:F.perYearShort]})]}),(0,t.jsx)("ul",{className:"mt-3 space-y-1",children:s.length>0?s.map(e=>(0,t.jsxs)("li",{className:"text-xs text-slate-600 flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-green-500",children:"✓"})," ",e.label]},e.id)):F.planFeatures[e].map(e=>(0,t.jsxs)("li",{className:"text-xs text-slate-600 flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-green-500",children:"✓"})," ",e]},e))})]},e)})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-slate-700 mb-2",children:F.paymentProvider}),(0,t.jsxs)("div",{className:"flex gap-3",children:[k.amanpay?(0,t.jsx)("button",{onClick:()=>S("AMANPAY"),className:`flex items-center gap-2 px-4 py-2.5 rounded-xl border-2 text-sm font-medium transition-all ${"AMANPAY"===E?"border-blue-500 bg-blue-50 text-blue-700":"border-slate-200 text-slate-600 hover:border-slate-300"}`,children:"🏦 AmanPay"}):null,k.paypal?(0,t.jsx)("button",{onClick:()=>S("PAYPAL"),className:`flex items-center gap-2 px-4 py-2.5 rounded-xl border-2 text-sm font-medium transition-all ${"PAYPAL"===E?"border-blue-500 bg-blue-50 text-blue-700":"border-slate-200 text-slate-600 hover:border-slate-300"}`,children:"🔵 PayPal"}):null]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between pt-2 border-t border-slate-100",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm text-slate-500",children:F.total}),(0,t.jsxs)("p",{className:"text-xl font-black text-slate-900",children:[B?(0,n.formatCurrency)(B,"MAD"):"—",(0,t.jsxs)("span",{className:"text-sm font-normal text-slate-500 ml-1",children:["/","MONTHLY"===N?F.perMonth:F.perYear]})]})]}),(0,t.jsx)("button",{onClick:_,disabled:C||x||!k.amanpay&&!k.paypal,className:"btn-primary px-8 py-3",children:C?F.redirecting:u?.status==="ACTIVE"?F.changePlan:F.subscribeNow})]})]}),(0,t.jsxs)("div",{className:"card overflow-hidden",children:[(0,t.jsx)("div",{className:"px-6 py-4 border-b border-slate-200",children:(0,t.jsx)("h3",{className:"text-base font-semibold text-slate-900",children:F.invoiceHistory})}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"bg-slate-50 border-b border-slate-200",children:[(0,t.jsx)("th",{className:"text-left px-6 py-3 text-xs font-medium text-slate-500 uppercase tracking-wide",children:F.date}),(0,t.jsx)("th",{className:"text-left px-6 py-3 text-xs font-medium text-slate-500 uppercase tracking-wide",children:F.provider}),(0,t.jsx)("th",{className:"text-left px-6 py-3 text-xs font-medium text-slate-500 uppercase tracking-wide",children:F.status}),(0,t.jsx)("th",{className:"text-left px-6 py-3 text-xs font-medium text-slate-500 uppercase tracking-wide",children:F.paid}),(0,t.jsx)("th",{className:"text-right px-6 py-3 text-xs font-medium text-slate-500 uppercase tracking-wide",children:F.amount})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-slate-100",children:x?(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:5,className:"px-6 py-10 text-center text-sm text-slate-400",children:F.loading})}):0===m.length?(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:5,className:"px-6 py-10 text-center text-sm text-slate-400",children:F.noInvoices})}):m.map(e=>(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{className:"px-6 py-4 text-sm text-slate-700",children:new Date(e.createdAt).toLocaleDateString()}),(0,t.jsx)("td",{className:"px-6 py-4 text-sm text-slate-700",children:e.paymentProvider}),(0,t.jsx)("td",{className:"px-6 py-4",children:(0,t.jsx)("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${o[e.status]??"bg-slate-100 text-slate-600"}`,children:F.invoiceStatusLabels[e.status]??e.status})}),(0,t.jsx)("td",{className:"px-6 py-4 text-sm text-slate-500",children:e.paidAt?new Date(e.paidAt).toLocaleDateString():"—"}),(0,t.jsx)("td",{className:"px-6 py-4 text-right text-sm font-semibold text-slate-900",children:(0,n.formatCurrency)(e.amount,"MAD")})]},e.id))})]})})]})]})}])}]); |