(()=>{"use strict";let r=!1,e=!1;const t=[],o=async(o,...i)=>{e?await(async(r,e)=>{const t=globalThis.formbricks;t&&await t[r](...e)})(o,i):"setup"===o?await(async o=>{if(r)return void console.warn("🧱 Formbricks - Warning: Formbricks is already initializing.");const i=(r=>{const e=r[0],{appUrl:t,environmentId:o}=e;return t?o?{appUrl:t,environmentId:o}:(console.error("🧱 Formbricks - Error: environmentId is required"),null):(console.error("🧱 Formbricks - Error: appUrl is required"),null)})(o);if(i){r=!0;try{const r=await(async r=>{if(!globalThis.formbricks){const e=document.createElement("script");e.type="text/javascript",e.src=`${r}/js/formbricks.umd.cjs`,e.async=!0;const t=async()=>new Promise((r,t)=>{const o=setTimeout(()=>{t(new Error("Formbricks SDK loading timed out"))},1e4);e.onload=()=>{clearTimeout(o),r()},e.onerror=()=>{clearTimeout(o),t(new Error("Failed to load Formbricks SDK"))}});document.head.appendChild(e);try{return await t(),{ok:!0,data:void 0}}catch(r){return{ok:!1,error:new Error(r.message??"Failed to load Formbricks SDK")}}}return{ok:!0,data:void 0}})(i.appUrl),n=globalThis.formbricks;if(!r.ok||!n)return void console.error("🧱 Formbricks - Error: Failed to load Formbricks SDK");await n.setup(...o),e=!0,(r=>{for(const{prop:e,args:o}of t)"function"==typeof r[e]?r[e](...o):console.error(`🧱 Formbricks - Error: Method ${e} does not exist on formbricks`)})(formbricks)}catch(r){console.error("🧱 Formbricks - Error: setup failed",r)}finally{r=!1}}})(i):(console.warn("🧱 Formbricks - Warning: Formbricks not initialized. This method will be queued and executed after initialization."),t.push({prop:o,args:i}))},i=new Proxy({},{get:(r,e,t)=>(...r)=>o(e,...r)});document.addEventListener("DOMContentLoaded",()=>{window.tgsdk_formbricks={init:async r=>{var e,t;"object"==typeof r&&null!==r||(r={});const o={...window.tgsdk_survey_data,...r,attributes:{...null!==(e=window.tgsdk_survey_data.attributes)&&void 0!==e?e:{},...null!==(t=r.attributes)&&void 0!==t?t:{}}},{environmentId:n,appUrl:s,attributes:a,userId:c}=o;await(i?.setup({environmentId:n,appUrl:s})),i?.setAttributes(a),function(){const r=localStorage.getItem("formbricks-js");if(!r)return!0;try{const e=JSON.parse(r);if(e?.user?.data?.userId)return!1}catch(r){console.warn(r)}return!0}()&&i?.setUserId(c)}};let r=null;var e;e=window.tgsdk_survey_data?.attributes?.install_days_number,isNaN(e)||"boolean"==typeof e||(r=setTimeout(()=>{window.tgsdk_formbricks?.init()},350)),window.addEventListener("themegrill:survey:trigger:cancel",()=>{clearTimeout(r)}),window.dispatchEvent(new Event("themegrill:survey:loaded"))})})();