1import{h as y,m as b,l as j,s as v,i as w,k as _,g as N,r as m,j as e,O as D}from"./index-Cqd0JOc_.js";import{D as k}from"./DashboardLayout-BinGEAd0.js";import{D as S,a as T,b as C,c as L,d as P}from"./dialog-iEhwrC3O.js";import{B as f}from"./button-BF8JIYbj.js";import{T as O}from"./triangle-alert-DvL76Jdc.js";import{S as E}from"./shield-check-v-xp2Ixk.js";import{L as h}from"./loader-circle-BS6OsW3x.js";import{C as x}from"./credit-card-BuMO8ibT.js";import"./index-DEqiOm32.js";import"./use-mobile-Cc7N6gKM.js";import"./index-RVQqwujB.js";import"./index-BS3rh8m8.js";import"./input-J4lF_ZPD.js";import"./useProjects-D_-Uw0MY.js";import"./useCreditCosts-BcRtE5PW.js";import"./textarea-BJl_ZXoV.js";import"./currency-CECdeNGG.js";import"./index-B-GB_aZ6.js";import"./crown-gKsGUkXj.js";import"./createLucideIcon-BUgdZWmp.js";import"./sparkles-y60jKWHf.js";import"./building-2-CgqKxnVV.js";import"./zap-C6BjTcY5.js";import"./mail-DQ_txK33.js";import"./send-9-SUNmbP.js";import"./x-CI-zb7NX.js";import"./skeleton-B6LPOF7D.js";import"./dropdown-menu-B50cqF0J.js";import"./index-_h1cipRK.js";import"./index-BQdIuXMc.js";import"./index-Cv1VlRNV.js";import"./log-out-B2OGXzKC.js";import"./check-BRRfmCJJ.js";import"./radio-group-wqp0Ln5l.js";import"./index-QGGOdO5c.js";import"./use-toast-B9tLpTqp.js";import"./ContactDialog-DtR5fo-M.js";import"./label-yK3TlKaU.js";import"./select-BwYIxdh_.js";import"./chevron-up-BM3YnvV8.js";import"./laure-avatar-wH1i9WzZ.js";import"./share-2-CNqDtR-b.js";import"./gift-EIldoFoh.js";import"./copy-BHUDp6u9.js";import"./OrganizationContext-CQoJsQ29.js";import"./users-DRrtC0T5.js";
1import"./user-wbwqibtj.js";import"./globe-C9_lmDAP.js";import"./banknote-D5tBcXRh.js";import"./settings-C2YpJ7nr.js";import"./circle-help-QREzNaV4.js";import"./alert-dialog-CpS25gTn.js";import"./party-popper-hfHhLT72.js";import"./book-open-C13MO25X.js";import"./coins-JNu2WCpw.js";import"./graduation-cap-OS2P0j5w.js";import"./kbFileTypes-CK7dhHB6.js";import"./rotate-ccw-C__7SGaS.js";import"./arrow-up-Cbmnt9CZ.js";const A=["starter","pro","business"],F="[email protected]";function R(){const{user:s}=y(),{profile:t}=b(),a=!!s&&!!t&&(A.includes(t.subscription_status??"")||t.email===F),{data:o}=j({queryKey:["payment-overdue",s==null?void 0:s.id],queryFn:async()=>{try{const{data:l,error:r}=await v.functions.invoke("check-payment-overdue",{body:{}});return r?{overdue:!1}:l??{overdue:!1}}catch{return{overdue:!1}}},enabled:a,staleTime:6e4,refetchInterval:2*6e4,refetchOnWindowFocus:!0,retry:!1});return{isOverdue:(o==null?void 0:o.overdue)===!0,details:o??null}}const I=s=>/^\/dashboard\/projects\/[^/]+/.test(s),q=({children:s})=>{const{t}=w(),a=_(),o=N(),{isOverdue:l,details:r}=R(),[n,p]=m.useState(!1),[g,c]=m.useState(!1);if(m.useEffect(()=>{c(!1)},[a.pathname]),!l||!I(a.pathname))return e.jsx(e.Fragment,{children:s});const u=async()=>{if(r!=null&&r.invoice_url){window.open(r.invoice_url,"_blank","noopener,noreferrer");return}p(!0);try{const{data:i}=await v.functions.invoke("create-billing-portal",{body:{}});i!=null&&i.url&&window.open(i.url,"_blank","noopener,noreferrer")}catch{}finally{p(!1)}},d=r!=null&&r.overdue_since?new Intl.DateTimeFormat("fr-FR",{timeZone:"Europe/Paris",day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(r.overdue_since)):null;return e.jsx(S,{open:!g,onOpenChange:i=>{if(i){c(!1);return}c(!0),o("/dashboard/billing")},children:e.jsxs(T,{className:"max-w-[calc(100vw-2rem)] sm:max-w-md border-destructive/40 max-h-[85vh] overflow-y-auto",children:[e.jsxs(C,{children:[e.jsx("div",{className:"mx-auto mb-2 flex h-12 w-12 items-center justify-center rounded-full bg-destructive/10",children:e.jsx(O,{className:"h-6 w-6 text-destructive"})}),e.jsx(L,{className:"text-center text-destructive text-lg",children:t("org.payment_overdue_title","Retard de paiement")}),e.jsx(P,{className:"text-center text-sm",children:t("org.payment_overdue_desc","Le renouvellement de votre abonnement n'a pas pu être encaissé. Vos contenus sont temporairement bloqués en attente de régularisation.")})]}),e.jsxs("div",{className:"space-y-3 text-sm",children:[d&&e.jsx("p",{className:"rounded-lg border border-destructive/30 bg-destructive/5 px-3 py-2 text-destructive",children:t("org.payment_overdue_since","Paiement en attente depuis le {{date}}",{date:d})}),e.jsxs("p",{className:"flex items-start gap-2 text-muted-foreground",children:[e.jsx(E,{className:"mt-0.5 h-4 w-4 shrink-0 text-primary"}),e.jsx("span",{children:t("org.payment_overdue_retention","Vos formations, documents et données restent conservés en sécurité sur SkillKa.ai pendant 30 jours. Dès la régularisation, tout est immédiatement réaccessible.")})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-2",children:[e.jsxs(f,{onClick:u,disabled:n,variant:"destructive",className:"w-full",children:[n?e.jsx(h,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(x,{className:"mr-2 h-4 w-4"}),t("org.payment_overdue_cta","Régulariser mon paiement")]}),e.jsxs(f,{variant:"outline",className:"w-full",onClick:u,disabled:n,children:[n?e.jsx(h,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(x,{className:"mr-2 h-4 w-4"}),t("org.payment_overdue_billing","Voir mon abonnement")]})]})]})})},Me=()=>e.jsx(k,{children:e.jsx(q,{children:e.jsx(m.Suspense,{fallback:null,children:e.jsx(D,{})})})});export{Me as default};
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.