@minsize/utils 0.3.2 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,7 +33,8 @@ yarn add @minsize/utils
33
33
  | `comparison` | Сравнивает два объекта на глубокое равенство, включая массивы (с учетом порядка). |
34
34
  | `generateUniqueKey` | Генерирует уникальный ключ для произвольного JavaScript объекта с использованием хэширования. |
35
35
  | `unlink` | Удаляет связь или ссылку между элементами или объектами. |
36
- | `textParserUrl` | Разбирает текст для извлечения и обработки URL. |
36
+ | `textParserUrl` | Разбирает текст для извлечения и обработки URL. DEPRECATED |
37
+ | `parseTextTokens` | Разбирает текст для извлечения и обработки raw/url/emoji. |
37
38
  | `memoize` | Запоминает результаты вызова функции, чтобы оптимизировать её производительность. |
38
39
  | `retry` | Повторяет выполнение функции при неудаче, например, при временных сбоях. |
39
40
  | `unique` | Возвращает массив, содержащий только уникальные элементы исходного массива. |
package/index.d.ts CHANGED
@@ -108,21 +108,78 @@ declare const distributor: <VALUE extends unknown>(prev: VALUE, next: VALUE) =>
108
108
  * @param {any} obj Произвольный JavaScript объект (string, number, array, object, итд.).
109
109
  * @returns {string} Строка, представляющая собой уникальный ключ (хеш) для переданного объекта.
110
110
  */
111
- declare const generateUniqueKey: <VALUE extends any>(obj: VALUE) => string;
111
+ declare const generateUniqueKey: <VALUE extends unknown>(obj: VALUE) => string;
112
112
 
113
- declare const unlink: <VALUE extends any>(value: VALUE) => VALUE;
113
+ declare const unlink: <VALUE extends unknown>(value: VALUE) => VALUE;
114
114
 
115
+ interface TextParserOptions$1 {
116
+ onToken?: (token: TextToken$1) => TextToken$1;
117
+ requireProtocol?: boolean;
118
+ regex?: RegExp;
119
+ }
120
+ type TextTokenType$1 = "raw" | "url";
121
+ interface TextToken$1 {
122
+ type: TextTokenType$1;
123
+ value: string;
124
+ }
125
+ /**
126
+ *
127
+ * @deprecated Using in `parseTextTokens`
128
+ */
129
+ declare const textParserUrl: (input: string, options?: TextParserOptions$1) => TextToken$1[];
130
+
131
+ /**
132
+ * Опции для парсера текста
133
+ */
115
134
  interface TextParserOptions {
135
+ /**
136
+ * Callback-функция, вызываемая для каждого найденного токена
137
+ * Позволяет модифицировать токены перед добавлением в результат
138
+ */
116
139
  onToken?: (token: TextToken) => TextToken;
140
+ /**
141
+ * Требовать ли наличие протокола (http/https) для распознавания URL
142
+ * @default false
143
+ */
117
144
  requireProtocol?: boolean;
145
+ /**
146
+ * Кастомное регулярное выражение для поиска URL
147
+ * Если не указано, используется стандартное выражение
148
+ */
118
149
  regex?: RegExp;
119
150
  }
120
- type TextTokenType = "raw" | "url";
151
+ /**
152
+ * Типы токенов, которые может распознавать парсер
153
+ */
154
+ type TextTokenType = "raw" | "url" | "emoji";
155
+ /**
156
+ * Токен - минимальная единица разбора текста
157
+ */
121
158
  interface TextToken {
159
+ /** Тип токена */
122
160
  type: TextTokenType;
161
+ /** Значение токена */
123
162
  value: string;
124
163
  }
125
- declare const textParserUrl: (input: string, options?: TextParserOptions) => TextToken[];
164
+ /**
165
+ * Парсит текст на токены: URL, эмодзи и обычный текст
166
+ *
167
+ * @param input - Входная строка для парсинга
168
+ * @param options - Опции парсера
169
+ * @returns Массив токенов
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * const result = parseTextTokens("Привет! 😊 Посети https://example.com")
174
+ * // [
175
+ * // { type: "raw", value: "Привет! " },
176
+ * // { type: "emoji", value: "😊" },
177
+ * // { type: "raw", value: " Посети " },
178
+ * // { type: "url", value: "https://example.com" }
179
+ * // ]
180
+ * ```
181
+ */
182
+ declare const parseTextTokens: (input: string, options?: TextParserOptions) => TextToken[];
126
183
 
