1import{j as t,a as oe,L as ae}from"./vendor-react-B138QwH7.js";import{u as le}from"./usePlanFeatures-C28YDrt6.js";import{T as W,E as ce,u as de,A as ue,R as y,C as U,d as H,a as pe,b as xe,S as he,c as fe}from"./AppPrivate-D86La96B.js";import{c as ee,aC as J,X as ge,C as te,d as C,u as v,B as q,R as me}from"./index-DeLxZwuS.js";import{A as Q}from"./AdminConsoleShell-DBatHazS.js";import{A as be}from"./AccessDenied-8o98KOVj.js";import{R as je,L as _e,b as ve,T as Ne}from"./vendor-recharts-DyeYCWwb.js";import{C as Ee}from"./circle-x-BpuCSwLo.js";import{L as I}from"./label-V8Vm6spV.js";import{a as Te,u as Ie,b as Ce}from"./vendor-data-B5dyDEkI.js";import{supabase as P}from"./supabaseClient-Dg8qU-k4.js";import{C as z}from"./circle-check-q4Cny2FW.js";import"./vendor-ui-utils-C_CMQnMN.js";import"./vendor-radix-5UMTW6R-.js";import"./ShellHeader-C1AWFlW8.js";import"./PageHero-BUNIKx4m.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Se=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],ke=ee("CircleDashed",Se);/** 7 * @license lucide-react v0.475.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Re=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}]],we=ee("CircleMinus",Re);function T(e){if(e==null||e==="")return null;const s=Number(e);return Number.isFinite(s)?s:null}function De(e,s){if(!s||typeof s!="object")return null;switch(e){case"stripe":return T(s.mrr_cents);case"posthog":return T(s.pageviews_24h);case"sentry":return T(s.unresolved_issues_24h);case"checkly":return T(s.failing);case"vercel":return T(s.recent_errors);case"search_console":return T(s.clicks_7d);default:return null}}function Ae(e,s){if(!Array.isArray(s)||s.length===0)return null;const r=s.map(n=>{const o=De(e,(n==null?void 0:n.summary)||""),i=n!=null&&n.fetched_at?Date.parse(n.fetched_at):null;return o==null||!i||Number.isNaN(i)?null:{t:i,v:o}}).filter(Boolean||"");return r.length<2?null:r}function Oe(e){switch(e){case"stripe":return"MRR (cents)";case"posthog":return"Pages vues / 24h";case"sentry":return"Issues ouvertes";case"checkly":return"Checks en échec";case"vercel":return"Erreurs de déploiement";case"search_console":return"Clics / 7j";default:return"Tendance"}}function se(e){return e==="stripe"?s=>`${(Number(s)/100).toFixed(0)} EUR`:s=>String(s||"")}function Ve(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleString("fr-FR",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})}function ye({active:e,payload:s,provider:r}){if(!e||!(s!=null&&s.length))return null;const n=s[0].payload,o=se(r);return t.jsxs("div",{className:"rounded-md border border-border/60 bg-background/95 px-2 py-1 text-[10px] shadow-sm",children:[t.jsx("p",{className:"font-medium text-foreground",children:o(n.v)}),t.jsx("p",{className:"text-muted-foreground/70",children:Ve(n.t)})]})}function Le({provider:e,history:s,color:r,live:n=!1}){const o=Ae(e,s);if(!o)return null;const i=o.map(E=>E.v),c=i[0],x=i[i.length-1],d=x-c,h=c!==0?d/Math.abs(c)*100:null,f=r||(d>0?"hsl(142, 71%, 45%)":d<0?"hsl(0, 84%, 60%)":"hsl(48, 96%, 53%)"),g=se(e);return t.jsxs("div",{className:"mt-2 space-y-1",children:[t.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground/70",children:[t.jsx("span",{children:Oe(e)}),t.jsxs("span",{className:"tabular-nums",children:[g(x),h!=null&&t.jsxs("span",{className:"ml-1.5 "+(d>0?"text-emerald-400":d<0?"text-red-400":"text-muted-foreground"),children:[d>0?"+":"",h.toFixed(0),"%"]})]})]}),t.jsx("div",{className:"h-10 w-full",children:t.jsx(je,{width:"100%",height:"100%",children:t.jsxs(_e,{data:o,children:[t.jsx(ve,{type:"monotone",dataKey:"v",stroke:f,strokeWidth:1.5,dot:n?{fill:f,r:3}:!1,isAnimationActive:!1,activeDot:n?{r:5,style:{animation:"rl-sparkline-live-flash 400ms ease-out",boxShadow:`0 0 8px ${f}`}}:void 0}),t.jsx(Ne,{cursor:{stroke:"hsl(var(--border))",strokeWidth:1},content:t.jsx(ye,{provider:e})})]})})})]})}function Me(e){if(!e)return"-";const s=new Date(e);
11return Number.isNaN(s.getTime())?"-":s.toLocaleString("fr-FR",{day:"2-digit",month:"2-digit",hour:"2-digit",minute:"2-digit"})}function Pe(e){if(e==null||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const s=Math.floor(e/6e4),r=Math.round(e%6e4/1e3);return`${s}m${r.toString().padStart(2,"0")}`}const Z={success:{icon:te,color:"text-emerald-400",label:"OK"},error:{icon:ge,color:"text-red-400",label:"Erreur"},running:{icon:J,color:"text-amber-400",label:"En cours"},pending:{icon:J,color:"text-muted-foreground",label:"En attente"}};function $e({entries:e}){return!Array.isArray(e)||e.length===0?null:t.jsxs("div",{className:"mt-3 space-y-1 border-t border-border/30 pt-3",children:[t.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground/60",children:"Derniers syncs"}),t.jsx("ul",{className:"space-y-0.5",children:e.map((s,r)=>{const n=Z[s.status]||Z.pending,o=n.icon,i=Pe(s.duration_ms);return t.jsxs("li",{className:"flex items-center gap-2 text-[11px] text-muted-foreground/80",children:[t.jsx(o,{className:C("h-3 w-3 shrink-0",n.color),"aria-hidden":!0}),t.jsx("span",{className:"tabular-nums",children:Me(s.started_at)}),t.jsx("span",{className:C("uppercase tracking-wider",n.color),children:n.label}),i&&t.jsx("span",{className:"ml-auto text-muted-foreground/60",children:i})]},s.id||`${s.started_at}-${r}`)})})]})}const L={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,VITE_APP_URL:"https://rollcodex.app",VITE_POSTHOG_HOST:`/ingest 12`,VITE_POSTHOG_KEY:"phx_AFMKmSxcBkKaPGFFEttneF6GuA3PZCq6kgsRxfcpKnXGQAsL",VITE_SENTRY_DSN:"https://41cb80503b02bb816906c11118e42fc6@o4511189156167680.ingest.de.sentry.io/4511189158789200",VITE_STRIPE_PUBLISHABLE_KEY:"pk_test_51TGL36Guq8aekrjHyjxRixdEoyQNLwvqzVPAuudLmiiK3F9FwnnJN9r5oLt65jhM4QDW1Vdnj3VJ43Mwnap0CcJq00CQ7w5Qtq",VITE_SUPABASE_ANON_KEY:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imxyc21nZmxwc3draXZxZmZvcWxkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ1NTQ3NDEsImV4cCI6MjA5MDEzMDc0MX0.XPByH36NDThGK_IdmZaS2_9RE-wo7oW07xq-58nWCCs",VITE_SUPABASE_URL:"https://lrsmgflpswkivqffoqld.supabase.co",VITE_VERCEL_BRANCH_URL:"rolllcodex-git-main-fernails-projects.vercel.app",VITE_VERCEL_DEPLOYMENT_ID:"dpl_34m7wNQ6L1HhwvBj6beceFP5Cqpm",VITE_VERCEL_ENV:"production",VITE_VERCEL_GIT_COMMIT_AUTHOR_LOGIN:"github-actions[bot]",VITE_VERCEL_GIT_COMMIT_AUTHOR_NAME:"github-actions[bot]",VITE_VERCEL_GIT_COMMIT_MESSAGE:`chore(agents): autonomous improvement roadmap-v4-api-contract-scout (#131) 13 14Co-authored-by: Fernail <[email protected]>`,VITE_VERCEL_GIT_COMMIT_REF:"main",VITE_VERCEL_GIT_COMMIT_SHA:"c4f6be36c82289a92f68e18fcf5d980f807e6a64",VITE_VERCEL_GIT_PREVIOUS_SHA:"",VITE_VERCEL_GIT_PROVIDER:"github",VITE_VERCEL_GIT_PULL_REQUEST_ID:"",VITE_VERCEL_GIT_REPO_ID:"1193406930",VITE_VERCEL_GIT_REPO_OWNER:"Fernail",VITE_VERCEL_GIT_REPO_SLUG:"RollCodex",VITE_VERCEL_OBSERVABILITY_CLIENT_CONFIG:'{"analytics":{"scriptSrc":"af0a1a0c4620326e/script.js","viewEndpoint":"af0a1a0c4620326e/view","eventEndpoint":"af0a1a0c4620326e/event","sessionEndpoint":"af0a1a0c4620326e/session"},"speedInsights":{"scriptSrc":"9998db52323d1203/script.js","endpoint":"9998db52323d1203/vitals"}}',VITE_VERCEL_PROJECT_ID:"prj_S6hPp5CQEUGGrOSWdyMc7VtywANI",VITE_VERCEL_PROJECT_PRODUCTION_URL:"rollcodex.app",VITE_VERCEL_TARGET_ENV:"production",VITE_VERCEL_URL:"rolllcodex-py8ml9u4i-fernails-projects.vercel.app"};function _(e){return String((L==null?void 0:L[e])??"").trim()}function Fe(e,{environment:s,summary:r}={}){switch(e){case"checkly":{const n=_("VITE_CHECKLY_ACCOUNT_ID"),o="https://app.checklyhq.com/checks";return n?`${o}?account=${encodeURIComponent(n)}`:o}case"vercel":{const n=_("VITE_VERCEL_PROJECT_SLUG"),o=_("VITE_VERCEL_TEAM_SLUG");return n&&o?`https://vercel.com/${encodeURIComponent(o)}/${encodeURIComponent(n)}/deployments`:n?`https://vercel.com/dashboard/project/${encodeURIComponent(n)}`:"https://vercel.com/dashboard"}case"sentry":{const n=_("VITE_SENTRY_ORG")||(r==null?void 0:r.organization_slug),o=(r==null?void 0:r.project_slug)||_("VITE_SENTRY_PROJECT");if(n&&o){const i=s?`&environment=${encodeURIComponent(s)}`:"";return`https://sentry.io/organizations/${encodeURIComponent(n)}/issues/?project=${encodeURIComponent(o)}${i}&statsPeriod=24h`}return n?`https://sentry.io/organizations/${encodeURIComponent(n)}/issues/`:"https://sentry.io/"}case"posthog":{const n=_("VITE_POSTHOG_HOST")||"https://eu.posthog.com",o=_("VITE_POSTHOG_PROJECT_ID");return o?`${n.replace(/\/+$/,"")}/project/${encodeURIComponent(o)}/insights`:n}case"stripe":return s==="test"?"https://dashboard.stripe.com/test/dashboard":"https://dashboard.stripe.com/dashboard";case"search_console":{const n=_("VITE_GSC_SITE_URL"),o="https://search.google.com/search-console";return n?`${o}/performance/search-analytics?resource_id=${encodeURIComponent(n)}`:o}default:return null}}function Ge(e){switch(e){case"checkly":return"Ouvrir Checkly";case"vercel":return"Ouvrir Vercel";case"sentry":return"Ouvrir Sentry";case"posthog":return"Ouvrir PostHog";case"stripe":return"Ouvrir Stripe";case"search_console":return"Ouvrir Search Console";default:return"Ouvrir"}}const K={healthy:{icon:te,label:"OK",border:"border-emerald-500/40",bg:"bg-emerald-500/5",text:"text-emerald-400",dot:"bg-emerald-400"},degraded:{icon:W,label:"Dégradé",border:"border-amber-500/40",bg:"bg-amber-500/5",text:"text-amber-400",dot:"bg-
14amber-400"},down:{icon:Ee,label:"En panne",border:"border-red-500/40",bg:"bg-red-500/5",text:"text-red-400",dot:"bg-red-400"},unknown:{icon:ke,label:"Inconnu",border:"border-border/60",bg:"bg-secondary/20",text:"text-muted-foreground",dot:"bg-muted-foreground"},not_applicable:{icon:we,label:"N/A",border:"border-border/40",bg:"bg-secondary/10",text:"text-muted-foreground",dot:"bg-muted-foreground/50"}};function w(e){return e==null||e===""?"-":["string","number","boolean"].includes(typeof e)?e:String(e)}function Ue(e){if(!e)return null;const s=new Date(e),n=Date.now()-s.getTime(),o=Math.floor(n/6e4);if(o<1)return"il y a moins d'une minute";if(o<60)return`il y a ${o} min`;const i=Math.floor(o/60);return i<24?`il y a ${i} h`:`il y a ${Math.floor(i/24)} j`}function B({provider:e,label:s,description:r,status:n="unknown",severity:o,summary:i={},fetchedAt:c,lastSync:x,environment:d,history:h,recentSyncs:f,loading:g=!1,children:E}){const b=K[n]||K.unknown;b.icon;const R=Fe(e,{environment:d,summary:i}),N=Ge(e);return t.jsxs("div",{className:C("rounded-2xl border p-5 transition-all duration-300","hover:shadow-lg hover:shadow-primary/5",b.border,b.bg),children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-muted-foreground",children:s}),t.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground/70",children:r})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[R&&t.jsx("a",{href:R,target:"_blank",rel:"noreferrer noopener",className:"rounded border border-border/40 p-1 text-muted-foreground/70 transition-colors hover:border-border hover:bg-secondary/40 hover:text-foreground",title:N,"aria-label":N,children:t.jsx(ce,{className:"h-3 w-3","aria-hidden":!0})}),g?t.jsx(I,{className:"h-4 w-4 animate-spin text-muted-foreground"}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:C("h-2 w-2 rounded-full",b.dot)}),t.jsx("span",{className:C("text-xs font-semibold",b.text),children:b.label})]})]})]}),!g&&t.jsx("div",{className:"mt-4 space-y-2",children:E||t.jsx(He,{summary:i,status:n})}),!g&&h&&h.length>1&&t.jsx(Le,{provider:e,history:h}),!g&&Array.isArray(f)&&f.length>0&&t.jsx($e,{entries:f}),c&&!g&&t.jsxs("div",{className:"mt-3 flex items-center gap-1.5 border-t border-border/30 pt-3",children:[t.jsxs("span",{className:"text-[10px] text-muted-foreground/60",children:["Dernière sync : ",Ue(c)]}),(x==null?void 0:x.error_message)&&t.jsxs("span",{className:"text-[10px] text-red-400/80",children:["· Erreur : ",x.error_message]})]})]})}function He({summary:e,status:s}){const r=(e==null?void 0:e.reason)??(e==null?void 0:e.message);return s==="not_applicable"&&r?t.jsx("p",{className:"text-xs text-muted-foreground/70",children:w(r)}):s==="unknown"&&r?t.jsx("p",{className:"text-xs text-muted-foreground/70",children:w(r)}):e!=null&&e.error?t.jsx("p",{className:"text-xs text-red-400/80",children:w(e.error)}):null}function p({label:e,value:s,unit:r,className:n}){const o=w(s);return t.jsxs("div",{className:C("flex items-baseline justify-between text-sm",n),children:[t.jsx("span",{className:"text-muted-foreground/80",children:e}),t.jsxs("span",{className:"tabular-nums font-medium text-foreground",children:[o,r&&t.jsx("span",{className:"ml-0.5 text-xs text-muted-foreground/60",children:r})]})]})}function D(e){return Array.isArray(e)?e:[]}function m(e,s="-"){return e==null||e===""?s:String(e)}function Je(e){if(!e)return null;const s=new Date(e);if(Number.isNaN(s.getTime()))return null;const r=Math.floor((Date.now()-s.getTime())/6e4);if(r<1)return"a l instant";if(r<60)return`il y a ${r} min`;const n=Math.floor(r/60);return n<24?`il y a ${n} h`:`il y a ${Math.floor(n/24)} j`}function qe(e){if(!e)return null;const s=new Date(e);return Number.isNaN(s.getTime())?null:s.toLocaleString("fr-FR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}function S(e){return!!(e!=null&&e.reason||e!=null&&e.message||e!=null&&e.error||Array.isArray(e==null?void 0:e.missing_env)&&e.missing_env.length>0||e!=null&&e.provider_response)}function k({summary:e}){const{t:s}
14=v(),r=(e==null?void 0:e.reason)??(e==null?void 0:e.message),n=e==null?void 0:e.error,o=D(e==null?void 0:e.missing_env),i=e==null?void 0:e.provider_response;return!r&&!n&&o.length===0&&!i?null:t.jsxs("div",{className:"space-y-1",children:[r?t.jsx("p",{className:"text-xs text-muted-foreground/70",children:m(r)}):null,o.length>0?t.jsxs("p",{className:"text-[10px] text-muted-foreground/60",children:[s("opsDetails.providerMessage.requiredVariables")," : ",o.map(c=>m(c)).join(", ")]}):null,n&&n!==r?t.jsx("p",{className:"text-xs text-red-400/80",children:m(n)}):null,i?t.jsxs("p",{className:"text-[10px] text-muted-foreground/50",children:[s("opsDetails.providerMessage.providerDetails")," : ",m(i)]}):null]})}function Qe({summary:e}){const{t:s}=v();if(!e)return null;if(S(e))return t.jsx(k,{summary:e});const r=D(e.failing_names).filter(c=>typeof c=="string"||typeof c=="number"),n=Number(e.total_checks??0),o=Number(e.passing??0),i=n>0?Math.round(o/n*100):null;return t.jsxs(t.Fragment,{children:[t.jsx(p,{label:s("opsDetails.checkly.totalChecks"),value:e.total_checks}),t.jsx(p,{label:s("opsDetails.checkly.passing"),value:e.passing}),t.jsx(p,{label:s("opsDetails.checkly.failing"),value:e.failing}),t.jsx(p,{label:s("opsDetails.checkly.degraded"),value:e.degraded}),i!=null&&t.jsx(p,{label:s("opsDetails.checkly.globalHealth"),value:`${i}%`}),e.last_updated&&t.jsx(p,{label:s("opsDetails.checkly.lastRun"),value:Je(e.last_updated)??qe(e.last_updated)}),r.length>0&&t.jsxs("div",{className:"mt-1",children:[t.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground/60",children:s("opsDetails.checkly.failingChecks")}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:r.map(c=>t.jsxs("li",{className:"text-xs text-red-400/80",children:["· ",c]},c))})]})]})}function ze({summary:e}){const{t:s}=v();if(S(e))return t.jsx(k,{summary:e});if(!(e!=null&&e.latest_deployment))return null;const r=e.latest_deployment;return t.jsxs(t.Fragment,{children:[t.jsx(p,{label:s("opsDetails.vercel.status"),value:r.state}),t.jsx(p,{label:s("opsDetails.vercel.branch"),value:r.branch||"-"}),t.jsx(p,{label:s("opsDetails.vercel.commit"),value:r.commit_sha||"-"}),t.jsx(p,{label:s("opsDetails.vercel.author"),value:r.author||"-"}),r.created_at&&t.jsx(p,{label:s("opsDetails.vercel.date"),value:new Date(r.created_at).toLocaleString("fr-FR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}),e.recent_errors>0&&t.jsx(p,{label:s("opsDetails.vercel.recentErrors"),value:e.recent_errors,className:"text-red-400/80"})]})}function Ze({summary:e}){const{t:s}=v();return e?S(e)?t.jsx(k,{summary:e}):t.jsxs(t.Fragment,{children:[t.jsx(p,{label:s("opsDetails.sentry.unresolvedIssues"),value:e.unresolved_issues_24h}),t.jsx(p,{label:s("opsDetails.sentry.totalEvents"),value:e.total_events_24h}),t.jsx(p,{label:s("opsDetails.sentry.critical"),value:e.critical_count}),e.latest_issue&&t.jsxs("div",{className:"mt-1",children:[t.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground/60",children:s("opsDetails.sentry.latestIssue")}),t.jsx("p",{className:"mt-0.5 text-xs text-foreground/80 truncate",children:m(e.latest_issue.title)}),t.jsxs("p",{className:"text-[10px] text-muted-foreground/60",children:[m(e.latest_issue.level)," · ",m(e.latest_issue.count)," ",s("opsDetails.sentry.occurrences")]})]})]}):null}function Ke({summary:e}){const{t:s}=v();if(!e)return null;if(S(e))return t.jsx(k,{summary:e});const r=D(e.top_pages_24h).filter(n=>n&&typeof n=="object");return t.jsxs(t.Fragment,{children:[t.jsx(p,{label:s("opsDetails.posthog.pageviews"),value:e.pageviews_24h}),t.jsx(p,{label:s("opsDetails.posthog.visitors"),value:e.visitors_24h}),t.jsx(p,{label:s("opsDetails.posthog.distinctPages"),value:e.paths_24h}),r.length>0&&t.jsxs("div",{className:"mt-1",children:[t.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground/60",children:s("opsDetails.posthog.topPages")}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:r.map((n,o)=>{const i=n.pathname==null?"-":String(n.pathname),c=n.pageviews_24h==null?"-":String(n.pageviews_24h);return t.jsxs("li",{className:"flex justify-between gap-3 text-xs",children:[t.jsx("span",{className:"truncate text-foreground
14/80",children:i}),t.jsx("span",{className:"tabular-nums text-muted-foreground/60",children:c})]},n.id||`${i}-${c}-${o}`)})})]})]})}function Be({summary:e}){const{t:s}=v();if(!e)return null;if(S(e))return t.jsx(k,{summary:e});const r=e.mrr_cents!=null?`${(e.mrr_cents/100).toFixed(2)} â¬`:"-";return t.jsxs(t.Fragment,{children:[t.jsx(p,{label:s("opsDetails.stripe.activeSubscriptions"),value:e.active_subscriptions}),t.jsx(p,{label:s("opsDetails.stripe.payments7d"),value:e.recent_charges_7d}),t.jsx(p,{label:s("opsDetails.stripe.failedPayments7d"),value:e.failed_charges_7d}),t.jsx(p,{label:s("opsDetails.stripe.estimatedMRR"),value:r})]})}function Xe({summary:e}){const{t:s}=v();if(!e)return null;if(S(e))return t.jsx(k,{summary:e});const r=D(e.top_queries).filter(n=>n&&typeof n=="object");return t.jsxs(t.Fragment,{children:[t.jsx(p,{label:s("opsDetails.searchConsole.clicks7d"),value:e.clicks_7d}),t.jsx(p,{label:s("opsDetails.searchConsole.impressions7d"),value:e.impressions_7d}),r.length>0&&t.jsxs("div",{className:"mt-1",children:[t.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground/60",children:s("opsDetails.searchConsole.topQueries")}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:r.map((n,o)=>{const i=n.query==null?"-":String(n.query),c=n.clicks==null?"-":String(n.clicks);return t.jsxs("li",{className:"flex justify-between text-xs",children:[t.jsx("span",{className:"truncate text-foreground/80",children:i}),t.jsxs("span",{className:"tabular-nums text-muted-foreground/60",children:[c," ",s("opsDetails.searchConsole.clicks")]})]},n.id||`${i}-${c}-${o}`)})})]}),e.period&&t.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground/50",children:[s("opsDetails.searchConsole.period")," : ",m(e.period.start)," - ",m(e.period.end)]})]})}const X={checkly:Qe,vercel:ze,sentry:Ze,posthog:Ke,stripe:Be,search_console:Xe};function Ye(e){return e==="test"?"test":e==="all"?"all":"production"}async function ne(e,s,r){if(!P)throw new Error("Service de supervision non configuré.");const{data:{session:n}}=await P.auth.getSession(),o=await fetch(`https://lrsmgflpswkivqffoqld.supabase.co/functions/v1/${e}`,{method:"POST",headers:{"Content-Type":"application/json",apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imxyc21nZmxwc3draXZxZmZvcWxkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQ1NTQ3NDEsImV4cCI6MjA5MDEzMDc0MX0.XPByH36NDThGK_IdmZaS2_9RE-wo7oW07xq-58nWCCs",...n!=null&&n.access_token?{Authorization:`Bearer ${n.access_token}`}:{}},body:JSON.stringify(s??{})});let i=null;try{i=await o.json()}catch{i=null}if(!o.ok){const c=(i==null?void 0:i.message)||(i==null?void 0:i.error)||r,x=new Error(c);throw x.code=(i==null?void 0:i.code)||`HTTP_${o.status}`,x.status=o.status,x}if(i&&i.success===!1){const c=new Error(i.message||r);throw c.code=i.code||"INTERNAL_ERROR",c}if(!i)throw new Error("Réponse vide du service de supervision.");return i}async function We(e){return ne("get-ops-snapshots",{environment:e},"Erreur lors de la lecture des snapshots ops")}function et(e,s=!0){const r=Ye(e);return Te({queryKey:["ops-snapshots",r],queryFn:()=>We(r),enabled:s&&!!P,staleTime:120*1e3,refetchInterval:300*1e3})}async function tt({providers:e,environment:s}){const r={environment:s};return e&&e.length>0&&(r.providers=e),ne("sync-ops-snapshot",r,"Erreur lors de la synchronisation")}function st(){const e=Ie();return Ce({mutationFn:tt,onSuccess:()=>{e.invalidateQueries({queryKey:["ops-snapshots"]})}})}const M=[{id:"checkly",label:"Checkly",description:"Monitoring synthétique"},{id:"vercel",label:"Vercel",description:"Déploiements"},{id:"sentry",label:"Sentry",description:"Erreurs applicatives"},{id:"posthog",label:"PostHog",description:"Analytics produit"},{id:"stripe",label:"Stripe",description:"Paiements et abonnements"},{id:"search_console",label:"Search Console",description:"SEO Google"}];function nt(e){return e==="test"?"test":e==="all"?"all":"production"}function Y(e){return(e==null?void 0:e.provider)==="stripe"&&(e==null?void 0:e.status)==="degraded"&&(e==null?void 0:e.severity)==="warning"}function _t(){var $,F;const{isSuperAdmin:e}=le(),{t:s}=v("app"),{scope:r}=de(),n=nt(r),{data:o,isLoading:i,isFetching:c,error:x}=et(r,e),d=st(),[h,f]=oe.useState(null),g=()=>{f("all"),n==="all"?(d.mutate({environment:"production"}),d.mutate({environment:"test"})):d.mutate({environment:n})},E=a=>{f(a),n==="all"?(d.mutate({providers:[a],environment:"production"}),d.mutate({providers:[a],environment:"test"})):d.mutate({providers:[a],environment:n})};if(!e)return t.jsx(Q,{title:s("admin.ops.deniedShellTitle","Administration"),description:s("admin.verifyingPermissions"),children:t.jsx(be,{title:s("admin.ops.deniedTitle","Ops / Monitoring"),message:s("admin.overview.deniedMessage"),requiredRole:"Super Admin"})});const b=Array.isArray(o==null?void 0:o.providers)?o.providers:[],R=Array.isArray(o==null?void 0:o.alerts)?o.alerts:[],N=R.filter(a=>!Y(a)),re=R.filter(Y),ie=c&&!i,A=r==="all",O={};for(const a of b){if(!a||typeof a!="object")continue;const l=A?`${a.provider}:${a.environment}`:a.provider;O[l]=a}return t.jsxs(Q,{title:s("admin.ops.shellTitle","Ops / Monitoring"),description:s("admin.ops.shellDescription","Vue centralisée de l'état des services externes et des alertes de la plateforme."),children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx(q,{asChild:!0,variant:"ghost",size:"sm",children:t.jsxs(ae,{to:me.adminConsole,children:[t.jsx(ue,{className:"mr-2 h-4 w-4"}),s("admin.ops.backToAdmin","Retour")]})}),t.jsxs("div",{className:"flex items-center gap-2",children:[ie&&t.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.jsx(I,{className:"mr-1 inline h-3 w-3 animate-spin"}),s("admin.ops.refreshing","Rafraîchissement...")]}),t.jsxs(q,{variant:"outline",size:"sm",onClick:g,disabled:d.isPending,children:[d.isPending&&h==="all"?t.jsx(I,{className:"mr-2 h-4 w-4 animate-spin"}):t.jsx(y,{className:"mr-2 h-4 w-4"}),s("admin.ops.syncAll","Synchroniser tout")]})]})]}),(x||d.error)&&t.jsx(U,{className:"border-destructive/40 bg-destructive/10",children:t.jsx(H,{className:"pt-6 text-sm text-destructive",children:(x==null?void 0:x.message)||(($=d.error)==null?void 0:$.message)})}),t.jsxs(U,{className:"rl-panel",children:[t.jsxs(pe,{children:[t.jsxs(xe,{className:"flex items-center gap-2",children:[t.jsx(he,{className:"h-5 w-5 text-muted-foreground"}),s("admin.ops.activeAlerts","Alertes actives"),N.length>
140&&t.jsx("span",{className:"ml-2 rounded-full bg-red-500/20 px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider text-red-300",children:N.length})]}),t.jsx(fe,{children:s("admin.ops.activeAlertsDesc","Problèmes détectés sur les services externes nécessitant une attention.")})]}),t.jsx(H,{children:i?t.jsxs("p",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground",children:[t.jsx(I,{className:"h-4 w-4 animate-spin"}),s("admin.loading")]}):t.jsxs("div",{className:"space-y-3",children:[N.length===0?t.jsxs("div",{className:"rl-inline-banner flex items-center gap-2 rounded-lg border-emerald-500/30 bg-emerald-500/5 px-4 py-3 text-sm text-emerald-400",children:[t.jsx(z,{className:"h-4 w-4 shrink-0"}),s("admin.ops.noAlerts","Aucune alerte active. Tous les services sont opérationnels.")]}):t.jsx("div",{className:"space-y-2",children:N.map(a=>{var l,j;return t.jsxs("div",{className:"flex items-start gap-3 rounded-lg border px-4 py-3 text-sm "+(a.severity==="critical"?"border-red-500/40 bg-red-500/5 text-red-300":"border-amber-500/40 bg-amber-500/5 text-amber-300"),children:[t.jsx(W,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("p",{className:"font-medium",children:[((l=M.find(u=>u.id===a.provider))==null?void 0:l.label)||a.provider,A&&a.environment&&t.jsx("span",{className:"ml-1.5 rounded bg-secondary/60 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:a.environment}),t.jsxs("span",{className:"ml-2 font-normal opacity-80",children:["- ",a.status]})]}),((j=a.summary)==null?void 0:j.error)&&t.jsx("p",{className:"mt-0.5 text-xs opacity-70",children:a.summary.error})]}),t.jsx("span",{className:"shrink-0 rounded-full px-2 py-0.5 text-[10px] font-bold uppercase tracking-wider "+(a.severity==="critical"?"bg-red-500/20 text-red-300":"bg-amber-500/20 text-amber-300"),children:a.severity==="critical"?s("admin.overview.critical","Critique"):s("admin.overview.warning","Attention")})]},`${a.provider}-${a.environment||""}-${a.severity}`)})}),re.length>0&&t.jsx("div",{className:"rl-inline-banner rounded-lg px-4 py-3 text-xs text-muted-foreground",children:"Le statut Stripe « dégradé » attendu reste visible sur sa carte, sans être compté comme alerte Ops bloquante."})]})})]}),A?["production","test"].map(a=>t.jsxs("div",{children:[t.jsxs("h3",{className:"mb-3 flex items-center gap-2 text-sm font-semibold uppercase tracking-wider text-muted-foreground",children:[t.jsx("span",{className:a==="production"?"text-emerald-400":"text-amber-400",children:"â"}),a==="production"?s("admin.ops.envProduction","Production"):s("admin.ops.envTest","Test")]}),t.jsx("div",{className:"mb-6 grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:M.map(l=>{const j=`${l.id}:${a}`,u=O[j],G=X[l.id],V=d.isPending&&(h===l.id||h==="all");return t.jsxs("div",{className:"group relative",children:[t.jsx(B,{provider:l.id,label:l.label,description:l.description,status:(u==null?void 0:u.status)||"unknown",severity:u==null?void 0:u.severity,summary:(u==null?void 0:u.summary)||{},fetchedAt:u==null?void 0:u.fetched_at,lastSync:u==null?void 0:u.last_sync,loading:i||V,children:!i&&!V&&(u==null?void 0:u.summary)&&G&&t.jsx(G,{summary:u.summary})}),!i&&t.jsx("button",{type:"button",className:"absolute right-3 top-3 rounded-lg border border-border/60 bg-background/75 p-1.5 text-muted-foreground transition-colors hover:bg-secondary/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>E(l.id),disabled:d.isPending,title:`Synchroniser ${l.label}`,"aria-label":`Synchroniser ${l.label}`,children:V?t.jsx(I,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):t.jsx(y,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},j)})})]},a)):t.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:M.map(a=>{const l=O[a.id],j=X[a.id],u=d.isPending&&(h===a.id||h==="all");return t.jsxs("div",{className:"group relative",children:[t.jsx(B,{provider:a.id,label:a.label,description:a.description,status:(l==null?void 0:l.status)||"unknown",severity:l==null?void 0:l.severity,summary:(l==null?void 0:l.summary)||{},fetchedAt:l==null?void 0:l.fetched_at,lastSync:l==null?void 0:l.last_sync,loading:i||u,children:!i&&!u&&(l==null?void 0:l.summary)&&j&&t.jsx(j,{summary:l.summary})}),!i&&t.jsx("button",{type:"button",className:"absolute right-3 top-3 rounded-lg border border-border/60 bg-background/75 p-1.5 text-muted-foreground transition-colors hover:bg-secondary/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",onClick:()=>E(a.id),disabled:d.isPending,title:`Synchroniser ${a.label}`,"aria-label":`Synchroniser ${a.label}`,children:u?t.jsx(I,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":!0}):t.jsx(y,{className:"h-3.5 w-3.5","aria-hidden":!0})})]},a.id)})}),d.isSuccess&&t.jsxs("div",{className:"rl-inline-banner flex items-center gap-2 rounded-lg border-emerald-500/30 bg-emerald-500/5 px-4 py-3 text-sm text-emerald-400",children:[t.jsx(z,{className:"h-4 w-4 shrink-0"}),s("admin.ops.syncSuccess","Synchronisation terminée."),((F=d.data)==null?void 0:F.synced)!=null&&t.jsxs("span",{className:"text-xs opacity-70",children:[d.data.synced," providers synchronisés",d.data.errors>0&&`, ${d.data.errors} erreur(s)`]})]})]})}export{_t 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.