{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/extends\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/objectWithoutProperties\";\nimport _classCallCheck from \"@babel/runtime/helpers/classCallCheck\";\nimport _createClass from \"@babel/runtime/helpers/createClass\";\nimport _inherits from \"@babel/runtime/helpers/inherits\";\nimport _possibleConstructorReturn from \"@babel/runtime/helpers/possibleConstructorReturn\";\nimport _getPrototypeOf from \"@babel/runtime/helpers/getPrototypeOf\";\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }\n\nimport * as React from 'react';\nimport Platform from \"react-native-web/dist/exports/Platform\";\nimport processColor from \"react-native-web/dist/exports/processColor\";\nimport NativeLinearGradient from \"./NativeLinearGradient\";\nexport var LinearGradient = function (_React$Component) {\n  _inherits(LinearGradient, _React$Component);\n\n  var _super = _createSuper(LinearGradient);\n\n  function LinearGradient() {\n    _classCallCheck(this, LinearGradient);\n\n    return _super.apply(this, arguments);\n  }\n\n  _createClass(LinearGradient, [{\n    key: \"render\",\n    value: function render() {\n      var _this$props = this.props,\n          colors = _this$props.colors,\n          locations = _this$props.locations,\n          start = _this$props.start,\n          end = _this$props.end,\n          props = _objectWithoutProperties(_this$props, [\"colors\", \"locations\", \"start\", \"end\"]);\n\n      var resolvedLocations = locations;\n\n      if (locations && colors.length !== locations.length) {\n        console.warn('LinearGradient colors and locations props should be arrays of the same length');\n        resolvedLocations = locations.slice(0, colors.length);\n      }\n\n      return React.createElement(NativeLinearGradient, _extends({}, props, {\n        colors: Platform.select({\n          web: colors,\n          default: colors.map(processColor)\n        }),\n        locations: resolvedLocations,\n        startPoint: _normalizePoint(start),\n        endPoint: _normalizePoint(end)\n      }));\n    }\n  }]);\n\n  return LinearGradient;\n}(React.Component);\n\nfunction _normalizePoint(point) {\n  if (!point) {\n    return undefined;\n  }\n\n  if (Array.isArray(point) && point.length !== 2) {\n    console.warn('start and end props for LinearGradient must be of the format [x,y] or {x, y}');\n    return undefined;\n  }\n\n  return Array.isArray(point) ? point : [point.x, point.y];\n}","map":{"version":3,"sources":["../src/LinearGradient.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;;;AAGA,OAAO,oBAAP;AA0DA,WAAa,cAAb;AAAA;;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA,6BACQ;AAAA,wBACgD,KAAK,KADrD;AAAA,UACI,MADJ,eACI,MADJ;AAAA,UACY,SADZ,eACY,SADZ;AAAA,UACuB,KADvB,eACuB,KADvB;AAAA,UAC8B,GAD9B,eAC8B,GAD9B;AAAA,UACsC,KADtC;;AAEJ,UAAI,iBAAiB,GAAG,SAAxB;;AACA,UAAI,SAAS,IAAI,MAAM,CAAC,MAAP,KAAkB,SAAS,CAAC,MAA7C,EAAqD;AACnD,QAAA,OAAO,CAAC,IAAR,CAAa,+EAAb;AACA,QAAA,iBAAiB,GAAG,SAAS,CAAC,KAAV,CAAgB,CAAhB,EAAmB,MAAM,CAAC,MAA1B,CAApB;AACD;;AAED,aACE,KAAA,CAAA,aAAA,CAAC,oBAAD,EAAqB,SAAA,EAAA,EACf,KADe,EACV;AACT,QAAA,MAAM,EAAE,QAAQ,CAAC,MAAT,CAAgB;AACtB,UAAA,GAAG,EAAE,MADiB;AAEtB,UAAA,OAAO,EAAE,MAAM,CAAC,GAAP,CAAW,YAAX;AAFa,SAAhB,CADC;AAKT,QAAA,SAAS,EAAE,iBALF;AAMT,QAAA,UAAU,EAAE,eAAe,CAAC,KAAD,CANlB;AAOT,QAAA,QAAQ,EAAE,eAAe,CAAC,GAAD;AAPhB,OADU,CAArB,CADF;AAYD;AArBH;;AAAA;AAAA,EAAoC,KAAK,CAAC,SAA1C;;AAwBA,SAAS,eAAT,CACE,KADF,EAC+C;AAE7C,MAAI,CAAC,KAAL,EAAY;AACV,WAAO,SAAP;AACD;;AAED,MAAI,KAAK,CAAC,OAAN,CAAc,KAAd,KAAwB,KAAK,CAAC,MAAN,KAAiB,CAA7C,EAAgD;AAC9C,IAAA,OAAO,CAAC,IAAR,CAAa,8EAAb;AACA,WAAO,SAAP;AACD;;AAED,SAAO,KAAK,CAAC,OAAN,CAAc,KAAd,IAAuB,KAAvB,GAA+B,CAAC,KAAK,CAAC,CAAP,EAAU,KAAK,CAAC,CAAhB,CAAtC;AACD","sourcesContent":["import * as React from 'react';\nimport { Platform, processColor, View } from 'react-native';\n\nimport NativeLinearGradient from './NativeLinearGradient';\nimport { NativeLinearGradientPoint } from './NativeLinearGradient.types';\n\n// @needsAudit\n/**\n * An object `{ x: number; y: number }` or array `[x, y]` that represents the point\n * at which the gradient starts or ends, as a fraction of the overall size of the gradient ranging\n * from `0` to `1`, inclusive.\n */\nexport type LinearGradientPoint =\n  | {\n      /**\n       * A number ranging from `0` to `1`, representing the position of gradient transformation.\n       */\n      x: number;\n      /**\n       * A number ranging from `0` to `1`, representing the position of gradient transformation.\n       */\n      y: number;\n    }\n  | NativeLinearGradientPoint;\n\n// @needsAudit\nexport type LinearGradientProps = {\n  /**\n   * An array of colors that represent stops in the gradient. At least two colors are required\n   * (for a single-color background, use the `style.backgroundColor` prop on a `View` component).\n   */\n  colors: string[];\n  /**\n   * An array that contains `number`s ranging from `0` to `1`, inclusive, and is the same length as the `colors` property.\n   * Each number indicates a color-stop location where each respective color should be located.\n   *\n   * For example, `[0.5, 0.8]` would render:\n   * - the first color, solid, from the beginning of the gradient view to 50% through (the middle);\n   * - a gradient from the first color to the second from the 50% point to the 80% point; and\n   * - the second color, solid, from the 80% point to the end of the gradient view.\n   *\n   * > The color-stop locations must be ascending from least to greatest.\n   */\n  locations?: number[] | null;\n  /**\n   * For example, `{ x: 0.1, y: 0.2 }` means that the gradient will start `10%` from the left and `20%` from the top.\n   *\n   * **On web**, this only changes the angle of the gradient because CSS gradients don't support changing the starting position.\n   */\n  start?: LinearGradientPoint | null;\n  /**\n   * For example, `{ x: 0.1, y: 0.2 }` means that the gradient will end `10%` from the left and `20%` from the bottom.\n   *\n   * **On web**, this only changes the angle of the gradient because CSS gradients don't support changing the end position.\n   */\n  end?: LinearGradientPoint | null;\n} & React.ComponentProps<typeof View>;\n\n/**\n * Renders a native view that transitions between multiple colors in a linear direction.\n */\nexport class LinearGradient extends React.Component<LinearGradientProps> {\n  render() {\n    const { colors, locations, start, end, ...props } = this.props;\n    let resolvedLocations = locations;\n    if (locations && colors.length !== locations.length) {\n      console.warn('LinearGradient colors and locations props should be arrays of the same length');\n      resolvedLocations = locations.slice(0, colors.length);\n    }\n\n    return (\n      <NativeLinearGradient\n        {...props}\n        colors={Platform.select({\n          web: colors as any,\n          default: colors.map(processColor),\n        })}\n        locations={resolvedLocations}\n        startPoint={_normalizePoint(start)}\n        endPoint={_normalizePoint(end)}\n      />\n    );\n  }\n}\n\nfunction _normalizePoint(\n  point: LinearGradientPoint | null | undefined\n): NativeLinearGradientPoint | undefined {\n  if (!point) {\n    return undefined;\n  }\n\n  if (Array.isArray(point) && point.length !== 2) {\n    console.warn('start and end props for LinearGradient must be of the format [x,y] or {x, y}');\n    return undefined;\n  }\n\n  return Array.isArray(point) ? point : [point.x, point.y];\n}\n"],"sourceRoot":""},"metadata":{},"sourceType":"module"}