{"version":3,"file":"combine-style.cjs","sources":["../../src/utils/combine-style.ts"],"sourcesContent":["// credit: https://github.com/solidjs-community/solid-primitives/blob/main/packages/props/src/combineProps.ts\n\nimport type { JSX } from 'solid-js'\n\nconst extractCSSregex = /((?:--)?[\\w-]+)\\s*:\\s*([^;]*)/g;\n\n/**\n * converts inline string styles to object form\n * @example\n * const styles = stringStyleToObject(\"margin: 24px; border: 1px solid #121212\");\n * styles; // { margin: \"24px\", border: \"1px solid #121212\" }\n * */\nfunction stringStyleToObject(style: string): JSX.CSSProperties {\n  const object: Record<string, string> = {};\n  let match: RegExpExecArray | null;\n  while ((match = extractCSSregex.exec(style))) {\n    object[match[1]!] = match[2]!;\n  }\n  return object;\n}\n\n/**\n * Combines two set of styles together. Accepts both string and object styles.\\\n * @example\n * const styles = combineStyle(\"margin: 24px; border: 1px solid #121212\", {\n *   margin: \"2rem\",\n *   padding: \"16px\"\n * });\n * styles; // { margin: \"2rem\", border: \"1px solid #121212\", padding: \"16px\" }\n */\nexport function combineStyle(a: string, b: string): string;\nexport function combineStyle(\n  a: JSX.CSSProperties | undefined,\n  b: JSX.CSSProperties | undefined,\n): JSX.CSSProperties;\nexport function combineStyle(\n  a: JSX.CSSProperties | string | undefined,\n  b: JSX.CSSProperties | string | undefined,\n): JSX.CSSProperties;\nexport function combineStyle(\n  a: JSX.CSSProperties | string | undefined,\n  b: JSX.CSSProperties | string | undefined,\n): JSX.CSSProperties | string {\n  if (typeof a === \"string\") {\n    if (typeof b === \"string\") return `${a};${b}`;\n\n    a = stringStyleToObject(a);\n  } else if (typeof b === \"string\") {\n    b = stringStyleToObject(b);\n  }\n\n  return { ...a, ...b };\n}"],"names":["extractCSSregex","stringStyleToObject","style","object","match","combineStyle","a","b"],"mappings":"gFAIA,MAAMA,EAAkB,iCAQxB,SAASC,EAAoBC,EAAkC,CAC7D,MAAMC,EAAiC,CAAA,EACvC,IAAIC,EACJ,KAAQA,EAAQJ,EAAgB,KAAKE,CAAK,GACxCC,EAAOC,EAAM,CAAC,CAAE,EAAIA,EAAM,CAAC,EAE7B,OAAOD,CACT,CAoBO,SAASE,EACdC,EACAC,EAC4B,CAC5B,GAAI,OAAOD,GAAM,SAAU,CACzB,GAAI,OAAOC,GAAM,eAAiB,GAAGD,CAAC,IAAIC,CAAC,GAE3CD,EAAIL,EAAoBK,CAAC,CAC3B,MAAW,OAAOC,GAAM,WACtBA,EAAIN,EAAoBM,CAAC,GAG3B,MAAO,CAAE,GAAGD,EAAG,GAAGC,CAAA,CACpB"}