timered-counter 1.1.1 → 1.2.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"timered-counter-datetime-duration.js","sourceRoot":"","sources":["../../src/timered-counter-datetime-duration.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAG/D;;;;;;;GAOG;AACH,SAAS,YAAY,CAAC,IAAU,EAAE,EAAQ,EAAE,YAA8B;IACxE,MAAM,cAAc,GAAG,uBAAuB,CAAC,YAAY,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC9B,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAE1B,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,MAAM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CAAC;QAE1C,MAAM,0BAA0B,GAAG,GAAG,CACpC,IAAI,CAAC,wBAAwB,EAC7B,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAClB,CAAC;QAEF,OAAO,IAAI,CAAA;;;;;;gBAMC,IAAI,CAAC,KAAK;+BACK,IAAI,CAAC,kBAAkB;iBACrC,IAAI,CAAC,KAAK;kCACO,IAAI,CAAC,sBAAsB;4BACjC,gBAAgB;qBACvB,SAAS;sBACR,UAAU;uBACT,WAAW;sBACZ,UAAU;qBACX,IAAI,CAAC,SAAS;kCACD,IAAI,CAAC,oCAAoC;gCAC3C,IAAI,CAAC,kCAAkC;;oDAEnB,MAAM,CAChD,IAAI,CAAC,KAAK,EACV,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EACnB,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CACf,IAAI,CAAA,cAAc,eAAe,SAAS,EAAE;iBACvC,IAAI,CAAC,qBAAqB,CAC3B,0BAA0B,CAAC,SAAS,CAAC,CACtC;cACD,CACL;;KAEJ,CAAC;IACJ,CAAC;;AA1OM,qCAAM,GAAG,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,4BAA4B,CAAC,AAA3D,CAA4D;AAwBzE;IARC,QAAQ,CAAC;QACR,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,KAAK,CAAC,EAAE;YACjB,IAAI,SAAS,CAAC,KAAK,CAAC;gBAAE,OAAO,KAAK,CAAC;YAEnC,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;KACF,CAAC;+DAGD;AA3BU,8BAA8B;IAD1C,aAAa,CAAC,mCAAmC,CAAC;GACtC,8BAA8B,CA4O1C","sourcesContent":["import { customElement, property } from 'lit/decorators.js';\nimport { html, PropertyValues } from 'lit';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { isArray, isDate, isNullish, isString, map } from 'remeda';\nimport { isValid, toDate, isBefore } from 'date-fns';\nimport { TimeredCounter } from './timered-counter.js';\nimport { AvailableNumberAdapterValueType } from './number-adapter/index.js';\nimport { DurationPartMillisecond, DurationPartType } from './types/duration.js';\nimport { getLocalizedDateTimeFields } from './utils/localized-date-time-fields.js';\nimport { duration, durationObject } from './utils/duration.js';\nimport { iso8601Duration } from './utils/iso8601-duration.js';\nimport { timeredCounterDatetimeStyles } from './styles/timered-counter-datetime-styles.js';\nimport { parseJsonString } from './utils/parse-json-string.js';\nimport { PartsOptions } from './mixins/counter-parts.js';\n\n/**\n * 根据最小精度对 from 进行优化. 避免频繁更新.\n *\n * 1. from 先会被减小到 minPrecisionMs 的整数倍.\n * 2. 如果 from 和 to 的差值不是 minPrecisionMs 的整数倍, 则再加上/减去一个 minPrecisionMs 的值. 加上或减去取决于 from 和 to 的谁更大.\n * 这相当于将 from 中小于 minPrecisionMs 的值舍入到 minPrecisionMs 的整数倍.\n * 3. 加上 to 余 minPrecisionMs 的值, 保证 from 与 to 的差值是 minPrecisionMs 的整数倍.\n */\nfunction optimizeFrom(from: Date, to: Date, minPrecision: DurationPartType) {\n const minPrecisionMs = DurationPartMillisecond[minPrecision];\n const fromTS = from.getTime();\n const toTS = to.getTime();\n\n const base = fromTS - (fromTS % minPrecisionMs);\n const offset = Math.abs(toTS - fromTS) % minPrecisionMs;\n\n return (\n base +\n (offset > 0 ? (fromTS < toTS ? -1 : 1) * minPrecisionMs : 0) +\n // 加上 deadlineDate 的余数, 消除精度误差.\n (toTS % minPrecisionMs)\n );\n}\n\nfunction toDurationInMilliseconds(value: any, minPrecision: DurationPartType) {\n if (isString(value)) value = parseJsonString(value);\n\n if (!isArray(value)) value = [value, value];\n\n const result = [\n isDate(value[0]) ? value[0] : toDate(value[0]),\n isDate(value[1]) ? value[1] : toDate(value[1]),\n ] as const;\n\n if (!isValid(result[0]) || !isValid(result[1])) {\n throw new Error(`value ${value[0]} or ${value[1]} is not a valid date.`);\n }\n\n const durationInMilliseconds = Math.abs(\n result[1].getTime() - optimizeFrom(result[0], result[1], minPrecision),\n );\n\n return {\n durationInMilliseconds,\n from: result[0],\n to: result[1],\n };\n}\n\n@customElement('timered-counter-datetime-duration')\nexport class TimeredCounterDatetimeDuration extends TimeredCounter {\n static styles = [...TimeredCounter.styles, timeredCounterDatetimeStyles];\n\n private __precision: DurationPartType | [DurationPartType, DurationPartType] =\n [DurationPartType.Second, DurationPartType.Day];\n\n /**\n * 计数器显示的精度.\n * 1. 当为单个值时, 表示最小精度.\n * 2. 当为数组时, 第一个值表示最小精度, 第二个值表示最大精度.\n *\n * @default [DurationPartType.Second, DurationPartType.Day]\n *\n * @example DurationPartType.Second 显示从年份到秒数的所有精度.\n * @example [DurationPartType.Second, DurationPartType.Day] 显示从天数到秒数的所有精度.\n * @example [DurationPartType.Millisecond, DurationPartType.Year] 显示从年份到毫秒的所有精度.\n */\n @property({\n reflect: true,\n converter: value => {\n if (isNullish(value)) return value;\n\n return parseJsonString(value);\n },\n })\n get precision() {\n return this.__precision;\n }\n\n set precision(value: any) {\n if (isString(value)) value = parseJsonString(value);\n\n this.__precision = value;\n\n /**\n * `precision` 相关属性的更新需要立即更新, 以便于在 `value`, `initialValue` 等属性的 setter 中使用.\n */\n this.__minPrecision = isArray(this.__precision)\n ? this.__precision[0]\n : this.__precision;\n this.__maxPrecision = isArray(this.__precision)\n ? this.__precision[1]\n : this.__precision;\n\n this.__availableDurationParts = Object.values(DurationPartType)\n .reverse()\n .map(type => {\n const minPrecisionBreakpoint =\n DurationPartMillisecond[this.__minPrecision];\n const maxPrecisionBreakpoint =\n DurationPartMillisecond[this.__maxPrecision];\n const partMilliseconds = DurationPartMillisecond[type];\n return {\n type,\n available:\n partMilliseconds >= minPrecisionBreakpoint &&\n partMilliseconds <= maxPrecisionBreakpoint,\n };\n })\n .filter(part => part.available);\n }\n\n get value() {\n return super.value;\n }\n\n /**\n * 通过 property 设置 value 时, 支持 Date 类型.\n */\n set value(value: any) {\n const { from, to, durationInMilliseconds } = toDurationInMilliseconds(\n value,\n this.__minPrecision,\n );\n\n this.__from = from;\n this.__to = to;\n super.value = durationInMilliseconds;\n }\n\n private __initialValuePlain: any = null;\n\n get initialValue() {\n return super.initialValue;\n }\n\n /**\n * 同 value\n */\n set initialValue(value: any) {\n this.__initialValuePlain = value;\n\n const { durationInMilliseconds } = toDurationInMilliseconds(\n value,\n this.__minPrecision,\n );\n super.initialValue = durationInMilliseconds;\n }\n\n private __partsOptions: Partial<PartsOptions> | null = null;\n\n get partsOptions(): Partial<PartsOptions> {\n return super.partsOptions;\n }\n\n set partsOptions(value: Partial<PartsOptions>) {\n this.__partsOptions = value;\n super.partsOptions = {\n minPlaces: [2, undefined],\n ...this.__partsOptions,\n };\n }\n\n private __from: Date = new Date();\n\n private __to: Date = new Date();\n\n private __minPrecision: DurationPartType = DurationPartType.Second;\n\n private __maxPrecision: DurationPartType = DurationPartType.Day;\n\n private __availableDurationParts = [] as {\n type: DurationPartType;\n available: boolean;\n }[];\n\n private __dateTimeFieldLabels = {} as Record<DurationPartType, string>;\n\n override sampleSplit(\n samples: AvailableNumberAdapterValueType[],\n ): AvailableNumberAdapterValueType[][] {\n const availableDurationPartTypes = map(\n this.__availableDurationParts,\n part => part.type,\n );\n\n const tempParts = availableDurationPartTypes.map(() => [] as number[]);\n for (const n of samples) {\n const num = this.numberAdapter.toNumber(n);\n /**\n * 计算并保存每个在 {@link precision} 范围内的时间部分的值\n */\n const availablePartValues = duration(\n new Date(Math.min(num, 0)),\n new Date(Math.max(num, 0)),\n availableDurationPartTypes,\n );\n availablePartValues.forEach((value, i) => tempParts[i].push(value));\n }\n\n return tempParts;\n }\n\n override generateAriaLabel(): string {\n return iso8601Duration(\n durationObject(\n isBefore(this.__from, this.__to) ? this.__from : this.__to,\n isBefore(this.__from, this.__to) ? this.__to : this.__from,\n map(this.__availableDurationParts, part => part.type),\n ),\n );\n }\n\n override connectedCallback() {\n this.role = 'timer';\n\n /**\n * TimeredCounterDatetimeDuration 将 `minPlaces` 默认设置为 `[2]`. 实例化时需要手动触发 `partsOptions` 的 setter.\n */\n this.partsOptions = this.__partsOptions ?? {};\n\n this.initialValue = this.__initialValuePlain;\n\n /**\n * 类似上方的 partsOptions, precision 也需要在初始化时手动触发 setter. 以此确保 __minPrecision, __maxPrecision, __availableDurationParts 有值.\n */\n this.precision = this.__precision;\n\n super.connectedCallback();\n }\n\n override willUpdate(_changedProperties: PropertyValues) {\n super.willUpdate(_changedProperties);\n\n if (_changedProperties.has('locale')) {\n this.__dateTimeFieldLabels = getLocalizedDateTimeFields(\n this.localeInstance,\n );\n }\n }\n\n override render() {\n const cellStyles = this.extractCellStyles();\n const digitStyles = this.extractDigitStyles();\n const partStyles = this.extractPartStyles();\n\n const animationOptions = this.extractAnimationOptions();\n const keyframes = this.extractKeyframes();\n\n const availableDurationPartTypes = map(\n this.__availableDurationParts,\n part => part.type,\n );\n\n return html`\n <timered-counter-roller\n class=\"timered-counter timered-counter-datetime-duration\"\n exportparts=\"group, part, digit, cell, prefix, suffix, part-suffix\"\n part=\"group\"\n aria-hidden=\"true\"\n color=${this.color}\n .parentContainerRect=${this.partsContainerRect}\n .parts=${this.parts}\n .partPreprocessDataList=${this.partPreprocessDataList}\n .animationOptions=${animationOptions}\n .keyframes=${keyframes}\n .cellStyles=${cellStyles}\n .digitStyles=${digitStyles}\n .partStyles=${partStyles}\n .direction=${this.direction}\n @roller-animation-start=${this.dispatchTimeredCounterAnimationStart}\n @roller-animation-end=${this.dispatchTimeredCounterAnimationEnd}\n ><slot name=\"prefix\" slot=\"prefix\"></slot\n ><slot name=\"suffix\" slot=\"suffix\"></slot>${repeat(\n this.parts,\n (_, index) => index,\n (_, partIndex) =>\n html`<span slot=${`part-suffix-${partIndex}`} class=\"duration-unit\"\n >${this.__dateTimeFieldLabels[\n availableDurationPartTypes[partIndex]\n ]}</span\n >`,\n )}\n </timered-counter-roller>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"timered-counter-datetime-duration.js","sourceRoot":"","sources":["../../src/timered-counter-datetime-duration.ts"],"names":[],"m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CAAC,SAAS;kCACD,IAAI,CAAC,oCAAoC;gCAC3C,IAAI,CAAC,kCAAkC;;oDAEnB,MAAM,CAChD,IAAI,CAAC,KAAK,EACV,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,EACnB,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CACf,IAAI,CAAA,cAAc,eAAe,SAAS,EAAE;iBACvC,IAAI,CAAC,qBAAqB,CAC3B,0BAA0B,CAAC,SAAS,CAAC,CACtC;cACD,CACL;;KAEJ,CAAC;IACJ,CAAC;;AAnPM,qCAAM,GAAG,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,4BAA4B,CAAC,AAA3D,CAA4D;AAwBzE;IARC,QAAQ,CAAC;QACR,OAAO,EAAE,IAAI;QACb,SAAS,EAAE,KAAK,CAAC,EAAE;YACjB,IAAI,SAAS,CAAC,KAAK,CAAC;gBAAE,OAAO,KAAK,CAAC;YAEnC,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;KACF,CAAC;+DAGD;AA3BU,8BAA8B;IAD1C,aAAa,CAAC,mCAAmC,CAAC;GACtC,8BAA8B,CAqP1C","sourcesContent":["import { customElement, property } from 'lit/decorators.js';\nimport { html, PropertyValues } from 'lit';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { isArray, isDate, isNullish, isString, map } from 'remeda';\nimport { isValid, toDate, isBefore } from 'date-fns';\nimport { TimeredCounter } from './timered-counter.js';\nimport { AvailableNumberAdapterValueType } from './number-adapter/index.js';\nimport { DurationPartMillisecond, DurationPartType } from './types/duration.js';\nimport { getLocalizedDateTimeFields } from './utils/localized-date-time-fields.js';\nimport { duration, durationObject } from './utils/duration.js';\nimport { iso8601Duration } from './utils/iso8601-duration.js';\nimport { timeredCounterDatetimeStyles } from './styles/timered-counter-datetime-styles.js';\nimport { parseJsonString } from './utils/parse-json-string.js';\nimport { PartsOptions } from './mixins/counter-parts.js';\n\n/**\n * 根据最小精度对 from 进行优化. 避免频繁更新.\n *\n * 1. from 先会被减小到 minPrecisionMs 的整数倍.\n * 2. 加上 to 余 minPrecisionMs 的值, 保证 from 与 to 的差值是 minPrecisionMs 的整数倍.\n */\nfunction optimizeFrom(from: Date, to: Date, minPrecision: DurationPartType) {\n const minPrecisionMs = DurationPartMillisecond[minPrecision];\n const fromTS = from.getTime();\n const toTS = to.getTime();\n\n const base = fromTS - (fromTS % minPrecisionMs);\n\n return base + (toTS % minPrecisionMs);\n}\n\nfunction toDurationInMilliseconds(value: any, minPrecision: DurationPartType) {\n if (isString(value)) value = parseJsonString(value);\n\n if (!isArray(value)) value = [value, value];\n\n const result = [\n isDate(value[0]) ? value[0] : toDate(value[0]),\n isDate(value[1]) ? value[1] : toDate(value[1]),\n ] as const;\n\n if (!isValid(result[0]) || !isValid(result[1])) {\n throw new Error(`value ${value[0]} or ${value[1]} is not a valid date.`);\n }\n\n const durationInMilliseconds = Math.abs(\n result[1].getTime() - optimizeFrom(result[0], result[1], minPrecision),\n );\n\n return {\n durationInMilliseconds,\n from: result[0],\n to: result[1],\n };\n}\n\n@customElement('timered-counter-datetime-duration')\nexport class TimeredCounterDatetimeDuration extends TimeredCounter {\n static styles = [...TimeredCounter.styles, timeredCounterDatetimeStyles];\n\n private __precision: DurationPartType | [DurationPartType, DurationPartType] =\n [DurationPartType.Second, DurationPartType.Day];\n\n /**\n * 计数器显示的精度.\n * 1. 当为单个值时, 仅显示该精度的时间部分.\n * 2. 当为数组时, 第一个值表示最小精度, 第二个值表示最大精度.\n *\n * @default [DurationPartType.Second, DurationPartType.Day]\n *\n * @example DurationPartType.Second 显示从年份到秒数的所有精度.\n * @example [DurationPartType.Second, DurationPartType.Day] 显示从天数到秒数的所有精度.\n * @example [DurationPartType.Millisecond, DurationPartType.Year] 显示从年份到毫秒的所有精度.\n */\n @property({\n reflect: true,\n converter: value => {\n if (isNullish(value)) return value;\n\n return parseJsonString(value);\n },\n })\n get precision() {\n return this.__precision;\n }\n\n set precision(value: any) {\n if (isString(value)) value = parseJsonString(value);\n\n this.__precision = value;\n\n /**\n * `precision` 相关属性的更新需要立即更新, 以便于在 `value`, `initialValue` 等属性的 setter 中使用.\n */\n this.__minPrecision = isArray(this.__precision)\n ? this.__precision[0]\n : this.__precision;\n this.__maxPrecision = isArray(this.__precision)\n ? this.__precision[1]\n : this.__precision;\n\n this.__availableDurationParts = Object.values(DurationPartType)\n .reverse()\n .map(type => {\n const minPrecisionBreakpoint =\n DurationPartMillisecond[this.__minPrecision];\n const maxPrecisionBreakpoint =\n DurationPartMillisecond[this.__maxPrecision];\n const partMilliseconds = DurationPartMillisecond[type];\n return {\n type,\n available:\n partMilliseconds >= minPrecisionBreakpoint &&\n partMilliseconds <= maxPrecisionBreakpoint,\n };\n })\n .filter(part => part.available);\n }\n\n get value() {\n return super.value;\n }\n\n /**\n * 通过 property 设置 value 时, 支持 Date 类型.\n */\n set value(value: any) {\n const { from, to, durationInMilliseconds } = toDurationInMilliseconds(\n value,\n this.__minPrecision,\n );\n\n this.__from = from;\n this.__to = to;\n super.value = durationInMilliseconds;\n }\n\n private __initialValuePlain: any = null;\n\n get initialValue() {\n return super.initialValue;\n }\n\n /**\n * 同 value\n */\n set initialValue(value: any) {\n this.__initialValuePlain = value;\n\n const { durationInMilliseconds } = toDurationInMilliseconds(\n value,\n this.__minPrecision,\n );\n super.initialValue = durationInMilliseconds;\n }\n\n private __partsOptions: Partial<PartsOptions> | null = null;\n\n get partsOptions(): Partial<PartsOptions> {\n return super.partsOptions;\n }\n\n set partsOptions(value: Partial<PartsOptions>) {\n this.__partsOptions = value;\n super.partsOptions = {\n minPlaces: [2, undefined],\n ...this.__partsOptions,\n };\n }\n\n private __from: Date = new Date();\n\n private __to: Date = new Date();\n\n private __minPrecision: DurationPartType = DurationPartType.Second;\n\n private __maxPrecision: DurationPartType = DurationPartType.Day;\n\n private __availableDurationParts = [] as {\n type: DurationPartType;\n available: boolean;\n }[];\n\n private __dateTimeFieldLabels = {} as Record<DurationPartType, string>;\n\n override sampleSplit(\n samples: AvailableNumberAdapterValueType[],\n ): AvailableNumberAdapterValueType[][] {\n const availableDurationPartTypes = map(\n this.__availableDurationParts,\n part => part.type,\n );\n\n const tempParts = availableDurationPartTypes.map(() => [] as number[]);\n for (const n of samples) {\n const num = this.numberAdapter.toNumber(n);\n /**\n * 计算并保存每个在 {@link precision} 范围内的时间部分的值\n */\n const availablePartValues = duration(\n new Date(Math.min(num, 0)),\n new Date(Math.max(num, 0)),\n availableDurationPartTypes,\n );\n availablePartValues.forEach((value, i) => tempParts[i].push(value));\n }\n\n return tempParts;\n }\n\n override generateAriaLabel(): string {\n return iso8601Duration(\n durationObject(\n isBefore(this.__from, this.__to) ? this.__from : this.__to,\n isBefore(this.__from, this.__to) ? this.__to : this.__from,\n map(this.__availableDurationParts, part => part.type),\n ),\n );\n }\n\n override connectedCallback() {\n this.role = 'timer';\n\n /**\n * TimeredCounterDatetimeDuration 将 `minPlaces` 默认设置为 `[2]`. 实例化时需要手动触发 `partsOptions` 的 setter.\n */\n this.partsOptions = this.__partsOptions ?? {};\n\n this.initialValue = this.__initialValuePlain;\n\n /**\n * 类似上方的 partsOptions, precision 也需要在初始化时手动触发 setter. 以此确保 __minPrecision, __maxPrecision, __availableDurationParts 有值.\n */\n this.precision = this.__precision;\n\n super.connectedCallback();\n }\n\n override shouldRebuildParts(\n changedProperties: PropertyValues<this>,\n ): boolean {\n return (\n super.shouldRebuildParts(changedProperties) ||\n changedProperties.has('precision')\n );\n }\n\n override willUpdate(_changedProperties: PropertyValues) {\n super.willUpdate(_changedProperties);\n\n if (_changedProperties.has('locale')) {\n this.__dateTimeFieldLabels = getLocalizedDateTimeFields(\n this.localeInstance,\n );\n }\n }\n\n override render() {\n const cellStyles = this.extractCellStyles();\n const digitStyles = this.extractDigitStyles();\n const partStyles = this.extractPartStyles();\n\n const animationOptions = this.extractAnimationOptions();\n const keyframes = this.extractKeyframes();\n\n const availableDurationPartTypes = map(\n this.__availableDurationParts,\n part => part.type,\n );\n\n return html`\n <timered-counter-roller\n class=\"timered-counter timered-counter-datetime-duration\"\n exportparts=\"group, part, digit, cell, prefix, suffix, part-suffix\"\n part=\"group\"\n aria-hidden=\"true\"\n color=${this.color}\n .parentContainerRect=${this.partsContainerRect}\n .parts=${this.parts}\n .partPreprocessDataList=${this.partPreprocessDataList}\n .animationOptions=${animationOptions}\n .keyframes=${keyframes}\n .cellStyles=${cellStyles}\n .digitStyles=${digitStyles}\n .partStyles=${partStyles}\n .direction=${this.direction}\n @roller-animation-start=${this.dispatchTimeredCounterAnimationStart}\n @roller-animation-end=${this.dispatchTimeredCounterAnimationEnd}\n ><slot name=\"prefix\" slot=\"prefix\"></slot\n ><slot name=\"suffix\" slot=\"suffix\"></slot>${repeat(\n this.parts,\n (_, index) => index,\n (_, partIndex) =>\n html`<span slot=${`part-suffix-${partIndex}`} class=\"duration-unit\"\n >${this.__dateTimeFieldLabels[\n availableDurationPartTypes[partIndex]\n ]}</span\n >`,\n )}\n </timered-counter-roller>\n `;\n }\n}\n"]}
@@ -29,6 +29,7 @@ export const rollerStyles = css `
29
29
 
30
30
  .roller-part .roller-part__wrapper {
31
31
  display: inline-block;
32
+ text-align: center;
32
33
  }
33
34
 
34
35
  .roller-part .roller-part__suffix {
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../src/transitions/roller/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmC9B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDnC,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const rollerStyles = css`\n :host {\n display: inline-flex;\n overflow: hidden;\n\n /**\n inline-block 和 overflow-hidden 同时存在会使得基线为下边缘. 手动设置 align-bottom 以修正这个问题.\n @see https://stackoverflow.com/questions/22421782/css-overflow-hidden-increases-height-of-container\n @see https://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align\n */\n vertical-align: bottom;\n }\n\n .counter-parts {\n display: inline-flex;\n flex: 1 1 auto;\n }\n\n .roller-part {\n display: inline-flex;\n white-space: nowrap;\n }\n\n .roller__prefix,\n .roller__suffix {\n flex: none;\n }\n\n .roller-part .roller-part__wrapper {\n display: inline-block;\n }\n\n .roller-part .roller-part__suffix {\n display: inline-block;\n }\n`;\n\nexport const rollerDigitStyles = css`\n .roller-part-digit {\n position: relative;\n display: inline-block;\n }\n\n .placeholder {\n visibility: hidden;\n display: inline-block;\n }\n\n .roll-list {\n position: absolute;\n left: 0;\n display: inline-flex;\n width: 100%;\n flex-direction: column;\n align-items: center;\n }\n\n .roll-list.roll-list__up {\n top: 0;\n }\n\n .roll-list.roll-list__down {\n bottom: 0;\n }\n\n .roll-list__shadow {\n visibility: hidden;\n position: absolute;\n left: 0;\n top: 0;\n z-index: -10;\n display: inline-flex;\n flex-direction: column;\n white-space: nowrap;\n }\n\n .roll-item {\n display: inline-block;\n width: 100%;\n }\n\n .roll-item.roll-item__head {\n position: absolute;\n top: 100%;\n }\n\n .roll-item.roll-item__tail {\n position: absolute;\n bottom: 100%;\n }\n`;\n"]}
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../src/transitions/roller/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoC9B,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqDnC,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const rollerStyles = css`\n :host {\n display: inline-flex;\n overflow: hidden;\n\n /**\n inline-block 和 overflow-hidden 同时存在会使得基线为下边缘. 手动设置 align-bottom 以修正这个问题.\n @see https://stackoverflow.com/questions/22421782/css-overflow-hidden-increases-height-of-container\n @see https://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align\n */\n vertical-align: bottom;\n }\n\n .counter-parts {\n display: inline-flex;\n flex: 1 1 auto;\n }\n\n .roller-part {\n display: inline-flex;\n white-space: nowrap;\n }\n\n .roller__prefix,\n .roller__suffix {\n flex: none;\n }\n\n .roller-part .roller-part__wrapper {\n display: inline-block;\n text-align: center;\n }\n\n .roller-part .roller-part__suffix {\n display: inline-block;\n }\n`;\n\nexport const rollerDigitStyles = css`\n .roller-part-digit {\n position: relative;\n display: inline-block;\n }\n\n .placeholder {\n visibility: hidden;\n display: inline-block;\n }\n\n .roll-list {\n position: absolute;\n left: 0;\n display: inline-flex;\n width: 100%;\n flex-direction: column;\n align-items: center;\n }\n\n .roll-list.roll-list__up {\n top: 0;\n }\n\n .roll-list.roll-list__down {\n bottom: 0;\n }\n\n .roll-list__shadow {\n visibility: hidden;\n position: absolute;\n left: 0;\n top: 0;\n z-index: -10;\n display: inline-flex;\n flex-direction: column;\n white-space: nowrap;\n }\n\n .roll-item {\n display: inline-block;\n width: 100%;\n }\n\n .roll-item.roll-item__head {\n position: absolute;\n top: 100%;\n }\n\n .roll-item.roll-item__tail {\n position: absolute;\n bottom: 100%;\n }\n`;\n"]}
@@ -1,9 +1,9 @@
1
1
  import { setCustomElementsManifest, } from '@storybook/web-components';
2
2
  import { isArray, isDate, range } from 'remeda';
3
- import { addDays, addHours, addMinutes, addMonths, addSeconds, addYears, differenceInMilliseconds, } from 'date-fns';
3
+ import { addDays, addHours, addMinutes, addMonths, addSeconds, addMilliseconds, addYears, differenceInMilliseconds, } from 'date-fns';
4
4
  import { expect } from '@storybook/test';
5
5
  import customElementsManifest from '../../custom-elements.json' with { type: 'json' };
6
- import { setNumberAdapter, } from '../../src/index.js';
6
+ import { DurationPartType, setNumberAdapter, } from '../../src/index.js';
7
7
  import { valueChange } from '../story-parts/value-change.js';
8
8
  import { datetimePrecision } from '../story-parts/datetime-precision.js';
9
9
  import { datetimeLocale } from '../story-parts/datetime-locale.js';
@@ -44,17 +44,20 @@ export const Basic = {
44
44
  animationOptions: {
45
45
  duration: 100,
46
46
  },
47
+ precision: [DurationPartType.Millisecond, DurationPartType.Day],
47
48
  },
48
49
  async play(context) {
49
50
  const { canvasElement, step } = context;
50
51
  const counter = canvasElement.querySelector('.test-target');
52
+ const date = new Date('2025-06-10T09:43:36Z');
51
53
  const list = [
52
- ...range(0, 2).map(v => [new Date(), addSeconds(new Date(), v)]),
53
- ...range(0, 2).map(v => [new Date(), addMinutes(new Date(), v)]),
54
- ...range(0, 2).map(v => [new Date(), addHours(new Date(), v)]),
55
- ...range(0, 2).map(v => [new Date(), addDays(new Date(), v)]),
56
- ...range(0, 2).map(v => [new Date(), addMonths(new Date(), v)]),
57
- ...range(0, 2).map(v => [new Date(), addYears(new Date(), v)]),
54
+ ...range(0, 2).map(v => [date, addMilliseconds(date, v)]),
55
+ ...range(0, 2).map(v => [date, addSeconds(date, v)]),
56
+ ...range(0, 2).map(v => [date, addMinutes(date, v)]),
57
+ ...range(0, 2).map(v => [date, addHours(date, v)]),
58
+ ...range(0, 2).map(v => [date, addDays(date, v)]),
59
+ ...range(0, 2).map(v => [date, addMonths(date, v)]),
60
+ ...range(0, 2).map(v => [date, addYears(date, v)]),
58
61
  ];
59
62
  await step('Testing with attribute', async () => {
60
63
  await valueChange(context, { counter, list, setBy: setByAttr, equal });
@@ -1 +1 @@
1
- {"version":3,"file":"index.stories.js","sourceRoot":"","sources":["../../../stories/timered-counter-datetime-duration/index.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,GAE1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,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{\n Meta,\n setCustomElementsManifest,\n StoryObj,\n} from '@storybook/web-components';\nimport { isArray, isDate, range } from 'remeda';\nimport {\n addDays,\n addHours,\n addMinutes,\n addMonths,\n addSeconds,\n addYears,\n differenceInMilliseconds,\n} from 'date-fns';\nimport { expect } from '@storybook/test';\nimport customElementsManifest from '../../custom-elements.json' with { type: 'json' };\nimport {\n setNumberAdapter,\n type TimeredCounter,\n TimeredCounterDatetimeDuration,\n} from '../../src/index.js';\nimport { valueChange } from '../story-parts/value-change.js';\nimport { datetimePrecision } from '../story-parts/datetime-precision.js';\nimport { datetimeLocale } from '../story-parts/datetime-locale.js';\n\nsetCustomElementsManifest(customElementsManifest);\n\nfunction setByAttr(\n element: TimeredCounter,\n attr: string,\n value: Date[] | string,\n) {\n if (isArray(value)) {\n if (isDate(value[0]) && isDate(value[1])) {\n element.setAttribute(\n attr,\n JSON.stringify((value as Date[]).map(date => date.getTime())),\n );\n }\n } else {\n element.setAttribute(attr, value);\n }\n}\n\nfunction setByProp(element: TimeredCounter, prop: string, value: any) {\n // @ts-ignore\n element[prop] = value;\n}\n\nfunction equal(counter: TimeredCounter, a: any, b: Date[]) {\n const na = counter.numberAdapter;\n return expect(na.toString(a)).toBe(\n na.toString(na.create(differenceInMilliseconds(b[1], b[0]))),\n );\n}\n\nconst meta: Meta = {\n title: 'TimeredCounterDatetimeDuration',\n component: 'timered-counter-datetime-duration',\n tags: ['autodocs', 'timered-counter-datetime-duration'],\n parameters: {\n controls: { expanded: true },\n },\n beforeEach: () => {\n setNumberAdapter('number');\n },\n};\nexport default meta;\n\nexport const Basic: StoryObj<TimeredCounterDatetimeDuration> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounterDatetimeDuration;\n\n const list = [\n ...range(0, 2).map(v => [new Date(), addSeconds(new Date(), v)]),\n ...range(0, 2).map(v => [new Date(), addMinutes(new Date(), v)]),\n ...range(0, 2).map(v => [new Date(), addHours(new Date(), v)]),\n ...range(0, 2).map(v => [new Date(), addDays(new Date(), v)]),\n ...range(0, 2).map(v => [new Date(), addMonths(new Date(), v)]),\n ...range(0, 2).map(v => [new Date(), addYears(new Date(), v)]),\n ];\n\n await step('Testing with attribute', async () => {\n await valueChange(context, { counter, list, setBy: setByAttr, equal });\n });\n\n await step('Testing with property', async () => {\n await valueChange(context, { counter, list, setBy: setByProp, equal });\n });\n },\n};\n\nexport const Precision: StoryObj<TimeredCounterDatetimeDuration> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounterDatetimeDuration;\n\n await step('Testing with attribute', async () =>\n datetimePrecision(context, { counter, setBy: setByAttr, equal }),\n );\n await step('Testing with property', async () =>\n datetimePrecision(context, { counter, setBy: setByProp, equal }),\n );\n },\n};\n\nexport const Locale: StoryObj<TimeredCounterDatetimeDuration> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounterDatetimeDuration;\n\n await step('Testing with attribute', () =>\n datetimeLocale(context, { counter, setBy: setByAttr, equal }),\n );\n await step('Testing with property', () =>\n datetimeLocale(context, { counter, setBy: setByProp, equal }),\n );\n },\n};\n"]}
1
+ {"version":3,"file":"index.stories.js","sourceRoot":"","sources":["../../../stories/timered-counter-datetime-duration/index.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,yBAAyB,GAE1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EACL,OAAO,EACP,QAAQ,EACR,UAAU,EACV,SAAS,EACT,UAAU,EACV,eAAe,EACf,QAAQ,EACR,wBAAwB,GAC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,CAC9D,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import {\n Meta,\n setCustomElementsManifest,\n StoryObj,\n} from '@storybook/web-components';\nimport { isArray, isDate, range } from 'remeda';\nimport {\n addDays,\n addHours,\n addMinutes,\n addMonths,\n addSeconds,\n addMilliseconds,\n addYears,\n differenceInMilliseconds,\n} from 'date-fns';\nimport { expect } from '@storybook/test';\nimport customElementsManifest from '../../custom-elements.json' with { type: 'json' };\nimport {\n DurationPartType,\n setNumberAdapter,\n type TimeredCounter,\n TimeredCounterDatetimeDuration,\n} from '../../src/index.js';\nimport { valueChange } from '../story-parts/value-change.js';\nimport { datetimePrecision } from '../story-parts/datetime-precision.js';\nimport { datetimeLocale } from '../story-parts/datetime-locale.js';\n\nsetCustomElementsManifest(customElementsManifest);\n\nfunction setByAttr(\n element: TimeredCounter,\n attr: string,\n value: Date[] | string,\n) {\n if (isArray(value)) {\n if (isDate(value[0]) && isDate(value[1])) {\n element.setAttribute(\n attr,\n JSON.stringify((value as Date[]).map(date => date.getTime())),\n );\n }\n } else {\n element.setAttribute(attr, value);\n }\n}\n\nfunction setByProp(element: TimeredCounter, prop: string, value: any) {\n // @ts-ignore\n element[prop] = value;\n}\n\nfunction equal(counter: TimeredCounter, a: any, b: Date[]) {\n const na = counter.numberAdapter;\n return expect(na.toString(a)).toBe(\n na.toString(na.create(differenceInMilliseconds(b[1], b[0]))),\n );\n}\n\nconst meta: Meta = {\n title: 'TimeredCounterDatetimeDuration',\n component: 'timered-counter-datetime-duration',\n tags: ['autodocs', 'timered-counter-datetime-duration'],\n parameters: {\n controls: { expanded: true },\n },\n beforeEach: () => {\n setNumberAdapter('number');\n },\n};\nexport default meta;\n\nexport const Basic: StoryObj<TimeredCounterDatetimeDuration> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n precision: [DurationPartType.Millisecond, DurationPartType.Day],\n },\n async play(context) {\n const { canvasElement, step } = context;\n\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounterDatetimeDuration;\n\n const date = new Date('2025-06-10T09:43:36Z');\n const list = [\n ...range(0, 2).map(v => [date, addMilliseconds(date, v)]),\n ...range(0, 2).map(v => [date, addSeconds(date, v)]),\n ...range(0, 2).map(v => [date, addMinutes(date, v)]),\n ...range(0, 2).map(v => [date, addHours(date, v)]),\n ...range(0, 2).map(v => [date, addDays(date, v)]),\n ...range(0, 2).map(v => [date, addMonths(date, v)]),\n ...range(0, 2).map(v => [date, addYears(date, v)]),\n ];\n\n await step('Testing with attribute', async () => {\n await valueChange(context, { counter, list, setBy: setByAttr, equal });\n });\n\n await step('Testing with property', async () => {\n await valueChange(context, { counter, list, setBy: setByProp, equal });\n });\n },\n};\n\nexport const Precision: StoryObj<TimeredCounterDatetimeDuration> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounterDatetimeDuration;\n\n await step('Testing with attribute', async () =>\n datetimePrecision(context, { counter, setBy: setByAttr, equal }),\n );\n await step('Testing with property', async () =>\n datetimePrecision(context, { counter, setBy: setByProp, equal }),\n );\n },\n};\n\nexport const Locale: StoryObj<TimeredCounterDatetimeDuration> = {\n args: {\n className: 'test-target',\n animationOptions: {\n duration: 100,\n },\n },\n async play(context) {\n const { canvasElement, step } = context;\n\n const counter = canvasElement.querySelector(\n '.test-target',\n ) as TimeredCounterDatetimeDuration;\n\n await step('Testing with attribute', () =>\n datetimeLocale(context, { counter, setBy: setByAttr, equal }),\n );\n await step('Testing with property', () =>\n datetimeLocale(context, { counter, setBy: setByProp, equal }),\n );\n },\n};\n"]}
@@ -15,7 +15,7 @@ const i=globalThis,s=i.ShadowRoot&&(void 0===i.ShadyCSS||i.ShadyCSS.nativeShadow
15
15
  * Copyright 2017 Google LLC
16
16
  * SPDX-License-Identifier: BSD-3-Clause
17
17
  */
18
- const w=globalThis,x=w.trustedTypes,E=x?x.createPolicy("lit-html",{createHTML:t=>t}):void 0,O="$lit$",C=`lit$${Math.random().toFixed(9).slice(2)}$`,P="?"+C,D=`<${P}>`,T=document,M=()=>T.createComment(""),N=t=>null===t||"object"!=typeof t&&"function"!=typeof t,k=Array.isArray,R="[ \t\n\f\r]",U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,I=/-->/g,L=/>/g,V=RegExp(`>|${R}(?:([^\\s"'>=/]+)(${R}*=${R}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,H=/"/g,B=/^(?:script|style|textarea|title)$/i,z=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),F=Symbol.for("lit-noChange"),Y=Symbol.for("lit-nothing"),W=new WeakMap,q=T.createTreeWalker(T,129);function Q(t,e){if(!k(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==E?E.createHTML(e):e}class K{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,n=0;const o=t.length-1,a=this.parts,[l,c]=((t,e)=>{const i=t.length-1,s=[];let r,n=2===e?"<svg>":3===e?"<math>":"",o=U;for(let e=0;e<i;e++){const i=t[e];let a,l,c=-1,h=0;for(;h<i.length&&(o.lastIndex=h,l=o.exec(i),null!==l);)h=o.lastIndex,o===U?"!--"===l[1]?o=I:void 0!==l[1]?o=L:void 0!==l[2]?(B.test(l[2])&&(r=RegExp("</"+l[2],"g")),o=V):void 0!==l[3]&&(o=V):o===V?">"===l[0]?(o=r??U,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?V:'"'===l[3]?H:j):o===H||o===j?o=V:o===I||o===L?o=U:(o=V,r=void 0);const u=o===V&&t[e+1].startsWith("/>")?" ":"";n+=o===U?i+D:c>=0?(s.push(a),i.slice(0,c)+O+i.slice(c)+C+u):i+C+(-2===c?e:u)}return[Q(t,n+(t[i]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),s]})(t,e);if(this.el=K.createElement(l,i),q.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(s=q.nextNode())&&a.length<o;){if(1===s.nodeType){if(s.hasAttributes())for(const t of s.getAttributeNames())if(t.endsWith(O)){const e=c[n++],i=s.getAttribute(t).split(C),o=/([.?@])?(.*)/.exec(e);a.push({type:1,index:r,name:o[2],strings:i,ctor:"."===o[1]?tt:"?"===o[1]?et:"@"===o[1]?it:X}),s.removeAttribute(t)}else t.startsWith(C)&&(a.push({type:6,index:r}),s.removeAttribute(t));if(B.test(s.tagName)){const t=s.textContent.split(C),e=t.length-1;if(e>0){s.textContent=x?x.emptyScript:"";for(let i=0;i<e;i++)s.append(t[i],M()),q.nextNode(),a.push({type:2,index:++r});s.append(t[e],M())}}}else if(8===s.nodeType)if(s.data===P)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=s.data.indexOf(C,t+1));)a.push({type:7,index:r}),t+=C.length-1}r++}}static createElement(t,e){const i=T.createElement("template");return i.innerHTML=t,i}}function G(t,e,i=t,s){if(e===F)return e;let r=void 0!==s?i._$Co?.[s]:i._$Cl;const n=N(e)?void 0:e._$litDirective$;return r?.constructor!==n&&(r?._$AO?.(!1),void 0===n?r=void 0:(r=new n(t),r._$AT(t,i,s)),void 0!==s?(i._$Co??=[])[s]=r:i._$Cl=r),void 0!==r&&(e=G(t,r._$AS(t,e.values),r,s)),e}let J=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=(t?.creationScope??T).importNode(e,!0);q.currentNode=s;let r=q.nextNode(),n=0,o=0,a=i[0];for(;void 0!==a;){if(n===a.index){let e;2===a.type?e=new Z(r,r.nextSibling,this,t):1===a.type?e=new a.ctor(r,a.name,a.strings,this,t):6===a.type&&(e=new st(r,this,t)),this._$AV.push(e),a=i[++o]}n!==a?.index&&(r=q.nextNode(),n++)}return q.currentNode=T,s}p(t){let e=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}};class Z{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=Y,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=G(this,t,e),N(t)?t===Y||null==t||""===t?(this._$AH!==Y&&this._$AR(),this._$AH=Y):t!==this._$AH&&t!==F&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>k(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==Y&&N(this._$AH)?this._$AA.nextSibling.data=t:this.T(T.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:i}=t,s="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=K.createElement(Q(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(e);else{const t=new J(s,this),i=t.u(this.options);t.p(e),this.T(i),this._$AH=t}}_$AC(t){let e=W.get(t.strings);return void 0===e&&W.set(t.strings,e=new K(t)),e}k(t){k(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new Z(this.O(M()),this.O(M()),this,this.options)):i=e[s],i._$AI(r),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}let X=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,r){this.type=1,this._$AH=Y,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Y}_$AI(t,e=this,i,s){const r=this.strings;let n=!1;if(void 0===r)t=G(this,t,e,0),n=!N(t)||t!==this._$AH&&t!==F,n&&(this._$AH=t);else{const s=t;let o,a;for(t=r[0],o=0;o<r.length-1;o++)a=G(this,s[i+o],e,o),a===F&&(a=this._$AH[o]),n||=!N(a)||a!==this._$AH[o],a===Y?t=Y:t!==Y&&(t+=(a??"")+r[o+1]),this._$AH[o]=a}n&&!s&&this.j(t)}j(t){t===Y?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}};class tt extends X{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===Y?void 0:t}}class et extends X{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==Y)}}class it extends X{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){if((t=G(this,t,e,0)??Y)===F)return;const i=this._$AH,s=t===Y&&i!==Y||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==Y&&(i===Y||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class st{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){G(this,t)}}const rt={I:Z},nt=w.litHtmlPolyfillSupport;nt?.(K,Z),(w.litHtmlVersions??=[]).push("3.2.1");
18
+ const w=globalThis,x=w.trustedTypes,E=x?x.createPolicy("lit-html",{createHTML:t=>t}):void 0,O="$lit$",C=`lit$${Math.random().toFixed(9).slice(2)}$`,P="?"+C,D=`<${P}>`,T=document,M=()=>T.createComment(""),N=t=>null===t||"object"!=typeof t&&"function"!=typeof t,R=Array.isArray,k="[ \t\n\f\r]",U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,I=/-->/g,L=/>/g,V=RegExp(`>|${k}(?:([^\\s"'>=/]+)(${k}*=${k}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),j=/'/g,H=/"/g,B=/^(?:script|style|textarea|title)$/i,z=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),F=Symbol.for("lit-noChange"),Y=Symbol.for("lit-nothing"),W=new WeakMap,q=T.createTreeWalker(T,129);function Q(t,e){if(!R(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==E?E.createHTML(e):e}class K{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,n=0;const o=t.length-1,a=this.parts,[l,c]=((t,e)=>{const i=t.length-1,s=[];let r,n=2===e?"<svg>":3===e?"<math>":"",o=U;for(let e=0;e<i;e++){const i=t[e];let a,l,c=-1,h=0;for(;h<i.length&&(o.lastIndex=h,l=o.exec(i),null!==l);)h=o.lastIndex,o===U?"!--"===l[1]?o=I:void 0!==l[1]?o=L:void 0!==l[2]?(B.test(l[2])&&(r=RegExp("</"+l[2],"g")),o=V):void 0!==l[3]&&(o=V):o===V?">"===l[0]?(o=r??U,c=-1):void 0===l[1]?c=-2:(c=o.lastIndex-l[2].length,a=l[1],o=void 0===l[3]?V:'"'===l[3]?H:j):o===H||o===j?o=V:o===I||o===L?o=U:(o=V,r=void 0);const u=o===V&&t[e+1].startsWith("/>")?" ":"";n+=o===U?i+D:c>=0?(s.push(a),i.slice(0,c)+O+i.slice(c)+C+u):i+C+(-2===c?e:u)}return[Q(t,n+(t[i]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),s]})(t,e);if(this.el=K.createElement(l,i),q.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(s=q.nextNode())&&a.length<o;){if(1===s.nodeType){if(s.hasAttributes())for(const t of s.getAttributeNames())if(t.endsWith(O)){const e=c[n++],i=s.getAttribute(t).split(C),o=/([.?@])?(.*)/.exec(e);a.push({type:1,index:r,name:o[2],strings:i,ctor:"."===o[1]?tt:"?"===o[1]?et:"@"===o[1]?it:X}),s.removeAttribute(t)}else t.startsWith(C)&&(a.push({type:6,index:r}),s.removeAttribute(t));if(B.test(s.tagName)){const t=s.textContent.split(C),e=t.length-1;if(e>0){s.textContent=x?x.emptyScript:"";for(let i=0;i<e;i++)s.append(t[i],M()),q.nextNode(),a.push({type:2,index:++r});s.append(t[e],M())}}}else if(8===s.nodeType)if(s.data===P)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=s.data.indexOf(C,t+1));)a.push({type:7,index:r}),t+=C.length-1}r++}}static createElement(t,e){const i=T.createElement("template");return i.innerHTML=t,i}}function G(t,e,i=t,s){if(e===F)return e;let r=void 0!==s?i._$Co?.[s]:i._$Cl;const n=N(e)?void 0:e._$litDirective$;return r?.constructor!==n&&(r?._$AO?.(!1),void 0===n?r=void 0:(r=new n(t),r._$AT(t,i,s)),void 0!==s?(i._$Co??=[])[s]=r:i._$Cl=r),void 0!==r&&(e=G(t,r._$AS(t,e.values),r,s)),e}let J=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=(t?.creationScope??T).importNode(e,!0);q.currentNode=s;let r=q.nextNode(),n=0,o=0,a=i[0];for(;void 0!==a;){if(n===a.index){let e;2===a.type?e=new Z(r,r.nextSibling,this,t):1===a.type?e=new a.ctor(r,a.name,a.strings,this,t):6===a.type&&(e=new st(r,this,t)),this._$AV.push(e),a=i[++o]}n!==a?.index&&(r=q.nextNode(),n++)}return q.currentNode=T,s}p(t){let e=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}};class Z{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=Y,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=G(this,t,e),N(t)?t===Y||null==t||""===t?(this._$AH!==Y&&this._$AR(),this._$AH=Y):t!==this._$AH&&t!==F&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>R(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==Y&&N(this._$AH)?this._$AA.nextSibling.data=t:this.T(T.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:i}=t,s="number"==typeof i?this._$AC(t):(void 0===i.el&&(i.el=K.createElement(Q(i.h,i.h[0]),this.options)),i);if(this._$AH?._$AD===s)this._$AH.p(e);else{const t=new J(s,this),i=t.u(this.options);t.p(e),this.T(i),this._$AH=t}}_$AC(t){let e=W.get(t.strings);return void 0===e&&W.set(t.strings,e=new K(t)),e}k(t){R(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new Z(this.O(M()),this.O(M()),this,this.options)):i=e[s],i._$AI(r),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}let X=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,r){this.type=1,this._$AH=Y,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Y}_$AI(t,e=this,i,s){const r=this.strings;let n=!1;if(void 0===r)t=G(this,t,e,0),n=!N(t)||t!==this._$AH&&t!==F,n&&(this._$AH=t);else{const s=t;let o,a;for(t=r[0],o=0;o<r.length-1;o++)a=G(this,s[i+o],e,o),a===F&&(a=this._$AH[o]),n||=!N(a)||a!==this._$AH[o],a===Y?t=Y:t!==Y&&(t+=(a??"")+r[o+1]),this._$AH[o]=a}n&&!s&&this.j(t)}j(t){t===Y?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}};class tt extends X{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===Y?void 0:t}}class et extends X{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==Y)}}class it extends X{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){if((t=G(this,t,e,0)??Y)===F)return;const i=this._$AH,s=t===Y&&i!==Y||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==Y&&(i===Y||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class st{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){G(this,t)}}const rt={I:Z},nt=w.litHtmlPolyfillSupport;nt?.(K,Z),(w.litHtmlVersions??=[]).push("3.2.1");
19
19
  /**
20
20
  * @license
21
21
  * Copyright 2017 Google LLC
@@ -63,7 +63,7 @@ function dt(t,e){return(e,i,s)=>((t,e,i)=>(i.configurable=!0,i.enumerable=!0,Ref
63
63
  * @license
64
64
  * Copyright 2017 Google LLC
65
65
  * SPDX-License-Identifier: BSD-3-Clause
66
- */var Et={done:!0,hasNext:!1},Ot={done:!1,hasNext:!1},Ct=()=>Et;function Pt(t,...e){let i=t,s=e.map((t=>"lazy"in t?function(t){let{lazy:e,lazyArgs:i}=t,s=e(...i);return Object.assign(s,{isSingle:e.single??!1,index:0,items:[]})}(t):void 0)),r=0;for(;r<e.length;){if(void 0===s[r]||!Tt(i)){i=(0,e[r])(i),r+=1;continue}let t=[];for(let i=r;i<e.length;i++){let e=s[i];if(void 0===e||(t.push(e),e.isSingle))break}let n=[];for(let e of i)if(Dt(e,n,t))break;let{isSingle:o}=t.at(-1);i=o?n[0]:n,r+=t.length}return i}function Dt(t,e,i){if(0===i.length)return e.push(t),!1;let s=t,r=Ot,n=!1;for(let[t,o]of i.entries()){let{index:a,items:l}=o;if(l.push(s),r=o(s,a,l),o.index+=1,r.hasNext){if(r.hasMany){for(let s of r.next)if(Dt(s,e,i.slice(t+1)))return!0;return n}s=r.next}if(!r.hasNext)break;r.done&&(n=!0)}return r.hasNext&&e.push(s),n}function Tt(t){return"string"==typeof t||"object"==typeof t&&null!==t&&Symbol.iterator in t}function Mt(t,e,i){let s=t.length-e.length;if(0===s)return t(...e);if(1===s)return function(t,e,i){let s=i=>t(i,...e);return void 0===i?s:Object.assign(s,{lazy:i,lazyArgs:e})}(t,e,i);throw new Error("Wrong number of arguments")}function Nt(...t){return Mt(kt,t)}var kt=(t,e)=>t.length>=e;function Rt(t,e){let i=[];for(let s=t;s<e;s++)i.push(s);return i}function Ut(t,e){if(!Nt(e,1))return{...t};if(!Nt(e,2)){let{[e[0]]:i,...s}=t;return s}let i={...t};for(let t of e)delete i[t];return i}function It(...t){return Mt(Lt,t)}var Lt=(t,e)=>({...t,...e});function Vt(...t){return Mt(jt,t,Ht)}var jt=(t,e)=>t.map(e),Ht=t=>(e,i,s)=>({done:!1,hasNext:!0,next:t(e,i,s)});function Bt(t){return"number"==typeof t&&!Number.isNaN(t)}function zt(t){return"string"==typeof t}function Ft(t){return void 0===t||("string"==typeof t||Array.isArray(t)?0===t.length:0===Object.keys(t).length)}function Yt(t){return null==t}function Wt(t){return Array.isArray(t)}function qt(t){return"boolean"==typeof t}function Qt(t){return t instanceof Date}function Kt(...t){return Mt(Gt,t)}function Gt(t,e){if(t===e||Object.is(t,e))return!0;if("object"!=typeof t||"object"!=typeof e||null===t||null===e||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;if(Array.isArray(t))return function(t,e){if(t.length!==e.length)return!1;for(let[i,s]of t.entries())if(!Gt(s,e[i]))return!1;return!0}(t,e);if(t instanceof Map)return function(t,e){if(t.size!==e.size)return!1;for(let[i,s]of t.entries())if(!e.has(i)||!Gt(s,e.get(i)))return!1;return!0}(t,e);if(t instanceof Set)return function(t,e){if(t.size!==e.size)return!1;let i=[...e];for(let e of t){let t=!1;for(let[s,r]of i.entries())if(Gt(e,r)){t=!0,i.splice(s,1);break}if(!t)return!1}return!0}(t,e);if(t instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp)return t.toString()===e.toString();if(Object.keys(t).length!==Object.keys(e).length)return!1;for(let[i,s]of Object.entries(t))if(!(i in e)||!Gt(s,e[i]))return!1;return!0}function Jt(...t){return function(t,e){let i=e.length-t.length;if(1===i){let[i,...s]=e;return Pt(i,{lazy:t,lazyArgs:s})}if(0===i){let i={lazy:t,lazyArgs:e};return Object.assign((t=>Pt(t,i)),i)}throw new Error("Wrong number of arguments")}(Zt,t)}function Zt(t){if(0===t.length)return Ct;let e=new Map;for(let i of t)e.set(i,(e.get(i)??0)+1);return t=>{let i=e.get(t);return void 0===i||0===i?Ot:(1===i?e.delete(t):e.set(t,i-1),{hasNext:!0,next:t,done:0===e.size})}}function Xt(t,e){const i=function(t,e){return function(t){return"function"==typeof t}(t)?t(e):t}(t,e),{data:s}=e,r=[];for(let t=0;t<s.length;t+=1){const e=Wt(i)?i[t]:i;r.push(e)}return r}function te(t,e){const i=Xt(t,e),{data:s}=e,r=[];for(let t=0;t<s.length;t+=1){const{digits:e}=s[t],n=i[t];r.push([]);for(let i=0;i<e.length;i+=1){const e=Wt(n)?n[i]:n;r[t].push(e)}}return r}function ee(t,e){const i=te(t,e),{data:s}=e,r=[];for(let t=0;t<s.length;t+=1){const{digits:e}=s[t],n=i[t];r.push([]);for(let i=0;i<e.length;i+=1){const{data:s}=e[i],o=n[i];r[t].push([]);for(let e=0;e<s.length;e+=1){const s=Wt(o)?o[e]:o;r[t][i].push(s)}}}return r}function ie(t,e){return It(t??{},e??{})}function se(t=[],e=[]){const i=Array.from(new Set(Object.keys(t).concat(Object.keys(e))));for(const s of i){const i=Number.parseInt(s,10);t[i]=ie(t[i],e[i])}return t}function re(t=[],e=[]){const i=Array.from(new Set(Object.keys(t).concat(Object.keys(e))));for(const s of i){const i=Number.parseInt(s,10);t[i]=se(t[i],e[i])}return t}const ne=e=>{class i extends e{constructor(){super(...arguments),this.cellStyles={},this.cachedCellStyles=[],this.digitStyles={},this.cachedDigitStyles=[],this.partStyles={},this.cachedPartStyles=[],this.color="inherit"}extractCellStyles(){const t={preprocessData:this.partPreprocessDataList,data:this.parts,direction:this.direction,value:[this.value,this.oldValue]},e=function(t=[],e=[]){const i=Array.from(new Set(Object.keys(t).concat(Object.keys(e))));for(const s of i){const i=Number.parseInt(s,10);t[i]=re(t[i],e[i])}return t}(ee(this.cellStyles??{},t),ee(this.cellStylesDynamic??{},t));return Kt(this.cachedCellStyles,e)||(this.cachedCellStyles=e),this.cachedCellStyles}extractDigitStyles(){const t={preprocessData:this.partPreprocessDataList,data:this.parts,direction:this.direction,value:[this.value,this.oldValue]},e=re(te(this.digitStyles??{},t),te(this.digitStylesDynamic??{},t));return Kt(this.cachedDigitStyles,e)||(this.cachedDigitStyles=e),this.cachedDigitStyles}extractPartStyles(){const t={preprocessData:this.partPreprocessDataList,data:this.parts,direction:this.direction,value:[this.value,this.oldValue]},e=se(Xt(this.partStyles??{},t),Xt(this.partStylesDynamic??{},t));return Kt(this.cachedPartStyles,e)||(this.cachedPartStyles=e),this.cachedPartStyles}}return t([ut({type:Object,attribute:"cell-styles",reflect:!0})],i.prototype,"cellStyles",void 0),t([ut({type:Object,attribute:"digit-styles",reflect:!0})],i.prototype,"digitStyles",void 0),t([ut({type:Object,attribute:"part-styles",reflect:!0})],i.prototype,"partStyles",void 0),t([ut({type:String,reflect:!0})],i.prototype,"color",void 0),i};function oe(t){return t.length}function ae(){return function(t){if(!(r=t.length))return[];for(var e=-1,i=function(t,e){let i;if(void 0===e)for(const e of t)null!=e&&(i>e||void 0===i&&e>=e)&&(i=e);else{let s=-1;for(let r of t)null!=(r=e(r,++s,t))&&(i>r||void 0===i&&r>=r)&&(i=r)}return i}(t,oe),s=new Array(i);++e<i;)for(var r,n=-1,o=s[e]=new Array(r);++n<r;)o[n]=t[n][e];return s}(arguments)}function le(t,e){const[i,s]=t,[r,n]=e,o={animate:!0,cancelPrevAnimation:!1};let a="";return 1===r.data.length&&(o.animate=!1,o.cancelPrevAnimation=!0,a="only one digit"),i!==s||(r.data[0]===r.data[r.data.length-1]&&(o.animate=!1,o.cancelPrevAnimation=!0,a="same head and tail"),Kt(r,n)&&(o.animate=!1,a="same digits"),a&&(o.earlyReturn=a)),o}function ce(t){try{return JSON.parse(t)}catch(e){return t}}function he(t){const e={};return Wt(t.digitToChar)?t.digitToChar.forEach(((t,i)=>{var s;e[(s=i,String.fromCodePoint(s+48))]=t})):function(t){return"object"==typeof t&&null!==t}(t.digitToChar)&&Object.entries(t.digitToChar).forEach((([t,i])=>{e[t]=i})),{...t,digitToChar:e}}const ue=i=>{var s,r;class n extends i{constructor(){super(...arguments),r.set(this,{...s.DEFAULT_PARTS_OPTIONS}),this.parts=[],this.oldParts=[],this.partPreprocessDataList=[]}get partsOptions(){return e(this,r,"f")}set partsOptions(t){const i=e(this,r,"f");!function(t,e,i,s,r){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===s?r.call(t,i):r?r.value=i:e.set(t,i)}(this,r,he({...s.DEFAULT_PARTS_OPTIONS,...t}),"f"),this.requestUpdate("partsOptions",i)}sampling(t,e){return function(t,e,i,s){let r=s;const n=t.isInteger(e)&&t.isInteger(i)?function(t,e,i){return function(s){return t.round(t.add(t.mul(e,t.sub(t.create(1),s)),t.mul(i,s)))}}(t,e,i):function(t,e,i){return function(s){return t.add(t.mul(e,t.sub(t.create(1),s)),t.mul(i,s))}}(t,e,i);t.eq(e,i)&&(r=1);const o=[];for(let e=0;e<r;e++){const i=t.div(t.create(e),t.create(Math.max(r-1,1)));o.push(n(i))}return o}(this.numberAdapter,this.numberAdapter.max(t,e),this.numberAdapter.min(t,e),this.partsOptions.sampleCount)}sampleSplit(t){return[t.slice()]}sampleToString(t){return this.numberAdapter.toString(t)}willUpdate(t){super.willUpdate(t),t.has("value")&&(this.oldParts=this.parts),(t.has("value")||t.has("partsOptions"))&&(this.parts=this.processPartData()),t.has("value")&&(this.partPreprocessDataList=function(t,e,i,s){const r=[];let n=0;for(let o=0;o<e.length;o++){const a=e[o],l=s?.[o],c=[];for(let e=0;e<a.digits.length;e++){const s=a.digits[e],r=l?.digits.find((t=>t.place===s.place));c.push({...le([t,i],[s,r]),index:n++,partIndex:o,digitIndex:e})}r.push(c)}return r}(this.direction,this.parts,this.oldDirection,this.oldParts))}processPartData(){const{decimalSeparator:t,digitToChar:e,minPlaces:i,fillChar:s,type:r}=this.partsOptions,n=this.value,o=this.oldValue;let a=e=>this.sampleToString(e).split(t);"string"===r&&(a=t=>[this.sampleToString(t),""]);const l=[],c=this.sampleSplit(this.sampling(n,o));{const r=this.numberAdapter.gt(n,o)?"down":"up";for(let n=0;n<c.length;n++){const o=c[n],h=o["down"===r?0:o.length-1],[u=1,p=0]=i,d=a(h),f=Math.max(this.stringAdapter.stringToChars(d[0]).length,u),m=Math.max(this.stringAdapter.stringToChars(d[1]??"").length,p),_=ae(...o.map((e=>{const[i="",r=""]=a(e),n=this.stringAdapter.stringToChars(i),o=this.stringAdapter.stringToChars(r),l=Math.max(f-n.length,0),c=Math.max(m-o.length,0);let h=[].concat(new Array(l).fill(s),n);return m>0&&(h=h.concat([t],o,new Array(c).fill(s))),h}))).map(((t,i,s)=>({data:t.filter(((t,e,i)=>0===e||t!==i[e-1])).map((t=>e[t]??t)),place:s.length-i})));l.push({digits:_})}}return l}}return s=n,r=new WeakMap,n.DEFAULT_PARTS_OPTIONS={sampleCount:16,decimalSeparator:".",fillChar:"0",minPlaces:[1,0],digitToChar:{},type:"number"},t([ut({type:Object,attribute:"parts-options",converter:t=>ce(t??"")??{},noAccessor:!0})],n.prototype,"partsOptions",null),n},pe=()=>({create(t){const e=Number(t);return Number.isFinite(e)?e:0},add:(t,e)=>t+e,sub:(t,e)=>t-e,mul:(t,e)=>t*e,div:(t,e)=>t/e,compare:(t,e)=>t>e?1:t<e?-1:0,eq:(t,e)=>t===e,gt:(t,e)=>t>e,gte:(t,e)=>t>=e,lt:(t,e)=>t<e,lte:(t,e)=>t<=e,isInteger:t=>Number.isInteger(t),isNegative:t=>t<0,isPositive:t=>t>0,isZero:t=>0===t,isNaN:t=>Number.isNaN(t),isFinite:t=>Number.isFinite(t),abs:t=>Math.abs(t),ceil:t=>Math.ceil(t),floor:t=>Math.floor(t),round:t=>Math.round(t),max:(t,e)=>Math.max(t,e),min:(t,e)=>Math.min(t,e),toNumber:t=>Number(t),toString:t=>String(t)}),de=()=>({stringToChars:t=>Array.from(t)});class fe{static setNumberAdapter(t){let e=pe();if(zt(t)){for(const[i,s]of fe.AVAILABLE_NUMBER_ADAPTERS)if(i.includes(t)){e=s();break}}else e=t;fe.NUMBER_ADAPTER=e}static setStringAdapter(t){let e=de();if(zt(t)){for(const[i,s]of fe.AVAILABLE_STRING_ADAPTERS)if(i.includes(t)){e=s();break}}else e=t;fe.STRING_ADAPTER=e}static registerNumberAdapter(t,e){fe.AVAILABLE_NUMBER_ADAPTERS.set(t,e)}static registerStringAdapter(t,e){fe.AVAILABLE_STRING_ADAPTERS.set(t,e)}static registryAdapter(t){t.register(this)}}function me(...t){fe.setNumberAdapter(...t)}function _e(...t){fe.setStringAdapter(...t)}function ge(...t){fe.registerNumberAdapter(...t)}function ye(...t){fe.registerStringAdapter(...t)}fe.AVAILABLE_NUMBER_ADAPTERS=new Map([[["number"],pe]]),fe.AVAILABLE_STRING_ADAPTERS=new Map([[["string"],de],[["intl-segmenter"],t=>{const e=new Intl.Segmenter(t,{granularity:"grapheme"});return{stringToChars:t=>Array.from(e.segment(t)).map((t=>t.segment))}}]]),fe.NUMBER_ADAPTER=pe(),fe.STRING_ADAPTER=de(),fe.VALUE_CONVERTER={fromAttribute:t=>t,toAttribute:t=>Yt(t)?t:fe.NUMBER_ADAPTER.toString(t)};const Ae=e=>{class i extends e{get value(){return this.numberAdapter.create(this.__value)}set value(t){t=fe.NUMBER_ADAPTER.create(Yt(t)||zt(t)&&""===t.trim()?0:t);const e=this.__value;this.__value=t,this.numberAdapter.eq(this.__value,e)||this.requestUpdate("value",e)}get oldValue(){return this.numberAdapter.create(this.__oldValue)}set oldValue(t){const e=this.__oldValue;this.__oldValue=t,this.requestUpdate("oldValue",e)}get initialValue(){return Yt(this.__initialValue)?this.__initialValue:this.numberAdapter.create(this.__initialValue)}set initialValue(t){const e=this.__initialValue;this.__initialValue=t,this.requestUpdate("initialValue",e)}get locale(){return this.__locale}set locale(t){const e=this.__locale;this.__locale=t,this.requestUpdate("locale",e),this.localeInstance=zt(this.__locale)?new Intl.Locale(this.__locale):new Intl.Locale(...this.__locale)}constructor(...t){super(...t),this.__value=fe.NUMBER_ADAPTER.create(0),this.__oldValue=fe.NUMBER_ADAPTER.create(0),this.__initialValue=null,this.__locale="en-US",this.localeInstance=zt(this.locale)?new Intl.Locale(this.locale):new Intl.Locale(...this.locale),this.direction="up",this.oldDirection=this.direction,this.numberAdapter=fe.NUMBER_ADAPTER,this.stringAdapter=fe.STRING_ADAPTER}willUpdate(t){super.willUpdate(t),t.has("value")&&!t.has("oldValue")&&(this.oldValue=t.get("value")??this.value),this.oldDirection=this.direction,this.numberAdapter.eq(this.value,this.oldValue)||(this.direction=this.numberAdapter.gt(this.value,this.oldValue)?"down":"up")}connectedCallback(){super.connectedCallback(),this.oldValue=function(t){return null!=t}(this.initialValue)?this.initialValue:this.value}}return t([ut({attribute:"value",reflect:!0,converter:{toAttribute:fe.VALUE_CONVERTER.toAttribute},noAccessor:!0})],i.prototype,"value",null),t([ut({attribute:"old-value",reflect:!0,converter:fe.VALUE_CONVERTER,noAccessor:!0})],i.prototype,"oldValue",null),t([ut({attribute:"initial-value",reflect:!0,converter:fe.VALUE_CONVERTER,noAccessor:!0})],i.prototype,"initialValue",null),t([ut({converter:t=>{if(Yt(t))return t;try{return JSON.parse(t)}catch(e){return t}},reflect:!0,noAccessor:!0})],i.prototype,"locale",null),t([pt()],i.prototype,"direction",void 0),t([pt()],i.prototype,"oldDirection",void 0),i},be=a`
66
+ */var Et={done:!0,hasNext:!1},Ot={done:!1,hasNext:!1},Ct=()=>Et;function Pt(t,...e){let i=t,s=e.map((t=>"lazy"in t?function(t){let{lazy:e,lazyArgs:i}=t,s=e(...i);return Object.assign(s,{isSingle:e.single??!1,index:0,items:[]})}(t):void 0)),r=0;for(;r<e.length;){if(void 0===s[r]||!Tt(i)){i=(0,e[r])(i),r+=1;continue}let t=[];for(let i=r;i<e.length;i++){let e=s[i];if(void 0===e||(t.push(e),e.isSingle))break}let n=[];for(let e of i)if(Dt(e,n,t))break;let{isSingle:o}=t.at(-1);i=o?n[0]:n,r+=t.length}return i}function Dt(t,e,i){if(0===i.length)return e.push(t),!1;let s=t,r=Ot,n=!1;for(let[t,o]of i.entries()){let{index:a,items:l}=o;if(l.push(s),r=o(s,a,l),o.index+=1,r.hasNext){if(r.hasMany){for(let s of r.next)if(Dt(s,e,i.slice(t+1)))return!0;return n}s=r.next}if(!r.hasNext)break;r.done&&(n=!0)}return r.hasNext&&e.push(s),n}function Tt(t){return"string"==typeof t||"object"==typeof t&&null!==t&&Symbol.iterator in t}function Mt(t,e,i){let s=t.length-e.length;if(0===s)return t(...e);if(1===s)return function(t,e,i){let s=i=>t(i,...e);return void 0===i?s:Object.assign(s,{lazy:i,lazyArgs:e})}(t,e,i);throw new Error("Wrong number of arguments")}function Nt(...t){return Mt(Rt,t)}var Rt=(t,e)=>t.length>=e;function kt(t,e){let i=[];for(let s=t;s<e;s++)i.push(s);return i}function Ut(t,e){if(!Nt(e,1))return{...t};if(!Nt(e,2)){let{[e[0]]:i,...s}=t;return s}let i={...t};for(let t of e)delete i[t];return i}function It(...t){return Mt(Lt,t)}var Lt=(t,e)=>({...t,...e});function Vt(...t){return Mt(jt,t,Ht)}var jt=(t,e)=>t.map(e),Ht=t=>(e,i,s)=>({done:!1,hasNext:!0,next:t(e,i,s)});function Bt(t){return"number"==typeof t&&!Number.isNaN(t)}function zt(t){return"string"==typeof t}function Ft(t){return void 0===t||("string"==typeof t||Array.isArray(t)?0===t.length:0===Object.keys(t).length)}function Yt(t){return null==t}function Wt(t){return Array.isArray(t)}function qt(t){return"boolean"==typeof t}function Qt(t){return t instanceof Date}function Kt(...t){return Mt(Gt,t)}function Gt(t,e){if(t===e||Object.is(t,e))return!0;if("object"!=typeof t||"object"!=typeof e||null===t||null===e||Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1;if(Array.isArray(t))return function(t,e){if(t.length!==e.length)return!1;for(let[i,s]of t.entries())if(!Gt(s,e[i]))return!1;return!0}(t,e);if(t instanceof Map)return function(t,e){if(t.size!==e.size)return!1;for(let[i,s]of t.entries())if(!e.has(i)||!Gt(s,e.get(i)))return!1;return!0}(t,e);if(t instanceof Set)return function(t,e){if(t.size!==e.size)return!1;let i=[...e];for(let e of t){let t=!1;for(let[s,r]of i.entries())if(Gt(e,r)){t=!0,i.splice(s,1);break}if(!t)return!1}return!0}(t,e);if(t instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp)return t.toString()===e.toString();if(Object.keys(t).length!==Object.keys(e).length)return!1;for(let[i,s]of Object.entries(t))if(!(i in e)||!Gt(s,e[i]))return!1;return!0}function Jt(...t){return function(t,e){let i=e.length-t.length;if(1===i){let[i,...s]=e;return Pt(i,{lazy:t,lazyArgs:s})}if(0===i){let i={lazy:t,lazyArgs:e};return Object.assign((t=>Pt(t,i)),i)}throw new Error("Wrong number of arguments")}(Zt,t)}function Zt(t){if(0===t.length)return Ct;let e=new Map;for(let i of t)e.set(i,(e.get(i)??0)+1);return t=>{let i=e.get(t);return void 0===i||0===i?Ot:(1===i?e.delete(t):e.set(t,i-1),{hasNext:!0,next:t,done:0===e.size})}}function Xt(t,e){const i=function(t,e){return function(t){return"function"==typeof t}(t)?t(e):t}(t,e),{data:s}=e,r=[];for(let t=0;t<s.length;t+=1){const e=Wt(i)?i[t]:i;r.push(e)}return r}function te(t,e){const i=Xt(t,e),{data:s}=e,r=[];for(let t=0;t<s.length;t+=1){const{digits:e}=s[t],n=i[t];r.push([]);for(let i=0;i<e.length;i+=1){const e=Wt(n)?n[i]:n;r[t].push(e)}}return r}function ee(t,e){const i=te(t,e),{data:s}=e,r=[];for(let t=0;t<s.length;t+=1){const{digits:e}=s[t],n=i[t];r.push([]);for(let i=0;i<e.length;i+=1){const{data:s}=e[i],o=n[i];r[t].push([]);for(let e=0;e<s.length;e+=1){const s=Wt(o)?o[e]:o;r[t][i].push(s)}}}return r}function ie(t,e){return It(t??{},e??{})}function se(t=[],e=[]){const i=Array.from(new Set(Object.keys(t).concat(Object.keys(e))));for(const s of i){const i=Number.parseInt(s,10);t[i]=ie(t[i],e[i])}return t}function re(t=[],e=[]){const i=Array.from(new Set(Object.keys(t).concat(Object.keys(e))));for(const s of i){const i=Number.parseInt(s,10);t[i]=se(t[i],e[i])}return t}const ne=e=>{class i extends e{constructor(){super(...arguments),this.cellStyles={},this.cachedCellStyles=[],this.digitStyles={},this.cachedDigitStyles=[],this.partStyles={},this.cachedPartStyles=[],this.color="inherit"}extractCellStyles(){const t={preprocessData:this.partPreprocessDataList,data:this.parts,direction:this.direction,value:[this.value,this.oldValue]},e=function(t=[],e=[]){const i=Array.from(new Set(Object.keys(t).concat(Object.keys(e))));for(const s of i){const i=Number.parseInt(s,10);t[i]=re(t[i],e[i])}return t}(ee(this.cellStyles??{},t),ee(this.cellStylesDynamic??{},t));return Kt(this.cachedCellStyles,e)||(this.cachedCellStyles=e),this.cachedCellStyles}extractDigitStyles(){const t={preprocessData:this.partPreprocessDataList,data:this.parts,direction:this.direction,value:[this.value,this.oldValue]},e=re(te(this.digitStyles??{},t),te(this.digitStylesDynamic??{},t));return Kt(this.cachedDigitStyles,e)||(this.cachedDigitStyles=e),this.cachedDigitStyles}extractPartStyles(){const t={preprocessData:this.partPreprocessDataList,data:this.parts,direction:this.direction,value:[this.value,this.oldValue]},e=se(Xt(this.partStyles??{},t),Xt(this.partStylesDynamic??{},t));return Kt(this.cachedPartStyles,e)||(this.cachedPartStyles=e),this.cachedPartStyles}}return t([ut({type:Object,attribute:"cell-styles",reflect:!0})],i.prototype,"cellStyles",void 0),t([ut({type:Object,attribute:"digit-styles",reflect:!0})],i.prototype,"digitStyles",void 0),t([ut({type:Object,attribute:"part-styles",reflect:!0})],i.prototype,"partStyles",void 0),t([ut({type:String,reflect:!0})],i.prototype,"color",void 0),i};function oe(t){return t.length}function ae(){return function(t){if(!(r=t.length))return[];for(var e=-1,i=function(t,e){let i;if(void 0===e)for(const e of t)null!=e&&(i>e||void 0===i&&e>=e)&&(i=e);else{let s=-1;for(let r of t)null!=(r=e(r,++s,t))&&(i>r||void 0===i&&r>=r)&&(i=r)}return i}(t,oe),s=new Array(i);++e<i;)for(var r,n=-1,o=s[e]=new Array(r);++n<r;)o[n]=t[n][e];return s}(arguments)}function le(t,e){const[i,s]=t,[r,n]=e,o={animate:!0,cancelPrevAnimation:!1};let a="";return 1===r.data.length&&(o.animate=!1,o.cancelPrevAnimation=!0,a="only one digit"),i!==s||(r.data[0]===r.data[r.data.length-1]&&(o.animate=!1,o.cancelPrevAnimation=!0,a="same head and tail"),Kt(r,n)&&(o.animate=!1,a="same digits"),a&&(o.earlyReturn=a)),o}function ce(t){try{return JSON.parse(t)}catch(e){return t}}function he(t){const e={};return Wt(t.digitToChar)?t.digitToChar.forEach(((t,i)=>{var s;e[(s=i,String.fromCodePoint(s+48))]=t})):function(t){return"object"==typeof t&&null!==t}(t.digitToChar)&&Object.entries(t.digitToChar).forEach((([t,i])=>{e[t]=i})),{...t,digitToChar:e}}const ue=i=>{var s,r;class n extends i{constructor(){super(...arguments),r.set(this,{...s.DEFAULT_PARTS_OPTIONS}),this.parts=[],this.oldParts=[],this.partPreprocessDataList=[]}get partsOptions(){return e(this,r,"f")}set partsOptions(t){const i=e(this,r,"f");!function(t,e,i,s,r){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===s?r.call(t,i):r?r.value=i:e.set(t,i)}(this,r,he({...s.DEFAULT_PARTS_OPTIONS,...t}),"f"),this.requestUpdate("partsOptions",i)}sampling(t,e){return function(t,e,i,s){let r=s;const n=t.isInteger(e)&&t.isInteger(i)?function(t,e,i){return function(s){return t.round(t.add(t.mul(e,t.sub(t.create(1),s)),t.mul(i,s)))}}(t,e,i):function(t,e,i){return function(s){return t.add(t.mul(e,t.sub(t.create(1),s)),t.mul(i,s))}}(t,e,i);t.eq(e,i)&&(r=1);const o=[];for(let e=0;e<r;e++){const i=t.div(t.create(e),t.create(Math.max(r-1,1)));o.push(n(i))}return o}(this.numberAdapter,this.numberAdapter.max(t,e),this.numberAdapter.min(t,e),this.partsOptions.sampleCount)}sampleSplit(t){return[t.slice()]}sampleToString(t){return this.numberAdapter.toString(t)}shouldRebuildParts(t){return t.has("value")||t.has("partsOptions")}willUpdate(t){super.willUpdate(t),t.has("value")&&(this.oldParts=this.parts),this.shouldRebuildParts(t)&&(this.parts=this.processPartData()),t.has("value")&&(this.partPreprocessDataList=function(t,e,i,s){const r=[];let n=0;for(let o=0;o<e.length;o++){const a=e[o],l=s?.[o],c=[];for(let e=0;e<a.digits.length;e++){const s=a.digits[e],r=l?.digits.find((t=>t.place===s.place));c.push({...le([t,i],[s,r]),index:n++,partIndex:o,digitIndex:e})}r.push(c)}return r}(this.direction,this.parts,this.oldDirection,this.oldParts))}processPartData(){const{decimalSeparator:t,digitToChar:e,minPlaces:i,fillChar:s,type:r}=this.partsOptions,n=this.value,o=this.oldValue;let a=e=>this.sampleToString(e).split(t);"string"===r&&(a=t=>[this.sampleToString(t),""]);const l=[],c=this.sampleSplit(this.sampling(n,o));{const r=this.numberAdapter.gt(n,o)?"down":"up";for(let n=0;n<c.length;n++){const o=c[n],h=o["down"===r?0:o.length-1],[u=1,p=0]=i,d=a(h),f=Math.max(this.stringAdapter.stringToChars(d[0]).length,u),m=Math.max(this.stringAdapter.stringToChars(d[1]??"").length,p),_=ae(...o.map((e=>{const[i="",r=""]=a(e),n=this.stringAdapter.stringToChars(i),o=this.stringAdapter.stringToChars(r),l=Math.max(f-n.length,0),c=Math.max(m-o.length,0);let h=[].concat(new Array(l).fill(s),n);return m>0&&(h=h.concat([t],o,new Array(c).fill(s))),h}))).map(((t,i,s)=>({data:t.filter(((t,e,i)=>0===e||t!==i[e-1])).map((t=>e[t]??t)),place:s.length-i})));l.push({digits:_})}}return l}}return s=n,r=new WeakMap,n.DEFAULT_PARTS_OPTIONS={sampleCount:16,decimalSeparator:".",fillChar:"0",minPlaces:[1,0],digitToChar:{},type:"number"},t([ut({type:Object,attribute:"parts-options",converter:t=>ce(t??"")??{},noAccessor:!0})],n.prototype,"partsOptions",null),n},pe=()=>({create(t){const e=Number(t);return Number.isFinite(e)?e:0},add:(t,e)=>t+e,sub:(t,e)=>t-e,mul:(t,e)=>t*e,div:(t,e)=>t/e,compare:(t,e)=>t>e?1:t<e?-1:0,eq:(t,e)=>t===e,gt:(t,e)=>t>e,gte:(t,e)=>t>=e,lt:(t,e)=>t<e,lte:(t,e)=>t<=e,isInteger:t=>Number.isInteger(t),isNegative:t=>t<0,isPositive:t=>t>0,isZero:t=>0===t,isNaN:t=>Number.isNaN(t),isFinite:t=>Number.isFinite(t),abs:t=>Math.abs(t),ceil:t=>Math.ceil(t),floor:t=>Math.floor(t),round:t=>Math.round(t),max:(t,e)=>Math.max(t,e),min:(t,e)=>Math.min(t,e),toNumber:t=>Number(t),toString:t=>String(t)}),de=()=>({stringToChars:t=>Array.from(t)});class fe{static setNumberAdapter(t){let e=pe();if(zt(t)){for(const[i,s]of fe.AVAILABLE_NUMBER_ADAPTERS)if(i.includes(t)){e=s();break}}else e=t;fe.NUMBER_ADAPTER=e}static setStringAdapter(t){let e=de();if(zt(t)){for(const[i,s]of fe.AVAILABLE_STRING_ADAPTERS)if(i.includes(t)){e=s();break}}else e=t;fe.STRING_ADAPTER=e}static registerNumberAdapter(t,e){fe.AVAILABLE_NUMBER_ADAPTERS.set(t,e)}static registerStringAdapter(t,e){fe.AVAILABLE_STRING_ADAPTERS.set(t,e)}static registryAdapter(t){t.register(this)}}function me(...t){fe.setNumberAdapter(...t)}function _e(...t){fe.setStringAdapter(...t)}function ge(...t){fe.registerNumberAdapter(...t)}function ye(...t){fe.registerStringAdapter(...t)}fe.AVAILABLE_NUMBER_ADAPTERS=new Map([[["number"],pe]]),fe.AVAILABLE_STRING_ADAPTERS=new Map([[["string"],de],[["intl-segmenter"],t=>{const e=new Intl.Segmenter(t,{granularity:"grapheme"});return{stringToChars:t=>Array.from(e.segment(t)).map((t=>t.segment))}}]]),fe.NUMBER_ADAPTER=pe(),fe.STRING_ADAPTER=de(),fe.VALUE_CONVERTER={fromAttribute:t=>t,toAttribute:t=>Yt(t)?t:fe.NUMBER_ADAPTER.toString(t)};const Ae=e=>{class i extends e{get value(){return this.numberAdapter.create(this.__value)}set value(t){t=fe.NUMBER_ADAPTER.create(Yt(t)||zt(t)&&""===t.trim()?0:t);const e=this.__value;this.__value=t,this.numberAdapter.eq(this.__value,e)||this.requestUpdate("value",e)}get oldValue(){return this.numberAdapter.create(this.__oldValue)}set oldValue(t){const e=this.__oldValue;this.__oldValue=t,this.requestUpdate("oldValue",e)}get initialValue(){return Yt(this.__initialValue)?this.__initialValue:this.numberAdapter.create(this.__initialValue)}set initialValue(t){const e=this.__initialValue;this.__initialValue=t,this.requestUpdate("initialValue",e)}get locale(){return this.__locale}set locale(t){const e=this.__locale;this.__locale=t,this.requestUpdate("locale",e),this.localeInstance=zt(this.__locale)?new Intl.Locale(this.__locale):new Intl.Locale(...this.__locale)}constructor(...t){super(...t),this.__value=fe.NUMBER_ADAPTER.create(0),this.__oldValue=fe.NUMBER_ADAPTER.create(0),this.__initialValue=null,this.__locale="en-US",this.localeInstance=zt(this.locale)?new Intl.Locale(this.locale):new Intl.Locale(...this.locale),this.direction="up",this.oldDirection=this.direction,this.numberAdapter=fe.NUMBER_ADAPTER,this.stringAdapter=fe.STRING_ADAPTER}willUpdate(t){super.willUpdate(t),t.has("value")&&!t.has("oldValue")&&(this.oldValue=t.get("value")??this.value),this.oldDirection=this.direction,this.numberAdapter.eq(this.value,this.oldValue)||(this.direction=this.numberAdapter.gt(this.value,this.oldValue)?"down":"up")}connectedCallback(){super.connectedCallback(),this.oldValue=function(t){return null!=t}(this.initialValue)?this.initialValue:this.value}}return t([ut({attribute:"value",reflect:!0,converter:{toAttribute:fe.VALUE_CONVERTER.toAttribute},noAccessor:!0})],i.prototype,"value",null),t([ut({attribute:"old-value",reflect:!0,converter:fe.VALUE_CONVERTER,noAccessor:!0})],i.prototype,"oldValue",null),t([ut({attribute:"initial-value",reflect:!0,converter:fe.VALUE_CONVERTER,noAccessor:!0})],i.prototype,"initialValue",null),t([ut({converter:t=>{if(Yt(t))return t;try{return JSON.parse(t)}catch(e){return t}},reflect:!0,noAccessor:!0})],i.prototype,"locale",null),t([pt()],i.prototype,"direction",void 0),t([pt()],i.prototype,"oldDirection",void 0),i},be=a`
67
67
  :host {
68
68
  position: relative;
69
69
  white-space: nowrap;
@@ -122,6 +122,7 @@ function dt(t,e){return(e,i,s)=>((t,e,i)=>(i.configurable=!0,i.enumerable=!0,Ref
122
122
 
123
123
  .roller-part .roller-part__wrapper {
124
124
  display: inline-block;
125
+ text-align: center;
125
126
  }
126
127
 
127
128
  .roller-part .roller-part__suffix {
@@ -180,7 +181,7 @@ function dt(t,e){return(e,i,s)=>((t,e,i)=>(i.configurable=!0,i.enumerable=!0,Ref
180
181
  position: absolute;
181
182
  bottom: 100%;
182
183
  }
183
- `,Ce=t=>t,Pe=(t,e,i)=>(((1-3*i+3*e)*t+(3*i-6*e))*t+3*e)*t;function De(t,e,i,s){if(t===e&&i===s)return Ce;const r=e=>function(t,e,i,s,r){let n,o,a=0;do{o=e+(i-e)/2,n=Pe(o,s,r)-t,n>0?i=o:e=o}while(Math.abs(n)>1e-7&&++a<12);return o}(e,0,1,t,i);return t=>0===t||1===t?t:Pe(r(t),e,s)}const Te=De(.12,0,.39,0),Me=De(.61,1,.88,1),Ne=De(.37,0,.63,1),ke=De(.11,0,.5,0),Re=De(.5,1,.89,1),Ue=De(.45,0,.55,1),Ie=De(.32,0,.67,0),Le=De(.33,1,.68,1),Ve=De(.65,0,.35,1),je=De(.5,0,.75,0),He=De(.25,1,.5,1),Be=De(.76,0,.24,1),ze=De(.64,0,.78,0),Fe=De(.22,1,.36,1),Ye=De(.83,0,.17,1),We=De(.7,0,.84,0),qe=De(.16,1,.3,1),Qe=De(.87,0,.13,1),Ke=De(.55,0,1,.45),Ge=De(0,.55,.45,1),Je=De(.85,0,.15,1),Ze=De(.36,0,.66,-.56),Xe=De(.34,1.56,.64,1),ti=De(.68,-.6,.32,1.6);function ei(t){const e=2*Math.PI/3;return 0===t?0:1===t?1:-(2**(10*t-10))*Math.sin((10*t-10.75)*e)}function ii(t){const e=2*Math.PI/3;return 0===t?0:1===t?1:2**(-10*t)*Math.sin((10*t-.75)*e)+1}function si(t){const e=2*Math.PI/4.5;return 0===t?0:1===t?1:t<.5?-(2**(20*t-10))*Math.sin((20*t-11.125)*e)/2:2**(-20*t+10)*Math.sin((20*t-11.125)*e)/2+1}function ri(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375}function ni(t){return 1-ri(1-t)}function oi(t){return t<.5?(1-ri(1-2*t))/2:(1+ri(2*t-1))/2}var ai=Object.freeze({__proto__:null,easeInBack:Ze,easeInBounce:ni,easeInCirc:Ke,easeInCubic:Ie,easeInElastic:ei,easeInExpo:We,easeInOutBack:ti,easeInOutBounce:oi,easeInOutCirc:Je,easeInOutCubic:Ve,easeInOutElastic:si,easeInOutExpo:Qe,easeInOutQuad:Ue,easeInOutQuart:Be,easeInOutQuint:Ye,easeInOutSine:Ne,easeInQuad:ke,easeInQuart:je,easeInQuint:ze,easeInSine:Te,easeOutBack:Xe,easeOutBounce:ri,easeOutCirc:Ge,easeOutCubic:Le,easeOutElastic:ii,easeOutExpo:qe,easeOutQuad:Re,easeOutQuart:He,easeOutQuint:Fe,easeOutSine:Me});class li extends Event{}let ci=class extends ot{constructor(){super(),this.digit={data:[],place:0},this.preprocessData={animate:!0,cancelPrevAnimation:!1,earlyReturn:"",index:0,partIndex:0,digitIndex:0},this.direction="up",this.textStyle={},this.cellStyle=[],this.animationOptions={},this.keyframes={},this.digitWidth=0,this.resizeObserver=new ResizeObserver((()=>{this.digitWidth=this.clonedRollDigitList?this.clonedRollDigitList.offsetWidth:0}))}firstUpdated(t){super.firstUpdated(t),this.clonedRollDigitList&&this.resizeObserver.observe(this.clonedRollDigitList)}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}updated(t){super.updated(t),Jt(Array.from(t.keys()),["digit","preprocessData","direction","animationOptions","keyframes"]).length>0&&this.shouldAnimate()&&this.startAnimation().then()}render(){const t=this.cellStyle.map((t=>function(...t){return Mt(Ut,t)}(t,["position"])));return z`<span class="roller-part-digit">
184
+ `,Ce=t=>t,Pe=(t,e,i)=>(((1-3*i+3*e)*t+(3*i-6*e))*t+3*e)*t;function De(t,e,i,s){if(t===e&&i===s)return Ce;const r=e=>function(t,e,i,s,r){let n,o,a=0;do{o=e+(i-e)/2,n=Pe(o,s,r)-t,n>0?i=o:e=o}while(Math.abs(n)>1e-7&&++a<12);return o}(e,0,1,t,i);return t=>0===t||1===t?t:Pe(r(t),e,s)}const Te=De(.12,0,.39,0),Me=De(.61,1,.88,1),Ne=De(.37,0,.63,1),Re=De(.11,0,.5,0),ke=De(.5,1,.89,1),Ue=De(.45,0,.55,1),Ie=De(.32,0,.67,0),Le=De(.33,1,.68,1),Ve=De(.65,0,.35,1),je=De(.5,0,.75,0),He=De(.25,1,.5,1),Be=De(.76,0,.24,1),ze=De(.64,0,.78,0),Fe=De(.22,1,.36,1),Ye=De(.83,0,.17,1),We=De(.7,0,.84,0),qe=De(.16,1,.3,1),Qe=De(.87,0,.13,1),Ke=De(.55,0,1,.45),Ge=De(0,.55,.45,1),Je=De(.85,0,.15,1),Ze=De(.36,0,.66,-.56),Xe=De(.34,1.56,.64,1),ti=De(.68,-.6,.32,1.6);function ei(t){const e=2*Math.PI/3;return 0===t?0:1===t?1:-(2**(10*t-10))*Math.sin((10*t-10.75)*e)}function ii(t){const e=2*Math.PI/3;return 0===t?0:1===t?1:2**(-10*t)*Math.sin((10*t-.75)*e)+1}function si(t){const e=2*Math.PI/4.5;return 0===t?0:1===t?1:t<.5?-(2**(20*t-10))*Math.sin((20*t-11.125)*e)/2:2**(-20*t+10)*Math.sin((20*t-11.125)*e)/2+1}function ri(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375}function ni(t){return 1-ri(1-t)}function oi(t){return t<.5?(1-ri(1-2*t))/2:(1+ri(2*t-1))/2}var ai=Object.freeze({__proto__:null,easeInBack:Ze,easeInBounce:ni,easeInCirc:Ke,easeInCubic:Ie,easeInElastic:ei,easeInExpo:We,easeInOutBack:ti,easeInOutBounce:oi,easeInOutCirc:Je,easeInOutCubic:Ve,easeInOutElastic:si,easeInOutExpo:Qe,easeInOutQuad:Ue,easeInOutQuart:Be,easeInOutQuint:Ye,easeInOutSine:Ne,easeInQuad:Re,easeInQuart:je,easeInQuint:ze,easeInSine:Te,easeOutBack:Xe,easeOutBounce:ri,easeOutCirc:Ge,easeOutCubic:Le,easeOutElastic:ii,easeOutExpo:qe,easeOutQuad:ke,easeOutQuart:He,easeOutQuint:Fe,easeOutSine:Me});class li extends Event{}let ci=class extends ot{constructor(){super(),this.digit={data:[],place:0},this.preprocessData={animate:!0,cancelPrevAnimation:!1,earlyReturn:"",index:0,partIndex:0,digitIndex:0},this.direction="up",this.textStyle={},this.cellStyle=[],this.animationOptions={},this.keyframes={},this.digitWidth=0,this.resizeObserver=new ResizeObserver((()=>{this.digitWidth=this.clonedRollDigitList?this.clonedRollDigitList.offsetWidth:0}))}firstUpdated(t){super.firstUpdated(t),this.clonedRollDigitList&&this.resizeObserver.observe(this.clonedRollDigitList)}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect()}updated(t){super.updated(t),Jt(Array.from(t.keys()),["digit","preprocessData","direction","animationOptions","keyframes"]).length>0&&this.shouldAnimate()&&this.startAnimation().then()}render(){const t=this.cellStyle.map((t=>function(...t){return Mt(Ut,t)}(t,["position"])));return z`<span class="roller-part-digit">
184
185
  <!-- 占位 -->
185
186
  <span
186
187
  class="placeholder"
@@ -228,7 +229,7 @@ function dt(t,e){return(e,i,s)=>((t,e,i)=>(i.configurable=!0,i.enumerable=!0,Ref
228
229
  ></span
229
230
  >`}</span
230
231
  ></span
231
- > `}shouldAnimate(){const{cancelPrevAnimation:t,animate:e}=this.preprocessData;return t&&(this.animation&&this.animation.cancel(),this.rollList&&this.rollList.style&&this.rollList.style.cssText&&(this.rollList.style.cssText="")),!!e}async startAnimation(){if(Yt(this.rollList))return;this.__emitAnimationStart();const t=It({duration:1e3,iterations:1,easing:"ease-out",fill:"forwards"},this.animationOptions),e=Ft(this.keyframes)?{up:{transform:["translateY(0)","translateY(-100%)"]},down:{transform:["translateY(0)","translateY(100%)"]}}[this.direction]:this.keyframes;if(zt(t.easing)&&ai[t.easing]){const e=ai[t.easing];t.easing=`linear(${function(...t){return Mt(Rt,t)}(0,64).map(((t,i)=>e(i/63))).join(",")})`}try{this.clearAnimation(),this.animation=this.rollList.animate(e,t),this.animation.addEventListener("finish",(()=>this.__emitAnimationEnd()),{once:!0})}catch(t){console.error(t)}}clearAnimation(){this.animation?.removeEventListener("finish",this.__emitAnimationEnd),this.animation?.cancel()}__emitAnimationStart(){this.isConnected&&this.dispatchEvent(new li("roller-digit-animation-start"))}__emitAnimationEnd(){this.isConnected&&this.dispatchEvent(new li("roller-digit-animation-end"))}};ci.styles=[Oe],t([ut({type:Object})],ci.prototype,"digit",void 0),t([ut({type:Object})],ci.prototype,"preprocessData",void 0),t([ut({type:String})],ci.prototype,"direction",void 0),t([ut({type:Object})],ci.prototype,"textStyle",void 0),t([ut({type:Array})],ci.prototype,"cellStyle",void 0),t([ut({type:Object})],ci.prototype,"animationOptions",void 0),t([ut({type:Object})],ci.prototype,"keyframes",void 0),t([dt(".roll-list__shadow")],ci.prototype,"clonedRollDigitList",void 0),t([dt(".roll-list")],ci.prototype,"rollList",void 0),t([pt()],ci.prototype,"digitWidth",void 0),ci=t([lt("timered-counter-roller-digit")],ci);class hi extends Event{}let ui=class extends ot{constructor(){super(...arguments),this.color="",this.direction="up",this.parts=[],this.partPreprocessDataList=[],this.animationOptions=[],this.keyframes=[],this.cellStyles=[],this.digitStyles=[],this.partStyles=[],this.parentContainerRect={},this.__partDigitsColorStyles=[],this.digitAnimateEndCount=0,this.digitAnimatedCount=0}render(){return z`<span
232
+ > `}shouldAnimate(){const{cancelPrevAnimation:t,animate:e}=this.preprocessData;return t&&(this.animation&&this.animation.cancel(),this.rollList&&this.rollList.style&&this.rollList.style.cssText&&(this.rollList.style.cssText="")),!!e}async startAnimation(){if(Yt(this.rollList))return;this.__emitAnimationStart();const t=It({duration:1e3,iterations:1,easing:"ease-out",fill:"forwards"},this.animationOptions),e=Ft(this.keyframes)?{up:{transform:["translateY(0)","translateY(-100%)"]},down:{transform:["translateY(0)","translateY(100%)"]}}[this.direction]:this.keyframes;if(zt(t.easing)&&ai[t.easing]){const e=ai[t.easing];t.easing=`linear(${function(...t){return Mt(kt,t)}(0,64).map(((t,i)=>e(i/63))).join(",")})`}try{this.clearAnimation(),this.animation=this.rollList.animate(e,t),this.animation.addEventListener("finish",(()=>this.__emitAnimationEnd()),{once:!0})}catch(t){console.error(t)}}clearAnimation(){this.animation?.removeEventListener("finish",this.__emitAnimationEnd),this.animation?.cancel()}__emitAnimationStart(){this.isConnected&&this.dispatchEvent(new li("roller-digit-animation-start"))}__emitAnimationEnd(){this.isConnected&&this.dispatchEvent(new li("roller-digit-animation-end"))}};ci.styles=[Oe],t([ut({type:Object})],ci.prototype,"digit",void 0),t([ut({type:Object})],ci.prototype,"preprocessData",void 0),t([ut({type:String})],ci.prototype,"direction",void 0),t([ut({type:Object})],ci.prototype,"textStyle",void 0),t([ut({type:Array})],ci.prototype,"cellStyle",void 0),t([ut({type:Object})],ci.prototype,"animationOptions",void 0),t([ut({type:Object})],ci.prototype,"keyframes",void 0),t([dt(".roll-list__shadow")],ci.prototype,"clonedRollDigitList",void 0),t([dt(".roll-list")],ci.prototype,"rollList",void 0),t([pt()],ci.prototype,"digitWidth",void 0),ci=t([lt("timered-counter-roller-digit")],ci);class hi extends Event{}let ui=class extends ot{constructor(){super(...arguments),this.color="",this.direction="up",this.parts=[],this.partPreprocessDataList=[],this.animationOptions=[],this.keyframes=[],this.cellStyles=[],this.digitStyles=[],this.partStyles=[],this.parentContainerRect={},this.__partDigitsColorStyles=[],this.digitAnimateEndCount=0,this.digitAnimatedCount=0}render(){return z`<span
232
233
  class="roller__prefix"
233
234
  data-part-id="-1"
234
235
  data-digit-id="0"
@@ -328,12 +329,12 @@ function dt(t,e){return(e,i,s)=>((t,e,i)=>(i.configurable=!0,i.enumerable=!0,Ref
328
329
  `}willUpdate(t){if(t.has("localeNumber")||t.has("locale")){this.localeNumberInstance=new Intl.NumberFormat(this.localeInstance,qt(this.localeNumber)?{}:this.localeNumber);{const e=this.localeNumberInstance.formatToParts(123456.789),i=e.find((t=>"decimal"===t.type))?.value||".",s=e.find((t=>"group"===t.type))?.value||"";if(this.localDecimalSeparator!==i||this.localeGroupingSeparator!==s){this.localDecimalSeparator=i;const e=this.partsOptions;this.partsOptions={...e,decimalSeparator:this.localDecimalSeparator},t.set("partsOptions",e)}}}super.willUpdate(t)}};_i.styles=[...fi.styles,mi],t([ut({converter:t=>{if(Yt(t))return!1;try{return JSON.parse(t)}catch(t){return!0}},reflect:!0,attribute:"locale-number"})],_i.prototype,"localeNumber",void 0),t([pt()],_i.prototype,"localDecimalSeparator",void 0),t([pt()],_i.prototype,"localeGroupingSeparator",void 0),_i=t([lt("timered-counter-number")],_i);const gi=a``
329
330
  /**
330
331
  * @license https://github.com/HarasimowiczKamil/any-base
331
- */;function yi(t,e,i){return s=>function(t,e,i){let s,r,n,{length:o}=i;const a={},l=t.length,c=e.length,h=[];if(!function(t,e){for(const i of t)if(-1===e.indexOf(i))return!1;return!0}(i,t))throw new Error(`Number "${i}" contains of non-alphabetic digits (${t})`);if(Kt(t,e))return i.join("");for(s=0;s<o;s++)a[s]=t.indexOf(i[s]);do{for(r=0,n=0,s=0;s<o;s++)r=r*l+a[s],r>=c?(a[n++]=Math.floor(r/c),r%=c):n>0&&(a[n++]=0);o=n,h.push(e[r])}while(0!==n);return h.reverse().join("")}(t.stringToChars(e),t.stringToChars(i),t.stringToChars(s))}const Ai=" ";let bi=class extends fi{constructor(){super(...arguments),this.__alphabet="",this.__initialValueString="",this.__valueString="",this.__oldValueString="",this.__partsOptions=null,this.__decimalToAnyBase=yi(this.stringAdapter,"0123456789",this.__alphabet),this.__anyBaseToDecimal=yi(this.stringAdapter,this.__alphabet,"0123456789")}get initialValue(){return super.initialValue}set initialValue(t){if(!zt(t))try{t=t.toString()}catch(e){throw new Error(`value ${t} is not a string.`)}this.__initialValueString=t??"",Ft(this.__initialValueString)?super.initialValue=this.numberAdapter.create(0):(this.__updateAlphabet(this.__valueString,this.__initialValueString),super.initialValue=this.numberAdapter.create(this.__anyBaseToDecimal(this.__initialValueString)),super.value=this.numberAdapter.create(this.__anyBaseToDecimal(this.__valueString)))}get value(){return super.value}set value(t){if(zt(t)){if(this.__valueString===t)return}else try{t=t.toString()}catch(e){throw new Error(`value ${t} is not a string.`)}this.__oldValueString=this.__valueString,this.__valueString=t??"",Ft(this.__valueString)?super.value=this.numberAdapter.create(0):(this.__updateAlphabet(this.__valueString,this.__oldValueString),super.oldValue=this.numberAdapter.create(this.__anyBaseToDecimal(this.__oldValueString)),super.value=this.numberAdapter.create(this.__anyBaseToDecimal(this.__valueString)))}get partsOptions(){return super.partsOptions}set partsOptions(t){this.__partsOptions=t,super.partsOptions={type:"string",fillChar:Ai,...this.__partsOptions,digitToChar:{" ":Ai,...this.__partsOptions.digitToChar}}}__updateAlphabet(t,e){const i=Ft(t)&&Ft(e)?"":`\0${e??""}${t??""}`,s=new Set(this.stringAdapter.stringToChars(i));this.__alphabet=Array.from(s).sort().join("");const r=this.stringAdapter,n=this.__alphabet;this.__decimalToAnyBase=yi(r,"0123456789",n),this.__anyBaseToDecimal=yi(r,n,"0123456789")}sampleToString(t){return this.__decimalToAnyBase(this.numberAdapter.toString(t))}connectedCallback(){this.__updateAlphabet(this.__valueString,this.__initialValueString),this.initialValue=this.__initialValueString,this.value=this.__valueString,this.partsOptions=this.__partsOptions??{},super.connectedCallback()}};bi.styles=[...fi.styles,gi],bi=t([lt("timered-counter-string")],bi);const $i=36e5,vi=Symbol.for("constructDateFrom");function Si(t,e){return"function"==typeof t?t(e):t&&"object"==typeof t&&vi in t?t[vi](e):t instanceof Date?new t.constructor(e):new Date(e)}function wi(t,e){return Si(t,t)}function xi(t,e,i){const s=wi(t);return isNaN(e)?Si(t,NaN):e?(s.setDate(s.getDate()+e),s):s}function Ei(t,e,i){const s=wi(t);if(isNaN(e))return Si(t,NaN);if(!e)return s;const r=s.getDate(),n=Si(t,s.getTime());n.setMonth(s.getMonth()+e+1,0);return r>=n.getDate()?n:(s.setFullYear(n.getFullYear(),n.getMonth(),r),s)}function Oi(t,e,i){return Si(t,+wi(t)+e)}function Ci(t){const e=wi(t),i=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return i.setUTCFullYear(e.getFullYear()),+t-+i}function Pi(t,...e){const i=Si.bind(null,e.find((t=>"object"==typeof t)));return e.map(i)}function Di(t,e){const i=wi(t);return i.setHours(0,0,0,0),i}function Ti(t,e){const i=+wi(t)-+wi(e);return i<0?-1:i>0?1:i}function Mi(t){return!(!((e=t)instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))&&"number"!=typeof t||isNaN(+wi(t)));var e}function Ni(t,e,i){const[s,r]=Pi(0,t,e),n=ki(s,r),o=Math.abs(function(t,e){const[i,s]=Pi(0,t,e),r=Di(i),n=Di(s),o=+r-Ci(r),a=+n-Ci(n);return Math.round((o-a)/864e5)}(s,r));s.setDate(s.getDate()-n*o);const a=n*(o-Number(ki(s,r)===-n));return 0===a?0:a}function ki(t,e){const i=t.getFullYear()-e.getFullYear()||t.getMonth()-e.getMonth()||t.getDate()-e.getDate()||t.getHours()-e.getHours()||t.getMinutes()-e.getMinutes()||t.getSeconds()-e.getSeconds()||t.getMilliseconds()-e.getMilliseconds();return i<0?-1:i>0?1:i}function Ri(t){return e=>{const i=(t?Math[t]:Math.trunc)(e);return 0===i?0:i}}function Ui(t,e,i){const[s,r]=Pi(0,t,e),n=(+s-+r)/$i;return Ri(i?.roundingMethod)(n)}function Ii(t,e){return+wi(t)-+wi(e)}function Li(t,e,i){const s=Ii(t,e)/6e4;return Ri(i?.roundingMethod)(s)}function Vi(t,e){const i=wi(t);return+function(t){const e=wi(t);return e.setHours(23,59,59,999),e}(i)==+function(t){const e=wi(t),i=e.getMonth();return e.setFullYear(e.getFullYear(),i+1,0),e.setHours(23,59,59,999),e}(i)}function ji(t,e,i){const[s,r,n]=Pi(0,t,t,e),o=Ti(r,n),a=Math.abs(function(t,e){const[i,s]=Pi(0,t,e);return 12*(i.getFullYear()-s.getFullYear())+(i.getMonth()-s.getMonth())}(r,n));if(a<1)return 0;1===r.getMonth()&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-o*a);let l=Ti(r,n)===-o;Vi(s)&&1===a&&1===Ti(s,n)&&(l=!1);const c=o*(a-+l);return 0===c?0:c}function Hi(t,e,i){const s=ji(t,e)/3;return Ri(i?.roundingMethod)(s)}function Bi(t,e,i){const s=Ii(t,e)/1e3;return Ri(i?.roundingMethod)(s)}function zi(t,e,i){const s=Ni(t,e)/7;return Ri(i?.roundingMethod)(s)}function Fi(t,e,i){const[s,r]=Pi(0,t,e),n=Ti(s,r),o=Math.abs(function(t,e){const[i,s]=Pi(0,t,e);return i.getFullYear()-s.getFullYear()}(s,r));s.setFullYear(1584),r.setFullYear(1584);const a=n*(o-+(Ti(s,r)===-n));return 0===a?0:a}function Yi(t,e){return+wi(t)<+wi(e)}function Wi(t,e,i){return xi(t,-e)}function qi(t,e,i){return function(t,e){return Oi(t,e*$i)}(t,-e)}function Qi(t,e,i){return Oi(t,-e)}function Ki(t,e,i){return function(t,e){const i=wi(t);return i.setTime(i.getTime()+6e4*e),i}(t,-e)}function Gi(t,e,i){return function(t,e){return Ei(t,3*e)}(t,-e)}function Ji(t,e,i){return function(t,e){return Oi(t,1e3*e)}(t,-e)}function Zi(t,e,i){return function(t,e){return xi(t,7*e)}(t,-e)}function Xi(t,e,i){return function(t,e){return Ei(t,12*e)}(t,-e)}var ts;!function(t){t.Millisecond="millisecond",t.Second="second",t.Minute="minute",t.Hour="hour",t.Day="day",t.Week="weekOfYear",t.Month="month",t.Quarter="quarter",t.Year="year"}(ts||(ts={}));const es={[ts.Millisecond]:1,[ts.Second]:1e3,[ts.Minute]:6e4,[ts.Hour]:36e5,[ts.Day]:864e5,[ts.Week]:6048e5,[ts.Month]:26298e5,[ts.Quarter]:78894e5,[ts.Year]:315576e5},is={1:ts.Millisecond,1e3:ts.Second,6e4:ts.Minute,36e5:ts.Hour,864e5:ts.Day,6048e5:ts.Week,26298e5:ts.Month,78894e5:ts.Quarter,315576e5:ts.Year},ss=["era","year","quarter","month","weekOfYear","weekday","day","dayPeriod","hour","minute","second","timeZoneName"];function rs(t,e,i){let s=e;const r={};for(const e of i){let i=0;switch(e){case ts.Year:i=Fi(s,t),s=Xi(s,i);break;case ts.Quarter:i=Hi(s,t),s=Gi(s,i);break;case ts.Month:i=ji(s,t),s=Ei(s,-i);break;case ts.Week:i=zi(s,t),s=Zi(s,i);break;case ts.Day:i=Ni(s,t),s=Wi(s,i);break;case ts.Hour:i=Ui(s,t),s=qi(s,i);break;case ts.Minute:i=Li(s,t),s=Ki(s,i);break;case ts.Second:i=Bi(s,t),s=Ji(s,i);break;case ts.Millisecond:i=Ii(s,t),s=Qi(s,i);break;default:throw new Error(`Unknown duration part: ${e}`)}r[e]=i}return r}function ns(t,e,i){const s=rs(t,e,i);return i.map((t=>s[t]))}const os={[ts.Year]:"Y",[ts.Month]:"M",[ts.Week]:"W",[ts.Day]:"D",[ts.Hour]:"H",[ts.Minute]:"M",[ts.Second]:"S"},as=[ts.Year,ts.Month,ts.Week,ts.Day],ls=[ts.Hour,ts.Minute,ts.Second];const cs=a`
332
+ */;function yi(t,e,i){return s=>function(t,e,i){let s,r,n,{length:o}=i;const a={},l=t.length,c=e.length,h=[];if(!function(t,e){for(const i of t)if(-1===e.indexOf(i))return!1;return!0}(i,t))throw new Error(`Number "${i}" contains of non-alphabetic digits (${t})`);if(Kt(t,e))return i.join("");for(s=0;s<o;s++)a[s]=t.indexOf(i[s]);do{for(r=0,n=0,s=0;s<o;s++)r=r*l+a[s],r>=c?(a[n++]=Math.floor(r/c),r%=c):n>0&&(a[n++]=0);o=n,h.push(e[r])}while(0!==n);return h.reverse().join("")}(t.stringToChars(e),t.stringToChars(i),t.stringToChars(s))}const Ai=" ";let bi=class extends fi{constructor(){super(...arguments),this.__alphabet="",this.__initialValueString="",this.__valueString="",this.__oldValueString="",this.__partsOptions=null,this.__decimalToAnyBase=yi(this.stringAdapter,"0123456789",this.__alphabet),this.__anyBaseToDecimal=yi(this.stringAdapter,this.__alphabet,"0123456789")}get initialValue(){return super.initialValue}set initialValue(t){if(!zt(t))try{t=t.toString()}catch(e){throw new Error(`value ${t} is not a string.`)}this.__initialValueString=t??"",Ft(this.__initialValueString)?super.initialValue=this.numberAdapter.create(0):(this.__updateAlphabet(this.__valueString,this.__initialValueString),super.initialValue=this.numberAdapter.create(this.__anyBaseToDecimal(this.__initialValueString)),super.value=this.numberAdapter.create(this.__anyBaseToDecimal(this.__valueString)))}get value(){return super.value}set value(t){if(zt(t)){if(this.__valueString===t)return}else try{t=t.toString()}catch(e){throw new Error(`value ${t} is not a string.`)}this.__oldValueString=this.__valueString,this.__valueString=t??"",Ft(this.__valueString)?super.value=this.numberAdapter.create(0):(this.__updateAlphabet(this.__valueString,this.__oldValueString),super.oldValue=this.numberAdapter.create(this.__anyBaseToDecimal(this.__oldValueString)),super.value=this.numberAdapter.create(this.__anyBaseToDecimal(this.__valueString)))}get partsOptions(){return super.partsOptions}set partsOptions(t){this.__partsOptions=t,super.partsOptions={type:"string",fillChar:Ai,...this.__partsOptions,digitToChar:{" ":Ai,...this.__partsOptions.digitToChar}}}__updateAlphabet(t,e){const i=Ft(t)&&Ft(e)?"":`\0${e??""}${t??""}`,s=new Set(this.stringAdapter.stringToChars(i));this.__alphabet=Array.from(s).sort().join("");const r=this.stringAdapter,n=this.__alphabet;this.__decimalToAnyBase=yi(r,"0123456789",n),this.__anyBaseToDecimal=yi(r,n,"0123456789")}sampleToString(t){return this.__decimalToAnyBase(this.numberAdapter.toString(t))}connectedCallback(){this.__updateAlphabet(this.__valueString,this.__initialValueString),this.initialValue=this.__initialValueString,this.value=this.__valueString,this.partsOptions=this.__partsOptions??{},super.connectedCallback()}};bi.styles=[...fi.styles,gi],bi=t([lt("timered-counter-string")],bi);const $i=36e5,vi=Symbol.for("constructDateFrom");function Si(t,e){return"function"==typeof t?t(e):t&&"object"==typeof t&&vi in t?t[vi](e):t instanceof Date?new t.constructor(e):new Date(e)}function wi(t,e){return Si(t,t)}function xi(t,e,i){const s=wi(t);return isNaN(e)?Si(t,NaN):e?(s.setDate(s.getDate()+e),s):s}function Ei(t,e,i){const s=wi(t);if(isNaN(e))return Si(t,NaN);if(!e)return s;const r=s.getDate(),n=Si(t,s.getTime());n.setMonth(s.getMonth()+e+1,0);return r>=n.getDate()?n:(s.setFullYear(n.getFullYear(),n.getMonth(),r),s)}function Oi(t,e,i){return Si(t,+wi(t)+e)}function Ci(t){const e=wi(t),i=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return i.setUTCFullYear(e.getFullYear()),+t-+i}function Pi(t,...e){const i=Si.bind(null,e.find((t=>"object"==typeof t)));return e.map(i)}function Di(t,e){const i=wi(t);return i.setHours(0,0,0,0),i}function Ti(t,e){const i=+wi(t)-+wi(e);return i<0?-1:i>0?1:i}function Mi(t){return!(!((e=t)instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e))&&"number"!=typeof t||isNaN(+wi(t)));var e}function Ni(t,e,i){const[s,r]=Pi(0,t,e),n=Ri(s,r),o=Math.abs(function(t,e){const[i,s]=Pi(0,t,e),r=Di(i),n=Di(s),o=+r-Ci(r),a=+n-Ci(n);return Math.round((o-a)/864e5)}(s,r));s.setDate(s.getDate()-n*o);const a=n*(o-Number(Ri(s,r)===-n));return 0===a?0:a}function Ri(t,e){const i=t.getFullYear()-e.getFullYear()||t.getMonth()-e.getMonth()||t.getDate()-e.getDate()||t.getHours()-e.getHours()||t.getMinutes()-e.getMinutes()||t.getSeconds()-e.getSeconds()||t.getMilliseconds()-e.getMilliseconds();return i<0?-1:i>0?1:i}function ki(t){return e=>{const i=(t?Math[t]:Math.trunc)(e);return 0===i?0:i}}function Ui(t,e,i){const[s,r]=Pi(0,t,e),n=(+s-+r)/$i;return ki(i?.roundingMethod)(n)}function Ii(t,e){return+wi(t)-+wi(e)}function Li(t,e,i){const s=Ii(t,e)/6e4;return ki(i?.roundingMethod)(s)}function Vi(t,e){const i=wi(t);return+function(t){const e=wi(t);return e.setHours(23,59,59,999),e}(i)==+function(t){const e=wi(t),i=e.getMonth();return e.setFullYear(e.getFullYear(),i+1,0),e.setHours(23,59,59,999),e}(i)}function ji(t,e,i){const[s,r,n]=Pi(0,t,t,e),o=Ti(r,n),a=Math.abs(function(t,e){const[i,s]=Pi(0,t,e);return 12*(i.getFullYear()-s.getFullYear())+(i.getMonth()-s.getMonth())}(r,n));if(a<1)return 0;1===r.getMonth()&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-o*a);let l=Ti(r,n)===-o;Vi(s)&&1===a&&1===Ti(s,n)&&(l=!1);const c=o*(a-+l);return 0===c?0:c}function Hi(t,e,i){const s=ji(t,e)/3;return ki(i?.roundingMethod)(s)}function Bi(t,e,i){const s=Ii(t,e)/1e3;return ki(i?.roundingMethod)(s)}function zi(t,e,i){const s=Ni(t,e)/7;return ki(i?.roundingMethod)(s)}function Fi(t,e,i){const[s,r]=Pi(0,t,e),n=Ti(s,r),o=Math.abs(function(t,e){const[i,s]=Pi(0,t,e);return i.getFullYear()-s.getFullYear()}(s,r));s.setFullYear(1584),r.setFullYear(1584);const a=n*(o-+(Ti(s,r)===-n));return 0===a?0:a}function Yi(t,e){return+wi(t)<+wi(e)}function Wi(t,e,i){return xi(t,-e)}function qi(t,e,i){return function(t,e){return Oi(t,e*$i)}(t,-e)}function Qi(t,e,i){return Oi(t,-e)}function Ki(t,e,i){return function(t,e){const i=wi(t);return i.setTime(i.getTime()+6e4*e),i}(t,-e)}function Gi(t,e,i){return function(t,e){return Ei(t,3*e)}(t,-e)}function Ji(t,e,i){return function(t,e){return Oi(t,1e3*e)}(t,-e)}function Zi(t,e,i){return function(t,e){return xi(t,7*e)}(t,-e)}function Xi(t,e,i){return function(t,e){return Ei(t,12*e)}(t,-e)}var ts;!function(t){t.Millisecond="millisecond",t.Second="second",t.Minute="minute",t.Hour="hour",t.Day="day",t.Week="weekOfYear",t.Month="month",t.Quarter="quarter",t.Year="year"}(ts||(ts={}));const es={[ts.Millisecond]:1,[ts.Second]:1e3,[ts.Minute]:6e4,[ts.Hour]:36e5,[ts.Day]:864e5,[ts.Week]:6048e5,[ts.Month]:26298e5,[ts.Quarter]:78894e5,[ts.Year]:315576e5},is={1:ts.Millisecond,1e3:ts.Second,6e4:ts.Minute,36e5:ts.Hour,864e5:ts.Day,6048e5:ts.Week,26298e5:ts.Month,78894e5:ts.Quarter,315576e5:ts.Year},ss=["era","year","quarter","month","weekOfYear","weekday","day","dayPeriod","hour","minute","second","timeZoneName"];function rs(t,e,i){let s=e;const r={};for(const e of i){let i=0;switch(e){case ts.Year:i=Fi(s,t),s=Xi(s,i);break;case ts.Quarter:i=Hi(s,t),s=Gi(s,i);break;case ts.Month:i=ji(s,t),s=Ei(s,-i);break;case ts.Week:i=zi(s,t),s=Zi(s,i);break;case ts.Day:i=Ni(s,t),s=Wi(s,i);break;case ts.Hour:i=Ui(s,t),s=qi(s,i);break;case ts.Minute:i=Li(s,t),s=Ki(s,i);break;case ts.Second:i=Bi(s,t),s=Ji(s,i);break;case ts.Millisecond:i=Ii(s,t),s=Qi(s,i);break;default:throw new Error(`Unknown duration part: ${e}`)}r[e]=i}return r}function ns(t,e,i){const s=rs(t,e,i);return i.map((t=>s[t]))}const os={[ts.Year]:"Y",[ts.Month]:"M",[ts.Week]:"W",[ts.Day]:"D",[ts.Hour]:"H",[ts.Minute]:"M",[ts.Second]:"S"},as=[ts.Year,ts.Month,ts.Week,ts.Day],ls=[ts.Hour,ts.Minute,ts.Second];const cs=a`
332
333
  ::part(part-suffix) {
333
334
  font-size: 0.4em;
334
335
  line-height: 1;
335
336
  }
336
- `;function hs(t,e){zt(t)&&(t=ce(t)),Wt(t)||(t=[t,t]);const i=[Qt(t[0])?t[0]:wi(t[0]),Qt(t[1])?t[1]:wi(t[1])];if(!Mi(i[0])||!Mi(i[1]))throw new Error(`value ${t[0]} or ${t[1]} is not a valid date.`);const s=Math.abs(i[1].getTime()-function(t,e,i){const s=es[i],r=t.getTime(),n=e.getTime();return r-r%s+(Math.abs(n-r)%s>0?(r<n?-1:1)*s:0)+n%s}(i[0],i[1],e));return{durationInMilliseconds:s,from:i[0],to:i[1]}}let us=class extends fi{constructor(){super(...arguments),this.__precision=[ts.Second,ts.Day],this.__initialValuePlain=null,this.__partsOptions=null,this.__from=new Date,this.__to=new Date,this.__minPrecision=ts.Second,this.__maxPrecision=ts.Day,this.__availableDurationParts=[],this.__dateTimeFieldLabels={}}get precision(){return this.__precision}set precision(t){zt(t)&&(t=ce(t)),this.__precision=t,this.__minPrecision=Wt(this.__precision)?this.__precision[0]:this.__precision,this.__maxPrecision=Wt(this.__precision)?this.__precision[1]:this.__precision,this.__availableDurationParts=Object.values(ts).reverse().map((t=>{const e=es[this.__minPrecision],i=es[this.__maxPrecision],s=es[t];return{type:t,available:s>=e&&s<=i}})).filter((t=>t.available))}get value(){return super.value}set value(t){const{from:e,to:i,durationInMilliseconds:s}=hs(t,this.__minPrecision);this.__from=e,this.__to=i,super.value=s}get initialValue(){return super.initialValue}set initialValue(t){this.__initialValuePlain=t;const{durationInMilliseconds:e}=hs(t,this.__minPrecision);super.initialValue=e}get partsOptions(){return super.partsOptions}set partsOptions(t){this.__partsOptions=t,super.partsOptions={minPlaces:[2,void 0],...this.__partsOptions}}sampleSplit(t){const e=Vt(this.__availableDurationParts,(t=>t.type)),i=e.map((()=>[]));for(const s of t){const t=this.numberAdapter.toNumber(s);ns(new Date(Math.min(t,0)),new Date(Math.max(t,0)),e).forEach(((t,e)=>i[e].push(t)))}return i}generateAriaLabel(){return function(t){const e=as.map((e=>Bt(t[e])?`${t[e]}${os[e]}`:"")),i=ls.map((e=>Bt(t[e])?`${t[e]}${os[e]}`:""));return`P${e.join("")}T${i.join("")}`}(rs(Yi(this.__from,this.__to)?this.__from:this.__to,Yi(this.__from,this.__to)?this.__to:this.__from,Vt(this.__availableDurationParts,(t=>t.type))))}connectedCallback(){this.role="timer",this.partsOptions=this.__partsOptions??{},this.initialValue=this.__initialValuePlain,this.precision=this.__precision,super.connectedCallback()}willUpdate(t){super.willUpdate(t),t.has("locale")&&(this.__dateTimeFieldLabels=function(t){const e=new Intl.DisplayNames(t,{type:"dateTimeField"});return ss.reduce(((t,i)=>(t[i]=e.of(i)??"",t)),{})}(this.localeInstance))}render(){const t=this.extractCellStyles(),e=this.extractDigitStyles(),i=this.extractPartStyles(),s=this.extractAnimationOptions(),r=this.extractKeyframes(),n=Vt(this.__availableDurationParts,(t=>t.type));return z`
337
+ `;function hs(t,e){zt(t)&&(t=ce(t)),Wt(t)||(t=[t,t]);const i=[Qt(t[0])?t[0]:wi(t[0]),Qt(t[1])?t[1]:wi(t[1])];if(!Mi(i[0])||!Mi(i[1]))throw new Error(`value ${t[0]} or ${t[1]} is not a valid date.`);const s=Math.abs(i[1].getTime()-function(t,e,i){const s=es[i],r=t.getTime();return r-r%s+e.getTime()%s}(i[0],i[1],e));return{durationInMilliseconds:s,from:i[0],to:i[1]}}let us=class extends fi{constructor(){super(...arguments),this.__precision=[ts.Second,ts.Day],this.__initialValuePlain=null,this.__partsOptions=null,this.__from=new Date,this.__to=new Date,this.__minPrecision=ts.Second,this.__maxPrecision=ts.Day,this.__availableDurationParts=[],this.__dateTimeFieldLabels={}}get precision(){return this.__precision}set precision(t){zt(t)&&(t=ce(t)),this.__precision=t,this.__minPrecision=Wt(this.__precision)?this.__precision[0]:this.__precision,this.__maxPrecision=Wt(this.__precision)?this.__precision[1]:this.__precision,this.__availableDurationParts=Object.values(ts).reverse().map((t=>{const e=es[this.__minPrecision],i=es[this.__maxPrecision],s=es[t];return{type:t,available:s>=e&&s<=i}})).filter((t=>t.available))}get value(){return super.value}set value(t){const{from:e,to:i,durationInMilliseconds:s}=hs(t,this.__minPrecision);this.__from=e,this.__to=i,super.value=s}get initialValue(){return super.initialValue}set initialValue(t){this.__initialValuePlain=t;const{durationInMilliseconds:e}=hs(t,this.__minPrecision);super.initialValue=e}get partsOptions(){return super.partsOptions}set partsOptions(t){this.__partsOptions=t,super.partsOptions={minPlaces:[2,void 0],...this.__partsOptions}}sampleSplit(t){const e=Vt(this.__availableDurationParts,(t=>t.type)),i=e.map((()=>[]));for(const s of t){const t=this.numberAdapter.toNumber(s);ns(new Date(Math.min(t,0)),new Date(Math.max(t,0)),e).forEach(((t,e)=>i[e].push(t)))}return i}generateAriaLabel(){return function(t){const e=as.map((e=>Bt(t[e])?`${t[e]}${os[e]}`:"")),i=ls.map((e=>Bt(t[e])?`${t[e]}${os[e]}`:""));return`P${e.join("")}T${i.join("")}`}(rs(Yi(this.__from,this.__to)?this.__from:this.__to,Yi(this.__from,this.__to)?this.__to:this.__from,Vt(this.__availableDurationParts,(t=>t.type))))}connectedCallback(){this.role="timer",this.partsOptions=this.__partsOptions??{},this.initialValue=this.__initialValuePlain,this.precision=this.__precision,super.connectedCallback()}shouldRebuildParts(t){return super.shouldRebuildParts(t)||t.has("precision")}willUpdate(t){super.willUpdate(t),t.has("locale")&&(this.__dateTimeFieldLabels=function(t){const e=new Intl.DisplayNames(t,{type:"dateTimeField"});return ss.reduce(((t,i)=>(t[i]=e.of(i)??"",t)),{})}(this.localeInstance))}render(){const t=this.extractCellStyles(),e=this.extractDigitStyles(),i=this.extractPartStyles(),s=this.extractAnimationOptions(),r=this.extractKeyframes(),n=Vt(this.__availableDurationParts,(t=>t.type));return z`
337
338
  <timered-counter-roller
338
339
  class="timered-counter timered-counter-datetime-duration"
339
340
  exportparts="group, part, digit, cell, prefix, suffix, part-suffix"
@@ -356,5 +357,5 @@ function dt(t,e){return(e,i,s)=>((t,e,i)=>(i.configurable=!0,i.enumerable=!0,Ref
356
357
  >${this.__dateTimeFieldLabels[n[e]]}</span
357
358
  >`))}
358
359
  </timered-counter-roller>
359
- `}};us.styles=[...fi.styles,cs],t([ut({reflect:!0,converter:t=>Yt(t)?t:ce(t)})],us.prototype,"precision",null),us=t([lt("timered-counter-datetime-duration")],us);const ps=t=>t;export{es as DurationPartMillisecond,is as DurationPartMillisecondToType,ts as DurationPartType,fi as TimeredCounter,fe as TimeredCounterAdapter,us as TimeredCounterDatetimeDuration,_i as TimeredCounterNumber,bi as TimeredCounterString,De as cubicBezier,Ze as easeInBack,ni as easeInBounce,Ke as easeInCirc,Ie as easeInCubic,ei as easeInElastic,We as easeInExpo,ti as easeInOutBack,oi as easeInOutBounce,Je as easeInOutCirc,Ve as easeInOutCubic,si as easeInOutElastic,Qe as easeInOutExpo,Ue as easeInOutQuad,Be as easeInOutQuart,Ye as easeInOutQuint,Ne as easeInOutSine,ke as easeInQuad,je as easeInQuart,ze as easeInQuint,Te as easeInSine,Xe as easeOutBack,ri as easeOutBounce,Ge as easeOutCirc,Le as easeOutCubic,ii as easeOutElastic,qe as easeOutExpo,Re as easeOutQuad,He as easeOutQuart,Fe as easeOutQuint,Me as easeOutSine,ps as linear,Ce as noop,ge as registerNumberAdapter,ye as registerStringAdapter,me as setNumberAdapter,_e as setStringAdapter};
360
+ `}};us.styles=[...fi.styles,cs],t([ut({reflect:!0,converter:t=>Yt(t)?t:ce(t)})],us.prototype,"precision",null),us=t([lt("timered-counter-datetime-duration")],us);const ps=t=>t;export{es as DurationPartMillisecond,is as DurationPartMillisecondToType,ts as DurationPartType,fi as TimeredCounter,fe as TimeredCounterAdapter,us as TimeredCounterDatetimeDuration,_i as TimeredCounterNumber,bi as TimeredCounterString,De as cubicBezier,Ze as easeInBack,ni as easeInBounce,Ke as easeInCirc,Ie as easeInCubic,ei as easeInElastic,We as easeInExpo,ti as easeInOutBack,oi as easeInOutBounce,Je as easeInOutCirc,Ve as easeInOutCubic,si as easeInOutElastic,Qe as easeInOutExpo,Ue as easeInOutQuad,Be as easeInOutQuart,Ye as easeInOutQuint,Ne as easeInOutSine,Re as easeInQuad,je as easeInQuart,ze as easeInQuint,Te as easeInSine,Xe as easeOutBack,ri as easeOutBounce,Ge as easeOutCirc,Le as easeOutCubic,ii as easeOutElastic,qe as easeOutExpo,ke as easeOutQuad,He as easeOutQuart,Fe as easeOutQuint,Me as easeOutSine,ps as linear,Ce as noop,ge as registerNumberAdapter,ye as registerStringAdapter,me as setNumberAdapter,_e as setStringAdapter};
360
361
  //# sourceMappingURL=timered-counter.esm-browser.js.map