{"version":3,"file":"BackButton.BfL6TOP2.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/c2BlJ7lBKkWsufN85ALQ/H8E4AqNqhpG7z1cwyfbI/controls.js","https:/framerusercontent.com/modules/YYWrpHru0A7XBqPnlp2y/aeLikHiIiUGbLPkODvgW/BackButton.js"],"sourcesContent":["import{ControlType}from\"framer\";import{BUTTON_STYLE_GROUP}from\"https://framerusercontent.com/modules/9i2Alm7tGoDSsKzk9kk3/9Y1RthbcC9dcPnTigB3t/buttonStyleGroup.js\";export const BACK_BUTTON_CONTROLS={icon:{type:ControlType.ComponentInstance,title:\"Icon\"},iconPosition:{type:ControlType.Enum,title:\"Icon Position\",options:[\"left\",\"right\"],optionTitles:[\"Left\",\"Right\"],defaultValue:\"left\"},iconGap:{type:ControlType.Number,title:\"Icon Gap\",defaultValue:8,min:0,max:40,displayStepper:true},label:{type:ControlType.String,title:\"Label\",defaultValue:\"Back\"},disableWhenNoHistory:{type:ControlType.Boolean,title:\"Disable if no history\",defaultValue:false},...BUTTON_STYLE_GROUP};\nexport const __FramerMetadata__ = {\"exports\":{\"BACK_BUTTON_CONTROLS\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./controls.map","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,isValidElement,useRef,useLayoutEffect}from\"react\";import{addPropertyControls}from\"framer\";import{resolveButtonStyles}from\"https://framerusercontent.com/modules/2nm11oCJ9YbIAtty0hAj/yWPmlHEIysfpBb7BPDqb/resolveButtonStyles.js\";import{useStepHistory}from\"https://framerusercontent.com/modules/wm78KsU1IYJJVRPxnalG/7zJiE09qHzT3tvBf6zOQ/stepStores.js\";import{track}from\"https://framerusercontent.com/modules/KHQRbo1PS40kxEtlsBHj/eAgZx6F6skeVRSwyjPMA/analytics.js\";import{BACK_BUTTON_CONTROLS}from\"https://framerusercontent.com/modules/c2BlJ7lBKkWsufN85ALQ/H8E4AqNqhpG7z1cwyfbI/controls.js\";export function BackButton({label=\"Back\",styles={},disableWhenNoHistory=false,icon,iconPosition=\"left\",iconGap=8,fontFamily=\"Figtree, system-ui, sans-serif\",textTransform=\"none\"}){const{goToPreviousStep,currentHistory,currentStep}=useStepHistory();const[isHovered,setHovered]=useState(false);const[isPressed,setPressed]=useState(false);const[isFocused,setFocused]=useState(false);const iconRef=useRef(null);const[measuredIconWidth,setMeasuredIconWidth]=useState(0);const canGoBack=Array.isArray(currentHistory)?currentHistory.length>1:true;const disabled=disableWhenNoHistory?!canGoBack:false;const r=resolveButtonStyles(styles);const style=r.buildStyle({disabled,hover:isHovered,press:isPressed,focus:isFocused});// Measure icon width and update padding so the button's width/minWidth accounts for the icon\nuseLayoutEffect(()=>{const el=iconRef.current;if(!el){setMeasuredIconWidth(0);return;}const update=()=>setMeasuredIconWidth(Math.ceil(el.getBoundingClientRect().width));update();// Use ResizeObserver when available to track icon resizing in canvas/preview\nlet ro=null;if(typeof ResizeObserver!==\"undefined\"){ro=new ResizeObserver(()=>update());try{ro.observe(el);}catch{// ignore\n}}return()=>{if(ro&&el)ro.unobserve(el);};},[icon,iconPosition,iconGap]);const handleBack=e=>{e.preventDefault();if(disabled)return;track(\"back_click\",{from_step:currentStep??null});goToPreviousStep?.();};const renderIcon=candidate=>{if(!candidate)return null;try{if(/*#__PURE__*/isValidElement(candidate))return candidate;}catch(err){// isValidElement can throw for strange values; swallow and try other heuristics\n}if(typeof candidate===\"object\"){return /*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-flex\",alignItems:\"center\"},children:candidate});}if(typeof candidate===\"function\"){try{const Comp=candidate;return /*#__PURE__*/_jsx(Comp,{});}catch(err){console.warn(\"BackButton: icon function failed to render\",err);return null;}}console.warn(\"BackButton: unsupported icon type\",candidate);return null;};return /*#__PURE__*/_jsxs(\"button\",{type:\"button\",disabled:disabled,style:{...style,fontFamily,textTransform:textTransform,// let resolved style tokens drive most visuals\nboxShadow:r.tokens.effects.shadow,transition:style.transition,minHeight:r.tokens.spacing.height,boxSizing:\"border-box\",position:\"relative\",// reserve space for absolute icons so min-width includes them\npaddingLeft:icon&&iconPosition===\"left\"?`${r.tokens.spacing.paddingH+measuredIconWidth+iconGap}px`:undefined,paddingRight:icon&&iconPosition===\"right\"?`${r.tokens.spacing.paddingH+measuredIconWidth+iconGap}px`:undefined},onMouseEnter:()=>setHovered(true),onMouseLeave:()=>setHovered(false),onMouseDown:()=>setPressed(true),onMouseUp:()=>setPressed(false),onFocus:()=>setFocused(true),onBlur:()=>setFocused(false),onClick:handleBack,children:[icon&&iconPosition===\"left\"?/*#__PURE__*/_jsx(\"span\",{ref:iconRef,style:{position:\"absolute\",left:iconGap,top:\"50%\",transform:\"translateY(-50%)\",display:\"inline-flex\",alignItems:\"center\"},children:renderIcon(icon)}):null,/*#__PURE__*/_jsx(\"span\",{style:{display:\"inline-flex\",alignItems:\"center\"},children:label}),icon&&iconPosition===\"right\"?/*#__PURE__*/_jsx(\"span\",{ref:iconRef,style:{position:\"absolute\",right:iconGap,top:\"50%\",transform:\"translateY(-50%)\",display:\"inline-flex\",alignItems:\"center\"},children:renderIcon(icon)}):null]});}// Framer type limitation\naddPropertyControls(BackButton,BACK_BUTTON_CONTROLS);\nexport const __FramerMetadata__ = {\"exports\":{\"BackButton\":{\"type\":\"reactComponent\",\"name\":\"BackButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"BackButtonProps\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"gUAAgC,IAAoI,CAAa,EAAqB,CAAC,KAAK,CAAC,KAAK,EAAY,kBAAkB,MAAM,OAAO,CAAC,aAAa,CAAC,KAAK,EAAY,KAAK,MAAM,gBAAgB,QAAQ,CAAC,OAAO,QAAQ,CAAC,aAAa,CAAC,OAAO,QAAQ,CAAC,aAAa,OAAO,CAAC,QAAQ,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