import{j as _,Q as j,U as y,V as b,W as k,c as d,v as l,b as A,F as w,r as g,e as F,w as u,y as m,t as v,X as N,T as S,d as c,o as s}from"./vendor-nextcloud-vue-BwabAicX.js";import{u as q}from"./aiquila-main.js";import{_ as I}from"./vendor-icons-D2YTIWGr.js";const B={name:"ChatSidebar",components:{NcAppNavigationNew:k,NcAppNavigationItem:b,NcActionButton:y,NcSelect:j},props:{conversations:{type:Array,default:()=>[]},activeConversationId:{type:Number,default:null},projects:{type:Array,default:()=>[]},activeProjectFilter:{type:Number,default:null}},emits:["new-chat","select-conversation","delete-conversation","duplicate-conversation","conversation-renamed","update-project-filter"],computed:{filteredConversations(){return this.activeProjectFilter?this.conversations.filter(e=>e.projectId===this.activeProjectFilter):this.conversations},projectFilterOptions(){return this.projects.map(e=>({value:e.id,label:e.title}))}},methods:{t:_,async onSaveRename(e,i){const n=i.trim();if(n)try{const{data:o}=await q(e,{title:n});this.$emit("conversation-renamed",o)}catch(o){console.error("Rename failed:",o)}}}},U={style:{display:"contents"}},V={key:0,class:"project-filter"};function P(e,i,n,o,R,a){const f=c("NcAppNavigationNew"),h=c("NcSelect"),p=c("NcActionButton"),C=c("NcAppNavigationItem");return s(),d("div",U,[l(f,{text:a.t("aiquila","New chat"),onClick:i[0]||(i[0]=t=>e.$emit("new-chat"))},null,8,["text"]),n.projects.length>0?(s(),d("div",V,[l(h,{"model-value":n.activeProjectFilter,options:a.projectFilterOptions,placeholder:a.t("aiquila","All conversations"),clearable:!0,label:"label",reduce:t=>t.value,"onUpdate:modelValue":i[1]||(i[1]=t=>e.$emit("update-project-filter",t))},null,8,["model-value","options","placeholder","reduce"])])):A("",!0),(s(!0),d(w,null,g(a.filteredConversations,t=>(s(),F(C,{key:t.id,name:t.title||a.t("aiquila","Untitled"),class:S({active:t.id===n.activeConversationId}),editable:!0,"edit-label":a.t("aiquila","Rename"),"edit-placeholder":a.t("aiquila","Conversation name"),"onUpdate:name":r=>a.onSaveRename(t.id,r),onClick:r=>e.$emit("select-conversation",t.id)},{actions:u(()=>[l(p,{onClick:N(r=>e.$emit("duplicate-conversation",t.id),["stop"])},{default:u(()=>[m(v(a.t("aiquila","Duplicate")),1)]),_:1},8,["onClick"]),l(p,{onClick:N(r=>e.$emit("delete-conversation",t.id),["stop"])},{default:u(()=>[m(v(a.t("aiquila","Delete")),1)]),_:1},8,["onClick"])]),_:2},1032,["name","class","edit-label","edit-placeholder","onUpdate:name","onClick"]))),128))])}const T=I(B,[["render",P],["__scopeId","data-v-50280c3f"]]);export{T as default};
