1import{r,j as t,B as N,s as o,v as u}from"./index-BNrdOJig.js";import{B as U,D as I,E as T}from"./BackOfficeWorkspace-BsNQ8xko.js";import{I as x}from"./input-CwAqzCK4.js";import{submitPlatformForm as E}from"./platform-submissions-D3ZGXLMB.js";function A(){const[a,f]=r.useState([]),[v,j]=r.useState([]),[i,p]=r.useState(""),[n,y]=r.useState(""),[l,b]=r.useState("US"),[c,k]=r.useState("sound_recording"),[d,g]=r.useState(""),[_,m]=r.useState(!1),h=async()=>{const{data:e}=await o.auth.getUser(),s=e.user?.id;if(!s)return;const[{data:C},{data:S}]=await Promise.all([o.from("copyright_registrations").select("*").eq("user_id",s).order("created_at",{ascending:!1}),o.from("tracks").select("id, title").eq("owner_id",s).eq("removed",!1).order("created_at",{ascending:!1}).limit(50)]);f(C??[]),j(S??[])};r.useEffect(()=>{h()},[]);const w=async()=>{if(!i.trim())return u.error("Title required");m(!0);const{data:e}=await o.auth.getUser(),{error:s}=await o.from("copyright_registrations").insert({user_id:e.user.id,track_id:n||null,title:i.trim(),jurisdiction:l,work_type:c,applicant_name:d.trim()||null,status:"draft"});if(m(!1),s)return u.error(s.message);p(""),g(""),u.success("Copyright registration drafted."),E({formType:"copyright-registration",subject:`Copyright registration: ${i.trim()}`,payload:{title:i.trim(),track_id:n||null,jurisdiction:l,work_type:c,applicant:d.trim()||null}}),h()};return t.jsx(U,{title:"Copyright Registration",subtitle:"File US Copyright Office (and international) registrations for your works",intro:"Track each work you register with copyright authorities, upload the certificate once it comes back, and keep a permanent audit trail.",kpis:[{label:"Registrations",value:a.length},{label:"Registered",value:a.filter(e=>e.status==="registered").length},{label:"In progress",value:a.filter(e=>e.status==="filed"||e.status==="in_review").length},{label:"Drafts",value:a.filter(e=>e.status==="draft").length}],toolbar:t.jsxs(t.Fragment,{children:[t.jsx(x,{placeholder:"Work title",value:i,onChange:e=>p(e.target.value),className:"w-56"}),t.jsxs("select",{value:n,onChange:e=>y(e.target.value),className:"rounded-md bg-background border border-border px-3 py-2 text-sm min-w-[180px]",children:[t.jsx("option",{value:"",children:"â Link to track (optional) â"}),v.map(e=>t.jsx("option",{value:e.id,children:e.title},e.id))]}),t.jsxs("select",{value:l,onChange:e=>b(e.target.value),className:"rounded-md bg-background border border-border px-3 py-2 text-sm",children:[t.jsx("option",{value:"US",children:"US Copyright Office"}),t.jsx("option",{value:"UK",children:"UK IPO"}),t.jsx("option",{value:"EU",children:"EUIPO"}),t.jsx("option",{value:"CA",children:"CIPO (Canada)"})]}),t.jsxs("select",{value:c,onChange:e=>k(e.target.value),className:"rounded-md bg-background border border-border px-3 py-2 text-sm",children:[t.jsx("option",{value:"sound_recording",children:"Sound recording (SR)"}),t.jsx("option",{value:"musical_work",children:"Musical composition (PA)"}),t.jsx("option",{value:"visual",children:"Visual / cover art (VA)"})]}),t.jsx(x,{placeholder:"Applicant name",value:d,onChange:e=>g(e.target.value),className:"w-44"}),t.jsx(N,{onClick:w,disabled:_,children:"Draft registration"})]}),children:t.jsx(I,{title:"Your registrations",children:a.length===0?t.jsx(T,{title:"No registrations yet",description:"Draft your first copyright registration above."}):t.jsx("ul",{className:"divide-y divide-white/5 text-sm",children:a.map(e=>t.jsxs("li",{className:"px-5 py-3 grid grid-cols-6 gap-2 items-center",children:[t.jsx("div",{className:"col-span-2 font-semibold truncate",children:e.title}),t.jsxs("div",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:[e.jurisdiction," · ",e.work_type]}),t.jsx("div",{className:"text-xs",children:e.service_request_number??"â"}),t.jsx("div",{className:"text-xs",children:e.applicant_name??"â"}),t.jsxs("div",{className:"text-xs text-right",children:[e.status,e.certificate_url&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("a",{href:e.certificate_url,target:"_blank",rel:"noreferrer",className:"text-primary underline",children:"cert"})]})]})]},e.id))})})})}export{A as component};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.