import _extends from "@babel/runtime/helpers/esm/extends"; /** * Add keys, values of `defaultProps` that does not exist in `props` * @param {object} defaultProps * @param {object} props * @returns {object} resolved props */ export default function resolveProps(defaultProps, props) { const output = _extends({}, props); Object.keys(defaultProps).forEach(propName => { if (propName.toString().match(/^(components|slots)$/)) { output[propName] = _extends({}, defaultProps[propName], output[propName]); } else if (propName.toString().match(/^(componentsProps|slotProps)$/)) { const defaultSlotProps = defaultProps[propName] || {}; const slotProps = props[propName]; output[propName] = {}; if (!slotProps || !Object.keys(slotProps)) { // Reduce the iteration if the slot props is empty output[propName] = defaultSlotProps; } else if (!defaultSlotProps || !Object.keys(defaultSlotProps)) { // Reduce the iteration if the default slot props is empty output[propName] = slotProps; } else { output[propName] = _extends({}, slotProps); Object.keys(defaultSlotProps).forEach(slotPropName => { output[propName][slotPropName] = resolveProps(defaultSlotProps[slotPropName], slotProps[slotPropName]); }); } } else if (output[propName] === undefined) { output[propName] = defaultProps[propName]; } }); return output; }