1import{r as b}from"./rolldown-runtime.C1f3BsDW.js";import"./inertia.BE4YqsTM.js";import"./http.DWpeO7Ui.js";import{Ln as f,Pn as g,Qr as S,X as D,Xt as j,fn as F,m as k}from"./icons.ChOq_Y4q.js";import{t as T}from"./react-core.CAMe6Z4j.js";import"./utils.CgzVjNgC.js";import"./state.L8kQliOB.js";import{Tt as l,Ut as N,k as L,ut as y}from"./entry-client.DX3aUoe5.js";import{n as A}from"./input.GzdAc1Aj.js";import"./dist.CoNAZqlp.js";import"./dist.DxccqHSW.js";import"./es2015.Cr2X04_P.js";import"./dist.DbqQa_sy.js";import{a as q,n as E,o as M,r as P,t as X}from"./dialog.Bb7MGeDP.js";var t=b(S(),1),e=b(T(),1);const O=({projectUuid:i,isOpen:n,onClose:m,onImportSuccess:c})=>{const[d,v]=(0,t.useState)([]),[r,w]=(0,t.useState)(""),[_,x]=(0,t.useState)(!1),[p,h]=(0,t.useState)(null),u=(0,t.useCallback)(async(s="")=>{try{x(!0);const a=await y.importableProjects(i,s);v(a.data?.data?.data??a.data?.data??[])}catch(a){console.error("Failed to load importable projects:",a),l.error("Could not load your films. Try again.")}finally{x(!1)}},[i]);(0,t.useEffect)(()=>{n&&u(r)},[n,r,u]);const I=async s=>{try{h(s.id);const a=(await y.importAssets(i,{source_project_id:s.id,import_assets:!0,import_characters:!0})).data?.message||`Imported files and characters from ${s.name}.`;l.success(a),c&&c(),m()}catch(a){console.error("Failed to import assets:",a);const o=a?.response?.data?.message||"Could not import. Try again.";l.error(o)}finally{h(null)}};return(0,e.jsx)(X,{open:n,onOpenChange:s=>!s&&m(),children:(0,e.jsxs)(E,{className:"sm:max-w-lg bg-card border-border",children:[(0,e.jsx)(q,{children:(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("div",{className:"p-2 rounded-lg bg-primary/10 text-primary",children:(0,e.jsx)(g,{className:"h-5 w-5"})}),(0,e.jsxs)("div",{children:[(0,e.jsx)(M,{className:"text-lg font-semibold",children:"Import files and characters"}),(0,e.jsx)(P,{className:"text-xs text-muted-foreground",children:"Copy files and characters from another film into this film."})]})]})}),(0,e.jsxs)("div",{className:"relative mt-2",children:[(0,e.jsx)(D,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),(0,e.jsx)(A,{value:r,onChange:s=>w(s.target.value),placeholder:"Search filmsâ¦",className:"pl-9 text-sm bg-secondary/50 border-border"})]}),(0,e.jsx)("div",{className:"mt-3 max-h-[320px] overflow-y-auto space-y-2 pr-1",children:_?(0,e.jsxs)("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:[(0,e.jsx)(j,{className:"h-6 w-6 animate-spin mr-2"}),(0,e.jsx)("span",{className:"text-sm",children:"Loading filmsâ¦"})]}):d.length===0?(0,e.jsxs)("div",{className:"text-center py-10 text-muted-foreground",children:[(0,e.jsx)(f,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),(0,e.jsx)("p",{className:"text-sm font-medium",children:"No films found"}),(0,e.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:r?"Try searching with a different term.":"You don't have any other films to import from."})]}):d.map(s=>{const a=p===s.id,o=s.assets_count??0,C=s.characters_count??0;return(0,e.jsxs)("div",{className:"flex items-center justify-between gap-3 p-3 rounded-lg border border-border/60 bg-secondary/30 hover:bg-secondary/70 transition-colors",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,e.jsx)("div",{className:"h-9 w-9 rounded-lg bg-primary/10 text-primary flex items-center justify-center shrink-0",children:(0,e.jsx)(f,{className:"h-4 w-4"})}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("h4",{className:"font-medium text-sm text-foreground truncate",children:s.name}),(0,e.jsxs)("div",{className:"flex items-center gap-2 mt-0.5 text-xs text-muted-foreground",children:[(0,e.jsxs)("span",{className:"flex items-center gap-1",children:[(0,e.jsx)(F,{className:"h-3 w-3"}),N(o,"file")]}),(0,e.jsx)("span",{children:"â¢"}),(0,e.jsxs)("span",{className:"flex items-center gap-1",children:[(0,e.jsx)(k,{className:"h-3 w-3"}),N(C,"character")]})]})]})]}),(0,e.jsx)(L,{size:"sm",variant:"outline",disabled:a||p!==null,onClick:()=>I(s),className:"shrink-0 gap-1.5",children:a?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(j,{className:"h-3.5 w-3.5 animate-spin"}),(0,e.jsx)("span",{children:"Importingâ¦"})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(g,{className:"h-3.5 w-3.5"}),(0,e.jsx)("span",{children:"Import"})]})})]},s.id)})})]})})};export{O as ImportAssetsModal};
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.