"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.imports = void 0;
const transpile_1 = require("../../transpile");
exports.imports = [
    { name: 'WmSlider', from: '@wavemaker/app-rn-runtime/components/input/slider/slider.component' }
];
exports.default = {
    pre: (element, context) => {
        var _a;
        let getDisplayExpression = (0, transpile_1.createExpression)(element, 'displayexpression');
        let onChangeFunction = element.getAttribute('on-change');
        let onChangeFunctionRegex = /fragment\.(\w+)\(/;
        let onChangeFunctionName = (_a = `${onChangeFunction}`.match(onChangeFunctionRegex)) === null || _a === void 0 ? void 0 : _a[1];
        let onChange = onChangeFunction ? `($event,widget,newVal,oldVal) => {
      if (fragment.${onChangeFunctionName}) {
        return ${onChangeFunction}
      }
    }` : '';
        if (onChangeFunction) {
            element.removeAttribute('on-change');
        }
        if (getDisplayExpression) {
            element.removeAttribute('displayexpression');
            element.removeAttribute('displayfield');
        }
        let getToolTipExpression = (0, transpile_1.createExpression)(element, 'tooltipexpression');
        if (getToolTipExpression) {
            element.removeAttribute('tooltipexpression');
        }
        return `<WmSlider 
      ${(0, transpile_1.transformAttrs)(element, context)} 
      ${onChangeFunction ? `onChange={${onChange}}` : ''}
      ${getDisplayExpression ? `getDisplayExpression=${getDisplayExpression}` : ''}
      ${getToolTipExpression ? `getToolTipExpression=${getToolTipExpression}` : ''}>`;
    },
    post: (element, context) => '</WmSlider>',
    imports: (element, context) => exports.imports
};
//# sourceMappingURL=slider.transformer.js.map