const e=/^-?\d+$/,t=/^[A-Za-z0-9_]{5,}$/i;function n(e){let t=e.trim(),n=!1;for(;;){let e=/^(telegram|tg):/i.test(t)?(n=!0,t.replace(/^(telegram|tg):/i,``).trim()):n&&/^group:/i.test(t)?t.replace(/^group:/i,``).trim():t;if(e===t)return t;t=e}}function r(t){let r=n(t);if(r&&e.test(r))return r}function i(t){return e.test(t.trim())}function a(e){let r=n(e);if(!r)return;if(i(r))return r;let a=/^(?:https?:\/\/)?t\.me\/([A-Za-z0-9_]+)$/i.exec(r);if(a?.[1])return`@${a[1]}`;if(r.startsWith(`@`)){let e=r.slice(1);return!e||!t.test(e)?void 0:`@${e}`}if(t.test(r))return`@${r}`}function o(e){let t=e.trim();return t&&i(t)?t.startsWith(`-`)?`group`:`direct`:`unknown`}function s(e){let t=n(e),r=/^(.+?):topic:(\d+)$/.exec(t);if(r)return{chatId:r[1],messageThreadId:Number.parseInt(r[2],10),chatType:o(r[1])};let i=/^(.+):(\d+)$/.exec(t);return i?{chatId:i[1],messageThreadId:Number.parseInt(i[2],10),chatType:o(i[1])}:{chatId:t,chatType:o(t)}}function c(e){return s(e).chatType}export{c as i,a as n,s as r,r as t};
