diff --git a/ruoyi-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml index 2541964..cfbb80e 100644 --- a/ruoyi-admin/src/main/resources/application-dev.yml +++ b/ruoyi-admin/src/main/resources/application-dev.yml @@ -177,10 +177,14 @@ sms: --- # OpenIM 集成 openim: - # OpenIM 核心 API 地址(admin token、发消息) - api-url: http://49.232.154.205:10002 - # OpenIM chat 业务 API 地址(手机号注册/查询,可选) - chat-url: http://49.232.154.205:10008 + # OpenIM 核心 API 地址 — 走 nginx 网关 :10006/api(直连 :10002 端口外网未开放) + api-url: http://49.232.154.205:10006/api + # 给前端 SDK 用的 API 地址 + public-api-url: http://49.232.154.205:10006/api + # WebSocket 长连接地址(与手机端一致) + ws-url: ws://49.232.154.205:10006/msg_gateway + # OpenIM chat 业务 API 地址 + chat-url: http://49.232.154.205:10006/chat # 与 OpenIM share.yml 中保持一致的 secret secret: openIM123 # 管理员 userID(chat share.yml 中 adminUserID) diff --git a/ruoyi-admin/src/main/resources/application-prod.yml b/ruoyi-admin/src/main/resources/application-prod.yml index c2a2bb9..86747ce 100644 --- a/ruoyi-admin/src/main/resources/application-prod.yml +++ b/ruoyi-admin/src/main/resources/application-prod.yml @@ -175,3 +175,22 @@ sms: signName: 测试 # 腾讯专用 sdkAppId: + + +--- # OpenIM 集成 +openim: + # OpenIM 核心 API 地址 — 走 nginx 网关 :10006/api(直连 :10002 端口外网未开放) + api-url: http://49.232.154.205:10006/api + # 给前端 SDK 用的 API 地址 + public-api-url: http://49.232.154.205:10006/api + # WebSocket 长连接地址(与手机端一致) + ws-url: ws://49.232.154.205:10006/msg_gateway + # OpenIM chat 业务 API 地址 + chat-url: http://49.232.154.205:10006/chat + # 与 OpenIM share.yml 中保持一致的 secret + secret: openIM123 + # 管理员 userID(chat share.yml 中 adminUserID) + admin-user-id: imAdmin + # 发送系统消息时显示的发送者 + notification-sender: imAdmin + enabled: true diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/controller/OaProjectScheduleController.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/controller/OaProjectScheduleController.java index eedebf9..0b7bd5c 100644 --- a/ruoyi-oa/src/main/java/com/ruoyi/oa/controller/OaProjectScheduleController.java +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/controller/OaProjectScheduleController.java @@ -24,6 +24,10 @@ import com.ruoyi.oa.domain.vo.OaProjectScheduleVo; import com.ruoyi.oa.domain.bo.OaProjectScheduleBo; import com.ruoyi.oa.service.IOaProjectScheduleService; import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.helper.LoginHelper; +import com.ruoyi.oa.im.ImSendService; +import com.ruoyi.system.service.ISysUserService; /** * 项目进度 @@ -38,6 +42,43 @@ import com.ruoyi.common.core.page.TableDataInfo; public class OaProjectScheduleController extends BaseController { private final IOaProjectScheduleService iOaProjectScheduleService; + private final ImSendService imSendService; + private final ISysUserService userService; + + /** + * 催促进度:给项目负责人发一条 IM 消息 + */ + @PostMapping("/urge/{scheduleId}") + public R urgeProgress(@PathVariable Long scheduleId) { + OaProjectScheduleVo vo = iOaProjectScheduleService.queryById(scheduleId); + if (vo == null) { + return R.fail("项目进度不存在"); + } + String header = vo.getHeader(); + if (header == null || header.isEmpty()) { + return R.fail("该项目未设置负责人"); + } + SysUser user = userService.selectUserByNickName(header); + if (user == null) { + return R.fail("找不到负责人 " + header + " 的账号"); + } + // 防止自己催自己 → 还是发,但提示 + String me = LoginHelper.getNickName(); + String projectName = vo.getProjectName() == null ? "(未命名项目)" : vo.getProjectName(); + String currentStep = vo.getCurrentStepName() == null ? "(无)" : vo.getCurrentStepName(); + int percent = vo.getSchedulePercentage() == null ? 0 : vo.getSchedulePercentage().intValue(); + long delay = vo.getDelayCount() == null ? 0 : vo.getDelayCount(); + + String title = "进度催促"; + String desc = String.format("[%s] 催促您推进【%s】,当前 %d%%,当前步骤:%s%s", + me == null ? "系统" : me, projectName, percent, currentStep, + delay > 0 ? ",已有 " + delay + " 步延期" : ""); + + imSendService.sendToOaUser(user.getUserId(), title, desc, + "schedule", scheduleId, "/projectSchedule?scheduleId=" + scheduleId); + + return R.ok(); + } /** * 查询项目进度列表 diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/SysOaWarehouseMaster.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/SysOaWarehouseMaster.java index 3c632af..d694511 100644 --- a/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/SysOaWarehouseMaster.java +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/SysOaWarehouseMaster.java @@ -57,6 +57,9 @@ public class SysOaWarehouseMaster extends BaseEntity { */ private String remark; + /** 收货单/相关附件 OSS ID(逗号分隔) */ + private String receiptDoc; + private Integer isLike; private Long status; private Integer returnType; diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/bo/SysOaWarehouseMasterBo.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/bo/SysOaWarehouseMasterBo.java index 679031d..39e0059 100644 --- a/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/bo/SysOaWarehouseMasterBo.java +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/bo/SysOaWarehouseMasterBo.java @@ -61,6 +61,9 @@ public class SysOaWarehouseMasterBo extends BaseEntity { */ private String remark; + /** 收货单/相关附件 OSS ID(逗号分隔) */ + private String receiptDoc; + /** * 涉及物料 */ diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/vo/SysOaWarehouseMasterVo.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/vo/SysOaWarehouseMasterVo.java index 376cf93..ca39834 100644 --- a/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/vo/SysOaWarehouseMasterVo.java +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/domain/vo/SysOaWarehouseMasterVo.java @@ -97,5 +97,9 @@ public class SysOaWarehouseMasterVo { private Long totalQty; /** 物料概览(GROUP_CONCAT 名称) */ private String itemsSummary; + /** 收货单 OSS ID(CSV) */ + private String receiptDoc; + /** 收货单文件信息(已联查 sys_oss,格式 ossId|name|url,, ) */ + private String receiptFiles; } diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/im/ImCredentialsController.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/im/ImCredentialsController.java new file mode 100644 index 0000000..5b0da4a --- /dev/null +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/im/ImCredentialsController.java @@ -0,0 +1,47 @@ +package com.ruoyi.oa.im; + +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.helper.LoginHelper; +import com.ruoyi.oa.im.mapper.ImBindMapper; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.Map; + +/** + * 当前用户的 IM 凭据(供 Web SDK 登录) + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/system/user/im") +public class ImCredentialsController extends BaseController { + + private final ImBindMapper bindMapper; + private final OpenImClient openImClient; + private final OpenImProperties props; + + /** 当前用户 IM 登录所需信息:imUserId + token + apiUrl + wsUrl */ + @GetMapping("/credentials") + public R> credentials() { + Long userId = LoginHelper.getUserId(); + ImBind bind = bindMapper.selectById(userId); + if (bind == null || bind.getImUserId() == null) { + return R.fail("当前账号未绑定 IM"); + } + // platformId=5: Web + String token = openImClient.issueUserToken(bind.getImUserId(), 5); + if (token == null) { + return R.fail("获取 IM token 失败"); + } + Map data = new HashMap<>(); + data.put("imUserId", bind.getImUserId()); + data.put("imToken", token); + data.put("apiUrl", props.getPublicApiUrl()); + data.put("wsUrl", props.getWsUrl()); + return R.ok(data); + } +} diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/im/OpenImClient.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/im/OpenImClient.java index 0ea5039..95fafba 100644 --- a/ruoyi-oa/src/main/java/com/ruoyi/oa/im/OpenImClient.java +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/im/OpenImClient.java @@ -106,20 +106,21 @@ public class OpenImClient { offlinePush.put("iOSPushSound", "default"); offlinePush.put("iOSBadgeCount", true); - Map sendMsg = new HashMap<>(); - sendMsg.put("sendID", props.getNotificationSender()); - sendMsg.put("recvID", recvImUserId); - sendMsg.put("senderNickname", "系统通知"); - sendMsg.put("senderPlatformID", 1); - sendMsg.put("content", content); - sendMsg.put("contentType", CUSTOM_CONTENT_TYPE); - sendMsg.put("sessionType", SESSION_SINGLE); - sendMsg.put("isOnlineOnly", false); - sendMsg.put("notOfflinePush", false); - sendMsg.put("offlinePushInfo", offlinePush); + // SendMsg 字段需要嵌套在 sendMessage 对象里(OpenIM v3.8 约定) + Map sendMessage = new HashMap<>(); + sendMessage.put("sendID", props.getNotificationSender()); + sendMessage.put("recvID", recvImUserId); + sendMessage.put("senderNickname", "系统通知"); + sendMessage.put("senderPlatformID", 1); + sendMessage.put("content", content); + sendMessage.put("contentType", CUSTOM_CONTENT_TYPE); + sendMessage.put("sessionType", SESSION_SINGLE); + sendMessage.put("isOnlineOnly", false); + sendMessage.put("notOfflinePush", false); + sendMessage.put("offlinePushInfo", offlinePush); Map body = new HashMap<>(); - body.put("sendMsg", sendMsg); + body.put("sendMessage", sendMessage); JSONObject resp = postJson(props.getApiUrl() + "/msg/send_msg", body, getAdminToken()); Integer errCode = resp.getInteger("errCode"); @@ -130,6 +131,26 @@ public class OpenImClient { return false; } + /** + * 用 admin 身份签发 IM 用户 token(Web SDK 登录需要)。 + * @param imUserId IM userID + * @param platformId 平台编号(5=Web) + */ + public String issueUserToken(String imUserId, int platformId) { + if (!props.isEnabled()) { return null; } + Map body = new HashMap<>(); + body.put("secret", props.getSecret()); + body.put("platformID", platformId); + body.put("userID", imUserId); + JSONObject resp = postJson(props.getApiUrl() + "/auth/get_user_token", body, getAdminToken()); + JSONObject data = resp.getJSONObject("data"); + if (data == null) { + log.warn("[OpenIM] issueUserToken failed: {}", resp); + return null; + } + return data.getString("token"); + } + /** chat 后端 admin token */ public String getChatAdminToken() { long now = System.currentTimeMillis(); diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/im/OpenImProperties.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/im/OpenImProperties.java index 1818ca9..505e4d4 100644 --- a/ruoyi-oa/src/main/java/com/ruoyi/oa/im/OpenImProperties.java +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/im/OpenImProperties.java @@ -14,14 +14,20 @@ import org.springframework.stereotype.Component; @ConfigurationProperties(prefix = "openim") public class OpenImProperties { - /** OpenIM 核心 API 地址 */ - private String apiUrl = "http://49.232.154.205:10002"; + /** OpenIM 核心 API 地址(走 nginx 网关,:10002 直连端口外网未开放) */ + private String apiUrl = "http://49.232.154.205:10006/api"; - /** OpenIM chat 业务 API 地址 */ - private String chatUrl = "http://49.232.154.205:10008"; + /** OpenIM WS 长连接地址(前端 SDK 用) */ + private String wsUrl = "ws://49.232.154.205:10006/msg_gateway"; - /** OpenIM chat 管理 API 地址(注册新用户、admin login) */ - private String chatAdminUrl = "http://49.232.154.205:10009"; + /** 前端 SDK 可以直接访问的 API 地址(如果跟后端调用地址不同) */ + private String publicApiUrl = "http://49.232.154.205:10006/api"; + + /** OpenIM chat 业务 API 地址(走 nginx 网关) */ + private String chatUrl = "http://49.232.154.205:10006/chat"; + + /** OpenIM chat 管理 API 地址(走 nginx 网关) */ + private String chatAdminUrl = "http://49.232.154.205:10006/chat"; /** chat 后端 admin 账号 */ private String chatAdminAccount = "chatAdmin"; diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/mapper/OaProjectScheduleMapper.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/mapper/OaProjectScheduleMapper.java index c73c1b1..396c6ab 100644 --- a/ruoyi-oa/src/main/java/com/ruoyi/oa/mapper/OaProjectScheduleMapper.java +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/mapper/OaProjectScheduleMapper.java @@ -1,5 +1,6 @@ package com.ruoyi.oa.mapper; +import com.baomidou.mybatisplus.annotation.InterceptorIgnore; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -18,5 +19,7 @@ import java.util.Map; */ public interface OaProjectScheduleMapper extends BaseMapperPlus { + /** dataPermission="true" 让 PlusDataPermissionInterceptor 跳过解析(SQL 太复杂 JsqlParser 不识别) */ + @InterceptorIgnore(dataPermission = "true") Page selectVoPagePlus(@Param("page") Page build,@Param(Constants.WRAPPER) QueryWrapper lqw); } diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/suggestion/UserSuggestion.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/suggestion/UserSuggestion.java new file mode 100644 index 0000000..4080bc5 --- /dev/null +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/suggestion/UserSuggestion.java @@ -0,0 +1,43 @@ +package com.ruoyi.oa.suggestion; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.util.Date; + +/** + * 用户修改意见(区别于已有的 oa_feedback 问题反馈,本表为顶栏入口提交的改进意见) + */ +@Data +@TableName("sys_oa_feedback") +public class UserSuggestion { + + @TableId(value = "feedback_id") + private Long feedbackId; + + private String title; + private String content; + private String category; + private Integer priority; + private String pagePath; + private String attachment; + + private Long submitterId; + private String submitterName; + + /** 0待处理 1已受理 2已完成 3已关闭 */ + private Integer status; + + private Long handlerId; + private String handlerName; + private String acceptRemark; + private Date acceptTime; + private Date finishTime; + + private String createBy; + private Date createTime; + private String updateBy; + private Date updateTime; + private Integer delFlag; +} diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/suggestion/UserSuggestionController.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/suggestion/UserSuggestionController.java new file mode 100644 index 0000000..bdb84db --- /dev/null +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/suggestion/UserSuggestionController.java @@ -0,0 +1,148 @@ +package com.ruoyi.oa.suggestion; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.PageQuery; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.helper.LoginHelper; +import com.ruoyi.oa.im.ImSendService; +import com.ruoyi.oa.suggestion.mapper.UserSuggestionMapper; +import com.ruoyi.system.mapper.SysUserMapper; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.Date; +import java.util.List; + +/** + * 用户修改意见 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/oa/suggestion") +public class UserSuggestionController extends BaseController { + + /** 信息化部 dept_id */ + private static final Long IT_DEPT_ID = 1858416909042524161L; + + private final UserSuggestionMapper mapper; + private final ImSendService imSendService; + private final SysUserMapper userMapper; + + @GetMapping("/list") + public TableDataInfo list(UserSuggestion query, PageQuery pageQuery) { + LambdaQueryWrapper qw = Wrappers.lambdaQuery(); + qw.eq(UserSuggestion::getDelFlag, 0); + Long uid = LoginHelper.getUserId(); + if (!isItDeptMember(uid)) { + qw.eq(UserSuggestion::getSubmitterId, uid); + } + if (query.getStatus() != null) qw.eq(UserSuggestion::getStatus, query.getStatus()); + if (query.getCategory() != null && !query.getCategory().isEmpty()) { + qw.eq(UserSuggestion::getCategory, query.getCategory()); + } + if (query.getTitle() != null && !query.getTitle().isEmpty()) { + qw.like(UserSuggestion::getTitle, query.getTitle()); + } + qw.orderByDesc(UserSuggestion::getCreateTime); + Page result = mapper.selectPage(pageQuery.build(), qw); + return TableDataInfo.build(result); + } + + @PostMapping + public R submit(@RequestBody UserSuggestion body) { + Long uid = LoginHelper.getUserId(); + String name = LoginHelper.getNickName(); + body.setFeedbackId(null); + body.setSubmitterId(uid); + body.setSubmitterName(name); + body.setStatus(0); + body.setCreateBy(name); + body.setCreateTime(new Date()); + body.setDelFlag(0); + mapper.insert(body); + + List itUsers = userMapper.selectList( + Wrappers.lambdaQuery() + .eq(SysUser::getDeptId, IT_DEPT_ID) + .eq(SysUser::getDelFlag, "0")); + String title = "新的修改意见"; + String desc = String.format("[%s] %s", name == null ? "用户" : name, + body.getTitle() == null ? "未命名" : body.getTitle()); + for (SysUser u : itUsers) { + if (u.getUserId() == null || u.getUserId().equals(uid)) continue; + imSendService.sendToOaUser(u.getUserId(), title, desc, + "suggestion", body.getFeedbackId(), + "/system/feedback?id=" + body.getFeedbackId()); + } + return R.ok(); + } + + @PutMapping("/{id}/accept") + public R accept(@PathVariable Long id, @RequestParam(required = false) String remark) { + UserSuggestion fb = mapper.selectById(id); + if (fb == null) return R.fail("不存在"); + if (!isItDeptMember(LoginHelper.getUserId())) return R.fail("仅信息化部可操作"); + fb.setStatus(1); + fb.setHandlerId(LoginHelper.getUserId()); + fb.setHandlerName(LoginHelper.getNickName()); + fb.setAcceptRemark(remark); + fb.setAcceptTime(new Date()); + mapper.updateById(fb); + if (fb.getSubmitterId() != null) { + imSendService.sendToOaUser(fb.getSubmitterId(), + "您的意见已受理", + String.format("[%s] 受理了您的意见:%s%s", + fb.getHandlerName() == null ? "信息化部" : fb.getHandlerName(), + fb.getTitle(), + remark == null || remark.isEmpty() ? "" : "(备注:" + remark + ")"), + "suggestion", id, "/system/feedback?id=" + id); + } + return R.ok(); + } + + @PutMapping("/{id}/finish") + public R finish(@PathVariable Long id, @RequestParam(required = false) String remark) { + UserSuggestion fb = mapper.selectById(id); + if (fb == null) return R.fail("不存在"); + if (!isItDeptMember(LoginHelper.getUserId())) return R.fail("仅信息化部可操作"); + fb.setStatus(2); + fb.setFinishTime(new Date()); + if (remark != null) fb.setAcceptRemark(remark); + mapper.updateById(fb); + if (fb.getSubmitterId() != null) { + imSendService.sendToOaUser(fb.getSubmitterId(), + "您的意见已完成", + String.format("[%s] 已处理完毕:%s", fb.getHandlerName(), fb.getTitle()), + "suggestion", id, "/system/feedback?id=" + id); + } + return R.ok(); + } + + @PutMapping("/{id}/close") + public R close(@PathVariable Long id, @RequestParam(required = false) String remark) { + UserSuggestion fb = mapper.selectById(id); + if (fb == null) return R.fail("不存在"); + Long uid = LoginHelper.getUserId(); + if (!isItDeptMember(uid) && !uid.equals(fb.getSubmitterId())) return R.fail("无权关闭"); + fb.setStatus(3); + if (remark != null) fb.setAcceptRemark(remark); + mapper.updateById(fb); + return R.ok(); + } + + @GetMapping("/isItMember") + public R isItMember() { + return R.ok(isItDeptMember(LoginHelper.getUserId())); + } + + private boolean isItDeptMember(Long userId) { + if (userId == null) return false; + SysUser u = userMapper.selectById(userId); + return u != null && IT_DEPT_ID.equals(u.getDeptId()); + } +} diff --git a/ruoyi-oa/src/main/java/com/ruoyi/oa/suggestion/mapper/UserSuggestionMapper.java b/ruoyi-oa/src/main/java/com/ruoyi/oa/suggestion/mapper/UserSuggestionMapper.java new file mode 100644 index 0000000..935a000 --- /dev/null +++ b/ruoyi-oa/src/main/java/com/ruoyi/oa/suggestion/mapper/UserSuggestionMapper.java @@ -0,0 +1,7 @@ +package com.ruoyi.oa.suggestion.mapper; + +import com.ruoyi.common.core.mapper.BaseMapperPlus; +import com.ruoyi.oa.suggestion.UserSuggestion; + +public interface UserSuggestionMapper extends BaseMapperPlus { +} diff --git a/ruoyi-oa/src/main/resources/mapper/oa/OaProjectScheduleMapper.xml b/ruoyi-oa/src/main/resources/mapper/oa/OaProjectScheduleMapper.xml index af1de2d..26ef22b 100644 --- a/ruoyi-oa/src/main/resources/mapper/oa/OaProjectScheduleMapper.xml +++ b/ruoyi-oa/src/main/resources/mapper/oa/OaProjectScheduleMapper.xml @@ -22,6 +22,13 @@ + + diff --git a/ruoyi-oa/src/main/resources/mapper/oa/OaRequirementsMapper.xml b/ruoyi-oa/src/main/resources/mapper/oa/OaRequirementsMapper.xml index 2a4e9ba..9247668 100644 --- a/ruoyi-oa/src/main/resources/mapper/oa/OaRequirementsMapper.xml +++ b/ruoyi-oa/src/main/resources/mapper/oa/OaRequirementsMapper.xml @@ -32,7 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT GROUP_CONCAT(CONCAT_WS('|', o.oss_id, COALESCE(o.original_name, o.file_name), o.url) ORDER BY FIND_IN_SET(o.oss_id, r.accessory) SEPARATOR ',,') FROM sys_oss o - WHERE r.accessory IS NOT NULL AND r.accessory <> '' + WHERE r.accessory IS NOT NULL AND r.accessory != '' AND FIND_IN_SET(o.oss_id, r.accessory) ) AS accessory_files FROM oa_requirements r @@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT GROUP_CONCAT(CONCAT_WS('|', o.oss_id, COALESCE(o.original_name, o.file_name), o.url) ORDER BY FIND_IN_SET(o.oss_id, r.accessory) SEPARATOR ',,') FROM sys_oss o - WHERE r.accessory IS NOT NULL AND r.accessory <> '' + WHERE r.accessory IS NOT NULL AND r.accessory != '' AND FIND_IN_SET(o.oss_id, r.accessory) ) AS accessory_files FROM oa_requirements r diff --git a/ruoyi-oa/src/main/resources/mapper/oa/SysOaWarehouseMasterMapper.xml b/ruoyi-oa/src/main/resources/mapper/oa/SysOaWarehouseMasterMapper.xml index 6a73288..4a78797 100644 --- a/ruoyi-oa/src/main/resources/mapper/oa/SysOaWarehouseMasterMapper.xml +++ b/ruoyi-oa/src/main/resources/mapper/oa/SysOaWarehouseMasterMapper.xml @@ -29,6 +29,8 @@ + + window.__MICRO_APP_ENVIRONMENT__ = true + + diff --git a/ruoyi-ui/public/openIM.wasm b/ruoyi-ui/public/openIM.wasm new file mode 100644 index 0000000..634293b Binary files /dev/null and b/ruoyi-ui/public/openIM.wasm differ diff --git a/ruoyi-ui/public/sql-wasm.wasm b/ruoyi-ui/public/sql-wasm.wasm new file mode 100755 index 0000000..18b392e Binary files /dev/null and b/ruoyi-ui/public/sql-wasm.wasm differ diff --git a/ruoyi-ui/public/wasm_exec.js b/ruoyi-ui/public/wasm_exec.js new file mode 100644 index 0000000..bc6f210 --- /dev/null +++ b/ruoyi-ui/public/wasm_exec.js @@ -0,0 +1,561 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +"use strict"; + +(() => { + const enosys = () => { + const err = new Error("not implemented"); + err.code = "ENOSYS"; + return err; + }; + + if (!globalThis.fs) { + let outputBuf = ""; + globalThis.fs = { + constants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused + writeSync(fd, buf) { + outputBuf += decoder.decode(buf); + const nl = outputBuf.lastIndexOf("\n"); + if (nl != -1) { + console.log(outputBuf.substring(0, nl)); + outputBuf = outputBuf.substring(nl + 1); + } + return buf.length; + }, + write(fd, buf, offset, length, position, callback) { + if (offset !== 0 || length !== buf.length || position !== null) { + callback(enosys()); + return; + } + const n = this.writeSync(fd, buf); + callback(null, n); + }, + chmod(path, mode, callback) { callback(enosys()); }, + chown(path, uid, gid, callback) { callback(enosys()); }, + close(fd, callback) { callback(enosys()); }, + fchmod(fd, mode, callback) { callback(enosys()); }, + fchown(fd, uid, gid, callback) { callback(enosys()); }, + fstat(fd, callback) { callback(enosys()); }, + fsync(fd, callback) { callback(null); }, + ftruncate(fd, length, callback) { callback(enosys()); }, + lchown(path, uid, gid, callback) { callback(enosys()); }, + link(path, link, callback) { callback(enosys()); }, + lstat(path, callback) { callback(enosys()); }, + mkdir(path, perm, callback) { callback(enosys()); }, + open(path, flags, mode, callback) { callback(enosys()); }, + read(fd, buffer, offset, length, position, callback) { callback(enosys()); }, + readdir(path, callback) { callback(enosys()); }, + readlink(path, callback) { callback(enosys()); }, + rename(from, to, callback) { callback(enosys()); }, + rmdir(path, callback) { callback(enosys()); }, + stat(path, callback) { callback(enosys()); }, + symlink(path, link, callback) { callback(enosys()); }, + truncate(path, length, callback) { callback(enosys()); }, + unlink(path, callback) { callback(enosys()); }, + utimes(path, atime, mtime, callback) { callback(enosys()); }, + }; + } + + if (!globalThis.process) { + globalThis.process = { + getuid() { return -1; }, + getgid() { return -1; }, + geteuid() { return -1; }, + getegid() { return -1; }, + getgroups() { throw enosys(); }, + pid: -1, + ppid: -1, + umask() { throw enosys(); }, + cwd() { throw enosys(); }, + chdir() { throw enosys(); }, + } + } + + if (!globalThis.crypto) { + throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)"); + } + + if (!globalThis.performance) { + throw new Error("globalThis.performance is not available, polyfill required (performance.now only)"); + } + + if (!globalThis.TextEncoder) { + throw new Error("globalThis.TextEncoder is not available, polyfill required"); + } + + if (!globalThis.TextDecoder) { + throw new Error("globalThis.TextDecoder is not available, polyfill required"); + } + + const encoder = new TextEncoder("utf-8"); + const decoder = new TextDecoder("utf-8"); + + globalThis.Go = class { + constructor() { + this.argv = ["js"]; + this.env = {}; + this.exit = (code) => { + if (code !== 0) { + console.warn("exit code:", code); + } + }; + this._exitPromise = new Promise((resolve) => { + this._resolveExitPromise = resolve; + }); + this._pendingEvent = null; + this._scheduledTimeouts = new Map(); + this._nextCallbackTimeoutID = 1; + + const setInt64 = (addr, v) => { + this.mem.setUint32(addr + 0, v, true); + this.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true); + } + + const setInt32 = (addr, v) => { + this.mem.setUint32(addr + 0, v, true); + } + + const getInt64 = (addr) => { + const low = this.mem.getUint32(addr + 0, true); + const high = this.mem.getInt32(addr + 4, true); + return low + high * 4294967296; + } + + const loadValue = (addr) => { + const f = this.mem.getFloat64(addr, true); + if (f === 0) { + return undefined; + } + if (!isNaN(f)) { + return f; + } + + const id = this.mem.getUint32(addr, true); + return this._values[id]; + } + + const storeValue = (addr, v) => { + const nanHead = 0x7FF80000; + + if (typeof v === "number" && v !== 0) { + if (isNaN(v)) { + this.mem.setUint32(addr + 4, nanHead, true); + this.mem.setUint32(addr, 0, true); + return; + } + this.mem.setFloat64(addr, v, true); + return; + } + + if (v === undefined) { + this.mem.setFloat64(addr, 0, true); + return; + } + + let id = this._ids.get(v); + if (id === undefined) { + id = this._idPool.pop(); + if (id === undefined) { + id = this._values.length; + } + this._values[id] = v; + this._goRefCounts[id] = 0; + this._ids.set(v, id); + } + this._goRefCounts[id]++; + let typeFlag = 0; + switch (typeof v) { + case "object": + if (v !== null) { + typeFlag = 1; + } + break; + case "string": + typeFlag = 2; + break; + case "symbol": + typeFlag = 3; + break; + case "function": + typeFlag = 4; + break; + } + this.mem.setUint32(addr + 4, nanHead | typeFlag, true); + this.mem.setUint32(addr, id, true); + } + + const loadSlice = (addr) => { + const array = getInt64(addr + 0); + const len = getInt64(addr + 8); + return new Uint8Array(this._inst.exports.mem.buffer, array, len); + } + + const loadSliceOfValues = (addr) => { + const array = getInt64(addr + 0); + const len = getInt64(addr + 8); + const a = new Array(len); + for (let i = 0; i < len; i++) { + a[i] = loadValue(array + i * 8); + } + return a; + } + + const loadString = (addr) => { + const saddr = getInt64(addr + 0); + const len = getInt64(addr + 8); + return decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len)); + } + + const timeOrigin = Date.now() - performance.now(); + this.importObject = { + _gotest: { + add: (a, b) => a + b, + }, + gojs: { + // Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters) + // may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported + // function. A goroutine can switch to a new stack if the current stack is too small (see morestack function). + // This changes the SP, thus we have to update the SP used by the imported function. + + // func wasmExit(code int32) + "runtime.wasmExit": (sp) => { + sp >>>= 0; + const code = this.mem.getInt32(sp + 8, true); + this.exited = true; + delete this._inst; + delete this._values; + delete this._goRefCounts; + delete this._ids; + delete this._idPool; + this.exit(code); + }, + + // func wasmWrite(fd uintptr, p unsafe.Pointer, n int32) + "runtime.wasmWrite": (sp) => { + sp >>>= 0; + const fd = getInt64(sp + 8); + const p = getInt64(sp + 16); + const n = this.mem.getInt32(sp + 24, true); + fs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n)); + }, + + // func resetMemoryDataView() + "runtime.resetMemoryDataView": (sp) => { + sp >>>= 0; + this.mem = new DataView(this._inst.exports.mem.buffer); + }, + + // func nanotime1() int64 + "runtime.nanotime1": (sp) => { + sp >>>= 0; + setInt64(sp + 8, (timeOrigin + performance.now()) * 1000000); + }, + + // func walltime() (sec int64, nsec int32) + "runtime.walltime": (sp) => { + sp >>>= 0; + const msec = (new Date).getTime(); + setInt64(sp + 8, msec / 1000); + this.mem.setInt32(sp + 16, (msec % 1000) * 1000000, true); + }, + + // func scheduleTimeoutEvent(delay int64) int32 + "runtime.scheduleTimeoutEvent": (sp) => { + sp >>>= 0; + const id = this._nextCallbackTimeoutID; + this._nextCallbackTimeoutID++; + this._scheduledTimeouts.set(id, setTimeout( + () => { + this._resume(); + while (this._scheduledTimeouts.has(id)) { + // for some reason Go failed to register the timeout event, log and try again + // (temporary workaround for https://github.com/golang/go/issues/28975) + console.warn("scheduleTimeoutEvent: missed timeout event"); + this._resume(); + } + }, + getInt64(sp + 8), + )); + this.mem.setInt32(sp + 16, id, true); + }, + + // func clearTimeoutEvent(id int32) + "runtime.clearTimeoutEvent": (sp) => { + sp >>>= 0; + const id = this.mem.getInt32(sp + 8, true); + clearTimeout(this._scheduledTimeouts.get(id)); + this._scheduledTimeouts.delete(id); + }, + + // func getRandomData(r []byte) + "runtime.getRandomData": (sp) => { + sp >>>= 0; + crypto.getRandomValues(loadSlice(sp + 8)); + }, + + // func finalizeRef(v ref) + "syscall/js.finalizeRef": (sp) => { + sp >>>= 0; + const id = this.mem.getUint32(sp + 8, true); + this._goRefCounts[id]--; + if (this._goRefCounts[id] === 0) { + const v = this._values[id]; + this._values[id] = null; + this._ids.delete(v); + this._idPool.push(id); + } + }, + + // func stringVal(value string) ref + "syscall/js.stringVal": (sp) => { + sp >>>= 0; + storeValue(sp + 24, loadString(sp + 8)); + }, + + // func valueGet(v ref, p string) ref + "syscall/js.valueGet": (sp) => { + sp >>>= 0; + const result = Reflect.get(loadValue(sp + 8), loadString(sp + 16)); + sp = this._inst.exports.getsp() >>> 0; // see comment above + storeValue(sp + 32, result); + }, + + // func valueSet(v ref, p string, x ref) + "syscall/js.valueSet": (sp) => { + sp >>>= 0; + Reflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32)); + }, + + // func valueDelete(v ref, p string) + "syscall/js.valueDelete": (sp) => { + sp >>>= 0; + Reflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16)); + }, + + // func valueIndex(v ref, i int) ref + "syscall/js.valueIndex": (sp) => { + sp >>>= 0; + storeValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16))); + }, + + // valueSetIndex(v ref, i int, x ref) + "syscall/js.valueSetIndex": (sp) => { + sp >>>= 0; + Reflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24)); + }, + + // func valueCall(v ref, m string, args []ref) (ref, bool) + "syscall/js.valueCall": (sp) => { + sp >>>= 0; + try { + const v = loadValue(sp + 8); + const m = Reflect.get(v, loadString(sp + 16)); + const args = loadSliceOfValues(sp + 32); + const result = Reflect.apply(m, v, args); + sp = this._inst.exports.getsp() >>> 0; // see comment above + storeValue(sp + 56, result); + this.mem.setUint8(sp + 64, 1); + } catch (err) { + sp = this._inst.exports.getsp() >>> 0; // see comment above + storeValue(sp + 56, err); + this.mem.setUint8(sp + 64, 0); + } + }, + + // func valueInvoke(v ref, args []ref) (ref, bool) + "syscall/js.valueInvoke": (sp) => { + sp >>>= 0; + try { + const v = loadValue(sp + 8); + const args = loadSliceOfValues(sp + 16); + const result = Reflect.apply(v, undefined, args); + sp = this._inst.exports.getsp() >>> 0; // see comment above + storeValue(sp + 40, result); + this.mem.setUint8(sp + 48, 1); + } catch (err) { + sp = this._inst.exports.getsp() >>> 0; // see comment above + storeValue(sp + 40, err); + this.mem.setUint8(sp + 48, 0); + } + }, + + // func valueNew(v ref, args []ref) (ref, bool) + "syscall/js.valueNew": (sp) => { + sp >>>= 0; + try { + const v = loadValue(sp + 8); + const args = loadSliceOfValues(sp + 16); + const result = Reflect.construct(v, args); + sp = this._inst.exports.getsp() >>> 0; // see comment above + storeValue(sp + 40, result); + this.mem.setUint8(sp + 48, 1); + } catch (err) { + sp = this._inst.exports.getsp() >>> 0; // see comment above + storeValue(sp + 40, err); + this.mem.setUint8(sp + 48, 0); + } + }, + + // func valueLength(v ref) int + "syscall/js.valueLength": (sp) => { + sp >>>= 0; + setInt64(sp + 16, parseInt(loadValue(sp + 8).length)); + }, + + // valuePrepareString(v ref) (ref, int) + "syscall/js.valuePrepareString": (sp) => { + sp >>>= 0; + const str = encoder.encode(String(loadValue(sp + 8))); + storeValue(sp + 16, str); + setInt64(sp + 24, str.length); + }, + + // valueLoadString(v ref, b []byte) + "syscall/js.valueLoadString": (sp) => { + sp >>>= 0; + const str = loadValue(sp + 8); + loadSlice(sp + 16).set(str); + }, + + // func valueInstanceOf(v ref, t ref) bool + "syscall/js.valueInstanceOf": (sp) => { + sp >>>= 0; + this.mem.setUint8(sp + 24, (loadValue(sp + 8) instanceof loadValue(sp + 16)) ? 1 : 0); + }, + + // func copyBytesToGo(dst []byte, src ref) (int, bool) + "syscall/js.copyBytesToGo": (sp) => { + sp >>>= 0; + const dst = loadSlice(sp + 8); + const src = loadValue(sp + 32); + if (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) { + this.mem.setUint8(sp + 48, 0); + return; + } + const toCopy = src.subarray(0, dst.length); + dst.set(toCopy); + setInt64(sp + 40, toCopy.length); + this.mem.setUint8(sp + 48, 1); + }, + + // func copyBytesToJS(dst ref, src []byte) (int, bool) + "syscall/js.copyBytesToJS": (sp) => { + sp >>>= 0; + const dst = loadValue(sp + 8); + const src = loadSlice(sp + 16); + if (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) { + this.mem.setUint8(sp + 48, 0); + return; + } + const toCopy = src.subarray(0, dst.length); + dst.set(toCopy); + setInt64(sp + 40, toCopy.length); + this.mem.setUint8(sp + 48, 1); + }, + + "debug": (value) => { + console.log(value); + }, + } + }; + } + + async run(instance) { + if (!(instance instanceof WebAssembly.Instance)) { + throw new Error("Go.run: WebAssembly.Instance expected"); + } + this._inst = instance; + this.mem = new DataView(this._inst.exports.mem.buffer); + this._values = [ // JS values that Go currently has references to, indexed by reference id + NaN, + 0, + null, + true, + false, + globalThis, + this, + ]; + this._goRefCounts = new Array(this._values.length).fill(Infinity); // number of references that Go has to a JS value, indexed by reference id + this._ids = new Map([ // mapping from JS values to reference ids + [0, 1], + [null, 2], + [true, 3], + [false, 4], + [globalThis, 5], + [this, 6], + ]); + this._idPool = []; // unused ids that have been garbage collected + this.exited = false; // whether the Go program has exited + + // Pass command line arguments and environment variables to WebAssembly by writing them to the linear memory. + let offset = 4096; + + const strPtr = (str) => { + const ptr = offset; + const bytes = encoder.encode(str + "\0"); + new Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes); + offset += bytes.length; + if (offset % 8 !== 0) { + offset += 8 - (offset % 8); + } + return ptr; + }; + + const argc = this.argv.length; + + const argvPtrs = []; + this.argv.forEach((arg) => { + argvPtrs.push(strPtr(arg)); + }); + argvPtrs.push(0); + + const keys = Object.keys(this.env).sort(); + keys.forEach((key) => { + argvPtrs.push(strPtr(`${key}=${this.env[key]}`)); + }); + argvPtrs.push(0); + + const argv = offset; + argvPtrs.forEach((ptr) => { + this.mem.setUint32(offset, ptr, true); + this.mem.setUint32(offset + 4, 0, true); + offset += 8; + }); + + // The linker guarantees global data starts from at least wasmMinDataAddr. + // Keep in sync with cmd/link/internal/ld/data.go:wasmMinDataAddr. + const wasmMinDataAddr = 4096 + 8192; + if (offset >= wasmMinDataAddr) { + throw new Error("total length of command line and environment variables exceeds limit"); + } + + this._inst.exports.run(argc, argv); + if (this.exited) { + this._resolveExitPromise(); + } + await this._exitPromise; + } + + _resume() { + if (this.exited) { + throw new Error("Go program has already exited"); + } + this._inst.exports.resume(); + if (this.exited) { + this._resolveExitPromise(); + } + } + + _makeFuncWrapper(id) { + const go = this; + return function () { + const event = { id: id, this: this, args: arguments }; + go._pendingEvent = event; + go._resume(); + return event.result; + }; + } + } +})(); diff --git a/ruoyi-ui/public/worker-legacy.js b/ruoyi-ui/public/worker-legacy.js new file mode 100644 index 0000000..11a3917 --- /dev/null +++ b/ruoyi-ui/public/worker-legacy.js @@ -0,0 +1 @@ +!function(){"use strict";var e=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,s=(t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,a=(e,t)=>{for(var r in t||(t={}))i.call(t,r)&&s(e,r,t[r]);if(n)for(var r of n(t))o.call(t,r)&&s(e,r,t[r]);return e},u=(e,n)=>t(e,r(n)),c=(e,t,r)=>(s(e,"symbol"!=typeof t?t+"":t,r),r);const l={CONNECT_TIMEOUT:{code:-32300,message:"Connect timeout"},APPLICATION_ERROR:{code:-32500,message:"Application error"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found"}};const f=class{constructor(e){c(this,"_event"),c(this,"_methods",{}),c(this,"_timeout",0),c(this,"_$connect",null),this._event=e.event,this._timeout=e.timeout||0,e.methods&&Object.entries(e.methods).forEach((([e,t])=>{this.registerMethod(e,t)})),this._event.onerror=e=>{const{code:t,message:r,data:n}=e;if(n.event&&Array.isArray(n.args)&&n.args.length){const e=n.args[0],i=this._getAckEventName(e.method),o={jsonrpc:"2.0",id:null==e?void 0:e.id,error:{code:t,message:r,data:e}};this._event.emit(i,o)}else console.error(e)},this.connect()}static uuid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}_getSynEventName(e){return`${f.EVENT.SYN_SIGN}${e}`}_getAckEventName(e){return`${f.EVENT.ACK_SIGN}${e}`}connect(e){return this._$connect||(this._$connect=new Promise(((t,r)=>{const n=e||this._timeout;let i;n&&(i=setTimeout((()=>{const e=u(a({},l.TIMEOUT),{data:{timeout:n}});r(e)}),n));const o=f.EVENT.CONNECT,s=this._getAckEventName(o),c=this._getSynEventName(o),d=()=>{clearTimeout(i),t()};this._event.on(s,d);this._event.on(c,(()=>{this._event.emit(s),d()})),this._event.emit(c)}))),this._$connect}registerMethod(e,t){if(this._methods[e])throw new Error(`${e} already registered`);this._methods[e]=t;const r=this._getSynEventName(e);this._event.on(r,(r=>{const n=this._getAckEventName(e);r.id?Promise.resolve(t(...r.params)).then((e=>{const t={jsonrpc:"2.0",result:e,id:r.id};this._event.emit(n,t)})).catch((e=>{const t={jsonrpc:"2.0",id:r.id,error:{code:(null==e?void 0:e.code)||l.APPLICATION_ERROR.code,message:(null==e?void 0:e.message)||l.APPLICATION_ERROR.message,data:null}};this._event.emit(n,t)})):t(...r.params)}))}removeMethod(e){this._methods[e]||delete this._methods[e];const t=this._getSynEventName(e);this._event.off(t)}invoke(e,...t){return new Promise(((r,n)=>{const i=t[t.length-1],o=i&&"object"==typeof i&&(Reflect.has(i,"isNotify")||Reflect.has(i,"timeout")),s=o?i:{isNotify:!1,timeout:0},c=o?t.slice(0,-1):t,d=this._getSynEventName(e),h=f.uuid(),_={jsonrpc:"2.0",method:e,params:c,id:h};if(this._event.emit(d,_),s.isNotify)r(void 0);else{const t=this._getAckEventName(e),i=s.timeout||this._timeout;let o;i&&(o=setTimeout((()=>{const e=u(a({},l.CONNECT_TIMEOUT),{data:{timeout:i}});n(e)}),i));const c=e=>{e.id===h&&(clearTimeout(o),this._event.off(t,c),e.error?n(e.error):r(e.result))};this._event.on(t,c)}}))}destroy(){Object.entries(this._methods).forEach((([e])=>{const t=this._getSynEventName(e);this._event.off(t)}));const e=this._getAckEventName(f.EVENT.CONNECT),t=this._getSynEventName(f.EVENT.CONNECT);this._event.off(t),this._event.off(e),this._event.destroy&&this._event.destroy()}};let d=f;c(d,"CODES",l),c(d,"EVENT",{SYN_SIGN:"syn:",ACK_SIGN:"ack:",CONNECT:"__rpc_connect_event",SYNC_METHODS:"__rpc_sync_methods_event"});const h={ErrorInit:10001,ErrorNoRecord:10002,ErrorDBTimeout:10003};var _;!function(e){e.Login="Login",e.OnConnectFailed="OnConnectFailed",e.OnConnectSuccess="OnConnectSuccess",e.OnConnecting="OnConnecting",e.OnKickedOffline="OnKickedOffline",e.OnSelfInfoUpdated="OnSelfInfoUpdated",e.OnUserTokenExpired="OnUserTokenExpired",e.OnUserTokenInvalid="OnUserTokenInvalid",e.OnProgress="OnProgress",e.OnRecvNewMessage="OnRecvNewMessage",e.OnRecvNewMessages="OnRecvNewMessages",e.OnRecvOnlineOnlyMessage="OnRecvOnlineOnlyMessage",e.OnRecvOfflineNewMessage="onRecvOfflineNewMessage",e.OnRecvOnlineOnlyMessages="OnRecvOnlineOnlyMessages",e.OnRecvOfflineNewMessages="onRecvOfflineNewMessages",e.OnRecvMessageRevoked="OnRecvMessageRevoked",e.OnNewRecvMessageRevoked="OnNewRecvMessageRevoked",e.OnRecvC2CReadReceipt="OnRecvC2CReadReceipt",e.OnRecvGroupReadReceipt="OnRecvGroupReadReceipt",e.OnConversationChanged="OnConversationChanged",e.OnNewConversation="OnNewConversation",e.OnConversationUserInputStatusChanged="OnConversationUserInputStatusChanged",e.OnSyncServerFailed="OnSyncServerFailed",e.OnSyncServerFinish="OnSyncServerFinish",e.OnSyncServerProgress="OnSyncServerProgress",e.OnSyncServerStart="OnSyncServerStart",e.OnTotalUnreadMessageCountChanged="OnTotalUnreadMessageCountChanged",e.OnBlackAdded="OnBlackAdded",e.OnBlackDeleted="OnBlackDeleted",e.OnFriendApplicationAccepted="OnFriendApplicationAccepted",e.OnFriendApplicationAdded="OnFriendApplicationAdded",e.OnFriendApplicationDeleted="OnFriendApplicationDeleted",e.OnFriendApplicationRejected="OnFriendApplicationRejected",e.OnFriendInfoChanged="OnFriendInfoChanged",e.OnFriendAdded="OnFriendAdded",e.OnFriendDeleted="OnFriendDeleted",e.OnJoinedGroupAdded="OnJoinedGroupAdded",e.OnJoinedGroupDeleted="OnJoinedGroupDeleted",e.OnGroupDismissed="OnGroupDismissed",e.OnGroupMemberAdded="OnGroupMemberAdded",e.OnGroupMemberDeleted="OnGroupMemberDeleted",e.OnGroupApplicationAdded="OnGroupApplicationAdded",e.OnGroupApplicationDeleted="OnGroupApplicationDeleted",e.OnGroupInfoChanged="OnGroupInfoChanged",e.OnGroupMemberInfoChanged="OnGroupMemberInfoChanged",e.OnGroupApplicationAccepted="OnGroupApplicationAccepted",e.OnGroupApplicationRejected="OnGroupApplicationRejected",e.UploadComplete="UploadComplete",e.OnRecvCustomBusinessMessage="OnRecvCustomBusinessMessage",e.OnUserStatusChanged="OnUserStatusChanged",e.OnUploadLogsProgress="OnUploadLogsProgress",e.OnReceiveNewInvitation="OnReceiveNewInvitation",e.OnInviteeAccepted="OnInviteeAccepted",e.OnInviteeRejected="OnInviteeRejected",e.OnInvitationCancelled="OnInvitationCancelled",e.OnHangUp="OnHangUp",e.OnInvitationTimeout="OnInvitationTimeout",e.OnInviteeAcceptedByOtherDevice="OnInviteeAcceptedByOtherDevice",e.OnInviteeRejectedByOtherDevice="OnInviteeRejectedByOtherDevice",e.OnStreamChange="OnStreamChange",e.OnRoomParticipantConnected="OnRoomParticipantConnected",e.OnRoomParticipantDisconnected="OnRoomParticipantDisconnected",e.OnReceiveCustomSignal="OnReceiveCustomSignal",e.UnUsedEvent="UnUsedEvent"}(_||(_={}));"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function g(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var m={exports:{}};m.exports=function(){var e=function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,r,n)}if("value"in i)return i.value;var s=i.get;return void 0!==s?s.call(n):void 0},t=function(){function e(e,t){for(var r=0;r1?t-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:null,_={isSquelBuilder:function(e){return e&&!!e._toParamString}},p=function(e){return!_.isSquelBuilder(e)||!e.options.rawNesting};_.DefaultQueryBuilderOptions={autoQuoteTableNames:!1,autoQuoteFieldNames:!1,autoQuoteAliasNames:!0,useAsForTableAliasNames:!1,nameQuoteCharacter:"`",tableAliasQuoteCharacter:"`",fieldAliasQuoteCharacter:'"',valueHandlers:[],parameterCharacter:"?",numberedParameters:!1,numberedParametersPrefix:"$",numberedParametersStartAt:1,replaceSingleQuotes:!1,singleQuoteReplacement:"''",separator:" ",stringFormatter:null,rawNesting:!1},_.globalValueHandlers=[],_.registerValueHandler=function(e,t){f(_.globalValueHandlers,e,t)},_.Cloneable=function(){function e(){o(this,e)}return t(e,[{key:"clone",value:function(){return a(new this.constructor,l(a({},this)))}}]),e}(),_.BaseBuilder=function(e){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this)),r=JSON.parse(JSON.stringify(_.DefaultQueryBuilderOptions));return["stringFormatter"].forEach((function(e){r[e]=_.DefaultQueryBuilderOptions[e]})),t.options=a({},r,e),t}return i(s,e),t(s,[{key:"registerValueHandler",value:function(e,t){return f(this.options.valueHandlers,e,t),this}},{key:"_sanitizeExpression",value:function(e){if(!_.isSquelBuilder(e)&&"string"!=typeof e)throw new Error("expression must be a string or builder instance");return e}},{key:"_sanitizeName",value:function(e,t){if("string"!=typeof e)throw new Error(t+" must be a string");return e}},{key:"_sanitizeField",value:function(e){return _.isSquelBuilder(e)||(e=this._sanitizeName(e,"field name")),e}},{key:"_sanitizeBaseBuilder",value:function(e){if(_.isSquelBuilder(e))return e;throw new Error("must be a builder instance")}},{key:"_sanitizeTable",value:function(e){if("string"!=typeof e)try{e=this._sanitizeBaseBuilder(e)}catch(e){throw new Error("table name must be a string or a builder")}else e=this._sanitizeName(e,"table");return e}},{key:"_sanitizeTableAlias",value:function(e){return this._sanitizeName(e,"table alias")}},{key:"_sanitizeFieldAlias",value:function(e){return this._sanitizeName(e,"field alias")}},{key:"_sanitizeLimitOffset",value:function(e){if(0>(e=parseInt(e))||isNaN(e))throw new Error("limit/offset must be >= 0");return e}},{key:"_sanitizeValue",value:function(e){var t=void 0===e?"undefined":r(e);if(null===e);else if("string"===t||"number"===t||"boolean"===t);else if(_.isSquelBuilder(e));else if(!d(e,this.options.valueHandlers,_.globalValueHandlers))throw new Error("field value must be a string, number, boolean, null or one of the registered custom value types");return e}},{key:"_escapeValue",value:function(e){return this.options.replaceSingleQuotes&&e?e.replace(/\'/g,this.options.singleQuoteReplacement):e}},{key:"_formatTableName",value:function(e){if(this.options.autoQuoteTableNames){var t=this.options.nameQuoteCharacter;e=""+t+e+t}return e}},{key:"_formatFieldAlias",value:function(e){if(this.options.autoQuoteAliasNames){var t=this.options.fieldAliasQuoteCharacter;e=""+t+e+t}return e}},{key:"_formatTableAlias",value:function(e){if(this.options.autoQuoteAliasNames){var t=this.options.tableAliasQuoteCharacter;e=""+t+e+t}return this.options.useAsForTableAliasNames?"AS "+e:e}},{key:"_formatFieldName",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.options.autoQuoteFieldNames){var r=this.options.nameQuoteCharacter;e=t.ignorePeriodsForFieldNameQuotes?""+r+e+r:e.split(".").map((function(e){return"*"===e?e:""+r+e+r})).join(".")}return e}},{key:"_formatCustomValue",value:function(e,t,r){var n=d(e,this.options.valueHandlers,_.globalValueHandlers);return n&&(e=n(e,t,r))&&e.rawNesting?{formatted:!0,rawNesting:!0,value:e.value}:{formatted:!!n,value:e}}},{key:"_formatValueForParamArray",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return c(e)?e.map((function(e){return t._formatValueForParamArray(e,r)})):this._formatCustomValue(e,!0,r).value}},{key:"_formatValueForQueryString",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this._formatCustomValue(e,!1,n),o=i.rawNesting,s=i.formatted,a=i.value;if(s)return o?a:this._applyNestingFormatting(a,p(e));if(c(a))a=a.map((function(e){return t._formatValueForQueryString(e)})),a=this._applyNestingFormatting(a.join(", "),p(a));else{var u=void 0===a?"undefined":r(a);if(null===a)a="NULL";else if("boolean"===u)a=a?"TRUE":"FALSE";else if(_.isSquelBuilder(a))a=this._applyNestingFormatting(a.toString(),p(a));else if("number"!==u){if("string"===u&&this.options.stringFormatter)return this.options.stringFormatter(a);a=n.dontQuote?""+a:"'"+this._escapeValue(a)+"'"}}return a}},{key:"_applyNestingFormatting",value:function(e){if(e&&"string"==typeof e&&(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&!this.options.rawNesting){var t="("===e.charAt(0)&&")"===e.charAt(e.length-1);if(t)for(var r=0,n=1;e.length-1>++r;){var i=e.charAt(r);if("("===i)n++;else if(")"===i&&1>--n){t=!1;break}}t||(e="("+e+")")}return e}},{key:"_buildString",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.nested,i=r.buildParameterized,o=r.formattingOptions;t=t||[],e=e||"";for(var s="",a=-1,u=[],l=this.options.parameterCharacter,f=0;e.length>f;)if(e.substr(f,l.length)===l){var d=t[++a];if(i)if(_.isSquelBuilder(d)){var h=d._toParamString({buildParameterized:i,nested:!0});s+=h.text,h.values.forEach((function(e){return u.push(e)}))}else c(d=this._formatValueForParamArray(d,o))?(s+="("+d.map((function(){return l})).join(", ")+")",d.forEach((function(e){return u.push(e)}))):(s+=l,u.push(d));else s+=this._formatValueForQueryString(d,o);f+=l.length}else s+=e.charAt(f),f++;return{text:this._applyNestingFormatting(s,!!n),values:u}}},{key:"_buildManyStrings",value:function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=[],i=[],o=0;e.length>o;++o){var s=e[o],a=t[o],u=this._buildString(s,a,{buildParameterized:r.buildParameterized,nested:!1}),c=u.text,l=u.values;n.push(c),l.forEach((function(e){return i.push(e)}))}return{text:(n=n.join(this.options.separator)).length?this._applyNestingFormatting(n,!!r.nested):"",values:i}}},{key:"_toParamString",value:function(e){throw new Error("Not yet implemented")}},{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._toParamString(e).text}},{key:"toParam",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._toParamString(a({},e,{buildParameterized:!0}))}}]),s}(_.Cloneable),_.Expression=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._nodes=[],t}return i(r,e),t(r,[{key:"and",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n1?t-1:0),n=1;n0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._nodes[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.type,l=u.expr,f=u.para,d=_.isSquelBuilder(l)?l._toParamString({buildParameterized:e.buildParameterized,nested:!0}):this._buildString(l,f,{buildParameterized:e.buildParameterized}),h=d.text,p=d.values;t.length&&t.push(c),t.push(h),p.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return t=t.join(" "),{text:this._applyNestingFormatting(t,!!e.nested),values:r}}}]),r}(_.BaseBuilder),_.Case=function(e){function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t));return u(e)&&(t=e,e=null),e&&(i._fieldName=i._sanitizeField(e)),i.options=a({},_.DefaultQueryBuilderOptions,t),i._cases=[],i._elseValue=null,i}return i(r,e),t(r,[{key:"when",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._cases[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.expression,f=c.values,d=c.result;t=s(t," ");var h=this._buildString(l,f,{buildParameterized:e.buildParameterized,nested:!0});t+="WHEN "+h.text+" THEN "+this._formatValueForQueryString(d),h.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return t.length?(t+=" ELSE "+this._formatValueForQueryString(this._elseValue)+" END",this._fieldName&&(t=this._fieldName+" "+t),t="CASE "+t):t=this._formatValueForQueryString(this._elseValue),{text:t,values:r}}}]),r}(_.BaseBuilder),_.Block=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e))}return i(r,e),t(r,[{key:"exposedMethods",value:function(){for(var e={},t=this;t;)Object.getOwnPropertyNames(t).forEach((function(r){"constructor"===r||"function"!=typeof t[r]||"_"===r.charAt(0)||_.Block.prototype[r]||(e[r]=t[r])})),t=Object.getPrototypeOf(t);return e}}]),r}(_.BaseBuilder),_.StringBlock=function(e){function r(e,t){o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return i._str=t,i}return i(r,e),t(r,[{key:"_toParamString",value:function(){return{text:this._str,values:[]}}}]),r}(_.Block),_.FunctionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._strings=[],t._values=[],t}return i(r,e),t(r,[{key:"function",value:function(e){this._strings.push(e);for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n0&&void 0!==arguments[0]?arguments[0]:{};return this._buildManyStrings(this._strings,this._values,e)}}]),r}(_.Block),_.registerValueHandler(_.FunctionBlock,(function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?e.toParam():e.toString()})),_.AbstractTableBlock=function(e){function r(e,t){o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return i._tables=[],i}return i(r,e),t(r,[{key:"_table",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t=t?this._sanitizeTableAlias(t):t,e=this._sanitizeTable(e),this.options.singleTable&&(this._tables=[]),this._tables.push({table:e,alias:t})}},{key:"_hasTable",value:function(){return 00&&void 0!==arguments[0]?arguments[0]:{},t="",r=[];if(this._hasTable()){var n=!0,i=!1,o=void 0;try{for(var a,u=this._tables[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.table,f=c.alias;t=s(t,", ");var d=void 0;if(_.isSquelBuilder(l)){var h=l._toParamString({buildParameterized:e.buildParameterized,nested:!0}),p=h.text,g=h.values;d=p,g.forEach((function(e){return r.push(e)}))}else d=this._formatTableName(l);f&&(d+=" "+this._formatTableAlias(f)),t+=d}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}this.options.prefix&&(t=this.options.prefix+" "+t)}return{text:t,values:r}}}]),r}(_.Block),_.TargetTableBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"target",value:function(e){this._table(e)}}]),r}(_.AbstractTableBlock),_.UpdateTableBlock=function(r){function s(){return o(this,s),n(this,(s.__proto__||Object.getPrototypeOf(s)).apply(this,arguments))}return i(s,r),t(s,[{key:"table",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._table(e,t)}},{key:"_toParamString",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this._hasTable())throw new Error("table() needs to be called");return e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t)}}]),s}(_.AbstractTableBlock),_.FromTableBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{prefix:"FROM"})))}return i(r,e),t(r,[{key:"from",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._table(e,t)}}]),r}(_.AbstractTableBlock),_.IntoTableBlock=function(r){function s(e){return o(this,s),n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,a({},e,{prefix:"INTO",singleTable:!0})))}return i(s,r),t(s,[{key:"into",value:function(e){this._table(e)}},{key:"_toParamString",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this._hasTable())throw new Error("into() needs to be called");return e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t)}}]),s}(_.AbstractTableBlock),_.GetFieldBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._fields=[],t}return i(r,e),t(r,[{key:"fields",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(c(e)){var r=!0,n=!1,i=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var a=o.value;this.field(a,null,t)}}catch(e){n=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(n)throw i}}}else for(var u in e){var l=e[u];this.field(u,l,t)}}},{key:"field",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t=t?this._sanitizeFieldAlias(t):t,e=this._sanitizeField(e),this._fields.filter((function(r){return r.name===e&&r.alias===t})).length)return this;this._fields.push({name:e,alias:t,options:r})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.queryBuilder,r=e.buildParameterized,n="",i=[],o=!0,a=!1,u=void 0;try{for(var c,l=this._fields[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var f=c.value;n=s(n,", ");var d=f.name,h=f.alias,p=f.options;if("string"==typeof d)n+=this._formatFieldName(d,p);else{var g=d._toParamString({nested:!0,buildParameterized:r});n+=g.text,g.values.forEach((function(e){return i.push(e)}))}h&&(n+=" AS "+this._formatFieldAlias(h))}}catch(e){a=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(a)throw u}}if(!n.length){var m=t&&t.getBlock(_.FromTableBlock);m&&m._hasTable()&&(n="*")}return{text:n,values:i}}}]),r}(_.Block),_.AbstractSetFieldBlock=function(e){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));return t._reset(),t}return i(s,e),t(s,[{key:"_reset",value:function(){this._fields=[],this._values=[[]],this._valueOptions=[[]]}},{key:"_set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this._values.length>1)throw new Error("Cannot set multiple rows of fields this way.");void 0!==t&&(t=this._sanitizeValue(t)),e=this._sanitizeField(e);var n=this._fields.indexOf(e);-1===n&&(this._fields.push(e),n=this._fields.length-1),this._values[0][n]=t,this._valueOptions[0][n]=r}},{key:"_setFields",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==(void 0===e?"undefined":r(e)))throw new Error("Expected an object but got "+(void 0===e?"undefined":r(e)));for(var n in e)this._set(n,e[n],t)}},{key:"_setFieldsRows",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!c(e))throw new Error("Expected an array of objects but got "+(void 0===e?"undefined":r(e)));this._reset();for(var n=0;e.length>n;++n){var i=e[n];for(var o in i){var s=i[o];o=this._sanitizeField(o),s=this._sanitizeValue(s);var a=this._fields.indexOf(o);if(00&&void 0!==arguments[0]?arguments[0]:{}).buildParameterized;if(0>=this._fields.length)throw new Error("set() needs to be called");for(var t="",r=[],n=0;ni.indexOf("=")&&(i=i+" = "+this.options.parameterCharacter);var a=this._buildString(i,[o],{buildParameterized:e,formattingOptions:this._valueOptions[0][n]});t+=a.text,a.values.forEach((function(e){return r.push(e)}))}return{text:"SET "+t,values:r}}}]),r}(_.AbstractSetFieldBlock),_.InsertFieldValueBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._set(e,t,r)}},{key:"setFields",value:function(e,t){this._setFields(e,t)}},{key:"setFieldsRows",value:function(e,t){this._setFieldsRows(e,t)}},{key:"_toParamString",value:function(){for(var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).buildParameterized,r=this._fields.map((function(t){return e._formatFieldName(t)})).join(", "),n=[],i=[],o=0;o0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[];if(this._fields.length&&this._query){var n=this._query._toParamString({buildParameterized:e.buildParameterized,nested:!0}),i=n.text,o=n.values;t="("+this._fields.join(", ")+") "+this._applyNestingFormatting(i),r=o}return{text:t,values:r}}}]),r}(_.Block),_.DistinctBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"distinct",value:function(){this._useDistinct=!0}},{key:"_toParamString",value:function(){return{text:this._useDistinct?"DISTINCT":"",values:[]}}}]),r}(_.Block),_.GroupByBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._groups=[],t}return i(r,e),t(r,[{key:"group",value:function(e){this._groups.push(this._sanitizeField(e))}},{key:"_toParamString",value:function(){return{text:this._groups.length?"GROUP BY "+this._groups.join(", "):"",values:[]}}}]),r}(_.Block),_.AbstractVerbSingleValueBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._value=null,t}return i(r,e),t(r,[{key:"_setValue",value:function(e){this._value=null!==e?this._sanitizeLimitOffset(e):e}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=null!==this._value?this.options.verb+" "+this.options.parameterCharacter:"",r=null!==this._value?[this._value]:[];return this._buildString(t,r,e)}}]),r}(_.Block),_.OffsetBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"OFFSET"})))}return i(r,e),t(r,[{key:"offset",value:function(e){this._setValue(e)}}]),r}(_.AbstractVerbSingleValueBlock),_.LimitBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"LIMIT"})))}return i(r,e),t(r,[{key:"limit",value:function(e){this._setValue(e)}}]),r}(_.AbstractVerbSingleValueBlock),_.AbstractConditionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._conditions=[],t}return i(r,e),t(r,[{key:"_condition",value:function(e){e=this._sanitizeExpression(e);for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._conditions[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.expr,l=u.values,f=_.isSquelBuilder(c)?c._toParamString({buildParameterized:e.buildParameterized}):this._buildString(c,l,{buildParameterized:e.buildParameterized});f.text.length&&t.push(f.text),f.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return t.length&&(t=t.join(") AND (")),{text:t.length?this.options.verb+" ("+t+")":"",values:r}}}]),r}(_.Block),_.WhereBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"WHERE"})))}return i(r,e),t(r,[{key:"where",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n1?t-1:0),n=1;n2?r-2:0),i=2;i0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._orders[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var l=a.value,f=l.field,d=l.dir,h=l.values;t=s(t,", ");var _=this._buildString(f,h,{buildParameterized:e.buildParameterized});t+=_.text,c(_.values)&&_.values.forEach((function(e){return r.push(e)})),null!==d&&(t+=" "+d)}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t.length?"ORDER BY "+t:"",values:r}}}]),r}(_.Block),_.JoinBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._joins=[],t}return i(r,e),t(r,[{key:"join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"INNER";e=this._sanitizeTable(e,!0),t=t?this._sanitizeTableAlias(t):t,r=r?this._sanitizeExpression(r):r,this._joins.push({type:n,table:e,alias:t,condition:r})}},{key:"left_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"LEFT")}},{key:"right_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"RIGHT")}},{key:"outer_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"OUTER")}},{key:"left_outer_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"LEFT OUTER")}},{key:"full_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"FULL")}},{key:"cross_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"CROSS")}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._joins[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.type,f=c.table,d=c.alias,h=c.condition;t=s(t,this.options.separator);var p=void 0;if(_.isSquelBuilder(f)){var g=f._toParamString({buildParameterized:e.buildParameterized,nested:!0});g.values.forEach((function(e){return r.push(e)})),p=g.text}else p=this._formatTableName(f);if(t+=l+" JOIN "+p,d&&(t+=" "+this._formatTableAlias(d)),h){t+=" ON ";var m=void 0;m=_.isSquelBuilder(h)?h._toParamString({buildParameterized:e.buildParameterized}):this._buildString(h,[],{buildParameterized:e.buildParameterized}),t+=this._applyNestingFormatting(m.text),m.values.forEach((function(e){return r.push(e)}))}}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t,values:r}}}]),r}(_.Block),_.UnionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._unions=[],t}return i(r,e),t(r,[{key:"union",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"UNION";e=this._sanitizeTable(e),this._unions.push({type:t,table:e})}},{key:"union_all",value:function(e){this.union(e,"UNION ALL")}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._unions[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.type,f=c.table;t=s(t,this.options.separator);var d=void 0;if(f instanceof _.BaseBuilder){var h=f._toParamString({buildParameterized:e.buildParameterized,nested:!0});d=h.text,h.values.forEach((function(e){return r.push(e)}))}else t=this._formatTableName(f);t+=l+" "+d}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t,values:r}}}]),r}(_.Block),_.QueryBuilder=function(r){function s(e,t){o(this,s);var r=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));r.blocks=t||[];var i=!0,a=!1,u=void 0;try{for(var c,l=r.blocks[Symbol.iterator]();!(i=(c=l.next()).done);i=!0){var f=c.value,d=f.exposedMethods();for(var h in d){var _=d[h];if(void 0!==r[h])throw new Error("Builder already has a builder method called: "+h);!function(e,t,n){r[t]=function(){for(var t=arguments.length,i=Array(t),o=0;o0&&void 0!==arguments[0]?arguments[0]:{};t=a({},this.options,t);var r=this.blocks.map((function(r){return r._toParamString({buildParameterized:t.buildParameterized,queryBuilder:e})})),n=r.map((function(e){return e.text})),i=r.map((function(e){return e.values})),o=n.filter((function(e){return 01&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"SELECT"),new _.FunctionBlock(e),new _.DistinctBlock(e),new _.GetFieldBlock(e),new _.FromTableBlock(e),new _.JoinBlock(e),new _.WhereBlock(e),new _.GroupByBlock(e),new _.HavingBlock(e),new _.OrderByBlock(e),new _.LimitBlock(e),new _.OffsetBlock(e),new _.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder),_.Update=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"UPDATE"),new _.UpdateTableBlock(e),new _.SetFieldBlock(e),new _.WhereBlock(e),new _.OrderByBlock(e),new _.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder),_.Delete=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"DELETE"),new _.TargetTableBlock(e),new _.FromTableBlock(a({},e,{singleTable:!0})),new _.JoinBlock(e),new _.WhereBlock(e),new _.OrderByBlock(e),new _.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder),_.Insert=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"INSERT"),new _.IntoTableBlock(e),new _.InsertFieldValueBlock(e),new _.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder);var g={VERSION:"5.13.0",flavour:h,expr:function(e){return new _.Expression(e)},case:function(e,t){return new _.Case(e,t)},select:function(e,t){return new _.Select(e,t)},update:function(e,t){return new _.Update(e,t)},insert:function(e,t){return new _.Insert(e,t)},delete:function(e,t){return new _.Delete(e,t)},str:function(){var e=new _.FunctionBlock;return e.function.apply(e,arguments),e},rstr:function(){var e=new _.FunctionBlock({rawNesting:!0});return e.function.apply(e,arguments),e},registerValueHandler:_.registerValueHandler};return g.remove=g.delete,g.cls=_,g}var p=_();return p.flavours={},p.useFlavour=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!e)return p;if(p.flavours[e]instanceof Function){var t=_(e);return p.flavours[e].call(null,t),t.flavours=p.flavours,t.useFlavour=p.useFlavour,t}throw new Error("Flavour not available: "+e)},p.flavours.mssql=function(r){var u=r.cls;u.DefaultQueryBuilderOptions.replaceSingleQuotes=!0,u.DefaultQueryBuilderOptions.autoQuoteAliasNames=!1,u.DefaultQueryBuilderOptions.numberedParametersPrefix="@",r.registerValueHandler(Date,(function(e){return"'"+e.getUTCFullYear()+"-"+(e.getUTCMonth()+1)+"-"+e.getUTCDate()+" "+e.getUTCHours()+":"+e.getUTCMinutes()+":"+e.getUTCSeconds()+"'"})),u.MssqlLimitOffsetTopBlock=function(e){function r(e){o(this,r);var s=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));s._limits=null,s._offsets=null;var a=function(e){e=this._sanitizeLimitOffset(e),this._parent._limits=e};return s.ParentBlock=function(e){function t(e){o(this,t);var r=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e.options));return r._parent=e,r}return i(t,e),t}(u.Block),s.LimitBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.limit=a,t}return i(r,e),t(r,[{key:"_toParamString",value:function(){var e="";return this._parent._limits&&this._parent._offsets&&(e="FETCH NEXT "+this._parent._limits+" ROWS ONLY"),{text:e,values:[]}}}]),r}(s.ParentBlock),s.TopBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.top=a,t}return i(r,e),t(r,[{key:"_toParamString",value:function(){var e="";return this._parent._limits&&!this._parent._offsets&&(e="TOP ("+this._parent._limits+")"),{text:e,values:[]}}}]),r}(s.ParentBlock),s.OffsetBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"offset",value:function(e){this._parent._offsets=this._sanitizeLimitOffset(e)}},{key:"_toParamString",value:function(){var e="";return this._parent._offsets&&(e="OFFSET "+this._parent._offsets+" ROWS"),{text:e,values:[]}}}]),r}(s.ParentBlock),s}return i(r,e),t(r,[{key:"LIMIT",value:function(){return new this.LimitBlock(this)}},{key:"TOP",value:function(){return new this.TopBlock(this)}},{key:"OFFSET",value:function(){return new this.OffsetBlock(this)}}]),r}(u.Block),u.MssqlUpdateTopBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._limits=null,t.limit=t.top=function(e){t._limits=t._sanitizeLimitOffset(e)},t}return i(r,e),t(r,[{key:"_toParamString",value:function(){return{text:this._limits?"TOP ("+this._limits+")":"",values:[]}}}]),r}(u.Block),u.MssqlInsertFieldValueBlock=function(r){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));return t._outputs=[],t}return i(s,r),t(s,[{key:"output",value:function(e){var t=this;"string"==typeof e?this._outputs.push("INSERTED."+this._sanitizeField(e)):e.forEach((function(e){t._outputs.push("INSERTED."+t._sanitizeField(e))}))}},{key:"_toParamString",value:function(t){var r=e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t);if(r.text.length&&01&&void 0!==arguments[1]?arguments[1]:null;e=this._sanitizeField(e),t=t?this._sanitizeFieldAlias(t):t,this._outputs.push({name:this.options.forDelete?"DELETED."+e:"INSERTED."+e,alias:t})}},{key:"_toParamString",value:function(e){var t="";if(this._outputs.length){var r=!0,n=!1,i=void 0;try{for(var o,a=this._outputs[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var u=o.value;t=s(t,", "),t+=u.name,u.alias&&(t+=" AS "+this._formatFieldAlias(u.alias))}}catch(e){n=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(n)throw i}}t="OUTPUT "+t}return{text:t,values:[]}}}]),r}(u.Block),u.Select=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;o(this,t);var i=new u.MssqlLimitOffsetTopBlock(e);return r=r||[new u.StringBlock(e,"SELECT"),new u.DistinctBlock(e),i.TOP(),new u.GetFieldBlock(e),new u.FromTableBlock(e),new u.JoinBlock(e),new u.WhereBlock(e),new u.GroupByBlock(e),new u.OrderByBlock(e),i.OFFSET(),i.LIMIT(),new u.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Update=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"UPDATE"),new u.MssqlUpdateTopBlock(e),new u.UpdateTableBlock(e),new u.SetFieldBlock(e),new u.MssqlUpdateDeleteOutputBlock(e),new u.WhereBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Delete=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"DELETE"),new u.TargetTableBlock(e),new u.FromTableBlock(a({},e,{singleTable:!0})),new u.JoinBlock(e),new u.MssqlUpdateDeleteOutputBlock(a({},e,{forDelete:!0})),new u.WhereBlock(e),new u.OrderByBlock(e),new u.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Insert=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"INSERT"),new u.IntoTableBlock(e),new u.MssqlInsertFieldValueBlock(e),new u.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder)},p.flavours.mysql=function(e){var r=e.cls;r.MysqlOnDuplicateKeyUpdateBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"onDupUpdate",value:function(e,t,r){this._set(e,t,r)}},{key:"_toParamString",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=0;n1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.StringBlock(e,"INSERT"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e),new r.MysqlOnDuplicateKeyUpdateBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Replace=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.StringBlock(e,"REPLACE"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),e.replace=function(e,t){return new r.Replace(e,t)}},p.flavours.postgres=function(e){var r=e.cls;r.DefaultQueryBuilderOptions.numberedParameters=!0,r.DefaultQueryBuilderOptions.numberedParametersStartAt=1,r.DefaultQueryBuilderOptions.autoQuoteAliasNames=!1,r.DefaultQueryBuilderOptions.useAsForTableAliasNames=!0,r.PostgresOnConflictKeyUpdateBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"onConflict",value:function(e,t){var r=this;this._onConflict=!0,e&&(c(e)||(e=[e]),this._dupFields=e.map(this._sanitizeField.bind(this)),t&&Object.keys(t).forEach((function(e){r._set(e,t[e])})))}},{key:"_toParamString",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=0;n1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t=t?this._sanitizeFieldAlias(t):t,e=this._sanitizeField(e),this._fields.filter((function(r){return r.name===e&&r.alias===t})).length)return this;this._fields.push({name:e,alias:t,options:r})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.queryBuilder;var t=e.buildParameterized,r="",n=[],i=!0,o=!1,a=void 0;try{for(var u,c=this._fields[Symbol.iterator]();!(i=(u=c.next()).done);i=!0){var l=u.value;r=s(r,", ");var f=l.name,d=l.alias,h=l.options;if("string"==typeof f)r+=this._formatFieldName(f,h);else{var _=f._toParamString({nested:!0,buildParameterized:t});r+=_.text,_.values.forEach((function(e){return n.push(e)}))}d&&(r+=" AS "+this._formatFieldAlias(d))}}catch(e){o=!0,a=e}finally{try{!i&&c.return&&c.return()}finally{if(o)throw a}}return{text:r.length>0?"RETURNING "+r:"",values:n}}}]),r}(r.Block),r.WithBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._tables=[],t}return i(r,e),t(r,[{key:"with",value:function(e,t){this._tables.push({alias:e,table:t})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._tables[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.alias,l=u.table._toParamString({buildParameterized:e.buildParameterized,nested:!0});t.push(c+" AS "+l.text),l.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return{text:t.length?"WITH "+t.join(", "):"",values:r}}}]),r}(r.Block),r.DistinctOnBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._distinctFields=[],t}return i(r,e),t(r,[{key:"distinct",value:function(){var e=this;this._useDistinct=!0;for(var t=arguments.length,r=Array(t),n=0;n1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"SELECT"),new r.FunctionBlock(e),new r.DistinctOnBlock(e),new r.GetFieldBlock(e),new r.FromTableBlock(e),new r.JoinBlock(e),new r.WhereBlock(e),new r.GroupByBlock(e),new r.HavingBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.OffsetBlock(e),new r.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Insert=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"INSERT"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e),new r.PostgresOnConflictKeyUpdateBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Update=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"UPDATE"),new r.UpdateTableBlock(e),new r.SetFieldBlock(e),new r.FromTableBlock(e),new r.WhereBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Delete=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"DELETE"),new r.TargetTableBlock(e),new r.FromTableBlock(a({},e,{singleTable:!0})),new r.JoinBlock(e),new r.WhereBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder)},p}();var v=p(m.exports);function y(e,t){!function(e,t){e.exec(`\n create table if not exists 'chat_logs_${t}' (\n 'client_msg_id' char(32),\n 'server_msg_id' char(32),\n 'send_id' char(32),\n 'recv_id' char(32),\n 'sender_platform_id' smallint,\n 'sender_nick_name' varchar(255),\n 'sender_face_url' varchar(255),\n 'session_type' smallint,\n 'msg_from' smallint,\n 'content_type' smallint,\n 'content' varchar(1000),\n 'is_read' tinyint(1),\n 'status' smallint,\n 'seq' int DEFAULT 0,\n 'send_time' int,\n 'create_time' int,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n 'local_ex' varchar(1024),\n 'is_react' tinyint(1),\n 'is_external_extensions' tinyint(1),\n 'msg_first_modify_time' int,\n PRIMARY KEY ('client_msg_id')\n );\n `)}(e,t)}function b(e){return e.exec("\n select * from local_super_groups;\n ")}function w(e,t){const r=v.insert().into("local_friends").setFields(t).toString();return e.exec(r)}function E(e,t){const r=v.insert().into("local_groups").setFields(t).toString();return e.exec(r)}function O(e){return e.exec("\n SELECT * FROM local_groups\n ")}function S(e,t,r){return e.exec(`INSERT INTO local_notification_seqs (conversation_id, seq) VALUES ("${t}", ${r});`)}function k(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_stranger\n WHERE user_id = (${r.join(",")})\n `)}function R(e){return e.exec("\n SELECT * FROM local_app_sdk_version LIMIT 1\n ")}function N(e,t,r){return e.exec(`\n SELECT * FROM local_sync_version WHERE table_name = "${t}" AND entity_id = "${r}"\n `)}function M(e,t,r){let n=e;return"object"==typeof e&&(n=JSON.stringify(e)),{data:void 0!==e?n:"{}",errCode:t||0,errMsg:r||""}}const x=[["user_id","userID"],["group_id","groupID"],["client_msg_id","clientMsgID"],["server_msg_id","serverMsgID"],["send_id","sendID"],["recv_id","recvID"],["sender_platform_id","senderPlatformID"],["sender_nick_name","senderNickname"],["sender_face_url","senderFaceURL"],["session_type","sessionType"],["msg_from","msgFrom"],["content_type","contentType"],["content","content"],["is_read","isRead"],["is_react","isReact"],["is_external_extensions","isExternalExtensions"],["msg_first_modify_time","msgFirstModifyTime"],["status","status"],["seq","seq"],["send_time","sendTime"],["create_time","createTime"],["attached_info","attachedInfo"],["ex","ex"],["face_url","faceURL"],["creator_user_id","creatorUserID"],["conversation_id","conversationID"],["owner_user_id","ownerUserID"],["notification_user_id","notificationUserID"],["operator_user_id","operatorUserID"],["from_face_url","fromFaceURL"],["from_user_id","fromUserID"],["from_gender","fromGender"],["from_nickname","fromNickname"],["to_user_id","toUserID"],["to_nickname","toNickname"],["to_face_url","toFaceURL"],["to_gender","toGender"],["req_msg","reqMsg"],["handle_msg","handleMsg"],["handle_time","handleTime"],["handle_result","handleResult"],["handler_user_id","handlerUserID"],["handle_user_id","handleUserID"],["inviter_user_id","inviterUserID"],["mute_end_time","muteEndTime"],["role_level","roleLevel"],["join_time","joinTime"],["join_source","joinSource"],["friend_user_id","friendUserID"],["recv_msg_opt","recvMsgOpt"],["group_at_type","groupAtType"],["latest_msg_send_time","latestMsgSendTime"],["draft_text_time","draftTextTime"],["is_private_chat","isPrivateChat"],["is_not_in_group","isNotInGroup"],["update_unread_count_time","updateUnreadCountTime"],["is_msg_destruct","isMsgDestruct"],["msg_destruct_time","msgDestructTime"],["part_hash","partHash"],["upload_id","uploadID"],["upload_info","uploadInfo"],["expire_time","expireTime"],["entity_id","entityID"],["version_id","versionID"],["display_is_read","displayIsRead"]];function I(e){const t=function(e){const t=x.find((t=>t[0]===e));if(t)return t[1]}(e);if(t)return t;const r=[];let n=-2;for(let t=0;tt[1]===e));if(t)return t[0]}(e);if(t)return t;const r=[];for(let t=0;t{const o={};i.forEach(((i,s)=>{let a=i,u=e[s];"CamelCase"===t&&(a=I(i)),"SnakeCase"===t&&(a=A(i)),r.find((e=>e===a))&&(u=!!u),a=n[i]||a,o[a]=u})),s.push(o)})),s}function B(e,t=!0){const r={};return Object.keys(e).forEach((n=>{let i=e[n];t&&function(e){return"string"==typeof e}(i)&&(i=function(e,t={backslashSupported:!1}){if(null==e)throw new Error("Need to pass a valid string");if(!(t=t||{}).backslashSupported)return"'"+e.replace(/'/g,"''")+"'";const r=T,n=C;let i,o=r.lastIndex=0,s="";for(;i=r.exec(e);)s+=e.slice(o,i.index)+n[i[0]],o=r.lastIndex;return 0===o?"'"+e+"'":o{const i=t[n]||n;r[i]=e[n]})),r}var D="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function $(){throw new Error("setTimeout has not been defined")}function L(){throw new Error("clearTimeout has not been defined")}var U=$,q=L;function j(e){if(U===setTimeout)return setTimeout(e,0);if((U===$||!U)&&setTimeout)return U=setTimeout,setTimeout(e,0);try{return U(e,0)}catch(t){try{return U.call(null,e,0)}catch(t){return U.call(this,e,0)}}}"function"==typeof D.setTimeout&&(U=setTimeout),"function"==typeof D.clearTimeout&&(q=clearTimeout);var J,z=[],W=!1,H=-1;function G(){W&&J&&(W=!1,J.length?z=J.concat(z):H=-1,z.length&&Y())}function Y(){if(!W){var e=j(G);W=!0;for(var t=z.length;t;){for(J=z,z=[];++H1)for(var r=1;r>18&63]+ue[i>>12&63]+ue[i>>6&63]+ue[63&i]);return o.join("")}function _e(e){var t;fe||de();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=ue[t>>2],i+=ue[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=ue[t>>10],i+=ue[t>>4&63],i+=ue[t<<2&63],i+="="),o.push(i),o.join("")}function pe(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,l=-7,f=r?i-1:0,d=r?-1:1,h=e[t+f];for(f+=d,o=h&(1<<-l)-1,h>>=-l,l+=a;l>0;o=256*o+e[t+f],f+=d,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+e[t+f],f+=d,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,n),o-=c}return(h?-1:1)*s*Math.pow(2,o-n)}function ge(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,l=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:o-1,_=n?1:-1,p=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+f>=1?d/u:d*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(t*u-1)*Math.pow(2,i),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;e[r+h]=255&a,h+=_,a/=256,i-=8);for(s=s<0;e[r+h]=255&s,h+=_,s/=256,c-=8);e[r+h-_]|=128*p}var me={}.toString,ve=Array.isArray||function(e){return"[object Array]"==me.call(e)};function ye(){return we.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function be(e,t){if(ye()=ye())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ye().toString(16)+" bytes");return 0|e}function Ne(e){return!(null==e||!e._isBuffer)}function Me(e,t){if(Ne(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return tt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return rt(e).length;default:if(n)return tt(e).length;t=(""+t).toLowerCase(),n=!0}}function xe(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return ze(this,t,r);case"utf8":case"utf-8":return Ue(this,t,r);case"ascii":return je(this,t,r);case"latin1":case"binary":return Je(this,t,r);case"base64":return Le(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return We(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Ie(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Ae(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=we.from(t,n)),Ne(t))return 0===t.length?-1:Te(e,t,r,n,i);if("number"==typeof t)return t&=255,we.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Te(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Te(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var f=!0,d=0;di&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function Le(e,t,r){return 0===t&&r===e.length?_e(e):_e(e.slice(t,r))}function Ue(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+f<=r)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(l=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=f}return function(e){var t=e.length;if(t<=qe)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},we.prototype.compare=function(e,t,r,n,i){if(!Ne(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),c=e.slice(t,r),l=0;li)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return Ce(this,e,t,r);case"utf8":case"utf-8":return Fe(this,e,t,r);case"ascii":return Be(this,e,t,r);case"latin1":case"binary":return Pe(this,e,t,r);case"base64":return De(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $e(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},we.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var qe=4096;function je(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function Ge(e,t,r,n,i,o){if(!Ne(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Ye(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Ve(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Qe(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ke(e,t,r,n,i){return i||Qe(e,0,r,4),ge(e,t,r,n,23,4),r+4}function Xe(e,t,r,n,i){return i||Qe(e,0,r,8),ge(e,t,r,n,52,8),r+8}we.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},we.prototype.readUInt8=function(e,t){return t||He(e,1,this.length),this[e]},we.prototype.readUInt16LE=function(e,t){return t||He(e,2,this.length),this[e]|this[e+1]<<8},we.prototype.readUInt16BE=function(e,t){return t||He(e,2,this.length),this[e]<<8|this[e+1]},we.prototype.readUInt32LE=function(e,t){return t||He(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},we.prototype.readUInt32BE=function(e,t){return t||He(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},we.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||He(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},we.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||He(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},we.prototype.readInt8=function(e,t){return t||He(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},we.prototype.readInt16LE=function(e,t){t||He(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},we.prototype.readInt16BE=function(e,t){t||He(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},we.prototype.readInt32LE=function(e,t){return t||He(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},we.prototype.readInt32BE=function(e,t){return t||He(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},we.prototype.readFloatLE=function(e,t){return t||He(e,4,this.length),pe(this,e,!0,23,4)},we.prototype.readFloatBE=function(e,t){return t||He(e,4,this.length),pe(this,e,!1,23,4)},we.prototype.readDoubleLE=function(e,t){return t||He(e,8,this.length),pe(this,e,!0,52,8)},we.prototype.readDoubleBE=function(e,t){return t||He(e,8,this.length),pe(this,e,!1,52,8)},we.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Ge(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},we.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,1,255,0),we.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},we.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,65535,0),we.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ye(this,e,t,!0),t+2},we.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,65535,0),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ye(this,e,t,!1),t+2},we.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,4294967295,0),we.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ve(this,e,t,!0),t+4},we.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,4294967295,0),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ve(this,e,t,!1),t+4},we.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Ge(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},we.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Ge(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},we.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,1,127,-128),we.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},we.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,32767,-32768),we.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ye(this,e,t,!0),t+2},we.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,32767,-32768),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ye(this,e,t,!1),t+2},we.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,2147483647,-2147483648),we.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ve(this,e,t,!0),t+4},we.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ve(this,e,t,!1),t+4},we.prototype.writeFloatLE=function(e,t,r){return Ke(this,e,t,!0,r)},we.prototype.writeFloatBE=function(e,t,r){return Ke(this,e,t,!1,r)},we.prototype.writeDoubleLE=function(e,t,r){return Xe(this,e,t,!0,r)},we.prototype.writeDoubleBE=function(e,t,r){return Xe(this,e,t,!1,r)},we.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!we.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function rt(e){return function(e){var t,r,n,i,o,s;fe||de();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new le(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=ce[e.charCodeAt(t)]<<2|ce[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=ce[e.charCodeAt(t)]<<10|ce[e.charCodeAt(t+1)]<<4|ce[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Ze,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function nt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function it(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var ot={exports:{}};function st(e,t){for(var r=0,n=e.length-1;n>=0;n--){var i=e[n];"."===i?e.splice(n,1):".."===i?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var at=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,ut=function(e){return at.exec(e).slice(1)};function ct(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(e=n+"/"+e,t="/"===n.charAt(0))}return(t?"/":"")+(e=st(vt(e.split("/"),(function(e){return!!e})),!t).join("/"))||"."}function lt(e){var t=ft(e),r="/"===yt(e,-1);return(e=st(vt(e.split("/"),(function(e){return!!e})),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function ft(e){return"/"===e.charAt(0)}function dt(){return lt(vt(Array.prototype.slice.call(arguments,0),(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))}function ht(e,t){function r(e){for(var t=0;t=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=ct(e).substr(1),t=ct(t).substr(1);for(var n=r(e.split("/")),i=r(t.split("/")),o=Math.min(n.length,i.length),s=o,a=0;a>>0),this.Xc=!0,null!=e&&Re.zb("/",this.filename,e,!0,!0)):this.filename=e,this.handleError(s(this.filename,n)),this.db=R(n,"i32"),ee(this.db),this.nb={},this.Xa={}}var n=Ye(4),o=i.cwrap,s=o("sqlite3_open","number",["string","number"]),a=o("sqlite3_close_v2","number",["number"]),u=o("sqlite3_exec","number",["number","string","number","number","number"]),c=o("sqlite3_changes","number",["number"]),l=o("sqlite3_prepare_v2","number",["number","string","number","number","number"]),f=o("sqlite3_sql","string",["number"]),d=o("sqlite3_normalized_sql","string",["number"]),h=o("sqlite3_prepare_v2","number",["number","number","number","number","number"]),_=o("sqlite3_bind_text","number",["number","number","number","number","number"]),p=o("sqlite3_bind_blob","number",["number","number","number","number","number"]),g=o("sqlite3_bind_double","number",["number","number","number"]),m=o("sqlite3_bind_int","number",["number","number","number"]),v=o("sqlite3_bind_parameter_index","number",["number","string"]),y=o("sqlite3_step","number",["number"]),b=o("sqlite3_errmsg","string",["number"]),w=o("sqlite3_column_count","number",["number"]),E=o("sqlite3_data_count","number",["number"]),N=o("sqlite3_column_double","number",["number","number"]),M=o("sqlite3_column_text","string",["number","number"]),x=o("sqlite3_column_blob","number",["number","number"]),I=o("sqlite3_column_bytes","number",["number","number"]),T=o("sqlite3_column_type","number",["number","number"]),B=o("sqlite3_column_name","string",["number","number"]),P=o("sqlite3_reset","number",["number"]),D=o("sqlite3_clear_bindings","number",["number"]),$=o("sqlite3_finalize","number",["number"]),L=o("sqlite3_create_function_v2","number","number string number number number number number number number".split(" ")),U=o("sqlite3_value_type","number",["number"]),z=o("sqlite3_value_bytes","number",["number"]),W=o("sqlite3_value_text","string",["number"]),H=o("sqlite3_value_blob","number",["number"]),G=o("sqlite3_value_double","number",["number"]),Y=o("sqlite3_result_double","",["number","number"]),V=o("sqlite3_result_null","",["number"]),Q=o("sqlite3_result_text","",["number","string","number","number"]),K=o("sqlite3_result_blob","",["number","number","number","number"]),X=o("sqlite3_result_int","",["number","number"]),Z=o("sqlite3_result_error","",["number","string","number"]),ee=o("RegisterExtensionFunctions","number",["number"]);e.prototype.bind=function(e){if(!this.Qa)throw"Statement closed";return this.reset(),Array.isArray(e)?this.vc(e):null==e||"object"!=typeof e||this.wc(e)},e.prototype.step=function(){if(!this.Qa)throw"Statement closed";this.Pa=1;var e=y(this.Qa);switch(e){case 100:return!0;case 101:return!1;default:throw this.db.handleError(e)}},e.prototype.Pc=function(e){return null==e&&(e=this.Pa,this.Pa+=1),N(this.Qa,e)},e.prototype.Qc=function(e){return null==e&&(e=this.Pa,this.Pa+=1),M(this.Qa,e)},e.prototype.getBlob=function(e){null==e&&(e=this.Pa,this.Pa+=1);var t=I(this.Qa,e);e=x(this.Qa,e);for(var r=new Uint8Array(t),n=0;n{let t=S((function(t,r){return t=te.get(t),e.lock(t,r)?0:5}),"iii"),r=S((function(t,r){return t=te.get(t),e.unlock(t,r),0}),"iii"),n=S((function(e,t){e=q(e),te.set(t,e)}),"vii");i._register_for_idb(t,r,n)},i.cleanup_file=e=>{let t=[...te.entries()].find((t=>t[1]===e));te.delete(t[0])},i.reset_filesystem=()=>{Re.root=null,Re.lc()}};var s,a={};for(s in i)i.hasOwnProperty(s)&&(a[s]=i[s]);var u,c,l,f,d,h="./this.program",_="object"==typeof window,p="function"==typeof importScripts,g="object"==typeof ae&&"object"==typeof ae.versions&&"string"==typeof ae.versions.node,m="";g?(m=p?bt.dirname(m)+"/":"/home/runner/work/openim-sdk-js-wasm/openim-sdk-js-wasm/node_modules/@jlongster/sql.js/dist/",u=function(e,t){return f||(f=wt),d||(d=bt),e=d.normalize(e),f.readFileSync(e,t?null:"utf8")},l=function(e){return(e=u(e,!0)).buffer||(e=new Uint8Array(e)),x(e.buffer),e},c=function(e,t,r){f||(f=wt),d||(d=bt),e=d.normalize(e),f.readFile(e,(function(e,n){e?r(e):t(n.buffer)}))},1>0]=0;break;case"i16":B[e>>1]=0;break;case"i32":P[e>>2]=0;break;case"i64":Z=[0,(X=0,1<=+Math.abs(X)?0>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[e>>2]=Z[0],P[e+4>>2]=Z[1];break;case"float":D[e>>2]=0;break;case"double":$[e>>3]=0;break;default:oe("invalid type for setValue: "+t)}}function R(e,t){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return C[e>>0];case"i16":return B[e>>1];case"i32":case"i64":return P[e>>2];case"float":return D[e>>2];case"double":return $[e>>3];default:oe("invalid type for getValue: "+t)}return null}i.wasmBinary&&(w=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&oe("no native wasm support detected");var N,M=!1;function x(e,t){e||oe("Assertion failed: "+t)}function I(e){var t=i["_"+e];return x(t,"Cannot call unknown function "+e+", make sure it is exported"),t}function A(e){var t=Ue(e.length);return e.subarray||e.slice?F.set(e,t):F.set(new Uint8Array(e),t),t}var T,C,F,B,P,D,$,L="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function U(e,t,r){var n=t+r;for(r=t;e[r]&&!(r>=n);)++r;if(16(i=224==(240&i)?(15&i)<<12|o<<6|s:(7&i)<<18|o<<12|s<<6|63&e[t++])?n+=String.fromCharCode(i):(i-=65536,n+=String.fromCharCode(55296|i>>10,56320|1023&i))}}else n+=String.fromCharCode(i)}return n}function q(e,t){return e?U(F,e,t):""}function j(e,t,r,n){if(!(0=s)s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o);if(127>=s){if(r>=n)break;t[r++]=s}else{if(2047>=s){if(r+1>=n)break;t[r++]=192|s>>6}else{if(65535>=s){if(r+2>=n)break;t[r++]=224|s>>12}else{if(r+3>=n)break;t[r++]=240|s>>18,t[r++]=128|s>>12&63}t[r++]=128|s>>6&63}t[r++]=128|63&s}}return t[r]=0,r-i}function J(e){for(var t=0,r=0;r=n&&(n=65536+((1023&n)<<10)|1023&e.charCodeAt(++r)),127>=n?++t:t=2047>=n?t+2:65535>=n?t+3:t+4}return t}function z(e){var t=J(e)+1,r=Ue(t);return r&&j(e,C,r,t),r}function W(){var e=N.buffer;T=e,i.HEAP8=C=new Int8Array(e),i.HEAP16=B=new Int16Array(e),i.HEAP32=P=new Int32Array(e),i.HEAPU8=F=new Uint8Array(e),i.HEAPU16=new Uint16Array(e),i.HEAPU32=new Uint32Array(e),i.HEAPF32=D=new Float32Array(e),i.HEAPF64=$=new Float64Array(e)}var H,G=[],Y=[],V=[];function Q(){var e=i.preRun.shift();G.unshift(e)}var K,X,Z,ee,te=0,re=null;function ne(){te++,i.monitorRunDependencies&&i.monitorRunDependencies(te)}function ie(){if(te--,i.monitorRunDependencies&&i.monitorRunDependencies(te),0==te&&re){var e=re;re=null,e()}}function oe(e){throw i.onAbort&&i.onAbort(e),y(e),M=!0,new WebAssembly.RuntimeError("abort("+e+"). Build with -s ASSERTIONS=1 for more info.")}function se(){return K.startsWith("data:application/octet-stream;base64,")}if(i.preloadedImages={},i.preloadedAudios={},K="sql-wasm.wasm",!se()){var ue=K;K=i.locateFile?i.locateFile(ue,m):m+ue}function ce(){var e=K;try{if(e==K&&w)return new Uint8Array(w);if(l)return l(e);throw"both async and sync fetching of the wasm failed"}catch(e){oe(e)}}function le(e){for(;0r?[]:e.slice(t,r-t+1)}e=ge(e).substr(1),t=ge(t).substr(1),e=r(e.split("/")),t=r(t.split("/"));for(var n=Math.min(e.length,t.length),i=n,o=0;o=t||(t=Math.max(t,r*(1048576>r?2:1.125)>>>0),0!=r&&(t=Math.max(t,256)),r=e.Na,e.Na=new Uint8Array(t),0=e.node.Ra)return 0;if(8<(e=Math.min(e.node.Ra-i,n))&&o.subarray)t.set(o.subarray(i,i+e),r);else for(n=0;nt)throw new Re.ErrnoError(28);return t},allocate:function(e,t,r){ke.Zb(e.node,t+r),e.node.Ra=Math.max(e.node.Ra,t+r)},mmap:function(e,t,r,n,i,o){if(0!==t)throw new Re.ErrnoError(28);if(!Re.isFile(e.node.mode))throw new Re.ErrnoError(43);if(e=e.node.Na,2&o||e.buffer!==T){if((0>>0)%Re.Ua.length},ec:function(e){var t=Re.Gb(e.parent.id,e.name);e.cb=Re.Ua[t],Re.Ua[t]=e},fc:function(e){var t=Re.Gb(e.parent.id,e.name);if(Re.Ua[t]===e)Re.Ua[t]=e.cb;else for(t=Re.Ua[t];t;){if(t.cb===e){t.cb=e.cb;break}t=t.cb}},lookupNode:function(e,t){var r=Re.Vc(e);if(r)throw new Re.ErrnoError(r,e);for(r=Re.Ua[Re.Gb(e.id,t)];r;r=r.cb){var n=r.name;if(r.parent.id===e.id&&n===t)return r}return Re.lookup(e,t)},createNode:function(e,t,r,n){return e=new Re.FSNode(e,t,r,n),Re.ec(e),e},Ab:function(e){Re.fc(e)},isRoot:function(e){return e===e.parent},ab:function(e){return!!e.lb},isFile:function(e){return 32768==(61440&e)},isDir:function(e){return 16384==(61440&e)},fb:function(e){return 40960==(61440&e)},pb:function(e){return 8192==(61440&e)},Rc:function(e){return 24576==(61440&e)},isFIFO:function(e){return 4096==(61440&e)},isSocket:function(e){return 49152==(49152&e)},Mc:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Yc:function(e){var t=Re.Mc[e];if(void 0===t)throw Error("Unknown file open mode: "+e);return t},$b:function(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},Za:function(e,t){return Re.hc?0:!t.includes("r")||292&e.mode?t.includes("w")&&!(146&e.mode)||t.includes("x")&&!(73&e.mode)?2:0:2},Vc:function(e){var t=Re.Za(e,"x");return t||(e.node_ops.lookup?0:2)},Lb:function(e,t){try{return Re.lookupNode(e,t),20}catch(e){}return Re.Za(e,"wx")},qb:function(e,t,r){try{var n=Re.lookupNode(e,t)}catch(e){return e.Oa}if(e=Re.Za(e,"wx"))return e;if(r){if(!Re.isDir(n.mode))return 54;if(Re.isRoot(n)||Re.Ya(n)===Re.cwd())return 10}else if(Re.isDir(n.mode))return 31;return 0},Wc:function(e,t){return e?Re.fb(e.mode)?32:Re.isDir(e.mode)&&("r"!==Re.$b(t)||512&t)?31:Re.Za(e,Re.$b(t)):44},oc:4096,$c:function(e,t){for(t=t||Re.oc,e=e||0;e<=t;e++)if(!Re.streams[e])return e;throw new Re.ErrnoError(33)},$a:function(e){return Re.streams[e]},Jc:function(e,t,r){Re.ub||(Re.ub=function(){},Re.ub.prototype={object:{get:function(){return this.node},set:function(e){this.node=e}}});var n,i=new Re.ub;for(n in e)i[n]=e[n];return e=i,t=Re.$c(t,r),e.fd=t,Re.streams[t]=e},Dc:function(e){Re.streams[e]=null},Cc:{open:function(e){e.stream_ops=Re.Oc(e.node.rdev).stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new Re.ErrnoError(70)}},Kb:function(e){return e>>8},sd:function(e){return 255&e},bb:function(e,t){return e<<8|t},Qb:function(e,t){Re.Xb[e]={stream_ops:t}},Oc:function(e){return Re.Xb[e]},bc:function(e){var t=[];for(e=[e];e.length;){var r=e.pop();t.push(r),e.push.apply(e,r.mb)}return t},mc:function(e,t){function r(e){return Re.tb--,t(e)}function n(e){if(e){if(!n.Kc)return n.Kc=!0,r(e)}else++o>=i.length&&r(null)}"function"==typeof e&&(t=e,e=!1),Re.tb++,1t)throw new Re.ErrnoError(28);if(!(e="string"==typeof e?Re.lookupPath(e,{Ta:!0}).node:e).node_ops.setattr)throw new Re.ErrnoError(63);if(Re.isDir(e.mode))throw new Re.ErrnoError(31);if(!Re.isFile(e.mode))throw new Re.ErrnoError(28);var r=Re.Za(e,"w");if(r)throw new Re.ErrnoError(r);e.node_ops.setattr(e,{size:t,timestamp:Date.now()})},Nc:function(e,t){if(!(e=Re.$a(e)))throw new Re.ErrnoError(8);if(0==(2097155&e.flags))throw new Re.ErrnoError(28);Re.truncate(e.node,t)},kd:function(e,t,r){(e=Re.lookupPath(e,{Ta:!0}).node).node_ops.setattr(e,{timestamp:Math.max(t,r)})},open:function(e,t,r,n,o){if(""===e)throw new Re.ErrnoError(44);if(r=64&(t="string"==typeof t?Re.Yc(t):t)?4095&(void 0===r?438:r)|32768:0,"object"==typeof e)var s=e;else{e=de(e);try{s=Re.lookupPath(e,{Ta:!(131072&t)}).node}catch(e){}}var a=!1;if(64&t)if(s){if(128&t)throw new Re.ErrnoError(20)}else s=Re.mknod(e,r,0),a=!0;if(!s)throw new Re.ErrnoError(44);if(Re.pb(s.mode)&&(t&=-513),65536&t&&!Re.isDir(s.mode))throw new Re.ErrnoError(54);if(!a&&(r=Re.Wc(s,t)))throw new Re.ErrnoError(r);512&t&&Re.truncate(s,0),t&=-131713,(n=Re.Jc({node:s,path:Re.Ya(s),flags:t,seekable:!0,position:0,stream_ops:s.stream_ops,jd:[],error:!1},n,o)).stream_ops.open&&n.stream_ops.open(n),!i.logReadFiles||1&t||(Re.Ob||(Re.Ob={}),e in Re.Ob||(Re.Ob[e]=1,y("FS.trackingDelegate error on read file: "+e)));try{Re.Sa.onOpenFile&&(o=0,1!=(2097155&t)&&(o|=Re.nc.kc.qc),0!=(2097155&t)&&(o|=Re.nc.kc.rc),Re.Sa.onOpenFile(e,o))}catch(t){y("FS.trackingDelegate['onOpenFile']('"+e+"', flags) threw an exception: "+t.message)}return n},close:function(e){if(Re.kb(e))throw new Re.ErrnoError(8);e.Fb&&(e.Fb=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{Re.Dc(e.fd)}e.fd=null},kb:function(e){return null===e.fd},llseek:function(e,t,r){if(Re.kb(e))throw new Re.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new Re.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new Re.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.jd=[],e.position},read:function(e,t,r,n,i){if(0>n||0>i)throw new Re.ErrnoError(28);if(Re.kb(e))throw new Re.ErrnoError(8);if(1==(2097155&e.flags))throw new Re.ErrnoError(8);if(Re.isDir(e.node.mode))throw new Re.ErrnoError(31);if(!e.stream_ops.read)throw new Re.ErrnoError(28);var o=void 0!==i;if(o){if(!e.seekable)throw new Re.ErrnoError(70)}else i=e.position;return t=e.stream_ops.read(e,t,r,n,i),o||(e.position+=t),t},write:function(e,t,r,n,i,o){if(0>n||0>i)throw new Re.ErrnoError(28);if(Re.kb(e))throw new Re.ErrnoError(8);if(0==(2097155&e.flags))throw new Re.ErrnoError(8);if(Re.isDir(e.node.mode))throw new Re.ErrnoError(31);if(!e.stream_ops.write)throw new Re.ErrnoError(28);e.seekable&&1024&e.flags&&Re.llseek(e,0,2);var s=void 0!==i;if(s){if(!e.seekable)throw new Re.ErrnoError(70)}else i=e.position;t=e.stream_ops.write(e,t,r,n,i,o),s||(e.position+=t);try{e.path&&Re.Sa.onWriteToFile&&Re.Sa.onWriteToFile(e.path)}catch(t){y("FS.trackingDelegate['onWriteToFile']('"+e.path+"') threw an exception: "+t.message)}return t},allocate:function(e,t,r){if(Re.kb(e))throw new Re.ErrnoError(8);if(0>t||0>=r)throw new Re.ErrnoError(28);if(0==(2097155&e.flags))throw new Re.ErrnoError(8);if(!Re.isFile(e.node.mode)&&!Re.isDir(e.node.mode))throw new Re.ErrnoError(43);if(!e.stream_ops.allocate)throw new Re.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:function(e,t,r,n,i,o){if(0!=(2&i)&&0==(2&o)&&2!=(2097155&e.flags))throw new Re.ErrnoError(2);if(1==(2097155&e.flags))throw new Re.ErrnoError(2);if(!e.stream_ops.mmap)throw new Re.ErrnoError(43);return e.stream_ops.mmap(e,t,r,n,i,o)},msync:function(e,t,r,n,i){return e&&e.stream_ops.msync?e.stream_ops.msync(e,t,r,n,i):0},ud:function(){return 0},ic:function(e,t,r){if(!e.stream_ops.ic)throw new Re.ErrnoError(59);return e.stream_ops.ic(e,t,r)},readFile:function(e,t){if((t=t||{}).flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw Error('Invalid encoding type "'+t.encoding+'"');var r,n=Re.open(e,t.flags);e=Re.stat(e).size;var i=new Uint8Array(e);return Re.read(n,i,0,e,0),"utf8"===t.encoding?r=U(i,0):"binary"===t.encoding&&(r=i),Re.close(n),r},writeFile:function(e,t,r){if((r=r||{}).flags=r.flags||577,e=Re.open(e,r.flags,r.mode),"string"==typeof t){var n=new Uint8Array(J(t)+1);t=j(t,n,0,n.length),Re.write(e,n,0,t,void 0,r.Bc)}else{if(!ArrayBuffer.isView(t))throw Error("Unsupported data type");Re.write(e,t,0,t.byteLength,void 0,r.Bc)}Re.close(e)},cwd:function(){return Re.Wb},chdir:function(e){if(null===(e=Re.lookupPath(e,{Ta:!0})).node)throw new Re.ErrnoError(44);if(!Re.isDir(e.node.mode))throw new Re.ErrnoError(54);var t=Re.Za(e.node,"x");if(t)throw new Re.ErrnoError(t);Re.Wb=e.path},Fc:function(){Re.mkdir("/tmp"),Re.mkdir("/home"),Re.mkdir("/home/web_user")},Ec:function(){Re.mkdir("/dev"),Re.Qb(Re.bb(1,3),{read:function(){return 0},write:function(e,t,r,n){return n}}),Re.rb("/dev/null",Re.bb(1,3)),ye(Re.bb(5,0),Ee),ye(Re.bb(6,0),Oe),Re.rb("/dev/tty",Re.bb(5,0)),Re.rb("/dev/tty1",Re.bb(6,0));var e=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return function(){return crypto.getRandomValues(e),e[0]}}if(g)try{var t=Et;return function(){return t.randomBytes(1)[0]}}catch(e){}return function(){oe("randomDevice")}}();Re.Wa("/dev","random",e),Re.Wa("/dev","urandom",e),Re.mkdir("/dev/shm"),Re.mkdir("/dev/shm/tmp")},Hc:function(){Re.mkdir("/proc");var e=Re.mkdir("/proc/self");Re.mkdir("/proc/self/fd"),Re.mount({mount:function(){var t=Re.createNode(e,"fd",16895,73);return t.node_ops={lookup:function(e,t){var r=Re.$a(+t);if(!r)throw new Re.ErrnoError(8);return(e={parent:null,mount:{jc:"fake"},node_ops:{readlink:function(){return r.path}}}).parent=e}},t}},{},"/proc/self/fd")},Ic:function(){i.stdin?Re.Wa("/dev","stdin",i.stdin):Re.symlink("/dev/tty","/dev/stdin"),i.stdout?Re.Wa("/dev","stdout",null,i.stdout):Re.symlink("/dev/tty","/dev/stdout"),i.stderr?Re.Wa("/dev","stderr",null,i.stderr):Re.symlink("/dev/tty1","/dev/stderr"),Re.open("/dev/stdin",0),Re.open("/dev/stdout",1),Re.open("/dev/stderr",1)},Yb:function(){Re.ErrnoError||(Re.ErrnoError=function(e,t){this.node=t,this.hd=function(e){this.Oa=e},this.hd(e),this.message="FS error"},Re.ErrnoError.prototype=Error(),Re.ErrnoError.prototype.constructor=Re.ErrnoError,[44].forEach((function(e){Re.Db[e]=new Re.ErrnoError(e),Re.Db[e].stack=""})))},lc:function(){Re.Yb(),Re.Ua=Array(4096),Re.mount(ke,{},"/"),Re.Fc(),Re.Ec(),Re.Hc(),Re.Lc={MEMFS:ke}},jb:function(e,t,r){Re.jb.Hb=!0,Re.Yb(),i.stdin=e||i.stdin,i.stdout=t||i.stdout,i.stderr=r||i.stderr,Re.Ic()},wd:function(){Re.jb.Hb=!1;var e=i._fflush;for(e&&e(0),e=0;ethis.length-1||0>e)){var t=e%this.chunkSize;return this.dc(e/this.chunkSize|0)[t]}},o.prototype.pc=function(e){this.dc=e},o.prototype.Ub=function(){var e=new XMLHttpRequest;if(e.open("HEAD",r,!1),e.send(null),!(200<=e.status&&300>e.status||304===e.status))throw Error("Couldn't load "+r+". Status: "+e.status);var t,n=Number(e.getResponseHeader("Content-length")),i=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t;e=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t;var o=1048576;i||(o=n);var s=this;s.pc((function(e){var t=e*o,i=(e+1)*o-1;if(i=Math.min(i,n-1),void 0===s.ob[e]){var a=s.ob;if(t>i)throw Error("invalid range ("+t+", "+i+") or no bytes requested!");if(i>n-1)throw Error("only "+n+" bytes available! programmer error!");var u=new XMLHttpRequest;if(u.open("GET",r,!1),n!==o&&u.setRequestHeader("Range","bytes="+t+"-"+i),"undefined"!=typeof Uint8Array&&(u.responseType="arraybuffer"),u.overrideMimeType&&u.overrideMimeType("text/plain; charset=x-user-defined"),u.send(null),!(200<=u.status&&300>u.status||304===u.status))throw Error("Couldn't load "+r+". Status: "+u.status);t=void 0!==u.response?new Uint8Array(u.response||[]):De(u.responseText||"",!0),a[e]=t}if(void 0===s.ob[e])throw Error("doXHR failed!");return s.ob[e]})),!e&&n||(o=n=1,o=n=this.dc(0).length,v("LazyFiles on gzip forces download of the whole file when length is accessed")),this.tc=n,this.sc=o,this.Jb=!0},"undefined"!=typeof XMLHttpRequest){if(!p)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new o;Object.defineProperties(s,{length:{get:function(){return this.Jb||this.Ub(),this.tc}},chunkSize:{get:function(){return this.Jb||this.Ub(),this.sc}}}),s={Ib:!1,Na:s}}else s={Ib:!1,url:r};var a=Re.Gc(e,t,s,n,i);s.Na?a.Na=s.Na:s.url&&(a.Na=null,a.url=s.url),Object.defineProperties(a,{Ra:{get:function(){return this.Na.length}}});var u={};return Object.keys(a.stream_ops).forEach((function(e){var t=a.stream_ops[e];u[e]=function(){return Re.ac(a),t.apply(null,arguments)}})),u.read=function(e,t,r,n,i){if(Re.ac(a),i>=(e=e.node.Na).length)return 0;if(n=Math.min(e.length-i,n),e.slice)for(var o=0;o>2]=n.dev,P[r+4>>2]=0,P[r+8>>2]=n.ino,P[r+12>>2]=n.mode,P[r+16>>2]=n.nlink,P[r+20>>2]=n.uid,P[r+24>>2]=n.gid,P[r+28>>2]=n.rdev,P[r+32>>2]=0,Z=[n.size>>>0,(X=n.size,1<=+Math.abs(X)?0>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[r+40>>2]=Z[0],P[r+44>>2]=Z[1],P[r+48>>2]=4096,P[r+52>>2]=n.blocks,P[r+56>>2]=n.atime.getTime()/1e3|0,P[r+60>>2]=0,P[r+64>>2]=n.mtime.getTime()/1e3|0,P[r+68>>2]=0,P[r+72>>2]=n.ctime.getTime()/1e3|0,P[r+76>>2]=0,Z=[n.ino>>>0,(X=n.ino,1<=+Math.abs(X)?0>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[r+80>>2]=Z[0],P[r+84>>2]=Z[1],0}var xe,Ie=void 0;function Ae(){return P[(Ie+=4)-4>>2]}function Te(e){if(!(e=Re.$a(e)))throw new Re.ErrnoError(8);return e}xe=g?function(){var e=ae.hrtime();return 1e3*e[0]+e[1]/1e6}:function(){return performance.now()};var Ce,Fe={};function Be(){if(!Ce){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:h||"./this.program"};for(e in Fe)void 0===Fe[e]?delete t[e]:t[e]=Fe[e];var r=[];for(e in t)r.push(e+"="+t[e]);Ce=r}return Ce}function Pe(e,t,r,n){e||(e=this),this.parent=e,this.mount=e.mount,this.lb=null,this.id=Re.Zc++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=n}function De(e,t){var r=Array(J(e)+1);return e=j(e,r,0,r.length),t&&(r.length=e),r}Object.defineProperties(Pe.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},Sc:{get:function(){return Re.isDir(this.mode)}},Ib:{get:function(){return Re.pb(this.mode)}}}),Re.FSNode=Pe,Re.lc();var $e={a:function(e,t,r,n){oe("Assertion failed: "+q(e)+", at: "+[t?q(t):"unknown filename",r,n?q(n):"unknown function"])},u:function(e,t){!function(){function e(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}if(!ee){ee=!0;var t=(new Date).getFullYear(),r=new Date(t,0,1),n=new Date(t,6,1);t=r.getTimezoneOffset();var i=n.getTimezoneOffset(),o=Math.max(t,i);P[We()>>2]=60*o,P[ze()>>2]=Number(t!=i),r=e(r),n=e(n),r=z(r),n=z(n),i>2]=r,P[Je()+4>>2]=n):(P[Je()>>2]=n,P[Je()+4>>2]=r)}}(),e=new Date(1e3*P[e>>2]),P[t>>2]=e.getSeconds(),P[t+4>>2]=e.getMinutes(),P[t+8>>2]=e.getHours(),P[t+12>>2]=e.getDate(),P[t+16>>2]=e.getMonth(),P[t+20>>2]=e.getFullYear()-1900,P[t+24>>2]=e.getDay();var r=new Date(e.getFullYear(),0,1);P[t+28>>2]=(e.getTime()-r.getTime())/864e5|0,P[t+36>>2]=-60*e.getTimezoneOffset();var n=new Date(e.getFullYear(),6,1).getTimezoneOffset();return e=0|(n!=(r=r.getTimezoneOffset())&&e.getTimezoneOffset()==Math.min(r,n)),P[t+32>>2]=e,e=P[Je()+(e?4:0)>>2],P[t+40>>2]=e,t},m:function(e,t){try{var r;if(e=q(e),-8&t)var n=-28;else(r=Re.lookupPath(e,{Ta:!0}).node)?(e="",4&t&&(e+="r"),2&t&&(e+="w"),1&t&&(e+="x"),n=e&&Re.Za(r,e)?-2:0):n=-44;return n}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},A:function(e,t){try{return e=q(e),Re.chmod(e,t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},H:function(e,t,r){try{return e=q(e),Re.chown(e,t,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},B:function(e,t){try{return Re.fchmod(e,t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},I:function(e,t,r){try{return Re.fchown(e,t,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},b:function(e,t,r){Ie=r;try{var n=Te(e);switch(t){case 0:var i=Ae();return 0>i?-28:Re.open(n.path,n.flags,0,i).fd;case 1:case 2:case 13:case 14:return 0;case 3:return n.flags;case 4:return i=Ae(),n.flags|=i,0;case 12:return i=Ae(),B[i+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return P[Le()>>2]=28,-1}}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},E:function(e,t){try{var r=Te(e);return Me(Re.stat,r.path,t)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},n:function(e,t,r){try{return Re.Nc(e,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},l:function(e,t){try{if(0===t)return-28;var r=Re.cwd();return t=r)var n=-28;else{var i=Re.readlink(e),o=Math.min(r,J(i)),s=C[t+o];j(i,F,t,r+1),C[t+o]=s,n=o}return n}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},F:function(e){try{return e=q(e),Re.rmdir(e),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},e:function(e,t){try{return e=q(e),Me(Re.stat,e,t)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},i:function(e){try{return e=q(e),Re.unlink(e),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},v:function(){return 2147483648},p:function(e,t,r){F.copyWithin(e,t,t+r)},c:function(e){var t=F.length;if(2147483648<(e>>>=0))return!1;for(var r=1;4>=r;r*=2){var n=t*(1+.2/r);n=Math.min(n,e+100663296),0<(n=Math.max(e,n))%65536&&(n+=65536-n%65536);e:{try{N.grow(Math.min(2147483648,n)-T.byteLength+65535>>>16),W();var i=1;break e}catch(e){}i=void 0}if(i)return!0}return!1},t:function(e){for(var t=xe();xe()-t>2]=o,o=0;o>0]=n.charCodeAt(o);C[i>>0]=0,r+=n.length+1})),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},s:function(e,t){try{var r=Be();P[e>>2]=r.length;var n=0;return r.forEach((function(e){n+=e.length+1})),P[t>>2]=n,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},f:function(e){try{var t=Te(e);return Re.close(t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},q:function(e,t){try{var r=Te(e),n=r.tty?2:Re.isDir(r.mode)?3:Re.fb(r.mode)?7:4;return C[t>>0]=n,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},j:function(e,t,r,n){try{e:{for(var i=Te(e),o=e=0;o>2],a=Re.read(i,C,P[t+8*o>>2],s,void 0);if(0>a){var u=-1;break e}if(e+=a,a>2]=u,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},o:function(e,t,r,n,i){try{var o=Te(e);return-9007199254740992>=(e=4294967296*r+(t>>>0))||9007199254740992<=e?-61:(Re.llseek(o,e,n),Z=[o.position>>>0,(X=o.position,1<=+Math.abs(X)?0>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[i>>2]=Z[0],P[i+4>>2]=Z[1],o.Fb&&0===e&&0===n&&(o.Fb=null),0)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},k:function(e){try{var t=Te(e);return t.stream_ops&&t.stream_ops.fsync?-t.stream_ops.fsync(t):0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},g:function(e,t,r,n){try{e:{for(var i=Te(e),o=e=0;o>2],P[t+(8*o+4)>>2],void 0);if(0>s){var a=-1;break e}e+=s}a=e}return P[n>>2]=a,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},h:function(e){var t=Date.now();return P[e>>2]=t/1e3|0,P[e+4>>2]=t%1e3*1e3|0,0},K:function(e){var t=Date.now()/1e3|0;return e&&(P[e>>2]=t),t},D:function(e,t){if(t){var r=t+8;t=1e3*P[r>>2],t+=P[r+4>>2]/1e3}else t=Date.now();e=q(e);try{Re.kd(e,t,t);var n=0}catch(e){if(!(e instanceof Re.ErrnoError)){e:{if(!(n=Error()).stack){try{throw Error()}catch(e){n=e}if(!n.stack){n="(no stack trace available)";break e}}n=n.stack.toString()}throw i.extraStackTrace&&(n+="\n"+i.extraStackTrace()),n=function(e){return e.replace(/\b_Z[\w\d_]+/g,(function(e){return e==e?e:e+" ["+e+"]"}))}(n),e+" : "+n}n=e.Oa,P[Le()>>2]=n,n=-1}return n}};!function(){function e(e){i.asm=e.exports,N=i.asm.L,W(),H=i.asm.Da,Y.unshift(i.asm.M),ie()}function t(t){e(t.instance)}function r(e){return function(){if(!w&&(_||p)){if("function"==typeof fetch&&!K.startsWith("file://"))return fetch(K,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+K+"'";return e.arrayBuffer()})).catch((function(){return ce()}));if(c)return new Promise((function(e,t){c(K,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return ce()}))}().then((function(e){return WebAssembly.instantiate(e,n)})).then(e,(function(e){y("failed to asynchronously prepare wasm: "+e),oe(e)}))}var n={a:$e};if(ne(),i.instantiateWasm)try{return i.instantiateWasm(n,e)}catch(e){return y("Module.instantiateWasm callback failed with error: "+e),!1}w||"function"!=typeof WebAssembly.instantiateStreaming||se()||K.startsWith("file://")||"function"!=typeof fetch?r(t):fetch(K,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,n).then(t,(function(e){return y("wasm streaming compile failed: "+e),y("falling back to ArrayBuffer instantiation"),r(t)}))}))}(),i.___wasm_call_ctors=function(){return(i.___wasm_call_ctors=i.asm.M).apply(null,arguments)},i._sqlite3_vfs_find=function(){return(i._sqlite3_vfs_find=i.asm.N).apply(null,arguments)},i._sqlite3_free=function(){return(i._sqlite3_free=i.asm.O).apply(null,arguments)};var Le=i.___errno_location=function(){return(Le=i.___errno_location=i.asm.P).apply(null,arguments)};i._sqlite3_finalize=function(){return(i._sqlite3_finalize=i.asm.Q).apply(null,arguments)},i._sqlite3_reset=function(){return(i._sqlite3_reset=i.asm.R).apply(null,arguments)},i._sqlite3_clear_bindings=function(){return(i._sqlite3_clear_bindings=i.asm.S).apply(null,arguments)},i._sqlite3_value_blob=function(){return(i._sqlite3_value_blob=i.asm.T).apply(null,arguments)},i._sqlite3_value_text=function(){return(i._sqlite3_value_text=i.asm.U).apply(null,arguments)},i._sqlite3_value_bytes=function(){return(i._sqlite3_value_bytes=i.asm.V).apply(null,arguments)},i._sqlite3_value_double=function(){return(i._sqlite3_value_double=i.asm.W).apply(null,arguments)},i._sqlite3_value_int=function(){return(i._sqlite3_value_int=i.asm.X).apply(null,arguments)},i._sqlite3_value_type=function(){return(i._sqlite3_value_type=i.asm.Y).apply(null,arguments)},i._sqlite3_result_blob=function(){return(i._sqlite3_result_blob=i.asm.Z).apply(null,arguments)},i._sqlite3_result_double=function(){return(i._sqlite3_result_double=i.asm._).apply(null,arguments)},i._sqlite3_result_error=function(){return(i._sqlite3_result_error=i.asm.$).apply(null,arguments)},i._sqlite3_result_int=function(){return(i._sqlite3_result_int=i.asm.aa).apply(null,arguments)},i._sqlite3_result_int64=function(){return(i._sqlite3_result_int64=i.asm.ba).apply(null,arguments)},i._sqlite3_result_null=function(){return(i._sqlite3_result_null=i.asm.ca).apply(null,arguments)},i._sqlite3_result_text=function(){return(i._sqlite3_result_text=i.asm.da).apply(null,arguments)},i._sqlite3_step=function(){return(i._sqlite3_step=i.asm.ea).apply(null,arguments)},i._sqlite3_column_count=function(){return(i._sqlite3_column_count=i.asm.fa).apply(null,arguments)},i._sqlite3_data_count=function(){return(i._sqlite3_data_count=i.asm.ga).apply(null,arguments)},i._sqlite3_column_blob=function(){return(i._sqlite3_column_blob=i.asm.ha).apply(null,arguments)},i._sqlite3_column_bytes=function(){return(i._sqlite3_column_bytes=i.asm.ia).apply(null,arguments)},i._sqlite3_column_double=function(){return(i._sqlite3_column_double=i.asm.ja).apply(null,arguments)},i._sqlite3_column_text=function(){return(i._sqlite3_column_text=i.asm.ka).apply(null,arguments)},i._sqlite3_column_type=function(){return(i._sqlite3_column_type=i.asm.la).apply(null,arguments)},i._sqlite3_column_name=function(){return(i._sqlite3_column_name=i.asm.ma).apply(null,arguments)},i._sqlite3_bind_blob=function(){return(i._sqlite3_bind_blob=i.asm.na).apply(null,arguments)},i._sqlite3_bind_double=function(){return(i._sqlite3_bind_double=i.asm.oa).apply(null,arguments)},i._sqlite3_bind_int=function(){return(i._sqlite3_bind_int=i.asm.pa).apply(null,arguments)},i._sqlite3_bind_text=function(){return(i._sqlite3_bind_text=i.asm.qa).apply(null,arguments)},i._sqlite3_bind_parameter_index=function(){return(i._sqlite3_bind_parameter_index=i.asm.ra).apply(null,arguments)},i._sqlite3_sql=function(){return(i._sqlite3_sql=i.asm.sa).apply(null,arguments)},i._sqlite3_normalized_sql=function(){return(i._sqlite3_normalized_sql=i.asm.ta).apply(null,arguments)},i._sqlite3_errmsg=function(){return(i._sqlite3_errmsg=i.asm.ua).apply(null,arguments)},i._sqlite3_exec=function(){return(i._sqlite3_exec=i.asm.va).apply(null,arguments)},i._sqlite3_prepare_v2=function(){return(i._sqlite3_prepare_v2=i.asm.wa).apply(null,arguments)},i._sqlite3_changes=function(){return(i._sqlite3_changes=i.asm.xa).apply(null,arguments)},i._sqlite3_close_v2=function(){return(i._sqlite3_close_v2=i.asm.ya).apply(null,arguments)},i._sqlite3_create_function_v2=function(){return(i._sqlite3_create_function_v2=i.asm.za).apply(null,arguments)},i._sqlite3_open=function(){return(i._sqlite3_open=i.asm.Aa).apply(null,arguments)};var Ue=i._malloc=function(){return(Ue=i._malloc=i.asm.Ba).apply(null,arguments)},qe=i._free=function(){return(qe=i._free=i.asm.Ca).apply(null,arguments)};i._RegisterExtensionFunctions=function(){return(i._RegisterExtensionFunctions=i.asm.Ea).apply(null,arguments)},i._register_for_idb=function(){return(i._register_for_idb=i.asm.Fa).apply(null,arguments)};var je,Je=i.__get_tzname=function(){return(Je=i.__get_tzname=i.asm.Ga).apply(null,arguments)},ze=i.__get_daylight=function(){return(ze=i.__get_daylight=i.asm.Ha).apply(null,arguments)},We=i.__get_timezone=function(){return(We=i.__get_timezone=i.asm.Ia).apply(null,arguments)},He=i.stackSave=function(){return(He=i.stackSave=i.asm.Ja).apply(null,arguments)},Ge=i.stackRestore=function(){return(Ge=i.stackRestore=i.asm.Ka).apply(null,arguments)},Ye=i.stackAlloc=function(){return(Ye=i.stackAlloc=i.asm.La).apply(null,arguments)},Ve=i._memalign=function(){return(Ve=i._memalign=i.asm.Ma).apply(null,arguments)};function Qe(){function e(){if(!je&&(je=!0,i.calledRun=!0,!M)){if(i.noFSInit||Re.jb.Hb||Re.jb(),Re.hc=!1,le(Y),i.onRuntimeInitialized&&i.onRuntimeInitialized(),i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;){var e=i.postRun.shift();V.unshift(e)}le(V)}}if(!(0{let r=e.isFile(t.mode)?t.contents.getattr():null,n={dev:1};return n.ino=t.id,n.mode=r?r.mode:t.mode,n.nlink=1,n.uid=0,n.gid=0,n.rdev=t.rdev,n.size=r?r.size:e.isDir(t.mode)?4096:0,n.atime=new Date(0),n.mtime=new Date(0),n.ctime=new Date(0),n.blksize=r?r.blockSize:4096,n.blocks=Math.ceil(n.size/n.blksize),n},setattr:(e,t)=>{this.FS.isFile(e.mode)?e.contents.setattr(t):(null!=t.mode&&(e.mode=t.mode),null!=t.size&&(e.size=t.size))},lookup:(e,t)=>{throw new this.FS.ErrnoError(kt)},mknod:(e,t,r,n)=>{if(t.endsWith(".lock"))throw new Error("Locking via lockfiles is not supported");return this.createNode(e,t,r,n)},rename:(e,t,r)=>{throw new Error("rename not implemented")},unlink:(e,t)=>{this.FS.lookupNode(e,t).contents.delete(t)},readdir:e=>{throw new Error("readdir not implemented")},symlink:(e,t,r)=>{throw new Error("symlink not implemented")},readlink:e=>{throw new Error("symlink not implemented")}},this.stream_ops={open:e=>{this.FS.isFile(e.node.mode)&&e.node.contents.open()},close:e=>{this.FS.isFile(e.node.mode)&&e.node.contents.close()},read:(e,t,r,n,i)=>e.node.contents.read(t,r,n,i),write:(e,t,r,n,i)=>e.node.contents.write(t,r,n,i),llseek:(t,r,n)=>{var i=r;if(1===n?i+=t.position:2===n&&e.isFile(t.node.mode)&&(i+=t.node.contents.getattr().size),i<0)throw new this.FS.ErrnoError(28);return i},allocate:(e,t,r)=>{e.node.contents.setattr({size:t+r})},mmap:(e,t,r,n,i,o)=>{throw new Error("mmap not implemented")},msync:(e,t,r,n,i)=>{throw new Error("msync not implemented")},fsync:(e,t,r,n,i)=>{e.node.contents.fsync()}}}mount(){return this.createNode(null,"/",16895,0)}lock(e,t){let{node:r}=this.FS.lookupPath(e);return r.contents.lock(t)}unlock(e,t){let{node:r}=this.FS.lookupPath(e);return r.contents.unlock(t)}createNode(e,t,r,n){if(!this.FS.isDir(r)&&!this.FS.isFile(r))throw new this.FS.ErrnoError(St);var i=this.FS.createNode(e,t,r,n);return this.FS.isDir(i.mode)?(i.node_ops={mknod:this.node_ops.mknod,lookup:this.node_ops.lookup,unlink:this.node_ops.unlink,setattr:this.node_ops.setattr},i.stream_ops={},i.contents={}):this.FS.isFile(i.mode)&&(i.node_ops=this.node_ops,i.stream_ops=this.stream_ops,i.contents=this.backend.createFile(t)),e&&(e.contents[t]=i,e.timestamp=i.timestamp),i}};let Nt=1,Mt=2;function xt(e){return(e[16]<<8)+e[17]}function It(e,t,r){return function(e,t,r){let n=[];for(let i=e;i<=t;i+=r)n.push(i);return n}(t-t%e,r-1-(r-1)%e,e)}function At(e,t,r,n){let i=It(t,r,n),o=0;return i.map((i=>{let s=0,a=t;r>i&&ri&&ni+t||n<=i)return null;let l=e.byteOffset+o,f=e.buffer.byteLength-l;if(f<=0)return null;let d=Math.min(u,f);return new Uint8Array(c).set(new Uint8Array(e.buffer,l,d),s),o+=d,{pos:i,data:c,offset:s,length:d}})).filter(Boolean)}class Tt{constructor(e,t,r=null){this.filename=e,this.buffer=new Map,this.ops=t,this.meta=r,this._metaDirty=!1,this.writeLock=!1,this.openHandles=0}bufferChunks(e){for(let t=0;t{let r=this.buffer.get(t);return r?e.chunks.push(r):e.missing.push(t),e}),{chunks:[],missing:[]}),r=[];return t.missing.length>0&&(r=this.ops.readBlocks(t.missing,this.meta.blockSize)),t.chunks.concat(r)}read(e,t,r,n){let i=e.buffer;if(r<=0)return 0;if(n<0)return 0;if(n>=this.meta.size){let e=new Uint8Array(i,t);for(let t=0;to.pos&&(s=t-o.pos),ro.data.byteLength||a<0)continue;let u=a-s;i.set(new Uint8Array(o.data,s,u),o.pos-t+s)}return n}(this.load(u),s,a);if(i.byteLength-t(t.length!==this.meta.blockSize?e.partialWrites.push(t):e.fullWrites.push({pos:t.pos,data:t.data}),e)),{fullWrites:[],partialWrites:[]}),u=[];s.length>0&&(u=this.load(s.map((e=>e.pos))));let c=a.concat(u.map((e=>{let t=s.find((t=>t.pos===e.pos));return new Uint8Array(e.data).set(new Uint8Array(t.data,t.offset,t.length),t.offset,t.length),e})));return this.bufferChunks(c),n+r>this.meta.size&&this.setattr({size:n+r}),r}async readIfFallback(){if(this.ops.readIfFallback){let e=await this.ops.readIfFallback();this.meta=e||{size:0}}}lock(e){return this._recordingLock||(this._recordingLock=!0),!!this.ops.lock(e)&&(e>=Mt&&(this.writeLock=!0),!0)}unlock(e){return 0===e&&(this._recordingLock=!1),this.writeLock&&(this.fsync(),this.writeLock=!1),this.ops.unlock(e)}fsync(){if(this.buffer.size>0){let e=this.buffer.get(0);if(e){let t=xt(new Uint8Array(e.data));if(t!==this.meta.blockSize){let e=this.buffer;this.buffer=new Map;let r=[...e.values()],n=r.length*this.meta.blockSize,i=new ArrayBuffer(n),o=new Uint8Array(i);for(let e of r)o.set(new Uint8Array(e.data),e.pos);this.bufferChunks(At(o,t,0,n)),this.setattr({blockSize:t})}}this.ops.writeBlocks([...this.buffer.values()],this.meta.blockSize)}this._metaDirty&&(this.ops.writeMeta({size:this.meta.size}),this._metaDirty=!1),this.buffer=new Map}setattr(e){null==this.meta&&(this.meta={}),void 0!==e.mode&&(this.meta.mode=e.mode),void 0!==e.blockSize&&(this.meta.blockSize=e.blockSize),void 0!==e.size&&(this.meta.size=e.size,this._metaDirty=!0)}getattr(){return this.meta}}let Ct,Ft,Bt,Pt=3735928559;class Dt{constructor(e,{initialOffset:t=4,useAtomics:r=!0,stream:n=!0,debug:i,name:o}={}){this.buffer=e,this.atomicView=new Int32Array(e),this.offset=t,this.useAtomics=r,this.stream=n,this.debug=i,this.name=o}log(...e){this.debug&&console.log(`[reader: ${this.name}]`,...e)}waitWrite(e,t=null){if(this.useAtomics){for(this.log(`waiting for ${e}`);0===Atomics.load(this.atomicView,0);){if(null!=t&&"timed-out"===Atomics.wait(this.atomicView,0,0,t))throw new Error("timeout");Atomics.wait(this.atomicView,0,0,500)}this.log(`resumed for ${e}`)}else if(1!==this.atomicView[0])throw new Error("`waitWrite` expected array to be readable")}flip(){if(this.log("flip"),this.useAtomics){if(1!==Atomics.compareExchange(this.atomicView,0,1,0))throw new Error("Read data out of sync! This is disastrous");Atomics.notify(this.atomicView,0)}else this.atomicView[0]=0;this.offset=4}done(){this.waitWrite("done");let e=new DataView(this.buffer,this.offset).getUint32(0)===Pt;return e&&(this.log("done"),this.flip()),e}peek(e){this.peekOffset=this.offset;let t=e();return this.offset=this.peekOffset,this.peekOffset=null,t}string(e){this.waitWrite("string",e);let t=this._int32(),r=t/2,n=new DataView(this.buffer,this.offset,t),i=[];for(let e=0;e{console.warn(`Deleting ${this.filename} database failed`)},e.onsuccess=()=>{}}open(){let e=new SharedArrayBuffer(36864);this.writer=new $t(e,{name:"args (backend)",debug:!1});let t=new SharedArrayBuffer(36864);var r,n;this.reader=new Dt(t,{name:"results",debug:!1}),r=this.reader,n=this.writer,self.postMessage({type:"__absurd:spawn-idb-worker",argBuffer:n.buffer,resultBuffer:r.buffer}),self.addEventListener("message",(e=>{switch(e.data.type){case"__perf-deets:start-profile":n.string("profile-start"),n.finalize(),r.int32(),r.done();break;case"__perf-deets:stop-profile":n.string("profile-stop"),n.finalize(),r.int32(),r.done()}}))}close(){this.invokeWorker("closeFile",{name:this.getStoreName()}),this.reader=null,this.writer=null,this.worker=null}readMeta(){return this.invokeWorker("readMeta",{name:this.getStoreName()})}writeMeta(e){return this.invokeWorker("writeMeta",{name:this.getStoreName(),meta:e})}readBlocks(e,t){return this.stats&&(this.stats.read+=e.length),this.invokeWorker("readBlocks",{name:this.getStoreName(),positions:e,blockSize:t})}writeBlocks(e,t){return this.stats&&(this.stats.writes+=e.length),this.invokeWorker("writeBlocks",{name:this.getStoreName(),writes:e,blockSize:t})}}function qt(e,t){return Math.round(e/t)}async function jt(e){return await function(){if(navigator.userAgentData||!/Safari\//.test(navigator.userAgent)||/Chrom(e|ium)\//.test(navigator.userAgent)||!indexedDB.databases)return Promise.resolve();let e;return new Promise((t=>{const r=()=>indexedDB.databases().finally(t);e=setInterval(r,100),r()})).finally((()=>clearInterval(e)))}(),new Promise(((t,r)=>{let n=globalThis.indexedDB.open(e,2);n.onsuccess=e=>{let r=e.target.result;r.onversionchange=()=>{console.log("closing because version changed"),r.close()},r.onclose=()=>{},t(r)},n.onupgradeneeded=e=>{let t=e.target.result;t.objectStoreNames.contains("data")||t.createObjectStore("data")},n.onblocked=e=>console.log("blocked",e),n.onerror=n.onabort=e=>r(e.target.error)}))}class Jt{constructor(e,t){this.dbName=e,this._openDb=null,this.hasAlertedFailure=!1,this.onFallbackFailure=t}async getDb(){return this._openDb||(this._openDb=await jt(this.dbName)),this._openDb}closeDb(){this._openDb&&(this._openDb.close(),this._openDb=null)}async readAll(){let e=await this.getDb(this.dbName),t=new Map,r=e.transaction(["data"],"readonly").objectStore("data");return new Promise(((e,n)=>{let i=r.openCursor(IDBKeyRange.lowerBound(-1));i.onerror=n,i.onsuccess=r=>{let n=r.target.result;n?(t.set(n.key,n.value),n.continue()):e(t)}}))}async write(e,t,r){let n=(await this.getDb(this.dbName)).transaction(["data"],"readwrite"),i=n.objectStore("data");await new Promise(((o,s)=>{let a=i.get(0);a.onsuccess=u=>{if(r&&!function(e,t){if(null!=e&&null!=t){let r=new Uint8Array(e),n=new Uint8Array(t);for(let e=24;e<40;e++)if(r[e]!==n[e])return!1;return!0}return null==e&&null==t}(a.result,t))return this.onFallbackFailure&&!this.hasAlertedFailure&&(this.hasAlertedFailure=!0,this.onFallbackFailure()),void s(new Error("Fallback mode unable to write file changes"));for(let t of e)i.put(t.value,t.key);n.onsuccess=()=>o(),n.onerror=()=>s()},a.onerror=s}))}}class zt{constructor(e,t){this.filename=e,this.dbName=this.filename.replace(/\//g,"-"),this.cachedFirstBlock=null,this.writeQueue=null,this.blocks=new Map,this.lockType=0,this.transferBlockOwnership=!1,this.persistance=new Jt(this.dbName,t)}async readIfFallback(){return this.transferBlockOwnership=!0,this.blocks=await this.persistance.readAll(),this.readMeta()}lock(e){return this.cachedFirstBlock=this.blocks.get(0),this.lockType=e,!0}unlock(e){return this.lockType>Nt&&e===Nt&&this.flush(),this.lockType=e,!0}delete(){let e=globalThis.indexedDB.deleteDatabase(this.dbName);e.onerror=()=>{console.warn(`Deleting ${this.filename} database failed`)},e.onsuccess=()=>{}}open(){this.writeQueue=[],this.lockType=0}close(){this.flush(),this.transferBlockOwnership?this.transferBlockOwnership=!1:this.blocks=new Map,this.persistance.closeDb()}readMeta(){let e=this.blocks.get(-1);if(e){let t=this.blocks.get(0);return{size:e.size,blockSize:xt(new Uint8Array(t))}}return null}writeMeta(e){this.blocks.set(-1,e),this.queueWrite(-1,e)}readBlocks(e,t){let r=[];for(let n of e)r.push({pos:n,data:this.blocks.get(qt(n,t))});return r}writeBlocks(e,t){for(let r of e){let e=qt(r.pos,t);this.blocks.set(e,r.data),this.queueWrite(e,r.data)}this.lockType<=Nt&&this.flush()}queueWrite(e,t){this.writeQueue.push({key:e,value:t})}flush(){this.writeQueue.length>0&&(this.persistance.write(this.writeQueue,this.cachedFirstBlock,this.lockType>Nt),this.writeQueue=[]),this.cachedFirstBlock=null}}class Wt{constructor(e){this.onFallbackFailure=e}createFile(e){let t;t="undefined"!=typeof SharedArrayBuffer?new Ut(e):new zt(e,this.onFallbackFailure);let r=new Tt(e,t);return("production"!==ae.env.NODE_ENV||ae.env.PERF_BUILD)&&(null==this._files&&(this._files=new Set),this._files.add(r)),r}startProfile(){for(let e of this._files)if(e.ops.writer){let t=e.ops.writer,r=e.ops.reader;t.string("profile-start"),t.finalize(),r.int32(),r.done()}}stopProfile(){for(let e of this._files)if(e.ops.writer){let t=e.ops.writer,r=e.ops.reader;t.string("profile-stop"),t.finalize(),r.int32(),r.done()}}}function Ht(e,t){if(Ct)return Ct;if(!e)throw new Error("must speciefic database file");return Ct=new Promise(((r,n)=>{const i=async function(e,t="/sql-wasm.wasm"){if(!Ft){Ft=await Ot({locateFile:()=>t});const e=new Rt(Ft.FS,new Wt);Ft.register_for_idb(e),Ft.FS.mkdir("/sql"),Ft.FS.mount(e,{},"/sql")}const r=`/sql/${e}`,n=new Ft.Database(r,{filename:!0});if("undefined"==typeof SharedArrayBuffer){const e=Ft.FS.open(r,"a+");await e.node.contents.readIfFallback(),Ft.FS.close(e)}return n.exec("\n PRAGMA page_size=8192;\n PRAGMA journal_mode=MEMORY;\n "),n}(e,t);i.then((e=>r(e))).catch((e=>n(e)))})),Ct}async function Gt(e,t,r=!1){try{const n=function(e,t,r,n){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' ORDER BY send_time ${n?"ASC":"DESC"} LIMIT ${r}\n `)}(await Ht(),e,t,r);return M(F(n[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}}async function Yt(e){try{const t=await Ht(),r=(JSON.parse(e)||[]).map((e=>B(e)));if(0===r.length)return M("");const n=function(e,t){const r=v.insert().into("local_conversations").setFieldsRows(t).toString();return e.exec(r)}(t,r);return M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}}async function Vt(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("temp_cache_local_chat_logs").setFieldsRows(t).toString();return e.exec(r)}(t,JSON.parse(e).map((e=>B(e))));return M(r[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}}self.$RefreshReg$=()=>{},self.$RefreshSig$=()=>()=>{};const Qt=new Map,Kt=self,Xt=new d({event:new class{constructor(e){c(this,"_currentEndpoint"),c(this,"_targetEndpoint"),c(this,"_events"),c(this,"_originOnmessage"),c(this,"_receiveMessage"),c(this,"onerror",null),c(this,"config"),c(this,"sendAdapter"),c(this,"receiveAdapter"),this._events={},this._currentEndpoint=e.currentEndpoint,this._targetEndpoint=e.targetEndpoint,this._originOnmessage=null,this.config=e.config,this.receiveAdapter=e.receiveAdapter,this.sendAdapter=e.sendAdapter;const t=e=>{const t=this.receiveAdapter?this.receiveAdapter(e):e.data;if(t&&"string"==typeof t.event){const e=this._events[t.event]||[];if(e.length)return void e.forEach((e=>{e(...t.args||[])}));this.onerror&&this.onerror(u(a({},l.METHOD_NOT_FOUND),{data:t}))}};if(this._currentEndpoint.addEventListener)return"start"in this._currentEndpoint&&this._currentEndpoint.start&&this._currentEndpoint.start(),this._currentEndpoint.addEventListener("message",t,!1),void(this._receiveMessage=t);this._originOnmessage=this._currentEndpoint.onmessage,this._currentEndpoint.onmessage=e=>{this._originOnmessage&&this._originOnmessage(e),t(e)},this._receiveMessage=this._currentEndpoint.onmessage}emit(e,...t){const r={event:e,args:t},n=this.sendAdapter?this.sendAdapter(r,this._targetEndpoint):{data:r},i=n.data||r,o=this.config?"function"==typeof this.config?this.config(i,this._targetEndpoint)||{}:this.config||{}:{};Array.isArray(n.transfer)&&n.transfer.length&&(o.transfer=n.transfer),this._targetEndpoint.postMessage(i,o)}on(e,t){this._events[e]||(this._events[e]=[]),this._events[e].push(t)}off(e,t){if(!this._events[e])return;if(!t)return void(this._events[e]=[]);const r=this._events[e]||[];this._events[e]=r.filter((e=>e!==t))}destroy(){if(this._currentEndpoint.removeEventListener)this._currentEndpoint.removeEventListener("message",this._receiveMessage,!1);else try{this._currentEndpoint.onmessage=this._originOnmessage}catch(e){console.warn(e)}}}({currentEndpoint:Kt,targetEndpoint:Kt})});Xt.registerMethod("fileMapSet",((e,t)=>(Qt.set(e,t),M(e)))),Xt.registerMethod("fileMapClear",(()=>(Qt.clear(),M("")))),Xt.registerMethod("wasmOpen",(e=>new Promise(((t,r)=>{const n=Qt.get(e);n?t(M(n.size)):r("file not found")})))),Xt.registerMethod("wasmClose",(async e=>new Promise((t=>{Qt.delete(e),t(M(e))})))),Xt.registerMethod("wasmRead",((e,t,r)=>{const n=Qt.get(e);if(!n)throw"file not found";const i=n.slice(t,t+r);return new Promise(((e,t)=>{const r=new FileReader;r.onload=()=>{e(r.result)},r.onerror=()=>{t(r.error)},r.readAsArrayBuffer(i)}))})),Xt.registerMethod("getUpload",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_uploads where part_hash = '${t}' limit 1;\n `)}(await Ht(),e),r=F(t[0],"CamelCase");if(0===r.length)throw`no upload with partHash = ${e}`;return M(r[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertUpload",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_uploads").setFields(t).toString();return e.exec(r)}(t,B(P(JSON.parse(e))));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateUpload",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.update().table("local_uploads").setFields(t).where(`part_hash = '${t.part_hash}'`).toString();return e.exec(r)}(t,B(P(JSON.parse(e))));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteUpload",(async function(e){try{const t=function(e,t){const r=v.delete().from("local_uploads").where(`part_hash = '${t}'`).toString();return e.exec(r)}(await Ht(),e);return M(t)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("setSqlWasmPath",(function(e){Bt=e})),Xt.registerMethod("initDB",(async function(e,t){try{const r=await Ht(`${t}${e}.sqlite`,Bt),n=[],i=function(e){return e.exec("\n create table if not exists 'local_uploads' (\n 'part_hash' text,\n 'upload_id' varchar(1000),\n 'upload_info' varchar(2000),\n 'expire_time' integer,\n 'create_time' integer,\n PRIMARY KEY ('part_hash')\n )\n ")}(r),o=function(e){return e.exec("\n create table if not exists 'local_stranger'\n (\n 'user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'app_manger_level' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'global_recv_msg_opt' integer,\n PRIMARY KEY ('user_id')\n )\n ")}(r),s=function(e){return e.exec("\n create table if not exists 'local_conversations' (\n 'conversation_id' char(128),\n 'conversation_type' integer,\n 'user_id' char(64),\n 'group_id' char(128),\n 'show_name' varchar(255),\n 'face_url' varchar(255),\n 'recv_msg_opt' integer,\n 'unread_count' integer,\n 'group_at_type' integer,\n 'latest_msg' varchar(1000),\n 'latest_msg_send_time' integer,\n 'draft_text' text,\n 'draft_text_time' integer,\n 'is_pinned' numeric,\n 'burn_duration' integer,\n 'is_private_chat' numeric,\n 'is_not_in_group' numeric,\n 'update_unread_count_time' integer,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n 'max_seq' integer,\n 'min_seq' integer,\n 'has_read_seq' integer,\n 'msg_destruct_time' integer default 604800,\n 'is_msg_destruct' numeric default false,\n primary key ('conversation_id')\n )\n ")}(r),a=function(e){return e.exec("\n create table if not exists 'local_users' (\n 'user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'app_manger_level' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'global_recv_msg_opt' integer,\n primary key ('user_id')\n )\n ")}(r),u=function(e){return e.exec("\n create table if not exists 'local_blacks' (\n 'owner_user_id' varchar(64),\n 'block_user_id' varchar(64),\n 'nickname' varchar(255),\n 'face_url' varchar(255),\n 'gender' INTEGER,\n 'create_time' INTEGER,\n 'add_source' INTEGER,\n 'operator_user_id' varchar(64),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n primary key ('owner_user_id', 'block_user_id')\n ) \n ")}(r),c=function(e){return e.exec("\n create table if not exists 'local_friends'\n (\n 'owner_user_id' varchar(64),\n 'friend_user_id' varchar(64),\n 'remark' varchar(255),\n 'create_time' INTEGER,\n 'add_source' INTEGER,\n 'operator_user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'is_pinned' numeric,\n primary key ('owner_user_id', 'friend_user_id')\n ) \n ")}(r),l=function(e){return e.exec("\n create table if not exists 'local_groups'\n (\n 'group_id' varchar(64) PRIMARY KEY,\n 'name' TEXT,\n 'notification' varchar(255),\n 'introduction' varchar(255),\n 'face_url' varchar(255),\n 'create_time' INTEGER,\n 'status' INTEGER,\n 'creator_user_id' varchar(64),\n 'group_type' INTEGER,\n 'owner_user_id' varchar(64),\n 'member_count' INTEGER,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'need_verification' INTEGER,\n 'look_member_info' INTEGER,\n 'apply_member_friend' INTEGER,\n 'notification_update_time' INTEGER,\n 'notification_user_id' TEXT,\n 'display_is_read' numeric\n ) \n ")}(r),f=function(e){return e.exec('\n create table if not exists "local_group_requests" (\n "group_id" varchar(64),\n "group_name" text,\n "notification" varchar(255),\n "introduction" varchar(255),\n "face_url" varchar(255),\n "create_time" integer,\n "status" integer,\n "creator_user_id" varchar(64),\n "group_type" integer,\n "owner_user_id" varchar(64),\n "member_count" integer,\n "user_id" varchar(64),\n "nickname" varchar(255),\n "user_face_url" varchar(255),\n "gender" integer,\n "handle_result" integer,\n "req_msg" varchar(255),\n "handle_msg" varchar(255),\n "req_time" integer,\n "handle_user_id" varchar(64),\n "handle_time" integer,\n "ex" varchar(1024),\n "attached_info" varchar(1024),\n "join_source" integer,\n "inviter_user_id" text,\n PRIMARY KEY ("group_id", "user_id")\n );\n ')}(r),d=function(e){return e.exec("\n create table if not exists 'local_group_members' (\n 'group_id' varchar(64),\n 'user_id' varchar(64),\n 'nickname' varchar(255),\n 'user_group_face_url' varchar(255),\n 'role_level' integer,\n 'join_time' integer,\n 'join_source' integer,\n 'inviter_user_id' text,\n 'mute_end_time' integer DEFAULT 0,\n 'operator_user_id' varchar(64),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n PRIMARY KEY ('group_id', 'user_id')\n ) \n ")}(r),h=function(e){return e.exec('\n create table if not exists "local_admin_group_requests" (\n "group_id" varchar(64),\n "group_name" text,\n "notification" varchar(255),\n "introduction" varchar(255),\n "face_url" varchar(255),\n "create_time" integer,\n "status" integer,\n "creator_user_id" varchar(64),\n "group_type" integer,\n "owner_user_id" varchar(64),\n "member_count" integer,\n "user_id" varchar(64),\n "nickname" varchar(255),\n "user_face_url" varchar(255),\n "gender" integer,\n "handle_result" integer,\n "req_msg" varchar(255),\n "handle_msg" varchar(255),\n "req_time" integer,\n "handle_user_id" varchar(64),\n "handle_time" integer,\n "ex" varchar(1024),\n "attached_info" varchar(1024),\n "join_source" integer,\n "inviter_user_id" text,\n PRIMARY KEY ("group_id", "user_id")\n );\n ')}(r),_=function(e){return e.exec("\n create table if not exists 'local_friend_requests'\n (\n 'from_user_id' varchar(64),\n 'from_nickname' varchar(255),\n 'from_face_url' varchar(255),\n 'to_user_id' varchar(64),\n 'to_nickname' varchar(255),\n 'to_face_url' varchar(255),\n 'handle_result' INTEGER,\n 'req_msg' varchar(255),\n 'create_time' INTEGER,\n 'handler_user_id' varchar(64),\n 'handle_msg' varchar(255),\n 'handle_time' INTEGER,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n primary key ('from_user_id', 'to_user_id')\n ); \n ")}(r),p=function(e){return e.exec("\n create table if not exists 'local_super_groups' (\n 'group_id' varchar(64),\n 'name' text,\n 'notification' varchar(255),\n 'introduction' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'status' integer,\n 'creator_user_id' varchar(64),\n 'group_type' integer,\n 'owner_user_id' varchar(64),\n 'member_count' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'need_verification' integer,\n 'look_member_info' integer,\n 'apply_member_friend' integer,\n 'notification_update_time' integer,\n 'notification_user_id' text,\n primary key ('group_id')\n )\n ")}(r),g=function(e){return e.exec("\n create table if not exists 'temp_cache_local_chat_logs' (\n 'client_msg_id' char(64),\n 'server_msg_id' char(64),\n 'send_id' char(64),\n 'recv_id' char(64),\n 'sender_platform_id' integer,\n 'sender_nick_name' varchar(255),\n 'sender_face_url' varchar(255),\n 'session_type' integer,\n 'msg_from' integer,\n 'content_type' integer,\n 'content' varchar(1000),\n 'is_read' numeric,\n 'status' integer,\n 'seq' integer DEFAULT 0,\n 'send_time' integer,\n 'create_time' integer,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n PRIMARY KEY ('client_msg_id')\n );\n ")}(r),m=function(e){return e.exec("\n create table if not exists 'local_notification_seqs'\n (\n 'conversation_id' char(128),\n 'seq' integer,\n PRIMARY KEY ('conversation_id')\n )\n ")}(r),v=function(e){return e.exec("\n create table if not exists 'local_sending_messages'\n (\n conversation_id varchar(128),\n client_msg_id varchar(64),\n ex varchar(1024),\n PRIMARY KEY ('conversation_id', 'client_msg_id')\n );\n ")}(r),y=function(e){return e.exec("\n create table if not exists 'local_conversation_unread_messages' (\n 'conversation_id' char(128),\n 'client_msg_id' char(64),\n 'send_time' integer,\n 'ex' varchar(1024),\n primary key (\n 'conversation_id',\n 'client_msg_id'\n )\n );\n ")}(r),b=function(e){return e.exec("\n create table if not exists 'local_app_sdk_version' (\n 'version' varchar(255),\n 'installed' numeric,\n primary key ('version')\n ) \n ")}(r),w=function(e){return e.exec("\n create table if not exists 'local_sync_version' (\n 'table_name' varchar(255),\n 'entity_id' varchar(255),\n 'version_id' text,\n 'version' integer,\n 'create_time' integer,\n 'id_list' text,\n primary key ('table_name','entity_id')\n ) \n ")}(r);return function(e){!function(e){try{e.exec("\n ALTER TABLE local_friends ADD COLUMN is_pinned numeric;\n ")}catch(e){}}(e),function(e){try{e.exec("\n ALTER TABLE local_groups ADD COLUMN display_is_read numeric;\n ")}catch(e){}}(e),function(e){try{e.exec("\n ALTER TABLE local_app_sdk_version ADD COLUMN installed numeric;\n ")}catch(e){}}(e)}(r),n.push(i,o,s,a,p,y,u,c,l,d,_,f,h,g,m,v,b,w),M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("close",(async function(){try{return await async function(){if(!Ct)return;(await Ct).close(),Ct=void 0}(),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMessage",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id = '${r}' limit 1\n `)}(await Ht(),e,t);return 0===r.length?M("",h.ErrorNoRecord,`no message with id ${t}`):M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMultipleMessage",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id in (${r.map((e=>`'${e}'`)).join(",")}) order by send_time desc;\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getSendingMessageList",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE status = 1;\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateMessageTimeAndStatus",(async function(e,t,r,n,i){try{const o=await Ht(),s=function(e,t,r,n,i,o){return e.exec(`\n UPDATE 'chat_logs_${t}' SET server_msg_id = '${n}', send_time = ${i}, status = ${o} WHERE client_msg_id = '${r}' and seq=0;\n `)}(o,e,t,r,n,i);if(0===o.getRowsModified())throw"updateMessageTimeAndStatus no record updated";return M(s)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateMessage",(async function(e,t,r){try{const n=await Ht(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`client_msg_id = '${r}'`).toString();return e.exec(i)}(n,e,t,B(P(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessage no record updated";return M(i)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateMessageBySeq",(async function(e,t,r){try{const n=await Ht(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`seq = '${r}'`).toString();return e.exec(i)}(n,e,t,B(P(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessageBySeq no record updated";return M(i)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateColumnsMessage",(async function(e,t,r){try{const n=await Ht(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`client_msg_id = '${r}'`).toString();return e.exec(i)}(n,e,t,B(P(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessage no record updated";return M(i)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertMessage",(async function(e,t){try{const r=await Ht(),n=function(e,t,r){const n=v.insert().into(`'chat_logs_${t}'`).setFields(r).toString();return e.exec(n)}(r,e,B(JSON.parse(t)));return M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertMessageList",(async function(e,t){try{const r=await Ht(),n=function(e,t,r){y(e,t);const n=v.insert().into(`'chat_logs_${t}'`).setFieldsRows(r).toString();return e.exec(n)}(r,e,JSON.parse(t).map((e=>B(e))));return M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMessageList",(async function(e,t,r,n=!1){if(r<=0)return Gt(e,t,n);try{const i=function(e,t,r,n,i){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE send_time ${i?">":"<"} ${n} ORDER BY send_time ${i?"ASC":"DESC"} LIMIT ${r}\n `)}(await Ht(),e,t,r,n);return M(F(i[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMessageListNoTime",Gt),Xt.registerMethod("messageIfExists",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id = '${r}';\n `)}(await Ht(),e,t);return M(0!==r.length)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("searchMessageByKeyword",(async function(e,t,r,n,i,o,s,a){try{const u=function(e,t,r,n,i,o,s,a,u){const c=s||(new Date).getTime();let l="";const f=r.map((e=>`${e}`)).join(","),d=0===i?"or ":"and ";return n.forEach(((e,t)=>{0==t&&(l+="And ("),t+1>=n.length?l+="content like '%"+n[t]+"%') ":l+="content like '%"+n[t]+"%' "+d})),e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${o} and ${c} \n AND status <=3 \n And content_type IN (${f}) \n ${l}\n ORDER BY send_time DESC LIMIT ${u} OFFSET ${a};\n `)}(await Ht(),e,JSON.parse(t),JSON.parse(r),n,i,o,s,a);return M(F(u[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("searchMessageByContentType",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){const a=r.map((e=>`${e}`)).join(","),u=i||(new Date).getTime();return e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${n} and ${u} \n AND status <=3 \n And content_type IN (${a}) \n ORDER BY send_time DESC LIMIT ${s} OFFSET ${o};\n `)}(await Ht(),e,JSON.parse(t),r,n,i,o);return M(F(s[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("searchMessageByContentTypeAndKeyword",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){const a=r.map((e=>`${e}`)).join(","),u=s||(new Date).getTime();let c="";const l=0===i?"or ":"and ";return n.forEach(((e,t)=>{0==t&&(c+="And ("),t+1>=n.length?c+="content like '%"+n[t]+"%') ":c+="content like '%"+n[t]+"%' "+l})),e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${o} and ${u} \n AND status <=3 \n And content_type IN (${a}) \n ${c}\n ORDER BY send_time DESC;\n `)}(await Ht(),e,JSON.parse(t),JSON.parse(r),n,i,o);return M(F(s[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateMsgSenderFaceURLAndSenderNickname",(async function(e,t,r,n){try{return function(e,t,r,n,i){y(e,t),e.exec(`\n UPDATE 'chat_logs_${t}' SET sender_face_url = '${n}', sender_nick_name = '${i}' WHERE send_id = '${r}';\n `)}(await Ht(),e,t,r,n),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAlreadyExistSeqList",(async function(e,t){var r;try{const n=function(e,t,r){return e.exec(`\n SELECT seq FROM 'chat_logs_${t}' WHERE seq in (${r.join(",")})\n `)}(await Ht(),e,JSON.parse(t));return M(null!==(r=F(n[0],"CamelCase",["isRead","isReact","isExternalExtensions"]).map((e=>e.seq)))&&void 0!==r?r:[])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getLatestValidServerMessage",(async function(e,t,r){try{const n=function(e,t,r,n){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE send_time ${n?"<":">"} ${r} AND seq != 0 ORDER BY send_time ${n?"DESC":"ASC"} LIMIT 1\n `)}(await Ht(),e,t,r),i=F(n[0],"CamelCase",["isRead","isReact","isExternalExtensions"])[0];return i?M(i):M("",h.ErrorNoRecord,`no message with conversationID ${e}`)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMessageBySeq",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE seq = ${r} limit 1;\n `)}(await Ht(),e,t);return 0===r.length?M("",h.ErrorNoRecord,`no message with seq ${t}`):M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMessagesByClientMsgIDs",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id in (${r.map((e=>`'${e}'`)).join(",")}) order by send_time desc;\n `)}(await Ht(),e,JSON.parse(t));return 0===r.length?M("",h.ErrorNoRecord,`no message with clientMsgIDListStr ${t}`):M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMessagesBySeqs",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE seq in (${r.join(",")}) order by send_time desc;\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getConversationNormalMsgSeq",(async function(e){var t,r;try{const n=function(e,t){return y(e,t),e.exec(`\n SELECT seq FROM 'chat_logs_${t}' order by seq desc limit 1;\n `)}(await Ht(),e);return M(null!==(r=null===(t=F(n[0],"CamelCase")[0])||void 0===t?void 0:t.seq)&&void 0!==r?r:0)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getConversationPeerNormalMsgSeq",(async function(e,t){var r,n;try{const i=function(e,t,r){return e.exec(`\n SELECT seq FROM 'chat_logs_${t}' where send_id != '${r}' order by seq desc limit 1;\n `)}(await Ht(),e,t);return M(null!==(n=null===(r=F(i[0],"CamelCase")[0])||void 0===r?void 0:r.seq)&&void 0!==n?n:0)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteConversationAllMessages",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM 'chat_logs_${t}' WHERE 1=1;\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("markDeleteConversationAllMessages",(async function(e){try{return function(e,t){e.exec(`\n UPDATE 'chat_logs_${t}' SET status = 2 WHERE (1=1) and (conversation_id = '${t}')';\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getUnreadMessage",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE send_id != '${r}' and is_read = 0;\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("markConversationMessageAsReadBySeqs",(async function(e,t,r){try{const n=await Ht();return function(e,t,r,n){y(e,t);const i=r.map((e=>`${e}`)).join(",");e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE seq IN (${i}) and send_id != '${n}';\n `)}(n,e,JSON.parse(t),r),M(n.getRowsModified())}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("markConversationMessageAsRead",(async function(e,t,r){try{const n=await Ht();return function(e,t,r,n){const i=r.map((e=>`'${e}'`)).join(",");e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE client_msg_id IN (${i}) and send_id != '${n}';\n `)}(n,e,JSON.parse(t),r),M(n.getRowsModified())}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteConversationMsgs",(async function(e,t){try{const r=function(e,t,r){const n=r.map((e=>`'${e}'`)).join(",");return e.exec(`\n DELETE FROM 'chat_logs_${t}' WHERE client_msg_id IN (${n});\n `)}(await Ht(),e,JSON.parse(t));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("markConversationAllMessageAsRead",(async function(e,t){try{const r=await Ht();return function(e,t,r){e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE is_read = 0 and send_id != '${r}';\n `)}(r,e,JSON.parse(t)),M(r.getRowsModified())}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("searchAllMessageByContentType",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE content_type = ${r};\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertSendingMessage",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_sending_messages").setFields(t).toString();return e.exec(r)}(t,B(JSON.parse(e)));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteSendingMessage",(async function(e,t){try{const r=function(e,t,r){const n=v.delete().from("local_sending_messages").where(`conversation_id = '${t}'`).where(`client_msg_id = '${r}'`).toString();return e.exec(n)}(await Ht(),e,t);return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllSendingMessages",(async function(){try{const e=function(e){const t=v.select().from("local_sending_messages").toString();return e.exec(t)}(await Ht());return M(F(e[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getLatestActiveMessage",(async function(e,t){try{const r=function(e,t,r){y(e,t);const n=r?"ASC":"DESC";return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE status < 4 ORDER BY send_time ${n};\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllConversationList",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations where latest_msg_send_time > 0 order by case when is_pinned=1 then 0 else 1 end,max(latest_msg_send_time,draft_text_time) desc;\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllConversationListToSync",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations;\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getHiddenConversationList",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations where latest_msg_send_time = 0;\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getConversation",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_conversations where conversation_id = '${t}' limit 1;\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no conversation with id ${e}`):M(F(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMultipleConversation",(async function(e){try{const t=await Ht(),r=function(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select * from local_conversations where conversation_id in (${r.join(",")});\n `)}(t,JSON.parse(e));return M(F(r[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateColumnsConversation",(async function(e,t){try{const r=await Ht();let n=t;"string"==typeof t&&(n=B(P(JSON.parse(t))));const i=function(e,t,r){const n=v.update().table("local_conversations").setFields(r).where(`conversation_id = '${t}'`).toString();return e.exec(n)}(r,e,n);if(0===r.getRowsModified())throw"updateColumnsConversation no record updated";return M(i)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("decrConversationUnreadCount",(async function(e,t){try{const r=function(e,t,r){e.exec("begin"),e.exec(`\n update local_conversations set \n unread_count=unread_count-${r} \n where conversation_id = '${t}';\n `);const n=e.exec(`select unread_count from local_conversations where conversation_id = '${t}'`);return Number(n[0].values[0])<0&&e.exec(`\n update local_conversations set \n unread_count=0 \n where conversation_id = '${t}';\n `),e.exec("commit")}(await Ht(),e,t);return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertConversationList",Yt),Xt.registerMethod("getTotalUnreadMsgCount",(async function(){var e,t,r;try{const n=function(e){return e.exec("\n select sum(unread_count) from local_conversations where recv_msg_opt < 2 and latest_msg_send_time > 0;\n ")}(await Ht());return M(null!==(r=null===(t=null===(e=n[0])||void 0===e?void 0:e.values[0])||void 0===t?void 0:t[0])&&void 0!==r?r:0)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertConversation",(async function(e){return Yt(`[${e}]`)})),Xt.registerMethod("getConversationByUserID",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_conversations where user_id = "${t}" limit 1;\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no conversation with userID ${e}`):M(F(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getConversationListSplit",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT *\n FROM local_conversations\n WHERE latest_msg_send_time > 0\n ORDER BY case\n when is_pinned = 1 then 0\n else 1 end, max(latest_msg_send_time, draft_text_time) DESC\n LIMIT ${r} OFFSET ${t}\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteConversation",(async function(e){try{return function(e,t){e.exec(`\n DELETE\n FROM local_conversations\n WHERE conversation_id = "${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteAllConversation",(async function(){try{return function(e){e.exec("\n DELETE FROM local_conversations;\n ")}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchUpdateConversationList",(async function(e){try{const t=await Ht(),r=(JSON.parse(e)||[]).map((e=>B(e)));return 0===r.length||r.forEach((e=>{!function(e,t){const r=v.update().table("local_conversations").setFields(t).where(`conversation_id = '${t.conversation_id}'`).toString();e.exec(r)}(t,e)})),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("conversationIfExists",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT count(*)\n FROM local_conversations\n WHERE conversation_id = "${t}"\n `)}(await Ht(),e);return M(0!==t.length)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("resetConversation",(async function(e){try{return function(e,t){e.exec(`\n UPDATE local_conversations\n SET unread_count=0,\n latest_msg="",\n latest_msg_send_time=0,\n draft_text="",\n draft_text_time=0\nWHERE conversation_id = "${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("resetAllConversation",(async function(){try{return function(e){e.exec('\n UPDATE local_conversations\n SET unread_count=0,\n latest_msg="",\n latest_msg_send_time=0,\n draft_text="",\n draft_text_time=0\n ')}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("clearConversation",(async function(e){try{return function(e,t){e.exec(`\n UPDATE local_conversations\nSET unread_count=0,\n latest_msg="",\n draft_text="",\n draft_text_time=0\nWHERE conversation_id = "${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("clearAllConversation",(async function(){try{return function(e){e.exec('\n UPDATE local_conversations\nSET unread_count=0,\n latest_msg="",\n draft_text="",\n draft_text_time=0\n ')}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("setConversationDraft",(async function(e,t){try{return function(e,t,r){const n=(new Date).getTime();e.exec(`\n update local_conversations\n set draft_text='${r}',\n draft_text_time=${n},\n latest_msg_send_time=case when latest_msg_send_time = 0 then ${n} else latest_msg_send_time end\n where conversation_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("removeConversationDraft",(async function(e,t){try{return function(e,t,r){e.exec(`\n update local_conversations\n set draft_text="${r}",\n draft_text_time=0\n where conversation_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("unPinConversation",(async function(e,t){try{return function(e,t,r){e.exec(`\n update local_conversations\n set is_pinned=${r},\n draft_text_time=case when draft_text = "" then 0 else draft_text_time end\n where conversation_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("incrConversationUnreadCount",(async function(e){try{const t=function(e,t){return e.exec(`\n update local_conversations set \n unread_count=unread_count+1 \n where conversation_id = '${t}';\n `)}(await Ht(),e);return M(t)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("setMultipleConversationRecvMsgOpt",(async function(e,t){try{return function(e,t,r){const n=t.map((e=>`'${e}'`)).join(",");e.exec(`\n UPDATE local_conversations\n SET recv_msg_opt=${r}\n WHERE conversation_id IN (${n})\n `)}(await Ht(),JSON.parse(e),t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("findAllUnreadConversationConversationID",(async function(){try{const e=function(e){return e.exec("\n select conversation_id from local_conversations where unread_count > 0;\n ")}(await Ht());return M(F(e[0],"CamelCase").map((e=>e.conversationID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllSingleConversationIDList",(async function(){try{const e=function(e){return e.exec("\n select conversation_id from local_conversations where conversation_type = 1;\n ")}(await Ht());return M(F(e[0],"CamelCase").map((e=>e.conversationID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllConversationIDList",(async function(){try{const e=function(e){return e.exec("\n select conversation_id from local_conversations;\n ")}(await Ht());return M(F(e[0],"CamelCase").map((e=>e.conversationID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllConversations",(async function(){try{const e=function(e){return e.exec("\n SELECT * FROM local_conversations\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("searchConversations",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_conversations\n WHERE show_name LIKE '%${t}%'\n ORDER BY latest_msg_send_time DESC\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getLoginUser",(async function(e){try{const t=function(e,t){return e.exec(`\n select *, name as nickname from local_users where user_id = '${t}' limit 1;\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no login user with id ${e}`):M(F(t[0],"CamelCase",[],{name:"nickname"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertLoginUser",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_users").setFields(t).toString();return e.exec(r)}(t,B(P(JSON.parse(e),{nickname:"name"})));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateLoginUser",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.update().table("local_users").setFields(t).where(`user_id = '${t.user_id}'`).toString();return e.exec(r)}(t,B(P(JSON.parse(e),{nickname:"name"})));if(0===t.getRowsModified())throw"updateLoginUser no record updated";return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getStrangerInfo",(async function(e){try{const t=await Ht();return M(F(k(t,JSON.parse(e))[0],"CamelCase",[],{name:"nickname"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("setStrangerInfo",(function(e){try{return JSON.parse(e).map((e=>B(P(e,{nickname:"name"})))).map((e=>async function(e){try{const t=await Ht(),r=k(t,[e.user_id]);return F(r[0]).length?function(e,t){const r=v.update().table("local_stranger").setFields(t).where(`user_id = '${t.user_id}'`).toString();e.exec(r)}(t,e):function(e,t){const r=v.insert().into("local_stranger").setFields(t).toString();e.exec(r)}(t,e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}}(e))),Promise.resolve(M(""))}catch(e){return console.error(e),Promise.resolve(M(void 0,h.ErrorInit,JSON.stringify(e)))}})),Xt.registerMethod("getAppSDKVersion",(async function(){try{const e=R(await Ht());return 0===e.length?M("",h.ErrorNoRecord,"no app version with database"):M(F(e[0],"CamelCase",["installed"])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("setAppSDKVersion",(async function(e){try{const t=await Ht(),r=B(P(JSON.parse(e))),n=F(R(t)[0],"CamelCase",["installed"]);return n[0]&&n[0].version?(function(e,t,r){const n=v.update().table("local_app_sdk_version").setFields(r).where(`version = '${t}'`).toString();e.exec(n)}(t,n[0].version,r),M("")):(function(e,t){const r=v.insert().into("local_app_sdk_version").setFields(t).toString();e.exec(r)}(t,r),M(""))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getVersionSync",(async function(e,t){try{const r=N(await Ht(),e,t);if(0===r.length)return M("",h.ErrorNoRecord,`no sync version with tableName ${e}, entityID ${t}`);const n=F(r[0],"CamelCase",[],{id_list:"uidList"})[0];return n.uidList=JSON.parse(n.uidList),M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("setVersionSync",(async function(e){try{const t=await Ht(),r=B(P(JSON.parse(e)));r.id_list=JSON.stringify(r.uid_list),delete r.uid_list;const n=F(N(t,r.table_name,r.entity_id)[0],"CamelCase",[]);return n[0]&&n[0].tableName?(function(e,t,r,n){delete n.table;const i=v.update().table("local_sync_version").setFields(n).where(`table_name = '${t}' AND entity_id = '${r}'`).toString();e.exec(i)}(t,n[0].tableName,n[0].entityID,r),M("")):(function(e,t){delete t.table;const r=v.insert().into("local_sync_version").setFields(t).toString();e.exec(r)}(t,r),M(""))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteVersionSync",(async function(e,t){try{return function(e,t,r){e.exec(`\n DELETE FROM local_sync_version WHERE table_name = "${t}" AND entity_id = "${r}";\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getJoinedSuperGroupList",(async function(){try{const e=await Ht();return M(F(b(e)[0]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getJoinedSuperGroupIDList",(async function(){try{const e=await Ht(),t=F(b(e)[0]);return M(t.map((e=>e.groupID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getSuperGroupInfoByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_super_groups where group_id = '${t}' LIMIT 1;\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no super group with id ${e}`):M(F(t[0])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteSuperGroup",(async function(e){try{const t=function(e,t){return e.exec(`\n delete from local_super_groups where group_id = '${t}';\n `)}(await Ht(),e);return M(t)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertSuperGroup",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_super_groups").setFields(t).toString();return e.exec(r)}(t,B(P(JSON.parse(e),{groupName:"name"})));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateSuperGroup",(async function(e,t){try{const r=await Ht(),n=function(e,t,r){const n=v.update().table("local_super_groups").setFields(r).where(`group_id = '${t}'`).toString();return e.exec(n)}(r,e,B(P(JSON.parse(t),{groupName:"name"})));if(0===r.getRowsModified())throw"updateSuperGroup no record updated";return M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteConversationUnreadMessageList",(async function(e,t){try{const r=await Ht();!function(e,t,r){e.exec(`\n delete from local_conversation_unread_messages where conversation_id = '${t}' and send_time <= ${r};\n `)}(r,e,t);return M(r.getRowsModified())}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertConversationUnreadMessageList",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_conversation_unread_messages").setFieldsRows(t).toString();return e.exec(r)}(t,JSON.parse(e).map((e=>B(e))));return M(r[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getBlackList",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_blacks\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{block_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getBlackListUserID",(async function(){try{const e=function(e){return e.exec("\n SELECT block_user_id\n FROM local_blacks\n ")}(await Ht());return M(F(e[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getBlackInfoByBlockUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT *\n FROM local_blacks\n WHERE owner_user_id = "${r}"\n AND block_user_id = "${t}"\n LIMIT 1\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getBlackInfoList",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_blacks\n where block_user_id in (${r.join(",")})\n `)}(await Ht(),JSON.parse(e));return M(F(t[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertBlack",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_blacks").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{userID:"block_user_id",name:"nickname"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteBlack",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_blacks\n where owner_user_id = "${r}"\n and block_user_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateBlack",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_blacks").setFields(t).where(`owner_user_id = '${t.owner_user_id}' and block_user_id = '${t.block_user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e)))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertFriendRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_friend_requests").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e)))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteFriendRequestBothUserID",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_friend_requests\n where from_user_id = "${t}"\n and to_user_id = "${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateFriendRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_friend_requests").setFields(t).where(`from_user_id = '${t.from_user_id}' and to_user_id = '${t.to_user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e)))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getRecvFriendApplication",(async function(e){try{const t=function(e,t){return e.exec(`\n select *\n from local_friend_requests\n where to_user_id = "${t}"\n order by create_time desc\n `)}(await Ht(),e);return M(F(t[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getSendFriendApplication",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_friend_requests\n where from_user_id = "${t}"\n order by create_time desc\n `)}(await Ht(),e);return M(F(t[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getFriendApplicationByBothID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friend_requests\n where from_user_id = "${t}"\n and to_user_id = "${r}"\n limit 1\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getBothFriendReq",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friend_requests\n where (from_user_id = "${t}"\n and to_user_id = "${r}")\n or (from_user_id = "${r}"\n and to_user_id = "${t}")\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertGroup",(async function(e){try{const t=await Ht();return E(t,B(P(JSON.parse(e),{groupName:"name"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteGroup",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM local_groups \n WHERE group_id="${t}" \n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateGroup",(async function(e,t){try{const r=await Ht();return function(e,t,r){const n=v.update().table("local_groups").setFields(r).where(`group_id = '${t}'`).toString();e.exec(n)}(r,e,B(P(JSON.parse(t),{groupName:"name"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getJoinedGroupList",(async function(){try{const e=await Ht();return M(F(O(e)[0],"CamelCase",["displayIsRead"],{name:"groupName"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupInfoByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT *\n FROM local_groups\n WHERE group_id = "${t}"\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no group with id ${e}`):M(F(t[0],"CamelCase",["displayIsRead"],{name:"groupName"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllGroupInfoByGroupIDOrGroupName",(async function(e,t,r){try{const n=function(e,t,r,n){let i="";const o=`group_id like "%${t}%"`,s=`name like "%${t}%"`;return r&&(i=o),n&&(i=s),n&&r&&(i=o+" or "+s),e.exec(`\n select *\n from local_groups\n where ${i}\n order by create_time desc\n `)}(await Ht(),e,t,r);return M(F(n[0],"CamelCase",["displayIsRead"],{name:"groupName"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("subtractMemberCount",(async function(e){try{return function(e,t){e.exec(` \n update local_groups set member_count = member_count-1 where group_id = '${t}'\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("addMemberCount",(async function(e){try{return function(e,t){e.exec(` \n update local_groups set member_count = member_count+1 where group_id = '${t}' \n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getJoinedWorkingGroupIDList",(async function(){try{const e=await Ht(),t=F(O(e)[0],"CamelCase",["displayIsRead"]),r=[];return t.forEach((e=>{2===e.groupType&&r.push(e.groupID)})),M(JSON.stringify(r))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getJoinedWorkingGroupList",(async function(){try{const e=O(await Ht()),t=F(e[0],"CamelCase",["displayIsRead"],{name:"groupName"}).filter((e=>2===e.groupType));return M(JSON.stringify(t))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberAllGroupIDs",(async function(){try{const e=function(e){return e.exec("\n select distinct group_id from local_group_members\n ")}(await Ht());return M(F(e[0],"CamelCase",["displayIsRead"]).map((e=>e.groupID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroups",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`)).join(",");return e.exec(`\n select * from local_groups where group_id in (${r});\n `)}(await Ht(),JSON.parse(e)),r=F(t[0],"CamelCase",["displayIsRead"],{name:"groupName"});return M(JSON.stringify(r))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertGroup",(async function(e){try{const t=await Ht();return JSON.parse(e).map((e=>{const r=B(P(e,{groupName:"name"}));return E(t,r),null})),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteAllGroup",(async function(){try{return function(e){e.exec("\n DELETE FROM local_groups;\n ")}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberInfoByGroupIDUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_group_members\n WHERE group_id = "${t}" \n AND user_id = "${r}" \n LIMIT 1\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",[],{user_group_face_url:"faceURL"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllGroupMemberList",(async function(){try{const e=function(e){return e.exec("\n SELECT *\n FROM local_group_members\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllGroupMemberUserIDList",(async function(){try{const e=function(e){return e.exec("\n SELECT user_id\n FROM local_group_members\n ")}(await Ht());return M(F(e[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberCount",(async function(e){var t,r;try{const n=function(e,t){return e.exec(`\n SELECT count(*) FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await Ht(),e);return M(null===(r=null===(t=n[0])||void 0===t?void 0:t.values[0])||void 0===r?void 0:r[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupSomeMemberInfo",(async function(e,t){try{const r=function(e,t,r){const n=r.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_group_members\n where group_id = "${t}"\n and user_id in (${n.join(",")})\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupAdminID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT user_id FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 3\n `)}(await Ht(),e);return M(F(t[0],"CamelCase").map((e=>e.userID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberListByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberListSplit",(async function(e,t,r,n,i){try{const o=function(e,t,r,n,i,o){let s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `;return 1===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 100 \n LIMIT ${i} OFFSET ${n}\n `),2===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 60 \n ORDER BY join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),3===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 20 \n ORDER BY join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),4===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 20 OR role_level = 60 ) \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),5===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 100 OR role_level = 60 ) \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),6===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And user_id != "${o}" \n LIMIT ${i} OFFSET ${n}\n `),e.exec(s)}(await Ht(),e,t,r,n,i);return M(F(o[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberOwnerAndAdmin",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level > 1 \n ORDER BY role_level DESC\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberOwner",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 2\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberListSplitByJoinTimeFilter",(async function(e,t,r,n=0,i=1e11,o){try{const s=function(e,t,r,n,i=0,o=1e11,s){let a="";a=0===s.length?`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And join_time between ${i} and ${o} \n ORDER BY join_time DESC \n LIMIT ${n} OFFSET ${r}\n `:`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And join_time between ${i} and ${o} \n And user_id NOT IN (${s.map((e=>`'${e}'`)).join(",")})\n ORDER BY join_time DESC \n LIMIT ${n} OFFSET ${r}\n `;return e.exec(a)}(await Ht(),e,t,r,n,i,JSON.parse(o));return M(F(s[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupOwnerAndAdminByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level > 1\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberUIDListByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT user_id FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await Ht(),e);return M(F(t[0],"CamelCase").map((e=>e.userID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertGroupMember",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_group_members").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{faceURL:"user_group_face_url"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertGroupMember",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_group_members").setFieldsRows(t).toString();e.exec(r)}(t,(JSON.parse(e)||[]).map((e=>B(P(e,{faceURL:"user_group_face_url"}))))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteGroupMember",(async function(e,t){try{return function(e,t,r){e.exec(`\n DELETE FROM local_group_members \n WHERE group_id="${t}" \n and user_id="${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteGroupAllMembers",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM local_group_members \n WHERE group_id="${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateGroupMember",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_group_members").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{faceURL:"user_group_face_url"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateGroupMemberField",(async function(e,t,r){try{const n=await Ht();return function(e,t,r,n){const i=v.update().table("local_group_members").setFields(n).where(`group_id = '${t}' and user_id = '${r}'`).toString();e.exec(i)}(n,e,t,B(P(JSON.parse(r),{faceURL:"user_group_face_url"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("searchGroupMembers",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){let a="";a=r?n&&i?`\n SELECT * FROM local_group_members \n WHERE ( user_id like "%${t}%" or nickname like "%${t}%" ) \n and group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n||i?`\n SELECT * FROM local_group_members \n WHERE ${n?`nickname like "%${t}%"`:`user_id like "%${t}%"`}\n and group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:`\n SELECT * FROM local_group_members \n WHERE group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n&&n?`\n SELECT * FROM local_group_members \n WHERE user_id like "%${t}%" or nickname like "%${t}%" \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n||n?`\n SELECT * FROM local_group_members \n WHERE ${n?`nickname like "%${t}%"`:`user_id like "%${t}%"`} \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:`\n SELECT * FROM local_group_members \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `;return e.exec(a)}(await Ht(),e,t,r,n,i,o);return M(F(s[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getUserJoinedGroupIDs",(async function(e){try{const t=function(e,t){return e.exec(`\n select group_id from local_group_members where user_id = "${t}";\n `)}(await Ht(),e);return M(F(t[0],"CamelCase").map((e=>e.groupID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberListByUserIDs",(async function(e,t,r){try{const n=function(e,t,r,n){const i=n.map((e=>`'${e}'`));let o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And user_id IN (${i.join(",")})\n ORDER BY role_level DESC,join_time ASC \n `;return 1===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 100 \n And user_id IN (${i.join(",")})\n `),2===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 60 \n And user_id IN (${i.join(",")})\n ORDER BY join_time ASC \n `),3===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 20 \n And user_id IN (${i.join(",")})\n ORDER BY join_time ASC \n `),4===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 20 OR role_level = 60 ) \n And user_id IN (${i.join(",")})\n ORDER BY role_level DESC,join_time ASC \n `),5===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 100 OR role_level = 60 ) \n And user_id IN (${i.join(",")})\n ORDER BY role_level DESC,join_time ASC \n `),e.exec(o)}(await Ht(),e,t,JSON.parse(r));return M(F(n[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_group_requests").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteGroupRequest",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_group_requests\n where group_id = "${t}"\n and user_id = "${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_group_requests").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getSendGroupApplication",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_group_requests\n order by create_time desc\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{face_url:"groupFaceURL",user_face_url:"userFaceURL",handle_msg:"handledMsg",handle_time:"handledTime"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertAdminGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_admin_group_requests").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteAdminGroupRequest",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_admin_group_requests\n where group_id = "${t}"\n and user_id = "${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateAdminGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_admin_group_requests").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAdminGroupApplication",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_admin_group_requests\n order by create_time desc\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{face_url:"groupFaceURL",user_face_url:"userFaceURL",handle_msg:"handledMsg",handle_time:"handledTime"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertFriend",(async function(e){try{const t=await Ht();return w(t,B(P(JSON.parse(e),{userID:"friend_user_id",nickname:"name"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteFriend",(async function(e,t){try{return function(e,t,r){e.exec(`\n DELETE FROM local_friends \n WHERE owner_user_id="${r}" \n and friend_user_id="${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateFriend",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_friends").setFields(t).where(`owner_user_id = '${t.owner_user_id}' and friend_user_id = '${t.friend_user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{userID:"friend_user_id",nickname:"name"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllFriendList",(async function(e){try{const t=function(e,t){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${t}"\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("searchFriendList",(async function(e,t,r,n){try{const i=function(e,t,r,n,i){let o="";const s=`name like "%${t}%"`,a=`remark like "%${t}%"`;return r&&(o=`friend_user_id like "%${t}%"`),n&&(o=o?o+" or "+s:s),i&&(o=o?o+" or "+a:a),e.exec(`\n select *\n from local_friends\n where ${o}\n order by create_time desc\n `)}(await Ht(),e,t,r,n);return M(F(i[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getFriendInfoByFriendUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${r}"\n and friend_user_id = "${t}"\n limit 1\n `)}(await Ht(),e,t);return 0===r.length?M("",h.ErrorNoRecord,`no friend with id ${e}`):M(F(r[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getFriendInfoList",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`)).join(",");return e.exec(`\n select *\n from local_friends\n where friend_user_id in (${r})\n `)}(await Ht(),JSON.parse(e));return M(F(t[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getPageFriendList",(async function(e,t,r){try{const n=function(e,t,r,n){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${n}"\n order by name\n limit ${r} offset ${t}\n `)}(await Ht(),e,t,r);return M(F(n[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateColumnsFriend",(async function(e,t){try{const r=await Ht(),n=B(P(JSON.parse(t),{userID:"friend_user_id",nickname:"name"}));return function(e,t,r){const n=t.map((e=>`'${e}'`)).join(","),i=v.update().table("local_friends").setFields(r).where(`friend_user_id IN (${n})`).toString();e.exec(i)}(r,JSON.parse(e),n),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getFriendListCount",(async function(){var e,t,r;try{const n=function(e){return e.exec("\n SELECT COUNT(*) FROM local_friends;\n ")}(await Ht());return M(null!==(r=null===(t=null===(e=n[0])||void 0===e?void 0:e.values[0])||void 0===t?void 0:t[0])&&void 0!==r?r:0)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertFriend",(async function(e){try{const t=await Ht();return JSON.parse(e).map((e=>{const r=B(P(e,{userID:"friend_user_id",nickname:"name"}));return w(t,r),null})),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteAllFriend",(async function(){try{return function(e){e.exec("\n DELETE FROM local_friends;\n ")}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertTempCacheMessageList",Vt),Xt.registerMethod("InsertTempCacheMessage",(async function(e){return Vt(`[${e}]`)})),Xt.registerMethod("getNotificationAllSeqs",(async function(){try{const e=function(e){return e.exec("SELECT * from local_notification_seqs where 1 = 1;")}(await Ht());return M(F(e[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertNotificationSeq",(async function(e){try{const t=JSON.parse(e),r=await Ht();return t.map((e=>{const{conversationID:t,seq:n}=e;S(r,t,n)})),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("setNotificationSeq",(async function(e,t){try{const r=await Ht();let n=function(e,t,r){return e.exec(`UPDATE local_notification_seqs set seq = ${r} where conversation_id = "${t}"`)}(r,e,t);return 0===r.getRowsModified()&&(n=S(r,e,t)),M(n[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getExistedTables",(async function(){try{const e=function(e){return e.exec('\n SELECT name FROM sqlite_master WHERE type="table";\n ')}(await Ht());return M(F(e[0],"CamelCase",[],{tbl_name:"tblName"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("exec",(async e=>{const t=await Ht();try{const r=t.exec(e);console.info(`sql debug with exec sql = ${e.trim()} , return `,r)}catch(t){console.info(`sql debug with exec sql = ${e} , return `,t)}})),Xt.registerMethod("getRowsModified",(async()=>{const e=await Ht();try{const t=e.getRowsModified();console.info("sql debug with getRowsModified return ",t)}catch(e){console.info("sql debug with getRowsModified return ",e)}})),Xt.registerMethod("exportDB",(async()=>{const e=await Ht();try{const t=e.export(),r=new Blob([t]);return URL.createObjectURL(r)}catch(e){console.info("sql export error, return ",e)}}))}(); diff --git a/ruoyi-ui/public/worker.js b/ruoyi-ui/public/worker.js new file mode 100644 index 0000000..19ac85f --- /dev/null +++ b/ruoyi-ui/public/worker.js @@ -0,0 +1 @@ +var e=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,s=(t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,a=(e,t)=>{for(var r in t||(t={}))i.call(t,r)&&s(e,r,t[r]);if(n)for(var r of n(t))o.call(t,r)&&s(e,r,t[r]);return e},u=(e,n)=>t(e,r(n)),c=(e,t,r)=>(s(e,"symbol"!=typeof t?t+"":t,r),r);const l={CONNECT_TIMEOUT:{code:-32300,message:"Connect timeout"},APPLICATION_ERROR:{code:-32500,message:"Application error"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found"}};const f=class{constructor(e){c(this,"_event"),c(this,"_methods",{}),c(this,"_timeout",0),c(this,"_$connect",null),this._event=e.event,this._timeout=e.timeout||0,e.methods&&Object.entries(e.methods).forEach((([e,t])=>{this.registerMethod(e,t)})),this._event.onerror=e=>{const{code:t,message:r,data:n}=e;if(n.event&&Array.isArray(n.args)&&n.args.length){const e=n.args[0],i=this._getAckEventName(e.method),o={jsonrpc:"2.0",id:null==e?void 0:e.id,error:{code:t,message:r,data:e}};this._event.emit(i,o)}else console.error(e)},this.connect()}static uuid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"==e?t:3&t|8).toString(16)}))}_getSynEventName(e){return`${f.EVENT.SYN_SIGN}${e}`}_getAckEventName(e){return`${f.EVENT.ACK_SIGN}${e}`}connect(e){return this._$connect||(this._$connect=new Promise(((t,r)=>{const n=e||this._timeout;let i;n&&(i=setTimeout((()=>{const e=u(a({},l.TIMEOUT),{data:{timeout:n}});r(e)}),n));const o=f.EVENT.CONNECT,s=this._getAckEventName(o),c=this._getSynEventName(o),d=()=>{clearTimeout(i),t()};this._event.on(s,d);this._event.on(c,(()=>{this._event.emit(s),d()})),this._event.emit(c)}))),this._$connect}registerMethod(e,t){if(this._methods[e])throw new Error(`${e} already registered`);this._methods[e]=t;const r=this._getSynEventName(e);this._event.on(r,(r=>{const n=this._getAckEventName(e);r.id?Promise.resolve(t(...r.params)).then((e=>{const t={jsonrpc:"2.0",result:e,id:r.id};this._event.emit(n,t)})).catch((e=>{const t={jsonrpc:"2.0",id:r.id,error:{code:(null==e?void 0:e.code)||l.APPLICATION_ERROR.code,message:(null==e?void 0:e.message)||l.APPLICATION_ERROR.message,data:null}};this._event.emit(n,t)})):t(...r.params)}))}removeMethod(e){this._methods[e]||delete this._methods[e];const t=this._getSynEventName(e);this._event.off(t)}invoke(e,...t){return new Promise(((r,n)=>{const i=t[t.length-1],o=i&&"object"==typeof i&&(Reflect.has(i,"isNotify")||Reflect.has(i,"timeout")),s=o?i:{isNotify:!1,timeout:0},c=o?t.slice(0,-1):t,d=this._getSynEventName(e),h=f.uuid(),_={jsonrpc:"2.0",method:e,params:c,id:h};if(this._event.emit(d,_),s.isNotify)r(void 0);else{const t=this._getAckEventName(e),i=s.timeout||this._timeout;let o;i&&(o=setTimeout((()=>{const e=u(a({},l.CONNECT_TIMEOUT),{data:{timeout:i}});n(e)}),i));const c=e=>{e.id===h&&(clearTimeout(o),this._event.off(t,c),e.error?n(e.error):r(e.result))};this._event.on(t,c)}}))}destroy(){Object.entries(this._methods).forEach((([e])=>{const t=this._getSynEventName(e);this._event.off(t)}));const e=this._getAckEventName(f.EVENT.CONNECT),t=this._getSynEventName(f.EVENT.CONNECT);this._event.off(t),this._event.off(e),this._event.destroy&&this._event.destroy()}};let d=f;c(d,"CODES",l),c(d,"EVENT",{SYN_SIGN:"syn:",ACK_SIGN:"ack:",CONNECT:"__rpc_connect_event",SYNC_METHODS:"__rpc_sync_methods_event"});const h={ErrorInit:10001,ErrorNoRecord:10002,ErrorDBTimeout:10003};var _;!function(e){e.Login="Login",e.OnConnectFailed="OnConnectFailed",e.OnConnectSuccess="OnConnectSuccess",e.OnConnecting="OnConnecting",e.OnKickedOffline="OnKickedOffline",e.OnSelfInfoUpdated="OnSelfInfoUpdated",e.OnUserTokenExpired="OnUserTokenExpired",e.OnUserTokenInvalid="OnUserTokenInvalid",e.OnProgress="OnProgress",e.OnRecvNewMessage="OnRecvNewMessage",e.OnRecvNewMessages="OnRecvNewMessages",e.OnRecvOnlineOnlyMessage="OnRecvOnlineOnlyMessage",e.OnRecvOfflineNewMessage="onRecvOfflineNewMessage",e.OnRecvOnlineOnlyMessages="OnRecvOnlineOnlyMessages",e.OnRecvOfflineNewMessages="onRecvOfflineNewMessages",e.OnRecvMessageRevoked="OnRecvMessageRevoked",e.OnNewRecvMessageRevoked="OnNewRecvMessageRevoked",e.OnRecvC2CReadReceipt="OnRecvC2CReadReceipt",e.OnRecvGroupReadReceipt="OnRecvGroupReadReceipt",e.OnConversationChanged="OnConversationChanged",e.OnNewConversation="OnNewConversation",e.OnConversationUserInputStatusChanged="OnConversationUserInputStatusChanged",e.OnSyncServerFailed="OnSyncServerFailed",e.OnSyncServerFinish="OnSyncServerFinish",e.OnSyncServerProgress="OnSyncServerProgress",e.OnSyncServerStart="OnSyncServerStart",e.OnTotalUnreadMessageCountChanged="OnTotalUnreadMessageCountChanged",e.OnBlackAdded="OnBlackAdded",e.OnBlackDeleted="OnBlackDeleted",e.OnFriendApplicationAccepted="OnFriendApplicationAccepted",e.OnFriendApplicationAdded="OnFriendApplicationAdded",e.OnFriendApplicationDeleted="OnFriendApplicationDeleted",e.OnFriendApplicationRejected="OnFriendApplicationRejected",e.OnFriendInfoChanged="OnFriendInfoChanged",e.OnFriendAdded="OnFriendAdded",e.OnFriendDeleted="OnFriendDeleted",e.OnJoinedGroupAdded="OnJoinedGroupAdded",e.OnJoinedGroupDeleted="OnJoinedGroupDeleted",e.OnGroupDismissed="OnGroupDismissed",e.OnGroupMemberAdded="OnGroupMemberAdded",e.OnGroupMemberDeleted="OnGroupMemberDeleted",e.OnGroupApplicationAdded="OnGroupApplicationAdded",e.OnGroupApplicationDeleted="OnGroupApplicationDeleted",e.OnGroupInfoChanged="OnGroupInfoChanged",e.OnGroupMemberInfoChanged="OnGroupMemberInfoChanged",e.OnGroupApplicationAccepted="OnGroupApplicationAccepted",e.OnGroupApplicationRejected="OnGroupApplicationRejected",e.UploadComplete="UploadComplete",e.OnRecvCustomBusinessMessage="OnRecvCustomBusinessMessage",e.OnUserStatusChanged="OnUserStatusChanged",e.OnUploadLogsProgress="OnUploadLogsProgress",e.OnReceiveNewInvitation="OnReceiveNewInvitation",e.OnInviteeAccepted="OnInviteeAccepted",e.OnInviteeRejected="OnInviteeRejected",e.OnInvitationCancelled="OnInvitationCancelled",e.OnHangUp="OnHangUp",e.OnInvitationTimeout="OnInvitationTimeout",e.OnInviteeAcceptedByOtherDevice="OnInviteeAcceptedByOtherDevice",e.OnInviteeRejectedByOtherDevice="OnInviteeRejectedByOtherDevice",e.OnStreamChange="OnStreamChange",e.OnRoomParticipantConnected="OnRoomParticipantConnected",e.OnRoomParticipantDisconnected="OnRoomParticipantDisconnected",e.OnReceiveCustomSignal="OnReceiveCustomSignal",e.UnUsedEvent="UnUsedEvent"}(_||(_={}));"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function p(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function g(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var r=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var m={exports:{}};m.exports=function(){var e=function e(t,r,n){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,r);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,r,n)}if("value"in i)return i.value;var s=i.get;return void 0!==s?s.call(n):void 0},t=function(){function e(e,t){for(var r=0;r1?t-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:null,_={isSquelBuilder:function(e){return e&&!!e._toParamString}},p=function(e){return!_.isSquelBuilder(e)||!e.options.rawNesting};_.DefaultQueryBuilderOptions={autoQuoteTableNames:!1,autoQuoteFieldNames:!1,autoQuoteAliasNames:!0,useAsForTableAliasNames:!1,nameQuoteCharacter:"`",tableAliasQuoteCharacter:"`",fieldAliasQuoteCharacter:'"',valueHandlers:[],parameterCharacter:"?",numberedParameters:!1,numberedParametersPrefix:"$",numberedParametersStartAt:1,replaceSingleQuotes:!1,singleQuoteReplacement:"''",separator:" ",stringFormatter:null,rawNesting:!1},_.globalValueHandlers=[],_.registerValueHandler=function(e,t){f(_.globalValueHandlers,e,t)},_.Cloneable=function(){function e(){o(this,e)}return t(e,[{key:"clone",value:function(){return a(new this.constructor,l(a({},this)))}}]),e}(),_.BaseBuilder=function(e){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this)),r=JSON.parse(JSON.stringify(_.DefaultQueryBuilderOptions));return["stringFormatter"].forEach((function(e){r[e]=_.DefaultQueryBuilderOptions[e]})),t.options=a({},r,e),t}return i(s,e),t(s,[{key:"registerValueHandler",value:function(e,t){return f(this.options.valueHandlers,e,t),this}},{key:"_sanitizeExpression",value:function(e){if(!_.isSquelBuilder(e)&&"string"!=typeof e)throw new Error("expression must be a string or builder instance");return e}},{key:"_sanitizeName",value:function(e,t){if("string"!=typeof e)throw new Error(t+" must be a string");return e}},{key:"_sanitizeField",value:function(e){return _.isSquelBuilder(e)||(e=this._sanitizeName(e,"field name")),e}},{key:"_sanitizeBaseBuilder",value:function(e){if(_.isSquelBuilder(e))return e;throw new Error("must be a builder instance")}},{key:"_sanitizeTable",value:function(e){if("string"!=typeof e)try{e=this._sanitizeBaseBuilder(e)}catch(e){throw new Error("table name must be a string or a builder")}else e=this._sanitizeName(e,"table");return e}},{key:"_sanitizeTableAlias",value:function(e){return this._sanitizeName(e,"table alias")}},{key:"_sanitizeFieldAlias",value:function(e){return this._sanitizeName(e,"field alias")}},{key:"_sanitizeLimitOffset",value:function(e){if(0>(e=parseInt(e))||isNaN(e))throw new Error("limit/offset must be >= 0");return e}},{key:"_sanitizeValue",value:function(e){var t=void 0===e?"undefined":r(e);if(null===e);else if("string"===t||"number"===t||"boolean"===t);else if(_.isSquelBuilder(e));else if(!d(e,this.options.valueHandlers,_.globalValueHandlers))throw new Error("field value must be a string, number, boolean, null or one of the registered custom value types");return e}},{key:"_escapeValue",value:function(e){return this.options.replaceSingleQuotes&&e?e.replace(/\'/g,this.options.singleQuoteReplacement):e}},{key:"_formatTableName",value:function(e){if(this.options.autoQuoteTableNames){var t=this.options.nameQuoteCharacter;e=""+t+e+t}return e}},{key:"_formatFieldAlias",value:function(e){if(this.options.autoQuoteAliasNames){var t=this.options.fieldAliasQuoteCharacter;e=""+t+e+t}return e}},{key:"_formatTableAlias",value:function(e){if(this.options.autoQuoteAliasNames){var t=this.options.tableAliasQuoteCharacter;e=""+t+e+t}return this.options.useAsForTableAliasNames?"AS "+e:e}},{key:"_formatFieldName",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.options.autoQuoteFieldNames){var r=this.options.nameQuoteCharacter;e=t.ignorePeriodsForFieldNameQuotes?""+r+e+r:e.split(".").map((function(e){return"*"===e?e:""+r+e+r})).join(".")}return e}},{key:"_formatCustomValue",value:function(e,t,r){var n=d(e,this.options.valueHandlers,_.globalValueHandlers);return n&&(e=n(e,t,r))&&e.rawNesting?{formatted:!0,rawNesting:!0,value:e.value}:{formatted:!!n,value:e}}},{key:"_formatValueForParamArray",value:function(e){var t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return c(e)?e.map((function(e){return t._formatValueForParamArray(e,r)})):this._formatCustomValue(e,!0,r).value}},{key:"_formatValueForQueryString",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=this._formatCustomValue(e,!1,n),o=i.rawNesting,s=i.formatted,a=i.value;if(s)return o?a:this._applyNestingFormatting(a,p(e));if(c(a))a=a.map((function(e){return t._formatValueForQueryString(e)})),a=this._applyNestingFormatting(a.join(", "),p(a));else{var u=void 0===a?"undefined":r(a);if(null===a)a="NULL";else if("boolean"===u)a=a?"TRUE":"FALSE";else if(_.isSquelBuilder(a))a=this._applyNestingFormatting(a.toString(),p(a));else if("number"!==u){if("string"===u&&this.options.stringFormatter)return this.options.stringFormatter(a);a=n.dontQuote?""+a:"'"+this._escapeValue(a)+"'"}}return a}},{key:"_applyNestingFormatting",value:function(e){if(e&&"string"==typeof e&&(!(arguments.length>1&&void 0!==arguments[1])||arguments[1])&&!this.options.rawNesting){var t="("===e.charAt(0)&&")"===e.charAt(e.length-1);if(t)for(var r=0,n=1;e.length-1>++r;){var i=e.charAt(r);if("("===i)n++;else if(")"===i&&1>--n){t=!1;break}}t||(e="("+e+")")}return e}},{key:"_buildString",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.nested,i=r.buildParameterized,o=r.formattingOptions;t=t||[],e=e||"";for(var s="",a=-1,u=[],l=this.options.parameterCharacter,f=0;e.length>f;)if(e.substr(f,l.length)===l){var d=t[++a];if(i)if(_.isSquelBuilder(d)){var h=d._toParamString({buildParameterized:i,nested:!0});s+=h.text,h.values.forEach((function(e){return u.push(e)}))}else c(d=this._formatValueForParamArray(d,o))?(s+="("+d.map((function(){return l})).join(", ")+")",d.forEach((function(e){return u.push(e)}))):(s+=l,u.push(d));else s+=this._formatValueForQueryString(d,o);f+=l.length}else s+=e.charAt(f),f++;return{text:this._applyNestingFormatting(s,!!n),values:u}}},{key:"_buildManyStrings",value:function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=[],i=[],o=0;e.length>o;++o){var s=e[o],a=t[o],u=this._buildString(s,a,{buildParameterized:r.buildParameterized,nested:!1}),c=u.text,l=u.values;n.push(c),l.forEach((function(e){return i.push(e)}))}return{text:(n=n.join(this.options.separator)).length?this._applyNestingFormatting(n,!!r.nested):"",values:i}}},{key:"_toParamString",value:function(e){throw new Error("Not yet implemented")}},{key:"toString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._toParamString(e).text}},{key:"toParam",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._toParamString(a({},e,{buildParameterized:!0}))}}]),s}(_.Cloneable),_.Expression=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._nodes=[],t}return i(r,e),t(r,[{key:"and",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n1?t-1:0),n=1;n0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._nodes[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.type,l=u.expr,f=u.para,d=_.isSquelBuilder(l)?l._toParamString({buildParameterized:e.buildParameterized,nested:!0}):this._buildString(l,f,{buildParameterized:e.buildParameterized}),h=d.text,p=d.values;t.length&&t.push(c),t.push(h),p.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return t=t.join(" "),{text:this._applyNestingFormatting(t,!!e.nested),values:r}}}]),r}(_.BaseBuilder),_.Case=function(e){function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t));return u(e)&&(t=e,e=null),e&&(i._fieldName=i._sanitizeField(e)),i.options=a({},_.DefaultQueryBuilderOptions,t),i._cases=[],i._elseValue=null,i}return i(r,e),t(r,[{key:"when",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._cases[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.expression,f=c.values,d=c.result;t=s(t," ");var h=this._buildString(l,f,{buildParameterized:e.buildParameterized,nested:!0});t+="WHEN "+h.text+" THEN "+this._formatValueForQueryString(d),h.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return t.length?(t+=" ELSE "+this._formatValueForQueryString(this._elseValue)+" END",this._fieldName&&(t=this._fieldName+" "+t),t="CASE "+t):t=this._formatValueForQueryString(this._elseValue),{text:t,values:r}}}]),r}(_.BaseBuilder),_.Block=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e))}return i(r,e),t(r,[{key:"exposedMethods",value:function(){for(var e={},t=this;t;)Object.getOwnPropertyNames(t).forEach((function(r){"constructor"===r||"function"!=typeof t[r]||"_"===r.charAt(0)||_.Block.prototype[r]||(e[r]=t[r])})),t=Object.getPrototypeOf(t);return e}}]),r}(_.BaseBuilder),_.StringBlock=function(e){function r(e,t){o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return i._str=t,i}return i(r,e),t(r,[{key:"_toParamString",value:function(){return{text:this._str,values:[]}}}]),r}(_.Block),_.FunctionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._strings=[],t._values=[],t}return i(r,e),t(r,[{key:"function",value:function(e){this._strings.push(e);for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n0&&void 0!==arguments[0]?arguments[0]:{};return this._buildManyStrings(this._strings,this._values,e)}}]),r}(_.Block),_.registerValueHandler(_.FunctionBlock,(function(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?e.toParam():e.toString()})),_.AbstractTableBlock=function(e){function r(e,t){o(this,r);var i=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return i._tables=[],i}return i(r,e),t(r,[{key:"_table",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;t=t?this._sanitizeTableAlias(t):t,e=this._sanitizeTable(e),this.options.singleTable&&(this._tables=[]),this._tables.push({table:e,alias:t})}},{key:"_hasTable",value:function(){return 00&&void 0!==arguments[0]?arguments[0]:{},t="",r=[];if(this._hasTable()){var n=!0,i=!1,o=void 0;try{for(var a,u=this._tables[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.table,f=c.alias;t=s(t,", ");var d=void 0;if(_.isSquelBuilder(l)){var h=l._toParamString({buildParameterized:e.buildParameterized,nested:!0}),p=h.text,g=h.values;d=p,g.forEach((function(e){return r.push(e)}))}else d=this._formatTableName(l);f&&(d+=" "+this._formatTableAlias(f)),t+=d}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}this.options.prefix&&(t=this.options.prefix+" "+t)}return{text:t,values:r}}}]),r}(_.Block),_.TargetTableBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"target",value:function(e){this._table(e)}}]),r}(_.AbstractTableBlock),_.UpdateTableBlock=function(r){function s(){return o(this,s),n(this,(s.__proto__||Object.getPrototypeOf(s)).apply(this,arguments))}return i(s,r),t(s,[{key:"table",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._table(e,t)}},{key:"_toParamString",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this._hasTable())throw new Error("table() needs to be called");return e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t)}}]),s}(_.AbstractTableBlock),_.FromTableBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{prefix:"FROM"})))}return i(r,e),t(r,[{key:"from",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this._table(e,t)}}]),r}(_.AbstractTableBlock),_.IntoTableBlock=function(r){function s(e){return o(this,s),n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,a({},e,{prefix:"INTO",singleTable:!0})))}return i(s,r),t(s,[{key:"into",value:function(e){this._table(e)}},{key:"_toParamString",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this._hasTable())throw new Error("into() needs to be called");return e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t)}}]),s}(_.AbstractTableBlock),_.GetFieldBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._fields=[],t}return i(r,e),t(r,[{key:"fields",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(c(e)){var r=!0,n=!1,i=void 0;try{for(var o,s=e[Symbol.iterator]();!(r=(o=s.next()).done);r=!0){var a=o.value;this.field(a,null,t)}}catch(e){n=!0,i=e}finally{try{!r&&s.return&&s.return()}finally{if(n)throw i}}}else for(var u in e){var l=e[u];this.field(u,l,t)}}},{key:"field",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t=t?this._sanitizeFieldAlias(t):t,e=this._sanitizeField(e),this._fields.filter((function(r){return r.name===e&&r.alias===t})).length)return this;this._fields.push({name:e,alias:t,options:r})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.queryBuilder,r=e.buildParameterized,n="",i=[],o=!0,a=!1,u=void 0;try{for(var c,l=this._fields[Symbol.iterator]();!(o=(c=l.next()).done);o=!0){var f=c.value;n=s(n,", ");var d=f.name,h=f.alias,p=f.options;if("string"==typeof d)n+=this._formatFieldName(d,p);else{var g=d._toParamString({nested:!0,buildParameterized:r});n+=g.text,g.values.forEach((function(e){return i.push(e)}))}h&&(n+=" AS "+this._formatFieldAlias(h))}}catch(e){a=!0,u=e}finally{try{!o&&l.return&&l.return()}finally{if(a)throw u}}if(!n.length){var m=t&&t.getBlock(_.FromTableBlock);m&&m._hasTable()&&(n="*")}return{text:n,values:i}}}]),r}(_.Block),_.AbstractSetFieldBlock=function(e){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));return t._reset(),t}return i(s,e),t(s,[{key:"_reset",value:function(){this._fields=[],this._values=[[]],this._valueOptions=[[]]}},{key:"_set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(this._values.length>1)throw new Error("Cannot set multiple rows of fields this way.");void 0!==t&&(t=this._sanitizeValue(t)),e=this._sanitizeField(e);var n=this._fields.indexOf(e);-1===n&&(this._fields.push(e),n=this._fields.length-1),this._values[0][n]=t,this._valueOptions[0][n]=r}},{key:"_setFields",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==(void 0===e?"undefined":r(e)))throw new Error("Expected an object but got "+(void 0===e?"undefined":r(e)));for(var n in e)this._set(n,e[n],t)}},{key:"_setFieldsRows",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!c(e))throw new Error("Expected an array of objects but got "+(void 0===e?"undefined":r(e)));this._reset();for(var n=0;e.length>n;++n){var i=e[n];for(var o in i){var s=i[o];o=this._sanitizeField(o),s=this._sanitizeValue(s);var a=this._fields.indexOf(o);if(00&&void 0!==arguments[0]?arguments[0]:{}).buildParameterized;if(0>=this._fields.length)throw new Error("set() needs to be called");for(var t="",r=[],n=0;ni.indexOf("=")&&(i=i+" = "+this.options.parameterCharacter);var a=this._buildString(i,[o],{buildParameterized:e,formattingOptions:this._valueOptions[0][n]});t+=a.text,a.values.forEach((function(e){return r.push(e)}))}return{text:"SET "+t,values:r}}}]),r}(_.AbstractSetFieldBlock),_.InsertFieldValueBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._set(e,t,r)}},{key:"setFields",value:function(e,t){this._setFields(e,t)}},{key:"setFieldsRows",value:function(e,t){this._setFieldsRows(e,t)}},{key:"_toParamString",value:function(){for(var e=this,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).buildParameterized,r=this._fields.map((function(t){return e._formatFieldName(t)})).join(", "),n=[],i=[],o=0;o0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[];if(this._fields.length&&this._query){var n=this._query._toParamString({buildParameterized:e.buildParameterized,nested:!0}),i=n.text,o=n.values;t="("+this._fields.join(", ")+") "+this._applyNestingFormatting(i),r=o}return{text:t,values:r}}}]),r}(_.Block),_.DistinctBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"distinct",value:function(){this._useDistinct=!0}},{key:"_toParamString",value:function(){return{text:this._useDistinct?"DISTINCT":"",values:[]}}}]),r}(_.Block),_.GroupByBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._groups=[],t}return i(r,e),t(r,[{key:"group",value:function(e){this._groups.push(this._sanitizeField(e))}},{key:"_toParamString",value:function(){return{text:this._groups.length?"GROUP BY "+this._groups.join(", "):"",values:[]}}}]),r}(_.Block),_.AbstractVerbSingleValueBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._value=null,t}return i(r,e),t(r,[{key:"_setValue",value:function(e){this._value=null!==e?this._sanitizeLimitOffset(e):e}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=null!==this._value?this.options.verb+" "+this.options.parameterCharacter:"",r=null!==this._value?[this._value]:[];return this._buildString(t,r,e)}}]),r}(_.Block),_.OffsetBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"OFFSET"})))}return i(r,e),t(r,[{key:"offset",value:function(e){this._setValue(e)}}]),r}(_.AbstractVerbSingleValueBlock),_.LimitBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"LIMIT"})))}return i(r,e),t(r,[{key:"limit",value:function(e){this._setValue(e)}}]),r}(_.AbstractVerbSingleValueBlock),_.AbstractConditionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._conditions=[],t}return i(r,e),t(r,[{key:"_condition",value:function(e){e=this._sanitizeExpression(e);for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._conditions[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.expr,l=u.values,f=_.isSquelBuilder(c)?c._toParamString({buildParameterized:e.buildParameterized}):this._buildString(c,l,{buildParameterized:e.buildParameterized});f.text.length&&t.push(f.text),f.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return t.length&&(t=t.join(") AND (")),{text:t.length?this.options.verb+" ("+t+")":"",values:r}}}]),r}(_.Block),_.WhereBlock=function(e){function r(e){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,a({},e,{verb:"WHERE"})))}return i(r,e),t(r,[{key:"where",value:function(e){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n1?t-1:0),n=1;n2?r-2:0),i=2;i0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._orders[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var l=a.value,f=l.field,d=l.dir,h=l.values;t=s(t,", ");var _=this._buildString(f,h,{buildParameterized:e.buildParameterized});t+=_.text,c(_.values)&&_.values.forEach((function(e){return r.push(e)})),null!==d&&(t+=" "+d)}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t.length?"ORDER BY "+t:"",values:r}}}]),r}(_.Block),_.JoinBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._joins=[],t}return i(r,e),t(r,[{key:"join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"INNER";e=this._sanitizeTable(e,!0),t=t?this._sanitizeTableAlias(t):t,r=r?this._sanitizeExpression(r):r,this._joins.push({type:n,table:e,alias:t,condition:r})}},{key:"left_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"LEFT")}},{key:"right_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"RIGHT")}},{key:"outer_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"OUTER")}},{key:"left_outer_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"LEFT OUTER")}},{key:"full_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"FULL")}},{key:"cross_join",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.join(e,t,r,"CROSS")}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._joins[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.type,f=c.table,d=c.alias,h=c.condition;t=s(t,this.options.separator);var p=void 0;if(_.isSquelBuilder(f)){var g=f._toParamString({buildParameterized:e.buildParameterized,nested:!0});g.values.forEach((function(e){return r.push(e)})),p=g.text}else p=this._formatTableName(f);if(t+=l+" JOIN "+p,d&&(t+=" "+this._formatTableAlias(d)),h){t+=" ON ";var m=void 0;m=_.isSquelBuilder(h)?h._toParamString({buildParameterized:e.buildParameterized}):this._buildString(h,[],{buildParameterized:e.buildParameterized}),t+=this._applyNestingFormatting(m.text),m.values.forEach((function(e){return r.push(e)}))}}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t,values:r}}}]),r}(_.Block),_.UnionBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._unions=[],t}return i(r,e),t(r,[{key:"union",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"UNION";e=this._sanitizeTable(e),this._unions.push({type:t,table:e})}},{key:"union_all",value:function(e){this.union(e,"UNION ALL")}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=!0,i=!1,o=void 0;try{for(var a,u=this._unions[Symbol.iterator]();!(n=(a=u.next()).done);n=!0){var c=a.value,l=c.type,f=c.table;t=s(t,this.options.separator);var d=void 0;if(f instanceof _.BaseBuilder){var h=f._toParamString({buildParameterized:e.buildParameterized,nested:!0});d=h.text,h.values.forEach((function(e){return r.push(e)}))}else t=this._formatTableName(f);t+=l+" "+d}}catch(e){i=!0,o=e}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return{text:t,values:r}}}]),r}(_.Block),_.QueryBuilder=function(r){function s(e,t){o(this,s);var r=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));r.blocks=t||[];var i=!0,a=!1,u=void 0;try{for(var c,l=r.blocks[Symbol.iterator]();!(i=(c=l.next()).done);i=!0){var f=c.value,d=f.exposedMethods();for(var h in d){var _=d[h];if(void 0!==r[h])throw new Error("Builder already has a builder method called: "+h);!function(e,t,n){r[t]=function(){for(var t=arguments.length,i=Array(t),o=0;o0&&void 0!==arguments[0]?arguments[0]:{};t=a({},this.options,t);var r=this.blocks.map((function(r){return r._toParamString({buildParameterized:t.buildParameterized,queryBuilder:e})})),n=r.map((function(e){return e.text})),i=r.map((function(e){return e.values})),o=n.filter((function(e){return 01&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"SELECT"),new _.FunctionBlock(e),new _.DistinctBlock(e),new _.GetFieldBlock(e),new _.FromTableBlock(e),new _.JoinBlock(e),new _.WhereBlock(e),new _.GroupByBlock(e),new _.HavingBlock(e),new _.OrderByBlock(e),new _.LimitBlock(e),new _.OffsetBlock(e),new _.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder),_.Update=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"UPDATE"),new _.UpdateTableBlock(e),new _.SetFieldBlock(e),new _.WhereBlock(e),new _.OrderByBlock(e),new _.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder),_.Delete=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"DELETE"),new _.TargetTableBlock(e),new _.FromTableBlock(a({},e,{singleTable:!0})),new _.JoinBlock(e),new _.WhereBlock(e),new _.OrderByBlock(e),new _.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder),_.Insert=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new _.StringBlock(e,"INSERT"),new _.IntoTableBlock(e),new _.InsertFieldValueBlock(e),new _.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(_.QueryBuilder);var g={VERSION:"5.13.0",flavour:h,expr:function(e){return new _.Expression(e)},case:function(e,t){return new _.Case(e,t)},select:function(e,t){return new _.Select(e,t)},update:function(e,t){return new _.Update(e,t)},insert:function(e,t){return new _.Insert(e,t)},delete:function(e,t){return new _.Delete(e,t)},str:function(){var e=new _.FunctionBlock;return e.function.apply(e,arguments),e},rstr:function(){var e=new _.FunctionBlock({rawNesting:!0});return e.function.apply(e,arguments),e},registerValueHandler:_.registerValueHandler};return g.remove=g.delete,g.cls=_,g}var p=_();return p.flavours={},p.useFlavour=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(!e)return p;if(p.flavours[e]instanceof Function){var t=_(e);return p.flavours[e].call(null,t),t.flavours=p.flavours,t.useFlavour=p.useFlavour,t}throw new Error("Flavour not available: "+e)},p.flavours.mssql=function(r){var u=r.cls;u.DefaultQueryBuilderOptions.replaceSingleQuotes=!0,u.DefaultQueryBuilderOptions.autoQuoteAliasNames=!1,u.DefaultQueryBuilderOptions.numberedParametersPrefix="@",r.registerValueHandler(Date,(function(e){return"'"+e.getUTCFullYear()+"-"+(e.getUTCMonth()+1)+"-"+e.getUTCDate()+" "+e.getUTCHours()+":"+e.getUTCMinutes()+":"+e.getUTCSeconds()+"'"})),u.MssqlLimitOffsetTopBlock=function(e){function r(e){o(this,r);var s=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));s._limits=null,s._offsets=null;var a=function(e){e=this._sanitizeLimitOffset(e),this._parent._limits=e};return s.ParentBlock=function(e){function t(e){o(this,t);var r=n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e.options));return r._parent=e,r}return i(t,e),t}(u.Block),s.LimitBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.limit=a,t}return i(r,e),t(r,[{key:"_toParamString",value:function(){var e="";return this._parent._limits&&this._parent._offsets&&(e="FETCH NEXT "+this._parent._limits+" ROWS ONLY"),{text:e,values:[]}}}]),r}(s.ParentBlock),s.TopBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t.top=a,t}return i(r,e),t(r,[{key:"_toParamString",value:function(){var e="";return this._parent._limits&&!this._parent._offsets&&(e="TOP ("+this._parent._limits+")"),{text:e,values:[]}}}]),r}(s.ParentBlock),s.OffsetBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"offset",value:function(e){this._parent._offsets=this._sanitizeLimitOffset(e)}},{key:"_toParamString",value:function(){var e="";return this._parent._offsets&&(e="OFFSET "+this._parent._offsets+" ROWS"),{text:e,values:[]}}}]),r}(s.ParentBlock),s}return i(r,e),t(r,[{key:"LIMIT",value:function(){return new this.LimitBlock(this)}},{key:"TOP",value:function(){return new this.TopBlock(this)}},{key:"OFFSET",value:function(){return new this.OffsetBlock(this)}}]),r}(u.Block),u.MssqlUpdateTopBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._limits=null,t.limit=t.top=function(e){t._limits=t._sanitizeLimitOffset(e)},t}return i(r,e),t(r,[{key:"_toParamString",value:function(){return{text:this._limits?"TOP ("+this._limits+")":"",values:[]}}}]),r}(u.Block),u.MssqlInsertFieldValueBlock=function(r){function s(e){o(this,s);var t=n(this,(s.__proto__||Object.getPrototypeOf(s)).call(this,e));return t._outputs=[],t}return i(s,r),t(s,[{key:"output",value:function(e){var t=this;"string"==typeof e?this._outputs.push("INSERTED."+this._sanitizeField(e)):e.forEach((function(e){t._outputs.push("INSERTED."+t._sanitizeField(e))}))}},{key:"_toParamString",value:function(t){var r=e(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_toParamString",this).call(this,t);if(r.text.length&&01&&void 0!==arguments[1]?arguments[1]:null;e=this._sanitizeField(e),t=t?this._sanitizeFieldAlias(t):t,this._outputs.push({name:this.options.forDelete?"DELETED."+e:"INSERTED."+e,alias:t})}},{key:"_toParamString",value:function(e){var t="";if(this._outputs.length){var r=!0,n=!1,i=void 0;try{for(var o,a=this._outputs[Symbol.iterator]();!(r=(o=a.next()).done);r=!0){var u=o.value;t=s(t,", "),t+=u.name,u.alias&&(t+=" AS "+this._formatFieldAlias(u.alias))}}catch(e){n=!0,i=e}finally{try{!r&&a.return&&a.return()}finally{if(n)throw i}}t="OUTPUT "+t}return{text:t,values:[]}}}]),r}(u.Block),u.Select=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;o(this,t);var i=new u.MssqlLimitOffsetTopBlock(e);return r=r||[new u.StringBlock(e,"SELECT"),new u.DistinctBlock(e),i.TOP(),new u.GetFieldBlock(e),new u.FromTableBlock(e),new u.JoinBlock(e),new u.WhereBlock(e),new u.GroupByBlock(e),new u.OrderByBlock(e),i.OFFSET(),i.LIMIT(),new u.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Update=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"UPDATE"),new u.MssqlUpdateTopBlock(e),new u.UpdateTableBlock(e),new u.SetFieldBlock(e),new u.MssqlUpdateDeleteOutputBlock(e),new u.WhereBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Delete=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"DELETE"),new u.TargetTableBlock(e),new u.FromTableBlock(a({},e,{singleTable:!0})),new u.JoinBlock(e),new u.MssqlUpdateDeleteOutputBlock(a({},e,{forDelete:!0})),new u.WhereBlock(e),new u.OrderByBlock(e),new u.LimitBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder),u.Insert=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),r=r||[new u.StringBlock(e,"INSERT"),new u.IntoTableBlock(e),new u.MssqlInsertFieldValueBlock(e),new u.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,r))}return i(t,e),t}(u.QueryBuilder)},p.flavours.mysql=function(e){var r=e.cls;r.MysqlOnDuplicateKeyUpdateBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"onDupUpdate",value:function(e,t,r){this._set(e,t,r)}},{key:"_toParamString",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=0;n1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.StringBlock(e,"INSERT"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e),new r.MysqlOnDuplicateKeyUpdateBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Replace=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.StringBlock(e,"REPLACE"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),e.replace=function(e,t){return new r.Replace(e,t)}},p.flavours.postgres=function(e){var r=e.cls;r.DefaultQueryBuilderOptions.numberedParameters=!0,r.DefaultQueryBuilderOptions.numberedParametersStartAt=1,r.DefaultQueryBuilderOptions.autoQuoteAliasNames=!1,r.DefaultQueryBuilderOptions.useAsForTableAliasNames=!0,r.PostgresOnConflictKeyUpdateBlock=function(e){function r(){return o(this,r),n(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments))}return i(r,e),t(r,[{key:"onConflict",value:function(e,t){var r=this;this._onConflict=!0,e&&(c(e)||(e=[e]),this._dupFields=e.map(this._sanitizeField.bind(this)),t&&Object.keys(t).forEach((function(e){r._set(e,t[e])})))}},{key:"_toParamString",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t="",r=[],n=0;n1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(t=t?this._sanitizeFieldAlias(t):t,e=this._sanitizeField(e),this._fields.filter((function(r){return r.name===e&&r.alias===t})).length)return this;this._fields.push({name:e,alias:t,options:r})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.queryBuilder;var t=e.buildParameterized,r="",n=[],i=!0,o=!1,a=void 0;try{for(var u,c=this._fields[Symbol.iterator]();!(i=(u=c.next()).done);i=!0){var l=u.value;r=s(r,", ");var f=l.name,d=l.alias,h=l.options;if("string"==typeof f)r+=this._formatFieldName(f,h);else{var _=f._toParamString({nested:!0,buildParameterized:t});r+=_.text,_.values.forEach((function(e){return n.push(e)}))}d&&(r+=" AS "+this._formatFieldAlias(d))}}catch(e){o=!0,a=e}finally{try{!i&&c.return&&c.return()}finally{if(o)throw a}}return{text:r.length>0?"RETURNING "+r:"",values:n}}}]),r}(r.Block),r.WithBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._tables=[],t}return i(r,e),t(r,[{key:"with",value:function(e,t){this._tables.push({alias:e,table:t})}},{key:"_toParamString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=[],r=[],n=!0,i=!1,o=void 0;try{for(var s,a=this._tables[Symbol.iterator]();!(n=(s=a.next()).done);n=!0){var u=s.value,c=u.alias,l=u.table._toParamString({buildParameterized:e.buildParameterized,nested:!0});t.push(c+" AS "+l.text),l.values.forEach((function(e){return r.push(e)}))}}catch(e){i=!0,o=e}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return{text:t.length?"WITH "+t.join(", "):"",values:r}}}]),r}(r.Block),r.DistinctOnBlock=function(e){function r(e){o(this,r);var t=n(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,e));return t._distinctFields=[],t}return i(r,e),t(r,[{key:"distinct",value:function(){var e=this;this._useDistinct=!0;for(var t=arguments.length,r=Array(t),n=0;n1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"SELECT"),new r.FunctionBlock(e),new r.DistinctOnBlock(e),new r.GetFieldBlock(e),new r.FromTableBlock(e),new r.JoinBlock(e),new r.WhereBlock(e),new r.GroupByBlock(e),new r.HavingBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.OffsetBlock(e),new r.UnionBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Insert=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"INSERT"),new r.IntoTableBlock(e),new r.InsertFieldValueBlock(e),new r.InsertFieldsFromQueryBlock(e),new r.PostgresOnConflictKeyUpdateBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Update=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"UPDATE"),new r.UpdateTableBlock(e),new r.SetFieldBlock(e),new r.FromTableBlock(e),new r.WhereBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder),r.Delete=function(e){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return o(this,t),i=i||[new r.WithBlock(e),new r.StringBlock(e,"DELETE"),new r.TargetTableBlock(e),new r.FromTableBlock(a({},e,{singleTable:!0})),new r.JoinBlock(e),new r.WhereBlock(e),new r.OrderByBlock(e),new r.LimitBlock(e),new r.ReturningBlock(e)],n(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,i))}return i(t,e),t}(r.QueryBuilder)},p}();var v=p(m.exports);function y(e,t){!function(e,t){e.exec(`\n create table if not exists 'chat_logs_${t}' (\n 'client_msg_id' char(32),\n 'server_msg_id' char(32),\n 'send_id' char(32),\n 'recv_id' char(32),\n 'sender_platform_id' smallint,\n 'sender_nick_name' varchar(255),\n 'sender_face_url' varchar(255),\n 'session_type' smallint,\n 'msg_from' smallint,\n 'content_type' smallint,\n 'content' varchar(1000),\n 'is_read' tinyint(1),\n 'status' smallint,\n 'seq' int DEFAULT 0,\n 'send_time' int,\n 'create_time' int,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n 'local_ex' varchar(1024),\n 'is_react' tinyint(1),\n 'is_external_extensions' tinyint(1),\n 'msg_first_modify_time' int,\n PRIMARY KEY ('client_msg_id')\n );\n `)}(e,t)}function b(e){return e.exec("\n select * from local_super_groups;\n ")}function w(e,t){const r=v.insert().into("local_friends").setFields(t).toString();return e.exec(r)}function E(e,t){const r=v.insert().into("local_groups").setFields(t).toString();return e.exec(r)}function O(e){return e.exec("\n SELECT * FROM local_groups\n ")}function S(e,t,r){return e.exec(`INSERT INTO local_notification_seqs (conversation_id, seq) VALUES ("${t}", ${r});`)}function k(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_stranger\n WHERE user_id = (${r.join(",")})\n `)}function R(e){return e.exec("\n SELECT * FROM local_app_sdk_version LIMIT 1\n ")}function N(e,t,r){return e.exec(`\n SELECT * FROM local_sync_version WHERE table_name = "${t}" AND entity_id = "${r}"\n `)}function M(e,t,r){let n=e;return"object"==typeof e&&(n=JSON.stringify(e)),{data:void 0!==e?n:"{}",errCode:t||0,errMsg:r||""}}const x=[["user_id","userID"],["group_id","groupID"],["client_msg_id","clientMsgID"],["server_msg_id","serverMsgID"],["send_id","sendID"],["recv_id","recvID"],["sender_platform_id","senderPlatformID"],["sender_nick_name","senderNickname"],["sender_face_url","senderFaceURL"],["session_type","sessionType"],["msg_from","msgFrom"],["content_type","contentType"],["content","content"],["is_read","isRead"],["is_react","isReact"],["is_external_extensions","isExternalExtensions"],["msg_first_modify_time","msgFirstModifyTime"],["status","status"],["seq","seq"],["send_time","sendTime"],["create_time","createTime"],["attached_info","attachedInfo"],["ex","ex"],["face_url","faceURL"],["creator_user_id","creatorUserID"],["conversation_id","conversationID"],["owner_user_id","ownerUserID"],["notification_user_id","notificationUserID"],["operator_user_id","operatorUserID"],["from_face_url","fromFaceURL"],["from_user_id","fromUserID"],["from_gender","fromGender"],["from_nickname","fromNickname"],["to_user_id","toUserID"],["to_nickname","toNickname"],["to_face_url","toFaceURL"],["to_gender","toGender"],["req_msg","reqMsg"],["handle_msg","handleMsg"],["handle_time","handleTime"],["handle_result","handleResult"],["handler_user_id","handlerUserID"],["handle_user_id","handleUserID"],["inviter_user_id","inviterUserID"],["mute_end_time","muteEndTime"],["role_level","roleLevel"],["join_time","joinTime"],["join_source","joinSource"],["friend_user_id","friendUserID"],["recv_msg_opt","recvMsgOpt"],["group_at_type","groupAtType"],["latest_msg_send_time","latestMsgSendTime"],["draft_text_time","draftTextTime"],["is_private_chat","isPrivateChat"],["is_not_in_group","isNotInGroup"],["update_unread_count_time","updateUnreadCountTime"],["is_msg_destruct","isMsgDestruct"],["msg_destruct_time","msgDestructTime"],["part_hash","partHash"],["upload_id","uploadID"],["upload_info","uploadInfo"],["expire_time","expireTime"],["entity_id","entityID"],["version_id","versionID"],["display_is_read","displayIsRead"]];function I(e){const t=function(e){const t=x.find((t=>t[0]===e));if(t)return t[1]}(e);if(t)return t;const r=[];let n=-2;for(let t=0;tt[1]===e));if(t)return t[0]}(e);if(t)return t;const r=[];for(let t=0;t{const o={};i.forEach(((i,s)=>{let a=i,u=e[s];"CamelCase"===t&&(a=I(i)),"SnakeCase"===t&&(a=A(i)),r.find((e=>e===a))&&(u=!!u),a=n[i]||a,o[a]=u})),s.push(o)})),s}function B(e,t=!0){const r={};return Object.keys(e).forEach((n=>{let i=e[n];t&&function(e){return"string"==typeof e}(i)&&(i=function(e,t={backslashSupported:!1}){if(null==e)throw new Error("Need to pass a valid string");if(!(t=t||{}).backslashSupported)return"'"+e.replace(/'/g,"''")+"'";const r=T,n=C;let i,o=r.lastIndex=0,s="";for(;i=r.exec(e);)s+=e.slice(o,i.index)+n[i[0]],o=r.lastIndex;return 0===o?"'"+e+"'":o{const i=t[n]||n;r[i]=e[n]})),r}var D="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function $(){throw new Error("setTimeout has not been defined")}function L(){throw new Error("clearTimeout has not been defined")}var U=$,q=L;function j(e){if(U===setTimeout)return setTimeout(e,0);if((U===$||!U)&&setTimeout)return U=setTimeout,setTimeout(e,0);try{return U(e,0)}catch(t){try{return U.call(null,e,0)}catch(t){return U.call(this,e,0)}}}"function"==typeof D.setTimeout&&(U=setTimeout),"function"==typeof D.clearTimeout&&(q=clearTimeout);var J,z=[],W=!1,H=-1;function G(){W&&J&&(W=!1,J.length?z=J.concat(z):H=-1,z.length&&Y())}function Y(){if(!W){var e=j(G);W=!0;for(var t=z.length;t;){for(J=z,z=[];++H1)for(var r=1;r>18&63]+ue[i>>12&63]+ue[i>>6&63]+ue[63&i]);return o.join("")}function _e(e){var t;fe||de();for(var r=e.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;au?u:a+s));return 1===n?(t=e[r-1],i+=ue[t>>2],i+=ue[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=ue[t>>10],i+=ue[t>>4&63],i+=ue[t<<2&63],i+="="),o.push(i),o.join("")}function pe(e,t,r,n,i){var o,s,a=8*i-n-1,u=(1<>1,l=-7,f=r?i-1:0,d=r?-1:1,h=e[t+f];for(f+=d,o=h&(1<<-l)-1,h>>=-l,l+=a;l>0;o=256*o+e[t+f],f+=d,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+e[t+f],f+=d,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(h?-1:1);s+=Math.pow(2,n),o-=c}return(h?-1:1)*s*Math.pow(2,o-n)}function ge(e,t,r,n,i,o){var s,a,u,c=8*o-i-1,l=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,h=n?0:o-1,_=n?1:-1,p=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+f>=1?d/u:d*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(t*u-1)*Math.pow(2,i),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;e[r+h]=255&a,h+=_,a/=256,i-=8);for(s=s<0;e[r+h]=255&s,h+=_,s/=256,c-=8);e[r+h-_]|=128*p}var me={}.toString,ve=Array.isArray||function(e){return"[object Array]"==me.call(e)};function ye(){return we.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function be(e,t){if(ye()=ye())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ye().toString(16)+" bytes");return 0|e}function Ne(e){return!(null==e||!e._isBuffer)}function Me(e,t){if(Ne(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return tt(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return rt(e).length;default:if(n)return tt(e).length;t=(""+t).toLowerCase(),n=!0}}function xe(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return ze(this,t,r);case"utf8":case"utf-8":return Ue(this,t,r);case"ascii":return je(this,t,r);case"latin1":case"binary":return Je(this,t,r);case"base64":return Le(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return We(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function Ie(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Ae(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=we.from(t,n)),Ne(t))return 0===t.length?-1:Te(e,t,r,n,i);if("number"==typeof t)return t&=255,we.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):Te(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Te(e,t,r,n,i){var o,s=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(o=r;oa&&(r=a-u),o=r;o>=0;o--){for(var f=!0,d=0;di&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function Le(e,t,r){return 0===t&&r===e.length?_e(e):_e(e.slice(t,r))}function Ue(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:c>223?3:c>191?2:1;if(i+f<=r)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(l=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=f}return function(e){var t=e.length;if(t<=qe)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),""},we.prototype.compare=function(e,t,r,n,i){if(!Ne(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),a=Math.min(o,s),u=this.slice(n,i),c=e.slice(t,r),l=0;li)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return Ce(this,e,t,r);case"utf8":case"utf-8":return Fe(this,e,t,r);case"ascii":return Be(this,e,t,r);case"latin1":case"binary":return Pe(this,e,t,r);case"base64":return De(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $e(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},we.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var qe=4096;function je(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function Ge(e,t,r,n,i,o){if(!Ne(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function Ye(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function Ve(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function Qe(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ke(e,t,r,n,i){return i||Qe(e,0,r,4),ge(e,t,r,n,23,4),r+4}function Xe(e,t,r,n,i){return i||Qe(e,0,r,8),ge(e,t,r,n,52,8),r+8}we.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},we.prototype.readUInt8=function(e,t){return t||He(e,1,this.length),this[e]},we.prototype.readUInt16LE=function(e,t){return t||He(e,2,this.length),this[e]|this[e+1]<<8},we.prototype.readUInt16BE=function(e,t){return t||He(e,2,this.length),this[e]<<8|this[e+1]},we.prototype.readUInt32LE=function(e,t){return t||He(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},we.prototype.readUInt32BE=function(e,t){return t||He(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},we.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||He(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},we.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||He(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},we.prototype.readInt8=function(e,t){return t||He(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},we.prototype.readInt16LE=function(e,t){t||He(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},we.prototype.readInt16BE=function(e,t){t||He(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},we.prototype.readInt32LE=function(e,t){return t||He(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},we.prototype.readInt32BE=function(e,t){return t||He(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},we.prototype.readFloatLE=function(e,t){return t||He(e,4,this.length),pe(this,e,!0,23,4)},we.prototype.readFloatBE=function(e,t){return t||He(e,4,this.length),pe(this,e,!1,23,4)},we.prototype.readDoubleLE=function(e,t){return t||He(e,8,this.length),pe(this,e,!0,52,8)},we.prototype.readDoubleBE=function(e,t){return t||He(e,8,this.length),pe(this,e,!1,52,8)},we.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||Ge(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},we.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,1,255,0),we.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},we.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,65535,0),we.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ye(this,e,t,!0),t+2},we.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,65535,0),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ye(this,e,t,!1),t+2},we.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,4294967295,0),we.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ve(this,e,t,!0),t+4},we.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,4294967295,0),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ve(this,e,t,!1),t+4},we.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Ge(this,e,t,r,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o>0)-a&255;return t+r},we.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);Ge(this,e,t,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+r},we.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,1,127,-128),we.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},we.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,32767,-32768),we.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Ye(this,e,t,!0),t+2},we.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,2,32767,-32768),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Ye(this,e,t,!1),t+2},we.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,2147483647,-2147483648),we.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ve(this,e,t,!0),t+4},we.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||Ge(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),we.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ve(this,e,t,!1),t+4},we.prototype.writeFloatLE=function(e,t,r){return Ke(this,e,t,!0,r)},we.prototype.writeFloatBE=function(e,t,r){return Ke(this,e,t,!1,r)},we.prototype.writeDoubleLE=function(e,t,r){return Xe(this,e,t,!0,r)},we.prototype.writeDoubleBE=function(e,t,r){return Xe(this,e,t,!1,r)},we.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!we.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function rt(e){return function(e){var t,r,n,i,o,s;fe||de();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new le(3*a/4-o),n=o>0?a-4:a;var u=0;for(t=0,r=0;t>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=ce[e.charCodeAt(t)]<<2|ce[e.charCodeAt(t+1)]>>4,s[u++]=255&i):1===o&&(i=ce[e.charCodeAt(t)]<<10|ce[e.charCodeAt(t+1)]<<4|ce[e.charCodeAt(t+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Ze,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function nt(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function it(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var ot={exports:{}};function st(e,t){for(var r=0,n=e.length-1;n>=0;n--){var i=e[n];"."===i?e.splice(n,1):".."===i?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var at=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,ut=function(e){return at.exec(e).slice(1)};function ct(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var n=r>=0?arguments[r]:"/";if("string"!=typeof n)throw new TypeError("Arguments to path.resolve must be strings");n&&(e=n+"/"+e,t="/"===n.charAt(0))}return(t?"/":"")+(e=st(vt(e.split("/"),(function(e){return!!e})),!t).join("/"))||"."}function lt(e){var t=ft(e),r="/"===yt(e,-1);return(e=st(vt(e.split("/"),(function(e){return!!e})),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e}function ft(e){return"/"===e.charAt(0)}function dt(){return lt(vt(Array.prototype.slice.call(arguments,0),(function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e})).join("/"))}function ht(e,t){function r(e){for(var t=0;t=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=ct(e).substr(1),t=ct(t).substr(1);for(var n=r(e.split("/")),i=r(t.split("/")),o=Math.min(n.length,i.length),s=o,a=0;a>>0),this.Xc=!0,null!=e&&Re.zb("/",this.filename,e,!0,!0)):this.filename=e,this.handleError(s(this.filename,n)),this.db=R(n,"i32"),ee(this.db),this.nb={},this.Xa={}}var n=Ye(4),o=i.cwrap,s=o("sqlite3_open","number",["string","number"]),a=o("sqlite3_close_v2","number",["number"]),u=o("sqlite3_exec","number",["number","string","number","number","number"]),c=o("sqlite3_changes","number",["number"]),l=o("sqlite3_prepare_v2","number",["number","string","number","number","number"]),f=o("sqlite3_sql","string",["number"]),d=o("sqlite3_normalized_sql","string",["number"]),h=o("sqlite3_prepare_v2","number",["number","number","number","number","number"]),_=o("sqlite3_bind_text","number",["number","number","number","number","number"]),p=o("sqlite3_bind_blob","number",["number","number","number","number","number"]),g=o("sqlite3_bind_double","number",["number","number","number"]),m=o("sqlite3_bind_int","number",["number","number","number"]),v=o("sqlite3_bind_parameter_index","number",["number","string"]),y=o("sqlite3_step","number",["number"]),b=o("sqlite3_errmsg","string",["number"]),w=o("sqlite3_column_count","number",["number"]),E=o("sqlite3_data_count","number",["number"]),N=o("sqlite3_column_double","number",["number","number"]),M=o("sqlite3_column_text","string",["number","number"]),x=o("sqlite3_column_blob","number",["number","number"]),I=o("sqlite3_column_bytes","number",["number","number"]),T=o("sqlite3_column_type","number",["number","number"]),B=o("sqlite3_column_name","string",["number","number"]),P=o("sqlite3_reset","number",["number"]),D=o("sqlite3_clear_bindings","number",["number"]),$=o("sqlite3_finalize","number",["number"]),L=o("sqlite3_create_function_v2","number","number string number number number number number number number".split(" ")),U=o("sqlite3_value_type","number",["number"]),z=o("sqlite3_value_bytes","number",["number"]),W=o("sqlite3_value_text","string",["number"]),H=o("sqlite3_value_blob","number",["number"]),G=o("sqlite3_value_double","number",["number"]),Y=o("sqlite3_result_double","",["number","number"]),V=o("sqlite3_result_null","",["number"]),Q=o("sqlite3_result_text","",["number","string","number","number"]),K=o("sqlite3_result_blob","",["number","number","number","number"]),X=o("sqlite3_result_int","",["number","number"]),Z=o("sqlite3_result_error","",["number","string","number"]),ee=o("RegisterExtensionFunctions","number",["number"]);e.prototype.bind=function(e){if(!this.Qa)throw"Statement closed";return this.reset(),Array.isArray(e)?this.vc(e):null==e||"object"!=typeof e||this.wc(e)},e.prototype.step=function(){if(!this.Qa)throw"Statement closed";this.Pa=1;var e=y(this.Qa);switch(e){case 100:return!0;case 101:return!1;default:throw this.db.handleError(e)}},e.prototype.Pc=function(e){return null==e&&(e=this.Pa,this.Pa+=1),N(this.Qa,e)},e.prototype.Qc=function(e){return null==e&&(e=this.Pa,this.Pa+=1),M(this.Qa,e)},e.prototype.getBlob=function(e){null==e&&(e=this.Pa,this.Pa+=1);var t=I(this.Qa,e);e=x(this.Qa,e);for(var r=new Uint8Array(t),n=0;n{let t=S((function(t,r){return t=te.get(t),e.lock(t,r)?0:5}),"iii"),r=S((function(t,r){return t=te.get(t),e.unlock(t,r),0}),"iii"),n=S((function(e,t){e=q(e),te.set(t,e)}),"vii");i._register_for_idb(t,r,n)},i.cleanup_file=e=>{let t=[...te.entries()].find((t=>t[1]===e));te.delete(t[0])},i.reset_filesystem=()=>{Re.root=null,Re.lc()}};var s,a={};for(s in i)i.hasOwnProperty(s)&&(a[s]=i[s]);var u,c,l,f,d,h="./this.program",_="object"==typeof window,p="function"==typeof importScripts,g="object"==typeof ae&&"object"==typeof ae.versions&&"string"==typeof ae.versions.node,m="";g?(m=p?bt.dirname(m)+"/":"/home/runner/work/openim-sdk-js-wasm/openim-sdk-js-wasm/node_modules/@jlongster/sql.js/dist/",u=function(e,t){return f||(f=wt),d||(d=bt),e=d.normalize(e),f.readFileSync(e,t?null:"utf8")},l=function(e){return(e=u(e,!0)).buffer||(e=new Uint8Array(e)),x(e.buffer),e},c=function(e,t,r){f||(f=wt),d||(d=bt),e=d.normalize(e),f.readFile(e,(function(e,n){e?r(e):t(n.buffer)}))},1>0]=0;break;case"i16":B[e>>1]=0;break;case"i32":P[e>>2]=0;break;case"i64":Z=[0,(X=0,1<=+Math.abs(X)?0>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[e>>2]=Z[0],P[e+4>>2]=Z[1];break;case"float":D[e>>2]=0;break;case"double":$[e>>3]=0;break;default:oe("invalid type for setValue: "+t)}}function R(e,t){switch("*"===(t=t||"i8").charAt(t.length-1)&&(t="i32"),t){case"i1":case"i8":return C[e>>0];case"i16":return B[e>>1];case"i32":case"i64":return P[e>>2];case"float":return D[e>>2];case"double":return $[e>>3];default:oe("invalid type for getValue: "+t)}return null}i.wasmBinary&&(w=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&oe("no native wasm support detected");var N,M=!1;function x(e,t){e||oe("Assertion failed: "+t)}function I(e){var t=i["_"+e];return x(t,"Cannot call unknown function "+e+", make sure it is exported"),t}function A(e){var t=Ue(e.length);return e.subarray||e.slice?F.set(e,t):F.set(new Uint8Array(e),t),t}var T,C,F,B,P,D,$,L="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function U(e,t,r){var n=t+r;for(r=t;e[r]&&!(r>=n);)++r;if(16(i=224==(240&i)?(15&i)<<12|o<<6|s:(7&i)<<18|o<<12|s<<6|63&e[t++])?n+=String.fromCharCode(i):(i-=65536,n+=String.fromCharCode(55296|i>>10,56320|1023&i))}}else n+=String.fromCharCode(i)}return n}function q(e,t){return e?U(F,e,t):""}function j(e,t,r,n){if(!(0=s)s=65536+((1023&s)<<10)|1023&e.charCodeAt(++o);if(127>=s){if(r>=n)break;t[r++]=s}else{if(2047>=s){if(r+1>=n)break;t[r++]=192|s>>6}else{if(65535>=s){if(r+2>=n)break;t[r++]=224|s>>12}else{if(r+3>=n)break;t[r++]=240|s>>18,t[r++]=128|s>>12&63}t[r++]=128|s>>6&63}t[r++]=128|63&s}}return t[r]=0,r-i}function J(e){for(var t=0,r=0;r=n&&(n=65536+((1023&n)<<10)|1023&e.charCodeAt(++r)),127>=n?++t:t=2047>=n?t+2:65535>=n?t+3:t+4}return t}function z(e){var t=J(e)+1,r=Ue(t);return r&&j(e,C,r,t),r}function W(){var e=N.buffer;T=e,i.HEAP8=C=new Int8Array(e),i.HEAP16=B=new Int16Array(e),i.HEAP32=P=new Int32Array(e),i.HEAPU8=F=new Uint8Array(e),i.HEAPU16=new Uint16Array(e),i.HEAPU32=new Uint32Array(e),i.HEAPF32=D=new Float32Array(e),i.HEAPF64=$=new Float64Array(e)}var H,G=[],Y=[],V=[];function Q(){var e=i.preRun.shift();G.unshift(e)}var K,X,Z,ee,te=0,re=null;function ne(){te++,i.monitorRunDependencies&&i.monitorRunDependencies(te)}function ie(){if(te--,i.monitorRunDependencies&&i.monitorRunDependencies(te),0==te&&re){var e=re;re=null,e()}}function oe(e){throw i.onAbort&&i.onAbort(e),y(e),M=!0,new WebAssembly.RuntimeError("abort("+e+"). Build with -s ASSERTIONS=1 for more info.")}function se(){return K.startsWith("data:application/octet-stream;base64,")}if(i.preloadedImages={},i.preloadedAudios={},K="sql-wasm.wasm",!se()){var ue=K;K=i.locateFile?i.locateFile(ue,m):m+ue}function ce(){var e=K;try{if(e==K&&w)return new Uint8Array(w);if(l)return l(e);throw"both async and sync fetching of the wasm failed"}catch(e){oe(e)}}function le(e){for(;0r?[]:e.slice(t,r-t+1)}e=ge(e).substr(1),t=ge(t).substr(1),e=r(e.split("/")),t=r(t.split("/"));for(var n=Math.min(e.length,t.length),i=n,o=0;o=t||(t=Math.max(t,r*(1048576>r?2:1.125)>>>0),0!=r&&(t=Math.max(t,256)),r=e.Na,e.Na=new Uint8Array(t),0=e.node.Ra)return 0;if(8<(e=Math.min(e.node.Ra-i,n))&&o.subarray)t.set(o.subarray(i,i+e),r);else for(n=0;nt)throw new Re.ErrnoError(28);return t},allocate:function(e,t,r){ke.Zb(e.node,t+r),e.node.Ra=Math.max(e.node.Ra,t+r)},mmap:function(e,t,r,n,i,o){if(0!==t)throw new Re.ErrnoError(28);if(!Re.isFile(e.node.mode))throw new Re.ErrnoError(43);if(e=e.node.Na,2&o||e.buffer!==T){if((0>>0)%Re.Ua.length},ec:function(e){var t=Re.Gb(e.parent.id,e.name);e.cb=Re.Ua[t],Re.Ua[t]=e},fc:function(e){var t=Re.Gb(e.parent.id,e.name);if(Re.Ua[t]===e)Re.Ua[t]=e.cb;else for(t=Re.Ua[t];t;){if(t.cb===e){t.cb=e.cb;break}t=t.cb}},lookupNode:function(e,t){var r=Re.Vc(e);if(r)throw new Re.ErrnoError(r,e);for(r=Re.Ua[Re.Gb(e.id,t)];r;r=r.cb){var n=r.name;if(r.parent.id===e.id&&n===t)return r}return Re.lookup(e,t)},createNode:function(e,t,r,n){return e=new Re.FSNode(e,t,r,n),Re.ec(e),e},Ab:function(e){Re.fc(e)},isRoot:function(e){return e===e.parent},ab:function(e){return!!e.lb},isFile:function(e){return 32768==(61440&e)},isDir:function(e){return 16384==(61440&e)},fb:function(e){return 40960==(61440&e)},pb:function(e){return 8192==(61440&e)},Rc:function(e){return 24576==(61440&e)},isFIFO:function(e){return 4096==(61440&e)},isSocket:function(e){return 49152==(49152&e)},Mc:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},Yc:function(e){var t=Re.Mc[e];if(void 0===t)throw Error("Unknown file open mode: "+e);return t},$b:function(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},Za:function(e,t){return Re.hc?0:!t.includes("r")||292&e.mode?t.includes("w")&&!(146&e.mode)||t.includes("x")&&!(73&e.mode)?2:0:2},Vc:function(e){var t=Re.Za(e,"x");return t||(e.node_ops.lookup?0:2)},Lb:function(e,t){try{return Re.lookupNode(e,t),20}catch(e){}return Re.Za(e,"wx")},qb:function(e,t,r){try{var n=Re.lookupNode(e,t)}catch(e){return e.Oa}if(e=Re.Za(e,"wx"))return e;if(r){if(!Re.isDir(n.mode))return 54;if(Re.isRoot(n)||Re.Ya(n)===Re.cwd())return 10}else if(Re.isDir(n.mode))return 31;return 0},Wc:function(e,t){return e?Re.fb(e.mode)?32:Re.isDir(e.mode)&&("r"!==Re.$b(t)||512&t)?31:Re.Za(e,Re.$b(t)):44},oc:4096,$c:function(e,t){for(t=t||Re.oc,e=e||0;e<=t;e++)if(!Re.streams[e])return e;throw new Re.ErrnoError(33)},$a:function(e){return Re.streams[e]},Jc:function(e,t,r){Re.ub||(Re.ub=function(){},Re.ub.prototype={object:{get:function(){return this.node},set:function(e){this.node=e}}});var n,i=new Re.ub;for(n in e)i[n]=e[n];return e=i,t=Re.$c(t,r),e.fd=t,Re.streams[t]=e},Dc:function(e){Re.streams[e]=null},Cc:{open:function(e){e.stream_ops=Re.Oc(e.node.rdev).stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new Re.ErrnoError(70)}},Kb:function(e){return e>>8},sd:function(e){return 255&e},bb:function(e,t){return e<<8|t},Qb:function(e,t){Re.Xb[e]={stream_ops:t}},Oc:function(e){return Re.Xb[e]},bc:function(e){var t=[];for(e=[e];e.length;){var r=e.pop();t.push(r),e.push.apply(e,r.mb)}return t},mc:function(e,t){function r(e){return Re.tb--,t(e)}function n(e){if(e){if(!n.Kc)return n.Kc=!0,r(e)}else++o>=i.length&&r(null)}"function"==typeof e&&(t=e,e=!1),Re.tb++,1t)throw new Re.ErrnoError(28);if(!(e="string"==typeof e?Re.lookupPath(e,{Ta:!0}).node:e).node_ops.setattr)throw new Re.ErrnoError(63);if(Re.isDir(e.mode))throw new Re.ErrnoError(31);if(!Re.isFile(e.mode))throw new Re.ErrnoError(28);var r=Re.Za(e,"w");if(r)throw new Re.ErrnoError(r);e.node_ops.setattr(e,{size:t,timestamp:Date.now()})},Nc:function(e,t){if(!(e=Re.$a(e)))throw new Re.ErrnoError(8);if(0==(2097155&e.flags))throw new Re.ErrnoError(28);Re.truncate(e.node,t)},kd:function(e,t,r){(e=Re.lookupPath(e,{Ta:!0}).node).node_ops.setattr(e,{timestamp:Math.max(t,r)})},open:function(e,t,r,n,o){if(""===e)throw new Re.ErrnoError(44);if(r=64&(t="string"==typeof t?Re.Yc(t):t)?4095&(void 0===r?438:r)|32768:0,"object"==typeof e)var s=e;else{e=de(e);try{s=Re.lookupPath(e,{Ta:!(131072&t)}).node}catch(e){}}var a=!1;if(64&t)if(s){if(128&t)throw new Re.ErrnoError(20)}else s=Re.mknod(e,r,0),a=!0;if(!s)throw new Re.ErrnoError(44);if(Re.pb(s.mode)&&(t&=-513),65536&t&&!Re.isDir(s.mode))throw new Re.ErrnoError(54);if(!a&&(r=Re.Wc(s,t)))throw new Re.ErrnoError(r);512&t&&Re.truncate(s,0),t&=-131713,(n=Re.Jc({node:s,path:Re.Ya(s),flags:t,seekable:!0,position:0,stream_ops:s.stream_ops,jd:[],error:!1},n,o)).stream_ops.open&&n.stream_ops.open(n),!i.logReadFiles||1&t||(Re.Ob||(Re.Ob={}),e in Re.Ob||(Re.Ob[e]=1,y("FS.trackingDelegate error on read file: "+e)));try{Re.Sa.onOpenFile&&(o=0,1!=(2097155&t)&&(o|=Re.nc.kc.qc),0!=(2097155&t)&&(o|=Re.nc.kc.rc),Re.Sa.onOpenFile(e,o))}catch(t){y("FS.trackingDelegate['onOpenFile']('"+e+"', flags) threw an exception: "+t.message)}return n},close:function(e){if(Re.kb(e))throw new Re.ErrnoError(8);e.Fb&&(e.Fb=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{Re.Dc(e.fd)}e.fd=null},kb:function(e){return null===e.fd},llseek:function(e,t,r){if(Re.kb(e))throw new Re.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new Re.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new Re.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.jd=[],e.position},read:function(e,t,r,n,i){if(0>n||0>i)throw new Re.ErrnoError(28);if(Re.kb(e))throw new Re.ErrnoError(8);if(1==(2097155&e.flags))throw new Re.ErrnoError(8);if(Re.isDir(e.node.mode))throw new Re.ErrnoError(31);if(!e.stream_ops.read)throw new Re.ErrnoError(28);var o=void 0!==i;if(o){if(!e.seekable)throw new Re.ErrnoError(70)}else i=e.position;return t=e.stream_ops.read(e,t,r,n,i),o||(e.position+=t),t},write:function(e,t,r,n,i,o){if(0>n||0>i)throw new Re.ErrnoError(28);if(Re.kb(e))throw new Re.ErrnoError(8);if(0==(2097155&e.flags))throw new Re.ErrnoError(8);if(Re.isDir(e.node.mode))throw new Re.ErrnoError(31);if(!e.stream_ops.write)throw new Re.ErrnoError(28);e.seekable&&1024&e.flags&&Re.llseek(e,0,2);var s=void 0!==i;if(s){if(!e.seekable)throw new Re.ErrnoError(70)}else i=e.position;t=e.stream_ops.write(e,t,r,n,i,o),s||(e.position+=t);try{e.path&&Re.Sa.onWriteToFile&&Re.Sa.onWriteToFile(e.path)}catch(t){y("FS.trackingDelegate['onWriteToFile']('"+e.path+"') threw an exception: "+t.message)}return t},allocate:function(e,t,r){if(Re.kb(e))throw new Re.ErrnoError(8);if(0>t||0>=r)throw new Re.ErrnoError(28);if(0==(2097155&e.flags))throw new Re.ErrnoError(8);if(!Re.isFile(e.node.mode)&&!Re.isDir(e.node.mode))throw new Re.ErrnoError(43);if(!e.stream_ops.allocate)throw new Re.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:function(e,t,r,n,i,o){if(0!=(2&i)&&0==(2&o)&&2!=(2097155&e.flags))throw new Re.ErrnoError(2);if(1==(2097155&e.flags))throw new Re.ErrnoError(2);if(!e.stream_ops.mmap)throw new Re.ErrnoError(43);return e.stream_ops.mmap(e,t,r,n,i,o)},msync:function(e,t,r,n,i){return e&&e.stream_ops.msync?e.stream_ops.msync(e,t,r,n,i):0},ud:function(){return 0},ic:function(e,t,r){if(!e.stream_ops.ic)throw new Re.ErrnoError(59);return e.stream_ops.ic(e,t,r)},readFile:function(e,t){if((t=t||{}).flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw Error('Invalid encoding type "'+t.encoding+'"');var r,n=Re.open(e,t.flags);e=Re.stat(e).size;var i=new Uint8Array(e);return Re.read(n,i,0,e,0),"utf8"===t.encoding?r=U(i,0):"binary"===t.encoding&&(r=i),Re.close(n),r},writeFile:function(e,t,r){if((r=r||{}).flags=r.flags||577,e=Re.open(e,r.flags,r.mode),"string"==typeof t){var n=new Uint8Array(J(t)+1);t=j(t,n,0,n.length),Re.write(e,n,0,t,void 0,r.Bc)}else{if(!ArrayBuffer.isView(t))throw Error("Unsupported data type");Re.write(e,t,0,t.byteLength,void 0,r.Bc)}Re.close(e)},cwd:function(){return Re.Wb},chdir:function(e){if(null===(e=Re.lookupPath(e,{Ta:!0})).node)throw new Re.ErrnoError(44);if(!Re.isDir(e.node.mode))throw new Re.ErrnoError(54);var t=Re.Za(e.node,"x");if(t)throw new Re.ErrnoError(t);Re.Wb=e.path},Fc:function(){Re.mkdir("/tmp"),Re.mkdir("/home"),Re.mkdir("/home/web_user")},Ec:function(){Re.mkdir("/dev"),Re.Qb(Re.bb(1,3),{read:function(){return 0},write:function(e,t,r,n){return n}}),Re.rb("/dev/null",Re.bb(1,3)),ye(Re.bb(5,0),Ee),ye(Re.bb(6,0),Oe),Re.rb("/dev/tty",Re.bb(5,0)),Re.rb("/dev/tty1",Re.bb(6,0));var e=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return function(){return crypto.getRandomValues(e),e[0]}}if(g)try{var t=Et;return function(){return t.randomBytes(1)[0]}}catch(e){}return function(){oe("randomDevice")}}();Re.Wa("/dev","random",e),Re.Wa("/dev","urandom",e),Re.mkdir("/dev/shm"),Re.mkdir("/dev/shm/tmp")},Hc:function(){Re.mkdir("/proc");var e=Re.mkdir("/proc/self");Re.mkdir("/proc/self/fd"),Re.mount({mount:function(){var t=Re.createNode(e,"fd",16895,73);return t.node_ops={lookup:function(e,t){var r=Re.$a(+t);if(!r)throw new Re.ErrnoError(8);return(e={parent:null,mount:{jc:"fake"},node_ops:{readlink:function(){return r.path}}}).parent=e}},t}},{},"/proc/self/fd")},Ic:function(){i.stdin?Re.Wa("/dev","stdin",i.stdin):Re.symlink("/dev/tty","/dev/stdin"),i.stdout?Re.Wa("/dev","stdout",null,i.stdout):Re.symlink("/dev/tty","/dev/stdout"),i.stderr?Re.Wa("/dev","stderr",null,i.stderr):Re.symlink("/dev/tty1","/dev/stderr"),Re.open("/dev/stdin",0),Re.open("/dev/stdout",1),Re.open("/dev/stderr",1)},Yb:function(){Re.ErrnoError||(Re.ErrnoError=function(e,t){this.node=t,this.hd=function(e){this.Oa=e},this.hd(e),this.message="FS error"},Re.ErrnoError.prototype=Error(),Re.ErrnoError.prototype.constructor=Re.ErrnoError,[44].forEach((function(e){Re.Db[e]=new Re.ErrnoError(e),Re.Db[e].stack=""})))},lc:function(){Re.Yb(),Re.Ua=Array(4096),Re.mount(ke,{},"/"),Re.Fc(),Re.Ec(),Re.Hc(),Re.Lc={MEMFS:ke}},jb:function(e,t,r){Re.jb.Hb=!0,Re.Yb(),i.stdin=e||i.stdin,i.stdout=t||i.stdout,i.stderr=r||i.stderr,Re.Ic()},wd:function(){Re.jb.Hb=!1;var e=i._fflush;for(e&&e(0),e=0;ethis.length-1||0>e)){var t=e%this.chunkSize;return this.dc(e/this.chunkSize|0)[t]}},o.prototype.pc=function(e){this.dc=e},o.prototype.Ub=function(){var e=new XMLHttpRequest;if(e.open("HEAD",r,!1),e.send(null),!(200<=e.status&&300>e.status||304===e.status))throw Error("Couldn't load "+r+". Status: "+e.status);var t,n=Number(e.getResponseHeader("Content-length")),i=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t;e=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t;var o=1048576;i||(o=n);var s=this;s.pc((function(e){var t=e*o,i=(e+1)*o-1;if(i=Math.min(i,n-1),void 0===s.ob[e]){var a=s.ob;if(t>i)throw Error("invalid range ("+t+", "+i+") or no bytes requested!");if(i>n-1)throw Error("only "+n+" bytes available! programmer error!");var u=new XMLHttpRequest;if(u.open("GET",r,!1),n!==o&&u.setRequestHeader("Range","bytes="+t+"-"+i),"undefined"!=typeof Uint8Array&&(u.responseType="arraybuffer"),u.overrideMimeType&&u.overrideMimeType("text/plain; charset=x-user-defined"),u.send(null),!(200<=u.status&&300>u.status||304===u.status))throw Error("Couldn't load "+r+". Status: "+u.status);t=void 0!==u.response?new Uint8Array(u.response||[]):De(u.responseText||"",!0),a[e]=t}if(void 0===s.ob[e])throw Error("doXHR failed!");return s.ob[e]})),!e&&n||(o=n=1,o=n=this.dc(0).length,v("LazyFiles on gzip forces download of the whole file when length is accessed")),this.tc=n,this.sc=o,this.Jb=!0},"undefined"!=typeof XMLHttpRequest){if(!p)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new o;Object.defineProperties(s,{length:{get:function(){return this.Jb||this.Ub(),this.tc}},chunkSize:{get:function(){return this.Jb||this.Ub(),this.sc}}}),s={Ib:!1,Na:s}}else s={Ib:!1,url:r};var a=Re.Gc(e,t,s,n,i);s.Na?a.Na=s.Na:s.url&&(a.Na=null,a.url=s.url),Object.defineProperties(a,{Ra:{get:function(){return this.Na.length}}});var u={};return Object.keys(a.stream_ops).forEach((function(e){var t=a.stream_ops[e];u[e]=function(){return Re.ac(a),t.apply(null,arguments)}})),u.read=function(e,t,r,n,i){if(Re.ac(a),i>=(e=e.node.Na).length)return 0;if(n=Math.min(e.length-i,n),e.slice)for(var o=0;o>2]=n.dev,P[r+4>>2]=0,P[r+8>>2]=n.ino,P[r+12>>2]=n.mode,P[r+16>>2]=n.nlink,P[r+20>>2]=n.uid,P[r+24>>2]=n.gid,P[r+28>>2]=n.rdev,P[r+32>>2]=0,Z=[n.size>>>0,(X=n.size,1<=+Math.abs(X)?0>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[r+40>>2]=Z[0],P[r+44>>2]=Z[1],P[r+48>>2]=4096,P[r+52>>2]=n.blocks,P[r+56>>2]=n.atime.getTime()/1e3|0,P[r+60>>2]=0,P[r+64>>2]=n.mtime.getTime()/1e3|0,P[r+68>>2]=0,P[r+72>>2]=n.ctime.getTime()/1e3|0,P[r+76>>2]=0,Z=[n.ino>>>0,(X=n.ino,1<=+Math.abs(X)?0>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[r+80>>2]=Z[0],P[r+84>>2]=Z[1],0}var xe,Ie=void 0;function Ae(){return P[(Ie+=4)-4>>2]}function Te(e){if(!(e=Re.$a(e)))throw new Re.ErrnoError(8);return e}xe=g?function(){var e=ae.hrtime();return 1e3*e[0]+e[1]/1e6}:function(){return performance.now()};var Ce,Fe={};function Be(){if(!Ce){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:h||"./this.program"};for(e in Fe)void 0===Fe[e]?delete t[e]:t[e]=Fe[e];var r=[];for(e in t)r.push(e+"="+t[e]);Ce=r}return Ce}function Pe(e,t,r,n){e||(e=this),this.parent=e,this.mount=e.mount,this.lb=null,this.id=Re.Zc++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=n}function De(e,t){var r=Array(J(e)+1);return e=j(e,r,0,r.length),t&&(r.length=e),r}Object.defineProperties(Pe.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}},Sc:{get:function(){return Re.isDir(this.mode)}},Ib:{get:function(){return Re.pb(this.mode)}}}),Re.FSNode=Pe,Re.lc();var $e={a:function(e,t,r,n){oe("Assertion failed: "+q(e)+", at: "+[t?q(t):"unknown filename",r,n?q(n):"unknown function"])},u:function(e,t){!function(){function e(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}if(!ee){ee=!0;var t=(new Date).getFullYear(),r=new Date(t,0,1),n=new Date(t,6,1);t=r.getTimezoneOffset();var i=n.getTimezoneOffset(),o=Math.max(t,i);P[We()>>2]=60*o,P[ze()>>2]=Number(t!=i),r=e(r),n=e(n),r=z(r),n=z(n),i>2]=r,P[Je()+4>>2]=n):(P[Je()>>2]=n,P[Je()+4>>2]=r)}}(),e=new Date(1e3*P[e>>2]),P[t>>2]=e.getSeconds(),P[t+4>>2]=e.getMinutes(),P[t+8>>2]=e.getHours(),P[t+12>>2]=e.getDate(),P[t+16>>2]=e.getMonth(),P[t+20>>2]=e.getFullYear()-1900,P[t+24>>2]=e.getDay();var r=new Date(e.getFullYear(),0,1);P[t+28>>2]=(e.getTime()-r.getTime())/864e5|0,P[t+36>>2]=-60*e.getTimezoneOffset();var n=new Date(e.getFullYear(),6,1).getTimezoneOffset();return e=0|(n!=(r=r.getTimezoneOffset())&&e.getTimezoneOffset()==Math.min(r,n)),P[t+32>>2]=e,e=P[Je()+(e?4:0)>>2],P[t+40>>2]=e,t},m:function(e,t){try{var r;if(e=q(e),-8&t)var n=-28;else(r=Re.lookupPath(e,{Ta:!0}).node)?(e="",4&t&&(e+="r"),2&t&&(e+="w"),1&t&&(e+="x"),n=e&&Re.Za(r,e)?-2:0):n=-44;return n}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},A:function(e,t){try{return e=q(e),Re.chmod(e,t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},H:function(e,t,r){try{return e=q(e),Re.chown(e,t,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},B:function(e,t){try{return Re.fchmod(e,t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},I:function(e,t,r){try{return Re.fchown(e,t,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},b:function(e,t,r){Ie=r;try{var n=Te(e);switch(t){case 0:var i=Ae();return 0>i?-28:Re.open(n.path,n.flags,0,i).fd;case 1:case 2:case 13:case 14:return 0;case 3:return n.flags;case 4:return i=Ae(),n.flags|=i,0;case 12:return i=Ae(),B[i+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return P[Le()>>2]=28,-1}}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},E:function(e,t){try{var r=Te(e);return Me(Re.stat,r.path,t)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},n:function(e,t,r){try{return Re.Nc(e,r),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},l:function(e,t){try{if(0===t)return-28;var r=Re.cwd();return t=r)var n=-28;else{var i=Re.readlink(e),o=Math.min(r,J(i)),s=C[t+o];j(i,F,t,r+1),C[t+o]=s,n=o}return n}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},F:function(e){try{return e=q(e),Re.rmdir(e),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},e:function(e,t){try{return e=q(e),Me(Re.stat,e,t)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},i:function(e){try{return e=q(e),Re.unlink(e),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),-e.Oa}},v:function(){return 2147483648},p:function(e,t,r){F.copyWithin(e,t,t+r)},c:function(e){var t=F.length;if(2147483648<(e>>>=0))return!1;for(var r=1;4>=r;r*=2){var n=t*(1+.2/r);n=Math.min(n,e+100663296),0<(n=Math.max(e,n))%65536&&(n+=65536-n%65536);e:{try{N.grow(Math.min(2147483648,n)-T.byteLength+65535>>>16),W();var i=1;break e}catch(e){}i=void 0}if(i)return!0}return!1},t:function(e){for(var t=xe();xe()-t>2]=o,o=0;o>0]=n.charCodeAt(o);C[i>>0]=0,r+=n.length+1})),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},s:function(e,t){try{var r=Be();P[e>>2]=r.length;var n=0;return r.forEach((function(e){n+=e.length+1})),P[t>>2]=n,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},f:function(e){try{var t=Te(e);return Re.close(t),0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},q:function(e,t){try{var r=Te(e),n=r.tty?2:Re.isDir(r.mode)?3:Re.fb(r.mode)?7:4;return C[t>>0]=n,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},j:function(e,t,r,n){try{e:{for(var i=Te(e),o=e=0;o>2],a=Re.read(i,C,P[t+8*o>>2],s,void 0);if(0>a){var u=-1;break e}if(e+=a,a>2]=u,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},o:function(e,t,r,n,i){try{var o=Te(e);return-9007199254740992>=(e=4294967296*r+(t>>>0))||9007199254740992<=e?-61:(Re.llseek(o,e,n),Z=[o.position>>>0,(X=o.position,1<=+Math.abs(X)?0>>0:~~+Math.ceil((X-+(~~X>>>0))/4294967296)>>>0:0)],P[i>>2]=Z[0],P[i+4>>2]=Z[1],o.Fb&&0===e&&0===n&&(o.Fb=null),0)}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},k:function(e){try{var t=Te(e);return t.stream_ops&&t.stream_ops.fsync?-t.stream_ops.fsync(t):0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},g:function(e,t,r,n){try{e:{for(var i=Te(e),o=e=0;o>2],P[t+(8*o+4)>>2],void 0);if(0>s){var a=-1;break e}e+=s}a=e}return P[n>>2]=a,0}catch(e){return void 0!==Re&&e instanceof Re.ErrnoError||oe(e),e.Oa}},h:function(e){var t=Date.now();return P[e>>2]=t/1e3|0,P[e+4>>2]=t%1e3*1e3|0,0},K:function(e){var t=Date.now()/1e3|0;return e&&(P[e>>2]=t),t},D:function(e,t){if(t){var r=t+8;t=1e3*P[r>>2],t+=P[r+4>>2]/1e3}else t=Date.now();e=q(e);try{Re.kd(e,t,t);var n=0}catch(e){if(!(e instanceof Re.ErrnoError)){e:{if(!(n=Error()).stack){try{throw Error()}catch(e){n=e}if(!n.stack){n="(no stack trace available)";break e}}n=n.stack.toString()}throw i.extraStackTrace&&(n+="\n"+i.extraStackTrace()),n=function(e){return e.replace(/\b_Z[\w\d_]+/g,(function(e){return e==e?e:e+" ["+e+"]"}))}(n),e+" : "+n}n=e.Oa,P[Le()>>2]=n,n=-1}return n}};!function(){function e(e){i.asm=e.exports,N=i.asm.L,W(),H=i.asm.Da,Y.unshift(i.asm.M),ie()}function t(t){e(t.instance)}function r(e){return function(){if(!w&&(_||p)){if("function"==typeof fetch&&!K.startsWith("file://"))return fetch(K,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+K+"'";return e.arrayBuffer()})).catch((function(){return ce()}));if(c)return new Promise((function(e,t){c(K,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return ce()}))}().then((function(e){return WebAssembly.instantiate(e,n)})).then(e,(function(e){y("failed to asynchronously prepare wasm: "+e),oe(e)}))}var n={a:$e};if(ne(),i.instantiateWasm)try{return i.instantiateWasm(n,e)}catch(e){return y("Module.instantiateWasm callback failed with error: "+e),!1}w||"function"!=typeof WebAssembly.instantiateStreaming||se()||K.startsWith("file://")||"function"!=typeof fetch?r(t):fetch(K,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,n).then(t,(function(e){return y("wasm streaming compile failed: "+e),y("falling back to ArrayBuffer instantiation"),r(t)}))}))}(),i.___wasm_call_ctors=function(){return(i.___wasm_call_ctors=i.asm.M).apply(null,arguments)},i._sqlite3_vfs_find=function(){return(i._sqlite3_vfs_find=i.asm.N).apply(null,arguments)},i._sqlite3_free=function(){return(i._sqlite3_free=i.asm.O).apply(null,arguments)};var Le=i.___errno_location=function(){return(Le=i.___errno_location=i.asm.P).apply(null,arguments)};i._sqlite3_finalize=function(){return(i._sqlite3_finalize=i.asm.Q).apply(null,arguments)},i._sqlite3_reset=function(){return(i._sqlite3_reset=i.asm.R).apply(null,arguments)},i._sqlite3_clear_bindings=function(){return(i._sqlite3_clear_bindings=i.asm.S).apply(null,arguments)},i._sqlite3_value_blob=function(){return(i._sqlite3_value_blob=i.asm.T).apply(null,arguments)},i._sqlite3_value_text=function(){return(i._sqlite3_value_text=i.asm.U).apply(null,arguments)},i._sqlite3_value_bytes=function(){return(i._sqlite3_value_bytes=i.asm.V).apply(null,arguments)},i._sqlite3_value_double=function(){return(i._sqlite3_value_double=i.asm.W).apply(null,arguments)},i._sqlite3_value_int=function(){return(i._sqlite3_value_int=i.asm.X).apply(null,arguments)},i._sqlite3_value_type=function(){return(i._sqlite3_value_type=i.asm.Y).apply(null,arguments)},i._sqlite3_result_blob=function(){return(i._sqlite3_result_blob=i.asm.Z).apply(null,arguments)},i._sqlite3_result_double=function(){return(i._sqlite3_result_double=i.asm._).apply(null,arguments)},i._sqlite3_result_error=function(){return(i._sqlite3_result_error=i.asm.$).apply(null,arguments)},i._sqlite3_result_int=function(){return(i._sqlite3_result_int=i.asm.aa).apply(null,arguments)},i._sqlite3_result_int64=function(){return(i._sqlite3_result_int64=i.asm.ba).apply(null,arguments)},i._sqlite3_result_null=function(){return(i._sqlite3_result_null=i.asm.ca).apply(null,arguments)},i._sqlite3_result_text=function(){return(i._sqlite3_result_text=i.asm.da).apply(null,arguments)},i._sqlite3_step=function(){return(i._sqlite3_step=i.asm.ea).apply(null,arguments)},i._sqlite3_column_count=function(){return(i._sqlite3_column_count=i.asm.fa).apply(null,arguments)},i._sqlite3_data_count=function(){return(i._sqlite3_data_count=i.asm.ga).apply(null,arguments)},i._sqlite3_column_blob=function(){return(i._sqlite3_column_blob=i.asm.ha).apply(null,arguments)},i._sqlite3_column_bytes=function(){return(i._sqlite3_column_bytes=i.asm.ia).apply(null,arguments)},i._sqlite3_column_double=function(){return(i._sqlite3_column_double=i.asm.ja).apply(null,arguments)},i._sqlite3_column_text=function(){return(i._sqlite3_column_text=i.asm.ka).apply(null,arguments)},i._sqlite3_column_type=function(){return(i._sqlite3_column_type=i.asm.la).apply(null,arguments)},i._sqlite3_column_name=function(){return(i._sqlite3_column_name=i.asm.ma).apply(null,arguments)},i._sqlite3_bind_blob=function(){return(i._sqlite3_bind_blob=i.asm.na).apply(null,arguments)},i._sqlite3_bind_double=function(){return(i._sqlite3_bind_double=i.asm.oa).apply(null,arguments)},i._sqlite3_bind_int=function(){return(i._sqlite3_bind_int=i.asm.pa).apply(null,arguments)},i._sqlite3_bind_text=function(){return(i._sqlite3_bind_text=i.asm.qa).apply(null,arguments)},i._sqlite3_bind_parameter_index=function(){return(i._sqlite3_bind_parameter_index=i.asm.ra).apply(null,arguments)},i._sqlite3_sql=function(){return(i._sqlite3_sql=i.asm.sa).apply(null,arguments)},i._sqlite3_normalized_sql=function(){return(i._sqlite3_normalized_sql=i.asm.ta).apply(null,arguments)},i._sqlite3_errmsg=function(){return(i._sqlite3_errmsg=i.asm.ua).apply(null,arguments)},i._sqlite3_exec=function(){return(i._sqlite3_exec=i.asm.va).apply(null,arguments)},i._sqlite3_prepare_v2=function(){return(i._sqlite3_prepare_v2=i.asm.wa).apply(null,arguments)},i._sqlite3_changes=function(){return(i._sqlite3_changes=i.asm.xa).apply(null,arguments)},i._sqlite3_close_v2=function(){return(i._sqlite3_close_v2=i.asm.ya).apply(null,arguments)},i._sqlite3_create_function_v2=function(){return(i._sqlite3_create_function_v2=i.asm.za).apply(null,arguments)},i._sqlite3_open=function(){return(i._sqlite3_open=i.asm.Aa).apply(null,arguments)};var Ue=i._malloc=function(){return(Ue=i._malloc=i.asm.Ba).apply(null,arguments)},qe=i._free=function(){return(qe=i._free=i.asm.Ca).apply(null,arguments)};i._RegisterExtensionFunctions=function(){return(i._RegisterExtensionFunctions=i.asm.Ea).apply(null,arguments)},i._register_for_idb=function(){return(i._register_for_idb=i.asm.Fa).apply(null,arguments)};var je,Je=i.__get_tzname=function(){return(Je=i.__get_tzname=i.asm.Ga).apply(null,arguments)},ze=i.__get_daylight=function(){return(ze=i.__get_daylight=i.asm.Ha).apply(null,arguments)},We=i.__get_timezone=function(){return(We=i.__get_timezone=i.asm.Ia).apply(null,arguments)},He=i.stackSave=function(){return(He=i.stackSave=i.asm.Ja).apply(null,arguments)},Ge=i.stackRestore=function(){return(Ge=i.stackRestore=i.asm.Ka).apply(null,arguments)},Ye=i.stackAlloc=function(){return(Ye=i.stackAlloc=i.asm.La).apply(null,arguments)},Ve=i._memalign=function(){return(Ve=i._memalign=i.asm.Ma).apply(null,arguments)};function Qe(){function e(){if(!je&&(je=!0,i.calledRun=!0,!M)){if(i.noFSInit||Re.jb.Hb||Re.jb(),Re.hc=!1,le(Y),i.onRuntimeInitialized&&i.onRuntimeInitialized(),i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;){var e=i.postRun.shift();V.unshift(e)}le(V)}}if(!(0{let r=e.isFile(t.mode)?t.contents.getattr():null,n={dev:1};return n.ino=t.id,n.mode=r?r.mode:t.mode,n.nlink=1,n.uid=0,n.gid=0,n.rdev=t.rdev,n.size=r?r.size:e.isDir(t.mode)?4096:0,n.atime=new Date(0),n.mtime=new Date(0),n.ctime=new Date(0),n.blksize=r?r.blockSize:4096,n.blocks=Math.ceil(n.size/n.blksize),n},setattr:(e,t)=>{this.FS.isFile(e.mode)?e.contents.setattr(t):(null!=t.mode&&(e.mode=t.mode),null!=t.size&&(e.size=t.size))},lookup:(e,t)=>{throw new this.FS.ErrnoError(kt)},mknod:(e,t,r,n)=>{if(t.endsWith(".lock"))throw new Error("Locking via lockfiles is not supported");return this.createNode(e,t,r,n)},rename:(e,t,r)=>{throw new Error("rename not implemented")},unlink:(e,t)=>{this.FS.lookupNode(e,t).contents.delete(t)},readdir:e=>{throw new Error("readdir not implemented")},symlink:(e,t,r)=>{throw new Error("symlink not implemented")},readlink:e=>{throw new Error("symlink not implemented")}},this.stream_ops={open:e=>{this.FS.isFile(e.node.mode)&&e.node.contents.open()},close:e=>{this.FS.isFile(e.node.mode)&&e.node.contents.close()},read:(e,t,r,n,i)=>e.node.contents.read(t,r,n,i),write:(e,t,r,n,i)=>e.node.contents.write(t,r,n,i),llseek:(t,r,n)=>{var i=r;if(1===n?i+=t.position:2===n&&e.isFile(t.node.mode)&&(i+=t.node.contents.getattr().size),i<0)throw new this.FS.ErrnoError(28);return i},allocate:(e,t,r)=>{e.node.contents.setattr({size:t+r})},mmap:(e,t,r,n,i,o)=>{throw new Error("mmap not implemented")},msync:(e,t,r,n,i)=>{throw new Error("msync not implemented")},fsync:(e,t,r,n,i)=>{e.node.contents.fsync()}}}mount(){return this.createNode(null,"/",16895,0)}lock(e,t){let{node:r}=this.FS.lookupPath(e);return r.contents.lock(t)}unlock(e,t){let{node:r}=this.FS.lookupPath(e);return r.contents.unlock(t)}createNode(e,t,r,n){if(!this.FS.isDir(r)&&!this.FS.isFile(r))throw new this.FS.ErrnoError(St);var i=this.FS.createNode(e,t,r,n);return this.FS.isDir(i.mode)?(i.node_ops={mknod:this.node_ops.mknod,lookup:this.node_ops.lookup,unlink:this.node_ops.unlink,setattr:this.node_ops.setattr},i.stream_ops={},i.contents={}):this.FS.isFile(i.mode)&&(i.node_ops=this.node_ops,i.stream_ops=this.stream_ops,i.contents=this.backend.createFile(t)),e&&(e.contents[t]=i,e.timestamp=i.timestamp),i}};let Nt=1,Mt=2;function xt(e){return(e[16]<<8)+e[17]}function It(e,t,r){return function(e,t,r){let n=[];for(let i=e;i<=t;i+=r)n.push(i);return n}(t-t%e,r-1-(r-1)%e,e)}function At(e,t,r,n){let i=It(t,r,n),o=0;return i.map((i=>{let s=0,a=t;r>i&&ri&&ni+t||n<=i)return null;let l=e.byteOffset+o,f=e.buffer.byteLength-l;if(f<=0)return null;let d=Math.min(u,f);return new Uint8Array(c).set(new Uint8Array(e.buffer,l,d),s),o+=d,{pos:i,data:c,offset:s,length:d}})).filter(Boolean)}class Tt{constructor(e,t,r=null){this.filename=e,this.buffer=new Map,this.ops=t,this.meta=r,this._metaDirty=!1,this.writeLock=!1,this.openHandles=0}bufferChunks(e){for(let t=0;t{let r=this.buffer.get(t);return r?e.chunks.push(r):e.missing.push(t),e}),{chunks:[],missing:[]}),r=[];return t.missing.length>0&&(r=this.ops.readBlocks(t.missing,this.meta.blockSize)),t.chunks.concat(r)}read(e,t,r,n){let i=e.buffer;if(r<=0)return 0;if(n<0)return 0;if(n>=this.meta.size){let e=new Uint8Array(i,t);for(let t=0;to.pos&&(s=t-o.pos),ro.data.byteLength||a<0)continue;let u=a-s;i.set(new Uint8Array(o.data,s,u),o.pos-t+s)}return n}(this.load(u),s,a);if(i.byteLength-t(t.length!==this.meta.blockSize?e.partialWrites.push(t):e.fullWrites.push({pos:t.pos,data:t.data}),e)),{fullWrites:[],partialWrites:[]}),u=[];s.length>0&&(u=this.load(s.map((e=>e.pos))));let c=a.concat(u.map((e=>{let t=s.find((t=>t.pos===e.pos));return new Uint8Array(e.data).set(new Uint8Array(t.data,t.offset,t.length),t.offset,t.length),e})));return this.bufferChunks(c),n+r>this.meta.size&&this.setattr({size:n+r}),r}async readIfFallback(){if(this.ops.readIfFallback){let e=await this.ops.readIfFallback();this.meta=e||{size:0}}}lock(e){return this._recordingLock||(this._recordingLock=!0),!!this.ops.lock(e)&&(e>=Mt&&(this.writeLock=!0),!0)}unlock(e){return 0===e&&(this._recordingLock=!1),this.writeLock&&(this.fsync(),this.writeLock=!1),this.ops.unlock(e)}fsync(){if(this.buffer.size>0){let e=this.buffer.get(0);if(e){let t=xt(new Uint8Array(e.data));if(t!==this.meta.blockSize){let e=this.buffer;this.buffer=new Map;let r=[...e.values()],n=r.length*this.meta.blockSize,i=new ArrayBuffer(n),o=new Uint8Array(i);for(let e of r)o.set(new Uint8Array(e.data),e.pos);this.bufferChunks(At(o,t,0,n)),this.setattr({blockSize:t})}}this.ops.writeBlocks([...this.buffer.values()],this.meta.blockSize)}this._metaDirty&&(this.ops.writeMeta({size:this.meta.size}),this._metaDirty=!1),this.buffer=new Map}setattr(e){null==this.meta&&(this.meta={}),void 0!==e.mode&&(this.meta.mode=e.mode),void 0!==e.blockSize&&(this.meta.blockSize=e.blockSize),void 0!==e.size&&(this.meta.size=e.size,this._metaDirty=!0)}getattr(){return this.meta}}let Ct,Ft,Bt,Pt=3735928559;class Dt{constructor(e,{initialOffset:t=4,useAtomics:r=!0,stream:n=!0,debug:i,name:o}={}){this.buffer=e,this.atomicView=new Int32Array(e),this.offset=t,this.useAtomics=r,this.stream=n,this.debug=i,this.name=o}log(...e){this.debug&&console.log(`[reader: ${this.name}]`,...e)}waitWrite(e,t=null){if(this.useAtomics){for(this.log(`waiting for ${e}`);0===Atomics.load(this.atomicView,0);){if(null!=t&&"timed-out"===Atomics.wait(this.atomicView,0,0,t))throw new Error("timeout");Atomics.wait(this.atomicView,0,0,500)}this.log(`resumed for ${e}`)}else if(1!==this.atomicView[0])throw new Error("`waitWrite` expected array to be readable")}flip(){if(this.log("flip"),this.useAtomics){if(1!==Atomics.compareExchange(this.atomicView,0,1,0))throw new Error("Read data out of sync! This is disastrous");Atomics.notify(this.atomicView,0)}else this.atomicView[0]=0;this.offset=4}done(){this.waitWrite("done");let e=new DataView(this.buffer,this.offset).getUint32(0)===Pt;return e&&(this.log("done"),this.flip()),e}peek(e){this.peekOffset=this.offset;let t=e();return this.offset=this.peekOffset,this.peekOffset=null,t}string(e){this.waitWrite("string",e);let t=this._int32(),r=t/2,n=new DataView(this.buffer,this.offset,t),i=[];for(let e=0;e{console.warn(`Deleting ${this.filename} database failed`)},e.onsuccess=()=>{}}open(){let e=new SharedArrayBuffer(36864);this.writer=new $t(e,{name:"args (backend)",debug:!1});let t=new SharedArrayBuffer(36864);var r,n;this.reader=new Dt(t,{name:"results",debug:!1}),r=this.reader,n=this.writer,self.postMessage({type:"__absurd:spawn-idb-worker",argBuffer:n.buffer,resultBuffer:r.buffer}),self.addEventListener("message",(e=>{switch(e.data.type){case"__perf-deets:start-profile":n.string("profile-start"),n.finalize(),r.int32(),r.done();break;case"__perf-deets:stop-profile":n.string("profile-stop"),n.finalize(),r.int32(),r.done()}}))}close(){this.invokeWorker("closeFile",{name:this.getStoreName()}),this.reader=null,this.writer=null,this.worker=null}readMeta(){return this.invokeWorker("readMeta",{name:this.getStoreName()})}writeMeta(e){return this.invokeWorker("writeMeta",{name:this.getStoreName(),meta:e})}readBlocks(e,t){return this.stats&&(this.stats.read+=e.length),this.invokeWorker("readBlocks",{name:this.getStoreName(),positions:e,blockSize:t})}writeBlocks(e,t){return this.stats&&(this.stats.writes+=e.length),this.invokeWorker("writeBlocks",{name:this.getStoreName(),writes:e,blockSize:t})}}function qt(e,t){return Math.round(e/t)}async function jt(e){return await function(){if(navigator.userAgentData||!/Safari\//.test(navigator.userAgent)||/Chrom(e|ium)\//.test(navigator.userAgent)||!indexedDB.databases)return Promise.resolve();let e;return new Promise((t=>{const r=()=>indexedDB.databases().finally(t);e=setInterval(r,100),r()})).finally((()=>clearInterval(e)))}(),new Promise(((t,r)=>{let n=globalThis.indexedDB.open(e,2);n.onsuccess=e=>{let r=e.target.result;r.onversionchange=()=>{console.log("closing because version changed"),r.close()},r.onclose=()=>{},t(r)},n.onupgradeneeded=e=>{let t=e.target.result;t.objectStoreNames.contains("data")||t.createObjectStore("data")},n.onblocked=e=>console.log("blocked",e),n.onerror=n.onabort=e=>r(e.target.error)}))}class Jt{constructor(e,t){this.dbName=e,this._openDb=null,this.hasAlertedFailure=!1,this.onFallbackFailure=t}async getDb(){return this._openDb||(this._openDb=await jt(this.dbName)),this._openDb}closeDb(){this._openDb&&(this._openDb.close(),this._openDb=null)}async readAll(){let e=await this.getDb(this.dbName),t=new Map,r=e.transaction(["data"],"readonly").objectStore("data");return new Promise(((e,n)=>{let i=r.openCursor(IDBKeyRange.lowerBound(-1));i.onerror=n,i.onsuccess=r=>{let n=r.target.result;n?(t.set(n.key,n.value),n.continue()):e(t)}}))}async write(e,t,r){let n=(await this.getDb(this.dbName)).transaction(["data"],"readwrite"),i=n.objectStore("data");await new Promise(((o,s)=>{let a=i.get(0);a.onsuccess=u=>{if(r&&!function(e,t){if(null!=e&&null!=t){let r=new Uint8Array(e),n=new Uint8Array(t);for(let e=24;e<40;e++)if(r[e]!==n[e])return!1;return!0}return null==e&&null==t}(a.result,t))return this.onFallbackFailure&&!this.hasAlertedFailure&&(this.hasAlertedFailure=!0,this.onFallbackFailure()),void s(new Error("Fallback mode unable to write file changes"));for(let t of e)i.put(t.value,t.key);n.onsuccess=()=>o(),n.onerror=()=>s()},a.onerror=s}))}}class zt{constructor(e,t){this.filename=e,this.dbName=this.filename.replace(/\//g,"-"),this.cachedFirstBlock=null,this.writeQueue=null,this.blocks=new Map,this.lockType=0,this.transferBlockOwnership=!1,this.persistance=new Jt(this.dbName,t)}async readIfFallback(){return this.transferBlockOwnership=!0,this.blocks=await this.persistance.readAll(),this.readMeta()}lock(e){return this.cachedFirstBlock=this.blocks.get(0),this.lockType=e,!0}unlock(e){return this.lockType>Nt&&e===Nt&&this.flush(),this.lockType=e,!0}delete(){let e=globalThis.indexedDB.deleteDatabase(this.dbName);e.onerror=()=>{console.warn(`Deleting ${this.filename} database failed`)},e.onsuccess=()=>{}}open(){this.writeQueue=[],this.lockType=0}close(){this.flush(),this.transferBlockOwnership?this.transferBlockOwnership=!1:this.blocks=new Map,this.persistance.closeDb()}readMeta(){let e=this.blocks.get(-1);if(e){let t=this.blocks.get(0);return{size:e.size,blockSize:xt(new Uint8Array(t))}}return null}writeMeta(e){this.blocks.set(-1,e),this.queueWrite(-1,e)}readBlocks(e,t){let r=[];for(let n of e)r.push({pos:n,data:this.blocks.get(qt(n,t))});return r}writeBlocks(e,t){for(let r of e){let e=qt(r.pos,t);this.blocks.set(e,r.data),this.queueWrite(e,r.data)}this.lockType<=Nt&&this.flush()}queueWrite(e,t){this.writeQueue.push({key:e,value:t})}flush(){this.writeQueue.length>0&&(this.persistance.write(this.writeQueue,this.cachedFirstBlock,this.lockType>Nt),this.writeQueue=[]),this.cachedFirstBlock=null}}class Wt{constructor(e){this.onFallbackFailure=e}createFile(e){let t;t="undefined"!=typeof SharedArrayBuffer?new Ut(e):new zt(e,this.onFallbackFailure);let r=new Tt(e,t);return("production"!==ae.env.NODE_ENV||ae.env.PERF_BUILD)&&(null==this._files&&(this._files=new Set),this._files.add(r)),r}startProfile(){for(let e of this._files)if(e.ops.writer){let t=e.ops.writer,r=e.ops.reader;t.string("profile-start"),t.finalize(),r.int32(),r.done()}}stopProfile(){for(let e of this._files)if(e.ops.writer){let t=e.ops.writer,r=e.ops.reader;t.string("profile-stop"),t.finalize(),r.int32(),r.done()}}}function Ht(e,t){if(Ct)return Ct;if(!e)throw new Error("must speciefic database file");return Ct=new Promise(((r,n)=>{const i=async function(e,t="/sql-wasm.wasm"){if(!Ft){Ft=await Ot({locateFile:()=>t});const e=new Rt(Ft.FS,new Wt);Ft.register_for_idb(e),Ft.FS.mkdir("/sql"),Ft.FS.mount(e,{},"/sql")}const r=`/sql/${e}`,n=new Ft.Database(r,{filename:!0});if("undefined"==typeof SharedArrayBuffer){const e=Ft.FS.open(r,"a+");await e.node.contents.readIfFallback(),Ft.FS.close(e)}return n.exec("\n PRAGMA page_size=8192;\n PRAGMA journal_mode=MEMORY;\n "),n}(e,t);i.then((e=>r(e))).catch((e=>n(e)))})),Ct}async function Gt(e,t,r=!1){try{const n=function(e,t,r,n){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' ORDER BY send_time ${n?"ASC":"DESC"} LIMIT ${r}\n `)}(await Ht(),e,t,r);return M(F(n[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}}async function Yt(e){try{const t=await Ht(),r=(JSON.parse(e)||[]).map((e=>B(e)));if(0===r.length)return M("");const n=function(e,t){const r=v.insert().into("local_conversations").setFieldsRows(t).toString();return e.exec(r)}(t,r);return M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}}async function Vt(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("temp_cache_local_chat_logs").setFieldsRows(t).toString();return e.exec(r)}(t,JSON.parse(e).map((e=>B(e))));return M(r[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}}self.$RefreshReg$=()=>{},self.$RefreshSig$=()=>()=>{};const Qt=new Map,Kt=self,Xt=new d({event:new class{constructor(e){c(this,"_currentEndpoint"),c(this,"_targetEndpoint"),c(this,"_events"),c(this,"_originOnmessage"),c(this,"_receiveMessage"),c(this,"onerror",null),c(this,"config"),c(this,"sendAdapter"),c(this,"receiveAdapter"),this._events={},this._currentEndpoint=e.currentEndpoint,this._targetEndpoint=e.targetEndpoint,this._originOnmessage=null,this.config=e.config,this.receiveAdapter=e.receiveAdapter,this.sendAdapter=e.sendAdapter;const t=e=>{const t=this.receiveAdapter?this.receiveAdapter(e):e.data;if(t&&"string"==typeof t.event){const e=this._events[t.event]||[];if(e.length)return void e.forEach((e=>{e(...t.args||[])}));this.onerror&&this.onerror(u(a({},l.METHOD_NOT_FOUND),{data:t}))}};if(this._currentEndpoint.addEventListener)return"start"in this._currentEndpoint&&this._currentEndpoint.start&&this._currentEndpoint.start(),this._currentEndpoint.addEventListener("message",t,!1),void(this._receiveMessage=t);this._originOnmessage=this._currentEndpoint.onmessage,this._currentEndpoint.onmessage=e=>{this._originOnmessage&&this._originOnmessage(e),t(e)},this._receiveMessage=this._currentEndpoint.onmessage}emit(e,...t){const r={event:e,args:t},n=this.sendAdapter?this.sendAdapter(r,this._targetEndpoint):{data:r},i=n.data||r,o=this.config?"function"==typeof this.config?this.config(i,this._targetEndpoint)||{}:this.config||{}:{};Array.isArray(n.transfer)&&n.transfer.length&&(o.transfer=n.transfer),this._targetEndpoint.postMessage(i,o)}on(e,t){this._events[e]||(this._events[e]=[]),this._events[e].push(t)}off(e,t){if(!this._events[e])return;if(!t)return void(this._events[e]=[]);const r=this._events[e]||[];this._events[e]=r.filter((e=>e!==t))}destroy(){if(this._currentEndpoint.removeEventListener)this._currentEndpoint.removeEventListener("message",this._receiveMessage,!1);else try{this._currentEndpoint.onmessage=this._originOnmessage}catch(e){console.warn(e)}}}({currentEndpoint:Kt,targetEndpoint:Kt})});Xt.registerMethod("fileMapSet",((e,t)=>(Qt.set(e,t),M(e)))),Xt.registerMethod("fileMapClear",(()=>(Qt.clear(),M("")))),Xt.registerMethod("wasmOpen",(e=>new Promise(((t,r)=>{const n=Qt.get(e);n?t(M(n.size)):r("file not found")})))),Xt.registerMethod("wasmClose",(async e=>new Promise((t=>{Qt.delete(e),t(M(e))})))),Xt.registerMethod("wasmRead",((e,t,r)=>{const n=Qt.get(e);if(!n)throw"file not found";const i=n.slice(t,t+r);return new Promise(((e,t)=>{const r=new FileReader;r.onload=()=>{e(r.result)},r.onerror=()=>{t(r.error)},r.readAsArrayBuffer(i)}))})),Xt.registerMethod("getUpload",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_uploads where part_hash = '${t}' limit 1;\n `)}(await Ht(),e),r=F(t[0],"CamelCase");if(0===r.length)throw`no upload with partHash = ${e}`;return M(r[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertUpload",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_uploads").setFields(t).toString();return e.exec(r)}(t,B(P(JSON.parse(e))));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateUpload",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.update().table("local_uploads").setFields(t).where(`part_hash = '${t.part_hash}'`).toString();return e.exec(r)}(t,B(P(JSON.parse(e))));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteUpload",(async function(e){try{const t=function(e,t){const r=v.delete().from("local_uploads").where(`part_hash = '${t}'`).toString();return e.exec(r)}(await Ht(),e);return M(t)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("setSqlWasmPath",(function(e){Bt=e})),Xt.registerMethod("initDB",(async function(e,t){try{const r=await Ht(`${t}${e}.sqlite`,Bt),n=[],i=function(e){return e.exec("\n create table if not exists 'local_uploads' (\n 'part_hash' text,\n 'upload_id' varchar(1000),\n 'upload_info' varchar(2000),\n 'expire_time' integer,\n 'create_time' integer,\n PRIMARY KEY ('part_hash')\n )\n ")}(r),o=function(e){return e.exec("\n create table if not exists 'local_stranger'\n (\n 'user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'app_manger_level' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'global_recv_msg_opt' integer,\n PRIMARY KEY ('user_id')\n )\n ")}(r),s=function(e){return e.exec("\n create table if not exists 'local_conversations' (\n 'conversation_id' char(128),\n 'conversation_type' integer,\n 'user_id' char(64),\n 'group_id' char(128),\n 'show_name' varchar(255),\n 'face_url' varchar(255),\n 'recv_msg_opt' integer,\n 'unread_count' integer,\n 'group_at_type' integer,\n 'latest_msg' varchar(1000),\n 'latest_msg_send_time' integer,\n 'draft_text' text,\n 'draft_text_time' integer,\n 'is_pinned' numeric,\n 'burn_duration' integer,\n 'is_private_chat' numeric,\n 'is_not_in_group' numeric,\n 'update_unread_count_time' integer,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n 'max_seq' integer,\n 'min_seq' integer,\n 'has_read_seq' integer,\n 'msg_destruct_time' integer default 604800,\n 'is_msg_destruct' numeric default false,\n primary key ('conversation_id')\n )\n ")}(r),a=function(e){return e.exec("\n create table if not exists 'local_users' (\n 'user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'app_manger_level' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'global_recv_msg_opt' integer,\n primary key ('user_id')\n )\n ")}(r),u=function(e){return e.exec("\n create table if not exists 'local_blacks' (\n 'owner_user_id' varchar(64),\n 'block_user_id' varchar(64),\n 'nickname' varchar(255),\n 'face_url' varchar(255),\n 'gender' INTEGER,\n 'create_time' INTEGER,\n 'add_source' INTEGER,\n 'operator_user_id' varchar(64),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n primary key ('owner_user_id', 'block_user_id')\n ) \n ")}(r),c=function(e){return e.exec("\n create table if not exists 'local_friends'\n (\n 'owner_user_id' varchar(64),\n 'friend_user_id' varchar(64),\n 'remark' varchar(255),\n 'create_time' INTEGER,\n 'add_source' INTEGER,\n 'operator_user_id' varchar(64),\n 'name' varchar(255),\n 'face_url' varchar(255),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'is_pinned' numeric,\n primary key ('owner_user_id', 'friend_user_id')\n ) \n ")}(r),l=function(e){return e.exec("\n create table if not exists 'local_groups'\n (\n 'group_id' varchar(64) PRIMARY KEY,\n 'name' TEXT,\n 'notification' varchar(255),\n 'introduction' varchar(255),\n 'face_url' varchar(255),\n 'create_time' INTEGER,\n 'status' INTEGER,\n 'creator_user_id' varchar(64),\n 'group_type' INTEGER,\n 'owner_user_id' varchar(64),\n 'member_count' INTEGER,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'need_verification' INTEGER,\n 'look_member_info' INTEGER,\n 'apply_member_friend' INTEGER,\n 'notification_update_time' INTEGER,\n 'notification_user_id' TEXT,\n 'display_is_read' numeric\n ) \n ")}(r),f=function(e){return e.exec('\n create table if not exists "local_group_requests" (\n "group_id" varchar(64),\n "group_name" text,\n "notification" varchar(255),\n "introduction" varchar(255),\n "face_url" varchar(255),\n "create_time" integer,\n "status" integer,\n "creator_user_id" varchar(64),\n "group_type" integer,\n "owner_user_id" varchar(64),\n "member_count" integer,\n "user_id" varchar(64),\n "nickname" varchar(255),\n "user_face_url" varchar(255),\n "gender" integer,\n "handle_result" integer,\n "req_msg" varchar(255),\n "handle_msg" varchar(255),\n "req_time" integer,\n "handle_user_id" varchar(64),\n "handle_time" integer,\n "ex" varchar(1024),\n "attached_info" varchar(1024),\n "join_source" integer,\n "inviter_user_id" text,\n PRIMARY KEY ("group_id", "user_id")\n );\n ')}(r),d=function(e){return e.exec("\n create table if not exists 'local_group_members' (\n 'group_id' varchar(64),\n 'user_id' varchar(64),\n 'nickname' varchar(255),\n 'user_group_face_url' varchar(255),\n 'role_level' integer,\n 'join_time' integer,\n 'join_source' integer,\n 'inviter_user_id' text,\n 'mute_end_time' integer DEFAULT 0,\n 'operator_user_id' varchar(64),\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n PRIMARY KEY ('group_id', 'user_id')\n ) \n ")}(r),h=function(e){return e.exec('\n create table if not exists "local_admin_group_requests" (\n "group_id" varchar(64),\n "group_name" text,\n "notification" varchar(255),\n "introduction" varchar(255),\n "face_url" varchar(255),\n "create_time" integer,\n "status" integer,\n "creator_user_id" varchar(64),\n "group_type" integer,\n "owner_user_id" varchar(64),\n "member_count" integer,\n "user_id" varchar(64),\n "nickname" varchar(255),\n "user_face_url" varchar(255),\n "gender" integer,\n "handle_result" integer,\n "req_msg" varchar(255),\n "handle_msg" varchar(255),\n "req_time" integer,\n "handle_user_id" varchar(64),\n "handle_time" integer,\n "ex" varchar(1024),\n "attached_info" varchar(1024),\n "join_source" integer,\n "inviter_user_id" text,\n PRIMARY KEY ("group_id", "user_id")\n );\n ')}(r),_=function(e){return e.exec("\n create table if not exists 'local_friend_requests'\n (\n 'from_user_id' varchar(64),\n 'from_nickname' varchar(255),\n 'from_face_url' varchar(255),\n 'to_user_id' varchar(64),\n 'to_nickname' varchar(255),\n 'to_face_url' varchar(255),\n 'handle_result' INTEGER,\n 'req_msg' varchar(255),\n 'create_time' INTEGER,\n 'handler_user_id' varchar(64),\n 'handle_msg' varchar(255),\n 'handle_time' INTEGER,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n primary key ('from_user_id', 'to_user_id')\n ); \n ")}(r),p=function(e){return e.exec("\n create table if not exists 'local_super_groups' (\n 'group_id' varchar(64),\n 'name' text,\n 'notification' varchar(255),\n 'introduction' varchar(255),\n 'face_url' varchar(255),\n 'create_time' integer,\n 'status' integer,\n 'creator_user_id' varchar(64),\n 'group_type' integer,\n 'owner_user_id' varchar(64),\n 'member_count' integer,\n 'ex' varchar(1024),\n 'attached_info' varchar(1024),\n 'need_verification' integer,\n 'look_member_info' integer,\n 'apply_member_friend' integer,\n 'notification_update_time' integer,\n 'notification_user_id' text,\n primary key ('group_id')\n )\n ")}(r),g=function(e){return e.exec("\n create table if not exists 'temp_cache_local_chat_logs' (\n 'client_msg_id' char(64),\n 'server_msg_id' char(64),\n 'send_id' char(64),\n 'recv_id' char(64),\n 'sender_platform_id' integer,\n 'sender_nick_name' varchar(255),\n 'sender_face_url' varchar(255),\n 'session_type' integer,\n 'msg_from' integer,\n 'content_type' integer,\n 'content' varchar(1000),\n 'is_read' numeric,\n 'status' integer,\n 'seq' integer DEFAULT 0,\n 'send_time' integer,\n 'create_time' integer,\n 'attached_info' varchar(1024),\n 'ex' varchar(1024),\n PRIMARY KEY ('client_msg_id')\n );\n ")}(r),m=function(e){return e.exec("\n create table if not exists 'local_notification_seqs'\n (\n 'conversation_id' char(128),\n 'seq' integer,\n PRIMARY KEY ('conversation_id')\n )\n ")}(r),v=function(e){return e.exec("\n create table if not exists 'local_sending_messages'\n (\n conversation_id varchar(128),\n client_msg_id varchar(64),\n ex varchar(1024),\n PRIMARY KEY ('conversation_id', 'client_msg_id')\n );\n ")}(r),y=function(e){return e.exec("\n create table if not exists 'local_conversation_unread_messages' (\n 'conversation_id' char(128),\n 'client_msg_id' char(64),\n 'send_time' integer,\n 'ex' varchar(1024),\n primary key (\n 'conversation_id',\n 'client_msg_id'\n )\n );\n ")}(r),b=function(e){return e.exec("\n create table if not exists 'local_app_sdk_version' (\n 'version' varchar(255),\n 'installed' numeric,\n primary key ('version')\n ) \n ")}(r),w=function(e){return e.exec("\n create table if not exists 'local_sync_version' (\n 'table_name' varchar(255),\n 'entity_id' varchar(255),\n 'version_id' text,\n 'version' integer,\n 'create_time' integer,\n 'id_list' text,\n primary key ('table_name','entity_id')\n ) \n ")}(r);return function(e){!function(e){try{e.exec("\n ALTER TABLE local_friends ADD COLUMN is_pinned numeric;\n ")}catch(e){}}(e),function(e){try{e.exec("\n ALTER TABLE local_groups ADD COLUMN display_is_read numeric;\n ")}catch(e){}}(e),function(e){try{e.exec("\n ALTER TABLE local_app_sdk_version ADD COLUMN installed numeric;\n ")}catch(e){}}(e)}(r),n.push(i,o,s,a,p,y,u,c,l,d,_,f,h,g,m,v,b,w),M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("close",(async function(){try{return await async function(){if(!Ct)return;(await Ct).close(),Ct=void 0}(),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMessage",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id = '${r}' limit 1\n `)}(await Ht(),e,t);return 0===r.length?M("",h.ErrorNoRecord,`no message with id ${t}`):M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMultipleMessage",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id in (${r.map((e=>`'${e}'`)).join(",")}) order by send_time desc;\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getSendingMessageList",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE status = 1;\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateMessageTimeAndStatus",(async function(e,t,r,n,i){try{const o=await Ht(),s=function(e,t,r,n,i,o){return e.exec(`\n UPDATE 'chat_logs_${t}' SET server_msg_id = '${n}', send_time = ${i}, status = ${o} WHERE client_msg_id = '${r}' and seq=0;\n `)}(o,e,t,r,n,i);if(0===o.getRowsModified())throw"updateMessageTimeAndStatus no record updated";return M(s)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateMessage",(async function(e,t,r){try{const n=await Ht(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`client_msg_id = '${r}'`).toString();return e.exec(i)}(n,e,t,B(P(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessage no record updated";return M(i)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateMessageBySeq",(async function(e,t,r){try{const n=await Ht(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`seq = '${r}'`).toString();return e.exec(i)}(n,e,t,B(P(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessageBySeq no record updated";return M(i)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateColumnsMessage",(async function(e,t,r){try{const n=await Ht(),i=function(e,t,r,n){const i=v.update().table(`'chat_logs_${t}'`).setFields(n).where(`client_msg_id = '${r}'`).toString();return e.exec(i)}(n,e,t,B(P(JSON.parse(r))));if(0===n.getRowsModified())throw"updateMessage no record updated";return M(i)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertMessage",(async function(e,t){try{const r=await Ht(),n=function(e,t,r){const n=v.insert().into(`'chat_logs_${t}'`).setFields(r).toString();return e.exec(n)}(r,e,B(JSON.parse(t)));return M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertMessageList",(async function(e,t){try{const r=await Ht(),n=function(e,t,r){y(e,t);const n=v.insert().into(`'chat_logs_${t}'`).setFieldsRows(r).toString();return e.exec(n)}(r,e,JSON.parse(t).map((e=>B(e))));return M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMessageList",(async function(e,t,r,n=!1){if(r<=0)return Gt(e,t,n);try{const i=function(e,t,r,n,i){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE send_time ${i?">":"<"} ${n} ORDER BY send_time ${i?"ASC":"DESC"} LIMIT ${r}\n `)}(await Ht(),e,t,r,n);return M(F(i[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMessageListNoTime",Gt),Xt.registerMethod("messageIfExists",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id = '${r}';\n `)}(await Ht(),e,t);return M(0!==r.length)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("searchMessageByKeyword",(async function(e,t,r,n,i,o,s,a){try{const u=function(e,t,r,n,i,o,s,a,u){const c=s||(new Date).getTime();let l="";const f=r.map((e=>`${e}`)).join(","),d=0===i?"or ":"and ";return n.forEach(((e,t)=>{0==t&&(l+="And ("),t+1>=n.length?l+="content like '%"+n[t]+"%') ":l+="content like '%"+n[t]+"%' "+d})),e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${o} and ${c} \n AND status <=3 \n And content_type IN (${f}) \n ${l}\n ORDER BY send_time DESC LIMIT ${u} OFFSET ${a};\n `)}(await Ht(),e,JSON.parse(t),JSON.parse(r),n,i,o,s,a);return M(F(u[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("searchMessageByContentType",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){const a=r.map((e=>`${e}`)).join(","),u=i||(new Date).getTime();return e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${n} and ${u} \n AND status <=3 \n And content_type IN (${a}) \n ORDER BY send_time DESC LIMIT ${s} OFFSET ${o};\n `)}(await Ht(),e,JSON.parse(t),r,n,i,o);return M(F(s[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("searchMessageByContentTypeAndKeyword",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){const a=r.map((e=>`${e}`)).join(","),u=s||(new Date).getTime();let c="";const l=0===i?"or ":"and ";return n.forEach(((e,t)=>{0==t&&(c+="And ("),t+1>=n.length?c+="content like '%"+n[t]+"%') ":c+="content like '%"+n[t]+"%' "+l})),e.exec(` \n SELECT * FROM 'chat_logs_${t}' \n WHERE send_time between ${o} and ${u} \n AND status <=3 \n And content_type IN (${a}) \n ${c}\n ORDER BY send_time DESC;\n `)}(await Ht(),e,JSON.parse(t),JSON.parse(r),n,i,o);return M(F(s[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateMsgSenderFaceURLAndSenderNickname",(async function(e,t,r,n){try{return function(e,t,r,n,i){y(e,t),e.exec(`\n UPDATE 'chat_logs_${t}' SET sender_face_url = '${n}', sender_nick_name = '${i}' WHERE send_id = '${r}';\n `)}(await Ht(),e,t,r,n),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAlreadyExistSeqList",(async function(e,t){var r;try{const n=function(e,t,r){return e.exec(`\n SELECT seq FROM 'chat_logs_${t}' WHERE seq in (${r.join(",")})\n `)}(await Ht(),e,JSON.parse(t));return M(null!==(r=F(n[0],"CamelCase",["isRead","isReact","isExternalExtensions"]).map((e=>e.seq)))&&void 0!==r?r:[])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getLatestValidServerMessage",(async function(e,t,r){try{const n=function(e,t,r,n){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE send_time ${n?"<":">"} ${r} AND seq != 0 ORDER BY send_time ${n?"DESC":"ASC"} LIMIT 1\n `)}(await Ht(),e,t,r),i=F(n[0],"CamelCase",["isRead","isReact","isExternalExtensions"])[0];return i?M(i):M("",h.ErrorNoRecord,`no message with conversationID ${e}`)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMessageBySeq",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE seq = ${r} limit 1;\n `)}(await Ht(),e,t);return 0===r.length?M("",h.ErrorNoRecord,`no message with seq ${t}`):M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMessagesByClientMsgIDs",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE client_msg_id in (${r.map((e=>`'${e}'`)).join(",")}) order by send_time desc;\n `)}(await Ht(),e,JSON.parse(t));return 0===r.length?M("",h.ErrorNoRecord,`no message with clientMsgIDListStr ${t}`):M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMessagesBySeqs",(async function(e,t){try{const r=function(e,t,r){return y(e,t),e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE seq in (${r.join(",")}) order by send_time desc;\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getConversationNormalMsgSeq",(async function(e){var t,r;try{const n=function(e,t){return y(e,t),e.exec(`\n SELECT seq FROM 'chat_logs_${t}' order by seq desc limit 1;\n `)}(await Ht(),e);return M(null!==(r=null===(t=F(n[0],"CamelCase")[0])||void 0===t?void 0:t.seq)&&void 0!==r?r:0)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getConversationPeerNormalMsgSeq",(async function(e,t){var r,n;try{const i=function(e,t,r){return e.exec(`\n SELECT seq FROM 'chat_logs_${t}' where send_id != '${r}' order by seq desc limit 1;\n `)}(await Ht(),e,t);return M(null!==(n=null===(r=F(i[0],"CamelCase")[0])||void 0===r?void 0:r.seq)&&void 0!==n?n:0)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteConversationAllMessages",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM 'chat_logs_${t}' WHERE 1=1;\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("markDeleteConversationAllMessages",(async function(e){try{return function(e,t){e.exec(`\n UPDATE 'chat_logs_${t}' SET status = 2 WHERE (1=1) and (conversation_id = '${t}')';\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getUnreadMessage",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE send_id != '${r}' and is_read = 0;\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("markConversationMessageAsReadBySeqs",(async function(e,t,r){try{const n=await Ht();return function(e,t,r,n){y(e,t);const i=r.map((e=>`${e}`)).join(",");e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE seq IN (${i}) and send_id != '${n}';\n `)}(n,e,JSON.parse(t),r),M(n.getRowsModified())}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("markConversationMessageAsRead",(async function(e,t,r){try{const n=await Ht();return function(e,t,r,n){const i=r.map((e=>`'${e}'`)).join(",");e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE client_msg_id IN (${i}) and send_id != '${n}';\n `)}(n,e,JSON.parse(t),r),M(n.getRowsModified())}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteConversationMsgs",(async function(e,t){try{const r=function(e,t,r){const n=r.map((e=>`'${e}'`)).join(",");return e.exec(`\n DELETE FROM 'chat_logs_${t}' WHERE client_msg_id IN (${n});\n `)}(await Ht(),e,JSON.parse(t));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("markConversationAllMessageAsRead",(async function(e,t){try{const r=await Ht();return function(e,t,r){e.exec(`\n UPDATE 'chat_logs_${t}' SET is_read = 1 WHERE is_read = 0 and send_id != '${r}';\n `)}(r,e,JSON.parse(t)),M(r.getRowsModified())}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("searchAllMessageByContentType",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE content_type = ${r};\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertSendingMessage",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_sending_messages").setFields(t).toString();return e.exec(r)}(t,B(JSON.parse(e)));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteSendingMessage",(async function(e,t){try{const r=function(e,t,r){const n=v.delete().from("local_sending_messages").where(`conversation_id = '${t}'`).where(`client_msg_id = '${r}'`).toString();return e.exec(n)}(await Ht(),e,t);return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllSendingMessages",(async function(){try{const e=function(e){const t=v.select().from("local_sending_messages").toString();return e.exec(t)}(await Ht());return M(F(e[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getLatestActiveMessage",(async function(e,t){try{const r=function(e,t,r){y(e,t);const n=r?"ASC":"DESC";return e.exec(`\n SELECT * FROM 'chat_logs_${t}' WHERE status < 4 ORDER BY send_time ${n};\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",["isRead","isReact","isExternalExtensions"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllConversationList",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations where latest_msg_send_time > 0 order by case when is_pinned=1 then 0 else 1 end,max(latest_msg_send_time,draft_text_time) desc;\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllConversationListToSync",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations;\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getHiddenConversationList",(async function(){try{const e=function(e){return e.exec("\n select * from local_conversations where latest_msg_send_time = 0;\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getConversation",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_conversations where conversation_id = '${t}' limit 1;\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no conversation with id ${e}`):M(F(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getMultipleConversation",(async function(e){try{const t=await Ht(),r=function(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select * from local_conversations where conversation_id in (${r.join(",")});\n `)}(t,JSON.parse(e));return M(F(r[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateColumnsConversation",(async function(e,t){try{const r=await Ht();let n=t;"string"==typeof t&&(n=B(P(JSON.parse(t))));const i=function(e,t,r){const n=v.update().table("local_conversations").setFields(r).where(`conversation_id = '${t}'`).toString();return e.exec(n)}(r,e,n);if(0===r.getRowsModified())throw"updateColumnsConversation no record updated";return M(i)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("decrConversationUnreadCount",(async function(e,t){try{const r=function(e,t,r){e.exec("begin"),e.exec(`\n update local_conversations set \n unread_count=unread_count-${r} \n where conversation_id = '${t}';\n `);const n=e.exec(`select unread_count from local_conversations where conversation_id = '${t}'`);return Number(n[0].values[0])<0&&e.exec(`\n update local_conversations set \n unread_count=0 \n where conversation_id = '${t}';\n `),e.exec("commit")}(await Ht(),e,t);return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertConversationList",Yt),Xt.registerMethod("getTotalUnreadMsgCount",(async function(){var e,t,r;try{const n=function(e){return e.exec("\n select sum(unread_count) from local_conversations where recv_msg_opt < 2 and latest_msg_send_time > 0;\n ")}(await Ht());return M(null!==(r=null===(t=null===(e=n[0])||void 0===e?void 0:e.values[0])||void 0===t?void 0:t[0])&&void 0!==r?r:0)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertConversation",(async function(e){return Yt(`[${e}]`)})),Xt.registerMethod("getConversationByUserID",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_conversations where user_id = "${t}" limit 1;\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no conversation with userID ${e}`):M(F(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getConversationListSplit",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT *\n FROM local_conversations\n WHERE latest_msg_send_time > 0\n ORDER BY case\n when is_pinned = 1 then 0\n else 1 end, max(latest_msg_send_time, draft_text_time) DESC\n LIMIT ${r} OFFSET ${t}\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteConversation",(async function(e){try{return function(e,t){e.exec(`\n DELETE\n FROM local_conversations\n WHERE conversation_id = "${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteAllConversation",(async function(){try{return function(e){e.exec("\n DELETE FROM local_conversations;\n ")}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchUpdateConversationList",(async function(e){try{const t=await Ht(),r=(JSON.parse(e)||[]).map((e=>B(e)));return 0===r.length||r.forEach((e=>{!function(e,t){const r=v.update().table("local_conversations").setFields(t).where(`conversation_id = '${t.conversation_id}'`).toString();e.exec(r)}(t,e)})),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("conversationIfExists",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT count(*)\n FROM local_conversations\n WHERE conversation_id = "${t}"\n `)}(await Ht(),e);return M(0!==t.length)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("resetConversation",(async function(e){try{return function(e,t){e.exec(`\n UPDATE local_conversations\n SET unread_count=0,\n latest_msg="",\n latest_msg_send_time=0,\n draft_text="",\n draft_text_time=0\nWHERE conversation_id = "${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("resetAllConversation",(async function(){try{return function(e){e.exec('\n UPDATE local_conversations\n SET unread_count=0,\n latest_msg="",\n latest_msg_send_time=0,\n draft_text="",\n draft_text_time=0\n ')}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("clearConversation",(async function(e){try{return function(e,t){e.exec(`\n UPDATE local_conversations\nSET unread_count=0,\n latest_msg="",\n draft_text="",\n draft_text_time=0\nWHERE conversation_id = "${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("clearAllConversation",(async function(){try{return function(e){e.exec('\n UPDATE local_conversations\nSET unread_count=0,\n latest_msg="",\n draft_text="",\n draft_text_time=0\n ')}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("setConversationDraft",(async function(e,t){try{return function(e,t,r){const n=(new Date).getTime();e.exec(`\n update local_conversations\n set draft_text='${r}',\n draft_text_time=${n},\n latest_msg_send_time=case when latest_msg_send_time = 0 then ${n} else latest_msg_send_time end\n where conversation_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("removeConversationDraft",(async function(e,t){try{return function(e,t,r){e.exec(`\n update local_conversations\n set draft_text="${r}",\n draft_text_time=0\n where conversation_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("unPinConversation",(async function(e,t){try{return function(e,t,r){e.exec(`\n update local_conversations\n set is_pinned=${r},\n draft_text_time=case when draft_text = "" then 0 else draft_text_time end\n where conversation_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("incrConversationUnreadCount",(async function(e){try{const t=function(e,t){return e.exec(`\n update local_conversations set \n unread_count=unread_count+1 \n where conversation_id = '${t}';\n `)}(await Ht(),e);return M(t)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("setMultipleConversationRecvMsgOpt",(async function(e,t){try{return function(e,t,r){const n=t.map((e=>`'${e}'`)).join(",");e.exec(`\n UPDATE local_conversations\n SET recv_msg_opt=${r}\n WHERE conversation_id IN (${n})\n `)}(await Ht(),JSON.parse(e),t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("findAllUnreadConversationConversationID",(async function(){try{const e=function(e){return e.exec("\n select conversation_id from local_conversations where unread_count > 0;\n ")}(await Ht());return M(F(e[0],"CamelCase").map((e=>e.conversationID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllSingleConversationIDList",(async function(){try{const e=function(e){return e.exec("\n select conversation_id from local_conversations where conversation_type = 1;\n ")}(await Ht());return M(F(e[0],"CamelCase").map((e=>e.conversationID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllConversationIDList",(async function(){try{const e=function(e){return e.exec("\n select conversation_id from local_conversations;\n ")}(await Ht());return M(F(e[0],"CamelCase").map((e=>e.conversationID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllConversations",(async function(){try{const e=function(e){return e.exec("\n SELECT * FROM local_conversations\n ")}(await Ht());return M(F(e[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("searchConversations",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_conversations\n WHERE show_name LIKE '%${t}%'\n ORDER BY latest_msg_send_time DESC\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",["isPinned","isPrivateChat","isNotInGroup","isMsgDestruct"]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getLoginUser",(async function(e){try{const t=function(e,t){return e.exec(`\n select *, name as nickname from local_users where user_id = '${t}' limit 1;\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no login user with id ${e}`):M(F(t[0],"CamelCase",[],{name:"nickname"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertLoginUser",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_users").setFields(t).toString();return e.exec(r)}(t,B(P(JSON.parse(e),{nickname:"name"})));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateLoginUser",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.update().table("local_users").setFields(t).where(`user_id = '${t.user_id}'`).toString();return e.exec(r)}(t,B(P(JSON.parse(e),{nickname:"name"})));if(0===t.getRowsModified())throw"updateLoginUser no record updated";return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getStrangerInfo",(async function(e){try{const t=await Ht();return M(F(k(t,JSON.parse(e))[0],"CamelCase",[],{name:"nickname"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("setStrangerInfo",(function(e){try{return JSON.parse(e).map((e=>B(P(e,{nickname:"name"})))).map((e=>async function(e){try{const t=await Ht(),r=k(t,[e.user_id]);return F(r[0]).length?function(e,t){const r=v.update().table("local_stranger").setFields(t).where(`user_id = '${t.user_id}'`).toString();e.exec(r)}(t,e):function(e,t){const r=v.insert().into("local_stranger").setFields(t).toString();e.exec(r)}(t,e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}}(e))),Promise.resolve(M(""))}catch(e){return console.error(e),Promise.resolve(M(void 0,h.ErrorInit,JSON.stringify(e)))}})),Xt.registerMethod("getAppSDKVersion",(async function(){try{const e=R(await Ht());return 0===e.length?M("",h.ErrorNoRecord,"no app version with database"):M(F(e[0],"CamelCase",["installed"])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("setAppSDKVersion",(async function(e){try{const t=await Ht(),r=B(P(JSON.parse(e))),n=F(R(t)[0],"CamelCase",["installed"]);return n[0]&&n[0].version?(function(e,t,r){const n=v.update().table("local_app_sdk_version").setFields(r).where(`version = '${t}'`).toString();e.exec(n)}(t,n[0].version,r),M("")):(function(e,t){const r=v.insert().into("local_app_sdk_version").setFields(t).toString();e.exec(r)}(t,r),M(""))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getVersionSync",(async function(e,t){try{const r=N(await Ht(),e,t);if(0===r.length)return M("",h.ErrorNoRecord,`no sync version with tableName ${e}, entityID ${t}`);const n=F(r[0],"CamelCase",[],{id_list:"uidList"})[0];return n.uidList=JSON.parse(n.uidList),M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("setVersionSync",(async function(e){try{const t=await Ht(),r=B(P(JSON.parse(e)));r.id_list=JSON.stringify(r.uid_list),delete r.uid_list;const n=F(N(t,r.table_name,r.entity_id)[0],"CamelCase",[]);return n[0]&&n[0].tableName?(function(e,t,r,n){delete n.table;const i=v.update().table("local_sync_version").setFields(n).where(`table_name = '${t}' AND entity_id = '${r}'`).toString();e.exec(i)}(t,n[0].tableName,n[0].entityID,r),M("")):(function(e,t){delete t.table;const r=v.insert().into("local_sync_version").setFields(t).toString();e.exec(r)}(t,r),M(""))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteVersionSync",(async function(e,t){try{return function(e,t,r){e.exec(`\n DELETE FROM local_sync_version WHERE table_name = "${t}" AND entity_id = "${r}";\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getJoinedSuperGroupList",(async function(){try{const e=await Ht();return M(F(b(e)[0]))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getJoinedSuperGroupIDList",(async function(){try{const e=await Ht(),t=F(b(e)[0]);return M(t.map((e=>e.groupID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getSuperGroupInfoByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_super_groups where group_id = '${t}' LIMIT 1;\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no super group with id ${e}`):M(F(t[0])[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteSuperGroup",(async function(e){try{const t=function(e,t){return e.exec(`\n delete from local_super_groups where group_id = '${t}';\n `)}(await Ht(),e);return M(t)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertSuperGroup",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_super_groups").setFields(t).toString();return e.exec(r)}(t,B(P(JSON.parse(e),{groupName:"name"})));return M(r)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateSuperGroup",(async function(e,t){try{const r=await Ht(),n=function(e,t,r){const n=v.update().table("local_super_groups").setFields(r).where(`group_id = '${t}'`).toString();return e.exec(n)}(r,e,B(P(JSON.parse(t),{groupName:"name"})));if(0===r.getRowsModified())throw"updateSuperGroup no record updated";return M(n)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteConversationUnreadMessageList",(async function(e,t){try{const r=await Ht();!function(e,t,r){e.exec(`\n delete from local_conversation_unread_messages where conversation_id = '${t}' and send_time <= ${r};\n `)}(r,e,t);return M(r.getRowsModified())}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertConversationUnreadMessageList",(async function(e){try{const t=await Ht(),r=function(e,t){const r=v.insert().into("local_conversation_unread_messages").setFieldsRows(t).toString();return e.exec(r)}(t,JSON.parse(e).map((e=>B(e))));return M(r[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getBlackList",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_blacks\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{block_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getBlackListUserID",(async function(){try{const e=function(e){return e.exec("\n SELECT block_user_id\n FROM local_blacks\n ")}(await Ht());return M(F(e[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getBlackInfoByBlockUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n SELECT *\n FROM local_blacks\n WHERE owner_user_id = "${r}"\n AND block_user_id = "${t}"\n LIMIT 1\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getBlackInfoList",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_blacks\n where block_user_id in (${r.join(",")})\n `)}(await Ht(),JSON.parse(e));return M(F(t[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertBlack",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_blacks").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{userID:"block_user_id",name:"nickname"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteBlack",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_blacks\n where owner_user_id = "${r}"\n and block_user_id = "${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateBlack",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_blacks").setFields(t).where(`owner_user_id = '${t.owner_user_id}' and block_user_id = '${t.block_user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e)))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertFriendRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_friend_requests").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e)))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteFriendRequestBothUserID",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_friend_requests\n where from_user_id = "${t}"\n and to_user_id = "${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateFriendRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_friend_requests").setFields(t).where(`from_user_id = '${t.from_user_id}' and to_user_id = '${t.to_user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e)))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getRecvFriendApplication",(async function(e){try{const t=function(e,t){return e.exec(`\n select *\n from local_friend_requests\n where to_user_id = "${t}"\n order by create_time desc\n `)}(await Ht(),e);return M(F(t[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getSendFriendApplication",(async function(e){try{const t=function(e,t){return e.exec(`\n select * from local_friend_requests\n where from_user_id = "${t}"\n order by create_time desc\n `)}(await Ht(),e);return M(F(t[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getFriendApplicationByBothID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friend_requests\n where from_user_id = "${t}"\n and to_user_id = "${r}"\n limit 1\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getBothFriendReq",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friend_requests\n where (from_user_id = "${t}"\n and to_user_id = "${r}")\n or (from_user_id = "${r}"\n and to_user_id = "${t}")\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertGroup",(async function(e){try{const t=await Ht();return E(t,B(P(JSON.parse(e),{groupName:"name"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteGroup",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM local_groups \n WHERE group_id="${t}" \n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateGroup",(async function(e,t){try{const r=await Ht();return function(e,t,r){const n=v.update().table("local_groups").setFields(r).where(`group_id = '${t}'`).toString();e.exec(n)}(r,e,B(P(JSON.parse(t),{groupName:"name"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getJoinedGroupList",(async function(){try{const e=await Ht();return M(F(O(e)[0],"CamelCase",["displayIsRead"],{name:"groupName"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupInfoByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT *\n FROM local_groups\n WHERE group_id = "${t}"\n `)}(await Ht(),e);return 0===t.length?M("",h.ErrorNoRecord,`no group with id ${e}`):M(F(t[0],"CamelCase",["displayIsRead"],{name:"groupName"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllGroupInfoByGroupIDOrGroupName",(async function(e,t,r){try{const n=function(e,t,r,n){let i="";const o=`group_id like "%${t}%"`,s=`name like "%${t}%"`;return r&&(i=o),n&&(i=s),n&&r&&(i=o+" or "+s),e.exec(`\n select *\n from local_groups\n where ${i}\n order by create_time desc\n `)}(await Ht(),e,t,r);return M(F(n[0],"CamelCase",["displayIsRead"],{name:"groupName"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("subtractMemberCount",(async function(e){try{return function(e,t){e.exec(` \n update local_groups set member_count = member_count-1 where group_id = '${t}'\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("addMemberCount",(async function(e){try{return function(e,t){e.exec(` \n update local_groups set member_count = member_count+1 where group_id = '${t}' \n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getJoinedWorkingGroupIDList",(async function(){try{const e=await Ht(),t=F(O(e)[0],"CamelCase",["displayIsRead"]),r=[];return t.forEach((e=>{2===e.groupType&&r.push(e.groupID)})),M(JSON.stringify(r))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getJoinedWorkingGroupList",(async function(){try{const e=O(await Ht()),t=F(e[0],"CamelCase",["displayIsRead"],{name:"groupName"}).filter((e=>2===e.groupType));return M(JSON.stringify(t))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberAllGroupIDs",(async function(){try{const e=function(e){return e.exec("\n select distinct group_id from local_group_members\n ")}(await Ht());return M(F(e[0],"CamelCase",["displayIsRead"]).map((e=>e.groupID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroups",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`)).join(",");return e.exec(`\n select * from local_groups where group_id in (${r});\n `)}(await Ht(),JSON.parse(e)),r=F(t[0],"CamelCase",["displayIsRead"],{name:"groupName"});return M(JSON.stringify(r))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertGroup",(async function(e){try{const t=await Ht();return JSON.parse(e).map((e=>{const r=B(P(e,{groupName:"name"}));return E(t,r),null})),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteAllGroup",(async function(){try{return function(e){e.exec("\n DELETE FROM local_groups;\n ")}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberInfoByGroupIDUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_group_members\n WHERE group_id = "${t}" \n AND user_id = "${r}" \n LIMIT 1\n `)}(await Ht(),e,t);return M(F(r[0],"CamelCase",[],{user_group_face_url:"faceURL"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllGroupMemberList",(async function(){try{const e=function(e){return e.exec("\n SELECT *\n FROM local_group_members\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllGroupMemberUserIDList",(async function(){try{const e=function(e){return e.exec("\n SELECT user_id\n FROM local_group_members\n ")}(await Ht());return M(F(e[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberCount",(async function(e){var t,r;try{const n=function(e,t){return e.exec(`\n SELECT count(*) FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await Ht(),e);return M(null===(r=null===(t=n[0])||void 0===t?void 0:t.values[0])||void 0===r?void 0:r[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupSomeMemberInfo",(async function(e,t){try{const r=function(e,t,r){const n=r.map((e=>`'${e}'`));return e.exec(`\n select *\n from local_group_members\n where group_id = "${t}"\n and user_id in (${n.join(",")})\n `)}(await Ht(),e,JSON.parse(t));return M(F(r[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupAdminID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT user_id FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 3\n `)}(await Ht(),e);return M(F(t[0],"CamelCase").map((e=>e.userID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberListByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberListSplit",(async function(e,t,r,n,i){try{const o=function(e,t,r,n,i,o){let s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `;return 1===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 100 \n LIMIT ${i} OFFSET ${n}\n `),2===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 60 \n ORDER BY join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),3===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 20 \n ORDER BY join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),4===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 20 OR role_level = 60 ) \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),5===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 100 OR role_level = 60 ) \n ORDER BY role_level DESC,join_time ASC \n LIMIT ${i} OFFSET ${n}\n `),6===r&&(s=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And user_id != "${o}" \n LIMIT ${i} OFFSET ${n}\n `),e.exec(s)}(await Ht(),e,t,r,n,i);return M(F(o[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberOwnerAndAdmin",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level > 1 \n ORDER BY role_level DESC\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberOwner",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 2\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberListSplitByJoinTimeFilter",(async function(e,t,r,n=0,i=1e11,o){try{const s=function(e,t,r,n,i=0,o=1e11,s){let a="";a=0===s.length?`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And join_time between ${i} and ${o} \n ORDER BY join_time DESC \n LIMIT ${n} OFFSET ${r}\n `:`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And join_time between ${i} and ${o} \n And user_id NOT IN (${s.map((e=>`'${e}'`)).join(",")})\n ORDER BY join_time DESC \n LIMIT ${n} OFFSET ${r}\n `;return e.exec(a)}(await Ht(),e,t,r,n,i,JSON.parse(o));return M(F(s[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupOwnerAndAdminByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level > 1\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberUIDListByGroupID",(async function(e){try{const t=function(e,t){return e.exec(`\n SELECT user_id FROM local_group_members \n WHERE group_id = "${t}" \n `)}(await Ht(),e);return M(F(t[0],"CamelCase").map((e=>e.userID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertGroupMember",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_group_members").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{faceURL:"user_group_face_url"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertGroupMember",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_group_members").setFieldsRows(t).toString();e.exec(r)}(t,(JSON.parse(e)||[]).map((e=>B(P(e,{faceURL:"user_group_face_url"}))))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteGroupMember",(async function(e,t){try{return function(e,t,r){e.exec(`\n DELETE FROM local_group_members \n WHERE group_id="${t}" \n and user_id="${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteGroupAllMembers",(async function(e){try{return function(e,t){e.exec(`\n DELETE FROM local_group_members \n WHERE group_id="${t}"\n `)}(await Ht(),e),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateGroupMember",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_group_members").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{faceURL:"user_group_face_url"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateGroupMemberField",(async function(e,t,r){try{const n=await Ht();return function(e,t,r,n){const i=v.update().table("local_group_members").setFields(n).where(`group_id = '${t}' and user_id = '${r}'`).toString();e.exec(i)}(n,e,t,B(P(JSON.parse(r),{faceURL:"user_group_face_url"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("searchGroupMembers",(async function(e,t,r,n,i,o){try{const s=function(e,t,r,n,i,o,s){let a="";a=r?n&&i?`\n SELECT * FROM local_group_members \n WHERE ( user_id like "%${t}%" or nickname like "%${t}%" ) \n and group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n||i?`\n SELECT * FROM local_group_members \n WHERE ${n?`nickname like "%${t}%"`:`user_id like "%${t}%"`}\n and group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:`\n SELECT * FROM local_group_members \n WHERE group_id IN ("${r}") \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n&&n?`\n SELECT * FROM local_group_members \n WHERE user_id like "%${t}%" or nickname like "%${t}%" \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:n||n?`\n SELECT * FROM local_group_members \n WHERE ${n?`nickname like "%${t}%"`:`user_id like "%${t}%"`} \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `:`\n SELECT * FROM local_group_members \n ORDER BY join_time DESC \n LIMIT ${s} OFFSET ${o}\n `;return e.exec(a)}(await Ht(),e,t,r,n,i,o);return M(F(s[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getUserJoinedGroupIDs",(async function(e){try{const t=function(e,t){return e.exec(`\n select group_id from local_group_members where user_id = "${t}";\n `)}(await Ht(),e);return M(F(t[0],"CamelCase").map((e=>e.groupID)))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getGroupMemberListByUserIDs",(async function(e,t,r){try{const n=function(e,t,r,n){const i=n.map((e=>`'${e}'`));let o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And user_id IN (${i.join(",")})\n ORDER BY role_level DESC,join_time ASC \n `;return 1===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 100 \n And user_id IN (${i.join(",")})\n `),2===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 60 \n And user_id IN (${i.join(",")})\n ORDER BY join_time ASC \n `),3===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And role_level = 20 \n And user_id IN (${i.join(",")})\n ORDER BY join_time ASC \n `),4===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 20 OR role_level = 60 ) \n And user_id IN (${i.join(",")})\n ORDER BY role_level DESC,join_time ASC \n `),5===r&&(o=`\n SELECT * FROM local_group_members \n WHERE group_id = "${t}" \n And ( role_level = 100 OR role_level = 60 ) \n And user_id IN (${i.join(",")})\n ORDER BY role_level DESC,join_time ASC \n `),e.exec(o)}(await Ht(),e,t,JSON.parse(r));return M(F(n[0],"CamelCase",[],{user_group_face_url:"faceURL"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_group_requests").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteGroupRequest",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_group_requests\n where group_id = "${t}"\n and user_id = "${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_group_requests").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getSendGroupApplication",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_group_requests\n order by create_time desc\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{face_url:"groupFaceURL",user_face_url:"userFaceURL",handle_msg:"handledMsg",handle_time:"handledTime"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertAdminGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.insert().into("local_admin_group_requests").setFields(t).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteAdminGroupRequest",(async function(e,t){try{return function(e,t,r){e.exec(`\n delete\n from local_admin_group_requests\n where group_id = "${t}"\n and user_id = "${r}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateAdminGroupRequest",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_admin_group_requests").setFields(t).where(`group_id = '${t.group_id}' and user_id = '${t.user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{groupFaceURL:"face_url",userFaceURL:"user_face_url",handledMsg:"handle_msg",handledTime:"handle_time"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAdminGroupApplication",(async function(){try{const e=function(e){return e.exec("\n select *\n from local_admin_group_requests\n order by create_time desc\n ")}(await Ht());return M(F(e[0],"CamelCase",[],{face_url:"groupFaceURL",user_face_url:"userFaceURL",handle_msg:"handledMsg",handle_time:"handledTime"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("insertFriend",(async function(e){try{const t=await Ht();return w(t,B(P(JSON.parse(e),{userID:"friend_user_id",nickname:"name"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteFriend",(async function(e,t){try{return function(e,t,r){e.exec(`\n DELETE FROM local_friends \n WHERE owner_user_id="${r}" \n and friend_user_id="${t}"\n `)}(await Ht(),e,t),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateFriend",(async function(e){try{const t=await Ht();return function(e,t){const r=v.update().table("local_friends").setFields(t).where(`owner_user_id = '${t.owner_user_id}' and friend_user_id = '${t.friend_user_id}'`).toString();e.exec(r)}(t,B(P(JSON.parse(e),{userID:"friend_user_id",nickname:"name"}))),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getAllFriendList",(async function(e){try{const t=function(e,t){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${t}"\n `)}(await Ht(),e);return M(F(t[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("searchFriendList",(async function(e,t,r,n){try{const i=function(e,t,r,n,i){let o="";const s=`name like "%${t}%"`,a=`remark like "%${t}%"`;return r&&(o=`friend_user_id like "%${t}%"`),n&&(o=o?o+" or "+s:s),i&&(o=o?o+" or "+a:a),e.exec(`\n select *\n from local_friends\n where ${o}\n order by create_time desc\n `)}(await Ht(),e,t,r,n);return M(F(i[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getFriendInfoByFriendUserID",(async function(e,t){try{const r=function(e,t,r){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${r}"\n and friend_user_id = "${t}"\n limit 1\n `)}(await Ht(),e,t);return 0===r.length?M("",h.ErrorNoRecord,`no friend with id ${e}`):M(F(r[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"})[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getFriendInfoList",(async function(e){try{const t=function(e,t){const r=t.map((e=>`'${e}'`)).join(",");return e.exec(`\n select *\n from local_friends\n where friend_user_id in (${r})\n `)}(await Ht(),JSON.parse(e));return M(F(t[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getPageFriendList",(async function(e,t,r){try{const n=function(e,t,r,n){return e.exec(`\n select *\n from local_friends\n where owner_user_id = "${n}"\n order by name\n limit ${r} offset ${t}\n `)}(await Ht(),e,t,r);return M(F(n[0],"CamelCase",["isPinned"],{name:"nickname",friend_user_id:"userID"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("updateColumnsFriend",(async function(e,t){try{const r=await Ht(),n=B(P(JSON.parse(t),{userID:"friend_user_id",nickname:"name"}));return function(e,t,r){const n=t.map((e=>`'${e}'`)).join(","),i=v.update().table("local_friends").setFields(r).where(`friend_user_id IN (${n})`).toString();e.exec(i)}(r,JSON.parse(e),n),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getFriendListCount",(async function(){var e,t,r;try{const n=function(e){return e.exec("\n SELECT COUNT(*) FROM local_friends;\n ")}(await Ht());return M(null!==(r=null===(t=null===(e=n[0])||void 0===e?void 0:e.values[0])||void 0===t?void 0:t[0])&&void 0!==r?r:0)}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertFriend",(async function(e){try{const t=await Ht();return JSON.parse(e).map((e=>{const r=B(P(e,{userID:"friend_user_id",nickname:"name"}));return w(t,r),null})),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("deleteAllFriend",(async function(){try{return function(e){e.exec("\n DELETE FROM local_friends;\n ")}(await Ht()),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertTempCacheMessageList",Vt),Xt.registerMethod("InsertTempCacheMessage",(async function(e){return Vt(`[${e}]`)})),Xt.registerMethod("getNotificationAllSeqs",(async function(){try{const e=function(e){return e.exec("SELECT * from local_notification_seqs where 1 = 1;")}(await Ht());return M(F(e[0],"CamelCase"))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("batchInsertNotificationSeq",(async function(e){try{const t=JSON.parse(e),r=await Ht();return t.map((e=>{const{conversationID:t,seq:n}=e;S(r,t,n)})),M("")}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("setNotificationSeq",(async function(e,t){try{const r=await Ht();let n=function(e,t,r){return e.exec(`UPDATE local_notification_seqs set seq = ${r} where conversation_id = "${t}"`)}(r,e,t);return 0===r.getRowsModified()&&(n=S(r,e,t)),M(n[0])}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("getExistedTables",(async function(){try{const e=function(e){return e.exec('\n SELECT name FROM sqlite_master WHERE type="table";\n ')}(await Ht());return M(F(e[0],"CamelCase",[],{tbl_name:"tblName"}))}catch(e){return console.error(e),M(void 0,h.ErrorInit,JSON.stringify(e))}})),Xt.registerMethod("exec",(async e=>{const t=await Ht();try{const r=t.exec(e);console.info(`sql debug with exec sql = ${e.trim()} , return `,r)}catch(t){console.info(`sql debug with exec sql = ${e} , return `,t)}})),Xt.registerMethod("getRowsModified",(async()=>{const e=await Ht();try{const t=e.getRowsModified();console.info("sql debug with getRowsModified return ",t)}catch(e){console.info("sql debug with getRowsModified return ",e)}})),Xt.registerMethod("exportDB",(async()=>{const e=await Ht();try{const t=e.export(),r=new Blob([t]);return URL.createObjectURL(r)}catch(e){console.info("sql export error, return ",e)}})); diff --git a/ruoyi-ui/src/api/oa/projectSchedule.js b/ruoyi-ui/src/api/oa/projectSchedule.js index 8764ed2..c325f70 100644 --- a/ruoyi-ui/src/api/oa/projectSchedule.js +++ b/ruoyi-ui/src/api/oa/projectSchedule.js @@ -1,5 +1,13 @@ import request from '@/utils/request' +// 催促进度:给项目负责人发 IM 消息 +export function urgeProgress (scheduleId) { + return request({ + url: '/oa/projectSchedule/urge/' + scheduleId, + method: 'post' + }) +} + // 查询项目进度列表 export function listProjectSchedule (query) { return request({ diff --git a/ruoyi-ui/src/api/oa/suggestion.js b/ruoyi-ui/src/api/oa/suggestion.js new file mode 100644 index 0000000..d59cd84 --- /dev/null +++ b/ruoyi-ui/src/api/oa/suggestion.js @@ -0,0 +1,25 @@ +import request from '@/utils/request' + +export function listSuggestion (query) { + return request({ url: '/oa/suggestion/list', method: 'get', params: query }) +} + +export function submitSuggestion (data) { + return request({ url: '/oa/suggestion', method: 'post', data }) +} + +export function acceptSuggestion (id, remark) { + return request({ url: `/oa/suggestion/${id}/accept`, method: 'put', params: { remark } }) +} + +export function finishSuggestion (id, remark) { + return request({ url: `/oa/suggestion/${id}/finish`, method: 'put', params: { remark } }) +} + +export function closeSuggestion (id, remark) { + return request({ url: `/oa/suggestion/${id}/close`, method: 'put', params: { remark } }) +} + +export function isItMember () { + return request({ url: '/oa/suggestion/isItMember', method: 'get' }) +} diff --git a/ruoyi-ui/src/api/system/im.js b/ruoyi-ui/src/api/system/im.js new file mode 100644 index 0000000..809929b --- /dev/null +++ b/ruoyi-ui/src/api/system/im.js @@ -0,0 +1,9 @@ +import request from '@/utils/request' + +// 当前用户 IM 登录凭据 +export function getImCredentials () { + return request({ + url: '/system/user/im/credentials', + method: 'get' + }) +} diff --git a/ruoyi-ui/src/assets/styles/index.scss b/ruoyi-ui/src/assets/styles/index.scss index 1999122..341ad29 100644 --- a/ruoyi-ui/src/assets/styles/index.scss +++ b/ruoyi-ui/src/assets/styles/index.scss @@ -24,16 +24,20 @@ body { // 表单 / 输入 / 按钮 紧凑 .el-form-item { - margin-bottom: 14px; + margin-bottom: 10px; } .el-form-item__label { - font-size: 12px; - line-height: 30px; - padding: 0 8px 0 0; -} -.el-form-item--small.el-form-item { - margin-bottom: 12px; + font-size: 12px !important; + font-weight: normal !important; + color: #606266; + line-height: 26px !important; + padding: 0 6px 0 0 !important; } +.el-form-item--small .el-form-item__label, +.el-form-item--medium .el-form-item__label { font-size: 12px !important; line-height: 26px !important; } +.el-form-item--mini .el-form-item__label { font-size: 11px !important; line-height: 22px !important; } +.el-form-item--small.el-form-item { margin-bottom: 8px; } +.el-form-item--mini.el-form-item { margin-bottom: 6px; } /* 全局输入控件统一压低高度(含 input/select/cascader/date/range/autocomplete) */ .el-input__inner, .el-textarea__inner, @@ -45,39 +49,56 @@ body { .el-date-editor--datetimerange.el-range-editor, .el-date-editor--monthrange.el-range-editor, .el-range-editor.el-input__inner { - height: 28px !important; - line-height: 28px !important; + height: 26px !important; + line-height: 26px !important; font-size: 12px !important; padding: 0 8px !important; } -.el-input--medium .el-input__inner { height: 30px !important; line-height: 30px !important; } -.el-input--small .el-input__inner { height: 28px !important; line-height: 28px !important; } -.el-input--mini .el-input__inner { height: 24px !important; line-height: 24px !important; font-size: 12px !important; } +.el-input--medium .el-input__inner { height: 28px !important; line-height: 28px !important; } +.el-input--small .el-input__inner { height: 26px !important; line-height: 26px !important; } +.el-input--mini .el-input__inner { height: 22px !important; line-height: 22px !important; font-size: 12px !important; } .el-input--mini.el-input, .el-input--mini .el-input__suffix, -.el-input--mini .el-input__prefix { line-height: 24px !important; } +.el-input--mini .el-input__prefix { line-height: 22px !important; } .el-range-editor.el-input__inner { padding: 0 10px !important; } .el-range-editor .el-range-input { font-size: 12px !important; height: 100% !important; line-height: 1 !important; } -.el-range-editor .el-range-separator { line-height: 26px !important; font-size: 12px !important; } -.el-input__icon { line-height: 28px !important; } -.el-input__suffix-inner .el-input__icon { line-height: 28px !important; } -.el-form-item__content { line-height: 28px; } +.el-range-editor .el-range-separator { line-height: 24px !important; font-size: 12px !important; } +.el-input__icon { line-height: 26px !important; } +.el-input__suffix-inner .el-input__icon { line-height: 26px !important; } +.el-form-item__content { line-height: 26px; } + +/* 按钮:默认 26px 高,mini 22px,medium 28px */ .el-button { - padding: 7px 12px; - font-size: 12px; - border-radius: 6px; + padding: 5px 10px !important; + font-size: 12px !important; + border-radius: 4px; + line-height: 1.2; +} +.el-button--mini { + padding: 3px 8px !important; + font-size: 11px !important; + height: 22px; + line-height: 1.1; } -.el-button--mini, .el-button--small { - padding: 6px 10px; - font-size: 12px; + padding: 4px 10px !important; + font-size: 12px !important; + height: 24px; } .el-button--medium { - padding: 8px 14px; - font-size: 12px; + padding: 6px 12px !important; + font-size: 12px !important; + height: 28px; +} +.el-button [class*="el-icon-"] + span { + margin-left: 3px; } .el-button + .el-button { - margin-left: 8px; + margin-left: 6px; +} +/* 文字按钮去掉额外 padding */ +.el-button--text { + padding: 2px 4px !important; } // 表格紧凑 @@ -143,15 +164,36 @@ body { // Tabs / Tags .el-tabs__item { - height: 36px; - line-height: 36px; + height: 30px; + line-height: 30px; font-size: 12px; } .el-tag { - height: 22px; - line-height: 20px; - padding: 0 8px; + height: 18px !important; + line-height: 16px !important; + padding: 0 6px !important; + font-size: 11px !important; + border-radius: 3px; +} +.el-tag.el-tag--mini { + height: 16px !important; + line-height: 14px !important; + padding: 0 5px !important; + font-size: 10px !important; +} +.el-tag .el-tag__close { + font-size: 11px; + transform: scale(0.85); +} +.el-checkbox__inner, +.el-radio__inner { + width: 12px; + height: 12px; +} +.el-radio__label, +.el-checkbox__label { font-size: 12px; + padding-left: 6px; } // 描述列表 / 步骤 @@ -194,19 +236,17 @@ body { } // 圆角按钮/输入框 -.el-button { - border-radius: 6px; -} .el-input__inner, .el-textarea__inner { - border-radius: 6px; + border-radius: 4px; } .el-card { border-radius: 8px; } +/* 注意:原本全局 label { font-weight: 700 } 会把所有表单 label 加粗看上去傻大,去掉 */ label { - font-weight: 700; + font-weight: normal; } html { @@ -372,30 +412,10 @@ aside { margin-bottom: 10px; } } -/* 全局按钮缩小:默认按钮等比 small 化 */ -.el-button { - padding: 7px 12px; - font-size: 12px; - border-radius: 3px; -} -.el-button--medium { - padding: 8px 14px; - font-size: 12px; -} -.el-button--small { - padding: 6px 10px; - font-size: 12px; -} -.el-button--mini { - padding: 5px 8px; - font-size: 12px; -} -.el-button [class*="el-icon-"] + span { - margin-left: 4px; -} +/* 旧的按钮缩小块已合并到顶部 .el-button 主样式,这里不再重复 */ .el-button-group > .el-button { - padding-left: 10px; - padding-right: 10px; + padding-left: 8px !important; + padding-right: 8px !important; } /* 列表页搜索表单紧凑模式(加 class="compact-search" 即可生效) */ diff --git a/ruoyi-ui/src/components/HomeModules/index.js b/ruoyi-ui/src/components/HomeModules/index.js index d5388c3..a6f5b2c 100644 --- a/ruoyi-ui/src/components/HomeModules/index.js +++ b/ruoyi-ui/src/components/HomeModules/index.js @@ -3,6 +3,8 @@ import MiniList from './components/MiniList.vue'; import ExpressQuestionList from './modules/ExpressQuestionList.vue'; import FeedbackList from './modules/FeedbackList.vue'; import FinancialCharts from './modules/FinancialCharts.vue'; +import ImChatPanel from './modules/ImChatPanel.vue'; +import MyProgressList from './modules/MyProgressList.vue'; import MyTaskList from './modules/MyTaskList.vue'; import OwnerTaskList from './modules/OwnerTaskList.vue'; import ProjectManagement from './modules/ProjectManagement.vue'; @@ -12,7 +14,9 @@ export { ExpressQuestionList, FeedbackList, FinancialCharts, + ImChatPanel, MiniList, + MyProgressList, MyTaskList, OwnerTaskList, ProjectManagement, RequirementList }; diff --git a/ruoyi-ui/src/components/HomeModules/modules/ImChatPanel.vue b/ruoyi-ui/src/components/HomeModules/modules/ImChatPanel.vue new file mode 100644 index 0000000..cbeb714 --- /dev/null +++ b/ruoyi-ui/src/components/HomeModules/modules/ImChatPanel.vue @@ -0,0 +1,270 @@ + + + + + diff --git a/ruoyi-ui/src/components/HomeModules/modules/MyProgressList.vue b/ruoyi-ui/src/components/HomeModules/modules/MyProgressList.vue new file mode 100644 index 0000000..55019d4 --- /dev/null +++ b/ruoyi-ui/src/components/HomeModules/modules/MyProgressList.vue @@ -0,0 +1,143 @@ + + + + + diff --git a/ruoyi-ui/src/components/Workbench/widgets/registry.js b/ruoyi-ui/src/components/Workbench/widgets/registry.js index 5aedfd0..02f988f 100644 --- a/ruoyi-ui/src/components/Workbench/widgets/registry.js +++ b/ruoyi-ui/src/components/Workbench/widgets/registry.js @@ -9,6 +9,8 @@ import { ExpressQuestionList, FeedbackList, FinancialCharts, + ImChatPanel, + MyProgressList, MyTaskList, OwnerTaskList, ProjectManagement, @@ -56,6 +58,16 @@ export const WIDGET_REGISTRY = { component: ExpressQuestionList, defaultSize: { w: 4, h: 8 } }, + myProgress: { + title: '我的待做进度', + component: MyProgressList, + defaultSize: { w: 4, h: 10 } + }, + imChat: { + title: 'IM 聊天', + component: ImChatPanel, + defaultSize: { w: 6, h: 12 } + }, miniCalendar: { title: '日程日历', component: MiniCalendar, diff --git a/ruoyi-ui/src/components/fad-service/ProjectSelect/index.vue b/ruoyi-ui/src/components/fad-service/ProjectSelect/index.vue index f333853..ea21dac 100644 --- a/ruoyi-ui/src/components/fad-service/ProjectSelect/index.vue +++ b/ruoyi-ui/src/components/fad-service/ProjectSelect/index.vue @@ -1,11 +1,11 @@