import{b4 as t}from"./index.BFRcEQe4.js";const e="signal_device_id",a=new Map;let s=0;function n(){let t=localStorage.getItem(e);return t||(t=`${Date.now()}-${Math.random().toString(36).substring(2,11)}`,localStorage.setItem(e,t)),t}var E=(t=>(t[t.MSG_NEW=10001]="MSG_NEW",t[t.MSG_SYNC=10002]="MSG_SYNC",t[t.STATUS_CHANGE=10003]="STATUS_CHANGE",t[t.STATUS_QUERY=10004]="STATUS_QUERY",t[t.MSG_READ_ACK=10005]="MSG_READ_ACK",t[t.MSG_FETCH=10006]="MSG_FETCH",t[t.STAGE_VIDEO_PARSE=10008]="STAGE_VIDEO_PARSE",t[t.FLOATING_NOTICE=10009]="FLOATING_NOTICE",t[t.SYS_NOTIFY=20001]="SYS_NOTIFY",t[t.SYS_KICK=20002]="SYS_KICK",t[t.SYS_CONFIG_UPDATE=20003]="SYS_CONFIG_UPDATE",t[t.SIGNAL_PULL=30001]="SIGNAL_PULL",t[t.SIGNAL_PULL_RESP=30002]="SIGNAL_PULL_RESP",t[t.SEND_MSG=40001]="SEND_MSG",t[t.REQUEST_PHOTO=40002]="REQUEST_PHOTO",t[t.REQUEST_VIDEO=40003]="REQUEST_VIDEO",t[t.REGENERATE_ANSWER=40004]="REGENERATE_ANSWER",t[t.SEND_GIFT=40006]="SEND_GIFT",t[t.STAGE_VIDEO_PLAY_ACK=40007]="STAGE_VIDEO_PLAY_ACK",t[t.INTIMACY_RESET=40008]="INTIMACY_RESET",t[t.HOTPOINT_UPDATE=40009]="HOTPOINT_UPDATE",t[t.ENTER_PRIVATE_CHAT=40010]="ENTER_PRIVATE_CHAT",t[t.GUIDE_IDLE=40011]="GUIDE_IDLE",t[t.STAY_REPORT=40012]="STAY_REPORT",t[t.GOLD_COINS_UPDATE=50001]="GOLD_COINS_UPDATE",t[t.ACK=90001]="ACK",t[t.ERROR=99999]="ERROR",t))(E||{});const S="/chat/v3/signal/gateway";["1","true","on"].includes(String("").trim().toLowerCase());class _{static async gateway(e,_){const i=++s,T=Date.now(),c=((t=>{E[t]})(e),{clientSeq:i,code:e,version:1,timestamp:T,deviceId:n(),data:_});return new Promise((s,n)=>{const E=setTimeout(()=>{a.delete(i),Date.now(),n(new Error(`Request timeout: clientSeq=${i}`))},3e4);a.set(i,{clientSeq:i,code:e,timestamp:T,resolve:s,reject:n,timeoutId:E}),t({url:S,method:"post",data:c}).then(t=>{clearTimeout(E);t.clientSeq;a.delete(i),Date.now(),s(t)}).catch(t=>{clearTimeout(E),a.delete(i),Date.now(),n(t)})})}static async pullSignals(t,e,a,s){const n={};return void 0!==t&&(n.lastSeq=t),void 0!==e&&(n.limit=e),a&&a.length>0&&(n.ackSeqs=a),void 0!==s&&(n.init=s),this.gateway(E.SIGNAL_PULL,n)}static async sendMessage(t,e,a=1,s,n){const S={botId:t,content:e,chatType:a,clientMsgId:s};return void 0!==n&&(S.sessionType=n),this.gateway(E.SEND_MSG,S)}static async sendStageVideoPlayAck(t){return this.gateway(E.STAGE_VIDEO_PLAY_ACK,t)}static async sendGift(t){return this.gateway(E.SEND_GIFT,t)}static async sendIntimacyReset(t){return this.gateway(E.INTIMACY_RESET,t)}static async requestHotpointUpdate(t){return this.gateway(E.HOTPOINT_UPDATE,t)}static async enterPrivateChat(t){return this.gateway(E.ENTER_PRIVATE_CHAT,t)}static async sendGuideIdle(t){return this.gateway(E.GUIDE_IDLE,t)}static async sendStayReport(t){return this.gateway(E.STAY_REPORT,t)}static async sendInteractMessage(t){return this.gateway(E.SEND_MSG,t)}static async fetchMessages(t){const e={messageIds:t};return this.gateway(E.MSG_FETCH,e)}static async syncMessages(t,e,a){const s={botId:t};return e&&(s.lastMsgId=e),a&&(s.limit=a),this.gateway(E.MSG_SYNC,s)}static async queryStatus(t){const e={botIds:t};return this.gateway(E.STATUS_QUERY,e)}static async ackRead(t,e,a){const s={botId:t};return e&&(s.lastReadMsgId=e),a&&(s.lastReadTime=a),this.gateway(E.MSG_READ_ACK,s)}static async requestPhoto(t,e){const a={botId:t};return e&&(a.poseType=e),this.gateway(E.REQUEST_PHOTO,a)}static async regenerateAnswer(t,e,a,s=1,n){const S={botId:t,answerMsgIds:e,lastContent:a,chatType:s,clientMsgId:n};return this.gateway(E.REGENERATE_ANSWER,S)}}export{_ as S,E as a,n as g};