127
184
  /**
128
185
  * Функция мемоизации, которая сохраняет результаты вызовов функции `fn` с определенными аргументами.
@@ -326,6 +383,13 @@ declare class DataKeeper<VALUE extends unknown> {
326
383
  get updateValues(): VALUE | undefined;
327
384
  }
328
385
 
386
+ declare class RequestDeduplicator {
387
+ private requests;
388
+ private emitter;
389
+ private mutex;
390
+ fetch<Result>(key: string, callback: () => Promise<Result>): Promise<Result>;
391
+ }
392
+
329
393
  interface UrlRule {
330
394
  hosts: (string | RegExp)[];
331
395
  paths?: (string | RegExp)[];
@@ -482,4 +546,4 @@ declare class UrlSecurityManager {
482
546
  getCacheSize(): number;
483
547
  }
484
548
 
485
- export { DataKeeper, DebouncedFunction, EventEmitter, HEXtoRGB, HSVtoRGB, RGBtoHEX, RGBtoHSV, UrlAction, type UrlRule, UrlSecurityManager, alignTo, chunks, clamp, distributor as comparison, copyText, createLinksFromText, decWord, elasticClamp, formatNumber, generateUniqueKey, getChangedData, groupBy, isType, memoize, omit, orderBy, parseQueryString, parseVersionString, pick, random, randomByWeight, retry, shuffle, sleep, textParserUrl, timeAgo, toShort, unique, unlink, updateCurrent };
549
+ export { DataKeeper, DebouncedFunction, EventEmitter, HEXtoRGB, HSVtoRGB, RGBtoHEX, RGBtoHSV, RequestDeduplicator, UrlAction, type UrlRule, UrlSecurityManager, alignTo, chunks, clamp, distributor as comparison, copyText, createLinksFromText, decWord, elasticClamp, formatNumber, generateUniqueKey, getChangedData, groupBy, isType, memoize, omit, orderBy, parseQueryString, parseTextTokens, parseVersionString, pick, random, randomByWeight, retry, shuffle, sleep, textParserUrl, timeAgo, toShort, unique, unlink, updateCurrent };
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";const e=(e,t)=>t[e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2];function t(e,t,r){if(!r){const e=new Date;r=e.getDate()*e.getFullYear()*(e.getHours()??1)*e.getMilliseconds()}const n=function(e){const t=2**32;let r=e;return function(){var e;return r=(1664525*r+1013904223)%t,e=r,e^=e>>>21,r=(e^=e<<35)^e>>>4,(r>>>0)/t}}(r);return function(e,t,r){if(t>r)throw new Error("Минимальная граница не может быть больше максимальной.");return Math.floor(e()*(r-t+1))+t}(n,e,t)}function r(e,t){var r=Object.prototype.toString.call(e).replace("[object ","").replace("]","").toLowerCase();try{"number"===r?isNaN(e)&&(r="nan"):e instanceof Buffer&&(r="buffer")}catch{}return void 0!==t?r===t:r}const n=(e,t)=>{switch(r(e)){case"array":if(!function(e,t,r){if(!s(e,t,"array",r))return!1;if(e.length!==t.length)return!1;for(var o=0;o<e.length;o++)if(!n(e[o],t[o]))return!1;return!0}(e,t,{skipCheckPrev:!0}))return!1;break;case"object":if(!function(e,t,r){if(!s(e,t,"object",r))return!1;const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(var a of o){if(!t.hasOwnProperty(a))return!1;if(!n(e[a],t[a]))return!1}return!0}(e,t,{skipCheckPrev:!0}))return!1;break;case"function":if(!function(e,t,r){return!!s(e,t,"function",r)&&e===t}(e,t,{skipCheckPrev:!0}))return!1;break;case"date":if(!function(e,t,r){return!!s(e,t,"date",r)&&e.getTime()===t.getTime()}(e,t,{skipCheckPrev:!0}))return!1;break;case"map":if(!function(e,t,r){if(!s(e,t,"map",r))return!1;if(e.size!==t.size)return!1;for(const[r,s]of e)if(!n(s,t.get(r)))return!1;return!0}(e,t,{skipCheckPrev:!0}))return!1;break;case"set":if(!function(e,t,r){if(!s(e,t,"set",r))return!1;if(e.size!==t.size)return!1;const o=Array.from(e.keys()),i=Array.from(t.keys());for(var a=0;a<o.length;a++)if(!n(o[a],i[a]))return!1;return!0}(e,t,{skipCheckPrev:!0}))return!1;break;default:if(e!==t)return!1}return!0};function s(e,t,n,s){return!(!s?.skipCheckPrev&&!r(e,n)||!r(t,n))}const o=e=>{switch(r(e)){case"array":return i(e);case"object":return a(e);case"number":return Number(String(e));case"string":return String(e);case"bigint":return BigInt(String(e));case"map":return new Map(e);case"set":return new Set(e);default:return e}},i=e=>{const t=[];for(const r of e)t.push(o(r));return t},a=e=>{const t={};for(const r in e)t[r]=o(e[r]);return t},c=new RegExp(/(?:https?:\/\/)?(?:www\.)?([А-Яа-яa-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*\.(?:ru|com|org|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!$&'()*+,;=-]*)?)(?:\s)/),h=e=>e;function l(e){return Array.from(new Set(e))}function f(e,t){switch(r(e)){case"object":return function(e,t){const r={},n=Object.keys(e),s=Object.keys(t),o=l([...n,...s]);for(const n of o)r[n]=f(e[n],t[n]);return r}(e,t);case"array":return function(e,t){const r=[];for(var n=0;n<e.length;n++)r.push(f(e?.[n],t?.[n]));for(n=e.length;n<t.length;n++)r.push(f(e?.[n],t?.[n]));return r}(e,t);default:return e??t}}function p(e,t){switch(r(e)){case"object":return function(e,t){const r={};var n=!1;for(const s in t)if(e.hasOwnProperty(s)){const o=p(e?.[s],t?.[s]);void 0!==o&&(r[s]=o,n=!0)}else r[s]=t[s],n=!0;for(const s in e)s in t||(r[s]=void 0,n=!0);return n?r:void 0}(e,t);case"array":return function(e,t){const r=[];for(var n=!1,s=0;s<e.length;s++){const o=p(e?.[s],t?.[s]);void 0===o&&void 0!==t?.[s]||(r[s]=o,n=!0)}for(s=0;s<t.length;s++){const o=p(e?.[s],t?.[s]);void 0!==o&&(r[s]=o,n=!0)}return n?r:void 0}(e,t);default:if(e!==t)return t}}function g(e,t){return t.split(".").reduce(((e,t)=>e?e[t]:void 0),e)}const d=e=>{const t=e.toString(16);return 1==t.length?"0"+t:t};var m=Object.defineProperty,b=(e,t,r)=>(((e,t,r)=>{t in e?m(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);var y=Object.defineProperty,k=(e,t,r)=>(((e,t,r)=>{t in e?y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);var v=Object.defineProperty,w=(e,t,r)=>(((e,t,r)=>{t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);var x=Object.defineProperty,j=(e,t,r)=>(((e,t,r)=>{t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),$=(e=>(e[e.ALLOW=1]="ALLOW",e[e.DENY=2]="DENY",e))($||{});exports.DataKeeper=class{constructor(e){w(this,"initValue"),w(this,"currentValue"),this.initValue=o(e),this.currentValue=e}setter(e){this.currentValue=e(this.currentValue)}reset(e){this.initValue=o(e),this.currentValue=e}isModified(){return!n(this.initValue,this.currentValue)}get updateValues(){return p(this.initValue,this.currentValue)}},exports.DebouncedFunction=class{constructor(e,t){k(this,"cb"),k(this,"o"),k(this,"tId",null),k(this,"s"),this.cb=e,this.o=t,this.s=[]}execute(...e){if(this.cancel(),"[object Function]"===Object.prototype.toString.call(e[0]))this.s=e[0](...this.s);else for(let t=0;t<this.cb.length;t++)this.s[t]=e[t];this.tId=setTimeout(this.executeImmediately.bind(this),this.o.delay)}executeImmediately(){this.cancel(),this.cb(...this.s),this.s=[]}cancel(){this.tId&&(clearTimeout(this.tId),this.tId=null)}},exports.EventEmitter=class{constructor(){b(this,"e",{})}on(e,t){return this.e[e]||(this.e[e]=[]),this.e[e].push(t),()=>this.off(e,t)}off(e,t){if(!this.e[e])return;const r=this.e[e].findIndex((e=>e===t));-1!==r&&(this.e[e].splice(r,1),0===this.e[e].length&&delete this.e[e])}emit(e,...t){if(!this.e[e])return;const r=this.e[e].slice();for(const n of r)try{n(...t)}catch(t){console.error(`Ошибка в обработчике события ${e}:`,t)}}once(e,t){const r=(...n)=>{this.off(e,r),t(...n)};return this.on(e,r)}clear(e){e?delete this.e[e]:this.e={}}},exports.HEXtoRGB=e=>{if(3===(e=e.replace("#","")).length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6!==e.length)return[0,0,0];const t=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),n=parseInt(e.substring(4,6),16);return isNaN(t)||isNaN(r)||isNaN(n)||t<0||t>255||r<0||r>255||n<0||n>255?[0,0,0]:[t,r,n]},exports.HSVtoRGB=(e,t,r)=>{var n,s,o,i,a,c,u,h;switch(c=r*(1-t),u=r*(1-(a=6*e-(i=Math.floor(6*e)))*t),h=r*(1-(1-a)*t),i%6){case 0:n=r,s=h,o=c;break;case 1:n=u,s=r,o=c;break;case 2:n=c,s=r,o=h;break;case 3:n=c,s=u,o=r;break;case 4:n=h,s=c,o=r;break;case 5:n=r,s=c,o=u}return[Math.round(255*n),Math.round(255*s),Math.round(255*o)]},exports.RGBtoHEX=(e,t,r)=>"#"+d(e)+d(t)+d(r),exports.RGBtoHSV=(e,t,r)=>{var n=Math.max(e,t,r),s=Math.min(e,t,r),o=n-s,i=0,a=0===n?0:o/n,c=n/255;switch(n){case s:i=0;break;case e:i=t-r+o*(t<r?6:0),i/=6*o;break;case t:i=r-e+2*o,i/=6*o;break;case r:i=e-t+4*o,i/=6*o}return[i,a,c]},exports.UrlAction=$,exports.UrlSecurityManager=class{constructor(e=[],t=!0){j(this,"rules"),j(this,"cache"),j(this,"cacheEnabled"),this.rules=[...e].sort(((e,t)=>(e.priority||50)-(t.priority||50))),this.cache=new Map,this.cacheEnabled=t,this.validateConfig()}isAllowed(e){try{const t="string"==typeof e?new URL(e):e;if(this.isObfuscatedUrl(t))return!1;const r=this.getCacheKey(t);if(this.cacheEnabled&&this.cache.has(r))return this.cache.get(r);const n=this.evaluateRules(t);return this.cacheEnabled&&this.cache.set(r,n),this.logAccess(t,n),n}catch(t){return console.error("Invalid URL:",e,t),!1}}evaluateRules(e){let t=null,r=null;for(const n of this.rules)this.ruleMatches(e,n)&&(null===t&&(t=1===n.action,r=n.id||null),console.debug(`Rule "${n.id}" matched for ${e.href}`));return null===t?(console.warn(`No rules matched for ${e.href}, defaulting to deny`),!1):(console.debug(`Final decision for ${e.href}: ${t} (rule: ${r})`),t)}ruleMatches(e,t){return this.checkHost(t,e)&&this.checkPaths(t,e)&&this.checkHash(t,e)&&this.checkParams(t,e)}checkHost(e,t){return e.hosts.some((e=>"string"==typeof e?"*"===e||t.host===e:e.test(t.host)))}checkPaths(e,t){return!e.paths||0===e.paths.length||e.paths.some((e=>"string"==typeof e?t.pathname===e||t.pathname.startsWith(e+"/"):e.test(t.pathname)))}checkHash(e,t){if(!e.hash||0===e.hash.length)return!0;const r=t.hash;return e.hash.some((e=>"string"==typeof e?r===e:e.test(r)))}checkParams(e,t){if(!e.allowedParams&&!e.ignoreParams)return!0;const r=new URL(t.toString());if(e.ignoreParams&&e.ignoreParams.forEach((e=>{r.searchParams.delete(e)})),e.allowedParams&&r.searchParams.size>0)for(const[t]of r.searchParams)if(!e.allowedParams.includes(t))return!1;return!0}isObfuscatedUrl(e){return[/@/,/\\/,/^\d+\.\d+\.\d+\.\d+$/,/\[.*\]/,/localhost/].some((t=>t.test(e.hostname)||t.test(e.href)))}getCacheKey(e){const t=new URL(e.toString());return t.searchParams.sort(),`${t.host}${t.pathname}${t.search}${t.hash}`}logAccess(e,t){console[t?"info":"warn"](`URL ${t?"allowed":"blocked"}: ${e.href}`)}validateConfig(){const e=[];this.rules.forEach(((t,r)=>{t.hosts&&Array.isArray(t.hosts)&&0!==t.hosts.length||e.push(`Rule ${r}: missing or invalid 'hosts' array`),void 0!==t.priority&&(t.priority<1||t.priority>100)&&e.push(`Rule ${r}: priority must be between 1 and 100`),t.action&&![1,2].includes(t.action)&&e.push(`Rule ${r}: action must be 'allow' or 'deny'`)})),e.length>0&&console.warn("URL security config validation errors:",e)}findMatchingRule(e){try{const t="string"==typeof e?new URL(e):e;for(const e of this.rules)if(this.ruleMatches(t,e))return e;return null}catch(e){return null}}clearCache(){this.cache.clear()}setCacheEnabled(e){this.cacheEnabled=e,e||this.clearCache()}getCacheSize(){return this.cache.size}},exports.alignTo=function(e,t){return e<=0?t:e+(t-e%t)%t},exports.chunks=(e,t)=>{const r=[];for(let n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return r},exports.clamp=(e,t,r)=>e>t?e<r?e:r:t,exports.comparison=n,exports.copyText=e=>{if(e){try{navigator.clipboard?.writeText(e)}catch{}try{var t=document.createElement("input");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}catch{}}},exports.createLinksFromText=(e,t)=>{const r=[],n=/{{([^}]+):([^}]+)}}/g;let s,o=0;for(;null!==(s=n.exec(e));)r.push(e.substring(o,s.index)),o=s.index+s[0].length,r.push({key:s[1],text:s[2]});return r.push(e.substring(o)),r.map((e=>"string"==typeof e?e:t(e.key,e.text)))},exports.decWord=e,exports.elasticClamp=(e,t,r,n={})=>{const{threshold:s=50,resistance:o=.2}=n;if(e<t){const r=t-e;return t-s*(1-Math.exp(-r*o/s))}if(e>r){const t=e-r;return r+s*(1-Math.exp(-t*o/s))}return e},exports.formatNumber=e=>(e||0).toString().replace(/\B(?=(\d{3})+(?!\d))/g,"."),exports.generateUniqueKey=e=>{const t=e=>{if("string"==typeof e||"number"==typeof e||"boolean"==typeof e||null===e)return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(t).join(",")+"]";if("object"==typeof e){const r=Object.keys(e).sort();let n="{";for(let s=0;s<r.length;s++){const o=r[s];n+=JSON.stringify(o)+":"+t(e[o]),s<r.length-1&&(n+=",")}return n+="}",n}return String(e)},r=e=>{let t=0;if(0===e.length)return t;for(let r=0;r<e.length;r++){t=(t<<5)-t+e.charCodeAt(r),t|=0}return t};try{const n=t(e);return r(n).toString(16)}catch(t){return console.warn(`Object could not be fully stringified. Using a simple string conversion. Error: ${t}`),r(String(e)).toString(16)}},exports.getChangedData=p,exports.groupBy=function(e,t){return e.reduce(((e,r)=>{const n=t(r);return e[n]||(e[n]=[]),e[n].push(r),e}),{})},exports.isType=r,exports.memoize=function(e){const t=new Map;return function(...r){const n=JSON.stringify(r);if(t.has(n))return t.get(n);const s=e(...r);return t.set(n,s),s}},exports.omit=function(e,t){return Object.keys(e).reduce(((r,n)=>(t.includes(n)||(r[n]=e[n]),r)),{})},exports.orderBy=function(e,t){const r=Object.keys(t);return e.slice().sort(((e,n)=>{for(const s of r){const r="desc"===t[s]?-1:1,o=g(e,s),i=g(n,s);if(o<i)return-r;if(o>i)return r}return 0}))},exports.parseQueryString=function(e){const t={},r=(e.startsWith("?")?e.slice(1):e).split("&");for(const e of r){const[r,n]=e.split("=");if(r){const e=decodeURIComponent(r),s=n?decodeURIComponent(n):"";t[e]=s}}return t},exports.parseVersionString=function(e){const t=e.match(/^(\d+|\*)\.(\d+|\*)\.(\d+|\*)(?:-([a-zA-Z0-9-.]+))?$/);if(!t)throw new Error("Invalid version string");const[,r,n,s,o]=t,i=e=>"*"===e?"*":parseInt(e,10);return{major:i(r),minor:i(n),patch:i(s),prerelease:o||null}},exports.pick=function(e,t){return Object.keys(e).reduce(((r,n)=>(t.includes(n)&&(r[n]=e[n]),r)),{})},exports.random=t,exports.randomByWeight=function(e,r){let n=0;for(const t in e)n+=e[t];const s=t(0,n,r);let o=0;for(const t in e)if(o+=e[t],s<o)return t;const i=Object.keys(e);return i[t(0,i.length-1,r)]},exports.retry=function(e,t,r){return new Promise(((n,s)=>{const o=t=>{e().then(n).catch((e=>{0===t?s(e):(console.log(`Retrying... attempts left: ${t}`),setTimeout((()=>o(t-1)),r))}))};o(t)}))},exports.shuffle=(e,r)=>{for(let n=e.length-1;n>0;n--){const s=t(0,n,r);[e[n],e[s]]=[e[s],e[n]]}return e},exports.sleep=async e=>await new Promise((t=>setTimeout(t,e))),exports.textParserUrl=(e,t)=>{const r=t?.onToken??h,n=t?.requireProtocol??!1,s=t?.regex??n?u:c,o=[];let i=e+" ",a=s.exec(i);for(;a;){const e=a[0].trim(),t=a.index;t>0&&(o.push(r({type:"raw",value:i.substring(0,t)})),i=i.substring(t)),o.push(r({type:"url",value:e})),i=i.substring(e.length),a=s.exec(i)}return i.length>0&&o.push(r({type:"raw",value:i})),o},exports.timeAgo=t=>{if(!t)return"только что";const r=new Date(t),n=Math.floor((Date.now()-r.getTime())/1e3),s=()=>new Intl.DateTimeFormat("RU-ru",{day:"numeric",month:"short"}).format(r).replace(".",""),o=()=>r.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),i=(t,r,n)=>Array.isArray(t)?`${n} ${e(n,t)} ${r}`:`${t} ${r}`;switch(!0){case n<0:return"скоро";case n<60:return i(["секунду","секунды","секунд"],"назад",n);case n<3600:return i(["минуту","минуты","минут"],"назад",Math.floor(n/60));case n<7200:return i("час","назад",Math.floor(n/3600));case n<10800:return i("два часа","назад",Math.floor(n/3600));case n<14400:return i("три часа","назад",Math.floor(n/3600));case n<86400:return i(`сегодня в ${o()}`,"",Math.floor(n/3600));case n<172800:return i(`вчера в ${o()}`,"",Math.floor(n/86400));case n<259200:return i("два дня","назад",Math.floor(n/86400));case n<345600:return i("три дня","назад",Math.floor(n/86400));case n<31536e3:return i(`${s()} в ${o()}`,"",Math.floor(n/86400));case n>=31536e3:return i(`${s()} ${r.getFullYear()} г.`,"",Math.floor(n/31536e3))}return"только что"},exports.toShort=(e,t,r=1)=>{const n=t||["","k","M","G","T","P"],s=e<0,o=Math.abs(e),i=Math.log10(o)/3|0,a=o/10**(3*i);return parseFloat(`${s?"-":""}${a%1?(Math.floor(10*a)/10).toFixed(r):a}`)+n[i]},exports.unique=l,exports.unlink=o,exports.updateCurrent=f;
1
+ "use strict";var u=require("@minsize/mutex");const D=(u,D)=>D[u%10==1&&u%100!=11?0:u%10>=2&&u%10<=4&&(u%100<10||u%100>=20)?1:2];function F(u,D,F){if(!F){const u=new Date;F=u.getDate()*u.getFullYear()*(u.getHours()??1)*u.getMilliseconds()}const e=function(u){const D=2**32;let F=u;return function(){var u;return F=(1664525*F+1013904223)%D,u=F,u^=u>>>21,F=(u^=u<<35)^u>>>4,(F>>>0)/D}}(F);return function(u,D,F){if(D>F)throw new Error("Минимальная граница не может быть больше максимальной.");return Math.floor(u()*(F-D+1))+D}(e,u,D)}function e(u,D){var F=Object.prototype.toString.call(u).replace("[object ","").replace("]","").toLowerCase();try{"number"===F?isNaN(u)&&(F="nan"):u instanceof Buffer&&(F="buffer")}catch{}return void 0!==D?F===D:F}const t=(u,D)=>{switch(e(u)){case"array":if(!function(u,D,F){if(!r(u,D,"array",F))return!1;if(u.length!==D.length)return!1;for(var e=0;e<u.length;e++)if(!t(u[e],D[e]))return!1;return!0}(u,D,{skipCheckPrev:!0}))return!1;break;case"object":if(!function(u,D,F){if(!r(u,D,"object",F))return!1;const e=Object.keys(u),s=Object.keys(D);if(e.length!==s.length)return!1;for(var n of e){if(!D.hasOwnProperty(n))return!1;if(!t(u[n],D[n]))return!1}return!0}(u,D,{skipCheckPrev:!0}))return!1;break;case"function":if(!function(u,D,F){return!!r(u,D,"function",F)&&u===D}(u,D,{skipCheckPrev:!0}))return!1;break;case"date":if(!function(u,D,F){return!!r(u,D,"date",F)&&u.getTime()===D.getTime()}(u,D,{skipCheckPrev:!0}))return!1;break;case"map":if(!function(u,D,F){if(!r(u,D,"map",F))return!1;if(u.size!==D.size)return!1;for(const[F,e]of u)if(!t(e,D.get(F)))return!1;return!0}(u,D,{skipCheckPrev:!0}))return!1;break;case"set":if(!function(u,D,F){if(!r(u,D,"set",F))return!1;if(u.size!==D.size)return!1;const e=Array.from(u.keys()),s=Array.from(D.keys());for(var n=0;n<e.length;n++)if(!t(e[n],s[n]))return!1;return!0}(u,D,{skipCheckPrev:!0}))return!1;break;default:if(u!==D)return!1}return!0};function r(u,D,F,t){return!(!t?.skipCheckPrev&&!e(u,F)||!e(D,F))}const s=u=>{switch(e(u)){case"array":return n(u);case"object":return C(u);case"number":return Number(String(u));case"string":return String(u);case"bigint":return BigInt(String(u));case"map":return new Map(u);case"set":return new Set(u);default:return u}},n=u=>{const D=[];for(const F of u)D.push(s(F));return D},C=u=>{const D={};for(const F in u)D[F]=s(u[F]);return D},o=new RegExp(/(?:https?:\/\/)?(?:www\.)?([А-Яа-яa-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*\.(?:ru|com|org|net|me|su|рф|biz|info|co|uk|de|fr|jp|cn|es|it|ca|au|nl|se|no|dk|fi|pl|at|ch|be|cz|ie|pt|ro|hu|gr|sk|bg|hr|si|lt|lv|ee|is|mt|lu|li|mc|sm|va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!$&'()*+,;=-]*)?)(?=\s|$)/g),l=/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]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DED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g,h=u=>u;function B(u){return Array.from(new Set(u))}function f(u,D){switch(e(u)){case"object":return function(u,D){const F={},e=Object.keys(u),t=Object.keys(D),r=B([...e,...t]);for(const e of r)F[e]=f(u[e],D[e]);return F}(u,D);case"array":return function(u,D){const F=[];for(var e=0;e<u.length;e++)F.push(f(u?.[e],D?.[e]));for(e=u.length;e<D.length;e++)F.push(f(u?.[e],D?.[e]));return F}(u,D);default:return u??D}}function p(u,D){switch(e(u)){case"object":return function(u,D){const F={};var e=!1;for(const t in D)if(u.hasOwnProperty(t)){const r=p(u?.[t],D?.[t]);void 0!==r&&(F[t]=r,e=!0)}else F[t]=D[t],e=!0;for(const t in u)t in D||(F[t]=void 0,e=!0);return e?F:void 0}(u,D);case"array":return function(u,D){const F=[];for(var e=!1,t=0;t<u.length;t++){const r=p(u?.[t],D?.[t]);void 0===r&&void 0!==D?.[t]||(F[t]=r,e=!0)}for(t=0;t<D.length;t++){const r=p(u?.[t],D?.[t]);void 0!==r&&(F[t]=r,e=!0)}return e?F:void 0}(u,D);default:if(u!==D)return D}}function g(u,D){return D.split(".").reduce(((u,D)=>u?u[D]:void 0),u)}const m=u=>{const D=u.toString(16);return 1==D.length?"0"+D:D};var A=Object.defineProperty,d=(u,D,F)=>(((u,D,F)=>{D in u?A(u,D,{enumerable:!0,configurable:!0,writable:!0,value:F}):u[D]=F})(u,"symbol"!=typeof D?D+"":D,F),F);class b{constructor(){d(this,"e",{})}on(u,D){return this.e[u]||(this.e[u]=[]),this.e[u].push(D),()=>this.off(u,D)}off(u,D){if(!this.e[u])return;const F=this.e[u].findIndex((u=>u===D));-1!==F&&(this.e[u].splice(F,1),0===this.e[u].length&&delete this.e[u])}emit(u,...D){if(!this.e[u])return;const F=this.e[u].slice();for(const e of F)try{e(...D)}catch(D){console.error(`Ошибка в обработчике события ${u}:`,D)}}once(u,D){const F=(...e)=>{this.off(u,F),D(...e)};return this.on(u,F)}clear(u){u?delete this.e[u]:this.e={}}}var y=Object.defineProperty,k=(u,D,F)=>(((u,D,F)=>{D in u?y(u,D,{enumerable:!0,configurable:!0,writable:!0,value:F}):u[D]=F})(u,"symbol"!=typeof D?D+"":D,F),F);var v=Object.defineProperty,w=(u,D,F)=>(((u,D,F)=>{D in u?v(u,D,{enumerable:!0,configurable:!0,writable:!0,value:F}):u[D]=F})(u,"symbol"!=typeof D?D+"":D,F),F);var x=Object.defineProperty,j=(u,D,F)=>(((u,D,F)=>{D in u?x(u,D,{enumerable:!0,configurable:!0,writable:!0,value:F}):u[D]=F})(u,"symbol"!=typeof D?D+"":D,F),F);var z=Object.defineProperty,$=(u,D,F)=>(((u,D,F)=>{D in u?z(u,D,{enumerable:!0,configurable:!0,writable:!0,value:F}):u[D]=F})(u,"symbol"!=typeof D?D+"":D,F),F),P=(u=>(u[u.ALLOW=1]="ALLOW",u[u.DENY=2]="DENY",u))(P||{});exports.DataKeeper=class{constructor(u){w(this,"initValue"),w(this,"currentValue"),this.initValue=s(u),this.currentValue=u}setter(u){this.currentValue=u(this.currentValue)}reset(u){this.initValue=s(u),this.currentValue=u}isModified(){return!t(this.initValue,this.currentValue)}get updateValues(){return p(this.initValue,this.currentValue)}},exports.DebouncedFunction=class{constructor(u,D){k(this,"cb"),k(this,"o"),k(this,"tId",null),k(this,"s"),this.cb=u,this.o=D,this.s=[]}execute(...u){if(this.cancel(),"[object Function]"===Object.prototype.toString.call(u[0]))this.s=u[0](...this.s);else for(let D=0;D<this.cb.length;D++)this.s[D]=u[D];this.tId=setTimeout(this.executeImmediately.bind(this),this.o.delay)}executeImmediately(){this.cancel(),this.cb(...this.s),this.s=[]}cancel(){this.tId&&(clearTimeout(this.tId),this.tId=null)}},exports.EventEmitter=b,exports.HEXtoRGB=u=>{if(3===(u=u.replace("#","")).length&&(u=u[0]+u[0]+u[1]+u[1]+u[2]+u[2]),6!==u.length)return[0,0,0];const D=parseInt(u.substring(0,2),16),F=parseInt(u.substring(2,4),16),e=parseInt(u.substring(4,6),16);return isNaN(D)||isNaN(F)||isNaN(e)||D<0||D>255||F<0||F>255||e<0||e>255?[0,0,0]:[D,F,e]},exports.HSVtoRGB=(u,D,F)=>{var e,t,r,s,n,C,o,E;switch(C=F*(1-D),o=F*(1-(n=6*u-(s=Math.floor(6*u)))*D),E=F*(1-(1-n)*D),s%6){case 0:e=F,t=E,r=C;break;case 1:e=o,t=F,r=C;break;case 2:e=C,t=F,r=E;break;case 3:e=C,t=o,r=F;break;case 4:e=E,t=C,r=F;break;case 5:e=F,t=C,r=o}return[Math.round(255*e),Math.round(255*t),Math.round(255*r)]},exports.RGBtoHEX=(u,D,F)=>"#"+m(u)+m(D)+m(F),exports.RGBtoHSV=(u,D,F)=>{var e=Math.max(u,D,F),t=Math.min(u,D,F),r=e-t,s=0,n=0===e?0:r/e,C=e/255;switch(e){case t:s=0;break;case u:s=D-F+r*(D<F?6:0),s/=6*r;break;case D:s=F-u+2*r,s/=6*r;break;case F:s=u-D+4*r,s/=6*r}return[s,n,C]},exports.RequestDeduplicator=class{constructor(){j(this,"requests",new Set),j(this,"emitter",new b),j(this,"mutex",u.Mutex({globalLimit:999999}))}async fetch(u,D){const F=await this.mutex.wait({key:u,limit:1});return this.requests.has(u)?(F(),new Promise(((D,F)=>{this.emitter.once(u,(u=>{u.error?F(u.error):D(u.result)}))}))):(this.requests.add(u),F(),new Promise(((F,e)=>{D().then((D=>{F(D),this.emitter.emit(u,{result:D}),this.requests.delete(u)})).catch((D=>{e(D),this.emitter.emit(u,{error:D}),this.requests.delete(u)}))})))}},exports.UrlAction=P,exports.UrlSecurityManager=class{constructor(u=[],D=!0){$(this,"rules"),$(this,"cache"),$(this,"cacheEnabled"),this.rules=[...u].sort(((u,D)=>(u.priority||50)-(D.priority||50))),this.cache=new Map,this.cacheEnabled=D,this.validateConfig()}isAllowed(u){try{const D="string"==typeof u?new URL(u):u;if(this.isObfuscatedUrl(D))return!1;const F=this.getCacheKey(D);if(this.cacheEnabled&&this.cache.has(F))return this.cache.get(F);const e=this.evaluateRules(D);return this.cacheEnabled&&this.cache.set(F,e),this.logAccess(D,e),e}catch(D){return console.error("Invalid URL:",u,D),!1}}evaluateRules(u){let D=null,F=null;for(const e of this.rules)this.ruleMatches(u,e)&&(null===D&&(D=1===e.action,F=e.id||null),console.debug(`Rule "${e.id}" matched for ${u.href}`));return null===D?(console.warn(`No rules matched for ${u.href}, defaulting to deny`),!1):(console.debug(`Final decision for ${u.href}: ${D} (rule: ${F})`),D)}ruleMatches(u,D){return this.checkHost(D,u)&&this.checkPaths(D,u)&&this.checkHash(D,u)&&this.checkParams(D,u)}checkHost(u,D){return u.hosts.some((u=>"string"==typeof u?"*"===u||D.host===u:u.test(D.host)))}checkPaths(u,D){return!u.paths||0===u.paths.length||u.paths.some((u=>"string"==typeof u?D.pathname===u||D.pathname.startsWith(u+"/"):u.test(D.pathname)))}checkHash(u,D){if(!u.hash||0===u.hash.length)return!0;const F=D.hash;return u.hash.some((u=>"string"==typeof u?F===u:u.test(F)))}checkParams(u,D){if(!u.allowedParams&&!u.ignoreParams)return!0;const F=new URL(D.toString());if(u.ignoreParams&&u.ignoreParams.forEach((u=>{F.searchParams.delete(u)})),u.allowedParams&&F.searchParams.size>0)for(const[D]of F.searchParams)if(!u.allowedParams.includes(D))return!1;return!0}isObfuscatedUrl(u){return[/@/,/\\/,/^\d+\.\d+\.\d+\.\d+$/,/\[.*\]/,/localhost/].some((D=>D.test(u.hostname)||D.test(u.href)))}getCacheKey(u){const D=new URL(u.toString());return D.searchParams.sort(),`${D.host}${D.pathname}${D.search}${D.hash}`}logAccess(u,D){console[D?"info":"warn"](`URL ${D?"allowed":"blocked"}: ${u.href}`)}validateConfig(){const u=[];this.rules.forEach(((D,F)=>{D.hosts&&Array.isArray(D.hosts)&&0!==D.hosts.length||u.push(`Rule ${F}: missing or invalid 'hosts' array`),void 0!==D.priority&&(D.priority<1||D.priority>100)&&u.push(`Rule ${F}: priority must be between 1 and 100`),D.action&&![1,2].includes(D.action)&&u.push(`Rule ${F}: action must be 'allow' or 'deny'`)})),u.length>0&&console.warn("URL security config validation errors:",u)}findMatchingRule(u){try{const D="string"==typeof u?new URL(u):u;for(const u of this.rules)if(this.ruleMatches(D,u))return u;return null}catch(u){return null}}clearCache(){this.cache.clear()}setCacheEnabled(u){this.cacheEnabled=u,u||this.clearCache()}getCacheSize(){return this.cache.size}},exports.alignTo=function(u,D){return u<=0?D:u+(D-u%D)%D},exports.chunks=(u,D)=>{const F=[];for(let e=0;e<D.length;e+=u)F.push(D.slice(e,e+u));return F},exports.clamp=(u,D,F)=>u>D?u<F?u:F:D,exports.comparison=t,exports.copyText=u=>{if(u){try{navigator.clipboard?.writeText(u)}catch{}try{var D=document.createElement("input");D.value=u,document.body.appendChild(D),D.select(),document.execCommand("copy"),document.body.removeChild(D)}catch{}}},exports.createLinksFromText=(u,D)=>{const F=[],e=/{{([^}]+):([^}]+)}}/g;let t,r=0;for(;null!==(t=e.exec(u));)F.push(u.substring(r,t.index)),r=t.index+t[0].length,F.push({key:t[1],text:t[2]});return F.push(u.substring(r)),F.map((u=>"string"==typeof u?u:D(u.key,u.text)))},exports.decWord=D,exports.elasticClamp=(u,D,F,e={})=>{const{threshold:t=50,resistance:r=.2}=e;if(u<D){const F=D-u;return D-t*(1-Math.exp(-F*r/t))}if(u>F){const D=u-F;return F+t*(1-Math.exp(-D*r/t))}return u},exports.formatNumber=u=>(u||0).toString().replace(/\B(?=(\d{3})+(?!\d))/g,"."),exports.generateUniqueKey=u=>{const D=u=>{if("string"==typeof u||"number"==typeof u||"boolean"==typeof u||null===u)return JSON.stringify(u);if(Array.isArray(u))return"["+u.map(D).join(",")+"]";if("object"==typeof u){const F=Object.keys(u).sort();let e="{";for(let t=0;t<F.length;t++){const r=F[t];e+=JSON.stringify(r)+":"+D(u[r]),t<F.length-1&&(e+=",")}return e+="}",e}return String(u)},F=u=>{let D=0;if(0===u.length)return D;for(let F=0;F<u.length;F++){D=(D<<5)-D+u.charCodeAt(F),D|=0}return D};try{const e=D(u);return F(e).toString(16)}catch(D){return console.warn(`Object could not be fully stringified. Using a simple string conversion. Error: ${D}`),F(String(u)).toString(16)}},exports.getChangedData=p,exports.groupBy=function(u,D){return u.reduce(((u,F)=>{const e=D(F);return u[e]||(u[e]=[]),u[e].push(F),u}),{})},exports.isType=e,exports.memoize=function(u){const D=new Map;return function(...F){const e=JSON.stringify(F);if(D.has(e))return D.get(e);const t=u(...F);return D.set(e,t),t}},exports.omit=function(u,D){return Object.keys(u).reduce(((F,e)=>(D.includes(e)||(F[e]=u[e]),F)),{})},exports.orderBy=function(u,D){const F=Object.keys(D);return u.slice().sort(((u,e)=>{for(const t of F){const F="desc"===D[t]?-1:1,r=g(u,t),s=g(e,t);if(r<s)return-F;if(r>s)return F}return 0}))},exports.parseQueryString=function(u){const D={},F=(u.startsWith("?")?u.slice(1):u).split("&");for(const u of F){const[F,e]=u.split("=");if(F){const u=decodeURIComponent(F),t=e?decodeURIComponent(e):"";D[u]=t}}return D},exports.parseTextTokens=(u,D)=>{const{onToken:F=h,requireProtocol:e=!1,regex:t}=D||{},r=[];if(!u)return r;let s=u;const n=u=>{if(!u)return;const D=[...u.matchAll(l)];if(0===D.length)return void r.push(F({type:"raw",value:u}));let e=0;for(const t of D){const D=t[0],s=t.index;if(s>e){const D=u.substring(e,s);r.push(F({type:"raw",value:D}))}r.push(F({type:"emoji",value:D})),e=s+D.length}if(e<u.length){const D=u.substring(e);r.push(F({type:"raw",value:D}))}};let C,o=0;const E=new RegExp((t||(e?c:a)).source,"g");for(;null!==(C=E.exec(s));){const u=C[0],D=C.index;if(D>o){n(s.substring(o,D))}r.push(F({type:"url",value:u})),o=D+u.length}if(o<s.length){n(s.substring(o))}return r},exports.parseVersionString=function(u){const D=u.match(/^(\d+|\*)\.(\d+|\*)\.(\d+|\*)(?:-([a-zA-Z0-9-.]+))?$/);if(!D)throw new Error("Invalid version string");const[,F,e,t,r]=D,s=u=>"*"===u?"*":parseInt(u,10);return{major:s(F),minor:s(e),patch:s(t),prerelease:r||null}},exports.pick=function(u,D){return Object.keys(u).reduce(((F,e)=>(D.includes(e)&&(F[e]=u[e]),F)),{})},exports.random=F,exports.randomByWeight=function(u,D){let e=0;for(const D in u)e+=u[D];const t=F(0,e,D);let r=0;for(const D in u)if(r+=u[D],t<r)return D;const s=Object.keys(u);return s[F(0,s.length-1,D)]},exports.retry=function(u,D,F){return new Promise(((e,t)=>{const r=D=>{u().then(e).catch((u=>{0===D?t(u):(console.log(`Retrying... attempts left: ${D}`),setTimeout((()=>r(D-1)),F))}))};r(D)}))},exports.shuffle=(u,D)=>{for(let e=u.length-1;e>0;e--){const t=F(0,e,D);[u[e],u[t]]=[u[t],u[e]]}return u},exports.sleep=async u=>await new Promise((D=>setTimeout(D,u))),exports.textParserUrl=(u,D)=>{const F=D?.onToken??i,e=D?.requireProtocol??!1,t=D?.regex??e?E:o,r=[];let s=u+" ",n=t.exec(s);for(;n;){const u=n[0].trim(),D=n.index;D>0&&(r.push(F({type:"raw",value:s.substring(0,D)})),s=s.substring(D)),r.push(F({type:"url",value:u})),s=s.substring(u.length),n=t.exec(s)}return s.length>0&&r.push(F({type:"raw",value:s})),r},exports.timeAgo=u=>{if(!u)return"только что";const F=new Date(u),e=Math.floor((Date.now()-F.getTime())/1e3),t=()=>new Intl.DateTimeFormat("RU-ru",{day:"numeric",month:"short"}).format(F).replace(".",""),r=()=>F.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),s=(u,F,e)=>Array.isArray(u)?`${e} ${D(e,u)} ${F}`:`${u} ${F}`;switch(!0){case e<0:return"скоро";case e<60:return s(["секунду","секунды","секунд"],"назад",e);case e<3600:return s(["минуту","минуты","минут"],"назад",Math.floor(e/60));case e<7200:return s("час","назад",Math.floor(e/3600));case e<10800:return s("два часа","назад",Math.floor(e/3600));case e<14400:return s("три часа","назад",Math.floor(e/3600));case e<86400:return s(`сегодня в ${r()}`,"",Math.floor(e/3600));case e<172800:return s(`вчера в ${r()}`,"",Math.floor(e/86400));case e<259200:return s("два дня","назад",Math.floor(e/86400));case e<345600:return s("три дня","назад",Math.floor(e/86400));case e<31536e3:return s(`${t()} в ${r()}`,"",Math.floor(e/86400));case e>=31536e3:return s(`${t()} ${F.getFullYear()} г.`,"",Math.floor(e/31536e3))}return"только что"},exports.toShort=(u,D,F=1)=>{const e=D||["","k","M","G","T","P"],t=u<0,r=Math.abs(u),s=Math.log10(r)/3|0,n=r/10**(3*s);return parseFloat(`${t?"-":""}${n%1?(Math.floor(10*n)/10).toFixed(F):n}`)+e[s]},exports.unique=B,exports.unlink=s,exports.updateCurrent=f;
package/index.mjs CHANGED
@@ -1 +1 @@
1
- const e=(e,t,r)=>e>t?e<r?e:r:t,t=(e,t)=>t[e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2];function r(e,t){return e<=0?t:e+(t-e%t)%t}const n=(e,t,r=1)=>{const n=t||["","k","M","G","T","P"],s=e<0,o=Math.abs(e),i=Math.log10(o)/3|0,a=o/10**(3*i);return parseFloat(`${s?"-":""}${a%1?(Math.floor(10*a)/10).toFixed(r):a}`)+n[i]},s=e=>{if(!e)return"только что";const r=new Date(e),n=Math.floor((Date.now()-r.getTime())/1e3),s=()=>new Intl.DateTimeFormat("RU-ru",{day:"numeric",month:"short"}).format(r).replace(".",""),o=()=>r.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),i=(e,r,n)=>Array.isArray(e)?`${n} ${t(n,e)} ${r}`:`${e} ${r}`;switch(!0){case n<0:return"скоро";case n<60:return i(["секунду","секунды","секунд"],"назад",n);case n<3600:return i(["минуту","минуты","минут"],"назад",Math.floor(n/60));case n<7200:return i("час","назад",Math.floor(n/3600));case n<10800:return i("два часа","назад",Math.floor(n/3600));case n<14400:return i("три часа","назад",Math.floor(n/3600));case n<86400:return i(`сегодня в ${o()}`,"",Math.floor(n/3600));case n<172800:return i(`вчера в ${o()}`,"",Math.floor(n/86400));case n<259200:return i("два дня","назад",Math.floor(n/86400));case n<345600:return i("три дня","назад",Math.floor(n/86400));case n<31536e3:return i(`${s()} в ${o()}`,"",Math.floor(n/86400));case n>=31536e3:return i(`${s()} ${r.getFullYear()} г.`,"",Math.floor(n/31536e3))}return"только что"},o=e=>(e||0).toString().replace(/\B(?=(\d{3})+(?!\d))/g,".");function i(e,t,r){if(!r){const e=new Date;r=e.getDate()*e.getFullYear()*(e.getHours()??1)*e.getMilliseconds()}const n=function(e){const t=2**32;let r=e;return function(){var e;return r=(1664525*r+1013904223)%t,e=r,e^=e>>>21,r=(e^=e<<35)^e>>>4,(r>>>0)/t}}(r);return function(e,t,r){if(t>r)throw new Error("Минимальная граница не может быть больше максимальной.");return Math.floor(e()*(r-t+1))+t}(n,e,t)}function a(e,t){let r=0;for(const t in e)r+=e[t];const n=i(0,r,t);let s=0;for(const t in e)if(s+=e[t],n<s)return t;const o=Object.keys(e);return o[i(0,o.length-1,t)]}function c(e,t){var r=Object.prototype.toString.call(e).replace("[object ","").replace("]","").toLowerCase();try{"number"===r?isNaN(e)&&(r="nan"):e instanceof Buffer&&(r="buffer")}catch{}return void 0!==t?r===t:r}function u(e,t){return Object.keys(e).reduce(((r,n)=>(t.includes(n)||(r[n]=e[n]),r)),{})}function h(e,t){return Object.keys(e).reduce(((r,n)=>(t.includes(n)&&(r[n]=e[n]),r)),{})}const l=async e=>await new Promise((t=>setTimeout(t,e))),f=e=>{if(e){try{navigator.clipboard?.writeText(e)}catch{}try{var t=document.createElement("input");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}catch{}}},g=(e,t)=>{const r=[],n=/{{([^}]+):([^}]+)}}/g;let s,o=0;for(;null!==(s=n.exec(e));)r.push(e.substring(o,s.index)),o=s.index+s[0].length,r.push({key:s[1],text:s[2]});return r.push(e.substring(o)),r.map((e=>"string"==typeof e?e:t(e.key,e.text)))},d=(e,t)=>{switch(c(e)){case"array":if(!function(e,t,r){if(!p(e,t,"array",r))return!1;if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!d(e[n],t[n]))return!1;return!0}(e,t,{skipCheckPrev:!0}))return!1;break;case"object":if(!function(e,t,r){if(!p(e,t,"object",r))return!1;const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(var o of n){if(!t.hasOwnProperty(o))return!1;if(!d(e[o],t[o]))return!1}return!0}(e,t,{skipCheckPrev:!0}))return!1;break;case"function":if(!function(e,t,r){return!!p(e,t,"function",r)&&e===t}(e,t,{skipCheckPrev:!0}))return!1;break;case"date":if(!function(e,t,r){return!!p(e,t,"date",r)&&e.getTime()===t.getTime()}(e,t,{skipCheckPrev:!0}))return!1;break;case"map":if(!function(e,t,r){if(!p(e,t,"map",r))return!1;if(e.size!==t.size)return!1;for(const[r,n]of e)if(!d(n,t.get(r)))return!1;return!0}(e,t,{skipCheckPrev:!0}))return!1;break;case"set":if(!function(e,t,r){if(!p(e,t,"set",r))return!1;if(e.size!==t.size)return!1;const n=Array.from(e.keys()),s=Array.from(t.keys());for(var o=0;o<n.length;o++)if(!d(n[o],s[o]))return!1;return!0}(e,t,{skipCheckPrev:!0}))return!1;break;default:if(e!==t)return!1}return!0};function p(e,t,r,n){return!(!n?.skipCheckPrev&&!c(e,r)||!c(t,r))}const m=e=>{const t=e=>{if("string"==typeof e||"number"==typeof e||"boolean"==typeof e||null===e)return JSON.stringify(e);if(Array.isArray(e))return"["+e.map(t).join(",")+"]";if("object"==typeof e){const r=Object.keys(e).sort();let n="{";for(let s=0;s<r.length;s++){const o=r[s];n+=JSON.stringify(o)+":"+t(e[o]),s<r.length-1&&(n+=",")}return n+="}",n}return String(e)},r=e=>{let t=0;if(0===e.length)return t;for(let r=0;r<e.length;r++){t=(t<<5)-t+e.charCodeAt(r),t|=0}return t};try{const n=t(e);return r(n).toString(16)}catch(t){return console.warn(`Object could not be fully stringified. Using a simple string conversion. Error: ${t}`),r(String(e)).toString(16)}},b=e=>{switch(c(e)){case"array":return y(e);case"object":return k(e);case"number":return Number(String(e));case"string":return String(e);case"bigint":return BigInt(String(e));case"map":return new Map(e);case"set":return new Set(e);default:return e}},y=e=>{const t=[];for(const r of e)t.push(b(r));return t},k=e=>{const t={};for(const r in e)t[r]=b(e[r]);return t},v=new RegExp(/(?:https?:\/\/)?(?:www\.)?([А-Яа-яa-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*\.(?:ru|com|org|net|me|su|рф|biz|info|co|uk|de|fr|jp|cn|es|it|ca|au|nl|se|no|dk|fi|pl|at|ch|be|cz|ie|pt|ro|hu|gr|sk|bg|hr|si|lt|lv|ee|is|mt|lu|li|mc|sm|va|ad|al|ba|mk|me|rs|tr|ua|by|kz|uz|am|ge|az|tm|kg|tj|md|kg|tj|af|dz|bh|eg|iq|ir|jo|kw|lb|ly|ma|om|ps|qa|sa|sd|sy|tn|ae|ye|ar|bo|br|cl|co|ec|gf|gy|pe|py|sr|uy|ve|ag|ai|aw|bb|bm|bs|bz|ca|cr|cu|dm|do|gd|gp|gt|hn|ht|jm|kn|ky|lc|ms|mx|ni|pa|pr|sv|tc|tt|vc|vg|vi|an|aq|as|fj|fm|gu|hm|id|ki|mh|mp|nc|nf|nr|nu|pf|pg|pw|sb|tk|to|tv|vu|wf|ws)(?:\/[a-zA-Z0-9._~:\/?#[\]@!$&'()*+,;=-]*)?)(?:\s)/),w=new RegExp(/(?:https?:\/\/)(?:www\.)?([А-Яа-яa-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*\.(?:ru|com|org|net|me|su|рф|biz|info|co|uk|de|fr|jp|cn|es|it|ca|au|nl|se|no|dk|fi|pl|at|ch|be|cz|ie|pt|ro|hu|gr|sk|bg|hr|si|lt|lv|ee|is|mt|lu|li|mc|sm|va|ad|al|ba|mk|me|rs|tr|ua|by|kz|uz|am|ge|az|tm|kg|tj|md|kg|tj|af|dz|bh|eg|iq|ir|jo|kw|lb|ly|ma|om|ps|qa|sa|sd|sy|tn|ae|ye|ar|bo|br|cl|co|ec|gf|gy|pe|py|sr|uy|ve|ag|ai|aw|bb|bm|bs|bz|ca|cr|cu|dm|do|gd|gp|gt|hn|ht|jm|kn|ky|lc|ms|mx|ni|pa|pr|sv|tc|tt|vc|vg|vi|an|aq|as|fj|fm|gu|hm|id|ki|mh|mp|nc|nf|nr|nu|pf|pg|pw|sb|tk|to|tv|vu|wf|ws)(?:\/[a-zA-Z0-9._~:\/?#[\]@!$&'()*+,;=-]*)?)(?:\s)/),j=e=>e,$=(e,t)=>{const r=t?.onToken??j,n=t?.requireProtocol??!1,s=t?.regex??n?w:v,o=[];let i=e+" ",a=s.exec(i);for(;a;){const e=a[0].trim(),t=a.index;t>0&&(o.push(r({type:"raw",value:i.substring(0,t)})),i=i.substring(t)),o.push(r({type:"url",value:e})),i=i.substring(e.length),a=s.exec(i)}return i.length>0&&o.push(r({type:"raw",value:i})),o};function M(e){const t=new Map;return function(...r){const n=JSON.stringify(r);if(t.has(n))return t.get(n);const s=e(...r);return t.set(n,s),s}}function P(e,t,r){return new Promise(((n,s)=>{const o=t=>{e().then(n).catch((e=>{0===t?s(e):(console.log(`Retrying... attempts left: ${t}`),setTimeout((()=>o(t-1)),r))}))};o(t)}))}function z(e){const t={},r=(e.startsWith("?")?e.slice(1):e).split("&");for(const e of r){const[r,n]=e.split("=");if(r){const e=decodeURIComponent(r),s=n?decodeURIComponent(n):"";t[e]=s}}return t}function O(e){const t=e.match(/^(\d+|\*)\.(\d+|\*)\.(\d+|\*)(?:-([a-zA-Z0-9-.]+))?$/);if(!t)throw new Error("Invalid version string");const[,r,n,s,o]=t,i=e=>"*"===e?"*":parseInt(e,10);return{major:i(r),minor:i(n),patch:i(s),prerelease:o||null}}const x=(e,t,r,n={})=>{const{threshold:s=50,resistance:o=.2}=n;if(e<t){const r=t-e;return t-s*(1-Math.exp(-r*o/s))}if(e>r){const t=e-r;return r+s*(1-Math.exp(-t*o/s))}return e};function A(e){return Array.from(new Set(e))}function C(e,t){switch(c(e)){case"object":return function(e,t){const r={},n=Object.keys(e),s=Object.keys(t),o=A([...n,...s]);for(const n of o)r[n]=C(e[n],t[n]);return r}(e,t);case"array":return function(e,t){const r=[];for(var n=0;n<e.length;n++)r.push(C(e?.[n],t?.[n]));for(n=e.length;n<t.length;n++)r.push(C(e?.[n],t?.[n]));return r}(e,t);default:return e??t}}function R(e,t){switch(c(e)){case"object":return function(e,t){const r={};var n=!1;for(const s in t)if(e.hasOwnProperty(s)){const o=R(e?.[s],t?.[s]);void 0!==o&&(r[s]=o,n=!0)}else r[s]=t[s],n=!0;for(const s in e)s in t||(r[s]=void 0,n=!0);return n?r:void 0}(e,t);case"array":return function(e,t){const r=[];for(var n=!1,s=0;s<e.length;s++){const o=R(e?.[s],t?.[s]);void 0===o&&void 0!==t?.[s]||(r[s]=o,n=!0)}for(s=0;s<t.length;s++){const o=R(e?.[s],t?.[s]);void 0!==o&&(r[s]=o,n=!0)}return n?r:void 0}(e,t);default:if(e!==t)return t}}const S=(e,t)=>{const r=[];for(let n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return r},I=(e,t)=>{for(let r=e.length-1;r>0;r--){const n=i(0,r,t);[e[r],e[n]]=[e[n],e[r]]}return e};function E(e,t){return e.reduce(((e,r)=>{const n=t(r);return e[n]||(e[n]=[]),e[n].push(r),e}),{})}function N(e,t){return t.split(".").reduce(((e,t)=>e?e[t]:void 0),e)}function L(e,t){const r=Object.keys(t);return e.slice().sort(((e,n)=>{for(const s of r){const r="desc"===t[s]?-1:1,o=N(e,s),i=N(n,s);if(o<i)return-r;if(o>i)return r}return 0}))}const U=(e,t,r)=>{var n,s,o,i,a,c,u,h;switch(c=r*(1-t),u=r*(1-(a=6*e-(i=Math.floor(6*e)))*t),h=r*(1-(1-a)*t),i%6){case 0:n=r,s=h,o=c;break;case 1:n=u,s=r,o=c;break;case 2:n=c,s=r,o=h;break;case 3:n=c,s=u,o=r;break;case 4:n=h,s=c,o=r;break;case 5:n=r,s=c,o=u}return[Math.round(255*n),Math.round(255*s),Math.round(255*o)]},V=e=>{const t=e.toString(16);return 1==t.length?"0"+t:t},T=(e,t,r)=>"#"+V(e)+V(t)+V(r),q=(e,t,r)=>{var n=Math.max(e,t,r),s=Math.min(e,t,r),o=n-s,i=0,a=0===n?0:o/n,c=n/255;switch(n){case s:i=0;break;case e:i=t-r+o*(t<r?6:0),i/=6*o;break;case t:i=r-e+2*o,i/=6*o;break;case r:i=e-t+4*o,i/=6*o}return[i,a,c]},D=e=>{if(3===(e=e.replace("#","")).length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6!==e.length)return[0,0,0];const t=parseInt(e.substring(0,2),16),r=parseInt(e.substring(2,4),16),n=parseInt(e.substring(4,6),16);return isNaN(t)||isNaN(r)||isNaN(n)||t<0||t>255||r<0||r>255||n<0||n>255?[0,0,0]:[t,r,n]};var F=Object.defineProperty,Z=(e,t,r)=>(((e,t,r)=>{t in e?F(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class H{constructor(){Z(this,"e",{})}on(e,t){return this.e[e]||(this.e[e]=[]),this.e[e].push(t),()=>this.off(e,t)}off(e,t){if(!this.e[e])return;const r=this.e[e].findIndex((e=>e===t));-1!==r&&(this.e[e].splice(r,1),0===this.e[e].length&&delete this.e[e])}emit(e,...t){if(!this.e[e])return;const r=this.e[e].slice();for(const n of r)try{n(...t)}catch(t){console.error(`Ошибка в обработчике события ${e}:`,t)}}once(e,t){const r=(...n)=>{this.off(e,r),t(...n)};return this.on(e,r)}clear(e){e?delete this.e[e]:this.e={}}}var W=Object.defineProperty,Y=(e,t,r)=>(((e,t,r)=>{t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class B{constructor(e,t){Y(this,"cb"),Y(this,"o"),Y(this,"tId",null),Y(this,"s"),this.cb=e,this.o=t,this.s=[]}execute(...e){if(this.cancel(),"[object Function]"===Object.prototype.toString.call(e[0]))this.s=e[0](...this.s);else for(let t=0;t<this.cb.length;t++)this.s[t]=e[t];this.tId=setTimeout(this.executeImmediately.bind(this),this.o.delay)}executeImmediately(){this.cancel(),this.cb(...this.s),this.s=[]}cancel(){this.tId&&(clearTimeout(this.tId),this.tId=null)}}var J=Object.defineProperty,K=(e,t,r)=>(((e,t,r)=>{t in e?J(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);class _{constructor(e){K(this,"initValue"),K(this,"currentValue"),this.initValue=b(e),this.currentValue=e}setter(e){this.currentValue=e(this.currentValue)}reset(e){this.initValue=b(e),this.currentValue=e}isModified(){return!d(this.initValue,this.currentValue)}get updateValues(){return R(this.initValue,this.currentValue)}}var G=Object.defineProperty,Q=(e,t,r)=>(((e,t,r)=>{t in e?G(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r),X=(e=>(e[e.ALLOW=1]="ALLOW",e[e.DENY=2]="DENY",e))(X||{});class ee{constructor(e=[],t=!0){Q(this,"rules"),Q(this,"cache"),Q(this,"cacheEnabled"),this.rules=[...e].sort(((e,t)=>(e.priority||50)-(t.priority||50))),this.cache=new Map,this.cacheEnabled=t,this.validateConfig()}isAllowed(e){try{const t="string"==typeof e?new URL(e):e;if(this.isObfuscatedUrl(t))return!1;const r=this.getCacheKey(t);if(this.cacheEnabled&&this.cache.has(r))return this.cache.get(r);const n=this.evaluateRules(t);return this.cacheEnabled&&this.cache.set(r,n),this.logAccess(t,n),n}catch(t){return console.error("Invalid URL:",e,t),!1}}evaluateRules(e){let t=null,r=null;for(const n of this.rules)this.ruleMatches(e,n)&&(null===t&&(t=1===n.action,r=n.id||null),console.debug(`Rule "${n.id}" matched for ${e.href}`));return null===t?(console.warn(`No rules matched for ${e.href}, defaulting to deny`),!1):(console.debug(`Final decision for ${e.href}: ${t} (rule: ${r})`),t)}ruleMatches(e,t){return this.checkHost(t,e)&&this.checkPaths(t,e)&&this.checkHash(t,e)&&this.checkParams(t,e)}checkHost(e,t){return e.hosts.some((e=>"string"==typeof e?"*"===e||t.host===e:e.test(t.host)))}checkPaths(e,t){return!e.paths||0===e.paths.length||e.paths.some((e=>"string"==typeof e?t.pathname===e||t.pathname.startsWith(e+"/"):e.test(t.pathname)))}checkHash(e,t){if(!e.hash||0===e.hash.length)return!0;const r=t.hash;return e.hash.some((e=>"string"==typeof e?r===e:e.test(r)))}checkParams(e,t){if(!e.allowedParams&&!e.ignoreParams)return!0;const r=new URL(t.toString());if(e.ignoreParams&&e.ignoreParams.forEach((e=>{r.searchParams.delete(e)})),e.allowedParams&&r.searchParams.size>0)for(const[t]of r.searchParams)if(!e.allowedParams.includes(t))return!1;return!0}isObfuscatedUrl(e){return[/@/,/\\/,/^\d+\.\d+\.\d+\.\d+$/,/\[.*\]/,/localhost/].some((t=>t.test(e.hostname)||t.test(e.href)))}getCacheKey(e){const t=new URL(e.toString());return t.searchParams.sort(),`${t.host}${t.pathname}${t.search}${t.hash}`}logAccess(e,t){console[t?"info":"warn"](`URL ${t?"allowed":"blocked"}: ${e.href}`)}validateConfig(){const e=[];this.rules.forEach(((t,r)=>{t.hosts&&Array.isArray(t.hosts)&&0!==t.hosts.length||e.push(`Rule ${r}: missing or invalid 'hosts' array`),void 0!==t.priority&&(t.priority<1||t.priority>100)&&e.push(`Rule ${r}: priority must be between 1 and 100`),t.action&&![1,2].includes(t.action)&&e.push(`Rule ${r}: action must be 'allow' or 'deny'`)})),e.length>0&&console.warn("URL security config validation errors:",e)}findMatchingRule(e){try{const t="string"==typeof e?new URL(e):e;for(const e of this.rules)if(this.ruleMatches(t,e))return e;return null}catch(e){return null}}clearCache(){this.cache.clear()}setCacheEnabled(e){this.cacheEnabled=e,e||this.clearCache()}getCacheSize(){return this.cache.size}}export{_ as DataKeeper,B as DebouncedFunction,H as EventEmitter,D as HEXtoRGB,U as HSVtoRGB,T as RGBtoHEX,q as RGBtoHSV,X as UrlAction,ee as UrlSecurityManager,r as alignTo,S as chunks,e as clamp,d as comparison,f as copyText,g as createLinksFromText,t as decWord,x as elasticClamp,o as formatNumber,m as generateUniqueKey,R as getChangedData,E as groupBy,c as isType,M as memoize,u as omit,L as orderBy,z as parseQueryString,O as parseVersionString,h as pick,i as random,a as randomByWeight,P as retry,I as shuffle,l as sleep,$ as textParserUrl,s as timeAgo,n as toShort,A as unique,b as unlink,C as updateCurrent};
1
+ import{Mutex as u}from"@minsize/mutex";const D=(u,D,F)=>u>D?u<F?u:F:D,F=(u,D)=>D[u%10==1&&u%100!=11?0:u%10>=2&&u%10<=4&&(u%100<10||u%100>=20)?1:2];function e(u,D){return u<=0?D:u+(D-u%D)%D}const t=(u,D,F=1)=>{const e=D||["","k","M","G","T","P"],t=u<0,r=Math.abs(u),n=Math.log10(r)/3|0,s=r/10**(3*n);return parseFloat(`${t?"-":""}${s%1?(Math.floor(10*s)/10).toFixed(F):s}`)+e[n]},r=u=>{if(!u)return"только что";const D=new Date(u),e=Math.floor((Date.now()-D.getTime())/1e3),t=()=>new Intl.DateTimeFormat("RU-ru",{day:"numeric",month:"short"}).format(D).replace(".",""),r=()=>D.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),n=(u,D,e)=>Array.isArray(u)?`${e} ${F(e,u)} ${D}`:`${u} ${D}`;switch(!0){case e<0:return"скоро";case e<60:return n(["секунду","секунды","секунд"],"назад",e);case e<3600:return n(["минуту","минуты","минут"],"назад",Math.floor(e/60));case e<7200:return n("час","назад",Math.floor(e/3600));case e<10800:return n("два часа","назад",Math.floor(e/3600));case e<14400:return n("три часа","назад",Math.floor(e/3600));case e<86400:return n(`сегодня в ${r()}`,"",Math.floor(e/3600));case e<172800:return n(`вчера в ${r()}`,"",Math.floor(e/86400));case e<259200:return n("два дня","назад",Math.floor(e/86400));case e<345600:return n("три дня","назад",Math.floor(e/86400));case e<31536e3:return n(`${t()} в ${r()}`,"",Math.floor(e/86400));case e>=31536e3:return n(`${t()} ${D.getFullYear()} г.`,"",Math.floor(e/31536e3))}return"только что"},n=u=>(u||0).toString().replace(/\B(?=(\d{3})+(?!\d))/g,".");function s(u,D,F){if(!F){const u=new Date;F=u.getDate()*u.getFullYear()*(u.getHours()??1)*u.getMilliseconds()}const e=function(u){const D=2**32;let F=u;return function(){var u;return F=(1664525*F+1013904223)%D,u=F,u^=u>>>21,F=(u^=u<<35)^u>>>4,(F>>>0)/D}}(F);return function(u,D,F){if(D>F)throw new Error("Минимальная граница не может быть больше максимальной.");return Math.floor(u()*(F-D+1))+D}(e,u,D)}function C(u,D){let F=0;for(const D in u)F+=u[D];const e=s(0,F,D);let t=0;for(const D in u)if(t+=u[D],e<t)return D;const r=Object.keys(u);return r[s(0,r.length-1,D)]}function E(u,D){var F=Object.prototype.toString.call(u).replace("[object ","").replace("]","").toLowerCase();try{"number"===F?isNaN(u)&&(F="nan"):u instanceof Buffer&&(F="buffer")}catch{}return void 0!==D?F===D:F}function i(u,D){return Object.keys(u).reduce(((F,e)=>(D.includes(e)||(F[e]=u[e]),F)),{})}function a(u,D){return Object.keys(u).reduce(((F,e)=>(D.includes(e)&&(F[e]=u[e]),F)),{})}const o=async u=>await new Promise((D=>setTimeout(D,u))),c=u=>{if(u){try{navigator.clipboard?.writeText(u)}catch{}try{var D=document.createElement("input");D.value=u,document.body.appendChild(D),D.select(),document.execCommand("copy"),document.body.removeChild(D)}catch{}}},h=(u,D)=>{const F=[],e=/{{([^}]+):([^}]+)}}/g;let t,r=0;for(;null!==(t=e.exec(u));)F.push(u.substring(r,t.index)),r=t.index+t[0].length,F.push({key:t[1],text:t[2]});return F.push(u.substring(r)),F.map((u=>"string"==typeof u?u:D(u.key,u.text)))},l=(u,D)=>{switch(E(u)){case"array":if(!function(u,D,F){if(!B(u,D,"array",F))return!1;if(u.length!==D.length)return!1;for(var e=0;e<u.length;e++)if(!l(u[e],D[e]))return!1;return!0}(u,D,{skipCheckPrev:!0}))return!1;break;case"object":if(!function(u,D,F){if(!B(u,D,"object",F))return!1;const e=Object.keys(u),t=Object.keys(D);if(e.length!==t.length)return!1;for(var r of e){if(!D.hasOwnProperty(r))return!1;if(!l(u[r],D[r]))return!1}return!0}(u,D,{skipCheckPrev:!0}))return!1;break;case"function":if(!function(u,D,F){return!!B(u,D,"function",F)&&u===D}(u,D,{skipCheckPrev:!0}))return!1;break;case"date":if(!function(u,D,F){return!!B(u,D,"date",F)&&u.getTime()===D.getTime()}(u,D,{skipCheckPrev:!0}))return!1;break;case"map":if(!function(u,D,F){if(!B(u,D,"map",F))return!1;if(u.size!==D.size)return!1;for(const[F,e]of u)if(!l(e,D.get(F)))return!1;return!0}(u,D,{skipCheckPrev:!0}))return!1;break;case"set":if(!function(u,D,F){if(!B(u,D,"set",F))return!1;if(u.size!==D.size)return!1;const e=Array.from(u.keys()),t=Array.from(D.keys());for(var r=0;r<e.length;r++)if(!l(e[r],t[r]))return!1;return!0}(u,D,{skipCheckPrev:!0}))return!1;break;default:if(u!==D)return!1}return!0};function B(u,D,F,e){return!(!e?.skipCheckPrev&&!E(u,F)||!E(D,F))}const f=u=>{const D=u=>{if("string"==typeof u||"number"==typeof u||"boolean"==typeof u||null===u)return JSON.stringify(u);if(Array.isArray(u))return"["+u.map(D).join(",")+"]";if("object"==typeof u){const F=Object.keys(u).sort();let e="{";for(let t=0;t<F.length;t++){const r=F[t];e+=JSON.stringify(r)+":"+D(u[r]),t<F.length-1&&(e+=",")}return e+="}",e}return String(u)},F=u=>{let D=0;if(0===u.length)return D;for(let F=0;F<u.length;F++){D=(D<<5)-D+u.charCodeAt(F),D|=0}return D};try{const e=D(u);return F(e).toString(16)}catch(D){return console.warn(`Object could not be fully stringified. Using a simple string conversion. Error: ${D}`),F(String(u)).toString(16)}},g=u=>{switch(E(u)){case"array":return m(u);case"object":return A(u);case"number":return Number(String(u));case"string":return String(u);case"bigint":return BigInt(String(u));case"map":return new Map(u);case"set":return new Set(u);default:return u}},m=u=>{const D=[];for(const F of u)D.push(g(F));return D},A=u=>{const D={};for(const F in u)D[F]=g(u[F]);return D},p=new RegExp(/(?:https?:\/\/)?(?:www\.)?([А-Яа-яa-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*\.(?:ru|com|org|net|me|su|рф|biz|info|co|uk|de|fr|jp|cn|es|it|ca|au|nl|se|no|dk|fi|pl|at|ch|be|cz|ie|pt|ro|hu|gr|sk|bg|hr|si|lt|lv|ee|is|mt|lu|li|mc|sm|va|ad|al|ba|mk|me|rs|tr|ua|by|kz|uz|am|ge|az|tm|kg|tj|md|kg|tj|af|dz|bh|eg|iq|ir|jo|kw|lb|ly|ma|om|ps|qa|sa|sd|sy|tn|ae|ye|ar|bo|br|cl|co|ec|gf|gy|pe|py|sr|uy|ve|ag|ai|aw|bb|bm|bs|bz|ca|cr|cu|dm|do|gd|gp|gt|hn|ht|jm|kn|ky|lc|ms|mx|ni|pa|pr|sv|tc|tt|vc|vg|vi|an|aq|as|fj|fm|gu|hm|id|ki|mh|mp|nc|nf|nr|nu|pf|pg|pw|sb|tk|to|tv|vu|wf|ws)(?:\/[a-zA-Z0-9._~:\/?#[\]@!$&'()*+,;=-]*)?)(?:\s)/),d=new RegExp(/(?:https?:\/\/)(?:www\.)?([А-Яа-яa-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*\.(?:ru|com|org|net|me|su|рф|biz|info|co|uk|de|fr|jp|cn|es|it|ca|au|nl|se|no|dk|fi|pl|at|ch|be|cz|ie|pt|ro|hu|gr|sk|bg|hr|si|lt|lv|ee|is|mt|lu|li|mc|sm|va|ad|al|ba|mk|me|rs|tr|ua|by|kz|uz|am|ge|az|tm|kg|tj|md|kg|tj|af|dz|bh|eg|iq|ir|jo|kw|lb|ly|ma|om|ps|qa|sa|sd|sy|tn|ae|ye|ar|bo|br|cl|co|ec|gf|gy|pe|py|sr|uy|ve|ag|ai|aw|bb|bm|bs|bz|ca|cr|cu|dm|do|gd|gp|gt|hn|ht|jm|kn|ky|lc|ms|mx|ni|pa|pr|sv|tc|tt|vc|vg|vi|an|aq|as|fj|fm|gu|hm|id|ki|mh|mp|nc|nf|nr|nu|pf|pg|pw|sb|tk|to|tv|vu|wf|ws)(?:\/[a-zA-Z0-9._~:\/?#[\]@!$&'()*+,;=-]*)?)(?:\s)/),b=u=>u,y=(u,D)=>{const F=D?.onToken??b,e=D?.requireProtocol??!1,t=D?.regex??e?d:p,r=[];let n=u+" ",s=t.exec(n);for(;s;){const u=s[0].trim(),D=s.index;D>0&&(r.push(F({type:"raw",value:n.substring(0,D)})),n=n.substring(D)),r.push(F({type:"url",value:u})),n=n.substring(u.length),s=t.exec(n)}return n.length>0&&r.push(F({type:"raw",value:n})),r},k=new RegExp(/(?:https?:\/\/)?(?:www\.)?([А-Яа-яa-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*\.(?:ru|com|org|net|me|su|рф|biz|info|co|uk|de|fr|jp|cn|es|it|ca|au|nl|se|no|dk|fi|pl|at|ch|be|cz|ie|pt|ro|hu|gr|sk|bg|hr|si|lt|lv|ee|is|mt|lu|li|mc|sm|va|ad|al|ba|mk|me|rs|tr|ua|by|kz|uz|am|ge|az|tm|kg|tj|md|kg|tj|af|dz|bh|eg|iq|ir|jo|kw|lb|ly|ma|om|ps|qa|sa|sd|sy|tn|ae|ye|ar|bo|br|cl|co|ec|gf|gy|pe|py|sr|uy|ve|ag|ai|aw|bb|bm|bs|bz|ca|cr|cu|dm|do|gd|gp|gt|hn|ht|jm|kn|ky|lc|ms|mx|ni|pa|pr|sv|tc|tt|vc|vg|vi|an|aq|as|fj|fm|gu|hm|id|ki|mh|mp|nc|nf|nr|nu|pf|pg|pw|sb|tk|to|tv|vu|wf|ws)(?:\/[a-zA-Z0-9._~:\/?#[\]@!$&'()*+,;=-]*)?)(?=\s|$)/g),v=new RegExp(/(?:https?:\/\/)(?:www\.)?([А-Яа-яa-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*\.(?:ru|com|org|net|me|su|рф|biz|info|co|uk|de|fr|jp|cn|es|it|ca|au|nl|se|no|dk|fi|pl|at|ch|be|cz|ie|pt|ro|hu|gr|sk|bg|hr|si|lt|lv|ee|is|mt|lu|li|mc|sm|va|ad|al|ba|mk|me|rs|tr|ua|by|kz|uz|am|ge|az|tm|kg|tj|md|kg|tj|af|dz|bh|eg|iq|ir|jo|kw|lb|ly|ma|om|ps|qa|sa|sd|sy|tn|ae|ye|ar|bo|br|cl|co|ec|gf|gy|pe|py|sr|uy|ve|ag|ai|aw|bb|bm|bs|bz|ca|cr|cu|dm|do|gd|gp|gt|hn|ht|jm|kn|ky|lc|ms|mx|ni|pa|pr|sv|tc|tt|vc|vg|vi|an|aq|as|fj|fm|gu|hm|id|ki|mh|mp|nc|nf|nr|nu|pf|pg|pw|sb|tk|to|tv|vu|wf|ws)(?:\/[a-zA-Z0-9._~:\/?#[\]@!$&'()*+,;=-]*)?)(?=\s|$)/g),w=/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35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F\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g,j=u=>u,z=(u,D)=>{const{onToken:F=j,requireProtocol:e=!1,regex:t}=D||{},r=[];if(!u)return r;let n=u;const s=u=>{if(!u)return;const D=[...u.matchAll(w)];if(0===D.length)return void r.push(F({type:"raw",value:u}));let e=0;for(const t of D){const D=t[0],n=t.index;if(n>e){const D=u.substring(e,n);r.push(F({type:"raw",value:D}))}r.push(F({type:"emoji",value:D})),e=n+D.length}if(e<u.length){const D=u.substring(e);r.push(F({type:"raw",value:D}))}};let C,E=0;const i=new RegExp((t||(e?v:k)).source,"g");for(;null!==(C=i.exec(n));){const u=C[0],D=C.index;if(D>E){s(n.substring(E,D))}r.push(F({type:"url",value:u})),E=D+u.length}if(E<n.length){s(n.substring(E))}return r};function $(u){const D=new Map;return function(...F){const e=JSON.stringify(F);if(D.has(e))return D.get(e);const t=u(...F);return D.set(e,t),t}}function x(u,D,F){return new Promise(((e,t)=>{const r=D=>{u().then(e).catch((u=>{0===D?t(u):(console.log(`Retrying... attempts left: ${D}`),setTimeout((()=>r(D-1)),F))}))};r(D)}))}function P(u){const D={},F=(u.startsWith("?")?u.slice(1):u).split("&");for(const u of F){const[F,e]=u.split("=");if(F){const u=decodeURIComponent(F),t=e?decodeURIComponent(e):"";D[u]=t}}return D}function M(u){const D=u.match(/^(\d+|\*)\.(\d+|\*)\.(\d+|\*)(?:-([a-zA-Z0-9-.]+))?$/);if(!D)throw new Error("Invalid version string");const[,F,e,t,r]=D,n=u=>"*"===u?"*":parseInt(u,10);return{major:n(F),minor:n(e),patch:n(t),prerelease:r||null}}const O=(u,D,F,e={})=>{const{threshold:t=50,resistance:r=.2}=e;if(u<D){const F=D-u;return D-t*(1-Math.exp(-F*r/t))}if(u>F){const D=u-F;return F+t*(1-Math.exp(-D*r/t))}return u};function R(u){return Array.from(new Set(u))}function S(u,D){switch(E(u)){case"object":return function(u,D){const F={},e=Object.keys(u),t=Object.keys(D),r=R([...e,...t]);for(const e of r)F[e]=S(u[e],D[e]);return F}(u,D);case"array":return function(u,D){const F=[];for(var e=0;e<u.length;e++)F.push(S(u?.[e],D?.[e]));for(e=u.length;e<D.length;e++)F.push(S(u?.[e],D?.[e]));return F}(u,D);default:return u??D}}function q(u,D){switch(E(u)){case"object":return function(u,D){const F={};var e=!1;for(const t in D)if(u.hasOwnProperty(t)){const r=q(u?.[t],D?.[t]);void 0!==r&&(F[t]=r,e=!0)}else F[t]=D[t],e=!0;for(const t in u)t in D||(F[t]=void 0,e=!0);return e?F:void 0}(u,D);case"array":return function(u,D){const F=[];for(var e=!1,t=0;t<u.length;t++){const r=q(u?.[t],D?.[t]);void 0===r&&void 0!==D?.[t]||(F[t]=r,e=!0)}for(t=0;t<D.length;t++){const r=q(u?.[t],D?.[t]);void 0!==r&&(F[t]=r,e=!0)}return e?F:void 0}(u,D);default:if(u!==D)return D}}const I=(u,D)=>{const F=[];for(let e=0;e<D.length;e+=u)F.push(D.slice(e,e+u));return F},N=(u,D)=>{for(let F=u.length-1;F>0;F--){const e=s(0,F,D);[u[F],u[e]]=[u[e],u[F]]}return u};function L(u,D){return u.reduce(((u,F)=>{const e=D(F);return u[e]||(u[e]=[]),u[e].push(F),u}),{})}function T(u,D){return D.split(".").reduce(((u,D)=>u?u[D]:void 0),u)}function U(u,D){const F=Object.keys(D);return u.slice().sort(((u,e)=>{for(const t of F){const F="desc"===D[t]?-1:1,r=T(u,t),n=T(e,t);if(r<n)return-F;if(r>n)return F}return 0}))}const V=(u,D,F)=>{var e,t,r,n,s,C,E,i;switch(C=F*(1-D),E=F*(1-(s=6*u-(n=Math.floor(6*u)))*D),i=F*(1-(1-s)*D),n%6){case 0:e=F,t=i,r=C;break;case 1:e=E,t=F,r=C;break;case 2:e=C,t=F,r=i;break;case 3:e=C,t=E,r=F;break;case 4:e=i,t=C,r=F;break;case 5:e=F,t=C,r=E}return[Math.round(255*e),Math.round(255*t),Math.round(255*r)]},Z=u=>{const D=u.toString(16);return 1==D.length?"0"+D:D},H=(u,D,F)=>"#"+Z(u)+Z(D)+Z(F),W=(u,D,F)=>{var e=Math.max(u,D,F),t=Math.min(u,D,F),r=e-t,n=0,s=0===e?0:r/e,C=e/255;switch(e){case t:n=0;break;case u:n=D-F+r*(D<F?6:0),n/=6*r;break;case D:n=F-u+2*r,n/=6*r;break;case F:n=u-D+4*r,n/=6*r}return[n,s,C]},Y=u=>{if(3===(u=u.replace("#","")).length&&(u=u[0]+u[0]+u[1]+u[1]+u[2]+u[2]),6!==u.length)return[0,0,0];const D=parseInt(u.substring(0,2),16),F=parseInt(u.substring(2,4),16),e=parseInt(u.substring(4,6),16);return isNaN(D)||isNaN(F)||isNaN(e)||D<0||D>255||F<0||F>255||e<0||e>255?[0,0,0]:[D,F,e]};var _=Object.defineProperty,J=(u,D,F)=>(((u,D,F)=>{D in u?_(u,D,{enumerable:!0,configurable:!0,writable:!0,value:F}):u[D]=F})(u,"symbol"!=typeof D?D+"":D,F),F);class K{constructor(){J(this,"e",{})}on(u,D){return this.e[u]||(this.e[u]=[]),this.e[u].push(D),()=>this.off(u,D)}off(u,D){if(!this.e[u])return;const F=this.e[u].findIndex((u=>u===D));-1!==F&&(this.e[u].splice(F,1),0===this.e[u].length&&delete this.e[u])}emit(u,...D){if(!this.e[u])return;const F=this.e[u].slice();for(const e of F)try{e(...D)}catch(D){console.error(`Ошибка в обработчике события ${u}:`,D)}}once(u,D){const F=(...e)=>{this.off(u,F),D(...e)};return this.on(u,F)}clear(u){u?delete this.e[u]:this.e={}}}var G=Object.defineProperty,Q=(u,D,F)=>(((u,D,F)=>{D in u?G(u,D,{enumerable:!0,configurable:!0,writable:!0,value:F}):u[D]=F})(u,"symbol"!=typeof D?D+"":D,F),F);class X{constructor(u,D){Q(this,"cb"),Q(this,"o"),Q(this,"tId",null),Q(this,"s"),this.cb=u,this.o=D,this.s=[]}execute(...u){if(this.cancel(),"[object Function]"===Object.prototype.toString.call(u[0]))this.s=u[0](...this.s);else for(let D=0;D<this.cb.length;D++)this.s[D]=u[D];this.tId=setTimeout(this.executeImmediately.bind(this),this.o.delay)}executeImmediately(){this.cancel(),this.cb(...this.s),this.s=[]}cancel(){this.tId&&(clearTimeout(this.tId),this.tId=null)}}var uu=Object.defineProperty,Du=(u,D,F)=>(((u,D,F)=>{D in u?uu(u,D,{enumerable:!0,configurable:!0,writable:!0,value:F}):u[D]=F})(u,"symbol"!=typeof D?D+"":D,F),F);class Fu{constructor(u){Du(this,"initValue"),Du(this,"currentValue"),this.initValue=g(u),this.currentValue=u}setter(u){this.currentValue=u(this.currentValue)}reset(u){this.initValue=g(u),this.currentValue=u}isModified(){return!l(this.initValue,this.currentValue)}get updateValues(){return q(this.initValue,this.currentValue)}}var eu=Object.defineProperty,tu=(u,D,F)=>(((u,D,F)=>{D in u?eu(u,D,{enumerable:!0,configurable:!0,writable:!0,value:F}):u[D]=F})(u,"symbol"!=typeof D?D+"":D,F),F);class ru{constructor(){tu(this,"requests",new Set),tu(this,"emitter",new K),tu(this,"mutex",u({globalLimit:999999}))}async fetch(u,D){const F=await this.mutex.wait({key:u,limit:1});return this.requests.has(u)?(F(),new Promise(((D,F)=>{this.emitter.once(u,(u=>{u.error?F(u.error):D(u.result)}))}))):(this.requests.add(u),F(),new Promise(((F,e)=>{D().then((D=>{F(D),this.emitter.emit(u,{result:D}),this.requests.delete(u)})).catch((D=>{e(D),this.emitter.emit(u,{error:D}),this.requests.delete(u)}))})))}}var nu=Object.defineProperty,su=(u,D,F)=>(((u,D,F)=>{D in u?nu(u,D,{enumerable:!0,configurable:!0,writable:!0,value:F}):u[D]=F})(u,"symbol"!=typeof D?D+"":D,F),F),Cu=(u=>(u[u.ALLOW=1]="ALLOW",u[u.DENY=2]="DENY",u))(Cu||{});class Eu{constructor(u=[],D=!0){su(this,"rules"),su(this,"cache"),su(this,"cacheEnabled"),this.rules=[...u].sort(((u,D)=>(u.priority||50)-(D.priority||50))),this.cache=new Map,this.cacheEnabled=D,this.validateConfig()}isAllowed(u){try{const D="string"==typeof u?new URL(u):u;if(this.isObfuscatedUrl(D))return!1;const F=this.getCacheKey(D);if(this.cacheEnabled&&this.cache.has(F))return this.cache.get(F);const e=this.evaluateRules(D);return this.cacheEnabled&&this.cache.set(F,e),this.logAccess(D,e),e}catch(D){return console.error("Invalid URL:",u,D),!1}}evaluateRules(u){let D=null,F=null;for(const e of this.rules)this.ruleMatches(u,e)&&(null===D&&(D=1===e.action,F=e.id||null),console.debug(`Rule "${e.id}" matched for ${u.href}`));return null===D?(console.warn(`No rules matched for ${u.href}, defaulting to deny`),!1):(console.debug(`Final decision for ${u.href}: ${D} (rule: ${F})`),D)}ruleMatches(u,D){return this.checkHost(D,u)&&this.checkPaths(D,u)&&this.checkHash(D,u)&&this.checkParams(D,u)}checkHost(u,D){return u.hosts.some((u=>"string"==typeof u?"*"===u||D.host===u:u.test(D.host)))}checkPaths(u,D){return!u.paths||0===u.paths.length||u.paths.some((u=>"string"==typeof u?D.pathname===u||D.pathname.startsWith(u+"/"):u.test(D.pathname)))}checkHash(u,D){if(!u.hash||0===u.hash.length)return!0;const F=D.hash;return u.hash.some((u=>"string"==typeof u?F===u:u.test(F)))}checkParams(u,D){if(!u.allowedParams&&!u.ignoreParams)return!0;const F=new URL(D.toString());if(u.ignoreParams&&u.ignoreParams.forEach((u=>{F.searchParams.delete(u)})),u.allowedParams&&F.searchParams.size>0)for(const[D]of F.searchParams)if(!u.allowedParams.includes(D))return!1;return!0}isObfuscatedUrl(u){return[/@/,/\\/,/^\d+\.\d+\.\d+\.\d+$/,/\[.*\]/,/localhost/].some((D=>D.test(u.hostname)||D.test(u.href)))}getCacheKey(u){const D=new URL(u.toString());return D.searchParams.sort(),`${D.host}${D.pathname}${D.search}${D.hash}`}logAccess(u,D){console[D?"info":"warn"](`URL ${D?"allowed":"blocked"}: ${u.href}`)}validateConfig(){const u=[];this.rules.forEach(((D,F)=>{D.hosts&&Array.isArray(D.hosts)&&0!==D.hosts.length||u.push(`Rule ${F}: missing or invalid 'hosts' array`),void 0!==D.priority&&(D.priority<1||D.priority>100)&&u.push(`Rule ${F}: priority must be between 1 and 100`),D.action&&![1,2].includes(D.action)&&u.push(`Rule ${F}: action must be 'allow' or 'deny'`)})),u.length>0&&console.warn("URL security config validation errors:",u)}findMatchingRule(u){try{const D="string"==typeof u?new URL(u):u;for(const u of this.rules)if(this.ruleMatches(D,u))return u;return null}catch(u){return null}}clearCache(){this.cache.clear()}setCacheEnabled(u){this.cacheEnabled=u,u||this.clearCache()}getCacheSize(){return this.cache.size}}export{Fu as DataKeeper,X as DebouncedFunction,K as EventEmitter,Y as HEXtoRGB,V as HSVtoRGB,H as RGBtoHEX,W as RGBtoHSV,ru as RequestDeduplicator,Cu as UrlAction,Eu as UrlSecurityManager,e as alignTo,I as chunks,D as clamp,l as comparison,c as copyText,h as createLinksFromText,F as decWord,O as elasticClamp,n as formatNumber,f as generateUniqueKey,q as getChangedData,L as groupBy,E as isType,$ as memoize,i as omit,U as orderBy,P as parseQueryString,z as parseTextTokens,M as parseVersionString,a as pick,s as random,C as randomByWeight,x as retry,N as shuffle,o as sleep,y as textParserUrl,r as timeAgo,t as toShort,R as unique,g as unlink,S as updateCurrent};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minsize/utils",
3
- "version": "0.3.2",
3
+ "version": "0.4.1",
4
4
  "description": "Frequently used utilities",
5
5
  "license": "MIT",
6
6
  "types": "index.ts",
@@ -12,6 +12,9 @@
12
12
  "type": "git",
13
13
  "url": "https://github.com/minsize/utils"
14
14
  },
15
+ "dependencies": {
16
+ "@minsize/mutex": "^0.0.7"
17
+ },
15
18
  "contributors": [],
16
19
  "keywords": [
17
20
  "utils",