{"version":3,"file":"TallyBookingEmbed.CmR159Gs.mjs","names":["useRef","useState","__esmMin","init_ssg_sandbox_shims","window","_e","de","init_jsx_runtime","c","init_npm_react_18_3_1","ce","addPropertyControls","init_framer_BpuvUAiZ","ControlType","TallyBookingEmbed","props","wrapRef","frameRef","liveHeight","setLiveHeight","width","setWidth","params","cat","category","name","sevaName","cost","price","src","formId","el","update","ro","onMessage","h","parts","m","d","height","formHeight","minHeight","style","init_TallyBookingEmbed"],"sources":["https:/framerusercontent.com/modules/aChvGee7aLLEBTGYcS1l/SkGFuTV6sH2ETY5350xR/TallyBookingEmbed.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Embeds the GB SRS Brundavan seva booking form (Tally) and pre-selects the seva\n * the devotee was viewing, using the form's hidden fields.\n * The frame is sized so the whole form fits and only the page scrolls (no inner scrollbar).\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function TallyBookingEmbed(props){const{formId,minHeight,formHeight,hideTitle,transparentBackground,category,sevaName,price,style}=props;const wrapRef=useRef(null);const frameRef=useRef(null);const[liveHeight,setLiveHeight]=useState(null);const[width,setWidth]=useState(760);const params=[\"alignLeft=1\",\"hideTitle=\"+(hideTitle?1:0),\"transparentBackground=\"+(transparentBackground?1:0)];const cat=(category||\"\").trim();const name=(sevaName||\"\").trim();const cost=(price||\"\").trim();if(cat)params.push(\"seva_category=\"+encodeURIComponent(cat));if(name&&cost)params.push(\"seva_item=\"+encodeURIComponent(name+\" – \"+cost));const src=\"https://tally.so/embed/\"+formId+\"?\"+params.join(\"&\");// Track the width the form is drawn at: narrower screens wrap more, so the form is taller.\nuseEffect(()=>{const el=wrapRef.current;if(!el)return;const update=()=>setWidth(el.getBoundingClientRect().width||760);update();if(typeof ResizeObserver===\"undefined\")return;const ro=new ResizeObserver(update);ro.observe(el);return()=>ro.disconnect();},[]);// If Tally reports its real height, follow it (any common format).\nuseEffect(()=>{const onMessage=e=>{try{if(!frameRef.current||e.source!==frameRef.current.contentWindow)return;let h=0;if(typeof e.data===\"string\"){if(e.data.indexOf(\"[iFrameSizer]\")===0){const parts=e.data.slice(13).split(\":\");if(parts[0].indexOf(\"message\")===-1)h=Number(parts[1]);}else{const m=e.data.match(/\"height\"\\s*:\\s*\"?(\\d+(?:\\.\\d+)?)/i);if(m)h=Number(m[1]);}}else if(e.data&&typeof e.data===\"object\"){const d=e.data;h=Number(d.payload&&d.payload.height||d.height||0);}if(h>300)setLiveHeight(Math.ceil(h)+8);}catch(err){}};window.addEventListener(\"message\",onMessage);return()=>window.removeEventListener(\"message\",onMessage);},[]);// Fixed frame height, slightly taller than the form (about 2200px at every width), so nothing scrolls inside the frame.\nconst estimate=width>=480?2300:2350;const height=liveHeight||(formHeight&&formHeight>0?formHeight+(width<480?250:0):Math.max(minHeight,estimate));return /*#__PURE__*/_jsx(\"div\",{ref:wrapRef,style:{width:\"100%\",...style},children:/*#__PURE__*/_jsx(\"iframe\",{ref:frameRef,src:src,title:\"Book a seva\",width:\"100%\",height:height,style:{border:0,display:\"block\",width:\"100%\",height}},src)});}TallyBookingEmbed.defaultProps={formId:\"DqzzRj\",minHeight:900,formHeight:0,hideTitle:true,transparentBackground:true,category:\"\",sevaName:\"\",price:\"\"};addPropertyControls(TallyBookingEmbed,{formId:{type:ControlType.String,title:\"Tally form ID\",defaultValue:\"DqzzRj\"},formHeight:{type:ControlType.Number,title:\"Form height (0 = auto)\",defaultValue:0,min:0,max:6e3,step:50},minHeight:{type:ControlType.Number,title:\"Min height\",defaultValue:900,min:300,max:3e3,step:50},hideTitle:{type:ControlType.Boolean,title:\"Hide title\",defaultValue:true},transparentBackground:{type:ControlType.Boolean,title:\"Transparent bg\",defaultValue:true},category:{type:ControlType.String,title:\"Seva category\",defaultValue:\"\"},sevaName:{type:ControlType.String,title:\"Seva name\",defaultValue:\"\"},price:{type:ControlType.String,title:\"Price\",defaultValue:\"\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TallyBookingEmbed\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TallyBookingEmbed.map"],"mappings":"A,sMAMG,SAAwBc,EAAkB,EAAM,CAAC,GAAK,CAAC,SAAO,YAAU,aAAW,YAAU,wBAAsB,WAAS,WAAS,QAAM,SAAOC,EAAYC,EAAQhB,EAAO,IAAI,EAAQiB,EAASjB,EAAO,IAAI,EAAO,CAACkB,EAAWC,GAAelB,EAAS,IAAI,EAAO,CAACmB,EAAMC,GAAUpB,EAAS,GAAG,EAAQqB,EAAO,CAAC,cAAc,cAAc,KAAe,0BAA0B,IAA0B,EAAQC,GAAKC,GAAU,GAAA,CAAI,KAAK,EAAQC,GAAMC,GAAU,GAAA,CAAI,KAAK,EAAQC,GAAMC,GAAO,GAAA,CAAI,KAAK,EAAKL,GAAID,EAAO,KAAK,iBAAiB,mBAAmBC,CAAG,CAAC,EAAKE,GAAME,GAAKL,EAAO,KAAK,aAAa,mBAAmBG,EAAK,MAAME,CAAI,CAAC,EAAE,IAAME,EAAI,0BAA0BC,EAAO,IAAIR,EAAO,KAAK,GAAG,EAC1rBZ,MAAc,CAAC,IAAMqB,EAAGf,EAAQ,QAAQ,GAAG,CAACe,EAAG,OAAO,IAAMC,MAAWX,EAASU,EAAG,sBAAsB,CAAC,CAAC,OAAO,GAAG,EAAW,GAATC,EAAO,EAAK,OAAO,eAAiB,IAAY,OAAO,IAAMC,EAAG,IAAI,eAAeD,CAAM,EAAiB,OAAfC,EAAG,QAAQF,CAAE,MAAYE,EAAG,WAAW,CAAE,EAAE,CAAC,CAAC,EAC/PvB,MAAc,CAAC,IAAMwB,EAAU,GAAG,CAAC,GAAG,CAAC,GAAG,CAACjB,EAAS,SAAS,EAAE,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