@razorpay/blade 12.93.0 → 12.95.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/build/lib/native/components/Spark/RzpGlass/RzpGlass.js +2 -2
  2. package/build/lib/native/components/Spark/RzpGlass/RzpGlass.js.map +1 -1
  3. package/build/lib/native/components/Spark/RzpGlass/RzpGlassMount.js +1 -1
  4. package/build/lib/native/components/Spark/RzpGlass/RzpGlassMount.js.map +1 -1
  5. package/build/lib/native/components/Spark/RzpGlass/presets.js +2 -2
  6. package/build/lib/native/components/Spark/RzpGlass/presets.js.map +1 -1
  7. package/build/lib/native/components/Spark/RzpGlass/utils.js +5 -2
  8. package/build/lib/native/components/Spark/RzpGlass/utils.js.map +1 -1
  9. package/build/lib/native/components/index.js +1 -0
  10. package/build/lib/native/components/index.js.map +1 -1
  11. package/build/lib/web/development/_virtual/cloneDeep.js +1 -1
  12. package/build/lib/web/development/_virtual/cloneDeep3.js +1 -1
  13. package/build/lib/web/development/_virtual/flatten.js +1 -1
  14. package/build/lib/web/development/_virtual/flatten3.js +1 -1
  15. package/build/lib/web/development/components/Spark/RzpGlass/RzpGlass.js +50 -30
  16. package/build/lib/web/development/components/Spark/RzpGlass/RzpGlass.js.map +1 -1
  17. package/build/lib/web/development/components/Spark/RzpGlass/RzpGlassMount.js +8 -5
  18. package/build/lib/web/development/components/Spark/RzpGlass/RzpGlassMount.js.map +1 -1
  19. package/build/lib/web/development/components/Spark/RzpGlass/index.js +4 -0
  20. package/build/lib/web/development/components/Spark/RzpGlass/index.js.map +1 -1
  21. package/build/lib/web/development/components/Spark/RzpGlass/presets.js +85 -79
  22. package/build/lib/web/development/components/Spark/RzpGlass/presets.js.map +1 -1
  23. package/build/lib/web/development/components/Spark/RzpGlass/utils.js +82 -4
  24. package/build/lib/web/development/components/Spark/RzpGlass/utils.js.map +1 -1
  25. package/build/lib/web/development/components/index.js +1 -0
  26. package/build/lib/web/development/components/index.js.map +1 -1
  27. package/build/lib/web/development/node_modules/es-toolkit/dist/array/flatten.js +1 -1
  28. package/build/lib/web/development/node_modules/es-toolkit/dist/compat/array/flatten.js +1 -1
  29. package/build/lib/web/development/node_modules/es-toolkit/dist/compat/array/sortBy.js +2 -2
  30. package/build/lib/web/development/node_modules/es-toolkit/dist/compat/object/cloneDeep.js +1 -1
  31. package/build/lib/web/development/node_modules/es-toolkit/dist/compat/object/omit.js +2 -2
  32. package/build/lib/web/development/node_modules/es-toolkit/dist/compat/predicate/matches.js +2 -2
  33. package/build/lib/web/development/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.js +2 -2
  34. package/build/lib/web/development/node_modules/es-toolkit/dist/object/cloneDeep.js +1 -1
  35. package/build/lib/web/production/_virtual/cloneDeep.js +1 -1
  36. package/build/lib/web/production/_virtual/cloneDeep3.js +1 -1
  37. package/build/lib/web/production/components/Spark/RzpGlass/RzpGlass.js +50 -30
  38. package/build/lib/web/production/components/Spark/RzpGlass/RzpGlass.js.map +1 -1
  39. package/build/lib/web/production/components/Spark/RzpGlass/RzpGlassMount.js +8 -5
  40. package/build/lib/web/production/components/Spark/RzpGlass/RzpGlassMount.js.map +1 -1
  41. package/build/lib/web/production/components/Spark/RzpGlass/index.js +4 -0
  42. package/build/lib/web/production/components/Spark/RzpGlass/index.js.map +1 -1
  43. package/build/lib/web/production/components/Spark/RzpGlass/presets.js +85 -79
  44. package/build/lib/web/production/components/Spark/RzpGlass/presets.js.map +1 -1
  45. package/build/lib/web/production/components/Spark/RzpGlass/utils.js +82 -4
  46. package/build/lib/web/production/components/Spark/RzpGlass/utils.js.map +1 -1
  47. package/build/lib/web/production/components/index.js +1 -0
  48. package/build/lib/web/production/components/index.js.map +1 -1
  49. package/build/lib/web/production/node_modules/es-toolkit/dist/compat/object/cloneDeep.js +1 -1
  50. package/build/lib/web/production/node_modules/es-toolkit/dist/compat/predicate/matches.js +2 -2
  51. package/build/lib/web/production/node_modules/es-toolkit/dist/compat/predicate/matchesProperty.js +2 -2
  52. package/build/lib/web/production/node_modules/es-toolkit/dist/object/cloneDeep.js +1 -1
  53. package/build/types/components/index.d.ts +27 -3
  54. package/build/types/components/index.native.d.ts +27 -3
  55. package/package.json +1 -1
@@ -4,10 +4,10 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
4
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
5
  import { forwardRef, useState, useRef, useEffect, useCallback } from 'react';
6
6
  import { RzpGlassMount } from './RzpGlassMount.js';
7
- import { PRESETS } from './presets.js';
7
+ import { getPresets } from './presets.js';
8
8
  import { jsx } from 'react/jsx-runtime';
9
9
 
