import { ViewBase, ContainerView, Observable, ObservableArray, StackLayout, Property, booleanConverter, CSSType, Label, Builder, Color, ScrollView, addWeakEventListener, removeWeakEventListener } from '@nativescript/core';
export const NG_VIEW = 'ng_view';
export var ListViewViewType;
(function (ListViewViewType) {
    ListViewViewType["HeaderView"] = "HeaderView";
    ListViewViewType["ItemView"] = "ItemView";
    ListViewViewType["FooterView"] = "FooterView";
    ListViewViewType["GroupView"] = "GroupView";
    ListViewViewType["LoadOnDemandView"] = "LoadOnDemandView";
    ListViewViewType["ItemSwipeView"] = "ItemSwipeView";
})(ListViewViewType || (ListViewViewType = {}));
export var ListViewItemSnapMode;
(function (ListViewItemSnapMode) {
    ListViewItemSnapMode["Auto"] = "Auto";
    ListViewItemSnapMode["Start"] = "Start";
    ListViewItemSnapMode["End"] = "End";
    ListViewItemSnapMode["Center"] = "Center";
})(ListViewItemSnapMode || (ListViewItemSnapMode = {}));
export var ListViewScrollDirection;
(function (ListViewScrollDirection) {
    ListViewScrollDirection["Vertical"] = "Vertical";
    ListViewScrollDirection["Horizontal"] = "Horizontal";
})(ListViewScrollDirection || (ListViewScrollDirection = {}));
export var ListViewScrollPosition;
(function (ListViewScrollPosition) {
    ListViewScrollPosition["None"] = "None";
    ListViewScrollPosition["Top"] = "Top";
    ListViewScrollPosition["CenteredVertically"] = "CenteredVertically";
    ListViewScrollPosition["CenteredHorizontally"] = "CenteredHorizontally";
    ListViewScrollPosition["Bottom"] = "Bottom";
    ListViewScrollPosition["Left"] = "Left";
    ListViewScrollPosition["Right"] = "Right";
})(ListViewScrollPosition || (ListViewScrollPosition = {}));
export var ListViewReorderMode;
(function (ListViewReorderMode) {
    ListViewReorderMode["HoldAndDrag"] = "HoldAndDrag";
    ListViewReorderMode["Drag"] = "Drag";
})(ListViewReorderMode || (ListViewReorderMode = {}));
export var ListViewItemAnimation;
(function (ListViewItemAnimation) {
    ListViewItemAnimation["Default"] = "Default";
    ListViewItemAnimation["Fade"] = "Fade";
    ListViewItemAnimation["Scale"] = "Scale";
    ListViewItemAnimation["Slide"] = "Slide";
})(ListViewItemAnimation || (ListViewItemAnimation = {}));
export var ListViewLoadOnDemandMode;
(function (ListViewLoadOnDemandMode) {
    ListViewLoadOnDemandMode["None"] = "None";
    ListViewLoadOnDemandMode["Manual"] = "Manual";
    ListViewLoadOnDemandMode["Auto"] = "Auto";
})(ListViewLoadOnDemandMode || (ListViewLoadOnDemandMode = {}));
export var ListViewSelectionBehavior;
(function (ListViewSelectionBehavior) {
    ListViewSelectionBehavior["None"] = "None";
    ListViewSelectionBehavior["Press"] = "Press";
    ListViewSelectionBehavior["LongPress"] = "LongPress";
})(ListViewSelectionBehavior || (ListViewSelectionBehavior = {}));
export class PullToRefreshStyle extends ViewBase {
    onIndicatorColorPropertyChanged(oldValue, newValue) { }
    onIndicatorBackgroundColorPropertyChanged(oldValue, newValue) { }
}
PullToRefreshStyle.indicatorColorProperty = new Property({
    name: 'indicatorColor',
    defaultValue: undefined,
    valueConverter: (value) => new Color(value),
    valueChanged: (target, oldValue, newValue) => {
        target.onIndicatorColorPropertyChanged(oldValue, newValue);
    },
});
PullToRefreshStyle.indicatorBackgroundColorProperty = new Property({
    name: 'indicatorBackgroundColor',
    defaultValue: undefined,
    valueConverter: (value) => new Color(value),
    valueChanged: (target, oldValue, newValue) => {
        target.onIndicatorBackgroundColorPropertyChanged(oldValue, newValue);
    },
});
PullToRefreshStyle.indicatorColorProperty.register(PullToRefreshStyle);
PullToRefreshStyle.indicatorBackgroundColorProperty.register(PullToRefreshStyle);
let ReorderHandle = class ReorderHandle extends StackLayout {
    constructor() {
        super();
    }
};
ReorderHandle = __decorate([
    CSSType('ReorderHandle'),
    __metadata("design:paramtypes", [])
], ReorderHandle);
export { ReorderHandle };
export class ListViewScrollEventData {
    constructor() { }
    get object() {
        return this._object;
    }
    set object(value) {
        this._object = value;
    }
    set eventName(value) {
        this._eventName = value;
    }
    get eventName() {
        return this._eventName;
    }
    get scrollOffset() {
        return this._scrollOffset;
    }
    set scrollOffset(value) {
        this._scrollOffset = value;
    }
}
export class ListViewEventData {
    constructor() { }
    get android() {
        return this._android;
    }
    set android(value) {
        this._android = value;
    }
    get ios() {
        return this._ios;
    }
    set ios(value) {
        this._ios = value;
    }
    get eventName() {
        return this._eventName;
    }
    set eventName(value) {
        this._eventName = value;
    }
    get object() {
        return this._object;
    }
    set object(value) {
        this._object = value;
    }
    get index() {
        return this._index;
    }
    set index(value) {
        this._index = value;
    }
    get dataItemIndex() {
        return this._dataItemIndex;
    }
    set dataItemIndex(value) {
        this._dataItemIndex = value;
    }
    get groupIndex() {
        return this._groupIndex;
    }
    set groupIndex(value) {
        this._groupIndex = value;
    }
    get data() {
        return this._data;
    }
    set data(value) {
        this._data = value;
    }
    get returnValue() {
        return this._returnValue;
    }
    set returnValue(value) {
        this._returnValue = value;
    }
    get view() {
        return this._view;
    }
    set view(value) {
        this._view = value;
    }
}
export class LoadOnDemandListViewEventData extends ListViewEventData {
}
export class SwipeActionsEventData extends ListViewEventData {
    get mainView() {
        return this._mainView;
    }
    set mainView(value) {
        this._mainView = value;
    }
    get swipeView() {
        return this._swipeView;
    }
    set swipeView(value) {
        this._swipeView = value;
    }
}
export class ListViewLayoutBase extends ViewBase {
    // @ts-ignore
    get android() {
        return undefined;
    }
    // @ts-ignore
    get ios() {
        return undefined;
    }
    onScrollDirectionPropertyChanged(oldValue, newValue) {
        this.onScrollDirectionChanged(oldValue, newValue);
    }
    onScrollDirectionChanged(oldValue, newValue) { }
    onItemInsertAnimationPropertyChanged(oldValue, newValue) {
        this.onItemInsertAnimationChanged(oldValue, newValue);
    }
    onItemInsertAnimationChanged(oldValue, newValue) { }
    onItemDeleteAnimationPropertyChanged(oldValue, newValue) {
        this.onItemDeleteAnimationChanged(oldValue, newValue);
    }
    onItemDeleteAnimationChanged(oldValue, newValue) { }
    onItemWidthPropertyChanged(oldValue, newValue) {
        this.onItemWidthChanged(oldValue, newValue);
    }
    onItemWidthChanged(oldValue, newValue) { }
    onItemHeightPropertyChanged(oldValue, newValue) {
        this.onItemHeightChanged(oldValue, newValue);
    }
    onItemHeightChanged(oldValue, newValue) { }
    _onOwnerUICreated() { }
}
ListViewLayoutBase.scrollDirectionProperty = new Property({
    name: 'scrollDirection',
    defaultValue: ListViewScrollDirection.Vertical,
    valueConverter: (value) => ListViewScrollDirection[value],
    valueChanged: (target, oldValue, newValue) => {
        target.onScrollDirectionPropertyChanged(oldValue, newValue);
    },
});
ListViewLayoutBase.itemInsertAnimationProperty = new Property({
    name: 'itemInsertAnimation',
    defaultValue: ListViewItemAnimation.Default,
    valueConverter: (value) => ListViewItemAnimation[value],
    valueChanged: (target, oldValue, newValue) => {
        target.onItemInsertAnimationPropertyChanged(oldValue, newValue);
    },
});
ListViewLayoutBase.itemDeleteAnimationProperty = new Property({
    name: 'itemDeleteAnimation',
    defaultValue: ListViewItemAnimation.Default,
    valueConverter: (value) => ListViewItemAnimation[value],
    valueChanged: (target, oldValue, newValue) => {
        target.onItemDeleteAnimationPropertyChanged(oldValue, newValue);
    },
});
ListViewLayoutBase.itemWidthProperty = new Property({
    name: 'itemWidth',
    defaultValue: undefined,
    valueConverter: parseInt,
    valueChanged: (target, oldValue, newValue) => {
        target.onItemWidthPropertyChanged(oldValue, newValue);
    },
});
ListViewLayoutBase.itemHeightProperty = new Property({
    name: 'itemHeight',
    defaultValue: undefined,
    valueConverter: parseInt,
    valueChanged: (target, oldValue, newValue) => {
        target.onItemHeightPropertyChanged(oldValue, newValue);
    },
});
ListViewLayoutBase.scrollDirectionProperty.register(ListViewLayoutBase);
ListViewLayoutBase.itemInsertAnimationProperty.register(ListViewLayoutBase);
ListViewLayoutBase.itemDeleteAnimationProperty.register(ListViewLayoutBase);
ListViewLayoutBase.itemWidthProperty.register(ListViewLayoutBase);
ListViewLayoutBase.itemHeightProperty.register(ListViewLayoutBase);
function listViewLoadOnDemandModeConverter(value) {
    return ListViewLoadOnDemandMode[value];
}
let RadListView = class RadListView extends ContainerView {
    constructor() {
        super(...arguments);
        this._hasGroupingFunctionChanged = false;
        this._isEventListenerAttached = false;
        this._defaultTemplate = {
            key: 'default',
            createView: () => {
                if (this.itemTemplate) {
                    return Builder.parse(this.itemTemplate, this);
                }
                return undefined;
            },
        };
        this._itemTemplatesInternal = new Array(this._defaultTemplate);
        this._dataUpdatesSuspended = false;
        this._itemTemplateSelectorBindable = new Label();
    }
    onLoaded() {
        this.logWarningIfNeeded();
        if (this.items && this.items instanceof Observable) {
            addWeakEventListener(this.items, ObservableArray.changeEvent, this.onSourceCollectionChangedInternal, this);
            this._isEventListenerAttached = true;
        }
        super.onLoaded();
    }
    logWarningIfNeeded() {
        if (this.parent instanceof StackLayout || this.parent instanceof ScrollView) {
            if ((this.parent.orientation === 'vertical' && this.height === 'auto') || (this.parent.orientation === 'horizontal' && this.width === 'auto')) {
                const requiredProperty = this.parent.orientation === 'vertical' ? 'height' : 'width';
                console.log(`Warning: When used inside ${this.parent.typeName} with ${this.parent.orientation} orientation, RadListView should have an explicit ${requiredProperty}.`);
            }
        }
    }
    onUnloaded() {
        if (this._isEventListenerAttached) {
            removeWeakEventListener(this.items, ObservableArray.changeEvent, this.onSourceCollectionChangedInternal, this);
            this._isEventListenerAttached = false;
        }
        super.onUnloaded();
    }
    get itemViewLoader() {
        return this._itemViewLoader;
    }
    get itemViewDisposer() {
        return this._itemViewDisposer;
    }
    get nativeScriptViewAdded() {
        return this._nativeScriptViewAdded;
    }
    get isDataOperationsEnabled() {
        let isFilteringEnabled = this.filteringFunction !== undefined ? true : false;
        let isSortingEnabled = this.sortingFunction !== undefined ? true : false;
        let isGroupingEnabled = this.groupingFunction !== undefined ? true : false;
        return isFilteringEnabled || isSortingEnabled || isGroupingEnabled;
    }
    set itemViewLoader(value) {
        if (this._itemViewLoader !== value) {
            this._itemViewLoader = value;
            this.onItemViewLoaderChanged();
        }
    }
    set itemViewDisposer(value) {
        if (this._itemViewDisposer !== value) {
            this._itemViewDisposer = value;
            this.onItemViewDisposerChanged();
        }
    }
    set nativeScriptViewAdded(value) {
        if (this._nativeScriptViewAdded !== value) {
            this._nativeScriptViewAdded = value;
            this.onNativeScriptViewAddedChanged();
        }
    }
    _reorderItemInSource(oldPosition, newPosition) {
        this.suspendUpdates();
        let ownerSource = this.items;
        let item = this.getItemAtIndex(oldPosition);
        if (item) {
            ownerSource.splice(oldPosition, 1);
            ownerSource.splice(newPosition, 0, item);
        }
        this.resumeUpdates(false);
    }
    suspendUpdates() {
        this._dataUpdatesSuspended = true;
    }
    resumeUpdates(refresh) {
        this._dataUpdatesSuspended = false;
        if (refresh === true) {
            this.refresh();
        }
    }
    updatesSuspended() {
        return this._dataUpdatesSuspended;
    }
    getItemAtIndex(index) {
        if (this.items && this.items.getItem) {
            return this.items.getItem(index);
        }
        if (this.items && this.items.length && index < this.items.length) {
            return this.items[index];
        }
        return null;
    }
    getIndexOf(item) {
        if (this.items && this.items.indexOf) {
            return this.items.indexOf(item);
        }
        console.log("Error: Cannot retrieve the index of '" + item + "'. Make sure that 'items' is set correctly.");
        return -1;
    }
    selectItemAt(index) { }
    deselectItemAt(index) { }
    selectAll() {
        if (!this.multipleSelection) {
            throw new Error('Select all cannot be called unless multipleSelection is set to be true');
        }
    }
    deselectAll() { }
    isItemSelected(item) {
        return false;
    }
    getSelectedItems() {
        return new Array();
    }
    getViewForItem(item) {
        return null;
    }
    resolveTemplateView(template) {
        return Builder.parse(template, this);
    }
    _getDefaultGroupContent() {
        return undefined;
    }
    getViewForViewType(viewType, templateKey) {
        let newView = undefined;
        if (templateKey) {
            let template = this.getTemplateFromSelector(templateKey);
            newView = template.createView();
        }
        if (!newView && this._itemViewLoader !== undefined) {
            newView = this._itemViewLoader(viewType);
        }
        if (newView) {
            return newView;
        }
        let templateString = undefined;
        switch (viewType) {
            case ListViewViewType.ItemView:
                templateString = this.itemTemplate;
                if (templateString === undefined) {
                    return this._getDefaultItemContent();
                }
                break;
            case ListViewViewType.ItemSwipeView:
                templateString = this.itemSwipeTemplate;
                break;
            case ListViewViewType.LoadOnDemandView:
                templateString = this.loadOnDemandItemTemplate;
                break;
            case ListViewViewType.HeaderView: {
                templateString = this.headerItemTemplate;
                break;
            }
            case ListViewViewType.GroupView:
                if (this.groupingFunction) {
                    templateString = this.groupTemplate;
                    if (templateString === undefined) {
                        return this._getDefaultGroupContent();
                    }
                }
                break;
            case ListViewViewType.FooterView:
                templateString = this.footerItemTemplate;
                break;
        }
        return templateString === undefined ? undefined : this.resolveTemplateView(templateString);
    }
    onItemSelectedBackgroundColorPropertyChanged(oldValue, newValue) {
        this.onItemSelectedBackgroundColorChanged(oldValue, newValue);
    }
    onGroupingFunctionPropertyChanged(oldValue, newValue) {
        this.onGroupingFunctionChanged(oldValue, newValue);
    }
    onFilteringFunctionPropertyChanged(oldValue, newValue) {
        this.onFilteringFunctionChanged(oldValue, newValue);
    }
    onSortingFunctionPropertyChanged(oldValue, newValue) {
        this.onSortingFunctionChanged(oldValue, newValue);
    }
    onEnableCollapsibleGroupsPropertyChanged(oldValue, newValue) {
        this.onEnableCollapsibleGroupsChanged(oldValue, newValue);
    }
    _getDefaultItemContent() {
        let lbl = new Label();
        lbl.bind({
            targetProperty: 'text',
            sourceProperty: '$value',
        });
        return lbl;
    }
    getTemplateFromSelector(templateKey) {
        for (let i = 0, length = this._itemTemplatesInternal.length; i < length; i++) {
            if (this._itemTemplatesInternal[i].key.toLowerCase() === templateKey.toLowerCase()) {
                return this._itemTemplatesInternal[i];
            }
        }
        // This is the default template
        return this._itemTemplatesInternal[0];
    }
    onPullToRefreshStylePropertyChanged(oldValue, newValue) {
        this.onPullToRefreshStyleChanged(oldValue, newValue);
    }
    onHeaderItemTemplatePropertyChanged(oldValue, newValue) {
        this.onHeaderItemTemplateChanged(oldValue, newValue);
    }
    onFooterItemTemplatePropertyChanged(oldValue, newValue) {
        this.onFooterItemTemplateChanged(oldValue, newValue);
    }
    onLoadOnDemandItemTemplatePropertyChanged(oldValue, newValue) {
        this.onLoadOnDemandItemTemplateChanged(oldValue, newValue);
    }
    onListViewReorderModePropertyChanged(oldValue, newValue) {
        this.onReorderModeChanged(oldValue, newValue);
    }
    onLayoutPropertyChanged(oldValue, newValue) {
        this.onListViewLayoutChanged(oldValue, newValue);
    }
    onItemTemplateSelectorPropertyChanged(oldValue, newValue) {
        this.onItemTemplateSelectorChanged(oldValue, newValue);
    }
    onItemTemplatesPropertyChanged(oldValue, newValue) {
        this.onItemTemplatesChanged(oldValue, newValue);
    }
    onItemTemplatePropertyChanged(oldValue, newValue) {
        this.onItemTemplateChanged(oldValue, newValue);
    }
    onGroupTemplatePropertyChanged(oldValue, newValue) {
        this.onGroupTemplateChanged(oldValue, newValue);
    }
    onItemSwipeTemplatePropertyChanged(oldValue, newValue) {
        this.onItemSwipeTemplateChanged(oldValue, newValue);
    }
    onMultipleSelectionPropertyChanged(oldValue, newValue) {
        this.onMultipleSelectionChanged(oldValue, newValue);
    }
    onItemReorderPropertyChanged(oldValue, newValue) {
        this.onItemReorderChanged(oldValue, newValue);
    }
    onItemSwipePropertyChanged(oldValue, newValue) {
        this.onItemSwipeChanged(oldValue, newValue);
    }
    onSwipeActionsPropertyChanged(oldValue, newValue) {
        this.onSwipeActionsChanged(oldValue, newValue);
    }
    onPullToRefreshPropertyChanged(oldValue, newValue) {
        this.onPullToRefreshChanged(oldValue, newValue);
    }
    onLoadOnDemandModePropertyChanged(oldValue, newValue) {
        this.onLoadOnDemandModeChanged(oldValue, newValue);
    }
    onLoadOnDemandBufferSizePropertyChanged(oldValue, newValue) {
        this.onLoadOnDemandBufferSizeChanged(oldValue, newValue);
    }
    onSelectionBehaviorPropertyChanged(oldValue, newValue) {
        this.onSelectionBehaviorChanged(oldValue, newValue);
    }
    onItemsPropertyChanged(oldValue, newValue) {
        this.onItemsChanged(oldValue, newValue);
    }
    onScrollPositionPropertyChanged(oldValue, newValue) {
        this.onScrollPositionChanged(oldValue, newValue);
    }
    onItemViewLoaderChanged() { }
    onItemViewDisposerChanged() { }
    onNativeScriptViewAddedChanged() { }
    onItemSelectedBackgroundColorChanged(oldValue, newValue) { }
    onGroupingFunctionChanged(oldValue, newValue) {
        this._hasGroupingFunctionChanged = true;
    }
    onFilteringFunctionChanged(oldValue, newValue) { }
    onSortingFunctionChanged(oldValue, newValue) { }
    onEnableCollapsibleGroupsChanged(oldValue, newValue) { }
    onPullToRefreshStyleChanged(oldValue, newValue) { }
    onHeaderItemTemplateChanged(oldValue, newValue) { }
    onFooterItemTemplateChanged(oldValue, newValue) { }
    onLoadOnDemandItemTemplateChanged(oldValue, newValue) { }
    onReorderModeChanged(oldValue, newValue) { }
    onListViewLayoutChanged(oldValue, newValue) { }
    onItemTemplateSelectorChanged(oldValue, newValue) {
        if (typeof newValue === 'string') {
            this._itemTemplateSelectorBindable.bind({
                sourceProperty: null,
                targetProperty: 'templateKey',
                expression: newValue,
            });
            this.itemTemplateSelector = (item, index, items) => {
                item['$index'] = index;
                this._itemTemplateSelectorBindable.bindingContext = item;
                return this._itemTemplateSelectorBindable.get('templateKey');
            };
        }
        else if (typeof newValue === 'function') {
            this.itemTemplateSelector = newValue;
        }
    }
    onItemTemplatesChanged(oldValue, newValue) {
        this._itemTemplatesInternal = new Array(this._defaultTemplate);
        let newKeyedTemplates = newValue;
        if (newKeyedTemplates) {
            this._itemTemplatesInternal = this._itemTemplatesInternal.concat(newKeyedTemplates);
        }
    }
    onItemTemplateChanged(oldValue, newValue) { }
    onGroupTemplateChanged(oldValue, newValue) { }
    onItemSwipeTemplateChanged(oldValue, newValue) { }
    onMultipleSelectionChanged(oldValue, newValue) { }
    onItemReorderChanged(oldValue, newValue) { }
    onItemSwipeChanged(oldValue, newValue) {
        console.log("Warning: 'itemSwipe' property is deprecated use 'swipeActions' property instead.");
    }
    onSwipeActionsChanged(oldValue, newValue) { }
    onPullToRefreshChanged(oldValue, newValue) { }
    onLoadOnDemandModeChanged(oldValue, newValue) { }
    onLoadOnDemandBufferSizeChanged(oldValue, newValue) { }
    onSelectionBehaviorChanged(oldValue, newValue) { }
    onSourceCollectionChangedInternal(args) {
        if (this._dataUpdatesSuspended === false) {
            this.onSourceCollectionChanged(args);
        }
    }
    onItemsChangedInternal(oldValue, newValue) {
        if (!this.isLoaded) {
            return;
        }
        if (oldValue instanceof Observable) {
            removeWeakEventListener(oldValue, ObservableArray.changeEvent, this.onSourceCollectionChangedInternal, this);
            this._isEventListenerAttached = false;
        }
        if (newValue instanceof Observable) {
            addWeakEventListener(newValue, ObservableArray.changeEvent, this.onSourceCollectionChangedInternal, this);
            this._isEventListenerAttached = true;
        }
        this.refresh();
    }
    onItemsChanged(oldValue, newValue) {
        this.onItemsChangedInternal(oldValue, newValue);
    }
    onScrollPositionChanged(oldValue, newValue) { }
    clearEmbeddedViews() { }
    onSourceCollectionChanged(data) {
        this.refresh();
    }
    refresh() {
        // this.clearEmbeddedViews();
    }
    updateHeaderFooter() { }
    getScrollOffset() {
        return 0;
    }
    scrollToIndex(index, animate = false, snapMode = ListViewItemSnapMode.Auto) { }
    scrollWithAmount(amount, animate) { }
    notifyLoadOnDemandFinished(disableLoadOnDemand) { }
    notifyPullToRefreshFinished() { }
    notifySwipeToExecuteFinished() { }
};
// TODO: get rid of such hacks. This is from code modules ListView implementation
RadListView.knownFunctions = ['itemTemplateSelector'];
RadListView.scrolledEvent = 'scrolled';
RadListView.scrollDragEndedEvent = 'scrollDragEnded';
RadListView.scrollStartedEvent = 'scrollStarted';
RadListView.scrollEndedEvent = 'scrollEnded';
RadListView.itemSelectingEvent = 'itemSelecting';
RadListView.itemDeselectingEvent = 'itemDeselecting';
RadListView.itemTapEvent = 'itemTap';
RadListView.itemHoldEvent = 'itemHold';
RadListView.itemSelectedEvent = 'itemSelected';
RadListView.itemDeselectedEvent = 'itemDeselected';
RadListView.itemReorderStartingEvent = 'itemReorderStarting';
RadListView.itemReorderedEvent = 'itemReordered';
RadListView.itemReorderStartedEvent = 'itemReorderStarted';
RadListView.itemSwipingEvent = 'itemSwiping';
RadListView.itemSwipeProgressChangedEvent = 'itemSwipeProgressChanged';
RadListView.itemSwipeProgressStartedEvent = 'itemSwipeProgressStarted';
RadListView.itemSwipeProgressEndedEvent = 'itemSwipeProgressEnded';
RadListView.loadMoreDataRequestedEvent = 'loadMoreDataRequested';
RadListView.pullToRefreshInitiatedEvent = 'pullToRefreshInitiated';
RadListView.itemLoadingEvent = 'itemLoading';
// Used internally by the custom Angular/Vue directives to setup the EmbeddedViewRef
RadListView.itemLoadingInternalEvent = 'itemLoadingInternal';
RadListView.itemRecyclingInternalEvent = 'itemRecyclingInternal';
RadListView.itemReapperaingInternalEvent = 'itemReappearingInternal';
RadListView.itemDisposingInternalEvent = 'itemDisposingInternal';
RadListView.dataPopulatedEvent = 'dataPopulated';
RadListView.itemSelectedBackgroundColorProperty = new Property({
    name: 'itemSelectedBackgroundColor',
    defaultValue: undefined,
    valueConverter: (value) => new Color(value),
    valueChanged: (target, oldValue, newValue) => {
        target.onItemSelectedBackgroundColorPropertyChanged(oldValue, newValue);
    },
});
RadListView.groupingFunctionProperty = new Property({
    name: 'groupingFunction',
    valueChanged: (target, oldValue, newValue) => {
        target.onGroupingFunctionPropertyChanged(oldValue, newValue);
    },
});
RadListView.filteringFunctionProperty = new Property({
    name: 'filteringFunction',
    valueChanged: (target, oldValue, newValue) => {
        target.onFilteringFunctionPropertyChanged(oldValue, newValue);
    },
});
RadListView.sortingFunctionProperty = new Property({
    name: 'sortingFunction',
    valueChanged: (target, oldValue, newValue) => {
        target.onSortingFunctionPropertyChanged(oldValue, newValue);
    },
});
RadListView.enableCollapsibleGroupsProperty = new Property({
    name: 'enableCollapsibleGroups',
    defaultValue: false,
    valueConverter: booleanConverter,
    valueChanged: (target, oldValue, newValue) => {
        target.onEnableCollapsibleGroupsPropertyChanged(oldValue, newValue);
    },
});
RadListView.pullToRefreshStyleProperty = new Property({
    name: 'pullToRefreshStyle',
    defaultValue: undefined,
    valueChanged: (target, oldValue, newValue) => {
        target.onPullToRefreshStylePropertyChanged(oldValue, newValue);
    },
});
RadListView.headerItemTemplateProperty = new Property({
    name: 'headerItemTemplate',
    defaultValue: undefined,
    valueChanged: (target, oldValue, newValue) => {
        target.onHeaderItemTemplatePropertyChanged(oldValue, newValue);
    },
});
RadListView.footerItemTemplateProperty = new Property({
    name: 'footerItemTemplate',
    defaultValue: undefined,
    valueChanged: (target, oldValue, newValue) => {
        target.onFooterItemTemplatePropertyChanged(oldValue, newValue);
    },
});
RadListView.reorderModeProperty = new Property({
    name: 'reorderMode',
    defaultValue: ListViewReorderMode.HoldAndDrag,
    valueConverter: (value) => ListViewReorderMode[value],
    valueChanged: (target, oldValue, newValue) => {
        target.onListViewReorderModePropertyChanged(oldValue, newValue);
    },
});
RadListView.listViewLayoutProperty = new Property({
    name: 'listViewLayout',
    defaultValue: undefined,
    valueChanged: (target, oldValue, newValue) => {
        target.onLayoutPropertyChanged(oldValue, newValue);
    },
});
RadListView.loadOnDemandItemTemplateProperty = new Property({
    name: 'loadOnDemandItemTemplate',
    defaultValue: undefined,
    valueChanged: (target, oldValue, newValue) => {
        target.onLoadOnDemandItemTemplatePropertyChanged(oldValue, newValue);
    },
});
RadListView.itemTemplateSelectorProperty = new Property({
    name: 'itemTemplateSelector',
    defaultValue: undefined,
    valueChanged: (target, oldValue, newValue) => {
        target.onItemTemplateSelectorPropertyChanged(oldValue, newValue);
    },
});
RadListView.itemTemplatesProperty = new Property({
    name: 'itemTemplates',
    defaultValue: undefined,
    valueConverter: (value) => {
        if (typeof value === 'string') {
            return Builder.parseMultipleTemplates(value);
        }
        return value;
    },
    valueChanged: (target, oldValue, newValue) => {
        target.onItemTemplatesPropertyChanged(oldValue, newValue);
    },
});
RadListView.itemTemplateProperty = new Property({
    name: 'itemTemplate',
    defaultValue: undefined,
    valueChanged: (target, oldValue, newValue) => {
        target.onItemTemplatePropertyChanged(oldValue, newValue);
    },
});
RadListView.itemSwipeTemplateProperty = new Property({
    name: 'itemSwipeTemplate',
    defaultValue: undefined,
    valueChanged: (target, oldValue, newValue) => {
        target.onItemSwipeTemplatePropertyChanged(oldValue, newValue);
    },
});
RadListView.groupTemplateProperty = new Property({
    name: 'groupTemplate',
    defaultValue: undefined,
    valueChanged: (target, oldValue, newValue) => {
        target.onGroupTemplatePropertyChanged(oldValue, newValue);
    },
});
RadListView.multipleSelectionProperty = new Property({
    name: 'multipleSelection',
    defaultValue: false,
    valueConverter: booleanConverter,
    valueChanged: (target, oldValue, newValue) => {
        target.onMultipleSelectionPropertyChanged(oldValue, newValue);
    },
});
RadListView.itemReorderProperty = new Property({
    name: 'itemReorder',
    defaultValue: undefined,
    valueConverter: booleanConverter,
    valueChanged: (target, oldValue, newValue) => {
        target.onItemReorderPropertyChanged(oldValue, newValue);
    },
});
RadListView.itemSwipeProperty = new Property({
    name: 'itemSwipe',
    defaultValue: undefined,
    valueConverter: booleanConverter,
    valueChanged: (target, oldValue, newValue) => {
        target.onItemSwipePropertyChanged(oldValue, newValue);
    },
});
RadListView.swipeActionsProperty = new Property({
    name: 'swipeActions',
    defaultValue: undefined,
    valueConverter: booleanConverter,
    valueChanged: (target, oldValue, newValue) => {
        target.onSwipeActionsPropertyChanged(oldValue, newValue);
    },
});
RadListView.pullToRefreshProperty = new Property({
    name: 'pullToRefresh',
    defaultValue: undefined,
    valueConverter: booleanConverter,
    valueChanged: (target, oldValue, newValue) => {
        target.onPullToRefreshPropertyChanged(oldValue, newValue);
    },
});
RadListView.loadOnDemandModeProperty = new Property({
    name: 'loadOnDemandMode',
    defaultValue: undefined,
    valueConverter: listViewLoadOnDemandModeConverter,
    valueChanged: (target, oldValue, newValue) => {
        target.onLoadOnDemandModePropertyChanged(oldValue, newValue);
    },
});
RadListView.loadOnDemandBufferSizeProperty = new Property({
    name: 'loadOnDemandBufferSize',
    defaultValue: undefined,
    valueConverter: parseInt,
    valueChanged: (target, oldValue, newValue) => {
        target.onLoadOnDemandBufferSizePropertyChanged(oldValue, newValue);
    },
});
RadListView.selectionBehaviorProperty = new Property({
    name: 'selectionBehavior',
    defaultValue: ListViewSelectionBehavior.None,
    valueConverter: (value) => ListViewSelectionBehavior[value],
    valueChanged: (target, oldValue, newValue) => {
        target.onSelectionBehaviorPropertyChanged(oldValue, newValue);
    },
});
RadListView.itemsProperty = new Property({
    name: 'items',
    defaultValue: undefined,
    valueChanged: (target, oldValue, newValue) => {
        target.onItemsPropertyChanged(oldValue, newValue);
    },
});
RadListView.scrollPositionProperty = new Property({
    name: 'scrollPosition',
    defaultValue: undefined,
    valueConverter: (value) => ListViewScrollPosition[value],
    valueChanged: (target, oldValue, newValue) => {
        target.onScrollPositionPropertyChanged(oldValue, newValue);
    },
});
RadListView = __decorate([
    CSSType('RadListView')
], RadListView);
export { RadListView };
RadListView.itemSelectedBackgroundColorProperty.register(RadListView);
RadListView.enableCollapsibleGroupsProperty.register(RadListView);
RadListView.groupingFunctionProperty.register(RadListView);
RadListView.filteringFunctionProperty.register(RadListView);
RadListView.sortingFunctionProperty.register(RadListView);
RadListView.pullToRefreshStyleProperty.register(RadListView);
RadListView.headerItemTemplateProperty.register(RadListView);
RadListView.footerItemTemplateProperty.register(RadListView);
RadListView.reorderModeProperty.register(RadListView);
RadListView.listViewLayoutProperty.register(RadListView);
RadListView.loadOnDemandItemTemplateProperty.register(RadListView);
RadListView.itemTemplateSelectorProperty.register(RadListView);
RadListView.itemTemplateProperty.register(RadListView);
RadListView.groupTemplateProperty.register(RadListView);
RadListView.itemTemplatesProperty.register(RadListView);
RadListView.itemSwipeTemplateProperty.register(RadListView);
RadListView.multipleSelectionProperty.register(RadListView);
RadListView.itemReorderProperty.register(RadListView);
RadListView.itemSwipeProperty.register(RadListView);
RadListView.swipeActionsProperty.register(RadListView);
RadListView.pullToRefreshProperty.register(RadListView);
RadListView.loadOnDemandModeProperty.register(RadListView);
RadListView.loadOnDemandBufferSizeProperty.register(RadListView);
RadListView.selectionBehaviorProperty.register(RadListView);
RadListView.itemsProperty.register(RadListView);
RadListView.scrollPositionProperty.register(RadListView);
//# sourceMappingURL=common.js.map