{"version":3,"file":"index.mjs","sources":["../src/options.js","../src/onCSSDeclaration.js","../src/index.js"],"sourcesContent":["export default {\n\t/** Whether to preserve the original place value. */\n\tpreserve: true,\n};\n","import valueParser from 'postcss-value-parser';\nimport options from './options';\n\nexport default (decl, { result }) => {\n\t// alignment\n\tconst alignment = decl.prop.match(placeMatch)[1];\n\n\t// value ast and child nodes\n\tlet value;\n\n\ttry {\n\t\tvalue = valueParser(decl.value);\n\t} catch (error) {\n\t\tdecl.warn(\n\t\t\tresult,\n\t\t\t`Failed to parse value '${decl.value}'. Leaving the original value intact.`,\n\t\t);\n\t}\n\n\tif (typeof value === 'undefined') {\n\t\treturn;\n\t}\n\n\tlet alignmentValues = [];\n\n\tif (!value.nodes.length) {\n\t\talignmentValues = [valueParser.stringify(value)];\n\t} else {\n\t\talignmentValues = value.nodes.filter((node) => {\n\t\t\treturn node.type === 'word' || node.type === 'function';\n\t\t}).map((node) => {\n\t\t\treturn valueParser.stringify(node);\n\t\t});\n\t}\n\n\tdecl.cloneBefore({\n\t\tprop: `align-${alignment}`,\n\t\tvalue: alignmentValues[0],\n\t});\n\n\tdecl.cloneBefore({\n\t\tprop: `justify-${alignment}`,\n\t\tvalue: alignmentValues[1] || alignmentValues[0],\n\t});\n\n\t// conditionally remove place-[alignment]\n\tif (!options.preserve) {\n\t\tdecl.remove();\n\t}\n};\n\nexport const placeMatch = /^place-(content|items|self)/;\n","import options from './options';\nimport onCSSDeclaration, { placeMatch } from './onCSSDeclaration';\n\nconst creator = opts => {\n\t// prepare options\n\tif ('preserve' in Object(opts)) options.preserve = Boolean(opts.preserve);\n\n\treturn {\n\t\tpostcssPlugin: 'postcss-place',\n\t\tDeclaration: (decl, { result }) => {\n\t\t\tif (placeMatch.test(decl)) {\n\t\t\t\tonCSSDeclaration(decl, { result });\n\t\t\t}\n\t\t},\n\t};\n};\n\ncreator.postcss = true;\n\nexport default creator;\n"],"names":["preserve","placeMatch","creator","opts","Object","options","Boolean","postcssPlugin","Declaration","decl","result","test","alignment","prop","match","value","valueParser","error","warn","alignmentValues","nodes","length","filter","node","type","map","stringify","cloneBefore","remove","onCSSDeclaration","postcss"],"mappings":"oCAAA,MAAe,CAEdA,UAAU,GCiDJ,MAAMC,EAAa,8BChDpBC,EAAUC,IAEX,aAAcC,OAAOD,KAAOE,EAAQL,SAAWM,QAAQH,EAAKH,WAEzD,CACNO,cAAe,gBACfC,YAAa,CAACC,GAAQC,OAAAA,MACjBT,EAAWU,KAAKF,MDPPA,GAAQC,OAAAA,YAEjBE,EAAYH,EAAKI,KAAKC,MAAMb,GAAY,OAG1Cc,MAGHA,EAAQC,EAAYP,EAAKM,OACxB,MAAOE,GACRR,EAAKS,KACJR,EACC,0BAAyBD,EAAKM,sDAIZ,IAAVA,aAIPI,EAAkB,GAKrBA,EAHIJ,EAAMK,MAAMC,OAGEN,EAAMK,MAAME,QAAQC,GAChB,SAAdA,EAAKC,MAAiC,aAAdD,EAAKC,OAClCC,KAAKF,GACAP,EAAYU,UAAUH,KALZ,CAACP,EAAYU,UAAUX,IAS1CN,EAAKkB,YAAY,CAChBd,KAAO,SAAQD,IACfG,MAAOI,EAAgB,KAGxBV,EAAKkB,YAAY,CAChBd,KAAO,WAAUD,IACjBG,MAAOI,EAAgB,IAAMA,EAAgB,KAIzCd,EAAQL,UACZS,EAAKmB,UCpCHC,CAAiBpB,EAAM,CAAEC,OAAAA,OAM7BR,EAAQ4B,SAAU"}