{"version":3,"sources":["../src/arrow.tsx","../../../node_modules/@radix-ui/react-slot/src/Slot.tsx","../../../node_modules/@radix-ui/react-compose-refs/src/composeRefs.tsx","../../mabi-ui-core/preflight/src/Preflight.tsx"],"names":["React","forwardRef"],"mappings":";;;;;AAAA,OAAOA,YAAmB;;;ACA1B,YAAYA,YAAW;;;ACAvB,YAAY,WAAW;AAQvB,SAAS,OAAU,KAAqB,OAAU;AAChD,MAAI,OAAO,QAAQ,YAAY;AAC7B,QAAI,KAAK;EACX,WAAW,QAAQ,QAAQ,QAAQ,QAAW;AAC3C,QAAkC,UAAU;EAC/C;AACF;AAMA,SAAS,eAAkB,MAAwB;AACjD,SAAO,CAAC,SAAY,KAAK,QAAQ,CAAC,QAAQ,OAAO,KAAK,IAAI,CAAC;AAC7D;;;ADYM,SA+CG,UA/CH,WAAA;AAvBN,IAAM,OAAa,kBAAmC,CAAC,OAAO,iBAAiB;AAC7E,QAAM,EAAE,UAAU,GAAG,UAAU,IAAI;AACnC,QAAM,gBAAsB,gBAAS,QAAQ,QAAQ;AACrD,QAAM,YAAY,cAAc,KAAK,WAAW;AAEhD,MAAI,WAAW;AAEb,UAAM,aAAa,UAAU,MAAM;AAEnC,UAAM,cAAc,cAAc,IAAI,CAAC,UAAU;AAC/C,UAAI,UAAU,WAAW;AAGvB,YAAU,gBAAS,MAAM,UAAU,IAAI;AAAG,iBAAa,gBAAS,KAAK,IAAI;AACzE,eAAa,sBAAe,UAAU,IACjC,WAAW,MAAM,WAClB;MACN,OAAO;AACL,eAAO;MACT;IACF,CAAC;AAED,WACE,oBAAC,WAAA,EAAW,GAAG,WAAW,KAAK,cAC5B,UAAM,sBAAe,UAAU,IACtB,oBAAa,YAAY,QAAW,WAAW,IACrD,KAAA,CACN;EAEJ;AAEA,SACE,oBAAC,WAAA,EAAW,GAAG,WAAW,KAAK,cAC5B,SAAA,CACH;AAEJ,CAAC;AAED,KAAK,cAAc;AAUnB,IAAM,YAAkB,kBAAgC,CAAC,OAAO,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G;AACpE,MAAI,UAAU,UAAU,oBAAoB,UAAU,OAAO;AAC7D,MAAI,SAAS;AACX,WAAQ,QAAgB;EAC1B;AAGA,WAAS,OAAO,yBAAyB,SAAS,KAAK,GAAG;AAC1D,YAAU,UAAU,oBAAoB,UAAU,OAAO;AACzD,MAAI,SAAS;AACX,WAAO,QAAQ,MAAM;EACvB;AAGA,SAAO,QAAQ,MAAM,OAAQ,QAAgB;AAC/C;;;AEhJA,OAAOA;AAAA,EAGN;AAAA,EACA,cAAAC;AAAA,EACA;AAAA,OACM;AAMP,IAAM,mBAAmB,cAAc,EAAE,qBAAqB,MAAM,CAAC;AAW9D,IAAM,mBAAmBA;AAAA,EAC/B,CAAC,OAAO,QAAQ;AACf,UAAM,EAAE,oBAAoB,IAAI,aAAa;AAC7C,QAAI,CAAC;AAAqB,aAAO,gBAAAD,OAAA,cAAAA,OAAA,gBAAG,MAAM,QAAS;AAEnD,WAAO,gBAAAA,OAAA,cAAC,QAAK,WAAU,qBAAoB,KAAW,GAAG,OAAO;AAAA,EACjE;AACD;AAEO,IAAM,eAAe,MAAM;AACjC,QAAM,UAAU,WAAW,gBAAgB;AAE3C,MAAI,YAAY,QAAW;AAC1B,WAAO,EAAE,qBAAqB,MAAM;AAAA,EACrC;AAEA,SAAO;AACR;;;AHpCO,IAAM,QAAwB,CAAC,EAAE,UAAU,MAAM;AACvD,SACC,gBAAAA,OAAA,cAAC,wBACA,gBAAAA,OAAA;AAAA,IAAC;AAAA;AAAA,MACA,WAAW;AAAA,QACV;AAAA,QACA;AAAA,MACD;AAAA;AAAA,EACA,CACF;AAEF","sourcesContent":["import React, { FC } from \"react\";\nimport { cn } from \"./cn\";\nimport { PreflightWrapper } from \"@mabi-ui/preflight\";\n\ntype ArrowProps = {\n\tclassName?: string;\n};\nexport const Arrow: FC<ArrowProps> = ({ className }) => {\n\treturn (\n\t\t<PreflightWrapper>\n\t\t\t<div\n\t\t\t\tclassName={cn(\n\t\t\t\t\t\"overflow-hidden w-4 h-4 relative after:absolute after:w-4 after:h-4 after:bg-white after:[transform:translateY(-8px)_rotate(-60deg)_skewX(-30deg)_scale(1,_0.866)] after:rounded-bl-md\",\n\t\t\t\t\tclassName\n\t\t\t\t)}\n\t\t\t></div>\n\t\t</PreflightWrapper>\n\t);\n};\n","import * as React from 'react';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotProps extends React.HTMLAttributes<HTMLElement> {\n  children?: React.ReactNode;\n}\n\nconst Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n  const { children, ...slotProps } = props;\n  const childrenArray = React.Children.toArray(children);\n  const slottable = childrenArray.find(isSlottable);\n\n  if (slottable) {\n    // the new element to render is the one passed as a child of `Slottable`\n    const newElement = slottable.props.children as React.ReactNode;\n\n    const newChildren = childrenArray.map((child) => {\n      if (child === slottable) {\n        // because the new element will be the one rendered, we are only interested\n        // in grabbing its children (`newElement.props.children`)\n        if (React.Children.count(newElement) > 1) return React.Children.only(null);\n        return React.isValidElement(newElement)\n          ? (newElement.props.children as React.ReactNode)\n          : null;\n      } else {\n        return child;\n      }\n    });\n\n    return (\n      <SlotClone {...slotProps} ref={forwardedRef}>\n        {React.isValidElement(newElement)\n          ? React.cloneElement(newElement, undefined, newChildren)\n          : null}\n      </SlotClone>\n    );\n  }\n\n  return (\n    <SlotClone {...slotProps} ref={forwardedRef}>\n      {children}\n    </SlotClone>\n  );\n});\n\nSlot.displayName = 'Slot';\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n  children: React.ReactNode;\n}\n\nconst SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n  const { children, ...slotProps } = props;\n\n  if (React.isValidElement(children)) {\n    const childrenRef = getElementRef(children);\n    return React.cloneElement(children, {\n      ...mergeProps(slotProps, children.props),\n      // @ts-ignore\n      ref: forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef,\n    });\n  }\n\n  return React.Children.count(children) > 1 ? React.Children.only(null) : null;\n});\n\nSlotClone.displayName = 'SlotClone';\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst Slottable = ({ children }: { children: React.ReactNode }) => {\n  return <>{children}</>;\n};\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>;\n\nfunction isSlottable(child: React.ReactNode): child is React.ReactElement {\n  return React.isValidElement(child) && child.type === Slottable;\n}\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps) {\n  // all child props should override\n  const overrideProps = { ...childProps };\n\n  for (const propName in childProps) {\n    const slotPropValue = slotProps[propName];\n    const childPropValue = childProps[propName];\n\n    const isHandler = /^on[A-Z]/.test(propName);\n    if (isHandler) {\n      // if the handler exists on both, we compose them\n      if (slotPropValue && childPropValue) {\n        overrideProps[propName] = (...args: unknown[]) => {\n          childPropValue(...args);\n          slotPropValue(...args);\n        };\n      }\n      // but if it exists only on the slot, we use only this one\n      else if (slotPropValue) {\n        overrideProps[propName] = slotPropValue;\n      }\n    }\n    // if it's `style`, we merge them\n    else if (propName === 'style') {\n      overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n    } else if (propName === 'className') {\n      overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');\n    }\n  }\n\n  return { ...slotProps, ...overrideProps };\n}\n\n// Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`\n// After React 19 accessing `element.ref` does the opposite.\n// https://github.com/facebook/react/pull/28348\n//\n// Access the ref using the method that doesn't yield a warning.\nfunction getElementRef(element: React.ReactElement) {\n  // React <=18 in DEV\n  let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get;\n  let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n  if (mayWarn) {\n    return (element as any).ref;\n  }\n\n  // React 19 in DEV\n  getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get;\n  mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n  if (mayWarn) {\n    return element.props.ref;\n  }\n\n  // Not DEV\n  return element.props.ref || (element as any).ref;\n}\n\nconst Root = Slot;\n\nexport {\n  Slot,\n  Slottable,\n  //\n  Root,\n};\nexport type { SlotProps };\n","import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n  if (typeof ref === 'function') {\n    ref(value);\n  } else if (ref !== null && ref !== undefined) {\n    (ref as React.MutableRefObject<T>).current = value;\n  }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]) {\n  return (node: T) => refs.forEach((ref) => setRef(ref, node));\n}\n\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]) {\n  // eslint-disable-next-line react-hooks/exhaustive-deps\n  return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n","'use client'\n\nimport { Slot } from \"@radix-ui/react-slot\";\nimport React, {\n\tFC,\n\tReactNode,\n\tcreateContext,\n\tforwardRef,\n\tuseContext,\n} from \"react\";\n\nexport type PreflightProps = {\n\tchildren?: ReactNode;\n};\n\nconst PreflightContext = createContext({ hasEnabledPreflight: false });\n\nexport const PreflightProvider: FC<PreflightProps> = (props) => {\n\treturn (\n\t\t<PreflightContext.Provider\n\t\t\tvalue={{ hasEnabledPreflight: true }}\n\t\t\t{...props}\n\t\t/>\n\t);\n};\n\nexport const PreflightWrapper = forwardRef<HTMLElement, PreflightProps>(\n\t(props, ref) => {\n\t\tconst { hasEnabledPreflight } = usePreflight();\n\t\tif (!hasEnabledPreflight) return <>{props.children}</>;\n\n\t\treturn <Slot className=\"mabi-ui-preflight\" ref={ref} {...props} />;\n\t}\n);\n\nexport const usePreflight = () => {\n\tconst context = useContext(PreflightContext);\n\n\tif (context === undefined) {\n\t\treturn { hasEnabledPreflight: false };\n\t}\n\n\treturn context;\n};\n"]}