'use strict';

var linearEasing = require('../../../utils/supports/linear-easing.js');
var linear = require('../utils/linear.js');
var cubicBezier = require('./cubic-bezier.js');
var supported = require('./supported.js');
var isBezierDefinition = require('../../../../../../../../motion-utils@12.36.0/node_modules/motion-utils/dist/es/easing/utils/is-bezier-definition.js');

function mapEasingToNativeEasing(easing, duration) {
    if (!easing) {
        return undefined;
    }
    else if (typeof easing === "function") {
        return linearEasing.supportsLinearEasing()
            ? linear.generateLinearEasing(easing, duration)
            : "ease-out";
    }
    else if (isBezierDefinition.isBezierDefinition(easing)) {
        return cubicBezier.cubicBezierAsString(easing);
    }
    else if (Array.isArray(easing)) {
        return easing.map((segmentEasing) => mapEasingToNativeEasing(segmentEasing, duration) ||
            supported.supportedWaapiEasing.easeOut);
    }
    else {
        return supported.supportedWaapiEasing[easing];
    }
}

exports.mapEasingToNativeEasing = mapEasingToNativeEasing;
