{"version":3,"file":"Qmod_Loader.CIld317F.mjs","names":["React.useRef","React.useState","_Fragment"],"sources":["https:/framerusercontent.com/modules/fhlty43JluOeeOScVRr0/skz6i2RaGWYAqPPAQrxh/Qmod_Loader.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";const LOADER_ID=\"qmod\";function ensureHeadStyle(css,key=\"qmod-embed-style\"){if(!css?.trim())return;let el=document.getElementById(key);if(!el){el=document.createElement(\"style\");el.id=key;document.head.appendChild(el);}el.textContent=css;}async function ensureLoader(wmid,version){if(typeof window===\"undefined\")return;const existing=document.getElementById(LOADER_ID);if(existing){// wait if loader is still loading\nif(!window.QMod){await new Promise(res=>existing.addEventListener(\"load\",()=>res(),{once:true}));}return;}// Inject\nawait new Promise((resolve,reject)=>{const s=document.createElement(\"script\");s.id=LOADER_ID;s.type=\"application/javascript\";s.async=true;s.src=\"https://qmod.quotemedia.com/js/qmodLoader.js\";s.setAttribute(\"data-qmod-wmid\",wmid);s.setAttribute(\"data-qmod-version\",version||\"latest\");s.addEventListener(\"load\",()=>resolve(),{once:true});s.addEventListener(\"error\",()=>reject(new Error(\"Failed to load qmodLoader.js\")),{once:true});document.body.appendChild(s);});}function waitForQMod(timeoutMs){const start=Date.now();return new Promise(resolve=>{const tick=()=>{// @ts-ignore\nif(window.QMod)return resolve(true);if(Date.now()-start>timeoutMs)return resolve(false);requestAnimationFrame(tick);};tick();});}function nudgeQMod(){const w=window;try{if(w.QMod?.api?.refresh){w.QMod.api.refresh();return\"api.refresh\";}if(w.QMod?.refresh){w.QMod.refresh();return\"refresh\";}if(typeof w.qmodInit===\"function\"){w.qmodInit();return\"qmodInit\";}}catch{}return\"none\";}function observePaint(el,onPaint){// immediate\nif(el.querySelector(\".qmod-ui-tool, .qmod-quotehead, .qmod-news-list\")){onPaint();return()=>{};}const mo=new MutationObserver(()=>{if(el.querySelector(\".qmod-ui-tool, .qmod-quotehead, .qmod-news-list\")){onPaint();mo.disconnect();}});mo.observe(el,{childList:true,subtree:true});return()=>mo.disconnect();}// Hook history push/replace so SPA nav triggers a refresh\nlet historyPatched=false;function patchHistory(){if(historyPatched)return;try{const origPush=history.pushState;const origReplace=history.replaceState;history.pushState=function(...args){const r=origPush.apply(this,args);window.dispatchEvent(new Event(\"qmod-route\"));return r;};history.replaceState=function(...args){const r=origReplace.apply(this,args);window.dispatchEvent(new Event(\"qmod-route\"));return r;};historyPatched=true;}catch{}}export default function QModEmbed({html,css,wrapperClass,injectScriptIfMissing=false,wmid=\"104850\",loaderVersion=\"latest\",waitTimeoutMs=7e3,maxRetries=10,retryGapMs=350,minHeightPx=80,showSkeleton=true,skeletonHeightPx=140,showDebug=false}){const ref=React.useRef(null);const[painted,setPainted]=React.useState(false);const[tries,setTries]=React.useState(0);const[lastReinit,setLastReinit]=React.useState(\"none\");// inject CSS once (do not remove on unmount to survive bfcache)\nReact.useEffect(()=>{ensureHeadStyle(css,\"qmod-embed-style\");},[css]);// render HTML synchronously so QMod can see .qtool\nReact.useLayoutEffect(()=>{if(ref.current)ref.current.innerHTML=html||\"\";setPainted(false);},[html]);// watch for paint\nReact.useEffect(()=>{if(!ref.current)return;return observePaint(ref.current,()=>setPainted(true));},[html]);// main init loop\nReact.useEffect(()=>{let cancelled=false;let timer;const kick=async()=>{// 1) ensure loader present (optional)\nif(injectScriptIfMissing){try{await ensureLoader(wmid,loaderVersion);}catch{}}// 2) wait for QMod object (or timeout)\nawait waitForQMod(waitTimeoutMs);// 3) staggered nudges until painted (or we hit maxRetries)\nconst tryNudge=()=>{if(cancelled||painted)return;setTries(t=>t+1);const used=nudgeQMod();setLastReinit(used);if(!painted&&tries+1<maxRetries){timer=window.setTimeout(tryNudge,retryGapMs);}};// run immediately after a frame so our innerHTML is live\nrequestAnimationFrame(tryNudge);};kick();return()=>{cancelled=true;if(timer)window.clearTimeout(timer);};},[html,injectScriptIfMissing,wmid,loaderVersion,waitTimeoutMs,maxRetries,retryGapMs,painted,tries]);// extra reliability: react to visibility, focus, routes, bfcache\nReact.useEffect(()=>{const nudge=()=>{nudgeQMod();};// after paint\nrequestAnimationFrame(nudge);const t1=window.setTimeout(nudge,400);const t2=window.setTimeout(nudge,1200);const t3=window.setTimeout(nudge,2500);// visibility/focus\nconst onVis=()=>{if(!document.hidden)nudge();};const onFocus=()=>nudge();document.addEventListener(\"visibilitychange\",onVis);window.addEventListener(\"focus\",onFocus);// SPA nav (push/replace + back/forward)\npatchHistory();const onRoute=()=>nudge();window.addEventListener(\"qmod-route\",onRoute);window.addEventListener(\"popstate\",onRoute);// bfcache restore\nconst onPageShow=e=>{if(e.persisted)nudge();};window.addEventListener(\"pageshow\",onPageShow);return()=>{clearTimeout(t1);clearTimeout(t2);clearTimeout(t3);document.removeEventListener(\"visibilitychange\",onVis);window.removeEventListener(\"focus\",onFocus);window.removeEventListener(\"qmod-route\",onRoute);window.removeEventListener(\"popstate\",onRoute);window.removeEventListener(\"pageshow\",onPageShow);};},[]);return /*#__PURE__*/_jsxs(\"div\",{className:wrapperClass,style:{width:\"100%\",display:\"block\",minHeight:minHeightPx||undefined},children:[showSkeleton&&!painted&&/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"style\",{children:`@keyframes qmod-skel { 0%{background-position:100% 0} 100%{background-position:0 0} }`}),/*#__PURE__*/_jsx(\"div\",{\"aria-hidden\":true,style:{width:\"100%\",height:skeletonHeightPx,borderRadius:8,overflow:\"hidden\",background:\"linear-gradient(90deg, rgba(0,0,0,0.08) 25%, rgba(0,0,0,0.14) 37%, rgba(0,0,0,0.08) 63%)\",backgroundSize:\"400% 100%\",animation:\"qmod-skel 1.1s ease-in-out infinite\",marginBottom:8}})]}),/*#__PURE__*/_jsx(\"div\",{ref:ref}),showDebug&&/*#__PURE__*/_jsxs(\"div\",{style:{marginTop:8,padding:\"8px 10px\",fontSize:12,lineHeight:1.35,background:\"rgba(0,0,0,0.65)\",color:\"#fff\",borderRadius:6,maxWidth:520},children:[/*#__PURE__*/_jsx(\"b\",{children:\"QMod Debug\"}),/*#__PURE__*/_jsxs(\"div\",{children:[\"Loader present:\",\" \",String(!!document.getElementById(LOADER_ID))]}),/*#__PURE__*/_jsxs(\"div\",{children:[\"window.QMod: \",String(!!window.QMod)]}),/*#__PURE__*/_jsxs(\"div\",{children:[\"Tries: \",tries]}),/*#__PURE__*/_jsxs(\"div\",{children:[\"Last reinit: \",lastReinit]})]})]});}addPropertyControls(QModEmbed,{html:{type:ControlType.String,title:\"HTML\",displayTextArea:true},css:{type:ControlType.String,title:\"CSS\",displayTextArea:true},wrapperClass:{type:ControlType.String,title:\"Wrapper class\"},injectScriptIfMissing:{type:ControlType.Boolean,title:\"Inject loader if missing\",defaultValue:false},wmid:{type:ControlType.String,title:\"WMID\",defaultValue:\"104850\"},loaderVersion:{type:ControlType.String,title:\"Loader version\",defaultValue:\"latest\"},waitTimeoutMs:{type:ControlType.Number,title:\"Wait (ms)\",defaultValue:7e3,min:0,displayStepper:true},maxRetries:{type:ControlType.Number,title:\"Max retries\",defaultValue:10,min:0,displayStepper:true},retryGapMs:{type:ControlType.Number,title:\"Retry gap (ms)\",defaultValue:350,min:50,displayStepper:true},minHeightPx:{type:ControlType.Number,title:\"Min height\",defaultValue:80,min:0,displayStepper:true},showSkeleton:{type:ControlType.Boolean,title:\"Skeleton\",defaultValue:true},skeletonHeightPx:{type:ControlType.Number,title:\"Skeleton height\",defaultValue:140,min:20,displayStepper:true},showDebug:{type:ControlType.Boolean,title:\"Show debug\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"QModEmbed\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Qmod_Loader.map"],"mappings":"sNAAsL,SAAS,EAAgB,EAAI,EAAI,mBAAmB,CAAC,GAAG,CAAC,GAA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