10
- var _excluded=["width","height","className","style","onLoad","onError","preset","cdnPath","gradientMapSrc","gradientMap2Src","gradientMapCanvas","imageSrc"],_excluded2=["width","height","className","style","onLoad","onError","cdnPath","gradientMapCanvas","gradientMapSrc","gradientMap2Src","imageSrc"];var DEFAULT_CDN_PATH='https://cdn.jsdelivr.net/gh/razorpay/blade@feat/expose-assets-folder/packages/blade/assets/spark';var getDefaultAssets=function getDefaultAssets(cdnPath){return {videoSrc:`${cdnPath}/spark-base-video.mp4`,imageSrc:`${cdnPath}/bottom-frame.jpg`,gradientMapSrc:`${cdnPath}/colorama-gradient-map-green.jpg`,gradientMap2Src:`${cdnPath}/colorama-gradient-map-blue.jpg`,centerGradientMapSrc:`${cdnPath}/colorama-center-gradient-map.jpg`};};function useMergeRefs(refs){return useCallback(function(value){refs.forEach(function(ref){if(typeof ref==='function'){ref(value);}else if(ref!=null){ref.current=value;}});},[refs]);}function extractConfig(props){props.width;props.height;props.className;props.style;props.onLoad;props.onError;props.preset;props.cdnPath;props.gradientMapSrc;props.gradientMap2Src;props.gradientMapCanvas;props.imageSrc;var config=_objectWithoutProperties(props,_excluded);return Object.fromEntries(Object.entries(config).filter(function(_ref){var _ref2=_slicedToArray(_ref,2),v=_ref2[1];return v!==undefined;}));}var ASSET_KEYS=new Set(['videoSrc','imageSrc','gradientMapSrc','gradientMap2Src','centerGradientMapSrc']);function getPresetDefinition(preset){if(preset&&preset in PRESETS)return Object.assign({},PRESETS[preset]);return {};}function getPresetConfig(preset){var def=getPresetDefinition(preset);return Object.fromEntries(Object.entries(def).filter(function(_ref3){var _ref4=_slicedToArray(_ref3,1),k=_ref4[0];return !ASSET_KEYS.has(k);}));}function getPresetAssets(preset){var def=getPresetDefinition(preset);return Object.fromEntries(Object.entries(def).filter(function(_ref5){var _ref6=_slicedToArray(_ref5,1),k=_ref6[0];return ASSET_KEYS.has(k);}));}function resolveConfig(props){return Object.assign({},getPresetConfig(props.preset),extractConfig(props));}var RzpGlass=forwardRef(function RzpGlass(props,forwardedRef){var _presetAssets$videoSr,_ref7,_ref8,_presetAssets$centerG,_configProps$edgeFeat;var _props$width=props.width,width=_props$width===void 0?'100%':_props$width,_props$height=props.height,height=_props$height===void 0?'100%':_props$height,className=props.className,style=props.style,onLoad=props.onLoad,onError=props.onError,cdnPathProp=props.cdnPath,gradientMapCanvas=props.gradientMapCanvas,gradientMapSrcProp=props.gradientMapSrc,gradientMap2SrcProp=props.gradientMap2Src,imageSrcProp=props.imageSrc,configProps=_objectWithoutProperties(props,_excluded2);var cdnPath=cdnPathProp!=null?cdnPathProp:DEFAULT_CDN_PATH;var defaultAssets=getDefaultAssets(cdnPath);var presetAssets=getPresetAssets(props.preset);var imageSrc=imageSrcProp!=null?imageSrcProp:presetAssets.imageSrc;var videoSrc=imageSrc?undefined:(_presetAssets$videoSr=presetAssets.videoSrc)!=null?_presetAssets$videoSr:defaultAssets.videoSrc;var gradientMapSrc=(_ref7=gradientMapSrcProp!=null?gradientMapSrcProp:presetAssets.gradientMapSrc)!=null?_ref7:defaultAssets.gradientMapSrc;var gradientMap2Src=(_ref8=gradientMap2SrcProp!=null?gradientMap2SrcProp:presetAssets.gradientMap2Src)!=null?_ref8:defaultAssets.gradientMap2Src;var centerGradientMapSrc=(_presetAssets$centerG=presetAssets.centerGradientMapSrc)!=null?_presetAssets$centerG:defaultAssets.centerGradientMapSrc;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),isInitialized=_useState2[0],setIsInitialized=_useState2[1];var _useState3=useState(null),_useState4=_slicedToArray(_useState3,2),error=_useState4[0],setError=_useState4[1];var divRef=useRef(null);var mountRef=useRef(null);useEffect(function(){var init=function(){var _ref9=_asyncToGenerator(function*(){if(!divRef.current||mountRef.current)return;try{var config=resolveConfig(props);mountRef.current=new RzpGlassMount(divRef.current,{videoSrc:videoSrc,imageSrc:imageSrc,gradientMapSrc:gradientMapSrc,gradientMap2Src:gradientMap2Src,centerGradientMapSrc:centerGradientMapSrc},config);yield mountRef.current.loadAssets();setIsInitialized(true);onLoad==null?void 0:onLoad();}catch(err){var _error=err instanceof Error?err:new Error(String(err));setError(_error);onError==null?void 0:onError(_error);}});return function init(){return _ref9.apply(this,arguments);};}();void init();return function(){var _mountRef$current;(_mountRef$current=mountRef.current)==null?void 0:_mountRef$current.dispose();mountRef.current=null;setIsInitialized(false);};},[cdnPath,videoSrc,imageSrc,gradientMapSrc,gradientMap2Src,centerGradientMapSrc,configProps.preset]);useEffect(function(){if(isInitialized&&mountRef.current){var config=resolveConfig(props);mountRef.current.setUniforms(config);}},[isInitialized,configProps.preset,configProps.inputMin,configProps.inputMax,configProps.modifyGamma,configProps.posterizeLevels,configProps.cycleRepetitions,configProps.phaseShift,configProps.cycleSpeed,configProps.wrapMode,configProps.reverse,configProps.blendWithOriginal,configProps.numSegments,configProps.slitAngle,configProps.displacementX,configProps.displacementY,configProps.enableCenterElement,configProps.centerAnimDuration,configProps.ccBlackPoint,configProps.ccWhitePoint,configProps.ccMidtoneGamma,configProps.ccGamma,configProps.ccContrast,configProps.zoom,configProps.panX,configProps.panY].concat(_toConsumableArray((_configProps$edgeFeat=configProps.edgeFeather)!=null?_configProps$edgeFeat:[0,0,0,0]),[configProps.enableDisplacement,configProps.enableColorama,configProps.enableBloom,configProps.enableLightSweep,configProps.lightIntensity,configProps.lightStartFrame,configProps.paused,configProps.startTime,configProps.endTime,configProps.animateLightIndependently,configProps.animateCycleReps,configProps.cycleRepetitionsStart,configProps.cycleRepetitionsEnd,configProps.cycleRepetitionsStartFrame,configProps.cycleRepetitionsDuration,configProps.gradientMapBlend,configProps.gradientMapBlendDuration]));useEffect(function(){if(isInitialized&&mountRef.current&&gradientMapCanvas){mountRef.current.updateGradientMapTexture(gradientMapCanvas);}},[isInitialized,gradientMapCanvas]);var mergedRef=useMergeRefs([divRef,forwardedRef]);var widthStyle=typeof width==='number'?`${width}px`:width;var heightStyle=typeof height==='number'?`${height}px`:height;if(error){return jsx("div",{ref:mergedRef,className:className,style:Object.assign({width:widthStyle,height:heightStyle},style)});}return jsx("div",{ref:mergedRef,className:className,style:Object.assign({width:widthStyle,height:heightStyle,position:'relative',overflow:'hidden',backgroundColor:'transparent',transition:'2s opacity'},isInitialized?{opacity:1}:{opacity:0},style)});});
10
+ var _excluded=["width","height","className","style","onLoad","onError","preset","assetsPath","gradientMapSrc","gradientMap2Src","gradientMapCanvas","imageSrc"],_excluded2=["width","height","className","style","onLoad","onError","assetsPath","gradientMapCanvas","gradientMapSrc","gradientMap2Src","imageSrc"];var FADE_IN_MS=200;var DEFAULT_CDN_PATH='https://cdn.jsdelivr.net/npm/@razorpay/blade/assets/spark';var getDefaultAssets=function getDefaultAssets(assetsPath){return {videoSrc:`${assetsPath}/spark-base-video.mp4`,imageSrc:`${assetsPath}/bottom-frame.jpg`,gradientMapSrc:`${assetsPath}/colorama-gradient-map-green.jpg`,gradientMap2Src:`${assetsPath}/colorama-gradient-map-blue.jpg`,centerGradientMapSrc:`${assetsPath}/colorama-center-gradient-map.jpg`};};function useMergeRefs(refs){return useCallback(function(value){refs.forEach(function(ref){if(typeof ref==='function'){ref(value);}else if(ref!=null){ref.current=value;}});},[refs]);}function extractConfig(props){props.width;props.height;props.className;props.style;props.onLoad;props.onError;props.preset;props.assetsPath;props.gradientMapSrc;props.gradientMap2Src;props.gradientMapCanvas;props.imageSrc;var config=_objectWithoutProperties(props,_excluded);return Object.fromEntries(Object.entries(config).filter(function(_ref){var _ref2=_slicedToArray(_ref,2),v=_ref2[1];return v!==undefined;}));}var ASSET_KEYS=new Set(['videoSrc','imageSrc','gradientMapSrc','gradientMap2Src','centerGradientMapSrc']);function getPresetDefinition(preset,assetsPath){var presets=getPresets(assetsPath);if(preset&&preset in presets)return Object.assign({},presets[preset]);return {};}function getPresetConfig(preset,assetsPath){var def=getPresetDefinition(preset,assetsPath);return Object.fromEntries(Object.entries(def).filter(function(_ref3){var _ref4=_slicedToArray(_ref3,1),k=_ref4[0];return !ASSET_KEYS.has(k);}));}function getPresetAssets(preset,assetsPath){var def=getPresetDefinition(preset,assetsPath);return Object.fromEntries(Object.entries(def).filter(function(_ref5){var _ref6=_slicedToArray(_ref5,1),k=_ref6[0];return ASSET_KEYS.has(k);}));}function resolveConfig(props,assetsPath){return Object.assign({},getPresetConfig(props.preset,assetsPath),extractConfig(props));}var RzpGlass=forwardRef(function RzpGlass(props,forwardedRef){var _presetAssets$videoSr,_ref7,_ref8,_presetAssets$centerG,_configProps$edgeFeat;var _props$width=props.width,width=_props$width===void 0?'100%':_props$width,_props$height=props.height,height=_props$height===void 0?'100%':_props$height,className=props.className,style=props.style,onLoad=props.onLoad,onError=props.onError,assetsPathProp=props.assetsPath,gradientMapCanvas=props.gradientMapCanvas,gradientMapSrcProp=props.gradientMapSrc,gradientMap2SrcProp=props.gradientMap2Src,imageSrcProp=props.imageSrc,configProps=_objectWithoutProperties(props,_excluded2);var assetsPath=assetsPathProp!=null?assetsPathProp:DEFAULT_CDN_PATH;var defaultAssets=getDefaultAssets(assetsPath);var presetAssets=getPresetAssets(props.preset,assetsPath);var imageSrc=imageSrcProp!=null?imageSrcProp:presetAssets.imageSrc;var videoSrc=imageSrc?undefined:(_presetAssets$videoSr=presetAssets.videoSrc)!=null?_presetAssets$videoSr:defaultAssets.videoSrc;var gradientMapSrc=(_ref7=gradientMapSrcProp!=null?gradientMapSrcProp:presetAssets.gradientMapSrc)!=null?_ref7:defaultAssets.gradientMapSrc;var gradientMap2Src=(_ref8=gradientMap2SrcProp!=null?gradientMap2SrcProp:presetAssets.gradientMap2Src)!=null?_ref8:defaultAssets.gradientMap2Src;var centerGradientMapSrc=(_presetAssets$centerG=presetAssets.centerGradientMapSrc)!=null?_presetAssets$centerG:defaultAssets.centerGradientMapSrc;var _useState=useState(false),_useState2=_slicedToArray(_useState,2),isInitialized=_useState2[0],setIsInitialized=_useState2[1];var _useState3=useState(null),_useState4=_slicedToArray(_useState3,2),error=_useState4[0],setError=_useState4[1];var divRef=useRef(null);var mountRef=useRef(null);useEffect(function(){var init=function(){var _ref9=_asyncToGenerator(function*(){if(!divRef.current||mountRef.current)return;try{var _config$paused;var config=resolveConfig(props,assetsPath);mountRef.current=new RzpGlassMount(divRef.current,{videoSrc:videoSrc,imageSrc:imageSrc,gradientMapSrc:gradientMapSrc,gradientMap2Src:gradientMap2Src,centerGradientMapSrc:centerGradientMapSrc},config);yield mountRef.current.loadAssets();var userWantsPaused=(_config$paused=config.paused)!=null?_config$paused:false;if(!userWantsPaused){mountRef.current.pause();}setIsInitialized(true);setTimeout(function(){if(!mountRef.current)return;if(!userWantsPaused){mountRef.current.play();}onLoad==null?void 0:onLoad();},FADE_IN_MS);}catch(err){var _error=err instanceof Error?err:new Error(String(err));setError(_error);onError==null?void 0:onError(_error);}});return function init(){return _ref9.apply(this,arguments);};}();void init();return function(){var _mountRef$current;(_mountRef$current=mountRef.current)==null?void 0:_mountRef$current.dispose();mountRef.current=null;setIsInitialized(false);};},[assetsPath,videoSrc,imageSrc,gradientMapSrc,gradientMap2Src,centerGradientMapSrc,configProps.preset]);useEffect(function(){if(isInitialized&&mountRef.current){var config=resolveConfig(props,assetsPath);mountRef.current.setUniforms(config);}},[isInitialized,configProps.preset,configProps.inputMin,configProps.inputMax,configProps.modifyGamma,configProps.posterizeLevels,configProps.cycleRepetitions,configProps.phaseShift,configProps.cycleSpeed,configProps.wrapMode,configProps.reverse,configProps.blendWithOriginal,configProps.numSegments,configProps.slitAngle,configProps.displacementX,configProps.displacementY,configProps.enableCenterElement,configProps.centerAnimDuration,configProps.ccBlackPoint,configProps.ccWhitePoint,configProps.ccMidtoneGamma,configProps.ccGamma,configProps.ccContrast,configProps.zoom,configProps.panX,configProps.panY].concat(_toConsumableArray((_configProps$edgeFeat=configProps.edgeFeather)!=null?_configProps$edgeFeat:[0,0,0,0]),[configProps.enableDisplacement,configProps.enableColorama,configProps.enableBloom,configProps.enableLightSweep,configProps.lightIntensity,configProps.lightStartFrame,configProps.paused,configProps.startTime,configProps.endTime,configProps.animateLightIndependently,configProps.animateCycleReps,configProps.cycleRepetitionsStart,configProps.cycleRepetitionsEnd,configProps.cycleRepetitionsStartFrame,configProps.cycleRepetitionsDuration,configProps.gradientMapBlend,configProps.gradientMapBlendDuration]));useEffect(function(){if(isInitialized&&mountRef.current&&gradientMapCanvas){mountRef.current.updateGradientMapTexture(gradientMapCanvas);}},[isInitialized,gradientMapCanvas]);var mergedRef=useMergeRefs([divRef,forwardedRef]);var widthStyle=typeof width==='number'?`${width}px`:width;var heightStyle=typeof height==='number'?`${height}px`:height;if(error){return jsx("div",{ref:mergedRef,className:className,style:Object.assign({width:widthStyle,height:heightStyle},style)});}return jsx("div",{ref:mergedRef,className:className,style:Object.assign({width:widthStyle,height:heightStyle,position:'relative',overflow:'hidden',backgroundColor:'transparent',transition:'2s opacity'},isInitialized?{opacity:1}:{opacity:0},style)});});
11
11
 
12
12
  export { RzpGlass, RzpGlass as default };
