{"ast":null,"code":"import canUseDom from \"./canUseDom\";\nimport contains from \"./contains\";\nvar APPEND_ORDER = 'data-rc-order';\nvar APPEND_PRIORITY = 'data-rc-priority';\nvar MARK_KEY = \"rc-util-key\";\nvar containerCache = new Map();\nfunction getMark() {\n  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n    mark = _ref.mark;\n  if (mark) {\n    return mark.startsWith('data-') ? mark : \"data-\".concat(mark);\n  }\n  return MARK_KEY;\n}\nfunction getContainer(option) {\n  if (option.attachTo) {\n    return option.attachTo;\n  }\n  var head = document.querySelector('head');\n  return head || document.body;\n}\nfunction getOrder(prepend) {\n  if (prepend === 'queue') {\n    return 'prependQueue';\n  }\n  return prepend ? 'prepend' : 'append';\n}\n\n/**\n * Find style which inject by rc-util\n */\nfunction findStyles(container) {\n  return Array.from((containerCache.get(container) || container).children).filter(function (node) {\n    return node.tagName === 'STYLE';\n  });\n}\nexport function injectCSS(css) {\n  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  if (!canUseDom()) {\n    return null;\n  }\n  var csp = option.csp,\n    prepend = option.prepend,\n    _option$priority = option.priority,\n    priority = _option$priority === void 0 ? 0 : _option$priority;\n  var mergedOrder = getOrder(prepend);\n  var isPrependQueue = mergedOrder === 'prependQueue';\n  var styleNode = document.createElement('style');\n  styleNode.setAttribute(APPEND_ORDER, mergedOrder);\n  if (isPrependQueue && priority) {\n    styleNode.setAttribute(APPEND_PRIORITY, \"\".concat(priority));\n  }\n  if (csp !== null && csp !== void 0 && csp.nonce) {\n    styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce;\n  }\n  styleNode.innerHTML = css;\n  var container = getContainer(option);\n  var firstChild = container.firstChild;\n  if (prepend) {\n    // If is queue `prepend`, it will prepend first style and then append rest style\n    if (isPrependQueue) {\n      var existStyle = findStyles(container).filter(function (node) {\n        // Ignore style which not injected by rc-util with prepend\n        if (!['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER))) {\n          return false;\n        }\n\n        // Ignore style which priority less then new style\n        var nodePriority = Number(node.getAttribute(APPEND_PRIORITY) || 0);\n        return priority >= nodePriority;\n      });\n      if (existStyle.length) {\n        container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);\n        return styleNode;\n      }\n    }\n\n    // Use `insertBefore` as `prepend`\n    container.insertBefore(styleNode, firstChild);\n  } else {\n    container.appendChild(styleNode);\n  }\n  return styleNode;\n}\nfunction findExistNode(key) {\n  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  var container = getContainer(option);\n  return findStyles(container).find(function (node) {\n    return node.getAttribute(getMark(option)) === key;\n  });\n}\nexport function removeCSS(key) {\n  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  var existNode = findExistNode(key, option);\n  if (existNode) {\n    var container = getContainer(option);\n    container.removeChild(existNode);\n  }\n}\n\n/**\n * qiankun will inject `appendChild` to insert into other\n */\nfunction syncRealContainer(container, option) {\n  var cachedRealContainer = containerCache.get(container);\n\n  // Find real container when not cached or cached container removed\n  if (!cachedRealContainer || !contains(document, cachedRealContainer)) {\n    var placeholderStyle = injectCSS('', option);\n    var parentNode = placeholderStyle.parentNode;\n    containerCache.set(container, parentNode);\n    container.removeChild(placeholderStyle);\n  }\n}\n\n/**\n * manually clear container cache to avoid global cache in unit testes\n */\nexport function clearContainerCache() {\n  containerCache.clear();\n}\nexport function updateCSS(css, key) {\n  var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n  var container = getContainer(option);\n\n  // Sync real parent\n  syncRealContainer(container, option);\n  var existNode = findExistNode(key, option);\n  if (existNode) {\n    var _option$csp, _option$csp2;\n    if ((_option$csp = option.csp) !== null && _option$csp !== void 0 && _option$csp.nonce && existNode.nonce !== ((_option$csp2 = option.csp) === null || _option$csp2 === void 0 ? void 0 : _option$csp2.nonce)) {\n      var _option$csp3;\n      existNode.nonce = (_option$csp3 = option.csp) === null || _option$csp3 === void 0 ? void 0 : _option$csp3.nonce;\n    }\n    if (existNode.innerHTML !== css) {\n      existNode.innerHTML = css;\n    }\n    return existNode;\n  }\n  var newNode = injectCSS(css, option);\n  newNode.setAttribute(getMark(option), key);\n  return newNode;\n}","map":{"version":3,"names":["canUseDom","contains","APPEND_ORDER","APPEND_PRIORITY","MARK_KEY","containerCache","Map","getMark","_ref","arguments","length","undefined","mark","startsWith","concat","getContainer","option","attachTo","head","document","querySelector","body","getOrder","prepend","findStyles","container","Array","from","get","children","filter","node","tagName","injectCSS","css","csp","_option$priority","priority","mergedOrder","isPrependQueue","styleNode","createElement","setAttribute","nonce","innerHTML","firstChild","existStyle","includes","getAttribute","nodePriority","Number","insertBefore","nextSibling","appendChild","findExistNode","key","find","removeCSS","existNode","removeChild","syncRealContainer","cachedRealContainer","placeholderStyle","parentNode","set","clearContainerCache","clear","updateCSS","_option$csp","_option$csp2","_option$csp3","newNode"],"sources":["/Users/chrishaack/UC_Trains_Voice/react-demo/node_modules/rc-util/es/Dom/dynamicCSS.js"],"sourcesContent":["import canUseDom from \"./canUseDom\";\nimport contains from \"./contains\";\nvar APPEND_ORDER = 'data-rc-order';\nvar APPEND_PRIORITY = 'data-rc-priority';\nvar MARK_KEY = \"rc-util-key\";\nvar containerCache = new Map();\nfunction getMark() {\n  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n    mark = _ref.mark;\n  if (mark) {\n    return mark.startsWith('data-') ? mark : \"data-\".concat(mark);\n  }\n  return MARK_KEY;\n}\nfunction getContainer(option) {\n  if (option.attachTo) {\n    return option.attachTo;\n  }\n  var head = document.querySelector('head');\n  return head || document.body;\n}\nfunction getOrder(prepend) {\n  if (prepend === 'queue') {\n    return 'prependQueue';\n  }\n  return prepend ? 'prepend' : 'append';\n}\n\n/**\n * Find style which inject by rc-util\n */\nfunction findStyles(container) {\n  return Array.from((containerCache.get(container) || container).children).filter(function (node) {\n    return node.tagName === 'STYLE';\n  });\n}\nexport function injectCSS(css) {\n  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  if (!canUseDom()) {\n    return null;\n  }\n  var csp = option.csp,\n    prepend = option.prepend,\n    _option$priority = option.priority,\n    priority = _option$priority === void 0 ? 0 : _option$priority;\n  var mergedOrder = getOrder(prepend);\n  var isPrependQueue = mergedOrder === 'prependQueue';\n  var styleNode = document.createElement('style');\n  styleNode.setAttribute(APPEND_ORDER, mergedOrder);\n  if (isPrependQueue && priority) {\n    styleNode.setAttribute(APPEND_PRIORITY, \"\".concat(priority));\n  }\n  if (csp !== null && csp !== void 0 && csp.nonce) {\n    styleNode.nonce = csp === null || csp === void 0 ? void 0 : csp.nonce;\n  }\n  styleNode.innerHTML = css;\n  var container = getContainer(option);\n  var firstChild = container.firstChild;\n  if (prepend) {\n    // If is queue `prepend`, it will prepend first style and then append rest style\n    if (isPrependQueue) {\n      var existStyle = findStyles(container).filter(function (node) {\n        // Ignore style which not injected by rc-util with prepend\n        if (!['prepend', 'prependQueue'].includes(node.getAttribute(APPEND_ORDER))) {\n          return false;\n        }\n\n        // Ignore style which priority less then new style\n        var nodePriority = Number(node.getAttribute(APPEND_PRIORITY) || 0);\n        return priority >= nodePriority;\n      });\n      if (existStyle.length) {\n        container.insertBefore(styleNode, existStyle[existStyle.length - 1].nextSibling);\n        return styleNode;\n      }\n    }\n\n    // Use `insertBefore` as `prepend`\n    container.insertBefore(styleNode, firstChild);\n  } else {\n    container.appendChild(styleNode);\n  }\n  return styleNode;\n}\nfunction findExistNode(key) {\n  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  var container = getContainer(option);\n  return findStyles(container).find(function (node) {\n    return node.getAttribute(getMark(option)) === key;\n  });\n}\nexport function removeCSS(key) {\n  var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n  var existNode = findExistNode(key, option);\n  if (existNode) {\n    var container = getContainer(option);\n    container.removeChild(existNode);\n  }\n}\n\n/**\n * qiankun will inject `appendChild` to insert into other\n */\nfunction syncRealContainer(container, option) {\n  var cachedRealContainer = containerCache.get(container);\n\n  // Find real container when not cached or cached container removed\n  if (!cachedRealContainer || !contains(document, cachedRealContainer)) {\n    var placeholderStyle = injectCSS('', option);\n    var parentNode = placeholderStyle.parentNode;\n    containerCache.set(container, parentNode);\n    container.removeChild(placeholderStyle);\n  }\n}\n\n/**\n * manually clear container cache to avoid global cache in unit testes\n */\nexport function clearContainerCache() {\n  containerCache.clear();\n}\nexport function updateCSS(css, key) {\n  var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n  var container = getContainer(option);\n\n  // Sync real parent\n  syncRealContainer(container, option);\n  var existNode = findExistNode(key, option);\n  if (existNode) {\n    var _option$csp, _option$csp2;\n    if ((_option$csp = option.csp) !== null && _option$csp !== void 0 && _option$csp.nonce && existNode.nonce !== ((_option$csp2 = option.csp) === null || _option$csp2 === void 0 ? void 0 : _option$csp2.nonce)) {\n      var _option$csp3;\n      existNode.nonce = (_option$csp3 = option.csp) === null || _option$csp3 === void 0 ? void 0 : _option$csp3.nonce;\n    }\n    if (existNode.innerHTML !== css) {\n      existNode.innerHTML = css;\n    }\n    return existNode;\n  }\n  var newNode = injectCSS(css, option);\n  newNode.setAttribute(getMark(option), key);\n  return newNode;\n}"],"mappings":"AAAA,OAAOA,SAAS,MAAM,aAAa;AACnC,OAAOC,QAAQ,MAAM,YAAY;AACjC,IAAIC,YAAY,GAAG,eAAe;AAClC,IAAIC,eAAe,GAAG,kBAAkB;AACxC,IAAIC,QAAQ,GAAG,aAAa;AAC5B,IAAIC,cAAc,GAAG,IAAIC,GAAG,CAAC,CAAC;AAC9B,SAASC,OAAOA,CAAA,EAAG;EACjB,IAAIC,IAAI,GAAGC,SAAS,CAACC,MAAM,GAAG,CAAC,IAAID,SAAS,CAAC,CAAC,CAAC,KAAKE,SAAS,GAAGF,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC/EG,IAAI,GAAGJ,IAAI,CAACI,IAAI;EAClB,IAAIA,IAAI,EA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