{"version":3,"file":"SimplePracticeAppointmentOverride.CFJKFHLZ.mjs","names":["useRef","useState","useCallback"],"sources":["https:/framerusercontent.com/modules/gGupkPlaK2g0oJlTxx66/sJWRftXakSqikt6MBjcK/SimplePracticeAppointmentOverride.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{RenderTarget}from\"framer\";import{forwardRef,startTransition,useCallback,useEffect,useRef,useState}from\"react\";let simplePracticeScriptPromise=null;let simplePracticeScriptState=\"idle\";const boundAnchors=new WeakSet;const guardedAnchors=new WeakSet;const bookingUrl=\"https://wellnest-counseling.clientsecure.me\";function ensureSimplePracticeScript(){if(typeof window===\"undefined\"||typeof document===\"undefined\"){return Promise.resolve();}if(simplePracticeScriptState===\"loaded\")return Promise.resolve();if(simplePracticeScriptState===\"failed\"){return Promise.reject(new Error(\"SimplePractice script failed to load\"));}if(simplePracticeScriptPromise)return simplePracticeScriptPromise;const scriptSrc=\"https://widget-cdn.simplepractice.com/assets/integration-1.0.js\";const existingScript=document.querySelector(`script[src=\"${scriptSrc}\"]`);simplePracticeScriptState=\"loading\";simplePracticeScriptPromise=new Promise((resolve,reject)=>{let timeoutId=null;let settled=false;const finishLoaded=()=>{if(settled)return;settled=true;simplePracticeScriptState=\"loaded\";resolve();};const finishFailed=()=>{if(settled)return;settled=true;simplePracticeScriptState=\"failed\";simplePracticeScriptPromise=null;reject(new Error(\"SimplePractice script failed to load\"));};const clearTimer=()=>{if(timeoutId!==null&&typeof window!==\"undefined\"){window.clearTimeout(timeoutId);}timeoutId=null;};if(existingScript){const onLoad=()=>{clearTimer();if(existingScript){existingScript.dataset.spLoaded=\"true\";}finishLoaded();};const onError=()=>{clearTimer();finishFailed();};if(existingScript.dataset.spLoaded===\"true\"){finishLoaded();return;}if(getSimplePracticeWidgetApi()){existingScript.dataset.spLoaded=\"true\";finishLoaded();return;}existingScript.addEventListener(\"load\",onLoad,{once:true});existingScript.addEventListener(\"error\",onError,{once:true});timeoutId=window.setTimeout(()=>{existingScript.removeEventListener(\"load\",onLoad);existingScript.removeEventListener(\"error\",onError);existingScript.dataset.spLoaded=\"true\";finishLoaded();},1500);return;}const script=document.createElement(\"script\");script.src=scriptSrc;script.async=true;const onLoad=()=>{clearTimer();script.dataset.spLoaded=\"true\";finishLoaded();};const onError=()=>{clearTimer();script.remove();finishFailed();};script.addEventListener(\"load\",onLoad,{once:true});script.addEventListener(\"error\",onError,{once:true});timeoutId=window.setTimeout(()=>{script.removeEventListener(\"load\",onLoad);script.removeEventListener(\"error\",onError);script.remove();finishFailed();},1e4);document.body.appendChild(script);});return simplePracticeScriptPromise;}function applySimplePracticeAttributes(anchor){anchor.setAttribute(\"href\",bookingUrl);anchor.setAttribute(\"data-spwidget-scope-id\",\"823539f6-3191-4e53-beda-7de83b8b1985\");anchor.setAttribute(\"data-spwidget-scope-uri\",\"wellnest-counseling\");anchor.setAttribute(\"data-spwidget-application-id\",\"7c72cb9f9a9b913654bb89d6c7b4e71a77911b30192051da35384b4d0c6d505b\");anchor.setAttribute(\"data-spwidget-type\",\"OAR\");anchor.setAttribute(\"data-spwidget-scope-global\",\"true\");anchor.setAttribute(\"data-spwidget-autobind\",\"true\");}function getSimplePracticeWidgetApi(){if(typeof window===\"undefined\")return null;return window.SimplePracticeWidget||window.SPWidget;}function tryBindSimplePracticeWidget(anchor){if(typeof window===\"undefined\")return;const widgetApi=getSimplePracticeWidgetApi();if(!widgetApi)return;if(typeof widgetApi.bind===\"function\"){widgetApi.bind(anchor);}else if(typeof widgetApi.autobind===\"function\"){widgetApi.autobind();}}function ensureWidgetBinding(anchor){applySimplePracticeAttributes(anchor);if(boundAnchors.has(anchor))return ensureSimplePracticeScript();return ensureSimplePracticeScript().then(()=>{tryBindSimplePracticeWidget(anchor);boundAnchors.add(anchor);});}function guardAnchorNavigation(anchor){if(guardedAnchors.has(anchor))return;const preventNavigation=event=>{event.preventDefault();};anchor.addEventListener(\"click\",preventNavigation,true);guardedAnchors.add(anchor);}export function withSimplePracticeAppointment(Component){return /*#__PURE__*/forwardRef(function WithSimplePracticeAppointment(props,ref){const rootRef=useRef(null);const actionAnchorRef=useRef(null);const syntheticAnchorRef=useRef(null);const isCanvas=RenderTarget.current()===RenderTarget.canvas;const[hasAnchor,setHasAnchor]=useState(true);const[statusMessage,setStatusMessage]=useState(\"\");useEffect(()=>{if(isCanvas)return;if(!rootRef.current)return;if(typeof document===\"undefined\")return;const anchor=rootRef.current.querySelector(\"a\");const foundAnchor=Boolean(anchor);startTransition(()=>setHasAnchor(foundAnchor));if(anchor){actionAnchorRef.current=anchor;guardAnchorNavigation(anchor);ensureWidgetBinding(anchor).catch(()=>{// Do not announce failures on mount; only surface issues on user activation.\n});return;}const syntheticAnchor=document.createElement(\"a\");syntheticAnchor.setAttribute(\"aria-hidden\",\"true\");syntheticAnchor.tabIndex=-1;syntheticAnchor.style.position=\"fixed\";syntheticAnchor.style.left=\"-9999px\";syntheticAnchor.style.top=\"0\";syntheticAnchor.style.width=\"1px\";syntheticAnchor.style.height=\"1px\";syntheticAnchor.style.opacity=\"0\";syntheticAnchor.style.pointerEvents=\"none\";applySimplePracticeAttributes(syntheticAnchor);guardAnchorNavigation(syntheticAnchor);document.body.appendChild(syntheticAnchor);syntheticAnchorRef.current=syntheticAnchor;actionAnchorRef.current=syntheticAnchor;ensureWidgetBinding(syntheticAnchor).catch(()=>{// Do not announce failures on mount; only surface issues on user activation.\n});return()=>{if(syntheticAnchorRef.current?.parentNode){syntheticAnchorRef.current.parentNode.removeChild(syntheticAnchorRef.current);}syntheticAnchorRef.current=null;if(actionAnchorRef.current===syntheticAnchor){actionAnchorRef.current=null;}};},[isCanvas]);const activateAppointment=useCallback(()=>{if(isCanvas)return;const anchor=actionAnchorRef.current;if(!anchor){startTransition(()=>setStatusMessage(\"Unable to open booking right now. Please try again in a moment.\"));return;}if(simplePracticeScriptState===\"loaded\"){tryBindSimplePracticeWidget(anchor);startTransition(()=>setStatusMessage(\"\"));if(typeof window!==\"undefined\"){anchor.dispatchEvent(new MouseEvent(\"click\",{bubbles:true,cancelable:true,view:window}));}return;}ensureWidgetBinding(anchor).then(()=>{startTransition(()=>setStatusMessage(\"\"));if(typeof window!==\"undefined\"){anchor.dispatchEvent(new MouseEvent(\"click\",{bubbles:true,cancelable:true,view:window}));}}).catch(()=>{startTransition(()=>setStatusMessage(\"Unable to open booking right now. Please try again in a moment.\"));});},[isCanvas]);const handleClick=useCallback(event=>{if(typeof props.onClick===\"function\"){props.onClick(event);}if(isCanvas||hasAnchor)return;activateAppointment();},[activateAppointment,hasAnchor,isCanvas,props]);const handleKeyDown=useCallback(event=>{if(typeof props.onKeyDown===\"function\"){props.onKeyDown(event);}if(isCanvas||hasAnchor)return;if(event.defaultPrevented)return;const key=event.key;if(key===\"Enter\"||key===\" \"){event.preventDefault();activateAppointment();}},[activateAppointment,hasAnchor,isCanvas,props]);const role=!isCanvas&&!hasAnchor&&props.role==null?\"button\":props.role;const tabIndex=!isCanvas&&!hasAnchor&&props.tabIndex==null?0:props.tabIndex;return /*#__PURE__*/_jsxs(\"span\",{ref:rootRef,style:{display:\"contents\"},children:[/*#__PURE__*/_jsx(Component,{ref:ref,...props,onClick:handleClick,onKeyDown:handleKeyDown,role:role,tabIndex:tabIndex}),statusMessage?/*#__PURE__*/_jsx(\"span\",{role:\"status\",\"aria-live\":\"polite\",style:{position:\"absolute\",width:\"1px\",height:\"1px\",overflow:\"hidden\",clip:\"rect(0 0 0 0)\",whiteSpace:\"nowrap\",clipPath:\"inset(50%)\"},children:statusMessage}):null]});});}\nexport const __FramerMetadata__ = {\"exports\":{\"withSimplePracticeAppointment\":{\"type\":\"reactHoc\",\"name\":\"withSimplePracticeAppointment\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./SimplePracticeAppointmentOverride.map"],"mappings":"sNAAuX,SAAS,GAA4B,CAA0F,GAA/E,IAAS,QAAa,OAAO,SAAW,KAA0C,IAA4B,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