13
13
  //# sourceMappingURL=RzpGlass.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RzpGlass.js","sources":["../../../../../../src/components/Spark/RzpGlass/RzpGlass.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\n/* eslint-disable @typescript-eslint/no-unsafe-argument */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable react/react-in-jsx-scope */\n/* eslint-disable react-hooks/exhaustive-deps */\n/* eslint-disable @typescript-eslint/no-implicit-any-catch */\n/* eslint-disable @typescript-eslint/no-shadow */\n/**\n * RzpGlass React Component\n *\n * A React wrapper for the RzpGlassMount WebGL shader effect.\n * Manages the component lifecycle with useEffect hooks.\n *\n * @example\n * ```tsx\n * // Uses default assets and config\n * <RzpGlass width=\"400px\" height=\"300px\" />\n *\n * // With custom assets\n * <RzpGlass\n * videoSrc=\"/custom_video.mp4\"\n * gradientMapSrc=\"/custom-gradient.jpg\"\n * enableBloom={true}\n * />\n * ```\n */\n\nimport { forwardRef, useEffect, useRef, useState, useCallback } from 'react';\nimport { RzpGlassMount } from './RzpGlassMount';\nimport type {\n RzpGlassProps,\n RzpGlassConfig,\n RzpGlassAssets,\n RzpGlassPresetDefinition,\n} from './types';\nimport { PRESETS } from './presets';\nimport type { RzpGlassPreset } from './presets';\n\nconst DEFAULT_CDN_PATH =\n 'https://cdn.jsdelivr.net/gh/razorpay/blade@feat/expose-assets-folder/packages/blade/assets/spark';\n\nconst getDefaultAssets = (cdnPath: string): Required<RzpGlassAssets> => ({\n videoSrc: `${cdnPath}/spark-base-video.mp4`,\n imageSrc: `${cdnPath}/bottom-frame.jpg`,\n gradientMapSrc: `${cdnPath}/colorama-gradient-map-green.jpg`,\n gradientMap2Src: `${cdnPath}/colorama-gradient-map-blue.jpg`,\n centerGradientMapSrc: `${cdnPath}/colorama-center-gradient-map.jpg`,\n});\n\n/**\n * Hook to merge multiple refs into one\n */\nfunction useMergeRefs<T>(refs: (React.Ref<T> | undefined)[]): React.RefCallback<T> {\n return useCallback(\n (value: T) => {\n refs.forEach((ref) => {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref != null) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n });\n },\n [refs],\n );\n}\n\n/**\n * Extract config from props (exclude non-config props).\n * Strips undefined values so they don't clobber preset defaults.\n */\nfunction extractConfig(props: RzpGlassProps): Partial<RzpGlassConfig> {\n const {\n width: _width,\n height: _height,\n className: _className,\n style: _style,\n onLoad: _onLoad,\n onError: _onError,\n preset: _preset,\n cdnPath: _cdnPath,\n gradientMapSrc: _gradientMapSrc,\n gradientMap2Src: _gradientMap2Src,\n gradientMapCanvas: _gradientMapCanvas,\n imageSrc: _imageSrc,\n ...config\n } = props;\n\n // Drop keys with undefined values so preset config isn't overridden by unset props\n return Object.fromEntries(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n Object.entries(config).filter(([, v]) => v !== undefined),\n ) as Partial<RzpGlassConfig>;\n}\n\nconst ASSET_KEYS = new Set<string>([\n 'videoSrc',\n 'imageSrc',\n 'gradientMapSrc',\n 'gradientMap2Src',\n 'centerGradientMapSrc',\n]);\n\n/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return */\nfunction getPresetDefinition(preset: RzpGlassPreset | undefined): RzpGlassPresetDefinition {\n if (preset && preset in PRESETS) return { ...PRESETS[preset] };\n return {};\n}\n\nfunction getPresetConfig(preset: RzpGlassPreset | undefined): Partial<RzpGlassConfig> {\n const def = getPresetDefinition(preset) as Record<string, unknown>;\n return Object.fromEntries(\n Object.entries(def).filter(([k]) => !ASSET_KEYS.has(k)),\n ) as Partial<RzpGlassConfig>;\n}\n\nfunction getPresetAssets(preset: RzpGlassPreset | undefined): Partial<RzpGlassAssets> {\n const def = getPresetDefinition(preset) as Record<string, unknown>;\n return Object.fromEntries(\n Object.entries(def).filter(([k]) => ASSET_KEYS.has(k)),\n ) as Partial<RzpGlassAssets>;\n}\n\n/**\n * Merge preset config with user-provided config.\n * Preset values are used as base; any explicit prop overrides them.\n */\nfunction resolveConfig(props: RzpGlassProps): Partial<RzpGlassConfig> {\n return {\n ...getPresetConfig(props.preset),\n ...extractConfig(props),\n };\n}\n\nexport const RzpGlass = forwardRef<HTMLDivElement, RzpGlassProps>(function RzpGlass(\n props,\n forwardedRef,\n) {\n const {\n width = '100%',\n height = '100%',\n className,\n style,\n onLoad,\n onError,\n cdnPath: cdnPathProp,\n gradientMapCanvas,\n gradientMapSrc: gradientMapSrcProp,\n gradientMap2Src: gradientMap2SrcProp,\n imageSrc: imageSrcProp,\n ...configProps\n } = props;\n\n // Get default assets based on cdnPath\n const cdnPath: string = cdnPathProp ?? DEFAULT_CDN_PATH;\n const defaultAssets = getDefaultAssets(cdnPath);\n\n // Resolve assets: prop overrides preset, preset overrides default\n const presetAssets = getPresetAssets(props.preset);\n const imageSrc = imageSrcProp ?? presetAssets.imageSrc;\n const videoSrc = imageSrc ? undefined : presetAssets.videoSrc ?? defaultAssets.videoSrc;\n const gradientMapSrc =\n gradientMapSrcProp ?? presetAssets.gradientMapSrc ?? defaultAssets.gradientMapSrc;\n const gradientMap2Src =\n gradientMap2SrcProp ?? presetAssets.gradientMap2Src ?? defaultAssets.gradientMap2Src;\n const centerGradientMapSrc =\n presetAssets.centerGradientMapSrc ?? defaultAssets.centerGradientMapSrc;\n\n const [isInitialized, setIsInitialized] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const divRef = useRef<HTMLDivElement>(null);\n const mountRef = useRef<RzpGlassMount | null>(null);\n\n // Initialize on mount\n useEffect(() => {\n const init = async () => {\n if (!divRef.current || mountRef.current) return;\n\n try {\n const config = resolveConfig(props);\n\n mountRef.current = new RzpGlassMount(\n divRef.current,\n {\n videoSrc,\n imageSrc,\n gradientMapSrc,\n gradientMap2Src,\n centerGradientMapSrc,\n },\n config,\n );\n\n await mountRef.current.loadAssets();\n setIsInitialized(true);\n onLoad?.();\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n setError(error);\n onError?.(error);\n }\n };\n\n void init();\n\n return () => {\n mountRef.current?.dispose();\n mountRef.current = null;\n setIsInitialized(false);\n };\n }, [\n cdnPath,\n videoSrc,\n imageSrc,\n gradientMapSrc,\n gradientMap2Src,\n centerGradientMapSrc,\n configProps.preset,\n ]);\n\n // Update uniforms when config props change\n useEffect(() => {\n if (isInitialized && mountRef.current) {\n const config = resolveConfig(props);\n mountRef.current.setUniforms(config);\n }\n }, [\n isInitialized,\n configProps.preset,\n // Colorama\n configProps.inputMin,\n configProps.inputMax,\n configProps.modifyGamma,\n configProps.posterizeLevels,\n configProps.cycleRepetitions,\n configProps.phaseShift,\n configProps.cycleSpeed,\n configProps.wrapMode,\n configProps.reverse,\n configProps.blendWithOriginal,\n // Displacement\n configProps.numSegments,\n configProps.slitAngle,\n configProps.displacementX,\n configProps.displacementY,\n // Center element\n configProps.enableCenterElement,\n configProps.centerAnimDuration,\n // Color correction\n configProps.ccBlackPoint,\n configProps.ccWhitePoint,\n configProps.ccMidtoneGamma,\n configProps.ccGamma,\n configProps.ccContrast,\n // Zoom & Pan\n configProps.zoom,\n configProps.panX,\n configProps.panY,\n // eslint-disable-next-line react-hooks/exhaustive-deps\n ...(configProps.edgeFeather ?? [0, 0, 0, 0]),\n // Effect toggles\n configProps.enableDisplacement,\n configProps.enableColorama,\n configProps.enableBloom,\n configProps.enableLightSweep,\n // Light\n configProps.lightIntensity,\n configProps.lightStartFrame,\n // Playback\n configProps.paused,\n configProps.startTime,\n configProps.endTime,\n configProps.animateLightIndependently,\n // Cycle animation\n configProps.animateCycleReps,\n configProps.cycleRepetitionsStart,\n configProps.cycleRepetitionsEnd,\n configProps.cycleRepetitionsStartFrame,\n configProps.cycleRepetitionsDuration,\n // Gradient map blend\n configProps.gradientMapBlend,\n configProps.gradientMapBlendDuration,\n ]);\n\n // Update gradient map texture when a canvas is provided\n useEffect(() => {\n if (isInitialized && mountRef.current && gradientMapCanvas) {\n mountRef.current.updateGradientMapTexture(gradientMapCanvas);\n }\n }, [isInitialized, gradientMapCanvas]);\n\n const mergedRef = useMergeRefs([divRef, forwardedRef]);\n\n // Convert width/height to string if number\n const widthStyle = typeof width === 'number' ? `${width}px` : width;\n const heightStyle = typeof height === 'number' ? `${height}px` : height;\n\n if (error) {\n return (\n <div\n ref={mergedRef}\n className={className}\n style={{\n width: widthStyle,\n height: heightStyle,\n ...style,\n }}\n />\n );\n }\n\n return (\n <div\n ref={mergedRef}\n className={className}\n style={{\n width: widthStyle,\n height: heightStyle,\n position: 'relative',\n overflow: 'hidden',\n backgroundColor: 'transparent',\n transition: '2s opacity',\n ...(isInitialized ? { opacity: 1 } : { opacity: 0 }),\n ...style,\n }}\n />\n );\n});\n\nexport default RzpGlass;\n"],"names":["DEFAULT_CDN_PATH","getDefaultAssets","cdnPath","videoSrc","imageSrc","gradientMapSrc","gradientMap2Src","centerGradientMapSrc","useMergeRefs","refs","useCallback","value","forEach","ref","current","extractConfig","props","width","height","className","style","onLoad","onError","preset","gradientMapCanvas","config","_objectWithoutProperties","_excluded","Object","fromEntries","entries","filter","_ref","_ref2","_slicedToArray","v","undefined","ASSET_KEYS","Set","getPresetDefinition","PRESETS","assign","getPresetConfig","def","_ref3","_ref4","k","has","getPresetAssets","_ref5","_ref6","resolveConfig","RzpGlass","forwardRef","forwardedRef","_presetAssets$videoSr","_ref7","_ref8","_presetAssets$centerG","_configProps$edgeFeat","_props$width","_props$height","cdnPathProp","gradientMapSrcProp","gradientMap2SrcProp","imageSrcProp","configProps","_excluded2","defaultAssets","presetAssets","_useState","useState","_useState2","isInitialized","setIsInitialized","_useState3","_useState4","error","setError","divRef","useRef","mountRef","useEffect","init","_ref9","_asyncToGenerator","RzpGlassMount","loadAssets","err","Error","String","apply","arguments","_mountRef$current","dispose","setUniforms","inputMin","inputMax","modifyGamma","posterizeLevels","cycleRepetitions","phaseShift","cycleSpeed","wrapMode","reverse","blendWithOriginal","numSegments","slitAngle","displacementX","displacementY","enableCenterElement","centerAnimDuration","ccBlackPoint","ccWhitePoint","ccMidtoneGamma","ccGamma","ccContrast","zoom","panX","panY","concat","_toConsumableArray","edgeFeather","enableDisplacement","enableColorama","enableBloom","enableLightSweep","lightIntensity","lightStartFrame","paused","startTime","endTime","animateLightIndependently","animateCycleReps","cycleRepetitionsStart","cycleRepetitionsEnd","cycleRepetitionsStartFrame","cycleRepetitionsDuration","gradientMapBlend","gradientMapBlendDuration","updateGradientMapTexture","mergedRef","widthSt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,CAGtD,IAAMwF,UAAU,CAAG,OAAO7H,KAAK,GAAK,QAAQ,CAAG,GAAGA,KAAK,CAAA,EAAA,CAAI,CAAGA,KAAK,CACnE,IAAM8H,WAAW,CAAG,OAAO7H,MAAM,GAAK,QAAQ,CAAG,GAAGA,MAAM,CAAA,EAAA,CAAI,CAAGA,MAAM,CAEvE,GAAI2D,KAAK,CAAE,CACT,OACEmE,GAAA,CAAA,KAAA,CAAA,CACEnI,GAAG,CAAEgI,SAAU,CACf1H,SAAS,CAAEA,SAAU,CACrBC,KAAK,CAAAQ,MAAA,CAAAa,MAAA,EACHxB,KAAK,CAAE6H,UAAU,CACjB5H,MAAM,CAAE6H,WAAW,CAChB3H,CAAAA,KAAK,CACR,CACH,CAAC,CAEN,CAEA,OACE4H,GAAA,CAAA,KAAA,CAAA,CACEnI,GAAG,CAAEgI,SAAU,CACf1H,SAAS,CAAEA,SAAU,CACrBC,KAAK,CAAAQ,MAAA,CAAAa,MAAA,CACHxB,CAAAA,KAAK,CAAE6H,UAAU,CACjB5H,MAAM,CAAE6H,WAAW,CACnBE,QAAQ,CAAE,UAAU,CACpBC,QAAQ,CAAE,QAAQ,CAClBC,eAAe,CAAE,aAAa,CAC9BC,UAAU,CAAE,YAAY,CACpB3E,CAAAA,aAAa,CAAG,CAAE4E,OAAO,CAAE,CAAE,CAAC,CAAG,CAAEA,OAAO,CAAE,CAAE,CAAC,CAChDjI,KAAK,CACR,CACH,CAAC,CAEN,CAAC;;;;"}
