PageSourceSearch

https://story-prompt.ai/assets/StorySettingsModal-HnXFB2qh.js

js story-prompt.ai collected 2026-10-05 16:21:16 UTC 29,424 bytes, 5 lines download raw bytes

1import{j as e,u as B,n as ne,o as oe,h as de,m as ce,p as xe,q as me}from"./index-BlP-uOVz.js";import{b as he,r as n}from"./react-vendor-1453rJBm.js";import{M as pe,D as ue,b as be,d as fe,A as ge,R as we,e as ye}from"./StudioApp-BB2cRYcN.js";import{u as J}from"./useFeatureAccess-BuOd8dpV.js";import{b as je,u as ve,s as re,a as Ne,c as F}from"./ToastContext-CUeYy5o_.js";import{g as ke}from"./ideation-Dg-LvOEp.js";import{P as T}from"./PortalTooltip-D9cQKI-Y.js";import"./supabase-vendor--UE4jgTP.js";import"./SmartTooltip-CUvSFIgU.js";import"./ConfirmationModal-Cd1R32os.js";import"./projectService-DaK3raYN.js";const ee=({isOpen:a,onClose:r,title:k,icon:E,options:f,selectedValue:M,onSelect:g})=>a?he.createPortal(e.jsx("div",{className:"fixed inset-0 flex items-center justify-center z-[100] p-4 pointer-events-none",children:e.jsxs("div",{className:"glass-panel rounded-2xl overflow-hidden flex flex-col w-full max-w-lg shadow-2xl animate-fade-in pointer-events-auto",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/5 bg-black/20 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/90 font-medium text-sm",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-primary",children:E}),e.jsx("span",{className:"font-medium",children:k})]}),e.jsx("button",{onClick:r,className:"size-6 rounded-full bg-white/5 hover:bg-white/10 flex items-center justify-center text-white/50 hover:text-white transition-colors",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),e.jsx("div",{className:"overflow-y-auto no-scrollbar p-3 max-h-[60vh]",children:e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:f.map(i=>{const d=i.value===M;return e.jsxs("button",{onClick:()=>{g(i.value),r()},className:`group relative aspect-[4/3] rounded-xl border transition-all overflow-hidden text-left ${d?"border-primary/40 ring-1 ring-primary/20":"border-white/5 hover:border-white/20"}`,children:[e.jsx("div",{className:"absolute inset-0 transition-transform duration-300 group-hover:scale-105",style:{background:i.gradient}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent opacity-90 group-hover:opacity-70 transition-opacity"}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx("span",{className:`material-symbols-outlined text-[20px] drop-shadow-md ${d?"text-primary-light":"text-white/60"}`,children:i.icon})}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-2",children:[e.jsx("h4",{className:"text-[11px] font-medium text-white leading-tight",children:i.label}),i.description&&e.jsx("p",{className:"text-[9px] text-white/40 leading-snug mt-0.5 line-clamp-2",children:i.description})]}),d&&e.jsx("div",{className:"absolute top-1.5 right-1.5 size-5 rounded-full bg-primary text-white flex items-center justify-center",children:e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"check"})})]},i.value)})})})]})}),document.body):null,W=n.forwardRef(({localSettings:a,onFieldChange:r,assets:k,dossiers:E,shots:f,modelId:M,genreOptions:g,endingOptions:i},d)=>{const{t:m}=B(),{canAccess:l}=J(),b=n.useRef(null),[w,q]=n.useState([]),[_,z]=n.useState(!1),[j,p]=n.useState(!1),[v,D]=n.useState(!1),[o,c]=n.useState(!1),[V,y]=n.useState(!1),[h,S]=n.useState(!1),[N,$]=n.useState(null),A=async()=>{if(k.length!==0){z(!0),p(!0),q([]);try{const t=await ke(k,a,M);q(t)}catch(t){console.error("Failed to generate story ideas:",t)}finally{z(!1)}}},I=()=>{w.length===0&&!_&&!j?A():p(t=>!t)},R=t=>{r("prompt",t),p(!1)},x=t=>{const P=N,L=a.prompt;P!==null?r("prompt",L.slice(0,P)+t+L.slice(P)):r("prompt",L.trim()?`${L.trim()} ${t}`:t),$(null)},u=t=>{$(b.current?.getCursorPosition()??a.prompt.length),t(!0)},G=t=>{x(`@${t.roleLabel} `),D(!1)},O=t=>{x(`#${t} `),c(!1)};return n.useImperativeHandle(d,()=>({openDossierPicker:()=>u(D),openShotPicker:()=>u(c)})),e.jsxs(e.Fragment,{children:[e.jsxs("fieldset",{disabled:a.mode==="auto",className:"flex-1 flex flex-col gap-3 min-h-0 disabled:opacity-50 transition-opacity",children:[e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsx("label",{className:"text-[10px] font-medium text-white/40 uppercase tracking-wider",children:m(j?"storyModal.ideaSelect":"storyModal.ideaLabel")}),e.jsxs("div",{className:"flex items-center gap-2",children:[j&&e.jsxs("button",{onClick:A,disabled:_||k.length===0,className:"text-[10px] font-medium text-white/50 hover:text-primary flex items-center gap-1 transition-colors px-2 py-1 rounded hover:bg-white/5",children:[e.jsx("span",{className:`material-symbols-outlined text-[14px] ${_?"animate-spin":""}`,children:"refresh"}),m("storyModal.refresh")]}),e.jsxs("button",{onClick:I,disabled:k.length===0,className:`flex items-center gap-1.5 text-[10px] font-medium transition-all px-2 py-1 rounded-lg ${j?"bg-white/10 text-white":"bg-primary/15 text-primary hover:bg-primary/25"} disabled:opacity-50 disabled:cursor-not-allowed`,children:[e.jsx("span",{className:`material-symbols-outlined text-[14px] ${_?"animate-spin":""}`,children:_?"sync":j?"edit":"lightbulb"}),e.jsx("span",{children:m(j?"storyModal.editor":"storyModal.ideas")})]})]})]}),e.jsx("div",{className:"flex-1 min-h-0 relative",children:j?e.jsx("div",{className:"absolute inset-0 overflow-y-auto custom-scrollbar",children:_?e.jsx("div",{className:"grid grid-cols-1 gap-2",children:Array.from({length:3}).map((t,P)=>e.jsx("div",{className:"h-16 bg-white/5 rounded-xl animate-pulse"},P))}):e.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[w.map((t,P)=>e.jsx(T,{text:t.synopsis,maxWidth:"400px",children:e.jsxs("button",{onClick:()=>R(t.synopsis),className:"w-full p-3 rounded-xl text-left bg-black/60 border border-white/5 hover:border-primary/30 hover:bg-primary/10 transition-all group",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"material-symbols-outlined text-primary text-sm",children:"auto_awesome"}),e.jsx("p",{className:"font-medium text-xs text-white group-hover:text-primary-light transition-colors",children:t.title})]}),e.jsx("p",{className:"text-[11px] text-white/50 line-clamp-2 leading-relaxed",children:t.synopsis})]})},P)),w.length===0&&e.jsx("div",{className:"py-8 text-center text-xs text-white/30 border border-dashed border-white/10 rounded-xl",children:m("storyModal.generatePlaceholder")})]})}):e.jsxs("div",{className:"relative w-full h-full",children:[e.jsx(pe,{ref:b,value:a.prompt,onChange:t=>r("prompt",t),dossiers:E,shots:f,placeholder:m("storyModal.promptPlaceholder"),className:"w-full h-full bg-black/60 border border-white/5 focus:border-primary/30 rounded-xl text-sm placeholder:text-white/25 resize-none no-scrollbar leading-relaxed outline-none transition-colors pr-8"}),a.prompt&&e.jsx("button",{onClick:()=>r("prompt",""),className:"absolute top-2 right-2 size-5 flex items-center justify-center rounded-md bg-white/10 hover:bg-white/20 text-white/50 hover:text-white transition-all z-30",type:"button",children:e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"close"})})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>l("story_genre_selection")&&y(!0),disabled:!l("story_genre_selection"),className:`flex items-center gap-2 bg-black/60 border border-white/5 hover:border-white/15 text-xs rounded-xl px-3 py-2.5 transition-all group ${l("story_genre_selection")?"":"opacity-40 cursor-not-allowed"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-sm text-white/40 group-hover:text-primary transition-colors",children:g.find(t=>t.value===a.genre)?.icon||"shuffle"}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"text-[9px] text-white/30 uppercase tracking-wider leading-none",children:m("storyModal.genre")}),e.jsx("span",{className:`text-[11px] font-medium truncate ${a.genre?"text-white/90":"text-white/50"}`,children:a.genre||m("storyModal.any")})]})]}),e.jsxs("button",{type:"button",onClick:()=>l("story_ending_selection")&&S(!0),disabled:!l("story_ending_selection"),className:`flex items-center gap-2 bg-black/60 border border-white/5 hover:border-white/15 text-xs rounded-xl px-3 py-2.5 transition-all group ${l("story_ending_selection")?"":"opacity-40 cursor-not-allowed"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-sm text-white/40 group-hover:text-primary transition-colors",children:i.find(t=>t.value===a.ending)?.icon||"smart_toy"}),e.jsxs("div",{className:"flex flex-col items-start min-w-0",children:[e.jsx("span",{className:"text-[9px] text-white/30 uppercase tracking-wider leading-none",children:m("storyModal.ending")}),e.jsx("span",{className:`text-[11px] font-medium truncate ${a.ending?"text-white/90":"text-white/50"}`,children:a.ending||m("storyModal.aiDecide")})]})]})]})]}),v&&e.jsx(ue,{dossiers:E,frames:[],onClose:()=>D(!1),onSelectDossier:G}),o&&e.jsx(be,{shots:f,onClose:()=>c(!1),onSelectShot:O}),e.jsx(ee,{isOpen:V,onClose:()=>y(!1),title:m("storyModal.genre"),icon:"movie",options:g,selectedValue:a.genre,onSelect:t=>r("genre",t)}),e.jsx(ee,{isOpen:h,onClose:()=>S(!1),title:m("storyModal.ending"),icon:"flag",options:i,selectedValue:a.ending,onSelect:t=>r("ending",t)})]})});W.displayName="StoryPromptSection";const te=({localSettings:a,onFieldChange:r,onOpenStyleModal:k,onOpenDossierPicker:E,onOpenShotPicker:f,frameCount:M,onFrameCountChange:g,maxFrames:i,tierMaxFrames:d,estimatedCost:m,isLimited:l,isByokTier:b,hasActiveByokKey:w,isProModel:q,planningCost:_,costPerFrame:z,onSave:j,onClose:p,isCompactLayout:v,hideActions:D})=>{const{t:o}=B(),{canAccess:c,getLimit:V}=J(),{showFeatureUpgrade:y}=je(),{notify:h}=ve(),S=re.getSettings().models.generationModel,N=c("story_qc_autofix"),$=N?Math.max(1,V("story_qc_max_versions")||3):0,A=Math.min(3,$||1),I=a.qcAutofixEnabled!==!1&&N,R=Math.max(1,Math.min(a.qcMaxVersions??A,$||1
1));return n.useEffect(()=>{a.parallelMode===!1&&!c("story_sequential_mode")?c("story_parallel_mode")&&r("parallelMode",!0):a.parallelMode!==!1&&!c("story_parallel_mode")&&c("story_sequential_mode")&&r("parallelMode",!1)},[a.parallelMode,c,r]),e.jsxs("div",{className:`flex flex-col gap-3 ${v?"w-full":"w-[240px] shrink-0"}`,children:[e.jsxs("div",{className:"bg-black/30 border border-white/5 rounded-xl p-3 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[10px] font-medium text-white/40 uppercase tracking-wider",children:o("editMode.toolsLabel")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{text:o("advModal.dossierBtn"),children:e.jsx("button",{onClick:E,disabled:a.mode==="auto"||!c("story_dossier_mentions"),className:"w-8 h-8 flex items-center justify-center rounded-lg border border-white/10 bg-black/40 hover:bg-white/5 hover:border-white/20 transition-all group shrink-0 disabled:opacity-50",children:e.jsx("span",{className:"material-symbols-outlined text-[16px] text-white/50 group-hover:text-amber-400",children:"folder_shared"})})}),e.jsx(T,{text:o("advModal.shotsLibrary"),children:e.jsx("button",{onClick:f,disabled:a.mode==="auto"||!c("story_shot_mentions"),className:"w-8 h-8 flex items-center justify-center rounded-lg border border-white/10 bg-black/40 hover:bg-white/5 hover:border-white/20 transition-all group shrink-0 font-bold text-sm text-white/50 group-hover:text-cyan-400 disabled:opacity-50",children:"#"})}),e.jsx(fe,{config:a.styleConfig,onClick:k,className:"flex-1 !h-8 bg-black/40 border-white/10 hover:bg-white/5 text-[10px]"})]})]}),e.jsx("div",{className:"h-px bg-white/5"}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[10px] font-medium text-white/40 uppercase tracking-wider",children:o("editMode.settingsLabel")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(ge,{value:a.aspectRatio||"Auto",onChange:x=>r("aspectRatio",x),compact:!0,availableRatios:ne(S)})}),e.jsx("div",{className:"flex-1",children:e.jsx(we,{value:a.resolution||"1K",onChange:x=>r("resolution",x),compact:!0,disabled:!q,disabledReason:q?void 0:o("selectors.proOnly"),availableResolutions:oe(S)})})]})]}),e.jsx("div",{className:"h-px bg-white/5"}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-[10px] font-medium text-white/40 uppercase tracking-wider",children:o("storyModal.framesCount")}),i>0&&e.jsx("span",{className:"text-xs font-bold text-white",children:Math.min(M,i)})]}),i>0||d>0?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"range",min:"1",max:20,value:M,onChange:x=>{const u=parseInt(x.target.value,10);d>0&&u>d&&!b&&!w?(g(u),y("story_max_frames"),setTimeout(()=>g(d),600)):i>0&&u>i&&!b&&!w?(g(u),h(`Кредитов хватит максимум на ${i} кадров`,"warning"),setTimeout(()=>g(i),600)):g(u)},className:"w-full h-1.5 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3.5 [&::-webkit-slider-thumb]:h-3.5 [&::-webkit-slider-thumb]:bg-primary [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:relative [&::-webkit-slider-thumb]:z-10",style:{background:d<20?`linear-gradient(to right, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.1) ${d/20*100}%, rgba(251,191,36,0.15) ${d/20*100}%, rgba(251,191,36,0.08) 100%)`:"rgba(255,255,255,0.1)"}}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[d<20&&!b&&!w?e.jsx(T,{text:`Макс. ${d} кадров на вашем тарифе (до 20 на платном)`,children:e.jsxs("p",{className:"text-[9px] text-amber-400/70 flex items-center gap-0.5 cursor-help whitespace-nowrap",children:[e.jsx("span",{className:"material-symbols-outlined text-[10px]",children:"lock"}),d,"/20"]})}):l&&!b&&!w?e.jsx("p",{className:"text-[9px] text-yellow-400 whitespace-nowrap",children:o("storyModal.limitedFrames",{max:i})}):e.jsx("span",{}),!b&&!w&&e.jsx(T,{text:`Стоимость генерации ${M} кадров — будет списано при запуске`,children:e.jsxs("p",{className:"text-[9px] text-white/40 flex items-center gap-0.5 cursor-help whitespace-nowrap",children:[e.jsx("span",{className:"material-symbols-outlined text-[10px]",children:"payments"}),"~",m," кр."]})})]})]}):!b&&!w&&e.jsxs("p",{className:"text-[9px] text-red-400 flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[10px]",children:"error"}),o("storyModal.notEnoughCredits",{cost:_+z})]})]}),e.jsx("div",{className:"h-px bg-white/5"}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-[10px] font-medium text-white/40 uppercase tracking-wider",children:o("storyModal.generationMode")}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs("button",{onClick:()=>r("parallelMode",!0),disabled:!c("story_parallel_mode"),className:`flex-1 h-7 rounded-lg text-[10px] font-medium transition-all flex items-center justify-center gap-1 disabled:opacity-30 disabled:cursor-not-allowed
2                                ${a.parallelMode!==!1?"bg-cyan-500/20 border border-cyan-400/30 text-cyan-300":"bg-black/40 border border-white/10 text-white/40 hover:text-white/60"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"bolt"}),o("storyModal.parallelMode")]}),e.jsxs("button",{onClick:()=>r("parallelMode",!1),disabled:!c("story_sequential_mode"),className:`flex-1 h-7 rounded-lg text-[10px] font-medium transition-all flex items-center justify-center gap-1 disabled:opacity-30 disabled:cursor-not-allowed
3                                ${a.parallelMode===!1?"bg-amber-500/20 border border-amber-400/30 text-amber-300":"bg-black/40 border border-white/10 text-white/40 hover:text-white/60"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"movie_creation"}),o("storyModal.sequentialMode")]})]}),e.jsx("p",{className:"text-[9px] text-white/30",children:a.parallelMode!==!1?o("storyModal.parallelModeDesc"):o("storyModal.sequentialModeDesc")})]}),e.jsx("div",{className:"h-px bg-white/5"}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-1",children:[e.jsxs("label",{className:"text-[10px] font-medium text-white/40 uppercase tracking-wider flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[12px] text-emerald-400/80",children:"verified"}),"Режиссёр-перфекционист"]}),!N&&e.jsx(T,{text:"Доступно на платных тарифах",children:e.jsx("span",{className:"material-symbols-outlined text-[12px] text-amber-400/70 cursor-help",children:"lock"})})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs("button",{onClick:()=>
3{if(!N){y("story_qc_autofix");return}r("qcAutofixEnabled",!0),a.qcMaxVersions||r("qcMaxVersions",A)},disabled:!N,className:`flex-1 h-7 rounded-lg text-[10px] font-medium transition-all flex items-center justify-center gap-1 disabled:opacity-30 disabled:cursor-not-allowed
4                                ${I?"bg-emerald-500/20 border border-emerald-400/30 text-emerald-300":"bg-black/40 border border-white/10 text-white/40 hover:text-white/60"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"auto_fix_high"}),"Включено"]}),e.jsxs("button",{onClick:()=>r("qcAutofixEnabled",!1),className:`flex-1 h-7 rounded-lg text-[10px] font-medium transition-all flex items-center justify-center gap-1
5                                ${I?"bg-black/40 border border-white/10 text-white/40 hover:text-white/60":"bg-white/10 border border-white/20 text-white/70"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[12px]",children:"close"}),"Выключено"]})]}),I&&$>1&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between mt-0.5",children:[e.jsx("label",{className:"text-[9px] font-medium text-white/40 uppercase tracking-wider",children:"Макс. версий на кадр"}),e.jsx("span",{className:"text-xs font-bold text-emerald-300",children:R})]}),e.jsx("input",{type:"range",min:1,max:$,value:R,onChange:x=>r("qcMaxVersions",parseInt(x.target.value,10)),className:"w-full h-1.5 rounded-lg appearance-none cursor-pointer bg-white/10 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3.5 [&::-webkit-slider-thumb]:h-3.5 [&::-webkit-slider-thumb]:bg-emerald-400 [&::-webkit-slider-thumb]:rounded-full"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("p",{className:"text-[9px] text-white/30 flex items-center gap-0.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[10px]",children:"payments"}),"1-",R-1," попыток × кредиты модели"]}),e.jsx(T,{text:"Лимит вашего тарифа",children:e.jsxs("p",{className:"text-[9px] text-white/40 flex items-center gap-0.5 cursor-help",children:["макс ",$]})})]})]}),e.jsx("p",{className:"text-[9px] text-white/30 leading-snug",children:I?e.jsx(e.Fragment,{children:"Режиссёр проверит каждый кадр после рендера и переделает если найдёт ошибки (артефакты, потеря персонажа, разрыв стиля). Если ни одна версия не идеальна — выберет лучшую и активирует её."}):e.jsx(e.Fragment,{children:"Кадры выводятся как сгенерировались — без проверки и улучшений. Можно вручную перегенерировать кадры через UI."})})]})]}),!D&&e.jsxs("div",{className:`${v?"flex gap-3":"flex flex-col gap-2"}`,children:[v&&e.jsx("button",{onClick:p,className:"flex-1 h-10 rounded-xl bg-white/5 hover:bg-white/10 text-white/60 hover:text-white text-xs font-medium transition-all",children:o("common.cancel")}),e.jsxs("button",{onClick:j,className:`h-10 rounded-xl bg-gradient-to-r from-primary to-accent text-white text-xs font-bold flex items-center justify-center gap-2 hover:shadow-lg hover:shadow-primary/20 transition-all ${v?"flex-[2]":"w-full"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"save"}),o("storyModal.saveBtn")]}),!v&&e.jsx("button",{onClick:p,className:"w-full h-8 rounded-xl bg-white/5 hover:bg-white/10 text-white/60 hover:text-white text-xs font-medium transition-all",children:o("common.cancel")})]})]})},H=10,Me=["scifi","drama","comedy","thriller","fantasy","horror","cyberpunk","noir","documentary"],_e=["happy","tragic","open","plotTwist","cliffhanger"],se={scifi:{icon:"rocket_launch",gradient:"linear-gradient(135deg, #0f172a 0%, #1e3a5f 40%, #6366f1 100%)"},drama:{icon:"theater_comedy",gradient:"linear-gradient(135deg, #1a0a0a 0%, #6b2130 50%, #c2544b 100%)"},comedy:{icon:"sentiment_very_satisfied",gradient:"linear-gradient(135deg, #1a1500 0%, #92700a 50%, #fbbf24 100%)"},thriller:{icon:"electric_bolt",gradient:"linear-gradient(135deg, #0a0a0a 0%, #4a1
5525 50%, #dc2626 100%)"},fantasy:{icon:"auto_awesome",gradient:"linear-gradient(135deg, #1a0a2e 0%, #5b21b6 50%, #a78bfa 100%)"},horror:{icon:"dark_mode",gradient:"linear-gradient(135deg, #050505 0%, #1a1a2e 50%, #374151 100%)"},cyberpunk:{icon:"smart_toy",gradient:"linear-gradient(135deg, #0a0a1a 0%, #06b6d4 50%, #d946ef 100%)"},noir:{icon:"visibility_off",gradient:"linear-gradient(135deg, #0a0a0a 0%, #1f2937 50%, #4b5563 100%)"},documentary:{icon:"videocam",gradient:"linear-gradient(135deg, #0a1a0a 0%, #166534 50%, #4ade80 100%)"}},ae={happy:{icon:"sentiment_satisfied",gradient:"linear-gradient(135deg, #1a1500 0%, #a16207 50%, #facc15 100%)"},tragic:{icon:"sentiment_dissatisfied",gradient:"linear-gradient(135deg, #0a0a1a 0%, #1e3a5f 50%, #64748b 100%)"},open:{icon:"help",gradient:"linear-gradient(135deg, #0a1a1a 0%, #0e7490 50%, #22d3ee 100%)"},plotTwist:{icon:"shuffle",gradient:"linear-gradient(135deg, #1a0a2e 0%, #7c3aed 50%, #e879f9 100%)"},cliffhanger:{icon:"more_horiz",gradient:"linear-gradient(135deg, #1a0a00 0%, #c2410c 50%, #fb923c 100%)"}},Te=({isOpen:a,onClose:r,settings:k,onSave:E,assets:f,dossiers:M,shots:g,frameCount:i,onFrameCountChange:d,modelId:m})=>{const{t:l}=B(),{isByokTier:b,effectiveBalance:w,canUseBYOK:q}=de(),{getLimit:_}=J(),{isTouchDevice:z,isMobile:j}=Ne(),[p,v]=n.useState(k),[D,o]=n.useState(!1),[c,V]=n.useState(q&&F.hasActiveKey()),y=n.useRef(null),h=j||z,S=re.getSettings().models.generationModel,N=S?ce(S):!1,[$,A]=n.useState(N?21:6),[I,R]=n.useState(1);n.useEffect(()=>{const s=()=>V(F.hasActiveKey());return window.addEventListener("api-key-changed",s),()=>window.removeEventListener("api-key-changed",s)},[]),n.useEffect(()=>{if(!a)return;const s=p.resolution||"1K";xe(S||"",s).then(A),me().then(R)},[a,S,p.resolution]);const x=$+I*2,u=I,G=_("story_max_frames"),O=G===1/0?20:Math.min(20,G),{maxFrames:t,estimatedCost:P,isLimited:L}=n.useMemo(()=>{if(b||c)return{maxFrames:O,estimatedCost:0,isLimited:!1};const s=w??0;if(s<H)return{maxFrames:0,estimatedCost:x,isLimited:!0};if(s<=H)return{maxFrames:1,estimatedCost:u+x,isLimited:!0};const C=s-u-x;let U=0;C>=H&&(U=1+Math.floor((C-H)/x));const Z=1+U;return{maxFrames:Math.min(O,Math.max(1,Z)),estimatedCost:u+x*i,isLimited:Z<O}},[w,b,c,x,u,i,O]);n.useEffect(()=>{i>t&&t>0&&d(t)},[t,i,d]);const Y=()=>{E(p)},ie=s=>{v(C=>({...C,mode:s}))},K=(s,C)=>{v(U=>({...U,[s]:C}))},le=s=>{v(C=>({...C,styleConfig:s}))},Q=n.useMemo(()=>[{value:"",label:l("storyModal.any"),icon:"shuffle",description:"",gradient:"linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #374151 100%)"},...Me.map(s=>({value:l(`storyModal.genres.${s}`),label:l(`storyModal.genres.${s}`),icon:se[s]?.icon||"category",description:l(`storyModal.genreDesc.${s}`),gradient:se[s]?.gradient||"linear-gradient(135deg, #111 0%, #333 100%)"}))],[l]),X=n.useMemo(()=>[{value:"",label:l("storyModal.aiDecide"),icon:"smart_toy",description:"",gradient:"linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #374151 100%)"},..._e.map(s=>({value:l(`storyModal.endings.${s}`),label:l(`storyModal.endings.${s}`),icon:ae[s]?.icon||"flag",description:l(`storyModal.endingDesc.${s}`),gradient:ae[s]?.gradient||"linear-gradient(135deg, #111 0%, #333 100%)"}))],[l]);return a?e.jsxs("div",{className:`fixed inset-x-0 top-0 flex items-center justify-center z-50 pointer-events-none ${h?"p-2":"inset-y-0 p-4"}`,style:h?{height:"100dvh"}:void 0,children:[e.jsxs("div",{className:`flex flex-col glass-panel shadow-2xl overflow-hidden animate-fade-in pointer-events-auto w-full rounded-2xl ${h?"h-full":"max-w-4xl max-h-[90vh]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/5 bg-black/20 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-white/90 font-medium text-sm",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-primary",children:"movie_edit"}),e.jsx("span",{className:"font-medium",children:l("storyModal.title")})]}),e.jsx("button",{onClick:r,className:"size-6 rounded-full bg-white/5 hover:bg-white/10 flex items-center justify-center text-white/50 hover:text-white transition-colors",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[e.jsxs("div",{className:`flex items-center bg-black/30 shrink-0 ${h?"flex-wrap gap-3 p-3":"gap-4 p-4"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-x-auto no-scrollbar",children:[f.slice(0,h?4:6).map(s=>e.jsx("div",{className:`rounded-lg overflow-hidden border border-white/10 bg-black/40 shrink-0 ${h?"
5size-10":"size-12"}`,children:e.jsx("img",{src:s.imageUrl,alt:s.name,className:"w-full h-full object-cover opacity-80"})},s.id)),f.length>(h?4:6)&&e.jsxs("div",{className:`rounded-lg border border-white/10 bg-white/5 flex items-center justify-center text-[10px] font-bold text-white/40 shrink-0 ${h?"size-10":"size-12"}`,children:["+",f.length-(h?4:6)]}),f.length===0&&e.jsx("div",{className:`px-4 rounded-lg border border-dashed border-white/10 bg-white/5 flex items-center ${h?"h-10":"h-12"}`,children:e.jsx("span",{className:"text-[11px] text-white/40",children:l("storyModal.noAssets")})})]}),!h&&e.jsx("div",{className:"flex-1"}),e.jsx("div",{className:`flex p-1 bg-black/40 rounded-xl border border-white/10 ${h?"ml-auto":""}`,children:["auto","manual"].map(s=>e.jsxs("button",{onClick:()=>ie(s),className:`px-3 py-1.5 rounded-lg text-[11px] font-medium transition-all flex items-center gap-1.5 ${p.mode===s?"bg-primary text-white":"text-white/50 hover:text-white hover:bg-white/5"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-sm",children:s==="auto"?"smart_toy":"edit_note"}),l(`storyModal.${s}`)]},s))})]}),h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex-1 flex flex-col gap-4 p-3 bg-black/40 overflow-y-auto custom-scrollbar min-h-0",children:[e.jsx("div",{className:"flex-1 min-h-[220px] flex flex-col",children:e.jsx(W,{ref:y,localSettings:p,onFieldChange:K,assets:f,dossiers:M,shots:g,modelId:m,genreOptions:Q,endingOptions:X})}),e.jsx(te,{localSettings:p,onFieldChange:K,onOpenStyleModal:()=>o(!0),onOpenDossierPicker:()=>y.current?.openDossierPicker(),onOpenShotPicker:()=>y.current?.openShotPicker(),frameCount:i,onFrameCountChange:d,maxFrames:t,tierMaxFrames:O,estimatedCost:P,isLimited:L,isByokTier:b,hasActiveByokKey:c,isProModel:N,planningCost:u,costPerFrame:x,onSave:Y,onClose:r,isCompactLayout:h,hideActions:!0})]}),e.jsxs("div",{className:"shrink-0 flex gap-3 px-3 pt-3 border-t border-white/5 bg-black/60",style:{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom, 0px))"},children:[e.jsx("button",{onClick:r,className:"flex-1 h-11 rounded-xl bg-white/5 hover:bg-white/10 text-white/60 hover:text-white text-xs font-medium transition-all",children:l("common.cancel")}),e.jsxs("button",{onClick:Y,className:"flex-[2] h-11 rounded-xl bg-gradient-to-r from-primary to-accent text-white text-xs font-bold flex items-center justify-center gap-2 hover:shadow-lg hover:shadow-primary/20 transition-all",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"save"}),l("storyModal.saveBtn")]})]})]}):e.jsxs("div",{className:"flex-1 flex gap-4 p-4 bg-black/40 min-h-0 overflow-hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:e.jsx(W,{ref:y,localSettings:p,onFieldChange:K,assets:f,dossiers:M,shots:g,modelId:m,genreOptions:Q,endingOptions:X})}),e.jsx("div",{className:"shrink-0 min-h-0 overflow-y-auto custom-scrollbar pr-1",children:e.jsx(te,{localSettings:p,onFieldChange:K,onOpenStyleModal:()=>o(!0),onOpenDossierPicker:()=>y.current?.openDossierPicker(),onOpenShotPicker:()=>y.current?.openShotPicker(),frameCount:i,onFrameCountChange:d,maxFrames:t,tierMaxFrames:O,estimatedCost:P,isLimited:L,isByokTier:b,hasActiveByokKey:c,isProModel:N,planningCost:u,costPerFrame:x,onSave:Y,onClose:r})})]})]})]}),D&&e.jsx(ye,{isOpen:D,onClose:()=>o(!1),currentConfig:p.styleConfig,onSelect:le})]}):null};export{Te as StorySettingsModal};

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.