y("apple"),children:"Apple Wallet"}),i.jsx("button",{type:"button",className:"chip","aria-pressed":v==="google",onClick:()=>y("google"),children:"Google Wallet"})]}),v==="apple"?i.jsx(Mg,{d:_}):i.jsx(Ag,{d:_}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Aperçu indicatif — QR et solde fictifs."})]})]})}function ky({rewards:e,unit:t,onChange:n}){const r=(l,s)=>n(e.map((o,a)=>a===l?{...o,...s}:o));return i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Récompenses"}),e.length===0&&i.jsxs("p",{className:"muted",style:{margin:0},children:["Aucune récompense. Exemple : « Café offert » pour 10 ",t,"."]}),e.map((l,s)=>i.jsxs("div",{className:"row",style:{alignItems:"flex-end",opacity:l.active===!1?.6:1},children:[i.jsxs("div",{className:"field",style:{flex:"1 1 240px"},children:[i.jsx("label",{htmlFor:`rw-label-${s}`,children:"Libellé"}),i.jsx("input",{id:`rw-label-${s}`,className:"input",maxLength:60,value:l.label,onChange:o=>r(s,{label:o.target.value})})]}),i.jsxs("div",{className:"field",style:{width:140},children:[i.jsxs("label",{htmlFor:`rw-cost-${s}`,children:["Coût (",t,")"]}),i.jsx("input",{id:`rw-cost-${s}`,className:"input",type:"number",min:1,value:l.cost,onChange:o=>r(s,{cost:Number(o.target.value)})})]}),l.active===!1?i.jsx("button",{type:"button",className:"btn secondary",onClick:()=>r(s,{active:!0}),children:"Réactiver"}):i.jsx("button",{type:"button",className:"btn secondary","aria-label":`Retirer ${l.label||"la récompense"}`,onClick:()=>n(e.filter((o,a)=>a!==s)),children:"Retirer"})]},l.id??`new-${s}`)),i.jsx("div",{children:i.jsx("button",{type:"button",className:"btn secondary",disabled:e.length>=20,onClick:()=>n([...e,{label:"",cost:10}]),children:"+ Ajouter une récompense"})})]})}const Uf={MANAGER:"Dirigeant",EMPLOYEE:"Employé"};function Py({storeId:e}){const t=`/api/admin/stores/${e}/staff`,[n,r]=w.useState([]),[l,s]=w.useState(null),[o,a]=w.useState(null),u=w.useRef(null),c=w.useRef(null),f=w.useCallback(()=>{b.get(t).then(r).catch(y=>s(y.message))},[t]);w.useEffect(f,[f]);function h(y){var j;a(y),(j=c.current)==null||j.showModal(),f()}async function g(y){try{await b.patch(`${t}/${y.id}`,{active:!y.active}),f()}catch(j){s(j.message)}}async function v(y){if(window.confirm(`Générer un nouveau mot de passe pour ${y.displayName} ? Ses sessions seront fermées.`))try{h(await b.post(`${t}/${y.id}/reset-password`))}catch(j){s(j.message)}}return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"row between",children:[i.jsx("h2",{children:"Employés"}),i.jsx("button",{className:"btn",onClick:()=>{var y;return(y=u.current)==null?void 0:y.showModal()},children:"+ Nouvel employé"})]}),l&&i.jsx("div",{className:"alert error",role:"alert",children:l}),i.jsxs("div",{className:"table-wrap",children:[i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{style:{minWidth:720},children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{scope:"col",style:{paddingLeft:24},children:"Nom"}),i.jsx("th",{scope:"col",children:"E-mail"}),i.jsx("th",{scope:"col",children:"Rôle"}),i.jsx("th",{scope:"col",children:"Statut"}),i.jsx("th",{scope:"col",children:i.jsx("span",{className:"sr-only",children:"Actions"})})]})}),i.jsx("tbody",{children:n.map(y=>i.jsxs("tr",{style:{opacity:y.active?1:.6},children:[i.jsx("td",{style:{paddingLeft:24,fontWeight:600},children:y.displayName}),i.jsx("td",{children:y.email}),i.jsx("td",{children:Uf[y.role]}),i.jsx("td",{children:y.active?i.jsx("span",{className:"badge ACTIVE",children:"Actif"}):i.jsx("span",{className:"badge DRAFT",children:"Désactivé"})}),i.jsxs("td",{style:{textAlign:"right",whiteSpace:"nowrap"},children:[i.jsx("button",{className:"btn secondary small",onClick:()=>v(y),children:"Nouveau mot de passe"})," ",i.jsx("button",{className:"btn secondary small",onClick:()=>g(y),children:y.active?"Désactiver":"Réactiver"})]})]},y.id))})]})}),n.length===0&&i.jsx("p",{className:"muted",style:{padding:24,margin:0,textAlign:"center"},children:"Aucun employé. Créez au moins un dirigeant pour que le magasin puisse utiliser l'app Pro."})]}),i.jsx("dialog",{ref:u,"aria-labelledby":"new-staff-title",children:i.jsx(Ry,{base:t,onCancel:()=>{var y;return(y=u.current)==null?void 0:y.close()},onCreated:y=>{var j;(j=u.current)==null||j.close(),h(y)}})}),i.jsx("dialog",{ref:c,"aria-labelledby":"pwd-title",children:i.jsxs("div",{className:"dialog-body",children:[i.jsx("h2",{id:"pwd-title",children:"Mot de passe provisoire"}),i.jsxs("p",{style:{margin:0},children:["Communiquez-le à ",i.jsx("strong",{children:o==null?void 0:o.displayName})," (",o==null?void 0:o.email,"). Il ne sera plus affiché ensuite."]}),i.jsx("div",{className:"password-box",children:o==null?void 0:o.provisionalPassword}),i.jsxs("div",{className:"row",style:{justifyContent:"flex-end"},children:[i.jsx("button",{className:"btn secondary",onClick:()=>{var y;return(y=navigator.clipboard)==null?void 0:y.writeText((o==null?void 0:o.provisionalPassword)??"")},children:"Copier"}),i.jsx("button",{className:"btn",onClick:()=>{var y;return(y=c.current)==null?void 0:y.close()},children:"J'ai noté le mot de passe"})]})]})})]})}function Ry({base:e,onCancel:t,onCreated:n}){const[r,l]=w.useState(""),[s,o]=w.useState(""),[a,u]=w.useState("EMPLOYEE"),[c,f]=w.useState(null),[h,g]=w.useState(!1);async function v(y){y.preventDefault(),g(!0),f(null);try{n(await b.post(e,{displayName:r,email:s,role:a})),l(""),o(""),u("EMPLOYEE")}catch(j){f(j.message)}finally{g(!1)}}return i.jsxs("form",{className:"dialog-body",onSubmit:v,children:[i.jsx("h2",{id:"new-staff-title",children:"Nouvel employé"}),c&&i.jsx("div",{className:"alert error",role:"alert",children:c}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"staff-name",children:"Prénom et nom *"}),i.jsx("input",{id:"staff-name",className:"input",required:!0,placeholder:"Prénom Nom",value:r,onChange:y=>l(y.target.value)})]}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"staff-email",children:"E-mail *"}),i.jsx("input",{id:"staff-email",className:"input",type:"email",required:!0,placeholder:"prenom@exemple.fr",value:s,onChange:y=>o(y.target.value)})]}),i.jsxs("fieldset",{style:{border:0,padding:0,margin:0},className:"field",children:[i.jsx("legend",{style:{fontWeight:600,marginBottom:6},children:"Rôle *"}),i.jsx("div",{className:"mode-cards",children:["EMPLOYEE","MANAGER"].map(y=>i.jsxs("label",{className:"mode-card",children:[i.jsx("input",{type:"radio",name:"role",checked:a===y,onChange:()=>u(y)}),i.jsxs("span",{children:[i.jsx("strong",{children:Uf[y]}),i.jsx("br",{}),i.jsx("span",{className:"muted",style:{fontSize:14},children:y==="MANAGER"?"Toute la configuration : carte, modules, campagnes, employés, statistiques":"Scanne les cartes et crédite les points, voit ses opérations"})]})]},y))})]}),i.jsx("p",{className:"muted",style:{margin:0,fontSize:14},children:"Un mot de passe provisoire sera généré à la création."}),i.jsxs("div",{className:"row",style:{justifyContent:"flex-end"},children:[i.jsx("button",{type:"button",className:"btn secondary",onClick:t,children:"Annuler"}),i.jsx("button",{className:"btn",disabled:h,children:"Créer le compte"})]})]})}const zu={ACTIVE:["Actif","ACTIVE"],INCOMPLETE:["En attente de paiement","DRAFT"],PAST_DUE:["Impayé","SUSPENDED"],CANCELED:["Résilié","CLOSED"]},Ty={multiStore:"Carte commune à plusieurs magasins"},Iu=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:e%100?2:0}),Gn=e=>new Date(e).toLocaleDateString("fr-FR",{day:"numeric",month:"short",year:"numeric"});function Ly({storeId:e,contactEmail:t,onChange:n}){const[r,l]=w.useState(null),[s,o]=w.useState(null),[a,u]=w.useState(null),[c,f]=w.useState(!1),[h,g]=w.useState(null),[v,y]=w.useState(null),j=w.useCallback(()=>{b.get(`/api/admin/stores/${e}/billing`).then(l).catch(S=>o(S.message))},[e]);w.useEffect(j,[j]);async function E(S,N,P){f(!0),o(null);try{const z=await b.post(N,P);u({...z,label:S}),j(),n()}catch(z){o(z.message)}finally{f(!1)}}if(!r)return s?i.jsx("div",{className:"alert error",children:s}):i.jsx("p",{className:"muted",children:"Chargement…"});const p=r.subscription,d=p&&p.status!=="CANCELED"&&p.hasSubscription?r.catalog.find(S=>S.plan===p.plan):null,m=!d,x=h??(p==null?void 0:p.plan)??"PRO",C=v??(p==null?void 0:p.interval)??"MONTH";return i.jsxs(i.Fragment,{children:[r.testMode&&i.jsx("div",{className:"alert warn",children:"Stripe est en mode test : aucun paiement réel n'est encaissé (carte de test 4242 4242 4242 4242)."}),s&&i.jsx("div",{className:"alert error",role:"alert",children:s}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:16},children:[i.jsxs("div",{className:"row between",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Abonnement"}),i.jsx("p",{className:"muted",style:{margin:0},children:d?`Formule ${d.name}${p.legacyPrice?" (tarif fondateur)":""} — ${p.interval==="YEAR"?"annuelle":"mensuelle"}`:"Aucune formule souscrite. Sans abonnement actif, le magasin a les droits de la formule Essentiel."})]}),i.jsx("span",{className:`badge ${p?zu[p.status][1]:"DRAFT"}`,children:p?zu[p.status][0]:"Aucun abonnement"})]}),(p==null?void 0:p.cancelAtPeriodEnd)&&p.currentPeriodEnd&&i.jsxs("div",{className:"alert warn",children:["Résiliation demandée : l'abonnement s'arrête le ",i.jsx("strong",{children:Gn(p.currentPeriodEnd)}),"."]}),(p==null?void 0:p.currentPeriodEnd)&&p.status==="ACTIVE"&&!p.cancelAtPeriodEnd&&i.jsxs("p",{style:{margin:0},children:["Prochain prélèvement le ",i.jsx("strong",{children:Gn(p.currentPeriodEnd)}),"."]}),r.billingSuspended&&i.jsx("div",{className:"alert warn",children:"Magasin suspendu automatiquement pour impayé. Il sera réactivé dès que le paiement passera."}),d&&i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsxs("button",{className:"btn",disabled:c,onClick:()=>E("Espace abonnement",`/api/admin/stores/${e}/billing/portal-link`,{sendEmail:!0}),children:["Envoyer l'espace abonnement à ",t]}),i.jsx("button",{className:"btn secondary",disabled:c,onClick:()=>E("Espace abonnement",`/api/admin/stores/${e}/billing/portal-link`,{sendEmail:!1}),children:"Ouvrir l'espace abonnement"}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Changer de formule, de moyen de paiement, résilier."})]})]}),m&&i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:20},children:[i.jsxs("div",{className:"row between",children:[i.jsx("h2",{children:"Choisir une formule"}),i.jsxs("div",{role:"group","aria-label":"Périodicité",className:"row",style:{gap:8},children:[i.jsx("button",{type:"button",className:"chip","aria-pressed":C==="MONTH",onClick:()=>y("MONTH"),children:"Mensuel"}),i.jsx("button",{type:"button",className:"chip","aria-pressed":C==="YEAR",onClick:()=>y("YEAR"),children:"Annuel — 2 mois offerts"})]})]}),i.jsx("div",{className:"mode-cards",role:"radiogroup","aria-label":"Formule",children:r.catalog.map(S=>i.jsxs("label",{className:"mode-card",style:{flexDirection:"column",gap:8},children:[i.jsxs("span",{className:"row",style:{gap:10},children:[i.jsx("input",{type:"radio",name:"plan",checked:x===S.plan,onChange:()=>g(S.plan)}),i.jsx("strong",{style:{fontSize:18},children:S.name}),S.plan==="PRO"&&i.jsx("span",{className:"badge ACTIVE",style:{height:22},children:"Conseillée"})]}),i.jsxs("span",{style:{fontSize:24,fontWeight:800},children:[Iu(S.priceCents[C]),i.jsxs("span",{className:"muted",style:{fontSize:14,fontWeight:500},children:[" / ",C==="YEAR"?"an":"mois",S.plan==="RESEAU"?" / magasin":""]})]}),i.jsx("span",{className:"muted",style:{fontSize:14},children:S.tagline}),i.jsxs("ul",{style:{margin:0,paddingLeft:18,fontSize:14,lineHeight:1.6},children:[i.jsx("li",{children:S.limits.maxStaff?`${S.limits.maxStaff} employés`:"Employés illimités"}),i.jsx("li",{children:"Carte Wallet, points ou tampons, récompenses, mises à jour en direct"}),S.features.map(N=>i.jsx("li",{children:Ty[N]??N},N))]}),i.jsx("span",{style:{fontSize:14,fontWeight:700},children:S.modules.length?`Modules inclus (${S.modules.length})`:"Aucun module inclus"}),S.modules.length>0&&i.jsx("ul",{style:{margin:0,paddingLeft:18,fontSize:14,lineHeight:1.6},children:S.modules.map(N=>i.jsx("li",{title:N.tagline,children:N.name},N.id))})]},S.plan))}),i.jsxs("p",{className:"muted",style:{margin:0,fontSize:14},children:["Lien permanent (il ne périme pas) : ",i.jsx("a",{href:r.subscribeUrl,target:"_blank",rel:"noreferrer",style:{wordBreak:"break-all"},children:r.subscribeUrl}),". Le commerçant pourra saisir un code promo sur la page de paiement (codes à créer dans Stripe → Coupons)."]}),i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsxs("button",{className:"btn",disabled:c,onClick:()=>E("Lien d'abonnement",`/api/admin/stores/${e}/billing/checkout-link`,{plan:x,interval:C,sendEmail:!0}),children:["Envoyer le lien à ",t]}),i.jsx("button",{className:"btn secondary",disabled:c,onClick:()=>E("Lien d'abonnement",`/api/admin/stores/${e}/billing/checkout-link`,{plan:x,interval:C,sendEmail:!1}),children:"Enregistrer la formule sans envoyer"})]})]}),a&&i.jsxs("div",{className:"alert ok",children:[a.label," ",a.emailedTo?i.jsxs(i.Fragment,{children:["envoyé à ",i.jsx("strong",{children:a.emailedTo}),". "]}):"créé. ",i.jsx("a",{href:a.url,target:"_blank",rel:"noreferrer",style:{wordBreak:"break-all"},children:a.url})]}),i.jsxs("div",{className:"table-wrap",children:[i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{style:{minWidth:720},children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{scope:"col",style:{paddingLeft:24},children:"Facture"}),i.jsx("th",{scope:"col",children:"Objet"}),i.jsx("th",{scope:"col",children:"Période"}),i.jsx("th",{scope:"col",className:"num",children:"Montant"}),i.jsx("th",{scope:"col",children:"Statut"}),i.jsx("th",{scope:"col",children:i.jsx("span",{className:"sr-only",children:"PDF"})})]})}),i.jsx("tbody",{children:r.invoices.map(S=>i.jsxs("tr",{children:[i.jsx("td",{style:{paddingLeft:24,fontWeight:600},children:S.number}),i.jsx("td",{style:{fontSize:14},children:S.description.replace("Abonnement MonEspacePro — ","")}),i.jsxs("td",{children:[Gn(S.periodStart)," → ",Gn(S.periodEnd)]}),i.jsx("td",{className:"num",children:Iu(S.amountCents)}),i.jsx("td",{children:S.paidAt?i.jsxs("span",{className:"badge ACTIVE",children:["Payée le ",Gn(S.paidAt)]}):i.jsx("span",{className:"badge SUSPENDED",children:"Impayée"})}),i.jsx("td",{style:{textAlign:"right",paddingRight:24},children:i.jsx("button",{className:"btn secondary small",onClick:()=>to(`/api/admin/invoices/${S.id}/pdf`,`${S.number}.pdf`).catch(N=>o(N.message)),children:"PDF"})})]},S.id))})]})}),r.invoices.length===0&&i.jsx("p",{className:"muted",style:{padding:24,margin:0,textAlign:"center"},children:"Aucune facture pour l'instant. Elles sont créées automatiquement à chaque paiement."})]})]})}const Fu=e=>new Date(e).toLocaleString("fr-FR",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"});function _y({storeId:e,storeName:t}){const[n,r]=w.useState(null),[l,s]=w.useState(""),[o,a]=w.useState(null),[u,c]=w.useState(null),[f,h]=w.useState(null),[g,v]=w.useState(!1),y=w.useCallback(()=>{b.get(`/api/admin/stores/${e}/campaigns`).then(r).catch(d=>c(d.message))},[e]);if(w.useEffect(y,[y]),!n)return u?i.jsx("div",{className:"alert error",children:u}):i.jsx("p",{className:"muted",children:"Chargement…"});const j=l.trim(),E=!n.allowed||!!n.nextAllowedAt;async function p(){if(confirm(`Envoyer ce message aux ${n.audience.cards} cartes de ${t} ?
+
+« ${j} »`)){v(!0),c(null);try{await b.post(`/api/admin/stores/${e}/campaigns`,{message:j,title:(o??n.defaultTitle).trim()}),s(""),h("Campagne envoyée. Les cartes se mettent à jour dans les minutes qui suivent."),y()}catch(d){c(d.message)}finally{v(!1)}}}return i.jsxs(i.Fragment,{children:[u&&i.jsx("div",{className:"alert error",role:"alert",children:u}),f&&i.jsx("div",{className:"alert ok",role:"status",children:f}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:16},children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Nouvelle campagne"}),i.jsxs("p",{className:"muted",style:{margin:0},children:["Le message apparaît en notification sur le téléphone des clients et reste visible sur leur carte. Audience : ",i.jsx("strong",{children:n.audience.cards})," cartes, dont ",i.jsx("strong",{children:n.audience.appleDevices})," iPhone joignables (Google Wallet : tous les clients qui ont ajouté la carte)."]})]}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"campaign-title",children:"Titre de la notification"}),i.jsx("input",{id:"campaign-title",className:"input",maxLength:40,value:o??n.defaultTitle,onChange:d=>a(d.target.value),disabled:E||g}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Affiché sur Google Wallet. Sur iPhone, le nom du magasin apparaît toujours en titre."})]}),i.jsx("label",{htmlFor:"campaign-msg",children:"Message"}),i.jsx("textarea",{id:"campaign-msg",className:"input",rows:3,maxLength:n.maxLength,placeholder:"Ex. : -20 % sur les viennoiseries ce samedi, sur présentation de votre carte !",value:l,onChange:d=>s(d.target.value),disabled:E||g}),i.jsxs("div",{className:"row between",children:[i.jsxs("span",{className:"muted",style:{fontSize:14},children:[j.length," / ",n.maxLength," caractères · 1 campagne toutes les ",n.minIntervalHours," h maximum"]}),i.jsx("button",{className:"btn",disabled:E||g||j.length<5,onClick:p,children:g?"Envoi…":"Envoyer la campagne"})]}),n.nextAllowedAt&&i.jsxs("div",{className:"alert warn",children:["Prochain envoi possible le ",Fu(n.nextAllowedAt),"."]})]}),i.jsxs("section",{className:"card",children:[i.jsx("h2",{children:"Historique"}),n.items.length===0?i.jsx("p",{className:"muted",style:{margin:0},children:"Aucune campagne envoyée pour l'instant."}):i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{scope:"col",children:"Date"}),i.jsx("th",{scope:"col",children:"Message"}),i.jsx("th",{scope:"col",children:"Envoyée par"}),i.jsx("th",{scope:"col",className:"num",children:"Cartes"})]})}),i.jsx("tbody",{children:n.items.map(d=>i.jsxs("tr",{children:[i.jsx("td",{className:"muted",style:{whiteSpace:"nowrap"},children:Fu(d.createdAt)}),i.jsxs("td",{children:[d.title&&i.jsxs("strong",{children:[d.title," · "]}),d.message]}),i.jsx("td",{children:d.sentByName}),i.jsx("td",{className:"num",children:d.cards})]},d.id))})]})})]})]})}function My({m:e}){const[t,n]=e.override===!0?["Ajouté sur mesure","ACTIVE"]:e.override===!1?["Retiré","CLOSED"]:e.inPlan?["Inclus dans la formule","ACTIVE"]:["Non inclus","DRAFT"];return i.jsx("span",{className:`badge ${n}`,children:t})}function Ay({f:e,value:t,onChange:n}){var a;const r=`f-${e.key}`,l=i.jsxs(i.Fragment,{children:[e.help&&i.jsxs("span",{className:"muted",style:{fontSize:14},children:[e.help," "]}),"variables"in e&&((a=e.variables)!=null&&a.length)?i.jsxs("span",{className:"muted",style:{fontSize:14},children:["Variables : ",e.variables.map(u=>i.jsx("code",{style:{marginRight:6},children:u},u))]}):null]});if(e.type==="boolean")return i.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,fontWeight:600},children:[i.jsx("input",{type:"checkbox",checked:!!t,onChange:u=>n(u.target.checked)}),e.label,e.help&&i.jsxs("span",{className:"muted",style:{fontWeight:400,fontSize:14},children:["— ",e.help]})]});if(e.type==="int"||e.type==="hour")return i.jsxs("div",{children:[i.jsx("label",{htmlFor:r,style:{fontWeight:600},children:e.label}),i.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[i.jsx("input",{id:r,className:"input",type:"number",style:{width:120},min:e.min,max:e.max,value:Number(t),onChange:u=>n(Math.floor(Number(u.target.value)||0))}),i.jsx("span",{className:"muted",children:e.type==="hour"?"h":e.unit})]}),l]});const s=e,o=String(t??"");return i.jsxs("div",{children:[i.jsx("label",{htmlFor:r,style:{fontWeight:600},children:e.label}),s.type==="textarea"?i.jsx("textarea",{id:r,className:"input",rows:2,maxLength:s.maxLength,value:o,onChange:u=>n(u.target.value)}):i.jsx("input",{id:r,className:"input",type:s.type==="url"?"url":"text",maxLength:s.maxLength,value:o,onChange:u=>n(u.target.value)}),i.jsxs("div",{className:"row between",style:{gap:8},children:[i.jsx("span",{children:l}),i.jsxs("span",{className:"muted",style:{fontSize:13},children:[o.length," / ",s.maxLength]})]}),s.type!=="url"&&o!==s.default&&i.jsx("button",{type:"button",className:"link",style:{fontSize:14},onClick:()=>n(s.default),children:"Remettre le texte par défaut"})]})}function zy({storeId:e,storeName:t,initial:n,onChanged:r}){const[l,s]=w.useState(n),[o,a]=w.useState(n.config),[u,c]=w.useState(!1),[f,h]=w.useState(!1),[g,v]=w.useState(null),[y,j]=w.useState(null),E=`/api/admin/stores/${e}/modules/${l.id}`,p=x=>{s(x),a(x.config)};w.useEffect(()=>{u&&b.get(E).then(p).catch(x=>v(x.message))},[u,E]);async function d(x,C){h(!0),v(null),j(null);try{p(await x()),j(C),r()}catch(S){v(S.message)}finally{h(!1)}}const m=JSON.stringify(o)!==JSON.stringify(l.config);return i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:14},children:[i.jsxs("div",{className:"row between",style:{alignItems:"flex-start",gap:12},children:[i.jsxs("div",{style:{flex:"1 1 320px"},children:[i.jsxs("div",{className:"row",style:{gap:10,alignItems:"center"},children:[i.jsx("h2",{style:{margin:0},children:l.name}),i.jsx(My,{m:l}),l.available&&i.jsx("span",{className:`badge ${l.config.enabled?"ACTIVE":"DRAFT"}`,children:l.config.enabled?"Activé":"Désactivé"})]}),i.jsx("p",{className:"muted",style:{margin:"6px 0 0"},children:l.description})]}),i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsx("label",{className:"sr-only",htmlFor:`ov-${l.id}`,children:"Disponibilité du module"}),i.jsxs("select",{id:`ov-${l.id}`,className:"input",style:{width:"auto"},disabled:f,value:l.override===null?"plan":l.override?"add":"remove",onChange:x=>{const C=x.target.value==="plan"?null:x.target.value==="add";d(()=>b.put(`${E}/override`,{value:C}),C===null?"Module remis selon la formule.":C?"Module ajouté sur mesure.":"Module retiré.")},children:[i.jsxs("option",{value:"plan",children:["Selon la formule",l.inPlan?" (inclus)":" (non inclus)"]}),i.jsx("option",{value:"add",children:"Ajouter sur mesure"}),i.jsx("option",{value:"remove",children:"Retirer"})]}),i.jsx("button",{type:"button",className:"btn secondary",onClick:()=>c(!u),"aria-expanded":u,children:u?"Fermer":"Personnaliser"})]})]}),g&&i.jsx("div",{className:"alert error",role:"alert",children:g}),y&&i.jsx("div",{className:"alert ok",role:"status",children:y}),u&&i.jsxs(i.Fragment,{children:[!l.available&&i.jsx("div",{className:"alert warn",children:"Module non disponible pour ce magasin : ajoutez-le sur mesure ou changez de formule pour l'activer. Vous pouvez déjà préparer ses réglages."}),i.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,fontWeight:700},children:[i.jsx("input",{type:"checkbox",checked:!!o.enabled,onChange:x=>a({...o,enabled:x.target.checked})}),"Module activé"]}),l.fields.map(x=>i.jsx(Ay,{f:x,value:o[x.key],onChange:C=>a({...o,[x.key]:C})},x.key)),l.stats&&i.jsx("div",{className:"row",style:{gap:24},children:Object.entries(l.stats).map(([x,C])=>i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:22,fontWeight:800},children:C??"—"}),i.jsx("div",{className:"muted",style:{fontSize:14},children:x})]},x))}),l.id==="stats"&&i.jsx(We,{to:"../statistiques",children:"Voir les statistiques du magasin →"}),i.jsxs("div",{className:"row",style:{gap:8,justifyContent:"flex-end"},children:[m&&i.jsx("button",{type:"button",className:"btn secondary",disabled:f,onClick:()=>a(l.config),children:"Annuler"}),i.jsx("button",{type:"button",className:"btn",disabled:f||!m,onClick:()=>d(()=>b.put(E,o),"Réglages enregistrés."),children:f?"Enregistrement…":"Enregistrer"})]}),l.id==="campaigns"&&l.available&&l.config.enabled&&i.jsx(_y,{storeId:e,storeName:t})]})]})}function Iy({storeId:e,storeName:t}){const[n,r]=w.useState(null),[l,s]=w.useState(null),o=w.useCallback(()=>{b.get(`/api/admin/stores/${e}/modules`).then(r).catch(u=>s(u.message))},[e]);if(w.useEffect(o,[o]),!n)return l?i.jsx("div",{className:"alert error",children:l}):i.jsx("p",{className:"muted",children:"Chargement…"});const a=n.filter(u=>u.available&&u.config.enabled).length;return i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"muted",style:{margin:0},children:[a," module(s) actif(s) sur ",n.length,". Chaque module est inclus ou non dans la formule ; vous pouvez l'ajouter ou le retirer sur mesure, et tous ses textes et réglages sont personnalisables. Le dirigeant peut aussi les régler depuis l'app Pro."]}),n.map(u=>i.jsx(zy,{storeId:e,storeName:t,initial:u,onChanged:o},u.id))]})}const Fy=[[30,"30 jours"],[90,"3 mois"],[365,"12 mois"]],ti=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",maximumFractionDigits:e>=1e5?0:2}),rn=e=>e.toLocaleString("fr-FR");function Dy({value:e}){if(e===null)return null;const t=e>=0;return i.jsxs("span",{style:{fontSize:13,fontWeight:700,color:t?"var(--ok)":"var(--err)"},children:[t?"▲":"▼"," ",Math.abs(e).toLocaleString("fr-FR")," %"]})}function Ot({label:e,value:t,hint:n,change:r}){return i.jsxs("div",{className:"card",style:{padding:16,display:"flex",flexDirection:"column",gap:4},children:[i.jsx("span",{className:"muted",style:{fontSize:14},children:e}),i.jsx("span",{style:{fontSize:26,fontWeight:800},children:t}),i.jsxs("span",{style:{display:"flex",gap:8,alignItems:"baseline"},children:[r!==void 0&&i.jsx(Dy,{value:r}),n&&i.jsx("span",{className:"muted",style:{fontSize:13},children:n})]})]})}function Uy({series:e}){const t=Math.max(1,...e.map(l=>Math.max(l.visits,l.newCards))),n=100/e.length,r=Math.ceil(e.length/8);return i.jsxs("svg",{viewBox:"0 0 100 46",preserveAspectRatio:"none",style:{width:"100%",height:220},role:"img","aria-label":"Passages et nouvelles cartes sur la période",children:[e.map((l,s)=>i.jsxs("g",{children:[i.jsx("title",{children:`${l.label} : ${l.visits} passage(s), ${l.newCards} nouvelle(s) carte(s)`}),i.jsx("rect",{x:s*n+n*.1,y:40-l.visits/t*38,width:n*.45,height:l.visits/t*38,fill:"var(--primary)"}),i.jsx("rect",{x:s*n+n*.55,y:40-l.newCards/t*38,width:n*.35,height:l.newCards/t*38,fill:"var(--primary-soft)",stroke:"var(--primary)",strokeWidth:.1}),s%r===0&&i.jsx("text",{x:s*n+n/2,y:45,fontSize:2.2,textAnchor:"middle",fill:"currentColor",opacity:.6,children:l.label})]},s)),i.jsx("line",{x1:0,x2:100,y1:40,y2:40,stroke:"var(--border)",strokeWidth:.2})]})}function Oy({heat:e}){const t=Array.from({length:15},(r,l)=>l+7),n=Math.max(1,...e.values.flat());return i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{style:{borderCollapse:"separate",borderSpacing:3,minWidth:560},children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{}),t.map(r=>i.jsxs("th",{style:{fontSize:12,fontWeight:500,padding:0,textAlign:"center"},children:[r,"h"]},r))]})}),i.jsx("tbody",{children:e.weekdays.map((r,l)=>i.jsxs("tr",{children:[i.jsx("th",{scope:"row",style:{fontSize:13,fontWeight:600,padding:"0 8px 0 0"},children:r}),t.map(s=>{const o=e.values[l][s];return i.jsx("td",{title:`${r} ${s} h : ${o} passage(s)`,style:{padding:0,height:26,borderRadius:4,background:o?`color-mix(in srgb, var(--primary) ${Math.round(15+o/n*85)}%, transparent)`:"var(--surface-2)"}},s)})]},r))})]})})}function By({storeId:e,storeSlug:t}){const[n,r]=w.useState(30),[l,s]=w.useState(null),[o,a]=w.useState(null),[u,c]=w.useState(null);w.useEffect(()=>{a(null),b.get(`/api/admin/stores/${e}/stats?days=${n}`).then(s).catch(v=>a(v.message))},[e,n]);async function f(v){c(v);try{const y=new Date().toISOString().slice(0,10);v==="customers"?await to(`/api/admin/stores/${e}/export/customers`,`clients-${t}-${y}.csv`):await to(`/api/admin/stores/${e}/export/transactions?days=${n}`,`operations-${t}-${n}j-${y}.csv`)}catch(y){a(y.message)}finally{c(null)}}const h=l==null?void 0:l.kpis,g=(l==null?void 0:l.pointsMode)==="STAMP"?"tampons":"points";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"row between",style:{alignItems:"center"},children:[i.jsx("div",{role:"group","aria-label":"Période",className:"row",style:{gap:8},children:Fy.map(([v,y])=>i.jsx("button",{type:"button",className:"chip","aria-pressed":n===v,onClick:()=>r(v),children:y},v))}),i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsx("button",{className:"btn secondary",disabled:!!u,onClick:()=>f("customers"),children:u==="customers"?"Export…":"Exporter les clients (CSV)"}),i.jsx("button",{className:"btn secondary",disabled:!!u,onClick:()=>f("transactions"),children:u==="transactions"?"Export…":"Exporter les opérations (CSV)"})]})]}),o&&i.jsx("div",{className:"alert error",role:"alert",children:o}),l&&!l.allowed&&i.jsx("div",{className:"alert warn",children:"Ce magasin n'a pas la formule Pro : il ne voit pas ces statistiques dans son app (vous, si)."}),!l||!h?!o&&i.jsx("p",{className:"muted",children:"Chargement…"}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(190px, 1fr))",gap:12},children:[i.jsx(Ot,{label:"Passages",value:rn(h.visits),change:h.visitsChange,hint:"vs période précédente"}),i.jsx(Ot,{label:"Nouvelles cartes",value:rn(h.newCards),change:h.newCardsChange,hint:`${rn(h.cardsTotal)} au total`}),i.jsx(Ot,{label:"Clients actifs",value:rn(h.activeCustomers),hint:`${h.visitsPerCustomer.toLocaleString("fr-FR")} passage(s) par client`}),i.jsx(Ot,{label:"Clients fidèles",value:h.returningRate===null?"—":`${h.returningRate.toLocaleString("fr-FR")} %`,hint:"venus au moins 2 fois"}),l.pointsMode==="AMOUNT"&&i.jsx(Ot,{label:"Achats enregistrés",value:ti(h.revenueCents),hint:h.averageBasketCents===null?void 0:`panier moyen ${ti(h.averageBasketCents)}`}),i.jsx(Ot,{label:"Récompenses",value:rn(h.rewardsRedeemed),hint:`${rn(h.pointsGiven)} ${g} distribués`}),i.jsx(Ot,{label:"Cartes dans Apple Wallet",value:h.appleWalletRate===null?"—":`${h.appleWalletRate.toLocaleString("fr-FR")} %`,hint:"iPhone joignables"})]}),i.jsxs("section",{className:"card",children:[i.jsx("h2",{children:"Fréquentation"}),i.jsxs("p",{className:"muted",style:{marginTop:0,fontSize:14},children:[i.jsx("span",{style:{display:"inline-block",width:10,height:10,background:"var(--primary)",borderRadius:2}})," Passages ",i.jsx("span",{style:{display:"inline-block",width:10,height:10,background:"var(--primary-soft)",border:"1px solid var(--primary)",borderRadius:2}})," Nouvelles cartes"]}),i.jsx(Uy,{series:l.series})]}),i.jsxs("section",{className:"card",children:[i.jsx("h2",{children:"Heures d'affluence"}),i.jsx("p",{className:"muted",style:{marginTop:0},children:l.busiest?`Créneau le plus fréquenté : ${l.busiest}.`:"Pas encore de passage sur la période."}),i.jsx(Oy,{heat:l.heatmap})]}),i.jsxs("section",{className:"card",children:[i.jsx("h2",{children:"Meilleurs clients"}),l.top.length===0?i.jsx("p",{className:"muted",style:{margin:0},children:"Pas encore de passage sur la période."}):i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{scope:"col",children:"Client"}),i.jsx("th",{scope:"col",className:"num",children:"Passages"}),l.pointsMode==="AMOUNT"&&i.jsx("th",{scope:"col",className:"num",children:"Achats"}),i.jsx("th",{scope:"col",className:"num",children:"Solde"})]})}),i.jsx("tbody",{children:l.top.map((v,y)=>i.jsxs("tr",{children:[i.jsx("td",{children:v.firstName}),i.jsx("td",{className:"num",children:v.visits}),l.pointsMode==="AMOUNT"&&i.jsx("td",{className:"num",children:ti(v.amountCents)}),i.jsx("td",{className:"num",children:v.balance})]},y))})]})})]})]})]})}const $y=[["infos","Infos"],["carte","Carte de fidélité"],["employes","Employés"],["modules","Modules"],["statistiques","Statistiques"],["facturation","Facturation"]];function by(){var c;const{id:e}=of(),[t,n]=w.useState(null),[r,l]=w.useState(null),[s,o]=w.useState(null),a=w.useCallback(()=>{b.get(`/api/admin/stores/${e}`).then(n).catch(f=>l(f.message))},[e]);w.useEffect(a,[a]);async function u(f,h){if(!(h&&!window.confirm(h))){l(null);try{await b.patch(`/api/admin/stores/${e}/status`,{status:f}),a()}catch(g){l(g.message)}}}return t?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"row between",children:[i.jsxs("div",{children:[i.jsx(We,{to:"/magasins",children:"← Magasins"}),i.jsxs("div",{className:"row",style:{gap:12},children:[i.jsx("h1",{children:t.name}),i.jsx(hf,{status:t.status}),((c=t.subscription)==null?void 0:c.stripeSubscriptionId)&&t.subscription.status!=="CANCELED"&&i.jsx(vl,{to:"facturation",className:"badge DRAFT",style:{textDecoration:"none"},title:"Formule d'abonnement",children:_n[t.subscription.plan]})]}),i.jsxs("p",{className:"muted",style:{margin:0},children:[t.city," · ",t.counts.cards," clients · ",t.counts.staff," employés"]})]}),i.jsxs("div",{className:"row",style:{gap:8},children:[(t.status==="DRAFT"||t.status==="CLOSED")&&i.jsx("button",{className:"btn",onClick:()=>u("ACTIVE"),children:"Activer"}),t.status==="SUSPENDED"&&i.jsx("button",{className:"btn",onClick:()=>u("ACTIVE"),children:"Réactiver"}),t.status==="ACTIVE"&&i.jsx("button",{className:"btn secondary",onClick:()=>u("SUSPENDED","Suspendre ce magasin ? Les employés ne pourront plus scanner."),children:"Suspendre"}),t.status!=="CLOSED"&&i.jsx("button",{className:"btn secondary",onClick:()=>u("CLOSED","Fermer ce magasin ?"),children:"Fermer"})]})]}),t.status==="SUSPENDED"&&i.jsxs("div",{className:"alert warn",role:"status",children:["Magasin suspendu",t.billingSuspended?" pour impayé":""," : les scans et les nouvelles inscriptions sont refusés.",t.billingSuspended&&i.jsxs(i.Fragment,{children:[" Voir l'onglet ",i.jsx(vl,{to:"facturation",children:"Facturation"}),"."]})]}),r&&i.jsx("div",{className:"alert error",role:"alert",children:r}),s&&i.jsx("div",{className:"alert ok",role:"status",children:s}),i.jsx("nav",{className:"tabs","aria-label":"Sections du magasin",children:$y.map(([f,h])=>i.jsx(vl,{to:f,children:h},f))}),i.jsxs(qi,{children:[i.jsx(G,{index:!0,element:i.jsx(yl,{to:"infos",replace:!0})}),i.jsx(G,{path:"infos",element:i.jsx(mf,{initial:t,submitLabel:"Enregistrer",onSubmit:async f=>{const{name:h,siret:g,addressLine:v,postalCode:y,city:j,contactName:E,contactEmail:p,contactPhone:d,maxAmountEuros:m,minScanIntervalMin:x}=f;await b.patch(`/api/admin/stores/${e}`,{name:h,siret:g,addressLine:v,postalCode:y,city:j,contactName:E,contactEmail:p,contactPhone:d,maxAmountEuros:m,minScanIntervalMin:x}),o("Modifications enregistrées."),a()}},t.id)}),i.jsx(G,{path:"carte",element:i.jsx(Df,{store:t,onSaved:a})}),i.jsx(G,{path:"employes",element:i.jsx(Py,{storeId:t.id})}),i.jsx(G,{path:"modules",element:i.jsx(Iy,{storeId:t.id,storeName:t.name})}),i.jsx(G,{path:"statistiques",element:i.jsx(By,{storeId:t.id,storeSlug:t.slug})}),i.jsx(G,{path:"facturation",element:i.jsx(Ly,{storeId:t.id,contactEmail:t.contactEmail,onChange:a})})]})]}):r?i.jsx("div",{className:"alert error",children:r}):i.jsx("p",{className:"muted",children:"Chargement…"})}function Du({merchant:e=!1}){const{id:t}=of(),n=e?"/api/staff/store":`/api/admin/stores/${t}`,r=e?"/api/staff/card-design":`/api/admin/stores/${t}/card-design`,[l,s]=ra(),o=l.get("format")==="A6"?"A6":"A5",[a,u]=w.useState(null),[c,f]=w.useState(null),[h,g]=w.useState(null);return w.useEffect(()=>{Promise.all([b.get(n),b.get(r)]).then(([v,y])=>{u(v),f(y)}).catch(v=>g(v.message))},[n,r]),h?i.jsx("div",{className:"alert error",style:{margin:24},children:h}):a?c?i.jsxs("div",{className:"poster-page",children:[i.jsx("style",{children:`@page{size:${o};margin:0}@media print{.no-print{display:none!important}body{background:#fff}.poster-page{padding:0!important}}`}),i.jsxs("div",{className:"no-print row between",style:{padding:16},children:[i.jsx(We,{to:e?"/espace":`/magasins/${t}/carte`,children:"← Retour à la carte"}),i.jsxs("div",{className:"row",style:{gap:8},children:[["A5","A6"].map(v=>i.jsx("button",{type:"button",className:"chip","aria-pressed":o===v,onClick:()=>s({format:v}),children:v},v)),i.jsx("button",{type:"button",className:"btn",onClick:()=>window.print(),children:"Imprimer"})]})]}),a.status!=="ACTIVE"&&i.jsx("div",{className:"alert warn no-print",style:{margin:"0 16px 16px"},children:"Le magasin n'est pas actif : le QR mène pour l'instant à une page « introuvable » ou « indisponible »."}),i.jsx("div",{style:{display:"flex",justifyContent:"center",padding:16},className:"poster-page",children:i.jsx(zf,{format:o,url:a.enrollUrl,storeName:a.name,programName:c.programName,logoUrl:eo(c.logoUrl),backgroundColor:c.backgroundColor,foregroundColor:c.foregroundColor,labelColor:c.labelColor,rewards:c.rewards,pointsMode:c.pointsMode})}),i.jsx("p",{className:"no-print muted",style:{textAlign:"center"},children:a.enrollUrl})]}):i.jsx("div",{className:"alert warn",style:{margin:24},children:"Concevez d'abord la carte de fidélité."}):i.jsx("p",{className:"muted",style:{margin:24},children:"Chargement…"})}const Wy=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:e%100?2:0}),Uu=["ESSENTIEL","PRO","RESEAU"],Vy=[["name","Nom du commerce",{autoComplete:"organization",placeholder:"Boulangerie Kerlann",maxLength:120}],["siret","SIRET",{inputMode:"numeric",placeholder:"123 456 789 00012"}],["addressLine","Adresse",{autoComplete:"street-address",maxLength:200}],["postalCode","Code postal",{autoComplete:"postal-code",inputMode:"numeric",maxLength:5}],["city","Ville",{autoComplete:"address-level2",maxLength:120}],["contactName","Prénom et nom du dirigeant",{autoComplete:"name",maxLength:120}],["contactPhone","Téléphone",{autoComplete:"tel",type:"tel"}],["contactEmail","E-mail (votre identifiant)",{autoComplete:"email",type:"email"}]];function Hy(){const[e]=ra(),t=(e.get("formule")??"").toUpperCase(),[n,r]=w.useState(Uu.includes(t)?t:"PRO"),[l,s]=w.useState(e.get("periode")==="annuel"?"YEAR":"MONTH"),[o,a]=w.useState([]),[u,c]=w.useState({name:"",siret:"",addressLine:"",postalCode:"",city:"",contactName:"",contactPhone:"",contactEmail:"",password:""}),[f,h]=w.useState(!1),[g,v]=w.useState(e.get("annule")?"Paiement annulé : rien n’a été prélevé. Vous pouvez reprendre quand vous voulez.":null),[y,j]=w.useState(!1);w.useEffect(()=>{Tu.get("/api/public/signup/plans").then(a).catch(()=>{})},[]);async function E(d){d.preventDefault(),j(!0),v(null);try{const{url:m}=await Tu.post("/api/public/signup",{...u,plan:n,interval:l,cgv:f});window.location.assign(m)}catch(m){v(m.message),j(!1),window.scrollTo({top:0,behavior:"smooth"})}}const p=o.find(d=>d.plan===n);return i.jsx("main",{style:{minHeight:"100vh",padding:"32px 16px"},children:i.jsxs("form",{onSubmit:E,style:{maxWidth:720,margin:"0 auto",display:"flex",flexDirection:"column",gap:24},children:[i.jsx("a",{href:"https://monespacepro.eu/tarif/",style:{textDecoration:"none",color:"inherit"},children:i.jsx(Fr,{admin:!1})}),i.jsxs("div",{children:[i.jsx("h1",{children:"Créer mon programme de fidélité"}),i.jsx("p",{className:"muted",style:{margin:0},children:"Sans engagement, résiliable à tout moment. Votre espace est prêt dès le paiement validé."})]}),g&&i.jsx("div",{className:"alert error",role:"alert",children:g}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:16},children:[i.jsx("h2",{children:"Formule"}),i.jsxs("div",{role:"group","aria-label":"Périodicité",className:"row",style:{gap:8},children:[i.jsx("button",{type:"button",className:"chip","aria-pressed":l==="MONTH",onClick:()=>s("MONTH"),children:"Mensuel"}),i.jsx("button",{type:"button",className:"chip","aria-pressed":l==="YEAR",onClick:()=>s("YEAR"),children:"Annuel — 2 mois offerts"})]}),i.jsx("div",{className:"mode-cards",role:"radiogroup","aria-label":"Formule",children:(o.length?o:Uu.map(d=>({plan:d,name:_n[d],tagline:"",priceCents:{MONTH:0,YEAR:0},modules:[],limits:{maxStaff:null}}))).map(d=>i.jsxs("label",{className:"mode-card",style:{flexDirection:"column",gap:6},children:[i.jsxs("span",{className:"row",style:{gap:10},children:[i.jsx("input",{type:"radio",name:"plan",checked:n===d.plan,onChange:()=>r(d.plan)}),i.jsx("strong",{style:{fontSize:18},children:d.name})]}),d.priceCents[l]>0&&i.jsxs("span",{style:{fontSize:22,fontWeight:800},children:[Wy(d.priceCents[l]),i.jsxs("span",{className:"muted",style:{fontSize:14,fontWeight:500},children:[" / ",l==="YEAR"?"an":"mois"]})]}),i.jsx("span",{className:"muted",style:{fontSize:14},children:d.tagline})]},d.plan))}),p&&i.jsxs("p",{className:"muted",style:{margin:0,fontSize:14},children:[p.limits.maxStaff?`${p.limits.maxStaff} employés`:"Employés illimités"," ·"," ",p.modules.length?`Modules : ${p.modules.map(d=>d.name).join(", ")}`:"Sans module complémentaire"]})]}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:16},children:[i.jsx("h2",{children:"Votre commerce"}),Vy.map(([d,m,x])=>i.jsxs("div",{className:"field",children:[i.jsxs("label",{htmlFor:`s-${d}`,children:[m," *"]}),i.jsx("input",{id:`s-${d}`,className:"input",required:!0,value:u[d],onChange:C=>c({...u,[d]:C.target.value}),...x})]},d)),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"s-password",children:"Mot de passe *"}),i.jsx("input",{id:"s-password",className:"input",type:"password",required:!0,minLength:10,autoComplete:"new-password",value:u.password,onChange:d=>c({...u,password:d.target.value})}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"10 caractères minimum. Il ouvre votre espace web et l’app MonEspacePro Pro."})]})]}),i.jsxs("label",{className:"row",style:{gap:10,alignItems:"flex-start"},children:[i.jsx("input",{type:"checkbox",required:!0,checked:f,onChange:d=>h(d.target.checked),style:{marginTop:4}}),i.jsxs("span",{children:["J’accepte les ",i.jsx("a",{href:"https://monespacepro.eu/cgv/",target:"_blank",rel:"noreferrer",children:"conditions générales de vente"})," et la"," ",i.jsx("a",{href:"https://monespacepro.eu/confidentialite/",target:"_blank",rel:"noreferrer",children:"politique de confidentialité"}),"."]})]}),i.jsx("button",{className:"btn",disabled:y,children:y?"Redirection vers le paiement…":"Continuer vers le paiement"}),i.jsxs("p",{className:"muted",style:{margin:0,fontSize:14,textAlign:"center"},children:["Paiement sécurisé par Stripe (carte ou prélèvement SEPA). Déjà inscrit ? ",i.jsx(We,{to:"/espace",children:"Se connecter"})]})]})})}function Qy({onLogin:e}){const t=en(),[n]=ra(),r=n.has("bienvenue"),[l,s]=w.useState(""),[o,a]=w.useState(""),[u,c]=w.useState(null),[f,h]=w.useState(!1);async function g(v){v.preventDefault(),h(!0),c(null);try{await Sg(l,o),e(),t("/espace",{replace:!0})}catch(y){c(r&&y instanceof ms&&y.status===401?"Votre espace est en cours de création. Réessayez dans quelques secondes.":y.message)}finally{h(!1)}}return i.jsx("main",{style:{minHeight:"100vh",display:"grid",placeItems:"center",padding:16},children:i.jsxs("form",{className:"card",onSubmit:g,style:{width:"100%",maxWidth:420,display:"flex",flexDirection:"column",gap:20},children:[i.jsx(Fr,{admin:!1}),r&&i.jsx("div",{className:"alert ok",children:"Paiement reçu, merci ! Connectez-vous avec l’e-mail et le mot de passe choisis à l’inscription."}),i.jsxs("div",{children:[i.jsx("h1",{style:{fontSize:26},children:"Mon espace"}),i.jsx("p",{className:"muted",style:{margin:0},children:"Mêmes identifiants que l’app MonEspacePro Pro."})]}),u&&i.jsx("div",{className:"alert error",role:"alert",children:u}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"m-email",children:"E-mail"}),i.jsx("input",{id:"m-email",className:"input",type:"email",autoComplete:"username",required:!0,value:l,onChange:v=>s(v.target.value)})]}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"m-password",children:"Mot de passe"}),i.jsx("input",{id:"m-password",className:"input",type:"password",autoComplete:"current-password",required:!0,value:o,onChange:v=>a(v.target.value)})]}),i.jsx("button",{className:"btn",disabled:f,children:f?"Connexion…":"Se connecter"}),i.jsxs("p",{className:"muted",style:{margin:0,fontSize:14,textAlign:"center"},children:["Pas encore client ? ",i.jsx(We,{to:"/inscription",children:"Créer mon programme"})]})]})})}function Ky(){const[e,t]=w.useState(null),[n,r]=w.useState(null),l=w.useCallback(()=>{b.get("/api/staff/store").then(t).catch(s=>r(s instanceof ms&&s.status===403?"Cet espace est réservé au Dirigeant du magasin. Utilisez l’app MonEspacePro Pro pour scanner les cartes.":s.message))},[]);return w.useEffect(l,[l]),i.jsxs("div",{style:{minHeight:"100vh"},children:[i.jsxs("header",{className:"row between",style:{padding:"16px 24px",borderBottom:"1px solid var(--border)"},children:[i.jsx(Fr,{admin:!1}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:ia,children:"Se déconnecter"})]}),i.jsxs("main",{className:"container",style:{padding:24,display:"flex",flexDirection:"column",gap:24},children:[n&&i.jsx("div",{className:"alert error",role:"alert",children:n}),!e&&!n&&i.jsx("p",{className:"muted",children:"Chargement…"}),e&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx("h1",{children:e.name}),i.jsxs("p",{className:"muted",style:{margin:0},children:[e.subscription?`Formule ${_n[e.subscription.plan]}`:"Aucune formule"," ·"," ",e.status==="ACTIVE"?"Programme ouvert à vos clients":e.status==="DRAFT"?"Programme pas encore ouvert":"Programme suspendu"]})]}),e.subscribeUrl&&i.jsxs("div",{className:"alert warn row between",style:{gap:12},children:[i.jsx("span",{children:"Votre abonnement n’est pas encore actif : le programme s’ouvrira dès le paiement validé."}),i.jsx("a",{className:"btn small",href:e.subscribeUrl,children:"Activer mon abonnement"})]}),e.status==="SUSPENDED"&&i.jsx("div",{className:"alert warn",children:"Programme suspendu. Il rouvre automatiquement dès le paiement de l’abonnement régularisé."}),e.status==="ACTIVE"&&i.jsxs("div",{className:"alert ok",children:["Vos clients s’inscrivent sur ",i.jsx("a",{href:e.enrollUrl,target:"_blank",rel:"noreferrer",children:e.enrollUrl})," (QR code de l’affichette)."]}),i.jsx("p",{className:"muted",style:{margin:0},children:"Employés, modules (campagnes, anniversaire, relances…) et statistiques : dans l’app MonEspacePro Pro, avec les mêmes identifiants."}),i.jsx(Df,{store:e,onSaved:l,base:"/api/staff/card-design",posterHref:"/espace/affichette",draftNote:i.jsx("p",{style:{margin:0},children:e.subscribeUrl?"Votre programme s’ouvrira automatiquement dès votre abonnement activé.":"Enregistrez la carte : votre programme s’ouvre automatiquement à vos clients."})})]})]})]})}function Yy(){const e=en(),t=It(),[n,r]=w.useState(wg()),l=t.pathname.startsWith("/espace");w.useEffect(()=>{xg(()=>{r(null),e(l?"/espace":"/connexion")})},[e,l]);const s=i.jsx(Qy,{onLogin:()=>r("staff")});return n!=="admin"||t.pathname==="/inscription"?i.jsxs(qi,{children:[i.jsx(G,{path:"/inscription",element:i.jsx(Hy,{})}),n==="staff"?i.jsxs(i.Fragment,{children:[i.jsx(G,{path:"/espace/affichette",element:i.jsx(Du,{merchant:!0})}),i.jsx(G,{path:"/espace",element:i.jsx(Ky,{})}),i.jsx(G,{path:"*",element:i.jsx(yl,{to:"/espace",replace:!0})})]}):i.jsxs(i.Fragment,{children:[i.jsx(G,{path:"/espace",element:s}),i.jsx(G,{path:"/connexion",element:i.jsx(Ng,{onLogin:()=>r("admin")})}),i.jsx(G,{path:"*",element:i.jsx(yl,{to:l?"/espace":"/connexion",replace:!0})})]})]}):i.jsxs(qi,{children:[i.jsx(G,{path:"/espace",element:s}),i.jsx(G,{path:"/magasins/:id/affichette",element:i.jsx(Du,{})}),i.jsxs(G,{element:i.jsx(Eg,{}),children:[i.jsx(G,{path:"/magasins",element:i.jsx(Tg,{})}),i.jsx(G,{path:"/magasins/nouveau",element:i.jsx(_g,{})}),i.jsx(G,{path:"/magasins/:id/*",element:i.jsx(by,{})})]}),i.jsx(G,{path:"*",element:i.jsx(yl,{to:"/magasins",replace:!0})})]})}Jd(document.getElementById("root")).render(i.jsx(w.StrictMode,{children:i.jsx(pg,{future:{v7_startTransition:!0},children:i.jsx(Yy,{})})}));
diff --git a/site/assets/espace/index-Co2TMa3A.css b/site/assets/espace/index-Co2TMa3A.css
new file mode 100644
index 0000000..cedeae4
--- /dev/null
+++ b/site/assets/espace/index-Co2TMa3A.css
@@ -0,0 +1 @@
+:root{--primary: #0e7a66;--primary-hover: #0b6253;--primary-soft: #eaf6f2;--accent: #f2b544;--bg: #f6f6f3;--surface: #ffffff;--surface-2: #eeede8;--border: #dedcd6;--border-strong: #8a897f;--text: #1c1c19;--text-2: #45443e;--text-3: #5f5e56;--ok-bg: #e5f3e9;--ok: #1e7a3c;--warn-bg: #fcefd6;--warn: #8f5300;--err-bg: #fbe7e5;--err: #b8322a;--radius: 10px;color-scheme:light}@media (prefers-color-scheme: dark){:root{--primary: #3cb59c;--primary-hover: #5cc7b0;--primary-soft: #143a33;--bg: #141412;--surface: #1d1d1a;--surface-2: #272723;--border: #34342f;--border-strong: #6d6c63;--text: #f2f1ec;--text-2: #cfcec6;--text-3: #a5a49b;--ok-bg: #173523;--ok: #6fcf8f;--warn-bg: #3a2b10;--warn: #f2b544;--err-bg: #3d1a17;--err: #f08a80;color-scheme:dark}}*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--text);font:400 16px/1.5 Figtree,system-ui,sans-serif}a{color:var(--primary)}a:hover{color:var(--primary-hover)}h1{margin:0;font-size:32px;line-height:40px;font-weight:700;letter-spacing:-.01em}h2{margin:0;font-size:20px;font-weight:700}.muted{color:var(--text-3)}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}.shell{min-height:100vh;display:flex;flex-wrap:wrap}.sidebar{flex:1 1 240px;max-width:280px;background:var(--surface);border-right:1px solid var(--border);padding:24px 16px;display:flex;flex-direction:column;gap:28px}.sidebar nav{display:flex;flex-direction:column;gap:4px}.sidebar nav a{display:flex;align-items:center;gap:12px;height:44px;padding:0 12px;border-radius:var(--radius);color:var(--text-2);font-weight:500;text-decoration:none}.sidebar nav a.active{background:var(--primary-soft);color:var(--primary);font-weight:600}.sidebar .bottom{margin-top:auto;border-top:1px solid var(--surface-2);padding:16px 8px 0}.main{flex:999 1 560px;min-width:0;padding:32px 40px 48px}.container{max-width:1200px;margin:0 auto;display:flex;flex-direction:column;gap:24px}.row{display:flex;flex-wrap:wrap;gap:16px;align-items:center}.between{justify-content:space-between}@media (max-width: 720px){.sidebar{max-width:none;border-right:0;border-bottom:1px solid var(--border)}.main{padding:24px 16px}}.brand{display:flex;align-items:center;gap:10px;padding:0 8px}.brand{--brand-arch: #0e7a66}@media (prefers-color-scheme: dark){.brand{--brand-arch: #3dc3a2}}.brand-name{font-size:19px;font-weight:700;letter-spacing:-.03em}.brand-name b{font-weight:700;color:var(--brand-arch)}.card{background:var(--surface);border:1px solid var(--border);border-radius:16px;padding:24px}.btn{height:48px;padding:0 20px;border-radius:var(--radius);border:1px solid transparent;cursor:pointer;font:600 16px Figtree,sans-serif;display:inline-flex;align-items:center;justify-content:center;gap:10px;text-decoration:none;background:var(--primary);color:#fff}.btn:hover:not(:disabled){background:var(--primary-hover);color:#fff}.btn:disabled{opacity:.55;cursor:not-allowed}.btn.secondary{background:var(--surface);color:var(--text);border-color:var(--border-strong)}.btn.secondary:hover:not(:disabled){background:var(--surface-2);color:var(--text)}.btn.danger{background:var(--err)}.btn.small{height:36px;padding:0 14px;font-size:14px}.field{display:flex;flex-direction:column;gap:6px}.field label{font-size:15px;font-weight:600}.field .hint{font-size:14px;color:var(--text-3)}.field .error{font-size:14px;color:var(--err)}.input,select.input{height:48px;padding:0 14px;border:1px solid var(--border-strong);border-radius:var(--radius);background:var(--surface);color:var(--text);font:400 16px Figtree,sans-serif;width:100%}.input:focus{outline:2px solid var(--primary);outline-offset:1px}.grid-2{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:20px}.badge{display:inline-flex;align-items:center;gap:8px;height:28px;padding:0 12px;border-radius:999px;font-size:14px;font-weight:600}.badge:before{content:"";width:8px;height:8px;border-radius:50%;background:currentColor}.badge.DRAFT{background:var(--surface-2);color:var(--text-2)}.badge.DRAFT:before{background:transparent;border:2px solid currentColor}.badge.ACTIVE{background:var(--ok-bg);color:var(--ok)}.badge.SUSPENDED{background:var(--warn-bg);color:var(--warn)}.badge.CLOSED{background:var(--err-bg);color:var(--err)}.chip{height:40px;padding:0 14px;border-radius:999px;border:1px solid var(--border-strong);background:var(--surface);color:var(--text);font:600 15px Figtree,sans-serif;cursor:pointer;display:inline-flex;align-items:center;gap:8px}.chip[aria-pressed=true]{background:var(--primary);border-color:var(--primary);color:#fff}.table-wrap{background:var(--surface);border:1px solid var(--border);border-radius:16px;overflow:hidden}.table-scroll{overflow-x:auto}table{width:100%;border-collapse:collapse;font-size:15px}th{background:var(--surface-2);text-align:left;color:var(--text-2);font-size:13px;font-weight:600;padding:12px 16px}td{border-top:1px solid var(--surface-2);padding:12px 16px;height:64px}td.num,th.num{text-align:right;font-variant-numeric:tabular-nums}.alert{padding:14px 18px;border-radius:12px;font-weight:500}.alert.error{background:var(--err-bg);color:var(--err)}.alert.warn{background:var(--warn-bg);color:var(--warn)}.alert.ok{background:var(--ok-bg);color:var(--ok)}.tabs{display:flex;gap:4px;border-bottom:1px solid var(--border);overflow-x:auto}.tabs a{padding:12px 16px;text-decoration:none;color:var(--text-2);font-weight:600;border-bottom:3px solid transparent;white-space:nowrap}.tabs a.active{color:var(--primary);border-bottom-color:var(--primary)}dialog{border:0;border-radius:16px;padding:0;max-width:520px;width:calc(100% - 32px);background:var(--surface);color:var(--text)}dialog::backdrop{background:#00000073}.dialog-body{padding:24px;display:flex;flex-direction:column;gap:20px}.password-box{font:600 22px ui-monospace,monospace;letter-spacing:.06em;background:var(--surface-2);border-radius:var(--radius);padding:14px;text-align:center;-webkit-user-select:all;user-select:all}.wizard{display:grid;grid-template-columns:minmax(0,1fr) 380px;gap:32px;align-items:start}@media (max-width: 1000px){.wizard{grid-template-columns:1fr}}.steps{display:flex;gap:8px;flex-wrap:wrap;list-style:none;margin:0;padding:0}.steps button{height:40px;padding:0 14px;border-radius:999px;border:1px solid var(--border);background:var(--surface);color:var(--text-2);font:600 14px Figtree,sans-serif;cursor:pointer}.steps button[aria-current=step]{background:var(--primary);border-color:var(--primary);color:#fff}.preview-col{position:sticky;top:24px;display:flex;flex-direction:column;gap:16px;align-items:center}.color-row{display:flex;align-items:center;gap:12px}.color-row input[type=color]{width:48px;height:48px;border:1px solid var(--border-strong);border-radius:var(--radius);padding:2px;background:var(--surface)}.mode-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:16px}.mode-card{border:2px solid var(--border);border-radius:14px;padding:18px;cursor:pointer;display:flex;gap:12px}.mode-card:has(input:checked){border-color:var(--primary);background:var(--primary-soft)}.upload-drop{border:2px dashed var(--border-strong);border-radius:14px;padding:20px;display:flex;align-items:center;gap:16px}.upload-drop img{max-height:72px;max-width:200px;border-radius:6px}.link{background:none;border:0;padding:0;color:var(--primary);font:inherit;text-decoration:underline;cursor:pointer}
diff --git a/site/espace/affichette/index.html b/site/espace/affichette/index.html
new file mode 100644
index 0000000..0059849
--- /dev/null
+++ b/site/espace/affichette/index.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+ Affichette — MonEspacePro
+
+
+
+
+
+
+
+
+
diff --git a/site/espace/index.html b/site/espace/index.html
new file mode 100644
index 0000000..55747fe
--- /dev/null
+++ b/site/espace/index.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+ Mon espace — MonEspacePro
+
+
+
+
+
+
+
+
+
diff --git a/site/inscription/index.html b/site/inscription/index.html
new file mode 100644
index 0000000..4403cb5
--- /dev/null
+++ b/site/inscription/index.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+ Créer mon programme de fidélité — MonEspacePro
+
+
+
+
+
+
+
+
+
diff --git a/site/tarif/index.html b/site/tarif/index.html
index 8dc176a..3c2f65e 100644
--- a/site/tarif/index.html
+++ b/site/tarif/index.html
@@ -95,7 +95,7 @@
La carte de fidélité dans le Wallet de vos clients
19 €/ mois
Sans engagement, résiliable à tout moment
-Choisir Essentiel
+Choisir Essentiel
- La carte à vos couleurs, dans Apple Wallet et Google Wallet
@@ -114,7 +114,7 @@
Faites revenir vos clients
39 €/ mois
Sans engagement, résiliable à tout moment
-Choisir Pro
+Choisir Pro
Tout Essentiel, plus :
- Employés illimités
@@ -136,7 +136,7 @@
Plusieurs magasins, une seule carte
29 €/ mois / magasin
Sans engagement, résiliable à tout moment
-Choisir Réseau
+Choisir Réseau
Tout Pro, plus :
- Une carte commune à tous vos magasins Bientôt