{"version":3,"file":"index-CiyKClrF.js","sources":["../../../node_modules/.pnpm/timeago.js@4.0.2/node_modules/timeago.js/esm/lang/en_US.js","../../../node_modules/.pnpm/timeago.js@4.0.2/node_modules/timeago.js/esm/lang/zh_CN.js","../../../node_modules/.pnpm/timeago.js@4.0.2/node_modules/timeago.js/esm/register.js","../../../node_modules/.pnpm/timeago.js@4.0.2/node_modules/timeago.js/esm/utils/date.js","../../../node_modules/.pnpm/timeago.js@4.0.2/node_modules/timeago.js/esm/format.js","../../../node_modules/.pnpm/timeago.js@4.0.2/node_modules/timeago.js/esm/index.js"],"sourcesContent":["var EN_US = ['second', 'minute', 'hour', 'day', 'week', 'month', 'year'];\nexport default function (diff, idx) {\n if (idx === 0)\n return ['just now', 'right now'];\n var unit = EN_US[Math.floor(idx / 2)];\n if (diff > 1)\n unit += 's';\n return [diff + \" \" + unit + \" ago\", \"in \" + diff + \" \" + unit];\n}\n//# sourceMappingURL=en_US.js.map","var ZH_CN = ['秒', '分钟', 'å°æ—¶', '天', '周', '个月', 'å¹´'];\nexport default function (diff, idx) {\n if (idx === 0)\n return ['刚刚', '片刻åŽ'];\n var unit = ZH_CN[~~(idx / 2)];\n return [diff + \" \" + unit + \"\\u524D\", diff + \" \" + unit + \"\\u540E\"];\n}\n//# sourceMappingURL=zh_CN.js.map","/**\n * Created by hustcc on 18/5/20.\n * Contract: i@hust.cc\n */\n/**\n * All supported locales\n */\nvar Locales = {};\n/**\n * register a locale\n * @param locale\n * @param func\n */\nexport var register = function (locale, func) {\n Locales[locale] = func;\n};\n/**\n * get a locale, default is en_US\n * @param locale\n * @returns {*}\n */\nexport var getLocale = function (locale) {\n return Locales[locale] || Locales['en_US'];\n};\n//# sourceMappingURL=register.js.map","/**\n * Created by hustcc on 18/5/20.\n * Contract: i@hust.cc\n */\nvar SEC_ARRAY = [\n 60,\n 60,\n 24,\n 7,\n 365 / 7 / 12,\n 12,\n];\n/**\n * format Date / string / timestamp to timestamp\n * @param input\n * @returns {*}\n */\nexport function toDate(input) {\n if (input instanceof Date)\n return input;\n // @ts-ignore\n if (!isNaN(input) || /^\\d+$/.test(input))\n return new Date(parseInt(input));\n input = (input || '')\n // @ts-ignore\n .trim()\n .replace(/\\.\\d+/, '') // remove milliseconds\n .replace(/-/, '/')\n .replace(/-/, '/')\n .replace(/(\\d)T(\\d)/, '$1 $2')\n .replace(/Z/, ' UTC') // 2017-2-5T3:57:52Z -> 2017-2-5 3:57:52UTC\n .replace(/([+-]\\d\\d):?(\\d\\d)/, ' $1$2'); // -04:00 -> -0400\n return new Date(input);\n}\n/**\n * format the diff second to *** time ago, with setting locale\n * @param diff\n * @param localeFunc\n * @returns\n */\nexport function formatDiff(diff, localeFunc) {\n /**\n * if locale is not exist, use defaultLocale.\n * if defaultLocale is not exist, use build-in `en`.\n * be sure of no error when locale is not exist.\n *\n * If `time in`, then 1\n * If `time ago`, then 0\n */\n var agoIn = diff < 0 ? 1 : 0;\n /**\n * Get absolute value of number (|diff| is non-negative) value of x\n * |diff| = diff if diff is positive\n * |diff| = -diff if diff is negative\n * |0| = 0\n */\n diff = Math.abs(diff);\n /**\n * Time in seconds\n */\n var totalSec = diff;\n /**\n * Unit of time\n */\n var idx = 0;\n for (; diff >= SEC_ARRAY[idx] && idx < SEC_ARRAY.length; idx++) {\n diff /= SEC_ARRAY[idx];\n }\n /**\n * Math.floor() is alternative of ~~\n *\n * The differences and bugs:\n * Math.floor(3.7) -> 4 but ~~3.7 -> 3\n * Math.floor(1559125440000.6) -> 1559125440000 but ~~1559125440000.6 -> 52311552\n *\n * More information about the performance of algebraic:\n * https://www.youtube.com/watch?v=65-RbBwZQdU\n */\n diff = Math.floor(diff);\n idx *= 2;\n if (diff > (idx === 0 ? 9 : 1))\n idx += 1;\n return localeFunc(diff, idx, totalSec)[agoIn].replace('%s', diff.toString());\n}\n/**\n * calculate the diff second between date to be formatted an now date.\n * @param date\n * @param relativeDate\n * @returns {number}\n */\nexport function diffSec(date, relativeDate) {\n var relDate = relativeDate ? toDate(relativeDate) : new Date();\n return (+relDate - +toDate(date)) / 1000;\n}\n/**\n * nextInterval: calculate the next interval time.\n * - diff: the diff sec between now and date to be formatted.\n *\n * What's the meaning?\n * diff = 61 then return 59\n * diff = 3601 (an hour + 1 second), then return 3599\n * make the interval with high performance.\n **/\nexport function nextInterval(diff) {\n var rst = 1, i = 0, d = Math.abs(diff);\n for (; diff >= SEC_ARRAY[i] && i < SEC_ARRAY.length; i++) {\n diff /= SEC_ARRAY[i];\n rst *= SEC_ARRAY[i];\n }\n d = d % rst;\n d = d ? rst - d : rst;\n return Math.ceil(d);\n}\n//# sourceMappingURL=date.js.map","import { formatDiff, diffSec } from './utils/date';\nimport { getLocale } from './register';\n/**\n * format a TDate into string\n * @param date\n * @param locale\n * @param opts\n */\nexport var format = function (date, locale, opts) {\n // diff seconds\n var sec = diffSec(date, opts && opts.relativeDate);\n // format it with locale\n return formatDiff(sec, getLocale(locale));\n};\n//# sourceMappingURL=format.js.map","/**\n * Created by hustcc on 18/5/20.\n * Contract: i@hust.cc\n */\nimport en_US from './lang/en_US';\nimport zh_CN from './lang/zh_CN';\nimport { register } from './register';\nregister('en_US', en_US);\nregister('zh_CN', zh_CN);\nexport { format } from './format';\nexport { render, cancel } from './realtime';\nexport { register };\n//# sourceMappingURL=index.js.map"],"names":["EN_US","en_US","diff","idx","unit","ZH_CN","zh_CN","Locales","register","locale","func","getLocale","SEC_ARRAY","toDate","input","formatDiff","localeFunc","agoIn","totalSec","diffSec","date","relativeDate","relDate","format","opts","sec"],"mappings":"AAAA,IAAIA,EAAQ,CAAC,SAAU,SAAU,OAAQ,MAAO,OAAQ,QAAS,MAAM,EACxD,SAAAC,EAAUC,EAAMC,EAAK,CAChC,GAAIA,IAAQ,EACR,MAAO,CAAC,WAAY,WAAW,EACnC,IAAIC,EAAOJ,EAAM,KAAK,MAAMG,EAAM,CAAC,CAAC,EACpC,OAAID,EAAO,IACPE,GAAQ,KACL,CAACF,EAAO,IAAME,EAAO,OAAQ,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