1
+ {"version":3,"file":"RzpGlass.js","sources":["../../../../../../src/components/Spark/RzpGlass/RzpGlass.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/explicit-function-return-type */\n/* eslint-disable @typescript-eslint/no-unsafe-argument */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable react/react-in-jsx-scope */\n/* eslint-disable react-hooks/exhaustive-deps */\n/* eslint-disable @typescript-eslint/no-implicit-any-catch */\n/* eslint-disable @typescript-eslint/no-shadow */\n/**\n * RzpGlass React Component\n *\n * A React wrapper for the RzpGlassMount WebGL shader effect.\n * Manages the component lifecycle with useEffect hooks.\n *\n * @example\n * ```tsx\n * // Uses default assets and config\n * <RzpGlass width=\"400px\" height=\"300px\" />\n *\n * // With custom assets\n * <RzpGlass\n * videoSrc=\"/custom_video.mp4\"\n * gradientMapSrc=\"/custom-gradient.jpg\"\n * enableBloom={true}\n * />\n * ```\n */\n\nimport { forwardRef, useEffect, useRef, useState, useCallback } from 'react';\nimport { RzpGlassMount } from './RzpGlassMount';\nimport type {\n RzpGlassProps,\n RzpGlassConfig,\n RzpGlassAssets,\n RzpGlassPresetDefinition,\n} from './types';\nimport { getPresets } from './presets';\nimport type { RzpGlassPreset } from './presets';\n\n// Duration of the component's built-in fade-in transition.\n// The video is kept paused during this window so one-shot animations\n// (e.g. circleSlideUp) don't \"waste\" frames while the canvas is invisible.\nconst FADE_IN_MS = 200;\n\nconst DEFAULT_CDN_PATH = 'https://cdn.jsdelivr.net/npm/@razorpay/blade/assets/spark';\n\nconst getDefaultAssets = (assetsPath: string): Required<RzpGlassAssets> => ({\n videoSrc: `${assetsPath}/spark-base-video.mp4`,\n imageSrc: `${assetsPath}/bottom-frame.jpg`,\n gradientMapSrc: `${assetsPath}/colorama-gradient-map-green.jpg`,\n gradientMap2Src: `${assetsPath}/colorama-gradient-map-blue.jpg`,\n centerGradientMapSrc: `${assetsPath}/colorama-center-gradient-map.jpg`,\n});\n\n/**\n * Hook to merge multiple refs into one\n */\nfunction useMergeRefs<T>(refs: (React.Ref<T> | undefined)[]): React.RefCallback<T> {\n return useCallback(\n (value: T) => {\n refs.forEach((ref) => {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref != null) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n });\n },\n [refs],\n );\n}\n\n/**\n * Extract config from props (exclude non-config props).\n * Strips undefined values so they don't clobber preset defaults.\n */\nfunction extractConfig(props: RzpGlassProps): Partial<RzpGlassConfig> {\n const {\n width: _width,\n height: _height,\n className: _className,\n style: _style,\n onLoad: _onLoad,\n onError: _onError,\n preset: _preset,\n assetsPath: _assetsPath,\n gradientMapSrc: _gradientMapSrc,\n gradientMap2Src: _gradientMap2Src,\n gradientMapCanvas: _gradientMapCanvas,\n imageSrc: _imageSrc,\n ...config\n } = props;\n\n // Drop keys with undefined values so preset config isn't overridden by unset props\n return Object.fromEntries(\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n Object.entries(config).filter(([, v]) => v !== undefined),\n ) as Partial<RzpGlassConfig>;\n}\n\nconst ASSET_KEYS = new Set<string>([\n 'videoSrc',\n 'imageSrc',\n 'gradientMapSrc',\n 'gradientMap2Src',\n 'centerGradientMapSrc',\n]);\n\n/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return */\nfunction getPresetDefinition(\n preset: RzpGlassPreset | undefined,\n assetsPath: string,\n): RzpGlassPresetDefinition {\n const presets = getPresets(assetsPath);\n if (preset && preset in presets) return { ...presets[preset] };\n return {};\n}\n\nfunction getPresetConfig(\n preset: RzpGlassPreset | undefined,\n assetsPath: string,\n): Partial<RzpGlassConfig> {\n const def = getPresetDefinition(preset, assetsPath) as Record<string, unknown>;\n return Object.fromEntries(\n Object.entries(def).filter(([k]) => !ASSET_KEYS.has(k)),\n ) as Partial<RzpGlassConfig>;\n}\n\nfunction getPresetAssets(\n preset: RzpGlassPreset | undefined,\n assetsPath: string,\n): Partial<RzpGlassAssets> {\n const def = getPresetDefinition(preset, assetsPath) as Record<string, unknown>;\n return Object.fromEntries(\n Object.entries(def).filter(([k]) => ASSET_KEYS.has(k)),\n ) as Partial<RzpGlassAssets>;\n}\n\n/**\n * Merge preset config with user-provided config.\n * Preset values are used as base; any explicit prop overrides them.\n */\nfunction resolveConfig(props: RzpGlassProps, assetsPath: string): Partial<RzpGlassConfig> {\n return {\n ...getPresetConfig(props.preset, assetsPath),\n ...extractConfig(props),\n };\n}\n\nexport const RzpGlass = forwardRef<HTMLDivElement, RzpGlassProps>(function RzpGlass(\n props,\n forwardedRef,\n) {\n const {\n width = '100%',\n height = '100%',\n className,\n style,\n onLoad,\n onError,\n assetsPath: assetsPathProp,\n gradientMapCanvas,\n gradientMapSrc: gradientMapSrcProp,\n gradientMap2Src: gradientMap2SrcProp,\n imageSrc: imageSrcProp,\n ...configProps\n } = props;\n\n // Get default assets based on assetsPath\n const assetsPath: string = assetsPathProp ?? DEFAULT_CDN_PATH;\n const defaultAssets = getDefaultAssets(assetsPath);\n\n // Resolve assets: prop overrides preset, preset overrides default\n const presetAssets = getPresetAssets(props.preset, assetsPath);\n const imageSrc = imageSrcProp ?? presetAssets.imageSrc;\n const videoSrc = imageSrc ? undefined : presetAssets.videoSrc ?? defaultAssets.videoSrc;\n const gradientMapSrc =\n gradientMapSrcProp ?? presetAssets.gradientMapSrc ?? defaultAssets.gradientMapSrc;\n const gradientMap2Src =\n gradientMap2SrcProp ?? presetAssets.gradientMap2Src ?? defaultAssets.gradientMap2Src;\n const centerGradientMapSrc =\n presetAssets.centerGradientMapSrc ?? defaultAssets.centerGradientMapSrc;\n\n const [isInitialized, setIsInitialized] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const divRef = useRef<HTMLDivElement>(null);\n const mountRef = useRef<RzpGlassMount | null>(null);\n\n // Initialize on mount\n useEffect(() => {\n const init = async () => {\n if (!divRef.current || mountRef.current) return;\n\n try {\n const config = resolveConfig(props, assetsPath);\n\n mountRef.current = new RzpGlassMount(\n divRef.current,\n {\n videoSrc,\n imageSrc,\n gradientMapSrc,\n gradientMap2Src,\n centerGradientMapSrc,\n },\n config,\n );\n\n await mountRef.current.loadAssets();\n\n // Pause the video during the CSS fade-in so one-shot animations\n // don't burn frames while the component is still transparent.\n // Only do this when the consumer hasn't explicitly set paused: true.\n const userWantsPaused = config.paused ?? false;\n if (!userWantsPaused) {\n mountRef.current.pause();\n }\n\n setIsInitialized(true); // kicks off the CSS opacity 0 → 1 transition\n\n // After the fade-in completes, resume video and notify the consumer.\n setTimeout(() => {\n if (!mountRef.current) return;\n if (!userWantsPaused) {\n mountRef.current.play();\n }\n onLoad?.();\n }, FADE_IN_MS);\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n setError(error);\n onError?.(error);\n }\n };\n\n void init();\n\n return () => {\n mountRef.current?.dispose();\n mountRef.current = null;\n setIsInitialized(false);\n };\n }, [\n assetsPath,\n videoSrc,\n imageSrc,\n gradientMapSrc,\n gradientMap2Src,\n centerGradientMapSrc,\n configProps.preset,\n ]);\n\n // Update uniforms when config props change\n useEffect(() => {\n if (isInitialized && mountRef.current) {\n const config = resolveConfig(props, assetsPath);\n mountRef.current.setUniforms(config);\n }\n }, [\n isInitialized,\n configProps.preset,\n // Colorama\n configProps.inputMin,\n configProps.inputMax,\n configProps.modifyGamma,\n configProps.posterizeLevels,\n configProps.cycleRepetitions,\n configProps.phaseShift,\n configProps.cycleSpeed,\n configProps.wrapMode,\n configProps.reverse,\n configProps.blendWithOriginal,\n // Displacement\n configProps.numSegments,\n configProps.slitAngle,\n configProps.displacementX,\n configProps.displacementY,\n // Center element\n configProps.enableCenterElement,\n configProps.centerAnimDuration,\n // Color correction\n configProps.ccBlackPoint,\n configProps.ccWhitePoint,\n configProps.ccMidtoneGamma,\n configProps.ccGamma,\n configProps.ccContrast,\n // Zoom & Pan\n configProps.zoom,\n configProps.panX,\n configProps.panY,\n // eslint-disable-next-line react-hooks/exhaustive-deps\n ...(configProps.edgeFeather ?? [0, 0, 0, 0]),\n // Effect toggles\n configProps.enableDisplacement,\n configProps.enableColorama,\n configProps.enableBloom,\n configProps.enableLightSweep,\n // Light\n configProps.lightIntensity,\n configProps.lightStartFrame,\n // Playback\n configProps.paused,\n configProps.startTime,\n configProps.endTime,\n configProps.animateLightIndependently,\n // Cycle animation\n configProps.animateCycleReps,\n configProps.cycleRepetitionsStart,\n configProps.cycleRepetitionsEnd,\n configProps.cycleRepetitionsStartFrame,\n configProps.cycleRepetitionsDuration,\n // Gradient map blend\n configProps.gradientMapBlend,\n configProps.gradientMapBlendDuration,\n ]);\n\n // Update gradient map texture when a canvas is provided\n useEffect(() => {\n if (isInitialized && mountRef.current && gradientMapCanvas) {\n mountRef.current.updateGradientMapTexture(gradientMapCanvas);\n }\n }, [isInitialized, gradientMapCanvas]);\n\n const mergedRef = useMergeRefs([divRef, forwardedRef]);\n\n // Convert width/height to string if number\n const widthStyle = typeof width === 'number' ? `${width}px` : width;\n const heightStyle = typeof height === 'number' ? `${height}px` : height;\n\n if (error) {\n return (\n <div\n ref={mergedRef}\n className={className}\n style={{\n width: widthStyle,\n height: heightStyle,\n ...style,\n }}\n />\n );\n }\n\n return (\n <div\n ref={mergedRef}\n className={className}\n style={{\n width: widthStyle,\n height: heightStyle,\n position: 'relative',\n overflow: 'hidden',\n backgroundColor: 'transparent',\n transition: '2s opacity',\n ...(isInitialized ? { opacity: 1 } : { opacity: 0 }),\n ...style,\n }}\n />\n );\n});\n\nexport default RzpGlass;\n"],"names":["FADE_IN_MS","DEFAULT_CDN_PATH","getDefaultAssets","assetsPath","videoSrc","imageSrc","gradientMapSrc","gradientMap2Src","centerGradientMapSrc","useMergeRefs","refs","useCallback","value","forEach","ref","current","extractConfig","props","width","height","className","style","onLoad","onError","preset","gradientMapCanvas","config","_objectWithoutProperties","_excluded","Object","fromEntries","entries","filter","_ref","_ref2","_slicedToArray","v","undefined","ASSET_KEYS","Set","getPresetDefinition","presets","getPresets","assign","getPresetConfig","def","_ref3","_ref4","k","has","getPresetAssets","_ref5","_ref6","resolveConfig","RzpGlass","forwardRef","forwardedRef","_presetAssets$videoSr","_ref7","_ref8","_presetAssets$centerG","_configProps$edgeFeat","_props$width","_props$height","assetsPathProp","gradientMapSrcProp","gradientMap2SrcProp","imageSrcProp","configProps","_excluded2","defaultAssets","presetAssets","_useState","useState","_useState2","isInitialized","setIsInitialized","_useState3","_useState4","error","setError","divRef","useRef","mountRef","useEffect","init","_ref9","_asyncToGenerator","_config$paused","RzpGlassMount","loadAssets","userWantsPaused","paused","pause","setTimeout","play","err","Error","String","apply","arguments","_mountRef$current","dispose","setUniforms","inputMin","inputMax","modifyGamma","posterizeLevels","cycleRepetitions","phaseShift","cycleSpeed","wrapMode","reverse","blendWithOriginal","numSegments","slitAngle","displacementX","displacementY","enableCenterElement","centerAnimDuration","ccBlackPoint","ccWhitePoint","ccMidtoneGamma","ccGamma","ccContrast","zoom","panX","panY","concat","_toConsumableArray","edgeFeather","enableDisplacement","enableColorama","enableBloom","enableLightSweep","lightIntensity","lightStartFrame","startTime","endTime","animateLightIndependently","animateCycleReps","cycleRepetitionsStart","cycleRepetitionsEnd","cycleRepetitionsStartFrame","cycleRepetitionsDuration","gradientMapBlend","gradientMapBlendDuration","updateGradientMapTexture","mergedRef","widthStyle","heightStyle","_jsx","position","overflow","backgroundColor","transition","opacity"],"mappings":";;;;;;;;;AA2BA,IAAA,SAAA,CAAA,CAAA,OAAA,CAAA,QAAA,CAAA,WAAA,CAAA,OAAA,CAAA,QAAA,CAAA,SAAA,CAAA,QAAA,CAAA,YAAA,CAAA,gBAAA,CAAA,iBAAA,CAAA,mBAAA,CAAA,UAAA,CAAA,CAAA,UAAA,CAAA,CAAA,OAAA,CAAA,QAAA,CAAA,WAAA,CAAA,OAAA,CAAA,QAAA,CAAA,SAAA,CAAA,YAAA,CAAA,mBAAA,CAAA,gBAAA,CAAA,iBAAA,CAAA,UAAA,CAAA,CAcA,IAAMA,UAAU,CAAG,GAAG,CAEtB,IAAMC,gBAAgB,CAAG,2DAA2D,CAEpF,IAAMC,gBAAgB,CAAG,SAAnBA,gBAAgBA,CAAIC,UAAkB,CAAA,CAAA,OAAgC,CAC1EC,QAAQ,CAAE,GAAGD,UAAU,CAAA,qBAAA,CAAuB,CAC9CE,QAAQ,CAAE,CAAGF,EAAAA,UAAU,mBAAmB,CAC1CG,cAAc,CAAE,CAAGH,EAAAA,UAAU,kCAAkC,CAC/DI,eAAe,CAAE,CAAA,EAAGJ,UAAU,CAAiC,+BAAA,CAAA,CAC/D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G,OAAOnI,MAAM,GAAK,QAAQ,CAAG,CAAA,EAAGA,MAAM,CAAI,EAAA,CAAA,CAAGA,MAAM,CAEvE,GAAI4D,KAAK,CAAE,CACT,OACEwE,GAAA,QACEzI,GAAG,CAAEsI,SAAU,CACfhI,SAAS,CAAEA,SAAU,CACrBC,KAAK,CAAAQ,MAAA,CAAAc,MAAA,EACHzB,KAAK,CAAEmI,UAAU,CACjBlI,MAAM,CAAEmI,WAAW,EAChBjI,KAAK,CACR,CACH,CAAC,CAEN,CAEA,OACEkI,GAAA,CAAA,KAAA,CAAA,CACEzI,GAAG,CAAEsI,SAAU,CACfhI,SAAS,CAAEA,SAAU,CACrBC,KAAK,CAAAQ,MAAA,CAAAc,MAAA,CACHzB,CAAAA,KAAK,CAAEmI,UAAU,CACjBlI,MAAM,CAAEmI,WAAW,CACnBE,QAAQ,CAAE,UAAU,CACpBC,QAAQ,CAAE,QAAQ,CAClBC,eAAe,CAAE,aAAa,CAC9BC,UAAU,CAAE,YAAY,CAAA,CACpBhF,aAAa,CAAG,CAAEiF,OAAO,CAAE,CAAE,CAAC,CAAG,CAAEA,OAAO,CAAE,CAAE,CAAC,CAChDvI,KAAK,CACR,CACH,CAAC,CAEN,CAAC;;;;"}
@@ -22,7 +22,7 @@ var REF_RESOLUTION={width:3000,height:2000};var DEFAULT_MAX_PIXEL_COUNT=1920*108
22
22
  border-radius: inherit;
