{"version":3,"file":"index.mjs","sources":["../src/index.js"],"sourcesContent":["// gap shorthand property matcher\nconst gapPropertyRegExp = /^(column-gap|gap|row-gap)$/i;\n\n// filter `display: grid` declarations\nconst isDisplayGrid = (node) => node.prop === 'display' && node.value === 'grid';\n\nmodule.exports = function creator(opts) {\n\tconst preserve = 'preserve' in Object(opts) ? Boolean(opts.preserve) : true;\n\n\treturn {\n\t\tpostcssPlugin: 'postcss-gap-properties',\n\t\t// walk decl shorthand gap, column-gap, or row-gap declaration\n\t\tDeclaration(decl) {\n\t\t\tif (gapPropertyRegExp.test(decl.prop) && decl.parent.some(isDisplayGrid)) {\n\t\t\t\t// insert a grid-* fallback declaration\n\t\t\t\tdecl.cloneBefore({\n\t\t\t\t\tprop: `grid-${decl.prop}`,\n\t\t\t\t});\n\n\t\t\t\t// conditionally remove the original declaration\n\t\t\t\tif (!preserve) {\n\t\t\t\t\tdecl.remove();\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t};\n};\n\nmodule.exports.postcss = true;\n"],"names":["gapPropertyRegExp","isDisplayGrid","node","prop","value","module","exports","opts","preserve","Object","Boolean","postcssPlugin","Declaration","decl","test","parent","some","cloneBefore","remove","postcss"],"mappings":"AACA,MAAMA,EAAoB,8BAGpBC,EAAiBC,GAAuB,YAAdA,EAAKC,MAAqC,SAAfD,EAAKE,MAEhEC,OAAOC,QAAU,SAAiBC,SAC3BC,IAAW,aAAcC,OAAOF,KAAQG,QAAQH,EAAKC,gBAEpD,CACNG,cAAe,yBAEfC,YAAYC,GACPb,EAAkBc,KAAKD,EAAKV,OAASU,EAAKE,OAAOC,KAAKf,KAEzDY,EAAKI,YAAY,CAChBd,KAAO,QAAOU,EAAKV,SAIfK,GACJK,EAAKK,aAOVb,OAAOC,QAAQa,SAAU"}