1import{r as j,bf as he,j as t,R as qe,d as J,a as T,L as Ee,a6 as Ne,e as Rt,a4 as $t,U as Lt,l as Je,aK as It,b5 as Xe,S as Yt,g as Pt,y as qt}from"./index-Bn97Kz8X.js";import{S as Vt}from"./SEO-BjAPr8No.js";import{S as Y}from"./shield-alert-DnPSteYw.js";import{I as Re}from"./info-WZWzOYAm.js";import{P as Ke}from"./plus-CPfhT_Zt.js";import{F as ge}from"./file-text-CeuKdFir.js";import{U as ye}from"./user-check-DLTD2Rz8.js";import{M as we}from"./mic-vocal-CmQfePvu.js";import{F as Fe}from"./film-29rVbhZY.js";import{Y as pe}from"./youtube-D8gizUv_.js";import{L as ot}from"./list-checks-B3kN5TTK.js";import{C as Ve}from"./clock-3-CzVCToOo.js";const it="[email protected]",Gt="[email protected]",dt=new Set([it,Gt]),lt=["[email protected]","[email protected]"],Ot=new Set([...dt,...lt]);function ce(e){return(e==null?void 0:e.data)??e}function W(e,r){var d,p;const s=ce(e),i=[s==null?void 0:s.error,s==null?void 0:s.message,e==null?void 0:e.message,(p=(d=e==null?void 0:e.response)==null?void 0:d.data)==null?void 0:p.error].find(n=>typeof n=="string"&&n.trim());return i?String(i).replace(/[\u0000-\u001f\u007f]/g," ").trim().slice(0,240):r}function be(e){var d,p;const r=[e,e==null?void 0:e.response,(d=e==null?void 0:e.response)==null?void 0:d.data,e==null?void 0:e.data,e==null?void 0:e.cause,(p=e==null?void 0:e.cause)==null?void 0:p.data],s=r.map(n=>Number((n==null?void 0:n.status)??(n==null?void 0:n.statusCode)??0)).find(n=>n===401||n===403),i=r.map(n=>typeof n=="string"?n:[n==null?void 0:n.message,n==null?void 0:n.error,n==null?void 0:n.reason,n==null?void 0:n.code].join(" ")).join(" ").toLowerCase();return s===403||/forbidden|access_denied|allowlist|not_authorized/.test(i)?"denied":s===401||/invalid[_ -]?session|authentication required|unauthorized|sign in again|token expired/.test(i)?"session":"error"}function et(e){return Array.isArray(e)?e.map(String).filter(Boolean):[]}function Ut(e){const r=String((e==null?void 0:e.id)||"").trim();return r?{id:r,created_at:(e==null?void 0:e.created_at)??null,updated_at:(e==null?void 0:e.updated_at)??null,package_slug:(e==null?void 0:e.package_slug)??null,source_title:(e==null?void 0:e.source_title)??null,source_channel_name:(e==null?void 0:e.source_channel_name)??null,source_url:(e==null?void 0:e.source_url)??null,source_video_id:(e==null?void 0:e.source_video_id)??null,source_kind:(e==null?void 0:e.source_kind)??null,source_content:(e==null?void 0:e.source_content)??null,source_approval_reference:(e==null?void 0:e.source_approval_reference)??null,source_identity:(e==null?void 0:e.source_identity)??null,source_provenance_fingerprint:(e==null?void 0:e.source_provenance_fingerprint)??null,source_provenance_snapshot:(e==null?void 0:e.source_provenance_snapshot)??null,source_provenance_captured_at:(e==null?void 0:e.source_provenance_captured_at)??null,domain_page_url:(e==null?void 0:e.domain_page_url)??null,domain_page_status:(e==null?void 0:e.domain_page_status)??null,status:(e==null?void 0:e.status)??null,stage:(e==null?void 0:e.stage)??null,track:(e==null?void 0:e.track)==="SHORTS"?"SHORTS":(e==null?void 0:e.track)==="FLAGSHIP"?"FLAGSHIP":null,script_draft:(e==null?void 0:e.script_draft)??null,tts_script_draft:(e==null?void 0:e.tts_script_draft)??null,final_display_script:(e==null?void 0:e.final_display_script)??null,final_script:(e==null?void 0:e.final_script)??null,voice_id:(e==null?void 0:e.voice_id)??null,voiceover_url:(e==null?void 0:e.voiceover_url)??null,voiceover_status:(e==null?void 0:e.voiceover_status)??null,broll_checklist:et(e==null?void 0:e.broll_checklist),final_video_url:(e==null?void 0:e.final_video_url)??null,edit_status:(e==null?void 0:e.edit_status)??null,youtube_video_id:(e==null?void 0:e.youtube_video_id)??null,youtube_status:(e==null?void 0:e.youtube_status)??null,youtube_title:(e==null?void 0:e.youtube_title)??null,youtube_description:(e==null?void 0:e.youtube_description)??null,youtube_tags:et(e==null?void 0:e.youtube_tags),publish_at:(e==null?void 0:e.publish_at)??null,published_at:(e==null?void 0:e.published_at)??null,generated_at:(e==null?void 0:e.generated_at)??null,views:(e==null?void 0:e.views)??null,likes:(e==null?void 0:e.likes)??null,provider_error:(e==null?void 0:e.provider_error)??null,direct_youtube_status:(e==null?void 0:e.direct_youtube_status)??null,direct_youtube_video_id:(e==null?void 0:e.direct_youtube_video_id)??null,direct_youtube_attempted_at:(e==null?void 0:e.direct_youtube_attempted_at)??null,direct_youtube_completed_at:(e==null?void 0:e.direct_youtube_completed_at)??null,direct_youtube_error:(e==null?void 0:e.direct_youtube_error)??null,n8n_dispatch_status:(e==null?void 0:e.n8n_dispatch_status)??null,
1n8n_last_dispatch_event:(e==null?void 0:e.n8n_last_dispatch_event)??null,n8n_last_dispatch_at:(e==null?void 0:e.n8n_last_dispatch_at)??null,n8n_dispatch_error:(e==null?void 0:e.n8n_dispatch_error)??null,n8n_last_event:(e==null?void 0:e.n8n_last_event)??null,n8n_last_event_at:(e==null?void 0:e.n8n_last_event_at)??null,script_approved_by_email:(e==null?void 0:e.script_approved_by_email)??null,script_approved_at:(e==null?void 0:e.script_approved_at)??null,edit_approved_by_email:(e==null?void 0:e.edit_approved_by_email)??null,edit_approved_at:(e==null?void 0:e.edit_approved_at)??null,script_maeesha_review_status:(e==null?void 0:e.script_maeesha_review_status)??null,script_maeesha_review_note:(e==null?void 0:e.script_maeesha_review_note)??null,script_maeesha_reviewed_by_email:(e==null?void 0:e.script_maeesha_reviewed_by_email)??null,script_maeesha_reviewed_at:(e==null?void 0:e.script_maeesha_reviewed_at)??null,script_owner_review_status:(e==null?void 0:e.script_owner_review_status)??null,script_owner_review_note:(e==null?void 0:e.script_owner_review_note)??null,script_owner_reviewed_by_email:(e==null?void 0:e.script_owner_reviewed_by_email)??null,script_owner_reviewed_at:(e==null?void 0:e.script_owner_reviewed_at)??null,edit_review_status:(e==null?void 0:e.edit_review_status)??null,edit_review_note:(e==null?void 0:e.edit_review_note)??null,edit_reviewed_by_email:(e==null?void 0:e.edit_reviewed_by_email)??null,edit_reviewed_at:(e==null?void 0:e.edit_reviewed_at)??null,maeesha_review_status:(e==null?void 0:e.maeesha_review_status)??null,maeesha_review_note:(e==null?void 0:e.maeesha_review_note)??null,maeesha_reviewed_by_email:(e==null?void 0:e.maeesha_reviewed_by_email)??null,maeesha_reviewed_at:(e==null?void 0:e.maeesha_reviewed_at)??null,owner_review_status:(e==null?void 0:e.owner_review_status)??null,owner_review_note:(e==null?void 0:e.owner_review_note)??null,owner_reviewed_by_email:(e==null?void 0:e.owner_reviewed_by_email)??null,owner_reviewed_at:(e==null?void 0:e.owner_reviewed_at)??null,handoff_status:(e==null?void 0:e.handoff_status)??null,notification_status:(e==null?void 0:e.notification_status)??null,last_action:(e==null?void 0:e.last_action)??null,last_action_at:(e==null?void 0:e.last_action_at)??null,last_action_note:(e==null?void 0:e.last_action_note)??null}:null}function M(e){if(!e)return"Not recorded";const r=new Date(e);return Number.isNaN(r.getTime())?"Not recorded":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}).format(r)}function Mt(e){if(!e)return"";const r=new Date(e);if(Number.isNaN(r.getTime()))return"";const s=i=>String(i).padStart(2,"0");return`${r.getFullYear()}-${s(r.getMonth()+1)}-${s(r.getDate())}T${s(r.getHours())}:${s(r.getMinutes())}`}function Ht(e){if(!e)return null;const r=new Date(e);return Number.isNaN(r.getTime())?null:r.toISOString()}function Ge(e){return{intake:"Intake",draft:"Script draft",voiceover:"Voiceover",edit:"Descript edit",review:"Final review",scheduled:"Scheduled",published:"Published",failed:"Workflow failed"}[e||""]||"Stage not recorded"}function ct(e){return{source_ready:"Source ready",generated:"Package generated",maeesha_approved:"Copywriter approved",changes_requested:"Changes requested",approved:"Owner approved",published:"Companion page published",failed:"Workflow failed"}[e||""]||"Status not recorded"}function Wt(e){return["approved","published"].includes(e||"")?"border-[#9DB696] bg-[#EEF6EC] text-[#3D6B3A]":["failed","changes_requested"].includes(e||"")?"border-[#D99A8E] bg-[#FBEDE9] text-[#9E2F20]":e==="maeesha_approved"?"border-[#AFC6D5] bg-[#EDF5FA] text-[#2B5871]":"border-[#D8B66B] bg-[#FFF4D9] text-[#78520D]"}function zt(e){return{not_sent:"Not sent",waiting_for_url:"Waiting for n8n address",sent:"Delivered to n8n",failed:"Delivery failed"}[e||""]||"Dispatch not recorded"}function pt(e){const r=e.n8n_dispatch_status||"not_sent";return["not_sent","waiting_for_url","failed"].includes(r)?["new_case","script_approved","edit_approved"].includes(e.n8n_last_dispatch_event||"")?e.n8n_last_dispatch_event:e.stage==="intake"?"new_case":e.edit_approved_at?"edit_approved":e.script_approved_at?"script_approved":null:null}function je(e){return e==="approved"?"Approved":e==="changes_requested"?"Changes requested":"Not reviewed"}function Oe(e,r){return String(e||r||"").trim().toLowerCase()||null}function X(e,r){return[e,r].map(i=>String(i||"").trim()).find(Boolean)||null}function H(e){return Oe(e.script_maeesha_review_status,e.maeesha_review_status)}function Qt(e){return X(e.script_maeesha_review_note,e.maeesha_review_note)}function Zt(e){return X(e.script_maeesha_reviewed_by_email,e.maeesha_reviewed_by_email)}function $e(e){return X(e.script_maeesha_reviewed_at,e.maeesha_reviewed_at)}function te(e){return Oe(e.script_owner_review_status,e.owner_review_status)}function Jt(e){return X(e.script_owner_review_note,e.owner_review_note)}function Xt(e){return X(e.script_owner_reviewed_by_email,e.owner_reviewed_by_email)}function Le(e){return X(e.script_owner_reviewed_at,e.owner_reviewed_at)}function me(e){return Oe(e.edit_review_status)}function Kt(e){return X(e.edit_review_note)}function er(e){return X(e.edit_reviewed_by_email)}function Ie(e){return X(e.edit_reviewed_at)}function Ae(e){return!!(e.script_approved_at||e.script_approved_by_email||String(e.final_script||"").trim()||String(e.final_display_script||"").trim())}function Ce(e){return!!(String(e.youtube_video_id||"").trim()||String(e.youtube_status||"").trim())}function Ue(e){return K(e)!=="not_started"||!!(e.direct_youtube_attempted_at||e.direct_youtube_completed_at||e.direct_youtube_video_id||e.direct_youtube_error)}function Ye(e){var r;return!!(String(e.voiceover_status||"").trim()||He(e)||(r=e.broll_checklist)!=null&&r.length)}function ke(e){return String(e.edit_status||"").trim().toLowerCase()==="approved"||!!(e.edit_approved_at||e.edit_approved_by_email)}function xt(e){return["published"].includes(String(e.status||"").trim().toLowerCase())||String(e.domain_page_status||"").trim().toLowerCase()==="published"||!!e.published_at}function ut(e){return String(e.status||"").trim().toLowerCase()==="changes_requested"&&e.stage==="draft"}function tr(e,r){return r&&["intake","draft"].includes(String(e.stage||"").trim().toLowerCase())&&(ut(e)||!Ae(e))&&!xt(e)&&!ke(e)&&!Ce(e)&&!Ue(e)&&!Ye(e)}function rr(e,r){return r&&["edit","review"].includes(String(e.stage||"").trim().toLowerCase())&&!xt(e)&&!ke(e)&&!Ce(e)&&!Ue(e)}const sr=new Set(["not_started","uploading","uploaded_private","failed","needs_review"]);function K(e){const r=e.direct_youtube_status||"not_started";return sr.has(r)?r:"needs_review"}function xe(e){return typeof e=="string"&&/^[A-Za-z0-9_-]{6,32}$/.test(e)?e:null}function Me(e){return!!(xe(e.youtube_video_id)&&["private","scheduled","published","public"].includes(String(e.youtube_status||"").toLowerCase()))}const fe=new Set(["ready","completed","generated","available","success"]);function Q(e){return String(e||"").trim().toLowerCase()}function He(e){const r=String(e.voiceover_url||"").trim();if(!r)return null;try{const s=new URL(r);return["http:","https:"].includes(s.protocol)?s.toString():null}catch{return null}}
1function De(e){return!!(He(e)&&fe.has(Q(e.voiceover_status)))}function tt(e){const r=Q(e);return{generating:"Generating",generated:"Generated",ready:"Ready via n8n",completed:"Completed",available:"Available",success:"Completed",failed:"Failed","":"Idle"}[r]||r||"Idle"}function z(e,r){const s=e.status||"";if(r==="voice"){const i=!!e.script_approved_at&&!!String(e.voice_id||"").trim();return De(e)?"complete":["generating","failed"].includes(Q(e.voiceover_status))||i?"current":e.voiceover_status||e.script_approved_at?"waiting":"unavailable"}if(r==="render")return e.final_video_url?"complete":"unavailable";if(r==="youtube"){const i=K(e);return i==="uploaded_private"&&xe(e.direct_youtube_video_id)&&e.direct_youtube_completed_at||Me(e)?"complete":["uploading","failed","needs_review"].includes(i)||i==="not_started"&&e.edit_approved_at?"current":"unavailable"}if(r==="source")return e.source_content||e.source_title||e.source_url?"complete":"waiting";if(r==="package")return["generated","maeesha_approved","approved","published"].includes(s)?"complete":s==="source_ready"||s==="failed"?"current":"waiting";if(r==="maeesha"){const i=e.stage==="draft"&&!!String(e.script_draft||"").trim();return H(e)==="approved"||e.script_approved_at&&!i?"complete":i&&["","source_ready","generated","changes_requested"].includes(s)?"current":"waiting"}if(r==="carl"){const i=e.stage==="draft"&&!!String(e.script_draft||"").trim();return te(e)==="approved"||e.script_approved_at?"complete":i&&(s==="maeesha_approved"||H(e)==="approved")?"current":"waiting"}return r==="page"?s==="published"||e.domain_page_status==="published"?"complete":s==="approved"?"current":"waiting":"waiting"}const ne=["source","package","maeesha","carl","page","voice","render","youtube"],ar=[{label:"Source",action:"In New case, add the approved source reference and stable source ID, optionally add a human-supplied title, choose FLAGSHIP or SHORTS, paste the real source content, then create the private case.",stop:"Never invent missing source material."},{label:"Buildy package",action:"Use the recorded source to create and save a display script and a separate TTS script.",stop:"Saving text does not create audio or video."},{label:"Copywriter review",action:"The assigned copywriter reviews both source-bound scripts and either approves or requests changes. If changes are requested, stop, revise from the source, and return to review.",stop:"Do not move forward until the revised scripts are approved."},{label:"Carl review",action:"Carl reviews the final display and TTS scripts and records owner approval.",stop:"Do not start voiceover before this gate."},{label:"Domain page",action:"Check only the companion-page status recorded on the case.",stop:"When no real status is available, wait. Never claim the page is prepared or published."},{label:"ElevenLabs voice",action:"An approved Carl owner saves the approved voice ID and starts the separate voice action, or waits for the legacy n8n callback.",stop:"Continue only when usable audio is truthfully confirmed."},{label:"Video renderer",action:"Keep Descript editing and B-roll manual. Enter the real final MP4 and YouTube metadata, then record final-edit approval.",stop:"Do not infer that rendering happened."},{label:"YouTube upload",action:"An approved Carl owner uploads the approved video privately and checks YouTube's actual confirmation.",stop:"This flow never schedules or publicly publishes automatically."}];function nr(){return t.jsxs("section",{className:"space-y-3 rounded-[4px] border-2 border-[#B5321F] bg-[#FFF8F5] p-3 sm:p-4","aria-labelledby":"va-operating-guide-title",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-[3px] bg-[#B5321F] text-white",children:t.jsx(ot,{className:"h-5 w-5","aria-hidden":"true"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.16em] text-[#B5321F]",children:"VA operating guide"}),t.jsx("h3",{id:"va-operating-guide-title",className:"mt-1 text-[18px] font-black tracking-tight text-[#1A1714]",children:"Follow the eight gates in order."}),t.jsx("p",{className:"mt-1 max-w-3xl text-[11px] leading-relaxed text-[#4F4941]",children:"This guide explains what to do. The lower detailed rail shows the live recorded status for the selected case."})]})]}),t.jsx("ol",{className:"grid gap-2 sm:grid-cols-2 xl:grid-cols-4","aria-label":"Eight-step VA operating guide",children:ar.map((e,r)=>t.jsxs("li",{"aria-label":`Step ${r+1} of 8, ${e.label}`,className:"flex min-w-0 flex-col rounded-[3px] border border-[#D8D2C8] bg-white p-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{"aria-hidden":"true",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[2px] bg-[#1A1714] font-mono text-[11px] font-bold text-[#E8DCC0]",children:r+1}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"font-mono text-[8px] font-bold uppercase tracking-[0.1em] text-[#B5321F]",children:["Step ",r+1," of 8"]}),t.jsx("h4",{className:"mt-0.5 text-[13px] font-black leading-tight text-[#1A1714]",children:e.label})]})]}),t.jsxs("p",{className:"mt-3 text-[11px] leading-relaxed text-[#4F4941]",children:[t.jsx("span",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.06em] text-[#756C60]",children:"Do:"})," ",e.action]}
1),t.jsxs("p",{className:"mt-2 border-t border-[#EEE9E0] pt-2 text-[10px] leading-relaxed text-[#7E2419]",children:[t.jsx("span",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.06em] text-[#B5321F]",children:"Stop:"})," ",e.stop]})]},e.label))}),t.jsxs("aside",{className:"flex items-start gap-2 rounded-[3px] border border-[#D8B66B] bg-[#FFF4D9] px-3 py-2.5 text-[10px] leading-relaxed text-[#78520D]",children:[t.jsx(Y,{className:"mt-0.5 h-4 w-4 shrink-0","aria-hidden":"true"}),t.jsxs("p",{children:[t.jsx("span",{className:"font-bold",children:"VA rules:"})," Use only supplied source material. Never record a Copywriter or Carl approval without the proper role. Stop on Waiting, Not connected, or Needs attention. Refresh after saved actions."]})]})]})}const or=[{key:"all",label:"All"},{key:"needs_attention",label:"Needs attention"},{key:"in_progress",label:"In progress"},{key:"ready_for_review",label:"Ready for review"},{key:"completed",label:"Completed"},{key:"private_tests",label:"Private tests"}],rt={all:"all cases",needs_attention:"cases needing attention",in_progress:"in-progress cases",ready_for_review:"cases ready for review",completed:"completed cases",private_tests:"private test cases"};function We(e){if(!e)return!1;const r=new Date(e).getTime();return Number.isFinite(r)}function ze(e){const r=String(e.source_approval_reference||"").trim(),s=String(e.source_identity||"").trim(),i=String(e.source_content||""),d=String(e.source_provenance_fingerprint||"").trim(),p=String(e.source_provenance_captured_at||"").trim(),n=e.source_provenance_snapshot;return!(!r||!s||!i.trim()||!/^[a-f0-9]{64}$/i.test(d)||!We(p)||!n||n.version!==1||n.source_approval_reference!==r||n.source_identity!==s||n.captured_at!==p||(n.source_url??null)!==(e.source_url??null)||(n.source_video_id??null)!==(e.source_video_id??null)||!/^[a-f0-9]{64}$/i.test(String(n.source_content_sha256||"").trim())||n.source_content_length!==i.length)}function oe(e){return K(e)==="uploaded_private"&&!!xe(e.direct_youtube_video_id)&&We(e.direct_youtube_completed_at)}function ir(e){return K(e)!=="not_started"||!!(e.direct_youtube_attempted_at||e.direct_youtube_completed_at||e.direct_youtube_video_id||e.direct_youtube_error)}function re(e){return oe(e)||Me(e)}function ie(e){if([e.status,e.stage,e.edit_status,e.voiceover_status,e.direct_youtube_status,e.n8n_dispatch_status,e.handoff_status,e.youtube_status,H(e),te(e),me(e)].map(n=>String(n||"").trim().toLowerCase()).some(n=>["failed","changes_requested","generation_failed","delivery_failed","needs_review"].includes(n))||[e.provider_error,e.direct_youtube_error,e.n8n_dispatch_error].some(n=>!!String(n||"").trim()))return!0;const s=K(e);if(s==="needs_review"||s==="uploaded_private"&&!oe(e)||s==="failed"&&xe(e.direct_youtube_video_id)||!!(String(e.voiceover_url||"").trim()||String(e.voiceover_status||"").trim())&&Q(e.voiceover_status)!=="generating"&&!De(e))return!0;const d=!!(String(e.youtube_video_id||"").trim()||String(e.youtube_status||"").trim()),p=String(e.youtube_status||"").trim().toLowerCase();return!!(d&&(!xe(e.youtube_video_id)||!["private","scheduled","published","public"].includes(p)))}function ve(e){if(ie(e)||re(e))return!1;const r=String(e.status||"").trim().toLowerCase(),s=Ae(e),i=!!String(e.script_draft||"").trim(),d=e.stage==="draft"&&i&&(ut(e)||!s),p=d&&H(e)!=="approved"&&r!=="maeesha_approved",n=d&&(r==="maeesha_approved"||H(e)==="approved")&&!e.script_approved_at&&te(e)!=="approved",x=["edit","review"].includes(e.stage||"")&&!e.edit_approved_at;return p||n||x}function dr(e){return!ie(e)&&!re(e)&&!ve(e)}function lr(e){return ie(e)?"needs_attention":re(e)?"completed":ve(e)?"ready_for_review":"in_progress"}function Be(e,r){return r==="all"?!0:r==="private_tests"?ir(e):lr(e)===r}function Qe(e){return ne.reduce((r,s)=>r+(z(e,s)==="complete"?1:0),0)}function cr(e){const r=e.length*ne.length,s=e.reduce((i,d)=>i+Qe(d),0);return{recorded:s,total:r,percentage:r?Math.round(s/r*100):0}}function st(e){const r={new_case:"Case created",generate_script_draft:"Script draft generated",save_script_draft:"Script draft saved",media_review:"Media review saved",script_approve:"Script approved",update_voice_id:"Voice ID saved",generate_voiceover:"Voiceover requested",edit_approve:"Final edit approved",dispatch_n8n:"n8n handoff sent",upload_youtube_private:"Private upload confirmed"},s=String(e||"").trim();return r[s]||(s?s.replace(/[_-]+/g," ").replace(/\b\w/g,i=>i.toUpperCase()):"Action recorded")}function Se(e){const r=[];return(e.last_action||e.last_action_at)&&r.push({label:st(e.last_action),at:e.last_action_at||null}),(H(e)||$e(e))&&r.push({label:`Copywriter ${je(H(e)).toLowerCase()} script review`,at:$e(e)}),(te(e)||Le(e))&&r.push({label:`Carl ${je(te(e)).toLowerCase()} script review`,at:Le(e)}),(me(e)||Ie(e))&&r.push({label:`Carl ${je(me(e)).toLowerCase()} final edit review`,at:Ie(e)}),(e.n8n_last_event||e.n8n_last_event_at)&&r.push({label:`n8n callback: ${st(e.n8n_last_event)}`,at:e.n8n_last_event_at||null}),oe(e)?r.push({label:"Private upload confirmed",at:e.direct_youtube_completed_at||null}):e.direct_youtube_attempted_at&&r.push({label:"Private upload started",at:e.direct_youtube_attempted_at}),e.published_at&&r.push({label:"Published timestamp recorded",at:e.published_at}),e.generated_at&&r.push({label:"Package generated",at:e.generated_at}),e.updated_at&&r.push({label:"Record updated",at:e.updated_at}),e.created_at&&r.push({label:"Case created",at:e.created_at}),r.filter(i=>We(i.at)).sort((i,d)=>new Date(d.at).getTime()-new Date(i.at).getTime())[0]||r[0]||{label:"No action recorded",at:null}}function ht(e){const r=K(e);return r==="uploading"?"Private upload · Uploading":r==="needs_review"?"Private upload · Review":r==="failed"?"Private upload · Failed":Q(e.voiceover_status)==="generating"?"Voiceover · Generating":[e.stage?Ge(e.stage):"",e.status?ct(e.status):""].filter(
1Boolean).join(" · ")||"Stage not recorded"}function pr(e){if(ie(e))return"Review the recorded issue";if(oe(e))return"Private test complete";if(re(e))return"Legacy YouTube result recorded";if(Q(e.voiceover_status)==="generating")return"Waiting for voiceover confirmation";if(K(e)==="uploading")return"Waiting for private upload confirmation";if(e.stage==="draft"&&String(e.script_draft||"").trim()&&!e.script_approved_at)return String(e.status||"").trim().toLowerCase()==="maeesha_approved"||H(e)==="approved"?"Carl owner review":"Copywriter script review";if(e.status==="generated"&&H(e)!=="approved")return"Copywriter script review";if(e.status==="maeesha_approved"&&te(e)!=="approved")return"Carl owner review";if(["edit","review"].includes(e.stage||"")&&!e.edit_approved_at)return"Final edit approval";if(e.edit_approved_at||e.n8n_dispatch_status==="sent")return"Waiting for provider callback";const r=ne.find(s=>z(e,s)==="current");return r?`${r==="maeesha"?"Copywriter":r==="carl"?"Carl":Ge(r)} gate`:"Next gate not recorded"}function bt(e){return ie(e)?"Needs attention":oe(e)?"Private test complete":re(e)?"Completed":ve(e)?"Ready for review":"In progress"}function ft(e){return ie(e)?{dot:"bg-[#B5321F]",badge:"border-[#D99A8E] bg-[#FBEDE9] text-[#9E2F20]",bar:"bg-[#B5321F]"}:oe(e)?{dot:"bg-[#2B5871]",badge:"border-[#AFC6D5] bg-[#EDF5FA] text-[#2B5871]",bar:"bg-[#2B5871]"}:re(e)?{dot:"bg-[#3D6B3A]",badge:"border-[#9DB696] bg-[#EEF6EC] text-[#3D6B3A]",bar:"bg-[#3D6B3A]"}:ve(e)?{dot:"bg-[#C08A2D]",badge:"border-[#D8B66B] bg-[#FFF4D9] text-[#78520D]",bar:"bg-[#C08A2D]"}:{dot:"bg-[#C08A2D]",badge:"border-[#D8B66B] bg-[#FFF4D9] text-[#78520D]",bar:"bg-[#C08A2D]"}}function xr({label:e,value:r,note:s,icon:i,tone:d}
1){const p={neutral:"border-[#D8D2C8] bg-white",amber:"border-[#E8D29A] bg-[#FFF9E9]",red:"border-[#E4B1A8] bg-[#FFF5F2]",green:"border-[#BBD2B5] bg-[#F5FBF3]",blue:"border-[#B7CBD7] bg-[#F3F9FC]"},n={neutral:"text-[#756C60]",amber:"text-[#A66A0B]",red:"text-[#B5321F]",green:"text-[#3D6B3A]",blue:"text-[#2B5871]"};return t.jsxs("article",{className:`min-w-0 rounded-[4px] border p-3 ${p[d]}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("p",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.1em] text-[#756C60]",children:e}),t.jsx("span",{className:n[d],children:i})]}),t.jsx("p",{className:"mt-2 text-[24px] font-black leading-none text-[#1A1714]",children:r}),t.jsx("p",{className:"mt-2 text-[10px] leading-snug text-[#756C60]",children:s})]})}function ur({item:e,selected:r,onSelect:s}){const i=ft(e),d=Qe(e),p=Math.round(d/ne.length*100),n=Se(e),x=String(e.source_title||"").trim()||"Untitled source case";return t.jsxs("button",{type:"button",onClick:()=>s(e.id),"aria-pressed":r,className:`w-full rounded-[4px] border p-3 text-left transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] focus-visible:ring-offset-2 focus-visible:ring-offset-white ${r?"border-[#B5321F] bg-[#FFF8F5] shadow-[0_3px_12px_rgba(181,50,31,0.12)]":"border-[#DED8CE] bg-white hover:border-[#C9B889] hover:bg-[#FFFCF4]"}`,children:[t.jsxs("span",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-3",children:[t.jsx("span",{className:`mt-1.5 h-2.5 w-2.5 shrink-0 rounded-full ${i.dot}`,"aria-hidden":"true"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-[13px] font-black text-[#1A1714]",children:x}),t.jsxs("span",{className:"mt-1 block font-mono text-[9px] font-bold uppercase tracking-[0.08em] text-[#756C60]",children:[e.track||"Track not recorded"," · ",ht(e)]})]}),t.jsx("span",{className:`inline-flex shrink-0 self-start rounded-[3px] border px-2 py-1 font-mono text-[9px] font-bold uppercase tracking-[0.06em] ${i.badge}`,children:bt(e)})]}),t.jsxs("span",{className:"mt-3 grid gap-2 border-t border-[#EEE9E0] pt-2.5 text-[10px] text-[#756C60] sm:grid-cols-[1fr_auto] sm:items-center",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-mono font-bold uppercase tracking-[0.06em] text-[#948B7F]",children:"Latest action"})," ",n.label," · ",t.jsx("time",{dateTime:n.at||void 0,children:M(n.at)})]}),t.jsxs("span",{className:"font-mono font-bold text-[#4F4941]",children:[d,"/",ne.length," recorded · ",p,"%"]})]}),t.jsx("span",{className:"mt-2 block h-1.5 overflow-hidden rounded-full bg-[#EDE8DE]","aria-hidden":"true",children:t.jsx("span",{className:`block h-full rounded-full transition-[width] duration-500 ${i.bar}`,style:{width:`${p}%`}})})]})}function hr({records:e,loading:r,activeFilter:s,selectedId:i,latestRefreshAt:d,onFilter:p,onSelect:n}){const x=cr(e),f=e.filter(h=>Be(h,s)).sort((h,_)=>{const F=Se(h).at,C=Se(_).at;return(C?new Date(C).getTime():0)-(F?new Date(F).getTime():0)}),u=r?"Refreshing recordsâ¦":d?`Last refreshed ${M(d)}`:"Waiting for first successful refresh",g=[{label:"Total shown",value:String(e.length),note:"Private records returned",icon:t.jsx(ge,{className:"h-4 w-4"}),tone:"neutral"},{label:"In progress",value:String(e.filter(dr).length),note:"Active, nonfailed cases",icon:t.jsx(Ve,{className:"h-4 w-4"}),tone:"amber"},{label:"Ready for review",value:String(e.filter(ve).length),note:"A real human gate is waiting",icon:t.jsx(ye,{className:"h-4 w-4"}),tone:"amber"},{label:"Needs attention",value:String(e.filter(ie).length),note:"Failure or ambiguity recorded",icon:t.jsx(Y,{className:"h-4 w-4"}),tone:"red"},{label:"Completed",value:String(e.filter(re).length),note:"Private or legacy result recorded",icon:t.jsx(J,{className:"h-4 w-4"}),tone:"green"},{label:"Private test complete",value:String(e.filter(oe).length),note:"YouTube confirmed private",icon:t.jsx(pe,{className:"h-4 w-4"}),tone:"blue"}];return t.jsxs("section",{className:"space-y-3","aria-labelledby":"
1case-operations-overview-title",children:[t.jsxs("div",{className:"flex flex-col gap-2 rounded-[4px] border border-[#D8D2C8] bg-white p-3 sm:flex-row sm:items-end sm:justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.16em] text-[#B5321F]",children:"Operations overview"}),t.jsx("h3",{id:"case-operations-overview-title",className:"mt-1 text-[17px] font-black tracking-tight text-[#1A1714]",children:"See the next move before opening a case."}),t.jsx("p",{className:"mt-1 max-w-2xl text-[11px] leading-relaxed text-[#756C60]",children:"This queue groups only the statuses and timestamps returned by the private YouTube case records. Recorded progress is a checkpoint count, not a forecast of provider work."})]}),t.jsx("p",{className:"shrink-0 font-mono text-[9px] font-bold uppercase tracking-[0.08em] text-[#756C60]","aria-live":"polite",children:u})]}),t.jsx("div",{className:"grid grid-cols-2 gap-2 md:grid-cols-3 lg:grid-cols-6",children:g.map(h=>t.jsx(xr,{...h},h.label))}),t.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.2fr_0.8fr]",children:[t.jsxs("section",{className:"rounded-[4px] border border-[#D8D2C8] bg-white p-3","aria-labelledby":"recorded-progress-title",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{id:"recorded-progress-title",className:"font-mono text-[9px] font-bold uppercase tracking-[0.12em] text-[#756C60]",children:"Workflow checkpoints recorded"}),t.jsxs("p",{className:"mt-1 text-[13px] font-black text-[#1A1714]",children:[x.recorded," / ",x.total," checkpoints"]})]}),t.jsx("span",{className:"font-mono text-[18px] font-black text-[#3D6B3A]",children:x.total?`${x.percentage}%`:"â"})]}),t.jsx("div",{className:"mt-3 h-2 overflow-hidden rounded-full bg-[#EDE8DE]",role:"progressbar","aria-label":"Recorded workflow checkpoint progress","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":x.percentage,children:t.jsx("div",{className:"h-full rounded-full bg-[#3D6B3A] transition-[width] duration-500",style:{width:`${x.percentage}%`}})}),t.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-[#756C60]",children:"Each case contributes eight existing rail checkpoints. A checkpoint is counted only when the current record marks it complete."})]}),t.jsxs("section",{className:"rounded-[4px] border border-[#D8D2C8] bg-white p-3","aria-labelledby":"status-legend-title",children:[t.jsx("p",{id:"status-legend-title",className:"font-mono text-[9px] font-bold uppercase tracking-[0.12em] text-[#756C60]",children:"Color guide"}),t.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-x-3 gap-y-2 text-[10px] text-[#4F4941] sm:grid-cols-3 lg:grid-cols-2",children:[t.jsxs("span",{className:"inline-flex items-center gap-2",children:[t.jsx("i",{className:"h-2.5 w-2.5 rounded-full bg-[#3D6B3A]"}),"Recorded completion"]}),t.jsxs("span",{className:"inline-flex items-center gap-2",children:[t.jsx("i",{className:"h-2.5 w-2.5 rounded-full bg-[#C08A2D]"}),"Waiting or current gate"]}),t.jsxs("span",{className:"inline-flex items-center gap-2",children:[t.jsx("i",{className:"h-2.5 w-2.5 rounded-full bg-[#B5321F]"}),"Needs attention"]}),t.jsxs("span",{className:"inline-flex items-center gap-2",children:[t.jsx("i",{className:"h-2.5 w-2.5 rounded-full bg-[#2B5871]"}),"Provider or handoff"]}),t.jsxs("span",{className:"inline-flex items-center gap-2",children:[t.jsx("i",{className:"h-2.5 w-2.5 rounded-full bg-[#8F877C]"}),"Not started or unavailable"]})]})]})]}),t.jsxs("section",{className:"rounded-[4px] border border-[#D8D2C8] bg-[#F9F7F2] p-3","aria-labelledby":"case-queue-title","aria-busy":r,children:[t.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-end sm:justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.12em] text-[#B5321F]",children:"YouTube case queue"}),t.jsx("h3",{id:"case-queue-title",className:"mt-1 text-[16px] font-black text-[#1A1714]",children:"Filter the work, then open one case."})]}),t.jsxs("p",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.06em] text-[#756C60]",children:[f.length," of ",e.length," shown"]})]}),t.jsxs("div",{className:"mt-3 flex gap-2 overflow-x-auto pb-1",role:"toolbar","aria-label":"YouTube case filters",style:{scrollbarWidth:"thin"},children:[or.map(h=>{const _=e.filter(F=>Be(F,h.key)).length;return t.jsxs("button",{type:"button",onClick:()=>
1p(h.key),"aria-pressed":s===h.key,className:`inline-flex min-h-[38px] shrink-0 items-center gap-2 rounded-[3px] border px-3 font-mono text-[10px] font-bold uppercase tracking-[0.06em] transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] ${s===h.key?"border-[#B5321F] bg-[#B5321F] text-white":"border-[#D2C9BC] bg-white text-[#5F584F] hover:border-[#B5321F] hover:text-[#8E2D20]"}`,children:[t.jsx("span",{children:h.label}),t.jsx("span",{className:`rounded-[2px] px-1.5 py-0.5 text-[9px] ${s===h.key?"bg-white/20 text-white":"bg-[#F1EADB] text-[#756C60]"}`,children:_})]},h.key)}),t.jsxs("button",{type:"button",disabled:!0,title:"Deleted history unavailable","aria-label":"Deleted, deleted history unavailable",className:"inline-flex min-h-[38px] shrink-0 items-center gap-2 rounded-[3px] border border-dashed border-[#C9C2B7] bg-[#F1EEE8] px-3 font-mono text-[10px] font-bold uppercase tracking-[0.06em] text-[#9A9389]",children:[t.jsx("span",{children:"Deleted"}),t.jsx("span",{className:"normal-case tracking-normal",children:"Deleted history unavailable"})]})]}),r&&e.length===0?t.jsxs("div",{className:"space-y-2","aria-label":"Loading YouTube case queue",children:[t.jsx("div",{className:"h-24 animate-pulse rounded-[4px] border border-[#E2DDD4] bg-white"}),t.jsx("div",{className:"h-24 animate-pulse rounded-[4px] border border-[#E2DDD4] bg-white"})]}):e.length===0?t.jsxs("div",{className:"rounded-[4px] border border-dashed border-[#CFC7BB] bg-white p-5 text-center",children:[t.jsx(ge,{className:"mx-auto h-5 w-5 text-[#8F877C]"}),t.jsx("p",{className:"mt-2 font-mono text-[10px] font-bold uppercase tracking-[0.08em] text-[#1A1714]",children:"No YouTube case records returned"}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#756C60]",children:"The queue is empty because no private YouTube case records were returned. Deleted history is not available in the current data layer."})]}):f.length===0?t.jsxs("div",{className:"rounded-[4px] border border-dashed border-[#CFC7BB] bg-white p-5 text-center",children:[t.jsxs("p",{className:"font-mono text-[10px] font-bold uppercase tracking-[0.08em] text-[#1A1714]",children:["No ",rt[s]]}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#756C60]",children:"No current records match this filter. Choose another queue view to continue."})]}):t.jsx("div",{className:"space-y-2",role:"list","aria-label":`${rt[s]} queue`,children:f.map(h=>t.jsx(ur,{item:h,selected:i===h.id,onSelect:n},h.id))})]})]})}function br({item:e}){const r=ze(e),s=e.source_provenance_snapshot,i=String(e.source_approval_reference||"").trim(),d=String(e.source_identity||"").trim();return t.jsxs("section",{className:`rounded-[3px] border p-3 ${r?"border-[#B7CBD7] bg-[#F3F9FC]":"border-[#D99A8E] bg-[#FFF5F2]"}`,"aria-labelledby":`source-provenance-${e.id}`,children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Ee,{className:`mt-0.5 h-4 w-4 shrink-0 ${r?"text-[#2B5871]":"text-[#B5321F]"}`}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h4",{id:`source-provenance-${e.id}`,className:"font-mono text-[10px] font-bold uppercase tracking-[0.12em] text-[#1A1714]",children:"Approved-source provenance"}),t.jsx("span",{className:`rounded-[2px] border px-2 py-0.5 font-mono text-[9px] font-bold uppercase tracking-[0.06em] ${r?"border-[#AFC6D5] bg-white text-[#2B5871]":"border-[#D99A8E] bg-white text-[#9E2F20]"}`,children:r?"Verified and locked":"Review required"})]}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#756C60]",children:r?"Locked when this case was created.":"Creation-time provenance could not be verified for this historical record."})]})]}),!r&&t.jsxs("div",{role:"alert",className:"mt-3 flex items-start gap-2 rounded-[3px] border border-[#D99A8E] bg-white p-2.5 text-[10px] leading-relaxed text-[#7E2419]",children:[t.jsx(Y,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-bold",children:"Source review required"}),t.jsx("p",{className:"mt-1",children:"This record is readable for review, but script generation, voiceover generation, and private upload are disabled. Create a new case after reviewing the approved source."})]})]}),t.jsxs("dl",{className:"mt-3 grid gap-2 sm:grid-cols-2 xl:grid-cols-4",children:[t.jsx(E,{label:"Approval reference",value:i||"Not recorded",detail
1:"Read-only record of the source approval."}),t.jsx(E,{label:"Stable source ID",value:d||"Not recorded",detail:"Locked identity for the approved source."}),t.jsx(E,{label:"Captured",value:M(e.source_provenance_captured_at),detail:s!=null&&s.version?`Server snapshot v${s.version}`:"No creation snapshot recorded."}),t.jsx(E,{label:"Verification",value:r?"Complete":"Incomplete",detail:r?"Server fingerprint and creation snapshot are recorded.":"A required fingerprint, capture time, or snapshot check is missing."})]})]})}function fr({item:e}){const r=ft(e),s=Qe(e),i=Math.round(s/ne.length*100),d=Se(e);return t.jsxs("section",{className:"rounded-[4px] border border-[#D8D2C8] bg-white p-3","aria-labelledby":`selected-case-${e.id}`,children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.14em] text-[#B5321F]",children:"Selected case"}),t.jsx("h3",{id:`selected-case-${e.id}`,className:"mt-1 truncate text-[17px] font-black text-[#1A1714]",children:e.source_title||"Untitled source case"}),t.jsxs("p",{className:"mt-1 font-mono text-[9px] font-bold uppercase tracking-[0.08em] text-[#756C60]",children:[e.track||"Track not recorded"," · ",ht(e)]})]}),t.jsx("span",{className:`inline-flex shrink-0 self-start rounded-[3px] border px-2 py-1 font-mono text-[9px] font-bold uppercase tracking-[0.06em] ${r.badge}`,children:bt(e)})]}),t.jsx(br,{item:e}),t.jsxs("div",{className:"mt-3 grid gap-2 sm:grid-cols-[1fr_1fr_1.35fr]",children:[t.jsxs("div",{className:"rounded-[3px] border border-[#E6E0D7] bg-[#FBFAF7] p-2.5",children:[t.jsx("p",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.08em] text-[#948B7F]",children:"Next gate"}),t.jsx("p",{className:"mt-1 text-[12px] font-bold text-[#1A1714]",children:pr(e)})]}),t.jsxs("div",{className:"rounded-[3px] border border-[#E6E0D7] bg-[#FBFAF7] p-2.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx("p",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.08em] text-[#948B7F]",children:"Recorded progress"}),t.jsxs("p",{className:"font-mono text-[10px] font-bold text-[#3D6B3A]",children:[i,"%"]})]}),t.jsxs("p",{className:"mt-1 text-[12px] font-bold text-[#1A1714]",children:[s," / ",ne.length," checkpoints"]}),t.jsx("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-[#EDE8DE]",role:"progressbar","aria-label":`Recorded progress for ${e.source_title||"this case"}`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i,children:t.jsx("div",{className:`h-full rounded-full transition-[width] duration-500 ${r.bar}`,style:{width:`${i}%`}})})]}),t.jsxs("div",{className:"rounded-[3px] border border-[#E6E0D7] bg-[#FBFAF7] p-2.5",children:[t.jsx("p",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.08em] text-[#948B7F]",children:"Latest meaningful action"}),t.jsx("p",{className:"mt-1 truncate text-[12px] font-bold text-[#1A1714]",children:d.label}),t.jsx("time",{dateTime:d.at||void 0,className:"mt-1 block text-[10px] text-[#756C60]",children:M(d.at)})]})]})]})}function ee({stepNumber:e,label:r,stage:s,item:i}){const d=z(i,s),p=d==="complete"?"Recorded":d==="current"?"Current gate":d==="unavailable"?"Not connected":"Waiting";return t.jsxs("li",{className:"min-w-[108px] flex-1","aria-label":`Step ${e} of 8, ${r}: ${p}.`,children:[t.jsx("div",{className:`h-1.5 rounded-full ${d==="complete"?"bg-[#3D6B3A]":d==="current"?"bg-[#C08A2D]":d==="unavailable"?"bg-[#1A1714]/25":"bg-[#1A1714]/10"}`}),t.jsx("span",{"aria-hidden":"true",className:"mt-2 inline-flex h-5 w-5 items-center justify-center rounded-[2px] border border-[#C9B889] bg-[#FFFCF4] font-mono text-[9px] font-bold text-[#5F584F]",children:e}),t.jsx("p",{className:`mt-1 truncate font-mono text-[9px] font-bold uppercase tracking-[0.08em] ${d==="unavailable"?"text-[#6D665E]":"text-[#1A1714]"}`,children:r}),t.jsx("p",{className:"mt-0.5 font-mono text-[9px] text-[#6D665E]",children:p})]})}
1function E({label:e,value:r,detail:s}){return t.jsxs("div",{className:"min-w-0 rounded-[3px] border border-[#E0D5B9] bg-[#FFFCF4] p-2.5",children:[t.jsx("dt",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.12em] text-[#756C60]",children:e}),t.jsx("dd",{className:"mt-1 break-words text-[12px] font-bold text-[#1A1714]",children:r}),s&&t.jsx("p",{className:"mt-1 text-[10px] leading-snug text-[#756C60]",children:s})]})}function B({id:e,label:r,value:s,onChange:i,rows:d,readOnly:p=!1,helper:n,placeholder:x,type:f="text",maxLength:u,required:g=!1}){const h=`mt-1 w-full rounded-[3px] border border-[#C9B889] bg-[#FFFCF4] px-3 py-2.5 text-[16px] leading-relaxed text-[#1A1714] outline-none transition focus:border-[#B5321F] focus:ring-2 focus:ring-[#B5321F]/15 ${p?"bg-[#F1EADB] text-[#5F584F]":""}`;return t.jsxs("div",{children:[t.jsx("label",{htmlFor:e,className:"font-mono text-[9px] font-bold uppercase tracking-[0.1em] text-[#756C60]",children:r}),d?t.jsx("textarea",{id:e,rows:d,value:s,readOnly:p,maxLength:u,placeholder:x,required:g,onChange:_=>i==null?void 0:i(_.target.value),className:`${h} resize-y`}):t.jsx("input",{id:e,type:f,value:s,readOnly:p,maxLength:u,placeholder:x,required:g,onChange:_=>i==null?void 0:i(_.target.value),className:`${h} h-11`}),n&&t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#756C60]",children:n})]})}function at(){return{scriptDraft:"",ttsScriptDraft:"",finalDisplayScript:"",finalScript:"",voiceId:"",finalVideoUrl:"",title:"",description:"",tags:"",publishAt:"",track:"FLAGSHIP"}}function le(e){return{scriptDraft:String(e.script_draft||""),ttsScriptDraft:String(e.tts_script_draft||""),finalDisplayScript:String(e.final_display_script||""),finalScript:String(e.final_script||""),voiceId:String(e.voice_id||""),finalVideoUrl:String(e.final_video_url||""),title:String(e.youtube_title||e.source_title||""),description:String(e.youtube_description||""),tags:(e.youtube_tags||[]).join(", "),publishAt:Mt(e.publish_at),track:e.track||"FLAGSHIP"}}function nt({kind:e}){return t.jsxs("div",{className:"flex items-start gap-3 rounded-[4px] border border-[#D8C9A3] bg-[#F4EFE2] p-4 text-[#1A1714]",children:[t.jsx(Ee,{className:"mt-0.5 h-5 w-5 shrink-0 text-[#B5321F]"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-mono text-[10px] font-bold uppercase tracking-[0.14em] text-[#B5321F]",children:e==="missing"?"Staff sign-in required":"Staff access denied"}),t.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-[#4F4941]",children:e==="missing"?"Sign in with an approved RSG staff account to view private case files.":"This account is not approved for the private YouTube Studio workspace."})]})]})}function gr(e){return e==="approved"?"border-[#9DB696] bg-[#EEF6EC] text-[#3D6B3A]":e==="changes_requested"?"border-[#D99A8E] bg-[#FBEDE9] text-[#9E2F20]":"border-[#D8D2C8] bg-[#FBFAF7] text-[#756C60]"}function Pe({label:e,status:r,reviewer:s,reviewedAt:i,note:d}){const p=je(r);return t.jsxs("article",{className:`rounded-[3px] border p-2.5 ${gr(r)}`,children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("h5",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.1em]",children:e}),t.jsx("span",{className:"rounded-[2px] border border-current/30 px-1.5 py-0.5 font-mono text-[9px] font-bold uppercase tracking-[0.05em]",children:p})]}),t.jsxs("dl",{className:"mt-2 grid gap-1 text-[10px] leading-relaxed sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("dt",{className:"font-mono uppercase tracking-[0.06em] opacity-70",children:"Reviewer"}),t.jsx("dd",{className:"break-all font-semibold",children:s||"Not recorded"})]}),t.jsxs("div",{children:[t.jsx("dt",{className:"font-mono uppercase tracking-[0.06em] opacity-70",children:"Recorded"}),t.jsx("dd",{children:t.jsx("time",{dateTime:i||void 0,children:M(i)})})]})]}),t.jsx("p",{className:"mt-2 border-t border-current/15 pt-2 text-[10px] leading-relaxed",children:d||"No review note was recorded."})]})}function mr(e){if(String(e.stage||"").trim().toLowerCase()!=="draft"||!String(e.script_draft||"").trim()||Ae(e))return null;const r=String(e.status||"").trim().toLowerCase();return r==="maeesha_approved"?"owner":["","source_ready","generated","changes_requested"].includes(r)?"maeesha":null}function vr(e){return e==="complete"?"Recorded":e==="current"?"Current gate":e==="waiting"?"Waiting":e==="attention"?"Needs attention":"Not connected"}function _r(e){return e==="complete"?"border-[#BBD2B5] bg-[#F5FBF3] text-[#3D6B3A]":e==="attention"?"border-[#
1E4B1A8] bg-[#FFF5F2] text-[#9E2F20]":e==="current"?"border-[#E8D29A] bg-[#FFF9E9] text-[#78520D]":e==="waiting"?"border-[#D8D2C8] bg-white text-[#756C60]":"border-[#D8D2C8] bg-[#F1EEE8] text-[#6D665E]"}function wr(e){const r=z(e,"source"),s=[z(e,"package"),z(e,"maeesha"),z(e,"carl")],i=s.filter(L=>L==="complete").length,p=[H(e),te(e)].includes("changes_requested")?"attention":i===s.length?"complete":s.includes("current")?"current":s.includes("waiting")?"waiting":"unavailable",n=z(e,"voice"),f=Q(e.voiceover_status)==="failed"||Ye(e)&&!De(e)&&Q(e.voiceover_status)!=="generating"?"attention":n,u=[ke(e),!!String(e.final_video_url||"").trim()],g=u.filter(Boolean).length,h=String(e.stage||"").trim().toLowerCase(),_=me(e)==="changes_requested",F=z(e,"render"),C=_?"attention":g===u.length?"complete":["edit","review"].includes(h)&&!ke(e)?"current":g||F==="current"?"waiting":"unavailable",N=z(e,"youtube"),w=["failed","needs_review"].includes(K(e))||Ce(e)&&!Me(e)?"attention":N;return[{label:"Source",state:r,recorded:r==="complete"?1:0,total:1,detail:r==="complete"?"Source material is recorded.":"No source checkpoint is recorded."},{label:"Script & reviews",state:p,recorded:i,total:s.length,detail:`${i} of ${s.length} script and review checkpoints recorded.`},{label:"Voiceover",state:f,recorded:f==="complete"?1:0,total:1,detail:De(e)?"Confirmed audio and status are recorded.":Ye(e)?"A voiceover record exists and needs a clear confirmation.":"No confirmed voiceover is recorded."},{label:"Manual edit",state:C,recorded:g,total:u.length,detail:`${g} of ${u.length} edit checkpoints recorded.`},{label:"YouTube",state:w,recorded:N==="complete"?1:0,total:1,detail:re(e)?"A private or legacy YouTube result is recorded.":Ue(e)||Ce(e)?"A YouTube result or attempt is recorded.":"No YouTube result is recorded."}]}function jr({item:e}){const r=wr(e);return t.jsxs("section",{className:"rounded-[4px] border border-[#D8D2C8] bg-white p-3","aria-labelledby":`recorded-stages-${e.id}`,children:[t.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-end sm:justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.12em] text-[#B5321F]",children:"Recorded stage progress"}),t.jsx("h3",{id:`recorded-stages-${e.id}`,className:"mt-1 text-[15px] font-black text-[#1A1714]",children:"Five operating sections, using the case record."})]}),t.jsx("p",{className:"font-mono text-[9px] uppercase tracking-[0.06em] text-[#756C60]",children:"The detailed rail below remains the audit view."})]}),t.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2 xl:grid-cols-5",children:r.map(s=>{const i=Math.round(s.recorded/s.total*100);return t.jsxs("article",{className:`rounded-[3px] border p-2.5 ${_r(s.state)}`,children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsx("h4",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.08em]",children:s.label}),t.jsx("span",{className:"shrink-0 rounded-[2px] border border-current/25 px-1.5 py-0.5 font-mono text-[8px] font-bold uppercase tracking-[0.04em]",children:vr(s.state)})]}),t.jsx("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-black/10",role:"progressbar","aria-label":`${s.label} recorded progress`,"aria-valuemin":0,"aria-valuemax":s.total,"aria-valuenow":s.recorded,children:t.jsx("div",{className:"h-full rounded-full bg-current transition-[width] duration-500",style:{width:`${i}%`}})}),t.jsxs("p",{className:"mt-1.5 font-mono text-[9px] font-bold uppercase tracking-[0.05em]",children:[s.recorded,"/",s.total," recorded"]}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed opacity-80",children:s.detail})]},s.label)})})]})}function Nr({item:e,draft:r,owner:s,provenanceValid:i,isCopywriter:d,reviewNotes:p,busyKey:n,onDraft:x,onReviewNote:f,onCopy:u,onGenerateScriptDraft:g,onSaveScriptDraft:h,onMediaReview:_,onScriptApprove:F}){var se;const C=!!(n!=null&&n.startsWith(`${e.id}:`)),N=String(e.script_draft||"").trim(),A=String(e.tts_script_draft||"").trim(),w=tr(e,d||s),L=Ae(e),P=!!(String(e.source_content||"").trim()||String(e.source_title||"").trim()),k=!!(N||A),D=!!(r.scriptDraft.trim()||r.ttsScriptDraft.trim()),q=k||w,I=String(e.stage||"").trim().toLowerCase()==="draft"&&!!N&&!L,Z=s&&P&&!k&&!D&&!L,V=n===`${e.id}:generate_script_draft`,b=n===`${e.id}:save_script_draft`,y=n===`${e.id}:media_review`,m=mr(e),_e=m==="owner"?"owner":"maeesha",R=((se=p[e.id])==null?void 0:se[_e])||"",Te=!!e.script_approved_at;return t.jsxs("section",{className:"space-y-3 rounded-[3px] border border-[#D8C9A3] bg-[#FFFCF4] p-3","aria-labelledby":`script-workspace-${e.id}`,children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(ge,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#B5321F]"}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h4",{id:`script-workspace-${e.id}`,className:"font-mono text-[10px] font-bold uppercase tracking-[0.12em] text-[#1A1714]",children:"Script workspace and approval gate"}),t.jsx("span",{className:"rounded-[2px] border border-[#B7C7CE] bg-[#EDF5F7] px-2 py-1 font-mono text-[8px] font-bold uppercase tracking-[0.06em] text-[#2B5871]",children:"Steps 2â4 of 8 · Buildy package and human reviews"})]}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#756C60]",children:"Saved drafts remain editable only before the recorded irreversible gates. The two boxes below are display text and speech text, not finished media."})]})]}),q?t.jsxs("div",{className:"space-y-3 rounded-[3px] border border-[#D8C9A3] bg-[#EDE2C9] p-3",children:[t.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-center sm:justify-between",children:[t.jsx("p",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.1em] text-[#756C60]",children:"Recorded script drafts"}),t.jsx("p",{className:"text-[10px] leading-relaxed text-[#756C60]",children:w?"Edit locally, then save both values together.":"Read-only for this staff account."})]}),t.jsx(B,{id:`script-draft-${e.id}`,label:"Display script draft",value:w?r.scriptDraft:N,onChange:w?S=>x(e.id,"scriptDraft",S):void 0,rows:7,readOnly:!w,helper:N?w?"This editor-facing block will be saved to the case only when you choose Save script draft.":"This is the recorded editor-facing draft. It is not an approval.":"No display script is recorded yet. Add one or use Buildy generation when a real source is available."}),t.jsx(B,{id:`tts-script-draft-${e.id}
1`,label:"TTS script draft",value:w?r.ttsScriptDraft:A,onChange:w?S=>x(e.id,"ttsScriptDraft",S):void 0,rows:7,readOnly:!w,helper:A?w?"This speech-ready block is saved separately. It is text only and does not start audio.":"This speech-ready block is recorded for review. It is not audio and does not start provider work.":"No separate TTS draft is recorded yet."}),w&&D?t.jsxs("button",{type:"button",onClick:()=>h(e),disabled:C||!!n,className:"inline-flex min-h-[44px] w-full items-center justify-center gap-2 rounded-[3px] bg-[#1A1714] px-4 text-[12px] font-bold text-[#E8DCC0] transition hover:bg-[#302923] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] disabled:cursor-not-allowed disabled:opacity-50",children:[b?t.jsx(T,{className:"h-4 w-4 animate-spin"}):t.jsx(J,{className:"h-4 w-4"}),b?"Saving script draft":"Save script draft"]}):w?t.jsx("p",{className:"rounded-[3px] bg-[#FFF4D9] px-3 py-2.5 text-[10px] leading-relaxed text-[#78520D]",children:"Enter at least one draft before saving. Saving keeps the script in review and performs no provider work."}):null]}):Z?t.jsxs("div",{className:"space-y-3 rounded-[3px] border border-[#B7C7CE] bg-[#EDF5F7] p-3",children:[!i&&t.jsxs("p",{className:"rounded-[3px] border border-[#D99A8E] bg-[#FFF5F2] px-3 py-2.5 text-[10px] leading-relaxed text-[#7E2419]",children:[t.jsx("span",{className:"font-bold",children:"Source review required."})," This historical case is missing verified locked provenance, so script generation is disabled."]}),t.jsx("p",{className:"text-[10px] leading-relaxed text-[#2B5871]",children:"No script draft is recorded yet. Buildy can create a source-bound display block and separate TTS block from the supplied source. Drafting does not call ElevenLabs, n8n, or start audio work."}),t.jsxs("button",{type:"button",onClick:()=>g(e),disabled:C||!!n||!i,"aria-label":"Generate Buildy script draft",className:"inline-flex min-h-[44px] w-full items-center justify-center gap-2 rounded-[3px] bg-[#1A1714] px-4 text-[12px] font-bold text-[#E8DCC0] transition hover:bg-[#302923] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] disabled:cursor-not-allowed disabled:opacity-50",children:[V?t.jsx(T,{className:"h-4 w-4 animate-spin"}):t.jsx(ge,{className:"h-4 w-4"}),V?"Generating Buildy script draft":"Generate Buildy script draft"]})]}):!P&&!L&&!k?t.jsx("p",{className:"rounded-[3px] bg-[#F1EADB] px-3 py-2.5 text-[10px] leading-relaxed text-[#756C60]",children:"Add source content or a source title before generating a Buildy script draft. Buildy will not invent one."}):!L&&!k?t.jsx("p",{className:"rounded-[3px] bg-[#F1EADB] px-3 py-2.5 text-[10px] leading-relaxed text-[#756C60]",children:"A verified Carl owner can generate the Buildy script draft from the recorded source."}):null,t.jsxs("section",{className:"space-y-3 rounded-[3px] border border-[#B7C7CE] bg-[#EDF5F7] p-3","aria-labelledby":`script-reviews-${e.id}`,children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(ye,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#2B5871]"}),t.jsxs("div",{children:[t.jsx("h5",{id:`script-reviews-${e.id}`,className:"font-mono text-[10px] font-bold uppercase tracking-[0.1em] text-[#1A1714]",children:"Latest script review decisions"}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#4F4941]",children:"These are the latest recorded snapshots. Saving a review does not approve the final script or start provider work."})]})]}),t.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[t.jsx(Pe,{label:"Copywriter script review",status:H(e),reviewer:Zt(e),reviewedAt:$e(e),note:Qt(e)}),t.jsx(Pe,{label:"Carl script review",status:te(e),reviewer:Xt(e),reviewedAt:Le(e),note:Jt(e)})]}),m==="maeesha"?d?t.jsxs("div",{className:"space-y-3 rounded-[3px] border border-[#D8B66B] bg-[#FFF4D9] p-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-bold text-[11px] text-[#78520D]",children:"Copywriter review is the current script gate."}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#78520D]",children:"Approval note is optional. Request changes requires a short reason, up to 500 characters."})]}),t.jsx(B,{id:`maeesha-review-note-${e.id}`,label:"Copywriter review note",value:R,onChange:S=>f(e.id,"maeesha",S),rows:3,maxLength:500,placeholder:"Add a short review note",helper:`${R.length}/500 characters`}),t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsxs("button",{type:"button",onClick:()=>_(e,"script","approve"),disabled:C||!!n,className:"inline-flex min-h-[44px] flex-1 items-center justify-center gap-2 rounded-[3px] bg-[#3D6B3A] px-3 text-[11px] font-bold text-white transition hover:bg-[#31562F] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#3D6B3A] disabled:cursor-not-allowed disabled:opacity-50",children:[y?t.jsx(T,{className:"h-4 w-4 animate-spin"}):t.jsx(J,{className:"h-4 w-4"}),"Approve script review"]}),t.jsxs("button",{type:"button",onClick:()=>_(e,"script","request_changes"),disabled:C||!!n,className:"inline-flex min-h-[44px] flex-1 items-center justify-center gap-2 rounded-[3px] border border-[#B5321F] bg-white px-3 text-[11px] font-bold text-[#8E2D20] transition hover:bg-[#FFF8F6] focu
1s-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] disabled:cursor-not-allowed disabled:opacity-50",children:[y?t.jsx(T,{className:"h-4 w-4 animate-spin"}):t.jsx(Y,{className:"h-4 w-4"}),"Request changes"]})]})]}):t.jsx("p",{className:"rounded-[3px] bg-white/70 px-3 py-2.5 text-[10px] leading-relaxed text-[#4F4941]",children:"The copywriter review is waiting. Saved review details are read-only for this staff account."}):m==="owner"?s?t.jsxs("div",{className:"space-y-3 rounded-[3px] border border-[#D8B66B] bg-[#FFF4D9] p-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-bold text-[11px] text-[#78520D]",children:"Carl owner review is the current script gate."}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#78520D]",children:"Use Request changes for a short reason, up to 500 characters. The existing Approve script action below remains separate."})]}),t.jsx(B,{id:`owner-review-note-${e.id}`,label:"Carl review note",value:R,onChange:S=>f(e.id,"owner",S),rows:3,maxLength:500,placeholder:"Explain the script change needed",helper:`${R.length}/500 characters`}),t.jsxs("button",{type:"button",onClick:()=>_(e,"script","request_changes"),disabled:C||!!n,className:"inline-flex min-h-[44px] w-full items-center justify-center gap-2 rounded-[3px] border border-[#B5321F] bg-white px-3 text-[11px] font-bold text-[#8E2D20] transition hover:bg-[#FFF8F6] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] disabled:cursor-not-allowed disabled:opacity-50",children:[y?t.jsx(T,{className:"h-4 w-4 animate-spin"}):t.jsx(Y,{className:"h-4 w-4"}),"Request script changes"]})]}):t.jsx("p",{className:"rounded-[3px] bg-white/70 px-3 py-2.5 text-[10px] leading-relaxed text-[#4F4941]",children:"Carl owner review is waiting. Saved review details are read-only for this staff account."}):t.jsx("p",{className:"rounded-[3px] bg-white/70 px-3 py-2.5 text-[10px] leading-relaxed text-[#4F4941]",children:"No new script review action is available at this media stage."})]}),Te?t.jsxs("div",{className:"rounded-[3px] border border-[#9DB696] bg-[#EEF6EC] p-2.5 text-[10px] leading-relaxed text-[#3D6B3A]",children:[t.jsxs("p",{className:"font-bold",children:["Script approved by ",e.script_approved_by_email||"approved owner"]}),t.jsxs("p",{className:"mt-1",children:[M(e.script_approved_at),". Voiceover generation is a separate owner action. Choose ElevenLabs below or continue with the legacy n8n callback."]})]}):I&&s?t.jsxs("div",{className:"space-y-3 border-t border-[#E0D5B9] pt-3",children:[t.jsx(B,{id:`final-display-script-${e.id}`,label:"Final display script, edit before approving",value:r.finalDisplayScript,onChange:S=>x(e.id,"finalDisplayScript",S),rows:8,helper:A?"This owner-edited block is stored for the case display.":"This legacy case has no separate TTS draft. Copying the display draft gives the final speech field a safe fallback."}),t.jsx(B,{id:`final-script-${e.id}`,label:"Final TTS script, edit before approving",value:r.finalScript,onChange:S=>x(e.id,"finalScript",S),rows:8,helper:A?"This owner-edited speech text is stored for the later voiceover action. Approval does not generate audio.":"Use the display draft as the safe TTS fallback, or edit this speech text yourself. Approval does not generate audio."}),t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsxs("button",{type:"button",onClick:()=>u(e),disabled:C||!!n,className:"inline-flex min-h-[40px] flex-1 items-center justify-center gap-2 rounded-[3px] border border-[#C9B889] bg-[#F4EFE2] px-3 text-[11px] font-bold text-[#5F584F] transition hover:bg-white disabled:opacity-50",children:[t.jsx($t,{className:"h-4 w-4"}),A?"Copy drafts into final fields":"Copy display draft into both final fields"]}),t.jsx(B,{id:`voice-id-${e.id}`,label:"Voice ID, optional during approval",value:r.voiceId,onChange:S=>x(e.id,"voiceId",S),helper:"Optional here. Saving a voice ID is separate from script approval and does not start audio. You can save or replace it in the direct voice panel below."})]}),t.jsxs("button",{type:"button",onClick:()=>F(e),disabled:C||!!n,className:"inline-flex min-h-[44px] w-full items-center justify-center gap-2 rounded-[3px] bg-[#B5321F] px-4 text-[12px] font-bold text-white transition hover:bg-[#8E2D20] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] disabled:cursor-not-allowed disabled:opacity-50",children:[n===`${e.id}:script_approve`?t.jsx(T,{className:"h-4 w-4 animate-spin"}):t.jsx(ye,{className:"h-4 w-4"}),"Approve script"]})]}):I?t.jsx("p",{className:"text-[10px] leading-relaxed text-[#756C60]",children:"Only an approved Carl owner can edit the final script and record owner approval."}):L?t.jsx("p",{className:"text-[10px] leading-relaxed text-[#756C60]",children:"Script content or approval is already recorded. Refresh the case before making another draft."}):k?t.jsx("p",{className:"text-[10px] leading-relaxed text-[#756C60]",children:"The script approval gate is not available at this media stage."}):null]})}function yr({item:e,owner:r,reviewNotes:s,busyKey:i,onReviewNote:d,onMediaReview:p}){var u;const n=rr(e,r),x=((u=s[e.id])==null?void 0:u.edit)||"",f=i===`${e.id}:media_review`;return t.jsxs("section",{className:"space-y-3 rounded-[3px] border border-[#B7C7CE] bg-[#EDF5F7] p-3","aria-labelledby":`edit-reviews-${e.id}`,children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Fe,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#2B5871]"}),t.jsxs("div",{children:[t.jsx("h5",{id:`edit-reviews-${e.id}`,className:"font-mono text-[10px] font-bold uppercase tracking-[0.1em] text-[#1A1714]",children:"Latest final-edit review"}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#4F4941]",children:"The snapshot below records only the latest Carl request. It does not approve, render, upload, schedule, or publish the video."})]})]}),t.jsx(Pe,{label:"Carl final-edit review",status:me(e),reviewer:er(e),reviewedAt:Ie(e),note:Kt(e)}
1),n?t.jsxs("div",{className:"space-y-3 rounded-[3px] border border-[#D8B66B] bg-[#FFF4D9] p-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"font-bold text-[11px] text-[#78520D]",children:"Carl can request final-edit changes before approval."}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#78520D]",children:"Request changes requires a short reason, up to 500 characters. The approval action below remains unchanged."})]}),t.jsx(B,{id:`edit-review-note-${e.id}`,label:"Final-edit change note",value:x,onChange:g=>d(e.id,"edit",g),rows:3,maxLength:500,placeholder:"Explain the edit change needed",helper:`${x.length}/500 characters`}),t.jsxs("button",{type:"button",onClick:()=>p(e,"edit","request_changes"),disabled:!!(i!=null&&i.startsWith(`${e.id}:`))||!!i,className:"inline-flex min-h-[44px] w-full items-center justify-center gap-2 rounded-[3px] border border-[#B5321F] bg-white px-3 text-[11px] font-bold text-[#8E2D20] transition hover:bg-[#FFF8F6] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] disabled:cursor-not-allowed disabled:opacity-50",children:[f?t.jsx(T,{className:"h-4 w-4 animate-spin"}):t.jsx(Y,{className:"h-4 w-4"}),"Request final-edit changes"]})]}):r?t.jsx("p",{className:"rounded-[3px] bg-white/70 px-3 py-2.5 text-[10px] leading-relaxed text-[#4F4941]",children:"Final-edit changes are locked after approval or a recorded provider attempt. Review the existing edit gate below."}):t.jsx("p",{className:"rounded-[3px] bg-white/70 px-3 py-2.5 text-[10px] leading-relaxed text-[#4F4941]",children:"Only an approved Carl owner can request final-edit changes before the irreversible gate."})]})}function Fr({item:e,owner:r,provenanceValid:s,busy:i,busyKey:d,onUpload:p}){const n=K(e),x=xe(e.direct_youtube_video_id),f=n==="uploaded_private"&&!!x&&!!e.direct_youtube_completed_at,u=n==="needs_review"||n==="uploaded_private"&&(!x||!e.direct_youtube_completed_at)||n==="failed"&&!!x,g=n==="failed"&&!x,h=!!(e.youtube_video_id||e.youtube_status);return t.jsxs("section",{className:"space-y-3 rounded-[3px] border border-[#B7C7CE] bg-[#EDF5F7] p-3","aria-labelledby":`direct-youtube-${e.id}`,children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(pe,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#B5321F]"}),t.jsxs("div",{children:[t.jsx("h4",{id:`direct-youtube-${e.id}`,className:"font-mono text-[10px] font-bold uppercase tracking-[0.12em] text-[#1A1714]",children:"Direct private YouTube upload"}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#4F4941]",children:"A separate one-video test using the approved MP4 and stored metadata. It sets visibility to private and never schedules or publishes."})]})]}),f?t.jsxs("div",{className:"space-y-2 rounded-[3px] border border-[#9DB696] bg-[#EEF6EC] p-2.5 text-[10px] leading-relaxed text-[#3D6B3A]",children:[t.jsx("p",{className:"font-bold",children:"YouTube confirmed a private video."}),t.jsx("p",{children:"The provider returned a real video id. This upload was not scheduled or published."}),t.jsxs("dl",{className:"grid gap-2 sm:grid-cols-3",children:[t.jsx(E,{label:"Video id",value:x||"Not recorded"}),t.jsx(E,{label:"Direct status",value:"Uploaded privately"}),t.jsx(E,{label:"Completed",value:M(e.direct_youtube_completed_at)})]}),t.jsxs("a",{href:`https://studio.youtube.com/video/${x}/edit`,target:"_blank",rel:"noreferrer",className:"inline-flex min-h-[36px] items-center gap-1.5 rounded-[3px] border border-[#9DB696] bg-white px-3 text-[11px] font-bold text-[#3D6B3A] underline-offset-2 transition hover:bg-[#F7FFF5] hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#3D6B3A]",children:["Open in YouTube Studio ",t.jsx(Ne,{className:"h-3.5 w-3.5"})]})]}):n==="uploading"?t.jsxs("div",{className:"flex items-start gap-2 rounded-[3px] border border-[#D8B66B] bg-[#FFF4D9] p-2.5 text-[10px] leading-relaxed text-[#78520D]",children:[t.jsx(T,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 animate-spin"}),t.jsxs("p",{children:[t.jsx("span",{className:"font-bold",children:"Private upload is in progress."})," Attempt started ",M(e.direct_youtube_attempted_at),". Do not start a second attempt while YouTube is still being checked."]})]}):u?t.jsxs("div",{className:"flex items-start gap-2 rounded-[3px] border border-[#D99A8E] bg-[#FBEDE9] p-2.5 text-[10px] leading-relaxed text-[#7E2419]",children:[t.jsx(Y,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-bold",children:"Private upload needs review."}),t.jsx("p",{className:"mt-1",children:"YouTube did not provide an unambiguou
1s result. Review YouTube Studio before any retry. This panel will not retry an ambiguous attempt."}),e.direct_youtube_error&&t.jsxs("p",{className:"mt-1",children:["Provider note: ",e.direct_youtube_error]})]})]}):n==="failed"?t.jsxs("div",{className:"space-y-2 rounded-[3px] border border-[#D99A8E] bg-[#FBEDE9] p-2.5 text-[10px] leading-relaxed text-[#7E2419]",children:[t.jsx("p",{className:"font-bold",children:"Private upload failed, with no video id recorded."}),e.direct_youtube_error&&t.jsx("p",{children:e.direct_youtube_error}),g&&r&&e.edit_approved_at?t.jsxs("button",{type:"button",onClick:()=>p(e),disabled:i||!!d||!s,className:"inline-flex min-h-[40px] items-center justify-center gap-2 rounded-[3px] bg-[#B5321F] px-3 text-[11px] font-bold text-white transition hover:bg-[#8E2D20] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] disabled:cursor-not-allowed disabled:opacity-50",children:[d===`${e.id}:upload_youtube_private`?t.jsx(T,{className:"h-4 w-4 animate-spin"}):t.jsx(qe,{className:"h-4 w-4"}),"Retry confirmed failure"]}):t.jsx("p",{children:"A verified Carl owner can retry only this confirmed failure."})]}):h?t.jsxs("div",{className:"flex items-start gap-2 rounded-[3px] border border-[#D8B66B] bg-[#FFF4D9] p-2.5 text-[10px] leading-relaxed text-[#78520D]",children:[t.jsx(Y,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),t.jsx("p",{children:"A legacy n8n YouTube result is already recorded. Review the separate legacy status below instead of starting a duplicate private upload."})]}):e.edit_approved_at?r?t.jsxs("div",{className:"space-y-2 rounded-[3px] border border-[#B7C7CE] bg-white/60 p-2.5 text-[10px] leading-relaxed text-[#2B5871]",children:[t.jsx("p",{className:"font-bold",children:"Ready for the approved private upload."}),t.jsx("p",{children:s?"Buildy will load the stored final MP4, title, description, tags, and metadata on the server. Your browser sends the case id only.":"Source review required. This historical case has incomplete locked provenance, so private upload is disabled until a new verified case is created."}),t.jsxs("button",{type:"button",onClick:()=>p(e),disabled:i||!!d||!s,className:"inline-flex min-h-[44px] w-full items-center justify-center gap-2 rounded-[3px] bg-[#1A1714] px-4 text-[12px] font-bold text-[#E8DCC0] transition hover:bg-[#302923] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] disabled:cursor-not-allowed disabled:opacity-50",children:[d===`${e.id}:upload_youtube_private`?t.jsx(T,{className:"h-4 w-4 animate-spin"}):t.jsx(pe,{className:"h-4 w-4"}),"Upload approved video privately"]})]}):t.jsx("div",{className:"rounded-[3px] bg-[#F4EFE2] p-2.5 text-[10px] leading-relaxed text-[#5F584F]",children:"The private upload can be started only by an approved Carl owner after final edit approval."}):t.jsx("div",{className:"rounded-[3px] bg-[#F4EFE2] p-2.5 text-[10px] leading-relaxed text-[#5F584F]",children:"Final Descript edit approval is required before the private YouTube test can start."})]})}function Cr({item:e,owner:r,provenanceValid:s,busy:i,busyKey:d,draftVoiceId:p,onVoiceIdChange:n,onSaveVoiceId:x,onGenerate:f}){var Z;const u=Q(e.voiceover_status),g=String(e.voice_id||"").trim(),h=He(e),_=!!String(e.voiceover_url||"").trim(),F=!!(h&&fe.has(u)),C=u==="generating"||_||fe.has(u),N=d===`${e.id}:generate_voiceover`,A=u==="generating"||N,w=u==="failed"&&e.last_action==="generate_voiceover",L=!!e.script_approved_at&&!!g,P=r&&L&&!A&&!F&&!_&&(!u||u==="failed"),k=e.n8n_last_event==="voiceover_ready"?"Voiceover ready":e.n8n_last_event||"No callback",D=e.last_action==="generate_voiceover"&&e.last_action_note?e.last_action_note:"The last voiceover attempt did not confirm usable audio.",q=s?e.script_approved_at?g?"Only an approved Carl owner can start this separate voice action.":"Voice generation is unavailable. Save the ElevenLabs voice ID above before generating voiceover. This panel never invents a voice ID.":"Approve the final script first. Direct voice generation stays locked until the owner approval is recorded.":"Source review is required. This historical case has incomplete locked provenance, so voiceover generation is disabled.",I=P?t.jsxs("button",{type:"button",onClick:()=>
1f(e),disabled:i||!!d||!s,className:"inline-flex min-h-[44px] w-full items-center justify-center gap-2 rounded-[3px] bg-[#1A1714] px-4 text-[12px] font-bold text-[#E8DCC0] transition hover:bg-[#302923] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] disabled:cursor-not-allowed disabled:opacity-50","aria-label":w?"Retry confirmed Coach Carl voiceover generation":"Generate Coach Carl voiceover",children:[N?t.jsx(T,{className:"h-4 w-4 animate-spin"}):w?t.jsx(qe,{className:"h-4 w-4"}):t.jsx(we,{className:"h-4 w-4"}),N?"Generating voiceover":w?"Retry confirmed voiceover generation":"Generate Coach Carl voiceover"]}):null;return t.jsxs("section",{className:"space-y-3 rounded-[3px] border border-[#D8C9A3] bg-[#FFFCF4] p-3","aria-labelledby":`voiceover-${e.id}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(we,{className:"h-4 w-4 text-[#B5321F]"}),t.jsxs("div",{children:[t.jsx("h4",{id:`voiceover-${e.id}`,className:"font-mono text-[10px] font-bold uppercase tracking-[0.12em] text-[#1A1714]",children:"Voiceover and B-roll handoff"}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#756C60]",children:"The legacy n8n path remains available below. Direct ElevenLabs generation is a separate owner action, and Descript editing stays manual."})]})]}),t.jsxs("section",{className:"space-y-3 rounded-[3px] border border-[#D8C9A3] bg-[#EDE2C9] p-3","aria-labelledby":`legacy-voiceover-${e.id}`,children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Re,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#B5321F]"}),t.jsxs("div",{children:[t.jsx("h5",{id:`legacy-voiceover-${e.id}`,className:"font-mono text-[10px] font-bold uppercase tracking-[0.1em] text-[#1A1714]",children:"Legacy n8n provider handoff"}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#5F584F]",children:"n8n callbacks can still report voiceover readiness and a provider audio link. This path is separate from the direct owner action and never makes Descript editing automatic."})]})]}),t.jsxs("dl",{className:"grid gap-2 sm:grid-cols-2",children:[t.jsx(E,{label:"Callback",value:k,detail:e.n8n_last_event_at?M(e.n8n_last_event_at):void 0}),t.jsx(E,{label:"Stored status",value:tt(u),detail:F?"Confirmed audio is available below.":"No confirmed managed audio from this callback."})]}),e.n8n_last_event==="voiceover_ready"?t.jsxs("p",{className:"flex items-start gap-2 rounded-[3px] bg-[#FFF4D9] px-3 py-2.5 text-[10px] leading-relaxed text-[#78520D]",children:[t.jsx(Ve,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),"n8n reported voiceover readiness. Review the recorded audio and keep the Descript and B-roll steps manual."]}):t.jsx("p",{className:"text-[10px] leading-relaxed text-[#756C60]",children:"No n8n voiceover-ready callback is recorded. You can use the direct owner action when its prerequisites are present."}),(Z=e.broll_checklist)!=null&&Z.length?t.jsxs("div",{children:[t.jsx("p",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.1em] text-[#756C60]",children:"Manual B-roll checklist"}),t.jsx("ul",{className:"mt-2 space-y-1.5 text-[11px] leading-relaxed text-[#3F3933]",children:e.broll_checklist.map((V,b)=>t.jsxs("li",{className:"flex items-start gap-2",children:[t.jsx(ot,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[#3D6B3A]"}),V]},`${e.id}-broll-${b}`))})]}):t.jsx("p",{className:"text-[10px] leading-relaxed text-[#756C60]",children:"B-roll checklist not recorded. The Descript edit remains a manual step."})]}),t.jsxs("section",{className:"space-y-3 rounded-[3px] border border-[#B7C7CE] bg-[#EDF5F7] p-3","aria-labelledby":`direct-voiceover-${e.id}`,children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(we,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#2B5871]"}),t.jsxs("div",{children:[t.jsx("h5",{id:`direct-voiceover-${e.id}`,className:"font-mono text-[10px] font-bold uppercase tracking-[0.1em] text-[#1A1714]",children:"Direct owner-approved ElevenLabs voice"}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#4F4941]",children:"This separate action sends the approved final script to ElevenLabs and stores audio only after the provider and managed storage confirm it. It does not render or edit video, create B-roll, schedule or publish, upload to YouTube, or send n8n work."})]})]}),t.jsxs("dl",{className:"grid gap-2 sm:grid-cols-2",children:[t.jsx(E,{label:"Stored voice id",value:g||"Not supplied",detail
1:g?"Stored for the separate owner voice action.":"Set by an approved owner before voiceover generation."}),t.jsx(E,{label:"Direct status",value:tt(u)})]}),r&&C?t.jsxs("div",{className:"flex items-start gap-2 rounded-[3px] border border-[#D99A8E] bg-[#FBEDE9] p-2.5 text-[10px] leading-relaxed text-[#7E2419]",children:[t.jsx(Ee,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),t.jsxs("p",{children:[t.jsx("span",{className:"font-bold",children:"Voice ID locked."})," This ID cannot be changed after voiceover generation starts or a voiceover record is stored. Buildy will not retarget a completed or ambiguous run."]})]}):r?t.jsxs("div",{className:"space-y-2 rounded-[3px] border border-[#B7C7CE] bg-white/60 p-2.5",children:[t.jsx(B,{id:`direct-voice-id-${e.id}`,label:"ElevenLabs voice ID",value:p,onChange:n,placeholder:"Your approved provider voice ID",helper:"Saving this ID is separate from script approval and does not start audio. You can replace it before voiceover begins."}),t.jsxs("button",{type:"button",onClick:()=>x(e),disabled:i||!!d||C||!p.trim()||p.trim()===g,className:"inline-flex min-h-[44px] w-full items-center justify-center gap-2 rounded-[3px] bg-[#1A1714] px-4 text-[12px] font-bold text-[#E8DCC0] transition hover:bg-[#302923] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] disabled:cursor-not-allowed disabled:opacity-50",children:[d===`${e.id}:update_voice_id`?t.jsx(T,{className:"h-4 w-4 animate-spin"}):t.jsx(J,{className:"h-4 w-4"}),"Save voice ID"]})]}):null,F?t.jsxs("div",{className:"space-y-3 rounded-[3px] border border-[#9DB696] bg-[#EEF6EC] p-2.5 text-[10px] leading-relaxed text-[#3D6B3A]",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(J,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-bold",children:"Stored voiceover confirmed."}),t.jsxs("p",{className:"mt-1",children:[e.last_action==="generate_voiceover"?"ElevenLabs and managed storage confirmed this recording.":"A successful voiceover status and audio link are recorded."," Descript editing and B-roll remain manual."]})]})]}),t.jsx("audio",{controls:!0,preload:"metadata",src:h||void 0,className:"w-full","aria-label":`Recorded Coach Carl voiceover for ${e.source_title||"this case"}`,children:"Your browser does not support audio playback. Use the link below."}),t.jsxs("a",{href:h||void 0,target:"_blank",rel:"noreferrer",className:"inline-flex min-h-[36px] items-center gap-1.5 rounded-[3px] border border-[#9DB696] bg-white px-3 text-[11px] font-bold text-[#3D6B3A] underline-offset-2 transition hover:bg-[#F7FFF5] hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#3D6B3A]",children:["Open recorded voiceover ",t.jsx(Ne,{className:"h-3.5 w-3.5"})]})]}):A?t.jsxs("div",{className:"flex items-start gap-2 rounded-[3px] border border-[#D8B66B] bg-[#FFF4D9] p-2.5 text-[10px] leading-relaxed text-[#78520D]",role:"status","aria-live":"polite",children:[t.jsx(T,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 animate-spin"}),t.jsxs("p",{children:[t.jsx("span",{className:"font-bold",children:"Voiceover generation is in progress."})," Buildy is waiting for confirmed ElevenLabs audio and managed storage. Keep this case open and do not start another attempt."]})]}):u==="failed"&&!_?t.jsxs("div",{className:"space-y-2 rounded-[3px] border border-[#D99A8E] bg-[#FBEDE9] p-2.5 text-[10px] leading-relaxed text-[#7E2419]",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(Y,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-bold",children:"Voiceover generation needs attention."}),t.jsx("p",{className:"mt-1",children:D})]})]}),I||t.jsx("p",{className:"text-[10px]",children:q})]}):_||u&&fe.has(u)?t.jsxs("div",{className:"flex items-start gap-2 rounded-[3px] border border-[#D8B66B] bg-[#FFF4D9] p-2.5 text-[10px] leading-relaxed text-[#78520D]",children:[t.jsx(Y,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),t.jsxs("p",{children:[t.jsx("span",{className:"font-bold",children:"Voiceover record needs review."})," A stored link or success status exists without both confirmations needed for playback. Buildy will not present it as complete or start a duplicate."]})]}):e.script_approved_at?g?r?t.jsxs("div",{className:"space-y-2 rounded-[3px] border border-[#B7C7CE] bg-white/60 p-2.5 text-[10px] leading-relaxed text-[#2B5871]",children:[t.jsx("p",{className:"font-bold",children:s?"Voiceover is idle and ready for the separate owner action.":"Source review required before voiceover generation."}),t.jsx("p",{children:s?"Script approval and a stored ElevenLabs voice id are present. Audio will appear here only after provider and storage confirmation.":"This historical case has incomplete locked provenance. Create a new verified case before starting voiceover."}),I]}):t.jsx("p",{className:"rounded-[3px] bg-[#F4EFE2] p-2.5 text-[10px] leading-relaxed text-[#5F584F]",children:q}):t.jsx("p",{className:"rounded-[3px] bg-[#F4EFE2] p-2.5 text-[10px] leading-relaxed text-[#5F584F]",children:q}):t.jsx("p",{className:"rounded-[3px] bg-[#F4EFE2] p-2.5 text-[10px] leading-relaxed text-[#5F584F]",children:q})]})]})}function kr({item:e,draft:r,owner:s,isCopywriter:i,provenanceValid:d,reviewNotes:p,n8nConfigured:n,busyKey:x,onDraft:f,onReviewNote:u,onCopy:g,onGenerateScriptDraft:h,onSaveScriptDraft:_,onMediaReview:F,onScriptApprove:C,onEditApprove:N,onDispatch:A,onUploadPrivate:w,onGenerateVoiceover:L,onSaveVoiceId:P}){const k=e.package_slug||e.id,D=!!(x!=null&&x.startsWith(`${e.id}:`)),q=e.n8n_dispatch_status||"not_sent",I=pt(e),Z=["edit","review"].includes(e.stage||"")&&!e.edit_approved_at,V=!!e.edit_approved_at,b=d&&ze(e);return t.jsxs("article",{className:"overflow-hidden rounded-[4px] border border-[#D8C9A3] border-l-4 border-l-[#B5321F] bg-[#F4EFE2] shadow-[0_1px_0_rgba(26,23,20,0.05)]",children:[t.jsxs("header",{className:"flex flex-col gap-3 border-b border-[#
1E0D5B9] p-3.5 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"font-mono text-[10px] font-bold uppercase tracking-[0.14em] text-[#B5321F]",children:"YouTube case"}),t.jsx("span",{className:`rounded-[2px] border px-2 py-0.5 font-mono text-[10px] font-bold uppercase tracking-[0.05em] ${Wt(e.status)}`,children:ct(e.status)}),t.jsx("span",{className:"rounded-[2px] border border-[#C9B889] bg-[#FFFCF4] px-2 py-0.5 font-mono text-[10px] font-bold uppercase tracking-[0.05em] text-[#5F584F]",children:e.track||"Track not recorded"})]}),t.jsx("h3",{className:"mt-2 text-[16px] font-black leading-tight text-[#1A1714]",children:e.source_title||"Untitled source case"}),t.jsxs("p",{className:"mt-1 break-all font-mono text-[10px] text-[#756C60]",children:[k," · case id ",e.id]})]}),t.jsx("div",{className:"shrink-0 rounded-[2px] border-2 border-[#B5321F] px-2 py-1 text-center font-mono text-[9px] font-bold uppercase tracking-[0.12em] text-[#B5321F] [transform:rotate(-4deg)]",children:"Private"})]}),t.jsxs("div",{className:"space-y-3 p-3.5",children:[e.source_url?t.jsxs("a",{href:e.source_url,target:"_blank",rel:"noreferrer",className:"inline-flex min-h-[36px] items-center gap-1.5 rounded-[3px] border border-[#C9B889] bg-[#FFFCF4] px-3 text-[11px] font-bold text-[#8E2D20] underline-offset-2 transition hover:bg-white hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] focus-visible:ring-offset-2 focus-visible:ring-offset-[#F4EFE2]",children:["Open recorded source ",t.jsx(Ne,{className:"h-3.5 w-3.5"})]}):t.jsx("p",{className:"font-mono text-[10px] text-[#756C60]",children:"Source link not recorded. This case uses the submitted source content."}),e.source_content?t.jsxs("details",{className:"rounded-[3px] border border-[#E0D5B9] bg-[#FFFCF4] p-3",children:[t.jsx("summary",{className:"cursor-pointer font-mono text-[10px] font-bold uppercase tracking-[0.1em] text-[#5F584F]",children:"Read submitted source content"}),t.jsx("p",{className:"mt-2 whitespace-pre-wrap text-[12px] leading-relaxed text-[#3F3933]",children:e.source_content})]}):t.jsx("p",{className:"rounded-[3px] bg-[#F1EADB] px-3 py-2 text-[10px] text-[#756C60]",children:"Source content was not recorded on this legacy package."}),t.jsxs("section",{className:"space-y-3 rounded-[3px] border border-[#D8C9A3] bg-[#EDE2C9] p-3","aria-labelledby":`media-${e.id}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Fe,{className:"h-4 w-4 text-[#B5321F]"}),t.jsx("h4",{id:`media-${e.id}`,className:"font-mono text-[10px] font-bold uppercase tracking-[0.12em] text-[#1A1714]",children:"Media pipeline"})]}),t.jsxs("dl",{className:"grid gap-2 sm:grid-cols-3",children:[t.jsx(E,{label:"Stage",value:Ge(e.stage)}),t.jsx(E,{label:"Track",value:e.track||"Not recorded"}),t.jsx(E,{label:"Buildy â n8n",value:zt(q),detail:e.n8n_last_dispatch_event?`${e.n8n_last_dispatch_event} · ${M(e.n8n_last_dispatch_at)}`:void 0})]}),q==="sent"?t.jsxs("p",{className:"flex items-start gap-2 rounded-[3px] bg-[#EEF6EC] px-3 py-2.5 text-[10px] leading-relaxed text-[#3D6B3A]",children:[t.jsx(J,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),"The request reached n8n. Voiceover, editing, rendering, upload, scheduling, and publishing remain pending callbacks."]}):t.jsxs("p",{className:"flex items-start gap-2 rounded-[3px] bg-[#FFF4D9] px-3 py-2.5 text-[10px] leading-relaxed text-[#78520D]",children:[t.jsx(Ve,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),n?"The next handoff can be sent when the case is ready. Buildy will wait for a truthful callback.":"Outbound workflow work is waiting for the n8n production address. No provider work has started."]}),e.n8n_dispatch_error&&t.jsxs("p",{className:"rounded-[3px] border border-[#D99A8E] bg-[#FBEDE9] px-3 py-2 text-[10px] leading-relaxed text-[#7E2419]",children:["Last delivery note: ",e.n8n_dispatch_error]}),I&&s&&t.jsxs("div",{className:"flex flex-col gap-2 rounded-[3px] border border-[#C9B889] bg-[#FFFCF4] p-2.5 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("p",{className:"text-[10px] leading-relaxed text-[#5F584F]",children:["Send the recorded ",t.jsx("span",{className:"font-bold",children:I})," handoff again. ",n?"The server will validate the current approval first.":"It will remain pending until the secure n8n address is configured."]}),t.jsxs("button",{type:"button",onClick:()=>A(e),disabled:D||!!x,className:"inline-flex min-h-[40px] shrink-0 items-center justify-center gap-2 rounded-[3px] bg-[#1A1714] px-3 text-[11px] font-bold text-[#E8DCC0] transition hover:bg-[#302923] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] disabled:cursor-not-allowed disabled:opacity-50",children:[x===`${e.id}:dispatch_n8n`?t.jsx(T,{className:"h-4 w-4 animate-spin"}):t.jsx(Rt,{className:"h-4 w-4"}),"Send to n8n"]})]})]}),t.jsx(Nr,{item:e,draft:r,owner:s,provenanceValid:b,isCopywriter:i,reviewNotes:p,busyKey:x,onDraft:f,onReviewNote:u,onCopy:g,onGenerateScriptDraft:h,onSaveScriptDraft:_,onMediaReview:F,onScriptApprove:C}),t.jsx(Cr,{item:e,owner:s,provenanceValid:b,busy:D,busyKey:x,draftVoiceId:r.voiceId,onVoiceIdChange:y=>f(e.id,"voiceId",y),onSaveVoiceId:P,onGenerate:L}),t.jsx(yr,{item:e,owner:s,reviewNotes:p,busyKey:x,onReviewNote:u,onMediaReview:F}),t.jsxs("section",{className:"space-y-3 rounded-[3px] border border-[#D8C9A3] bg-[#FFFCF4] p-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Fe,{className:"h-4 w-4 text-[#B5321F]"}),t.jsx("h4",{className:"font-mono text-[10px] font-bold uppercase tracking-[0.12em] text-[#1A1714]",children:"Final Descript edit approval"})]}),V?t.jsxs("div",{className:"space-y-2 rounded-[3px] border border-[#9DB696] bg-[#EEF6EC] p-2.5 text-[10px] leading-relaxed text-[#3D6B3A]",children:[t.jsxs("p",{className:"font-bold",children:["Edit approved by ",e.edit_approved_by_email||"approved owner"]}),t.jsxs("p",{children:[M(e.edit_approved_at),". The case remains in final review until n8n reports a later provider status."]}),e.final_video_url&&t.jsxs("a",{href:e.final_video_url,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 font-bold underline underline-offset-2",children:["Open approved MP4 ",t.jsx(Ne,{className:"h-3 w-3"})]})]}):Z&&s?t.jsxs("div",{className:"space-y-3",children:[t.jsx(B,{id:`final-video-${e.id}`,label:"Final MP4 or Drive URL",value:r.finalVideoUrl,onChange:y=>f(e.id,"finalVideoUrl",y),placeholder:"https://...",helper:"Use the real final file URL. Buildy checks that it is a secure external address."}),t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.jsx(B,{id:`youtube-title-${e.id}`,label:"YouTube title",value:r.title,onChange:y=>f(e.id,"title",y)}),t.jsx(B,{id:`publish-at-${e.id}`,label:"Requested publish date and time",type:"datetime-local",value:r.publishAt,onChange:y=>f(e.id,"publishAt",y)})]}),t.jsx(B,{id:`youtube-description-${e.id}`,label:"YouTube description",value:r.description,onChange:y=>f(e.id,"description",y),rows:6}),t.jsx(B,{id:`youtube-tags-${e.id}`,label:"YouTube tags, separated by commas or new lines",value:r.tags,onChange:y=>f(e.id,"tags",y),helper:"Keep the tag list focused. The server caps length and item count."}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:`edit-track-${e.id}`,className:"font-mono text-[9px] font-bold uppercase tracking-[0.1em] text-[#756C60]",children:"Production track"}),t.jsxs("select",{id:`edit-track-${e.id}`,value:r.track,onChange:y=>f(e.id,"track",y.target.value),className:"mt-1 h-11 w-full rounded-[3px] border border-[#C9B889] bg-[#FFFCF4] px-3 text-[16px] text-[#1A1714] outline-none focus:border-[#B5321F] focus:ring-2 focus:ring-[#B5321F]/15",children:[t.jsx("option",{value:"FLAGSHIP",children:"FLAGSHIP"}),t.jsx("option",{value:"SHORTS",children:"SHORTS"})]})]}),t.jsxs("button",{type:"button",onClick:()=>N(e),disabled:D||!!x,className:"inline-flex min-h-[44px] w-full items-center justify-center gap-2 rounded-[3px] bg-[#B5321F] px-4 text-[12px] font-bold text-white transition hover:bg-[#8E2D20] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] disabled:cursor-not-allowed disabled:opacity-50",children:[x===`${e.id}:edit_approve`?t.jsx(T,{className:"h-4 w-4 animate-spin"}):t.jsx(J,{className:"h-4 w-4"}),"Approve final edit and queue YouTube handoff"]}
1)]}):t.jsx("p",{className:"text-[10px] leading-relaxed text-[#756C60]",children:e.stage==="voiceover"?"Waiting for voice readiness from the direct owner-approved ElevenLabs action above or the legacy n8n callback. Descript editing remains a manual step.":s?"The final edit form becomes available when this case reaches edit or review.":"Only an approved Carl owner can record the final edit gate."})]}),t.jsx(Fr,{item:e,owner:s,provenanceValid:b,busy:D,busyKey:x,onUpload:w}),t.jsxs("section",{className:"rounded-[3px] border border-[#E0D5B9] bg-[#EDE2C9] p-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(pe,{className:"h-4 w-4 text-[#B5321F]"}),t.jsx("h4",{className:"font-mono text-[10px] font-bold uppercase tracking-[0.12em] text-[#1A1714]",children:"Legacy n8n YouTube status"})]}),e.youtube_video_id||e.youtube_status?t.jsxs("dl",{className:"mt-2 grid gap-2 sm:grid-cols-3",children:[t.jsx(E,{label:"Video id",value:e.youtube_video_id||"Not recorded"}),t.jsx(E,{label:"Status",value:e.youtube_status||"Not recorded"}),t.jsx(E,{label:"Views / likes",value:`${e.views??"Not recorded"} / ${e.likes??"Not recorded"}`})]}):t.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-[#756C60]",children:"No YouTube upload, schedule, publication, or metrics are recorded. The workflow must report them later."})]}),t.jsxs("div",{className:"overflow-x-auto border-t border-[#E0D5B9] pt-3",style:{scrollbarWidth:"thin"},children:[t.jsxs("p",{className:"mb-2 font-mono text-[9px] font-bold uppercase tracking-[0.12em] text-[#B5321F]",children:["Detailed eight-step production flow ",t.jsx("span",{className:"font-normal tracking-[0.06em] text-[#756C60]",children:"· read left to right"})]}),t.jsxs("ol",{className:"flex min-w-[760px] gap-2","aria-label":`Detailed eight-step production flow for ${k}`,children:[t.jsx(ee,{stepNumber:1,label:"Source",stage:"source",item:e}),t.jsx(ee,{stepNumber:2,label:"Buildy package",stage:"package",item:e}),t.jsx(ee,{stepNumber:3,label:"Copywriter review",stage:"maeesha",item:e}),t.jsx(ee,{stepNumber:4,label:"Carl review",stage:"carl",item:e}),t.jsx(ee,{stepNumber:5,label:"Domain page",stage:"page",item:e}),t.jsx(ee,{stepNumber:6,label:"ElevenLabs voice",stage:"voice",item:e}),t.jsx(ee,{stepNumber:7,label:"Video renderer",stage:"render",item:e}),t.jsx(ee,{stepNumber:8,label:"YouTube upload",stage:"youtube",item:e})]})]})]})]})}function Dr({staffEmail:e,email:r}){const s=String(e||r||"").trim().toLowerCase(),i=dt.has(s),d=lt.includes(s),p=Ot.has(s),n=d?"Owner":s===it?"Operations VA":i?"Copywriter":"Staff",[x,f]=j.useState([]),[u,g]=j.useState({}),[h,_]=j.useState({}),[F,C]=j.useState(null),[N,A]=j.useState(!0),[w,L]=j.useState(!1),[P,k]=j.useState(null),[D,q]=j.useState(null),[I,Z]=j.useState(null),[V,b]=j.useState(null),[y,m]=j.useState(null),[_e,R]=j.useState(null),[Te,se]=j.useState(null),[S,gt]=j.useState("all"),[mt,vt]=j.useState(null),[G,de]=j.useState({title:"",source:"",approvalReference:"",sourceIdentity:"",track:"FLAGSHIP"}),O=j.useCallback(async()=>{if(!p){A(!1);return}A(!0),Z(null),q(null),m(null),b(null);try{const a=ce(await he({action:"list"}));if((a==null?void 0:a.success)===!1||!Array.isArray(a==null?void 0:a.packages))throw new Error(W(a,"The private YouTube Studio queue returned an unexpected response."));const o=a.packages.map(Ut).filter(Boolean);f(o),se(c=>{var l;return c&&o.some(v=>v.id===c)?c:((l=o[0])==null?void 0:l.id)||null}),L(!0),vt(new Date().toISOString()),C((a==null?void 0:a.n8n_configured)===!0),g(Object.fromEntries(o.map(c=>[c.id,le(c)])))}catch(a){q(be(a)),Z(W(a,"The private YouTube case records could not be loaded."))}finally{A(!1)}},[p]);j.useEffect(()=>{O()},[O]);const ae=async(a,o,c)=>{k(`${a}:${String(o.action)}`),m(null),b(null),R(null);try{const l=ce(await he(o));if((l==null?void 0:l.success)===!1||l!=null&&l.error)throw new Error(W(l,"The YouTube Studio action could not be completed."));return R((l==null?void 0:l.message)||c),await O(),!0}catch(l){return b(be(l)),m(W(l,"The YouTube Studio action could not be completed.")),!1}finally{k(null)}},_t=(a,o,c)=>g(l=>({...l,[a]:{...l[a]||at(),[o]:c}})),wt=(a,o,c)=>_(l=>{var v,$,ue;return{...l,[a]:{maeesha:((v=l[a])==null?void 0:v.maeesha)||"",owner:(($=l[a])==null?void 0:$.owner)||"",edit:((ue=l[a])==null?void 0:ue.edit)||"",[o]:c.slice(0,500)}}}),jt=a=>{const o=u[a.id]||le(a),c=o.scriptDraft.trim(),l=o.ttsScriptDraft.trim();if(!c&&!l){b("error"),m("Enter a display script draft or TTS script draft before saving.");return}ae(a.id,{action:"save_script_draft",case_id:a.id,script_draft:c,tts_script_draft:l},"The display and TTS script drafts were saved. Nothing was approved and no provider work was started.")},Nt=async(a,o,c)=>{var ue;const l=o==="edit"?"edit":i?"maeesha":"owner",v=String(((ue=h[a.id])==null?void 0:ue[l])||"").trim();if(c==="request_changes"&&!v){b("error"),m("Add a short reason, up to 500 characters, before requesting changes.");return}await ae(a.id,{action:"media_review",case_id:a.id,section:o,decision:c,note:v||null},c==="approve"?"The script review was saved. Final approval and provider work remain separate.":"The change request was saved. No provider work was started.")&&_(Ze=>({...Ze,[a.id]:{...Ze[a.id]||{maeesha:"",owner:"",edit:""},[l]:""}}))},yt=a=>{const o=u[a.id],c=String((o==null?void 0:o.scriptDraft)??a.script_draft??"").trim(),l=String((o==null?void 0:o.ttsScriptDraft)??a.tts_script_draft??"").trim();!c&&!l||(g(v=>({...v,[a.id]:{...v[a.id]||at(),finalDisplayScript:c,finalScript:l||c}})),R(c&&l?"The display and TTS drafts are copied into their matching final fields. Nothing was approved yet.":c?"The display draft is copied into both final fields as a safe TTS fallback. Nothing was approved yet.":"The TTS draft is copied into the final TTS field. Add a display script before recording script approval."))},Ft=a=>{const o=u[a.id]||le(a),c=o.finalDisplayScript.trim(),l=o.finalScript.trim();if(String(a.script_draft||"").trim()&&!c){b("error"),m("Add or copy a final display script before recording script approval.");return}if(!l){b("error"),m("Add or copy a final TTS script before recording script approval.");return}const v={action:"script_approve",case_id:a.id,final_display_script:c,final_script:l};o.voiceId.trim()&&(v.voice_id=o.voiceId.trim()),ae(a.id,v,"Script approval is recorded. Choose the separate ElevenLabs voice action below, or keep using the legacy n8n callback.")},Ct=a=>{const o=!!(String(a.source_content||"").trim()||String(a.source_title||"").trim()),c=!!(String(a.script_draft||"").trim()||String(a.tts_script_draft||"").trim()),l=!!(a.script_approved_at||a.script_approved_by_email||String(a.final_script||"").trim()||String(a.final_display_script||"").trim());if(!o){b("error"),m("Add source content or a source title before generating a Buildy script draft.");return}if(c||l){b("error"),m("This case already has script content or approval. Refresh the queue before trying again.");return}ae(a.id,{action:"generate_script_draft",case_id:a.id},"Buildy created the display and TTS script drafts. Review both before script approval or provider work.")},kt=a=>{const o=u[a.id]||le(a),c=Ht(o.publishAt);if(!c){b("error"),m("Choose a valid publish date and time before approving the edit.");return}const l={action:"edit_approve",case_id:a.id,final_video_url:o.finalVideoUrl,title:o.title,de
1scription:o.description,tags:o.tags.split(/[\n,]+/).map(v=>v.trim()).filter(Boolean),publish_at:c,track:o.track};ae(a.id,l,"Final edit approval is recorded. Upload and publication remain pending the n8n workflow and callback.")},Dt=a=>{if(!d){b("denied"),m("Only an approved Carl owner can send an n8n handoff.");return}const o=pt(a);if(!o){b("error"),m("This case does not have a validated n8n handoff ready to retry.");return}ae(a.id,{action:"dispatch_n8n",case_id:a.id,event:o},"The n8n handoff request was recorded. Provider work remains pending its callback.")},Bt=async a=>{k(`${a.id}:upload_youtube_private`),m(null),b(null),R(null);try{const o=ce(await he({action:"upload_youtube_private",case_id:a.id}));if((o==null?void 0:o.success)===!1||o!=null&&o.error)throw new Error(W(o,"The private YouTube upload could not be confirmed."));return R((o==null?void 0:o.message)||"YouTube confirmed the approved video as private. It was not scheduled or published."),await O(),!0}catch(o){const c=be(o),l=W(o,"The private YouTube upload could not be confirmed.");return await O(),b(c),m(l),!1}finally{k(null)}},St=async a=>{k(`${a.id}:generate_voiceover`),m(null),b(null),R(null);try{const o=ce(await he({action:"generate_voiceover",case_id:a.id}));if((o==null?void 0:o.success)===!1||o!=null&&o.error)throw new Error(W(o,"The Coach Carl voiceover could not be confirmed."));return R((o==null?void 0:o.message)||"The voiceover was confirmed and stored. Descript editing and B-roll remain manual."),await O(),!0}catch(o){const c=be(o),l=W(o,"The Coach Carl voiceover could not be confirmed.");return await O(),b(c),m(l),!1}finally{k(null)}},Et=a=>{const c=(u[a.id]||le(a)).voiceId.trim(),l=String(a.voice_id||"").trim(),v=Q(a.voiceover_status);if(!c){b("error"),m("Enter an ElevenLabs voice ID before saving.");return}if(c===l){R("That ElevenLabs voice ID is already stored for this case.");return}if(v==="generating"||String(a.voiceover_url||"").trim()||fe.has(v)){b("error"),m("The ElevenLabs voice ID is locked after voiceover generation or recorded audio.");return}ae(a.id,{action:"update_voice_id",case_id:a.id,voice_id:c},"ElevenLabs voice ID saved. Script approval and voiceover generation remain unchanged.")},At=async a=>{a.preventDefault();const o=G.source.trim(),c=G.approvalReference.trim(),l=G.sourceIdentity.trim();if(!o){b("error"),m("Add the source content before creating a case.");return}if(!c){b("error"),m("Add the approved source reference before creating a case.");return}if(!l){b("error"),m("Add the stable source ID before creating a case.");return}k("new_case"),m(null),b(null),R(null);try{const v={action:"new_case",source_approval_reference:c,source_identity:l,source_content:o,track:G.track};G.title.trim()&&(v.source_title=G.title.trim());const $=ce(await he(v));if(($==null?void 0:$.success)===!1||$!=null&&$.error)throw new Error(W($,"The new case could not be saved."));R(($==null?void 0:$.message)||"Case saved. The next handoff is waiting for the n8n setup."),de({title:"",source:"",approvalReference:"",sourceIdentity:"",track:"FLAGSHIP"}),await O()}catch(v){b(be(v)),m(W(v,"The new case could not be saved."))}finally{k(null)}};j.useEffect(()=>{se(a=>{var c;const o=x.filter(l=>Be(l,S));return a&&o.some(l=>l.id===a)?a:((c=o[0])==null?void 0:c.id)||null})},[x,S]);const U=x.find(a=>a.id===Te)||null,Tt=a=>{gt(a);const o=x.filter(c=>Be(c,a));se(c=>{var l;return c&&o.some(v=>v.id===c)?c:((l=o[0])==null?void 0:l.id)||null})};return t.jsxs("section",{"aria-labelledby":"case-file-studio-title",className:"mb-4 overflow-hidden rounded-[5px] border border-[#C9B889] bg-[#E8DCC0] text-[#1A1714] shadow-[0_5px_18px_rgba(26,23,20,0.08)]",children:[t.jsxs("header",{className:"border-b-[3px] border-[#B5321F] bg-[#1A1714] p-4 text-[#E8DCC0] sm:p-5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.22em] text-[#D56A58]",children:"RSG Network · private staff control panel"}),t.jsx("h2",{id:"case-file-studio-title",className:"mt-1 text-[22px] font-black tracking-tight text-[#F4EFE2]",children:"YouTube Studio"}),t.jsx("p",{className:"mt-1.5 max-w-3xl text-[11px] leading-relaxed text-[#C8BFAF]",children:"Create real media cases, record Carl's two human approvals, generate an owner-approved ElevenLabs voiceover, and track honest n8n handoffs. Buildy can test one approved MP4 as a private YouTube upload, but it does not edit, render, schedule, or publicly publish media automatically."})]}),t.jsx("button",{type:"button",onClick:()=>{O()},disabled:N||!p||!!P,"aria-label":"Refresh private YouTube Studio records",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-[3px] border border-[#5A5046] bg-[#25201C] text-[#E8DCC0] transition hover:border-[#D56A58] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#D56A58] disabled:cursor-not-allowed disabled:opacity-50",children:t.jsx(qe,{className:`h-4 w-4 ${N?"animate-spin":""}`})})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2 font-mono text-[9px] font-bold uppercase tracking-[0.08em]",children:[p&&t.jsxs("span",{className:"rounded-[2px] border border-[#D56A58] bg-[#B5321F] px-2 py-1 text-[#F4EFE2]",children:["Current role · ",n]}
1),t.jsx("span",{className:"rounded-[2px] border border-[#6B5C4E] bg-[#25201C] px-2 py-1 text-[#C8BFAF]",children:"Real records only"}),t.jsx("span",{className:"rounded-[2px] border border-[#6B5C4E] bg-[#25201C] px-2 py-1 text-[#C8BFAF]",children:"Two human gates"}),t.jsx("span",{className:"rounded-[2px] border border-[#6B5C4E] bg-[#25201C] px-2 py-1 text-[#C8BFAF]",children:"Provider completion never inferred"})]})]}),t.jsx("div",{className:"space-y-3 p-3 sm:p-4",children:s?p?I&&!w?t.jsxs("div",{role:"alert",className:"flex items-start gap-3 rounded-[4px] border border-[#D99A8E] bg-[#FBEDE9] p-4 text-[#7E2419]",children:[t.jsx(Y,{className:"mt-0.5 h-5 w-5 shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-mono text-[10px] font-bold uppercase tracking-[0.14em]",children:D==="session"?"Staff session needs attention":D==="denied"?"Private access denied":"Case records unavailable"}),t.jsx("p",{className:"mt-1 text-[12px] leading-relaxed",children:D==="session"?"Your staff sign-in could not be verified. Sign in again to view this private YouTube Studio workspace.":D==="denied"?"This account is not approved for the private YouTube Studio workspace.":I}),t.jsx("button",{type:"button",onClick:()=>{O()},className:"mt-2 min-h-[36px] rounded-[3px] border border-[#C77A6B] bg-white px-3 text-[11px] font-bold text-[#7E2419] transition hover:bg-[#FFF8F6] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F]",children:"Try again"})]})]}):t.jsxs(t.Fragment,{children:[I&&w&&t.jsxs("div",{role:"alert",className:"flex items-start gap-3 rounded-[4px] border border-[#D99A8E] bg-[#FBEDE9] p-3 text-[#7E2419]",children:[t.jsx(Y,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-mono text-[10px] font-bold uppercase tracking-[0.14em]",children:D==="session"?"Staff session needs attention":D==="denied"?"Private access denied":"Queue refresh needs attention"}),t.jsx("p",{className:"mt-1 text-[11px] leading-relaxed",children:D==="session"?"Your staff sign-in could not be verified. Sign in again to view this private YouTube Studio workspace.":D==="denied"?"This account is not approved for the private YouTube Studio workspace.":I}),t.jsx("button",{type:"button",onClick:()=>{O()},disabled:N||!!P,className:"mt-2 min-h-[36px] rounded-[3px] border border-[#C77A6B] bg-white px-3 text-[11px] font-bold text-[#7E2419] transition hover:bg-[#FFF8F6] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] disabled:cursor-not-allowed disabled:opacity-50",children:"Try again"})]})]}),y&&t.jsxs("div",{role:"alert",className:"flex items-start gap-3 rounded-[4px] border border-[#D99A8E] bg-[#FBEDE9] p-3 text-[#7E2419]",children:[t.jsx(Y,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-mono text-[10px] font-bold uppercase tracking-[0.14em]",children:V==="session"?"Staff session needs attention":V==="denied"?"Private access denied":"Action needs attention"}),t.jsx("p",{className:"mt-1 text-[11px] leading-relaxed",children:V==="session"?"Your staff sign-in could not be verified. Sign in again to view this private YouTube Studio workspace.":V==="denied"?"This account is not approved for the private YouTube Studio workspace.":y})]})]}),!N&&F===!1&&t.jsxs("div",{role:"status",className:"flex items-start gap-2 rounded-[4px] border border-[#D8B66B] bg-[#FFF4D9] px-3 py-3 text-[11px] leading-relaxed text-[#78520D]",children:[t.jsx(Re,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsxs("p",{children:[t.jsx("span",{className:"font-bold",children:"n8n setup pending."})," Staff approvals can be saved in Buildy, but outbound provider work has not started. Add the production webhook address in secure server settings after the workflows are active. This panel never displays the address or secret."]})]}),!N&&F===!0&&t.jsxs("div",{role:"status",className:"flex items-start gap-2 rounded-[4px] border border-[#AFC6D5] bg-[#EDF5FA] px-3 py-3 text-[11px] leading-relaxed text-[#2B5871]",children:[t.jsx(J,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsxs("p",{children:[t.jsx("span",{className:"font-bold",children:"n8n address configured."})," A delivered request confirms only the Buildy-to-n8n handoff. Provider callbacks still have to report voiceover, edit, upload, schedule, or publication."]})]}),t.jsx(nr,{}),t.jsx(hr,{records:x,loading:N,activeFilter:S,selectedId:(U==null?void 0:U.id)||null,latestRefreshAt:mt,onFilter:Tt,onSelect:a=>se(a)}),t.jsxs("form",{onSubmit:At,className:"rounded-[4px] border border-[#C9B889] bg-[#F4EFE2] p-3.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ke,{className:"h-4 w-4 text-[#B5321F]"}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("h3",{className:"font-mono text-[10px] font-bold uppercase tracking-[0.14em] text-[#1A1714]",children:"New case"}),t.jsx("span",{className:"rounded-[2px] border border-[#D8B66B] bg-[#FFF4D9] px-2 py-1 font-mono text-[8px] font-bold uppercase tracking-[0.06em] text-[#78520D]",children:"Step 1 of 8 · Source"})]}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#756C60]",children:"Start with source material you supplied. The title is optional and n
1o source facts are invented."})]})]}),t.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-[1.2fr_0.8fr]",children:[t.jsx(B,{id:"new-case-title",label:"Source title, optional",value:G.title,onChange:a=>de(o=>({...o,title:a})),placeholder:"A human-supplied title"}),t.jsxs("div",{children:[t.jsx("label",{htmlFor:"new-case-track",className:"font-mono text-[9px] font-bold uppercase tracking-[0.1em] text-[#756C60]",children:"Production track"}),t.jsxs("select",{id:"new-case-track",value:G.track,onChange:a=>de(o=>({...o,track:a.target.value})),className:"mt-1 h-11 w-full rounded-[3px] border border-[#C9B889] bg-[#FFFCF4] px-3 text-[16px] text-[#1A1714] outline-none focus:border-[#B5321F] focus:ring-2 focus:ring-[#B5321F]/15",children:[t.jsx("option",{value:"FLAGSHIP",children:"FLAGSHIP"}),t.jsx("option",{value:"SHORTS",children:"SHORTS"})]})]})]}),t.jsxs("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:[t.jsx(B,{id:"new-case-approval-reference",label:"Approved source reference, required",value:G.approvalReference,onChange:a=>de(o=>({...o,approvalReference:a})),placeholder:"Approval ticket, brief, or review reference",helper:"Proof this source was approved.",required:!0}),t.jsx(B,{id:"new-case-source-identity",label:"Stable source ID, required",value:G.sourceIdentity,onChange:a=>de(o=>({...o,sourceIdentity:a})),placeholder:"youtube:VIDEO_ID or internal source ID",helper:"Use youtube:VIDEO_ID, an approved document ID, or an internal source ID.",required:!0})]}),t.jsx("div",{className:"mt-3",children:t.jsx(B,{id:"new-case-source",label:"Source content, required",value:G.source,onChange:a=>de(o=>({...o,source:a})),rows:6,placeholder:"Paste the source notes, transcript, brief, or other material you are authorizing for this case.",helper:"The submitted material is stored as the case source and sent only through the approved n8n handoff when configured.",required:!0})}),t.jsxs("button",{type:"submit",disabled:!!P,className:"mt-3 inline-flex min-h-[44px] w-full items-center justify-center gap-2 rounded-[3px] bg-[#B5321F] px-4 text-[12px] font-bold text-white transition hover:bg-[#8E2D20] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] disabled:cursor-not-allowed disabled:opacity-50",children:[P==="new_case"?t.jsx(T,{className:"h-4 w-4 animate-spin"}):t.jsx(Ke,{className:"h-4 w-4"}),"Create private case"]})]}),_e&&t.jsx("div",{role:"status",className:"rounded-[4px] border border-[#9DB696] bg-[#EEF6EC] px-3 py-3 text-[11px] leading-relaxed text-[#3D6B3A]",children:_e}),N?t.jsxs("div",{className:"space-y-3","aria-label":"Loading private YouTube case records",children:[t.jsx("div",{className:"h-40 animate-pulse rounded-[4px] border border-[#D8C9A3] bg-[#F4EFE2]"}),t.jsx("div",{className:"h-40 animate-pulse rounded-[4px] border border-[#D8C9A3] bg-[#F4EFE2]"})]}):x.length===0?t.jsxs("div",{className:"rounded-[4px] border border-dashed border-[#B9A77D] bg-[#F4EFE2] p-6 text-center",children:[t.jsx(ge,{className:"mx-auto h-6 w-6 text-[#756C60]"}),t.jsx("p",{className:"mt-3 font-mono text-[11px] font-bold uppercase tracking-[0.1em] text-[#1A1714]",children:"No YouTube cases yet"}),t.jsx("p",{className:"mx-auto mt-2 max-w-xl text-[11px] leading-relaxed text-[#756C60]",children:"Create a case above with real source material, or use the separate legacy pilot review workflow. This panel never creates sample records or fake provider metrics."}),t.jsx("a",{href:"#pilot-review-launcher",className:"mt-3 inline-flex min-h-[38px] items-center justify-center rounded-[3px] bg-[#1A1714] px-3.5 text-[11px] font-bold text-[#E8DCC0] transition hover:bg-[#302923] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] focus-visible:ring-offset-2 focus-visible:ring-offset-[#E8DCC0]",children:"Open legacy pilot workflow"})]}):U?t.jsxs("div",{className:"space-y-3",children:[t.jsx(fr,{item:U}),t.jsx(jr,{item:U}),t.jsx(kr,{item:U,draft:u[U.id]||le(U),owner:d,isCopywriter:i,provenanceValid:ze(U),reviewNotes:h,n8nConfigured:F===!0,busyKey:P,onDraft:_t,onReviewNote:wt,onCopy:yt,onGenerateScriptDraft:Ct,onSaveScriptDraft:jt,onMediaReview:Nt,onScriptApprove:Ft,onEditApprove:kt,onDispatch:Dt,onUploadPrivate:Bt,onGenerateVoiceover:St,onSaveVoiceId:Et},U.id)]}):t.jsxs("div",{className:"rounded-[4px] border border-dashed border-[#CFC7BB] bg-white p-5 text-center",children:[t.jsx("p",{className:"font-mono text-[10px] font-bold uppercase tracking-[0.08em] text-[#1A1714]",children:"No selected case in this view"}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-[#756C60]",children:"Choose another queue filter or select a case above to open its detailed workspace."})]}),t.jsxs("aside",{className:"flex items-start gap-2 rounded-[4px] border border-[#C9B889] bg-[#F4EFE2] px-3 py-3 text-[10px] leading-relaxed text-[#4F4941]",children:[t.jsx(Re,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#B5321F]"}),t.jsxs("p",{children:[t.jsx("span",{className:"font-bold text-[#1A1714]",children:"Pipeline boundary:"})," Buildy can generate an owner-approved ElevenLabs voiceover and perform the isolated private YouTube upload test. Descript editing and B-roll remain manual, and Buildy does not automatically edit, render, schedule, or publicly publish. A specialized renderer and YouTube handle those later steps, with completion recorded only from truthful provider status."]})]}),t.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1 font-mono text-[9px] text-[#756C60]",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(J,{className:"h-3 w-3 text-[#3D6B3A]"})," Recorded status"]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(ye,{className:"h-3 w-3 text-[#C08A2D]"})," Human gate"]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(we,{className:"h-3 w-3"})," Voice handoff"]}
1),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(Fe,{className:"h-3 w-3"})," Render handoff"]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(pe,{className:"h-3 w-3"})," YouTube handoff"]})]})]}):t.jsx(nt,{kind:"denied"}):t.jsx(nt,{kind:"missing"})})]})}function Br(e){if(!e||typeof e!="object")return null;const r=e.email;return typeof r!="string"?null:r.trim()||null}function Sr(){return t.jsxs("section",{className:"rounded-[5px] border border-[#D8D2C8] bg-white p-5 shadow-[0_8px_26px_rgba(26,23,20,0.05)] sm:p-7","aria-live":"polite","aria-busy":"true",children:[t.jsxs("div",{className:"flex items-center gap-3 text-[#5F584F]",children:[t.jsx("span",{className:"h-4 w-4 animate-spin rounded-full border-2 border-[#C9B889] border-t-[#B5321F]","aria-hidden":!0}),t.jsx("p",{className:"font-mono text-[10px] font-bold uppercase tracking-[0.12em]",children:"Checking your private workspace"})]}),t.jsxs("div",{className:"mt-5 grid gap-3 lg:grid-cols-[0.8fr_1.2fr]",children:[t.jsx("div",{className:"h-28 animate-pulse rounded-[4px] bg-[#F1EDE5]"}),t.jsx("div",{className:"h-28 animate-pulse rounded-[4px] bg-[#F1EDE5]"})]})]})}function Er(){const e=typeof window>"u"?"/auth/app-login":Pt(window.location.href);return t.jsx("section",{className:"mb-4 rounded-[5px] border border-[#D8B66B] bg-[#FFF8E8] p-4 shadow-[0_5px_18px_rgba(120,82,13,0.06)] sm:p-5","aria-labelledby":"youtube-studio-sign-in-title",children:t.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-[3px] bg-[#1A1714] text-[#E8DCC0]","aria-hidden":!0,children:t.jsx(Ee,{className:"h-4 w-4"})}),t.jsxs("div",{children:[t.jsx("h2",{id:"youtube-studio-sign-in-title",className:"text-[15px] font-black text-[#1A1714]",children:"Sign in to open this workspace"}),t.jsx("p",{className:"mt-1 max-w-2xl text-[11px] leading-relaxed text-[#78520D]",children:"Your account lookup did not return a signed-in email. Sign in with your RSG staff account, then return here. The studioâs own staff guard still controls access."})]})]}),t.jsxs("a",{href:e,className:"inline-flex min-h-[42px] shrink-0 items-center justify-center gap-2 rounded-[3px] bg-[#B5321F] px-4 text-[11px] font-bold text-white transition hover:bg-[#8E2D20] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] focus-visible:ring-offset-2 focus-visible:ring-offset-[#FFF8E8]",children:[t.jsx(qt,{className:"h-4 w-4"}),"Sign in to continue"]})]})})}function Ur(){const[e,r]=j.useState(null),[s,i]=j.useState(!0);return j.useEffect(()=>{let d=!1;return(async()=>{try{const p=await Lt.me();d||r(Br(p))}catch{d||r(null)}finally{d||i(!1)}})(),()=>{d=!0}},[]),t.jsxs("div",{className:"min-h-screen overflow-x-clip bg-[#F7F5F0] text-[#1A1714] selection:bg-[#B5321F]/15",children:[t.jsx(Vt,{title:"YouTube Studio | RideShareGuides",description:"Private RideShareGuides workspace for reviewing and tracking YouTube case records.",url:"https://rideshareguides.com/youtube-studio",noindex:!0}),t.jsx("header",{className:"border-b border-[#3B342E] bg-[#1A1714] text-[#F4EFE2]",children:t.jsxs("div",{className:"mx-auto flex min-h-[62px] w-full max-w-[1500px] items-center justify-between gap-4 px-4 sm:px-6 lg:px-8",children:[t.jsxs(Je,{to:"/pro-dashboard",className:"inline-flex min-h-[40px] items-center gap-2 rounded-[3px] px-2 text-[11px] font-bold text-[#C8BFAF] transition hover:bg-[#2A2420] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#D56A58] focus-visible:ring-offset-2 focus-visible:ring-offset-[#1A1714]",children:[t.jsx(It,{className:"h-4 w-4"}),"Back to dashboard"]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Xe,{className:"text-[18px] text-[#E8DCC0]","aria-hidden":!0}),t.jsx("span",{className:"hidden h-5 w-px bg-[#5A5046] sm:block","aria-hidden":!0}),t.jsx("span",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.14em] text-[#C8BFAF]",children:"Private operations"})]})]})}),t.jsxs("main",{className:"mx-auto w-full max-w-[1500px] px-3 pb-10 pt-4 sm:px-5 sm:pb-14 sm:pt-6 lg:px-8",children:[t.jsxs("section",{className:"mb-4 flex flex-col gap-4 roun
1ded-[5px] border border-[#D8D2C8] bg-white p-4 shadow-[0_8px_26px_rgba(26,23,20,0.05)] sm:flex-row sm:items-end sm:justify-between sm:p-5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"flex items-center gap-2 font-mono text-[9px] font-bold uppercase tracking-[0.18em] text-[#B5321F]",children:[t.jsx(pe,{className:"h-3.5 w-3.5"})," RSG media operations"]}),t.jsx("h1",{className:"mt-2 text-[25px] font-black tracking-tight text-[#1A1714] sm:text-[30px]",children:"YouTube Studio"}),t.jsx("p",{className:"mt-1 max-w-2xl text-[11px] leading-relaxed text-[#756C60]",children:"Review source-bound cases, record the human gates, and inspect the next handoff without exposing the queue to public site chrome."})]}),t.jsxs("span",{className:"inline-flex w-fit shrink-0 items-center gap-2 rounded-[3px] border border-[#B7C7CE] bg-[#EDF5F7] px-3 py-2 font-mono text-[9px] font-bold uppercase tracking-[0.08em] text-[#2B5871]",children:[t.jsx(Yt,{className:"h-3.5 w-3.5"})," Staff access only"]})]}),s?t.jsx(Sr,{}):t.jsxs(t.Fragment,{children:[!e&&t.jsx(Er,{}),t.jsx(Dr,{staffEmail:e,email:e})]})]}),t.jsx("footer",{className:"border-t border-[#DED8CE] bg-[#F1EDE5]",children:t.jsxs("div",{className:"mx-auto flex w-full max-w-[1500px] items-center justify-between gap-3 px-4 py-4 sm:px-6 lg:px-8",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Xe,{className:"text-[13px] text-[#756C60]","aria-hidden":!0}),t.jsx("span",{className:"font-mono text-[9px] font-bold uppercase tracking-[0.1em] text-[#756C60]",children:"Private staff workspace"})]}),t.jsx(Je,{to:"/pro-dashboard",className:"text-[10px] font-bold text-[#8E2D20] underline-offset-2 transition hover:text-[#B5321F] hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#B5321F] focus-visible:ring-offset-2",children:"Return to dashboard"})]})})]})}export{Ur 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.