// packages/block-editor/src/utils/color-values.ts
function extractPresetSlug(rawValue, type) {
  if (typeof rawValue !== "string") {
    return void 0;
  }
  const userPrefix = `var:preset|${type}|`;
  if (rawValue.startsWith(userPrefix)) {
    return rawValue.slice(userPrefix.length);
  }
  const cssVarPrefix = `--wp--preset--${type}--`;
  const themeFormatMatch = rawValue.match(
    new RegExp(`^var\\(${cssVarPrefix}([^)]+)\\)$`)
  );
  return themeFormatMatch?.[1];
}
function encodeColorValueWithPalette(allColors, colorValue, slug) {
  if (slug) {
    return "var:preset|color|" + slug;
  }
  const colorObject = allColors.find(({ color }) => color === colorValue);
  return colorObject ? "var:preset|color|" + colorObject.slug : colorValue;
}
export {
  encodeColorValueWithPalette,
  extractPresetSlug
};
//# sourceMappingURL=color-values.mjs.map