23
23
  }
24
24
  }
25
- }`;var CONFIG_TO_UNIFORM={enableDisplacement:'uEnableDisplacement',enableColorama:'uEnableColorama',enableBloom:'uEnableBloom',enableLightSweep:'uEnableLightSweep',inputMin:'uInputMin',inputMax:'uInputMax',modifyGamma:'uModifyGamma',posterizeLevels:'uPosterizeLevels',cycleRepetitions:'uCycleRepetitions',phaseShift:'uPhaseShift',cycleSpeed:'uCycleSpeed',wrapMode:'uWrapMode',reverse:'uReverse',blendWithOriginal:'uBlendWithOriginal',lightIntensity:'uLightIntensity',lightStartFrame:'uLightStartFrame',numSegments:'uNumSegments',slitAngle:'uSlitAngle',displacementX:'uDisplacementX',displacementY:'uDisplacementY',enableCenterElement:'uEnableCenterElement',centerAnimDuration:'uCenterAnimDuration',ccBlackPoint:'uCCBlackPoint',ccWhitePoint:'uCCWhitePoint',ccMidtoneGamma:'uCCMidtoneGamma',ccGamma:'uCCGamma',ccContrast:'uCCContrast',zoom:'uZoom',edgeFeather:'uEdgeFeather'};var RzpGlassMount=function(){function RzpGlassMount(parentElement,assets){var _this=this,_visualViewport2;var config=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var frame=arguments.length>3&&arguments[3]!==undefined?arguments[3]:0;var _minPixelRatio=arguments.length>4&&arguments[4]!==undefined?arguments[4]:1;var _maxPixelCount=arguments.length>5&&arguments[5]!==undefined?arguments[5]:DEFAULT_MAX_PIXEL_COUNT;_classCallCheck(this,RzpGlassMount);this.program=null;this.uniformLocations={};this.uniformCache={};this.videoTexture=null;this.gradientMapTexture=null;this.gradientMap2Texture=null;this.centerGradientMapTexture=null;this.currentGradientMapBlend=0;this.video=null;this.videoFrameCallbackId=null;this.rafId=null;this.lastRenderTime=0;this.currentFrame=0;this.independentLightTime=0;this.lastVideoTime=0;this.hasBeenDisposed=false;this.isInitialized=false;this.resolutionChanged=true;this.visibleUvBounds=[0,0,1,1];this.resizeObserver=null;this.renderScale=1;this.parentWidth=0;this.parentHeight=0;this.parentDevicePixelWidth=0;this.parentDevicePixelHeight=0;this.devicePixelsSupported=false;this.isSafariBrowser=isSafari();this.performanceController=null;this.handleVisualViewportChange=function(){var _this$resizeObserver;(_this$resizeObserver=_this.resizeObserver)==null?void 0:_this$resizeObserver.disconnect();_this.setupResizeObserver();};this.handleResize=function(){var _visualViewport$scale,_visualViewport;var containerWidth=_this.parentWidth||_this.parentElement.clientWidth;var containerHeight=_this.parentHeight||_this.parentElement.clientHeight;var containerAspect=containerWidth/containerHeight;var canvasWidth;var canvasHeight;var targetAspectRatio=_this.config.aspectRatio;if(containerAspect>targetAspectRatio){canvasWidth=containerWidth;canvasHeight=containerWidth/targetAspectRatio;}else {canvasHeight=containerHeight;canvasWidth=containerHeight*targetAspectRatio;}var offsetX=(containerWidth-canvasWidth)/2;var offsetY=(containerHeight-canvasHeight)/2;var visibleMinX=-offsetX/canvasWidth;var visibleMaxX=(containerWidth-offsetX)/canvasWidth;var visibleMinY=-offsetY/canvasHeight;var visibleMaxY=(containerHeight-offsetY)/canvasHeight;_this.visibleUvBounds=[visibleMinX,visibleMinY,visibleMaxX,visibleMaxY];_this.canvasElement.style.width=`${canvasWidth}px`;_this.canvasElement.style.height=`${canvasHeight}px`;_this.canvasElement.style.left=`${offsetX}px`;_this.canvasElement.style.top=`${offsetY}px`;var targetPixelWidth=0;var targetPixelHeight=0;var dpr=Math.max(1,window.devicePixelRatio);var pinchZoom=(_visualViewport$scale=(_visualViewport=visualViewport)==null?void 0:_visualViewport.scale)!=null?_visualViewport$scale:1;if(_this.devicePixelsSupported){var canvasToParentRatioX=canvasWidth/containerWidth;var canvasToParentRatioY=canvasHeight/containerHeight;var scaleToMeetMinPixelRatio=Math.max(1,_this.minPixelRatio/dpr);targetPixelWidth=_this.parentDevicePixelWidth*canvasToParentRatioX*scaleToMeetMinPixelRatio*pinchZoom;targetPixelHeight=_this.parentDevicePixelHeight*canvasToParentRatioY*scaleToMeetMinPixelRatio*pinchZoom;}else {var targetRenderScale=Math.max(dpr,_this.minPixelRatio)*pinchZoom;if(_this.isSafariBrowser){var zoomLevel=bestGuessBrowserZoom();targetRenderScale*=Math.max(1,zoomLevel);}targetPixelWidth=Math.round(canvasWidth)*targetRenderScale;targetPixelHeight=Math.round(canvasHeight)*targetRenderScale;}var maxPixelCountHeadroom=Math.sqrt(_this.maxPixelCount)/Math.sqrt(targetPixelWidth*targetPixelHeight);var scaleToMeetMaxPixelCount=Math.min(1,maxPixelCountHeadroom);var newWidth=Math.round(targetPixelWidth*scaleToMeetMaxPixelCount);var newHeight=Math.round(targetPixelHeight*scaleToMeetMaxPixelCount);var newRenderScale=newWidth/Math.round(canvasWidth);if(_this.canvasElement.width!==newWidth||_this.canvasElement.height!==newHeight||_this.renderScale!==newRenderScale){_this.renderScale=newRenderScale;_this.canvasElement.width=newWidth;_this.canvasElement.height=newHeight;_this.resolutionChanged=true;_this.gl.viewport(0,0,newWidth,newHeight);if(_this.rafId===null){_this.render(performance.now());}}};this.handleDocumentVisibilityChange=function(){if(document.hidden){var _this$video;_this.stopRenderLoop();(_this$video=_this.video)==null?void 0:_this$video.pause();}else {_this.startRenderLoop();if(!_this.config.paused){var _this$video2;(_this$video2=_this.video)==null?void 0:_this$video2.play().catch(function(){});}}};this.render=function(currentTime){if(_this.hasBeenDisposed)return;_this.rafId=requestAnimationFrame(_this.render);if(_this.program===null){console.warn('Tried to render before program was initialized');return;}var gl=_this.gl;var video=_this.video;gl.clear(gl.COLOR_BUFFER_BIT);var currentTimeSeconds=currentTime*0.001;var deltaTime=currentTimeSeconds-_this.lastRenderTime;_this.lastRenderTime=currentTimeSeconds;_this.currentFrame++;var usingStaticImage=!video&&_this.videoTexture!==null;if(!usingStaticImage){if(!video||video.readyState<video.HAVE_CURRENT_DATA){return;}if(!('requestVideoFrameCallback'in video)&&_this.videoTexture){_this.videoTexture.update(video);}if(!_this.config.paused){if(video.currentTime<_this.config.startTime||video.currentTime>=_this.config.endTime){video.currentTime=_this.config.startTime;}}}var videoAnimTime=usingStaticImage?currentTimeSeconds:video.currentTime-_this.config.startTime;if(_this.config.animateLightIndependently||usingStaticImage){_this.independentLightTime+=deltaTime;}else {var videoTimeDelta=videoAnimTime-_this.lastVideoTime;var isVideoJump=Math.abs(videoTimeDelta)>0.1||videoTimeDelta<-0.01;if(isVideoJump){_this.independentLightTime=videoAnimTime;}else {_this.independentLightTime+=deltaTime;}}_this.lastVideoTime=videoAnimTime;gl.useProgram(_this.program);gl.uniform1f(_this.uniformLocations.uTime,currentTimeSeconds);var frameCount=_this.config.animateLightIndependently?_this.independentLightTime*30:videoAnimTime*30;gl.uniform1f(_this.uniformLocations.uFrameCount,frameCount);gl.uniform1f(_this.uniformLocations.uCenterAnimTime,_this.independentLightTime);if(_this.resolutionChanged){gl.uniform2f(_this.uniformLocations.iResolution,_this.canvasElement.width,_this.canvasElement.height);gl.uniform1f(_this.uniformLocations.uDpr,_this.renderScale);gl.uniform4f(_this.uniformLocations.uVisibleUvBounds,_this.visibleUvBounds[0],_this.visibleUvBounds[1],_this.visibleUvBounds[2],_this.visibleUvBounds[3]);_this.resolutionChanged=false;}if(_this.config.animateCycleReps&&_this.currentFrame>_this.config.cycleRepetitionsStartFrame){var elapsed=_this.currentFrame-_this.config.cycleRepetitionsStartFrame;var cycleProgress=elapsed%(_this.config.cycleRepetitionsDuration*2)/_this.config.cycleRepetitionsDuration;var pingPong=cycleProgress<=1?cycleProgress:2-cycleProgress;var eased=pingPong*pingPong*(3-2*pingPong);var delta=_this.config.cycleRepetitionsEnd-_this.config.cycleRepetitionsStart;gl.uniform1f(_this.uniformLocations.uCycleRepetitions,_this.config.cycleRepetitionsStart+eased*delta);}else {gl.uniform1f(_this.uniformLocations.uCycleRepetitions,_this.config.cycleRepetitions);}var targetBlend=_this.config.gradientMapBlend;if(_this.currentGradientMapBlend!==targetBlend){var speed=1.0/_this.config.gradientMapBlendDuration;var diff=targetBlend-_this.currentGradientMapBlend;var step=Math.sign(diff)*Math.min(Math.abs(diff),speed*deltaTime);_this.currentGradientMapBlend+=step;gl.uniform1f(_this.uniformLocations.uGradientMapBlend,_this.currentGradientMapBlend);}gl.drawArrays(gl.TRIANGLES,0,6);};this.handlePerformanceLevelChange=function(level){if(level===0){_this.stopRenderLoop();_this.canvasElement.style.display='none';return;}var _LEVEL_RENDER_SETTING=LEVEL_RENDER_SETTINGS[level],maxPixelCount=_LEVEL_RENDER_SETTING.maxPixelCount,minPixelRatio=_LEVEL_RENDER_SETTING.minPixelRatio;_this.maxPixelCount=maxPixelCount;_this.minPixelRatio=minPixelRatio;if(_this.canvasElement.style.display==='none'){_this.canvasElement.style.display='';}if(_this.isInitialized){_this.startRenderLoop();}_this.handleResize();};this.parentElement=parentElement;this.assets=assets;this.config=Object.assign({},DEFAULT_CONFIG,config);this.currentFrame=frame;this.minPixelRatio=_minPixelRatio;this.maxPixelCount=_maxPixelCount;if(!document.querySelector('style[data-rzp-glass-style]')){var styleElement=document.createElement('style');styleElement.innerHTML=defaultStyle;styleElement.setAttribute('data-rzp-glass-style','');document.head.prepend(styleElement);}this.canvasElement=document.createElement('canvas');this.parentElement.prepend(this.canvasElement);this.parentElement.setAttribute('data-rzp-glass','');var _gl=this.canvasElement.getContext('webgl',{antialias:false,premultipliedAlpha:false,depth:false,alpha:true,powerPreference:'high-performance'});this.gl=_gl;this.performanceController=new WebGLPerformanceController({gl:this.gl,onLevelChange:this.handlePerformanceLevelChange});this.stopIfPotato();_gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL,true);_gl.disable(_gl.DEPTH_TEST);_gl.disable(_gl.CULL_FACE);_gl.clearColor(0,0,0,0);this.initProgram();this.setupPositionAttribute();this.setupUniformLocations();this.setupResizeObserver();(_visualViewport2=visualViewport)==null?void 0:_visualViewport2.addEventListener('resize',this.handleVisualViewportChange);document.addEventListener('visibilitychange',this.handleDocumentVisibilityChange);}return _createClass(RzpGlassMount,[{key:"stopIfPotato",value:function stopIfPotato(){var _this$performanceCont;if(!((_this$performanceCont=this.performanceController)!=null&&_this$performanceCont.isPotato())){return;}this.stopRenderLoop();throw new Error('RzpGlass: WebGL is not supported in this browser');}},{key:"loadAssets",value:(function(){var _loadAssets=_asyncToGenerator(function*(){this.stopIfPotato();try{var _this$assets$gradient;var useStaticImage=Boolean(this.assets.imageSrc);var gradientMap2Src=(_this$assets$gradient=this.assets.gradientMap2Src)!=null?_this$assets$gradient:this.assets.gradientMapSrc;var _yield$Promise$all=yield Promise.all([useStaticImage?loadImage(this.assets.imageSrc):loadVideo(this.assets.videoSrc),loadImage(this.assets.gradientMapSrc),loadImage(gradientMap2Src),loadImage(this.assets.centerGradientMapSrc)]),_yield$Promise$all2=_slicedToArray(_yield$Promise$all,4),baseAsset=_yield$Promise$all2[0],gradientMap=_yield$Promise$all2[1],gradientMap2=_yield$Promise$all2[2],centerGradientMap=_yield$Promise$all2[3];if(useStaticImage){this.setupImageTexture('uVideoTexture',baseAsset,0);}else {this.video=baseAsset;this.setupVideoTexture();this.video.currentTime=this.config.startTime;this.video.playbackRate=this.config.playbackRate;if(!this.config.paused){yield this.video.play().catch(function(e){console.warn('Video autoplay failed:',e);});}}this.setupImageTexture('uGradientMap',gradientMap,1);this.setupImageTexture('uCenterGradientMap',centerGradientMap,2);this.setupImageTexture('uGradientMap2',gradientMap2,3);this.setAllUniforms();this.isInitialized=true;this.handleResize();this.startRenderLoop();}catch(error){console.error('RzpGlass: Failed to load assets',error);throw error;}});function loadAssets(){return _loadAssets.apply(this,arguments);}return loadAssets;}())},{key:"initProgram",value:function initProgram(){var program=createProgram(this.gl,rzpGlassVertexShader,rzpGlassFragmentShader);if(!program){throw new Error('RzpGlass: Failed to create WebGL program');}this.program=program;}},{key:"setupPositionAttribute",value:function setupPositionAttribute(){var buffers=setupFullscreenQuad(this.gl,this.program);if(!buffers){throw new Error('RzpGlass: Failed to setup fullscreen quad');}}},{key:"setupUniformLocations",value:function setupUniformLocations(){var gl=this.gl;var program=this.program;var uniformNames=['uTime','iResolution','uDpr','uVideoTexture','uGradientMap','uGradientMap2','uGradientMapBlend','uCenterGradientMap','uEnableDisplacement','uEnableColorama','uEnableBloom','uEnableLightSweep','uInputMin','uInputMax','uModifyGamma','uPosterizeLevels','uCycleRepetitions','uPhaseShift','uCycleSpeed','uWrapMode','uReverse','uBlendWithOriginal','uLightIntensity','uFrameCount','uLightStartFrame','uNumSegments','uSlitAngle','uDisplacementX','uDisplacementY','uEnableCenterElement','uCenterAnimDuration','uCenterAnimTime','uCCBlackPoint','uCCWhitePoint','uCCMidtoneGamma','uCCGamma','uCCContrast','uZoom','uPan','uEdgeFeather','uRefResolution','uVisibleUvBounds','uBackgroundColor','uEnableRippleWave','uRippleSpeed','uRippleBlend','uRippleAngularPower','uRippleRadialFalloff','uRippleWaitTime'];for(var name of uniformNames){this.uniformLocations[name]=gl.getUniformLocation(program,name);}}},{key:"setupVideoTexture",value:function setupVideoTexture(){var _this2=this;this.videoTexture=new Texture(this.gl,{textureUnit:0});if(this.video&&'requestVideoFrameCallback'in this.video){var _updateVideoFrame=function updateVideoFrame(){if(_this2.hasBeenDisposed||!_this2.video||!_this2.videoTexture)return;_this2.videoTexture.update(_this2.video);_this2.videoFrameCallbackId=_this2.video.requestVideoFrameCallback(_updateVideoFrame);};this.videoFrameCallbackId=this.video.requestVideoFrameCallback(_updateVideoFrame);}}},{key:"setupImageTexture",value:function setupImageTexture(uniformName,image,textureUnit){var texture=new Texture(this.gl,{textureUnit:textureUnit});texture.image(image);if(uniformName==='uVideoTexture'){this.videoTexture=texture;}else if(uniformName==='uGradientMap'){this.gradientMapTexture=texture;}else if(uniformName==='uGradientMap2'){this.gradientMap2Texture=texture;}else if(uniformName==='uCenterGradientMap'){this.centerGradientMapTexture=texture;}}},{key:"updateGradientMapTexture",value:function updateGradientMapTexture(source){if(!this.isInitialized||!this.gradientMapTexture)return;this.gradientMapTexture.image(source);}},{key:"setupResizeObserver",value:function setupResizeObserver(){var _this3=this;this.resizeObserver=new ResizeObserver(function(_ref){var _ref2=_slicedToArray(_ref,1),entry=_ref2[0];if(entry!=null&&entry.borderBoxSize[0]){var _entry$devicePixelCon;var physicalPixelSize=(_entry$devicePixelCon=entry.devicePixelContentBoxSize)==null?void 0:_entry$devicePixelCon[0];if(physicalPixelSize!==undefined){_this3.devicePixelsSupported=true;_this3.parentDevicePixelWidth=physicalPixelSize.inlineSize;_this3.parentDevicePixelHeight=physicalPixelSize.blockSize;}_this3.parentWidth=entry.borderBoxSize[0].inlineSize;_this3.parentHeight=entry.borderBoxSize[0].blockSize;}_this3.handleResize();});this.resizeObserver.observe(this.parentElement);}},{key:"setAllUniforms",value:function setAllUniforms(){var gl=this.gl;gl.useProgram(this.program);gl.uniform1i(this.uniformLocations.uVideoTexture,0);gl.uniform1i(this.uniformLocations.uGradientMap,1);gl.uniform1i(this.uniformLocations.uCenterGradientMap,2);gl.uniform1i(this.uniformLocations.uGradientMap2,3);gl.uniform1f(this.uniformLocations.uGradientMapBlend,this.currentGradientMapBlend);this.setUniformValues(this.config);gl.uniform2f(this.uniformLocations.uPan,this.config.panX,this.config.panY);gl.uniform2f(this.uniformLocations.uRefResolution,REF_RESOLUTION.width,REF_RESOLUTION.height);if(this.config.backgroundColor){var _this$config$backgrou=_slicedToArray(this.config.backgroundColor,3),r=_this$config$backgrou[0],g=_this$config$backgrou[1],b=_this$config$backgrou[2];gl.uniform3f(this.uniformLocations.uBackgroundColor,r,g,b);gl.clearColor(r,g,b,1.0);}else {gl.uniform3f(this.uniformLocations.uBackgroundColor,-1.0,-1.0,-1.0);gl.clearColor(0,0,0,0);}gl.uniform4f(this.uniformLocations.uVisibleUvBounds,this.visibleUvBounds[0],this.visibleUvBounds[1],this.visibleUvBounds[2],this.visibleUvBounds[3]);}},{key:"areUniformValuesEqual",value:function areUniformValuesEqual(a,b){var _this4=this;if(a===b)return true;if(Array.isArray(a)&&Array.isArray(b)&&a.length===b.length){return a.every(function(val,i){return _this4.areUniformValuesEqual(val,b[i]);});}return false;}},{key:"setUniformValues",value:function setUniformValues(config){var _this5=this;var gl=this.gl;gl.useProgram(this.program);Object.entries(config).forEach(function(_ref3){var _ref4=_slicedToArray(_ref3,2),key=_ref4[0],value=_ref4[1];if(value===undefined)return;if(_this5.areUniformValuesEqual(_this5.uniformCache[key],value))return;_this5.uniformCache[key]=value;var uniformName=CONFIG_TO_UNIFORM[key];if(!uniformName)return;var location=_this5.uniformLocations[uniformName];if(!location)return;if(typeof value==='boolean'){gl.uniform1f(location,value?1:0);}else if(typeof value==='number'){gl.uniform1f(location,value);}else if(Array.isArray(value)){var flatArray=value.flat();switch(flatArray.length){case 2:gl.uniform2fv(location,flatArray);break;case 3:gl.uniform3fv(location,flatArray);break;case 4:gl.uniform4fv(location,flatArray);break;}}});if(config.panX!==undefined||config.panY!==undefined){var panCacheKey='pan';var panValue=[this.config.panX,this.config.panY];if(!this.areUniformValuesEqual(this.uniformCache[panCacheKey],panValue)){this.uniformCache[panCacheKey]=panValue;gl.uniform2f(this.uniformLocations.uPan,panValue[0],panValue[1]);}}if(config.backgroundColor!==undefined){var bgCacheKey='backgroundColor';if(!this.areUniformValuesEqual(this.uniformCache[bgCacheKey],config.backgroundColor)){this.uniformCache[bgCacheKey]=config.backgroundColor;if(config.backgroundColor){var _config$backgroundCol=_slicedToArray(config.backgroundColor,3),r=_config$backgroundCol[0],g=_config$backgroundCol[1],b=_config$backgroundCol[2];gl.uniform3f(this.uniformLocations.uBackgroundColor,r,g,b);gl.clearColor(r,g,b,1.0);}else {gl.uniform3f(this.uniformLocations.uBackgroundColor,-1.0,-1.0,-1.0);gl.clearColor(0,0,0,0);}}}}},{key:"setUniforms",value:function setUniforms(newConfig){this.config=Object.assign({},this.config,newConfig);if(!this.isInitialized)return;this.setUniformValues(newConfig);if(newConfig.paused!==undefined){if(newConfig.paused){var _this$video3;(_this$video3=this.video)==null?void 0:_this$video3.pause();}else {var _this$video4;(_this$video4=this.video)==null?void 0:_this$video4.play().catch(function(){});}}if(newConfig.playbackRate!==undefined&&this.video){this.video.playbackRate=newConfig.playbackRate;}if(newConfig.aspectRatio!==undefined){this.handleResize();}}},{key:"startRenderLoop",value:function startRenderLoop(){if(this.rafId!==null)return;this.lastRenderTime=performance.now()*0.001;this.rafId=requestAnimationFrame(this.render);}},{key:"stopRenderLoop",value:function stopRenderLoop(){if(this.rafId!==null){cancelAnimationFrame(this.rafId);this.rafId=null;}}},{key:"getCurrentFrame",value:function getCurrentFrame(){return this.currentFrame;}},{key:"setFrame",value:function setFrame(newFrame){this.currentFrame=newFrame;}},{key:"setMaxPixelCount",value:function setMaxPixelCount(){var newMaxPixelCount=arguments.length>0&&arguments[0]!==undefined?arguments[0]:DEFAULT_MAX_PIXEL_COUNT;this.maxPixelCount=newMaxPixelCount;this.handleResize();}},{key:"setMinPixelRatio",value:function setMinPixelRatio(){var newMinPixelRatio=arguments.length>0&&arguments[0]!==undefined?arguments[0]:2;this.minPixelRatio=newMinPixelRatio;this.handleResize();}},{key:"play",value:function play(){var _this$video5;this.config.paused=false;(_this$video5=this.video)==null?void 0:_this$video5.play().catch(function(){});}},{key:"pause",value:function pause(){var _this$video6;this.config.paused=true;(_this$video6=this.video)==null?void 0:_this$video6.pause();}},{key:"setTime",value:function setTime(time){if(this.video){this.video.currentTime=time;}}},{key:"dispose",value:function dispose(){var _this$performanceCont2,_visualViewport3;this.hasBeenDisposed=true;if(this.rafId!==null){cancelAnimationFrame(this.rafId);this.rafId=null;}if(this.videoFrameCallbackId!==null&&this.video&&'cancelVideoFrameCallback'in this.video){this.video.cancelVideoFrameCallback(this.videoFrameCallbackId);}if(this.video){this.video.pause();this.video.src='';this.video.load();this.video=null;}if(this.gl&&this.program){var _this$videoTexture,_this$gradientMapText,_this$gradientMap2Tex,_this$centerGradientM;(_this$videoTexture=this.videoTexture)==null?void 0:_this$videoTexture.destroy();(_this$gradientMapText=this.gradientMapTexture)==null?void 0:_this$gradientMapText.destroy();(_this$gradientMap2Tex=this.gradientMap2Texture)==null?void 0:_this$gradientMap2Tex.destroy();(_this$centerGradientM=this.centerGradientMapTexture)==null?void 0:_this$centerGradientM.destroy();this.gl.deleteProgram(this.program);this.program=null;this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null);this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null);this.gl.bindRenderbuffer(this.gl.RENDERBUFFER,null);this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null);this.gl.getError();}(_this$performanceCont2=this.performanceController)==null?void 0:_this$performanceCont2.dispose();this.performanceController=null;if(this.resizeObserver){this.resizeObserver.disconnect();this.resizeObserver=null;}(_visualViewport3=visualViewport)==null?void 0:_visualViewport3.removeEventListener('resize',this.handleVisualViewportChange);document.removeEventListener('visibilitychange',this.handleDocumentVisibilityChange);this.uniformLocations={};this.uniformCache={};this.canvasElement.remove();this.parentElement.removeAttribute('data-rzp-glass');}}]);}();
25
+ }`;var CONFIG_TO_UNIFORM={enableDisplacement:'uEnableDisplacement',enableColorama:'uEnableColorama',enableBloom:'uEnableBloom',enableLightSweep:'uEnableLightSweep',inputMin:'uInputMin',inputMax:'uInputMax',modifyGamma:'uModifyGamma',posterizeLevels:'uPosterizeLevels',cycleRepetitions:'uCycleRepetitions',phaseShift:'uPhaseShift',cycleSpeed:'uCycleSpeed',wrapMode:'uWrapMode',reverse:'uReverse',blendWithOriginal:'uBlendWithOriginal',lightIntensity:'uLightIntensity',lightStartFrame:'uLightStartFrame',numSegments:'uNumSegments',slitAngle:'uSlitAngle',displacementX:'uDisplacementX',displacementY:'uDisplacementY',enableCenterElement:'uEnableCenterElement',centerAnimDuration:'uCenterAnimDuration',ccBlackPoint:'uCCBlackPoint',ccWhitePoint:'uCCWhitePoint',ccMidtoneGamma:'uCCMidtoneGamma',ccGamma:'uCCGamma',ccContrast:'uCCContrast',zoom:'uZoom',edgeFeather:'uEdgeFeather'};var RzpGlassMount=function(){function RzpGlassMount(parentElement,assets){var _this=this,_visualViewport2;var config=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var frame=arguments.length>3&&arguments[3]!==undefined?arguments[3]:0;var _minPixelRatio=arguments.length>4&&arguments[4]!==undefined?arguments[4]:1;var _maxPixelCount=arguments.length>5&&arguments[5]!==undefined?arguments[5]:DEFAULT_MAX_PIXEL_COUNT;_classCallCheck(this,RzpGlassMount);this.program=null;this.uniformLocations={};this.uniformCache={};this.videoTexture=null;this.gradientMapTexture=null;this.gradientMap2Texture=null;this.centerGradientMapTexture=null;this.currentGradientMapBlend=0;this.video=null;this.videoFrameCallbackId=null;this.rafId=null;this.lastRenderTime=0;this.currentFrame=0;this.independentLightTime=0;this.lastVideoTime=0;this.hasBeenDisposed=false;this.isInitialized=false;this.resolutionChanged=true;this.visibleUvBounds=[0,0,1,1];this.resizeObserver=null;this.renderScale=1;this.parentWidth=0;this.parentHeight=0;this.parentDevicePixelWidth=0;this.parentDevicePixelHeight=0;this.devicePixelsSupported=false;this.isSafariBrowser=isSafari();this.performanceController=null;this.handleVisualViewportChange=function(){var _this$resizeObserver;(_this$resizeObserver=_this.resizeObserver)==null?void 0:_this$resizeObserver.disconnect();_this.setupResizeObserver();};this.handleResize=function(){var _visualViewport$scale,_visualViewport;var containerWidth=_this.parentWidth||_this.parentElement.clientWidth;var containerHeight=_this.parentHeight||_this.parentElement.clientHeight;var containerAspect=containerWidth/containerHeight;var canvasWidth;var canvasHeight;var targetAspectRatio=_this.config.aspectRatio;if(containerAspect>targetAspectRatio){canvasWidth=containerWidth;canvasHeight=containerWidth/targetAspectRatio;}else {canvasHeight=containerHeight;canvasWidth=containerHeight*targetAspectRatio;}var offsetX=(containerWidth-canvasWidth)/2;var offsetY=(containerHeight-canvasHeight)/2;var visibleMinX=-offsetX/canvasWidth;var visibleMaxX=(containerWidth-offsetX)/canvasWidth;var visibleMinY=-offsetY/canvasHeight;var visibleMaxY=(containerHeight-offsetY)/canvasHeight;_this.visibleUvBounds=[visibleMinX,visibleMinY,visibleMaxX,visibleMaxY];_this.canvasElement.style.width=`${canvasWidth}px`;_this.canvasElement.style.height=`${canvasHeight}px`;_this.canvasElement.style.left=`${offsetX}px`;_this.canvasElement.style.top=`${offsetY}px`;var targetPixelWidth=0;var targetPixelHeight=0;var dpr=Math.max(1,window.devicePixelRatio);var pinchZoom=(_visualViewport$scale=(_visualViewport=visualViewport)==null?void 0:_visualViewport.scale)!=null?_visualViewport$scale:1;if(_this.devicePixelsSupported){var canvasToParentRatioX=canvasWidth/containerWidth;var canvasToParentRatioY=canvasHeight/containerHeight;var scaleToMeetMinPixelRatio=Math.max(1,_this.minPixelRatio/dpr);targetPixelWidth=_this.parentDevicePixelWidth*canvasToParentRatioX*scaleToMeetMinPixelRatio*pinchZoom;targetPixelHeight=_this.parentDevicePixelHeight*canvasToParentRatioY*scaleToMeetMinPixelRatio*pinchZoom;}else {var targetRenderScale=Math.max(dpr,_this.minPixelRatio)*pinchZoom;if(_this.isSafariBrowser){var zoomLevel=bestGuessBrowserZoom();targetRenderScale*=Math.max(1,zoomLevel);}targetPixelWidth=Math.round(canvasWidth)*targetRenderScale;targetPixelHeight=Math.round(canvasHeight)*targetRenderScale;}var maxPixelCountHeadroom=Math.sqrt(_this.maxPixelCount)/Math.sqrt(targetPixelWidth*targetPixelHeight);var scaleToMeetMaxPixelCount=Math.min(1,maxPixelCountHeadroom);var newWidth=Math.round(targetPixelWidth*scaleToMeetMaxPixelCount);var newHeight=Math.round(targetPixelHeight*scaleToMeetMaxPixelCount);var newRenderScale=newWidth/Math.round(canvasWidth);if(_this.canvasElement.width!==newWidth||_this.canvasElement.height!==newHeight||_this.renderScale!==newRenderScale){_this.renderScale=newRenderScale;_this.canvasElement.width=newWidth;_this.canvasElement.height=newHeight;_this.resolutionChanged=true;_this.gl.viewport(0,0,newWidth,newHeight);if(_this.rafId===null){_this.render(performance.now());}}};this.handleDocumentVisibilityChange=function(){if(document.hidden){var _this$video;_this.stopRenderLoop();(_this$video=_this.video)==null?void 0:_this$video.pause();}else {_this.startRenderLoop();if(!_this.config.paused){var _this$video2;(_this$video2=_this.video)==null?void 0:_this$video2.play().catch(function(){});}}};this.render=function(currentTime){if(_this.hasBeenDisposed)return;_this.rafId=requestAnimationFrame(_this.render);if(_this.program===null){console.warn('Tried to render before program was initialized');return;}var gl=_this.gl;var video=_this.video;var currentTimeSeconds=currentTime*0.001;var deltaTime=currentTimeSeconds-_this.lastRenderTime;_this.lastRenderTime=currentTimeSeconds;_this.currentFrame++;var usingStaticImage=!video&&_this.videoTexture!==null;if(!usingStaticImage){if(!video||video.readyState<video.HAVE_CURRENT_DATA){return;}if(!('requestVideoFrameCallback'in video)&&_this.videoTexture){_this.videoTexture.update(video);}if(!_this.config.paused){if(video.currentTime<_this.config.startTime||video.currentTime>=_this.config.endTime){video.currentTime=_this.config.startTime;}}}gl.clear(gl.COLOR_BUFFER_BIT);var videoAnimTime=usingStaticImage?currentTimeSeconds:video.currentTime-_this.config.startTime;if(_this.config.animateLightIndependently||usingStaticImage){_this.independentLightTime+=deltaTime;}else {var videoTimeDelta=videoAnimTime-_this.lastVideoTime;var isVideoJump=Math.abs(videoTimeDelta)>0.1||videoTimeDelta<-0.01;if(isVideoJump){_this.independentLightTime=videoAnimTime;}else {_this.independentLightTime+=deltaTime;}}_this.lastVideoTime=videoAnimTime;gl.useProgram(_this.program);gl.uniform1f(_this.uniformLocations.uTime,currentTimeSeconds);var frameCount=_this.config.animateLightIndependently?_this.independentLightTime*30:videoAnimTime*30;gl.uniform1f(_this.uniformLocations.uFrameCount,frameCount);gl.uniform1f(_this.uniformLocations.uCenterAnimTime,_this.independentLightTime);if(_this.resolutionChanged){gl.uniform2f(_this.uniformLocations.iResolution,_this.canvasElement.width,_this.canvasElement.height);gl.uniform1f(_this.uniformLocations.uDpr,_this.renderScale);gl.uniform4f(_this.uniformLocations.uVisibleUvBounds,_this.visibleUvBounds[0],_this.visibleUvBounds[1],_this.visibleUvBounds[2],_this.visibleUvBounds[3]);_this.resolutionChanged=false;}if(_this.config.animateCycleReps&&_this.currentFrame>_this.config.cycleRepetitionsStartFrame){var elapsed=_this.currentFrame-_this.config.cycleRepetitionsStartFrame;var cycleProgress=elapsed%(_this.config.cycleRepetitionsDuration*2)/_this.config.cycleRepetitionsDuration;var pingPong=cycleProgress<=1?cycleProgress:2-cycleProgress;var eased=pingPong*pingPong*(3-2*pingPong);var delta=_this.config.cycleRepetitionsEnd-_this.config.cycleRepetitionsStart;gl.uniform1f(_this.uniformLocations.uCycleRepetitions,_this.config.cycleRepetitionsStart+eased*delta);}else {gl.uniform1f(_this.uniformLocations.uCycleRepetitions,_this.config.cycleRepetitions);}var targetBlend=_this.config.gradientMapBlend;if(_this.currentGradientMapBlend!==targetBlend){var speed=1.0/_this.config.gradientMapBlendDuration;var diff=targetBlend-_this.currentGradientMapBlend;var step=Math.sign(diff)*Math.min(Math.abs(diff),speed*deltaTime);_this.currentGradientMapBlend+=step;gl.uniform1f(_this.uniformLocations.uGradientMapBlend,_this.currentGradientMapBlend);}gl.drawArrays(gl.TRIANGLES,0,6);};this.handlePerformanceLevelChange=function(level){if(level===0){_this.stopRenderLoop();_this.canvasElement.style.display='none';return;}var _LEVEL_RENDER_SETTING=LEVEL_RENDER_SETTINGS[level],maxPixelCount=_LEVEL_RENDER_SETTING.maxPixelCount,minPixelRatio=_LEVEL_RENDER_SETTING.minPixelRatio;_this.maxPixelCount=maxPixelCount;_this.minPixelRatio=minPixelRatio;if(_this.canvasElement.style.display==='none'){_this.canvasElement.style.display='';}if(_this.isInitialized){_this.startRenderLoop();}_this.handleResize();};this.parentElement=parentElement;this.assets=assets;this.config=Object.assign({},DEFAULT_CONFIG,config);this.currentFrame=frame;this.minPixelRatio=_minPixelRatio;this.maxPixelCount=_maxPixelCount;if(!document.querySelector('style[data-rzp-glass-style]')){var styleElement=document.createElement('style');styleElement.innerHTML=defaultStyle;styleElement.setAttribute('data-rzp-glass-style','');document.head.prepend(styleElement);}this.canvasElement=document.createElement('canvas');this.parentElement.prepend(this.canvasElement);this.parentElement.setAttribute('data-rzp-glass','');var _gl=this.canvasElement.getContext('webgl',{antialias:false,premultipliedAlpha:false,depth:false,alpha:true,powerPreference:'high-performance'});this.gl=_gl;this.performanceController=new WebGLPerformanceController({gl:this.gl,onLevelChange:this.handlePerformanceLevelChange});this.stopIfPotato();_gl.pixelStorei(_gl.UNPACK_FLIP_Y_WEBGL,true);_gl.disable(_gl.DEPTH_TEST);_gl.disable(_gl.CULL_FACE);_gl.clearColor(0,0,0,0);this.initProgram();this.setupPositionAttribute();this.setupUniformLocations();this.setupResizeObserver();(_visualViewport2=visualViewport)==null?void 0:_visualViewport2.addEventListener('resize',this.handleVisualViewportChange);document.addEventListener('visibilitychange',this.handleDocumentVisibilityChange);}return _createClass(RzpGlassMount,[{key:"stopIfPotato",value:function stopIfPotato(){var _this$performanceCont;if(!((_this$performanceCont=this.performanceController)!=null&&_this$performanceCont.isPotato())){return;}this.stopRenderLoop();throw new Error('RzpGlass: WebGL is not supported in this browser');}},{key:"loadAssets",value:(function(){var _loadAssets=_asyncToGenerator(function*(){this.stopIfPotato();try{var _this$assets$gradient;var useStaticImage=Boolean(this.assets.imageSrc);var gradientMap2Src=(_this$assets$gradient=this.assets.gradientMap2Src)!=null?_this$assets$gradient:this.assets.gradientMapSrc;var _yield$Promise$all=yield Promise.all([useStaticImage?loadImage(this.assets.imageSrc):loadVideo(this.assets.videoSrc),loadImage(this.assets.gradientMapSrc),loadImage(gradientMap2Src),loadImage(this.assets.centerGradientMapSrc)]),_yield$Promise$all2=_slicedToArray(_yield$Promise$all,4),baseAsset=_yield$Promise$all2[0],gradientMap=_yield$Promise$all2[1],gradientMap2=_yield$Promise$all2[2],centerGradientMap=_yield$Promise$all2[3];if(useStaticImage){this.setupImageTexture('uVideoTexture',baseAsset,0);}else {this.video=baseAsset;this.setupVideoTexture();this.video.currentTime=this.config.startTime;this.video.playbackRate=this.config.playbackRate;if(!this.config.paused){yield this.video.play().catch(function(e){console.warn('Video autoplay failed:',e);});}}this.setupImageTexture('uGradientMap',gradientMap,1);this.setupImageTexture('uCenterGradientMap',centerGradientMap,2);this.setupImageTexture('uGradientMap2',gradientMap2,3);this.setAllUniforms();this.isInitialized=true;this.handleResize();this.startRenderLoop();}catch(error){console.error('RzpGlass: Failed to load assets',error);throw error;}});function loadAssets(){return _loadAssets.apply(this,arguments);}return loadAssets;}())},{key:"initProgram",value:function initProgram(){var program=createProgram(this.gl,rzpGlassVertexShader,rzpGlassFragmentShader);if(!program){throw new Error('RzpGlass: Failed to create WebGL program');}this.program=program;}},{key:"setupPositionAttribute",value:function setupPositionAttribute(){var buffers=setupFullscreenQuad(this.gl,this.program);if(!buffers){throw new Error('RzpGlass: Failed to setup fullscreen quad');}}},{key:"setupUniformLocations",value:function setupUniformLocations(){var gl=this.gl;var program=this.program;var uniformNames=['uTime','iResolution','uDpr','uVideoTexture','uGradientMap','uGradientMap2','uGradientMapBlend','uCenterGradientMap','uEnableDisplacement','uEnableColorama','uEnableBloom','uEnableLightSweep','uInputMin','uInputMax','uModifyGamma','uPosterizeLevels','uCycleRepetitions','uPhaseShift','uCycleSpeed','uWrapMode','uReverse','uBlendWithOriginal','uLightIntensity','uFrameCount','uLightStartFrame','uNumSegments','uSlitAngle','uDisplacementX','uDisplacementY','uEnableCenterElement','uCenterAnimDuration','uCenterAnimTime','uCCBlackPoint','uCCWhitePoint','uCCMidtoneGamma','uCCGamma','uCCContrast','uZoom','uPan','uEdgeFeather','uRefResolution','uVisibleUvBounds','uBackgroundColor','uEnableRippleWave','uRippleSpeed','uRippleBlend','uRippleAngularPower','uRippleRadialFalloff','uRippleWaitTime'];for(var name of uniformNames){this.uniformLocations[name]=gl.getUniformLocation(program,name);}}},{key:"setupVideoTexture",value:function setupVideoTexture(){var _this2=this;this.videoTexture=new Texture(this.gl,{textureUnit:0});if(this.video&&'requestVideoFrameCallback'in this.video){var _updateVideoFrame=function updateVideoFrame(){if(_this2.hasBeenDisposed||!_this2.video||!_this2.videoTexture)return;_this2.videoTexture.update(_this2.video);_this2.videoFrameCallbackId=_this2.video.requestVideoFrameCallback(_updateVideoFrame);};this.videoFrameCallbackId=this.video.requestVideoFrameCallback(_updateVideoFrame);}}},{key:"setupImageTexture",value:function setupImageTexture(uniformName,image,textureUnit){var texture=new Texture(this.gl,{textureUnit:textureUnit});texture.image(image);if(uniformName==='uVideoTexture'){this.videoTexture=texture;}else if(uniformName==='uGradientMap'){this.gradientMapTexture=texture;}else if(uniformName==='uGradientMap2'){this.gradientMap2Texture=texture;}else if(uniformName==='uCenterGradientMap'){this.centerGradientMapTexture=texture;}}},{key:"updateGradientMapTexture",value:function updateGradientMapTexture(source){if(!this.isInitialized||!this.gradientMapTexture)return;this.gradientMapTexture.image(source);}},{key:"setupResizeObserver",value:function setupResizeObserver(){var _this3=this;this.resizeObserver=new ResizeObserver(function(_ref){var _ref2=_slicedToArray(_ref,1),entry=_ref2[0];if(entry!=null&&entry.borderBoxSize[0]){var _entry$devicePixelCon;var physicalPixelSize=(_entry$devicePixelCon=entry.devicePixelContentBoxSize)==null?void 0:_entry$devicePixelCon[0];if(physicalPixelSize!==undefined){_this3.devicePixelsSupported=true;_this3.parentDevicePixelWidth=physicalPixelSize.inlineSize;_this3.parentDevicePixelHeight=physicalPixelSize.blockSize;}_this3.parentWidth=entry.borderBoxSize[0].inlineSize;_this3.parentHeight=entry.borderBoxSize[0].blockSize;}_this3.handleResize();});this.resizeObserver.observe(this.parentElement);}},{key:"setAllUniforms",value:function setAllUniforms(){var gl=this.gl;gl.useProgram(this.program);gl.uniform1i(this.uniformLocations.uVideoTexture,0);gl.uniform1i(this.uniformLocations.uGradientMap,1);gl.uniform1i(this.uniformLocations.uCenterGradientMap,2);gl.uniform1i(this.uniformLocations.uGradientMap2,3);gl.uniform1f(this.uniformLocations.uGradientMapBlend,this.currentGradientMapBlend);this.setUniformValues(this.config);gl.uniform2f(this.uniformLocations.uPan,this.config.panX,this.config.panY);gl.uniform2f(this.uniformLocations.uRefResolution,REF_RESOLUTION.width,REF_RESOLUTION.height);if(this.config.backgroundColor){var _this$config$backgrou=_slicedToArray(this.config.backgroundColor,3),r=_this$config$backgrou[0],g=_this$config$backgrou[1],b=_this$config$backgrou[2];gl.uniform3f(this.uniformLocations.uBackgroundColor,r,g,b);gl.clearColor(r,g,b,1.0);}else {gl.uniform3f(this.uniformLocations.uBackgroundColor,-1.0,-1.0,-1.0);gl.clearColor(0,0,0,0);}gl.uniform4f(this.uniformLocations.uVisibleUvBounds,this.visibleUvBounds[0],this.visibleUvBounds[1],this.visibleUvBounds[2],this.visibleUvBounds[3]);}},{key:"areUniformValuesEqual",value:function areUniformValuesEqual(a,b){var _this4=this;if(a===b)return true;if(Array.isArray(a)&&Array.isArray(b)&&a.length===b.length){return a.every(function(val,i){return _this4.areUniformValuesEqual(val,b[i]);});}return false;}},{key:"setUniformValues",value:function setUniformValues(config){var _this5=this;var gl=this.gl;gl.useProgram(this.program);Object.entries(config).forEach(function(_ref3){var _ref4=_slicedToArray(_ref3,2),key=_ref4[0],value=_ref4[1];if(value===undefined)return;if(_this5.areUniformValuesEqual(_this5.uniformCache[key],value))return;_this5.uniformCache[key]=value;var uniformName=CONFIG_TO_UNIFORM[key];if(!uniformName)return;var location=_this5.uniformLocations[uniformName];if(!location)return;if(typeof value==='boolean'){gl.uniform1f(location,value?1:0);}else if(typeof value==='number'){gl.uniform1f(location,value);}else if(Array.isArray(value)){var flatArray=value.flat();switch(flatArray.length){case 2:gl.uniform2fv(location,flatArray);break;case 3:gl.uniform3fv(location,flatArray);break;case 4:gl.uniform4fv(location,flatArray);break;}}});if(config.panX!==undefined||config.panY!==undefined){var panCacheKey='pan';var panValue=[this.config.panX,this.config.panY];if(!this.areUniformValuesEqual(this.uniformCache[panCacheKey],panValue)){this.uniformCache[panCacheKey]=panValue;gl.uniform2f(this.uniformLocations.uPan,panValue[0],panValue[1]);}}if(config.backgroundColor!==undefined){var bgCacheKey='backgroundColor';if(!this.areUniformValuesEqual(this.uniformCache[bgCacheKey],config.backgroundColor)){this.uniformCache[bgCacheKey]=config.backgroundColor;if(config.backgroundColor){var _config$backgroundCol=_slicedToArray(config.backgroundColor,3),r=_config$backgroundCol[0],g=_config$backgroundCol[1],b=_config$backgroundCol[2];gl.uniform3f(this.uniformLocations.uBackgroundColor,r,g,b);gl.clearColor(r,g,b,1.0);}else {gl.uniform3f(this.uniformLocations.uBackgroundColor,-1.0,-1.0,-1.0);gl.clearColor(0,0,0,0);}}}}},{key:"setUniforms",value:function setUniforms(newConfig){this.config=Object.assign({},this.config,newConfig);if(!this.isInitialized)return;this.setUniformValues(newConfig);if(newConfig.paused!==undefined){if(newConfig.paused){var _this$video3;(_this$video3=this.video)==null?void 0:_this$video3.pause();}else {var _this$video4;(_this$video4=this.video)==null?void 0:_this$video4.play().catch(function(){});}}if(newConfig.playbackRate!==undefined&&this.video){this.video.playbackRate=newConfig.playbackRate;}if(newConfig.aspectRatio!==undefined){this.handleResize();}}},{key:"startRenderLoop",value:function startRenderLoop(){if(this.rafId!==null)return;this.lastRenderTime=performance.now()*0.001;this.rafId=requestAnimationFrame(this.render);}},{key:"stopRenderLoop",value:function stopRenderLoop(){if(this.rafId!==null){cancelAnimationFrame(this.rafId);this.rafId=null;}}},{key:"getCurrentFrame",value:function getCurrentFrame(){return this.currentFrame;}},{key:"setFrame",value:function setFrame(newFrame){this.currentFrame=newFrame;}},{key:"setMaxPixelCount",value:function setMaxPixelCount(){var newMaxPixelCount=arguments.length>0&&arguments[0]!==undefined?arguments[0]:DEFAULT_MAX_PIXEL_COUNT;this.maxPixelCount=newMaxPixelCount;this.handleResize();}},{key:"setMinPixelRatio",value:function setMinPixelRatio(){var newMinPixelRatio=arguments.length>0&&arguments[0]!==undefined?arguments[0]:2;this.minPixelRatio=newMinPixelRatio;this.handleResize();}},{key:"play",value:function play(){var _this$video5;this.config.paused=false;(_this$video5=this.video)==null?void 0:_this$video5.play().catch(function(){});}},{key:"pause",value:function pause(){var _this$video6;this.config.paused=true;(_this$video6=this.video)==null?void 0:_this$video6.pause();}},{key:"setTime",value:function setTime(time){if(this.video){this.video.currentTime=time;}}},{key:"dispose",value:function dispose(){var _this$performanceCont2,_visualViewport3;this.hasBeenDisposed=true;if(this.rafId!==null){cancelAnimationFrame(this.rafId);this.rafId=null;}if(this.videoFrameCallbackId!==null&&this.video&&'cancelVideoFrameCallback'in this.video){this.video.cancelVideoFrameCallback(this.videoFrameCallbackId);}if(this.video){this.video.pause();this.video.src='';this.video.load();this.video=null;}if(this.gl&&this.program){var _this$videoTexture,_this$gradientMapText,_this$gradientMap2Tex,_this$centerGradientM;(_this$videoTexture=this.videoTexture)==null?void 0:_this$videoTexture.destroy();(_this$gradientMapText=this.gradientMapTexture)==null?void 0:_this$gradientMapText.destroy();(_this$gradientMap2Tex=this.gradientMap2Texture)==null?void 0:_this$gradientMap2Tex.destroy();(_this$centerGradientM=this.centerGradientMapTexture)==null?void 0:_this$centerGradientM.destroy();this.gl.deleteProgram(this.program);this.program=null;this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null);this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null);this.gl.bindRenderbuffer(this.gl.RENDERBUFFER,null);this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,null);this.gl.getError();}(_this$performanceCont2=this.performanceController)==null?void 0:_this$performanceCont2.dispose();this.performanceController=null;if(this.resizeObserver){this.resizeObserver.disconnect();this.resizeObserver=null;}(_visualViewport3=visualViewport)==null?void 0:_visualViewport3.removeEventListener('resize',this.handleVisualViewportChange);document.removeEventListener('visibilitychange',this.handleDocumentVisibilityChange);this.uniformLocations={};this.uniformCache={};this.canvasElement.remove();this.parentElement.removeAttribute('data-rzp-glass');}}]);}();
26
26
 
27
27
  export { RzpGlassMount };
28
28
  //# sourceMappingURL=RzpGlassMount.js.map