'use strict';

var decompose = require('./decompose.js');

var svgNode;

/* eslint-disable no-undef */
function parseCss(value) {
  const m = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + "");
  return m.isIdentity ? decompose.identity : decompose.default(m.a, m.b, m.c, m.d, m.e, m.f);
}

function parseSvg(value) {
  if (value == null) return decompose.identity;
  if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
  svgNode.setAttribute("transform", value);
  if (!(value = svgNode.transform.baseVal.consolidate())) return decompose.identity;
  value = value.matrix;
  return decompose.default(value.a, value.b, value.c, value.d, value.e, value.f);
}

exports.parseCss = parseCss;
exports.parseSvg = parseSvg;
