PageSourceSearch

https://aipeeps.com/assets/ChatHead-D8LweFyZ.js

js aipeeps.com collected 2026-10-09 17:41:27 UTC 33,747 bytes, 1 lines download raw bytes

1import{u as y,a as T,b as O,g as ie,w as fe,c as Y,d as ne,_ as pe,B as ge,r as me,o,e as h,f as H,h as p,i as g,j as c,k as m,l as d,m as b,p as S,q as V,T as E,t as _,s as K,F as v,v as D,x as F,y as _e,z as ye,A as Se,C as R,D as we,E as k,G as M,H as C,I as be,J as ve,K as q,L as ke,M as Ce,N as Ie,O as Me,P as xe,Q as Te,R as Pe,S as G,U as Ae}from"./app-Brzv3Rd5.js";let z=0,N=0,I=0,ae=0,P=!0,A=!1;const W=()=>new Date().toLocaleDateString("en-CA"),De=e=>O("chat-options-event",{event:e}).catch(()=>{});function Oe(){z+=1,P=!1,A=!1,y().bubbleOptions=[]}function Le(){N+=1,P=!1,A||(y().bubbleOptions=[])}function He(){I+=1,A=!1,P=!0;const e=y();e.bubbleOptions=[],e.bubbleLoadingOptions=!1}function Ee(){P=!0,A=!1}function Fe(){ae=Date.now()}function Re(){const e=T(),t=Y().sharedInfo?.cost_chat_message;return!!(e.userRecord.daily_chat_messages_freemium||e.totPeepCoinsLeft>=t||e.isSubscribed)}let j=null;function J(){const e=y();e.bubbleOptionsFailed=!0,clearTimeout(j),j=setTimeout(()=>e.bubbleOptionsFailed=!1,2500)}async function re({auto:e=!1,explicit:t=!1}={}){const i=y();if(i.bubbleLoadingOptions)return"stale";const r=z,a=N,s=++I;i.bubbleLoadingOptions=!0;try{let l;for(let n=0;;n++){try{l=await O("gen-options",{starting_text:i.userMessage,auto:e,accept_paid:ie("chat_options_paid_ok_day","")===W()})}catch(u){if(u?.response?.status!==429)throw u;l={status:"busy"}}if(l?.status!=="busy"||n>=(t?20:10))break;if(await new Promise(u=>setTimeout(u,1500)),s!==I||i.chatInterfaceMounted)return"stale"}return s!==I||i.chatInterfaceMounted||r!==z||!t&&a!==N?"stale":l?.status==="ok"?(localStorage.removeItem("chat_options_auto_paused_day"),i.bubbleOptions=l.options||[],A=t&&!P,"ok"):l?.status==="cap_reached"?(fe("chat_options_auto_paused_day",W()),"cap"):(t&&J(),"error")}catch(l){return console.error("gen-options (chat head) failed",l),t&&s===I&&!i.chatInterfaceMounted&&J(),"error"}finally{s===I&&!i.chatInterfaceMounted&&(i.bubbleLoadingOptions=!1)}}async function Ue(){const e=y(),t=T();return e.bubbleLoadingOptions?"busy":(t.settings.autoChatOptions===!1&&(t.setSetting("autoChatOptions",!0),De("toggle_on")),re({explicit:!0}))}function Xe(){const e=y(),t=T();e.chatInterfaceMounted||!e.bubbleShowsMessages||t.settings.autoChatOptions!==!1&&(e.bubbleOptions.length||e.bubbleLoadingOptions||!Re()||!e.chatData?.chat_uid||(e.userMessage||"").trim()||Date.now()-ae<3e3||ie("chat_options_auto_paused_day","")!==W()&&re({auto:!0}))}function oe(e){const t=e.messages.findIndex(i=>i.isTyping);t!==-1&&e.messages.splice(t,1)}function Be(e,t){const i=e.messages;if(t.sender_type==="AI"){oe(e),["Text","Action","Voice"].includes(t.message_type)&&Le();const r=T().settings.volumePingPerc;r>0&&(!i.length||i[i.length-1].sender_type!=="AI")&&e.wantsNewMessagePing()&&e.playAudioClip("sounds/new_message.mp3",r/100),e.addBlockMessage(t),i.push(t);return}i.length&&i[i.length-1].isTyping?i.splice(i.length-1,0,t):(e.addBlockMessage(t),i.push(t))}function Ye(e){const t=y();switch(e?.type){case"chat_message":t.in_explicit_mode=e.is_explicit,Be(t,e.msg);break;case"finished_delivery":Ee(),Xe();break;case"typing_indicator_on":t.messages.some(i=>i.isTyping)||t.messages.push({content:"...",sender_type:"AI",isTyping:!0,message_type:"Text",ai_uid:e.ai_uid});break;case"typing_indicator_off":setTimeout(()=>oe(t),100);break;case"activate_chat":t.chatIsActive=!0;break;case"pause_chat":t.chatIsActive=!1;break;case"update_client_chat_data":t.updateChatData(e.record);break}}function x(){return y().chatInterfaceMounted?!1:(ne().registerHandler("chat",Ye),!0)}const he="chat_head_pos",Z="chat_head_folded",U="chat_head_running",X="chat_head_swipe_hint_v2",ze=58,Ne=92,We=.085,Q=60,w=10,Ve=6,Ke=["Home","HomeLocalized"],$=10,ee=6e3,qe=14e3,Ge=60,te=4e3,je=8e3,Je=40;let le=0;const B=()=>`chp-${Date.now()}-${++le}`;function se(e){return e?(new DOMParser().parseFromString(String(e),"text/html").body?.textContent||"").replace(/\s+/g," ").trim():""}function Ze(){try{const e=JSON.parse(localStorage.getItem(he)||"null");if(e&&typeof e.y=="number"){const t=e.side==="left"||e.side==="right"?e.side:null;if(t||typeof e.x=="number")return{side:t,x:e.x??0,y:e.y}}}catch{}return{side:"right",x:0,y:.62}}const Qe={name:"ChatHead",components:{BaseButton:ge},props:{allowed:{type:Boolean,default:!0}},data(){return{ready:!1,userStore:T(),chatStore:y(),local:null,hidden:!1,askOpen:!1,pos:{side:"right",x:0,y:.62},vw:0,vh:0,minX:w,minY:w,dragging:!1,press:null,dragX:0,dragY:0,imgFailed:!1,websocketStore:ne(),previews:[],pendingKey:B(),bump:!1,panelShown:!1,held:!1,composing:!1,swipeDX:0,hintDue:!1,isTouch:!1,folded:!1,sending:!1,headlessContinues:0,scrolledUp:!1,atTop:!0}},computed:{savedLatest(){const e=this.userStore.saved_ai_chats;if(!this.userStore.isAuthorized||!Array.isArray(e)||!e.length)return null;let t=null;for(const s of e){const l=s?.last_chatted?new Date(s.last_chatted).getTime():0;s?.chat_uid&&(!t||l>t.at)&&(t={chat:s,at:l})}if(!t)return null;const i=t.chat,r=i.ai_uids?.[0],a=i.ai_chat_states?.[r];return{chat_uid:i.chat_uid,image:i.chat_image_url||Ae(r)||a?.face_image_url||null,name:a?.nickname||G(a?.characteristics?.name||a?.name)||"",at:t.at}},target(){const e=this.local,t=this.savedLatest;let i=e&&t?e.at>=t.at?e:t:e||t;if(!i)return null;this.chatStore.chatData?.chat_uid===i.chat_uid&&this.chatStore.chatImageUrl&&(i={...i,image:this.chatStore.chatImageUrl});const r=!this.imgFailed&&i.image?i.image:Pe;return{...i,image:r,name:i.name?G(i.name):""}},visible(){return this.allowed&&!Te&&this.userStore.settings.chatBubble!==!1&&this.$route.name!=="ChatPage"&&!(Ke.includes(this.$route.name)&&!this.userStore.isAuthorized)&&!this.hidden&&!!this.target},size(){const e=Math.min(this.vw||0,this.vh||0);return Math.round(Math.min(Ne,Math.max(ze,e*We)))},live(){return this.visible&&!!this.chatStore.chatData?.chat_uid&&this.chatStore.chatData.chat_uid===this.target?.chat_uid&&!this.userStore.settings.voice_mode},lastMessage(){const e=this.chatStore.messages;for(let t=e.length-1;t>=0&&t>=e.length-6;t--){const i=e[t];if((i?.sender_type==="AI"||i?.sender_type==="User")&&!i.isTyping)return i}return null},recentLines(){const e=this.chatStore.messages,t=[];for(let i=e.length-1;i>=0&&t.length<8;i--){const r=e[i];if(!r||r.isTyping)continue;const a=r.sender_type==="AI",s=r.sender_type==="User";a&&!["Text","Voice","Action","PeepImage"].includes(r.message_type)||s&&
1!["Text","Voice","Action"].includes(r.message_type)||!a&&!s||t.push({id:r.id??null,sender_type:r.sender_type,message_type:r.message_type,content:r.message_type==="PeepImage"?"":se(r.content).slice(0,600),media:r.message_type==="PeepImage"&&r.media||null,ai_uid:r.ai_uid||null})}return t.reverse()},lastAiMessage(){const e=this.chatStore.messages;for(let t=e.length-1;t>=0&&t>=e.length-12;t--){const i=e[t];if(i?.sender_type==="AI"&&!i.isTyping)return i}return null},options(){return this.live?this.chatStore.bubbleOptions||[]:[]},canWrite(){return this.visible&&!!this.target&&!this.userStore.settings.voice_mode},showsMessages(){return this.live&&!this.folded},hintShown(){return this.hintDue&&this.isTouch&&this.panelOpen},resumeReady(){return this.ready&&this.canWrite&&!this.folded&&!!this.target?.chat_uid&&this.websocketStore.isSessionReady&&this.$route.name!=="ChatPage"},running(){return this.showsMessages},canContinue(){if(this.chatStore.chatInterfaceMounted)return this.chatStore.bubbleCanContinue;const e=Y().sharedInfo?.max_consecutive_continues;return e==null||this.headlessContinues<e},holding(){return this.held||this.composing||this.options.length>0||!!this.typingMsg},swipeStyle(){return this.swipeDX?{transform:`translateX(${this.swipeDX}px)`,opacity:String(1-Math.min(.7,Math.abs(this.swipeDX)/160)),transition:"none"}:null},foldIcon(){const e=this.stackLeft?"fa-chevron-right":"fa-chevron-left",t=this.stackLeft?"fa-chevron-left":"fa-chevron-right";return this.folded?t:e},panelOpen(){return!this.folded&&(this.previews.length>0||!!this.typingAlone||this.options.length>0)},visiblePreviews(){return this.panelShown?this.previews:this.previews.slice(-1)},scrollMax(){const e=this.stackUp?this.y+this.size-this.minY:this.vh-this.y-w-24,t=this.composing?56:this.options.length*46+(this.canWrite?40:0);return Math.round(Math.max(90,Math.min(this.vh*.25,230,e-t)))},typingMsg(){if(!this.live)return null;const e=this.chatStore.messages[this.chatStore.messages.length-1];return e?.isTyping?e:null},typingInto(){const e=this.typingMsg,t=this.previews[this.previews.length-1];return!e||!t||t.kind==="media"?null:t.uid===this.peepUid(e)?t.key:null},typingAlone(){const e=this.typingMsg;if(!e||this.typingInto)return null;const{style:t,name:i,color:r}=this.peepLook(e,"text");return{key:this.pendingKey,style:t,name:i,color:r}},stackLeft(){return this.x+this.size/2>this.vw/2},stackUp(){return this.y+this.size/2>this.vh/2},stackMaxW(){const t=this.stackLeft?this.x-10-this.minX:this.vw-(this.x+this.size+10)-w;return Math.max(140,Math.min(300,t))},stackStyle(){const t={width:`${this.stackMaxW}px`};return this.stackLeft?t.right=`${this.vw-this.x+10}px`:t.left=`${this.x+this.size+10}px`,this.stackUp?t.bottom=`${this.vh-(this.y+this.size)}px`:t.top=`${this.y}px`,t},maxX(){return Math.max(this.minX,this.vw-this.size-w)},maxY(){return Math.max(this.minY,this.vh-this.size-w-24)},x(){return this.dragging?this.dragX:this.pos.side==="left"?this.minX:this.pos.side==="right"?this.maxX:this.clampX(this.pos.x*this.vw)},y(){return this.dragging?this.dragY:this.clampY(this.pos.y*this.vh)}},watch:{showsMessages:{immediate:!0,handler(e){this.chatStore.bubbleShowsMessages=e}},live(e){!e&&this.$route.name!=="ChatPage"&&this.clearPreviews()},running:{immediate:!0,handler(e,t){this.chatStore.bubbleLive=e;try{e?sessionStorage.setItem(U,this.chatStore.chatData?.chat_uid||""):t===!0&&this.$route.name!=="ChatPage"&&sessionStorage.removeItem(U)}catch{}if(this.$route.name!=="ChatPage"){if(!e){this.chatStore.chatIsActive&&(this._pausedByBubble=!0,this.chatStore.chatIsActive=!1,this.websocketStore.safeSend({type:"pause_chat"}));return}this.reopenIfNeeded()||(this.chatStore.activeWhenLeft||this._pausedByBubble)&&!this.chatStore.chatIsActive&&this.websocketStore.isSessionReady&&(this._pausedByBubble=!1,this.chatStore.chatInterfaceMounted||x(),this.chatStore.chatIsActive=!0,this.websocketStore.safeSend({type:"activate_chat"}))}}},resumeReady:{immediate:!0,handler(e){e&&this.resumeAfterReload()}},visible(e){e&&xe("chat_head","shown",{detail:this.funnelPeep()})},"websocketStore.isSessionReady"(e,t){e&&(t===!1&&this._sessionSeen&&this.chatStore.chatData?.chat_uid&&(this._needsReopen=!0,this.running&&this.$route.name!=="ChatPage"&&this.reopenIfNeeded()),this._sessionSeen=!0)},typingAlone(e,t){if(this.stickBottom(),!t||e)return;const i=t.key;setTimeout(()=>{this.pendingKey===i&&(this.pendingKey=B())},0)},lastMessage(e,t){if(!e||e===t||!this.live)return;const i=this._openingChat;if(this._openingChat=!1,e.id!=null){if(this._seenIds?.has(e.id))return;(this._seenIds=this._seenIds||new Set).add(e.id),this._seenIds.size>200&&(this._seenIds=new Set([e.id]))}
1this.addPreview(e,{quiet:i})},holding(e){e?(clearTimeout(this._hideTimer),this._hideAt=0,(this.typingMsg||this.options.length)&&this.showPanel(0)):this.panelShown&&this.scheduleHide(te,!0)},"options.length"(e,t){e&&!t&&this.lastAiMessage&&!this.previews.some(i=>i.kind!=="user")&&this.addPreview(this.lastAiMessage,{quiet:!0}),this.stickBottom()},typingInto(){this.stickBottom()},composing(e){e&&this.$nextTick(()=>this.$refs.composeInput?.focus()),this.stickBottom()},"chatStore.messages"(e,t){e===t||!this.live||this.$route.name==="ChatPage"||this.$nextTick(this.rebuildFromTranscript)},recentLines(e){clearTimeout(this._turnTimer),this._turnTimer=setTimeout(()=>{Me({uid:this.userStore.user_uid||k.currentUser?.uid,chat_uid:this.chatStore.chatData?.chat_uid,turn:e})},400)},$route(e,t){e.name==="ChatPage"?(this._needsReopen=!1,this.clearPreviews()):t?.name==="ChatPage"&&this.$nextTick(this.seedContext),e.name==="ChatPage"&&this.hidden&&(this.hidden=!1,R(!1)),this.readLocal(),this.$nextTick(this.measure)},"userStore.user_uid"(e,t){t&&e!==t&&(this.userStore.saved_ai_chats=null,this.clearPreviews(),this.userStore.isAuthorized&&Promise.resolve(this.userStore.ensureSavedChatsLoaded()).catch(()=>{})),this.readLocal()},"chatStore.chatInterfaceMounted"(e,t){!e&&t&&this.live&&x()},"chatStore.chatData.chat_uid"(e){if(!e)return;this.chatStore.chatInterfaceMounted||He();const t=this.chatStore.chatData,i=t?.ai_chat_states?.[t?.ai_uids?.[0]];q({uid:this.userStore.user_uid||k.currentUser?.uid,chat_uid:e,image:this.chatStore.chatImageUrl,name:i?.nickname||i?.characteristics?.name||i?.name||""}),this.readLocal()},"target.chat_uid"(e,t){this.imgFailed=!1,t&&e!==t&&(this.clearPreviews(),this.headlessContinues=0),this.$nextTick(this.seedContext)},"target.image"(){this.imgFailed=!1},"userStore.isAuthorized":{handler(e){e&&this.userStore.settings.chatBubble!==!1&&Promise.resolve(this.userStore.ensureSavedChatsLoaded()).catch(()=>{})},immediate:!0},allowed(){this.$nextTick(this.measure)}},mounted(){this.pos=Ze();try{this.hintDue=localStorage.getItem(X)!=="0"}catch{}this.isTouch=!!window.matchMedia?.("(pointer: coarse)").matches;try{this.folded=localStorage.getItem(Z)==="1"}catch{}this.hidden=Ie(),this.readLocal(),k.authStateReady&&k.authStateReady().then(this.readLocal).catch(()=>{}),this.$route.name==="ChatPage"&&this.hidden&&(this.hidden=!1,R(!1)),this.measure(),window.addEventListener("resize",this.measure),this.ready=!0},beforeUnmount(){window.removeEventListener("resize",this.measure),clearTimeout(this._askTimer),clearTimeout(this._bumpTimer),clearTimeout(this._turnTimer),this.clearPreviews()},methods:{peepLook(e,t){const i=this.chatStore.chatData?.ai_uids||[],r=i.length>1,a=i.indexOf(e?.ai_uid),s=r?Ce(a<0?0:a):null,l={};return s&&this.userStore.settings.colorPeepsInChat&&(l["--peep-action-color"]=s,t!=="action"&&(l.background=`color-mix(in srgb, ${s} 26%, rgb(46 52 56 / 0.96))`)),{style:l,color:s,name:r?this.chatStore.nameForMessage(e):""}},peepUid(e){return e?.ai_uid||this.chatStore.chatData?.ai_uids?.[0]||null},previewMs(e){return Math.min(qe,Math.max(ee,ee+e.length*Ge))},addPreview(e,{quiet:t=!1,silent:i=!1}={}){i&&(t=!0);const r=e.message_type,a=e.sender_type==="User";let s=null;if(a?s=["Text","Voice","Action"].includes(r)?"user":null:r==="Text"||r==="Voice"?s="text":r==="Action"?s="action":r==="PeepImage"&&(s="media"),!s)return;const l=s==="media"?"":se(e.content);if(s!=="media"&&!l)return;const n=a?"user":this.peepUid(e),u={id:++le,text:l,line:r==="Text"},f=this.previews[this.previews.length-1];if(f&&s!=="media"&&f.kind===s&&f.uid===n){f.segments.push(u),f.segments.length>Je&&f.segments.splice(0,1),f.len+=l.length,i||this.showPanel(this.previewMs(l)),this.stickBottom();return}const{style:L,color:ce,name:ue}=a?{style:{},color:null,name:""}:this.peepLook(e,s),de=this.pendingKey;this.pendingKey=B(),this.previews.push({key:de,uid:n,kind:s,segments:s==="media"?[]:[u],mediaId:s==="media"&&e.media||null,len:l.length,name:ue,color:ce,style:L}),this.previews.length>$&&this.previews.splice(0,this.previews.length-$),i||this.showPanel(this.previewMs(l)),this.stickBottom(),!(a||t)&&(this.bump=!1,clearTimeout(this._bumpTimer),this.$nextTick(()=>{this.bump=!0,this._bumpTimer=setTimeout(()=>this.bump=!1,450)}))},showPanel(e){this.panelShown||(this.panelShown=!0,this.scrolledUp=!1,this.stickBottom(!0)),!this.holding&&e&&this.scheduleHide(e)},scheduleHide(e,t=!1){const i=t?Date.now()+e:Math.max(this._hideAt||0,Date.now()+e);this._hideAt=i,clearTimeout(this._hideTimer),this._hideTimer=setTimeout(()=>{this.holding||(this.panelShown=!1,this.scrolledUp=!1,this.stickBottom(!0))},i-Date.now())},clearPreviews(){clearTimeout(this._hideTimer),this._seenIds=new Set,this._hideAt=0,this.previews=[],this.panelShown=!1,this.held=!1,this.composing=!1},stickBottom(e=!1){this.$nextTick(()=>{const t=this.$refs.scroller;!t||!e&&this.scrolledUp||(this._progScroll=!0,t.scrollTop=t.scrollHeight,this.atTop=t.scrollTop<4,requestAnimationFrame(()=>this._progScroll=!1))})},onScroll(e){const t=e.target;this.atTop=t.scrollTop<4,!this._progScroll&&(this.scrolledUp=t.scrollHeight-t.scrollTop-t.clientHeight>8,this.holding||this.scheduleHide(je))},onHover(e,t){e.pointerType==="mouse"&&(this.held=t,t&&this.showPanel(0))},seedContext(){if(!this.target||this.previews.length||this.$route.name==="ChatPage")return;const e=this.chatStore.chatData?.chat_uid===this.target.chat_uid?this.recentLines:ke(this.userStore.user_uid||k.currentUser?.uid,this.target.chat_uid);this.fileLines(e)},fileLines(e){this._seenIds=this._seenIds||new Set,e.forEach(t=>{t.id!=null&&this._seenIds.add(t.id),this.addPreview(t,{silent:!0})})},rebuildFromTranscript(){this.live&&(this.previews=[],this._seenIds=new Set,this.fileLines(this.recentLines),this.stickBottom(!0))},showContext(){this.seedContext(),this.previews.length&&this.showPanel(te)}
1,onFaceHover(e,t){e.pointerType!=="mouse"||this.dragging||this.press||(t?(this.showContext(),this.held=!0):this.held=!1)},onSwipeStart(e){e.pointerType==="mouse"||this.folded||(this._swipe={id:e.pointerId,x:e.clientX,y:e.clientY,active:!1})},onSwipeMove(e){const t=this._swipe;if(!t||t.id!==e.pointerId)return;const i=e.clientX-t.x,r=e.clientY-t.y;if(!t.active&&(Math.abs(i)>10&&Math.abs(i)>1.5*Math.abs(r)?t.active=!0:Math.abs(r)>10&&(this._swipe=null),!t.active))return;const a=this.stackLeft?i:-i;this.swipeDX=Math.max(0,a)*(this.stackLeft?1:-1)},onSwipeEnd(e){const t=this._swipe;if(this._swipe=null,!t||t.id!==e.pointerId||!t.active)return;this._swipedAt=Date.now();const i=Math.abs(this.swipeDX)>60;if(this.swipeDX=0,i&&!this.folded&&(this.toggleFold(),this.hintDue)){this.hintDue=!1;try{localStorage.setItem(X,"0")}catch{}}},onSwipeCancel(){this._swipe=null,this.swipeDX=0},onMsgClick(){Date.now()-(this._swipedAt||0)<400||this.openChat()},toggleFold(){this.folded=!this.folded,M("chat_head",this.folded?"collapse":"expand",{detail:this.funnelPeep()}),this.folded&&(this.composing=!1);try{localStorage.setItem(Z,this.folded?"1":"0")}catch{}this.folded||(this.showContext(),this.stickBottom(!0),this.$nextTick(()=>C.emit("chat-head-unfolded")))},openCompose(){this.composing=!0,this.showContext()},async sendCompose({fromOption:e=!1}={}){const t=this.chatStore.userMessage?.trim();if(this.sending||!t&&!this.canContinue)return;this.scrolledUp=!1,this.composing=!1;const i=t?"send":"continue";if(this.live&&this.chatStore.chatInterfaceMounted&&!this._needsReopen){e||M("chat_head",i,{detail:this.funnelPeep()}),C.emit("chat-head-send");return}const r=this.userStore,a=Y().sharedInfo?.cost_chat_message,s=r.userRecord.daily_chat_messages_freemium||r.totPeepCoinsLeft>=a||r.isSubscribed;if(r.isAuthorized&&!s){this.$modalStore.openNotEnoughCoins(a,"chat");return}if(!this.websocketStore.isSessionReady){this.openChat();return}this.sending=!0;try{if(!await this.ensureChatOpen()){this.openChat();return}if(e||M("chat_head",i,{detail:this.funnelPeep()}),this.chatStore.chatInterfaceMounted){C.emit("chat-head-send");return}x();const l=this.chatStore.chatData;if(this.websocketStore.safeSend({type:"activate_chat",data:"user_triggered"}),!t){this.headlessContinues+=1,await O("request-response");return}this.headlessContinues=0,Oe(),this.$gtag?.event("message_sent",{event_category:"Chat",event_label:"User sent a message",value:1}),be(),ve(),this.websocketStore.safeSend({type:"user_send_text",chat_uid:l?.chat_uid,content:this.chatStore.userMessage,is_audio:!1});const n=l?.ai_chat_states?.[l?.ai_uids?.[0]];q({uid:r.user_uid||k.currentUser?.uid,chat_uid:l?.chat_uid,image:this.chatStore.chatImageUrl,name:n?.nickname||n?.characteristics?.name||n?.name||""}),this.chatStore.userMessage="";try{localStorage.removeItem("auto_saved_msg")}catch{}}finally{this.sending=!1}},onComposeEnter(e){e.isComposing||e.keyCode===229||(e.preventDefault(),this.sendCompose())},onComposeInput(){if(Fe(),this.chatStore.chatInterfaceMounted)C.emit("chat-head-typing");else if(this.live){const e=Date.now();e-(this._typingSentAt||0)>500&&(this.websocketStore.safeSend({type:"user_started_typing"}),this._typingSentAt=e)}},mediaFor(e){if(!e.mediaId||!this.userStore.settings.custom_media_in_chat)return null;const t=this.chatStore.chatData?.ai_chat_states||{};for(const i of Object.keys(t)){const r=t[i]?.images?.find(a=>a.image_id===e.mediaId);if(r?.url)return r}return null},optionSegments(e){const t=String(e??""),i=[],r=/\*[^*]+\*/g;let a=0,s;for(;(s=r.exec(t))!==null;)s.index>a&&i.push({action:!1,text:t.slice(a,s.index)}),i.push({action:!0,text:s[0]}),a=s.index+s[0].length;return a<t.length&&i.push({action:!1,text:t.slice(a)}),i},async ensureChatOpen({resume:e=!1}={}){const t=this.target;if(!t)return!1;if(this.chatStore.chatData?.chat_uid!==t.chat_uid&&(this._needsReopen=!1),this.reopenIfNeeded(),this._reopening&&await this._reopening,this.chatStore.chatInterfaceMounted||x(),this.chatStore.chatData?.chat_uid!==t.chat_uid){if(this._openingChat=!0,!await this.chatStore.openChat(t.chat_uid,!e,e?"chat_head_reconnect":"chat_head"))return this._openingChat=!1,!1;e||M("chat_open","chat_head",{detail:this.userStore.isAuthorized?"signed":"guest"})}return!0},async resumeAfterReload(){if(this._resumeTried)return;let e="";try{e=sessionStorage.getItem(U)||""}catch{}!e||e!==this.target?.chat_uid||this.chatStore.chatData?.chat_uid!==e&&(this._resumeTried=!0,await this.ensureChatOpen({resume:!0}))},async toggleOptions(){if(!this.chatStore.bubbleLoadingOptions){if(!this.live||this._needsReopen){if(!this.websocketStore.isSessionReady){this.openChat();return}if(!await this.ensureChatOpen()){this.openChat();return}}if(this.chatStore.chatInterfaceMounted){C.emit("chat-head-toggle-options");return}await Ue()==="cap"&&this.openChat()}},async pickOption(e){if(!(Date.now()-(this._swipedAt||0)<400)){if(M("chat_head","option",{detail:this.funnelPeep()}),this.chatStore.chatInterfaceMounted){this.reopenIfNeeded(),this._reopening&&await this._reopening,C.emit("chat-head-option",e);return}O("chat-options-event",{event:"option_selected"}).catch(()=>{}),this.chatStore.userMessage=e,await this.sendCompose({fromOption:!0})}},funnelPeep(){const e=this.chatStore.chatData;if(!e||e.chat_uid!==this.target?.chat_uid)return"";const t=e.ai_uids?.[0],i=e.ai_chat_states?.[t];return i?.slug||i?.characteristics?.slug||t||""},reopenIfNeeded(){const e=this.chatStore.chatData?.chat_uid;return!this._needsReopen||!e||!this.websocketStore.isSessionReady?!1:(this._needsReopen=!1,this.chatStore.chatInterfaceMounted||x(),this._reopening=this.chatStore.openChat(e,!1,"chat_head_reconnect").catch(()=>{}).finally(()=>this._reopening=null),!0)},editOption(e){this.chatStore.userMessage=e,this.composing=!0,this.$nextTick(()=>{const t=this.$refs.composeInput;t&&(t.focus(),t.setSelectionRange?.(e.length,e.length))})},readLocal(){this.local=we(this.userStore.user_uid||k.currentUser?.uid||null),this.$nextTick(this.seedContext)},measure(){this.vw=window.innerWidth,this.vh=window.innerHeight;const e=document.getElementById("appcont"),t=e?Math.max(0,e.getBoundingClientRect().left):0;this.minX=t+w;const i=e&&parseFloat(getComputedStyle(e).getPropertyValue("--header-h"))||0;this.minY=i+w},clampX(e){return Math.min(this.maxX,Math.max(this.minX,e))},clampY(e){return Math.min(this.maxY,Math.max(this.minY,e))},onDown(e){if(!(e.pointerType==="mouse"&&e.button!==0)){this.measure(),this.press={id:e.pointerId,startX:e.clientX,startY:e.clientY,offX:e.clientX-this.x,offY:e.clientY-this.y};try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}}},onMove(e){const t=this.press;if(!(!t||t.id!==e.pointerId)){if(!this.dragging){if(Math.hypot(e.clientX-t.startX,e.clientY-t.startY)<Ve)return;this.dragging=!0}this.dragX=Math.min(this.vw-this.size,Math.max(0,e.clientX-t.offX)),this.dragY=Math.min(this.vh-this.size,Math.max(0,e.clientY-t.offY))}},tapFace(){if(this.folded&&this.canWrite){this.toggleFold();return}this.openChat()},onUp(e){const t=this.press;if(!t||t.id!==e.pointerId)return;if(this.press=null,!this.dragging){this.tapFace();return}const i=this.clampX(this.dragX),r=this.clampY(this.dragY);let a=null;i-this.minX<=Q?a="left":this.maxX-i<=Q&&(a="right"),this.pos={side:a,x:this.vw?i/this.vw:0,y:this.vh?r/this.vh:.62},this.dragging=!1;try{localStorage.setItem(he,JSON.stringify(this.pos))}catch{}},onCancel(){this.press=null,this.dragging=!1},isVideo(e){return!!e&&/\.(mp4|webm|ogg)(\?|#|$)/i.test(e)},onImgError(){this.imgFailed=!0},openChat(){const e=this.target;e&&(this.clearPreviews(),this.chatStore.chatData?.chat_uid===e.chat_uid?this.$router.push({path:"/chat/"}):this.$router.push({path:"/chat/",query:{chat_uid:e.chat_uid}}))},hide(){this.hidden=!0,this.hintDue=!0;try{localStorage.removeItem(X)}catch{}R(!0),this.askOpen=!0,clearTimeout(this._askTimer),this._askTimer=setTimeout(this.closeAsk,12e3)},closeAsk(){clearTimeout(this._askTimer),this.askOpen=!1},disableForGood(){this.userStore.setSetting("chatBubble",!1),this.closeAsk()}}},$e=["aria-label"],et=["src"],tt=["src"],st=["aria-label"],it=["aria-label"],nt={key:0,class:"ch-hint"},at=["src","poster"],rt=["src"],ot={key:2},ht={key:0,class:"ch-dots inline"},lt=["onClick"],ct={key:0,class:"ch-opt-emoji","aria-hidden":"true"},ut={class:"ch-opt-text"},dt=["aria-label","onClick"],ft={key:1,class:"ch-actions"},pt=["aria-label"],gt={key:0,class:"spinner"},mt={key:1,class:"fas fa-rotate-right"},_t={key:2,class:"fas fa-comment-dots"},yt=["aria-label"],St=["placeholder"],wt={viewBox:"0 0 12 13",width:"18",height:"18",fill:"
1currentColor","aria-hidden":"true",style:{"--color":"var(--primary-icon)"}},bt=["aria-label"],vt={key:0,class:"chat-head-ask container"},kt={class:"row-container ask-buttons"};function Ct(e,t,i,r,a,s){const l=me("base-button");return a.ready?(o(),h(v,{key:0},[s.visible?(o(),h("div",{key:0,class:g(["chat-head",{dragging:a.dragging,snapping:!a.dragging}]),style:p({left:`${s.x}px`,top:`${s.y}px`,"--ch-size":`${s.size}px`}),role:"button",tabindex:"0","aria-label":e.$t("chatHead.open",{name:s.target.name||""}),onPointerenter:t[6]||(t[6]=n=>s.onFaceHover(n,!0)),onPointerleave:t[7]||(t[7]=n=>s.onFaceHover(n,!1)),onPointerdown:t[8]||(t[8]=(...n)=>s.onDown&&s.onDown(...n)),onPointermove:t[9]||(t[9]=(...n)=>s.onMove&&s.onMove(...n)),onPointerup:t[10]||(t[10]=(...n)=>s.onUp&&s.onUp(...n)),onPointercancel:t[11]||(t[11]=(...n)=>s.onCancel&&s.onCancel(...n)),onKeydown:t[12]||(t[12]=H((...n)=>s.tapFace&&s.tapFace(...n),["enter"]))},[c("div",{class:g(["ch-face",{bump:a.bump}])},[s.isVideo(s.target.image)?(o(),h("video",{key:0,src:e.$toCdnUrl(s.target.image),autoplay:"",muted:"",loop:"",playsinline:"",disablepictureinpicture:"",onError:t[0]||(t[0]=(...n)=>s.onImgError&&s.onImgError(...n))},null,40,et)):(o(),h("img",{key:1,src:e.$toCdnUrl(s.target.image),alt:"",draggable:"false",onError:t[1]||(t[1]=(...n)=>s.onImgError&&s.onImgError(...n))},null,40,tt))],2),c("span",{class:"chat-head-x",role:"button","aria-label":e.$t("chatHead.hide"),onPointerdown:t[2]||(t[2]=m(()=>{},["stop"])),onClick:t[3]||(t[3]=m((...n)=>s.hide&&s.hide(...n),["stop"]))},[...t[32]||(t[32]=[c("i",{class:"fa-solid fa-xmark"},null,-1)])],40,st),s.canWrite&&(a.folded||s.panelOpen)?(o(),h("span",{key:0,class:g(["chat-head-x chat-head-fold",{lit:a.previews.length>0}]),role:"button","aria-label":a.folded?e.$t("chatHead.unfold"):e.$t("chatHead.fold"),onPointerdown:t[4]||(t[4]=m(()=>{},["stop"])),onClick:t[5]||(t[5]=m((...n)=>s.toggleFold&&s.toggleFold(...n),["stop"]))},[c("i",{class:g(["fa-solid",s.foldIcon])},null,2)],42,it)):d("",!0)],46,$e)):d("",!0),s.visible&&!a.dragging?(o(),h("div",{key:1,class:g(["ch-stack",[s.stackLeft?"stack-left":"stack-right",s.stackUp?"stack-up":"stack-down"]]),style:p(s.stackStyle),onPointerenter:t[30]||(t[30]=n=>s.onHover(n,!0)),onPointerleave:t[31]||(t[31]=n=>s.onHover(n,!1))},[b(E,{name:"ch-panel"},{default:S(()=>[V(c("div",{class:"ch-panel",style:p(s.swipeStyle),onPointerdown:t[18]||(t[18]=(...n)=>s.onSwipeStart&&s.onSwipeStart(...n)),onPointermove:t[19]||(t[19]=(...n)=>s.onSwipeMove&&s.onSwipeMove(...n)),onPointerup:t[20]||(t[20]=(...n)=>s.onSwipeEnd&&s.onSwipeEnd(...n)),onPointercancel:t[21]||(t[21]=(...n)=>s.onSwipeCancel&&s.onSwipeCancel(...n))},[b(E,{name:"ch-hint"},{default:S(()=>[s.hintShown?(o(),h("div",nt,_(s.stackLeft?e.$t("chatHead.swipeRightHint"):e.$t("chatHead.swipeLeftHint")),1)):d("",!0)]),_:1}),c("div",{ref:"scroller",class:g(["ch-scroll",{"fade-top":!a.atTop}]),style:p({maxHeight:`${s.scrollMax}px`}),onScroll:t[17]||(t[17]=(...n)=>s.onScroll&&s.onScroll(...n))},[b(K,{name:"ch-msg"},{default:S(()=>[(o(!0),h(v,null,D(s.visiblePreviews,n=>(o(),h("div",{key:n.key,class:g(["ch-msg",`ch-${n.kind}`]),style:p(n.style),onClick:t[15]||(t[15]=(...u)=>
1s.onMsgClick&&s.onMsgClick(...u))},[n.name?(o(),h("div",{key:0,class:"ch-msg-name",style:p({color:n.color})},_(n.name),5)):d("",!0),n.kind==="media"?(o(),h(v,{key:1},[s.mediaFor(n)?.type==="video"?(o(),h("video",{key:0,class:"ch-thumb",src:e.$toCdnUrl(s.mediaFor(n).url),poster:s.mediaFor(n).poster_url,autoplay:"",muted:"",loop:"",playsinline:"",disablepictureinpicture:"",onLoadedmetadata:t[13]||(t[13]=u=>s.stickBottom())},null,40,at)):s.mediaFor(n)?(o(),h("img",{key:1,class:"ch-thumb",src:e.$toCdnUrl(s.mediaFor(n).url),alt:"",draggable:"false",onLoad:t[14]||(t[14]=u=>s.stickBottom())},null,40,rt)):(o(),h("span",ot,[t[33]||(t[33]=c("i",{class:"fa-solid fa-image"},null,-1)),F(" "+_(e.$t("chatHead.sentPhoto")),1)]))],64)):(o(),h(v,{key:2},[(o(!0),h(v,null,D(n.segments,u=>(o(),h("span",{key:u.id,class:g(["ch-seg",{line:u.line}])},_(u.text+" "),3))),128)),s.typingInto===n.key?(o(),h("span",ht,[...t[34]||(t[34]=[c("i",null,null,-1),c("i",null,null,-1),c("i",null,null,-1)])])):d("",!0)],64))],6))),128)),s.typingAlone?(o(),h("div",{key:s.typingAlone.key,class:"ch-msg ch-text",style:p(s.typingAlone.style),onClick:t[16]||(t[16]=(...n)=>s.onMsgClick&&s.onMsgClick(...n))},[s.typingAlone.name?(o(),h("div",{key:0,class:"ch-msg-name",style:p({color:s.typingAlone.color})},_(s.typingAlone.name),5)):d("",!0),t[35]||(t[35]=c("span",{class:"ch-dots"},[c("i"),c("i"),c("i")],-1))],4)):d("",!0)]),_:1})],38)],36),[[_e,s.panelOpen]])]),_:1}),!a.folded&&s.options.length?(o(),ye(K,{key:0,name:"ch-opt",tag:"div",class:"ch-options",style:p(s.swipeStyle),appear:"",onPointerdown:s.onSwipeStart,onPointermove:s.onSwipeMove,onPointerup:s.onSwipeEnd,onPointercancel:s.onSwipeCancel},{default:S(()=>[(o(!0),h(v,null,D(s.options,(n,u)=>(o(),h("button",{key:n.content+":"+u,type:"button",class:"ch-opt",style:p({transitionDelay:`${u*70}ms`}),onClick:m(f=>s.pickOption(n.content),["stop"])},[n.emoji?(o(),h("span",ct,_(n.emoji),1)):d("",!0),c("span",ut,[(o(!0),h(v,null,D(s.optionSegments(n.content),(f,L)=>(o(),h("span",{key:L,class:g({"ch-opt-action":f.action})},_(f.text),3))),128))]),c("span",{class:"ch-opt-edit",role:"button","aria-label":e.$t("chatHead.editOption"),onClick:m(f=>s.editOption(n.content),["stop"])},[...t[36]||(t[36]=[c("i",{class:"fas fa-pen"},null,-1)])],8,dt)],12,lt))),128))]),_:1},8,["style","onPointerdown","onPointermove","onPointerup","onPointercancel"])):d("",!0),!a.folded&&s.canWrite?(o(),h("div",ft,[c("div",{class:g(["icon-circle special-icon",{"is-off":a.userStore.settings.autoChatOptions===!1,"is-failed":a.chatStore.bubbleOptionsFailed}]),role:"button","aria-label":e.$t("chatHead.options"),onClick:t[22]||(t[22]=m((...n)=>s.toggleOptions&&s.toggleOptions(...n),["stop"]))},[a.chatStore.bubbleLoadingOptions?(o(),h("span",gt)):a.chatStore.bubbleOptionsFailed?(o(),h("i",mt)):(o(),h("i",_t))],10,pt),c("button",{type:"button",class:g(["ch-write",{on:a.composing}]),"aria-label":e.$t("chatHead.write"),onClick:t[23]||(t[23]=m(n=>a.composing?a.composing=!1:s.openCompose(),["stop"]))},[...t[37]||(t[37]=[c("i",{class:"fa-solid fa-keyboard"},null,-1)])],10,yt)])):d("",!0),a.composing&&!a.folded?(o(),h("div",{key:2,class:"ch-compose",style:p({width:`${s.stackMaxW}px`}),onClick:t[29]||(t[29]=m(()=>{},["stop"]))},[V(c("input",{ref:"composeInput","onUpdate:modelValue":t[24]||(t[24]=n=>a.chatStore.userMessage=n),type:"text",class:"ch-compose-input",enterkeyhint:"send",placeholder:e.$t("chatHead.writePlaceholder"),onKeydown:[t[25]||(t[25]=H((...n)=>s.onComposeEnter&&s.onComposeEnter(...n),["enter"])),t[26]||(t[26]=H(m(n=>a.composing=!1,["prevent"]),["esc"]))],onInput:t[27]||(t[27]=(...n)=>s.onComposeInput&&s.onComposeInput(...n))},null,40,St),[[Se,a.chatStore.userMessage]]),b(l,{class:"control-btn","aria-label":e.$t("chatHead.send"),action:s.sendCompose,"is-disabled":!a.chatStore.userMessage?.trim()&&!s.canContinue},{default:S(()=>[(o(),h("svg",wt,[...t[38]||(t[38]=[c("g",{"fill-rule":"evenodd",transform:"translate(-449 -1072)"},[c("path",{d:"m458.371 1079.75-6.633.375a.243.243 0 0 0-.22.17l-.964 3.255c-.13.418-.024.886.305 1.175a1.08 1.08 0 0 0 1.205.158l8.836-4.413c.428-.214.669-.677.583-1.167-.06-.346-.303-.633-.617-.79l-8.802-4.396a1.073 1.073 0 0 0-1.183.14c-.345.288-.458.77-.325 1.198l.963 3.25c.03.097.118.165.22.17l6.632.375s.254 0 .254.25-.254.25-.254.25"})],-1)])]))]),_:1},8,["aria-label","action","is-disabled"]),c("button",{type:"button",class:"ch-compose-btn","aria-label":e.$t("chatHead.closeWrite"),onClick:t[28]||(t[28]=m(n=>a.composing=!1,["stop"]))},[...t[39]||(t[39]=[c("i",{class:"fa-solid fa-xmark"},null,-1)])],8,bt)],4)):d("",!0)],38)):d("",!0),b(E,{name:"ch-ask"},{default:S(()=>[a.askOpen?(o(),h("div",vt,[c("div",null,_(e.$t("chatHead.askDisable")),1),c("div",kt,[b(l,{"small-button":!0,onClick:s.disableForGood},{default:S(()=>[F(_(e.$t("chatHead.disable")),1)]),_:1},8,["onClick"]),b(l,{"small-button":!0,onClick:s.closeAsk},{default:S(()=>[F(_(e.$t("chatHead.keep")),1)]),_:1},8,["onClick"])])])):d("",!0)]),_:1})],64)):d("",!0)}const Mt=pe(Qe,[["render",Ct],["__scopeId","data-v-f90055b3"]]);export{Mt as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.