1import{t as dt,u as O,a4 as w,j as e,m as f,A as Me,ay as mt,n as ut,s as Re,ax as X,aD as xt,a9 as Le,ai as ze,aE as gt,a0 as qe,B as bt,aB as pt,X as Y,a5 as ht,ar as ft,z as u,O as jt,b as vt,k as _e,T as Nt}from"./vendor-ui--86-bCAR.js";import{f as yt,u as wt,a as i,N as kt,L as Ee}from"./vendor-react-dh0YdBDl.js";import{u as Z,a as Ct,W as St,X as Tt}from"./index-phOctNbv.js";import{t as b}from"./training.service-Dfuj7tAc.js";import{S as It}from"./Switch-BEddI1Id.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"ef0ac31441b1214a02bb8e808c37bed3a480a90b"};var n=new s.Error().stack;n&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[n]="cfd5394e-523e-444e-958c-cb18f547c6d5",s._sentryDebugIdIdentifier="sentry-dbid-cfd5394e-523e-444e-958c-cb18f547c6d5")}catch{}})();function Ft({url:s,blurDataUrl:n,filename:h,alreadySelected:l,isPending:p,isActive:x,onClick:m}){const[N,M]=i.useState(!1);return e.jsxs("button",{onClick:m,disabled:l,className:`relative aspect-[3/4] rounded-xl overflow-hidden border-2 transition-all w-full block ${l?"border-accent/40 opacity-40 cursor-default":p?"border-accent ring-1 ring-accent/30 cursor-pointer":"border-transparent hover:border-accent/30 cursor-pointer"}`,children:[n&&e.jsx("img",{src:n,alt:"",className:"absolute inset-0 w-full h-full object-cover"}),!n&&!N&&e.jsx("div",{className:"absolute inset-0 animate-pulse bg-background-card"}),e.jsx("img",{src:s,alt:h,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-300 ${N?"opacity-100":"opacity-0"}`,loading:"lazy",onLoad:()=>M(!0)}),x&&e.jsx("div",{className:`absolute inset-0 flex items-center justify-center ${l?"bg-black/40":"bg-accent/20"}`,children:e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center ${l?"bg-black/60":"bg-accent"}`,children:e.jsx(_e,{className:"w-4 h-4 text-white"})})})]})}function Vt(){var Te,Ie,Fe,Ae,Pe;const{t:s}=Z("train"),{modelId:n}=yt(),h=wt(),l=dt(),{user:p}=Ct(),x=i.useRef(null),[m,N]=i.useState(""),[M,J]=i.useState(0),[ee,te]=i.useState(0),[Ve,se]=i.useState(720),[Qe,ae]=i.useState(65),[re,ne]=i.useState(!0),[ie,oe]=i.useState(3),[le,ce]=i.useState(9),[de,me]=i.useState(1),[R,ue]=i.useState(""),[_,xe]=i.useState(!0),[V,ge]=i.useState(""),[be,Q]=i.useState(0),[Be,L]=i.useState(!1),[B,k]=i.useState(!1),[j,C]=i.useState(new Map),[pe,Ge]=i.useState(!1),[$e,Mt]=i.useState(null),[he,Ke]=i.useState(!1),{data:g}=O({queryKey:["training-price"],queryFn:()=>b.getPrice()}),{data:a,isLoading:De}=O({queryKey:["training-model",n],queryFn:()=>b.getById(n),enabled:!!n,refetchInterval:t=>{const r=t.state.data;return(r==null?void 0:r.status)==="training"||(r==null?void 0:r.status)==="generating"?5e3:!1}});i.useEffect(()=>{a&&!he&&(N(a.name),J(a.customLowSteps||0),te(a.customHighSteps||0),se(a.trainQuality||720),ae(a.trainFrames||65),ne(a.enableTransitions!==!1),oe(a.staticFrames??3),ce(a.transitionFrames??9),me(a.targetPersons??1),ue(a.prompt||""),ge(a.photoTips&&a.photoTips!=="Select images from gallery to test your template"?a.photoTips:""),xe(a.autoCaptions||!1),Ke(!0))},[a,he]);const v=w({mutationFn:t=>b.update(n,t),onSuccess:()=>l.invalidateQueries({queryKey:["training-model",n]})}),G=w({mutationFn:t=>b.uploadVideos(n,t,Q),onSuccess:()=>{l.invalidateQueries({queryKey:["training-model",n]}),l.invalidateQueries({queryKey:["training-models"]}),Q(0),u.success(s("toast.videosUploaded"))},onError:()=>{Q(0),u.error(s("toast.failedUploadVideos"))}}),He=w({mutationFn:t=>b.deleteVideo(n,t),onSuccess:()=>{l.invalidateQueries({queryKey:["training-model",n]}),l.invalidateQueries({queryKey:["training-models"]})}}),$=w({mutationFn:()=>b.startTraining(n),onSuccess:()=>{l.invalidateQueries({queryKey:["training-model",n]}),l.invalidateQueries({queryKey:["training-models"]}),u.success(s("toast.trainingStarted")),Tt({model_id:n,price_credits:(g==null?void 0:g.price)??0})},onError:t=>{var r,o;u.error(((o=(r=t==null?void 0:t.response)==null?void 0:r.data)==null?void 0:o.error)||s("toast.failedStartTraining"))}}),Ue=w({mutationFn:()=>b.delete(n),onSuccess:()=>
1{l.invalidateQueries({queryKey:["training-models"]}),h("/train"),u.success(s("toast.modelDeleted"))}}),K=w({mutationFn:()=>b.submitForReview(n,$e||void 0),onSuccess:()=>{l.invalidateQueries({queryKey:["training-model",n]}),u.success(s("toast.submittedForReview"))},onError:t=>{var r,o;u.error(((o=(r=t==null?void 0:t.response)==null?void 0:r.data)==null?void 0:o.error)||s("toast.failedSubmitReview"))}}),[D,fe]=i.useState("all"),[T,I]=i.useState(1),We=40,{data:d,isFetching:z}=O({queryKey:["curated-gallery",D,T],queryFn:()=>b.getCuratedGalleryImages(T,We,D),staleTime:10*6e4,placeholderData:t=>t}),je=i.useMemo(()=>d!=null&&d.categories?["all",...d.categories]:["all"],[d==null?void 0:d.categories]),Oe=i.useMemo(()=>new Set((d==null?void 0:d.hiddenCategories)??[]),[d]),q=i.useRef(null),[H,Xe]=i.useState(!1),[U,Ye]=i.useState(!1),F=i.useCallback(()=>{const t=q.current;t&&(Xe(t.scrollLeft>4),Ye(t.scrollLeft+t.clientWidth<t.scrollWidth-4))},[]);i.useEffect(()=>{if(!B)return;const t=requestAnimationFrame(F),r=q.current;if(!r)return()=>cancelAnimationFrame(t);r.addEventListener("scroll",F,{passive:!0});const o=new ResizeObserver(F);return o.observe(r),()=>{cancelAnimationFrame(t),r.removeEventListener("scroll",F),o.disconnect()}},[B,je.length,F]);const ve=t=>{var r;(r=q.current)==null||r.scrollBy({left:t,behavior:"smooth"})},Ne=(d==null?void 0:d.images)||[],A=d==null?void 0:d.pagination,Ze=w({mutationFn:t=>b.removeTestImage(n,t),onSuccess:()=>{l.invalidateQueries({queryKey:["training-model",n]})}}),Je=()=>{C(new Map),fe("all"),I(1),k(!0)},et=(t,r,o)=>{C(S=>{var E;const y=new Map(S);if(y.has(t))y.delete(t);else{if((((E=a==null?void 0:a.trainingImages)==null?void 0:E.length)||0)+y.size>=6)return u.error(s("toast.maxImagesAllowed")),S;y.set(t,{url:r,filename:o})}return y})},[ye,we]=i.useState(!1),tt=async()=>{var t,r;if(j.size===0){k(!1);return}we(!0);try{for(const[,{url:o,filename:S}]of j)await b.selectTestImage(n,o,S);l.invalidateQueries({queryKey:["training-model",n]}),u.success(s("toast.imagesAdded",{count:j.size})),C(new Map),k(!1)}catch(o){l.invalidateQueries({queryKey:["training-model",n]}),u.error(((r=(t=o==null?void 0:o.response)==null?void 0:t.data)==null?void 0:r.error)||s("toast.failedSaveSelections"))}finally{we(!1)}},P=i.useCallback((t,r)=>{!a||a.status!=="draft"||v.mutate({[t]:r})},[a,v]),st=t=>{const r=Array.from(t.target.files||[]);r.length!==0&&(G.mutate(r),t.target.value="")},at=t=>{t.preventDefault();const r=Array.from(t.dataTransfer.files).filter(o=>o.type.startsWith("video/"));r.length!==0&&G.mutate(r)},rt=()=>{var t,r;if(a){if(!R.trim()&&!_){u.error(s("toast.providePrompt"));return}if((((t=a.trainingVideos)==null?void 0:t.length)||0)<10){u.error(s("toast.uploadAtLeast10Videos"));return}if((((r=a.trainingImages)==null?void 0:r.length)||0)<3){u.error(s("toast.selectAtLeast3Images"));return}if(!pe){u.error(s("toast.readGuideFirst"));return}$.mutate()}};if(!p)return e.jsx(kt,{to:"/",replace:!0});const c=(a==null?void 0:a.status)==="draft",nt=(a==null?void 0:a.status)==="awaiting_start",ke=(a==null?void 0:a.status)==="training",Ce=(a==null?void 0:a.status)==="generating",Se=(a==null?void 0:a.status)==="preview_ready",it=(a==null?void 0:a.status)==="pending_review",ot=(a==null?void 0:a.status)==="approved",lt=(a==null?void 0:a.status)==="rejected",ct=(a==null?void 0:a.status)==="completed",W=(a==null?void 0:a.status)==="failed";return De?e.jsx("div",{className:"max-w-5xl mx-auto animate-fade-in flex items-center justify-center py-24",children:e.jsx(f,{className:"w-8 h-8 text-accent animate-spin"})}):a?e.jsxs("div",{className:"max-w-5xl mx-auto animate-fade-in",children:[e.jsxs("button",{onClick:()=>h("/train"),className:"flex items-center gap-2 text-sm text-foreground-muted hover:text-foreground transition-colors mb-6",children:[e.jsx(Me,{className:"w-4 h-4"}),s("config.backToTrain")]}),e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold",children:a.name}),e.jsx(Pt,{status:a.status})]}),ke&&e.jsx(At,{model:a}),Ce&&e.jsxs("div",{className:"bg-accent/10 border border-accent/20 rounded-xl p-4 mb-6 flex items-center gap-3",children:[e.jsx(f,{className:"w-5 h-5 text-accent animate-spin shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s("banner.generatingTitle")}),e.jsx("p",{className:"text-xs text-foreground-muted mt-0.5",children:s("banner.generatingDesc")})]})]}),Se&&e.jsxs("div",{className:"bg-purple-500/10 border border-purple-500/20 rounded-xl p-4 mb-6 flex items-center gap-3",children:[e.jsx(mt,{className:"w-5 h-5 text-purple-400 shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s("banner.previewReadyTitle")}),e.jsx("p",{className:"text-xs text-foreground-muted mt-0.5",children:s("banner.previewReadyDesc")})]})]}),it&&e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-xl p-4 mb-6 flex items-center gap-3",children:[e.jsx(ut,{className:"w-5 h-5 text-amber-400 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s("banner.pendingReviewTitle")}),e.jsx("p",{className:"text-xs text-foreground-muted mt-0.5",children:s("banner.pendingReviewDesc")})]})]}),ot&&e.jsxs("div",{className:"bg-success/10 border border-success/20 rounded-xl p-4 mb-6 flex items-center gap-3",children:[e.jsx(Re,{className:"w-5 h-5 text-success shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s("banner.approvedTitle")}),e.jsx("p",{className:"text-xs text-foreground-muted mt-0.5",children:s("banner.approvedDesc")})]})]}),lt&&e.jsx("div",{className:"bg-error/10 border border-error/20 rounded-xl p-4 mb-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(X,{className:"w-5 h-5 text-error shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s("banner.rejectedTitle")}),a.reviewNote&&e.jsx("p",{className:"text-xs text-error mt-0.5",children:a.reviewNote})]})]})}),ct&&e.jsxs("div",{className:"bg-success/10 border border-success/20 rounded-xl p-4 mb-6 flex items-center gap-3",children:[e.jsx(Re,{className:"w-5 h-5 text-success shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s("banner.completedTitle")}),e.jsx("p",{className:"text-xs text-foreground-muted mt-0.5",children:s("banner.completedDesc")}),a.completedAt&&e.jsx("p",{className:"text-xs text-foreground-muted mt-0.5",children:s("banner.completedAt",{date:new Date(a.completedAt).toLocaleStr
1ing()})})]})]}),W&&e.jsx("div",{className:"bg-error/10 border border-error/20 rounded-xl p-4 mb-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(X,{className:"w-5 h-5 text-error shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s("banner.failedTitle")}),a.error&&e.jsx("p",{className:"text-xs text-error mt-0.5",children:a.error})]})]})}),Ce&&a.previewVideos&&a.previewVideos.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-semibold mb-1",children:s("config.previewVideos")}),e.jsx("div",{className:"columns-2 sm:columns-3 md:columns-4 gap-3 space-y-3",children:a.previewVideos.map(t=>{const r=t.status==="completed"&&t.videoUrl;return e.jsx("div",{className:"break-inside-avoid",children:e.jsx("div",{className:"bg-background-card border-2 border-border rounded-xl overflow-hidden",children:r?e.jsx("video",{src:t.videoUrl,className:"w-full h-auto block",controls:!0,muted:!0,playsInline:!0,preload:"metadata"}):t.status==="failed"?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:t.imageUrl,className:"w-full h-auto block opacity-30",alt:""}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsx(X,{className:"w-5 h-5 text-error"})})]}):e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:t.imageUrl,className:"w-full h-auto block",alt:""}),e.jsxs("div",{className:"absolute inset-0 bg-background/50 flex flex-col items-center justify-center",children:[e.jsx(f,{className:"w-10 h-10 text-white animate-spin mb-3"}),e.jsx("p",{className:"text-sm font-medium text-white",children:s("config.processing")})]})]})})},t.id)})})]}),Se&&e.jsx("div",{className:"mb-6 flex justify-end",children:e.jsxs("button",{onClick:()=>K.mutate(),disabled:K.isPending,className:"flex items-center gap-2 bg-accent hover:bg-accent-hover text-white px-6 py-2.5 rounded-full text-sm font-semibold transition-colors disabled:opacity-50",children:[K.isPending?e.jsx(f,{className:"w-4 h-4 animate-spin"}):e.jsx(xt,{className:"w-4 h-4"}),s("config.sendToReview")]})}),ke&&a.trainingImages&&a.trainingImages.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-semibold mb-3",children:s("config.testingImages")}),e.jsx("div",{className:"columns-2 sm:columns-3 md:columns-4 lg:columns-5 gap-3 space-y-3",children:a.trainingImages.map(t=>e.jsx("div",{className:"break-inside-avoid",children:e.jsx("div",{className:"bg-background-card border border-border rounded-xl overflow-hidden",children:e.jsx("img",{src:t.url,alt:t.filename,className:"w-full h-auto block",loading:"lazy"})})},t.id))})]}),(c||W)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 mb-8",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:s("config.title")}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-foreground-muted mb-1.5 block",children:s("config.modelName")}),e.jsx("input",{type:"text",value:m,onChange:t=>N(t.target.value),onBlur:()=>P("name",m),disabled:!c,className:"w-full bg-background-input border border-border rounded-xl px-4 py-2.5 text-foreground text-sm focus:outline-none focus:border-accent disabled:opacity-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-foreground-muted mb-1.5 block",children:s("config.prompt")}),e.jsx("textarea",{value:R,onChange:t=>ue(t.target.value),onBlur:()=>P("prompt",R),disabled:!c,placeholder:s("config.promptPlaceholder"),rows:3,className:"w-full bg-background-input border border-border rounded-xl px-4 py-2.5 text-foreground text-sm focus:outline-none focus:border-accent resize-none disabled:opacity-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-foreground-muted mb-1.5 block",children:s("config.photoTips")}),e.jsx("textarea",{value:V,onChange:t=>ge(t.target.value),onBlur:()=>P("photoTips",V),disabled:!c,placeholder:s("config.photoTipsPlaceholder"),rows:2,maxLength:200,className:"w-full bg-background-input border border-border rounded-xl px-4 py-2.5 text-foreground text-sm focus:outline-none focus:border-accent resize-none disabled:opacity-50"}),e.jsxs("p",{className:"text-[10px] text-foreground-dim mt-1",children:[V.length,"/200 · ",s("config.photoTipsHint")]})]}),(p==null?void 0:p.isAdmin)&&e.jsxs("div",{className:"border border-dashed border-amber-500/30 rounded-xl p-3 bg-amber-500/5",children:[e.jsx("label",{className:"text-sm text-amber-400 mb-2 block font-medium",children:s("config.trainingStepsAdmin")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-amber-400/70 mb
1-1 block",children:s("config.lowSteps")}),e.jsx("input",{type:"number",value:M,onChange:t=>J(Number(t.target.value)),onBlur:()=>P("customLowSteps",M),disabled:!c,min:0,max:3e3,step:10,className:"w-full bg-background-input border border-border rounded-xl px-4 py-2.5 text-foreground text-sm focus:outline-none focus:border-amber-500 disabled:opacity-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-amber-400/70 mb-1 block",children:s("config.highSteps")}),e.jsx("input",{type:"number",value:ee,onChange:t=>te(Number(t.target.value)),onBlur:()=>P("customHighSteps",ee),disabled:!c,min:0,max:3e3,step:10,className:"w-full bg-background-input border border-border rounded-xl px-4 py-2.5 text-foreground text-sm focus:outline-none focus:border-amber-500 disabled:opacity-50"})]})]}),e.jsx("p",{className:"text-xs text-amber-400/70 mt-1.5",children:s("config.stepsAutoCalcHint")}),e.jsxs("div",{className:"mt-3 flex items-center gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:_,onChange:t=>{xe(t.target.checked),v.mutate({autoCaptions:t.target.checked})},disabled:!c,className:"rounded border-amber-500/50 text-amber-500 focus:ring-amber-500"}),e.jsx("span",{className:"text-sm text-amber-400",children:"Auto Captions"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:re,onChange:t=>{ne(t.target.checked),v.mutate({enableTransitions:t.target.checked})},disabled:!c,className:"rounded border-amber-500/50 text-amber-500 focus:ring-amber-500"}),e.jsx("span",{className:"text-sm text-amber-400",children:"Transitions"})]})]}),re&&e.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-amber-400/70 mb-1 block",children:"Static frames"}),e.jsx("input",{type:"number",min:0,max:30,value:ie,onChange:t=>oe(Number(t.target.value)),onBlur:()=>v.mutate({staticFrames:ie}),disabled:!c,className:"w-full bg-background-input border border-border rounded-xl px-4 py-2.5 text-foreground text-sm focus:outline-none focus:border-amber-500 disabled:opacity-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-amber-400/70 mb-1 block",children:"Transition frames"}),e.jsx("input",{type:"number",min:1,max:30,value:le,onChange:t=>ce(Number(t.target.value)),onBlur:()=>v.mutate({transitionFrames:le}),disabled:!c,className:"w-full bg-background-input border border-border rounded-xl px-4 py-2.5 text-foreground text-sm focus:outline-none focus:border-amber-500 disabled:opacity-50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-amber-400/70 mb-1 block",children:"Target persons"}),e.jsx("input",{type:"number",min:1,max:5,value:de,onChange:t=>me(Number(t.target.value)),onBlur:()=>v.mutate({targetPersons:de}),disabled:!c,className:"w-full bg-background-input border border-border rounded-xl px-4 py-2.5 text-foreground text-sm focus:outline-none focus:border-amber-500 disabled:opacity-50"})]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-amber-400/70 mb-1 block",children:"Quality (longest side)"}),e.jsxs("select",{value:Ve,onChange:t=>{const r=Number(t.target.value);se(r),v.mutate({trainQuality:r})},disabled:!c,className:"w-full bg-background-input border border-border rounded-xl px-4 py-2.5 text-foreground text-sm focus:outline-none focus:border-amber-500 disabled:opacity-50",children:[e.jsx("option",{value:720,children:"720p (fast)"}),e.jsx("option",{value:832,children:"832p (normal)"}),e.jsx("option",{value:960,children:"960p (high)"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-amber-400/70 mb-1 block",children:"Frames per sample"}),e.jsxs("select",{value:Qe,onChange:t=>{const r=Number(t.target.value);ae(r),v.mutate({trainFrames:r})},disabled:!c,className:"w-full bg-background-input border border-border rounded-xl px-4 py-2.5 text-foreground text-sm focus:outline-none focus:border-amber-500 disabled:opacity-50",children:[e.jsx("option",{value:33,children:"33 (~2s)"}),e.jsx("option",{value:49,children:"49 (~3s)"}),e.jsx("option",{value:65,children:"65 (~4s)"}),e.jsx("option",{value:81,children:"81 (~5s)"})]})]})]})]})]})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold mb-4",children:s("config.requirements")}),e.jsxs("div",{className:"bg-background-card border border-border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-4 px-5 py-4 border-b border-border",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-accent/10 flex items-center justify-center shrink-0",children:e.jsx(Le,{className:"w-5 h-5 text-accent"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s("config.trainingVideos")}),e.jsx("p",{className:"text-xs text-foreground-dim mt-0.5",children:s("config.trainingVideosDesc")})]}),e.jsx("span",{className:"text-xs bg-accent/15 text-accent px-3 py-1.5 rounded-full font-semibold whitespace-nowrap",children:s("config.trainingVideosRange")})]}),e.jsxs("div",{className:"flex items-center gap-4 px-5 py-4 border-b border-border",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-accent/10 flex items-center justify-center shrink-0",children:e.jsx(ze,{className:"w-5 h-5 text-accent"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s("config.testingImages")}),e.jsx("p",{className:"text-xs text-foreground-dim mt-0.5",children:s("config.testingImagesDesc")})]}),e.jsx("span",{className:"text-xs bg-accent/15 text-accent px-3 py-1.5 rounded-full font-semibold whitespace-nowrap",children:s("config.testingImagesRange")})]}),e.jsxs("div",{className:"flex items-center gap-4 px-5 py-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-accent/10 flex items-center justify-center shrink-0",children:e.jsx(gt,{className:"w-5 h-5 text-accent"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:s("config.cost")}),e.jsx("p",{className:"text-xs text-foreground-dim mt-0.5",children:s("config.costDesc")})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1",children:[e.jsxs("span",{className:"text-xs bg-gradient-to-r from-rose-500 to-orange-400 text-white px-3 py-1.5 rounded-full font-bold whitespace-nowrap flex items-center gap-1.5",children:[e.jsx(qe,{className:"w-3.5 h-3.5"}),(g==null?void 0:g.price)??"..."," ",s("config.credits")]}),(g==null?void 0:g.isFirstTraining)&&g.discount>0&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[10px] text-foreground-dim line-through",children:g.basePrice}),e.jsx("span",{className:"text-[10px] font-semibold text-rose-400",children:s("config.firstTrainingDiscount",{percent:Math.round(g.discount*100)})})]})]})]})]}),e.jsxs(Ee,{to:"/train-tutorial",className:"flex items-center gap-2.5 mt-4 px-5 py-3.5 bg-background-card border border-border rounded-xl hover:border-accent/40 transition-colors group",children:[e.jsx(bt,{className:"w-4.5 h-4.5 text-accent shrink-0"}),e.jsx("span",{className:"text-sm text-foreground-muted group-hover:text-foreground transition-colors",children:s("config.viewTutorial")}),e.jsx(Me,{className:"w-4 h-4 text-foreground-dim rotate-180 ml-auto shrink-0"})]})]})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("h3",{className:"font-semibold",children:s("config.trainingVideos")}),e.jsxs("span",{className:"text-xs bg-background-elevated text-foreground-muted px-2 py-1 rounded-full",children:[((Te=a.trainingVideos)==null?void 0:Te.length)||0,"/20"]})]}),c&&e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>{var t;return(t=x.current)==null?void 0:t.click()},onDrop:at,onDragOver:t=>t.preventDefault(),className:"border-2 border-dashed border-border rounded-2xl p-8 text-center cursor-pointer hover:border-accent/50 transition-colors mb-4",children:G.isPending?e.jsxs("div",{className:"space-y-2",children:[e.jsx(f,{className:"w-8 h-8 text-accent mx-auto animate-spin"}),e.jsx("p",{className:"text-sm text-foreground-muted",children:s("config.uploading",{percent:Math.round(be*100)})}),e.jsx("div",{className:"w-48 h-1.5 bg-background-elevated rounded-full mx-auto overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent rounded-full transition-all",style:{width:`${be*100}%`}})})]}):e.jsxs(e.Fragment,{children:[e.jsx(pt,{className:"w-8 h-8 text-foreground-dim mx-auto mb-2"}),e.jsx("p",{className:"text-accent font-medium text-sm",children:s("config.uploadVideos")}),e.jsx("p",{className:"text-xs text-foreground-dim mt-1",children:s("config.dragAndDrop")})]})}),e.jsx("input",{ref:x,type:"file",accept:"video/*",multiple:!0,className:"hidden",onChange:st})]}),a.trainingVideos&&a.trainingVideos.length>0&&e.jsx("div",{className:"columns-2 sm:columns-3 md:columns-4 lg:columns-5 gap-3 space-y-3",children:a.trainingVideos.map(t=>e.jsxs("div",{className:"relative group break-inside-avoid",children:[e.jsxs("div",{className:"bg-background-card border border-border rounded-xl overflow-hidden",children:[e.jsx("video",{src:t.url,className:"w-full h-auto block",muted:!0,playsInl
1ine:!0,preload:"metadata",onMouseEnter:r=>St(r.target),onMouseLeave:r=>{const o=r.target;o.pause(),o.currentTime=0}}),e.jsxs("div",{className:"px-2.5 py-2 flex items-center gap-2",children:[e.jsx(Le,{className:"w-3 h-3 text-foreground-dim shrink-0"}),e.jsx("p",{className:"text-[11px] text-foreground-dim truncate",children:t.filename})]})]}),c&&e.jsx("button",{onClick:()=>He.mutate(t.id),className:"absolute top-1.5 right-1.5 w-6 h-6 rounded-full bg-black/70 backdrop-blur-sm flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-error/80",children:e.jsx(Y,{className:"w-3 h-3 text-white"})})]},t.id))})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("h3",{className:"font-semibold",children:s("config.testingImages")}),e.jsxs("span",{className:"text-xs bg-background-elevated text-foreground-muted px-2 py-1 rounded-full",children:[((Ie=a.trainingImages)==null?void 0:Ie.length)||0,"/6"]})]}),e.jsx("p",{className:"text-xs text-foreground-dim mb-3",children:a.photoTips||s("config.defaultPhotoTips")}),a.trainingImages&&a.trainingImages.length>0&&e.jsx("div",{className:"columns-2 sm:columns-3 md:columns-4 lg:columns-5 gap-3 space-y-3 mb-4",children:a.trainingImages.map(t=>e.jsxs("div",{className:"relative group break-inside-avoid",children:[e.jsx("div",{className:"bg-background-card border border-border rounded-xl overflow-hidden",children:e.jsx("img",{src:t.url,alt:t.filename,className:"w-full h-auto block",loading:"lazy"})}),c&&e.jsx("button",{onClick:()=>Ze.mutate(t.id),className:"absolute top-1.5 right-1.5 w-6 h-6 rounded-full bg-black/70 backdrop-blur-sm flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity hover:bg-error/80",children:e.jsx(Y,{className:"w-3 h-3 text-white"})})]},t.id))}),c&&e.jsxs("button",{onClick:Je,className:"flex items-center gap-2 text-sm text-accent hover:text-accent-light transition-colors",children:[e.jsx(ze,{className:"w-4 h-4"}),(((Fe=a.trainingImages)==null?void 0:Fe.length)||0)>0?s("config.editSelection"):s("config.chooseFromGallery")]})]}),e.jsxs("div",{className:"flex items-center justify-between pb-8",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[(c||W)&&e.jsxs("button",{onClick:()=>L(!0),className:"flex items-center gap-2 text-sm text-error hover:text-error/80 transition-colors",children:[e.jsx(ht,{className:"w-4 h-4"}),s("config.delete")]}),(p==null?void 0:p.isAdmin)&&e.jsxs("button",{onClick:async()=>{try{const t=await b.clone(n);window.location.href=`/train/${t.id}`}catch{u.error("Failed to clone")}},className:"flex items-center gap-2 text-sm text-foreground-muted hover:text-foreground transition-colors",children:[e.jsx(ft,{className:"w-4 h-4"}),"Clone"]})]}),e.jsxs("div",{className:"flex flex-col items-end gap-3",children:[nt&&e.jsxs("div",{className:"bg-orange-500/10 border border-orange-500/30 rounded-xl px-4 py-3 text-center",children:[e.jsx("p",{className:"text-sm text-orange-400 font-medium",children:"Submitted for review"}),e.jsx("p",{className:"text-xs text-orange-400/70 mt-1",children:"An admin will review your videos and start training shortly."})]}),c&&e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[e.jsx(It,{checked:pe,onCheckedChange:Ge}),e.jsxs("span",{className:"text-xs text-foreground-muted",children:[s("config.iHaveReadThe")," ",e.jsx(Ee,{to:"/train-tutorial",target:"_blank",className:"text-accent hover:underline",children:s("config.trainingGuide")})]})]}),e.jsxs("button",{onClick:rt,disabled:$.isPending||!R.trim()&&!_,className:"flex items-center gap-2 bg-accent hover:bg-accent-hover text-white px-6 py-2.5 rounded-full text-sm font-semibold transition-colors disabled:opacity-50",children:[$.isPending?e.jsx(f,{className:"w-4 h-4 animate-spin"}):e.jsx(qe,{className:"w-4 h-4"}),s("config.startTraining")]})]})]})]})]}),B&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:()=>{k(!1),C(new Map)},children:e.jsxs("div",{className:"bg-background-elevated rounded-2xl w-full max-w-4xl max-h-[80vh] sm:max-h-[85vh] border border-border shadow-2xl flex flex-col",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border shrink-0",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg",children:s("gallery.title")}),e.jsxs("p",{className:"text-xs text-foreground-dim mt-0.5",children:[s("gallery.selected",{count:((Ae=a.trainingImages)==null?void 0:Ae.length)||0})," · ",s("gallery.pending",{count:j.size})," · ",s("gallery.remaining",{count:6-(((Pe=a.trainingImages)==null?void 0:Pe.length)||0)-j.size})]})]}),e.jsx("button",{onClick:()=>{k(!1),C(new Map)},className:"w-8 h-8 rounded-full bg-background-card flex items-center justify-center hover:bg-background-input transition-colors",children:e.jsx(Y,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"relative shrink-0 border-b border-border",children:[H&&e.jsx("button",{type:"button","aria-label":"Scroll categories left",onClick:()=>ve(-200),className:"absolute left-1 top-1/2 -translate-y-1/2 z-10 w-7 h-7 rounded-full bg-background-card/90 backdrop-blur-sm border border-border flex items-center justify-center hover:bg-background-input transition-colors",children:e.jsx(jt,{className:"w-4 h-4"})}),U&&e.jsx("button",{type:"button","aria-label":"Scroll categories right",onClick:()=>ve(200),className:"absolute right-1 top-1/2 -translate-y-1/2 z-10 w-7 h-7 rounded-full bg-background-card/90 backdrop-blur-sm border border-border flex items-center justify-center hover:bg-background-input transition-colors",children:e.jsx(vt,{className:"w-4 h-4"})}),e.jsx("div",{ref:q,className:"flex gap-1.5 px-3 sm:px-6 py-3 overflow-x-auto scrollbar-none",onWheel:t=>{Math.abs(t.deltaY)>Math.abs(t.deltaX)&&(t.currentTarget.scrollLeft+=t.deltaY)},style:{WebkitOverflowScrolling:"touch",maskImage:`linear-gradient(to right, ${H?"transparent 0%, black 6%":"black 0%"}, ${U?"black 94%, transparent 100%":"black 100%"})`,WebkitMaskImage:`linear-gradient(to right, ${H?"transparent 0%, black 6%":"black 0%"}, ${U?"black 94%, transparent 100%":"black 100%"})`},children:je.map(t=>{const r=Oe.has(t);return e.jsxs("button",{onClick:()=>{fe(t),I(1)},className:`px-3 py-1.5 rounded-full text-xs font-medium whitespace-nowrap transition-colors ${D===t?"bg-accent text-white":"bg-background-card text-foreground-muted hover:text-foreground hover:bg-background-input"} ${r?"ring-1 ring-amber-400/40":""}`,title:r?"Hidden from regular users (admin-only)":void 0,children:[r&&e.jsx("span",{className:"mr-1",children:"ð"}),s(`gallery.category.${t}`,{defaultValue:t.charAt(0).toUpperCase()+t.slice(1)})]},t)})})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4 sm:p-6",style:{WebkitOverflowScrolling:"touch"},children:d?Ne.length===0?e.jsx("p",{className:"text-sm text-foreground-dim text-center py-16",children:s("gallery.noImages")}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-2.5",children:Ne.map(t=>{var y;const r=(y=a.trainingImages)==null?void 0:y.some(E=>E.url===t.url),o=j.has(t.id),S=r||o;return e.jsx(Ft,{url:t.url,blurDataUrl:t.blurDataUrl,filename:t.filename,alreadySelected:!!r,isPending:o,isActive:!!S,onClick:()=>{r||et(t.id,t.url,t.filename)}},t.id)})}),A&&A.totalPages>1&&e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[e.jsx("button",{onClick:()=>I(t=>Math.max(1,t-1)),disabled:T<=1||z,className:"px-3 py-1.5 rounded-lg text-xs font-medium bg-background-card hover:bg-background-input disabled:opacity-30 transition-colors",children:"â"}),Array.from({length:A.totalPages},(t,r)=>r+1).map(t=>e.jsx("button",{onClick:()=>I(t),disabled:z,className:`w-8 h-8 rounded-lg text-xs font-medium transition-colors ${t===T?"bg-accent text-white":"bg-background-card hover:bg-background-input text-foreground-muted"}`,children:t},t)),e.jsx("button",{onClick:()=>I(t=>Math.min(A.totalPages,t+1)),disabled:T>=A.totalPages||z,className:"px-3 py-1.5 rounded-lg text-xs font-medium bg-background-card hover:bg-background-input disabled:opacity-30 transition-colors",children:"â"}),z&&e.jsx(f,{className:"w-4 h-4 text-accent animate-spin ml-2"})]})]}):e.jsx("div",{className:"flex justify-center py-16",children:e.jsx(f,{className:"w-6 h-6 text-accent animate-spin"})})}),e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-border shrink-0",children:[e.jsx("button",{onClick:()=>{k(!1),C(new Map)},className:"px-4 py-2 text-sm text-foreground-muted hover:text-foreground transition-colors",children:s("common:cancel")}),e.jsxs("button",{onClick:tt,disabled:ye||j.size===0,className:"flex items-center gap-2 bg-accent hover:bg-accent-hover text-white px-5 py-2.5 rounded-full text-sm font-semibold transition-colors disabled:opacity-50",children:[ye?e.jsx(f,{className:"w-4 h-4 animate-spin"}):e.jsx(_e,{className:"w-4 h-4"}),j.size>0?s("gallery.confirmCount",{count:j.size}):s("gallery.confirm")]})]})]})}),Be&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4",onClick:()=>L(!1),children:e.jsxs("div",{className:"bg-background-elevated rounded-2xl w-full max-w-sm border border-border shadow-2xl p-6",onClick:t=>t.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(Nt,{className:"w-5 h-5 text-error"}),e.jsx("h3",{className:"font-semibold",children:s("deleteModal.title")})]}),e.jsx("p",{className:"text-sm text-foreground-muted mb-6",children:s("deleteModal.description",{name:a.name})}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx("button",{onClick:()=>L(!1),className:"px-4 py-2 text-sm text-foreground-muted hover:text-foreground transition-colors",children:s("common:cancel")}),e.jsx("button",{onClick:()=>{L(!1),Ue.mutate()},className:"px-4 py-2 bg-error hover:bg-error/80 text-white rounded-lg text-sm font-medium transition-colors",children:s("config.delete")})]})]})})]}):e.jsx("div",{className:"max-w-5xl mx-auto animate-fade-in text-center py-24",children:e.jsx("p",{className:"text-foreground-muted",children:s("config.modelNotFound")})})}function At({model:s}){const{t:n}=Z("train"),h={preparing:n("phase.preparing"),captioning:n("phase.captioning"),caching:n("phase.caching"),training:n("phase.training"),uploading:n("phase.uploading"),generating_previews:n("phase.generatingPreviews"),preview_ready:n("phase.previewReady"),completed:n("phase.completed")},l=s.trainSteps||s.customHighSteps||800,p=s.currentStep||0,x=s.currentPhase||"preparing";let m=0;x==="preparing"?m=2:x==="captioning"?m=7:x==="caching"?m=12:x==="training"?m=15+p/l*80:x==="uploading"?m=97:x==="completed"&&(m=100),m=Math.min(100,Math.max(0,m));const N=x!=="completed"?n("progress.etaText"):"";return e.jsxs("div",{className:"bg-accent/10 border border-accent/20 rounded-xl p-5 mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx(f,{className:"w-5 h-5 text-accent animate-spin shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:h[x]||n("progress.inProgress")}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[s.startedAt&&e.jsx("p",{className:"text-xs text-foreground-muted",children:n("progress.startedAt",{date:new Date(s.startedAt).toLocaleStr
1ing()})}),N&&e.jsx("p",{className:"text-xs text-accent font-medium",children:N})]})]})]}),e.jsx("div",{className:"w-full h-2 bg-background-elevated rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent rounded-full transition-all duration-1000 ease-out",style:{width:`${m}%`}})}),e.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[e.jsx("span",{className:"text-[10px] text-foreground-dim capitalize",children:x}),e.jsxs("span",{className:"text-[10px] text-foreground-dim",children:[Math.round(m),"%"]})]})]})}function Pt({status:s}){const{t:n}=Z("train"),h={draft:{label:n("status.draft"),color:"bg-background-elevated text-foreground-muted"},awaiting_start:{label:"Awaiting Review",color:"bg-orange-500/20 text-orange-400"},training:{label:n("status.training"),color:"bg-accent/20 text-accent"},generating:{label:n("status.generating"),color:"bg-blue-500/20 text-blue-400"},preview_ready:{label:n("status.preview_ready"),color:"bg-purple-500/20 text-purple-400"},pending_review:{label:n("status.pending_review"),color:"bg-amber-500/20 text-amber-400"},approved:{label:n("status.approved"),color:"bg-success/20 text-success"},rejected:{label:n("status.rejected"),color:"bg-error/20 text-error"},completed:{label:n("status.completed"),color:"bg-success/20 text-success"},failed:{label:n("status.failed"),color:"bg-error/20 text-error"}},l=h[s]||h.draft;return e.jsx("span",{className:`text-xs px-2.5 py-1 rounded-full font-medium ${l.color}`,children:l.label})}export{Vt 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.