"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const buildTransform = require("./build-transform.js");
const isCssVariable = require("../../dom/utils/is-css-variable.js");
const transform = require("./transform.js");
const getAsType = require("../../dom/value-types/get-as-type.js");
const number = require("../../dom/value-types/number.js");
function buildHTMLStyles(state, latestValues, options, transformTemplate) {
  var _a;
  var style = state.style, vars = state.vars, transform$1 = state.transform, transformKeys = state.transformKeys, transformOrigin = state.transformOrigin;
  transformKeys.length = 0;
  var hasTransform = false;
  var hasTransformOrigin = false;
  var transformIsNone = true;
  for (var key in latestValues) {
    var value = latestValues[key];
    if (isCssVariable.isCSSVariable(key)) {
      vars[key] = value;
      continue;
    }
    var valueType = number.numberValueTypes[key];
    var valueAsType = getAsType.getValueAsType(value, valueType);
    if (transform.isTransformProp(key)) {
      hasTransform = true;
      transform$1[key] = valueAsType;
      transformKeys.push(key);
      if (!transformIsNone)
        continue;
      if (value !== ((_a = valueType.default) !== null && _a !== void 0 ? _a : 0))
        transformIsNone = false;
    } else if (transform.isTransformOriginProp(key)) {
      transformOrigin[key] = valueAsType;
      hasTransformOrigin = true;
    } else {
      style[key] = valueAsType;
    }
  }
  if (hasTransform) {
    style.transform = buildTransform.buildTransform(state, options, transformIsNone, transformTemplate);
  } else if (transformTemplate) {
    style.transform = transformTemplate({}, "");
  } else if (!latestValues.transform && style.transform) {
    style.transform = "none";
  }
  if (hasTransformOrigin) {
    style.transformOrigin = buildTransform.buildTransformOrigin(transformOrigin);
  }
}
exports.buildHTMLStyles = buildHTMLStyles;
//# sourceMappingURL=build-styles.js.map
