{"version":3,"file":"SimulatorButton.CZMo2ESv.mjs","names":["React.useMemo","React.useState"],"sources":["https:/framerusercontent.com/modules/6yTW9nDSqM7wcBWAdnDT/6phmqsWKtXsU8I67rMUl/useSimulatorURL.js","https:/framerusercontent.com/modules/U2lAUE0fUmM5i5Qeu1dk/g8wshyiH39nPxEOB1LAs/SimulatorButton.js"],"sourcesContent":["import*as React from\"react\";export function useSimulatorURL({destinyURL,staticURL,extraParams,credit}){return React.useMemo(()=>{if(typeof window===\"undefined\")return\"https://simulador.klubi.com.br\";const currentUrl=new URL(window.location.href);const parts=currentUrl.pathname.split(\"/\").filter(Boolean);const rawHost=currentUrl.hostname.replace(/^www\\./,\"\");const HOST_ALIAS={\"parceria.theklubi.com\":\"parceria.klubi.com.br\",\"theklubi.com\":\"klubi.com.br\",\"parceria.framer.website\":\"parceria.klubi.com.br\",\"klubi.framer.website\":\"klubi.com.br\"};const host=HOST_ALIAS[rawHost]??rawHost;const last=arr=>arr.length?arr[arr.length-1]:\"\";const secondLast=arr=>arr.length>=2?arr[arr.length-2]:\"\";let parceiro=\"\";let categoria=\"\";if(host===\"parceria.klubi.com.br\"){parceiro=last(parts);categoria=secondLast(parts);}else if(host===\"klubi.com.br\"){parceiro=\"klubi\";categoria=last(parts);}else{parceiro=\"klubi\";categoria=last(parts);}if(staticURL&&staticURL!==\"none\"){categoria=staticURL;}if(parceiro.endsWith(\"-simulador\")){parceiro=parceiro.replace(/-simulador$/,\"\");}if(!parceiro||!categoria)return\"https://simulador.klubi.com.br\";const params=new URLSearchParams(currentUrl.search);if(destinyURL!==\"consorcio\"){params.set(\"credito\",String(credit??1e4));}else{params.delete(\"credito\");}if(extraParams?.trim()){const cleaned=extraParams.trim().replace(/^\\?/,\"\");new URLSearchParams(cleaned).forEach((v,k)=>params.set(k,v));}const qs=params.toString();switch(destinyURL){case\"consorcio\":return`https://consorcio.klubi.com.br/${categoria}/selecao-credito?parceiro=${parceiro}&${qs}`;case\"compraplanejada\":return`https://simulador.klubi.com.br/klubi/${categoria}`;case\"seguro\":return`https://simulador.klubi.com.br/${parceiro}/seguro?${qs}`;case\"simulador\":default:return`https://simulador.klubi.com.br/${parceiro}/${categoria}?${qs}`;}},[destinyURL,staticURL,extraParams,credit]);}\nexport const __FramerMetadata__ = {\"exports\":{\"useSimulatorURL\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./useSimulatorURL.map","// @framerSupportedLayoutWidth any\n// @framerSupportedLayoutHeight fixed\nimport{jsx as _jsx}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,useTracking}from\"framer\";import{useCreditStore}from\"https://framerusercontent.com/modules/SwnDQm82Xt81SD83IHNA/Dn3v2txfpz3cdB4m0R8o/CreditStore.js\";import{useSimulatorURL}from\"https://framerusercontent.com/modules/6yTW9nDSqM7wcBWAdnDT/6phmqsWKtXsU8I67rMUl/useSimulatorURL.js\";export default function SimulatorButton(props){const{text,tracking,destinyURL,staticURL,extraParams,buttonHeight,padding,radius,textSize,background,content,stroke,border,backgroundHover,contentHover,borderHover,backgroundPressed,contentPressed,borderPressed,pressedScale,style}=props;const track=useTracking();const[hover,setHover]=React.useState(false);const[pressed,setPressed]=React.useState(false);let credit=1e4;try{const storeTuple=useCreditStore?.();const store=Array.isArray(storeTuple)?storeTuple[0]:storeTuple;if(store&&typeof store.credit!==\"undefined\")credit=Number(store.credit)||1e4;}catch(e){credit=1e4;}const targetUrl=useSimulatorURL({destinyURL,staticURL,extraParams,credit});const isHover=hover&&!pressed;const currentBackground=pressed?backgroundPressed:isHover?backgroundHover:background;const currentColor=pressed?contentPressed:isHover?contentHover:content;const currentBorderColor=pressed?borderPressed:isHover?borderHover:border;const currentScale=pressed?pressedScale:1;function handleClick(){track(tracking||\"simulador\");if(typeof window!==\"undefined\")window.location.href=targetUrl;}return /*#__PURE__*/_jsx(\"div\",{style:{...style,height:buttonHeight,minHeight:buttonHeight,maxHeight:buttonHeight,width:style?.width??\"100%\",display:\"block\"},children:/*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:handleClick,onMouseEnter:()=>setHover(true),onMouseLeave:()=>{setHover(false);setPressed(false);},onMouseDown:()=>setPressed(true),onMouseUp:()=>setPressed(false),onTouchStart:()=>setPressed(true),onTouchEnd:()=>setPressed(false),style:{width:\"100%\",height:\"100%\",background:currentBackground,color:currentColor,border:`${stroke}px solid ${currentBorderColor}`,fontSize:textSize,fontWeight:600,fontFamily:\"Red Hat Display, sans-serif\",lineHeight:\"1.15rem\",padding:`0 ${padding}px`,borderRadius:radius,cursor:\"pointer\",outline:\"none\",appearance:\"none\",boxSizing:\"border-box\",userSelect:\"none\",transform:`scale(${currentScale})`,transition:\"background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.08s ease\"},children:text})});}addPropertyControls(SimulatorButton,{destinyURL:{type:ControlType.Enum,title:\"destinyURL\",options:[\"simulador\",\"seguro\",\"consorcio\",\"compraplanejada\"],optionTitles:[\"simulador\",\"seguro\",\"consorcio\",\"compraplanejada\"],defaultValue:\"simulador\"},staticURL:{type:ControlType.Enum,title:\"staticURL\",options:[\"none\",\"auto\",\"celular\",\"cnh\",\"computador\",\"games\",\"imovel\",\"moto\",\"pesado\",\"viagem\"],optionTitles:[\"none\",\"auto\",\"celular\",\"cnh\",\"computador\",\"games\",\"imovel\",\"moto\",\"pesado\",\"viagem\"],defaultValue:\"none\"},buttonHeight:{type:ControlType.Number,title:\"height\",defaultValue:48,min:24,max:64,unit:\"px\"},pressedScale:{type:ControlType.Number,title:\"pressedScale\",defaultValue:.98,min:.9,max:1,step:.01},padding:{type:ControlType.Number,title:\"padding\",defaultValue:20,min:8,max:80,unit:\"px\"},radius:{type:ControlType.Number,title:\"radius\",defaultValue:20,min:4,max:40},background:{type:ControlType.Color,title:\"background\",defaultValue:\"#FFB73F\"},backgroundHover:{type:ControlType.Color,title:\"backgroundHover\",defaultValue:\"#FFC360\"},backgroundPressed:{type:ControlType.Color,title:\"backgroundPressed\",defaultValue:\"#FFCF81\"},textSize:{type:ControlType.Number,title:\"textSize\",defaultValue:14,min:10,max:18},text:{type:ControlType.String,title:\"text\",defaultValue:\"Simular agora\"},extraParams:{type:ControlType.String,title:\"extraParams\",defaultValue:\"\"},tracking:{type:ControlType.String,title:\"tracking\",defaultValue:\"simulador\"},content:{type:ControlType.Color,title:\"content\",defaultValue:\"#1A1000\"},contentHover:{type:ControlType.Color,title:\"contentHover\",defaultValue:\"#1A1000\"},contentPressed:{type:ControlType.Color,title:\"contentPressed\",defaultValue:\"#1A1000\"},stroke:{type:ControlType.Number,title:\"stroke\",defaultValue:1,min:0,max:4,unit:\"px\"},border:{type:ControlType.Color,title:\"border\",defaultValue:\"#FFB73F\"},borderHover:{type:ControlType.Color,title:\"borderHover\",defaultValue:\"#FFB73F\"},borderPressed:{type:ControlType.Color,title:\"borderPressed\",defaultValue:\"#FFB73F\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"SimulatorButton\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SimulatorButton.map"],"mappings":"8PAA4B,SAAgB,EAAgB,CAAC,aAAW,YAAU,cAAY,UAAQ,CAAC,OAAOA,MAAkB,CAAC,GAAU,IAAS,OAAY,MAAM,iCAAiC,IAAM,EAAW,IAAI,IAAI,EAAO,SAAS,KAAK,CAAO,EAAM,EAAW,SAAS,MAAM,IAAI,CAAC,OAAO,QAAQ,CAAO,EAAQ,EAAW,SAAS,QAAQ,SAAS,GAAG,CAAgM,EAA9K,CAAC,wBAAwB,wBAAwB,eAAe,eAAe,0BAA0B,wBAAwB,uBAAuB,eAAe,CAAuB,IAAU,EAAc,EAAK,GAAK,EAAI,OAAO,EAAI,EAAI,OAAO,GAAG,GAAS,EAAW,GAAK,EAAI,QAAQ,EAAE,EAAI,EAAI,OAA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