1import{o as e}from"./chunk-C_JJxWoe.js";import{c as s}from"./chunk-EPL6mP1y.js";import{a,n as t,o as i,r as l}from"./chunk-Dv4tCFv-.js";import{n as r,t as d}from"./chunk-Cf59AXHh.js";import{a as n,c,h as o,l as m,o as u}from"./chunk-Pkhj_1Nm.js";import{a as h,d as x,f as p}from"./chunk-BcffupGI.js";import{c as j,f,l as g,p as v,y as N}from"./chunk-DJXo0qKc.js";import{r as b}from"./chunk-CJgAGqKS.js";import{a as y,c as _,i as w,l as k}from"./chunk-CfLPUsxn.js";import{s as C}from"./chunk-mAnUq8cn.js";import{n as S,r as M}from"./chunk-pbrEGh0G.js";import{a as D,o as P}from"./chunk-CBh2d2Be.js";import{Bt as R,Ht as E,Ir as A,Mr as T,Qn as F,Rr as $,Rt as I,Ut as z,Wt as L,zt as O}from"../index-DkGUPYoQ.js";import{n as q}from"./chunk-BM0pDCyk2.js";import{a as H,n as G,o as B,r as V,s as U,t as Y}from"./chunk-Dwh9rESY2.js";import{t as W}from"./chunk-BQ3lwMr52.js";import{a as K,m as Q}from"./chunk-9TPctMZ6.js";import{t as J}from"./chunk-Bckf89-2.js";import{t as X}from"./chunk-CJ1Dl5N5.js";import{a as Z,i as ee,n as se,r as ae,t as te}from"./chunk-DZP29MQJ.js";import{t as ie}from"./chunk-HpbWOqlt.js";import{t as le}from"./chunk-Cn13GsAy.js";import{t as re}from"./chunk-DfWcVx0P.js";import{i as de,n as ne,r as ce,t as oe}from"./chunk-647lud5-.js";import{t as me}from"./chunk-CBXXxt7l.js";import{t as ue}from"./chunk-CCGKoFKW.js";var he=e($(),1),xe=T();function pe(){const[e,s]=(0,he.useState)(new Date),[t,l]=(0,he.useState)([]),[d,n]=(0,he.useState)([]),[c,o]=(0,he.useState)(!1),[m,u]=(0,he.useState)(""),{toast:h}=A(),x=async()=>{try{const{data:e,error:s}=await q.from("publication_schedule_with_computed").select("\n *,\n episode_workflows!publication_schedule_episode_workflow_id_fkey (\n episode_id,\n metadata\n )\n ").order("scheduled_date",{ascending:!0});if(s)throw s;const a=e?.map(e=>({...e,episode_title:(e.episode_workflows?.metadata)?.title||`Episode ${e.episode_workflows?.episode_id}`,platform_targets:Array.isArray(e.platform_targets)?e.platform_targets.map(String):[]}))||[];l(a)}catch(e){h({title:"Error loading events",description:"Failed to load publication calendar",variant:"destructive"})}};(0,he.useEffect)(()=>{x(),(async()=>{try{const{data:e,error:s}=await q.from("episode_workflows").select("*").in("current_stage",["uploaded","processed","content_generated","content_approved","scheduled","published"]).order("created_at",{ascending:!1});if(s)throw s;n(e||[])}catch(e){}})()},[]);const j=e=>t.filter(s=>Q(new Date(s.scheduled_date),e)),f=e=>{switch(e){case"published":case"approved":return"default";case"scheduled":return"secondary";case"pending_approval":return"destructive";default:return"outline"}};return(0,xe.jsxs)("div",{className:"space-y-6",children:[(0,xe.jsxs)("div",{className:"flex items-center justify-between",children:[(0,xe.jsxs)("div",{children:[(0,xe.jsx)("h2",{className:"text-3xl font-bold tracking-tight",children:"Publication Calendar"}),(0,xe.jsx)("p",{className:"text-muted-foreground",children:"Manage Thursday publication schedule and approval workflows"})]}),(0,xe.jsxs)(Y,{open:c,onOpenChange:o,children:[(0,xe.jsx)(U,{asChild:!0,children:(0,xe.jsxs)(L,{className:"gap-2",children:[(0,xe.jsx)(i,{className:"h-4 w-4"}),"Schedule Episode"]})}),(0,xe.jsxs)(G,{children:[(0,xe.jsxs)(H,{children:[(0,xe.jsx)(B,{children:"Schedule Episode for Publication"}),(0,xe.jsx)(V,{children:"Select an episode and date for automated Thursday publication"})]}),(0,xe.jsxs)("div",{className:"space-y-4",children:[(0,xe.jsxs)("div",{className:"space-y-2",children:[(0,xe.jsx)("label",{className:"text-sm font-medium",children:"Episode"}),(0,xe.jsxs)(te,{value:m,onValueChange:u,children:[(0,xe.jsx)(ee,{children:(0,xe.jsx)(Z,{placeholder:"Select episode to schedule"})}),(0,xe.jsx)(se,{children:d.map(e=>(0,xe.jsxs)(ae,{value:e.id,children:[e.metadata?.title||`Episode ${e.episode_id}`," [",(e.metadata?.type||"episode").toUpperCase(),"] - ",(e.current_stage||"unknown").replace("_"," ").toUpperCase()]},e.id))})]})]}),(0,xe.jsxs)("div",{className:"space-y-2",children:[(0,xe.jsx)("label",{className:"text-sm font-medium",children:"Publication Date"}),(0,xe.jsx)(ue,{mode:"single",selected:e,onSelect:s,disabled:e=>{const s=new Date;return s.setHours(0,0,0,0),e<s||!K(e)},className:"rounded-md border"}),(0,xe.jsx)("p",{className:"text-xs text-muted-foreground",children:"Only Thursdays are available for publication scheduling"})]}),(0,xe.jsx)(L,{onClick:async()=>
1{if(m&&e)try{const s=j(e);if(s.length>0)return void h({title:"Scheduling conflict detected",description:`${s.length} episode(s) already scheduled for ${J(e,"MMMM d, yyyy")}`,variant:"destructive"});const{error:a}=await q.from("publication_schedule").insert({episode_workflow_id:m,scheduled_date:J(e,"yyyy-MM-dd"),scheduled_time:"12:00:00",platform_targets:["facebook","instagram","linkedin","google_business"],publication_status:"scheduled",approval_required:!0});if(a)throw a;h({title:"Episode scheduled",description:`Successfully scheduled for ${J(e,"MMMM d, yyyy")}`}),o(!1),u(""),x()}catch(s){h({title:"Scheduling failed",description:"Failed to schedule episode",variant:"destructive"})}},disabled:!m||!e,className:"w-full",children:"Schedule for Publication"})]})]})]})]}),(0,xe.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,xe.jsx)("div",{className:"lg:col-span-2",children:(0,xe.jsxs)(I,{children:[(0,xe.jsx)(E,{children:(0,xe.jsxs)(z,{className:"flex items-center gap-2",children:[(0,xe.jsx)(p,{className:"h-5 w-5"}),"Monthly View"]})}),(0,xe.jsx)(O,{children:(0,xe.jsx)(ue,{mode:"single",selected:e,onSelect:s,className:"rounded-md border",components:{DayContent:({date:e})=>{const s=j(e),a=K(e);return(0,xe.jsxs)("div",{className:"relative w-full h-full p-1",children:[(0,xe.jsx)("div",{className:"text-center "+(a?"font-semibold text-primary":""),children:J(e,"d")}),s.length>0&&(0,xe.jsx)("div",{className:"absolute bottom-1 left-1 right-1",children:(0,xe.jsxs)("div",{className:"flex gap-1",children:[s.slice(0,2).map((e,s)=>(0,xe.jsx)("div",{className:"h-1.5 flex-1 rounded-full "+("published"===e.publication_status?"bg-green-500":"approved"===e.publication_status?"bg-blue-500":"scheduled"===e.publication_status?"bg-yellow-500":"bg-gray-400")},s)),s.length>2&&(0,xe.jsx)("div",{className:"h-1.5 w-1.5 rounded-full bg-primary"})]})})]})}}})})]})}),(0,xe.jsxs)("div",{className:"space-y-4",children:[(0,xe.jsxs)(I,{children:[(0,xe.jsxs)(E,{children:[(0,xe.jsxs)(z,{className:"flex items-center gap-2",children:[(0,xe.jsx)(a,{className:"h-5 w-5"}),e?J(e,"MMMM d, yyyy"):"Select a date"]}),(0,xe.jsx)(R,{children:e&&K(e)?"Publication day":"Regular day"})]}),(0,xe.jsx)(O,{children:e&&(0,xe.jsx)("div",{className:"space-y-3",children:0===j(e).length?(0,xe.jsx)("p",{className:"text-sm text-muted-foreground",children:"No episodes scheduled"}):j(e).map(e=>(0,xe.jsxs)("div",{className:"space-y-2 p-3 border rounded-lg",children:[(0,xe.jsxs)("div",{className:"flex items-start justify-between",children:[(0,xe.jsx)("h4",{className:"font-medium text-sm",children:e.episode_title}),(0,xe.jsx)(W,{variant:f(e.publication_status),children:e.publication_status})]}),(0,xe.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,xe.jsx)(a,{className:"h-3 w-3"}),e.scheduled_time]}),(0,xe.jsx)("div",{className:"flex flex-wrap gap-1",children:e.platform_targets.map(e=>(0,xe.jsx)(W,{variant:"outline",className:"text-xs",children:e},e))})]},e.id))})})]}),(0,xe.jsxs)(I,{children:[(0,xe.jsx)(E,{children:(0,xe.jsxs)(z,{className:"flex items-center gap-2",children:[(0,xe.jsx)(r,{className:"h-5 w-5"}),"Upcoming Publications"]})}),(0,xe.jsx)(O,{children:(0,xe.jsxs)("div",{className:"space-y-2",children:[t.filter(e=>new Date(e.scheduled_date)>=new Date).slice(0,5).map(e=>(0,xe.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,xe.jsx)("span",{className:"truncate",children:e.episode_title}),(0,xe.jsx)(W,{variant:"outline",className:"text-xs",children:J(new Date(e.scheduled_date),"MMM d")})]},e.id)),0===t.filter(e=>new Date(e.scheduled_date)>=new Date).length&&(0,xe.jsx)("p",{className:"text-sm text-muted-foreground",children:"No upcoming publications"})]})})]})]})]})]})}var je=[{id:"facebook",label:"Facebook",icon:"ð"},{id:"instagram",label:"Instagram",icon:"ð¸"},{id:"linkedin",label:"LinkedIn",icon:"ð¼"},{id:"twitter",label:"X/Twitter",icon:"ð¦"},{id:"tiktok",label:"TikTok",icon:"ðµ"},{id:"youtube",label:"YouTube",icon:"â¶ï¸"},{id:"pinterest",label:"Pinterest",icon:"ð"}];function fe(){const[e,s]=(0,he.useState)([]),[t,i]=(0,he.useState)([]),[l,u]=(0,he.useState)(null),[p,j]=(0,he.useState)(null),[f,g]=(0,he.useState)(""),[v,N]=(0,he.useState)(!1),[y,_]=(0,he.useState)(!1),[w,k]=(0,he.useState)(["facebook","instagram","linkedin"]),[C,D]=(0,he.useState)(!1),[P,T]=(0,he.useState)("content"),{toast:F}
1=A(),$=async()=>{try{const{data:e,error:a}=await q.from("approval_queue").select("\n *,\n episode_workflows!approval_queue_episode_workflow_id_fkey (\n episode_id,\n metadata\n )\n ").order("created_at",{ascending:!1});if(a)throw a;const t=e?.map(e=>({...e,episode_title:(e.episode_workflows?.metadata)?.title||`Episode ${e.episode_workflows?.episode_id}`,episode_metadata:e.episode_workflows?.metadata}))||[];s(t)}catch(e){F({title:"Error loading approvals",description:"Failed to load approval queue",variant:"destructive"})}},K=async()=>{try{const{data:e,error:s}=await q.from("content_assets").select("\n *,\n episode_workflows!content_assets_episode_workflow_id_fkey (\n episode_id,\n metadata\n )\n ").in("approval_status",["pending","approved"]).order("created_at",{ascending:!1}).limit(50);if(s)throw s;const a=(e||[]).map(e=>({id:e.id,episode_workflow_id:e.episode_workflow_id,content_type:e.content_type,approval_status:e.approval_status,distribution_status:e.distribution_status||"pending",generated_content:e.generated_content,platform_target:e.platform_target,target_platforms:e.target_platforms||[],summary:e.summary,media_urls:e.media_urls,created_at:e.created_at,approved_at:e.approved_at,distributed_at:e.distributed_at,distribution_results:Array.isArray(e.distribution_results)?e.distribution_results:[],episode_title:(e.episode_workflows?.metadata)?.title||`Episode ${e.episode_workflows?.episode_id}`}));i(a)}catch(e){F({title:"Error loading content",description:"Failed to load content assets",variant:"destructive"})}};(0,he.useEffect)(()=>{$(),K()},[]);const Q=async(e,s)=>{try{const{error:a}=await q.from("approval_queue").update({status:s,reviewed_by:(await q.auth.getUser()).data.user?.id,reviewer_notes:f,approved_at:"approved"===s?(new Date).toISOString():null}).eq("id",e);if(a)throw a;if("approved"===s&&l){const{error:e}=await q.from("episode_workflows").update({approval_status:"approved",current_stage:"approved"}).eq("id",l.episode_workflow_id);if(e)throw e}F({title:`Content ${s}`,description:`Successfully ${s} the content`}),N(!1),u(null),g(""),$()}catch(a){F({title:"Approval failed",description:"Failed to process approval decision",variant:"destructive"})}},Z=async(e,s)=>{try{const{error:a}=await q.from("content_assets").update({approval_status:s,approved_at:"approved"===s?(new Date).toISOString():null,approved_by:(await q.auth.getUser()).data.user?.id}).eq("id",e);if(a)throw a;F({title:`Content ${s}`,description:"approved"===s?"Content approved and queued for distribution":"Content rejected"}),N(!1),j(null),K()}catch(a){F({title:"Approval failed",description:"Failed to process approval decision",variant:"destructive"})}},ee=e=>{k(s=>s.includes(e)?s.filter(s=>s!==e):[...s,e])},se=e=>{switch(e){case"approved":case"distributed":return"default";case"rejected":case"failed":return"destructive";case"pending":case"distributing":return"secondary";default:return"outline"}},ae=t.filter(e=>"pending"===e.approval_status),te=t.filter(e=>"approved"===e.approval_status&&(!e.distribution_status||"pending"===e.distribution_status||"queued"===e.distribution_status)),ie=t.filter(e=>"distributed"===e.distribution_status||"distributing"===e.distribution_status),re=e.filter(e=>"pending"===e.status),me=e.filter(e=>"pending"!==e.status);return(0,xe.jsxs)("div",{className:"space-y-6",children:[(0,xe.jsxs)("div",{className:"flex items-center justify-between",children:[(0,xe.jsxs)("div",{children:[(0,xe.jsx)("h2",{className:"text-3xl font-bold tracking-tight",children:"Approval Queue"}),(0,xe.jsx)("p",{className:"text-muted-foreground",children:"Review content and manage distribution to social platforms"})]}),(0,xe.jsx)("div",{className:"flex gap-2",children:(0,xe.jsxs)(L,{variant:"outline",size:"sm",onClick:()=>{$(),K()},children:[(0,xe.jsx)(m,{className:"h-4 w-4 mr-2"}),"Refresh"]})})]}),(0,xe.jsxs)(oe,{value:P,onValueChange:T,children:[(0,xe.jsxs)(ce,{children:[(0,xe.jsxs)(de,{value:"content",className:"gap-2",children:[(0,xe.jsx)(o,{className:"h-4 w-4"}),"Content Assets",ae.length>0&&(0,xe.jsx)(W,{variant:"secondary",className:"ml-1",children:ae.length})]}),(0,xe.jsxs)(de,{value:"distribution",className:"gap-2",children:[(0,xe.jsx)(h,{className:"h-4 w-4"}),"Ready to Distribute",te.length>0&&(0,xe.jsx)(W,{variant:"default",className:"ml-1",children:te.length})]}),(0,xe.jsxs)(de,{value:"workflows",className:"gap-2",children:[(0,xe.jsx)(a,{className:"h-4 w-4"}),"Workflow Approvals",re.length>0&&(0,xe.jsx)(W,{variant:"secondary",className:"ml-1",children:re.length})]})]}),(0,xe.jsxs)(ne,{value:"content",className:"space-y-4",children:[(0,xe.jsx)("h3",{className:"text-xl font-semibold",children:"Pending Content Review"}),0===ae.length?(0,xe.jsx)(I,{children:(0,xe.jsx)(O,{className:"flex items-center justify-center py-8",children:(0,xe.jsxs)("div",{className:"text-center space-y-2",children:[(0,xe.jsx)(r,{className:"h-12 w-12 text-muted-foreground mx-auto"}),(0,xe.jsx)("p",{className:"text-muted-foreground",children:"No pending content to review"})]})})}):(0,xe.jsx)("div",{className:"grid gap-4",children:ae.map(e=>(0,xe.jsxs)(I,{children:[(0,xe.jsx)(E,{children:(0,xe.jsxs)("div",{className:"flex items-start justify-between",children:[(0,xe.jsxs)("div",{className:"space-y-1",children:[(0,xe.jsx)(z,{className:"text-lg",children:e.episode_title}),(0,xe.jsxs)(R,{className:"flex items-center gap-2",children:[(0,xe.jsx)(W,{variant:"outline",children:e.content_type}),(0,xe.jsx)(W,{variant:se(e.approval_status),children:e.approval_status}),(0,xe.jsxs)("span",{className:"text-sm",children:["Created ",J(new Date(e.created_at),"MMM d, yyyy")]})]})]}),(0,xe.jsxs)(Y,{open:v&&p?.id===e.id,onOpenChange:e=>{N(e),e||j(null)},children:[(0,xe.jsx)(U,{asChild:!0,children:(0,xe.jsxs)(L,{variant:"outline",size:"sm",onClick:()=>j(e),className:"gap-2",children:[(0,xe.jsx)(M,{className:"h-4 w-4"}),"Review"]})}),(0,xe.jsxs)(G,{className:"max-w-4xl max-h-[80vh] overflow-y-auto",children:[(0,xe.jsxs)(H,{children:[(0,xe.jsxs)(B,{children:["Review Content - ",e.episode_title]}),(0,xe.jsx)(V,{children:"Review the generated content and decide whether to approve for distribution"})]}),(0,xe.jsxs)("div",{className:"space-y-6",children:[(0,xe.jsxs)("div",{className:"space-y-4",children:[(0,xe.jsx)("h4",{className:"font-semibold",children:"Generated Content"}),(0,xe.jsxs)("div",{className:"grid gap-4",children:[e.summary&&(0,xe.jsxs)("div",{className:"space-y-2",children:[(0,xe.jsx)("label",{className:"text-sm font-medium",children:"Summary"}),(0,xe.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,xe.jsx)("p",{className:"text-sm",children:e.summary})})]}),e.generated_content&&Object.entries(e.generated_content).map(([e,s])=>(0,xe.jsxs)("div",{className:"space-y-2",children:[(0,xe.jsx)("label",{className:"text-sm font-medium capitalize",children:e.replace(/_/g," ")}),(0,xe.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,xe.jsx)("pre",{className:"whitespace-pre-wrap text-sm",children:"object"==typeof s?JSON.stringify(s,null,2):String(s)})})]},e))]})]}),e.media_urls&&Array.isArray(e.media_urls)&&e.media_urls.length>0&&(0,xe.jsxs)("div",{className:"space-y-2",children:[(0,xe.jsxs)("h4",{className:"font-semibold flex items-center gap-2",children:[(0,xe.jsx)(x,{className:"h-4 w-4"}),"Media Attachments"]}),(0,xe.jsx)("div",{className:"grid grid-cols-3 gap-2",children:e.media_urls.map((e,s)=>(0,xe.jsx)("img",{src:e,alt:`Media ${s+1}`,className:"rounded-lg object-cover aspect-square"},s))})]}),(0,xe.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,xe.jsx)(L,{variant:"outline",onClick:()=>N(!1),children:"Cancel"}),(0,xe.jsxs)(L,{variant:"destructive",onClick:()=>Z(e.id,"rejected"),className:"gap-2",children:[(0,xe.jsx)(d,{className:"h-4 w-4"}),"Reject"]}),(0,xe.jsxs)(L,{onClick:()=>Z(e.id,"approved"),className:"gap-2",children:[(0,xe.jsx)(r,{className:"h-4 w-4"}),"Approve"]})]})]})]})]})]})}),(0,xe.jsx)(O,{children:(0,xe.jsx)("p",{className:"text-sm text-muted-foreground line-clamp-2",children:e.summary||e.generated_content?.post_content||"No preview available"})})]},e.id))})]}),(0,xe.jsxs)(ne,{value:"distribution",className:"space-y-4",children:[(0,xe.jsx)("h3",{className:"text-xl font-semibold",children:"Ready for Distribution"}),0===te.length?(0,xe.jsx)(I,{children:(0,xe.jsx)(O,{className:"flex items-center justify-center py-8",children:(0,xe.jsxs)("div",{className:"text-center space-y-2",children:[(0,xe.jsx)(c,{className:"h-12 w-12 text-muted-foreground mx-auto"}),(0,xe.jsx)("p",{className:"text-muted-foreground",children:"No content ready for distribution"}),(0,xe.jsx)("p",{className:"text-sm text-muted-foreground",children:"Approve content to see it here"})]})})}):(0,xe.jsx)("div",{className:"grid gap-4",children:te.map(e=>(0,xe.jsxs)(I,{className:"border-primary/30",children:[(0,xe.jsx)(E,{children:(0,xe.jsxs)("div",{className:"flex items-start justify-between",children:[(0,xe.jsxs)("div",{className:"space-y-1",children:[(0,xe.jsx)(z,{className:"text-lg",children:e.episode_title}),(0,xe.jsxs)(R,{className:"flex items-center gap-2",children:[(0,xe.jsx)(W,{variant:"default",children:"Approved"}),(0,xe.jsx)(W,{variant:"outline",children:e.content_type}),e.approved_at&&(0,xe.jsxs)("span",{className:"text-sm",children:["Approved ",J(new Date(e.approved_at),"MMM d, yyyy")]})]})]}),(0,xe.jsxs)(Y,{open:y&&p?.id===e.id,onOpenChange:e=>{_(e),e||j(null)},children:[(0,xe.jsx)(U,{asChild:!0,children:(0,xe.jsxs)(L,{size:"sm",onClick:()=>j(e),className:"gap-2",children:[(0,xe.jsx)(c,{className:"h-4 w-4"}),"Distribute Now"]})}),(0,xe.jsxs)(G,{children:[(0,xe.jsxs)(H,{children:[(0,xe.jsx)(B,{children:"Distribute Content"}),(0,xe.jsx)(V,{children:"Select platforms to distribute this content to GHL Social Planner"})]}),(0,xe.jsxs)("div",{className:"space-y-4",children:[(0,xe.jsxs)("div",{className:"space-y-2",children:[(0,xe.jsx)("label",{className:"text-sm font-medium",children:"Target Platforms"}),(0,xe.jsx)("div",{className:"grid grid-cols-2 gap-2",children:je.map(e=>(0,xe.jsxs)("div",{className:"flex items-center space-x-2 p-2 rounded-lg border cursor-pointer hover:bg-muted",onClick:()=>ee(e.id),children:[(0,xe.jsx)(le,{checked:w.includes(e.id),onCheckedChange:()=>ee(e.id)}),(0,xe.jsx)("span",{children:e.icon}),(0,xe.jsx)("span",{className:"text-sm",children:e.label})]},e.id))})]}),(0,xe.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,xe.jsx)(L,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),(0,xe.jsxs)(L,{onClick:()=>(async e=>{D(!0);try{const{data:s,error:a}=await q.functions.invoke("ghl-distribution",{body:{action:"distribute_approved_content",contentAssetId:e,targetPlatforms:w}});if(a)throw a;s.success?F({title:"Distribution started",description:`Distributed to ${s.summary.success} platform(s)`}):F({title:"Distribution issues",description:s.results?.map(e=>
1e.error).filter(Boolean).join(", ")||"Some platforms failed",variant:"destructive"}),_(!1),j(null),K()}catch(s){F({title:"Distribution failed",description:s instanceof Error?s.message:"Failed to distribute content",variant:"destructive"})}finally{D(!1)}})(e.id),disabled:C||0===w.length,className:"gap-2",children:[C?(0,xe.jsx)(S,{className:"h-4 w-4 animate-spin"}):(0,xe.jsx)(c,{className:"h-4 w-4"}),"Distribute to ",w.length," Platform(s)"]})]})]})]})]})]})}),(0,xe.jsx)(O,{children:(0,xe.jsx)("p",{className:"text-sm text-muted-foreground line-clamp-2",children:e.summary||e.generated_content?.post_content||"No preview available"})})]},e.id))}),ie.length>0&&(0,xe.jsxs)("div",{className:"space-y-4 mt-8",children:[(0,xe.jsx)("h3",{className:"text-xl font-semibold",children:"Recently Distributed"}),(0,xe.jsx)("div",{className:"grid gap-3",children:ie.slice(0,5).map(e=>(0,xe.jsx)(I,{children:(0,xe.jsx)(O,{className:"py-3",children:(0,xe.jsxs)("div",{className:"flex items-center justify-between",children:[(0,xe.jsxs)("div",{className:"space-y-1",children:[(0,xe.jsx)("p",{className:"font-medium",children:e.episode_title}),(0,xe.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,xe.jsx)(W,{variant:se(e.distribution_status),children:e.distribution_status}),e.distributed_at&&(0,xe.jsx)("span",{children:J(new Date(e.distributed_at),"MMM d, yyyy h:mm a")})]})]}),e.distribution_results&&e.distribution_results.length>0&&(0,xe.jsx)("div",{className:"flex gap-1",children:e.distribution_results.map((e,s)=>(0,xe.jsx)(W,{variant:"success"===e.status?"default":"destructive",className:"text-xs",children:e.platform},s))})]})})},e.id))})]})]}),(0,xe.jsxs)(ne,{value:"workflows",className:"space-y-4",children:[(0,xe.jsx)("h3",{className:"text-xl font-semibold",children:"Workflow Approvals"}),0===re.length?(0,xe.jsx)(I,{children:(0,xe.jsx)(O,{className:"flex items-center justify-center py-8",children:(0,xe.jsxs)("div",{className:"text-center space-y-2",children:[(0,xe.jsx)(r,{className:"h-12 w-12 text-muted-foreground mx-auto"}),(0,xe.jsx)("p",{className:"text-muted-foreground",children:"No pending workflow approvals"})]})})}):(0,xe.jsx)("div",{className:"grid gap-4",children:re.map(e=>{const s=(e=>{if(!e)return"normal";const s=new Date(e),a=new Date,t=(s.getTime()-a.getTime())/36e5;return t<0?"overdue":t<24?"urgent":t<72?"high":"normal"})(e.review_deadline);return(0,xe.jsxs)(I,{className:"overdue"===s?"border-destructive":"urgent"===s?"border-orange-500":"high"===s?"border-yellow-500":"",children:[(0,xe.jsx)(E,{children:(0,xe.jsxs)("div",{className:"flex items-start justify-between",children:[(0,xe.jsxs)("div",{className:"space-y-1",children:[(0,xe.jsx)(z,{className:"text-lg",children:e.episode_title}),(0,xe.jsxs)(R,{className:"flex items-center gap-2",children:[(0,xe.jsx)(W,{variant:"outline",children:e.approval_type}),"normal"!==s&&(0,xe.jsx)(W,{variant:"overdue"===s||"urgent"===s?"destructive":"secondary",children:s}),(0,xe.jsxs)("span",{className:"text-sm",children:["Created ",J(new Date(e.created_at),"MMM d, yyyy")]})]})]}),(0,xe.jsxs)(Y,{open:v&&l?.id===e.id,onOpenChange:e=>{N(e),e||(u(null),g(""))},children:[(0,xe.jsx)(U,{asChild:!0,children:(0,xe.jsxs)(L,{variant:"outline",size:"sm",onClick:()=>u(e),className:"gap-2",children:[(0,xe.jsx)(M,{className:"h-4 w-4"}),"Review"]})}),(0,xe.jsxs)(G,{className:"max-w-4xl max-h-[80vh] overflow-y-auto",children:[(0,xe.jsxs)(H,{children:[(0,xe.jsxs)(B,{children:["Review - ",e.episode_title]}),(0,xe.jsx)(V,{children:"Review and approve or reject this workflow item"})]}),(0,xe.jsxs)("div",{className:"space-y-6",children:[(0,xe.jsxs)("div",{className:"space-y-4",children:[(0,xe.jsx)("h4",{className:"font-semibold",children:"Pending Content"}),(0,xe.jsx)("div",{className:"grid gap-4",children:Object.entries(e.pending_content||{}).map(([e,s])=>(0,xe.jsxs)("div",{className:"space-y-2",children:[(0,xe.jsx)("label",{className:"text-sm font-medium capitalize",children:e.replace(/_/g," ")}),(0,xe.jsx)("div",{className:"p-3 bg-muted rounded-lg",children:(0,xe.jsx)("pre",{className:"whitespace-pre-wrap text-sm",children:"object"==typeof s?JSON.stringify(s,null,2):String(s)})})]},e))})]}),(0,xe.jsxs)("div",{className:"space-y-2",children:[(0,xe.jsx)("label",{className:"text-sm font-medium",children:"Review Notes"}),(0,xe.jsx)(X,{placeholder:"Add notes about your review decision...",value:f,onChange:e=>g(e.target.value),rows:3})]}),(0,xe.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,xe.jsx)(L,{variant:"outline",onClick:()=>N(!1),children:"Cancel"}),(0,xe.jsxs)(L,{variant:"destructive",onClick:()=>Q(e.id,"rejected"),className:"gap-2",children:[(0,xe.jsx)(d,{className:"h-4 w-4"}),"Reject"]}),(0,xe.jsxs)(L,{onClick:()=>Q(e.id,"approved"),className:"gap-2",children:[(0,xe.jsx)(r,{className:"h-4 w-4"}),"Approve"]})]})]})]})]})]})}),(0,xe.jsx)(O,{children:e.review_deadline&&(0,xe.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,xe.jsx)(n,{className:"h-4 w-4"}),"Deadline: ",J(new Date(e.review_deadline),"MMM d, yyyy h:mm a")]})})]},e.id)})}),me.length>
10&&(0,xe.jsxs)("div",{className:"space-y-4 mt-8",children:[(0,xe.jsx)("h3",{className:"text-xl font-semibold",children:"Recent Decisions"}),(0,xe.jsx)("div",{className:"grid gap-3",children:me.slice(0,5).map(e=>(0,xe.jsx)(I,{children:(0,xe.jsx)(O,{className:"py-3",children:(0,xe.jsx)("div",{className:"flex items-center justify-between",children:(0,xe.jsxs)("div",{className:"space-y-1",children:[(0,xe.jsx)("p",{className:"font-medium",children:e.episode_title}),(0,xe.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,xe.jsx)(W,{variant:se(e.status),children:e.status}),(0,xe.jsx)("span",{children:J(new Date(e.created_at),"MMM d, yyyy")}),e.reviewer_notes&&(0,xe.jsxs)("div",{className:"flex items-center gap-1",children:[(0,xe.jsx)(b,{className:"h-3 w-3"}),(0,xe.jsx)("span",{children:"Has notes"})]})]})]})})})},e.id))})]})]})]})]})}var ge=[{id:"facebook",name:"Facebook",available:!0},{id:"instagram",name:"Instagram",available:!0},{id:"linkedin",name:"LinkedIn",available:!0},{id:"google_business",name:"Google Business Profile",available:!0}
1,{id:"tiktok",name:"TikTok",available:!0},{id:"twitter",name:"Twitter/X",available:!1,note:"Manual only"},{id:"youtube",name:"YouTube",available:!1,note:"Scheduled in the CRM"},{id:"rumble",name:"Rumble",available:!1,note:"Manual only"}];function ve(){const[e,s]=(0,he.useState)([]),[t,d]=(0,he.useState)([]),[n,o]=(0,he.useState)("0"),{toast:m}=A(),{leverStates:u}=me(),h="active"===u.E1,x="active"===u.E2,j=[{id:"thursday",label:"Episode Day",day:"Thursday",icon:(0,xe.jsx)(y,{className:"h-4 w-4"}),enabled:!0,platforms:["transistor","spotify","apple_podcasts"],description:"Main episode auto-syncs via RSS from Transistor"},{id:"saturday",label:"Scalar Saturdays",day:"Saturday",icon:(0,xe.jsx)(D,{className:"h-4 w-4"}),enabled:!0,platforms:["rumble"],description:"Video version released on Rumble"},...h?[{id:"monday",label:"Todo es EnergÃa",day:"Monday",icon:(0,xe.jsx)(k,{className:"h-4 w-4"}),leverKey:"E1",enabled:!0,platforms:["transistor_es","spotify_es"],description:"Spanish episode release"}]:[],...x?[{id:"tuesday",label:"Tout est Ãnergie",day:"Tuesday",icon:(0,xe.jsx)(k,{className:"h-4 w-4"}),leverKey:"E2",enabled:!1,platforms:["transistor_fr","spotify_fr"],description:"French episode release (coming soon)"}]:[]],f=async()=>{try{const{data:e,error:a}=await q.from("publication_schedule_with_computed").select("\n *,\n episode_workflows!publication_schedule_episode_workflow_id_fkey (\n episode_id,\n metadata\n )\n ").in("publication_status",["scheduled","approved","publishing"]).order("scheduled_date",{ascending:!0});if(a)throw a;const t=e?.map(e=>({...e,episode_title:(e.episode_workflows?.metadata)?.title||`Episode ${e.episode_workflows?.episode_id}`,platform_targets:Array.isArray(e.platform_targets)?e.platform_targets.map(String):[]}))||[];s(t)}catch(e){m({title:"Error loading publications",description:"Failed to load scheduled publications",variant:"destructive"})}};(0,he.useEffect)(()=>{f()},[]);const g=e=>{switch(e){case"published":case"approved":return"default";case"publishing":return"secondary";default:return"outline"}};return(0,xe.jsxs)("div",{className:"space-y-6",children:[(0,xe.jsx)("div",{className:"flex items-center justify-between",children:(0,xe.jsxs)("div",{children:[(0,xe.jsx)("h2",{className:"text-3xl font-bold tracking-tight",children:"Publication Scheduler"}),(0,xe.jsx)("p",{className:"text-muted-foreground",children:"Configure weekly content cascade and manage cross-platform distribution"})]})}),(0,xe.jsxs)(I,{children:[(0,xe.jsxs)(E,{children:[(0,xe.jsxs)(z,{className:"flex items-center gap-2",children:[(0,xe.jsx)(i,{className:"h-5 w-5"}),"Weekly Cascade Schedule"]}),(0,xe.jsx)(R,{children:"Content flows automatically from Thursday episode release through the week"})]}),(0,xe.jsxs)(O,{children:[(0,xe.jsx)("div",{className:"space-y-4",children:j.map(e=>(0,xe.jsxs)("div",{className:"flex items-center justify-between p-4 rounded-lg border "+(e.enabled?"bg-primary/5 border-primary/20":"bg-muted/30 border-muted"),children:[(0,xe.jsxs)("div",{className:"flex items-center gap-4",children:[(0,xe.jsx)("div",{className:"p-2 rounded-lg "+(e.enabled?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"),children:e.icon}),(0,xe.jsxs)("div",{children:[(0,xe.jsxs)("div",{className:"flex items-center gap-2",children:[(0,xe.jsx)("span",{className:"font-semibold",children:e.day}),(0,xe.jsx)(W,{variant:e.enabled?"default":"secondary",className:"text-xs",children:e.label}),!e.enabled&&e.leverKey&&(0,xe.jsxs)(W,{variant:"outline",className:"text-xs gap-1",children:[(0,xe.jsx)(l,{className:"h-3 w-3"}),"Coming Soon"]})]}),(0,xe.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description})]})]}),(0,xe.jsx)("div",{className:"flex items-center gap-2",children:e.enabled?(0,xe.jsx)(r,{className:"h-5 w-5 text-green-500"}):(0,xe.jsx)("div",{className:"h-5 w-5 rounded-full border-2 border-muted-foreground/30"})})]},e.id))}),(0,xe.jsx)("div",{className:"mt-6 p-4 rounded-lg bg-muted/30 border border-dashed",children:(0,xe.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(0,xe.jsx)("strong",{children:"Note:"})," Thursday episodes are uploaded directly to Transistor and auto-sync via RSS. This scheduler manages the downstream cascade of social posts, video releases, and localized versions."]})})]})]}),(0,xe.jsxs)(I,{children:[(0,xe.jsxs)(E,{children:[(0,xe.jsxs)(z,{className:"flex items-center gap-2",children:[(0,xe.jsx)(P,{className:"h-5 w-5"}),"Default Distribution Platforms"]}),(0,xe.jsx)(R,{children:"Configure default platforms for social cascade posts via GHL"})]}),(0,xe.jsx)(O,{children:(0,xe.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,xe.jsxs)("div",{className:"space-y-2",children:[(0,xe.jsx)("label",{className:"text-sm font-medium",children:"Platforms"}),(0,xe.jsx)("div",{className:"space-y-2",children:ge.filter(e=>e.available).map(e=>(0,xe.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,xe.jsx)(le,{id:e.id,checked:t.includes(e.id),onCheckedChange:s=>{d(s?[...t,e.id]:t.filter(s=>s!==e.id))}}),(0,xe.jsx)("label",{htmlFor:e.id,className:"text-sm",children:e.name})]},e.id))})]}),(0,xe.jsxs)("div",{className:"space-y-2",children:[(0,xe.jsx)("label",{className:"text-sm font-medium",children:"Time Adjustment"}),(0,xe.jsxs)(te,{value:n,onValueChange:o,children:[(0,xe.jsx)(ee,{children:(0,xe.jsx)(Z,{})}),(0,xe.jsxs)(se,{children:[(0,xe.jsx)(ae,{value:"-4",children:"4 hours earlier"}),(0,xe.jsx)(ae,{value:"-2",children:"2 hours earlier"}),(0,xe.jsx)(ae,{value:"-1",children:"1 hour earlier"}),(0,xe.jsx)(ae,{value:"0",children:"No change"}),(0,xe.jsx)(ae,{value:"1",children:"1 hour later"}),(0,xe.jsx)(ae,{value:"2",children:"2 hours later"}),(0,xe.jsx)(ae,{value:"4",children:"4 hours later"})]})]})]}),(0,xe.jsx)("div",{className:"flex items-end",children:(0,xe.jsx)(L,{onClick:()=>{m({title:"Defaults saved",description:"Default distribution platforms updated"})},className:"w-full",children:"Save Defaults"})})]})})]}),(0,xe.jsxs)("div",{className:"space-y-4",children:[(0,xe.jsx)("h3",{className:"text-xl font-semibold",children:"Scheduled Publications"}),0===e.length?(0,xe.jsx)(I,{children:(0,xe.jsx)(O,{className:"flex items-center justify-center py-8",children:(0,xe.jsxs)("div",{className:"text-center space-y-2",children:[(0,xe.jsx)(p,{className:"h-12 w-12 text-muted-foreground mx-auto"}),(0,xe.jsx)("p",{className:"text-muted-foreground",children:"No scheduled publications"})]})})}):(0,xe.jsx)("div",{className:"grid gap-4",children:e.map(e=>(0,xe.jsxs)(I,{children:[(0,xe.jsx)(E,{children:(0,xe.jsxs)("div",{className:"flex items-start justify-between",children:[(0,xe.jsxs)("div",{className:"space-y-1",children:[(0,xe.jsx)(z,{className:"text-lg",children:e.episode_title}),(0,xe.jsxs)(R,{className:"flex items-center gap-2",children:[(0,xe.jsx)(W,{variant:g(e.publication_status),children:e.publication_status}),(0,xe.jsx)(a,{className:"h-4 w-4"}),J(new Date(`${e.scheduled_date}T${e.scheduled_time}`),"MMM d, yyyy h:mm a")]})]}),(0,xe.jsxs)("div",{className:"flex gap-2",children:["approved"===e.publication_status&&(0,xe.jsxs)(L,{onClick:()=>(async e=>{try{const{data:s,error:a}=await q.from("publication_schedule").select("\n *,\n episode_workflows!publication_schedule_episode_workflow_id_fkey (\n episode_id\n )\n ").eq("id",e).single();if(a||!s)throw new Error("Publication not found");const{error:t}=await q.from("publication_schedule").update({publication_status:"publishing",published_at:(new Date).toISOString()}).eq("id",e);if(t)throw t;const i=s.episode_workflows?.episode_id;if(i){const{data:e,error:s}=await q.functions.invoke("workflow-orchestrator",{body:{trigger:"manual",episode_id:i,force_reprocess:!1}})}m({title:"Publication triggered",description:"Content is being distributed to selected platforms"}),f()}catch(s){m({title:"Publication failed",description:"Failed to trigger publication",variant:"destructive"})}})(e.id),className:"gap-2",size:"sm",children:[(0,xe.jsx)(c,{className:"h-4 w-4"}),"Publish Now"]}),"scheduled"===e.publication_status&&(0,xe.jsx)(L,{variant:"outline",size:"sm",onClick:()=>{},children:"Reschedule"})]})]})}),(0,xe.jsx)(O,{children:(0,xe.jsxs)("div",{className:"space-y-4",children:[(0,xe.jsxs)("div",{className:"space-y-2",children:[(0,xe.jsx)("label",{className:"text-sm font-medium",children:"Target Platforms"}),(0,xe.jsx)("div",{className:"flex flex-wrap gap-2",children:ge.map(s=>(0,xe.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,xe.jsx)(le,{id:`${e.id}-${s.id}
1`,checked:e.platform_targets.includes(s.id),disabled:!s.available,onCheckedChange:a=>{const t=a?[...e.platform_targets,s.id]:e.platform_targets.filter(e=>e!==s.id);(async(e,s)=>{try{const{error:a}=await q.from("publication_schedule").update({platform_targets:s}).eq("id",e);if(a)throw a;m({title:"Platforms updated",description:"Publication platform targets updated successfully"}),f()}catch(a){m({title:"Update failed",description:"Failed to update platform targets",variant:"destructive"})}})(e.id,t)}}),(0,xe.jsxs)("label",{htmlFor:`${e.id}-${s.id}`,className:"text-sm "+(s.available?"":"text-muted-foreground"),children:[s.name,s.note&&` (${s.note})`]})]},s.id))})]}),e.published_at&&(0,xe.jsxs)("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[(0,xe.jsx)(r,{className:"h-4 w-4 text-green-500"}),"Published ",J(new Date(e.published_at),"MMM d, yyyy h:mm a")]})]})})]},e.id))})]})]})}var Ne={facebook:N,instagram:v,linkedin:f,google_business:M,tiktok:M},be={facebook:"bg-blue-100 text-blue-800 border-blue-200",instagram:"bg-pink-100 text-pink-800 border-pink-200",linkedin:"bg-blue-100 text-blue-800 border-blue-200",google_business:"bg-green-100 text-green-800 border-green-200",tiktok:"bg-purple-100 text-purple-800 border-purple-200"};function ye(){const[e,s]=(0,he.useState)([]),[t,i]=(0,he.useState)(null),[l,d]=(0,he.useState)(!1),[o,m]=(0,he.useState)(!1),[u,h]=(0,he.useState)(""),[x,p]=(0,he.useState)(""),[j,f]=(0,he.useState)([]),{toast:g}=A(),v=async()=>{try{const{data:e,error:a}=await q.from("content_assets").select("\n id,\n episode_workflow_id,\n publication_schedule_id,\n platform_target,\n language,\n approval_status,\n distribution_status,\n distributed_at,\n distribution_results,\n generated_content,\n summary,\n created_at,\n episode_workflows!content_assets_episode_workflow_id_fkey (\n episode_id,\n metadata\n )\n ").in("approval_status",["approved","pending"]).is("deleted_at",null).order("created_at",{ascending:!1}).limit(50);if(a)throw a;const t=(e||[]).map(e=>({id:e.id,episode_workflow_id:e.episode_workflow_id,publication_schedule_id:e.publication_schedule_id||"",platform:e.platform_target||"unknown",approval_status:e.approval_status,status:"distributed"===e.distribution_status?"published":"distributing"===e.distribution_status?"publishing":"failed"===e.distribution_status?"failed":"scheduled",ghl_post_id:e.distribution_results?.postId,scheduled_at:e.created_at,content_preview:e.summary||e.generated_content?.content?.substring(0,100)||"AI-generated social media content...",episode_title:(e.episode_workflows?.metadata)?.title||`Episode ${e.episode_workflows?.episode_id}`}));s(t)}catch(e){g({title:"Error loading posts",description:"Failed to load distribution posts",variant:"destructive"})}};(0,he.useEffect)(()=>{v()},[]);const N=async s=>{try{const a=e.find(e=>e.id===s),t=a?.platform?[a.platform]:["facebook","instagram","linkedin"],{data:i,error:l}=await q.functions.invoke("ghl-distribution",{body:{action:"distribute_approved_content",contentAssetId:s,targetPlatforms:t,distributionState:"publish_now"}});if(l)throw l;g({title:"Distribution triggered",description:`Content is being distributed to ${t.join(", ")}`}),v()}catch(a){g({title:"Distribution failed",description:"Failed to trigger distribution",variant:"destructive"})}},b=e=>{switch(e){case"published":return"default";case"publishing":return"secondary";case"failed":return"destructive";default:return"outline"}},y=e.filter(e=>"scheduled"===e.status),_=e.filter(e=>"publishing"===e.status),w=e.filter(e=>"published"===e.status),k=e.filter(e=>"failed"===e.status);return(0,xe.jsxs)("div",{className:"space-y-6",children:[(0,xe.jsxs)("div",{className:"flex items-center justify-between",children:[(0,xe.jsxs)("div",{children:[(0,xe.jsx)("h2",{className:"text-3xl font-bold tracking-tight",children:"Cross-Channel Distribution"}),(0,xe.jsx)("p",{className:"text-muted-foreground",children:"Manage automated social media distribution via GHL Social Planner"})]}),(0,xe.jsxs)("div",{className:"flex gap-2",children:[(0,xe.jsxs)(W,{variant:"secondary",className:"gap-1",children:[(0,xe.jsx)(a,{className:"h-3 w-3"}),y.length," Scheduled"]}),(0,xe.jsxs)(W,{variant:"outline",className:"gap-1",children:[(0,xe.jsx)(c,{className:"h-3 w-3"}),_.length," Publishing"]}),(0,xe.jsxs)(W,{variant:"default",className:"gap-1",children:[(0,xe.jsx)(r,{className:"h-3 w-3"}),w.length," Published"]}),k.length>0&&(0,xe.jsxs)(W,{variant:"destructive",className:"gap-1",children:[(0,xe.jsx)(n,{className:"h-3 w-3"}),k.length," Failed"]})]})]}),(0,xe.jsxs)(I,{children:[(0,xe.jsxs)(E,{children:[(0,xe.jsxs)(z,{className:"flex items-center gap-2",children:[(0,xe.jsx)(C,{className:"h-5 w-5"}),"Bulk Distribution Actions"]}),(0,xe.jsx)(R,{children:"Apply actions to multiple posts across platforms"})]}),(0,xe.jsx)(O,{children:(0,xe.jsxs)("div",{className:"flex gap-4 items-end",children:[(0,xe.jsxs)("div",{className:"flex-1",children:[(0,xe.jsx)(ie,{htmlFor:"bulk-action",children:"Action"}),(0,xe.jsxs)(te,{value:x,onValueChange:p,children:[(0,xe.jsx)(ee,{children:(0,xe.jsx)(Z,{placeholder:"Select bulk action"})}),(0,xe.jsxs)(se,{children:[(0,xe.jsx)(ae,{value:"publish",children:"Publish Now"}),(0,xe.jsx)(ae,{value:"reschedule",children:"Reschedule"}),(0,xe.jsx)(ae,{value:"cancel",children:"Cancel"})]})]})]}),(0,xe.jsxs)(L,{onClick:async()=>
1{if(x&&0!==j.length)try{const e=j.map(e=>"publish"===x?N(e):Promise.resolve());await Promise.all(e),g({title:"Bulk action completed",description:`${x} applied to ${j.length} posts`}),f([]),p(""),v()}catch(e){g({title:"Bulk action failed",description:"Failed to complete bulk action",variant:"destructive"})}},disabled:!x||0===j.length,className:"gap-2",children:[(0,xe.jsx)(c,{className:"h-4 w-4"}),"Apply to ",j.length," posts"]})]})})]}),(0,xe.jsxs)("div",{className:"grid gap-6",children:[y.length>0&&(0,xe.jsxs)("div",{className:"space-y-4",children:[(0,xe.jsx)("h3",{className:"text-xl font-semibold",children:"Scheduled for Distribution"}),(0,xe.jsx)("div",{className:"grid gap-4",children:y.map(e=>{const s=Ne[e.platform]||M,a=be[e.platform]||"bg-gray-100 text-gray-800";return(0,xe.jsx)(I,{className:"hover:shadow-md transition-shadow",children:(0,xe.jsx)(E,{children:(0,xe.jsxs)("div",{className:"flex items-start justify-between",children:[(0,xe.jsxs)("div",{className:"space-y-2",children:[(0,xe.jsxs)("div",{className:"flex items-center gap-2",children:[(0,xe.jsx)("input",{type:"checkbox",checked:j.includes(e.id),onChange:s=>{s.target.checked?f([...j,e.id]):f(j.filter(s=>s!==e.id))},className:"rounded border-gray-300"}),(0,xe.jsx)(z,{className:"text-lg",children:e.episode_title})]}),(0,xe.jsxs)("div",{className:"flex items-center gap-2",children:[(0,xe.jsxs)(W,{variant:"outline",className:a,children:[(0,xe.jsx)(s,{className:"h-3 w-3 mr-1"}),e.platform.replace("_"," ")]}),(0,xe.jsx)(W,{variant:b(e.status),children:e.status}),(0,xe.jsx)("span",{className:"text-sm text-muted-foreground",children:J(new Date(e.scheduled_at),"MMM d, yyyy h:mm a")})]})]}),(0,xe.jsxs)("div",{className:"flex gap-2",children:[(0,xe.jsxs)(Y,{open:l&&t?.id===e.id,onOpenChange:e=>{d(e),e||i(null)},children:[(0,xe.jsx)(U,{asChild:!0,children:(0,xe.jsxs)(L,{variant:"outline",size:"sm",onClick:()=>i(e),className:"gap-2",children:[(0,xe.jsx)(M,{className:"h-4 w-4"}),"Preview"]})}),(0,xe.jsxs)(G,{children:[(0,xe.jsxs)(H,{children:[(0,xe.jsxs)(B,{children:["Content Preview - ",e.platform]}),(0,xe.jsxs)(V,{children:["Preview how this content will appear on ",e.platform]})]}),(0,xe.jsxs)("div",{className:"space-y-4",children:[(0,xe.jsx)("div",{className:"p-4 border rounded-lg bg-muted",children:(0,xe.jsx)("p",{className:"text-sm",children:e.content_preview})}),(0,xe.jsxs)("div",{className:"text-xs text-muted-foreground",children:["Scheduled for: ",J(new Date(e.scheduled_at),"MMMM d, yyyy at h:mm a")]})]})]})]}),(0,xe.jsxs)(L,{onClick:()=>N(e.id),size:"sm",className:"gap-2",disabled:"approved"!==e.approval_status,title:"approved"!==e.approval_status?"Awaiting approval":"Distribute now",children:[(0,xe.jsx)(c,{className:"h-4 w-4"}),"approved"===e.approval_status?"Publish Now":"Pending Approval"]})]})]})})},e.id)})})]}),_.length>0&&(0,xe.jsxs)("div",{className:"space-y-4",children:[(0,xe.jsx)("h3",{className:"text-xl font-semibold",children:"Currently Publishing"}),(0,xe.jsx)("div",{className:"grid gap-4",children:_.map(e=>{const s=Ne[e.platform]||M,a=be[e.platform]||"bg-gray-100 text-gray-800";return(0,xe.jsx)(I,{className:"border-blue-200 bg-blue-50",children:(0,xe.jsx)(E,{children:(0,xe.jsxs)("div",{className:"flex items-center justify-between",children:[(0,xe.jsxs)("div",{className:"flex items-center gap-2",children:[(0,xe.jsx)("div",{className:"animate-spin h-4 w-4 border-2 border-blue-500 border-t-transparent rounded-full"}),(0,xe.jsx)(z,{className:"text-lg",children:e.episode_title}),(0,xe.jsxs)(W,{variant:"outline",className:a,children:[(0,xe.jsx)(s,{className:"h-3 w-3 mr-1"}),e.platform.replace("_"," ")]})]}),(0,xe.jsx)(W,{variant:"secondary",children:"Publishing..."})]})})},e.id)})})]}),k.length>0&&(0,xe.jsxs)("div",{className:"space-y-4",children:[(0,xe.jsx)("h3",{className:"text-xl font-semibold text-destructive",children:"Failed Distributions"}),(0,xe.jsx)("div",{className:"grid gap-4",children:k.map(e=>{const s=Ne[e.platform]||M;return(0,xe.jsx)(I,{className:"border-destructive bg-red-50",children:(0,xe.jsx)(E,{children:(0,xe.jsxs)("div",{className:"flex items-center justify-between",children:[(0,xe.jsxs)("div",{className:"space-y-2",children:[(0,xe.jsxs)("div",{className:"flex items-center gap-2",children:[(0,xe.jsx)(n,{className:"h-4 w-4 text-destructive"}),(0,xe.jsx)(z,{className:"text-lg",children:e.episode_title}),(0,xe.jsxs)(W,{variant:"outline",className:"border-red-200 text-red-800",children:[(0,xe.jsx)(s,{className:"h-3 w-3 mr-1"}),e.platform.replace("_"," ")]})]}),e.error_message&&(0,xe.jsx)("p",{className:"text-sm text-destructive",children:e.error_message})]}),(0,xe.jsxs)(L,{onClick:()=>N(e.id),size:"sm",variant:"outline",className:"gap-2",children:[(0,xe.jsx)(c,{className:"h-4 w-4"}),"Retry"]})]})})},e.id)})})]}),w.length>0&&(0,xe.jsxs)("div",{className:"space-y-4",children:[(0,xe.jsx)("h3",{className:"text-xl font-semibold",children:"Recently Published"}),(0,xe.jsx)("div",{className:"grid gap-3",children:w.slice(0,5).map(e=>{const s=Ne[e.platform]||M,a=be[e.platform]||"bg-gray-100 text-gray-800";return(0,xe.jsx)(I,{children:(0,xe.jsx)(O,{className:"py-3",children:(0,xe.jsxs)("div",{className:"flex items-center justify-between",children:[(0,xe.jsxs)("div",{className:"flex items-center gap-2",children:[(0,xe.jsx)(r,{className:"h-4 w-4 text-green-500"}),(0,xe.jsx)("span",{className:"font-medium",children:e.episode_title}),(0,xe.jsxs)(W,{variant:"outline",className:a,children:[(0,xe.jsx)(s,{className:"h-3 w-3 mr-1"}),e.platform.replace("_"," ")]})]}),(0,xe.jsx)("span",{className:"text-sm text-muted-foreground",children:J(new Date(e.scheduled_at),"MMM d, h:mm a")})]})})},e.id)})})]})]})]})}var _e={facebook:N,instagram:v,linkedin:f,google_business:t,tiktok:u};function we(){const[e,t]=(0,he.useState)([]),[l,d]=(0,he.useState)([]),[c,o]=(0,he.useState)({total_scheduled:0,published_today:0,failed_today:0,success_rate:0,platforms_active:0}),[h,x]=(0,he.useState)(!1),{toast:p}=A(),f=async()=>{try{const{data:e,error:s}=await q.functions.invoke("manage-scheduled-episode",{body:{action:"get_scheduled_episodes"}});if(s)throw s;
1e?.episodes&&d(e.episodes)}catch(e){}},g=async()=>{x(!0);try{const{data:e,error:s}=await q.functions.invoke("ghl-distribution",{body:{action:"check_platform_health"}});if(s)return t([]),void o({total_scheduled:0,published_today:0,failed_today:0,success_rate:0,platforms_active:0});const a=(e?.platforms||[]).map(s=>({platform:(s.platform||s.type||"unknown").toLowerCase(),connected:!1!==s.isConnected,last_sync:e.health_check_time||(new Date).toISOString(),posts_today:s.postsToday||0,success_rate:s.successRate||(!1!==s.isConnected?100:0),error_count:s.errorCount||0,oauth_status:!1!==s.isConnected?"valid":"invalid"}));t(a);const i=a.filter(e=>e.connected),l=i.reduce((e,s)=>e+s.posts_today,0),r=i.reduce((e,s)=>e+s.error_count,0),d=i.length>0?i.reduce((e,s)=>e+s.success_rate,0)/i.length:0;o({total_scheduled:0,published_today:l,failed_today:r,success_rate:d,platforms_active:i.length}),a.length>0&&p({title:"Platforms loaded",description:`Found ${i.length} connected platform(s) from GHL`})}catch(e){p({title:"Error loading status",description:"Failed to load distribution status",variant:"destructive"})}finally{x(!1)}await f()};return(0,he.useEffect)(()=>{g();const e=setInterval(g,3e4);return()=>clearInterval(e)},[]),(0,xe.jsxs)("div",{className:"space-y-6",children:[(0,xe.jsxs)("div",{className:"flex items-center justify-between",children:[(0,xe.jsxs)("div",{children:[(0,xe.jsx)("h2",{className:"text-3xl font-bold tracking-tight",children:"Distribution Monitor"}),(0,xe.jsx)("p",{className:"text-muted-foreground",children:"Real-time monitoring of cross-platform distribution health"})]}),(0,xe.jsxs)(L,{onClick:g,disabled:h,variant:"outline",className:"gap-2",children:[(0,xe.jsx)(m,{className:"h-4 w-4 "+(h?"animate-spin":"")}),"Refresh Status"]})]}),(0,xe.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-4",children:[(0,xe.jsxs)(I,{children:[(0,xe.jsxs)(E,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,xe.jsx)(z,{className:"text-sm font-medium",children:"Scheduled Today"}),(0,xe.jsx)(a,{className:"h-4 w-4 text-muted-foreground"})]}),(0,xe.jsxs)(O,{children:[(0,xe.jsx)("div",{className:"text-2xl font-bold",children:c.total_scheduled}),(0,xe.jsx)("p",{className:"text-xs text-muted-foreground",children:"Cross-platform posts"})]})]}),(0,xe.jsxs)(I,{children:[(0,xe.jsxs)(E,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,xe.jsx)(z,{className:"text-sm font-medium",children:"Published Today"}),(0,xe.jsx)(r,{className:"h-4 w-4 text-green-600"})]}),(0,xe.jsxs)(O,{children:[(0,xe.jsx)("div",{className:"text-2xl font-bold text-green-600",children:c.published_today}),(0,xe.jsx)("p",{className:"text-xs text-muted-foreground",children:"Successfully distributed"})]})]}),(0,xe.jsxs)(I,{children:[(0,xe.jsxs)(E,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,xe.jsx)(z,{className:"text-sm font-medium",children:"Failed Today"}),(0,xe.jsx)(n,{className:"h-4 w-4 text-red-600"})]}),(0,xe.jsxs)(O,{children:[(0,xe.jsx)("div",{className:"text-2xl font-bold text-red-600",children:c.failed_today}),(0,xe.jsx)("p",{className:"text-xs text-muted-foreground",children:"Distribution failures"})]})]}),(0,xe.jsxs)(I,{children:[(0,xe.jsxs)(E,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,xe.jsx)(z,{className:"text-sm font-medium",children:"Success Rate"}),(0,xe.jsx)(u,{className:"h-4 w-4 text-muted-foreground"})]}),(0,xe.jsxs)(O,{children:[(0,xe.jsxs)("div",{className:"text-2xl font-bold",children:[c.success_rate.toFixed(1),"%"]}),(0,xe.jsx)(re,{value:c.success_rate,className:"mt-2"})]})]}),(0,xe.jsxs)(I,{children:[(0,xe.jsxs)(E,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[(0,xe.jsx)(z,{className:"text-sm font-medium",children:"Active Platforms"}),(0,xe.jsx)(s,{className:"h-4 w-4 text-muted-foreground"})]}),(0,xe.jsxs)(O,{children:[(0,xe.jsx)("div",{className:"text-2xl font-bold",children:c.platforms_active}),(0,xe.jsx)("p",{className:"text-xs text-muted-foreground",children:"Connected platforms"})]})]})]}),(0,xe.jsxs)("div",{className:"space-y-4",children:[(0,xe.jsx)("h3",{className:"text-xl font-semibold",children:"Platform Connection Status"}),0===e.length?(0,xe.jsxs)(I,{className:"border-amber-200 bg-amber-50",children:[(0,xe.jsxs)(E,{children:[(0,xe.jsxs)(z,{className:"flex items-center gap-2",children:[(0,xe.jsx)(a,{className:"h-5 w-5 text-amber-600"}),"No Platforms Connected"]}),(0,xe.jsx)(R,{children:"Social media platform integrations need to be synced from Go
1HighLevel."})]}),(0,xe.jsxs)(O,{children:[(0,xe.jsxs)("div",{className:"text-sm text-amber-700",children:[(0,xe.jsxs)("p",{className:"mb-2",children:["⨠",(0,xe.jsx)("strong",{children:"Platforms ready for configuration:"})]}),(0,xe.jsxs)("ul",{className:"list-disc list-inside space-y-1 ml-4",children:[(0,xe.jsx)("li",{children:"Facebook Business"}),(0,xe.jsx)("li",{children:"Instagram Business"}),(0,xe.jsx)("li",{children:"LinkedIn Company Pages"}),(0,xe.jsx)("li",{children:"Google Business Profile"}),(0,xe.jsx)("li",{children:"TikTok Business"})]}),(0,xe.jsx)("p",{className:"mt-3 text-xs",children:'Click "Sync from GHL" to load connected social media accounts.'})]}),(0,xe.jsxs)(L,{onClick:async()=>{x(!0);try{const{data:e,error:s}=await q.functions.invoke("ghl-distribution",{body:{action:"sync_social_accounts"}});if(s)throw s;p({title:"Accounts synced",description:`Synced ${e?.synced_count||0} social accounts from GHL`}),await g()}catch(e){p({title:"Sync failed",description:"Failed to sync accounts from GHL",variant:"destructive"})}finally{x(!1)}},disabled:h,className:"mt-4 gap-2",children:[(0,xe.jsx)(m,{className:"h-4 w-4 "+(h?"animate-spin":"")}),"Sync from GHL"]})]})]}):(0,xe.jsx)("div",{className:"grid gap-4",children:e.map(e=>{const a=_e[e.platform]||s,t=(e=>e.connected?"expired"===e.oauth_status?"border-yellow-500 bg-yellow-50":e.success_rate<90?"border-orange-500 bg-orange-50":"border-green-500 bg-green-50":"border-red-500 bg-red-50")(e);return(0,xe.jsxs)(I,{className:t,children:[(0,xe.jsx)(E,{children:(0,xe.jsxs)("div",{className:"flex items-center justify-between",children:[(0,xe.jsxs)("div",{className:"flex items-center gap-3",children:[(0,xe.jsx)("div",{className:"p-2 rounded-lg bg-white/50",children:(0,xe.jsx)(a,{className:"h-5 w-5"})}),(0,xe.jsxs)("div",{children:[(0,xe.jsx)(z,{className:"capitalize",children:e.platform.replace("_"," ")}),(0,xe.jsx)(R,{children:e.connected?(0,xe.jsxs)("span",{className:"flex items-center gap-1",children:[(0,xe.jsx)(r,{className:"h-3 w-3 text-green-600"}),"Connected"]}):(0,xe.jsxs)("span",{className:"flex items-center gap-1",children:[(0,xe.jsx)(n,{className:"h-3 w-3 text-red-600"}),"Disconnected"]})})]})]}),(0,xe.jsxs)("div",{className:"flex items-center gap-2",children:[e.connected&&(0,xe.jsxs)("div",{className:"text-right",children:[(0,xe.jsxs)("div",{className:"text-sm font-medium",children:[e.posts_today," posts today"]}),(0,xe.jsxs)("div",{className:"text-xs text-muted-foreground",children:[e.success_rate,"% success rate"]})]}),(!e.connected||"valid"!==e.oauth_status)&&(0,xe.jsxs)(L,{onClick:()=>(async e=>{try{const{error:s}=await q.functions.invoke("ghl-distribution",{body:{action:"reconnect_platform",platform:e}});if(s)throw s;p({title:"Reconnection initiated",description:`Reconnecting to ${e}...`}),g()}catch(s){p({title:"Reconnection failed",description:`Failed to reconnect to ${e}`,variant:"destructive"})}})(e.platform),size:"sm",variant:"outline",className:"gap-2",children:[(0,xe.jsx)(F,{className:"h-4 w-4"}),"Reconnect"]})]})]})}),e.connected&&(0,xe.jsxs)(O,{children:[(0,xe.jsxs)("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[(0,xe.jsxs)("div",{children:[(0,xe.jsx)("div",{className:"font-medium",children:"Last Sync"}),(0,xe.jsx)("div",{className:"text-muted-foreground",children:e.last_sync?new Date(e.last_sync).toLocaleTimeString():"Never"})]}),(0,xe.jsxs)("div",{children:[(0,xe.jsx)("div",{className:"font-medium",children:"OAuth Status"}),(0,xe.jsx)(W,{variant:"valid"===e.oauth_status?"default":"expired"===e.oauth_status?"secondary":"destructive",children:e.oauth_status})]}),(0,xe.jsxs)("div",{children:[(0,xe.jsx)("div",{className:"font-medium",children:"Errors"}),(0,xe.jsxs)("div",{className:"text-muted-foreground",children:[e.error_count," today"]})]})]}),e.success_rate<100&&(0,xe.jsxs)("div",{className:"mt-4",children:[(0,xe.jsxs)("div",{className:"flex items-center justify-between text-sm mb-2",children:[(0,xe.jsx)("span",{children:"Success Rate"}),(0,xe.jsxs)("span",{children:[e.success_rate,"%"]})]}),(0,xe.jsx)(re,{value:e.success_rate})]})]})]},e.platform)})})]}),(0,xe.jsxs)("div",{className:"space-y-4",children:[(0,xe.jsx)("h3",{className:"text-xl font-semibold",children:"Scheduled Episodes"}),0===l.length?(0,xe.jsx)(I,{children:(0,xe.jsxs)(O,{className:"py-8 text-center",children:[(0,xe.jsx)(i,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),(0,xe.jsx)("p",{className:"text-muted-foreground",children:"No episodes currently sc
1heduled"})]})}):(0,xe.jsx)("div",{className:"grid gap-4",children:l.map(e=>(0,xe.jsxs)(I,{children:[(0,xe.jsx)(E,{children:(0,xe.jsxs)("div",{className:"flex items-center justify-between",children:[(0,xe.jsxs)("div",{children:[(0,xe.jsx)(z,{className:"text-lg",children:e.metadata?.title||`Episode ${e.episode_id}`}),(0,xe.jsx)(R,{children:(0,xe.jsxs)("div",{className:"flex items-center gap-4 mt-2",children:[(0,xe.jsx)(W,{variant:"transistor_scheduled"===e.current_stage?"default":"ready_for_scheduling"===e.current_stage?"secondary":"outline",children:e.current_stage.replace("_"," ")}),e.transistor_scheduled_at&&(0,xe.jsxs)("span",{className:"text-sm text-muted-foreground",children:["Scheduled: ",new Date(e.transistor_scheduled_at).toLocaleString()]})]})})]}),(0,xe.jsxs)("div",{className:"flex items-center gap-2",children:["transistor_scheduled"===e.current_stage&&(0,xe.jsxs)(xe.Fragment,{children:[(0,xe.jsxs)(L,{size:"sm",variant:"outline",onClick:()=>{const s=prompt("Enter new schedule date (YYYY-MM-DD HH:MM):");s&&(async(e,s,a)=>{try{const{error:t}=await q.functions.invoke("manage-scheduled-episode",{body:{action:"reschedule",workflowId:e,transistorId:s,newDate:a}});if(t)throw t;p({title:"Episode rescheduled",description:"Episode has been rescheduled successfully"}),f()}catch(t){p({title:"Reschedule failed",description:"Failed to reschedule episode",variant:"destructive"})}})(e.id,e.transistor_id,s)},className:"gap-2",children:[(0,xe.jsx)(i,{className:"h-4 w-4"}),"Reschedule"]}),(0,xe.jsxs)(L,{size:"sm",variant:"outline",onClick:()=>(async(e,s)=>{try{const{error:a}=await q.functions.invoke("manage-scheduled-episode",{body:{action:"publish_now",workflowId:e,transistorId:s}});if(a)throw a;p({title:"Episode published",description:"Episode has been published immediately"}),f()}catch(a){p({title:"Publish failed",description:"Failed to publish episode",variant:"destructive"})}})(e.id,e.transistor_id),className:"gap-2",children:[(0,xe.jsx)(j,{className:"h-4 w-4"}),"Publish Now"]}),(0,xe.jsxs)(L,{size:"sm",variant:"outline",onClick:()=>(async(e,s)=>{try{const{error:a}=await q.functions.invoke("manage-scheduled-episode",{body:{action:"revert_to_draft",workflowId:e,transistorId:s}});if(a)throw a;p({title:"Episode reverted",description:"Episode has been reverted to draft"}),f()}catch(a){p({title:"Revert failed",description:"Failed to revert episode to draft",variant:"destructive"})}})(e.id,e.transistor_id),className:"gap-2",children:[(0,xe.jsx)(_,{className:"h-4 w-4"}),"Revert to Draft"]})]}),"ready_for_scheduling"===e.current_stage&&(0,xe.jsx)(W,{variant:"secondary",children:"Ready for Scheduling"})]})]})}),(0,xe.jsx)(O,{children:(0,xe.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[(0,xe.jsxs)("div",{children:[(0,xe.jsx)("div",{className:"font-medium",children:"Episode ID"}),(0,xe.jsx)("div",{className:"text-muted-foreground",children:e.episode_id})]}),(0,xe.jsxs)("div",{children:[(0,xe.jsx)("div",{className:"font-medium",children:"Created"}),(0,xe.jsx)("div",{className:"text-muted-foreground",children:new Date(e.created_at).toLocaleDateString()})]}),(0,xe.jsxs)("div",{children:[(0,xe.jsx)("div",{className:"font-medium",children:"Transistor ID"}),(0,xe.jsx)("div",{className:"text-muted-foreground",children:e.transistor_id||"N/A"})]}),(0,xe.jsxs)("div",{children:[(0,xe.jsx)("div",{className:"font-medium",children:"Status"}),(0,xe.jsx)("div",{className:"text-muted-foreground capitalize",children:e.current_stage.replace("_"," ")})]})]})})]},e.id))})]}),(0,xe.jsxs)(I,{children:[(0,xe.jsxs)(E,{children:[(0,xe.jsx)(z,{children:"Quick Actions"}),(0,xe.jsx)(R,{children:"Common distribution management tasks"})]}),(0,xe.jsx)(O,{children:(0,xe.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,xe.jsxs)(L,{variant:"outline",className:"gap-2",onClick:()=>{p({title:"Opening bulk operations",description:"Navigate to bulk distribution management"})},children:[(0,xe.jsx)(s,{className:"h-4 w-4"}),"Bulk Operations"]}),(0,xe.jsxs)(L,{variant:"outline",className:"gap-2",onClick:()=>{p({title:"Checking limits",description:"Verifying platform posting limits"})},children:[(0,xe.jsx)(n,{className:"h-4 w-4"}),"Check Limits"]}),(0,xe.jsxs)(L,{variant:"outline",className:"gap-2",onClick:g,disabled:h,children:[(0,xe.jsx)(r,{className:"h-4 w-4 "+(h?"animate-spin":"")}),h?"Testing...":"Test All Connections"]})]})})]})]})}function ke(){const[e,a]=(0,he.useState)("calendar");return(0,xe.jsxs)("div",{className:"space-y-6",children:[(0,xe.jsx)("div",{className:"flex items-center justify-between",children:(0,xe.jsxs)("div",{children:[(0,xe.jsx)("h1",{className:"text-3xl font-bold tracking-tight",children:"Publication Management"}),(0,xe.jsx)("p",{className:"text-muted-foreground",children:"Manage Thursday publication schedule, approvals, and cross-platform distribution"})]})}),(0,xe.jsxs)(oe,{value:e,onValueChange:a,className:"space-y-6",children:[(0,xe.jsxs)(ce,{className:"grid w-full grid-cols-5",children:[(0,xe.jsxs)(de,{value:"calendar",className:"gap-2",children:[(0,xe.jsx)(p,{className:"h-4 w-4"}),"Calendar"]}),(0,xe.jsxs)(de,{value:"approvals",className:"gap-2",children:[(0,xe.jsx)(w,{className:"h-4 w-4"}),"Approvals"]}
1),(0,xe.jsxs)(de,{value:"scheduler",className:"gap-2",children:[(0,xe.jsx)(P,{className:"h-4 w-4"}),"Scheduler"]}),(0,xe.jsxs)(de,{value:"distribution",className:"gap-2",children:[(0,xe.jsx)(s,{className:"h-4 w-4"}),"Distribution"]}),(0,xe.jsxs)(de,{value:"monitor",className:"gap-2",children:[(0,xe.jsx)(g,{className:"h-4 w-4"}),"Monitor"]})]}),(0,xe.jsx)(ne,{value:"calendar",className:"space-y-6",children:(0,xe.jsx)(pe,{})}),(0,xe.jsx)(ne,{value:"approvals",className:"space-y-6",children:(0,xe.jsx)(fe,{})}),(0,xe.jsx)(ne,{value:"scheduler",className:"space-y-6",children:(0,xe.jsx)(ve,{})}),(0,xe.jsx)(ne,{value:"distribution",className:"space-y-6",children:(0,xe.jsx)(ye,{})}),(0,xe.jsx)(ne,{value:"monitor",className:"space-y-6",children:(0,xe.jsx)(we,{})})]})]})}export{ke 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.