@file:Suppress("UNCHECKED_CAST", "USELESS_CAST", "INAPPLICABLE_JVM_NAME", "UNUSED_ANONYMOUS_PARAMETER", "SENSELESS_COMPARISON", "NAME_SHADOWING", "UNNECESSARY_NOT_NULL_ASSERTION")
package uni.UNIHelloUniAppX
import io.dcloud.uniapp.*
import io.dcloud.uniapp.extapi.*
import io.dcloud.uniapp.framework.*
import io.dcloud.uniapp.runtime.*
import io.dcloud.uniapp.vue.*
import io.dcloud.uniapp.vue.shared.*
import io.dcloud.unicloud.*
import io.dcloud.uts.*
import io.dcloud.uts.Map
import io.dcloud.uts.Set
import io.dcloud.uts.UTSAndroid
import kotlin.properties.Delegates
open class GenPagesUniUiTimeFormatTimeFormat : BasePage {
    constructor(__ins: ComponentInternalInstance, __renderer: String?) : super(__ins, __renderer) {
        onLoad(fun(_: OnLoadOptions) {
            stat_instance.onLoad(this)
        }
        , __ins)
        onPageShow(fun() {
            stat_instance.onShow(this)
        }
        , __ins)
        onPageHide(fun() {
            stat_instance.onHide(this)
        }
        , __ins)
        onUnload(fun() {
            stat_instance.onUnload(this)
        }
        , __ins)
    }
    open var data: Data__4
        get() {
            return unref(this.`$exposed`["data"]) as Data__4
        }
        set(value) {
            setRefValue(this.`$exposed`, "data", value)
        }
    companion object {
        @Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
        var setup: (__props: GenPagesUniUiTimeFormatTimeFormat, __setupCtx: SetupContext) -> Any? = fun(__props, __setupCtx): Any? {
            val __expose = __setupCtx.expose
            val __ins = getCurrentInstance()!!
            val _ctx = __ins.proxy as GenPagesUniUiTimeFormatTimeFormat
            val _cache = __ins.renderCache
            val data = reactive<Data__4>(Data__4(currentTimestamp = Date.now(), invalidTimestamp = NaN, relativeDateTimeText = ""))
            var timer: Number? = null
            val DAY_MS: Number = 86400000
            val pageOpenTimestamp = Date.now()
            val pageOpenDate = Date(pageOpenTimestamp)
            fun gen_padZero_fn(value: Number): String {
                return if (value < 10) {
                    "0" + value
                } else {
                    "" + value
                }
            }
            val padZero = ::gen_padZero_fn
            fun gen_formatDateTimeText_fn(date: Date): String {
                return "" + date.getFullYear() + "-" + padZero(date.getMonth() + 1) + "-" + padZero(date.getDate()) + " " + padZero(date.getHours()) + ":" + padZero(date.getMinutes()) + ":" + padZero(date.getSeconds())
            }
            val formatDateTimeText = ::gen_formatDateTimeText_fn
            fun gen_toSafeInt_fn(text: String): Number? {
                val value = parseInt(text)
                if (isNaN(value)) {
                    return null
                }
                return value
            }
            val toSafeInt = ::gen_toSafeInt_fn
            fun gen_parseDateTimeText_fn(text: String): Number? {
                if (text.length != 19) {
                    return null
                }
                if (text.substring(4, 5) != "-" || text.substring(7, 8) != "-" || text.substring(10, 11) != " " || text.substring(13, 14) != ":" || text.substring(16, 17) != ":") {
                    return null
                }
                val year = toSafeInt(text.substring(0, 4))
                val month = toSafeInt(text.substring(5, 7))
                val day = toSafeInt(text.substring(8, 10))
                val hours = toSafeInt(text.substring(11, 13))
                val minutes = toSafeInt(text.substring(14, 16))
                val seconds = toSafeInt(text.substring(17, 19))
                if (year == null || month == null || day == null || hours == null || minutes == null || seconds == null) {
                    return null
                }
                val date = Date(year, month - 1, day, hours, minutes, seconds)
                if (date.getFullYear() != year || date.getMonth() != month - 1 || date.getDate() != day || date.getHours() != hours || date.getMinutes() != minutes || date.getSeconds() != seconds) {
                    return null
                }
                return date.getTime()
            }
            val parseDateTimeText = ::gen_parseDateTimeText_fn
            val pageOpenDateText = formatDateTimeText(pageOpenDate)
            data.relativeDateTimeText = pageOpenDateText
            val inputRelativeTimestamp = computed(fun(): Number {
                val parsed = parseDateTimeText(data.relativeDateTimeText)
                if (parsed != null) {
                    return parsed
                }
                return NaN
            }
            )
            val fixedDayStartTimestamp = Date(pageOpenDate.getFullYear(), pageOpenDate.getMonth(), pageOpenDate.getDate()).getTime()
            val fixedJustNowTimestamp = pageOpenTimestamp - 20000
            val fixedFiveMinutesAgoTimestamp = pageOpenTimestamp - 300000
            val fixedHourBranchTimestamp = (fun(): Number {
                val fiveHoursAgo = pageOpenTimestamp - 18000000
                if (fiveHoursAgo >= fixedDayStartTimestamp) {
                    return fiveHoursAgo
                }
                val oneHourAgo = pageOpenTimestamp - 3600000
                if (oneHourAgo >= fixedDayStartTimestamp) {
                    return oneHourAgo
                }
                return pageOpenTimestamp - 60000
            }
            )()
            val fixedYesterdayTimestamp = fixedDayStartTimestamp - 3000000
            val fixedOlderThanYesterdayTimestamp = fixedDayStartTimestamp - 2 * DAY_MS - 1800000
            val secondTimestamp = computed(fun(): Number {
                return Math.floor(data.currentTimestamp / 1000)
            }
            )
            onMounted(fun(){
                timer = setInterval(fun(){
                    data.currentTimestamp = Date.now()
                }
                , 1000)
            }
            )
            onUnmounted(fun(){
                val currentTimer = timer
                if (currentTimer != null) {
                    clearInterval(currentTimer)
                    timer = null
                }
            }
            )
            __expose(_uM("data" to data, "inputRelativeTimestamp" to inputRelativeTimestamp, "secondTimestamp" to secondTimestamp))
            return fun(): Any? {
                val _component_uni_time_format = resolveEasyComponent("uni-time-format", GenUniModulesUniTimeFormatComponentsUniTimeFormatUniTimeFormatClass)
                return _cE("scroll-view", _uM("class" to "page"), _uA(
                    _cE("view", _uM("class" to "section"), _uA(
                        _cE("text", _uM("class" to "section-title"), "当前时间不同格式"),
                        _cE("view", _uM("class" to "row"), _uA(
                            _cE("text", _uM("class" to "row-label"), "date"),
                            _cV(_component_uni_time_format, _uM("timestamp" to unref(data).currentTimestamp, "format" to "date"), null, 8, _uA(
                                "timestamp"
                            ))
                        )),
                        _cE("view", _uM("class" to "row"), _uA(
                            _cE("text", _uM("class" to "row-label"), "time"),
                            _cV(_component_uni_time_format, _uM("timestamp" to unref(data).currentTimestamp, "format" to "time"), null, 8, _uA(
                                "timestamp"
                            ))
                        )),
                        _cE("view", _uM("class" to "row"), _uA(
                            _cE("text", _uM("class" to "row-label"), "datetime"),
                            _cV(_component_uni_time_format, _uM("timestamp" to unref(data).currentTimestamp, "format" to "datetime"), null, 8, _uA(
                                "timestamp"
                            ))
                        ))
                    )),
                    _cE("view", _uM("class" to "section"), _uA(
                        _cE("text", _uM("class" to "section-title"), "输入时间动态计算相对时间"),
                        _cE("view", _uM("class" to "input-block"), _uA(
                            _cE("text", _uM("class" to "row-label"), "输入格式"),
                            _cE("text", _uM("class" to "tip-text"), "yyyy-mm-dd hh:mm:ss"),
                            _cE("input", _uM("class" to "datetime-input", "modelValue" to unref(data).relativeDateTimeText, "onInput" to fun(`$event`: UniInputEvent){
                                unref(data).relativeDateTimeText = `$event`.detail.value
                            }
                            , "placeholder" to "yyyy-mm-dd hh:mm:ss"), null, 40, _uA(
                                "modelValue",
                                "onInput"
                            ))
                        )),
                        _cE("view", _uM("class" to "row"), _uA(
                            _cE("text", _uM("class" to "row-label"), "输出相对时间"),
                            _cV(_component_uni_time_format, _uM("timestamp" to unref(inputRelativeTimestamp), "format" to "relative"), null, 8, _uA(
                                "timestamp"
                            ))
                        ))
                    )),
                    _cE("view", _uM("class" to "section"), _uA(
                        _cE("text", _uM("class" to "section-title"), "固定 5 分支示例（不随输入变化）"),
                        _cE("view", _uM("class" to "row"), _uA(
                            _cE("text", _uM("class" to "row-label"), "刚刚"),
                            _cV(_component_uni_time_format, _uM("timestamp" to fixedJustNowTimestamp, "format" to "relative"))
                        )),
                        _cE("view", _uM("class" to "row"), _uA(
                            _cE("text", _uM("class" to "row-label"), "分钟前"),
                            _cV(_component_uni_time_format, _uM("timestamp" to fixedFiveMinutesAgoTimestamp, "format" to "relative"))
                        )),
                        _cE("view", _uM("class" to "row"), _uA(
                            _cE("text", _uM("class" to "row-label"), "小时前"),
                            _cV(_component_uni_time_format, _uM("timestamp" to unref(fixedHourBranchTimestamp), "format" to "relative"), null, 8, _uA(
                                "timestamp"
                            ))
                        )),
                        _cE("view", _uM("class" to "row"), _uA(
                            _cE("text", _uM("class" to "row-label"), "昨天 HH:mm"),
                            _cV(_component_uni_time_format, _uM("timestamp" to fixedYesterdayTimestamp, "format" to "relative"))
                        )),
                        _cE("view", _uM("class" to "row"), _uA(
                            _cE("text", _uM("class" to "row-label"), "超过昨天"),
                            _cV(_component_uni_time_format, _uM("timestamp" to fixedOlderThanYesterdayTimestamp, "format" to "relative"))
                        )),
                        _cE("text", _uM("class" to "tip-text"), "固定示例基于页面打开时刻计算，不随输入变化。")
                    )),
                    _cE("view", _uM("class" to "section"), _uA(
                        _cE("text", _uM("class" to "section-title"), "秒级时间戳自动换算"),
                        _cE("view", _uM("class" to "row"), _uA(
                            _cE("text", _uM("class" to "row-label"), "timestamp(s)"),
                            _cV(_component_uni_time_format, _uM("timestamp" to unref(secondTimestamp), "format" to "datetime"), null, 8, _uA(
                                "timestamp"
                            ))
                        ))
                    )),
                    _cE("view", _uM("class" to "section"), _uA(
                        _cE("text", _uM("class" to "section-title"), "非法时间戳"),
                        _cE("view", _uM("class" to "row"), _uA(
                            _cV(_component_uni_time_format, _uM("timestamp" to unref(data).invalidTimestamp, "format" to "datetime"), null, 8, _uA(
                                "timestamp"
                            ))
                        )),
                        _cE("text", _uM("class" to "tip-text"), "非法时间会显示为空字符串。")
                    ))
                ))
            }
        }
        val styles: Map<String, Map<String, Map<String, Any>>> by lazy {
            _nCS(_uA(
                styles0
            ))
        }
        val styles0: Map<String, Map<String, Map<String, Any>>>
            get() {
                return _uM("page" to _pS(_uM("flexGrow" to 1, "flexShrink" to 1, "flexBasis" to "0%", "paddingTop" to 12, "paddingRight" to 12, "paddingBottom" to 12, "paddingLeft" to 12)), "section" to _pS(_uM("marginBottom" to 20)), "section-title" to _pS(_uM("fontSize" to 16, "color" to "var(--text-color, #333333)")), "input-block" to _pS(_uM("marginTop" to 8, "marginBottom" to 8)), "datetime-input" to _pS(_uM("marginTop" to 8, "marginBottom" to 6, "borderTopWidth" to 1, "borderRightWidth" to 1, "borderBottomWidth" to 1, "borderLeftWidth" to 1, "borderTopStyle" to "solid", "borderRightStyle" to "solid", "borderBottomStyle" to "solid", "borderLeftStyle" to "solid", "borderTopColor" to "var(--border-color, #dddddd)", "borderRightColor" to "var(--border-color, #dddddd)", "borderBottomColor" to "var(--border-color, #dddddd)", "borderLeftColor" to "var(--border-color, #dddddd)", "height" to 38, "paddingLeft" to 10, "paddingRight" to 10, "color" to "var(--text-color, #333333)")), "row" to _pS(_uM("flexDirection" to "row", "alignItems" to "center", "justifyContent" to "space-between", "marginTop" to 8)), "row-label" to _pS(_uM("fontSize" to 14, "color" to "var(--text-color, #333333)", "opacity" to 0.75)), "tip-text" to _pS(_uM("marginTop" to 4, "fontSize" to 12, "color" to "var(--text-color, #333333)", "opacity" to 0.6)))
            }
        var inheritAttrs = true
        var inject: Map<String, Map<String, Any?>> = _uM()
        var emits: Map<String, Any?> = _uM()
        var props = _nP(_uM())
        var propsNeedCastKeys: UTSArray<String> = _uA()
        var components: Map<String, CreateVueComponent> = _uM()
    }
}
