@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
import io.dcloud.uniapp.extapi.createSelectorQuery as uni_createSelectorQuery
import io.dcloud.uniapp.extapi.getAppBaseInfo as uni_getAppBaseInfo
import io.dcloud.uniapp.extapi.getWindowInfo as uni_getWindowInfo
open class GenUniModulesUniDragCellComponentsUniDragCellUniDragCell : VueComponent {
    constructor(__ins: ComponentInternalInstance) : super(__ins) {}
    open var modelValue: UTSArray<Any?>? by `$props`
    open var column: Number by `$props`
    open var showClose: Boolean by `$props`
    open var showAppend: Boolean by `$props`
    open var handleMode: Boolean by `$props`
    companion object {
        @Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
        var setup: (__props: GenUniModulesUniDragCellComponentsUniDragCellUniDragCell) -> Any? = fun(__props): Any? {
            val __ins = getCurrentInstance()!!
            val _ctx = __ins.proxy as GenUniModulesUniDragCellComponentsUniDragCellUniDragCell
            val _cache = __ins.renderCache
            val props = __props
            fun emit(event: String, vararg do_not_transform_spread: Any?) {
                __ins.emit(event, *do_not_transform_spread)
            }
            val instance = getCurrentInstance()
            val slots = useSlots()
            val innerList = ref(if (props.modelValue != null) {
                props.modelValue!!.slice()
            } else {
                _uA()
            }
            )
            val itemIds = ref(_uA<Number>())
            val layouts = ref(_uA<ItemLayout>())
            val gridColumnCenters = ref(_uA<Number>())
            val gridRowCenters = ref(_uA<Number>())
            val previewItemIds = ref(_uA<Number>())
            val settling = ref(false)
            val dragging = ref(false)
            val activeIndex = ref(-1)
            val hoverIndex = ref(-1)
            val dragOffsetX = ref(0)
            val dragOffsetY = ref(0)
            val startTouchX = ref(0)
            val startTouchY = ref(0)
            val pendingIndex = ref(-1)
            val overDeleteBar = ref(false)
            val containerLayout = ref<ContainerLayout?>(null)
            val activeViewLeft = ref(0)
            val activeViewTop = ref(0)
            val dragCoordOffsetX = ref(0)
            val dragCoordOffsetY = ref(0)
            val nextItemId = ref(0)
            var longPressTimer: Number = 0
            val longPressDuration: Number = 350
            val pressCancelDistance: Number = 10
            val dragActiveScale: Number = 1.12
            val deleteBarHeight: Number = 56
            var touchVersion: Number = 0
            open class TouchContext {
                open lateinit var index: Number
                open lateinit var version: Number
                constructor(index: Number){
                    this.index = index
                    this.version = touchVersion
                }
            }
            val columnCount = computed(fun(): Number {
                val currentColumn = props.column as Number
                if (currentColumn <= 0) {
                    return 0
                }
                return Math.floor(currentColumn)
            }
            )
            val containerClass = computed(fun(): String {
                return if (columnCount.value > 0) {
                    "drag-cell-grid"
                } else {
                    "drag-cell-row"
                }
            }
            )
            val showClose = computed(fun(): Boolean {
                return props.showClose == true
            }
            )
            val showAppendSlot = computed(fun(): Boolean {
                return props.showAppend == true && slots["append"] != null
            }
            )
            val handleModeEnabled = computed(fun(): Boolean {
                return props.handleMode == true && slots["handle"] != null
            }
            )
            val showDeleteBar = computed(fun(): Boolean {
                return showClose.value && dragging.value
            }
            )
            val activeDragScale = computed(fun(): Number {
                return if (handleModeEnabled.value) {
                    1
                } else {
                    dragActiveScale
                }
            }
            )
            var useDeleteProxyForDeleteDrag = false
            useDeleteProxyForDeleteDrag = true
            val showDeleteProxy = computed(fun(): Boolean {
                return useDeleteProxyForDeleteDrag && showClose.value == true && dragging.value == true && activeIndex.value >= 0 && activeIndex.value < innerList.value.length
            }
            )
            val containerStyle = computed(fun(): String {
                val currentContainerLayout = containerLayout.value
                if (dragging.value == true && currentContainerLayout != null) {
                    return "height: " + currentContainerLayout.height + "px;"
                }
                return ""
            }
            )
            val getDeleteProxyStyle = fun(): String {
                if (showDeleteProxy.value != true || activeIndex.value < 0 || activeIndex.value >= layouts.value.length) {
                    return "display: none;"
                }
                val sourceLayout = layouts.value[activeIndex.value]
                return "position: fixed; left: " + activeViewLeft.value + "px; top: " + activeViewTop.value + "px; width: " + sourceLayout.width + "px; height: " + sourceLayout.height + "px; z-index: 30; transform: translateX(" + dragOffsetX.value + "px) translateY(" + dragOffsetY.value + "px) scale(" + activeDragScale.value + ");"
            }
            val getFixedActiveItemStyle = fun(sourceLayout: ItemLayout): String {
                return "position: fixed; left: " + activeViewLeft.value + "px; top: " + activeViewTop.value + "px; width: " + sourceLayout.width + "px; height: " + sourceLayout.height + "px; z-index: 30; transition-duration: 0ms; transform: translateX(" + dragOffsetX.value + "px) translateY(" + dragOffsetY.value + "px) scale(" + activeDragScale.value + ");"
            }
            val getDeletePlaceholderStyle = fun(baseLeft: Number, baseTop: Number, sourceLayout: ItemLayout): String {
                return "position: absolute; left: " + baseLeft + "px; top: " + baseTop + "px; width: " + sourceLayout.width + "px; height: " + sourceLayout.height + "px; z-index: 0; transition-duration: 0ms; opacity: 0; transform: translateX(0px) translateY(0px);"
            }
            val appLanguage = uni_getAppBaseInfo(null).appLanguage ?: "en"
            val getDeleteBarLocale = fun(): DeleteBarLocale {
                val language = appLanguage.toLowerCase()
                if (language.indexOf("zh-hant") == 0 || language.indexOf("zh-tw") == 0 || language.indexOf("zh-hk") == 0 || language.indexOf("zh-mo") == 0) {
                    return DeleteBarLocale(idle = "\u62d6\u5230\u6b64\u8655\u522a\u9664", active = "\u9b06\u624b\u522a\u9664")
                }
                if (language.indexOf("zh") == 0) {
                    return DeleteBarLocale(idle = "\u62d6\u5230\u6b64\u5904\u5220\u9664", active = "\u677e\u624b\u5220\u9664")
                }
                if (language.indexOf("fr") == 0) {
                    return DeleteBarLocale(idle = "Faites glisser ici pour supprimer", active = "Rel\u00e2chez pour supprimer")
                }
                if (language.indexOf("la") == 0) {
                    return DeleteBarLocale(idle = "Huc trahe ut deleas", active = "Dimitte ut deleas")
                }
                return DeleteBarLocale(idle = "Drag here to delete", active = "Release to delete")
            }
            val deleteBarLocale = getDeleteBarLocale()
            val deleteBarText = computed(fun(): String {
                return if (overDeleteBar.value) {
                    deleteBarLocale.active
                } else {
                    deleteBarLocale.idle
                }
            }
            )
            val createIdentityOrder = fun(length: Number): UTSArray<Number> {
                val order: UTSArray<Number> = _uA()
                run {
                    var i: Number = 0
                    while(i < length){
                        order.push(i)
                        i++
                    }
                }
                return order
            }
            val applyPreviewOrder = fun(order: UTSArray<Number>){
                val nextPreviewItemIds: UTSArray<Number> = _uA()
                run {
                    var i: Number = 0
                    while(i < order.length){
                        val sourceIndex = order[i]
                        if (sourceIndex >= 0 && sourceIndex < itemIds.value.length) {
                            nextPreviewItemIds.push(itemIds.value[sourceIndex])
                        }
                        i++
                    }
                }
                previewItemIds.value = nextPreviewItemIds
            }
            val findPreviewPosition = fun(itemId: Number): Number {
                run {
                    var i: Number = 0
                    while(i < previewItemIds.value.length){
                        if (previewItemIds.value[i] == itemId) {
                            return i
                        }
                        i++
                    }
                }
                return -1
            }
            val buildIdList = fun(length: Number): UTSArray<Number> {
                val ids: UTSArray<Number> = _uA()
                run {
                    var i: Number = 0
                    while(i < length){
                        ids.push(nextItemId.value)
                        nextItemId.value = nextItemId.value + 1
                        i++
                    }
                }
                return ids
            }
            fun gen_clearLongPressTimer_fn(): Unit {
                if (longPressTimer != 0) {
                    clearTimeout(longPressTimer)
                    longPressTimer = 0
                }
            }
            val clearLongPressTimer = ::gen_clearLongPressTimer_fn
            val resetDragState = fun(){
                clearLongPressTimer()
                dragging.value = false
                activeIndex.value = -1
                hoverIndex.value = -1
                pendingIndex.value = -1
                overDeleteBar.value = false
                activeViewLeft.value = 0
                activeViewTop.value = 0
                dragCoordOffsetX.value = 0
                dragCoordOffsetY.value = 0
                dragOffsetX.value = 0
                dragOffsetY.value = 0
                applyPreviewOrder(createIdentityOrder(innerList.value.length))
            }
            val getItemLayout = fun(index: Number): ItemLayout? {
                if (index < 0 || index >= layouts.value.length) {
                    return null
                }
                return layouts.value[index]
            }
            val getCurrentTargetRect = fun(index: Number): QueryRect? {
                val itemLayout = getItemLayout(index)
                if (itemLayout == null) {
                    return null
                }
                return QueryRect(left = itemLayout.left, top = itemLayout.pageTop, width = itemLayout.width, height = itemLayout.height, right = itemLayout.left + itemLayout.width, bottom = itemLayout.pageTop + itemLayout.height)
            }
            val rebuildGridAxisCache = fun(nextLayouts: UTSArray<ItemLayout>){
                val nextColumnCenters: UTSArray<Number> = _uA()
                val nextRowCenters: UTSArray<Number> = _uA()
                val length = nextLayouts.length
                val columns = columnCount.value
                if (columns > 0 && length > 0) {
                    val actualColumns = Math.min(columns, length)
                    run {
                        var i: Number = 0
                        while(i < actualColumns){
                            nextColumnCenters.push(nextLayouts[i].centerX)
                            i++
                        }
                    }
                    run {
                        var i: Number = 0
                        while(i < length){
                            nextRowCenters.push(nextLayouts[i].centerY)
                            i += actualColumns
                        }
                    }
                }
                gridColumnCenters.value = nextColumnCenters
                gridRowCenters.value = nextRowCenters
            }
            fun gen_measureLayouts_fn(): UTSPromise<Unit> {
                if (instance == null || instance.proxy == null) {
                    return UTSPromise.resolve()
                }
                val query = uni_createSelectorQuery().`in`(instance.proxy)
                query.select(".drag-cell").boundingClientRect(fun(rect){
                    if (rect != null) {
                        val containerRect = rect as NodeInfo
                        var top = if (containerRect.top != null) {
                            containerRect.top!!
                        } else {
                            0
                        }
                        val height = if (containerRect.height != null) {
                            containerRect.height!!
                        } else {
                            0
                        }
                        if (top == 0 && containerRect.bottom != null) {
                            top = containerRect.bottom!! - height
                        }
                        containerLayout.value = ContainerLayout(left = if (containerRect.left != null) {
                            containerRect.left!!
                        } else {
                            0
                        }
                        , pageTop = top, width = if (containerRect.width != null) {
                            containerRect.width!!
                        } else {
                            0
                        }
                        , height = height)
                    }
                }
                )
                query.selectAll(".drag-cell-item").boundingClientRect(fun(rects){
                    val nextLayouts: UTSArray<ItemLayout> = _uA()
                    if (rects != null) {
                        val rectList = rects as UTSArray<NodeInfo>
                        run {
                            var i: Number = 0
                            while(i < rectList.length){
                                val rect = rectList[i]
                                val left = if (rect.left != null) {
                                    rect.left!!
                                } else {
                                    0
                                }
                                var top = if (rect.top != null) {
                                    rect.top!!
                                } else {
                                    0
                                }
                                val width = if (rect.width != null) {
                                    rect.width!!
                                } else {
                                    0
                                }
                                val height = if (rect.height != null) {
                                    rect.height!!
                                } else {
                                    0
                                }
                                if (top == 0 && rect.bottom != null) {
                                    top = rect.bottom!! - height
                                }
                                nextLayouts.push(ItemLayout(left = left, pageTop = top, width = width, height = height, centerX = left + width / 2, centerY = top + height / 2))
                                i++
                            }
                        }
                    }
                    layouts.value = nextLayouts
                    rebuildGridAxisCache(nextLayouts)
                }
                )
                return UTSPromise(fun(resolve, _reject){
                    query.exec(fun(_result){
                        resolve(Unit)
                    }
                    )
                }
                )
            }
            val measureLayouts = ::gen_measureLayouts_fn
            val syncFromModel = fun(){
                if (dragging.value) {
                    return
                }
                innerList.value = if (props.modelValue != null) {
                    props.modelValue!!.slice()
                } else {
                    _uA()
                }
                itemIds.value = buildIdList(innerList.value.length)
                resetDragState()
            }
            val emitChange = fun(){
                emit("update:modelValue", innerList.value)
                emit("change", innerList.value)
            }
            val resetItemIdsByListOrder = fun(){
                itemIds.value = createIdentityOrder(innerList.value.length)
                applyPreviewOrder(createIdentityOrder(innerList.value.length))
            }
            watch(fun(): Number {
                val list = props.modelValue
                return if (list != null) {
                    list.length
                } else {
                    -1
                }
            }
            , fun(_newLength: Number){
                syncFromModel()
            }
            )
            val getWebWindowTopOffset = fun(): Number {
                return 0
            }
            val buildPreviewOrder = fun(length: Number, from: Number, to: Number): UTSArray<Number> {
                val order = createIdentityOrder(length)
                if (from == to) {
                    return order
                }
                order.splice(from, 1)
                order.splice(to, 0, from)
                return order
            }
            val findNearestAxisIndex = fun(centers: UTSArray<Number>, value: Number): Number {
                var nearestIndex: Number = 0
                var nearestDistance: Number = -1.0
                run {
                    var i: Number = 0
                    while(i < centers.length){
                        val distance = Math.abs(centers[i] - value)
                        if (nearestDistance < 0 || distance < nearestDistance) {
                            nearestDistance = distance
                            nearestIndex = i
                        }
                        i++
                    }
                }
                return nearestIndex
            }
            val getGridHoverIndex = fun(centerX: Number, centerY: Number): Number {
                val length = layouts.value.length
                val columns = columnCount.value
                if (columns <= 0 || length == 0) {
                    return activeIndex.value
                }
                val actualColumns = Math.min(columns, length)
                val columnIndex = findNearestAxisIndex(gridColumnCenters.value, centerX)
                val rowIndex = findNearestAxisIndex(gridRowCenters.value, centerY)
                val rowStart = rowIndex * actualColumns
                val rowEnd = Math.min(rowStart + actualColumns, length)
                var targetIndex = rowStart + columnIndex
                if (targetIndex >= rowEnd) {
                    targetIndex = rowEnd - 1
                }
                return targetIndex
            }
            val updateHoverIndex = fun(){
                val currentActiveIndex = activeIndex.value
                if (currentActiveIndex < 0 || currentActiveIndex >= layouts.value.length) {
                    return
                }
                val sourceLayout = layouts.value[currentActiveIndex]
                val centerX = sourceLayout.left + sourceLayout.width / 2 + dragOffsetX.value
                val centerY = sourceLayout.pageTop + sourceLayout.height / 2 + dragOffsetY.value
                if (columnCount.value > 0) {
                    val touchX = startTouchX.value + dragOffsetX.value + dragCoordOffsetX.value
                    val touchY = startTouchY.value + dragOffsetY.value + dragCoordOffsetY.value
                    val targetIndex = getGridHoverIndex(touchX, touchY)
                    if (targetIndex != hoverIndex.value) {
                        hoverIndex.value = targetIndex
                        applyPreviewOrder(buildPreviewOrder(innerList.value.length, currentActiveIndex, targetIndex))
                    }
                    return
                }
                var nearestIndex = currentActiveIndex
                var nearestDistance: Number = -1.0
                run {
                    var i: Number = 0
                    while(i < layouts.value.length){
                        val layout = layouts.value[i]
                        val deltaX = layout.centerX - centerX
                        val deltaY = layout.centerY - centerY
                        val distance = deltaX * deltaX + deltaY * deltaY
                        if (nearestDistance < 0 || distance < nearestDistance) {
                            nearestDistance = distance
                            nearestIndex = i
                        }
                        i++
                    }
                }
                if (nearestIndex != hoverIndex.value) {
                    hoverIndex.value = nearestIndex
                    applyPreviewOrder(buildPreviewOrder(innerList.value.length, currentActiveIndex, nearestIndex))
                }
            }
            val cancelPendingPress = fun(){
                clearLongPressTimer()
                pendingIndex.value = -1
            }
            val setDragContext = fun(index: Number, clientX: Number, clientY: Number){
                startTouchX.value = clientX
                startTouchY.value = clientY
                val rect = getCurrentTargetRect(index)
                activeViewLeft.value = if (rect != null) {
                    rect.left
                } else {
                    0
                }
                activeViewTop.value = if (rect != null) {
                    (rect.top + getWebWindowTopOffset())
                } else {
                    0
                }
            }
            val getScaledDragRect = fun(baseLeft: Number, baseTop: Number, width: Number, height: Number, scale: Number): QueryRect {
                if (scale == 1) {
                    return QueryRect(left = baseLeft, top = baseTop, width = width, height = height, right = baseLeft + width, bottom = baseTop + height)
                }
                val centerX = width / 2
                val centerY = height / 2
                val left = baseLeft + centerX + (0 - centerX) * scale
                val top = baseTop + centerY + (0 - centerY) * scale
                return QueryRect(left = left, top = top, width = width * scale, height = height * scale, right = baseLeft + centerX + (width - centerX) * scale, bottom = baseTop + centerY + (height - centerY) * scale)
            }
            fun gen_beginDrag_fn(index: Number, clientX: Number, clientY: Number): Unit {
                if (layouts.value.length != innerList.value.length || index >= layouts.value.length) {
                    cancelPendingPress()
                    return
                }
                clearLongPressTimer()
                pendingIndex.value = -1
                startTouchX.value = clientX
                startTouchY.value = clientY
                dragOffsetX.value = 0
                dragOffsetY.value = 0
                dragCoordOffsetX.value = layouts.value[index].left - activeViewLeft.value
                dragCoordOffsetY.value = layouts.value[index].pageTop - activeViewTop.value
                settling.value = false
                dragging.value = true
                activeIndex.value = index
                hoverIndex.value = index
                overDeleteBar.value = false
                applyPreviewOrder(createIdentityOrder(innerList.value.length))
            }
            val beginDrag = ::gen_beginDrag_fn
            val beginHandleDrag = fun(context: TouchContext, clientX: Number, clientY: Number){
                measureLayouts().then(fun(){
                    if (context.version !== touchVersion) {
                        return
                    }
                    setDragContext(context.index, clientX, clientY)
                    beginDrag(context.index, clientX, clientY)
                }
                )
            }
            val updateDeleteBarState = fun(){
                if (showClose.value != true || dragging.value != true || activeIndex.value < 0 || activeIndex.value >= layouts.value.length) {
                    overDeleteBar.value = false
                    return
                }
                val sourceLayout = layouts.value[activeIndex.value]
                val dragRect = getScaledDragRect(activeViewLeft.value + dragOffsetX.value, activeViewTop.value + dragOffsetY.value, sourceLayout.width, sourceLayout.height, activeDragScale.value)
                val contentLeft = dragRect.left
                val contentRight = if (dragRect.right != null) {
                    dragRect.right!!
                } else {
                    (dragRect.left + dragRect.width)
                }
                val contentBottom = if (dragRect.bottom != null) {
                    dragRect.bottom!!
                } else {
                    (dragRect.top + dragRect.height)
                }
                val normalizedContentBottom = contentBottom - getWebWindowTopOffset()
                val windowInfo = uni_getWindowInfo()
                val barTop = windowInfo.windowHeight - deleteBarHeight
                val isInside = normalizedContentBottom >= barTop
                if (isInside != overDeleteBar.value) {
                    overDeleteBar.value = isInside
                    if (isInside) {
                        hoverIndex.value = activeIndex.value
                        applyPreviewOrder(createIdentityOrder(innerList.value.length))
                    }
                }
            }
            val scheduleLongPress = fun(context: TouchContext, clientX: Number, clientY: Number){
                clearLongPressTimer()
                pendingIndex.value = context.index
                startTouchX.value = clientX
                startTouchY.value = clientY
                longPressTimer = setTimeout(fun(){
                    longPressTimer = 0
                    measureLayouts().then(fun(){
                        if (touchVersion !== context.version) {
                            return
                        }
                        setDragContext(context.index, clientX, clientY)
                        beginDrag(context.index, clientX, clientY)
                    }
                    )
                }
                , longPressDuration)
            }
            val moveDrag = fun(clientX: Number, clientY: Number){
                if (dragging.value == true && activeIndex.value >= 0) {
                    dragOffsetX.value = clientX - startTouchX.value
                    dragOffsetY.value = clientY - startTouchY.value
                    updateDeleteBarState()
                    if (overDeleteBar.value != true) {
                        updateHoverIndex()
                    }
                    return
                }
                if (pendingIndex.value >= 0) {
                    val deltaX = clientX - startTouchX.value
                    val deltaY = clientY - startTouchY.value
                    val distanceSquare = deltaX * deltaX + deltaY * deltaY
                    if (distanceSquare > pressCancelDistance * pressCancelDistance) {
                        cancelPendingPress()
                    }
                }
            }
            val finishDrag = fun(){
                if (pendingIndex.value >= 0) {
                    cancelPendingPress()
                    return
                }
                if (dragging.value != true || activeIndex.value < 0) {
                    return
                }
                val currentActiveIndex = activeIndex.value
                if (showClose.value == true) {
                    updateDeleteBarState()
                }
                if (showClose.value == true && overDeleteBar.value == true) {
                    val nextList = innerList.value.slice()
                    nextList.splice(currentActiveIndex, 1)
                    settling.value = true
                    resetDragState()
                    innerList.value = nextList
                    resetItemIdsByListOrder()
                    emitChange()
                    nextTick(fun(){
                        settling.value = false
                    }
                    )
                    return
                }
                val targetIndex = hoverIndex.value
                if (targetIndex < 0 || targetIndex == currentActiveIndex) {
                    resetDragState()
                    return
                }
                val nextList = innerList.value.slice()
                val movedItem = nextList.splice(currentActiveIndex, 1)[0]
                nextList.splice(targetIndex, 0, movedItem)
                settling.value = true
                resetDragState()
                innerList.value = nextList
                resetItemIdsByListOrder()
                emitChange()
                nextTick(fun(){
                    settling.value = false
                }
                )
            }
            var currentTouchContext: TouchContext? = null
            val onItemTouchStart = fun(event: Any, index: Number){
                if (handleModeEnabled.value == true) {
                    return
                }
                if (dragging.value == true) {
                    return
                }
                currentTouchContext = TouchContext(index)
                val touchEvent = event as UniTouchEvent
                val touch = touchEvent.touches[0]
                scheduleLongPress(currentTouchContext!!, touch.clientX, touch.clientY)
            }
            val onItemTouchMove = fun(event: Any, index: Number){
                val touchEvent = event as UniTouchEvent
                val touch = touchEvent.touches[0]
                if (dragging.value == true) {
                    touchEvent.preventDefault()
                    if (index != activeIndex.value) {
                        return
                    }
                    moveDrag(touch.clientX, touch.clientY)
                }
            }
            val onItemTouchEnd = fun(_event: Any, index: Number){
                if (isTruthy(currentTouchContext) && currentTouchContext!!.index === index) {
                    touchVersion++
                    currentTouchContext = null
                }
                if (index != activeIndex.value) {
                    return
                }
                if (dragging.value == true) {
                    finishDrag()
                }
            }
            val onHandleTouchStart = fun(event: Any, index: Number){
                if (handleModeEnabled.value != true) {
                    return
                }
                val touchEvent = event as UniTouchEvent
                val touch = touchEvent.touches[0]
                currentTouchContext = TouchContext(index)
                beginHandleDrag(currentTouchContext!!, touch.clientX, touch.clientY)
            }
            val onHandleTouchEnd = fun(_event: Any, index: Number){
                if (isTruthy(currentTouchContext) && currentTouchContext!!.index === index) {
                    touchVersion++
                    currentTouchContext = null
                }
                if (dragging.value == true) {
                    finishDrag()
                    return
                }
                cancelPendingPress()
            }
            val getHandleClass = fun(index: Number): String {
                if (handleModeEnabled.value == true && dragging.value == true && activeIndex.value == index) {
                    return "drag-cell-handle-active"
                }
                return ""
            }
            val getItemStyle = fun(index: Number): String {
                var widthStyle = "width: auto;"
                var positionStyle = ""
                if (columnCount.value > 0) {
                    widthStyle = "width: " + (100 as Number) / columnCount.value + "%;"
                }
                var zIndexStyle = "z-index: 1;"
                var transitionStyle = "transition-duration: 200ms;"
                var transformStyle = "translateX(0px) translateY(0px)"
                transitionStyle = "transition-duration: 0ms;"
                if (settling.value == true) {
                    transitionStyle = "transition-duration: 0ms;"
                }
                val currentContainerLayout = containerLayout.value
                if (dragging.value == true && index < layouts.value.length && currentContainerLayout != null) {
                    val sourceLayout = layouts.value[index]
                    val baseLeft = sourceLayout.left - currentContainerLayout.left
                    val baseTop = sourceLayout.pageTop - currentContainerLayout.pageTop
                    widthStyle = ""
                    if (activeIndex.value == index) {
                        positionStyle = "position: absolute; left: " + baseLeft + "px; top: " + baseTop + "px; width: " + sourceLayout.width + "px; height: " + sourceLayout.height + "px;"
                        transitionStyle = "transition-duration: 0ms;"
                        if (showClose.value == true) {
                            if (useDeleteProxyForDeleteDrag) {
                                return "" + widthStyle + getDeletePlaceholderStyle(baseLeft, baseTop, sourceLayout)
                            }
                            return "" + widthStyle + getFixedActiveItemStyle(sourceLayout)
                        }
                        zIndexStyle = "z-index: 30;"
                        transformStyle = "translateX(" + dragOffsetX.value + "px) translateY(" + dragOffsetY.value + "px) scale(" + activeDragScale.value + ")"
                    } else {
                        positionStyle = "position: absolute; left: " + baseLeft + "px; top: " + baseTop + "px; width: " + sourceLayout.width + "px; height: " + sourceLayout.height + "px;"
                        if (index < itemIds.value.length) {
                            val currentItemId = itemIds.value[index]
                            val targetPosition = findPreviewPosition(currentItemId)
                            if (targetPosition >= 0 && targetPosition < layouts.value.length) {
                                val targetLayout = layouts.value[targetPosition]
                                val deltaX = targetLayout.left - sourceLayout.left
                                val deltaY = targetLayout.pageTop - sourceLayout.pageTop
                                transformStyle = "translateX(" + deltaX + "px) translateY(" + deltaY + "px)"
                            }
                        }
                    }
                } else if (index !== activeIndex.value) {
                    transitionStyle = "transition-duration: 0ms;"
                }
                return "" + widthStyle + positionStyle + zIndexStyle + transitionStyle + "transform: " + transformStyle + ";"
            }
            val getAppendStyle = fun(): String {
                if (columnCount.value > 0) {
                    return "width: " + (100 as Number) / columnCount.value + "%;"
                }
                return "width: auto;"
            }
            onMounted(fun(){
                itemIds.value = buildIdList(innerList.value.length)
                applyPreviewOrder(createIdentityOrder(innerList.value.length))
            }
            )
            return fun(): Any? {
                return _cE("view", _uM("class" to "drag-cell-host"), _uA(
                    _cE("view", _uM("class" to _nC(_uA(
                        "drag-cell",
                        unref(containerClass)
                    )), "style" to _nS(unref(containerStyle))), _uA(
                        _cE(Fragment, null, RenderHelpers.renderList(unref(innerList), fun(item, index, __index, _cached): Any {
                            return _cE("view", _uM("key" to if (unref(itemIds).length > index) {
                                unref(itemIds)[index]
                            } else {
                                index
                            }
                            , "class" to "drag-cell-item", "style" to _nS(getItemStyle(index)), "onTouchstart" to withModifiers(fun(`$event`: Any){
                                onItemTouchStart(`$event`, index)
                            }
                            , _uA(
                                "stop"
                            )), "onTouchmove" to fun(`$event`: Any){
                                onItemTouchMove(`$event`, index)
                            }
                            , "onTouchend" to fun(`$event`: Any){
                                onItemTouchEnd(`$event`, index)
                            }
                            , "onTouchcancel" to fun(`$event`: Any){
                                onItemTouchEnd(`$event`, index)
                            }
                            ), _uA(
                                _cE("view", _uM("class" to "drag-cell-item-inner"), _uA(
                                    _cE("view", _uM("class" to "drag-cell-slot-content"), _uA(
                                        renderSlot(_ctx.`$slots`, "default", _uM("item" to item, "index" to index))
                                    )),
                                    if (isTrue(unref(handleModeEnabled))) {
                                        _cE("view", _uM("key" to 0, "class" to _nC(_uA(
                                            "drag-cell-handle",
                                            getHandleClass(index)
                                        )), "onTouchstart" to withModifiers(fun(`$event`: Any){
                                            onHandleTouchStart(`$event`, index)
                                        }, _uA(
                                            "stop"
                                        )), "onTouchend" to withModifiers(fun(`$event`: Any){
                                            onHandleTouchEnd(`$event`, index)
                                        }, _uA(
                                            "stop"
                                        )), "onTouchcancel" to withModifiers(fun(`$event`: Any){
                                            onHandleTouchEnd(`$event`, index)
                                        }, _uA(
                                            "stop"
                                        ))), _uA(
                                            renderSlot(_ctx.`$slots`, "handle", _uM("item" to item, "index" to index))
                                        ), 42, _uA(
                                            "onTouchstart",
                                            "onTouchend",
                                            "onTouchcancel"
                                        ))
                                    } else {
                                        _cC("v-if", true)
                                    }
                                ))
                            ), 44, _uA(
                                "onTouchstart",
                                "onTouchmove",
                                "onTouchend",
                                "onTouchcancel"
                            ))
                        }
                        ), 128),
                        if (isTrue(unref(showAppendSlot) && unref(dragging) != true)) {
                            _cE("view", _uM("key" to 0, "class" to "drag-cell-append", "style" to _nS(getAppendStyle())), _uA(
                                renderSlot(_ctx.`$slots`, "append")
                            ), 4)
                        } else {
                            _cC("v-if", true)
                        }
                        ,
                        if (isTrue(unref(showDeleteBar))) {
                            _cE("view", _uM("key" to 1, "class" to _nC(_uA(
                                "drag-cell-delete-bar",
                                if (unref(overDeleteBar)) {
                                    "drag-cell-delete-bar-active"
                                } else {
                                    ""
                                }
                            ))), _uA(
                                _cE("text", _uM("class" to "drag-cell-delete-text"), _tD(unref(deleteBarText)), 1)
                            ), 2)
                        } else {
                            _cC("v-if", true)
                        }
                        ,
                        if (isTrue(unref(showDeleteProxy))) {
                            _cE("view", _uM("key" to 2, "class" to "drag-cell-delete-proxy", "style" to _nS(getDeleteProxyStyle())), _uA(
                                _cE("view", _uM("class" to "drag-cell-delete-proxy-inner"), _uA(
                                    renderSlot(_ctx.`$slots`, "default", _uM("item" to unref(innerList)[unref(activeIndex)], "index" to unref(activeIndex)))
                                ))
                            ), 4)
                        } else {
                            _cC("v-if", true)
                        }
                    ), 6)
                ))
            }
        }
        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("drag-cell-host" to _pS(_uM("position" to "relative", "width" to "100%", "overflow" to "visible")), "drag-cell" to _pS(_uM("display" to "flex", "flexDirection" to "row", "flexWrap" to "wrap", "alignItems" to "flex-start", "width" to "100%", "position" to "relative", "overflow" to "visible")), "drag-cell-row" to _pS(_uM("justifyContent" to "flex-start")), "drag-cell-grid" to _pS(_uM("justifyContent" to "flex-start")), "drag-cell-item" to _pS(_uM("position" to "relative", "display" to "flex", "flexDirection" to "column", "transitionProperty" to "transform", "transitionTimingFunction" to "ease", "transformOrigin" to "center center", "overflow" to "visible")), "drag-cell-append" to _pS(_uM("position" to "relative", "display" to "flex", "flexDirection" to "column", "overflow" to "visible")), "drag-cell-item-inner" to _pS(_uM("position" to "relative", "display" to "flex", "flexDirection" to "column", "width" to "100%", "height" to "100%", "transitionProperty" to "transform", "transitionTimingFunction" to "ease", "transformOrigin" to "center center")), "drag-cell-slot-content" to _pS(_uM("display" to "flex", "flexDirection" to "column", "width" to "100%", "height" to "100%")), "drag-cell-handle" to _pS(_uM("position" to "absolute", "right" to 0, "top" to 0, "zIndex" to 2, "display" to "flex", "flexDirection" to "column", "alignItems" to "flex-end", "justifyContent" to "flex-start", "opacity" to 0.82, "transitionProperty" to "transform,opacity", "transitionDuration" to "160ms")), "drag-cell-handle-active" to _pS(_uM("opacity" to 1, "transform" to "scale(1.08)")), "drag-cell-delete-bar" to _pS(_uM("position" to "fixed", "left" to 0, "right" to 0, "bottom" to 0, "height" to 56, "borderTopLeftRadius" to 0, "borderTopRightRadius" to 0, "borderBottomRightRadius" to 0, "borderBottomLeftRadius" to 0, "backgroundColor" to "rgba(255,59,48,0.92)", "display" to "flex", "flexDirection" to "row", "alignItems" to "center", "justifyContent" to "center", "transform" to "translateY(0px)", "zIndex" to 20)), "drag-cell-delete-bar-active" to _pS(_uM("backgroundColor" to "rgba(209,33,23,0.96)", "transform" to "scale(1.02)")), "drag-cell-delete-text" to _pS(_uM("fontSize" to 16, "fontWeight" to "bold", "color" to "#ffffff", "textAlign" to "center")), "drag-cell-delete-proxy" to _pS(_uM("position" to "fixed", "zIndex" to 30, "overflow" to "visible")), "drag-cell-delete-proxy-inner" to _pS(_uM("display" to "flex", "flexDirection" to "column", "width" to "100%", "height" to "100%")), "drag-cell-drag-layer" to _pS(_uM("position" to "fixed", "left" to 0, "top" to 0, "right" to 0, "bottom" to 0, "backgroundColor" to "rgba(0,0,0,0)", "zIndex" to 25)), "@TRANSITION" to _uM("drag-cell-item" to _uM("property" to "transform", "timingFunction" to "ease"), "drag-cell-item-inner" to _uM("property" to "transform", "timingFunction" to "ease"), "drag-cell-handle" to _uM("property" to "transform,opacity", "duration" to "160ms")))
            }
        var inheritAttrs = true
        var inject: Map<String, Map<String, Any?>> = _uM()
        var emits: Map<String, Any?> = _uM("update:modelValue" to null, "change" to null)
        var props = _nP(_uM("modelValue" to _uM("type" to "Array", "required" to false), "column" to _uM("type" to "Number", "default" to 0), "showClose" to _uM("type" to "Boolean", "default" to false), "showAppend" to _uM("type" to "Boolean", "default" to true), "handleMode" to _uM("type" to "Boolean", "default" to false)))
        var propsNeedCastKeys = _uA(
            "column",
            "showClose",
            "showAppend",
            "handleMode"
        )
        var components: Map<String, CreateVueComponent> = _uM()
    }
}
