import{G as t}from"./p-9811c98c.js";const e=t=>{let e=null;try{const n=JSON.parse(t.message),{target:s,message:o}=n;e=void 0===s||void 0===o?t:Object.assign(Object.assign({},t),{targetUserIds:s,message:o})}catch(n){e=t}return e};function n(t){return t.sort(((t,e)=>t.localeCompare(e))).join("_")}function s(t,e){if(null==t)return!0;for(const n of t)if("file"===n.kind){const t=n.getAsFile();n.type.startsWith("image/")?e("image",t):e("file",t)}}function o({messages:t,participants:s,selfUserId:o}){const r={};for(const t of s)r[n([t.userId,o])]=[];return t.forEach((t=>{var s;const o=e(t);let c="everyone";if((null===(s=o.targetUserIds)||void 0===s?void 0:s.length)>0){const t=new Set([o.userId,...o.targetUserIds]);c=n(Array.from(t))}r[c]||(r[c]=[]),r[c].push({type:"chat",message:o})})),r}function r({messages:e,selfUserId:n,selectedGroupId:s,participants:r}){var c;const a=o({messages:e,selfUserId:n,participants:r}),i={};for(const e in a){const o=null!==(c=t[e])&&void 0!==c?c:0;e===s?(i[e]=0,t[e]=new Date):i[e]=a[e].filter((t=>"chat"==t.type&&t.message.time>o&&t.message.userId!==n)).length}return i}function c({groupId:t,selfUserId:e}){return t.split("_").find((t=>t!=e))}function a(t){return t.split("").reverse().join("")}const i=/^\*([^*\s]+)\*/,f=/^_([^_\s]+)_/,u=/^~([^~\s]+)~/,l=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.,~#?&//=]*)/,p=/<blockquote>[.\s\S]*<\/blockquote>\n\n/m;function d(t,e=!1){if(!p.test(t))return"";let n=0,s=13;return e&&(n=12,s=0),t.substring(t.indexOf("<blockquote>")+n,t.indexOf("</blockquote>")+s)}function g(t){return t.replace(p,"")}const b=2e3,m=["<a>","<b>","<i>","<q>","<s>"];function _(t){t=(t=t.split(" ").map((t=>{if(l.test(t)){const e=l.exec(t);t=t.replace(e[0],`<a>${e[0]}</a>`)}else{if(i.test(t)){const e=i.exec(t);t=t.replace(e[0],`<b>${e[1]}</b>`)}if(f.test(t)){const e=f.exec(t);t=t.replace(e[0],`<i>${e[1]}</i>`)}if(u.test(t)){const e=u.exec(t);t=t.replace(e[0],`<s>${e[1]}</s>`)}}return t})).join(" ")).split(" ").map(((t,e)=>">"!==t||0!==e&&">"!==t[e-1]?t:"<q></q>")).join(" ");const[e]=v(t);return e}function v(t,e=""){const n=[];if(0===t.length)return[n,0];let s=0;for(;s<t.length;){if(e.length&&e===t.substring(s,s+e.length))return[n,s+e.length];if(m.includes(t.substring(s,s+3))){const[e,o]=v(t.substring(s+3),`</${t[s+1]}>`);n.push({type:t[s+1],content:1===e.length&&"plain_text"===e[0].type?e[0].content:e}),s+=o+3}else{let e=n[n.length-1];e&&"plain_text"===e.type||(n.push({type:"plain_text",content:""}),e=n[n.length-1]),e.content+=t[s],s++}}return[n,s]}export{b as M,o as a,r as b,c,p as d,d as e,e as f,n as g,s as h,_ as p,a as r,g as s}