{"version":3,"file":"CBEZTvCM.js","sources":["../../src/utils/helpers.js"],"sourcesContent":["import { isValid, parseISO } from 'date-fns';\n\nconst dateTimeRegex = /^(\\d{4})-(\\d{2})-(\\d{2})(?:T(\\d{2}):(\\d{2}):(\\d{2})(?:\\.\\d+)?)?$/;\n\nexport const makeCurrency = (val, curr = '₽') => `${val}\\u00A0${curr}`; // nbsp\n\nexport function toNumericFormat(value) {\n if (value == null)\n return '\\u2014';\n\n return Number(value).toLocaleString('ru-RU', {\n minimumFractionDigits: 0,\n maximumFractionDigits: 2,\n });\n}\n\nexport function lastSeveralYears(lastYears) {\n const currentYear = new Date().getFullYear();\n const yearsArr = [];\n\n for (let i = lastYears; i > 0; --i) {\n yearsArr.push(currentYear - i);\n }\n\n return yearsArr;\n}\n\nexport function dateDiff(date1, date2) {\n let years = date2.getFullYear() - date1.getFullYear();\n let months = years * 12 + date2.getMonth() - date1.getMonth();\n let days = date2.getDate() - date1.getDate();\n\n years -= date2.getMonth() < date1.getMonth();\n months -= date2.getDate() < date1.getDate();\n days += days < 0 ? new Date(date2.getFullYear(), date2.getMonth() - 1, 0).getDate() + 1 : 0;\n\n return [years, months, days];\n}\n\nexport function datePassed(date) {\n const dateToCheck = new Date(date);\n const currentDate = new Date();\n let passed = false;\n // Обнуляем время, чтобы сравнение было только по дате (день, месяц, год)\n dateToCheck.setHours(0, 0, 0, 0);\n currentDate.setHours(0, 0, 0, 0);\n if (dateToCheck.getTime() <= currentDate.getTime()) {\n passed = true;\n }\n return passed;\n}\n\nexport function daysBetween(startDate, endDate) {\n if (!(startDate instanceof Date) || !(endDate instanceof Date)) {\n throw new TypeError('Применяйте корректные объекты Date.');\n }\n const diffTime = Math.abs(Date.UTC(endDate.getFullYear(), endDate.getMonth(), endDate.getDate()) - Date.UTC(startDate.getFullYear(), startDate.getMonth(), startDate.getDate()));\n const diffDays = Math.round(diffTime / (1000 * 60 * 60 * 24));\n return diffDays;\n}\n\n// FIXME: надо бы как-то пометить какие из них относятся к 1, 2, 5 и пр.\nexport function makePlural(iNumber, ...endings) {\n const [v1, v2, v3] = endings;\n let sEnding;\n\n const lastDigits = iNumber % 100;\n if (lastDigits >= 11 && lastDigits <= 19) {\n sEnding = v3;\n }\n else {\n switch (iNumber % 10) {\n case 1:\n sEnding = v1;\n break;\n case 2:\n case 3:\n case 4:\n sEnding = v2;\n break;\n default:\n sEnding = v3;\n }\n }\n\n return `${iNumber} ${sEnding}`;\n}\n\nexport function termActivity(date, turn) {\n const date1 = new Date(date);\n const date2 = new Date();\n const difference = turn ? dateDiff(date2, date1) : dateDiff(date1, date2);\n const differenceYear = difference[0];\n const differenceMonth = difference[1] - differenceYear * 12;\n const differenceDays = difference[2];\n let output = '';\n if (differenceYear) {\n output += makePlural(differenceYear, 'год', 'года', 'лет');\n }\n if (differenceMonth) {\n output += ` ${makePlural(differenceMonth, 'месяц', 'месяца', 'месяцев')}`;\n }\n if (differenceDays && !differenceMonth) {\n output += ` ${makePlural(differenceDays, 'день', 'дня', 'дней')}`;\n }\n return output;\n}\n\nconst patternEmail = /^\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$/;\n// eslint-disable-next-line regexp/no-obscure-range\nexport const patternOnlyLetter = /^[a-zа-яё]+$/i;\n\nconst patternPhone = /^\\+7\\(?\\d{3}\\)?[-\\s]?\\d{3}[-\\s]?\\d{2}[-\\s]?\\d{2}$/;\n\nexport function formatPhone(phone) {\n const phoneDigits = phone.replace(/\\D/g, '');\n if (phoneDigits.length !== 11)\n return phone;\n return phoneDigits.replace(/(\\d)(\\d{3})(\\d{3})(\\d{2})(\\d{2})/, '+$1 ($2) $3-$4-$5');\n}\n\nexport function notEmptyObject(obj) {\n if (obj == null)\n return false;\n\n // eslint-disable-next-line no-unreachable-loop\n for (const k in obj) {\n return true;\n }\n\n return false;\n}\n\nfunction clearPhone(phone) {\n return phone.replace(/\\D/g, '');\n}\n\nconst ISODateRegex = /^(\\d{4})-(\\d{2})-(\\d{2})/;\nfunction formatDate(str) {\n if (!str)\n return null;\n\n const matches = ISODateRegex.exec(str);\n if (!matches)\n return null;\n\n const [, year, month, day] = matches;\n return `${day}.${month}.${year}`;\n}\n\nfunction unformatDate(str) {\n if (!str)\n return null;\n\n const [day, month, year] = str.split('.');\n return `${year}-${month}-${day}`;\n}\n\nfunction validateBik(bik, rs, ks) {\n let result = false;\n const error = {};\n if (typeof bik === 'number') {\n bik = bik.toString();\n }\n else if (typeof bik !== 'string') {\n bik = '';\n }\n if (!bik.length) {\n error.code = 1;\n error.message = 'БИК пуст';\n }\n else if (/\\D/.test(bik)) {\n error.code = 2;\n error.message = 'БИК может состоять только из цифр';\n }\n else if (bik.length !== 9) {\n error.code = 3;\n error.message = 'БИК может состоять только из 9 цифр';\n }\n else {\n result = true;\n if (rs) {\n validateRs(rs, bik);\n }\n if (ks) {\n validateKs(ks, bik);\n }\n }\n return result;\n}\n\nfunction validateInn(inn) {\n let valid = false;\n if (inn.length === 10) {\n const sum = [2, 4, 10, 3, 5, 9, 4, 6, 8].reduce((res, n, i) => res + n * inn[i], 0);\n valid = Number.parseInt((sum % 11) % 10) === Number.parseInt(inn[9]);\n }\n if (inn.length === 12) {\n const sum11 = [7, 2, 4, 10, 3, 5, 9, 4, 6, 8].reduce((res, n, i) => res + n * inn[i], 0);\n const sum12 = [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8].reduce((res, n, i) => res + n * inn[i], 0);\n\n valid = Number.parseInt((sum11 % 11) % 10) === Number.parseInt(inn[10]) && Number.parseInt((sum12 % 11) % 10) === Number.parseInt(inn[11]);\n }\n return valid;\n}\n\nfunction validateVIN(vin) {\n let valid = false;\n const pattern = /^[A-H, R-ZJ-NP0-9]{17}$/;\n\n if (vin) {\n if (pattern.test(vin)) {\n valid = true;\n }\n }\n return valid;\n}\n\nfunction validateOgrn(ogrn) {\n let result = false;\n const error = {};\n if (typeof ogrn === 'number') {\n ogrn = ogrn.toString();\n }\n else if (typeof ogrn !== 'string') {\n ogrn = '';\n }\n if (!ogrn.length) {\n error.code = 1;\n error.message = 'ОГРН пуст';\n }\n else if (/\\D/.test(ogrn)) {\n error.code = 2;\n error.message = 'ОГРН может состоять только из цифр';\n }\n else if (ogrn.length !== 13) {\n error.code = 3;\n error.message = 'ОГРН может состоять только из 13 цифр';\n }\n else {\n const n13 = Number.parseInt((Number.parseInt(ogrn.slice(0, -1)) % 11).toString().slice(-1));\n if (n13 === Number.parseInt(ogrn[12])) {\n result = true;\n }\n else {\n error.code = 4;\n error.message = 'Неправильное контрольное число';\n }\n }\n return result;\n}\n\nfunction validateKpp(kpp) {\n let result = false;\n const error = {};\n if (typeof kpp === 'number') {\n kpp = kpp.toString();\n }\n else if (typeof kpp !== 'string') {\n kpp = '';\n }\n if (!kpp.length) {\n error.code = 1;\n error.message = 'КПП пуст';\n }\n else if (kpp.length !== 9) {\n error.code = 2;\n error.message = 'КПП может состоять только из 9 знаков (цифр или заглавных букв латинского алфавита от A до Z)';\n }\n else if (!/^\\d{4}[0-9A-Z]{2}\\d{3}$/.test(kpp)) {\n error.code = 3;\n error.message = 'Неправильный формат КПП';\n }\n else {\n result = true;\n }\n return result;\n}\n\nfunction validateRs(rs, bik) {\n let result = false;\n const error = {};\n if (validateBik(bik)) {\n if (typeof rs === 'number') {\n rs = rs.toString();\n }\n else if (typeof rs !== 'string') {\n rs = '';\n }\n if (!rs.length) {\n error.code = 1;\n error.message = 'Р/С пуст';\n }\n else if (/\\D/.test(rs)) {\n error.code = 2;\n error.message = 'Р/С может состоять только из цифр';\n }\n else if (rs.length !== 20) {\n error.code = 3;\n error.message = 'Р/С может состоять только из 20 цифр';\n }\n else {\n const bikRs = bik.toString().slice(-3) + rs;\n let checksum = 0;\n const coefficients = [7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1];\n for (const i in coefficients) {\n checksum += coefficients[i] * (bikRs[i] % 10);\n }\n if (checksum % 10 === 0) {\n result = true;\n }\n else {\n error.code = 4;\n error.message = 'Неправильное контрольное число';\n }\n }\n }\n return result;\n}\n\nfunction validateKs(ks, bik) {\n let result = false;\n const error = {};\n if (validateBik(bik, error)) {\n if (typeof ks === 'number') {\n ks = ks.toString();\n }\n else if (typeof ks !== 'string') {\n ks = '';\n }\n if (!ks.length) {\n error.code = 1;\n error.message = 'К/С пуст';\n }\n else if (/\\D/.test(ks)) {\n error.code = 2;\n error.message = 'К/С может состоять только из цифр';\n }\n else if (ks.length !== 20) {\n error.code = 3;\n error.message = 'К/С может состоять только из 20 цифр';\n }\n else {\n const bikKs = `0${bik.toString().slice(4, 6)}${ks}`;\n let checksum = 0;\n const coefficients = [7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1, 3, 7, 1];\n for (const i in coefficients) {\n checksum += coefficients[i] * (bikKs[i] % 10);\n }\n if (checksum % 10 === 0) {\n result = true;\n }\n else {\n error.code = 4;\n error.message = 'Неправильное контрольное число';\n }\n }\n }\n return result;\n}\n\nfunction validateSnils(snils, error) {\n let result = false;\n if (typeof snils === 'number') {\n snils = snils.toString();\n }\n else if (typeof snils !== 'string') {\n snils = '';\n }\n if (!snils.length) {\n error.code = 1;\n error.message = 'СНИЛС пуст';\n }\n else if (/\\D/.test(snils)) {\n error.code = 2;\n error.message = 'СНИЛС может состоять только из цифр';\n }\n else if (snils.length !== 11) {\n error.code = 3;\n error.message = 'СНИЛС может состоять только из 11 цифр';\n }\n else {\n let sum = 0;\n for (let i = 0; i < 9; i++) {\n sum += Number.parseInt(snils[i]) * (9 - i);\n }\n let checkDigit = 0;\n if (sum < 100) {\n checkDigit = sum;\n }\n else if (sum > 101) {\n checkDigit = Number.parseInt(sum % 101);\n if (checkDigit === 100) {\n checkDigit = 0;\n }\n }\n if (checkDigit === Number.parseInt(snils.slice(-2))) {\n result = true;\n }\n else {\n error.code = 4;\n error.message = 'Неправильное контрольное число';\n }\n }\n return result;\n}\n\nfunction validDate(v) {\n const unDate = unformatDate(v);\n const date = parseISO(unDate);\n\n let res = false;\n if (isValid(date)) {\n res = true;\n }\n return res;\n}\n\nconst shortGroups = [\n {\n name: 'млн.',\n minValue: 1e6,\n },\n {\n name: 'млрд.',\n minValue: 1e9,\n },\n];\n\nexport function makeCurrencyWithShortGroup(value) {\n if (value == null)\n return null;\n\n if (typeof value === 'string') {\n value = Number(value);\n }\n\n if (!Number.isFinite(value))\n return null;\n\n let output;\n\n const shortGroup = findLast(shortGroups, (item) => value >= item.minValue);\n if (shortGroup) {\n value /= shortGroup.minValue;\n output = makeCurrency(`${value.toFixed(2).toString()} ${shortGroup.name}`);\n }\n else {\n output = makeCurrency(\n value.toLocaleString('ru-RU', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })\n );\n }\n\n return output;\n}\n\nconst shortToLongCompanyNameRegexes = [\n // FIXME: случайно вытащил из интернета, в окопф справочнике не нашёл\n ['^ИП', 'Индивидуальный предприниматель'],\n ['^ООО', 'Общество с ограниченной ответственностью'],\n ['^АО', 'Акционерное общество'],\n ['^ЗАО', 'Закрытое акционерное общество'],\n ['^ОАО', 'Открытое акционерное общество'],\n ['^ПАО', 'Публичное акционерное общество'],\n ['^НКО', 'Некоммерческая организация'],\n ['^ОДО', 'Общество с дополнительной ответственностью'],\n ['^ПТ', 'Полное товарищество'],\n ['^КТ', 'Коммандитное товарищество'],\n ['^ПК', 'Производственный кооператив'],\n];\nexport function transformShortCompanyNameToLong(companyName) {\n if (typeof companyName !== 'string')\n return null;\n\n const idx = shortToLongCompanyNameRegexes.findIndex(([regexPattern]) => new RegExp(regexPattern).test(companyName));\n if (idx === -1)\n return companyName;\n\n const [regexPattern, textToReplace] = shortToLongCompanyNameRegexes[idx];\n return companyName.replace(new RegExp(regexPattern), textToReplace);\n}\n\nexport function removeCompanyOkopfFromText(text) {\n if (typeof text !== 'string' || !text?.length)\n return null;\n\n for (const [pattern] of shortToLongCompanyNameRegexes) {\n const regex = new RegExp(pattern);\n if (regex.test(text)) {\n return text.replace(regex, '');\n }\n }\n\n return text;\n}\n\nconst monthsLabels = {\n genetive: ['января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'],\n default: ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'],\n};\nexport function getZeroBasedMonthLabel(monthNumberZeroBased, genetive = false, lowerCase = true) {\n if (typeof monthNumberZeroBased === 'string') {\n monthNumberZeroBased = Number(monthNumberZeroBased);\n }\n\n if (typeof monthNumberZeroBased !== 'number' || !Number.isFinite(monthNumberZeroBased))\n return null;\n\n const labelType = genetive ? 'genetive' : 'default';\n\n const label = monthsLabels[labelType][monthNumberZeroBased];\n return !genetive && lowerCase ? label.toLowerCase() : label;\n}\n\n/**\n * @param {string} access_key base64 string\n * @returns String\n */\nexport function prepareDownloadKeyAsLink(access_key) {\n return `${__API_URL__}file/get/?access_key=${encodeURIComponent(access_key)}`;\n}\n\nexport function getDownloadPageUrl({ type, value, companyid, scope }) {\n // FIXME: динамически подставлять ссылку на entry - использовать define от vite?\n const downloadPageUrl = new URL('/download_page.html', document.location);\n downloadPageUrl.searchParams.append('type', type);\n downloadPageUrl.searchParams.append('value', value);\n companyid && downloadPageUrl.searchParams.append('cid', companyid);\n scope && downloadPageUrl.searchParams.append('scope', scope);\n\n return downloadPageUrl.toString();\n}\n\nexport function tryToBlankWindow(url) {\n if (window.open(url, '_blank') == null) {\n return Promise.reject(new Error('Не удалось открыть новое окно ссылки, возможно браузер ограничивает это действие'));\n }\n\n return Promise.resolve();\n}\n\nexport function transformSizeInBytesToHuman(sizeInBytes) {\n let postfix, size;\n\n if (sizeInBytes > 1_048_576) {\n // 1MB or more\n postfix = 'мегабайт';\n size = sizeInBytes / 1_048_576;\n }\n else if (sizeInBytes > 1024) {\n // 1KB or more\n postfix = 'килобайт';\n size = sizeInBytes / 1024;\n }\n else {\n postfix = 'байт';\n size = sizeInBytes;\n }\n\n return `${Math.floor(size).toString()} ${postfix}`;\n}\n\n/**\n * @param {number} valueHundred\n */\nexport function transformNumberToPercentString(valueHundred) {\n if (valueHundred == null)\n return '\\u2014';\n\n if (typeof valueHundred !== 'number') {\n valueHundred = Number(valueHundred);\n }\n\n return `${valueHundred.toLocaleString('ru', { maximumFractionDigits: 2 })}%`;\n}\n\nexport function parseDatetimeString(dateTimeString) {\n if (!dateTimeString || !dateTimeString.length)\n return null;\n\n const matches = dateTimeRegex.exec(dateTimeString);\n if (!matches)\n return null;\n\n const [, year, month, day, hour, minute, second] = matches;\n return { year, month, day, hour, minute, second };\n}\n\nexport function tryConvertYMDToDMYRussian(dateTimeString, includeTime = true) {\n const dateTime = parseDatetimeString(dateTimeString);\n if (!dateTime)\n return dateTimeString;\n\n const DMYDate = [dateTime.day, dateTime.month, dateTime.year].filter((part) => part != null).join('.');\n if (!includeTime)\n return DMYDate;\n\n const timeString = [dateTime.hour, dateTime.minute, dateTime.second].filter((part) => part != null).join(':');\n\n if (!DMYDate && !timeString)\n return '';\n else if (DMYDate && timeString)\n return `${DMYDate} ${timeString}`;\n else if (!DMYDate)\n return timeString;\n\n return DMYDate;\n}\n\n/**\n * Полифилл для findLast\n * @param {Array} array\n * @param {Function} predicate\n * @returns any\n */\nexport function findLast(array, predicate) {\n if (!Array.isArray(array) || !array.length)\n return undefined;\n\n if (typeof array.findLast === 'function') {\n return array.findLast(predicate);\n }\n\n for (let i = array.length - 1; i >= 0; --i) {\n const item = array[i];\n if (predicate(item, i, array)) {\n return item;\n }\n }\n\n return undefined;\n}\n\nexport function securityViewText(item) {\n let output = '';\n if (item.$extra.has_guarantor || item.project.issurety !== 'N' || item.project.ispledge !== 'N') {\n if (item.$extra.has_guarantor) {\n output = output.length !== 0 ? `${output}, Гарантия выкупа` : 'Гарантия выкупа';\n }\n if (item.project.ispledge !== 'N') {\n output = output.length !== 0 ? `${output}, Залог` : 'Залог';\n }\n if (item.project.issurety !== 'N') {\n output = output.length !== 0 ? `${output}, Поручительство` : 'Поручительство';\n }\n }\n else {\n output = '\\u2014';\n }\n return output;\n}\n\n/**\n * Get a random integer between `min` and `max`.\n *\n * @param {number} min - min number\n * @param {number} max - max number\n * @return {number} a random integer\n */\nexport function getRandomInt(min, max) {\n return Math.floor(Math.random() * (max - min + 1) + min);\n}\n\n// FIXME: перетащить trap-focus в composable\n/**\n * @overload\n * @param {Node[]} list\n * @returns {HTMLElement[]}\n *\n * @param {...Node} list\n * @returns {HTMLElement[]}\n */\nexport function setTrapFocus(...list) {\n const trapFocusElements = [];\n\n const iterateNodes = Array.isArray(list[0]) ? list[0] : list;\n for (const trapNode of iterateNodes) {\n if (!trapNode)\n continue;\n\n let currentElement = trapNode.parentElement;\n while (currentElement != null) {\n for (const children of currentElement.children) {\n if (children === trapNode || iterateNodes.some((node) => children.contains(node)))\n continue;\n if (children.inert || children.getAttribute('tabindex') === '-1')\n continue;\n if (children === document.head)\n continue;\n if ('disallowInert' in children.dataset)\n continue;\n\n children.setAttribute('inert', '');\n children.setAttribute('tabindex', '-1');\n\n trapFocusElements.push(children);\n }\n\n currentElement = currentElement.parentElement;\n }\n }\n\n return trapFocusElements;\n}\n\n/**\n * @param {Array} trapFocusElements\n */\nexport function removeTrapFocus(trapFocusElements) {\n for (const focusElement of trapFocusElements) {\n if (!focusElement)\n continue;\n\n focusElement.removeAttribute('inert');\n focusElement.removeAttribute('tabindex'); // TODO: проверять что до этого не было установлено значение (>=0, ...)\n }\n}\n\nexport { clearPhone, formatDate, patternEmail, patternPhone, unformatDate, validateBik, validateInn, validateKpp, validateKs, validateOgrn, validateRs, validateSnils, validateVIN, validDate };\n"],"names":["dateTimeRegex","makeCurrency","val","curr","toNumericFormat","value","lastSeveralYears","lastYears","currentYear","yearsArr","i","dateDiff","date1","date2","years","months","days","datePassed","date","dateToCheck","currentDate","passed","makePlural","iNumber","endings","v1","v2","v3","sEnding","lastDigits","termActivity","turn","difference","differenceYear","differenceMonth","differenceDays","output","patternEmail","formatPhone","phone","phoneDigits","notEmptyObject","obj","k","clearPhone","ISODateRegex","formatDate","str","matches","year","month","day","unformatDate","validateBik","bik","rs","ks","result","validateRs","bikRs","checksum","coefficients","validateKs","error","bikKs","shortGroups","makeCurrencyWithShortGroup","shortGroup","findLast","item","shortToLongCompanyNameRegexes","transformShortCompanyNameToLong","companyName","idx","regexPattern","textToReplace","removeCompanyOkopfFromText","text","pattern","regex","monthsLabels","getZeroBasedMonthLabel","monthNumberZeroBased","genetive","lowerCase","label","prepareDownloadKeyAsLink","access_key","getDownloadPageUrl","type","companyid","scope","downloadPageUrl","tryToBlankWindow","url","transformSizeInBytesToHuman","sizeInBytes","postfix","size","transformNumberToPercentString","valueHundred","parseDatetimeString","dateTimeString","hour","minute","second","tryConvertYMDToDMYRussian","includeTime","dateTime","DMYDate","part","timeString","array","predicate","securityViewText","setTrapFocus","list","trapFocusElements","iterateNodes","trapNode","currentElement","children","node","removeTrapFocus","focusElement"],"mappings":"AAEA,MAAMA,EAAgB,mEAETC,EAAe,CAACC,EAAKC,EAAO,MAAQ,GAAGD,CAAG,IAASC,CAAI,GAE7D,SAASC,EAAgBC,EAAO,CACrC,OAAIA,GAAS,KACJ,IAEF,OAAOA,CAAK,EAAE,eAAe,QAAS,CAC3C,sBAAuB,EACvB,sBAAuB,CAAA,CACxB,CACH,CAEO,SAASC,EAAiBC,EAAW,CAC1C,MAAMC,EAAc,IAAI,KAAK,EAAE,YAAY,EACrCC,EAAW,CAAC,EAElB,QAASC,EAAIH,EAAWG,EAAI,EAAG,EAAEA,EACtBD,EAAA,KAAKD,EAAcE,CAAC,EAGxB,OAAAD,CACT,CAEgB,SAAAE,EAASC,EAAOC,EAAO,CACrC,IAAIC,EAAQD,EAAM,YAAY,EAAID,EAAM,YAAY,EAChDG,EAASD,EAAQ,GAAKD,EAAM,SAAS,EAAID,EAAM,SAAS,EACxDI,EAAOH,EAAM,QAAQ,EAAID,EAAM,QAAQ,E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