@nam088/zca-js 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +5 -0
- package/CODE_OF_CONDUCT.md +163 -0
- package/CONTRIBUTING.md +470 -0
- package/LICENSE +21 -0
- package/README.md +225 -0
- package/SECURITY.md +83 -0
- package/dist/index.cjs +10043 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +3396 -0
- package/dist/index.js +10023 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.cjs +2 -0
- package/dist/index.min.cjs.map +1 -0
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/eslint.config.mjs +27 -0
- package/index.d.ts +2 -0
- package/package.json +88 -0
- package/rollup.config.js +110 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e,t,r,n,a,i,o,s,c,p,d,u,l,m=require("tough-cookie"),h=require("node:fs/promises"),f=require("crypto-js"),g=require("node:crypto"),y=require("node:fs"),w=require("node:path"),v=require("pako"),S=require("spark-md5"),T=require("json-bigint"),R=require("semver"),k=require("events"),U=require("ws"),E=require("form-data");class b extends Error{constructor(e,t){super(e),this.name="ZcaApiError",this.code=t||null}}class _ extends b{constructor(){super("Missing `imageMetadataGetter`. Please provide it in the Zalo object options."),this.name="ZaloApiMissingImageMetadataGetter"}}class x extends b{constructor(e="Operation aborted"){super(e),this.name="ZaloApiLoginQRAborted"}}class O extends b{constructor(e="Login QR request declined"){super(e),this.name="ZaloApiLoginQRDeclined"}}exports.AutoReplyScope=void 0,(e=exports.AutoReplyScope||(exports.AutoReplyScope={}))[e.Everyone=0]="Everyone",e[e.Stranger=1]="Stranger",e[e.SpecificFriends=2]="SpecificFriends",e[e.FriendsExcept=3]="FriendsExcept",exports.BoardType=void 0,(t=exports.BoardType||(exports.BoardType={}))[t.Note=1]="Note",t[t.PinnedMessage=2]="PinnedMessage",t[t.Poll=3]="Poll",exports.ThreadType=void 0,(r=exports.ThreadType||(exports.ThreadType={}))[r.User=0]="User",r[r.Group=1]="Group",exports.DestType=void 0,(n=exports.DestType||(exports.DestType={}))[n.Group=1]="Group",n[n.User=3]="User",n[n.Page=5]="Page",exports.Gender=void 0,(a=exports.Gender||(exports.Gender={}))[a.Male=0]="Male",a[a.Female=1]="Female",exports.BinBankCard=void 0,(i=exports.BinBankCard||(exports.BinBankCard={}))[i.ABBank=970425]="ABBank",i[i.ACB=970416]="ACB",i[i.Agribank=970405]="Agribank",i[i.BIDV=970418]="BIDV",i[i.BVBank=970454]="BVBank",i[i.BacA_Bank=970409]="BacA_Bank",i[i.BaoViet_Bank=970438]="BaoViet_Bank",i[i.CAKE=546034]="CAKE",i[i.CB_Bank=970444]="CB_Bank",i[i.CIMB_Bank=422589]="CIMB_Bank",i[i.Coop_Bank=970446]="Coop_Bank",i[i.DBS_Bank=796500]="DBS_Bank",i[i.DongA_Bank=970406]="DongA_Bank",i[i.Eximbank=970431]="Eximbank",i[i.GPBank=970408]="GPBank",i[i.HDBank=970437]="HDBank",i[i.HSBC=458761]="HSBC",i[i.HongLeong_Bank=970442]="HongLeong_Bank",i[i.IBK_HCM=970456]="IBK_HCM",i[i.IBK_HN=970455]="IBK_HN",i[i.Indovina_Bank=970434]="Indovina_Bank",i[i.KBank=668888]="KBank",i[i.KienlongBank=970452]="KienlongBank",i[i.Kookmin_Bank_HCM=970463]="Kookmin_Bank_HCM",i[i.Kookmin_Bank_HN=970462]="Kookmin_Bank_HN",i[i.LPBank=970449]="LPBank",i[i.MB_Bank=970422]="MB_Bank",i[i.MSB=970426]="MSB",i[i.NCB=970419]="NCB",i[i.Nam_A_Bank=970428]="Nam_A_Bank",i[i.NongHyup_Bank=801011]="NongHyup_Bank",i[i.OCB=970448]="OCB",i[i.Ocean_Bank=970414]="Ocean_Bank",i[i.PGBank=970430]="PGBank",i[i.PVcomBank=970412]="PVcomBank",i[i.Public_Bank_Vietnam=970439]="Public_Bank_Vietnam",i[i.SCB=970429]="SCB",i[i.SHB=970443]="SHB",i[i.Sacombank=970403]="Sacombank",i[i.Saigon_Bank=970400]="Saigon_Bank",i[i.SeABank=970440]="SeABank",i[i.Shinhan_Bank=970424]="Shinhan_Bank",i[i.Standard_Chartered_Vietnam=970410]="Standard_Chartered_Vietnam",i[i.TNEX=9704261]="TNEX",i[i.TPBank=970423]="TPBank",i[i.Techcombank=970407]="Techcombank",i[i.Timo=963388]="Timo",i[i.UBank=546035]="UBank",i[i.United_Overseas_Bank_Vietnam=970458]="United_Overseas_Bank_Vietnam",i[i.VIB=970441]="VIB",i[i.VPBank=970432]="VPBank",i[i.VRB=970421]="VRB",i[i.VietABank=970427]="VietABank",i[i.VietBank=970433]="VietBank",i[i.Vietcombank=970436]="Vietcombank",i[i.VietinBank=970415]="VietinBank",i[i.Woori_Bank=970457]="Woori_Bank";class A{constructor(e){this.type=exports.ThreadType.User,this.data=e,this.threadId=e.deliveredUids[0],this.isSelf=!1}}class L{constructor(e,t){this.type=exports.ThreadType.Group,this.data=t,this.threadId=t.groupId,this.isSelf=t.deliveredUids.includes(e)}}function I(e,t,r){if(r==exports.FriendEventType.ADD||r==exports.FriendEventType.REMOVE||r==exports.FriendEventType.BLOCK||r==exports.FriendEventType.UNBLOCK||r==exports.FriendEventType.BLOCK_CALL||r==exports.FriendEventType.UNBLOCK_CALL)return{type:r,data:t,threadId:t,isSelf:![exports.FriendEventType.ADD,exports.FriendEventType.REMOVE].includes(r)};if(r==exports.FriendEventType.REJECT_REQUEST||r==exports.FriendEventType.UNDO_REQUEST){return{type:r,data:t,threadId:t.toUid,isSelf:t.fromUid==e}}if(r==exports.FriendEventType.REQUEST){return{type:r,data:t,threadId:t.toUid,isSelf:t.fromUid==e}}if(r==exports.FriendEventType.SEEN_FRIEND_REQUEST)return{type:r,data:t,threadId:e,isSelf:!0};if(r==exports.FriendEventType.PIN_CREATE){return{type:r,data:t,threadId:t.conversationId,isSelf:t.actorId==e}}if(r==exports.FriendEventType.PIN_UNPIN){return{type:r,data:t,threadId:t.conversationId,isSelf:t.actorId==e}}return{type:exports.FriendEventType.UNKNOWN,data:JSON.stringify(t),threadId:"",isSelf:!1}}function N(e,t,r,n){var a;const i="group_id"in t?t.group_id:t.groupId;if(r==exports.GroupEventType.JOIN_REQUEST)return{type:r,act:n,data:t,threadId:i,isSelf:!1};if(r==exports.GroupEventType.NEW_PIN_TOPIC||r==exports.GroupEventType.UNPIN_TOPIC||r==exports.GroupEventType.UPDATE_PIN_TOPIC)return{type:r,act:n,data:t,threadId:i,isSelf:t.actorId==e};if(r==exports.GroupEventType.REORDER_PIN_TOPIC)return{type:r,act:n,data:t,threadId:i,isSelf:t.actorId==e};if(r==exports.GroupEventType.UPDATE_BOARD||r==exports.GroupEventType.REMOVE_BOARD)return{type:r,act:n,data:t,threadId:i,isSelf:t.sourceId==e};if(r==exports.GroupEventType.ACCEPT_REMIND||r==exports.GroupEventType.REJECT_REMIND)return{type:r,act:n,data:t,threadId:i,isSelf:t.updateMembers.some(t=>t==e)};if(r==exports.GroupEventType.REMIND_TOPIC)return{type:r,act:n,data:t,threadId:i,isSelf:t.creatorId==e};{const o=t;return{type:r,act:n,data:o,threadId:i,isSelf:(null===(a=o.updateMembers)||void 0===a?void 0:a.some(t=>t.id==e))||o.sourceId==e}}}exports.FriendEventType=void 0,(o=exports.FriendEventType||(exports.FriendEventType={}))[o.ADD=0]="ADD",o[o.REMOVE=1]="REMOVE",o[o.REQUEST=2]="REQUEST",o[o.UNDO_REQUEST=3]="UNDO_REQUEST",o[o.REJECT_REQUEST=4]="REJECT_REQUEST",o[o.SEEN_FRIEND_REQUEST=5]="SEEN_FRIEND_REQUEST",o[o.BLOCK=6]="BLOCK",o[o.UNBLOCK=7]="UNBLOCK",o[o.BLOCK_CALL=8]="BLOCK_CALL",o[o.UNBLOCK_CALL=9]="UNBLOCK_CALL",o[o.PIN_UNPIN=10]="PIN_UNPIN",o[o.PIN_CREATE=11]="PIN_CREATE",o[o.UNKNOWN=12]="UNKNOWN",exports.GroupTopicType=void 0,(s=exports.GroupTopicType||(exports.GroupTopicType={}))[s.Note=0]="Note",s[s.Message=2]="Message",s[s.Poll=3]="Poll",exports.GroupType=void 0,(c=exports.GroupType||(exports.GroupType={}))[c.Group=1]="Group",c[c.Community=2]="Community",exports.GroupEventType=void 0,(p=exports.GroupEventType||(exports.GroupEventType={})).JOIN_REQUEST="join_request",p.JOIN="join",p.LEAVE="leave",p.REMOVE_MEMBER="remove_member",p.BLOCK_MEMBER="block_member",p.UPDATE_SETTING="update_setting",p.UPDATE="update",p.NEW_LINK="new_link",p.ADD_ADMIN="add_admin",p.REMOVE_ADMIN="remove_admin",p.NEW_PIN_TOPIC="new_pin_topic",p.UPDATE_PIN_TOPIC="update_pin_topic",p.REORDER_PIN_TOPIC="reorder_pin_topic",p.UPDATE_BOARD="update_board",p.REMOVE_BOARD="remove_board",p.UPDATE_TOPIC="update_topic",p.UNPIN_TOPIC="unpin_topic",p.REMOVE_TOPIC="remove_topic",p.ACCEPT_REMIND="accept_remind",p.REJECT_REMIND="reject_remind",p.REMIND_TOPIC="remind_topic",p.UPDATE_AVATAR="update_avatar",p.UNKNOWN="unknown";class M{constructor(e,t){this.type=exports.ThreadType.User,this.data=t,this.threadId="0"==t.uidFrom?t.idTo:t.uidFrom,this.isSelf="0"==t.uidFrom,"0"==t.idTo&&(t.idTo=e),"0"==t.uidFrom&&(t.uidFrom=e),t.quote&&(t.quote.ownerId=String(t.quote.ownerId))}}class P{constructor(e,t){this.type=exports.ThreadType.Group,this.data=t,this.threadId=t.idTo,this.isSelf="0"==t.uidFrom,"0"==t.uidFrom&&(t.uidFrom=e),t.quote&&(t.quote.ownerId=String(t.quote.ownerId))}}exports.Reactions=void 0,(d=exports.Reactions||(exports.Reactions={})).HEART="/-heart",d.LIKE="/-strong",d.HAHA=":>",d.WOW=":o",d.CRY=":-((",d.ANGRY=":-h",d.KISS=":-*",d.TEARS_OF_JOY=":')",d.SHIT="/-shit",d.ROSE="/-rose",d.BROKEN_HEART="/-break",d.DISLIKE="/-weak",d.LOVE=";xx",d.CONFUSED=";-/",d.WINK=";-)",d.FADE="/-fade",d.SUN="/-li",d.BIRTHDAY="/-bd",d.BOMB="/-bome",d.OK="/-ok",d.PEACE="/-v",d.THANKS="/-thanks",d.PUNCH="/-punch",d.SHARE="/-share",d.PRAY="_()_",d.NO="/-no",d.BAD="/-bad",d.LOVE_YOU="/-loveu",d.SAD="--b",d.VERY_SAD=":((",d.COOL="x-)",d.NERD="8-)",d.BIG_SMILE=";-d",d.SUNGLASSES="b-)",d.NEUTRAL=":--|",d.SAD_FACE="p-(",d.BYE=":-bye",d.SLEEPY="|-)",d.WIPE=":wipe",d.DIG=":-dig",d.ANGUISH="&-(",d.HANDCLAP=":handclap",d.ANGRY_FACE=">-|",d.F_CHAIR=":-f",d.L_CHAIR=":-l",d.R_CHAIR=":-r",d.SILENT=";-x",d.SURPRISE=":-o",d.EMBARRASSED=";-s",d.AFRAID=";-a",d.SAD2=":-<",d.BIG_LAUGH=":))",d.RICH="$-)",d.BEER="/-beer",d.NONE="";class C{constructor(e,t,r){this.data=t,this.threadId=r||"0"==t.uidFrom?t.idTo:t.uidFrom,this.isSelf="0"==t.uidFrom,this.isGroup=r,"0"==t.idTo&&(t.idTo=e),"0"==t.uidFrom&&(t.uidFrom=e)}}exports.ReminderRepeatMode=void 0,(u=exports.ReminderRepeatMode||(exports.ReminderRepeatMode={}))[u.None=0]="None",u[u.Daily=1]="Daily",u[u.Weekly=2]="Weekly",u[u.Monthly=3]="Monthly";class F{constructor(e){this.type=exports.ThreadType.User,this.data=e,this.threadId=e.idTo,this.isSelf=!1}}class z{constructor(e,t){this.type=exports.ThreadType.Group,this.data=t,this.threadId=t.groupId,this.isSelf=t.seenUids.includes(e)}}class q{constructor(e){this.type=exports.ThreadType.User,this.data=e,this.threadId=e.uid,this.isSelf=!1}}class G{constructor(e){this.type=exports.ThreadType.Group,this.data=e,this.threadId=e.gid,this.isSelf=!1}}class B{constructor(e,t,r){this.data=t,this.threadId=r||"0"==t.uidFrom?t.idTo:t.uidFrom,this.isSelf="0"==t.uidFrom,this.isGroup=r,"0"==t.idTo&&(t.idTo=e),"0"==t.uidFrom&&(t.uidFrom=e)}}exports.BusinessCategory=void 0,(l=exports.BusinessCategory||(exports.BusinessCategory={}))[l.Other=0]="Other",l[l.RealEstate=1]="RealEstate",l[l.TechnologyAndDevices=2]="TechnologyAndDevices",l[l.TravelAndHospitality=3]="TravelAndHospitality",l[l.EducationAndTraining=4]="EducationAndTraining",l[l.ShoppingAndRetail=5]="ShoppingAndRetail",l[l.CosmeticsAndBeauty=6]="CosmeticsAndBeauty",l[l.RestaurantAndCafe=7]="RestaurantAndCafe",l[l.AutoAndMotorbike=8]="AutoAndMotorbike",l[l.FashionAndApparel=9]="FashionAndApparel",l[l.FoodAndBeverage=10]="FoodAndBeverage",l[l.MediaAndEntertainment=11]="MediaAndEntertainment",l[l.InternalCommunications=12]="InternalCommunications",l[l.Transportation=13]="Transportation",l[l.Telecommunications=14]="Telecommunications";const D={[exports.BusinessCategory.Other]:"Dịch vụ khác (Không hiển thị)",[exports.BusinessCategory.RealEstate]:"Bất động sản",[exports.BusinessCategory.TechnologyAndDevices]:"Công nghệ & Thiết bị",[exports.BusinessCategory.TravelAndHospitality]:"Du lịch & Lưu trú",[exports.BusinessCategory.EducationAndTraining]:"Giáo dục & Đào tạo",[exports.BusinessCategory.ShoppingAndRetail]:"Mua sắm & Bán lẻ",[exports.BusinessCategory.CosmeticsAndBeauty]:"Mỹ phẩm & Làm đẹp",[exports.BusinessCategory.RestaurantAndCafe]:"Nhà hàng & Quán",[exports.BusinessCategory.AutoAndMotorbike]:"Ô tô & Xe máy",[exports.BusinessCategory.FashionAndApparel]:"Thời trang & May mặc",[exports.BusinessCategory.FoodAndBeverage]:"Thực phẩm & Đồ uống",[exports.BusinessCategory.MediaAndEntertainment]:"Truyền thông & Giải trí",[exports.BusinessCategory.InternalCommunications]:"Truyền thông nội bộ",[exports.BusinessCategory.Transportation]:"Vận tải",[exports.BusinessCategory.Telecommunications]:"Viễn thông"};class J extends Map{set(e,t,r=3e5){return setTimeout(()=>{this.delete(e)},r),super.set(e,t)}}const $=(e=30,t=665)=>({API_TYPE:e,API_VERSION:t,uploadCallbacks:new J,options:{selfListen:!1,checkUpdate:!0,logging:!0,polyfill:global.fetch},secretKey:null});function j(e){return!!e.secretKey}function V(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function K(e,t){const r=[];for(const e in t)V(t,e)&&r.push(e);r.sort();let n="zsecure"+e;for(let e=0;e<r.length;e++)n+=t[r[e]];return f.MD5(n).toString()}function H(e,t,r={},n=!0){const a=new URL(t);for(const e in r)V(r,e)&&a.searchParams.append(e,r[e].toString());return n&&(a.searchParams.has("zpw_ver")||a.searchParams.set("zpw_ver",e.API_VERSION.toString()),a.searchParams.has("zpw_type")||a.searchParams.set("zpw_type",e.API_TYPE.toString())),a.toString()}class Q{constructor({type:e,imei:t,firstLaunchTime:r}){this.zcid=null,this.enc_ver="v2",this.zcid=null,this.encryptKey=null,this.createZcid(e,t,r),this.zcid_ext=Q.randomString(),this.createEncryptKey()}getEncryptKey(){if(!this.encryptKey)throw new b("getEncryptKey: didn't create encryptKey yet");return this.encryptKey}createZcid(e,t,r){if(!e||!t||!r)throw new b("createZcid: missing params");const n=`${e},${t},${r}`,a=Q.encodeAES("3FC4F0D2AB50057BCE0D90D9187A22B1",n,"hex",!0);this.zcid=a}createEncryptKey(e=0){const t=(e,t)=>{const{even:r}=Q.processStr(e),{even:n,odd:a}=Q.processStr(t);if(!r||!n||!a)return!1;const i=r.slice(0,8).join("")+n.slice(0,12).join("")+a.reverse().slice(0,12).join("");return this.encryptKey=i,!0};if(!this.zcid||!this.zcid_ext)throw new b("createEncryptKey: zcid or zcid_ext is null");try{if(t(f.MD5(this.zcid_ext).toString().toUpperCase(),this.zcid)||!(e<3))return!1;this.createEncryptKey(e+1)}catch(t){e<3&&this.createEncryptKey(e+1)}return!0}getParams(){return this.zcid?{zcid:this.zcid,zcid_ext:this.zcid_ext,enc_ver:this.enc_ver}:null}static processStr(e){if(!e||"string"!=typeof e)return{even:null,odd:null};const[t,r]=[...e].reduce((e,t,r)=>(e[r%2].push(t),e),[[],[]]);return{even:t,odd:r}}static randomString(e,t){const r=e||6,n=t&&e&&t>e?t:12;let a=Math.floor(Math.random()*(n-r+1))+r;if(a>12){let e="";for(;a>0;)e+=Math.random().toString(16).substr(2,a>12?12:a),a-=12;return e}return Math.random().toString(16).substr(2,a)}static encodeAES(e,t,r,n,a=0){if(!t)return null;try{{const a="hex"==r?f.enc.Hex:f.enc.Base64,i=f.enc.Utf8.parse(e),o={words:[0,0,0,0],sigBytes:16},s=f.AES.encrypt(t,i,{iv:o,mode:f.mode.CBC,padding:f.pad.Pkcs7}).ciphertext.toString(a);return n?s.toUpperCase():s}}catch(i){return a<3?Q.encodeAES(e,t,r,n,a+1):null}}}function W(e,t){let r=null;try{r=function(e,t){t=decodeURIComponent(t);const r=f.enc.Utf8.parse(e),n={words:[0,0,0,0],sigBytes:16};return f.AES.decrypt({ciphertext:f.enc.Base64.parse(t)},r,{iv:n,mode:f.mode.CBC,padding:f.pad.Pkcs7}).toString(f.enc.Utf8)}(e,t);return JSON.parse(r)}catch(e){return r}}function Y(e){return Buffer.from(e,"base64")}function Z(e,t,r=0){try{const r=f.enc.Base64.parse(e);return f.AES.encrypt(t,r,{iv:f.enc.Hex.parse("00000000000000000000000000000000"),mode:f.mode.CBC,padding:f.pad.Pkcs7}).ciphertext.toString(f.enc.Base64)}catch(n){return r<3?Z(e,t,r+1):null}}function X(e,t,r=0){try{t=decodeURIComponent(t);const r=f.enc.Base64.parse(e);return f.AES.decrypt({ciphertext:f.enc.Base64.parse(t)},r,{iv:f.enc.Hex.parse("00000000000000000000000000000000"),mode:f.mode.CBC,padding:f.pad.Pkcs7}).toString(f.enc.Utf8)}catch(n){return r<3?X(e,t,r+1):null}}async function ee(e,t,r,n=!1){e.cookie||(e.cookie=new m.CookieJar);const a=new URL(t).origin,i=await async function(e,t="https://chat.zalo.me"){if(!e.cookie)throw new b("Cookie is not available");if(!e.userAgent)throw new b("User agent is not available");return{Accept:"application/json, text/plain, */*","Accept-Encoding":"gzip, deflate, br, zstd","Accept-Language":"en-US,en;q=0.9","content-type":"application/x-www-form-urlencoded",Cookie:await e.cookie.getCookieString(t),Origin:"https://chat.zalo.me",Referer:"https://chat.zalo.me/","User-Agent":e.userAgent}}(e,a);n||(r?r.headers=Object.assign(i,r.headers||{}):r={headers:i});const o=Object.assign(Object.assign({},null!=r?r:{}),{agent:e.options.agent}),s=await e.options.polyfill(t,o),c=s.headers.get("set-cookie");if(c&&!n){const t=c.split(", ");for(const r of t){const t=m.Cookie.parse(r);try{t&&await e.cookie.setCookie(t,"zalo.me"!=t.domain?`https://${t.domain}`:a)}catch(t){oe(e).error(t)}}}const p=s.headers.get("location");if(p){const t=Object.assign({},r);return t.method="GET",n||(t.headers=new Headers(t.headers),t.headers.set("Referer","https://id.zalo.me/")),await ee(e,p,t)}return s}async function te(e,t){if(!e.options.imageMetadataGetter)throw new _;const r=await e.options.imageMetadataGetter(t);if(!r)throw new b("Failed to get image metadata");return{fileName:t.split("/").pop(),totalSize:r.size,width:r.width,height:r.height}}async function re(e){return y.promises.stat(e).then(e=>e.size)}async function ne(e,t){if(!e.options.imageMetadataGetter)throw new _;const r=await e.options.imageMetadataGetter(t);if(!r)throw new b("Failed to get gif metadata");return{fileName:w.basename(t),totalSize:r.size,width:r.width,height:r.height}}async function ae(e,t){if("string"!=typeof e.data)throw new b("Invalid data, expected string but got "+typeof e.data);if("number"!=typeof e.encrypt)throw new b("Invalid encrypt type, expected number but got "+typeof e.encrypt);if(e.encrypt<0||e.encrypt>3)throw new b(`Invalid encrypt type, expected 0-3 but got ${e.encrypt}`);const r=e.data,n=e.encrypt;if(0===n)return JSON.parse(r);const a=Y(1===n?r:decodeURIComponent(r));let i=a;if(1!==n){if(!(t&&a.length>=48))throw new b("Invalid data length or missing cipher key");{const e={name:"AES-GCM",iv:a.subarray(0,16),tagLength:128,additionalData:a.subarray(16,32)},r=a.subarray(32),n=await g.subtle.importKey("raw",Y(t),e,!1,["decrypt"]);i=await g.subtle.decrypt(e,n,r)}}const o=function(e){try{return(new TextDecoder).decode(e)}catch(e){return null}}(3===n?new Uint8Array(i):v.inflate(i));return o?T.parse(o):void 0}async function ie(e,t){const r="string"==typeof e?await y.promises.readFile(e):e.data;return new Promise(e=>{let n=0;const a=2097152,i=Math.ceil(t/a),o=new S.ArrayBuffer;!function s(){const c=n*a,p=c+a>=t?t:c+a;o.append(new Uint8Array(r.subarray(c,p)).buffer),n++,n<i?s():e({currentChunk:n,data:o.end()})}()})}const oe=e=>({verbose:(...t)=>{e.options.logging},info:(...t)=>{e.options.logging},warn:(...t)=>{e.options.logging},error:(...t)=>{e.options.logging},success:(...t)=>{e.options.logging},timestamp:(...t)=>{(new Date).toISOString();e.options.logging}});function se(e,t,r){const n=(e=""+e).length;return n===r?e:n>r?e.slice(-r):t.repeat(r-n)+e}function ce(e,t=Date.now()){const r=new Date(t),n=new Intl.DateTimeFormat("vi-VN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(r);return e.includes("%H")||e.includes("%d")?e.replace("%H",r.getHours().toString().padStart(2,"0")).replace("%M",r.getMinutes().toString().padStart(2,"0")).replace("%S",r.getSeconds().toString().padStart(2,"0")).replace("%d",r.getDate().toString().padStart(2,"0")).replace("%m",(r.getMonth()+1).toString().padStart(2,"0")).replace("%Y",r.getFullYear().toString()):n}function pe(e){const t=new Date(e);return se(t.getHours(),"0",2)+":"+se(t.getMinutes(),"0",2)+" "+se(t.getDate(),"0",2)+"/"+se(t.getMonth()+1,"0",2)+"/"+t.getFullYear()}function de(e){return w.extname(e).slice(1)}function ue(e){return w.basename(e)}function le(e){for(const t in e)void 0===e[t]&&delete e[t];return e}function me(e){return"join_request"==e?exports.GroupEventType.JOIN_REQUEST:"join"==e?exports.GroupEventType.JOIN:"leave"==e?exports.GroupEventType.LEAVE:"remove_member"==e?exports.GroupEventType.REMOVE_MEMBER:"block_member"==e?exports.GroupEventType.BLOCK_MEMBER:"update_setting"==e?exports.GroupEventType.UPDATE_SETTING:"update_avatar"==e?exports.GroupEventType.UPDATE_AVATAR:"update"==e?exports.GroupEventType.UPDATE:"new_link"==e?exports.GroupEventType.NEW_LINK:"add_admin"==e?exports.GroupEventType.ADD_ADMIN:"remove_admin"==e?exports.GroupEventType.REMOVE_ADMIN:"new_pin_topic"==e?exports.GroupEventType.NEW_PIN_TOPIC:"update_pin_topic"==e?exports.GroupEventType.UPDATE_PIN_TOPIC:"update_topic"==e?exports.GroupEventType.UPDATE_TOPIC:"update_board"==e?exports.GroupEventType.UPDATE_BOARD:"remove_board"==e?exports.GroupEventType.REMOVE_BOARD:"reorder_pin_topic"==e?exports.GroupEventType.REORDER_PIN_TOPIC:"unpin_topic"==e?exports.GroupEventType.UNPIN_TOPIC:"remove_topic"==e?exports.GroupEventType.REMOVE_TOPIC:"accept_remind"==e?exports.GroupEventType.ACCEPT_REMIND:"reject_remind"==e?exports.GroupEventType.REJECT_REMIND:"remind_topic"==e?exports.GroupEventType.REMIND_TOPIC:exports.GroupEventType.UNKNOWN}function he(e){return"add"==e?exports.FriendEventType.ADD:"remove"==e?exports.FriendEventType.REMOVE:"block"==e?exports.FriendEventType.BLOCK:"unblock"==e?exports.FriendEventType.UNBLOCK:"block_call"==e?exports.FriendEventType.BLOCK_CALL:"unblock_call"==e?exports.FriendEventType.UNBLOCK_CALL:"req_v2"==e?exports.FriendEventType.REQUEST:"reject"==e?exports.FriendEventType.REJECT_REQUEST:"undo_req"==e?exports.FriendEventType.UNDO_REQUEST:"seen_fr_req"==e?exports.FriendEventType.SEEN_FRIEND_REQUEST:"pin_unpin"==e?exports.FriendEventType.PIN_UNPIN:"pin_create"==e?exports.FriendEventType.PIN_CREATE:exports.FriendEventType.UNKNOWN}async function fe(e,t,r=!0){const n={data:null,error:null};if(!t.ok)return n.error={message:"Request failed with status code "+t.status},n;try{const a=await t.json();if(0!=a.error_code)return n.error={message:a.error_message,code:a.error_code},n;const i=r?JSON.parse(X(e.secretKey,a.data)):a;if(0!=i.error_code)return n.error={message:i.error_message,code:i.error_code},n;n.data=i.data}catch(t){oe(e).error("Failed to parse response data:",t),n.error={message:"Failed to parse response data"}}return n}async function ge(e,t,r,n){const a=await fe(e,t,n);if(a.error)throw new b(a.error.message,a.error.code);return r?r(a):a.data}function ye(){return e=>(t,r)=>{if(!j(t))throw new b("Invalid context "+JSON.stringify(t,null,2));const n={makeURL:(e,r,n)=>H(t,e,r,n),encodeAES:(e,r)=>Z(t.secretKey,e,r),request:(e,r,n)=>ee(t,e,r,n),logger:oe(t),resolve:(e,r,n)=>ge(t,e,r,n)};return e(r,t,n)}}var we;async function ve(e,t){await h.writeFile(e,t,"base64")}async function Se(e,t,r,n){const a=new URLSearchParams;return a.append("code",r),a.append("continue","https://chat.zalo.me/"),a.append("v",t),await ee(e,"https://id.zalo.me/account/authen/qr/waiting-scan",{headers:{accept:"*/*","accept-language":"vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5","content-type":"application/x-www-form-urlencoded",priority:"u=1, i","sec-ch-ua":'"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin",Referer:"https://id.zalo.me/account?continue=https%3A%2F%2Fchat.zalo.me%2F","Referrer-Policy":"strict-origin-when-cross-origin"},body:a,method:"POST",signal:n}).then(e=>e.json()).then(a=>8==a.error_code?Se(e,t,r,n):a).catch(t=>{n.aborted||oe(e).error(t)})}async function Te(e,t,r,n){const a=new URLSearchParams;return a.append("code",r),a.append("gToken",""),a.append("gAction","CONFIRM_QR"),a.append("continue","https://chat.zalo.me/"),a.append("v",t),oe(e).info("Please confirm on your phone"),await ee(e,"https://id.zalo.me/account/authen/qr/waiting-confirm",{headers:{accept:"*/*","accept-language":"vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5","content-type":"application/x-www-form-urlencoded",priority:"u=1, i","sec-ch-ua":'"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin",Referer:"https://id.zalo.me/account?continue=https%3A%2F%2Fchat.zalo.me%2F","Referrer-Policy":"strict-origin-when-cross-origin"},body:a,method:"POST",signal:n}).then(e=>e.json()).then(a=>8==a.error_code?Te(e,t,r,n):a).catch(t=>{n.aborted||oe(e).error(t)})}async function Re(e,t,r){return e.cookie=new m.CookieJar,e.userAgent=t.userAgent,new Promise(async(n,a)=>{var i;const o=new AbortController;let s=null;function c(){o.abort(),s&&(clearTimeout(s),s=null)}try{function p(){return c(),n(Re(e,t,r))}function d(){return c(),a(new x)}e.options.logging;const u=await async function(e){const t=await ee(e,"https://id.zalo.me/account?continue=https%3A%2F%2Fchat.zalo.me%2F",{headers:{accept:"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7","accept-language":"vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5","cache-control":"max-age=0",priority:"u=0, i","sec-ch-ua":'"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"document","sec-fetch-mode":"navigate","sec-fetch-site":"same-site","sec-fetch-user":"?1","upgrade-insecure-requests":"1",Referer:"https://chat.zalo.me/","Referrer-Policy":"strict-origin-when-cross-origin"},method:"GET"}),r=(await t.text()).match(/https:\/\/stc-zlogin\.zdn\.vn\/main-([\d.]+)\.js/);return null==r?void 0:r[1]}(e);if(!u)throw new b("Cannot get API login version");oe(e).info("Got login version:",u),await async function(e,t){const r=new URLSearchParams;return r.append("continue","https://zalo.me/pc"),r.append("v",t),await ee(e,"https://id.zalo.me/account/logininfo",{headers:{accept:"*/*","accept-language":"vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5","content-type":"application/x-www-form-urlencoded",priority:"u=1, i","sec-ch-ua":'"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin",Referer:"https://id.zalo.me/account?continue=https%3A%2F%2Fzalo.me%2Fpc","Referrer-Policy":"strict-origin-when-cross-origin"},body:r,method:"POST"}).then(e=>e.json()).catch(oe(e).error)}(e,u),await async function(e,t){const r=new URLSearchParams;return r.append("type","device"),r.append("continue","https://zalo.me/pc"),r.append("v",t),await ee(e,"https://id.zalo.me/account/verify-client",{headers:{accept:"*/*","accept-language":"vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5","content-type":"application/x-www-form-urlencoded",priority:"u=1, i","sec-ch-ua":'"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin",Referer:"https://id.zalo.me/account?continue=https%3A%2F%2Fzalo.me%2Fpc","Referrer-Policy":"strict-origin-when-cross-origin"},body:r,method:"POST"}).then(e=>e.json()).catch(oe(e).error)}(e,u);const l=await async function(e,t){const r=new URLSearchParams;return r.append("continue","https://zalo.me/pc"),r.append("v",t),await ee(e,"https://id.zalo.me/account/authen/qr/generate",{headers:{accept:"*/*","accept-language":"vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5","content-type":"application/x-www-form-urlencoded",priority:"u=1, i","sec-ch-ua":'"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin",Referer:"https://id.zalo.me/account?continue=https%3A%2F%2Fzalo.me%2Fpc","Referrer-Policy":"strict-origin-when-cross-origin"},body:r,method:"POST"}).then(e=>e.json()).catch(oe(e).error)}(e,u);if(!l||!l.data)throw new b(`Unable to generate QRCode\nResponse: ${JSON.stringify(l,null,2)}`);const m=l.data;if(r)r({type:exports.LoginQRCallbackEventType.QRCodeGenerated,data:Object.assign(Object.assign({},l.data),{image:l.data.image.replace(/^data:image\/png;base64,/,"")}),actions:{async saveToFile(r){var n;void 0===r&&(r=null!==(n=t.qrPath)&&void 0!==n?n:"qr.png"),await ve(r,m.image.replace(/^data:image\/png;base64,/,"")),oe(e).info("Scan the QR code at",`'${r}'`,"to proceed with login")},retry:p,abort:d}});else{const w=null!==(i=t.qrPath)&&void 0!==i?i:"qr.png";await ve(w,m.image.replace(/^data:image\/png;base64,/,"")),oe(e).info("Scan the QR code at",`'${w}'`,"to proceed with login")}s=setTimeout(()=>{c(),oe(e).info("QR expired!"),r?r({type:exports.LoginQRCallbackEventType.QRCodeExpired,data:null,actions:{retry:p,abort:d}}):p()},1e5);const h=await Se(e,u,l.data.code,o.signal);if(!h||!h.data)throw new b("Cannot get scan result");r&&r({type:exports.LoginQRCallbackEventType.QRCodeScanned,data:h.data,actions:{retry:p,abort:d}});const f=await Te(e,u,l.data.code,o.signal);if(!f)throw new b("Cannot get confirm result");if(clearTimeout(s),-13==f.error_code){if(!r)throw oe(e).error("QRCode login declined"),new O;return void r({type:exports.LoginQRCallbackEventType.QRCodeDeclined,data:{code:m.code},actions:{retry:p,abort:d}})}if(0!=f.error_code)throw new b(`An error has occurred.\nResponse: ${JSON.stringify(f,null,2)}`);const g=await async function(e){return await ee(e,"https://id.zalo.me/account/checksession?continue=https%3A%2F%2Fchat.zalo.me%2Findex.html",{headers:{accept:"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7","accept-language":"vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5",priority:"u=0, i","sec-ch-ua":'"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"document","sec-fetch-mode":"navigate","sec-fetch-site":"same-origin","upgrade-insecure-requests":"1",Referer:"https://id.zalo.me/account?continue=https%3A%2F%2Fchat.zalo.me%2F","Referrer-Policy":"strict-origin-when-cross-origin"},redirect:"manual",method:"GET"}).catch(oe(e).error)}(e);if(!g)throw new b("Cannot get session, login failed");oe(e).info("Successfully logged into the account",h.data.display_name);const y=await async function(e){return await ee(e,"https://jr.chat.zalo.me/jr/userinfo",{headers:{accept:"*/*","accept-language":"vi-VN,vi;q=0.9,fr-FR;q=0.8,fr;q=0.7,en-US;q=0.6,en;q=0.5",priority:"u=1, i","sec-ch-ua":'"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-site",Referer:"https://chat.zalo.me/","Referrer-Policy":"strict-origin-when-cross-origin"},method:"GET"}).then(e=>e.json()).catch(oe(e).error)}(e);if(!y||!y.data)throw new b("Can't get account info");if(!y.data.logged)throw new b("Can't login");n({cookies:e.cookie.toJSON().cookies,userInfo:y.data.info})}catch(v){c(),a(v)}})}exports.LoginQRCallbackEventType=void 0,(we=exports.LoginQRCallbackEventType||(exports.LoginQRCallbackEventType={}))[we.QRCodeGenerated=0]="QRCodeGenerated",we[we.QRCodeExpired=1]="QRCodeExpired",we[we.QRCodeScanned=2]="QRCodeScanned",we[we.QRCodeDeclined=3]="QRCodeDeclined",we[we.GotLoginInfo=4]="GotLoginInfo";var ke,Ue,Ee,be,_e,xe,Oe,Ae,Le,Ie,Ne,Me,Pe,Ce,Fe,ze,qe,Ge,Be,De,Je,$e,je,Ve,Ke,He,Qe,We,Ye,Ze,Xe,et,tt,rt,nt,at,it,ot,st,ct,pt,dt,ut,lt,mt,ht,ft,gt,yt,wt,vt,St,Tt,Rt,kt,Ut,Et,bt,_t,xt,Ot,At,Lt,It,Nt,Mt,Pt,Ct,Ft,zt,qt,Gt,Bt,Dt,Jt,$t,jt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Vt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Kt(){if(Ue)return ke;Ue=1;var e="object"==typeof jt&&jt&&jt.Object===Object&&jt;return ke=e}function Ht(){if(be)return Ee;be=1;var e=Kt(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Ee=r}function Qt(){if(xe)return _e;xe=1;var e=Ht().Symbol;return _e=e}function Wt(){if(Me)return Ne;Me=1;var e=Qt(),t=function(){if(Ae)return Oe;Ae=1;var e=Qt(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,a=e?e.toStringTag:void 0;return Oe=function(e){var t=r.call(e,a),i=e[a];try{e[a]=void 0;var o=!0}catch(e){}var s=n.call(e);return o&&(t?e[a]=i:delete e[a]),s}}(),r=function(){if(Ie)return Le;Ie=1;var e=Object.prototype.toString;return Le=function(t){return e.call(t)}}(),n=e?e.toStringTag:void 0;return Ne=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?t(e):r(e)}}function Yt(){if(Ce)return Pe;return Ce=1,Pe=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function Zt(){if(ze)return Fe;ze=1;var e=Wt(),t=Yt();return Fe=function(r){if(!t(r))return!1;var n=e(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function Xt(){if(De)return Be;De=1;var e,t=function(){if(Ge)return qe;Ge=1;var e=Ht()["__core-js_shared__"];return qe=e}(),r=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return Be=function(e){return!!r&&r in e}}function er(){if($e)return Je;$e=1;var e=Function.prototype.toString;return Je=function(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}function tr(){if(We)return Qe;We=1;var e=function(){if(Ve)return je;Ve=1;var e=Zt(),t=Xt(),r=Yt(),n=er(),a=/^\[object .+?Constructor\]$/,i=Function.prototype,o=Object.prototype,s=i.toString,c=o.hasOwnProperty,p=RegExp("^"+s.call(c).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return je=function(i){return!(!r(i)||t(i))&&(e(i)?p:a).test(n(i))}}(),t=He?Ke:(He=1,Ke=function(e,t){return null==e?void 0:e[t]});return Qe=function(r,n){var a=t(r,n);return e(a)?a:void 0}}function rr(){if(Ze)return Ye;Ze=1;var e=tr(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return Ye=t}function nr(){if(et)return Xe;et=1;var e=rr();return Xe=function(t,r,n){"__proto__"==r&&e?e(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n}}function ar(){if(rt)return tt;return rt=1,tt=function(e,t){return e===t||e!=e&&t!=t}}function ir(){if(at)return nt;at=1;var e=nr(),t=ar(),r=Object.prototype.hasOwnProperty;return nt=function(n,a,i){var o=n[a];r.call(n,a)&&t(o,i)&&(void 0!==i||a in n)||e(n,a,i)}}function or(){if(ct)return st;return ct=1,st=function(e){return e}}function sr(){if(lt)return ut;lt=1;var e=dt?pt:(dt=1,pt=function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}),t=Math.max;return ut=function(r,n,a){return n=t(void 0===n?r.length-1:n,0),function(){for(var i=arguments,o=-1,s=t(i.length-n,0),c=Array(s);++o<s;)c[o]=i[n+o];o=-1;for(var p=Array(n+1);++o<n;)p[o]=i[o];return p[n]=a(c),e(r,this,p)}},ut}function cr(){if(gt)return ft;gt=1;var e=ht?mt:(ht=1,mt=function(e){return function(){return e}}),t=rr(),r=or();return ft=t?function(r,n){return t(r,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:r}function pr(){if(St)return vt;St=1;var e=cr(),t=function(){if(wt)return yt;wt=1;var e=Date.now;return yt=function(t){var r=0,n=0;return function(){var a=e(),i=16-(a-n);if(n=a,i>0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}},yt}(),r=t(e);return vt=r}function dr(){if(Ut)return kt;Ut=1;return kt=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function ur(){if(bt)return Et;bt=1;var e=Zt(),t=dr();return Et=function(r){return null!=r&&t(r.length)&&!e(r)}}function lr(){if(xt)return _t;xt=1;var e=/^(?:0|[1-9]\d*)$/;return _t=function(t,r){var n=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&e.test(t))&&t>-1&&t%1==0&&t<r}}function mr(){if(It)return Lt;It=1;var e=function(){if(Rt)return Tt;Rt=1;var e=or(),t=sr(),r=pr();return Tt=function(n,a){return r(t(n,a,e),n+"")}}(),t=function(){if(At)return Ot;At=1;var e=ar(),t=ur(),r=lr(),n=Yt();return Ot=function(a,i,o){if(!n(o))return!1;var s=typeof i;return!!("number"==s?t(o)&&r(i,o.length):"string"==s&&i in o)&&e(o[i],a)}}();return Lt=function(r){return e(function(e,n){var a=-1,i=n.length,o=i>1?n[i-1]:void 0,s=i>2?n[2]:void 0;for(o=r.length>3&&"function"==typeof o?(i--,o):void 0,s&&t(n[0],n[1],s)&&(o=i<3?void 0:o,i=1),e=Object(e);++a<i;){var c=n[a];c&&r(e,c,a,o)}return e})}}function hr(){if(Mt)return Nt;Mt=1;var e=Object.prototype;return Nt=function(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||e)}}function fr(){if(zt)return Ft;return zt=1,Ft=function(e){return null!=e&&"object"==typeof e}}function gr(){if(Dt)return Bt;Dt=1;var e=function(){if(Gt)return qt;Gt=1;var e=Wt(),t=fr();return qt=function(r){return t(r)&&"[object Arguments]"==e(r)}}(),t=fr(),r=Object.prototype,n=r.hasOwnProperty,a=r.propertyIsEnumerable,i=e(function(){return arguments}())?e:function(e){return t(e)&&n.call(e,"callee")&&!a.call(e,"callee")};return Bt=i}function yr(){if($t)return Jt;$t=1;var e=Array.isArray;return Jt=e}var wr,vr,Sr,Tr,Rr,kr,Ur,Er={exports:{}};function br(){return Sr||(Sr=1,function(e,t){var r=Ht(),n=vr?wr:(vr=1,wr=function(){return!1}),a=t&&!t.nodeType&&t,i=a&&e&&!e.nodeType&&e,o=i&&i.exports===a?r.Buffer:void 0,s=(o?o.isBuffer:void 0)||n;e.exports=s}(Er,Er.exports)),Er.exports}var _r,xr,Or,Ar,Lr,Ir,Nr,Mr,Pr,Cr,Fr,zr,qr,Gr,Br,Dr={exports:{}};function Jr(){if(Or)return xr;Or=1;var e=function(){if(Rr)return Tr;Rr=1;var e=Wt(),t=dr(),r=fr(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,Tr=function(a){return r(a)&&t(a.length)&&!!n[e(a)]}}(),t=Ur?kr:(Ur=1,kr=function(e){return function(t){return e(t)}}),r=(_r||(_r=1,function(e,t){var r=Kt(),n=t&&!t.nodeType&&t,a=n&&e&&!e.nodeType&&e,i=a&&a.exports===n&&r.process,o=function(){try{return a&&a.require&&a.require("util").types||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=o}(Dr,Dr.exports)),Dr.exports),n=r&&r.isTypedArray,a=n?t(n):e;return xr=a}function $r(){if(Lr)return Ar;Lr=1;var e=Ct?Pt:(Ct=1,Pt=function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}),t=gr(),r=yr(),n=br(),a=lr(),i=Jr(),o=Object.prototype.hasOwnProperty;return Ar=function(s,c){var p=r(s),d=!p&&t(s),u=!p&&!d&&n(s),l=!p&&!d&&!u&&i(s),m=p||d||u||l,h=m?e(s.length,String):[],f=h.length;for(var g in s)!c&&!o.call(s,g)||m&&("length"==g||u&&("offset"==g||"parent"==g)||l&&("buffer"==g||"byteLength"==g||"byteOffset"==g)||a(g,f))||h.push(g);return h}}function jr(){if(Pr)return Mr;Pr=1;var e=(Nr?Ir:(Nr=1,Ir=function(e,t){return function(r){return e(t(r))}}))(Object.keys,Object);return Mr=e}function Vr(){if(Fr)return Cr;Fr=1;var e=hr(),t=jr(),r=Object.prototype.hasOwnProperty;return Cr=function(n){if(!e(n))return t(n);var a=[];for(var i in Object(n))r.call(n,i)&&"constructor"!=i&&a.push(i);return a}}var Kr=function(){if(Br)return Gr;Br=1;var e=ir(),t=function(){if(ot)return it;ot=1;var e=ir(),t=nr();return it=function(r,n,a,i){var o=!a;a||(a={});for(var s=-1,c=n.length;++s<c;){var p=n[s],d=i?i(a[p],r[p],p,a,r):void 0;void 0===d&&(d=r[p]),o?t(a,p,d):e(a,p,d)}return a}}(),r=mr(),n=ur(),a=hr(),i=function(){if(qr)return zr;qr=1;var e=$r(),t=Vr(),r=ur();return zr=function(n){return r(n)?e(n):t(n)}}(),o=Object.prototype.hasOwnProperty,s=r(function(r,s){if(a(s)||n(s))t(s,i(s),r);else for(var c in s)o.call(s,c)&&e(r,c,s[c])});return Gr=s}(),Hr=Vt(Kr);async function Qr(e,t,r){const n={},a={computer_name:"Web",imei:e.imei,language:e.language,ts:Date.now()},i=await async function(e,t,r){if(r){const r=new Q({type:e.API_TYPE,imei:t.imei,firstLaunchTime:Date.now()});try{const e=JSON.stringify(t),n=r.getEncryptKey(),a=Q.encodeAES(n,e,"base64",!1),i=r.getParams();return i?{encrypted_data:a,encrypted_params:i,enk:n}:null}catch(e){throw new b("Failed to encrypt params: "+e)}}return null}(e,a,t);if(null==i)Hr(n,a);else{const{encrypted_params:e,encrypted_data:t}=i;Hr(n,e),n.params=t}return n.type=e.API_TYPE,n.client_version=e.API_VERSION,n.signkey=K(r,"getserverinfo"==r?{imei:e.imei,type:e.API_TYPE,client_version:e.API_VERSION,computer_name:"Web"}:n),{params:n,enk:i?i.enk:null}}var Wr;exports.CloseReason=void 0,(Wr=exports.CloseReason||(exports.CloseReason={}))[Wr.ManualClosure=1e3]="ManualClosure",Wr[Wr.AbnormalClosure=1006]="AbnormalClosure",Wr[Wr.DuplicateConnection=3e3]="DuplicateConnection",Wr[Wr.KickConnection=3003]="KickConnection";class Yr extends k{constructor(e,t){if(super(),this.ctx=e,this.urls=t,this.id=0,!e.cookie)throw new b("Cookie is not available");if(!e.userAgent)throw new b("User agent is not available");this.wsURL=H(this.ctx,this.urls[0],{t:Date.now()}),this.retryCount={},this.rotateCount=0;for(const t in e.settings.features.socket.retries){const{times:r,max:n}=e.settings.features.socket.retries[t];this.retryCount[t]={count:0,max:n||0,times:"number"==typeof r?[r]:r}}this.cookie=e.cookie.getCookieStringSync("https://chat.zalo.me"),this.userAgent=e.userAgent,this.selfListen=e.options.selfListen,this.ws=null,this.onConnectedCallback=()=>{},this.onClosedCallback=()=>{},this.onErrorCallback=()=>{},this.onMessageCallback=()=>{}}onConnected(e){this.onConnectedCallback=e}onClosed(e){this.onClosedCallback=e}onError(e){this.onErrorCallback=e}onMessage(e){this.onMessageCallback=e}canRetry(e){if(!this.ctx.settings.features.socket.close_and_retry_codes.includes(e))return!1;if(this.retryCount[e.toString()].count>=this.retryCount[e.toString()].max)return!1;this.retryCount[e.toString()].count++;const{count:t,max:r,times:n}=this.retryCount[e.toString()],a=t-1<n.length?n[t-1]:n[n.length-1];return oe(this.ctx).verbose(`Retry for code ${e} in ${a}ms (${t}/${r})`),a}shouldRotate(e){return!!this.ctx.settings.features.socket.rotate_error_codes.includes(e)&&!(this.rotateCount>=this.urls.length-1)}rotateEndpoint(){this.rotateCount++,this.wsURL=H(this.ctx,this.urls[this.rotateCount],{t:Date.now()}),oe(this.ctx).verbose(`Rotating endpoint to ${this.wsURL}`)}start({retryOnClose:e=!1}={}){if(this.ws)throw new b("Already started");const t=new U(this.wsURL,{headers:{"accept-encoding":"gzip, deflate, br, zstd","accept-language":"en-US,en;q=0.9","cache-control":"no-cache",connection:"Upgrade",host:new URL(this.wsURL).host,origin:"https://chat.zalo.me",prgama:"no-cache","sec-websocket-extensions":"permessage-deflate; client_max_window_bits","sec-websocket-version":"13",upgrade:"websocket","user-agent":this.userAgent,cookie:this.cookie},agent:this.ctx.options.agent});this.ws=t,t.onopen=()=>{this.onConnectedCallback(),this.emit("connected")},t.onclose=t=>{this.reset(),this.emit("disconnected",t.code,t.reason);const r=e&&this.canRetry(t.code);if(r&&e){this.shouldRotate(t.code)&&this.rotateEndpoint(),setTimeout(()=>{this.start({retryOnClose:!0})},r)}else this.onClosedCallback(t.code,t.reason),this.emit("closed",t.code,t.reason)},t.onerror=e=>{this.onErrorCallback(e),this.emit("error",e)},t.onmessage=async e=>{const{data:r}=e;if(!(r instanceof Buffer))return;const n=r.subarray(0,4),[a,i,o]=function(e){if(e.byteLength<4)throw new b("Invalid header");return[e[0],e.readUInt16LE(1),e[3]]}(n);try{const e=r.subarray(4),n=new TextDecoder("utf-8").decode(e);if(0==n.length)return;const s=JSON.parse(n);if(1==a&&1==i&&1==o&&V(s,"key")){this.cipherKey=s.key,this.emit("cipher_key",s.key),this.pingInterval&&clearInterval(this.pingInterval);const e=()=>{const e={version:1,cmd:2,subCmd:1,data:{eventId:Date.now()}};this.sendWs(e,!1)};this.pingInterval=setInterval(()=>{e()},this.ctx.settings.features.socket.ping_interval)}if(1==a&&501==i&&0==o){const e=(await ae(s,this.cipherKey)).data,{msgs:t}=e;for(const e of t)if("object"==typeof e.content&&V(e.content,"deleteMsg")){const t=new B(this.ctx.uid,e,!1);if(t.isSelf&&!this.selfListen)continue;this.emit("undo",t)}else{const t=new M(this.ctx.uid,e);if(t.isSelf&&!this.selfListen)continue;this.onMessageCallback(t),this.emit("message",t)}}if(1==a&&521==i&&0==o){const e=(await ae(s,this.cipherKey)).data,{groupMsgs:t}=e;for(const e of t)if("object"==typeof e.content&&V(e.content,"deleteMsg")){const t=new B(this.ctx.uid,e,!0);if(t.isSelf&&!this.selfListen)continue;this.emit("undo",t)}else{const t=new P(this.ctx.uid,e);if(t.isSelf&&!this.selfListen)continue;this.onMessageCallback(t),this.emit("message",t)}}if(1==a&&601==i&&0==o){const e=(await ae(s,this.cipherKey)).data,{controls:t}=e;for(const e of t)if("file_done"==e.content.act_type){const t={fileUrl:e.content.data.url,fileId:e.content.fileId},r=this.ctx.uploadCallbacks.get(String(e.content.fileId));r&&r(t),this.ctx.uploadCallbacks.delete(String(e.content.fileId)),this.emit("upload_attachment",t)}else if("group"==e.content.act_type){if("join_reject"==e.content.act)continue;const t="string"==typeof e.content.data?JSON.parse(e.content.data):e.content.data,r=N(this.ctx.uid,t,me(e.content.act),e.content.act);if(r.isSelf&&!this.selfListen)continue;this.emit("group_event",r)}else if("fr"==e.content.act_type){if("req"==e.content.act)continue;const t="string"==typeof e.content.data?JSON.parse(e.content.data):e.content.data;"object"==typeof t&&"topic"in t&&"object"==typeof t.topic&&"params"in t.topic&&(t.topic.params=JSON.parse(`${t.topic.params}`));const r=I(this.ctx.uid,"number"==typeof t?e.content.data:t,he(e.content.act));if(r.isSelf&&!this.selfListen)continue;this.emit("friend_event",r)}}if(612==i){const e=(await ae(s,this.cipherKey)).data,{reacts:t,reactGroups:r}=e;for(const e of t){e.content=JSON.parse(e.content);const t=new C(this.ctx.uid,e,!1);t.isSelf&&!this.selfListen||this.emit("reaction",t)}for(const e of r){e.content=JSON.parse(e.content);const t=new C(this.ctx.uid,e,!0);t.isSelf&&!this.selfListen||this.emit("reaction",t)}}if(610==i||611==i){const e=(await ae(s,this.cipherKey)).data,t=611==i,r=e[t?"reactGroups":"reacts"].map(e=>new C(this.ctx.uid,e,t));this.emit("old_reactions",r,t)}if(510==i&&1==o){const e=(await ae(s,this.cipherKey)).data,t=e.msgs.map(e=>new M(this.ctx.uid,e));this.emit("old_messages",t,exports.ThreadType.User)}if(511==i&&1==o){const e=(await ae(s,this.cipherKey)).data,t=e.groupMsgs.map(e=>new P(this.ctx.uid,e));this.emit("old_messages",t,exports.ThreadType.Group)}if(602==i&&0==o){const e=(await ae(s,this.cipherKey)).data,{actions:t}=e;for(const e of t){const t=JSON.parse(`{${e.data}}`);if("typing"==e.act_type)if("typing"==e.act){const e=new q(t);this.emit("typing",e)}else if("gtyping"==e.act){const e=new G(t);this.emit("typing",e)}}}if(502==i&&0==o){const e=(await ae(s,this.cipherKey)).data,{delivereds:t,seens:r}=e;if(Array.isArray(t)&&t.length>0){const e=t.map(e=>new A(e));this.emit("delivered_messages",e)}if(Array.isArray(r)&&r.length>0){const e=r.map(e=>new F(e));this.emit("seen_messages",e)}}if(522==i&&0==o){const e=(await ae(s,this.cipherKey)).data,{delivereds:t,groupSeens:r}=e;if(Array.isArray(t)&&t.length>0){let e=t.map(e=>new L(this.ctx.uid,e));this.selfListen||(e=e.filter(e=>!e.isSelf)),this.emit("delivered_messages",e)}if(Array.isArray(r)&&r.length>0){let e=r.map(e=>new z(this.ctx.uid,e));this.selfListen||(e=e.filter(e=>!e.isSelf)),this.emit("seen_messages",e)}}1==a&&3e3==i&&0==o&&(oe(this.ctx).error(),oe(this.ctx).error("Another connection is opened, closing this one"),oe(this.ctx).error(),t.readyState!==U.CLOSED&&t.close(exports.CloseReason.DuplicateConnection))}catch(e){this.onErrorCallback(e),this.emit("error",e)}}}stop(){this.ws&&(this.ws.close(exports.CloseReason.ManualClosure),this.reset())}sendWs(e,t=!0){if(this.ws){t&&(e.data.req_id="req_"+this.id++);const r=(new TextEncoder).encode(JSON.stringify(e.data)),n=r.length,a=new DataView(Buffer.alloc(4+n).buffer);a.setUint8(0,e.version),a.setInt32(1,e.cmd,!0),a.setInt8(3,e.subCmd),r.forEach((e,t)=>{a.setUint8(4+t,e)}),this.ws.send(a)}}requestOldMessages(e,t=null){const r={version:1,cmd:e===exports.ThreadType.User?510:511,subCmd:1,data:{first:!0,lastId:t,preIds:[]}};this.sendWs(r)}requestOldReactions(e,t=null){const r={version:1,cmd:e===exports.ThreadType.User?610:611,subCmd:1,data:{first:!0,lastId:t,preIds:[]}};this.sendWs(r)}reset(){this.ws=null,this.cipherKey=void 0,this.pingInterval&&clearInterval(this.pingInterval)}}const Zr=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend[0]}/api/friend/accept`);return async function(e){const a={fid:e,language:t.language},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(n,{method:"POST",body:new URLSearchParams({params:i})});return r.resolve(o)}});var Xr,en;var tn=function(){if(en)return Xr;en=1;var e=yr();return Xr=function(){if(!arguments.length)return[];var t=arguments[0];return e(t)?t:[t]},Xr}(),rn=Vt(tn);const nn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/blockedmems/add`);return async function(e,t){const a={grid:t,members:rn(e)},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}}),an=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/admins/add`);return async function(e,a){const i={grid:a,members:rn(e),imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(r.makeURL(n,{params:o}),{method:"GET"});return r.resolve(s)}}),on=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/poll/option/add`);return async function(e){const t={poll_id:e.pollId,new_options:JSON.stringify(e.options),voted_option_ids:e.votedOptionIds},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i)}}),sn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.quick_message[0]}/api/quickmessage/create`);return async function(a){const i=a.media?1:0,o={keyword:a.keyword,message:{title:a.title,params:""},type:i,imei:t.imei};if(1===i){if(!a.media)throw new b("Media is required");const t=await e.uploadProductPhoto({file:a.media}),r=t.photoId,n=t.thumbUrl,i=t.normalUrl,s=t.hdUrl;o.media={items:[{type:0,photoId:r,title:"",width:"",height:"",previewThumb:n,rawUrl:i||s,thumbUrl:n,normalUrl:i||s,hdUrl:s||i}]}}const s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(r.makeURL(n,{params:s}),{method:"GET"});return r.resolve(c)}}),cn=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.reaction[0]}/api/message/reaction`),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.reaction[0]}/api/group/reaction`)};return async function(e,a){const i=n[a.type];let o,s;if("object"==typeof e)o=e.rType,s=e.source;else switch(e){case exports.Reactions.HAHA:o=0,s=6;break;case exports.Reactions.LIKE:o=3,s=6;break;case exports.Reactions.HEART:o=5,s=6;break;case exports.Reactions.WOW:o=32,s=6;break;case exports.Reactions.CRY:o=2,s=6;break;case exports.Reactions.ANGRY:o=20,s=6;break;case exports.Reactions.KISS:o=8,s=6;break;case exports.Reactions.TEARS_OF_JOY:o=7,s=6;break;case exports.Reactions.SHIT:o=66,s=6;break;case exports.Reactions.ROSE:o=120,s=6;break;case exports.Reactions.BROKEN_HEART:o=65,s=6;break;case exports.Reactions.DISLIKE:o=4,s=6;break;case exports.Reactions.LOVE:o=29,s=6;break;case exports.Reactions.CONFUSED:o=51,s=6;break;case exports.Reactions.WINK:o=45,s=6;break;case exports.Reactions.FADE:o=121,s=6;break;case exports.Reactions.SUN:o=67,s=6;break;case exports.Reactions.BIRTHDAY:o=126,s=6;break;case exports.Reactions.BOMB:o=127,s=6;break;case exports.Reactions.OK:o=68,s=6;break;case exports.Reactions.PEACE:o=69,s=6;break;case exports.Reactions.THANKS:o=70,s=6;break;case exports.Reactions.PUNCH:o=71,s=6;break;case exports.Reactions.SHARE:o=72,s=6;break;case exports.Reactions.PRAY:o=73,s=6;break;case exports.Reactions.NO:o=131,s=6;break;case exports.Reactions.BAD:o=132,s=6;break;case exports.Reactions.LOVE_YOU:o=133,s=6;break;case exports.Reactions.SAD:o=1,s=6;break;case exports.Reactions.VERY_SAD:o=16,s=6;break;case exports.Reactions.COOL:o=21,s=6;break;case exports.Reactions.NERD:o=22,s=6;break;case exports.Reactions.BIG_SMILE:o=23,s=6;break;case exports.Reactions.SUNGLASSES:o=26,s=6;break;case exports.Reactions.NEUTRAL:o=30,s=6;break;case exports.Reactions.SAD_FACE:o=35,s=6;break;case exports.Reactions.BYE:o=36,s=6;break;case exports.Reactions.SLEEPY:o=38,s=6;break;case exports.Reactions.WIPE:o=39,s=6;break;case exports.Reactions.DIG:o=42,s=6;break;case exports.Reactions.ANGUISH:o=44,s=6;break;case exports.Reactions.HANDCLAP:o=46,s=6;break;case exports.Reactions.ANGRY_FACE:o=47,s=6;break;case exports.Reactions.F_CHAIR:o=48,s=6;break;case exports.Reactions.L_CHAIR:o=49,s=6;break;case exports.Reactions.R_CHAIR:o=50,s=6;break;case exports.Reactions.SILENT:o=52,s=6;break;case exports.Reactions.SURPRISE:o=53,s=6;break;case exports.Reactions.EMBARRASSED:o=54,s=6;break;case exports.Reactions.AFRAID:o=60,s=6;break;case exports.Reactions.SAD2:o=61,s=6;break;case exports.Reactions.BIG_LAUGH:o=62,s=6;break;case exports.Reactions.RICH:o=63,s=6;break;case exports.Reactions.BEER:o=99,s=6;break;default:o=-1,s=6}const c="object"==typeof e?e.icon:e;if(null==o||null==s||null==c)throw new b("Invalid reaction");const p={react_list:[{message:JSON.stringify({rMsg:[{gMsgID:parseInt(a.data.msgId),cMsgID:parseInt(a.data.cliMsgId),msgType:1}],rIcon:c,rType:o,source:s}),clientId:Date.now()}]};a.type==exports.ThreadType.User?p.toid=a.threadId:(p.grid=a.threadId,p.imei=t.imei);const d=r.encodeAES(JSON.stringify(p));if(!d)throw new b("Failed to encrypt message");const u=await r.request(i,{method:"POST",body:new URLSearchParams({params:d})});return r.resolve(u,e=>"string"==typeof e.data.msgIds?{msgIds:JSON.parse(e.data.msgIds)}:e.data)}}),pn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.conversation[0]}/api/conv/addUnreadMark`);return async function(e,a=exports.ThreadType.User){const i=Date.now(),o=i.toString(),s=a===exports.ThreadType.Group,c={param:JSON.stringify({[s?"convsGroup":"convsUser"]:[{id:e,cliMsgId:o,fromUid:"0",ts:i}],[s?"convsUser":"convsGroup"]:[],imei:t.imei})},p=r.encodeAES(JSON.stringify(c));if(!p)throw new b("Failed to encrypt params");const d=await r.request(n,{method:"POST",body:new URLSearchParams({params:p})});return r.resolve(d,e=>{const t=e.data;return"string"==typeof t.data?{data:JSON.parse(t.data),status:t.status}:e.data})}}),dn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/invite/v2`);return async function(e,a){const i=rn(e),o={grid:a,members:i,memberTypes:i.map(()=>-1),imei:t.imei,clientLang:t.language},s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(n,{method:"POST",body:new URLSearchParams({params:s})});return r.resolve(c)}}),un=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend[0]}/api/friend/block`);return async function(e){const a={fid:e,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(n,{method:"POST",body:new URLSearchParams({params:i})});return r.resolve(o)}}),ln=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend[0]}/api/friend/feed/block`);return async function(e,a){const i={fid:a,isBlockFeed:e?1:0,imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(n,{method:"POST",body:new URLSearchParams({params:o})});return r.resolve(s)}}),mn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.file[0]}/api/profile/upavatar`);return async function(e){const a="string"==typeof e,i=a?await te(t,e):e.metadata,o=i.totalSize||0,s={avatarSize:120,clientId:String(t.uid+ce("%H:%M %d/%m/%Y")),language:t.language,metaData:JSON.stringify({origin:{width:i.width||1080,height:i.height||1080},processed:{width:i.width||1080,height:i.height||1080,size:o}})},c=a?y.readFileSync(e):e.data,p=new E;p.append("fileContent",c,{filename:"blob",contentType:"image/jpeg"});const d=r.encodeAES(JSON.stringify(s));if(!d)throw new b("Failed to encrypt params");const u=await r.request(r.makeURL(n,{params:d}),{method:"POST",headers:p.getHeaders(),body:p.getBuffer()});return r.resolve(u)}}),hn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.alias[0]}/api/alias/update`);return async function(e,a){const i={friendId:a,alias:e,imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(r.makeURL(n,{params:o}),{method:"GET"});return r.resolve(s)}}),fn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.file[0]}/api/group/upavatar`);return async function(e,a){const i={grid:a,avatarSize:120,clientId:`g${a}${pe((new Date).getTime())}`,imei:t.imei},o="string"==typeof e,s=o?await te(t,e):e.metadata;i.originWidth=s.width||1080,i.originHeight=s.height||1080;const c=o?y.readFileSync(e):e.data,p=new E;p.append("fileContent",c,{filename:"blob",contentType:"image/jpeg"});const d=r.encodeAES(JSON.stringify(i));if(!d)throw new b("Failed to encrypt params");const u=await r.request(r.makeURL(n,{params:d}),{method:"POST",headers:p.getHeaders(),body:p.getBuffer()});return r.resolve(u)}}),gn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/updateinfo`);return async function(e,a){0==e.length&&(e=Date.now().toString());const i={grid:a,gname:e,imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(n,{method:"POST",body:new URLSearchParams({params:o})});return r.resolve(s)}}),yn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/change-owner`);return async function(e,a){const i={grid:a,newAdminId:e,imei:t.imei,language:t.language},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(r.makeURL(n,{params:o}),{method:"GET"});return r.resolve(s)}}),wn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.auto_reply[0]}/api/autoreply/create`);return async function(e){const a=rn(e.uids||[]),i=2===e.scope||3===e.scope?a:[],o={cliLang:t.language,enable:e.isEnable,content:e.content,startTime:e.startTime,endTime:e.endTime,recurrence:["RRULE:FREQ=DAILY;"],scope:e.scope,uids:i},s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(n,{method:"POST",body:new URLSearchParams({params:s})});return r.resolve(c)}}),vn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.catalog[0]}/api/prodcatalog/catalog/create`);return async function(e){const t={catalog_name:e,catalog_photo:""},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt params");const i=await r.request(n,{method:"POST",body:new URLSearchParams({params:a})});return r.resolve(i)}}),Sn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/create/v2`);return async function(a){if(0==a.members.length)throw new b("Group must have at least one member");const i={clientId:Date.now(),gname:String(Date.now()),gdesc:null,members:a.members,membersTypes:a.members.map(()=>-1),nameChanged:0,createLink:1,clientLang:t.language,imei:t.imei,zsource:601};a.name&&a.name.length>0&&(i.gname=a.name,i.nameChanged=1);const o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt message");const s=await r.request(r.makeURL(n,{params:o}),{method:"POST"}),c=await r.resolve(s);return a.avatarSource=a.avatarSource||a.avatarPath,a.avatarSource&&await e.changeGroupAvatar(a.avatarSource,c.groupId).catch(r.logger.error),c}}),Tn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group_board[0]}/api/board/topic/createv2`);return async function(e,a){const i={grid:a,type:0,color:-16777216,emoji:"",startTime:-1,duration:-1,params:JSON.stringify({title:e.title}),repeat:0,src:1,imei:t.imei,pinAct:e.pinAct?1:0},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(n,{method:"POST",body:new URLSearchParams({params:o})});return r.resolve(s,e=>("string"==typeof e.data.params&&(e.data.params=JSON.parse(e.data.params)),e.data))}}),Rn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/poll/create`);return async function(e,a){var i;const o={group_id:a,question:e.question,options:e.options,expired_time:null!==(i=e.expiredTime)&&void 0!==i?i:0,pinAct:!1,allow_multi_choices:!!e.allowMultiChoices,allow_add_new_option:!!e.allowAddNewOption,is_hide_vote_preview:!!e.hideVotePreview,is_anonymous:!!e.isAnonymous,poll_type:0,src:1,imei:t.imei},s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(n,{method:"POST",body:new URLSearchParams({params:s})});return r.resolve(c)}}),kn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.catalog[0]}/api/prodcatalog/product/create`);return async function(t){const a=t.product_photos||[];if(t.files&&0==t.files.length){if(t.files.length>5)throw new b("Maximum 5 media files are allowed");for(const r of t.files){const t=await e.uploadProductPhoto({file:r}),n=t.normalUrl||t.hdUrl;a.push(n)}}if(a.length>5)throw new b("Maximum 5 media files are allowed");const i={product_name:t.productName,price:t.price,description:t.description,product_photos:a,catalog_id:t.catalogId,currency_unit:"₫",create_time:Date.now()},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(n,{method:"POST",body:new URLSearchParams({params:o})});return r.resolve(s)}}),Un=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.group_board[0]}/api/board/oneone/create`),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.group_board[0]}/api/board/topic/createv2`)};return async function(e,a,i=exports.ThreadType.User){var o,s,c,p,d,u;const l=i===exports.ThreadType.User?{objectData:JSON.stringify({toUid:a,type:0,color:-16245706,emoji:null!==(o=e.emoji)&&void 0!==o?o:"⏰",startTime:null!==(s=e.startTime)&&void 0!==s?s:Date.now(),duration:-1,params:{title:e.title},needPin:!1,repeat:null!==(c=e.repeat)&&void 0!==c?c:exports.ReminderRepeatMode.None,creatorUid:t.uid,src:1}),imei:t.imei}:{grid:a,type:0,color:-16245706,emoji:null!==(p=e.emoji)&&void 0!==p?p:"⏰",startTime:null!==(d=e.startTime)&&void 0!==d?d:Date.now(),duration:-1,params:JSON.stringify({title:e.title}),repeat:null!==(u=e.repeat)&&void 0!==u?u:exports.ReminderRepeatMode.None,src:1,imei:t.imei,pinAct:0},m=r.encodeAES(JSON.stringify(l));if(!m)throw new b("Failed to encrypt params");const h=await r.request(n[i],{method:"POST",body:new URLSearchParams({params:m})});return r.resolve(h)}}),En=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.auto_reply[0]}/api/autoreply/delete`);return async function(e){const a={cliLang:t.language,id:e},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(n,{method:"POST",body:new URLSearchParams({params:i})});return r.resolve(o)}}),bn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/del-avatars`);return async function(e){const a=rn(e).map(e=>({photoId:e})),i={delPhotos:JSON.stringify(a),imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(r.makeURL(n,{params:o}),{method:"GET"});return r.resolve(s)}}),_n=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.catalog[0]}/api/prodcatalog/catalog/delete`);return async function(e){const t={catalog_id:e},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt params");const i=await r.request(n,{method:"POST",body:new URLSearchParams({params:a})});return r.resolve(i)}}),xn=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.chat[0]}/api/message/deleteconver`,{nretry:0}),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/deleteconver`,{nretry:0})};return async function(e,a,i=exports.ThreadType.User){const o=Date.now().toString(),s=i===exports.ThreadType.User?{toid:a,cliMsgId:o,conver:e,onlyMe:1,imei:t.imei}:{grid:a,cliMsgId:o,conver:e,onlyMe:1,imei:t.imei},c=r.encodeAES(JSON.stringify(s));if(!c)throw new b("Failed to encrypt params");const p=await r.request(n[i],{method:"POST",body:new URLSearchParams({params:c})});return r.resolve(p)}}),On=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/inv-box/mdel-inv`);return async function(e,t=!1){const a=rn(e),i={invitations:JSON.stringify(a.map(e=>({grid:e}))),block:t?1:0},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(r.makeURL(n,{params:o}),{method:"GET"});return r.resolve(s)}}),An=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.chat[0]}/api/message/delete`),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/deletemsg`)};return async function(e,a=!1){const{threadId:i,type:o=exports.ThreadType.User,data:s}=e,c=o===exports.ThreadType.Group;if(t.uid==s.uidFrom&&!1===a)throw new b("To delete your message for everyone, use undo api instead");if(!c&&!1===a)throw new b("Can't delete message for everyone in a private chat");const p={[c?"grid":"toid"]:i,cliMsgId:Date.now(),msgs:[{cliMsgId:s.cliMsgId,globalMsgId:s.msgId,ownerId:s.uidFrom,destId:i}],onlyMe:a?1:0};c||(p.imei=t.imei);const d=r.encodeAES(JSON.stringify(p));if(!d)throw new b("Failed to encrypt message");const u=await r.request(n[o],{method:"POST",body:new URLSearchParams({params:d})});return r.resolve(u)}}),Ln=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.catalog[0]}/api/prodcatalog/product/mdelete`);return async function(e){const t={product_ids:rn(e.productIds),catalog_id:e.catalogId},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt params");const i=await r.request(n,{method:"POST",body:new URLSearchParams({params:a})});return r.resolve(i)}}),In=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/link/disable`);return async function(e){const t={grid:e},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i)}}),Nn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/disperse`);return async function(e){const a={grid:e,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(n,{method:"POST",body:new URLSearchParams({params:i})});return r.resolve(o)}}),Mn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group_board[0]}/api/board/topic/updatev2`);return async function(e,a){const i={grid:a,type:0,color:-16777216,emoji:"",startTime:-1,duration:-1,params:JSON.stringify({title:e.title}),topicId:e.topicId,repeat:0,imei:t.imei,pinAct:e.pinAct?1:2},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(n,{method:"POST",body:new URLSearchParams({params:o})});return r.resolve(s,e=>{const t=e.data;return"string"==typeof t.params&&(t.params=JSON.parse(t.params)),t})}}),Pn=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.group_board[0]}/api/board/oneone/update`),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.group_board[0]}/api/board/topic/updatev2`)};return async function(e,a,i=exports.ThreadType.User){var o,s,c,p,d,u;const l=i===exports.ThreadType.User?{objectData:JSON.stringify({toUid:a,type:0,color:-16777216,emoji:null!==(o=e.emoji)&&void 0!==o?o:"",startTime:null!==(s=e.startTime)&&void 0!==s?s:Date.now(),duration:-1,params:{title:e.title},needPin:!1,reminderId:e.topicId,repeat:null!==(c=e.repeat)&&void 0!==c?c:0})}:{grid:a,type:0,color:-16777216,emoji:null!==(p=e.emoji)&&void 0!==p?p:"",startTime:null!==(d=e.startTime)&&void 0!==d?d:Date.now(),duration:-1,params:JSON.stringify({title:e.title}),topicId:e.topicId,repeat:null!==(u=e.repeat)&&void 0!==u?u:0,imei:t.imei,pinAct:2},m=r.encodeAES(JSON.stringify(l));if(!m)throw new b("Failed to encrypt params");const h=await r.request(n[i],{method:"POST",body:new URLSearchParams({params:m})});return r.resolve(h)}}),Cn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/link/new`);return async function(e){const a={grid:e,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}}),Fn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/profile/me-v2`);return async function(){const e=await r.request(n,{method:"GET"});return r.resolve(e)}}),zn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend[0]}/api/friend/profile/get`);return async function(e){if(!e)throw new b("Missing phoneNumber");e.startsWith("0")&&"vi"==t.language&&(e="84"+e.slice(1));const a={phone:e,avatar_size:240,language:t.language,imei:t.imei,reqSrc:40},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt message");const o=new URL(n);o.searchParams.append("params",i);const s=await r.request(r.makeURL(o.toString(),{params:i}));return r.resolve(s,e=>{if(e.error&&216!=e.error.code)throw new b(e.error.message,e.error.code);return e.data})}}),qn=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.file[0]}/api/message/mforward`),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.file[0]}/api/group/mforward`)};return async function(e,a,i=exports.ThreadType.User){var o,s;if(!e.message)throw new b("Missing message content");if(!a||0===a.length)throw new b("Missing thread IDs");const c=Date.now().toString(),p={message:e.message,reference:e.reference?JSON.stringify({type:3,data:JSON.stringify(e.reference)}):void 0},d=e.reference?{fw:{pmsg:{st:1,ts:e.reference.ts,id:e.reference.id},rmsg:{st:1,ts:e.reference.ts,id:e.reference.id},fwLvl:e.reference.fwLvl}}:null;let u;u=i===exports.ThreadType.User?{toIds:a.map(t=>{var r;return{clientId:c,toUid:t,ttl:null!==(r=e.ttl)&&void 0!==r?r:0}}),imei:t.imei,ttl:null!==(o=e.ttl)&&void 0!==o?o:0,msgType:"1",totalIds:a.length,msgInfo:JSON.stringify(p),decorLog:JSON.stringify(d)}:{grids:a.map(t=>{var r;return{clientId:c,grid:t,ttl:null!==(r=e.ttl)&&void 0!==r?r:0}}),ttl:null!==(s=e.ttl)&&void 0!==s?s:0,msgType:"1",totalIds:a.length,msgInfo:JSON.stringify(p),decorLog:JSON.stringify(d)};const l=r.encodeAES(JSON.stringify(u));if(!l)throw new b("Failed to encrypt params");const m=await r.request(n[i],{method:"POST",body:new URLSearchParams({params:l})});return r.resolve(m)}}),Gn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.alias[0]}/api/alias/list`);return async function(e=100,a=1){const i={page:a,count:e,imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(r.makeURL(n,{params:o}),{method:"GET"});return r.resolve(s)}}),Bn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/friend/getfriends`);return async function(e=2e4,a=1){const i={incInvalid:1,page:a,count:e,avatar_size:120,actiontime:0,imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt message");const s=await r.request(r.makeURL(n,{params:o}),{method:"GET"});return r.resolve(s)}}),Dn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group_poll[0]}/api/group/getlg/v4`);return async function(){const e=await r.request(n,{method:"GET"});return r.resolve(e)}}),Jn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.label[0]}/api/archivedchat/list`);return async function(){const e={version:1,imei:t.imei},a=r.encodeAES(JSON.stringify(e));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i)}}),$n=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.conversation[0]}/api/conv/autodelete/getConvers`);return async function(){const e=r.encodeAES(JSON.stringify({}));if(!e)throw new b("Failed to encrypt params");const t=await r.request(r.makeURL(n,{params:e}),{method:"GET"});return r.resolve(t)}}),jn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.auto_reply[0]}/api/autoreply/list`);return async function(){const e={version:0,cliLang:t.language},a=r.encodeAES(JSON.stringify(e));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i)}}),Vn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/avatar-list`);return async function(e=50,a=1){const i={page:a,albumId:"0",count:e,imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(r.makeURL(n,{params:o}),{method:"GET"});return r.resolve(s)}}),Kn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/friend/get-bizacc`);return async function(e){const t={fid:e},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt params");const i=await r.request(n,{method:"POST",body:new URLSearchParams({params:a})});return r.resolve(i)}}),Hn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.catalog[0]}/api/prodcatalog/catalog/list`);return async function(e){var t,a,i;const o={version_list_catalog:0,limit:null!==(t=null==e?void 0:e.limit)&&void 0!==t?t:20,last_product_id:null!==(a=null==e?void 0:e.lastProductId)&&void 0!==a?a:-1,page:null!==(i=null==e?void 0:e.page)&&void 0!==i?i:0},s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(n,{method:"POST",body:new URLSearchParams({params:s})});return r.resolve(c)}}),Qn=ye()((e,t)=>()=>t),Wn=ye()((e,t)=>function(){return t.cookie}),Yn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend_board[0]}/api/friendboard/list`);return async function(e){const a={conversationId:e,version:0,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}});var Zn=Vt(yr());const Xn=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/friend/onlines`);return async function(){const e={imei:t.imei},a=r.encodeAES(JSON.stringify(e));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i,e=>{const t=e.data;if(Zn(t.onlines))for(const e of t.onlines)if("string"==typeof e.status){const t=JSON.parse(e.status);t&&"string"==typeof t.status&&(e.status=t.status)}return t})}}),ea=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend[0]}/api/friend/recommendsv2/list`);return async function(){const e={imei:t.imei},a=r.encodeAES(JSON.stringify(e));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i)}}),ta=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend[0]}/api/friend/reqstatus`);return async function(e){const a={fid:e,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}}),ra=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/blockedmems/list`);return async function(e,a){var i,o;const s={grid:a,page:null!==(i=e.page)&&void 0!==i?i:1,count:null!==(o=e.count)&&void 0!==o?o:50,imei:t.imei},c=r.encodeAES(JSON.stringify(s));if(!c)throw new b("Failed to encrypt params");const p=await r.request(r.makeURL(n,{params:c}),{method:"GET"});return r.resolve(p)}}),na=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/getmg-v2`);return async function(e){const t=rn(e),a={gridVerMap:JSON.stringify(t.reduce((e,t)=>(e[t]=0,e),{}))},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt message");const o=await r.request(n,{method:"POST",body:new URLSearchParams({params:i})});return r.resolve(o)}}),aa=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/inv-box/inv-info`);return async function(e){var t,a;const i={grId:e.groupId,mcount:null!==(t=e.mcount)&&void 0!==t?t:10,mpage:null!==(a=e.mpage)&&void 0!==a?a:1},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(r.makeURL(n,{params:o}),{method:"GET"});return r.resolve(s,e=>{const t=e.data,r=t.groupInfo.topic;if("string"==typeof r.params){const e=JSON.parse(r.params);"string"==typeof e.extra&&(e.extra=JSON.parse(e.extra)),r.params=e}return t})}}),ia=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/inv-box/list`);return async function(e){var t,a,i,o;const s={mpage:null!==(t=null==e?void 0:e.mpage)&&void 0!==t?t:1,page:null!==(a=null==e?void 0:e.page)&&void 0!==a?a:0,invPerPage:null!==(i=null==e?void 0:e.invPerPage)&&void 0!==i?i:12,mcount:null!==(o=null==e?void 0:e.mcount)&&void 0!==o?o:10,lastGroupId:null,avatar_size:120,member_avatar_size:120},c=r.encodeAES(JSON.stringify(s));if(!c)throw new b("Failed to encrypt params");const p=await r.request(r.makeURL(n,{params:c}),{method:"GET"});return r.resolve(p)}}),oa=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/link/detail`);return async function(e){const a={grid:e,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}}),sa=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/link/ginfo`);return async function(e){var t;const a={link:e.link,avatar_size:120,member_avatar_size:120,mpage:null!==(t=e.memberPage)&&void 0!==t?t:1},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}}),ca=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/group/members`);return async function(e){const t={friend_pversion_map:rn(e).map(e=>e.endsWith("_0")?e:`${e}_0`)},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt message");const i=await r.request(r.makeURL(n,{params:a}));return r.resolve(i)}}),pa=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.conversation[0]}/api/hiddenconvers/get-all`);return async function(){const e={imei:t.imei},a=r.encodeAES(JSON.stringify(e));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i)}}),da=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.label[0]}/api/convlabel/get`);return async function(){const e={imei:t.imei},a=r.encodeAES(JSON.stringify(e));if(!a)throw new b("Failed to encrypt message");const i=await r.request(r.makeURL(n,{params:a}));return r.resolve(i,e=>{const t=e.data;return{labelData:JSON.parse(t.labelData),version:t.version,lastUpdateTime:t.lastUpdateTime}})}}),ua=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group_board[0]}/api/board/list`);return async function(e,a){var i,o;const s={group_id:a,board_type:0,page:null!==(i=e.page)&&void 0!==i?i:1,count:null!==(o=e.count)&&void 0!==o?o:20,last_id:0,last_type:0,imei:t.imei},c=r.encodeAES(JSON.stringify(s));if(!c)throw new b("Failed to encrypt params");const p=await r.request(r.makeURL(n,{params:c}),{method:"GET"});return r.resolve(p,e=>{const t=e.data;return t.items.forEach(e=>{if(e.boardType!=exports.BoardType.Poll){const t=e.data;"string"==typeof t.params&&(t.params=JSON.parse(t.params))}}),t})}}),la=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.group_board[0]}/api/board/oneone/list`),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.group_board[0]}/api/board/listReminder`)};return async function(e,a,i=exports.ThreadType.User){var o,s,c,p;const d=Object.assign({objectData:JSON.stringify(i===exports.ThreadType.User?{uid:a,board_type:1,page:null!==(o=e.page)&&void 0!==o?o:1,count:null!==(s=e.count)&&void 0!==s?s:20,last_id:0,last_type:0}:{group_id:a,board_type:1,page:null!==(c=e.page)&&void 0!==c?c:1,count:null!==(p=e.count)&&void 0!==p?p:20,last_id:0,last_type:0})},i===exports.ThreadType.Group&&{imei:t.imei}),u=r.encodeAES(JSON.stringify(d));if(!u)throw new b("Failed to encrypt params");const l=await r.request(r.makeURL(n[i],{params:u}),{method:"GET"});return r.resolve(l,e=>JSON.parse(e.data))}}),ma=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/profile/getmute`);return async function(){const e={imei:t.imei},a=r.encodeAES(JSON.stringify(e));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i)}}),ha=ye()((e,t)=>()=>t.uid),fa=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/pending-mems/list`);return async function(e){const a={grid:e,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}}),ga=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.conversation[0]}/api/pinconvers/list`);return async function(){const e={imei:t.imei},a=r.encodeAES(JSON.stringify(e));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i)}}),ya=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/poll/detail`);return async function(e){if(!e)throw new b("Missing poll id");const a={poll_id:e,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt message");const o=await r.request(n,{method:"POST",body:new URLSearchParams({params:i})});return r.resolve(o)}}),wa=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.catalog[0]}/api/prodcatalog/product/list`);return async function(e){var t,a,i,o;const s={catalog_id:e.catalogId,limit:null!==(t=e.limit)&&void 0!==t?t:100,version_catalog:null!==(a=e.versionCatalog)&&void 0!==a?a:0,last_product_id:null!==(i=e.lastProductId)&&void 0!==i?i:-1,page:null!==(o=e.page)&&void 0!==o?o:0},c=r.encodeAES(JSON.stringify(s));if(!c)throw new b("Failed to encrypt params");const p=await r.request(n,{method:"POST",body:new URLSearchParams({params:c})});return r.resolve(p)}}),va=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend[0]}/api/friend/mget-qr`);return async function(e){"string"==typeof e&&(e=[e]);const t={fids:e},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt params");const i=await r.request(n,{method:"POST",body:new URLSearchParams({params:a})});return r.resolve(i)}}),Sa=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.quick_message[0]}/api/quickmessage/list`);return async function(){const e={version:0,lang:0,imei:t.imei},a=r.encodeAES(JSON.stringify(e));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i)}}),Ta=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend[0]}/api/friend/group/related`);return async function(e){const a=rn(e),i={friend_ids:JSON.stringify(a),imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(n,{method:"POST",body:new URLSearchParams({params:o})});return r.resolve(s)}}),Ra=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group_board[0]}/api/board/topic/getReminder`);return async function(e){const a={eventId:e,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}}),ka=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group_board[0]}/api/board/topic/listResponseEvent`);return async function(e){const t={eventId:e},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i)}}),Ua=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend[0]}/api/friend/requested/list`);return async function(){const e={imei:t.imei},a=r.encodeAES(JSON.stringify(e));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i)}}),Ea=ye()((e,t,r)=>{const n=r.makeURL("https://wpa.chat.zalo.me/api/setting/me");return async function(){const e=r.encodeAES(JSON.stringify({}));if(!e)throw new b("Failed to encrypt params");const t=await r.request(r.makeURL(n,{params:e}),{method:"GET"});return r.resolve(t)}}),ba=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.sticker}/api/message/sticker`);return async function(e){if(!e)throw new b("Missing keyword");const a={keyword:e,gif:1,guggy:0,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt message");const o=new URL(n);o.pathname=o.pathname+"/suggest/stickers";const s=await r.request(r.makeURL(o.toString(),{params:i}));return r.resolve(s,e=>{const t=e.data,r=[];return t.sugg_sticker&&t.sugg_sticker.forEach(e=>r.push(e.sticker_id)),r})}}),_a=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.sticker}/api/message/sticker/sticker_detail`);return async function(e){if(!e)throw new b("Missing sticker id");const a=rn(e);if(0==a.length)throw new b("Missing sticker id");const i=[],o=a.map(e=>async function(e){const a={sid:e},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt message");const o=await r.request(r.makeURL(n,{params:i}));return ge(t,o)}(e));return(await Promise.allSettled(o)).forEach(e=>{"fulfilled"===e.status&&i.push(e.value)}),i}}),xa=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.conversation[0]}/api/conv/getUnreadMark`);return async function(){const e=r.encodeAES(JSON.stringify({}));if(!e)throw new b("Failed to encrypt params");const t=await r.request(r.makeURL(n,{params:e}),{method:"GET"});return r.resolve(t,e=>{const t=e.data;return"string"==typeof t.data?{data:JSON.parse(t.data),status:t.status}:t})}}),Oa=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/friend/getprofiles/v2`);return async function(e){if(!e)throw new b("Missing user id");const a=rn(e).map(e=>e.split("_").length>1?e:`${e}_0`),i={phonebook_version:t.extraVer.phonebook,friend_pversion_map:a,avatar_size:120,language:t.language,show_online_status:1,imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(n,{method:"POST",body:new URLSearchParams({params:o})});return r.resolve(s)}}),Aa=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/invite/multi`);return async function(e,a){const i={grids:rn(a),member:e,memberType:-1,srcInteraction:2,clientLang:t.language},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(r.makeURL(n,{params:o}),{method:"GET"});return r.resolve(s)}}),La=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/inv-box/join`);return async function(e){const a={grid:e,lang:t.language},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}}),Ia=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/link/join`);return async function(e){const a={link:e,clientLang:t.language},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}}),Na=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.chat[0]}/keepalive`);return async function(){const e={imei:t.imei},a=r.encodeAES(JSON.stringify(e));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i,void 0,!1)}}),Ma=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/profile/lastOnline`);return async function(e){const a={uid:e,conv_type:1,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}}),Pa=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/leave`);return async function(e,a=!1){const i={grids:[e],imei:t.imei,silent:a?1:0,language:t.language},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(n,{method:"POST",body:new URLSearchParams({params:o})});return r.resolve(s)}}),Ca=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/poll/end`);return async function(e){const a={poll_id:e,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(n,{method:"POST",body:new URLSearchParams({params:i})});return r.resolve(o)}}),Fa=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.file[0]}/api/message/parselink`);return async function(e){const a={link:e,version:1,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}}),za=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend[0]}/api/friend/reject`);return async function(e){const t={fid:e},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt params");const i=await r.request(n,{method:"POST",body:new URLSearchParams({params:a})});return r.resolve(i)}}),qa=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend[0]}/api/friend/remove`);return async function(e){const a={fid:e,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(n,{method:"POST",body:new URLSearchParams({params:i})});return r.resolve(o)}}),Ga=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.alias[0]}/api/alias/remove`);return async function(e){const t={friendId:e},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i)}}),Ba=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/blockedmems/remove`);return async function(e,t){const a={grid:t,members:rn(e)},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}}),Da=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/admins/remove`);return async function(e,a){const i={grid:a,members:rn(e),imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(r.makeURL(n,{params:o}),{method:"GET"});return r.resolve(s)}}),Ja=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.quick_message[0]}/api/quickmessage/delete`);return async function(e){const t={itemIds:rn(e)},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i)}}),$a=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.group_board[0]}/api/board/oneone/remove`),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.group_board[0]}/api/board/topic/remove`)};return async function(e,a,i=exports.ThreadType.User){const o=i===exports.ThreadType.User?{uid:a,reminderId:e}:{grid:a,topicId:e,imei:t.imei},s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(n[i],{method:"POST",body:new URLSearchParams({params:s})});return r.resolve(c)}}),ja=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.conversation[0]}/api/conv/removeUnreadMark`);return async function(e,t=exports.ThreadType.User){const a=Date.now(),i=t===exports.ThreadType.Group,o={param:JSON.stringify({[i?"convsGroup":"convsUser"]:[e],[i?"convsUser":"convsGroup"]:[],[i?"convsGroupData":"convsUserData"]:[{id:e,ts:a}],[i?"convsUserData":"convsGroupData"]:[]})},s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(n,{method:"POST",body:new URLSearchParams({params:s})});return r.resolve(c,e=>{const t=e.data;return"string"==typeof t.data?{data:JSON.parse(t.data),status:t.status}:e.data})}}),Va=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/kickout`);return async function(e,a){const i={grid:a,members:rn(e),imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(n,{method:"POST",body:new URLSearchParams({params:o})});return r.resolve(s)}}),Ka=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.conversation[0]}/api/hiddenconvers/reset`);return async function(){const e=r.encodeAES(JSON.stringify({}));if(!e)throw new b("Failed to encrypt params");const t=await r.request(r.makeURL(n,{params:e}),{method:"GET"});return r.resolve(t)}}),Ha=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/reuse-avatar`);return async function(e){const a={photoId:e,isPostSocial:0,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}});var Qa;exports.ReviewPendingMemberRequestStatus=void 0,(Qa=exports.ReviewPendingMemberRequestStatus||(exports.ReviewPendingMemberRequestStatus={}))[Qa.SUCCESS=0]="SUCCESS",Qa[Qa.NOT_IN_PENDING_LIST=170]="NOT_IN_PENDING_LIST",Qa[Qa.ALREADY_IN_GROUP=178]="ALREADY_IN_GROUP",Qa[Qa.INSUFFICIENT_PERMISSION=166]="INSUFFICIENT_PERMISSION";const Wa=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/pending-mems/review`);return async function(e,t){const a={grid:t,members:rn(e.members),isApprove:e.isApprove?1:0},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}}),Ya=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.zimsg[0]}/api/transfer/card`);return async function(e,t,a=exports.ThreadType.User){var i;const o={binBank:e.binBank,numAccBank:e.numAccBank,nameAccBank:(null===(i=e.nameAccBank)||void 0===i?void 0:i.toUpperCase())||"---",cliMsgId:Date.now().toString(),tsMsg:Date.now(),destUid:t,destType:a===exports.ThreadType.Group?1:0},s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(n,{method:"POST",body:new URLSearchParams({params:s})});return r.resolve(c)}}),Za=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.file[0]}/api/message/forward`),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.file[0]}/api/group/forward`)};return async function(a,i,o=exports.ThreadType.User){var s;const c=(await e.getQR(a.userId))[a.userId],p=Date.now().toString(),d={ttl:null!==(s=a.ttl)&&void 0!==s?s:0,msgType:6,clientId:p,msgInfo:{contactUid:a.userId,qrCodeUrl:c}};a.phoneNumber&&(d.msgInfo.phone=a.phoneNumber),o==exports.ThreadType.Group?(d.visibility=0,d.grid=i):(d.toId=i,d.imei=t.imei);const u=JSON.stringify(d.msgInfo);d.msgInfo=u;const l=r.encodeAES(JSON.stringify(d));if(!l)throw new b("Failed to encrypt params");const m=await r.request(n[o],{method:"POST",body:new URLSearchParams({params:l})});return r.resolve(m)}}),Xa=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.chat[0]}/api/message/deliveredv2`),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/deliveredv2`)};return async function(e,a,i=exports.ThreadType.User){if(!a)throw new b("messages are missing or not in a valid array format.");const o=rn(a);if(0===o.length||o.length>50)throw new b("messages must contain between 1 and 50 messages.");const s=o[0].idTo;if(i===exports.ThreadType.Group&&!o.every(e=>e.idTo===s))throw new b("All messages must have the same idTo for Group thread");const c=Object.assign({seen:e?1:0,data:o.map(e=>({cmi:e.cliMsgId,gmi:e.msgId,si:e.uidFrom,di:e.idTo===t.uid?"0":e.idTo,mt:e.msgType,st:e.st||0===e.st?0:-1,at:e.at||0===e.at?0:-1,cmd:e.cmd||0===e.cmd?0:-1,ts:parseInt(`${e.ts}`)||0===parseInt(`${e.ts}`)?0:-1}))},i===exports.ThreadType.User?{}:{grid:s}),p=Object.assign({msgInfos:JSON.stringify(c)},i===exports.ThreadType.User?{}:{imei:t.imei}),d=r.encodeAES(JSON.stringify(p));if(!d)throw new b("Failed to encrypt params");const u=await r.request(n[i],{method:"POST",body:new URLSearchParams({params:d})});return r.resolve(u)}}),ei=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend[0]}/api/friend/sendreq`);return async function(e,a){const i={toid:a,msg:e,reqsrc:30,imei:t.imei,language:t.language,srcParams:JSON.stringify({uidTo:a})},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(n,{method:"POST",body:new URLSearchParams({params:o})});return r.resolve(s)}}),ti=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.chat[0]}/api/message/link`,{nretry:0}),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/sendlink`,{nretry:0})};return async function(a,i,o=exports.ThreadType.User){var s;const c=await e.parseLink(a.link),p={msg:a.msg&&a.msg.trim()?a.msg.includes(a.link)?a.msg:a.msg+" "+a.link:a.link,href:c.data.href,src:c.data.src,title:c.data.title,desc:c.data.desc,thumb:c.data.thumb,type:2,media:JSON.stringify(c.data.media),ttl:null!==(s=a.ttl)&&void 0!==s?s:0,clientId:Date.now()};o==exports.ThreadType.Group?(p.grid=i,p.imei=t.imei):(p.toId=i,p.mentionInfo="");const d=r.encodeAES(JSON.stringify(p));if(!d)throw new b("Failed to encrypt params");const u=await r.request(n[o],{method:"POST",body:new URLSearchParams({params:d})});return r.resolve(u)}});var ri,ni,ai,ii,oi,si,ci,pi,di,ui,li,mi,hi,fi;function gi(){if(mi)return li;mi=1;var e=function(){if(ni)return ri;ni=1;var e=tr()(Ht(),"DataView");return ri=e}(),t=function(){if(ii)return ai;ii=1;var e=tr()(Ht(),"Map");return ai=e}(),r=function(){if(si)return oi;si=1;var e=tr()(Ht(),"Promise");return oi=e}(),n=function(){if(pi)return ci;pi=1;var e=tr()(Ht(),"Set");return ci=e}(),a=function(){if(ui)return di;ui=1;var e=tr()(Ht(),"WeakMap");return di=e}(),i=Wt(),o=er(),s="[object Map]",c="[object Promise]",p="[object Set]",d="[object WeakMap]",u="[object DataView]",l=o(e),m=o(t),h=o(r),f=o(n),g=o(a),y=i;return(e&&y(new e(new ArrayBuffer(1)))!=u||t&&y(new t)!=s||r&&y(r.resolve())!=c||n&&y(new n)!=p||a&&y(new a)!=d)&&(y=function(e){var t=i(e),r="[object Object]"==t?e.constructor:void 0,n=r?o(r):"";if(n)switch(n){case l:return u;case m:return s;case h:return c;case f:return p;case g:return d}return t}),li=y}var yi=function(){if(fi)return hi;fi=1;var e=Vr(),t=gi(),r=gr(),n=yr(),a=ur(),i=br(),o=hr(),s=Jr(),c=Object.prototype.hasOwnProperty;return hi=function(p){if(null==p)return!0;if(a(p)&&(n(p)||"string"==typeof p||"function"==typeof p.splice||i(p)||s(p)||r(p)))return!p.length;var d=t(p);if("[object Map]"==d||"[object Set]"==d)return!p.size;if(o(p))return!e(p).length;for(var u in p)if(c.call(p,u))return!1;return!0}}(),wi=Vt(yi);const vi={image:"photo_original/send?",gif:"gif?",video:"asyncfile/msg?",others:"asyncfile/msg?"};function Si(e){const t=e;return"string"==typeof t.content?t.propertyExt:"chat.todo"==t.msgType?{properties:{color:0,size:0,type:0,subType:0,ext:'{"shouldParseLinkOrContact":0}'}}:Object.assign(Object.assign({},t.content),{thumbUrl:t.content.thumb,oriUrl:t.content.href,normalUrl:t.content.href})}function Ti(e){const t=e;return"chat.todo"==t.msgType&&"object"==typeof t.content&&"string"==typeof t.content.params?JSON.parse(t.content.params).item.content:""}var Ri,ki;exports.TextStyle=void 0,(Ri=exports.TextStyle||(exports.TextStyle={})).Bold="b",Ri.Italic="i",Ri.Underline="u",Ri.StrikeThrough="s",Ri.Red="c_db342e",Ri.Orange="c_f27806",Ri.Yellow="c_f7b503",Ri.Green="c_15a85f",Ri.Small="f_13",Ri.Big="f_18",Ri.UnorderedList="lst_1",Ri.OrderedList="lst_2",Ri.Indent="ind_$",exports.Urgency=void 0,(ki=exports.Urgency||(exports.Urgency={}))[ki.Default=0]="Default",ki[ki.Important=1]="Important",ki[ki.Urgent=2]="Urgent";const Ui=ye()((e,t,r)=>{const n={message:{[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.chat[0]}/api/message`,{nretry:0}),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.group[0]}/api/group`,{nretry:0})},attachment:{[exports.ThreadType.User]:`${e.zpwServiceMap.file[0]}/api/message/`,[exports.ThreadType.Group]:`${e.zpwServiceMap.file[0]}/api/group/`}},{sharefile:a}=t.settings.features;function i(e){return e>1024*a.max_size_share_file_v3*1024}async function o(e){const n=rn(e),a=[];for(const e of n)a.push((async()=>{const n=await r.request(e.url,{method:"POST",body:e.body,headers:e.headers});return await ge(t,n)})());return await Promise.all(a)}async function s(e,n){const a=new E,i="string"==typeof e?await h.readFile(e):e.data;a.append("fileContent",i,{filename:"blob",contentType:"image/png"});const o={clientId:Date.now(),imei:t.imei},s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt message");const c=await r.request(r.makeURL(n+"upthumb?",{params:s}),{method:"POST",headers:a.getHeaders(),body:a.getBuffer()});return await ge(t,c)}function c(e,t,r){let n=0;const a=wi(r)||e!=exports.ThreadType.Group?[]:rn(r).filter(e=>e.pos>=0&&e.uid&&e.len>0).map(e=>(n+=e.len,{pos:e.pos,uid:e.uid,len:e.len,type:"-1"==e.uid?1:0}));if(n>t.length)throw new b("Invalid mentions: total mention characters exceed message length");return{mentionsFinal:a,msgFinal:t}}function p(e,t){t!=exports.Urgency.Important&&t!=exports.Urgency.Urgent||Hr(e,{metaData:{urgency:t}})}async function d({msg:e,styles:a,urgency:i,mentions:o,quote:s,ttl:d},u,l){if(!e||0==e.length)throw new b("Missing message content");const m=l==exports.ThreadType.Group,{mentionsFinal:h,msgFinal:f}=c(l,e,o);if(e=f,s){if("string"!=typeof s.content&&"webchat"==s.msgType)throw new b("This kind of `webchat` quote type is not available");if("group.poll"==s.msgType)throw new b("The `group.poll` quote type is not available")}const g=h.length>0&&m,y=s?{toid:m?void 0:u,grid:m?u:void 0,message:e,clientId:Date.now(),mentionInfo:g?JSON.stringify(h):void 0,qmsgOwner:s.uidFrom,qmsgId:s.msgId,qmsgCliId:s.cliMsgId,qmsgType:(w=s.msgType,"webchat"===w?1:"chat.voice"===w?31:"chat.photo"===w?32:"chat.sticker"===w?36:"chat.doodle"===w?37:"chat.recommended"===w||"chat.link"===w?38:"chat.video.msg"===w?44:"share.file"===w?46:"chat.gif"===w?49:"chat.location.new"===w?43:1),qmsgTs:s.ts,qmsg:"string"==typeof s.content?s.content:Ti(s),imei:m?void 0:t.imei,visibility:m?0:void 0,qmsgAttach:m?JSON.stringify(Si(s)):void 0,qmsgTTL:s.ttl,ttl:null!=d?d:0}:{message:e,clientId:Date.now(),mentionInfo:g?JSON.stringify(h):void 0,imei:m?void 0:t.imei,ttl:null!=d?d:0,visibility:m?0:void 0,toid:m?void 0:u,grid:m?u:void 0};var w;!function(e,t){t&&Hr(e,{textProperties:JSON.stringify({styles:t.map(e=>{var t;const r=Object.assign(Object.assign({},e),{indentSize:void 0,st:e.st==exports.TextStyle.Indent?exports.TextStyle.Indent.replace(/\$/g,`${null!==(t=e.indentSize)&&void 0!==t?t:1}0`):e.st});return le(r),r}),ver:0})})}(y,a),p(y,i),le(y);const v=r.encodeAES(JSON.stringify(y));if(!v)throw new b("Failed to encrypt message");const S=new URL(n.message[l]);return S.pathname=s?S.pathname+"/quote":S.pathname+"/"+(m?y.mentionInfo?"mention":"sendmsg":"sms"),{url:S.toString(),body:new URLSearchParams({params:v})}}async function u({msg:o,attachments:d,mentions:u,quote:l,ttl:m,urgency:f},g,y){if(!d)throw new b("Missing attachments");const w=rn(d);if(0==w.length)throw new b("Missing attachments");const v=w[0],S=de("string"==typeof v?v:v.filename),T=1==w.length,R=y==exports.ThreadType.Group,k=T&&["jpg","jpeg","png","webp"].includes(S),U=w.filter(e=>"gif"==de("string"==typeof e?e:e.filename)),_=w.filter(e=>"gif"!=de("string"==typeof e?e:e.filename)),x=0==_.length?[]:await e.uploadAttachment(_,g,y),O=[];let A=x.length-1;const L=Date.now(),{mentionsFinal:I,msgFinal:N}=c(y,o,u);o=N;const M=I.length>0&&R&&1==_.length,P=_.length>1;let C=Date.now();for(const e of x){let t;switch(e.fileType){case"image":t={fileType:e.fileType,params:{photoId:e.photoId,clientId:(C++).toString(),desc:o,width:e.width,height:e.height,toid:R?void 0:String(g),grid:R?String(g):void 0,rawUrl:e.normalUrl,hdUrl:e.hdUrl,thumbUrl:e.thumbUrl,oriUrl:R?e.normalUrl:void 0,normalUrl:R?void 0:e.normalUrl,hdSize:String(e.totalSize),zsource:-1,ttl:null!=m?m:0,jcp:'{"convertible":"jxl"}',groupLayoutId:P?L:void 0,isGroupLayout:P?1:void 0,idInGroup:P?A--:void 0,totalItemInGroup:P?x.length:void 0,mentionInfo:M&&k&&!l?JSON.stringify(I):void 0},body:new URLSearchParams};break;case"video":case"others":t={fileType:e.fileType,params:{fileId:e.fileId,checksum:e.checksum,checksumSha:"",extention:de(e.fileName),totalSize:e.totalSize,fileName:e.fileName,clientId:e.clientFileId,fType:1,fileCount:0,fdata:"{}",toid:R?void 0:String(g),grid:R?String(g):void 0,fileUrl:e.fileUrl,zsource:-1,ttl:null!=m?m:0},body:new URLSearchParams}}p(t.params,f),le(t.params);const n=r.encodeAES(JSON.stringify(t.params));if(!n)throw new b("Failed to encrypt message");t.body.append("params",n),O.push(t)}for(const e of U){const c="string"==typeof e,d=c?await ne(t,e):Object.assign(Object.assign({},e.metadata),{fileName:e.filename});if(i(d.totalSize))throw new b(`File ${c?ue(e):e.filename} size exceed maximum size of ${a.max_size_share_file_v3}MB`);const u=await s(e,n.attachment[exports.ThreadType.User]),l=new E;l.append("chunkContent",c?await h.readFile(e):e.data,{filename:c?ue(e):e.filename,contentType:"application/octet-stream"});const y={clientId:Date.now().toString(),fileName:d.fileName,totalSize:d.totalSize,width:d.width,height:d.height,msg:o,type:1,ttl:null!=m?m:0,visibility:R?0:void 0,toid:R?void 0:g,grid:R?g:void 0,thumb:u.url,checksum:(await ie(e,d.totalSize)).data,totalChunk:1,chunkId:1};p(y,f),le(y);const w=r.encodeAES(JSON.stringify(y));if(!w)throw new b("Failed to encrypt message");O.push({query:{params:w,type:"1"},body:l.getBuffer(),headers:l.getHeaders(),fileType:"gif"})}const F=[];for(const e of O)F.push({url:r.makeURL(n.attachment[y]+vi[e.fileType],Hr({nretry:"0"},e.query||{})),body:e.body,headers:"gif"==e.fileType?e.headers:{}});return F}return async function(e,t,r=exports.ThreadType.User){if(!e)throw new b("Missing message content");if(!t)throw new b("Missing threadId");"string"==typeof e&&(e={msg:e});let{msg:n,mentions:i}=e;const{attachments:s}=e,{quote:c,ttl:p,styles:l,urgency:m}=e,h=s?rn(s):[];if(!n&&0==h.length)throw new b("Missing message content");if(h.length>0&&h.length>a.max_file)throw new b("Exceed maximum file of "+a.max_file);const f={message:null,attachment:[]};if(h.length>0){const a=de("string"==typeof h[0]?h[0]:h[0].filename);(!(1==h.length&&["jpg","jpeg","png","webp"].includes(a))&&n.length>0||n.length>0&&c)&&(await d(e,t,r).then(async e=>{f.message=(await o(e))[0]}),n="",i=void 0);const l=await u({msg:n,mentions:i,attachments:s,quote:c,ttl:p,urgency:m},t,r);f.attachment=await o(l),n=""}if(n.length>0){const n=await d(e,t,r);f.message=(await o(n))[0]}return f}});var Ei;exports.ReportReason=void 0,(Ei=exports.ReportReason||(exports.ReportReason={}))[Ei.Sensitive=1]="Sensitive",Ei[Ei.Annoy=2]="Annoy",Ei[Ei.Fraud=3]="Fraud",Ei[Ei.Other=0]="Other";const bi=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.profile[0]}/api/report/abuse-v2`),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/profile/reportabuse`)};return async function(e,a,i=exports.ThreadType.User){const o=i==exports.ThreadType.User?{idTo:a,objId:"person.profile",reason:e.reason.toString(),content:e.reason==exports.ReportReason.Other?e.content:void 0}:{uidTo:a,type:14,reason:e.reason,content:e.reason==exports.ReportReason.Other?e.content:"",imei:t.imei};le(o);const s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(n[i],{method:"POST",body:new URLSearchParams({params:s})});return r.resolve(c)}}),_i=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.chat[0]}/api/message/seenv2`,{nretry:0}),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/seenv2`,{nretry:0})};return async function(e,a=exports.ThreadType.User){if(!e)throw new b("messages are missing or not in a valid array format.");const i=rn(e);if(0===i.length||i.length>50)throw new b("messages must contain between 1 and 50 messages.");const o=a===exports.ThreadType.Group,s=o?i[0].idTo:i[0].uidFrom,c={data:i.map(e=>{if((o?e.idTo:e.uidFrom)!==s)throw new b("All messages must belong to the same thread.");return{cmi:e.cliMsgId,gmi:e.msgId,si:e.uidFrom,di:e.idTo===t.uid?"0":e.idTo,mt:e.msgType,st:e.st||0===e.st?0:-1,at:e.at||0===e.at?0:-1,cmd:e.cmd||0===e.cmd?0:-1,ts:parseInt(`${e.ts}`)||0===parseInt(`${e.ts}`)?0:-1}}),[o?"grid":"senderId"]:s},p=Object.assign({msgInfos:JSON.stringify(c)},o?{imei:t.imei}:{}),d=r.encodeAES(JSON.stringify(p));if(!d)throw new b("Failed to encrypt params");const u=await r.request(n[a],{method:"POST",body:new URLSearchParams({params:d})});return r.resolve(u)}}),xi=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.chat[0]}/api/message/sticker`,{nretry:"0"}),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/sticker`,{nretry:"0"})};return async function(e,a,i=exports.ThreadType.User){if(!e)throw new b("Missing sticker");if(!a)throw new b("Missing threadId");if(!e.id)throw new b("Missing sticker id");if(!e.cateId)throw new b("Missing sticker cateId");if(!e.type)throw new b("Missing sticker type");const o=i===exports.ThreadType.Group,s={stickerId:e.id,cateId:e.cateId,type:e.type,clientId:Date.now(),imei:t.imei,zsource:101,toid:o?void 0:a,grid:o?a:void 0};le(s);const c=r.encodeAES(JSON.stringify(s));if(!c)throw new b("Failed to encrypt message");const p=await r.request(n[i],{method:"POST",body:new URLSearchParams({params:c})});return r.resolve(p)}}),Oi=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.chat[0]}/api/message/typing`),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/typing`)};return async function(e,a=exports.ThreadType.User,i=exports.DestType.User){if(!e)throw new b("Missing threadId");const o=Object.assign(Object.assign({[a===exports.ThreadType.User?"toid":"grid"]:e},a===exports.ThreadType.User?{destType:i}:{}),{imei:t.imei}),s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(n[a],{method:"POST",body:new URLSearchParams({params:s})});return r.resolve(c)}}),Ai=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.file[0]}/api/message/forward`),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.file[0]}/api/group/forward`)};return async function(e,a,i=exports.ThreadType.User){var o,s,c,p,d,u,l,m,h,f;let g=0;const y=Date.now();try{const t=await r.request(e.videoUrl,{method:"HEAD"},!0);t.ok&&(g=parseInt(t.headers.get("content-length")||"0"))}catch(e){throw new b(`Unable to get video content: ${e instanceof Error?e.message:String(e)}`)}const w=i===exports.ThreadType.User?{toId:a,clientId:String(y),ttl:null!==(o=e.ttl)&&void 0!==o?o:0,zsource:704,msgType:5,msgInfo:JSON.stringify({videoUrl:e.videoUrl,thumbUrl:e.thumbnailUrl,duration:null!==(s=e.duration)&&void 0!==s?s:0,width:null!==(c=e.width)&&void 0!==c?c:1280,height:null!==(p=e.height)&&void 0!==p?p:720,fileSize:g,properties:{color:-1,size:-1,type:1003,subType:0,ext:{sSrcType:-1,sSrcStr:"",msg_warning_type:0}},title:null!==(d=e.msg)&&void 0!==d?d:""}),imei:t.imei}:{grid:a,visibility:0,clientId:String(y),ttl:null!==(u=e.ttl)&&void 0!==u?u:0,zsource:704,msgType:5,msgInfo:JSON.stringify({videoUrl:e.videoUrl,thumbUrl:e.thumbnailUrl,duration:null!==(l=e.duration)&&void 0!==l?l:0,width:null!==(m=e.width)&&void 0!==m?m:1280,height:null!==(h=e.height)&&void 0!==h?h:720,fileSize:g,properties:{color:-1,size:-1,type:1003,subType:0,ext:{sSrcType:-1,sSrcStr:"",msg_warning_type:0}},title:null!==(f=e.msg)&&void 0!==f?f:""}),imei:t.imei};if(i!==exports.ThreadType.User&&i!==exports.ThreadType.Group)throw new b("Thread type is invalid");const v=r.encodeAES(JSON.stringify(w));if(!v)throw new b("Failed to encrypt params");const S=await r.request(n[i],{method:"POST",body:new URLSearchParams({params:v})});return r.resolve(S)}}),Li=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.file[0]}/api/message/forward`),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.file[0]}/api/group/forward`)};return async function(e,a,i=exports.ThreadType.User){var o,s;let c=null;const p=Date.now().toString();try{const t=await r.request(e.voiceUrl,{method:"HEAD"},!0);t.ok&&(c=parseInt(t.headers.get("content-length")||"0"))}catch(e){throw new b(`Unable to get voice content: ${e instanceof Error?e.message:String(e)}`)}const d=i===exports.ThreadType.User?{toId:a,ttl:null!==(o=e.ttl)&&void 0!==o?o:0,zsource:-1,msgType:3,clientId:p,msgInfo:JSON.stringify({voiceUrl:e.voiceUrl,m4aUrl:e.voiceUrl,fileSize:null!=c?c:0}),imei:t.imei}:{grid:a,visibility:0,ttl:null!==(s=e.ttl)&&void 0!==s?s:0,zsource:-1,msgType:3,clientId:p,msgInfo:JSON.stringify({voiceUrl:e.voiceUrl,m4aUrl:e.voiceUrl,fileSize:null!=c?c:0}),imei:t.imei};if(i!==exports.ThreadType.User&&i!==exports.ThreadType.Group)throw new b("Thread type is invalid");const u=r.encodeAES(JSON.stringify(d));if(!u)throw new b("Failed to encrypt params");const l=await r.request(n[i],{method:"POST",body:new URLSearchParams({params:u})});return r.resolve(l)}}),Ii=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.conversation[0]}/api/hiddenconvers/add-remove`);return async function(e,a,i=exports.ThreadType.User){const o=rn(a);if(0===o.length)throw new b("threadId is required");const s=i===exports.ThreadType.Group?1:0,c={[e?"add_threads":"del_threads"]:JSON.stringify(o.map(e=>({thread_id:e,is_group:s}))),[e?"del_threads":"add_threads"]:"[]",imei:t.imei},p=r.encodeAES(JSON.stringify(c));if(!p)throw new b("Failed to encrypt params");const d=await r.request(n,{method:"POST",body:new URLSearchParams({params:p})});return r.resolve(d)}});var Ni,Mi;exports.MuteDuration=void 0,(Ni=exports.MuteDuration||(exports.MuteDuration={}))[Ni.ONE_HOUR=3600]="ONE_HOUR",Ni[Ni.FOUR_HOURS=14400]="FOUR_HOURS",Ni[Ni.FOREVER=-1]="FOREVER",Ni.UNTIL_8AM="until8AM",exports.MuteAction=void 0,(Mi=exports.MuteAction||(exports.MuteAction={}))[Mi.MUTE=1]="MUTE",Mi[Mi.UNMUTE=3]="UNMUTE";const Pi=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/profile/setmute`);return async function(e={},a,i=exports.ThreadType.User){const{duration:o=exports.MuteDuration.FOREVER,action:s=exports.MuteAction.MUTE}=e;let c;if(s===exports.MuteAction.UNMUTE)c=-1;else if(o===exports.MuteDuration.FOREVER)c=-1;else if(o===exports.MuteDuration.UNTIL_8AM){const e=new Date,t=new Date(e);t.setHours(8,0,0,0),e.getHours()>=8&&t.setDate(t.getDate()+1),c=Math.floor((t.getTime()-e.getTime())/1e3)}else c=o;const p={toid:a,duration:c,action:s,startTime:Math.floor(Date.now()/1e3),muteType:i===exports.ThreadType.User?1:2,imei:t.imei},d=r.encodeAES(JSON.stringify(p));if(!d)throw new b("Failed to encrypt params");const u=await r.request(n,{method:"POST",body:new URLSearchParams({params:d})});return r.resolve(u)}}),Ci=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.conversation[0]}/api/pinconvers/updatev2`);return async function(e,t,a=exports.ThreadType.User){const i=rn(t),o={actionType:e?1:2,conversations:a==exports.ThreadType.Group?i.map(e=>`g${e}`):i.map(e=>`u${e}`)},s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(n,{method:"POST",body:new URLSearchParams({params:s})});return r.resolve(c)}}),Fi=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/poll/share`);return async function(e){const a={poll_id:e,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(n,{method:"POST",body:new URLSearchParams({params:i})});return r.resolve(o)}}),zi=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend[0]}/api/friend/unblock`);return async function(e){const a={fid:e,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(n,{method:"POST",body:new URLSearchParams({params:i})});return r.resolve(o)}}),qi=ye()((e,t,r)=>{const n={[exports.ThreadType.User]:r.makeURL(`${e.zpwServiceMap.chat[0]}/api/message/undo`),[exports.ThreadType.Group]:r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/undomsg`)};return async function(e,a,i=exports.ThreadType.User){const o={msgId:e.msgId,clientId:Date.now(),cliMsgIdUndo:e.cliMsgId};i==exports.ThreadType.Group?(o.grid=a,o.visibility=0,o.imei=t.imei):o.toid=a;const s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt message");const c=await r.request(n[i],{method:"POST",body:new URLSearchParams({params:s})});return r.resolve(c)}}),Gi=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.friend[0]}/api/friend/undo`);return async function(e){const t={fid:e},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt params");const i=await r.request(n,{method:"POST",body:new URLSearchParams({params:a})});return r.resolve(i)}}),Bi=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/profile/ping`),a=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/profile/deactive`);return async function(e){const i={status:e?1:0,imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=e?n:a,c=await r.request(r.makeURL(s,{params:o}),{method:"GET"});return r.resolve(c)}});var Di;exports.ChatTTL=void 0,(Di=exports.ChatTTL||(exports.ChatTTL={}))[Di.NO_DELETE=0]="NO_DELETE",Di[Di.ONE_DAY=864e5]="ONE_DAY",Di[Di.SEVEN_DAYS=6048e5]="SEVEN_DAYS",Di[Di.FOURTEEN_DAYS=12096e5]="FOURTEEN_DAYS";const Ji=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.conversation[0]}/api/conv/autodelete/updateConvers`);return async function(e,a,i=exports.ThreadType.User){const o={threadId:a,isGroup:i===exports.ThreadType.Group?1:0,ttl:e,clientLang:t.language},s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(n,{method:"POST",body:new URLSearchParams({params:s})});return r.resolve(c)}}),$i=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.auto_reply[0]}/api/autoreply/update`);return async function(e){const a=rn(e.uids||[]),i=2===e.scope||3===e.scope?a:[],o={cliLang:t.language,id:e.id,enable:e.isEnable,content:e.content,startTime:e.startTime,endTime:e.endTime,recurrence:["RRULE:FREQ=DAILY;"],scope:e.scope,uids:i},s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(n,{method:"POST",body:new URLSearchParams({params:s})});return r.resolve(c)}}),ji=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.catalog[0]}/api/prodcatalog/catalog/update`);return async function(e){const t={catalog_id:e.catalogId,catalog_name:e.catalogName,catalog_photo:""},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt params");const i=await r.request(n,{method:"POST",body:new URLSearchParams({params:a})});return r.resolve(i)}}),Vi=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/group/setting/update`);return async function(e,a){const i={blockName:e.blockName?1:0,signAdminMsg:e.signAdminMsg?1:0,setTopicOnly:e.setTopicOnly?1:0,enableMsgHistory:e.enableMsgHistory?1:0,joinAppr:e.joinAppr?1:0,lockCreatePost:e.lockCreatePost?1:0,lockCreatePoll:e.lockCreatePoll?1:0,lockSendMsg:e.lockSendMsg?1:0,lockViewMember:e.lockViewMember?1:0,bannFeature:0,dirtyMedia:0,banDuration:0,blocked_members:[],grid:a,imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(r.makeURL(n,{params:o}),{method:"GET"});return r.resolve(s)}}),Ki=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.conversation[0]}/api/hiddenconvers/update-pin`),a=/^\d{4}$/;return async function(e){if(!a.test(e))throw new b("Pin must be a 4-digit number between 0000-9999");const i=function(e){return g.createHash("md5").update(e).digest("hex")}(e),o={new_pin:i,imei:t.imei},s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(r.makeURL(n,{params:s}),{method:"GET"});return r.resolve(c)}}),Hi=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.label[0]}/api/convlabel/update`);return async function(e){const a={labelData:JSON.stringify(e.labelData),version:e.version,imei:t.imei},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt message");const o=await r.request(n,{method:"POST",body:new URLSearchParams({params:i})}),s=await r.resolve(o);return{labelData:JSON.parse(s.labelData),version:s.version,lastUpdateTime:s.lastUpdateTime}}});var Qi;exports.UpdateLangAvailableLanguages=void 0,(Qi=exports.UpdateLangAvailableLanguages||(exports.UpdateLangAvailableLanguages={})).VI="VI",Qi.EN="EN";const Wi=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/profile/updatelang`);return async function(e=exports.UpdateLangAvailableLanguages.VI){const t={language:e},a=r.encodeAES(JSON.stringify(t));if(!a)throw new b("Failed to encrypt params");const i=await r.request(r.makeURL(n,{params:a}),{method:"GET"});return r.resolve(i)}}),Yi=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.catalog[0]}/api/prodcatalog/product/update`);return async function(t){const a=t.product_photos||[];if(t.files&&0==t.files.length){if(t.files.length>5)throw new b("Maximum 5 media files are allowed");for(const r of t.files){const t=await e.uploadProductPhoto({file:r}),n=t.normalUrl||t.hdUrl;a.push(n)}}if(a.length>5)throw new b("Maximum 5 media files are allowed");const i={product_id:t.productId,product_name:t.productName,price:t.price,description:t.description,product_photos:a,catalog_id:t.catalogId,currency_unit:"₫",create_time:t.createTime},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(n,{method:"POST",body:new URLSearchParams({params:o})});return r.resolve(s)}}),Zi=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.profile[0]}/api/social/profile/update`);return async function(e){var a,i,o,s,c;const p={profile:JSON.stringify({name:e.profile.name,dob:e.profile.dob,gender:e.profile.gender}),biz:JSON.stringify({desc:null===(a=e.biz)||void 0===a?void 0:a.description,cate:null===(i=e.biz)||void 0===i?void 0:i.cate,addr:null===(o=e.biz)||void 0===o?void 0:o.address,website:null===(s=e.biz)||void 0===s?void 0:s.website,email:null===(c=e.biz)||void 0===c?void 0:c.email}),language:t.language},d=r.encodeAES(JSON.stringify(p));if(!d)throw new b("Failed to encrypt params");const u=await r.request(n,{method:"POST",body:new URLSearchParams({params:d})});return r.resolve(u)}}),Xi=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.quick_message[0]}/api/quickmessage/update`);return async function(t,a){const i=t.media?1:0,o={itemId:a,keyword:t.keyword,message:{title:t.title,params:""},type:i};if(1===i){if(!t.media)throw new b("Media is required");const r=await e.uploadProductPhoto({file:t.media}),n=r.photoId,a=r.thumbUrl,i=r.normalUrl,s=r.hdUrl;o.media={items:[{type:0,photoId:n,title:"",width:"",height:"",previewThumb:a,rawUrl:i||s,thumbUrl:a,normalUrl:i||s,hdUrl:s||i}]}}const s=r.encodeAES(JSON.stringify(o));if(!s)throw new b("Failed to encrypt params");const c=await r.request(r.makeURL(n,{params:s}),{method:"GET"});return r.resolve(c)}});var eo;exports.UpdateSettingsType=void 0,(eo=exports.UpdateSettingsType||(exports.UpdateSettingsType={})).ViewBirthday="view_birthday",eo.ShowOnlineStatus="show_online_status",eo.DisplaySeenStatus="display_seen_status",eo.ReceiveMessage="receive_message",eo.AcceptCall="accept_stranger_call",eo.AddFriendViaPhone="add_friend_via_phone",eo.AddFriendViaQR="add_friend_via_qr",eo.AddFriendViaGroup="add_friend_via_group",eo.AddFriendViaContact="add_friend_via_contact",eo.DisplayOnRecommendFriend="display_on_recommend_friend",eo.ArchivedChat="archivedChatStatus",eo.QuickMessage="quickMessageStatus";const to=ye()((e,t,r)=>{const n=r.makeURL("https://wpa.chat.zalo.me/api/setting/update");return async function(e,t){const a={[e]:t},i=r.encodeAES(JSON.stringify(a));if(!i)throw new b("Failed to encrypt params");const o=await r.request(r.makeURL(n,{params:i}),{method:"GET"});return r.resolve(o)}}),ro={image:"photo_original/upload",video:"asyncfile/upload",others:"asyncfile/upload"},no=ye()((e,t,r)=>{const n=`${e.zpwServiceMap.file[0]}/api`,{sharefile:a}=t.settings.features;function i(e){return e>1024*a.max_size_share_file_v3*1024}function o(e){return-1==a.restricted_ext_file.indexOf(e)}return async function(e,s,c=exports.ThreadType.User){if(!e)throw new b("Missing sources");const p=rn(e);if(0==p.length)throw new b("Missing sources");if(p.length>a.max_file)throw new b("Exceed maximum file of "+a.max_file);if(!s)throw new b("Missing threadId");const d=t.settings.features.sharefile.chunk_size_file,u=c==exports.ThreadType.Group,l=[],m=`${n}/${u?"group":"message"}/`,h=u?"11":"2";let f=Date.now();for(const e of p){const r="string"==typeof e,n="object"==typeof e&&e.data instanceof Buffer;if(!r&&!n)throw new b("Invalid source type");if(!r&&!e.filename)throw new b("Missing filename");if(r&&!y.existsSync(e))throw new b("File not found");const c=de(r?e:e.filename).toLowerCase(),p=r?ue(e):e.filename;if(0==o(c))throw new b(`File extension "${c}" is not allowed`);const m={filePath:r?e:e.filename,chunkContent:[],params:{},source:e};switch(u?m.params.grid=s:m.params.toid=s,c){case"jpg":case"jpeg":case"png":case"webp":{const n=r?await te(t,e):Object.assign(Object.assign({},e.metadata),{fileName:p});if(i(n.totalSize))throw new b(`File ${p} size exceed maximum size of ${a.max_size_share_file_v3}MB`);m.fileData=n,m.fileType="image",m.params.totalChunk=Math.ceil(m.fileData.totalSize/d),m.params.fileName=p,m.params.clientId=f++,m.params.totalSize=n.totalSize,m.params.imei=t.imei,m.params.isE2EE=0,m.params.jxl=0,m.params.chunkId=1;break}case"mp4":{const n=r?await re(e):e.metadata.totalSize;if(i(n))throw new b(`File ${p} size exceed maximum size of ${a.max_size_share_file_v3}MB`);m.fileType="video",m.fileData={fileName:p,totalSize:n},m.params.totalChunk=Math.ceil(m.fileData.totalSize/d),m.params.fileName=p,m.params.clientId=f++,m.params.totalSize=n,m.params.imei=t.imei,m.params.isE2EE=0,m.params.jxl=0,m.params.chunkId=1;break}default:{const n=r?await re(e):e.metadata.totalSize;if(i(n))throw new b(`File ${p} size exceed maximum size of ${a.max_size_share_file_v3}MB`);m.fileType="others",m.fileData={fileName:p,totalSize:n},m.params.totalChunk=Math.ceil(m.fileData.totalSize/d),m.params.fileName=p,m.params.clientId=f++,m.params.totalSize=n,m.params.imei=t.imei,m.params.isE2EE=0,m.params.jxl=0,m.params.chunkId=1;break}}const h=r?await y.promises.readFile(e):e.data;for(let e=0;e<m.params.totalChunk;e++){const t=new E,r=h.subarray(e*d,(e+1)*d);t.append("chunkContent",r,{filename:p,contentType:"application/octet-stream"}),m.chunkContent[e]=t}l.push(m)}const g=[],w=[];for(const e of l)for(let n=0;n<e.params.totalChunk;n++){const a=r.encodeAES(JSON.stringify(e.params));if(!a)throw new b("Failed to encrypt message");g.push(r.request(r.makeURL(m+ro[e.fileType],{type:h,params:a}),{method:"POST",headers:e.chunkContent[n].getHeaders(),body:e.chunkContent[n].getBuffer()}).then(async r=>{const n=await ge(t,r);n&&"-1"!=n.fileId&&"-1"!=n.photoId&&await new Promise(r=>{if("video"==e.fileType||"others"==e.fileType){const a=async t=>{const a=Object.assign(Object.assign(Object.assign({fileType:e.fileType},n),t),{totalSize:e.fileData.totalSize,fileName:e.fileData.fileName,checksum:(await ie(e.source,e.fileData.totalSize)).data});w.push(a),r()};t.uploadCallbacks.set(n.fileId.toString(),a)}if("image"==e.fileType){const t={fileType:"image",width:e.fileData.width,height:e.fileData.height,totalSize:e.fileData.totalSize,hdSize:e.fileData.totalSize,finished:n.finished,normalUrl:n.normalUrl,hdUrl:n.hdUrl,thumbUrl:n.thumbUrl,chunkId:n.chunkId,photoId:n.photoId,clientFileId:n.clientFileId};w.push(t),r()}})})),e.params.chunkId++}return await Promise.all(g),w}}),ao=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.file[0]}/api/product/upload/photo`);return async function(e){const a="string"==typeof e.file,i=(a?await te(t,e.file):e.file.metadata).totalSize||0,o=a?await y.promises.readFile(e.file):e.file.data,s=new E;s.append("chunkContent",o,{filename:"undefined",contentType:"application/octet-stream"});const c={totalChunk:1,fileName:`Base64_Img_Picker_${Date.now()}.jpg`,clientId:Date.now(),totalSize:i,imei:t.imei,chunkId:1,toid:t.loginInfo.send2me_id,featureId:1},p=r.encodeAES(JSON.stringify(c));if(!p)throw new b("Failed to encrypt params");const d=await r.request(r.makeURL(n,{params:p}),{method:"POST",headers:s.getHeaders(),body:s.getBuffer()});return r.resolve(d)}}),io=ye()((e,t,r)=>{const n=r.makeURL(`${e.zpwServiceMap.group[0]}/api/poll/vote`);return async function(e,a){const i={poll_id:e,option_ids:rn(a),imei:t.imei},o=r.encodeAES(JSON.stringify(i));if(!o)throw new b("Failed to encrypt params");const s=await r.request(r.makeURL(n,{params:o}),{method:"GET"});return r.resolve(s)}}),oo=ye()((e,t,r)=>function(n,a){Object.defineProperty(e,n,{value:function(e){return a({ctx:t,utils:r,props:e})},writable:!1,enumerable:!1,configurable:!1})});class so{constructor(e,t,r){this.zpwServiceMap=t,this.listener=new Yr(e,r),this.acceptFriendRequest=Zr(e,this),this.addGroupBlockedMember=nn(e,this),this.addGroupDeputy=an(e,this),this.addPollOptions=on(e,this),this.addQuickMessage=sn(e,this),this.addReaction=cn(e,this),this.addUnreadMark=pn(e,this),this.addUserToGroup=dn(e,this),this.blockUser=un(e,this),this.blockViewFeed=ln(e,this),this.changeAccountAvatar=mn(e,this),this.changeFriendAlias=hn(e,this),this.changeGroupAvatar=fn(e,this),this.changeGroupName=gn(e,this),this.changeGroupOwner=yn(e,this),this.createAutoReply=wn(e,this),this.createCatalog=vn(e,this),this.createGroup=Sn(e,this),this.createNote=Tn(e,this),this.createPoll=Rn(e,this),this.createProductCatalog=kn(e,this),this.createReminder=Un(e,this),this.deleteAutoReply=En(e,this),this.deleteAvatar=bn(e,this),this.deleteCatalog=_n(e,this),this.deleteChat=xn(e,this),this.deleteGroupInviteBox=On(e,this),this.deleteMessage=An(e,this),this.deleteProductCatalog=Ln(e,this),this.disableGroupLink=In(e,this),this.disperseGroup=Nn(e,this),this.editNote=Mn(e,this),this.editReminder=Pn(e,this),this.enableGroupLink=Cn(e,this),this.fetchAccountInfo=Fn(e,this),this.findUser=zn(e,this),this.forwardMessage=qn(e,this),this.getAliasList=Gn(e,this),this.getAllFriends=Bn(e,this),this.getAllGroups=Dn(e,this),this.getArchivedChatList=Jn(e,this),this.getAutoDeleteChat=$n(e,this),this.getAutoReplyList=jn(e,this),this.getAvatarList=Vn(e,this),this.getBizAccount=Kn(e,this),this.getCatalogList=Hn(e,this),this.getContext=Qn(e,this),this.getCookie=Wn(e,this),this.getFriendBoardList=Yn(e,this),this.getFriendOnlines=Xn(e,this),this.getFriendRecommendations=ea(e,this),this.getFriendRequestStatus=ta(e,this),this.getGroupBlockedMember=ra(e,this),this.getGroupInfo=na(e,this),this.getGroupInviteBoxInfo=aa(e,this),this.getGroupInviteBoxList=ia(e,this),this.getGroupLinkDetail=oa(e,this),this.getGroupLinkInfo=sa(e,this),this.getGroupMembersInfo=ca(e,this),this.getHiddenConversations=pa(e,this),this.getLabels=da(e,this),this.getListBoard=ua(e,this),this.getListReminder=la(e,this),this.getMute=ma(e,this),this.getOwnId=ha(e,this),this.getPendingGroupMembers=fa(e,this),this.getPinConversations=ga(e,this),this.getPollDetail=ya(e,this),this.getProductCatalogList=wa(e,this),this.getQR=va(e,this),this.getQuickMessageList=Sa(e,this),this.getRelatedFriendGroup=Ta(e,this),this.getReminder=Ra(e,this),this.getReminderResponses=ka(e,this),this.getSentFriendRequest=Ua(e,this),this.getSettings=Ea(e,this),this.getStickers=ba(e,this),this.getStickersDetail=_a(e,this),this.getUnreadMark=xa(e,this),this.getUserInfo=Oa(e,this),this.inviteUserToGroups=Aa(e,this),this.joinGroupInviteBox=La(e,this),this.joinGroupLink=Ia(e,this),this.keepAlive=Na(e,this),this.lastOnline=Ma(e,this),this.leaveGroup=Pa(e,this),this.lockPoll=Ca(e,this),this.parseLink=Fa(e,this),this.rejectFriendRequest=za(e,this),this.removeFriend=qa(e,this),this.removeFriendAlias=Ga(e,this),this.removeGroupBlockedMember=Ba(e,this),this.removeGroupDeputy=Da(e,this),this.removeQuickMessage=Ja(e,this),this.removeReminder=$a(e,this),this.removeUnreadMark=ja(e,this),this.removeUserFromGroup=Va(e,this),this.resetHiddenConversPin=Ka(e,this),this.reuseAvatar=Ha(e,this),this.reviewPendingMemberRequest=Wa(e,this),this.sendBankCard=Ya(e,this),this.sendCard=Za(e,this),this.sendDeliveredEvent=Xa(e,this),this.sendFriendRequest=ei(e,this),this.sendLink=ti(e,this),this.sendMessage=Ui(e,this),this.sendReport=bi(e,this),this.sendSeenEvent=_i(e,this),this.sendSticker=xi(e,this),this.sendTypingEvent=Oi(e,this),this.sendVideo=Ai(e,this),this.sendVoice=Li(e,this),this.setHiddenConversations=Ii(e,this),this.setMute=Pi(e,this),this.setPinnedConversations=Ci(e,this),this.sharePoll=Fi(e,this),this.unblockUser=zi(e,this),this.undo=qi(e,this),this.undoFriendRequest=Gi(e,this),this.updateActiveStatus=Bi(e,this),this.updateAutoDeleteChat=Ji(e,this),this.updateAutoReply=$i(e,this),this.updateCatalog=ji(e,this),this.updateGroupSettings=Vi(e,this),this.updateHiddenConversPin=Ki(e,this),this.updateLabels=Hi(e,this),this.updateLang=Wi(e,this),this.updateProductCatalog=Yi(e,this),this.updateProfile=Zi(e,this),this.updateQuickMessage=Xi(e,this),this.updateSettings=to(e,this),this.uploadAttachment=no(e,this),this.uploadProductPhoto=ao(e,this),this.votePoll=io(e,this),this.custom=oo(e,this)}}exports.API=so,exports.BusinessCategoryName=D,exports.GroupDeliveredMessage=L,exports.GroupMessage=P,exports.GroupSeenMessage=z,exports.GroupTyping=G,exports.Reaction=C,exports.Undo=B,exports.UserDeliveredMessage=A,exports.UserMessage=M,exports.UserSeenMessage=F,exports.UserTyping=q,exports.Zalo=class{constructor(e={}){this.options=e,this.enableEncryptParam=!0}parseCookies(e){var t;const r=Array.isArray(e)?e:e.cookies;r.forEach((e,t)=>{"string"==typeof e.domain&&e.domain.startsWith(".")&&(r[t].domain=e.domain.slice(1))});const n=new m.CookieJar;for(const e of r)try{n.setCookieSync(null!==(t=m.Cookie.fromJSON(Object.assign(Object.assign({},e),{key:e.key||e.name})))&&void 0!==t?t:"","https://chat.zalo.me")}catch(e){oe({options:{logging:this.options.logging}}).error("Failed to set cookie:",e)}return n}validateParams(e){if(!e.imei||!e.cookie||!e.userAgent)throw new b("Missing required params")}async login(e){const t=$(this.options.apiType,this.options.apiVersion);return Object.assign(t.options,this.options),this.loginCookie(t,e)}async loginCookie(e,t){await async function(e){if(!e.options.checkUpdate)return;const t=Object.assign({},{agent:e.options.agent}),r=await e.options.polyfill("https://registry.npmjs.org/zca-js",t).catch(()=>null);if(!r||!r.ok)return;const n=await r.json().catch(()=>null);if(!n)return;const a=n["dist-tags"].latest;-1===R.compare("2.0.4",a)?oe(e).info(`A new version of zca-js is available: ${a}`):oe(e).info("zca-js is up to date")}(e),this.validateParams(t),e.imei=t.imei,e.cookie=this.parseCookies(t.cookie),e.userAgent=t.userAgent,e.language=t.language||"vi";const r=await async function(e,t){const r=await Qr(e,t,"getlogininfo");try{const t=await ee(e,H(e,"https://wpa.chat.zalo.me/api/login/getLoginInfo",Object.assign(Object.assign({},r.params),{nretry:0})));if(!t.ok)throw new b("Failed to fetch login info: "+t.statusText);const n=await t.json();if(r.enk){const e=W(r.enk,n.data);return null!=e&&"string"!=typeof e?e:null}return null}catch(t){throw oe(e).error("Login failed:",t),t}}(e,this.enableEncryptParam),n=await async function(e,t){const r=await Qr(e,t,"getserverinfo");if(!r.params.signkey||"string"!=typeof r.params.signkey)throw new b("Missing signkey");const n=await ee(e,H(e,"https://wpa.chat.zalo.me/api/login/getServerInfo",{imei:e.imei,type:e.API_TYPE,client_version:e.API_VERSION,computer_name:"Web",signkey:r.params.signkey},!1));if(!n.ok)throw new b("Failed to fetch server info: "+n.statusText);const a=await n.json();if(null==a.data)throw new b("Failed to fetch server info: "+a.error_message);return a.data}(e,this.enableEncryptParam),a=null==r?void 0:r.data;if(!r||!a||!n)throw new b("Đăng nhập thất bại");if(e.secretKey=a.zpw_enk,e.uid=a.uid,e.settings=n.setttings||n.settings,e.extraVer=n.extra_ver,e.loginInfo=a,!j(e))throw new b("Khởi tạo ngữ cảnh thất bại.");return oe(e).info("Logged in as",a.uid),new so(e,a.zpw_service_map_v3,a.zpw_ws)}async loginQR(e,t){e||(e={}),e.userAgent||(e.userAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0"),e.language||(e.language="vi");const r=$(this.options.apiType,this.options.apiVersion);Object.assign(r.options,this.options);const n=await Re(r,e,t);if(!n)throw new b("Unable to login with QRCode");const a=(i=e.userAgent,g.randomUUID()+"-"+f.MD5(i).toString());var i;return t&&t({type:exports.LoginQRCallbackEventType.GotLoginInfo,data:{cookie:n.cookies,imei:a,userAgent:e.userAgent},actions:null}),this.loginCookie(r,{cookie:n.cookies,imei:a,userAgent:e.userAgent,language:e.language})}},exports.ZaloApiError=b,exports.ZaloApiLoginQRAborted=x,exports.ZaloApiLoginQRDeclined=O,exports.ZaloApiMissingImageMetadataGetter=_,exports.initializeFriendEvent=I,exports.initializeGroupEvent=N;
|
|
2
|
+
//# sourceMappingURL=index.min.cjs.map
|