{"version":3,"file":"SimulatorButton.CxpMWDFI.mjs","names":["useState","React.useState","React.useMemo"],"sources":["https:/framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js","https:/framer.com/m/framer/store.js@^1.0.0","https:/framerusercontent.com/modules/SwnDQm82Xt81SD83IHNA/Dn3v2txfpz3cdB4m0R8o/CreditStore.js","https:/framerusercontent.com/modules/U2lAUE0fUmM5i5Qeu1dk/hBCvSe7eUkmBc1busVsh/SimulatorButton.js"],"sourcesContent":["import{useState,useEffect}from\"react\";import{Data,useObserveData}from\"framer\";export function createStore(state1){// Use Data so that a Preview reload resets the state\nconst dataStore=Data({state:Object.freeze({...state1})});// Create a set function that updates the state\nconst setDataStore=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(dataStore.state);}dataStore.state=Object.freeze({...dataStore.state,...newState});};// Store the initial state, copy the object if it's an object\nlet storeState=typeof state1===\"object\"?Object.freeze({...state1}):state1;// Keep a list of all the listeners, in the form of React hook setters\nconst storeSetters=new Set();// Create a set function that updates all the listeners / setters\nconst setStoreState=newState=>{// If the state is an object, make sure we copy it\nif(typeof newState===\"function\"){newState=newState(storeState);}storeState=typeof newState===\"object\"?Object.freeze({...storeState,...newState}):newState;// Update all the listeners / setters with the new value\nstoreSetters.forEach(setter=>setter(storeState));};// Create the actual hook based on everything above\nfunction useStore(){// Create the hook we are going to use as a listener\nconst[state,setState]=useState(storeState);// If we unmount the component using this hook, we need to remove the listener\n// @ts-ignore\nuseEffect(()=>{// But right now, we need to add the listener\nstoreSetters.add(setState);return()=>storeSetters.delete(setState);},[]);// If Data context exists, use Data, otherwise use vanilla React state\nif(useObserveData()===true){useObserveData();return[dataStore.state,setDataStore];}else{// Return the state and a function to update the central store\nreturn[state,setStoreState];}}return useStore;}\nexport const __FramerMetadata__ = {\"exports\":{\"createStore\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./createStore.map","/*\n * createStore (framer/store@1.0.1)\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/vj7bFUjvEQFgEzNBkdoG/vf3CKm378wlVcBk7IhSU/createStore.js\"\n","import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";export const useCreditStore=createStore({credit:1e4,discount:75,index:0,dataset:\"eletronico\"});\nexport const __FramerMetadata__ = {\"exports\":{\"useCreditStore\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CreditStore.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\";export default function SimulatorButton(props){const{text,tracking,destinyURL,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);// ✅ SAFE: não pode quebrar se a store não estiver disponível no contexto da Library\nlet 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){// fallback silencioso pra não bloquear Library\ncredit=1e4;}const targetUrl=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);// 1) normaliza host (staging herda regras do prod)\nconst rawHost=currentUrl.hostname.replace(/^www\\./,\"\");const HOST_ALIAS={// staging\n\"parceria.theklubi.com\":\"parceria.klubi.com.br\",\"theklubi.com\":\"klubi.com.br\",// preview\n\"parceria.framer.website\":\"parceria.klubi.com.br\",\"klubi.framer.website\":\"klubi.com.br\"};const host=HOST_ALIAS[rawHost]??rawHost;// helpers seguros\nconst last=arr=>arr.length?arr[arr.length-1]:\"\";const secondLast=arr=>arr.length>=2?arr[arr.length-2]:\"\";// 2) regras por host (prod)\nlet parceiro=\"\";let categoria=\"\";if(host===\"parceria.klubi.com.br\"){// parceria.klubi.com.br/compra-planejada/celular/picpay\nparceiro=last(parts);categoria=secondLast(parts);}else if(host===\"klubi.com.br\"){// klubi.com.br/consorcio/celular\nparceiro=\"klubi\";categoria=last(parts);}else{// fallback seguro\nparceiro=\"klubi\";categoria=last(parts);}if(parceiro.endsWith(\"-simulador\")){parceiro=parceiro.replace(/-simulador$/,\"\");}if(!parceiro||!categoria)return\"https://simulador.klubi.com.br\";// 3) mantém query params e injeta crédito\nconst params=new URLSearchParams(currentUrl.search);// ✅ Consórcio não deve receber \"credito\"\nif(destinyURL!==\"consorcio\"){params.set(\"credito\",String(credit));}else{params.delete(\"credito\")// garante que não vá se já existir na URL atual\n;}const qs=params.toString();switch(destinyURL){case\"consorcio\":return`https://consorcio.klubi.com.br/${categoria}/selecao-credito?parceiro=${parceiro}&${qs}`;case\"compraplanejada\":return`https://compraplanejada.klubi.com.br/${categoria}/simulador/credito?parceiro=${parceiro}&${qs}`;case\"simulador\":default:return`https://simulador.klubi.com.br/${parceiro}/${categoria}?${qs}`;}},[credit,destinyURL]);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\",\"consorcio\",\"compraplanejada\"],optionTitles:[\"simulador\",\"consorcio\",\"compraplanejada\"],defaultValue:\"simulador\"},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\"},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":"8NAA8E,SAAgB,EAAY,EAAO,CACjH,IAAM,EAAU,EAAK,CAAC,MAAM,OAAO,OAAO,CAAC,GAAG,EAAO,CAAC,CAAC,CAAC,CAClD,EAAa,GAAU,CAC1B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAU,MAAM,EAAE,EAAU,MAAM,OAAO,OAAO,CAAC,GAAG,EAAU,MAAM,GAAG,EAAS,CAAC,EAChI,EAAW,OAAO,GAAS,SAAS,OAAO,OAAO,CAAC,GAAG,EAAO,CAAC,CAAC,EAC7D,EAAa,IAAI,IACjB,EAAc,GAAU,CAC3B,OAAO,GAAW,aAAY,EAAS,EAAS,EAAW,EAAE,EAAW,OAAO,GAAW,SAAS,OAAO,OAAO,CAAC,GAAG,EAAW,GAAG,EAAS,CAAC,CAAC,EACjJ,EAAa,QAAQ,GAAQ,EAAO,EAAW,CAAC,EAChD,SAAS,GAAU,CACnB,GAAK,CAAC,EAAM,GAAUA,EAAS,EAAW,CAK1C,OAHA,OACA,EAAa,IAAI,EAAS,KAAW,EAAa,OAAO,EAAS,EAAG,EAAE,CAAC,CACrE,GAAgB,GAAG,IAAM,GAAgB,CAAO,CAAC,EAAU,MAAM,EAAa,EAC3E,CAAC,EAAM,EAAc,CAAG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