{"version":3,"sources":["jsdelivr-header.js","/npm/react-native-figma-squircle@0.3.5/lib/commonjs/index.tsx"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,mNCNA,IAAA,MAAA,wBAAA,QAAA,UACA,aAAA,QAAA,gBAEA,gBAAA,wBAAA,QAAA,qBACA,eAAA,QAAA,kB,63BAkBA,SAAS,cAAa,eACpB,EADoB,SAEpB,KACG,IAEH,OACE,MAAA,cAAC,aAAA,KAAS,EACR,MAAA,cAAC,mBAAuB,GACvB,EAGN,CAED,SAAS,oBAAmB,aAC1B,EAAe,EADW,oBAE1B,EAF0B,qBAG1B,EAH0B,wBAI1B,EAJ0B,uBAK1B,EAL0B,gBAM1B,EAN0B,UAO1B,EAAY,OAPc,YAQ1B,EAAc,OARY,YAS1B,EAAc,IAEd,OACE,MAAA,cAAC,KAAD,CAAM,MAAO,wBAAW,eACrB,EAAG,QAAO,aAGT,GAFkB,EAAc,EAmBzB,CACL,MAAM,EAAc,CAClB,EACA,EACA,EACA,EACA,GACA,QACC,GAAiB,GAAgB,EAAe,IAG7C,EAAiB,KAAK,OAAO,GAE7B,GADN,EAAc,KAAK,IAAI,EAAa,IACF,EAE5B,GAAoB,EAAA,eAAA,YAAW,CACnC,MAAO,EAAQ,EACf,OAAQ,EAAS,EACjB,kBACA,aAAc,eAAe,EAAc,GAC3C,oBAAqB,eACnB,EACA,GAEF,qBAAsB,eACpB,EACA,GAEF,wBAAyB,eACvB,EACA,GAEF,uBAAwB,eACtB,EACA,KAIJ,OACE,MAAA,cAAC,gBAAA,QAAD,CAAK,MAAM,OAAO,OAAO,OAAO,QAAU,OAAM,KAAS,KACvD,MAAA,cAAC,gBAAA,KAAD,CACE,EAAG,EACH,KAAM,EACN,OAAQ,EACR,YAAa,EACb,UAAW,IAIlB,CAlEe,CACd,MAAM,GAAe,EAAA,eAAA,YAAW,CAC9B,QACA,SACA,kBACA,eACA,sBACA,uBACA,0BACA,2BAGF,OACE,MAAA,cAAC,gBAAA,QAAD,CAAK,MAAM,OAAO,OAAO,OAAO,QAAU,OAAM,KAAS,KACvD,MAAA,cAAC,gBAAA,KAAD,CAAM,EAAG,EAAc,KAAM,IAGlC,CAiDA,GAIR,CAED,SAAS,eAAe,EAA4B,GAClD,OAAI,EACK,KAAK,IAAI,EAAG,EAAS,GAGvB,CACR,CAOD,SAAS,MAAK,SAAE,KAAa,IAC3B,MAAO,EAAM,IACX,EAAA,MAAA,UAAmD,MAErD,OACE,MAAA,cAAC,aAAA,KAAD,SAAA,GACM,EADN,CAEE,SAAW,IACT,EAAQ,CACN,MAAO,EAAE,YAAY,OAAO,MAC5B,OAAQ,EAAE,YAAY,OAAO,QAF/B,IAMD,EAAO,EAAS,GAAQ,KAG9B","file":"/npm/react-native-figma-squircle@0.3.5/lib/commonjs/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/react-native-figma-squircle@0.3.5/lib/commonjs/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import * as React from 'react'\nimport { ViewProps, View, StyleSheet } from 'react-native'\nimport { PropsWithChildren, ReactNode, useState } from 'react'\nimport Svg, { Color, Path } from 'react-native-svg'\nimport { getSvgPath } from 'figma-squircle'\n\ninterface SquircleParams {\n  cornerRadius?: number\n  topLeftCornerRadius?: number\n  topRightCornerRadius?: number\n  bottomRightCornerRadius?: number\n  bottomLeftCornerRadius?: number\n  cornerSmoothing: number\n  fillColor?: Color\n  strokeColor?: Color\n  strokeWidth?: number\n}\n\ninterface SquircleViewProps extends ViewProps {\n  squircleParams: SquircleParams\n}\n\nfunction SquircleView({\n  squircleParams,\n  children,\n  ...rest\n}: PropsWithChildren<SquircleViewProps>) {\n  return (\n    <View {...rest}>\n      <SquircleBackground {...squircleParams} />\n      {children}\n    </View>\n  )\n}\n\nfunction SquircleBackground({\n  cornerRadius = 0,\n  topLeftCornerRadius,\n  topRightCornerRadius,\n  bottomRightCornerRadius,\n  bottomLeftCornerRadius,\n  cornerSmoothing,\n  fillColor = '#000',\n  strokeColor = '#000',\n  strokeWidth = 0,\n}: SquircleParams) {\n  return (\n    <Rect style={StyleSheet.absoluteFill}>\n      {({ width, height }) => {\n        const hasStroke = strokeWidth > 0\n\n        if (!hasStroke) {\n          const squirclePath = getSvgPath({\n            width,\n            height,\n            cornerSmoothing,\n            cornerRadius,\n            topLeftCornerRadius,\n            topRightCornerRadius,\n            bottomRightCornerRadius,\n            bottomLeftCornerRadius,\n          })\n\n          return (\n            <Svg width=\"100%\" height=\"100%\" viewBox={`0 0 ${width} ${height}`}>\n              <Path d={squirclePath} fill={fillColor} />\n            </Svg>\n          )\n        } else {\n          const cornerRadii = [\n            cornerRadius,\n            topLeftCornerRadius,\n            topRightCornerRadius,\n            bottomLeftCornerRadius,\n            bottomRightCornerRadius,\n          ].filter(\n            (cornerRadius) => cornerRadius && cornerRadius > 0\n          ) as number[]\n\n          const maxStrokeWidth = Math.min(...cornerRadii)\n          strokeWidth = Math.min(strokeWidth, maxStrokeWidth)\n          const insetAmount = strokeWidth / 2\n\n          const insetSquirclePath = getSvgPath({\n            width: width - strokeWidth,\n            height: height - strokeWidth,\n            cornerSmoothing,\n            cornerRadius: getInnerRadius(cornerRadius, insetAmount),\n            topLeftCornerRadius: getInnerRadius(\n              topLeftCornerRadius,\n              insetAmount\n            ),\n            topRightCornerRadius: getInnerRadius(\n              topRightCornerRadius,\n              insetAmount\n            ),\n            bottomRightCornerRadius: getInnerRadius(\n              bottomRightCornerRadius,\n              insetAmount\n            ),\n            bottomLeftCornerRadius: getInnerRadius(\n              bottomLeftCornerRadius,\n              insetAmount\n            ),\n          })\n\n          return (\n            <Svg width=\"100%\" height=\"100%\" viewBox={`0 0 ${width} ${height}`}>\n              <Path\n                d={insetSquirclePath}\n                fill={fillColor}\n                stroke={strokeColor}\n                strokeWidth={strokeWidth}\n                translate={insetAmount}\n              />\n            </Svg>\n          )\n        }\n      }}\n    </Rect>\n  )\n}\n\nfunction getInnerRadius(radius: number | undefined, insetAmount: number) {\n  if (radius) {\n    return Math.max(0, radius - insetAmount)\n  }\n\n  return radius\n}\n\n// Inspired by https://reach.tech/rect/\ninterface RectProps extends ViewProps {\n  children: (rect: { width: number; height: number }) => ReactNode\n}\n\nfunction Rect({ children, ...rest }: RectProps) {\n  const [rect, setRect] =\n    useState<{ width: number; height: number } | null>(null)\n\n  return (\n    <View\n      {...rest}\n      onLayout={(e) => {\n        setRect({\n          width: e.nativeEvent.layout.width,\n          height: e.nativeEvent.layout.height,\n        })\n      }}\n    >\n      {rect ? children(rect) : null}\n    </View>\n  )\n}\n\nexport { SquircleView, getSvgPath }\nexport type { SquircleParams, SquircleViewProps }\n"]}