{"version":3,"file":"Rive.CMmdylPy.mjs","names":["useMemo","useStateMachineInput","Rive","useRive","useRef","__esmMin","de","init_npm_react_18_3_1","ce","c","init_jsx_runtime","pe","addPropertyControls","RenderTarget","init_framer_CN96F41L","ControlType","init_dist","L","a","H","useRiveInputs","inputsJSON","error","handler","rive","stateMachines","config","RivePlayer","props","layout","fit","alignment","inputs","prevInputsRef","input","prevInput","index","handleEvent","event","onEventTriggered","playOnCanvas","play","RiveComponent","init_Rive"],"sources":["https:/framerusercontent.com/modules/mbFPzZYTzIhSrigRSb6s/WlnJOre1X3CDSYtVS4Dk/Rive.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useMemo,useRef}from\"react\";import Rive,{useRive,useStateMachineInput}from\"@rive-app/react-canvas\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * Version 0.0.1\n * - Initial release\n */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 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(props){const{src,artboard,stateMachines,autoplay,fit,alignment,play,playOnCanvas,onEventTriggered,inputsJSON,isTouchScrollEnabled}=props;const layout=useMemo(()=>new Rive.Layout({fit,alignment}),[fit,alignment]);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]);// Handle Rive events\nuseEffect(()=>{if(rive){const handleEvent=event=>{console.log(\"Rive event triggered:\",event);if(onEventTriggered){onEventTriggered(event.data);console.log(\"Event data:\",event.data);}};rive.on(\"riveevent\",handleEvent);return()=>{rive.off(\"riveevent\",handleEvent);};}},[rive,onEventTriggered]);// Control playback\nuseEffect(()=>{if(rive){const shouldPlay=RenderTarget.current()===RenderTarget.canvas?playOnCanvas:play;shouldPlay?rive.play():rive.pause();}},[rive,play,playOnCanvas]);// Update layout\nuseEffect(()=>{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,{src:{title:\"Source\",type:ControlType.String},artboard:{title:\"Artboard\",type:ControlType.String},stateMachines:{title:\"State Machines\",type:ControlType.String},autoplay:{title:\"Autoplay\",type:ControlType.Boolean,hidden:()=>true},isTouchScrollEnabled:{title:\"Touch Screen Enabled\",type:ControlType.Boolean},fit:{title:\"Fit\",type:ControlType.Enum,options:[\"contain\",\"cover\",\"fill\",\"fitWidth\",\"fitHeight\",\"none\",\"scaleDown\"],optionTitles:[\"Contain\",\"Cover\",\"Fill\",\"Fit Width\",\"Fit Height\",\"None\",\"Scale Down\"]},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\"]},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.defaultProps={src:\"https://public.rive.app/hosted/63978/135405/cRjq3a7l40ScM-l2peKfBQ.riv\",artboard:\"AB_BG\",stateMachines:\"SM_BG\",autoplay:true,fit:\"cover\",alignment:\"center\",play:true,playOnCanvas:true,onEventTriggered:eventData=>null,inputsJSON:\"[]\",isTouchScrollEnabled:false};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RivePlayer\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Rive.map"],"mappings":"A,6PAGG,SAASoB,EAAc,EAAK,EAAc,EAAW,CAAkK,OAA9IpB,MAAY,CAAC,GAAG,CAAC,OAAO,KAAK,MAAMqB,GAAY,IAAI,CAAE,OAAOC,EAAM,CAAkD,OAAjD,QAAQ,MAAM,4BAA4BA,CAAK,EAAQ,CAAC,CAAE,CAAC,EAAE,CAACD,CAAU,CAAqB,CAAC,CAAC,IAAI,GAAQ,CAAC,IAAME,EAAQtB,EAAqBuB,EAAKC,EAAcC,EAAO,KAAKA,EAAO,OAAO,WAAeA,EAAO,KAAK,EAAE,MAAM,CAAC,GAAGA,EAAO,SAAO,CAAE,CAAC,CAAE,CAKlY,SAAwBC,EAAW,EAAM,CAAC,GAAK,CAAC,MAAI,WAAS,gBAAc,WAAS,MAAI,YAAU,OAAK,eAAa,mBAAiB,aAAW,wBAAsBC,EAAYC,EAAO7B,MAAY,IAAIE,EAAK,OAAO,CAAC,MAAI,WAAS,CAAC,EAAE,CAAC4B,EAAIC,CAAS,CAAC,EAAO,CAAC,OAAK,iBAAe5B,EAAQ,CAAC,MAAI,WAAS,gBAAc,W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