PageSourceSearch

https://cinessential.ai/assets/CharacterGallery-DjpFTPE_.js

js cinessential.ai collected 2026-10-05 12:22:33 UTC 4,862 bytes, 1 lines download raw bytes

1import{j as e}from"./ui-vendor-C-1KqH15.js";import{aN as F,c as O,B as n,aA as P,aD as R,X as v,I as z,am as B,dm as K,ds as M,s as d,t as s}from"./index-DMraBsI-.js";import{B as Q}from"./BackToProjectButton-DLCJY2Qy.js";import{h as S,i as L,a as l}from"./react-vendor-ByDWXJvr.js";import"./three-vendor-CfDQ9C4v.js";import"./pdf-vendor-BLM9xNEA.js";import"./stream-vendor-CoRm0Xqa.js";const W=()=>{S();const{projectId:o}=L(),[N,x]=l.useState(!1),[w,u]=l.useState(null),[m,p]=l.useState(""),h=F(),c=l.useRef(null),i=l.useRef(null),{data:g=[],isLoading:U}=O({queryKey:["project-cast",o],queryFn:async()=>{const{data:r,error:a}=await d.from("project_images").select("*").eq("project_id",o).eq("category","cast").order("display_order",{ascending:!0});if(a)throw console.error("Error fetching cast:",a),s.error("Failed to load cast members"),a;return r}}),C=async r=>{try{const{error:a}=await d.from("project_images").delete().eq("id",r);if(a)throw a;s.success("Character removed from cast"),h.invalidateQueries({queryKey:["project-cast",o]})}catch(a){console.error("Error removing from cast:",a),s.error("Failed to remove character from cast")}},b=r=>{u(r.id),p(r.element_name)},j=()=>{u(null),p("")},f=async r=>{if(!m.trim()){s.error("Name cannot be empty");return}try{const{error:a}=await d.from("project_images").update({element_name:m.trim()}).eq("id",r);if(a)throw a;s.success("Cast member renamed successfully"),h.invalidateQueries({queryKey:["project-cast",o]}),u(null)}catch(a){console.error("Error updating name:",a),s.error("Failed to rename cast member")}},_=async r=>{try{await navigator.clipboard.writeText(r),s.success("Image URL copied to clipboard")}catch(a){console.error("Failed to copy URL:",a),s.error("Failed to copy URL to clipboard")}},k=r=>{c.current=r},q=(r,a)=>{r.preventDefault(),i.current=a},E=async r=>{if(r.preventDefault(),c.current===null||i.current===null||c.current===i.current)return;const a=[...g],t=a[c.current];a.splice(c.current,1),a.splice(i.current,0,t);try{const y=a.map((D,I)=>d.from("project_images").update({display_order:I}).eq("id",D.id));await Promise.all(y),s.success("Cast order updated"),h.invalidateQueries({queryKey:["project-cast",o]})}catch(y){console.error("Error updating cast order:",y),s.error("Failed to update cast order")}c.current=null,i.current=null};return e.jsxs("div",{className:"container mx-auto p-4 space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(Q,{projectId:o,refetchOnNavigate:!0}),e.jsxs(n,{onClick:()=>x(!0),className:"flex items-center gap-2",children:[e.jsx(P,{className:"w-4 h-4"})," Add to Cast"]})]}),e.jsxs("div",{className:"my-8",children:[e.jsx("h2",{className:"text-2xl font-bold mb-4",children:"Character Bible"}),g.length>0?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4",children:g.map((r,a)=>e.jsxs("div",{className:"relative group cursor-move",draggable:!0,onDragStart:()=>k(a),onDragOver:t=>q(t,a),onDrop:E,children:[e.jsxs("div",{className:"absolute top-0 right-0 z-10 flex gap-1",children:[e.jsx(n,{variant:"secondary",size:"icon",className:"h-8 w-8 rounded-full opacity-0 group-hover:opacity-100 transition-opacity bg-black/60 text-white",onClick:t=>{t.stopPropagation(),_(r.image_url)},children:e.jsx(R,{className:"h-4 w-4"})}),e.jsx(n,{variant:"destructive",size:"icon",className:"h-8 w-8 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",onClick:t=>{t.stopPropagation(),C(r.id)},children:e.jsx(v,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"aspect-square w-full overflow-hidden rounded-lg",children:e.jsx("img",{src:r.image_url,alt:r.element_name,className:"w-full h-full object-cover"})}),w===r.id?e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx(z,{value:m,onChange:t=>p(t.target.value),className:"h-8 text-sm py-1",autoFocus:!0,onKeyDown:t=>{t.key==="Enter"&&f(r.id),t.key==="Escape"&&j()}}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(n,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>f(r.id),children:e.jsx(B,{className:"h-4 w-4"})}),e.jsx(n,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:j,children:e.jsx(v,{className:"h-4 w-4"})})]})]}):e.jsxs("div",{className:"mt-2 flex items-center justify-center",children:[e.jsx("h3",{className:"text-lg font-semibold text-center uppercase",children:r.element_name}),e.jsx(n,{variant:"ghost",size:"icon",className:"h-8 w-8 ml-1 opacity-0 group-hover:opacity-100 transition-opacity",onClick:t=>{t.stopPropagation(),b(r)},children:e.jsx(K,{className:"h-4 w-4"})})]})]},r.id))}):e.jsx("div",{className:"text-center py-8 border border-dashed rounded-lg",children:e.jsx("p",{className:"text-gray-500",children:'No cast members added yet. Click "Add to Cast" to build your cast.'})})]}),e.jsx(M,{projectId:o,open:N,onOpenChange:x})]})};export{W 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.