import{j as n,O as g,P as v,Q as k,k as S,d as c,o as h,c as m,a as s,t as i,v as r,y as d,w as u,R as K,S as b,T as C,b as q}from"./vendor-nextcloud-vue-BwabAicX.js";import{s as N,g as V}from"./aiquila-main.js";import{_ as w}from"./vendor-icons-D2YTIWGr.js";const x={name:"NavigationSettings",components:{NcButton:S,NcSelect:k,NcTextField:v,NcCheckboxRadioSwitch:g},emits:[],data(){return{modelOptions:[],selectedModel:null,apiKey:"",hasUserKey:!1,clearKey:!1,defaultSystemPrompt:"",defaultVerbose:!1,saving:!1,dirty:!1,status:"",statusType:"",loaded:!1}},computed:{keyPlaceholder(){return this.clearKey?n("aiquila","Key will be cleared on save"):this.hasUserKey?n("aiquila","Personal key configured — enter new to replace"):n("aiquila","sk-ant-… (leave blank to keep admin key)")}},async mounted(){await this.loadSettings()},methods:{t:n,async loadSettings(){try{const{data:l}=await V();this.modelOptions=l.availableModels||[],this.selectedModel=l.userModel||null,this.hasUserKey=!!l.hasUserKey,this.defaultSystemPrompt=l.defaultSystemPrompt||"",this.defaultVerbose=!!l.defaultVerbose,this.loaded=!0}catch(l){this.status=n("aiquila","Failed to load settings: ")+l.message,this.statusType="error"}},onClearKey(){this.apiKey="",this.clearKey=!0,this.dirty=!0},onCancel(){this.apiKey="",this.clearKey=!1,this.dirty=!1,this.status="",this.loadSettings()},async onSave(){this.saving=!0,this.status="";try{await N({model:this.selectedModel||"",api_key:this.clearKey?"":this.apiKey,default_system_prompt:this.defaultSystemPrompt,default_verbose:this.defaultVerbose?"1":"0"}),this.status=n("aiquila","Saved!"),this.statusType="success",this.dirty=!1,this.clearKey?this.hasUserKey=!1:this.apiKey&&(this.hasUserKey=!0),this.apiKey="",this.clearKey=!1}catch(l){this.status=n("aiquila","Error saving: ")+l.message,this.statusType="error"}finally{this.saving=!1}}}},P={class:"nav-settings"},T={class:"settings-section",open:""},M={class:"section-content"},U={class:"setting-group"},B={for:"settings-model"},I={class:"setting-group"},D={for:"settings-api-key"},F={class:"hint"},O={class:"key-row"},R={class:"settings-section"},A={class:"section-content"},E={class:"setting-group"},j={for:"settings-system-prompt"},z=["placeholder"],Q={class:"setting-group"},G={class:"setting-actions"};function H(l,a,J,L,e,t){const p=c("NcSelect"),f=c("NcTextField"),y=c("NcButton"),_=c("NcCheckboxRadioSwitch");return h(),m("div",P,[s("details",T,[s("summary",null,i(t.t("aiquila","Model & API")),1),s("div",M,[s("div",U,[s("label",B,i(t.t("aiquila","Model preference")),1),r(p,{modelValue:e.selectedModel,"onUpdate:modelValue":a[0]||(a[0]=o=>e.selectedModel=o),"input-id":"settings-model",options:e.modelOptions,placeholder:t.t("aiquila","(admin default)"),clearable:!0,onInput:a[1]||(a[1]=o=>e.dirty=!0)},null,8,["modelValue","options","placeholder"])]),s("div",I,[s("label",D,[d(i(t.t("aiquila","Personal API key"))+" ",1),s("span",F,i(t.t("aiquila","(overrides admin key)")),1)]),s("div",O,[r(f,{id:"settings-api-key",modelValue:e.apiKey,"onUpdate:modelValue":[a[2]||(a[2]=o=>e.apiKey=o),a[3]||(a[3]=o=>e.dirty=!0)],type:"password",placeholder:t.keyPlaceholder},null,8,["modelValue","placeholder"]),r(y,{type:"tertiary",onClick:t.onClearKey},{default:u(()=>[d(i(t.t("aiquila","Clear key")),1)]),_:1},8,["onClick"])])])])]),s("details",R,[s("summary",null,i(t.t("aiquila","Defaults")),1),s("div",A,[s("div",E,[s("label",j,i(t.t("aiquila","Default system prompt")),1),K(s("textarea",{id:"settings-system-prompt","onUpdate:modelValue":a[4]||(a[4]=o=>e.defaultSystemPrompt=o),class:"system-prompt-input",rows:"3",placeholder:t.t("aiquila","Custom instructions for Claude…"),onInput:a[5]||(a[5]=o=>e.dirty=!0)},null,40,z),[[b,e.defaultSystemPrompt]])]),s("div",Q,[r(_,{checked:e.defaultVerbose,"onUpdate:checked":a[6]||(a[6]=o=>{e.defaultVerbose=o,e.dirty=!0})},{default:u(()=>[d(i(t.t("aiquila","Show verbose mode by default")),1)]),_:1},8,["checked"])])])]),s("div",G,[r(y,{type:"secondary",onClick:t.onCancel},{default:u(()=>[d(i(t.t("aiquila","Cancel")),1)]),_:1},8,["onClick"]),r(y,{type:"primary",disabled:e.saving||!e.dirty,onClick:t.onSave},{default:u(()=>[d(i(e.saving?t.t("aiquila","Saving…"):t.t("aiquila","Save")),1)]),_:1},8,["disabled","onClick"])]),e.status?(h(),m("p",{key:0,class:C(["status-msg",e.statusType])},i(e.status),3)):q("",!0)])}const Z=w(x,[["render",H],["__scopeId","data-v-1ee13c4c"]]);export{Z as default};
