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,GAAG,IAAI,IAAI,CAAC,CAAC;oBAClB,WAAW;oBACX,aAAa;oBACb,GAAG,0BAA0B;gBAC/B;YACF;QACF;IACF,GAAG;QAAC;QAAW;QAAO;QAAU;QAAU;KAAS;IAEnD,OAAO;AACT","sources":["packages/react-aria/src/color/useColorAreaGradient.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n*/\n\nimport {Color, ColorChannel} from 'react-stately/Color';\n\nimport {ColorAreaState} from 'react-stately/useColorAreaState';\nimport {CSSProperties, useMemo} from 'react';\nimport {parseColor} from 'react-stately/Color';\n\nconst hue = (color: Color) => [0, 60, 120, 180, 240, 300, 360].map(hue => color.withChannelValue('hue', hue).toString('css')).join(', ');\nconst saturation = (color: Color) => `${color.withChannelValue('saturation', 0)}, transparent`;\n\nconst hslChannels = {\n  hue,\n  saturation,\n  lightness: () => 'black, transparent, white'\n};\n\nconst hsbChannels = {\n  hue,\n  saturation,\n  brightness: () => 'black, transparent'\n};\n\ninterface Gradients {\n  colorAreaStyleProps: {\n    style: CSSProperties\n  },\n  thumbStyleProps: {\n    style: CSSProperties\n  }\n}\n\ninterface ColorAreaGradientProps {\n  direction: 'ltr' | 'rtl',\n  state: ColorAreaState,\n  zChannel: ColorChannel,\n  xChannel: ColorChannel,\n  yChannel: ColorChannel\n}\n\nexport function useColorAreaGradient({direction, state, zChannel, xChannel, yChannel}: ColorAreaGradientProps): Gradients {\n  let returnVal = useMemo<Gradients>(() => {\n    let end = direction === 'rtl' ? 'left' : 'right';\n    let colorAreaStyles = {};\n    let zValue = state.value.getChannelValue(zChannel);\n\n    switch (state.value.getColorSpace()) {\n      case 'rgb': {\n        let rgb = parseColor('rgb(0, 0, 0)');\n        colorAreaStyles = {\n          background: [\n            // The screen blend mode multiplies the inverse of each channel, e.g. 1 - (1 - a) * (1 - b).\n            // Create a layer for each channel, with the other channels as 0. After blending, this should\n            // result in the gradients being combined channel by channel.\n            `linear-gradient(to ${end}, ${rgb.withChannelValue(xChannel, 0)}, ${rgb.withChannelValue(xChannel, 255)})`,\n            `linear-gradient(to top, ${rgb.withChannelValue(yChannel, 0)}, ${rgb.withChannelValue(yChannel, 255)})`,\n            rgb.withChannelValue(zChannel, zValue)\n          ].join(','),\n          backgroundBlendMode: 'screen'\n        };\n        break;\n      }\n      case 'hsl': {\n        let channels = state.value.getColorChannels();\n        let value = parseColor('hsl(0, 100%, 50%)').withChannelValue(zChannel, zValue);\n\n        let bg = channels\n          .filter(c => c !== zChannel)\n          .map(c => `linear-gradient(to ${c === xChannel ? end : 'top'}, ${hslChannels[c](value)})`)\n          .reverse();\n        if (zChannel === 'hue') {\n          bg.push(value.toString('css'));\n        }\n\n        colorAreaStyles = {\n          background: bg.join(', ')\n        };\n        break;\n      }\n      case 'hsb': {\n        let channels = state.value.getColorChannels();\n        let value = parseColor('hsb(0, 100%, 100%)').withChannelValue(zChannel, zValue);\n\n        let bg = channels\n          .filter(c => c !== zChannel)\n          .map(c => `linear-gradient(to ${c === xChannel ? end : 'top'}, ${hsbChannels[c](value)})`)\n          .reverse();\n        if (zChannel === 'hue') {\n          bg.push(value.toString('css'));\n        }\n\n        colorAreaStyles = {\n          background: bg.join(', ')\n        };\n        break;\n      }\n    }\n\n    let {x, y} = state.getThumbPosition();\n\n    if (direction === 'rtl') {\n      x = 1 - x;\n    }\n\n    let forcedColorAdjustNoneStyle = {forcedColorAdjust: 'none'};\n\n    return {\n      colorAreaStyleProps: {\n        style: {\n          position: 'relative',\n          touchAction: 'none',\n          ...forcedColorAdjustNoneStyle,\n          ...colorAreaStyles\n        }\n      },\n      thumbStyleProps: {\n        style: {\n          position: 'absolute',\n          left: `${x * 100}%`,\n          top: `${y * 100}%`,\n          transform: 'translate(-50%, -50%)',\n          touchAction: 'none',\n          ...forcedColorAdjustNoneStyle\n        }\n      }\n    };\n  }, [direction, state, zChannel, xChannel, yChannel]);\n\n  return returnVal;\n}\n\n"],"names":[],"version":3,"file":"useColorAreaGradient.cjs.map"}