import{a as v}from"./chunk-VJNS2G4F.js";import{fa as o}from"./chunk-Q232IBQN.js";import{b as P}from"./chunk-LGT7QKWT.js";import{h as b,m as s}from"./chunk-K3AFQ46O.js";import{K as f,ca as g,e as m,sa as C,xa as c}from"./chunk-O7RN3KYY.js";import{a as l}from"./chunk-ZE2KCNEA.js";import{a as h}from"./chunk-CEWFFWI2.js";l();var V=(()=>{class n{constructor(){this.http=c(b),this.helper=c(P),this.errorService=c(v),this.newChatRequestedSubject=new m,this.newChatRequested$=this.newChatRequestedSubject.asObservable()}requestNewChat(){this.newChatRequestedSubject.next()}getAiChatbotUserConfig(t,e=!1){return t?this.fetchAiChatbotUserConfig(t):((!this.aiChatbotUserConfig$||e)&&(this.aiChatbotUserConfig$=this.fetchAiChatbotUserConfig().pipe(g(1))),this.aiChatbotUserConfig$)}fetchAiChatbotUserConfig(t){return this.http.get(`${s.API_ENDPOINT_V2}/ai-chatbot/config/me/`,{context:o,params:this.helper.toHttpParams(t)}).pipe(f(this.errorService.errorHandler({404:()=>null,403:()=>null})))}sendMessage(t,e,a){return this.http.post(`${s.API_ENDPOINT_V2}/ai-chatbot/genai/`,t?h({conversation_public_id:t},e):e,{context:o,params:this.helper.toHttpParams(a)})}transcribeAudio(t,e){let a=new FormData;return a.append("audio",t,"dictation.wav"),e&&a.append("language",e),this.http.post(`${s.API_ENDPOINT_V2}/ai-chatbot/transcribe/`,a,{context:o})}getConversation(t){return this.http.get(`${s.API_ENDPOINT_V2}/ai-chatbot/conversations/${t}/`,{context:o})}rateConversation(t,e){return this.http.patch(`${s.API_ENDPOINT_V2}/ai-chatbot/conversations/${t}/rate/`,e,{context:o})}listConversations(t,e){return this.http.get(`${s.API_ENDPOINT_V2}/ai-chatbot/conversations/`,{context:o,params:this.helper.toHttpParams(h(h({},e),t))})}getConversationMessages(t){return this.http.get(`${s.API_ENDPOINT_V2}/ai-chatbot/messages/`,{context:o,params:this.helper.toHttpParams(t??{})})}getMessagesByUrl(t){return this.http.get(t,{context:o})}generateConversationTitle(t){return this.http.patch(`${s.API_ENDPOINT_V2}/ai-chatbot/conversations/${t}/generate-title/`,{},{context:o})}renameConversation(t,e){return this.http.patch(`${s.API_ENDPOINT_V2}/ai-chatbot/conversations/${t}/rename/`,{title:e})}pinConversation(t){return this.http.post(`${s.API_ENDPOINT_V2}/ai-chatbot/conversations/${t}/pin/`,{})}unpinConversation(t){return this.http.post(`${s.API_ENDPOINT_V2}/ai-chatbot/conversations/${t}/unpin/`,{})}groupConversationsByTime(t,e){let p=e.toMillis(),I=p-7*864e5,N=p-30*864e5,d=e.getYear(),i={last_7_days:[],last_30_days:[],this_year:[],older:[]};for(let r of t){let _=new Date(r.latest_message_timestamp),u=_.getTime();u>=I?i.last_7_days.push(r):u>=N?i.last_30_days.push(r):_.getFullYear()===d?i.this_year.push(r):i.older.push(r)}return["last_7_days","last_30_days","this_year","older"].filter(r=>i[r].length>0).map(r=>({label:r,conversations:i[r]}))}static{this.\u0275fac=function(e){return new(e||n)}}static{this.\u0275prov=C({token:n,factory:n.\u0275fac,providedIn:"root"})}}return n})();export{V as a};