{"version":3,"sources":["../src/childrenHavePropXorChildren.js"],"names":["childrenHavePropXorChildren","prop","TypeError","validator","childrenHavePropXorChildrenWithProp","_","componentName","children","truthyChildrenCount","propCount","grandchildrenCount","React","Children","forEach","child","props","count","isRequired"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAEe,SAASA,2BAAT,CAAqCC,IAArC,EAA2C;AACxD,MAAI,OAAOA,IAAP,KAAgB,QAAhB,IAA4B,QAAOA,IAAP,MAAgB,QAAhD,EAA0D;AACxD,UAAM,IAAIC,SAAJ,CAAc,wCAAd,CAAN;AACD;;AAED,MAAMC,SAAS,GAAG,SAASC,mCAAT,OAA2DC,CAA3D,EAA8DC,aAA9D,EAA6E;AAAA,QAA9BC,QAA8B,QAA9BA,QAA8B;AAC7F,QAAIC,mBAAmB,GAAG,CAA1B;AACA,QAAIC,SAAS,GAAG,CAAhB;AACA,QAAIC,kBAAkB,GAAG,CAAzB;;AAEAC,sBAAMC,QAAN,CAAeC,OAAf,CAAuBN,QAAvB,EAAiC,UAACO,KAAD,EAAW;AAC1C,UAAI,CAACA,KAAL,EAAY;AACV;AACD;;AAEDN,MAAAA,mBAAmB,IAAI,CAAvB;;AAEA,UAAIM,KAAK,CAACC,KAAN,CAAYd,IAAZ,CAAJ,EAAuB;AACrBQ,QAAAA,SAAS,IAAI,CAAb;AACD;;AAED,UAAIE,kBAAMC,QAAN,CAAeI,KAAf,CAAqBF,KAAK,CAACC,KAAN,CAAYR,QAAjC,CAAJ,EAAgD;AAC9CG,QAAAA,kBAAkB,IAAI,CAAtB;AACD;AACF,KAdD;;AAgBA,QACGD,SAAS,KAAKD,mBAAd,IAAqCE,kBAAkB,KAAK,CAA7D,IACID,SAAS,KAAK,CAAd,IAAmBC,kBAAkB,KAAKF,mBAD9C,IAEIC,SAAS,KAAK,CAAd,IAAmBC,kBAAkB,KAAK,CAHhD,EAIE;AACA,aAAO,IAAP;AACD;;AAED,WAAO,IAAIR,SAAJ,YAAmBI,aAAnB,wDAA0EL,IAA1E,qDAAP;AACD,GA9BD;;AA+BAE,EAAAA,SAAS,CAACc,UAAV,GAAuBd,SAAvB;AAEA,SAAO,+BAAcA,SAAd,gDAAgEF,IAAhE,GAAwEA,IAAxE,CAAP;AACD","sourcesContent":["import React from 'react';\nimport wrapValidator from './helpers/wrapValidator';\n\nexport default function childrenHavePropXorChildren(prop) {\n if (typeof prop !== 'string' && typeof prop !== 'symbol') {\n throw new TypeError('invalid prop: must be string or symbol');\n }\n\n const validator = function childrenHavePropXorChildrenWithProp({ children }, _, componentName) {\n let truthyChildrenCount = 0;\n let propCount = 0;\n let grandchildrenCount = 0;\n\n React.Children.forEach(children, (child) => {\n if (!child) {\n return;\n }\n\n truthyChildrenCount += 1;\n\n if (child.props[prop]) {\n propCount += 1;\n }\n\n if (React.Children.count(child.props.children)) {\n grandchildrenCount += 1;\n }\n });\n\n if (\n (propCount === truthyChildrenCount && grandchildrenCount === 0)\n || (propCount === 0 && grandchildrenCount === truthyChildrenCount)\n || (propCount === 0 && grandchildrenCount === 0)\n ) {\n return null;\n }\n\n return new TypeError(`\\`${componentName}\\` requires children to all have prop “${prop}”, all have children, or all have neither.`);\n };\n validator.isRequired = validator;\n\n return wrapValidator(validator, `childrenHavePropXorChildrenWithProp:${prop}`, prop);\n}\n"],"file":"childrenHavePropXorChildren.js"}