{"version":3,"file":"GoBackButton.BkOpVyWD.mjs","names":["React.useState","React.useRef","React.useCallback"],"sources":["https:/framerusercontent.com/modules/RwIW3a4QNVo4ULMUrWyz/0hM44QFIt3dZyr5OOEse/GoBackButton.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{startTransition}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";/**\n * User instructions:\n * \"please do this component so when pressing on it it goes one step back no mather what the entry point was\"\n *//**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function GoBackButton(props){const{label,fallbackUrl,enabled,background,textColor,borderColor,radius,padding,font,style}=props;const isStatic=RenderTarget.current()===RenderTarget.canvas||RenderTarget.current()===RenderTarget.thumbnail;const[isFocused,setIsFocused]=React.useState(false);const[isPressed,setIsPressed]=React.useState(false);const hadKeyboardEventRef=React.useRef(false);const onActivate=React.useCallback(()=>{if(!enabled)return;if(typeof window===\"undefined\")return;const getNavWindow=()=>{// In some Framer preview/canvas contexts the component can be rendered in an iframe.\n// Prefer navigating the top-level browsing context when it's accessible (same-origin).\ntry{if(window.top&&window.top!==window){// Touching location.href can throw on cross-origin frames.\nvoid window.top.location.href;return window.top;}}catch{}try{if(window.parent&&window.parent!==window){void window.parent.location.href;return window.parent;}}catch{}return window;};const navWindow=getNavWindow();try{// Most reliable: back() uses the current browsing context history stack.\nnavWindow.history.back();// Best-effort fallback only when there is no history entry to go back to.\nif(navWindow.history.length<=1){const referrer=typeof document!==\"undefined\"?document.referrer:\"\";if(referrer){navWindow.location.assign(referrer);return;}if(fallbackUrl)navWindow.location.assign(fallbackUrl);}}catch{try{const referrer=typeof document!==\"undefined\"?document.referrer:\"\";if(referrer){window.location.assign(referrer);return;}}catch{}if(fallbackUrl){try{window.location.assign(fallbackUrl);}catch{}}}},[enabled,fallbackUrl]);const onKeyDown=React.useCallback(e=>{if(!enabled)return;if(e.key===\"Tab\")hadKeyboardEventRef.current=true;if(e.key===\"Enter\"||e.key===\" \"){e.preventDefault();startTransition(()=>setIsPressed(true));onActivate();}},[enabled,onActivate]);const onKeyUp=React.useCallback(e=>{if(e.key===\"Enter\"||e.key===\" \"){startTransition(()=>setIsPressed(false));}},[]);const onFocus=React.useCallback(()=>{startTransition(()=>setIsFocused(!!hadKeyboardEventRef.current));},[]);const onBlur=React.useCallback(()=>{startTransition(()=>setIsFocused(false));},[]);return /*#__PURE__*/_jsxs(\"button\",{type:\"button\",\"aria-label\":label,disabled:!enabled,onClick:isStatic?undefined:onActivate,onKeyDown:isStatic?undefined:onKeyDown,onKeyUp:isStatic?undefined:onKeyUp,onPointerDown:isStatic?undefined:()=>{if(!enabled)return;hadKeyboardEventRef.current=false;startTransition(()=>setIsPressed(true));},onPointerUp:isStatic?undefined:()=>{startTransition(()=>setIsPressed(false));},onPointerCancel:isStatic?undefined:()=>{startTransition(()=>setIsPressed(false));},onPointerLeave:isStatic?undefined:()=>{startTransition(()=>setIsPressed(false));},onFocus:isStatic?undefined:onFocus,onBlur:isStatic?undefined:onBlur,style:{position:\"relative\",width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",gap:8,appearance:\"none\",WebkitTapHighlightColor:\"transparent\",border:\"none\",background,color:textColor,borderRadius:radius,padding,cursor:enabled?\"pointer\":\"not-allowed\",userSelect:\"none\",outline:isFocused?`2px solid ${textColor}`:\"none\",outlineOffset:2,transform:enabled&&isPressed?\"scale(0.98)\":\"scale(1)\",filter:enabled&&isPressed?\"brightness(0.95)\":\"none\",transition:\"transform 0.08s ease, filter 0.08s ease\",...font,...style},children:[/*#__PURE__*/_jsx(\"svg\",{width:\"16\",height:\"16\",viewBox:\"0 0 24 24\",fill:\"none\",xmlns:\"http://www.w3.org/2000/svg\",\"aria-hidden\":\"true\",focusable:\"false\",style:{flex:\"0 0 auto\",pointerEvents:\"none\"},children:/*#__PURE__*/_jsx(\"path\",{d:\"M15 18L9 12L15 6\",stroke:\"currentColor\",strokeWidth:\"2\",strokeLinecap:\"round\",strokeLinejoin:\"round\"})}),/*#__PURE__*/_jsx(\"span\",{style:{minWidth:\"max-content\",pointerEvents:\"none\"},children:label})]});}addPropertyControls(GoBackButton,{label:{type:ControlType.String,title:\"Label\",defaultValue:\"Back\"},enabled:{type:ControlType.Boolean,title:\"Enabled\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},fallbackUrl:{type:ControlType.Link,title:\"Fallback URL\",description:\"Optional. Used only when there is no previous browser history entry (e.g. opened directly).\",defaultValue:\"\"},background:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#000000\"},borderColor:{type:ControlType.Color,title:\"Border\",defaultValue:\"#EEEEEE\"},radius:{type:ControlType.BorderRadius,title:\"Radius\",defaultValue:\"12px\"},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"10px 14px\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"14px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"GoBackButton\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GoBackButton.map"],"mappings":"2NAMG,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,QAAM,cAAY,UAAQ,aAAW,YAAU,cAAY,SAAO,UAAQ,OAAK,SAAO,EAAY,EAAS,EAAa,SAAS,GAAG,EAAa,QAAQ,EAAa,SAAS,GAAG,EAAa,UAAe,CAAC,EAAU,GAAcA,EAAe,GAAM,CAAM,CAAC,EAAU,GAAcA,EAAe,GAAM,CAA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