{"version":3,"file":"RivePlayer_vX.C4HHO2DB.mjs","names":["useMemo","useState","rivePackage","riveWebGL","riveCanvas","useRef"],"sources":["https:/framerusercontent.com/modules/FYhRUfK47x1b4scDC0wi/DYdRhLFlH5joWztlcVvB/RivePlayer_vX.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect,useMemo,useRef}from\"react\";import*as riveCanvas from\"@rive-app/react-canvas\";import*as riveWebGL from\"@rive-app/react-webgl2\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";var isRiveRenderer=false;var rivePackage=()=>{if(isRiveRenderer){return riveWebGL;}else{return riveCanvas;}};// Mapping for fit options to Fit enum\nconst getFitValue=fit=>{const Fit=rivePackage().default.Fit;switch(fit){case\"layout\":return Fit.Layout;case\"contain\":return Fit.Contain;case\"cover\":return Fit.Cover;case\"fill\":return Fit.Fill;case\"fitWidth\":return Fit.FitWidth;case\"fitHeight\":return Fit.FitHeight;case\"none\":return Fit.None;case\"scaleDown\":return Fit.ScaleDown;default:return Fit.Contain;}};// Mapping for alignment options to Alignment enum\nconst getAlignmentValue=alignment=>{const Alignment=rivePackage().default.Alignment;switch(alignment){case\"center\":return Alignment.Center;case\"topLeft\":return Alignment.TopLeft;case\"topCenter\":return Alignment.TopCenter;case\"topRight\":return Alignment.TopRight;case\"centerLeft\":return Alignment.CenterLeft;case\"centerRight\":return Alignment.CenterRight;case\"bottomLeft\":return Alignment.BottomLeft;case\"bottomCenter\":return Alignment.BottomCenter;case\"bottomRight\":return Alignment.BottomRight;default:return Alignment.Center;}};function useRiveInputs(rive,stateMachines,inputsJSON){const inputConfigs=useMemo(()=>{try{return JSON.parse(inputsJSON||\"[]\");}catch(error){console.error(\"Error parsing inputsJSON:\",error);return[];}},[inputsJSON]);return inputConfigs.map(config=>{const{useStateMachineInput}=rivePackage();const handler=useStateMachineInput(rive,stateMachines,config.name,config.type===\"Trigger\"?true:config.value);return{...config,handler};});}/**\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerDisableUnlink\n */export default function RivePlayer_vX(props){const{riveRenderer}=props;isRiveRenderer=riveRenderer;const[renderer,setRenderer]=useState(riveRenderer);useEffect(()=>{setRenderer(riveRenderer);},[riveRenderer]);return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\"},children:/*#__PURE__*/_jsx(RivePlayerInternal,{...props,riveRenderer:renderer})},renderer?\"webgl\":\"canvas\");}function RivePlayerInternal(props){const{src,artboard,stateMachines,riveRenderer,autoplay,fit,alignment,play,playOnCanvas,onEventTriggered,inputsJSON,isTouchScrollEnabled,layoutScaleFactor}=props;const rivePackage=useMemo(()=>riveRenderer?riveWebGL:riveCanvas,[riveRenderer]);const{useRive}=rivePackage;const Layout=rivePackage.default.Layout;const layout=useMemo(()=>new Layout({fit:getFitValue(fit),alignment:getAlignmentValue(alignment),...fit===\"layout\"&&{layoutScaleFactor}}),[fit,alignment,layoutScaleFactor]);const{rive,RiveComponent}=useRive({src,artboard,stateMachines,autoplay,layout,isTouchScrollEnabled:isTouchScrollEnabled});const inputs=useRiveInputs(rive,stateMachines,inputsJSON);const prevInputsRef=useRef(inputs);useEffect(()=>{if(rive&&inputs.length){inputs.forEach((input,index)=>{if(input.handler){const prevInput=prevInputsRef.current[index];if(input.type===\"Trigger\"&&input.value&&(!prevInput||!prevInput.value)){input.handler.fire();}else if(input.type!==\"Trigger\"&&\"value\"in input){input.handler.value=input.value;}}});}prevInputsRef.current=inputs;},[rive,inputs]);useEffect(()=>{if(rive){const handleEvent=event=>{// console.log(\"Rive event triggered:\", event)\nif(onEventTriggered){onEventTriggered(event.data);// console.log(\"Event data:\", event.data)\n}};rive.on(\"riveevent\",handleEvent);return()=>{rive.off(\"riveevent\",handleEvent);};}},[rive,onEventTriggered]);useEffect(()=>{if(rive){const shouldPlay=RenderTarget.current()===RenderTarget.canvas?playOnCanvas:play;shouldPlay?rive.play():rive.pause();}},[rive,play,playOnCanvas]);useEffect(()=>{if(rive){rive.layout=layout;}},[rive,layout]);return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\"},children:/*#__PURE__*/_jsx(RiveComponent,{style:{width:\"100%\",height:\"100%\"}})});}// Property controls\naddPropertyControls(RivePlayer_vX,{src:{title:\"Source\",type:ControlType.String},artboard:{title:\"Artboard\",type:ControlType.String},stateMachines:{title:\"State Machines\",type:ControlType.String},riveRenderer:{title:\"Rive Renderer\",type:ControlType.Boolean,hidden:()=>true},autoplay:{title:\"Autoplay\",type:ControlType.Boolean,hidden:()=>true},isTouchScrollEnabled:{title:\"Touch Screen Enabled\",type:ControlType.Boolean},fit:{title:\"Fit\",type:ControlType.Enum,options:[\"layout\",\"contain\",\"cover\",\"fill\",\"fitWidth\",\"fitHeight\",\"none\",\"scaleDown\"],optionTitles:[\"Layout\",\"Contain\",\"Cover\",\"Fill\",\"Fit Width\",\"Fit Height\",\"None\",\"Scale Down\"],defaultValue:\"contain\"},layoutScaleFactor:{title:\"Layout Scale Factor\",type:ControlType.Number,defaultValue:1,min:.25,max:10,displayStepper:true,step:.25,hidden:props=>props.fit!==\"layout\"},alignment:{title:\"Alignment\",type:ControlType.Enum,options:[\"center\",\"topLeft\",\"topCenter\",\"topRight\",\"centerLeft\",\"centerRight\",\"bottomLeft\",\"bottomCenter\",\"bottomRight\"],optionTitles:[\"Center\",\"Top Left\",\"Top Center\",\"Top Right\",\"Center Left\",\"Center Right\",\"Bottom Left\",\"Bottom Center\",\"Bottom Right\"],defaultValue:\"center\"},play:{title:\"Auto-Play\",type:ControlType.Boolean},playOnCanvas:{title:\"Play on Canvas\",type:ControlType.Boolean},onEventTriggered:{type:ControlType.EventHandler},inputsJSON:{title:\"Inputs JSON\",type:ControlType.String,hidden:()=>true}});// Default props\nRivePlayer_vX.defaultProps={src:\"https://public.rive.app/hosted/63978/135405/cRjq3a7l40ScM-l2peKfBQ.riv\",artboard:\"AB_BG\",stateMachines:\"SM_BG\",riveRenderer:false,autoplay:true,fit:\"contain\",alignment:\"center\",play:true,playOnCanvas:true,onEventTriggered:eventData=>null,inputsJSON:\"[]\",isTouchScrollEnabled:false,layoutScaleFactor:1};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RivePlayer_vX\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerDisableUnlink\":\"\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RivePlayer_vX.map"],"mappings":"mZAEkhB,SAAS,EAAc,EAAK,EAAc,EAAW,CAAC,IAAM,EAAaA,MAAY,CAAC,GAAG,CAAC,OAAO,KAAK,MAAM,GAAY,KAAO,OAAM,EAAM,CAAkD,OAAjD,QAAQ,MAAM,4BAA4B,GAAa,EAAE,AAAE,CAAC,EAAC,CAAC,EAAW,EAAE,OAAO,EAAa,IAAI,GAAQ,CAAC,GAAK,CAAC,uBAAqB,CAAC,IAAoB,EAAQ,EAAqB,EAAK,EAAc,EAAO,KAAK,EAAO,OAAO,UAAU,GAAK,EAAO,OAAO,MAAM,CAAC,GAAG,EAAO,UAAQ,AAAE,EAAG,CAK57B,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,eAAa,CAAC,EAAM,EAAe,EAAa,GAAK,CAAC,EAAS,EAAY,CAACC,EAAS,GAAyE,OAA3D,MAAc,CAAC,EAAY,EAAe,EAAC,CAAC,EAAa,EAAsB,EAAK,MAAM,CAAC,MAAM,CAAC,MAAM,OAAO,OAAO,OAAO,CAAC,SAAsB,EAAK,EAAmB,CAAC,GAAG,EAAM,aAAa,EAAS,EAAE,CAAC,EAAS,QAAQ,SAAW,UAAS,EAAmB,EAAM,CAAC,GAAK,CAAC,MAAI,WAAS,gBAAc,eAAa,WAAS,MAAI,YAAU,OAAK,eAAa,mBAAiB,aAAW,uBAAqB,oBAAkB,CAAC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