{"version":3,"file":"StripeCheckout.Ce5EEDSB.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/3E3xPAlXDBvp3NoUzx7n/A7rsMrHVKnrpMKvO9Y19/StripeCheckout.js"],"sourcesContent":["// Code Overrides para o fluxo de checkout + upsell.\n//\n// Produção (com upsell):\n//    - \"withCheckoutStart\"              → Start (entrada)\n//    - \"withCheckoutStartMensal\"        → Start Mensal (subscription)\n//    - \"withCheckoutStartSemestral\"     → Start Semestral (subscription)\n//    - \"withCheckoutStartAnual\"         → Start Anual (subscription)\n//\n// Produção (sem upsell):\n//    - \"withCheckoutStartDirect\"        → Start direto → THANK_YOU_URL\n//    - \"withCheckoutStartMensalDirect\"  → Start Mensal direto\n//    - \"withCheckoutStartSemestralDirect\" → Start Semestral direto\n//    - \"withCheckoutStartAnualDirect\"   → Start Anual direto\n//\n// Test/Sandbox (com upsell → UPSELL_URL_TEST):\n//    - \"withCheckoutStartTest\"          → Start teste\n//    - \"withCheckoutStartMensalTest\"    → Start Mensal teste\n//    - \"withCheckoutStartSemestralTest\" → Start Semestral teste\n//\n// Test/Sandbox (sem upsell):\n//    - \"withCheckoutStartDirectTest\"    → Start teste direto\n//\n// Upsell:\n//    - \"withUpsellAccept\"               → botão \"Aceitar\" (auto-detecta test/live)\n//    - \"withUpsellDecline\"              → botão \"Não, obrigado\" (redireciona via worker)\n//\n// Backward compat: withCheckoutAndUpsell, withCheckoutDirect, withCheckoutAndUpsellTest, withCheckoutDirectTest\n//\n// Obs.: framer-forms.js cuida quando é via forms. Aí basta usar como link \"https://order.aros.com.br/NOME_OFERTA\" .\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect,useRef}from\"react\";// ---- CONFIGURAR ESTES VALORES ----\nconst WORKER_URL=\"https://order.aros.com.br\"// Worker Cloudflare\n;const UPSELL_URL=\"https://lp.aros.com.br/oto/start-grow-stripe\"// Página de upsell (produção)\n;const UPSELL_URL_TEST=\"https://lp.aros.com.br/tests/upsell\"// Página de upsell (teste/sandbox)\n;const THANK_YOU_URL=\"https://lp.aros.com.br/obrigado-compra/start-v2\"// recusou upsell / sem upsell\n;const THANK_YOU_UPSELL_URL=\"https://lp.aros.com.br/obrigado-compra/grow-v2\"// aceitou upsell\n;const UPSELL_ERROR_URL=\"https://lp.aros.com.br/oto/start-grow-stripe/erro\";const FALLBACK_URL=\"https://lp.aros.com.br/planos\"// Se acessa sem checkout session\n;const PRICE_ID=\"price_1T927vRpZjTrP17oIpG9FSmB\"// Start Produção\n;const PRICE_ID_TEST=\"price_1SOT4PRqbPX6xoSIxQOzfKro\"// Start Sandbox ou Teste\n;// -----------------------------------\nfunction getAllUrlParams(){const params=new URLSearchParams(window.location.search);const metadata={};params.forEach((value,key)=>{if(value)metadata[`query_${key}`]=value;});return metadata;}async function createCheckout(successUrl,mode=\"live\",productPath){if(typeof window.fbq!==\"undefined\")window.fbq(\"track\",\"InitiateCheckout\");const endpoint=productPath||\"/create-checkout\";const body={success_url:successUrl,metadata:getAllUrlParams()};// Só envia price_id pro fallback /create-checkout (backward compat)\nif(!productPath){body.price_id=mode===\"test\"?PRICE_ID_TEST:PRICE_ID;}if(mode===\"test\")body.mode=\"test\";const res=await fetch(`${WORKER_URL}${endpoint}`,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(body)});const data=await res.json();if(data.url){window.location.href=data.url;}}export function withUpsellAccept(Component){return props=>{const[processing,setProcessing]=useState(false);const[noSession]=useState(()=>{if(typeof window===\"undefined\")return false;return!new URLSearchParams(window.location.search).get(\"session_id\");});const wrapperRef=useRef(null);useEffect(()=>{if(!noSession)return;const wrapper=wrapperRef.current;if(!wrapper)return;const newText=\"Consulte ofertas dispon\\xedveis\";const applyText=()=>{const textEl=wrapper.querySelector(\"p\");if(textEl&&textEl.textContent!==newText){textEl.textContent=newText;}};applyText();const observer=new MutationObserver(applyText);observer.observe(wrapper,{childList:true,subtree:true,characterData:true});return()=>observer.disconnect();},[noSession]);const handleClick=async e=>{e.preventDefault();if(processing)return;if(noSession){window.location.href=FALLBACK_URL;return;}setProcessing(true);// Trocar texto do botão via DOM + animação dos pontinhos\nconst btn=e.currentTarget;const textEl=btn.querySelector(\"p\")||btn.firstElementChild;let dotCount=0;let dotInterval=null;let dotsSpan=null;if(textEl){textEl.textContent=\"\";const fixedSpan=document.createElement(\"span\");fixedSpan.textContent=\"Processando\";dotsSpan=document.createElement(\"span\");dotsSpan.style.display=\"inline-block\";dotsSpan.style.width=\"1.2em\";dotsSpan.style.textAlign=\"left\";dotsSpan.textContent=\"\";textEl.appendChild(fixedSpan);textEl.appendChild(dotsSpan);dotInterval=setInterval(()=>{dotCount=(dotCount+1)%4;if(dotsSpan)dotsSpan.textContent=\".\".repeat(dotCount);},400);}const stopDots=()=>{if(dotInterval)clearInterval(dotInterval);};const sessionId=new URLSearchParams(window.location.search).get(\"session_id\");try{const res=await fetch(`${WORKER_URL}/accept`,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify({session_id:sessionId})});const data=await res.json();stopDots();if(data.success){window.location.href=THANK_YOU_UPSELL_URL;}else{window.location.href=`${UPSELL_ERROR_URL}?session_id=${sessionId}`;}}catch(_){stopDots();window.location.href=`${UPSELL_ERROR_URL}?session_id=${sessionId}`;}};return /*#__PURE__*/_jsx(\"div\",{ref:wrapperRef,style:{display:\"contents\"},children:/*#__PURE__*/_jsx(Component,{...props,onClick:handleClick,style:{...props.style,...processing?{opacity:.6,pointerEvents:\"none\"}:{}}})});};}export function withUpsellDecline(Component){return props=>{const handleClick=e=>{e.preventDefault();const params=new URLSearchParams(window.location.search);const sessionId=params.get(\"session_id\");if(!sessionId){window.location.href=FALLBACK_URL;return;}window.location.href=`${WORKER_URL}/decline?session_id=${sessionId}`;};return /*#__PURE__*/_jsx(Component,{...props,onClick:handleClick});};}// ---------------------------------------------------------------------------\n// Factory: gera override por produto (slug → rota no worker)\n// ---------------------------------------------------------------------------\nfunction withCheckoutProduct(product,successUrl,mode=\"live\"){return function(Component){return props=>{const handleClick=()=>createCheckout(successUrl,mode,`/${product}`);return /*#__PURE__*/_jsx(Component,{...props,onClick:handleClick});};};}// Produção — com upsell\nexport function withCheckoutStart(C){return withCheckoutProduct(\"start\",UPSELL_URL)(C);}export function withCheckoutStartMensal(C){return withCheckoutProduct(\"start-mensal\",UPSELL_URL)(C);}export function withCheckoutStartSemestral(C){return withCheckoutProduct(\"start-semestral\",UPSELL_URL)(C);}export function withCheckoutStartAnual(C){return withCheckoutProduct(\"start-anual\",UPSELL_URL)(C);}// Produção — direto (sem upsell)\nexport function withCheckoutStartDirect(C){return withCheckoutProduct(\"start\",THANK_YOU_URL)(C);}export function withCheckoutStartMensalDirect(C){return withCheckoutProduct(\"start-mensal\",THANK_YOU_URL)(C);}export function withCheckoutStartSemestralDirect(C){return withCheckoutProduct(\"start-semestral\",THANK_YOU_URL)(C);}export function withCheckoutStartAnualDirect(C){return withCheckoutProduct(\"start-anual\",THANK_YOU_URL)(C);}// Backward compat\nexport function withCheckoutAndUpsell(C){return withCheckoutProduct(\"start\",UPSELL_URL)(C);}export function withCheckoutDirect(C){return withCheckoutProduct(\"start\",THANK_YOU_URL)(C);}// Test mode — com upsell (usa product route + mode: \"test\" → página de upsell de teste)\nexport function withCheckoutStartTest(C){return withCheckoutProduct(\"start\",UPSELL_URL_TEST,\"test\")(C);}export function withCheckoutStartMensalTest(C){return withCheckoutProduct(\"start-mensal\",UPSELL_URL_TEST,\"test\")(C);}export function withCheckoutStartSemestralTest(C){return withCheckoutProduct(\"start-semestral\",UPSELL_URL_TEST,\"test\")(C);}// Test mode — direto (sem upsell)\nexport function withCheckoutStartDirectTest(C){return withCheckoutProduct(\"start\",THANK_YOU_URL,\"test\")(C);}// Backward compat\nexport function withCheckoutAndUpsellTest(C){return withCheckoutProduct(\"start\",UPSELL_URL_TEST,\"test\")(C);}export function withCheckoutDirectTest(C){return withCheckoutProduct(\"start\",THANK_YOU_URL,\"test\")(C);}\nexport const __FramerMetadata__ = {\"exports\":{\"withUpsellAccept\":{\"type\":\"reactHoc\",\"name\":\"withUpsellAccept\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutStartSemestral\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutStartSemestral\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutStartDirectTest\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutStartDirectTest\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutDirect\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutDirect\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutStartSemestralDirect\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutStartSemestralDirect\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutStartTest\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutStartTest\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withUpsellDecline\":{\"type\":\"reactHoc\",\"name\":\"withUpsellDecline\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutDirectTest\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutDirectTest\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutAndUpsellTest\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutAndUpsellTest\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutStartMensalDirect\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutStartMensalDirect\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutStartAnual\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutStartAnual\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutStartMensal\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutStartMensal\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutAndUpsell\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutAndUpsell\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutStartDirect\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutStartDirect\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutStartSemestralTest\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutStartSemestralTest\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutStartMensalTest\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutStartMensalTest\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutStart\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutStart\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withCheckoutStartAnualDirect\":{\"type\":\"reactHoc\",\"name\":\"withCheckoutStartAnualDirect\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./StripeCheckout.map"],"mappings":"8IAuCA,SAAS,GAAiB,CAAC,IAAM,EAAO,IAAI,gBAAgB,EAAO,SAAS,OAAO,CAAO,EAAS,EAAE,CAAyE,OAAxE,EAAO,SAAS,EAAM,IAAM,CAAI,IAAM,EAAS,SAAS,KAAO,IAAQ,CAAQ,EAAU,eAAe,EAAe,EAAW,EAAK,OAAO,EAAY,CAAW,EAAO,MAAM,QAAY,EAAO,IAAI,QAAQ,mBAAmB,CAAC,IAAM,EAAS,GAAa,mBAAyB,EAAK,CAAC,YAAY,EAAW,SAAS,GAAiB,CAAC,CACpb,IAAa,EAAK,SAAS,IAAO,OAAO,EAAc,GAAa,IAAO,SAAO,EAAK,KAAK,QAA+I,IAAM,EAAK,MAAzI,MAAM,MAAM,GAAG,IAAa,IAAW,CAAC,OAAO,OAAO,QAAQ,CAAC,eAAe,mBAAmB,CAAC,KAAK,KAAK,UAAU,EAAK,CAAC,CAAC,EAAsB,MAAM,CAAI,EAAK,MAAK,EAAO,SAAS,KAAK,EAAK,KAAM,SAAgB,EAAiB,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,EAAW,GAAeA,EAAS,GAAM,CAAM,CAAC,GAAW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