{"version":3,"file":"Rive.Dmi78ZPy.mjs","names":["useMemo","useStateMachineInput","Rive","useRive","useRef"],"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":"2WAGG,SAAS,EAAc,EAAK,EAAc,EAAW,CAAkK,OAA9IA,MAAY,CAAC,GAAG,CAAC,OAAO,KAAK,MAAM,GAAY,KAAK,OAAQ,EAAM,CAAkD,OAAjD,QAAQ,MAAM,4BAA4B,EAAM,CAAO,EAAE,GAAI,CAAC,EAAW,CAAC,CAAqB,IAAI,GAAQ,CAAC,IAAM,EAAQC,EAAqB,EAAK,EAAc,EAAO,KAAK,EAAO,OAAO,UAAU,GAAK,EAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAO,UAAQ,EAAG,CAKjY,SAAwB,EAAW,EAAM,CAAC,GAAK,CAAC,MAAI,WAAS,gBAAc,WAAS,MAAI,YAAU,OAAK,eAAa,mBAAiB,aAAW,wBAAsB,EAAY,EAAOD,MAAY,IAAIE,EAAK,OAAO,CAAC,MAAI,YAAU,CAAC,CAAC,CAAC,EAAI,EAAU,CAAC,CAAM,CAAC,OAAK,iBAAeC,EAAQ,CAAC,MAAI,WAAS,gBAAc,WAAS,SAA4B,uBAAqB,CAAC,CAAO,EAAO,EAAc,EAAK,EAAc,EAAW,CAAO,EAAcC,EAAO,EAAO,CAGnZ,OAHoZ,MAAc,CAAI,GAAM,EAAO,QAAQ,EAAO,SAAS,EAAM,IAAQ,CAAC,GAAG,EAAM,QAAQ,CAAC,IAAM,EAAU,EAAc,QAAQ,GAAU,EAAM,OAAO,WAAW,EAAM,QAAQ,CAAC,GAAW,CAAC,EAAU,OAAQ,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