PageSourceSearch

https://scalancy.com/assets/hub-0FldxTEE.js

js scalancy.com collected 2026-10-04 12:58:21 UTC 36,899 bytes, 1 lines download raw bytes

1import{c as te,n as C,o as P,x as xe,r as w,j as e,t as I,U as se,L as he}from"./index-Bb7MW16W.js";import{r as S,u as F}from"./auth-middleware-n1c03vpl.js";import{u as Z}from"./useQuery-DmbsqL0C.js";import{u as M}from"./useMutation-Bw0kvBUb.js";import{B as H}from"./badge-BPl49u2a.js";import{B}from"./button-r_rzVEzm.js";import{T as ee}from"./textarea-beC-3IUQ.js";import{A as fe}from"./AudienceLeadsPanel-Bmj-_Dyg.js";import{D as ge,a as be,b as je,c as ve,d as Ne,e as we}from"./dialog-CgCal5AY.js";import{F as ye}from"./file-text-BfW_4k7l.js";import{L as z}from"./loader-circle-s8e7aEOK.js";import{M as Ie,r as _e}from"./index-BL6EqHKH.js";import{M as Y}from"./message-square-CFX2f_Hv.js";import{C as ke}from"./check-CwB6YO2t.js";import{X}from"./x-DODLCocl.js";import{T as ae}from"./target-CYipY95s.js";import{S as ie}from"./sparkles-D1vf_iJR.js";import{L as re}from"./library-rhCv3PnF.js";import{S as de}from"./send-KkFRA5Ug.js";import{T as Ce}from"./trending-up-Y1ouHOqK.js";import{P as le}from"./plus-CtS8P6On.js";import{C as Pe}from"./chevron-right-BV_V8S4u.js";import{T as Se}from"./trash-2-B7URenLM.js";import"./index-BdoTTF0b.js";import"./utils-BpQQxgda.js";import"./tabs-CyE9EYnn.js";import"./index-CAnULS-d.js";import"./index-BEDwFmbA.js";import"./index-aglqyZUe.js";import"./index-CCubb9ie.js";import"./index-B7i__pRb.js";import"./input-TRulLoES.js";import"./label-oskuzDO4.js";import"./mail-CWE_fLgS.js";import"./circle-check-CoKV6UJT.js";import"./database-Bg6NjD1i.js";import"./Combination-ewqtdsSy.js";const Ae=[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]],ce=te("flame",Ae);const Fe=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],oe=te("inbox",Fe),De=C({method:"GET"}).middleware([S]).handler(P("0e3065883011a6e4c2eadc5bc165d7691db3d4c6a441c20710e4264e365f4feb")),qe=C({method:"POST"}).middleware([S]).handler(P("4f39389bf0c527f418adf458d3367b3d89868f6efc3a6199371346f024da65df")),Re=C({method:"POST"}).middleware([S]).handler(P("00d13cbe191791295c5eb6c784404117904b2b1fca6d7992068041e61332b938")),Ee=C({method:"POST"}).middleware([S]).handler(P("4d927ab40320e4ae0e8f6304abb63b81a5f8745adb53f31546f68303a78e48e0")),Te=C({method:"POST"}).middleware([S]).handler(P("f7eedfc22227ce1ab671d1da9b340b4476d867045b9152bf4bd72f53f23b24d7"));C({method:"POST"}).middleware([S]).handler(P("6102dc653828af21cf6540d53746e2f286022d323a3acd57080df543f3b84afd"));const $e=C({method:"POST"}).middleware([S]).handler(P("5d70b83ba953a84a9d25c98e1a0d41a313a269b56281885634b18cf0a4a7ca74")),Le=C({method:"POST"}).middleware([S]).handler(P("7fb5cc00853e7e62c83afbba3e882bc3edefab52354136a83b9bd1a4ee40f4e5")),Oe=C({method:"GET"}).middleware([S]).handler(P("b6299526ca49cb084ac0bf77a1d77918e3481c21fb674c932f41006b286a16a9")),Be=C({method:"GET"}).middleware([S]).handler(P("134924cd50ebcb82b882c4c23948d3f847ecdb43c3ce7824d01e8c72d5b55e6f")),Me=C({method:"POST"}).middleware([S]).handler(P("95de0cc5c03e0d5f0af690af63ad5666261c9083128d66a553328e148f1e4a95")),ze=C({method:"POST"}).middleware([S]).handler(P("18683069e679b47552e429d261d8e41c24d6b5153b3ba89dbfb73e47c463bb1c"));C({method:"POST"}).middleware([S]).handler(P("8a4379463a3a2a79e67c02724e7c36372f62412dc2679e0a7464e52fd91613cc"));const Ue=C({method:"POST"}).middleware([S]).handler(P("56d656dd9cdd7a88e2d6be0b67d35b465d363867a8c4afef2458d00b7740edeb")),Ge=C({method:"POST"}).middleware([S]).handler(P("d3c5a54ff9375d9e5d2b70af8d7534293fcfb9e7d95c65e883464c0262ba03f6"));function He(){const i=F(Oe),o=xe(),[a,s]=w.useState(null);w.useEffect(()=>{if(typeof window>"u")return;const c=new URLSearchParams(window.location.search),j=c.get("review");if(j){s(j),c.delete("review");const _=`${window.location.pathname}${c.toString()?"?"+c.toString():""}`;window.history.replaceState({},"",_)}},[]);const{data:l,isLoading:t}=Z({queryKey:["content-reviews","pending"],queryFn:()=>i({}),refetchInterval:3e4}),m=l??[];return e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(ye,{className:"h-4 w-4"}),"Contenus en attente de validation",m.length>0&&e.jsx(H,{variant:"destructive",className:"ml-1",children:m.length})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Articles rédigés par le pipeline, en attente de ta relecture avant publication."})]})}),t?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(z,{className:"h-3.5 w-3.5 animate-spin"})," Chargement…"]}):m.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground",children:"Aucun contenu en attente. Quand le pipeline produit un article, il apparaît ici."}):e.jsx("ul",{className:"space-y-2",children:m.map(c=>e.jsxs("li",{className:"flex items-start justify-between gap-3 rounded-md border p-3 hover:bg-muted/30 transition",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(H,{variant:c.status==="pending_plan_review"?"outline":"default",children:c.status==="pending_plan_review"?"Plan à valider":"Article à valider"}),c.audiences?.name&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["· ",c.audiences.name]}),c.article_angles?.method&&e.jsx(H,{variant:"secondary",className:"text-[10px]",children:c.article_angles.method})]}),e.jsx("p",{className:"text-sm font-medium truncate",children:c.title}),c.excerpt&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-0.5",children:c.excerpt}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-1",children:[c.word_count??0," mots · ",c.reading_time_min??0," min de lecture"]})]}),e.jsx(B,{size:"sm",variant:"outline",onClick:()=>s(c.id),children:"Relire"})]},c.id))}),a&&e.jsx(Ke,{articleId:a,onClose:()=>s(null),onDone:()=>{s(null),o.invalidateQueries({queryKey:["content-reviews"]})}})]})}function Ke({articleId:i,onClose:o,onDone:a}
1){const s=F(Be),l=F(Me),t=F(ze),m=F(Ue),c=F(Ge),[j,_]=w.useState(""),[x,h]=w.useState(!1),{data:T,isLoading:u}=Z({queryKey:["content-reviews","detail",i],queryFn:()=>s({data:{articleId:i}})}),p=T?.article,A=p?.article_angles,y=p?.status==="pending_plan_review",q=M({mutationFn:()=>y?m({data:{articleId:i,comments:j||void 0}}):l({data:{articleId:i,comments:j||void 0,publish:!0}}),onSuccess:()=>{I.success(y?"Plan validé — Claude peut lancer la rédaction":"Article publié"),a()},onError:g=>I.error(g?.message??"Erreur")}),R=M({mutationFn:()=>y?c({data:{articleId:i,comments:j}}):t({data:{articleId:i,comments:j}}),onSuccess:()=>{I.success(y?"Plan rejeté — Claude reverra le plan avec ton feedback":"Article rejeté — le pipeline pourra re-itérer"),a()},onError:g=>I.error(g?.message??"Erreur")}),d=p?.plan_json;return e.jsx(ge,{open:!0,onOpenChange:g=>!g&&o(),children:e.jsxs(be,{className:"max-w-4xl max-h-[90vh] overflow-hidden flex flex-col",children:[e.jsxs(je,{children:[e.jsx(ve,{className:"pr-8",children:u?"Chargement…":p?.title??"Article"}),p&&e.jsxs(Ne,{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(H,{variant:y?"outline":"default",children:y?"Plan à valider":p.status}),A?.method&&e.jsx(H,{variant:"secondary",children:A.method}),!y&&e.jsxs("span",{children:[p.word_count??0," mots"]}),p.audiences?.name&&e.jsxs("span",{children:["· ",p.audiences.name]})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto pr-2",children:u?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-8",children:[e.jsx(z,{className:"h-4 w-4 animate-spin"})," Chargement…"]}):e.jsxs("div",{className:"space-y-4",children:[A&&e.jsxs("div",{className:"rounded-md bg-muted/40 border p-3 space-y-1 text-xs",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Angle :"})," ",A.title]}),A.subject&&e.jsxs("div",{children:[e.jsx("strong",{children:"Sujet :"})," ",A.subject]}),A.differentiation_note&&e.jsxs("div",{children:[e.jsx("strong",{children:"Différenciation :"})," ",A.differentiation_note]}),A.sdr_bridge&&e.jsxs("div",{className:"pt-1 border-t mt-2",children:[e.jsx("strong",{children:"Pont SDR (interne) :"})," ",A.sdr_bridge]})]}),y&&d?e.jsxs("div",{className:"space-y-4",children:[d.hook&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase mb-1",children:"Hook"}),e.jsx("p",{className:"text-sm",children:d.hook})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-semibold text-muted-foreground uppercase mb-2",children:["Sections (",d.sections?.length??0,")"]}),e.jsx("ol",{className:"space-y-3 list-decimal ml-5",children:d.sections?.map((g,U)=>e.jsxs("li",{className:"text-sm",children:[e.jsx("div",{className:"font-medium",children:g.heading}),g.angle&&e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5 italic",children:g.angle}),g.intro&&e.jsx("div",{className:"text-xs mt-1",children:g.intro}),g.key_points&&g.key_points.length>0&&e.jsx("ul",{className:"list-disc ml-4 mt-1.5 text-xs text-muted-foreground space-y-1",children:g.key_points.map(($,G)=>{const v=typeof $=="object"&&$!==null,O=v?$.point:$,D=v?$.sub_points??[]:[];return e.jsxs("li",{children:[O,D.length>0&&e.jsx("ul",{className:"list-[circle] ml-4 mt-0.5 space-y-0.5",children:D.map((L,J)=>e.jsx("li",{children:L},J))})]},G)})}),typeof g.expected_words=="number"&&e.jsxs("div",{className:"text-[11px] text-muted-foreground mt-1",children:["≈ ",g.expected_words," mots"]})]},U))})]}),d.conclusion_intent&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground uppercase mb-1",children:"Intention de conclusion"}),e.jsx("p",{className:"text-sm",children:d.conclusion_intent})]})]}):e.jsxs(e.Fragment,{children:[p?.excerpt&&e.jsx("p",{className:"text-sm italic text-muted-foreground",children:p.excerpt}),e.jsx("article",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx(Ie,{remarkPlugins:[_e],children:p?.content_md??""})})]})]})}),e.jsxs(we,{className:"flex-col gap-2 sm:flex-col sm:space-x-0 border-t pt-3",children:[x&&e.jsx(ee,{value:j,onChange:g=>_(g.target.value),placeholder:y?"Feedback pour Claude : ce qui manque dans le plan, angles à creuser, sources à ajouter…":"Commentaires pour le prochain tour (obligatoire) : ce qui ne va pas, ce qu'il faut corriger…",className:"min-h-[80px]"}),e.jsx("div",{className:"flex gap-2 justify-end w-full",children:x?e.jsxs(e.Fragment,{children:[e.jsx(B,{variant:"ghost",onClick:()=>h(!1),children:"Annuler"}),e.jsxs(B,{variant:"destructive",onClick:()=>R.mutate(),disabled:R.isPending||j.trim().length<3,children:[R.isPending?e.jsx(z,{className:"h-4 w-4 mr-1.5 animate-spin"}):e.jsx(X,{className:"h-4 w-4 mr-1.5"}),"Confirmer le rejet"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(B,{variant:"outline",onClick:()=>h(!0),disabled:q.isPending,children:[e.jsx(Y,{className:"h-4 w-4 mr-1.5"})," ",y?"Feedback / rejet":"Rejeter"]}),e.jsxs(B,{onClick:()=>q.mutate(),disabled:q.isPending,children:[q.isPending?e.jsx(z,{className:"h-4 w-4 mr-1.5 animate-spin"}):e.jsx(ke,{className:"h-4 w-4 mr-1.5"}),y?"Valider le plan":"Valider et publier"]})]})})]})]})})}function Tn(){const i=F(De),o=F(qe),{data:a,isLoading:s,refetch:l}=Z({queryKey:["hub-data"],queryFn:()=>i()}
1),[t,m]=w.useState({icpId:null,audienceId:null,painId:null,angleId:null,contentId:null,campaignId:null}),[c,j]=w.useState(!1),[_,x]=w.useState("");w.useEffect(()=>{a&&!t.icpId&&a.icps.length>0&&m(n=>({...n,icpId:a.icps[0].id}))},[a,t.icpId]);const h=w.useMemo(()=>{if(!a)return null;const n=new Map;a.articles.forEach(N=>n.set(N.id,N.angle_id));const r=new Map;(a.pains??[]).forEach(N=>r.set(N.id,N));const b=new Map,f=new Map;(a.audiencePains??[]).forEach(N=>{const K=r.get(N.pain_point_id);if(!K)return;const Q=b.get(N.audience_id)??[];Q.push({...K,position:N.position}),b.set(N.audience_id,Q);const ne=f.get(N.pain_point_id)??[];ne.push(N.audience_id),f.set(N.pain_point_id,ne)});for(const N of b.values())N.sort((K,Q)=>(K.position??0)-(Q.position??0));return{articleAngleById:n,painsById:r,painsByAudience:b,audiencesByPain:f}},[a]),T=M({mutationFn:n=>o({data:n}),onSuccess:(n,r)=>{I.success("Supprimé"),m(b=>{const f={...b};return r.kind==="icp"&&b.icpId===r.id?{icpId:null,audienceId:null,painId:null,angleId:null,contentId:null,campaignId:null}:(r.kind==="audience"&&b.audienceId===r.id&&(f.audienceId=null,f.painId=null,f.angleId=null,f.contentId=null,f.campaignId=null),r.kind==="angle"&&b.angleId===r.id&&(f.angleId=null),r.kind==="content"&&b.contentId===r.id&&(f.contentId=null,f.campaignId=null),r.kind==="campaign"&&b.campaignId===r.id&&(f.campaignId=null),f)}
1),l()},onError:n=>I.error(n?.message??"Suppression impossible")});if(s||!a)return e.jsx("div",{className:"flex h-full items-center justify-center py-20",children:e.jsx(z,{className:"h-5 w-5 animate-spin text-muted-foreground"})});const u=a.icps,p=a.audiences.filter(n=>n.is_active!==!1&&(!t.icpId||n.icp_id===t.icpId)),A=t.audienceId?h?.painsByAudience.get(t.audienceId)??[]:[],y=n=>n.pain_point_id?h?.audiencesByPain.get(n.pain_point_id)??[]:n.audience_id?[n.audience_id]:[],q=a.angles.filter(n=>t.painId?n.pain_point_id===t.painId:t.audienceId?y(n).includes(t.audienceId):!0),R=a.contents.filter(n=>t.angleId?(n.source_article_id?h?.articleAngleById.get(n.source_article_id)??null:null)===t.angleId:t.audienceId?Array.isArray(n.audience_ids)&&n.audience_ids.includes(t.audienceId):!0),d=a.campaigns.filter(n=>t.contentId?n.content_id===t.contentId:t.audienceId?n.audience_id===t.audienceId:!0);function g(n){m({icpId:n,audienceId:null,painId:null,angleId:null,contentId:null,campaignId:null})}function U(n){m(r=>({...r,audienceId:n,painId:null,angleId:null,contentId:null,campaignId:null}))}function $(n){m(r=>({...r,painId:r.painId===n?null:n,angleId:null,contentId:null,campaignId:null}))}function G(n){m(r=>({...r,angleId:n,contentId:null,campaignId:null}))}function v(n){m(r=>({...r,contentId:n,campaignId:null}))}function O(n){m(r=>({...r,campaignId:n}))}function D(n,r,b){typeof window<"u"&&!window.confirm(`Supprimer « ${b} » ?`)||T.mutate({kind:n,id:r})}function L(n){x(n),j(!0)}const J=Qe(t,a,{audiences:p,angles:q,contents:R}),ue=t.audienceId?a.audiences.find(n=>n.id===t.audienceId):null,me=t.angleId?a.angles.find(n=>n.id===t.angleId):null,pe=a.pains??[];return e.jsxs("div",{className:"flex h-screen flex-col gap-3 px-4 py-4",children:[e.jsxs("header",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-mono uppercase tracking-widest text-muted-foreground",children:"Hub"}),e.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:a.workspace?.name??"Workspace"})]}),e.jsx(We,{stats:{icps:u.length,audiences:a.audiences.filter(n=>n.is_active).length,angles:a.angles.length,contents:a.contents.length,campaigns:a.campaigns.length,qualifiedReads:a.stats.qualifiedReads}})]}),e.jsx("div",{className:"rounded-lg border bg-card p-3",children:e.jsx(He,{})}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[e.jsx("div",{className:"min-h-0 flex-1 overflow-x-auto",children:e.jsxs("div",{className:"grid h-full min-w-[1680px] grid-cols-6 gap-3",children:[e.jsxs(V,{icon:ae,title:"ICPs",count:u.length,onAdd:()=>L("Propose 3 ICPs pertinents pour mon business."),children:[u.length===0&&e.jsx(E,{hint:"Clique sur + pour demander à Claude"}),u.map(n=>e.jsx(W,{active:t.icpId===n.id,onClick:()=>g(n.id),onDelete:()=>D("icp",n.id,n.name),title:n.name,subtitle:n.description,meta:e.jsxs(e.Fragment,{children:[n.validated_at&&e.jsx(k,{children:"validé"}),n.global_score!=null&&e.jsxs(k,{children:[n.global_score,"/100"]}),e.jsxs(k,{muted:!0,children:[a.audiences.filter(r=>r.icp_id===n.id).length," aud."]})]})},n.id))]}),e.jsx(V,{icon:se,title:"Audiences",count:p.length,addDisabled:!t.icpId,onAdd:()=>{const n=u.find(r=>r.id===t.icpId);L(`Crée une nouvelle audience pour l'ICP « ${n?.name??""} ». Propose persona, taille estimée et angle d'attaque.`)},children:t.icpId?p.length===0?e.jsx(E,{hint:"Aucune audience. Clique sur +"}):p.map(n=>e.jsx(W,{active:t.audienceId===n.id,onClick:()=>U(n.id),onDelete:()=>D("audience",n.id,n.name),title:n.name,subtitle:[n.persona_role,n.persona_seniority].filter(Boolean).join(" · ")||null,indent:!!n.parent_audience_id,meta:e.jsxs(e.Fragment,{children:[!n.is_active&&e.jsx(k,{muted:!0,children:"inactive"}),n.hotline_managed&&e.jsx(k,{children:"gérée"}),n.global_score!=null&&e.jsxs(k,{children:["fit ",n.global_score]}),n.estimated_size!=null&&e.jsxs(k,{muted:!0,children:["~",(n.estimated_size/1e3).toFixed(1),"k"]}),e.jsxs(k,{muted:!0,children:[a.angles.filter(r=>r.pain_point_id?(h?.audiencesByPain.get(r.pain_point_id)??[]).includes(n.id
1):r.audience_id===n.id).length," angles"]})]})},n.id)):e.jsx(E,{hint:"Sélectionne un ICP"})}),e.jsx(Xe,{audience:t.audienceId?a.audiences.find(n=>n.id===t.audienceId):null,pains:A,selectedPainId:t.painId,onSelect:$,onAfterMutation:()=>l(),allAudiences:a.audiences.filter(n=>n.is_active!==!1),audiencePainsMap:h?.painsByAudience??new Map}),e.jsx(V,{icon:ie,title:"Angles",count:q.length,addDisabled:!t.audienceId&&!t.painId,onAdd:()=>{const n=a.audiences.find(b=>b.id===t.audienceId),r=t.painId?h?.painsById.get(t.painId):null;L(r&&!n?`Génère 3 nouveaux angles éditoriaux qui adressent le problème « ${r.title} ». Règle : un angle hérite automatiquement de toutes les audiences liées à ce problème — n'invente pas d'audience spécifique. Chaque angle est une façon différente (contrarian, pressure, question) de présenter la solution.`:r&&n?`Génère 3 angles éditoriaux qui adressent le problème « ${r.title} » (rattaché notamment à l'audience « ${n.name} »). Chaque angle couvrira toutes les audiences liées à ce problème. Méthodes variées (contrarian, pressure, question).`:`Génère 5 angles éditoriaux pour l'audience « ${n?.name??""} ». Règle : chaque angle doit d'abord identifier un problème (spécifique à cette audience OU partagé avec d'autres audiences) puis proposer une façon de présenter la solution. Si le problème est partagé, l'angle sera automatiquement rattaché aux autres audiences concernées.`)},children:!t.audienceId&&!t.painId?e.jsx(E,{hint:"Sélectionne une audience ou un problème"}):q.length===0?e.jsx(E,{hint:t.painId?"Aucun angle pour ce problème. Clique sur +":"Aucun angle. Clique sur +"}):q.map(n=>{const r=n.pain_point_id?h?.painsById.get(n.pain_point_id)?.title:null,f=y(n).map(K=>a.audiences.find(Q=>Q.id===K)?.name).filter(Boolean),N=[];return r&&N.push(`🔥 ${r}`),f.length>0&&N.push(f.length===1?`👥 ${f[0]}`:`👥 ${f.length} audiences`),e.jsx(W,{active:t.angleId===n.id,onClick:()=>G(n.id),onDelete:()=>D("angle",n.id,n.title),title:n.title,subtitle:N.join(" · ")||null,meta:e.jsxs(e.Fragment,{children:[e.jsx(k,{muted:!0,children:n.method??"—"}),e.jsx(k,{tone:n.status==="approved"?"primary":"muted",children:n.status})]})},n.id)})}),e.jsx(V,{icon:re,title:"Contenus",count:R.length,addDisabled:!t.audienceId,onAdd:()=>{const n=a.angles.find(f=>f.id===t.angleId),r=a.audiences.find(f=>f.id===t.audienceId),b=n?`angle « ${n.title} »`:`audience « ${r?.name??""} »`;L(`Produis un nouvel article pour ${b}. Suis le style éditorial Scalancy.`)},children:t.audienceId?R.length===0?e.jsx(E,{hint:t.angleId?"Aucun contenu pour cet angle":"Aucun contenu"}):R.map(n=>e.jsx(W,{active:t.contentId===n.id,onClick:()=>v(n.id),onDelete:()=>D("content",n.id,n.name),title:n.name,meta:e.jsxs(e.Fragment,{children:[e.jsx(k,{muted:!0,className:"uppercase",children:n.kind}),e.jsx(k,{tone:n.status==="published"?"primary":"muted",children:n.status}),e.jsxs(k,{muted:!0,children:[a.campaigns.filter(r=>r.content_id===n.id).length," camp."]})]})},n.id)):e.jsx(E,{hint:"Sélectionne une audience"})}),e.jsx(V,{icon:de,title:"Campagnes",count:d.length,addDisabled:!t.contentId&&!t.audienceId,onAdd:()=>{const n=a.contents.find(b=>b.id===t.contentId),r=a.audiences.find(b=>b.id===t.audienceId);L(`Lance une campagne sur le contenu « ${n?.name??""} » pour l'audience « ${r?.name??""} ». Confirme le séquencement avant de démarrer.`)},children:!t.audienceId&&!t.contentId?e.jsx(E,{hint:"Sélectionne audience/contenu"}):d.length===0?e.jsx(E,{hint:"Aucune campagne. Clique sur +"}):d.map(n=>e.jsx(W,{active:t.campaignId===n.id,onClick:()=>O(n.id),onDelete:()=>D("campaign",n.id,n.name),title:n.name,meta:e.jsxs(e.Fragment,{children:[e.jsx(k,{tone:n.status==="running"?"primary":"muted",children:n.status}),e.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:new Date(n.created_at).toLocaleDateString("fr-FR")})]})},n.id))})]})}),e.jsx(Ve,{details:J,audience:ue,angle:me,anglePainOptions:pe,onAfterMutation:()=>l()})]}),e.jsx(Je,{open:c,setOpen:j,prefill:_,onAfterAction:()=>l()})]})}function Qe(i,o,a){if(i.campaignId){const s=o.campaigns.find(l=>l.id===i.campaignId);return s?{kind:"campaign",title:s.name,eyebrow:"Campagne",sections:[{label:"Statut",value:s.status}
1,{label:"Créée le",value:new Date(s.created_at).toLocaleString("fr-FR")},s.scheduled_at&&{label:"Planifiée",value:new Date(s.scheduled_at).toLocaleString("fr-FR")},s.started_at&&{label:"Démarrée",value:new Date(s.started_at).toLocaleString("fr-FR")},s.completed_at&&{label:"Terminée",value:new Date(s.completed_at).toLocaleString("fr-FR")}].filter(Boolean),link:{to:"/campaigns/$id",params:{id:s.id},label:"Ouvrir la campagne →"}}:null}if(i.contentId){const s=o.contents.find(l=>l.id===i.contentId);return s?{kind:"content",title:s.name,eyebrow:`Contenu · ${s.kind}`,sections:[{label:"Statut",value:s.status},{label:"Audiences liées",value:String((s.audience_ids??[]).length)},{label:"Créé le",value:new Date(s.created_at).toLocaleString("fr-FR")}]}:null}if(i.angleId){const s=o.angles.find(l=>l.id===i.angleId);return s?{kind:"angle",title:s.title,eyebrow:`Angle · ${s.method??"—"}`,sections:[{label:"Statut",value:s.status},s.approved_at&&{label:"Approuvé le",value:new Date(s.approved_at).toLocaleString("fr-FR")},{label:"Contenus produits",value:String(a.contents.length)}].filter(Boolean)}:null}if(i.audienceId){const s=o.audiences.find(l=>l.id===i.audienceId);return s?{kind:"audience",title:s.name,eyebrow:"Audience",sections:[s.persona_role&&{label:"Persona",value:[s.persona_role,s.persona_seniority].filter(Boolean).join(" · ")},s.estimated_size!=null&&{label:"Taille estimée",value:`${s.estimated_size.toLocaleString("fr-FR")} leads`},s.global_score!=null&&{label:"Fit score",value:`${s.global_score}/100`},{label:"Active",value:s.is_active?"Oui":"Non"},{label:"Angles",value:String(a.angles.length)}].filter(Boolean)}:null}if(i.icpId){const s=o.icps.find(l=>l.id===i.icpId);return s?{kind:"icp",title:s.name,eyebrow:"ICP",sections:[s.description&&{label:"Description",value:s.description,full:!0},s.global_score!=null&&{label:"Score",value:`${s.global_score}/100`},s.validated_at&&{label:"Validé le",value:new Date(s.validated_at).toLocaleString("fr-FR")},{label:"Audiences",value:String(a.audiences.length)}].filter(Boolean)}:null}return null}function Ve({details:i,audience:o,angle:a,anglePainOptions:s,onAfterMutation:l}){const[t,m]=w.useState("summary");w.useEffect(()=>{m("summary")},[o?.id]);const c=!!o&&i?.kind==="audience",j=F($e),_=M({mutationFn:x=>j({data:x}),onSuccess:()=>{I.success("Pain associé"),l?.()},onError:x=>I.error(x?.message??"Erreur")});return e.jsxs("aside",{className:"flex max-h-[320px] min-h-[180px] flex-col overflow-hidden rounded-lg border border-border/60 bg-surface/40",children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Détail"}),i&&e.jsx(H,{variant:"outline",className:"ml-auto text-[10px]",children:i.eyebrow})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:i?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("h2",{className:"text-base font-semibold leading-tight",children:i.title}),c&&e.jsxs("div",{className:"flex gap-1 rounded-md border border-border/60 p-0.5",children:[e.jsx("button",{onClick:()=>m("summary"),className:`rounded px-2 py-0.5 text-[11px] ${t==="summary"?"bg-primary/15 text-primary":"text-muted-foreground"}`,children:"Résumé"}),e.jsx("button",{onClick:()=>m("leads"),className:`rounded px-2 py-0.5 text-[11px] ${t==="leads"?"bg-primary/15 text-primary":"text-muted-foreground"}`,children:"Leads"})]})]}),(!c||t==="summary")&&e.jsxs("div",{className:"flex flex-wrap gap-x-6 gap-y-2",children:[i.sections.map((x,h)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("dt",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:x.label}),e.jsx("dd",{className:"text-sm",children:x.value})]},h)),i.link&&e.jsx(he,{to:i.link.to,params:i.link.params,className:"text-xs text-primary hover:underline",children:i.link.label})]}),i.kind==="angle"&&a&&e.jsxs("div",{className:"flex items-center gap-2 border-t border-border/60 pt-3",children:[e.jsx(ce,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("label",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Problème adressé"}),e.jsxs("select",{disabled:_.isPending,value:a.pain_point_id??"",onChange:x=>_.mutate({angleId:a.id,painPointId:x.target.value||null}),className:"rounded-md border border-border/60 bg-background px-2 py-1 text-xs",children:[e.jsx("option",{value:"",children:"— non défini —"}),(s??[]).map(x=>e.jsx("option",{value:x.id,children:x.title.length>80?x.title.slice(0,80)+"…":x.title},x.id))]}
1),_.isPending&&e.jsx(z,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),c&&t==="leads"&&o&&e.jsx(fe,{audienceId:o.id,audienceName:o.name})]}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 text-center text-xs text-muted-foreground",children:[e.jsx(oe,{className:"h-5 w-5"}),e.jsx("p",{children:"Sélectionne un élément pour voir son détail complet ici."})]})})]})}function We({stats:i}){const o=[{key:"icps",label:"ICPs",icon:ae},{key:"audiences",label:"Audiences",icon:se},{key:"angles",label:"Angles",icon:ie},{key:"contents",label:"Contenus",icon:re},{key:"campaigns",label:"Campagnes",icon:de},{key:"qualifiedReads",label:"Lectures",icon:Ce}];return e.jsx("div",{className:"flex flex-wrap gap-2",children:o.map(({key:a,label:s,icon:l})=>e.jsxs("div",{className:"flex items-center gap-1.5 rounded-md border border-border/60 bg-surface/40 px-2.5 py-1.5",children:[e.jsx(l,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground",children:s}),e.jsx("span",{className:"text-sm font-semibold tabular-nums",children:i[a]??0})]},a))})}function V({icon:i,title:o,count:a,children:s,onAdd:l,addDisabled:t}){return e.jsxs("div",{className:"flex min-h-0 flex-col rounded-lg border border-border/60 bg-surface/20",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsx(i,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide",children:o}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:a}),l&&e.jsx("button",{disabled:t,onClick:l,title:t?"Sélectionne le parent":`Ajouter ${o.toLowerCase()}`,className:"ml-auto rounded-md p-1 text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary disabled:cursor-not-allowed disabled:opacity-30",children:e.jsx(le,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"flex-1 space-y-1.5 overflow-y-auto p-2",children:s})]})}function Xe({audience:i,pains:o,selectedPainId:a,onSelect:s,onAfterMutation:l,allAudiences:t,audiencePainsMap:m}){const c=F(Re),j=F(Te),_=F(Ee),[x,h]=w.useState(!1),[T,u]=w.useState(""),[p,A]=w.useState(null),y=M({mutationFn:d=>c({data:{title:d,audienceId:i?.id}}),onSuccess:()=>{I.success("Problème ajouté"),u(""),h(!1),l()},onError:d=>I.error(d?.message??"Erreur")}),q=M({mutationFn:d=>j({data:{audienceId:i.id,painPointId:d}}),onSuccess:()=>{I.success("Détaché"),l()},onError:d=>I.error(d?.message??"Erreur")}),R=M({mutationFn:d=>_({data:d}),onSuccess:()=>{I.success("Rattaché"),l()},onError:d=>I.error(d?.message??"Erreur")});return e.jsxs("div",{className:"flex min-h-0 flex-col rounded-lg border border-border/60 bg-surface/20",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsx(ce,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide",children:"Problèmes"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:o.length}),e.jsx("button",{disabled:!i,onClick:()=>h(d=>!d),title:i?"Ajouter un problème":"Sélectionne une audience",className:"ml-auto rounded-md p-1 text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary disabled:cursor-not-allowed disabled:opacity-30",children:e.jsx(le,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"flex-1 space-y-1.5 overflow-y-auto p-2",children:i?e.jsxs(e.Fragment,{children:[x&&e.jsxs("div",{className:"rounded-md border border-primary/40 bg-primary/5 p-2 space-y-1.5",children:[e.jsx(ee,{value:T,onChange:d=>u(d.target.value),placeholder:"Décris le problème (ex: cash-flow imprévisible en fin de trimestre)",rows:2,className:"resize-none text-xs"}),e.jsxs("div",{className:"flex justify-end gap-1",children:[e.jsx(B,{size:"sm",variant:"ghost",onClick:()=>{h(!1),u("")},children:"Annuler"}),e.jsx(B,{size:"sm",disabled:T.trim().length<4||y.isPending,onClick:()=>y.mutate(T.trim()),children:y.isPending?e.jsx(z,{className:"h-3 w-3 animate-spin"}):"Ajouter"})]})]}),o.length===0&&!x?e.jsx(E,{hint:"Aucun problème. Clique sur + pour en ajouter"}):o.map(d=>{const g=a===d.id,U=new Set;for(const[v,O]of m.entries())O.some(D=>D.id===d.id)&&U.add(v);const $=t.filter(v=>v.id!==i.id),G=p===d.id;return e.jsx("div",{onClick:()=>s(d.id),className:`group cursor-pointer rounded-md border p-2 transition-colors ${g?"border-primary/60 bg-primary/10":"border-border/60 bg-surface/40 hover:bg-surface-elevated"}`,children:e.jsxs("div",{className:"flex items-start gap-1.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[12px] leading-snug text-foreground
1/90",children:d.title}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1",children:[e.jsxs(k,{muted:!0,children:[U.size," aud."]}),e.jsx("button",{onClick:v=>{v.stopPropagation(),A(G?null:d.id)},className:"text-[10px] text-primary hover:underline",children:G?"fermer":"+ rattacher"})]}),G&&e.jsx("div",{onClick:v=>v.stopPropagation(),className:"mt-1.5 space-y-0.5 rounded border border-border/60 bg-background p-1.5",children:$.length===0?e.jsx("div",{className:"text-[10px] text-muted-foreground",children:"Aucune autre audience"}):$.map(v=>{const O=U.has(v.id);return e.jsxs("label",{className:"flex items-center gap-1.5 rounded px-1 py-0.5 text-[11px] hover:bg-surface-elevated",children:[e.jsx("input",{type:"checkbox",checked:O,disabled:R.isPending,onChange:()=>{O?j({data:{audienceId:v.id,painPointId:d.id}}).then(()=>{I.success("Détaché"),l()}).catch(D=>I.error(D?.message??"Erreur")):R.mutate({audienceId:v.id,painPointId:d.id})}}),e.jsx("span",{className:"truncate",children:v.name})]},v.id)})})]}),e.jsx("button",{onClick:v=>{v.stopPropagation(),window.confirm(`Détacher « ${d.title} » de cette audience ?`)&&q.mutate(d.id)},title:"Détacher de cette audience",className:"mt-0.5 rounded p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-destructive/10 hover:text-destructive group-hover:opacity-100",children:e.jsx(X,{className:"h-3 w-3"})})]})},d.id)})]}):e.jsx(E,{hint:"Sélectionne une audience"})})]})}function W({active:i,onClick:o,onDelete:a,title:s,subtitle:l,meta:t,indent:m}){return e.jsx("div",{onClick:o,className:`group w-full cursor-pointer rounded-md border p-2.5 text-left transition-colors ${i?"border-primary/60 bg-primary/10":"border-border/60 bg-surface/40 hover:bg-surface-elevated"}`,children:e.jsxs("div",{className:"flex items-start gap-1.5",children:[m&&e.jsx(Pe,{className:"mt-0.5 h-3 w-3 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-medium leading-snug break-words",title:s,children:s}),l&&e.jsx("div",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground line-clamp-2 break-words",title:l,children:l}),t&&e.jsx("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:t})]}),a&&e.jsx("button",{onClick:c=>{c.stopPropagation(),a()},title:"Supprimer",className:"mt-0.5 rounded p-1 text-muted-foreground opacity-0 transition-opacity hover:bg-destructive/10 hover:text-destructive group-hover:opacity-100",children:e.jsx(Se,{className:"h-3.5 w-3.5"})})]})})}function k({children:i,muted:o,tone:a,className:s}){const l=a??(o?"muted":"primary");return e.jsx(H,{variant:l==="primary"?"default":"outline",className:`px-1.5 py-0 text-[9px] font-normal ${s??""}`,children:i})}function E({hint:i}){return e.jsxs("div",{className:"flex h-full min-h-[120px] flex-col items-center justify-center gap-2 rounded-md border border-dashed border-border/40 px-3 py-6 text-center text-[11px] text-muted-foreground",children:[e.jsx(oe,{className:"h-4 w-4"}),e.jsx("p",{children:i})]})}function Je({open:i,setOpen:o,prefill:a,onAfterAction:s}){const l=F(Le),[t,m]=w.useState([]),[c,j]=w.useState(""),_=w.useRef(null),x=typeof window<"u"?window.location.origin:void 0;w.useEffect(()=>{i&&a&&j(a)},[i,a]);const h=M({mutationFn:u=>l({data:{messages:u,origin:x}}),onSuccess:u=>{m(p=>[...p,{role:"assistant",content:u.text||"(action exécutée)"}]),u.toolUses&&u.toolUses.length>0&&(I.success(`${u.toolUses.length} action(s) exécutée(s)`),s())},onError:u=>I.error(u?.message??"Erreur chat")});w.useEffect(()=>{_.current?.scrollTo({top:_.current.scrollHeight,behavior:"smooth"})},[t,h.isPending]);function T(){const u=c.trim();if(!u||h.isPending)return;const p=[...t,{role:"user",content:u}];m(p),j(""),h.mutate(p)}return e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>o(!i),className:"fixed bottom-6 right-6 z-40 flex h-12 w-12 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-lg transition-transform hover:scale-105",title:"Chat Scalancy",children:i?e.jsx(X,{className:"h-5 w-5"}):e.jsx(Y,{className:"h-5 w-5"})}),i&&e.jsxs("div",{className:"fixed bottom-24 right-6 z-40 flex h-[560px] w-[400px] max-w-[calc(100vw-2rem)] flex-col overflow-hidden rounded-xl border border-border/60 bg-background shadow-2xl",children:[e.jsxs("header",{className:"flex items-center gap-2 border-b border-border/60 bg-surface/60 px-3 py-2",children:[e.jsx(Y,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{className:"text-xs font-medium",children:"Chat Scalancy"}),e.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"Claude + MCP"}),e.jsx("button",{onClick:()=>o(!1),className:"rounded p-1 text-muted-foreground hover:text-foreground",children:e.jsx(X,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{ref:_,className:"flex-1 space-y-2 overflow-y-auto px-3 py-3",children:[t.length===0&&e.jsxs("div",{className:"rounded-md border border-dashed border-border/60 p-3 text-xs text-muted-foreground",children:[e.jsx("p",{className:"mb-2 font-medium",children:"Astuce"}),e.jsx("p",{children:"Utilise les boutons + dans les colonnes pour pré-remplir une demande. Ou tape librement ce que tu veux faire."})]}),t.map((u,p)=>e.jsx("div",{className:u.role==="user"?"ml-4 rounded-md bg-primary/10 px-2.5 py-1.5 text-sm":"mr-4 whitespace-pre-wrap rounded-md bg-surface-elevated px-2.5 py-1.5 text-sm",children:u.content},p)),h.isPending&&e.jsxs("div",{className:"mr-4 flex items-center gap-2 rounded-md bg-surface-elevated px-2.5 py-1.5 text-xs text-muted-foreground",children:[e.jsx(z,{className:"h-3 w-3 animate-spin"}),"Claude travaille…"]})]}),e.jsxs("div",{className:"border-t border-border/60 p-2.5",children:[e.jsx(ee,{value:c,onChange:u=>j(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),T())},placeholder:"Décris ce que tu veux faire…",rows:3,className:"resize-none text-sm",disabled:h.isPending}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between text-[10px] text-muted-foreground",children:[e.jsx("span",{children:"↵ envoyer · ⇧↵ saut"}),e.jsx(B,{size:"sm",onClick:T,disabled:!c.trim()||h.isPending,children:"Envoyer"})]})]})]})]})}export{Tn as component};

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.