import{u as w,E as h,C as s,k as l,n as E}from"./index-p1BAR2Hc.js";const T=["剧本反推","剧本分析","剧本解析","角色、场景、道具解析","角色生成","场景生成","道具生成","分镜图生成","首尾帧生成","视频生成"],g=["角色生成","场景生成","道具生成","视频生成"];function C(){const p=w(),a=l([]),r=l({});async function m(t=T){try{const e=await Promise.all(t.map(n=>s.promptPresets(n))),o=new Map,i={};e.forEach((n,y)=>{(n.prompts||[]).forEach(u=>o.set(u.id,u)),n.selected_id&&(i[t[y]]=n.selected_id)}),a.value=[...o.values()],r.value=i}catch(e){a.value=[],r.value={},c(e,"加载提示词失败")}}async function d(t){try{await s.selectPrompt(t.type,t.promptId),r.value={...r.value,[t.type]:t.promptId}}catch(e){c(e,"启用提示词失败")}}async function v(t){try{const e=await s.createCustomPrompt(t);a.value=[...a.value,e],await s.selectPrompt(t.type,e.id),r.value={...r.value,[t.type]:e.id}}catch(e){c(e,"保存自定义提示词失败")}}async function f(t){try{const e=await s.updateCustomPrompt(t.id,t);a.value=a.value.map(o=>o.id===e.id?e:o)}catch(e){c(e,"保存提示词失败")}}async function P(t){try{await h.confirm("删除后不可恢复，确定删除该提示词吗？","删除提示词",{type:"warning",confirmButtonText:"删除",cancelButtonText:"取消"}),await s.deleteCustomPrompt(t.id),a.value=a.value.filter(e=>e.id!==t.id),r.value[t.type]===t.id&&(r.value={...r.value,[t.type]:""})}catch(e){e!=="cancel"&&e!=="close"&&c(e,"删除提示词失败")}}function c(t,e){const o=E(t);p.error(o.message,o.copyText,e)}return{prompts:a,promptSelections:r,loadPrompts:m,selectPrompt:d,createPrompt:v,updatePrompt:f,deletePrompt:P}}export{g as p,C as u};
