{"version":3,"sources":["jsdelivr-header.js","/npm/postcss-calc@11.3.0/src/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OCLO,eAAgB,qBACd,6BAAgC,qBAuBzC,SAAS,eAAe,EAAM,EAAM,EAAS,GAE3C,MAAM,EAAoD,EAGpD,EAAU,EAAO,GACvB,IAAK,yBAAyB,GAC5B,OAEF,MAAM,EAAc,WAAW,EAAS,CACtC,UAAW,EAAQ,UACnB,sBAAuB,EAAQ,sBAC/B,aACE,EAAQ,cACR,CAAE,IACA,EAAO,KAAK,EAAM,QAAS,CAAE,QAC9B,GACH,OAAS,IACP,EAAO,KAAK,EAAS,CAAE,OAAQ,eAAgB,UAGjD,kBAA4B,aAAT,GAAuB,EAAQ,oBAEhD,IAAgB,IAClB,EAAO,GAAQ,EAEnB,CAMA,SAAS,cAAc,GAErB,MAAM,EAAU,CACd,uBAAuB,EACvB,cAAc,EACd,WAAW,EACX,mBAAmB,KAChB,EAEH,UAAW,GAAM,WAAa,GAGhC,MAAO,CACL,cAAe,eAKf,QAAA,CAAS,GAAK,OAAE,IACd,EAAI,KAAM,IACU,SAAd,EAAK,KACP,eAAe,EAAM,QAAS,EAAS,GAChB,WAAd,EAAK,MAAqB,EAAQ,aAC3C,eAAe,EAAM,SAAU,EAAS,GACjB,SAAd,EAAK,MAAmB,EAAQ,WAGzC,eAAe,EAAM,WAAY,EAAS,IAGhD,EAEJ,CAGA,cAAc,SAAU,iBAEuD,qBAGtE","file":"/npm/postcss-calc@11.3.0/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.48.0.\n * Original file: /npm/postcss-calc@11.3.0/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","// PostCSS adapter over the standalone component-value reducer.\nimport reduceCalc from './reduce.js';\nimport { hasPotentialMathFunction } from './lib/functions.js';\n/**\n * @typedef {object} PostCssCalcOptions\n * @property {number | false} [precision]\n * @property {boolean} [warnWhenCannotResolve]\n * @property {boolean} [mediaQueries]\n * @property {boolean} [selectors]\n * @property {boolean} [unwrapSingleValue] Serialize fully resolved finite scalar results without calculation syntax. Defaults to `false`.\n * @property {(error: Error, input: string) => void} [onParseError] Invoked when parse/simplify throws. Replaces the default `result.warn`.\n */\n\n/** @typedef {Required<Omit<PostCssCalcOptions, 'onParseError'>> & Pick<PostCssCalcOptions, 'onParseError'>} ResolvedOptions */\n\n/**\n * Runs `reduceCalc` over one text property of a decl/atrule/rule node\n * and updates it in place.\n *\n * @param {import('postcss').Declaration | import('postcss').AtRule | import('postcss').Rule} node\n * @param {'value' | 'params' | 'selector'} prop\n * @param {ResolvedOptions} options\n * @param {import('postcss').Result} result\n * @return {void}\n */\nfunction applyTransform(node, prop, options, result) {\n  // `Declaration`/`AtRule`/`Rule` don't share a typed \"text property\" name.\n  const target = /** @type {Record<typeof prop, string>} */ (\n    /** @type {unknown} */ (node)\n  );\n  const current = target[prop];\n  if (!hasPotentialMathFunction(current)) {\n    return;\n  }\n  const transformed = reduceCalc(current, {\n    precision: options.precision,\n    warnWhenCannotResolve: options.warnWhenCannotResolve,\n    onParseError:\n      options.onParseError ??\n      ((error) => {\n        result.warn(error.message, { node });\n      }),\n    onWarn: (message) => {\n      result.warn(message, { plugin: 'postcss-calc', node });\n    },\n    // Selectors cannot contain calc(), so they always unwrap resolved values.\n    unwrapSingleValue: prop === 'selector' || options.unwrapSingleValue,\n  });\n  if (transformed !== current) {\n    target[prop] = transformed;\n  }\n}\n\n/**\n * @param {PostCssCalcOptions} [opts]\n * @return {import('postcss').Plugin}\n */\nfunction pluginCreator(opts) {\n  /** @type {ResolvedOptions} */\n  const options = {\n    warnWhenCannotResolve: false,\n    mediaQueries: false,\n    selectors: false,\n    unwrapSingleValue: false,\n    ...opts,\n    // An explicit `precision: undefined` keeps the default.\n    precision: opts?.precision ?? 5,\n  };\n\n  return {\n    postcssPlugin: 'postcss-calc',\n    /**\n     * @param {import('postcss').Root} css\n     * @param {import('postcss').Helpers} helpers\n     */\n    OnceExit(css, { result }) {\n      css.walk((node) => {\n        if (node.type === 'decl') {\n          applyTransform(node, 'value', options, result);\n        } else if (node.type === 'atrule' && options.mediaQueries) {\n          applyTransform(node, 'params', options, result);\n        } else if (node.type === 'rule' && options.selectors) {\n          // Reduces `:nth-child(calc(...))` via the function walk. calc() in a\n          // quoted attribute value is a literal match, so it's left untouched.\n          applyTransform(node, 'selector', options, result);\n        }\n      });\n    },\n  };\n}\n\n/** @type {true} */\npluginCreator.postcss = true;\n\nexport default /** @type import('postcss').PluginCreator<PostCssCalcOptions>*/ (\n  pluginCreator\n);\nexport { pluginCreator as 'module.exports' };\n"]}