import{d as H,u as R,y as J,q as T,w as m,C as i,k as n,n as K,o as p,a as r,e as o,t as v,b as s,L as Q,j as S,G as W,c as w,F as X,v as Y,s as A,A as Z,r as B,H as ee,h as te,f as se,E as oe}from"./index-p1BAR2Hc.js";import{c as D,a as L,T as ae}from"./icons-CbZw_MCi.js";import{P as re}from"./ProjectSearchField-C68_CxpU.js";import{C as le}from"./CreativeSelect-CikGCVMP.js";import{M as ne}from"./ModelConfigDialog-BZPjXRWk.js";import{f as ie}from"./datetime-P3V4sQaP.js";import{u as ce}from"./useModelPrompts-BKmMdFPq.js";import{e as pe}from"./scriptAnalysisModel-D-P7Lk0D.js";import{_ as ue}from"./_plugin-vue_export-helper-DlAUqK2U.js";const de={class:"script-toolbar"},me={class:"creative-page-actions"},ve={class:"script-count"},fe={class:"script-grid"},_e=["onClick"],ye={class:"script-card__icon"},ge={class:"script-card__body"},we=["onClick"],Ce={key:0,class:"script-empty"},he=H({__name:"ScriptAnalysisView",setup(ke){const M=te(),f=R(),C=n([]),V=n({styles:[],models:[]}),h=n([]),_=n(!1),u=n(!1),y=n(!1),k=n(!1),c=n(""),P=Z(()=>{const t=c.value.trim().toLocaleLowerCase();return t?C.value.filter(e=>(e.name||"未命名剧本").toLocaleLowerCase().includes(t)):C.value}),{prompts:z,promptSelections:E,loadPrompts:U,selectPrompt:F,createPrompt:I,updatePrompt:N,deletePrompt:$}=ce();function g(t,e="加载失败"){const l=K(t);f.error(l.message,l.copyText,e)}async function x(){_.value=!0;try{const[t,e,l]=await Promise.all([i.scriptAnalyses(),i.options(),i.userModelConfigs("script_analysis")]);C.value=t,V.value=e,h.value=await pe(e,l),await U(["剧本分析"])}catch(t){g(t)}finally{_.value=!1}}async function j(t){var l;const e=(l=t.prompt_reverse)==null?void 0:l.model_id;if(!e)return f.warning("请选择文本模型");k.value=!0;try{await i.saveUserModelConfig("script_analysis","text",e),h.value=await i.userModelConfigs("script_analysis"),y.value=!1,f.success("模型配置已保存")}catch(d){g(d,"保存模型配置失败")}finally{k.value=!1}}async function b(){if(!u.value){u.value=!0;try{const t=await i.createScriptAnalysis();await M.push({name:"script-analysis-workbench",params:{scriptId:t.id}})}catch(t){g(t,"创建失败")}finally{u.value=!1}}}async function O(t){try{await oe.confirm(`确定删除“${t.name}”吗？`,"删除剧本",{type:"warning",confirmButtonText:"删除",cancelButtonText:"取消"}),await i.deleteScriptAnalysis(t.id),f.success("剧本已删除"),await x()}catch(e){e!=="cancel"&&e!=="close"&&g(e,"删除失败")}}return J(x),(t,e)=>{const l=B("el-icon"),d=B("el-button"),q=ee("loading");return p(),T(le,null,{default:m(()=>[r("section",de,[o(re,{modelValue:c.value,"onUpdate:modelValue":e[0]||(e[0]=a=>c.value=a),placeholder:"搜索剧本名称"},null,8,["modelValue"]),r("div",me,[r("span",ve,v(P.value.length)+" 个剧本",1),o(d,{onClick:e[1]||(e[1]=a=>y.value=!0)},{default:m(()=>[o(l,null,{default:m(()=>[o(s(Q))]),_:1}),e[3]||(e[3]=S("模型配置",-1))]),_:1}),o(d,{type:"primary",loading:u.value,onClick:b},{default:m(()=>[o(s(D),{size:16}),e[4]||(e[4]=S("新建剧本 ",-1))]),_:1},8,["loading"])])]),W((p(),w("section",fe,[(p(!0),w(X,null,Y(P.value,a=>(p(),w("article",{key:a.id,class:"script-card",onClick:G=>s(M).push({name:"script-analysis-workbench",params:{scriptId:a.id}})},[r("div",ye,[o(s(L),{size:22})]),r("div",ge,[r("strong",null,v(a.name||"未命名剧本"),1),r("time",null,v(s(ie)(a.updated_at)),1)]),r("button",{type:"button",class:"script-card__delete",title:"删除剧本",onClick:se(G=>O(a),["stop"])},[o(s(ae),{size:17})],8,we)],8,_e))),128)),!_.value&&!P.value.length?(p(),w("div",Ce,[o(s(L),{size:40,"stroke-width":"1.2"}),r("strong",null,v(c.value.trim()?"没有匹配的剧本":"还没有剧本"),1),r("p",null,v(c.value.trim()?"换一个关键词继续查找":"新建剧本后即可开始分析"),1),c.value.trim()?A("",!0):(p(),T(d,{key:0,type:"primary",loading:u.value,onClick:b},{default:m(()=>[o(s(D),{size:16}),e[5]||(e[5]=S("新建剧本 ",-1))]),_:1},8,["loading"]))])):A("",!0)])),[[q,_.value]]),o(ne,{modelValue:y.value,"onUpdate:modelValue":e[2]||(e[2]=a=>y.value=a),"analysis-only":"","project-type":"script_analysis",options:V.value,configs:h.value,saving:k.value,prompts:s(z),"prompt-selections":s(E),onSave:j,onPromptSelect:s(F),onPromptCreate:s(I),onPromptUpdate:s(N),onPromptDelete:s($)},null,8,["modelValue","options","configs","saving","prompts","prompt-selections","onPromptSelect","onPromptCreate","onPromptUpdate","onPromptDelete"])]),_:1})}}}),De=ue(he,[["__scopeId","data-v-fc2a2917"]]);export{De as default};
